agentroam-runtime-darwin-arm64 0.2.0-preview.75 → 0.2.0-preview.77

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 (409) hide show
  1. package/manifest.json +2 -2
  2. package/package.json +1 -1
  3. package/runtime/.next/BUILD_ID +1 -1
  4. package/runtime/.next/app-build-manifest.json +9 -9
  5. package/runtime/.next/app-path-routes-manifest.json +1 -1
  6. package/runtime/.next/build-manifest.json +5 -5
  7. package/runtime/.next/prerender-manifest.json +1 -1
  8. package/runtime/.next/required-server-files.json +1 -1
  9. package/runtime/.next/routes-manifest.json +1 -1
  10. package/runtime/.next/server/app/_not-found/page.js +1 -1
  11. package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/runtime/.next/server/app/_not-found.html +1 -1
  13. package/runtime/.next/server/app/_not-found.rsc +1 -1
  14. package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
  15. package/runtime/.next/server/app/api/agent/abort/route.js.nft.json +1 -1
  16. package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
  17. package/runtime/.next/server/app/api/agent/answer/route.js.nft.json +1 -1
  18. package/runtime/.next/server/app/api/agent/codex-sharing/route.js +1 -1
  19. package/runtime/.next/server/app/api/agent/codex-sharing/route.js.nft.json +1 -1
  20. package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
  21. package/runtime/.next/server/app/api/agent/harness/status/route.js.nft.json +1 -1
  22. package/runtime/.next/server/app/api/agent/model/route.js +1 -1
  23. package/runtime/.next/server/app/api/agent/model/route.js.nft.json +1 -1
  24. package/runtime/.next/server/app/api/agent/models/route.js +1 -1
  25. package/runtime/.next/server/app/api/agent/models/route.js.nft.json +1 -1
  26. package/runtime/.next/server/app/api/agent/run/route.js +1 -1
  27. package/runtime/.next/server/app/api/agent/run/route.js.nft.json +1 -1
  28. package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
  29. package/runtime/.next/server/app/api/agent/runtime-health/route.js.nft.json +1 -1
  30. package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
  31. package/runtime/.next/server/app/api/agent/steer/route.js.nft.json +1 -1
  32. package/runtime/.next/server/app/api/agent/stream/route.js +4 -4
  33. package/runtime/.next/server/app/api/agent/stream/route.js.nft.json +1 -1
  34. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
  35. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js.nft.json +1 -1
  36. package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
  37. package/runtime/.next/server/app/api/agent-workspaces/route.js.nft.json +1 -1
  38. package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
  39. package/runtime/.next/server/app/api/business/route.js +1 -1
  40. package/runtime/.next/server/app/api/business/route.js.nft.json +1 -1
  41. package/runtime/.next/server/app/api/calendar/route.js +2 -3
  42. package/runtime/.next/server/app/api/calendar/route.js.nft.json +1 -1
  43. package/runtime/.next/server/app/api/client-logs/route.js +1 -1
  44. package/runtime/.next/server/app/api/collaboration/route.js +9 -9
  45. package/runtime/.next/server/app/api/collaboration/route.js.nft.json +1 -1
  46. package/runtime/.next/server/app/api/engine-threads/route.js +1 -1
  47. package/runtime/.next/server/app/api/engine-threads/route.js.nft.json +1 -1
  48. package/runtime/.next/server/app/api/engine-threads.body +1 -1
  49. package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
  50. package/runtime/.next/server/app/api/flow/v1/catalog/route.js.nft.json +1 -1
  51. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
  52. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js.nft.json +1 -1
  53. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +2 -2
  54. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js.nft.json +1 -1
  55. package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
  56. package/runtime/.next/server/app/api/flow/v1/runs/route.js.nft.json +1 -1
  57. package/runtime/.next/server/app/api/flow-studio/config/route.js +1 -1
  58. package/runtime/.next/server/app/api/internal/todo-bootstrap/route.js +1 -0
  59. package/runtime/.next/server/app/api/internal/todo-bootstrap/route.js.nft.json +1 -0
  60. package/runtime/.next/server/app/api/internal/todo-mcp/route.js +1 -0
  61. package/runtime/.next/server/app/api/internal/todo-mcp/route.js.nft.json +1 -0
  62. package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
  63. package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
  64. package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
  65. package/runtime/.next/server/app/api/mcp/servers.body +1 -1
  66. package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
  67. package/runtime/.next/server/app/api/memory/route.js +1 -1
  68. package/runtime/.next/server/app/api/messaging/route.js +1 -1
  69. package/runtime/.next/server/app/api/notifications/[id]/ack/route.js +1 -0
  70. package/runtime/.next/server/app/api/notifications/[id]/ack/route.js.nft.json +1 -0
  71. package/runtime/.next/server/app/api/notifications/[id]/route.js +1 -0
  72. package/runtime/.next/server/app/api/notifications/[id]/route.js.nft.json +1 -0
  73. package/runtime/.next/server/app/api/notifications/route.js +1 -0
  74. package/runtime/.next/server/app/api/notifications/route.js.nft.json +1 -0
  75. package/runtime/.next/server/app/api/notifications/stream/route.js +4 -0
  76. package/runtime/.next/server/app/api/notifications/stream/route.js.nft.json +1 -0
  77. package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
  78. package/runtime/.next/server/app/api/plugins/load/route.js.nft.json +1 -1
  79. package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
  80. package/runtime/.next/server/app/api/projects/check/route.js +1 -1
  81. package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
  82. package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
  83. package/runtime/.next/server/app/api/projects/route.js +1 -1
  84. package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
  85. package/runtime/.next/server/app/api/push/subscribe/route.js.nft.json +1 -1
  86. package/runtime/.next/server/app/api/push/unsubscribe/route.js +2 -2
  87. package/runtime/.next/server/app/api/push/vapid/route.js +3 -3
  88. package/runtime/.next/server/app/api/push/vapid/route.js.nft.json +1 -1
  89. package/runtime/.next/server/app/api/push/vapid.body +1 -1
  90. package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
  91. package/runtime/.next/server/app/api/remote-tools/register/route.js.nft.json +1 -1
  92. package/runtime/.next/server/app/api/session-images/[id]/route.js +1 -0
  93. package/runtime/.next/server/app/api/session-images/[id]/route.js.nft.json +1 -0
  94. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/route.js +1 -1
  95. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/route.js.nft.json +1 -1
  96. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/stop/route.js +1 -1
  97. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/stop/route.js.nft.json +1 -1
  98. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/route.js +1 -1
  99. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/route.js.nft.json +1 -1
  100. package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +3 -3
  101. package/runtime/.next/server/app/api/sessions/[id]/changes/route.js.nft.json +1 -1
  102. package/runtime/.next/server/app/api/sessions/[id]/engine-switches/route.js +1 -1
  103. package/runtime/.next/server/app/api/sessions/[id]/engine-switches/route.js.nft.json +1 -1
  104. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
  105. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js.nft.json +1 -1
  106. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -1
  107. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js.nft.json +1 -1
  108. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
  109. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js.nft.json +1 -1
  110. package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
  111. package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js.nft.json +1 -1
  112. package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js +1 -1
  113. package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js.nft.json +1 -1
  114. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
  115. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js.nft.json +1 -1
  116. package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
  117. package/runtime/.next/server/app/api/sessions/[id]/release/route.js.nft.json +1 -1
  118. package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
  119. package/runtime/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
  120. package/runtime/.next/server/app/api/sessions/[id]/switch-engine/route.js +1 -1
  121. package/runtime/.next/server/app/api/sessions/[id]/switch-engine/route.js.nft.json +1 -1
  122. package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
  123. package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js.nft.json +1 -1
  124. package/runtime/.next/server/app/api/sessions/[id]/thread-history/route.js +1 -1
  125. package/runtime/.next/server/app/api/sessions/[id]/thread-history/route.js.nft.json +1 -1
  126. package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
  127. package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js.nft.json +1 -1
  128. package/runtime/.next/server/app/api/sessions/parallel/route.js +1 -1
  129. package/runtime/.next/server/app/api/sessions/parallel/route.js.nft.json +1 -1
  130. package/runtime/.next/server/app/api/sessions/route.js +1 -1
  131. package/runtime/.next/server/app/api/sessions/route.js.nft.json +1 -1
  132. package/runtime/.next/server/app/api/settings/route.js +1 -1
  133. package/runtime/.next/server/app/api/skills/route.js +1 -1
  134. package/runtime/.next/server/app/api/todos/[id]/commands/route.js +1 -0
  135. package/runtime/.next/server/app/api/todos/[id]/commands/route.js.nft.json +1 -0
  136. package/runtime/.next/server/app/api/todos/[id]/executions/route.js +1 -0
  137. package/runtime/.next/server/app/api/todos/[id]/executions/route.js.nft.json +1 -0
  138. package/runtime/.next/server/app/api/todos/[id]/route.js +1 -0
  139. package/runtime/.next/server/app/api/todos/[id]/route.js.nft.json +1 -0
  140. package/runtime/.next/server/app/api/todos/route.js +1 -0
  141. package/runtime/.next/server/app/api/todos/route.js.nft.json +1 -0
  142. package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
  143. package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js.nft.json +1 -1
  144. package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
  145. package/runtime/.next/server/app/api/tool-policies/route.js.nft.json +1 -1
  146. package/runtime/.next/server/app/api/tools/route.js +1 -1
  147. package/runtime/.next/server/app/api/tools/route.js.nft.json +1 -1
  148. package/runtime/.next/server/app/api/update/check/route.js +1 -1
  149. package/runtime/.next/server/app/api/update/install/route.js +1 -1
  150. package/runtime/.next/server/app/api/update/status/route.js +1 -1
  151. package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
  152. package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
  153. package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
  154. package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
  155. package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
  156. package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
  157. package/runtime/.next/server/app/api/web-console/computer-settings/route.js +1 -1
  158. package/runtime/.next/server/app/api/web-console/computers/route.js +1 -1
  159. package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
  160. package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
  161. package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
  162. package/runtime/.next/server/app/api/workspace-changes/route.js +1 -0
  163. package/runtime/.next/server/app/api/workspace-changes/route.js.nft.json +1 -0
  164. package/runtime/.next/server/app/web/page.js +4 -4
  165. package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
  166. package/runtime/.next/server/app-paths-manifest.json +45 -33
  167. package/runtime/.next/server/chunks/1298.js +1 -0
  168. package/runtime/.next/server/chunks/1973.js +1 -0
  169. package/runtime/.next/server/chunks/4621.js +1 -1
  170. package/runtime/.next/server/chunks/5303.js +1 -1
  171. package/runtime/.next/server/chunks/535.js +1 -0
  172. package/runtime/.next/server/chunks/5762.js +3 -3
  173. package/runtime/.next/server/chunks/5801.js +1 -0
  174. package/runtime/.next/server/chunks/5812.js +1 -0
  175. package/runtime/.next/server/chunks/685.js +1 -0
  176. package/runtime/.next/server/chunks/6977.js +1 -1
  177. package/runtime/.next/server/chunks/9119.js +15 -0
  178. package/runtime/.next/server/chunks/9457.js +1 -0
  179. package/runtime/.next/server/middleware-build-manifest.js +1 -1
  180. package/runtime/.next/server/pages/404.html +1 -1
  181. package/runtime/.next/server/pages/500.html +1 -1
  182. package/runtime/.next/server/server-reference-manifest.json +1 -1
  183. package/runtime/.next/static/chunks/753-90c7dd1ba08be9be.js +1 -0
  184. package/runtime/.next/static/chunks/app/web/{error-3cae58f0f14f0b4f.js → error-828d278147a0619d.js} +1 -1
  185. package/runtime/.next/static/chunks/app/web/layout-a8b7565989c1c063.js +1 -0
  186. package/runtime/.next/static/chunks/app/web/page-8ff95d45a0160843.js +1 -0
  187. package/runtime/.next/static/chunks/{main-d8ef9def37924b01.js → main-7240085c0ba42e9a.js} +1 -1
  188. package/runtime/.next/static/chunks/main-app-07d67f2d4e96ecb8.js +1 -0
  189. package/runtime/lib/desktop-discovery.mjs +12 -3
  190. package/runtime/lib/service-identity.mjs +17 -0
  191. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
  192. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
  193. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
  194. package/runtime/node_modules/.package-lock.json +17 -17
  195. package/runtime/node_modules/@agent/core/dist/index.js +865 -7
  196. package/runtime/node_modules/@agent/native-runtime/dist/index.js +28979 -9946
  197. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +82 -90
  198. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +65 -64
  199. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-0vfvgmex.mjs +39 -0
  200. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-x4kwpwv9.mjs → core-3h0s3zzg.mjs} +2 -2
  201. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-ba5rrckm.mjs → core-6w7w19rc.mjs} +2 -2
  202. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-8fprsbvz.mjs +42 -0
  203. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-avz7wgsg.mjs +23 -0
  204. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-b9ebje8h.mjs +20 -0
  205. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-tf03rfab.mjs → core-e1h3fbg3.mjs} +3 -3
  206. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-2h2qc9qv.mjs → core-ge6en8c9.mjs} +4 -4
  207. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-h6r54bwv.mjs → core-htcq9qj1.mjs} +2 -2
  208. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-sstebd83.mjs → core-nv0a4kre.mjs} +4 -4
  209. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-y4qk5bdp.mjs +17 -0
  210. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-qj4dtgyt.mjs → core-yrdmz7je.mjs} +3 -3
  211. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-z276fcqp.mjs +28 -0
  212. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +12 -11
  213. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +22 -22
  214. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +26 -26
  215. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +23 -25
  216. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +86 -90
  217. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +72 -45
  218. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +13 -13
  219. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +13 -13
  220. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +72 -45
  221. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +72 -45
  222. package/runtime/node_modules/mediabunny/dist/modules/src/input.js +6 -0
  223. package/runtime/node_modules/mediabunny/dist/modules/src/media-sink.js +52 -35
  224. package/runtime/node_modules/mediabunny/dist/modules/src/media-source.js +2 -0
  225. package/runtime/node_modules/mediabunny/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.js +7 -1
  226. package/runtime/node_modules/mediabunny/dist/modules/src/source.js +7 -4
  227. package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
  228. package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
  229. package/runtime/node_modules/mediabunny/dist/modules/src/wave/wave-demuxer.js +6 -6
  230. package/runtime/node_modules/mediabunny/package.json +1 -1
  231. package/runtime/node_modules/mediabunny/src/input.ts +7 -0
  232. package/runtime/node_modules/mediabunny/src/media-sink.ts +56 -37
  233. package/runtime/node_modules/mediabunny/src/media-source.ts +3 -0
  234. package/runtime/node_modules/mediabunny/src/mpeg-ts/mpeg-ts-demuxer.ts +6 -1
  235. package/runtime/node_modules/mediabunny/src/source.ts +7 -4
  236. package/runtime/node_modules/mediabunny/src/version.ts +1 -1
  237. package/runtime/node_modules/mediabunny/src/wave/wave-demuxer.ts +6 -6
  238. package/runtime/node_modules/source-map-js/lib/quick-sort.js +92 -22
  239. package/runtime/node_modules/source-map-js/package.json +1 -1
  240. package/runtime/package-lock.json +41 -65
  241. package/runtime/server.js +1 -1
  242. package/runtime/webapp/dist/assets/AIHubView-CrtJMKfW.js +1 -0
  243. package/runtime/webapp/dist/assets/{AgentManager-CrN2B-tH.js → AgentManager-C2O-Dacy.js} +2 -2
  244. package/runtime/webapp/dist/assets/{AiHubPane-Du6ajSsx.js → AiHubPane-D2XWxc9R.js} +1 -1
  245. package/runtime/webapp/dist/assets/App-Bum2L4_E.js +63 -0
  246. package/runtime/webapp/dist/assets/App-CtLZIOFu.css +1 -0
  247. package/runtime/webapp/dist/assets/BrowserLivePanel-DkBugqrH.js +61 -0
  248. package/runtime/webapp/dist/assets/CalendarPage-DzYWlqoZ.js +1 -0
  249. package/runtime/webapp/dist/assets/CalendarView-BjjC_t12.css +1 -0
  250. package/runtime/webapp/dist/assets/CalendarView-HQls5G-1.js +31 -0
  251. package/runtime/webapp/dist/assets/CollaborationCreateDialog-BwiSJbjb.js +1 -0
  252. package/runtime/webapp/dist/assets/CollaborationDashboard-CNHt31kl.js +1 -0
  253. package/runtime/webapp/dist/assets/CollaborationPage-C4l-tTvn.js +6 -0
  254. package/runtime/webapp/dist/assets/{FilePreview-CevPpP6E.js → FilePreview-EGUAbGpH.js} +5 -5
  255. package/runtime/webapp/dist/assets/FileTree-aJGl1V0W.js +6 -0
  256. package/runtime/webapp/dist/assets/FileWorkspaceDrawer-zpD91eB6.js +1 -0
  257. package/runtime/webapp/dist/assets/FlowStudioPane-K1o4pSkZ.js +5 -0
  258. package/runtime/webapp/dist/assets/HostProjectPicker-BvboCQ0a.js +1 -0
  259. package/runtime/webapp/dist/assets/{LSPServerList-BMY6dFfG.js → LSPServerList-BSLzGLtW.js} +1 -1
  260. package/runtime/webapp/dist/assets/{MCPServerList-c91QNM-g.js → MCPServerList-CeWTI1-m.js} +1 -1
  261. package/runtime/webapp/dist/assets/{MemoryViewer-C9IfWwzW.js → MemoryViewer-YcceFawC.js} +1 -1
  262. package/runtime/webapp/dist/assets/NewSessionWindow-C_HCQQnW.js +1 -0
  263. package/runtime/webapp/dist/assets/NewSessionWindow-DOLG1XEp.css +1 -0
  264. package/runtime/webapp/dist/assets/{RemoteDesktopPage-w8aL061W.js → RemoteDesktopPage-Cpzv8zH0.js} +1 -1
  265. package/runtime/webapp/dist/assets/{RunningSessionsIcon-B8Cr2-hp.js → RunningSessionsIcon-DmCYwIYD.js} +5 -5
  266. package/runtime/webapp/dist/assets/SessionDashboard-C58Mke8a.js +16 -0
  267. package/runtime/webapp/dist/assets/{SessionDashboardBridge-Bx4EXtos.js → SessionDashboardBridge-BPsNDY5Y.js} +1 -1
  268. package/runtime/webapp/dist/assets/{SettingsPanel-CS4XL2sd.js → SettingsPanel-CPBIPT-Z.js} +2 -2
  269. package/runtime/webapp/dist/assets/{SkillManager-5FZnR9My.js → SkillManager-_qaGEuOE.js} +1 -1
  270. package/runtime/webapp/dist/assets/{TerminalPane-CRrbd0i4.js → TerminalPane-mYe76Pgb.js} +2 -2
  271. package/runtime/webapp/dist/assets/TodoPage-DdF5_SkL.js +1 -0
  272. package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-DBioGYiE.js → abnfDiagram-VCTEODGH-DLd8EeCY.js} +1 -1
  273. package/runtime/webapp/dist/assets/{arc-BRj_RXHL.js → arc-D4smlqs5.js} +1 -1
  274. package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-CoCdq67U.js → architectureDiagram-5GKGNRK7-ByE3DRU4.js} +1 -1
  275. package/runtime/webapp/dist/assets/{arrow-right-Cqqb1zqH.js → arrow-right-BtIv2jiq.js} +1 -1
  276. package/runtime/webapp/dist/assets/artifact-links-4m1A00GO.js +2 -0
  277. package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-CLisIPjq.js → blockDiagram-I7D4REHJ-BvTUm5vA.js} +3 -3
  278. package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-BoLCIVW8.js → c4Diagram-7LVT6UL2-XKwj5RmQ.js} +1 -1
  279. package/runtime/webapp/dist/assets/calendar-days-BeI09qof.js +6 -0
  280. package/runtime/webapp/dist/assets/channel-wxCRUEc2.js +1 -0
  281. package/runtime/webapp/dist/assets/check-BdadwkYj.js +6 -0
  282. package/runtime/webapp/dist/assets/{chevron-down-DhZV290h.js → chevron-down-DwzPFeq8.js} +1 -1
  283. package/runtime/webapp/dist/assets/chevron-right-kcIXzCMb.js +6 -0
  284. package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-CIQxwzU0.js → chunk-2Q5K7J3B-7A6CDWIw.js} +1 -1
  285. package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-Buiv0MCN.js → chunk-5VM5RSS4-mkNEWbY6.js} +1 -1
  286. package/runtime/webapp/dist/assets/chunk-F27PBJKO-DKG-1HL0.js +1 -0
  287. package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-C0NrkJOc.js → chunk-IMKFNOWR-kiJDyKM7.js} +1 -1
  288. package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-CGON_UvB.js → chunk-JWPE2WC7-DS7C5_M7.js} +1 -1
  289. package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-BXvOsc9g.js → chunk-POPQ4Y6H-DvgeK_lX.js} +1 -1
  290. package/runtime/webapp/dist/assets/{chunk-SVP7TREG-ZD_qn-NK.js → chunk-SVP7TREG-BLo_2ua-.js} +3 -3
  291. package/runtime/webapp/dist/assets/{chunk-TICWLB2K-DrB8f6RG.js → chunk-TICWLB2K-CJT6Qkz4.js} +1 -1
  292. package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-CYgLMn5t.js → chunk-XXDRQBXY-D1OLqjNu.js} +1 -1
  293. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-Ct3Cgqrl.js +1 -0
  294. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-Ct3Cgqrl.js +1 -0
  295. package/runtime/webapp/dist/assets/{codeSyntax-DfQ5rLir.js → codeSyntax-Dd0hAazb.js} +3 -3
  296. package/runtime/webapp/dist/assets/collaboration-CAgt9AiV.js +6 -0
  297. package/runtime/webapp/dist/assets/composer-file-routing-DSC2Eojr.js +6 -0
  298. package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-CDPnTlcy.js → cose-bilkent-JH36ORCC-CI6EKHP8.js} +1 -1
  299. package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-DDCxhkA5.js → cynefin-OW5HDTMX-CJTXYieX.js} +1 -1
  300. package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-CIJ1KBPA.js → cynefinDiagram-5FMLGOSQ-CPl1UVhy.js} +2 -2
  301. package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-CFX8O3IJ.js → dagre-GXQ25YYZ-Dq3ZQGTN.js} +1 -1
  302. package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-B8UX2IBH.js → diagram-S7CK7UJ4-DJyU-2Di.js} +3 -3
  303. package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-Ce34DNrv.js → diagram-UQ7AKVKN-Csg8hC8m.js} +1 -1
  304. package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-CVL_erWD.js → diagram-VSXAHHWV-B14uLH_N.js} +3 -3
  305. package/runtime/webapp/dist/assets/{diagram-VX7I27RA-DBFHI7Dk.js → diagram-VX7I27RA-D2Ww2nHe.js} +1 -1
  306. package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-Bw_QcSQY.js → diagram-Z3DM3KII-D_YC6AVP.js} +2 -2
  307. package/runtime/webapp/dist/assets/{download-D3xZPWnZ.js → download-COWHIKec.js} +1 -1
  308. package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-DRly04dj.js → ebnfDiagram-PWID7BFC-s66xVEGY.js} +1 -1
  309. package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-DTm817hG.js → erDiagram-RLTQ6QDP-CgZh5cEn.js} +1 -1
  310. package/runtime/webapp/dist/assets/{external-link-Cwu5rEgp.js → external-link-T3kil1jt.js} +1 -1
  311. package/runtime/webapp/dist/assets/{file-types-DKkhMnUV.js → file-types-0e-tNIVd.js} +2 -2
  312. package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-tc8ygZtG.js → flowDiagram-HODETNUW-BISMKynN.js} +1 -1
  313. package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-CsQFf1IN.js → ganttDiagram-EL5Y4UJY-Cbyu0NcF.js} +1 -1
  314. package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-DAIxbmPX.js → gitGraphDiagram-WWUBYQGX-Cs6IQGBz.js} +7 -7
  315. package/runtime/webapp/dist/assets/history-Df4LXw6L.js +6 -0
  316. package/runtime/webapp/dist/assets/{image-plus-nplydLA5.js → image-plus-COHCHOpI.js} +1 -1
  317. package/runtime/webapp/dist/assets/index-CQTDnt74.css +1 -0
  318. package/runtime/webapp/dist/assets/index-CTJNAMck.js +489 -0
  319. package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-CVcMW4UM.js → infoDiagram-27XIBGKW-4f3bFqNV.js} +1 -1
  320. package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-zzlEtZ1l.js → ishikawaDiagram-5VMMS53U-D-cJ9vio.js} +4 -4
  321. package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-q7NuIMSl.js → journeyDiagram-3NMN7TZE-CeToS0Qx.js} +1 -1
  322. package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-DLYFZlKO.js → kanban-definition-UXKFOSKX-DStbIUk1.js} +7 -7
  323. package/runtime/webapp/dist/assets/{layout-PFWssIkE.js → layout-i2D4wlYd.js} +1 -1
  324. package/runtime/webapp/dist/assets/{linear-ZRVcojb1.js → linear-BcJhiCv3.js} +1 -1
  325. package/runtime/webapp/dist/assets/list-todo-7yETOqQe.js +6 -0
  326. package/runtime/webapp/dist/assets/{loader-circle-DIW9tlEz.js → loader-circle-CZdAfU-D.js} +1 -1
  327. package/runtime/webapp/dist/assets/locate-fixed-ByJuEKxC.js +6 -0
  328. package/runtime/webapp/dist/assets/{mermaid.core-C8Dl0Nah.js → mermaid.core-BjNFAB9I.js} +6 -6
  329. package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-BcbqtwVk.js → mindmap-definition-YA3MSWOX-BUIHHUVG.js} +1 -1
  330. package/runtime/webapp/dist/assets/new-session-window-C7R76XMp.css +1 -0
  331. package/runtime/webapp/dist/assets/new-session-window-DwtkwFBQ.js +190 -0
  332. package/runtime/webapp/dist/assets/page-9-9EC7QM.js +86 -0
  333. package/runtime/webapp/dist/assets/pause-DXyBDZlg.js +6 -0
  334. package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-BQN3zQuy.js → pegDiagram-XKGWAZYB-BY5Bio5e.js} +1 -1
  335. package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-pOgxh3os.js → pieDiagram-E7YTZNPT-CF8DVW3F.js} +3 -3
  336. package/runtime/webapp/dist/assets/pin-2YlrlSJv.js +6 -0
  337. package/runtime/webapp/dist/assets/play-BxEpdvoI.js +6 -0
  338. package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-BOg7ujzG.js → quadrantDiagram-AXDQQJYC-CXWHO3a-.js} +1 -1
  339. package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-CWsN3juJ.js → railroadDiagram-O6MQD6OU-C20JeJZ-.js} +1 -1
  340. package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-B0yrO7Oy.js → requirementDiagram-BXWQKSXE-IYd9UrO9.js} +3 -3
  341. package/runtime/webapp/dist/assets/{rotate-ccw-O4wnfQP7.js → rotate-ccw-CFIRtbUD.js} +1 -1
  342. package/runtime/webapp/dist/assets/{rotate-cw-CCJtlAtB.js → rotate-cw-B_vFqNsz.js} +1 -1
  343. package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-5MS_e-3E.js → sankeyDiagram-P5KCCOFB-ysBhpblA.js} +2 -2
  344. package/runtime/webapp/dist/assets/{send-Cdg4ZVlp.js → send-DUE2vBoK.js} +1 -1
  345. package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-C1w8qYSu.js → sequenceDiagram-WJ2MYXX4-CQMmk6cu.js} +4 -4
  346. package/runtime/webapp/dist/assets/session-dashboard-DnFhQhBN.js +1 -0
  347. package/runtime/webapp/dist/assets/{shield-check-CrjI2wPR.js → shield-check-Btyos6Iv.js} +1 -1
  348. package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-BonKTynC.js → sizeCapture-INFHLROL-DekvKUn1.js} +1 -1
  349. package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-D3mn6ZK5.js → stateDiagram-D77RDMKH-Ds_FEmbr.js} +1 -1
  350. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-DxJ1ks_8.js +1 -0
  351. package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-Bn9KWChU.js → swimlanes-42K2YHIH-cjPcEO_T.js} +1 -1
  352. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-JGHIAQXy.js +8 -0
  353. package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-BfuhI7EF.js → timeline-definition-24CTP7MA-CEOprVt5.js} +1 -1
  354. package/runtime/webapp/dist/assets/{trash-2-BrfgMjfL.js → trash-2-DLDxY6J7.js} +4 -9
  355. package/runtime/webapp/dist/assets/{types-VnQ_cKrp.js → types-CFAnlTif.js} +1 -1
  356. package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-CUFs5JyR.js → vennDiagram-4TSXK5OY-D82uxYY9.js} +5 -5
  357. package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-C27HHz1A.js → wardleyDiagram-VM6X3IG4-JFt7Izt0.js} +1 -1
  358. package/runtime/webapp/dist/assets/{web-CeCHmdwO.js → web-BMqaP0jw.js} +1 -1
  359. package/runtime/webapp/dist/assets/{web-BOzkL-0Z.js → web-Q9VPRftY.js} +1 -1
  360. package/runtime/webapp/dist/assets/{x-DP1nC4qG.js → x-CeSbythI.js} +1 -1
  361. package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-CQwRrSTf.js → xychartDiagram-S5SC5T6Z-1WCa4SfL.js} +3 -3
  362. package/runtime/webapp/dist/assets/zoom-out-CRr_o1NV.js +16 -0
  363. package/runtime/webapp/dist/index.html +2 -2
  364. package/runtime/ws-server.mjs +23 -4
  365. package/runtime/.next/server/chunks/1614.js +0 -1
  366. package/runtime/.next/server/chunks/732.js +0 -1
  367. package/runtime/.next/server/chunks/7519.js +0 -15
  368. package/runtime/.next/server/chunks/7788.js +0 -1
  369. package/runtime/.next/static/chunks/333-9881c3d2c558a28d.js +0 -1
  370. package/runtime/.next/static/chunks/app/web/layout-d5d7d1c5c74eef3c.js +0 -1
  371. package/runtime/.next/static/chunks/app/web/page-7afa4cb0119e90b7.js +0 -1
  372. package/runtime/.next/static/chunks/main-app-7a6902a607752446.js +0 -1
  373. package/runtime/lib/voice-tts-gateway.mjs +0 -96
  374. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-9sxfsmzx.mjs +0 -18
  375. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-dnsvg8nc.mjs +0 -53
  376. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-k67vj6j9.mjs +0 -20
  377. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-qbjntcdf.mjs +0 -18
  378. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-rn7tc54w.mjs +0 -17
  379. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-td7rt8zt.mjs +0 -17
  380. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-y6bhrwmk.mjs +0 -47
  381. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-ya1m7gzj.mjs +0 -18
  382. package/runtime/webapp/dist/assets/AIHubView-BMeOfqfm.js +0 -1
  383. package/runtime/webapp/dist/assets/App-CrZstnCH.css +0 -1
  384. package/runtime/webapp/dist/assets/App-zihaYk1L.js +0 -179
  385. package/runtime/webapp/dist/assets/BrowserLivePanel-CU_X6OU2.js +0 -56
  386. package/runtime/webapp/dist/assets/CollaborationCreateDialog-BmgYdwe7.js +0 -1
  387. package/runtime/webapp/dist/assets/CollaborationDashboard-mHU8iJYg.js +0 -1
  388. package/runtime/webapp/dist/assets/CollaborationPage-Br5fhNce.js +0 -6
  389. package/runtime/webapp/dist/assets/FileTree-CagcHV1N.js +0 -11
  390. package/runtime/webapp/dist/assets/FileWorkspaceDrawer-CWVndCXp.js +0 -1
  391. package/runtime/webapp/dist/assets/FlowStudioPane-BZA-qvBj.js +0 -5
  392. package/runtime/webapp/dist/assets/SessionDashboard-CFXXTm_4.js +0 -21
  393. package/runtime/webapp/dist/assets/artifact-links-73OZyi5W.js +0 -7
  394. package/runtime/webapp/dist/assets/channel-JGVZzkSo.js +0 -1
  395. package/runtime/webapp/dist/assets/chunk-F27PBJKO-XBMwIl6X.js +0 -1
  396. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BnctJ00R.js +0 -1
  397. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BnctJ00R.js +0 -1
  398. package/runtime/webapp/dist/assets/collaboration-CQhzjwS_.js +0 -6
  399. package/runtime/webapp/dist/assets/composer-file-routing-D9orqwzY.js +0 -11
  400. package/runtime/webapp/dist/assets/index-B-d1Vs9E.css +0 -1
  401. package/runtime/webapp/dist/assets/index-DKm9ESDq.js +0 -489
  402. package/runtime/webapp/dist/assets/page-BG97oPXr.js +0 -91
  403. package/runtime/webapp/dist/assets/session-dashboard-BigU92sz.js +0 -6
  404. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-WEfEW-mH.js +0 -1
  405. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-D26_Nmko.js +0 -8
  406. package/runtime/webapp/dist/assets/zoom-out-Dg7YyzcP.js +0 -21
  407. package/runtime/webapp/dist/pcm-audio-worklet.js +0 -126
  408. /package/runtime/.next/static/{xuZ1UJWVNJ-rxb5YgETmd → alt-ud1W2PlWW6FLlkBcB}/_buildManifest.js +0 -0
  409. /package/runtime/.next/static/{xuZ1UJWVNJ-rxb5YgETmd → alt-ud1W2PlWW6FLlkBcB}/_ssgManifest.js +0 -0
@@ -1,56 +0,0 @@
1
- var Ur=t=>{throw TypeError(t)};var xi=(t,e,r)=>e.has(t)||Ur("Cannot "+r);var Wr=(t,e,r)=>e.has(t)?Ur("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);var Hr=(t,e,r)=>(xi(t,e,"access private method"),r);import{c as Te,j as u,r as h,B as Ci,d as ar,n as $r}from"./index-DKm9ESDq.js";import{L as Se}from"./loader-circle-DIW9tlEz.js";import{C as Ri}from"./chevron-down-DhZV290h.js";import{r as Ei}from"./clipboard-BvwmdR4z.js";import{R as ji}from"./rotate-ccw-O4wnfQP7.js";import{X as Mi}from"./x-DP1nC4qG.js";import{M as Kr,V as Si,Z as Ti,a as Ii}from"./zoom-out-Dg7YyzcP.js";import{E as Di}from"./external-link-Cwu5rEgp.js";/**
2
- * @license lucide-react v0.468.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Ni=Te("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
7
- * @license lucide-react v0.468.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const cr=Te("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
12
- * @license lucide-react v0.468.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Xr=Te("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
17
- * @license lucide-react v0.468.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Pi=Te("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
22
- * @license lucide-react v0.468.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ai=Te("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
27
- * @license lucide-react v0.468.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const qi=Te("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
32
- * @license lucide-react v0.468.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const lr=Te("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/**
37
- * @license lucide-react v0.468.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Yr=Te("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
42
- * @license lucide-react v0.468.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Li=Te("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/**
47
- * @license lucide-react v0.468.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const Zr=Te("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/**
52
- * @license lucide-react v0.468.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const zi=Te("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);function _r({label:t,title:e,value:r,busy:n,disabled:s,compact:l,onChange:o,children:f}){return u.jsxs("span",{className:`live-view-select${l?" live-view-select--compact":""}`,children:[u.jsx("select",{"aria-label":t,"aria-busy":n,title:e,value:r,disabled:s||n,onChange:p=>o(p.target.value),children:f}),n?u.jsx("span",{className:"live-view-select-icon",role:"status","aria-label":`${t}正在切换`,children:u.jsx(Se,{size:14,className:"spin","aria-hidden":"true"})}):u.jsx(Ri,{size:14,className:"live-view-select-icon","aria-hidden":"true"})]})}function Fi({disabled:t,onPaste:e,onError:r}){const[n,s]=h.useState(!1),[l,o]=h.useState(!1),f=h.useRef(null),p=h.useRef(!1),m=h.useRef(!0),w=h.useRef(!t);w.current=!t,h.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]),h.useEffect(()=>{var x;l&&((x=f.current)==null||x.focus({preventScroll:!0}))},[l]);const k=async x=>{if(!(p.current||t)){p.current=!0,s(!0),r(null);try{const R=await x();if(!m.current||!w.current)return;if(R===null){o(!0),r("浏览器限制读取剪贴板,请长按“系统粘贴”使用系统菜单,粘贴后自动输入电脑");return}if(!R)throw new Error("剪贴板里没有文字");await e(R),m.current&&o(!1)}catch(R){m.current&&r(R instanceof Error?R.message:"粘贴失败,请重试")}finally{p.current=!1,m.current&&s(!1)}}};return l?u.jsx("input",{ref:f,className:"browser-live-native-paste","aria-label":"系统粘贴",placeholder:"系统粘贴",disabled:t||n,defaultValue:"",autoCapitalize:"none",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onPaste:x=>{x.preventDefault();const R=x.clipboardData.getData("text/plain");k(()=>Promise.resolve(R))}}):u.jsx("button",{type:"button",disabled:t||n,title:"直接粘贴当前手机或电脑剪贴板的文字",onClick:()=>void k(Ei),children:n?"粘贴中…":"粘贴"})}const Vi=5e3,Bi=1e4;class Oi{constructor(){this.startedAt=null,this.lastFrameAt=null,this.lastFrameCount=null}begin(e){this.startedAt=e,this.lastFrameAt=null,this.lastFrameCount=null}resume(e){this.startedAt!==null&&(this.startedAt=e),this.lastFrameAt!==null&&(this.lastFrameAt=e)}observe(e,r){return typeof e!="number"||!Number.isFinite(e)||e<0||e===this.lastFrameCount||(this.lastFrameCount=e,e===0)?!1:(this.lastFrameAt=r,!0)}evaluate(e){const r=this.lastFrameAt??this.startedAt;if(r===null)return{state:"streaming",silentForMs:0};const n=Math.max(0,e-r),s=this.lastFrameAt===null?Vi:Bi;return{state:n>=s?"stalled":"streaming",silentForMs:n}}}const z=Object.freeze({version:1,channelLabel:"agentroam.compound.v1",tileSize:64,maxDimension:4096,maxFramePixels:8388608,maxTileBytes:32768,maxMessageBytes:48e3,maxTiles:128,maxCacheEntries:4096,maxCachePixels:10485760,maxEntropy:24,initialEntropy:6.3,sampleIntervalMs:250,acknowledgementTimeoutMs:2e3});function pr(t,e){return[t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.width,t==null?void 0:t.height].every(Number.isSafeInteger)&&t.x>=0&&t.y>=0&&t.width>0&&t.height>0&&t.x+t.width<=e.width&&t.y+t.height<=e.height}function Ui(t){return typeof t.epoch=="string"&&t.epoch.length>0&&t.epoch.length<=120&&Number.isSafeInteger(t.revision)&&t.revision>=0&&Number.isFinite(t.timestamp)&&t.timestamp>=0&&Number.isInteger(t.width)&&t.width>0&&t.width<=z.maxDimension&&Number.isInteger(t.height)&&t.height>0&&t.height<=z.maxDimension&&t.width*t.height<=z.maxFramePixels}function mr(t,e){const r=t-e>>>0;return r!==0&&r<2147483648}function Wi(t,e){return Number.isSafeInteger(t==null?void 0:t.sourceRevision)&&t.sourceRevision>=0&&pr(t,e)&&pr({x:t.sourceX,y:t.sourceY,width:t.width,height:t.height},e)&&(t.sourceX!==t.x||t.sourceY!==t.y)}var Hi=ArrayBuffer,Z=Uint8Array,Kt=Uint16Array,$i=Int16Array,Yt=Int32Array,ur=function(t,e,r){if(Z.prototype.slice)return Z.prototype.slice.call(t,e,r);(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length);var n=new Z(r-e);return n.set(t.subarray(e,r)),n},Rt=function(t,e,r,n){if(Z.prototype.fill)return Z.prototype.fill.call(t,e,r,n);for((r==null||r<0)&&(r=0),(n==null||n>t.length)&&(n=t.length);r<n;++r)t[r]=e;return t},Ki=function(t,e,r,n){if(Z.prototype.copyWithin)return Z.prototype.copyWithin.call(t,e,r,n);for((r==null||r<0)&&(r=0),(n==null||n>t.length)&&(n=t.length);r<n;)t[e++]=t[r++]},Xi=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],_=function(t,e,r){var n=new Error(e||Xi[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,_),!r)throw n;return n},Gr=function(t,e,r){for(var n=0,s=0;n<r;++n)s|=t[e++]<<(n<<3);return s},Yi=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},Zi=function(t,e){var r=t[0]|t[1]<<8|t[2]<<16;if(r==3126568&&t[3]==253){var n=t[4],s=n>>5&1,l=n>>2&1,o=n&3,f=n>>6;n&8&&_(0);var p=6-s,m=o==3?4:o,w=Gr(t,p,m);p+=m;var k=f?1<<f:s,x=Gr(t,p,k)+(f==1&&256),R=x;if(!s){var g=1<<10+(t[5]>>3);R=g+(g>>3)*(t[5]&7)}R>2145386496&&_(1);var M=new Z((e==1?x||R:e?0:R)+12);return M[0]=1,M[4]=4,M[8]=8,{b:p+k,y:0,l:0,d:w,w:e&&e!=1?e:M.subarray(12),e:R,o:new Yt(M.buffer,0,3),u:x,c:l,m:Math.min(131072,R)}}else if((r>>4|t[3]<<20)==25481893)return Yi(t,4)+8;_(0)},et=function(t){for(var e=0;1<<e<=t;++e);return e-1},Et=function(t,e,r){var n=(e<<3)+4,s=(t[e]&15)+5;s>r&&_(3);for(var l=1<<s,o=l,f=-1,p=-1,m=-1,w=l,k=new Hi(512+(l<<2)),x=new $i(k,0,256),R=new Kt(k,0,256),g=new Kt(k,512,l),M=512+(l<<1),I=new Z(k,M,l),Q=new Z(k,M+l);f<255&&o>0;){var K=et(o+1),B=n>>3,q=(1<<K+1)-1,V=(t[B]|t[B+1]<<8|t[B+2]<<16)>>(n&7)&q,v=(1<<K)-1,U=q-o-1,X=V&v;if(X<U?(n+=K,V=X):(n+=K+1,V>v&&(V-=U)),x[++f]=--V,V==-1?(o+=V,I[--w]=f):o-=V,!V)do{var oe=n>>3;p=(t[oe]|t[oe+1]<<8)>>(n&7)&3,n+=2,f+=p}while(p==3)}(f>255||o)&&_(0);for(var W=0,Y=(l>>1)+(l>>3)+3,ee=l-1,T=0;T<=f;++T){var P=x[T];if(P<1){R[T]=-P;continue}for(m=0;m<P;++m){I[W]=T;do W=W+Y&ee;while(W>=w)}}for(W&&_(0),m=0;m<l;++m){var E=R[I[m]]++,O=Q[m]=s-et(E);g[m]=(E<<O)-l}return[n+7>>3,{b:s,s:I,n:Q,t:g}]},_i=function(t,e){var r=0,n=-1,s=new Z(292),l=t[e],o=s.subarray(0,256),f=s.subarray(256,268),p=new Kt(s.buffer,268);if(l<128){var m=Et(t,e+1,6),w=m[0],k=m[1];e+=l;var x=w<<3,R=t[e];R||_(0);for(var g=0,M=0,I=k.b,Q=I,K=(++e<<3)-8+et(R);K-=I,!(K<x);){var B=K>>3;if(g+=(t[B]|t[B+1]<<8)>>(K&7)&(1<<I)-1,o[++n]=k.s[g],K-=Q,K<x)break;B=K>>3,M+=(t[B]|t[B+1]<<8)>>(K&7)&(1<<Q)-1,o[++n]=k.s[M],I=k.n[g],g=k.t[g],Q=k.n[M],M=k.t[M]}++n>255&&_(0)}else{for(n=l-127;r<n;r+=2){var q=t[++e];o[r]=q>>4,o[r+1]=q&15}++e}var V=0;for(r=0;r<n;++r){var v=o[r];v>11&&_(0),V+=v&&1<<v-1}var U=et(V)+1,X=1<<U,oe=X-V;for(oe&oe-1&&_(0),o[n++]=et(oe)+1,r=0;r<n;++r){var v=o[r];++f[o[r]=v&&U+1-v]}var W=new Z(X<<1),Y=W.subarray(0,X),ee=W.subarray(X);for(p[U]=0,r=U;r>0;--r){var T=p[r];Rt(ee,r,T,p[r-1]=T+f[r]*(1<<U-r))}for(p[0]!=X&&_(0),r=0;r<n;++r){var P=o[r];if(P){var E=p[P];Rt(Y,r,E,p[P]=E+(1<<U-P))}}return[e,{n:ee,b:U,s:Y}]},Gi=Et(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Ji=Et(new Z([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],Qi=Et(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],ni=function(t,e){for(var r=t.length,n=new Yt(r),s=0;s<r;++s)n[s]=e,e+=1<<t[s];return n},vr=new Z(new Yt([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),en=ni(vr,0),yr=new Z(new Yt([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),tn=ni(yr,3),Ct=function(t,e,r){var n=t.length,s=e.length,l=t[n-1],o=(1<<r.b)-1,f=-r.b;l||_(0);for(var p=0,m=r.b,w=(n<<3)-8+et(l)-m,k=-1;w>f&&k<s;){var x=w>>3,R=(t[x]|t[x+1]<<8|t[x+2]<<16)>>(w&7);p=(p<<m|R)&o,e[++k]=r.s[p],w-=m=r.n[p]}(w!=f||k+1!=s)&&_(0)},rn=function(t,e,r){var n=6,s=e.length,l=s+3>>2,o=l<<1,f=l+o;Ct(t.subarray(n,n+=t[0]|t[1]<<8),e.subarray(0,l),r),Ct(t.subarray(n,n+=t[2]|t[3]<<8),e.subarray(l,o),r),Ct(t.subarray(n,n+=t[4]|t[5]<<8),e.subarray(o,f),r),Ct(t.subarray(n),e.subarray(f),r)},nn=function(t,e,r){var n,s=e.b,l=t[s],o=l>>1&3;e.l=l&1;var f=l>>3|t[s+1]<<5|t[s+2]<<13,p=(s+=3)+f;if(o==1)return s>=t.length?void 0:(e.b=s+1,r?(Rt(r,t[s],e.y,e.y+=f),r):Rt(new Z(f),t[s]));if(!(p>t.length)){if(o==0)return e.b=p,r?(r.set(t.subarray(s,p),e.y),e.y+=f,r):ur(t,s,p);if(o==2){var m=t[s],w=m&3,k=m>>2&3,x=m>>4,R=0,g=0;w<2?k&1?x|=t[++s]<<4|(k&2&&t[++s]<<12):x=m>>3:(g=k,k<2?(x|=(t[++s]&63)<<4,R=t[s]>>6|t[++s]<<2):k==2?(x|=t[++s]<<4|(t[++s]&3)<<12,R=t[s]>>2|t[++s]<<6):(x|=t[++s]<<4|(t[++s]&63)<<12,R=t[s]>>6|t[++s]<<2|t[++s]<<10)),++s;var M=r?r.subarray(e.y,e.y+e.m):new Z(e.m),I=M.length-x;if(w==0)M.set(t.subarray(s,s+=x),I);else if(w==1)Rt(M,t[s++],I);else{var Q=e.h;if(w==2){var K=_i(t,s);R+=s-(s=K[0]),e.h=Q=K[1]}else Q||_(0);(g?rn:Ct)(t.subarray(s,s+=R),M.subarray(I),Q)}var B=t[s++];if(B){B==255?B=(t[s++]|t[s++]<<8)+32512:B>127&&(B=B-128<<8|t[s++]);var q=t[s++];q&3&&_(0);for(var V=[Ji,Qi,Gi],v=2;v>-1;--v){var U=q>>(v<<1)+2&3;if(U==1){var X=new Z([0,0,t[s++]]);V[v]={s:X.subarray(2,3),n:X.subarray(0,1),t:new Kt(X.buffer,0,1),b:0}}else U==2?(n=Et(t,s,9-(v&1)),s=n[0],V[v]=n[1]):U==3&&(e.t||_(0),V[v]=e.t[v])}var oe=e.t=V,W=oe[0],Y=oe[1],ee=oe[2],T=t[p-1];T||_(0);var P=(p<<3)-8+et(T)-ee.b,E=P>>3,O=0,Ie=(t[E]|t[E+1]<<8)>>(P&7)&(1<<ee.b)-1;E=(P-=Y.b)>>3;var De=(t[E]|t[E+1]<<8)>>(P&7)&(1<<Y.b)-1;E=(P-=W.b)>>3;var be=(t[E]|t[E+1]<<8)>>(P&7)&(1<<W.b)-1;for(++B;--B;){var he=ee.s[Ie],D=ee.n[Ie],de=W.s[be],qe=W.n[be],Ne=Y.s[De],Le=Y.n[De];E=(P-=Ne)>>3;var me=1<<Ne,ve=me+((t[E]|t[E+1]<<8|t[E+2]<<16|t[E+3]<<24)>>>(P&7)&me-1);E=(P-=yr[de])>>3;var Ue=tn[de]+((t[E]|t[E+1]<<8|t[E+2]<<16)>>(P&7)&(1<<yr[de])-1);E=(P-=vr[he])>>3;var L=en[he]+((t[E]|t[E+1]<<8|t[E+2]<<16)>>(P&7)&(1<<vr[he])-1);if(E=(P-=D)>>3,Ie=ee.t[Ie]+((t[E]|t[E+1]<<8)>>(P&7)&(1<<D)-1),E=(P-=qe)>>3,be=W.t[be]+((t[E]|t[E+1]<<8)>>(P&7)&(1<<qe)-1),E=(P-=Le)>>3,De=Y.t[De]+((t[E]|t[E+1]<<8)>>(P&7)&(1<<Le)-1),ve>3)e.o[2]=e.o[1],e.o[1]=e.o[0],e.o[0]=ve-=3;else{var Pe=ve-(L!=0);Pe?(ve=Pe==3?e.o[0]-1:e.o[Pe],Pe>1&&(e.o[2]=e.o[1]),e.o[1]=e.o[0],e.o[0]=ve):ve=e.o[0]}for(var v=0;v<L;++v)M[O+v]=M[I+v];O+=L,I+=L;var we=O-ve;if(we<0){var _e=-we,se=e.e+we;_e>Ue&&(_e=Ue);for(var v=0;v<_e;++v)M[O+v]=e.w[se+v];O+=_e,Ue-=_e,we=0}for(var v=0;v<Ue;++v)M[O+v]=M[we+v];O+=Ue}if(O!=I)for(;I<M.length;)M[O++]=M[I++];else O=M.length;r?e.y+=O:M=ur(M,0,O)}else if(r){if(e.y+=x,I)for(var v=0;v<x;++v)M[v]=M[I+v]}else I&&(M=ur(M,I));return e.b=p,M}_(2)}},sn=function(t,e){if(t.length==1)return t[0];for(var r=new Z(e),n=0,s=0;n<t.length;++n){var l=t[n];r.set(l,s),s+=l.length}return r};function on(t,e){for(var r=[],n=+!e,s=0,l=0;t.length;){var o=Zi(t,n||e);if(typeof o=="object"){for(n?(e=null,o.w.length==o.u&&(r.push(e=o.w),l+=o.u)):(r.push(e),o.e=0);!o.l;){var f=nn(t,o,e);f||_(5),e?o.e=o.y:(r.push(f),l+=f.length,Ki(o.w,0,f.length),o.w.set(f,o.w.length-f.length))}s=o.b+o.c*4}else s=o;t=t.subarray(s)}return sn(r,l)}const ut=30,hr=10,an=new TextEncoder,cn=new TextDecoder("utf-8",{fatal:!0});function Zt(t,e,r){let n;if(typeof t=="string"){if(t.length>Math.ceil(z.maxTileBytes/3)*4||t.length%4!==0||!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new Error("Invalid compound image");n=Uint8Array.from(atob(t),p=>p.charCodeAt(0))}else n=t;const s=[137,80,78,71,13,10,26,10];if(!(n instanceof Uint8Array)||n.length<24||n.length>z.maxTileBytes||s.some((p,m)=>n[m]!==p)||String.fromCharCode(...n.subarray(12,16))!=="IHDR")throw new Error("Invalid PNG header");const l=new DataView(n.buffer,n.byteOffset,n.byteLength),o=l.getUint32(16),f=l.getUint32(20);if(o<1||f<1||o>z.tileSize||f>z.tileSize||e!==void 0&&o!==e||r!==void 0&&f!==r)throw new Error("Invalid PNG dimensions");return n}function ln(t){return[t.cacheId,t.x,t.y,t.width,t.height].every(Number.isSafeInteger)&&t.cacheId>=1&&t.cacheId<=z.maxCacheEntries&&t.x>=0&&t.y>=0&&t.width>0&&t.height>0&&t.width<=z.tileSize&&t.height<=z.tileSize&&t.x%z.tileSize===0&&t.y%z.tileSize===0&&t.x+t.width<=z.maxDimension&&t.y+t.height<=z.maxDimension}function un(t){return t.version===1&&t.kind==="tiles"&&typeof t.epoch=="string"&&t.epoch.length>0&&an.encode(t.epoch).length<=120&&Number.isSafeInteger(t.revision)&&t.revision>=0&&Number.isSafeInteger(t.sequence)&&t.sequence>0&&Number.isInteger(t.rtpTimestamp)&&t.rtpTimestamp>=0&&t.rtpTimestamp<=4294967295&&Array.isArray(t.tiles)&&t.tiles.length>0&&t.tiles.length<=z.maxTiles}function si(t){if(t[0]===65&&t[1]===82&&t[2]===67&&t[3]===90)return si(hn(t));if(t.length<ut||t.length>z.maxMessageBytes||[65,82,67,86,1,1].some((p,m)=>t[m]!==p))throw new Error("Invalid compound binary header");const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint16(6),n=e.getUint16(28);if(!r||r>120||!n||n>z.maxTiles||ut+r+n*hr>t.length)throw new Error("Invalid compound binary lengths");const s={version:1,kind:"tiles",epoch:cn.decode(t.subarray(ut,ut+r)),revision:e.getFloat64(8),sequence:e.getFloat64(16),rtpTimestamp:e.getUint32(24),tiles:[]};let l=ut+r;const o=new Set,f=new Set;for(let p=0;p<n;p++){if(l+hr>t.length)throw new Error("Truncated compound tile");const m={cacheId:e.getUint16(l),x:e.getUint16(l+2),y:e.getUint16(l+4),width:e.getUint8(l+6),height:e.getUint8(l+7)},w=e.getUint16(l+8);l+=hr;const k=`${m.x},${m.y}`;if(!ln(m)||o.has(k)||l+w>t.length)throw new Error("Invalid compound tile bounds");if(o.add(k),w){if(f.has(m.cacheId))throw new Error("Duplicate compound cache insertion");f.add(m.cacheId),m.data=Zt(t.subarray(l,l+w),m.width,m.height),l+=w}s.tiles.push(m)}if(l!==t.length||!un(s))throw new Error("Invalid compound binary batch");return s}function hn(t){if(t.length<14||t.length>z.maxMessageBytes)throw new Error("Invalid compressed compound length");const e=new DataView(t.buffer,t.byteOffset).getUint32(4);if(e<ut||e>z.maxMessageBytes)throw new Error("Invalid compound output length");const r=t.subarray(8);if([40,181,47,253].some((k,x)=>r[x]!==k))throw new Error("Invalid Zstd magic");const n=r[4],s=(n&32)!==0,l=n>>>6;if(n&27)throw new Error("Unsupported Zstd dictionary/reserved bits");let o=5;if(!s){const k=r[o++],x=2**(10+(k>>>3));if(x+x/8*(k&7)>65536)throw new Error("Compound Zstd window too large")}const f=l===0?s?1:0:l===1?2:l===2?4:8;if(!f||o+f>r.length)throw new Error("Zstd content size required");let p=0;for(let k=0;k<f;k++)p+=r[o+k]*2**(8*k);if(f===2&&(p+=256),p!==e)throw new Error("Zstd content size differs");o+=f;let m=!1;for(;!m;){if(o+3>r.length)throw new Error("Truncated Zstd block");const k=r[o]|r[o+1]<<8|r[o+2]<<16;o+=3,m=(k&1)!==0;const x=k>>>1&3,R=k>>>3;if(x===3||R>131072)throw new Error("Invalid Zstd block");if(o+=x===1?1:R,o>r.length)throw new Error("Truncated Zstd payload")}if(n&4&&(o+=4),o!==r.length)throw new Error("Trailing compound Zstd data");const w=on(r,new Uint8Array(e));if(w.length!==e||w[3]!==86)throw new Error("Invalid decompressed compound packet");return w}function $t(t){return Number.isInteger(t)&&Number(t)>=0&&Number(t)<=4294967295}function dn(t){return Number.isSafeInteger(t)&&Number(t)>=0}async function fn(t){const e=Zt(t),r=new Blob([new Uint8Array(e).buffer],{type:"image/png"});if(typeof createImageBitmap=="function"){const s=await createImageBitmap(r);return{source:s,width:s.width,height:s.height,close:()=>s.close()}}const n=URL.createObjectURL(r);try{const s=await new Promise((l,o)=>{const f=new Image;f.onload=()=>l(f),f.onerror=()=>o(new Error("PNG decode failed")),f.src=n});return{source:s,width:s.naturalWidth,height:s.naturalHeight,close:()=>{s.src=""}}}finally{URL.revokeObjectURL(n)}}class Jr{constructor(e){this.options=e,this.channel=null,this.observedVideo=null,this.stopped=!1,this.generation=0,this.epoch=null,this.revision=-1,this.width=0,this.height=0,this.assets=new Map,this.cachePixels=0,this.barriers=new Map,this.hasPixels=!1,this.decoding=!1,this.pending=null,this.batches=[],this.decodingBytes=0,this.lastReceivedSequence=0,this.previousCanvas=null,this.presentedAt=0,this.lastSequence=0,this.decodeImage=e.decodeImage??fn}static supported(){return typeof HTMLVideoElement<"u"&&typeof HTMLVideoElement.prototype.requestVideoFrameCallback=="function"}attach(e){const r=s=>{if(s.channel.label!==z.channelLabel||this.stopped)return;if(this.channel){s.channel.close();return}this.channel=s.channel,s.channel.binaryType="arraybuffer";const l=()=>this.feedback({kind:"ready",version:1,formats:["binary-zstd-v1","binary-v1","json-v1"],features:["window-v1","scroll-v1","qoe-v1","cursor-v1"],maxTileBytes:z.maxTileBytes});s.channel.onopen=l,s.channel.onmessage=o=>this.receive(o.data),s.channel.onclose=()=>this.stop(),s.channel.readyState==="open"&&l(),this.observeVideo()},n=()=>this.observeVideo();e.addEventListener("datachannel",r),e.addEventListener("track",n),this.removePeerListener=()=>{e.removeEventListener("datachannel",r),e.removeEventListener("track",n)}}observeVideo(){const e=this.options.getVideo();if(this.stopped||!this.channel||!e||this.observedVideo===e)return;if(typeof e.requestVideoFrameCallback!="function"){this.fail();return}this.observedVideo=e;const r=(n,s)=>{this.stopped||(this.presentFrame(s.rtpTimestamp),this.stopped||(this.callback=e.requestVideoFrameCallback(r)))};this.callback=e.requestVideoFrameCallback(r)}presentFrame(e){if(!this.stopped){if(!$t(e)){this.fail();return}this.presentedRtp=e,this.presentedAt=Date.now(),this.reportPresentation(),this.renderVisibility()}}receive(e){if(!this.stopped)try{if(e instanceof ArrayBuffer||e instanceof Uint8Array){const n=si(e instanceof Uint8Array?e:new Uint8Array(e));this.receiveTiles({...n,binary:!0,wireBytes:e.byteLength,tiles:n.tiles.map(s=>({...s,key:`slot:${s.cacheId}`}))});return}if(typeof e!="string"||e.length>z.maxMessageBytes)throw new Error("Invalid compound envelope");const r=JSON.parse(e);if(!r||r.version!==1)throw new Error("Unsupported compound version");if(r.kind==="ping"&&Number.isFinite(r.t0)){const n=Date.now();this.feedback({kind:"pong",t0:r.t0,t1:n,t2:Date.now()});return}if(r.kind==="reset"){const n={epoch:r.epoch,revision:r.revision,timestamp:0,width:r.width,height:r.height};if(!Ui(n))throw new Error("Invalid compound geometry");this.clearAssets(),this.epoch=r.epoch,this.width=r.width,this.height=r.height,this.revision=r.revision,this.lastSequence=0,this.lastReceivedSequence=0,this.previousCanvas=null,this.barriers.clear();const s=this.options.getCanvas();s&&(s.width=this.width,s.height=this.height),this.clearPlacements();return}if(r.epoch!==this.epoch)return;if(r.kind==="disabled"){this.stop();return}if(!dn(r.revision))throw new Error("Invalid compound revision");if(r.kind==="invalidate"){if(r.revision>this.revision){this.saveScrollBase();const n=r.rects;if(n!==void 0&&(!Array.isArray(n)||!n.length||n.length>32||!n.every(s=>pr(s,{width:this.width,height:this.height}))))throw new Error("Invalid dirty regions");this.revision=r.revision,this.clearPlacements(n)}}else if(r.kind==="frame"){if(!$t(r.rtpTimestamp))throw new Error("Invalid presentation barrier");for(r.revision>this.revision&&(this.revision=r.revision,this.clearPlacements()),this.barriers.set(r.rtpTimestamp,r.revision);this.barriers.size>128;)this.barriers.delete(this.barriers.keys().next().value);this.renderVisibility(),this.reportPresentation()}else if(r.kind==="scroll"){const n=r.copy;if(r.revision!==this.revision)return;if(!Wi(n,{width:this.width,height:this.height})||!$t(r.rtpTimestamp)||!Number.isSafeInteger(r.sequence)||Number(r.sequence)<=this.lastReceivedSequence)throw new Error("Invalid scroll command");this.lastReceivedSequence=Number(r.sequence);const s=this.previousCanvas,l=this.options.getCanvas(),o=l==null?void 0:l.getContext("2d"),f=!!s&&s.revision===n.sourceRevision&&!!o;f&&(o.clearRect(n.x,n.y,n.width,n.height),o.drawImage(s.canvas,n.sourceX,n.sourceY,n.width,n.height,n.x,n.y,n.width,n.height),this.hasPixels=!0,this.sourceRtp=r.rtpTimestamp,this.renderVisibility()),this.previousCanvas=null,this.feedback({kind:"ack",epoch:this.epoch,sequence:r.sequence,ok:f})}else r.kind==="tiles"&&this.receiveTiles({...r,binary:!1,wireBytes:new TextEncoder().encode(e).length})}catch{this.fail()}}receiveTiles(e){if(!(e.epoch!==this.epoch||e.revision!==this.revision)){if(!$t(e.rtpTimestamp)||!Number.isSafeInteger(e.sequence)||e.sequence<=this.lastReceivedSequence||!Array.isArray(e.tiles)||!e.tiles.length||e.tiles.length>z.maxTiles)throw new Error("Invalid tile batch");if(this.lastReceivedSequence=e.sequence,this.decoding){if(this.batches.length>=3||this.decodingBytes+this.batches.reduce((r,n)=>r+(n.wireBytes??0),0)+(e.wireBytes??0)>64e3)throw new Error("Compound decode window exceeded");this.batches.push(e)}else this.applyTiles(e)}}validTile(e,r=!1){return typeof(e==null?void 0:e.key)=="string"&&(r?/^slot:[1-9][0-9]{0,3}$/.test(e.key):/^[a-f0-9]{64}$/.test(e.key))&&[e.x,e.y,e.width,e.height].every(Number.isSafeInteger)&&e.x>=0&&e.y>=0&&e.width>0&&e.height>0&&e.width<=z.tileSize&&e.height<=z.tileSize&&e.x%z.tileSize===0&&e.y%z.tileSize===0&&e.x+e.width<=this.width&&e.y+e.height<=this.height}async applyTiles(e){this.decoding=!0,this.decodingBytes=e.wireBytes??0;const r=this.generation,n=new Map;let s=!1;try{const l=this.options.getCanvas(),o=l==null?void 0:l.getContext("2d");if(!o)throw new Error("Canvas unavailable");for(const f of e.tiles){if(!this.validTile(f,e.binary))throw new Error("Invalid tile bounds");let p=this.assets.get(f.key);if(e.binary&&p&&f.data!==void 0)throw new Error("Compound cache slot already occupied");if(!p){if(typeof f.data!="string"&&!(f.data instanceof Uint8Array))throw new Error("Missing cached tile");Zt(f.data,f.width,f.height);const m=await this.decodeImage(f.data);if(this.stopped||this.generation!==r){m.close();return}if(m.width!==f.width||m.height!==f.height||this.cachePixels+f.width*f.height>z.maxCachePixels||this.assets.size>=z.maxCacheEntries)throw m.close(),new Error("Compound image cache limit exceeded");p=m,this.assets.set(f.key,p),n.set(f.key,p),this.cachePixels+=f.width*f.height}if(p.width!==f.width||p.height!==f.height)throw new Error("Cached tile dimensions differ");if(this.stopped||this.generation!==r)return;o.drawImage(p.source,f.x,f.y,f.width,f.height)}if(this.stopped||this.generation!==r)return;this.sourceRtp=this.sourceRtp===void 0||mr(e.rtpTimestamp,this.sourceRtp)?e.rtpTimestamp:this.sourceRtp,this.hasPixels=!0,this.lastSequence=e.sequence,s=!0,this.feedback({kind:"ack",epoch:this.epoch,sequence:e.sequence,ok:!0}),this.renderVisibility()}catch{!this.stopped&&this.generation===r&&(this.clearPlacements(),this.feedback({kind:"ack",epoch:this.epoch,sequence:e.sequence,ok:!1}))}finally{if(!s)for(const[o,f]of n)this.assets.get(o)===f&&(this.assets.delete(o),this.cachePixels-=f.width*f.height,f.close());this.decoding=!1,this.decodingBytes=0;const l=this.batches.shift();this.pending=null,!this.stopped&&l&&l.epoch===this.epoch&&l.revision===this.revision&&this.applyTiles(l)}}renderVisibility(){const e=this.options.getCanvas(),r=this.options.getVideo();if(!e)return;const n=this.presentedRtp,s=n!==void 0&&this.sourceRtp!==void 0&&(n===this.sourceRtp||mr(n,this.sourceRtp))&&this.barriers.get(n)===this.revision;e.style.visibility=!this.stopped&&this.hasPixels&&s&&(r==null?void 0:r.videoWidth)===this.width&&r.videoHeight===this.height?"visible":"hidden"}feedback(e){var r;if(((r=this.channel)==null?void 0:r.readyState)==="open"&&this.channel.bufferedAmount<4096)try{this.channel.send(JSON.stringify(e))}catch{}}reportPresentation(){this.presentedRtp===void 0||this.reportedRtp===this.presentedRtp||this.barriers.get(this.presentedRtp)!==this.revision||(this.reportedRtp=this.presentedRtp,this.feedback({kind:"presented",epoch:this.epoch,rtpTimestamp:this.presentedRtp,presentedAt:this.presentedAt}))}saveScrollBase(){var n,s,l;const e=this.options.getCanvas();if(!e)return;const r=((s=(n=this.options).createCanvas)==null?void 0:s.call(n))??(typeof document<"u"?document.createElement("canvas"):null);r&&(r.width=this.width,r.height=this.height,(l=r.getContext("2d"))==null||l.drawImage(e,0,0),this.previousCanvas={canvas:r,revision:this.revision})}clearPlacements(e){this.generation+=1,this.pending=null,this.batches=[],e||(this.hasPixels=!1,this.sourceRtp=void 0);const r=this.options.getCanvas(),n=r==null?void 0:r.getContext("2d");if(e)for(const s of e)n==null||n.clearRect(s.x,s.y,s.width,s.height);else r&&(n==null||n.clearRect(0,0,r.width,r.height));r&&(r.style.visibility="hidden")}clearAssets(){for(const e of this.assets.values())e.close();this.assets.clear(),this.cachePixels=0}fail(){this.feedback({kind:"unsupported",version:1}),this.stop()}stop(){var e,r,n;this.stopped||(this.stopped=!0,this.clearPlacements(),this.clearAssets(),this.barriers.clear(),this.previousCanvas=null,this.callback!==void 0&&((e=this.observedVideo)==null||e.cancelVideoFrameCallback(this.callback)),(r=this.removePeerListener)==null||r.call(this),(n=this.channel)==null||n.close(),this.channel=null)}}class pn{constructor(e){this.options=e,this.stopped=!1,this.receivedAt=-1/0}attach(e){const r=s=>{if(!(s.channel.label!=="agentroam.cursor.v1"||this.stopped)){if(this.channel){s.channel.close();return}this.channel=s.channel,s.channel.onmessage=l=>this.receive(l.data),s.channel.onclose=()=>{this.state=void 0,this.hide()},this.observe()}},n=()=>this.observe();e.addEventListener("datachannel",r),e.addEventListener("track",n),this.remove=()=>{e.removeEventListener("datachannel",r),e.removeEventListener("track",n)}}observe(){const e=this.options.getVideo();if(!e||this.video===e||!this.channel||typeof e.requestVideoFrameCallback!="function")return;this.video=e;const r=(n,s)=>{this.stopped||(this.rtp=s.rtpTimestamp,this.render(),this.frameCallback=e.requestVideoFrameCallback(r))};this.frameCallback=e.requestVideoFrameCallback(r)}receive(e){var r;if(!(this.stopped||typeof e!="string"||e.length>12e3))try{const n=JSON.parse(e);if(![n.sequence,n.cutoverRtp].every(Number.isSafeInteger)||n.cutoverRtp<0||n.cutoverRtp>4294967295||![n.x,n.y].every(s=>Number.isFinite(s)&&s>=0&&s<=1)||typeof n.active!="boolean"||typeof n.visible!="boolean"||this.state&&n.sequence<=this.state.sequence)return;if(n.shape&&n.shape!==((r=this.state)==null?void 0:r.shape)&&(this.image=void 0,this.imageData=void 0),this.state={...this.state,...n},this.receivedAt=Date.now(),typeof n.image=="string"&&n.image!==this.imageData&&n.image.length<=8192&&/^[A-Za-z0-9+/]+={0,2}$/.test(n.image)){Zt(n.image),this.imageData=n.image;const s=new Image;s.onload=()=>{!this.stopped&&this.imageData===n.image&&s.naturalWidth<=64&&s.naturalHeight<=64&&(this.image=s,this.render())},s.src=`data:image/png;base64,${n.image}`}this.observe(),this.render()}catch{}}localPoint(e){typeof e.x!="number"||typeof e.y!="number"||!Number.isFinite(e.x)||!Number.isFinite(e.y)||(this.local={x:Math.max(0,Math.min(1,e.x)),y:Math.max(0,Math.min(1,e.y)),at:Date.now()},this.render())}render(){var m;const e=this.state,r=this.options.getVideo(),n=this.options.getCanvas();if(!n)return;if(!(e!=null&&e.active)||!e.visible||this.stopped||Date.now()-this.receivedAt>2e3||!(r!=null&&r.videoWidth)||r.videoWidth>4096||r.videoHeight>4096||r.videoWidth*r.videoHeight>8388608||this.rtp===void 0||this.activatedCutover!==e.cutoverRtp&&this.rtp!==e.cutoverRtp&&!mr(this.rtp,e.cutoverRtp)){this.hide();return}this.activatedCutover=e.cutoverRtp,n.width!==r.videoWidth&&(n.width=r.videoWidth),n.height!==r.videoHeight&&(n.height=r.videoHeight);const s=n.getContext("2d");if(!s)return;s.clearRect(0,0,n.width,n.height);const l=this.local&&Date.now()-this.local.at<150?this.local:e,o=l.x*n.width,f=l.y*n.height,p=(w,k,x)=>typeof w=="number"&&Number.isFinite(w)?Math.max(0,Math.min(x,w)):k;if(this.image)s.drawImage(this.image,o-p(e.hotX,0,128),f-p(e.hotY,0,128),p(e.drawWidth,this.image.naturalWidth,128),p(e.drawHeight,this.image.naturalHeight,128));else{s.save(),s.translate(o,f);const w=p(e.pixelScale,1,4);s.scale(w,w),s.lineWidth=2,s.strokeStyle="white",s.fillStyle="black",s.beginPath(),e.shape==="text"?(s.moveTo(0,-8),s.lineTo(0,8),s.moveTo(-4,-8),s.lineTo(4,-8),s.moveTo(-4,8),s.lineTo(4,8)):(s.moveTo(0,0),s.lineTo(0,20),s.lineTo(5,15),s.lineTo(9,23),s.lineTo(13,21),s.lineTo(9,13),s.lineTo(17,13),s.closePath(),s.fill()),s.stroke(),s.restore()}n.style.visibility="visible",(m=n.parentElement)==null||m.classList.add("has-independent-cursor")}hide(){var r;const e=this.options.getCanvas();e&&(e.style.visibility="hidden",(r=e.parentElement)==null||r.classList.remove("has-independent-cursor"))}stop(){var e,r,n;this.stopped=!0,this.hide(),(e=this.remove)==null||e.call(this),(r=this.channel)==null||r.close(),this.frameCallback!==void 0&&((n=this.video)==null||n.cancelVideoFrameCallback(this.frameCallback)),this.image&&(this.image.src="")}}function Qr(t,e){return t.kind==="pointer"&&t.action==="move"&&t.probe!==!0&&!e&&[t.x,t.y].every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0&&r<=1)}const dr=()=>Object.assign(new Error("输入会话已切换"),{code:"ECANCELED"});class mn{constructor(e,r=1,n=()=>{}){this.stream=e,this.version=r,this.onError=n,this.sequence=0,this.barrier=0,this.index=0,this.pressed=!1,this.stopped=!1,this.visible=!0,this.pending=new Map,this.queue=[]}attach(e){if(!this.stream||this.stream.length<16||this.stream.length>64)return;const r=n=>{const s=n.channel;if(!this.stopped){if(s.label==="agentroam.input.v1"){if(this.channel){s.close();return}this.channel=s,s.onclose=()=>{this.channel===s&&(this.channel=void 0)}}else if(s.label==="agentroam.input.reliable.v1"&&this.version===2){if(this.reliable){s.close();return}this.reliable=s,s.onmessage=l=>this.receipt(l.data),s.onclose=()=>{if(this.reliable===s&&(this.reliable=void 0),!this.stopped)for(const l of this.pending.values())this.fallback(l)}}}};e.addEventListener("datachannel",r),this.remove=()=>e.removeEventListener("datachannel",r)}prepare(e){var s;if(this.cancelCheckpoint(),this.stopped||!this.stream)return{fast:!1,input:e};const r=++this.sequence;if(Qr(e,this.pressed)&&this.visible&&((s=this.channel)==null?void 0:s.readyState)==="open"&&this.channel.bufferedAmount<16e3)try{return this.channel.send(JSON.stringify({kind:"move",stream:this.stream,sequence:r,barrier:this.barrier,x:e.x,y:e.y,mobile:e.mobile===!0})),{fast:!0,input:e}}catch{}return this.noteReliable(e,r),{fast:!1,input:{...e,direct:{stream:this.stream,sequence:r}}}}dispatch(e,r){var n;if(this.stopped)return Promise.reject(dr());if(this.version!==2||!this.stream){const s=this.prepare(e);return s.fast?(this.scheduleCheckpoint(e,r),Promise.resolve(null)):r(s.input)}if(this.cancelCheckpoint(),Qr(e,this.pressed)&&this.visible&&((n=this.channel)==null?void 0:n.readyState)==="open"&&this.channel.bufferedAmount<16e3){const s=++this.sequence;try{return this.channel.send(JSON.stringify({kind:"move",stream:this.stream,sequence:s,barrier:this.barrier,x:e.x,y:e.y,mobile:e.mobile===!0})),this.scheduleCheckpoint(e,r),Promise.resolve(null)}catch{}}return this.enqueue(e,r)}enqueue(e,r){if(this.stopped)return Promise.reject(dr());if(this.pending.size>=16&&this.queue.length>=64)return Promise.reject(Object.assign(new Error("输入队列繁忙,请稍后重试"),{code:"EBUSY"}));const n=++this.sequence,s=++this.index;return this.noteReliable(e,n),new Promise((l,o)=>{this.queue.push({index:s,sequence:n,input:{...e,direct:{stream:this.stream,sequence:n,index:s}},fallback:r,resolve:l,reject:o}),this.pump()})}pump(){var e;for(;!this.stopped&&this.pending.size<16&&this.queue.length;){const r=this.queue.shift();this.pending.set(r.index,r);const n=JSON.stringify({kind:"request",stream:this.stream,index:r.index,sequence:r.sequence,input:r.input});if(((e=this.reliable)==null?void 0:e.readyState)==="open"&&new TextEncoder().encode(n).length<=12288&&this.reliable.bufferedAmount<64e3)try{r.timer=setTimeout(()=>this.fallback(r),750),this.reliable.send(n);continue}catch{}this.fallback(r)}}fallback(e){this.stopped||e.fallingBack||this.pending.get(e.index)!==e||(e.fallingBack=!0,clearTimeout(e.timer),Promise.resolve().then(()=>e.fallback(e.input)).then(r=>this.settle(e,r),r=>this.settle(e,null,r instanceof Error?r:new Error(String(r)))))}receipt(e){if(!(typeof e!="string"||e.length>32768))try{const r=JSON.parse(e),n=this.pending.get(r.index);if(!n||r.kind!=="result"||r.stream!==this.stream||r.sequence!==n.sequence)return;r.ok===!0?this.settle(n,{input:r.result}):r.ok===!1&&this.settle(n,null,Object.assign(new Error(String(r.error||"输入失败")),{code:r.code}))}catch{}}settle(e,r,n){this.pending.get(e.index)===e&&(clearTimeout(e.timer),this.pending.delete(e.index),n?(e.reject(n),this.stop()):(e.resolve(r),this.pump()))}noteReliable(e,r){e.kind==="pointer"&&e.action==="down"&&(this.pressed=!0),e.kind==="pointer"&&e.action==="up"&&(this.pressed=!1),this.barrier=r}scheduleCheckpoint(e,r){this.checkpoint=setTimeout(()=>{if(this.checkpoint=void 0,this.stopped||!this.visible||this.pressed)return;const n=this.version===2?0:++this.sequence;this.version!==2&&this.noteReliable(e,n),(this.version===2?this.enqueue(e,r):r({...e,direct:{stream:this.stream,sequence:n}})).then(l=>{var f;const o=(f=l==null?void 0:l.input)==null?void 0:f.error;o&&this.onError(new Error(o))}).catch(l=>{(l==null?void 0:l.code)!=="ECANCELED"&&this.onError(l)})},40)}cancelCheckpoint(){clearTimeout(this.checkpoint),this.checkpoint=void 0}setVisible(e){this.visible=e,e||this.cancelCheckpoint()}stop(){var e,r,n;this.stopped=!0,this.cancelCheckpoint(),(e=this.remove)==null||e.call(this);for(const s of[...this.pending.values(),...this.queue])clearTimeout(s.timer),s.reject(dr());this.pending.clear(),this.queue=[],(r=this.channel)==null||r.close(),this.channel=void 0,(n=this.reliable)==null||n.close(),this.reliable=void 0}}class vn{constructor(){this.targetMs=40,this.sequence=-1,this.observedAt=-1/0,this.healthy=0}observe(e,r,n){if(!e||!e.visible||!Number.isSafeInteger(e.sequence)||e.sequence<=this.sequence||!Number.isFinite(n)||(e.intervalMs??0)<250||(e.intervalMs??1/0)>5e3||(e.decodedFrames??0)<3||!Number.isFinite(e.jitterBufferMs)||(this.sequence=e.sequence,n-this.observedAt<750))return;this.observedAt=n;const s=Math.max(20,Math.min(150,(Number.isFinite(r)?Math.max(0,r)*2:10)+20));return s>this.targetMs?(this.targetMs=Math.min(150,Math.max(s,this.targetMs+10)),this.healthy=0):(e.decodeMs??0)<25&&(e.droppedRatio??0)<.02?++this.healthy>=3&&(this.targetMs=Math.max(s,this.targetMs-10),this.healthy=0):this.healthy=0,Math.round(this.targetMs)}}class yn{constructor(e){this.peer=e,this.policy=new vn,this.applied=new Map,this.unsupported=new WeakSet}apply(e,r){var f;if(!((f=e.receiver)!=null&&f.visible))return this.restore(),{playoutControl:!1};const n=this.policy.observe(e.receiver,e.jitterMs,r),s=this.peer.getReceivers().find(p=>{var m;return((m=p.track)==null?void 0:m.kind)==="video"});if(!s||this.unsupported.has(s))return{playoutControl:!1};const l="jitterBufferTarget"in s?"jitterBufferTarget":"playoutDelayHint"in s?"playoutDelayHint":void 0;if(!l)return{playoutControl:!1};if(n!==void 0){const p=l==="jitterBufferTarget"?n:n/1e3,m=this.applied.has(s)?this.applied.get(s).original:s[l];try{if(s[l]=p,!Number.isFinite(s[l])||Math.abs(s[l]-p)>.001)throw new Error("Receiver ignored playout target");this.applied.set(s,{key:l,original:m,value:p})}catch{return this.unsupported.add(s),this.restoreReceiver(s),{playoutControl:!1}}}const o=this.applied.get(s);return o?{playoutControl:!0,playoutTargetMs:o.value*(o.key==="jitterBufferTarget"?1:1e3)}:{playoutControl:!1}}restoreReceiver(e){const r=this.applied.get(e);if(r){try{e[r.key]===r.value&&(r.key==="jitterBufferTarget"?e.jitterBufferTarget=r.original:e.playoutDelayHint=r.original)}catch{}this.applied.delete(e)}}restore(){for(const e of this.applied.keys())this.restoreReceiver(e)}stop(){this.restore()}}class gn{constructor(e,r){this.peer=e,this.attemptId=r,this.pending=[],this.ready=!1,this.stopped=!1,this.credentials=[]}accepts(e){return!this.stopped&&(e===void 0||e===this.attemptId)}async answer(e){if(await this.peer.setRemoteDescription(e),this.stopped)return null;this.credentials=[...(e.sdp??"").matchAll(/^a=ice-ufrag:([^\r\n]+)$/gm)].map(s=>s[1].trim()),this.ready=!0;const r=this.pending;this.pending=[];for(const s of r)await this.addIceCandidate(s);if(this.stopped)return null;const n=await this.peer.createAnswer();return this.stopped?null:(await this.peer.setLocalDescription(n),this.stopped?null:this.peer.localDescription)}async addIceCandidate(e,r){if(this.accepts(r)){if(!this.ready){this.pending.length<64&&this.pending.push(e);return}e.usernameFragment&&!this.credentials.includes(e.usernameFragment)||await this.peer.addIceCandidate(e)}}stop(){this.stopped=!0,this.pending=[]}}var Xt,oi;class bn{constructor(){Wr(this,Xt);this.points=new Map,this.origin=null,this.originDistance=0,this.moved=!1}reset(){this.points.clear(),this.origin=null,this.originDistance=0,this.moved=!1}down(e,r){this.points.size||(this.origin=r,this.moved=!1),this.points.set(e,r),this.points.size>1&&(this.moved=!0),this.originDistance=Hr(this,Xt,oi).call(this)}move(e,r){const n=this.points.get(e);if(!n)return null;const s=[...this.points.values()];if(this.points.set(e,r),this.origin&&Math.hypot(r.x-this.origin.x,r.y-this.origin.y)>8&&(this.moved=!0),this.points.size===1)return this.moved?{scale:1,distanceRatio:1,from:n,to:r,pointers:1}:null;const l=[...this.points.values()],o=w=>({x:(w[0].x+w[1].x)/2,y:(w[0].y+w[1].y)/2}),f=w=>Math.hypot(w[0].x-w[1].x,w[0].y-w[1].y),p=f(s),m=this.originDistance>0?f(l)/this.originDistance:1;return{scale:p>0?f(l)/p:1,distanceRatio:m,from:o(s),to:o(l),pointers:this.points.size}}up(e,r,n=!1){if(!this.points.has(e))return!1;const s=!n&&!this.moved&&this.points.size===1&&!!this.origin&&Math.hypot(r.x-this.origin.x,r.y-this.origin.y)<=8;return this.points.delete(e),n&&(this.moved=!0),this.points.size||this.reset(),s}}Xt=new WeakSet,oi=function(){const e=[...this.points.values()];return e.length>=2?Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y):0};function wn(t,e,r){const n=Math.max(t.top,e.top-r.top),s=Math.max(t.left,e.left-r.left),l=Math.min(t.top+t.height,e.top+e.height-r.top),o=Math.min(t.left+t.width,e.left+e.width-r.left);return{top:n,left:s,height:Math.max(0,l-n),width:Math.max(0,o-s)}}function ei(t){const e=t.visualViewport;return{top:(e==null?void 0:e.offsetTop)??0,left:(e==null?void 0:e.offsetLeft)??0,width:(e==null?void 0:e.width)??t.innerWidth,height:(e==null?void 0:e.height)??t.innerHeight}}function kn(t,e=window,r=!1){let n=null,s=null;try{e.parent!==e&&e.parent.location.origin===e.location.origin&&(n=e.parent,s=e.frameElement)}catch{}let l=null,o=null;const f=()=>{let x=ei(e);if(n&&s&&!e.document.fullscreenElement){const R={top:0,left:0,width:e.innerWidth,height:e.innerHeight};x=r?R:wn(R,ei(n),s.getBoundingClientRect())}for(const[R,g]of Object.entries(x))t.style.setProperty(`--browser-live-${R}`,`${g}px`)},p=()=>{l!==null&&e.cancelAnimationFrame(l),l=e.requestAnimationFrame(()=>{l=null,f()}),o!==null&&e.clearTimeout(o),o=e.setTimeout(f,250)},m=[e,e.document];e.visualViewport&&m.push(e.visualViewport),n&&(m.push(n),m.push(n.document),n.visualViewport&&m.push(n.visualViewport));const w=["resize","scroll","orientationchange","pageshow","visibilitychange","fullscreenchange","transitionend"];for(const x of m)for(const R of w)x.addEventListener(R,p);const k=s&&typeof ResizeObserver<"u"?new ResizeObserver(p):null;return s&&(k==null||k.observe(s)),f(),()=>{for(const x of m)for(const R of w)x.removeEventListener(R,p);l!==null&&e.cancelAnimationFrame(l),o!==null&&e.clearTimeout(o),k==null||k.disconnect();for(const x of["top","left","width","height"])t.style.removeProperty(`--browser-live-${x}`)}}const J=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0;function xn(t,e){var r;try{const n=(r=t==null?void 0:t.getVideoPlaybackQuality)==null?void 0:r.call(t);if(n&&Number.isFinite(n.totalVideoFrames)&&Number.isFinite(n.droppedVideoFrames))return Math.max(0,n.totalVideoFrames-n.droppedVideoFrames)}catch{}return J(t==null?void 0:t.webkitDecodedFrameCount)??J(e)}function Cn(t){var r,n,s;const e=new Set;for(const l of t??[]){if(((r=l.mimeType)==null?void 0:r.toLowerCase())!=="video/h264")continue;const o=(s=(n=/(?:^|;)\s*profile-level-id=([0-9a-f]{6})/i.exec(l.sdpFmtpLine??""))==null?void 0:n[1])==null?void 0:s.toLowerCase();o!=null&&o.startsWith("64")&&e.add("high"),(!o||o.startsWith("42"))&&e.add("baseline")}return[...e]}function Rn(){var e;if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities!="function")return["baseline"];const t=Cn((e=RTCRtpReceiver.getCapabilities("video"))==null?void 0:e.codecs);return t.length?t:["baseline"]}function En(t){var r,n;const e=(n=(r=/(?:^|;)\s*profile-level-id=([0-9a-f]{6})/i.exec(typeof t=="string"?t:""))==null?void 0:r[1])==null?void 0:n.toLowerCase();if(e!=null&&e.startsWith("64"))return"high";if(!e||e.startsWith("42"))return"baseline"}function jn(t,e,r=Date.now(),n){const l=[...typeof t.values=="function"?t.values():t],o=l.find(D=>D.type==="inbound-rtp"&&(D.kind==="video"||D.mediaType==="video"));if(!o)return null;const f=l.find(D=>D.id===o.codecId),p=l.find(D=>D.type==="candidate-pair"&&D.state==="succeeded"&&(D.nominated===!0||D.selected===!0)),m=l.find(D=>D.id===(p==null?void 0:p.localCandidateId)),w=l.find(D=>D.id===(p==null?void 0:p.remoteCandidateId)),k=[m==null?void 0:m.candidateType,w==null?void 0:w.candidateType].map(String),x=["relay","srflx","prflx","host"].find(D=>k.includes(D))??void 0,R=J(o.bytesReceived)??0,g=J(o.packetsReceived)??0,M=J(o.packetsLost)??0,I=J(o.framesDropped)??0,Q=e?Math.max(1,r-e.at):0,K=e?Math.max(0,g-e.packetsReceived):0,B=e?Math.max(0,M-e.packetsLost):0,q=e?Math.max(0,I-e.framesDropped):0,V=J(p==null?void 0:p.currentRoundTripTime),v=J(o.jitter),U=typeof o.decoderImplementation=="string"?o.decoderImplementation.slice(0,120):void 0,X=typeof o.powerEfficientDecoder=="boolean"?o.powerEfficientDecoder:void 0,oe=U!==void 0||X!==void 0?{implementation:U,powerEfficient:X,acceleration:X===!0?"hardware":X===!1?"software":"unknown"}:void 0,W=J(o.framesDecoded),Y=J(o.totalDecodeTime),ee=e!==null&&W!==void 0&&e.framesDecoded!==void 0&&W>=e.framesDecoded&&I>=e.framesDropped&&r>e.at&&r-e.at<=5e3,T=ee?W-e.framesDecoded:void 0,P=ee&&T>0&&Y!==void 0&&(e==null?void 0:e.totalDecodeTime)!==void 0&&Y>=e.totalDecodeTime?(Y-e.totalDecodeTime)*1e3/T:void 0,E=((e==null?void 0:e.sequence)??0)+1,O=J(o.jitterBufferEmittedCount),Ie=e&&O!==void 0&&e.jitterBufferEmittedCount!==void 0&&r>e.at&&r-e.at<=5e3?O-e.jitterBufferEmittedCount:0,De=D=>{const de=J(o[D]),qe=e==null?void 0:e[D];if(Ie<=0||de===void 0||qe===void 0||de<qe)return;const Ne=(de-qe)*1e3/Ie;return Number.isFinite(Ne)&&Ne>=0&&Ne<=6e4?Ne:void 0},be={jitterBufferMs:De("jitterBufferDelay"),jitterBufferTargetMs:De("jitterBufferTargetDelay"),jitterBufferMinimumMs:De("jitterBufferMinimumDelay")},he={...n?{receiver:{sequence:E,visible:n.visible,viewport:n.viewport,width:J(o.frameWidth),height:J(o.frameHeight),...Object.fromEntries(Object.entries(be).filter(([,D])=>D!==void 0)),...ee?{intervalMs:r-e.at,decodedFrames:T,...P!==void 0?{decodeMs:P}:{},...T+q>0?{droppedRatio:q/(T+q)}:{},...Number.isFinite(n.presentationDelayMs)?{presentationDelayMs:n.presentationDelayMs}:{}}:{}}}:{},codec:typeof(f==null?void 0:f.mimeType)=="string"?f.mimeType.replace(/^video\//i,""):void 0,codecProfile:En(f==null?void 0:f.sdpFmtpLine),decoder:oe,width:J(o.frameWidth),height:J(o.frameHeight),fps:J(o.framesPerSecond),rttMs:V!==void 0?V*1e3:void 0,jitterMs:v!==void 0?v*1e3:void 0,lossRate:K+B>0?B/(K+B):0,droppedFrames:q,receiveBitrate:e?Math.max(0,Math.round((R-e.bytesReceived)*8e3/Q)):void 0,availableBitrate:J(p==null?void 0:p.availableIncomingBitrate),candidateType:x,protocol:(m==null?void 0:m.protocol)==="tcp"||(w==null?void 0:w.protocol)==="tcp"?"tcp":p?"udp":void 0};for(const D of Object.keys(he))he[D]===void 0&&delete he[D];return{sample:he,cursor:{at:r,bytesReceived:R,packetsReceived:g,packetsLost:M,framesDropped:I,sequence:E,...Y!==void 0?{totalDecodeTime:Y}:{},...W!==void 0?{framesDecoded:W}:{},...Object.fromEntries(["jitterBufferDelay","jitterBufferTargetDelay","jitterBufferMinimumDelay","jitterBufferEmittedCount"].map(D=>[D,J(o[D])]).filter(([,D])=>D!==void 0))}}}function Mn(t){if(!t)return null;const e=[t.candidateType==="relay"?"TURN 中继":t.candidateType?"P2P 直连":null];return t.codec&&e.push(t.codec),t.width&&t.height&&e.push(`${t.width}x${t.height}${t.fps?`@${Math.round(t.fps)}`:""}`),t.receiveBitrate&&e.push(`${(t.receiveBitrate/1e6).toFixed(1)}Mbps`),t.rttMs!==void 0&&e.push(`${Math.round(t.rttMs)}ms`),e.filter(Boolean).join(" · ")||null}function Sn(t){const e=t==null?void 0:t.decoder;if(!e)return null;const r=e.acceleration==="hardware"?"硬件解码":e.acceleration==="software"?"软件解码":"解码方式未知";return e.implementation?`${r} · ${e.implementation}`:r}const Tn={"agent-controlled":"Agent 操作中","handoff-requested":"正在交接","user-controlled":"你正在操作","return-requested":"正在归还",resyncing:"Agent 正在同步页面"},In={smooth:"流畅",hd:"高清",original:"原画"};function fr(t){return t==="desktop"?"桌面屏幕":t==="ego-browser"?"ego-browser":"内置 Browser"}function ti(t,e,r){var n,s;return t||(((n=e.find(l=>l.agentSessionId===r))==null?void 0:n.id)??((s=e[0])==null?void 0:s.id)??null)}function Dn(t){return!!(t&&t.availability==="ready"&&!t.isController&&!t.controlledByAnotherViewer&&(t.state==="agent-controlled"||t.state==="handoff-requested"))}function ri(t){return(t==null?void 0:t.backend)==="desktop"&&t.platform==="darwin"?"Meta":"Control"}function ii(t){return[t.altKey?"Alt":"",t.ctrlKey?"Control":"",t.metaKey?"Meta":"",t.shiftKey?"Shift":""].filter(Boolean)}function Nn(t){const e=new Uint8Array(t.length*2),r=new DataView(e.buffer);for(let s=0;s<t.length;s+=1){const l=Math.max(-1,Math.min(1,t[s]));r.setInt16(s*2,l<0?l*32768:l*32767,!0)}let n="";for(let s=0;s<e.length;s+=8192)n+=String.fromCharCode(...e.subarray(s,s+8192));return btoa(n)}function Pn(t,e){const r=atob(t),n=Math.floor(r.length/2/e),s=Array.from({length:e},()=>new Float32Array(n));for(let l=0;l<n;l+=1)for(let o=0;o<e;o+=1){const f=(l*e+o)*2,p=r.charCodeAt(f)|r.charCodeAt(f+1)<<8;s[o][l]=(p&32768?p-65536:p)/32768}return s}async function An(t){const e=[],r=()=>{for(const s of e.splice(0))s()};let n=!1;t.addEventListener("abort",r);try{if(t.aborted)return null;const s=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1});if(e.push(()=>{for(const x of s.getTracks())x.stop()}),t.aborted)return null;const l=window.AudioContext,o=new l({latencyHint:"interactive"});e.push(()=>{o.close().catch(()=>{})});const f=new l({latencyHint:"interactive"});if(e.push(()=>{f.close().catch(()=>{})}),await Promise.all([o.resume(),f.resume()]),t.aborted)return null;const p=f.createGain();p.connect(f.destination);const m=o.createMediaStreamSource(s),w=o.createScriptProcessor(2048,1,1),k=o.createGain();return k.gain.value=0,m.connect(w),w.connect(k),k.connect(o.destination),n=!0,{stream:s,microphoneContext:o,remoteContext:f,remoteGain:p,source:m,processor:w,sink:k,dispose:r}}finally{t.removeEventListener("abort",r),n||r()}}function qn(t,e){return t?t.state==="user-controlled"&&t.isController===!0&&e.state==="handoff-requested"||t.state==="agent-controlled"&&e.state==="return-requested":!1}const Ln=2;function zn(t,e,r,n,s=.02){if(!t||!e||!e.width||!e.height)return!1;const l=t.x/e.width-s,o=t.y/e.height-s,f=(t.x+t.w)/e.width+s,p=(t.y+t.h)/e.height+s;return r>=l&&r<=f&&n>=o&&n<=p}function Fn(t,e,r=Ln){const n={deltaX:Math.round(t.x-e.x),deltaY:Math.round(t.y-e.y)};return Math.abs(n.deltaX)<r&&Math.abs(n.deltaY)<r?null:n}function Yn({open:t,active:e=!0,agentSessionId:r,onClose:n,onFullscreenChange:s}){const l=h.useContext(Ci),o=typeof window>"u"?void 0:window.browserLiveApi,f=h.useRef(null),p=h.useRef(null);h.useLayoutEffect(()=>{if(!(!t||!f.current))return kn(f.current,window,document.body.dataset.remoteDesktop==="1")},[t]);const[m,w]=h.useState(!1);h.useEffect(()=>{s==null||s(m)},[m,s]);const k=async()=>{const i=p.current;if(i){if(m){document.fullscreenElement===i&&await document.exitFullscreen().catch(()=>{}),w(!1);return}w(!0),i.requestFullscreen&&await i.requestFullscreen().catch(()=>{})}};h.useEffect(()=>{if(!t){w(!1);return}const i=p.current,c=()=>w(document.fullscreenElement===i),a=y=>{y.key==="Escape"&&(document.fullscreenElement===i||i!=null&&i.classList.contains("is-fullscreen"))&&(y.preventDefault(),y.stopPropagation(),document.fullscreenElement===i&&document.exitFullscreen().catch(()=>{}),w(!1))};return document.addEventListener("fullscreenchange",c),document.addEventListener("keydown",a,!0),()=>{document.removeEventListener("fullscreenchange",c),document.removeEventListener("keydown",a,!0),i&&document.fullscreenElement===i&&document.exitFullscreen().catch(()=>{})}},[t]);const[x,R]=h.useState([]),[g,M]=h.useState(null),[I,Q]=h.useState(null),[K,B]=h.useState("hd"),[q,V]=h.useState(null),[v,U]=h.useState(null),[X,oe]=h.useState(!1),[W,Y]=h.useState(0),[ee,T]=h.useState(null),[P,E]=h.useState(!1),[O,Ie]=h.useState(null),[De,be]=h.useState(!1),[he,D]=h.useState(""),[de,qe]=h.useState(!1),[Ne,Le]=h.useState(null),[me,ve]=h.useState(1),Ue=h.useRef(me);Ue.current=me;const[L,Pe]=h.useState(!1),[we,_e]=h.useState({width:0,height:0}),se=h.useRef(null),tt=h.useRef(null),jt=h.useRef(!1),We=h.useRef(null),He=h.useRef(new bn),ht=h.useRef(me),Mt=h.useRef(null);h.useLayoutEffect(()=>{ht.current=me;const i=Mt.current,c=se.current,a=c==null?void 0:c.querySelector(".browser-live-image-hit-area");if(!i||!c||!a)return;const y=a.getBoundingClientRect();c.scrollLeft+=y.left+i.x*y.width-i.clientX,c.scrollTop+=y.top+i.y*y.height-i.clientY,Mt.current=null},[me]);const $e=h.useRef(null),[Re,St]=h.useState(!1),rt=h.useRef(!1),Tt=h.useRef(0),Ke=h.useRef(null);h.useEffect(()=>{t||(be(!1),D(""),Le(null))},[t]);const[ai,dt]=h.useState(!1),ft=h.useRef(null),It=h.useRef(0),Ee=h.useRef("none"),ae=h.useRef(null),_t=h.useRef(null),[gr,Dt]=h.useState(null),[pt,ci]=h.useState(!1),br=h.useRef(null),[ze,je]=h.useState("off"),[wr,mt]=h.useState(null),Ge=h.useRef(null),te=h.useRef(null),re=h.useRef(null),Nt=h.useRef(0),Fe=h.useRef(null),kr=h.useRef(null),xr=h.useRef(null),Xe=h.useRef(null),fe=h.useRef(null),ye=h.useRef(null),it=h.useRef(null),Je=h.useRef(new Oi),vt=h.useRef(!1),[Cr,Pt]=h.useState(null),[Ve,yt]=h.useState("idle"),[At,Rr]=h.useState(!1),[qt,Er]=h.useState(!1),Lt=h.useRef(!1),zt=h.useRef(!1),gt=h.useRef(null),Gt=h.useRef(null),Jt=h.useRef(null),Qt=h.useRef(null),er=h.useRef(null),Ft=h.useRef(null),nt=h.useRef(null),st=h.useRef(0),jr=h.useRef(0),bt=h.useRef(0),Vt=h.useRef(null);h.useLayoutEffect(()=>{rt.current=Re,Re&&dt(!1)},[Re]);const d=h.useMemo(()=>x.find(i=>i.id===g)??null,[g,x]),F=(d==null?void 0:d.backend)==="desktop",Mr=F&&(d==null?void 0:d.platform)==="win32",li=(d==null?void 0:d.availability)==="unavailable"&&(d==null?void 0:d.capabilityErrorCode)==="desktop-locked",N=(d==null?void 0:d.isController)&&d.state==="user-controlled",ot=d==null?void 0:d.audioCapabilities,at=!!(ot!=null&&ot.fullDuplex&&ot.systemAudio&&ot.microphonePlayback&&ot.selfPlaybackExclusion),Qe=!!(d!=null&&d.online&&d.availability==="ready"&&!d.controlledByAnotherViewer),tr=Dn(d),wt=P||(d==null?void 0:d.state)==="handoff-requested";h.useEffect(()=>{if(!t||!o||!g){Dt(null);return}let i=!0;const c=()=>{const y=performance.now();o.request("browser:ping",{t:y}).then(()=>{i&&Dt(Math.round(performance.now()-y))}).catch(()=>{i&&Dt(null)})};c();const a=window.setInterval(c,3e3);return()=>{i=!1,window.clearInterval(a),Dt(null)}},[o,t,g]),h.useEffect(()=>{const i=navigator;if(!N||!i.wakeLock)return;let c=!1,a=null;return i.wakeLock.request("screen").then(y=>{if(c){y.release();return}a=y,br.current=y}).catch(()=>{}),()=>{c=!0,a==null||a.release().catch(()=>{}),br.current=null}},[N]);const ct=(v==null?void 0:v.viewport)??(d==null?void 0:d.viewport),rr=ct&&we.width&&we.height?Math.min(we.width/ct.width,we.height/ct.height):null;h.useEffect(()=>{var i;ve(1),Pe(!1),tt.current=null,He.current.reset(),Mt.current=null,Ke.current=null,(i=se.current)==null||i.scrollTo(0,0)},[t,g]),h.useEffect(()=>{const i=se.current;if(!t||!i)return;const c=new ResizeObserver(()=>{_e({width:i.clientWidth,height:i.clientHeight})});return c.observe(i),()=>c.disconnect()},[t,F]),h.useEffect(()=>{const i=se.current;if(!t||!i||!N||L)return;const c=a=>a.preventDefault();return i.addEventListener("wheel",c,{passive:!1}),()=>i.removeEventListener("wheel",c)},[t,N,L]);const ui=h.useCallback(()=>{Tt.current+=1;const i=$e.current;i&&(Re?(i.blur(),St(!1)):(ar.flushSync(()=>Pe(!1)),i.focus({preventScroll:!0})))},[Re]);h.useEffect(()=>{var i;(!e||!N||L)&&(Tt.current+=1,(i=$e.current)==null||i.blur(),St(!1))},[e,N,L,Re]);const Bt=h.useCallback(i=>{const c=(v==null?void 0:v.viewport)??(d==null?void 0:d.viewport),a=se.current,y=a==null?void 0:a.querySelector(".browser-live-image-hit-area");if(!i||!c||!a||!y)return;const C=y.getBoundingClientRect(),b=a.getBoundingClientRect(),S=C.top+i.y/c.height*C.height,j=S+i.h/c.height*C.height,A=16;S>=b.top+A&&j<=b.bottom-A||(a.scrollTop+=S-(b.top+Math.max(A,b.height*.3)))},[v==null?void 0:v.viewport,d==null?void 0:d.viewport]);h.useEffect(()=>{if(!Re||!Ke.current)return;const i=window.setTimeout(()=>Bt(Ke.current),420);return()=>window.clearTimeout(i)},[Re,we.width,we.height,Bt]);const ir=h.useCallback((i,c=!1)=>{var y;const a=i&&typeof i.input=="object"&&i.input!==null?i.input:i;if(typeof(a==null?void 0:a.editable)=="boolean"){if(!a.editable&&a.kind==="control"){Ke.current=null;return}if(a.editable){const C=a.bounds,b=C&&["x","y","w","h"].every(S=>typeof C[S]=="number")?{x:C.x,y:C.y,w:C.w,h:C.h}:null;b&&(Ke.current=b),c&&!rt.current&&!window.matchMedia("(pointer: coarse)").matches&&((y=$e.current)==null||y.focus({preventScroll:!0})),rt.current?Bt(b??Ke.current):dt(!0)}else Ke.current=null}},[Bt]),Me=h.useCallback((i=!0)=>{var C,b,S,j,A;(C=Vt.current)==null||C.abort(),Vt.current=null;const c=gt.current;gt.current=null;for(const H of(c==null?void 0:c.getTracks())??[])H.stop();(b=Jt.current)==null||b.disconnect(),(S=Qt.current)==null||S.disconnect(),(j=er.current)==null||j.disconnect(),Jt.current=null,Qt.current=null,er.current=null;const a=Gt.current;Gt.current=null,a&&a.close().catch(()=>{});const y=Ft.current;Ft.current=null,(A=nt.current)==null||A.disconnect(),nt.current=null,st.current=0,bt.current=0,y&&y.close().catch(()=>{}),Lt.current=!1,zt.current=!1,Rr(!1),Er(!1),yt("idle"),i&&o&&g&&o.request("browser:webrtc",{sessionId:g,data:{kind:"audio-stop"}}).catch(()=>{})},[o,g]),Sr=h.useCallback(i=>{var xe;if(zt.current||typeof i.data!="string")return;const c=Ft.current,a=Number(i.sampleRate),y=Number(i.channels);if(!c||!Number.isSafeInteger(a)||!Number.isSafeInteger(y)||y<1||y>2)return;const C=Pn(i.data,y);if(!((xe=C[0])!=null&&xe.length))return;const b=c.createBuffer(y,C[0].length,a);for(let ce=0;ce<y;ce+=1)b.copyToChannel(C[ce],ce);const S=c.createBufferSource();S.buffer=b;const j=nt.current;if(!j)return;S.connect(j);const A=c.currentTime,H=Math.max(A+.02,st.current);st.current=H-A>.35?A+.02:H,S.start(st.current),st.current+=b.duration},[]),hi=h.useCallback(async()=>{var c;if(!o||!g||!N||!at||document.visibilityState!=="visible")return;const i=new AbortController;(c=Vt.current)==null||c.abort(),Vt.current=i,T(null),yt("starting");try{const a=await An(i.signal);if(!a||i.signal.aborted||document.visibilityState!=="visible"){a==null||a.dispose();return}const{stream:y,microphoneContext:C,remoteContext:b,remoteGain:S,source:j,processor:A,sink:H}=a;gt.current=y,Gt.current=C,Jt.current=j,Qt.current=A,er.current=H,Ft.current=b,nt.current=S,jr.current=0,A.onaudioprocess=xe=>{if(i.signal.aborted||Lt.current||!gt.current||!o||!g||bt.current>=4)return;const ce=new Float32Array(xe.inputBuffer.getChannelData(0));bt.current+=1,o.request("browser:webrtc",{sessionId:g,data:{kind:"audio-microphone",sequence:++jr.current,sampleRate:C.sampleRate,channels:1,data:Nn(ce)}}).catch(()=>{}).finally(()=>{bt.current=Math.max(0,bt.current-1)})},await o.request("browser:webrtc",{sessionId:g,data:{kind:"audio-start"}})}catch(a){if(i.signal.aborted)return;Me(!1),yt("failed"),T(a instanceof Error?a.message:"无法开始语音")}},[o,N,g,Me,at]);h.useEffect(()=>{t&&e&&N&&at||Ve!=="idle"&&Me(!0)},[e,Ve,N,t,Me,at]),h.useEffect(()=>{const i=()=>{document.visibilityState!=="visible"&&Ve!=="idle"&&Me(!0)};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[Ve,Me]),h.useEffect(()=>()=>Me(!0),[Me]);const Tr=h.useMemo(()=>[{urls:"stun:stun.l.google.com:19302"}],[]),Ir=h.useCallback(async(i,c,a,y,C,b)=>{var j,A,H,xe,ce,Ze;if(!o||!i||!c)return;let S;try{const Ce=te.current;te.current=null,(j=re.current)==null||j.stop(),re.current=null,(A=Xe.current)==null||A.stop(),(H=fe.current)==null||H.stop(),fe.current=null,(xe=ye.current)==null||xe.stop(),ye.current=null,(ce=it.current)==null||ce.stop(),Ce==null||Ce.close();let $=te.current;if(!$){$=new RTCPeerConnection({iceServers:a!=null&&a.length?a:Tr}),S=new gn($,b),re.current=S;const ne=new Jr({getVideo:()=>Fe.current,getCanvas:()=>kr.current});ne.attach($);const le=new pn({getVideo:()=>Fe.current,getCanvas:()=>xr.current});le.attach($),(Ze=Xe.current)==null||Ze.stop(),Xe.current=le;const lt=new mn(y,C===2?2:1,ue=>T(ue.message));lt.setVisible(document.visibilityState!=="hidden"),lt.attach($),fe.current=lt,ye.current=new yn($),it.current=ne,$.onicecandidate=ue=>{!ue.candidate||te.current!==$||o.request("browser:webrtc",{sessionId:i,data:{kind:"ice",candidate:ue.candidate.toJSON(),...b?{attemptId:b}:{}}}).catch(()=>{})},$.ontrack=ue=>{if(te.current!==$)return;const Oe=Fe.current;Oe&&ue.streams[0]&&(Oe.srcObject=ue.streams[0],Oe.play().catch(()=>{}))},$.onconnectionstatechange=()=>{if(te.current!==$)return;const ue=$==null?void 0:$.connectionState;ue==="connected"?je("live"):(ue==="failed"||ue==="disconnected"||ue==="closed")&&je("failed")},te.current=$}const ie=await S.answer(c);if(!ie||re.current!==S)return;je("connecting"),await o.request("browser:webrtc",{sessionId:i,data:{kind:"answer",sdp:ie.toJSON(),...b?{attemptId:b}:{}}})}catch(Ce){if(S?re.current!==S:re.current!==null)return;o.request("browser:webrtc",{sessionId:i,data:{kind:"viewer-trace",event:"negotiation-failed",attemptId:b,error:Ce instanceof Error?Ce.message.slice(0,300):"WebRTC negotiation failed"}}).catch(()=>{}),je("failed")}},[o,Tr]),Dr=h.useCallback((i,c)=>{if(c){if(c.kind==="quality-state"&&["smooth","hd","original"].includes(String(c.quality))){B(String(c.quality)),V(null),typeof c.error=="string"&&T(c.error);return}if(c.kind==="audio-system"){Sr(c);return}if(c.kind==="audio-state"){const a=String(c.state);["idle","starting","live","failed"].includes(a)&&yt(a),typeof c.error=="string"&&(T(c.error),Me(!1),yt("failed"));return}if(c.kind==="offer"){typeof c.warning=="string"&&T(c.warning),Ir(i,c.sdp,Array.isArray(c.iceServers)?c.iceServers:void 0,typeof c.inputStream=="string"?c.inputStream:void 0,typeof c.inputVersion=="number"?c.inputVersion:void 0,typeof c.attemptId=="string"?c.attemptId:void 0);return}if(c.kind==="ice"){const a=c.candidate,y=re.current;y&&a&&y.addIceCandidate(a,c.attemptId).catch(()=>{});return}if(c.kind==="state"){if(c.attemptId!==void 0&&re.current&&!re.current.accepts(c.attemptId))return;const a=String(c.state);a==="connected"?je("live"):(a==="failed"||a==="disconnected"||a==="closed")&&je("failed")}}},[Ir,Sr,Me]),[Ye,Nr]=h.useState(null);h.useEffect(()=>{if(!v){Nr(null);return}const i=typeof v.data=="string"?`data:${v.mime};base64,${v.data}`:URL.createObjectURL(new Blob([v.data],{type:v.mime}));let c=!1,a=!1;const y=new Image;return y.src=i,y.decode().then(()=>{c||(a=!0,Nr(i))}).catch(()=>{}),()=>{c=!0,!a&&i.startsWith("blob:")&&URL.revokeObjectURL(i)}},[v]),h.useEffect(()=>()=>{Ye!=null&&Ye.startsWith("blob:")&&URL.revokeObjectURL(Ye)},[Ye]);const Ae=h.useCallback(i=>{R(c=>{const a=c.findIndex(C=>C.id===i.id);if(a>=0&&qn(c[a],i))return c;if(a<0)return[i,...c];const y=[...c];return y[a]=i,y.sort((C,b)=>b.updatedAt-C.updatedAt)}),M(c=>ti(c,[i],r)),E(!1)},[r]),Ot=h.useCallback(async()=>{if(!(!o||!t)){oe(!0),T(null);try{const i=await o.request("browser:list");R(i.sessions),M(c=>{const a=c&&i.sessions.some(y=>y.id===c)?c:null;return ti(a,i.sessions,r)}),g&&await o.request("browser:watch",{sessionId:g}).then(c=>Ae(c.session)).catch(()=>{}),Y(c=>c+1)}catch(i){T(i instanceof Error?i.message:"无法读取浏览器会话")}finally{oe(!1)}}},[r,o,Ae,t,g]);h.useEffect(()=>{if(!(!t||!o))return Ot(),o.onEvent(i=>{var c,a,y,C,b,S;if(i.type==="browser:connection"){(c=Xe.current)==null||c.stop(),(a=fe.current)==null||a.stop(),fe.current=null,(y=ye.current)==null||y.stop(),ye.current=null,(C=it.current)==null||C.stop(),(b=te.current)==null||b.close(),te.current=null,(S=re.current)==null||S.stop(),re.current=null,je("off"),E(!1),R([]),U(null),i.connected===!0?Ot():T("远程连接已断开,正在重新连接");return}if(i.type==="browser:frame"){const j=i;j.sessionId===g&&U(j);return}if(i.type==="browser:webrtc"){const j=i.data;i.sessionId===g&&Dr(g,j);return}if(i.session&&typeof i.session=="object"&&Ae(i.session),i.type==="browser:closed"){const j=i.session;j&&(R(A=>A.filter(H=>H.id!==j.id)),j.id===g&&(U(null),M(null)))}})},[o,Dr,Ae,t,Ot,g]),h.useEffect(()=>{if(!(!t||!o||!g))return U(null),T(null),vt.current=!1,Pt(null),o.request("browser:watch",{sessionId:g}).then(i=>Ae(i.session)).catch(i=>T(i instanceof Error?i.message:"无法观看浏览器")),()=>{o.request("browser:unwatch").catch(()=>{})}},[o,Ae,t,g]),h.useEffect(()=>{var i,c,a,y,C,b,S,j,A,H,xe,ce;if(!t||!o||!N||!F||!g){vt.current=!1,Pt(null),Nt.current=0,(i=Xe.current)==null||i.stop(),(c=fe.current)==null||c.stop(),fe.current=null,(a=ye.current)==null||a.stop(),ye.current=null,(y=it.current)==null||y.stop(),(C=te.current)==null||C.close(),te.current=null,(b=re.current)==null||b.stop(),re.current=null,Fe.current&&(Fe.current.srcObject=null),Ge.current=null,mt(null),je("off");return}return(S=Xe.current)==null||S.stop(),(j=fe.current)==null||j.stop(),fe.current=null,(A=ye.current)==null||A.stop(),ye.current=null,(H=it.current)==null||H.stop(),(xe=te.current)==null||xe.close(),te.current=null,(ce=re.current)==null||ce.stop(),re.current=null,Ge.current=null,mt(null),je("connecting"),Je.current.begin(performance.now()),o.request("browser:webrtc",{sessionId:g,data:{kind:"start",inputVersion:2,receiverProfiles:Rn(),...Jr.supported()?{compoundVersion:1}:{}}}).catch(()=>je("failed")),()=>{var Ze,Ce,$,ie,ne,le;(Ze=Xe.current)==null||Ze.stop(),(Ce=fe.current)==null||Ce.stop(),fe.current=null,($=ye.current)==null||$.stop(),ye.current=null,(ie=it.current)==null||ie.stop(),(ne=te.current)==null||ne.close(),te.current=null,(le=re.current)==null||le.stop(),re.current=null,Fe.current&&(Fe.current.srcObject=null),Ge.current=null,mt(null),o.request("browser:webrtc",{sessionId:g,data:{kind:"stop"}}).catch(()=>{})}},[o,N,F,t,g,W]),h.useEffect(()=>{if(!t||!N||!F||ze!=="failed"||Nt.current>=2)return;const i=window.setTimeout(()=>{Nt.current+=1,Y(c=>c+1)},2e3*(Nt.current+1));return()=>window.clearTimeout(i)},[t,N,F,ze]),h.useEffect(()=>{if(!o||!g||ze!=="live"){Ge.current=null,mt(null);return}let i=!0,c=!1;const a=Fe.current,y=typeof(a==null?void 0:a.requestVideoFrameCallback)=="function";let C,b=null,S=!1,j=0,A,H=-1/0,xe=0;Je.current.begin(performance.now());const ce=ie=>{if(!i||document.visibilityState==="hidden")return;const ne=performance.now(),le=Je.current.observe(ie,ne);le&&(!S||ne-j>=2e3)&&(S=!0,j=ne,o.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"playback-ready"}}).catch(()=>{})),le&&vt.current&&(vt.current=!1,Pt(null),o.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"stall-recovered",...b?{sample:b}:{}}}).catch(()=>{}))};if(y&&a){const ie=(ne,le)=>{ce(le.presentedFrames),document.visibilityState!=="hidden"&&Number.isFinite(le.expectedDisplayTime)&&(A=Math.max(0,ne-le.expectedDisplayTime),H=performance.now()),i&&(C=a.requestVideoFrameCallback(ie))};C=a.requestVideoFrameCallback(ie)}const Ze=()=>{var ie,ne;Ge.current=null,A=void 0,H=-1/0,(ie=fe.current)==null||ie.setVisible(document.visibilityState!=="hidden"),document.visibilityState==="hidden"&&((ne=ye.current)==null||ne.stop()),document.visibilityState!=="hidden"&&Je.current.resume(performance.now())};document.addEventListener("visibilitychange",Ze);const Ce=async()=>{var ne,le,lt;const ie=te.current;if(!(!ie||c)){c=!0;try{const ue=await ie.getStats().catch(()=>null);if(!i||ie!==te.current)return;const Oe=performance.now(),ge=ue&&jn(ue,Ge.current,Date.now(),{visible:document.visibilityState!=="hidden",...Oe-H<=2e3?{presentationDelayMs:A}:{},viewport:{width:((ne=se.current)==null?void 0:ne.clientWidth)??0,height:((le=se.current)==null?void 0:le.clientHeight)??0,pixelRatio:Math.min(4,Math.max(1,window.devicePixelRatio||1)),zoom:Math.min(4,Math.max(1,Ue.current))}});if(ge){ge.sample.receiver&&(ge.sample.receiver.sequence=++xe);const Ht=(lt=ye.current)==null?void 0:lt.apply(ge.sample,Oe);Ht&&ge.sample.receiver&&Object.assign(ge.sample.receiver,Ht),Ge.current=ge.cursor,b=ge.sample,mt(ge.sample),o.request("browser:webrtc",{sessionId:g,data:{kind:"stats",...ge.sample}}).catch(()=>{})}const Br=xn(a,ge==null?void 0:ge.cursor.framesDecoded);y||ce(Br);const ki=y||Br!==void 0||!(a!=null&&a.videoWidth);if(document.visibilityState!=="hidden"&&ki&&Je.current.evaluate(Oe).state==="stalled"){const Ht=Je.current.evaluate(Oe);Je.current.begin(Oe),je(Or=>Or==="live"?"failed":Or),vt.current=!0,Pt("实时画面超时,已切换为 JPEG 兜底画面"),o.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"jpeg-fallback",silentForMs:Ht.silentForMs,...b?{sample:b}:{}}}).catch(()=>{})}}catch{}finally{c=!1}}};Ce();const $=window.setInterval(()=>void Ce(),1e3);return()=>{i=!1,S&&o.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"jpeg-fallback"}}).catch(()=>{}),window.clearInterval($),C!==void 0&&(a==null||a.cancelVideoFrameCallback(C)),document.removeEventListener("visibilitychange",Ze)}},[o,g,ze]);const Pr=h.useCallback(async()=>{if(!(!o||!d)){E(!0),T(null);try{const i=await o.request("browser:takeover",{sessionId:d.id});Ae(i.session)}catch(i){E(!1),T(i instanceof Error?i.message:"无法接管浏览器")}}},[o,Ae,d]),di=h.useCallback(async()=>{if(!(!o||!d)){E(!0),T(null);try{const i=await o.request("browser:return",{sessionId:d.id});Ae(i.session)}catch(i){E(!1),T(i instanceof Error?i.message:"无法归还浏览器")}}},[o,Ae,d]),nr=h.useCallback(async(i,c)=>{if(!(!o||!g)){Ie(i),T(null);try{await o.request("browser:system",{sessionId:g,action:i,...c?{password:c}:{}}),window.setTimeout(()=>Y(a=>a+1),800)}catch(a){T(a instanceof Error?a.message:"系统操作失败")}finally{Ie(null)}}},[o,g]),fi=h.useCallback(async()=>{if(!(!o||!g||!he)){qe(!0),Le(null);try{await o.request("browser:system",{sessionId:g,action:"unlock",password:he}),D(""),be(!1),window.setTimeout(()=>Y(i=>i+1),2500)}catch(i){Le(i instanceof Error?i.message:"解锁失败")}finally{D(""),qe(!1)}}},[o,g,he]),kt=h.useCallback(i=>{var y,C;if(!o||I||q||!(d!=null&&d.isController)||d.state!=="user-controlled")return Promise.resolve(null);i.kind==="pointer"&&((y=Xe.current)==null||y.localPoint(i));const c={...i,mobile:window.matchMedia("(pointer: coarse)").matches},a=b=>o.request("browser:input",{sessionId:d.id,input:b});return(((C=fe.current)==null?void 0:C.dispatch(c,a))??a(c)).then(b=>{var S;if((S=b==null?void 0:b.input)!=null&&S.error)throw new Error(b.input.error);return b}).catch(b=>((b==null?void 0:b.code)!=="ECANCELED"&&T(b instanceof Error?b.message:"浏览器输入失败"),null))},[o,d,I,q]),G=h.useCallback(i=>{kt(i)},[kt]),ke=h.useCallback((i,c,a=[])=>{G({kind:"key",action:"down",key:i,code:c,text:"",modifiers:a}),G({kind:"key",action:"up",key:i,code:c,text:"",modifiers:a})},[G]),xt=h.useCallback(i=>{ke(i,`Key${i.toUpperCase()}`,[ri(d)])},[ke,d]),pi=h.useCallback(async i=>{var b,S;if(!o||!(d!=null&&d.isController)||d.state!=="user-controlled"||I||q)throw new Error("连接正在切换,请稍后重试");const c={kind:"key",action:"down",text:i,key:"",code:"",modifiers:[],mobile:window.matchMedia("(pointer: coarse)").matches},a=j=>o.request("browser:input",{sessionId:d.id,input:j}),y=await(((b=fe.current)==null?void 0:b.dispatch(c,a))??a(c)),C=(S=y==null?void 0:y.input)==null?void 0:S.error;if(C)throw new Error(C)},[o,d,I,q]),sr=h.useCallback((i,c,a=!1)=>{const y=++Tt.current;kt({kind:"pointer",action:"up",...i,button:"left",...c&&c>1?{click:c}:{}}).then(C=>{y===Tt.current&&ir(C,a)})},[ir,kt]),Ut=h.useRef(!1),Wt=h.useRef(""),Ar=h.useCallback(i=>{const c=Wt.current;if(i!==c){if(i.startsWith(c)){const a=i.slice(c.length);a&&G({kind:"key",action:"down",text:a,key:"",code:"",modifiers:[]})}Wt.current=i}},[G]),pe=(d==null?void 0:d.displays)??null,qr=i=>{if(!N||L)return;const c=$e.current,a=i.code==="KeyA"&&!i.shiftKey&&!i.altKey&&(ri(d)==="Meta"?i.metaKey:i.ctrlKey);c&&i.target===c&&a&&(i.preventDefault(),c.value="",Wt.current=""),!(i.target===$e.current&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey)&&(G({kind:"key",action:"down",key:i.key,code:i.code,text:i.key.length===1?i.key:"",modifiers:ii(i)}),["Backspace","Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Escape"].includes(i.key)&&i.preventDefault())},Lr=i=>{!N||L||i.target===$e.current&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey||G({kind:"key",action:"up",key:i.key,code:i.code,modifiers:ii(i)})};h.useEffect(()=>{if(!q)return;const i=window.setTimeout(()=>{V(null),T("画质切换未完成,请刷新画面后重试")},14e3);return()=>window.clearTimeout(i)},[q]),h.useEffect(()=>{V(null),B("hd")},[t,g]);const mi=i=>{!o||!Qe||I||q||!g||(V(i),o.request("browser:webrtc",{sessionId:g,data:{kind:"quality",quality:i}}).catch(c=>{V(null),T(c instanceof Error?c.message:"画质切换失败")}))};h.useEffect(()=>{if(!I)return;if(pe!=null&&pe.some(c=>c.id===I&&c.selected)){Q(null);return}const i=window.setTimeout(()=>{Q(null),T("切换屏幕未完成,请刷新画面后重试")},14e3);return()=>window.clearTimeout(i)},[pe,I]),h.useEffect(()=>{Q(null)},[t,g]);const or=h.useRef(0),vi=h.useCallback(i=>{!o||I||q||!g||!Qe||!(pe!=null&&pe.some(c=>c.id===i&&!c.selected))||(Q(i),o.request("browser:set-display",{sessionId:g,displayId:i}).catch(c=>{Q(null),T(c instanceof Error?c.message:"切换屏幕失败")}))},[o,pe,g,Qe,I,q]),Be=h.useCallback(i=>{const c=i.currentTarget.getBoundingClientRect(),a=(v==null?void 0:v.viewport)??(d==null?void 0:d.viewport);if(!a)return null;const y=Math.min(c.width/a.width,c.height/a.height),C=a.width*y,b=a.height*y,S=(c.width-C)/2,j=(c.height-b)/2,A=(i.clientX-c.left-S)/C,H=(i.clientY-c.top-j)/b;return A<0||A>1||H<0||H>1?null:{x:A,y:H}},[v==null?void 0:v.viewport,d==null?void 0:d.viewport]);if(!t||typeof document>"u")return null;const zr=(d==null?void 0:d.online)&&!d.controlledByAnotherViewer,yi=(d==null?void 0:d.availability)==="unavailable"?F?"桌面直播不可用":"浏览器直播不可用":(d==null?void 0:d.availability)==="starting"?"正在连接画面":F&&(d==null?void 0:d.state)==="agent-controlled"?"未被远程控制":d?Tn[d.state]:F?"等待桌面直播":"等待浏览器",gi=(d==null?void 0:d.availability)==="unavailable"?F?"桌面直播不可用":"浏览器直播不可用":(d==null?void 0:d.availability)==="starting"?"正在连接画面":x.length?"等待第一帧":F?"暂无桌面直播":"暂无浏览器直播",bi=(d==null?void 0:d.availability)==="unavailable"?d.capabilityError||(F?"需要在桌面 App 中开启并授予屏幕录制权限":"当前浏览器不支持实时画面传输"):x.length?"画面开始后会自动显示":F?"在桌面 App 设置中开启「桌面直播与远程控制」后,画面会出现在这里":"Agent 开始浏览网页后,会话会出现在这里",wi=Mn(wr),Fr=Sn(wr),Vr=ze==="live"?wi||"WebRTC 实时流":ze==="connecting"?"正在连接 WebRTC":Ye?"JPEG 兜底":null;return ar.createPortal(u.jsxs("div",{ref:f,className:"browser-live-backdrop",style:{visibility:e?void 0:"hidden",pointerEvents:e?void 0:"none"},"aria-hidden":!e,"data-tab-swipe-ignore":!0,role:"presentation",onMouseDown:i=>{i.target===i.currentTarget&&n()},children:[u.jsxs("section",{ref:p,className:`browser-live-panel ${m?"is-fullscreen":""}`,role:"dialog","aria-modal":"true","aria-label":"浏览器直播",children:[u.jsxs("header",{className:"browser-live-header",children:[u.jsxs("div",{className:"browser-live-heading",children:[u.jsx($r,{size:17,"aria-hidden":"true"}),u.jsxs("div",{children:[u.jsx("strong",{children:"浏览器直播"}),u.jsx("span",{children:d?fr(d.backend):"实时观看与接管"})]}),l]}),u.jsxs("div",{className:"browser-live-header-actions",children:[u.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>void k(),title:m?"退出全屏":"全屏","aria-label":m?"退出全屏":"全屏","aria-pressed":m,children:m?u.jsx(lr,{size:17}):u.jsx(Ai,{size:17})}),u.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>void Ot(),title:"刷新画面与会话","aria-label":"刷新直播画面与会话",children:u.jsx(ji,{size:15,className:X?"spin":void 0,"aria-hidden":"true"})}),u.jsx("button",{type:"button",className:"ui-icon-button",onClick:n,title:"关闭","aria-label":"关闭浏览器直播",children:u.jsx(Mi,{size:17,"aria-hidden":"true"})})]})]}),u.jsxs("div",{className:`browser-live-surface ${N?"is-controlling":""} has-zoom ${N&&!L&&pt?"has-quickkeys":""}`,children:[u.jsxs("div",{className:"browser-live-zoom",role:"group","aria-label":"桌面画面缩放",children:[m&&u.jsxs("button",{type:"button","aria-label":"退出全屏",title:"退出全屏",onClick:()=>void k(),children:[u.jsx(lr,{size:15,"aria-hidden":"true"}),"退出全屏"]}),x.length>1&&u.jsx("div",{className:"browser-live-session-tabs",role:"tablist","aria-label":"切换直播屏幕",children:x.map(i=>u.jsx("button",{type:"button",role:"tab","aria-selected":i.id===g,className:i.id===g?"is-active":"",title:`${fr(i.backend)} · ${i.title||"浏览器"}`,onClick:()=>M(i.id),children:i.title||fr(i.backend)},i.id))}),F&&pe&&pe.length>1&&u.jsx(_r,{label:"选择直播屏幕",title:Qe?"选择直播屏幕":"其他设备控制中或画面暂不可用",value:(pe.find(i=>i.selected)??pe[0]).id,busy:!!I,disabled:!v||!Qe||q||pe.length<2,onChange:vi,children:pe.map((i,c)=>u.jsx("option",{value:i.id,children:`第 ${c+1} 屏${i.primary?"(主屏)":""}`},i.id))}),F&&u.jsxs(_r,{label:"视频画质",title:Qe?"视频画质":"其他设备控制中或画面暂不可用",value:K,busy:q!==null,disabled:!Qe||!!I,compact:!0,onChange:mi,children:[u.jsx("option",{value:"smooth",children:"流畅"}),u.jsx("option",{value:"hd",children:"高清"}),u.jsx("option",{value:"original",children:"原画"})]}),F&&N&&at&&Ve!=="live"&&u.jsxs("button",{type:"button","aria-label":"开始语音",title:"开始双向语音",disabled:Ve==="starting",onClick:()=>void hi(),children:[Ve==="starting"?u.jsx(Se,{size:15,className:"spin","aria-hidden":"true"}):u.jsx(Kr,{size:15,"aria-hidden":"true"}),Ve==="starting"?"正在连接":"开始语音"]}),F&&N&&at&&Ve==="live"&&u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button","aria-label":At?"取消麦克风静音":"麦克风静音","aria-pressed":At,title:At?"打开麦克风":"关闭麦克风",onClick:()=>{var c;const i=!Lt.current;Lt.current=i;for(const a of((c=gt.current)==null?void 0:c.getAudioTracks())??[])a.enabled=!i;Rr(i)},children:At?u.jsx(qi,{size:15,"aria-hidden":"true"}):u.jsx(Kr,{size:15,"aria-hidden":"true"})}),u.jsx("button",{type:"button","aria-label":qt?"取消扬声器静音":"扬声器静音","aria-pressed":qt,title:qt?"打开电脑声音":"关闭电脑声音",onClick:()=>{const i=!zt.current;zt.current=i,nt.current&&(nt.current.gain.value=i?0:1),Er(i),i&&(st.current=0)},children:qt?u.jsx(zi,{size:15,"aria-hidden":"true"}):u.jsx(Si,{size:15,"aria-hidden":"true"})}),u.jsx("button",{type:"button","aria-label":"结束语音",title:"结束双向语音",onClick:()=>Me(!0),children:u.jsx(Li,{size:15,"aria-hidden":"true"})})]}),u.jsx("button",{type:"button","aria-label":"缩小桌面画面",title:"缩小",disabled:!v||me<=.5,onClick:()=>ve(i=>Math.max(.5,i-.25)),children:u.jsx(Ti,{size:16})}),u.jsxs("output",{"aria-label":"桌面缩放比例",children:[Math.round(me*100),"%"]}),u.jsx("button",{type:"button","aria-label":"放大桌面画面",title:"放大",disabled:!v||me>=5,onClick:()=>ve(i=>Math.min(5,i+.25)),children:u.jsx(Ii,{size:16})}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>{var i;ve(1),Pe(!1),(i=se.current)==null||i.scrollTo(0,0)},children:"适应窗口"}),u.jsxs("button",{type:"button","aria-label":"移动桌面画面","aria-pressed":L,title:"拖动或滚动画面,不发送远程输入",disabled:!v,onClick:()=>Pe(i=>!i),children:[u.jsx(Ni,{size:15}),"移动画面"]}),u.jsxs("span",{className:`browser-live-keyboard ${Re?"is-typing":""}`,children:[u.jsxs("button",{type:"button","aria-label":"唤起键盘","aria-pressed":Re,title:"唤起/收起键盘(无法识别输入框时可手动唤起)",className:ai&&!Re?"is-hint":void 0,disabled:!v||!N,onPointerDown:i=>i.preventDefault(),onClick:()=>{dt(!1),ui()},children:[u.jsx(cr,{size:15}),"键盘"]}),u.jsx("input",{ref:$e,className:"browser-live-mobile-input","aria-label":"浏览器键盘输入",tabIndex:-1,disabled:!v||!N,defaultValue:"",inputMode:"text",autoCapitalize:"none",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onFocus:()=>{Pe(!1),rt.current=!0,St(!0),dt(!1)},onKeyDown:qr,onKeyUp:Lr,onCompositionStart:()=>{Ut.current=!0},onCompositionEnd:i=>{Ut.current=!1,L||Ar(i.target.value)},onBlur:i=>{rt.current=!1,Ut.current=!1,Wt.current="",i.target.value="",St(!1)},onChange:i=>{!L&&!Ut.current&&Ar(i.target.value)}})]}),u.jsxs("button",{type:"button","aria-label":"快捷键条","aria-pressed":pt,title:"展开/收起快捷键(Esc/Tab/复制/粘贴/方向键)",disabled:!v||!N,onClick:()=>ci(i=>!i),children:[u.jsx(cr,{size:15}),pt?"收起":"快捷键"]}),u.jsxs("button",{type:"button","aria-label":"窗口控制",title:"全屏看不到左上角按钮时用:第 1 次点=退出全屏(ESC + Ctrl+Cmd+F),第 2 次点=关闭窗口(Cmd+W)",disabled:!v||!N,onClick:()=>{const i=Date.now();if(i-or.current<2500){ke("w","KeyW",["Meta"]),or.current=0;return}or.current=i,ke("Escape","Escape"),window.setTimeout(()=>{ke("f","KeyF",["Control","Meta"])},150)},children:[u.jsx(cr,{size:15}),"窗口"]}),Mr&&u.jsxs(u.Fragment,{children:[u.jsxs("button",{type:"button","aria-label":"锁屏",title:"锁屏(锁屏后仍可从空态区唤醒或远程解锁)",disabled:!v||!!O,onClick:()=>void nr("lock"),children:[O==="lock"?u.jsx(Se,{size:15,className:"spin"}):u.jsx(Pi,{size:15}),"锁屏"]}),u.jsxs("button",{type:"button","aria-label":"唤醒屏幕",title:"唤醒显示器或锁屏界面",disabled:!!O,onClick:()=>void nr("wake"),children:[O==="wake"?u.jsx(Se,{size:15,className:"spin"}):u.jsx(Zr,{size:15}),"唤醒"]})]})]}),N&&!L&&pt&&u.jsxs("div",{className:"browser-live-quickkeys",role:"group","aria-label":"快捷键",children:[u.jsx("button",{type:"button",disabled:!v,onClick:()=>ke("Escape","Escape"),children:"Esc"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>ke("Tab","Tab"),children:"Tab"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>xt("c"),children:"复制"}),u.jsx(Fi,{disabled:!v||!!I||!!q,onPaste:pi,onError:T},g),u.jsx("button",{type:"button",disabled:!v,onClick:()=>xt("a"),children:"全选"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>xt("z"),children:"撤销"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>xt("s"),children:"保存"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>xt("f"),children:"查找"}),u.jsx("button",{type:"button",disabled:!v,title:"退出当前前台应用(Cmd+Q)",onClick:()=>ke("q","KeyQ",["Meta"]),children:"⌘Q"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>ke("ArrowLeft","ArrowLeft"),children:"←"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>ke("ArrowUp","ArrowUp"),children:"↑"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>ke("ArrowDown","ArrowDown"),children:"↓"}),u.jsx("button",{type:"button",disabled:!v,onClick:()=>ke("ArrowRight","ArrowRight"),children:"→"})]}),!(N&&!L&&pt)&&u.jsx("div",{className:"browser-live-touch-hint",children:tr?"画面当前为只读 · 点击画面开始控制":"滑动滚动 · 轻点点击 · 双击打开 · 长按拖动 · 按住1秒右键 · 双指缩放"}),u.jsxs("div",{ref:se,className:"browser-live-viewport",onMouseDown:i=>{rt.current&&i.preventDefault()},children:[v&&Ye?u.jsxs("div",{className:"browser-live-image-hit-area",style:rr&&ct?{width:ct.width*rr*me,height:ct.height*rr*me,cursor:L?"grab":void 0}:void 0,tabIndex:N&&!L?0:-1,onContextMenu:i=>i.preventDefault(),onPointerDown:i=>{if(i.pointerType==="touch"){i.preventDefault(),He.current.down(i.pointerId,{x:i.clientX,y:i.clientY}),We.current=N&&!L?Be(i):null;const a=We.current;a&&F&&(d==null?void 0:d.platform)==="darwin"&&kt({kind:"pointer",action:"move",...a,probe:!0}).then(y=>{We.current===a&&ir(y)}),i.currentTarget.setPointerCapture(i.pointerId),ae.current&&window.clearTimeout(ae.current),Ee.current="none",ft.current=N&&!L?{x:i.clientX,y:i.clientY}:null,It.current=i.timeStamp,ft.current&&(ae.current=window.setTimeout(()=>{Ee.current="armed"},550));return}if(L&&se.current){const a=se.current;tt.current={x:i.clientX,y:i.clientY,left:a.scrollLeft,top:a.scrollTop},i.currentTarget.setPointerCapture(i.pointerId);return}if(!N)return;const c=Be(i);c&&(jt.current=!0,i.currentTarget.setPointerCapture(i.pointerId),G({kind:"pointer",action:"down",...c,button:"left"}))},onPointerMove:i=>{if(i.pointerType==="touch"){i.preventDefault();const a=He.current.move(i.pointerId,{x:i.clientX,y:i.clientY}),y=se.current;if(!a||!y)return;const C=a.pointers>=2&&Math.abs(a.distanceRatio-1)>.05,b=Math.max(.5,Math.min(5,ht.current*a.scale));if(C&&b!==ht.current){const j=i.currentTarget.getBoundingClientRect();Mt.current={x:(a.from.x-j.left)/j.width,y:(a.from.y-j.top)/j.height,clientX:a.to.x,clientY:a.to.y},ht.current=b,ar.flushSync(()=>ve(b));return}if(ae.current&&(window.clearTimeout(ae.current),ae.current=null),Ee.current==="armed"&&ft.current&&We.current&&(Ee.current="drag",G({kind:"pointer",action:"down",...We.current,button:"left"})),Ee.current==="drag"){const j=Be(i);j&&G({kind:"pointer",action:"move",...j,button:"left"});return}const S=ht.current<=1.001;if(N&&!L&&(a.pointers>=2||S)){const j=Fn(a.from,a.to);if(j){const A=We.current??Be(i);A&&G({kind:"pointer",action:"wheel",...A,...j})}return}y.scrollLeft+=a.from.x-a.to.x,y.scrollTop+=a.from.y-a.to.y;return}if(L&&tt.current&&se.current){const a=tt.current;se.current.scrollTo(a.left+a.x-i.clientX,a.top+a.y-i.clientY);return}if(!N)return;if(!jt.current){const a=Be(i);a&&G({kind:"pointer",action:"move",...a,button:"left"});return}const c=Be(i);c&&G({kind:"pointer",action:"move",...c,button:"left"})},onPointerUp:i=>{if(i.pointerType==="touch"){i.preventDefault(),ae.current&&(window.clearTimeout(ae.current),ae.current=null);const a=Be(i);We.current=null;const y=He.current.up(i.pointerId,{x:i.clientX,y:i.clientY});if(Ee.current==="armed"){Ee.current="none";const C=i.timeStamp-It.current;if(y&&C>=800&&a&&N&&!L){He.current.reset(),G({kind:"pointer",action:"down",...a,button:"right"}),G({kind:"pointer",action:"up",...a,button:"right"});return}}if(Ee.current==="drag"){Ee.current="none",He.current.reset(),a&&N&&G({kind:"pointer",action:"up",...a,button:"left"});return}if(y&&a&&N&&!L){const C=(v==null?void 0:v.viewport)??(d==null?void 0:d.viewport);if(zn(Ke.current,C,a.x,a.y)){const j=$e.current;j&&document.activeElement!==j&&j.focus({preventScroll:!0}),dt(!1)}const b=_t.current;b!==null&&Date.now()-b.at<400&&C!==void 0&&Math.hypot((a.x-b.x)*C.width,(a.y-b.y)*C.height)<C.width*.03?(G({kind:"pointer",action:"down",...a,button:"left",click:2}),sr(a,2,!0),_t.current=null):(G({kind:"pointer",action:"down",...a,button:"left"}),sr(a,void 0,!0),_t.current={at:Date.now(),x:a.x,y:a.y})}return}if(L){tt.current=null;return}if(!N)return;const c=Be(i);jt.current=!1,c&&sr(c)},onPointerCancel:i=>{He.current.up(i.pointerId,{x:i.clientX,y:i.clientY},!0),tt.current=null,jt.current=!1,We.current=null,ae.current&&(window.clearTimeout(ae.current),ae.current=null),Ee.current="none",ft.current=null,It.current=0},onLostPointerCapture:i=>{He.current.up(i.pointerId,{x:i.clientX,y:i.clientY},!0),ae.current&&(window.clearTimeout(ae.current),ae.current=null),Ee.current="none",ft.current=null,It.current=0},onWheel:i=>{if(!N||L)return;const c=Be(i);c&&G({kind:"pointer",action:"wheel",...c,deltaX:i.deltaX,deltaY:i.deltaY})},onKeyDown:qr,onKeyUp:Lr,children:[u.jsx("img",{src:Ye,alt:(d==null?void 0:d.title)||"浏览器实时画面",draggable:!1,decoding:"async"}),u.jsx("video",{ref:Fe,className:`browser-live-video ${ze==="live"?"is-live":""}`,"aria-label":F?"桌面实时视频流":"浏览器实时视频流",autoPlay:!0,playsInline:!0,muted:!0}),u.jsx("canvas",{ref:kr,className:"browser-live-compound","aria-hidden":"true",style:{display:ze==="live"?"block":"none",visibility:"hidden"}}),u.jsx("canvas",{ref:xr,className:"browser-live-compound browser-live-cursor","aria-hidden":"true",style:{display:ze==="live"?"block":"none",visibility:"hidden"}}),q&&u.jsxs("div",{className:"browser-live-quality-pending",role:"status",children:[u.jsx(Se,{size:13,className:"spin","aria-hidden":"true"}),"正在切换至",In[q]??q,"画质…"]})]}):u.jsxs("div",{className:"browser-live-empty",children:[X||(d==null?void 0:d.availability)==="starting"?u.jsx(Se,{size:22,className:"spin","aria-hidden":"true"}):u.jsx($r,{size:24,"aria-hidden":"true"}),u.jsx("strong",{children:X?"正在连接浏览器":gi}),u.jsx("span",{children:bi}),li&&u.jsxs("div",{role:"group","aria-label":"锁屏远程操作",style:{display:"flex",gap:8,marginTop:12},children:[u.jsxs("button",{type:"button",className:"browser-live-control-button",disabled:!!O,onClick:()=>void nr("wake"),children:[O==="wake"?u.jsx(Se,{size:14,className:"spin","aria-hidden":"true"}):u.jsx(Zr,{size:14,"aria-hidden":"true"}),"唤醒屏幕"]}),Mr&&u.jsxs("button",{type:"button",className:"browser-live-control-button",disabled:de,onClick:()=>{Le(null),be(!0)},children:[u.jsx(Xr,{size:14,"aria-hidden":"true"}),"远程解锁"]})]})]}),tr&&u.jsx("button",{type:"button",className:"browser-live-takeover-prompt","aria-label":wt?"正在开始控制远程桌面":"点击画面开始控制远程桌面",disabled:wt||!zr||(d==null?void 0:d.state)!=="agent-controlled",onClick:()=>void Pr(),children:u.jsxs("span",{className:"browser-live-takeover-card","aria-live":"polite",children:[u.jsx("span",{className:"browser-live-takeover-icon","aria-hidden":"true",children:wt?u.jsx(Se,{size:20,className:"spin"}):u.jsx(Yr,{size:20})}),u.jsxs("span",{children:[u.jsx("strong",{children:wt?"正在开始控制":"点击画面开始控制"}),u.jsx("small",{children:wt?"正在把鼠标和键盘切换到你的设备":`当前画面只读,点击不会发送到${F?" Mac":"浏览器"}`})]})]})})]}),m&&u.jsxs("button",{type:"button",className:"browser-live-exit-fullscreen",onClick:()=>void k(),children:[u.jsx(lr,{size:14,"aria-hidden":"true"}),"退出全屏"]}),N&&!L&&u.jsxs("div",{className:"browser-live-control-cue",children:[u.jsx(Yr,{size:13,"aria-hidden":"true"}),u.jsxs("span",{children:[F?"当前输入会发送到本机":"当前输入会发送到浏览器",F&&Vr?` · ${Vr}`:"",F&&Fr?` · ${Fr}`:"",gr!=null?` · 控制 ${gr}ms`:""]})]})]}),!m&&u.jsxs("footer",{className:"browser-live-footer",children:[u.jsxs("div",{className:"browser-live-location",children:[u.jsx("span",{className:`browser-live-status-dot is-${(d==null?void 0:d.state)??"idle"}`,"aria-hidden":"true"}),u.jsxs("div",{children:[u.jsx("strong",{children:yi}),u.jsx("span",{title:d==null?void 0:d.url,children:(d==null?void 0:d.capabilityError)||(F?tr?"点击画面开始控制后,单击和拖拽才会发送到本机":"本机屏幕":d==null?void 0:d.url)||ee||"等待可观看的直播会话"})]}),(d==null?void 0:d.url)&&!F&&u.jsx(Di,{size:13,"aria-hidden":"true"})]}),d&&(N?u.jsxs("button",{type:"button",className:"browser-live-control-button is-return",onClick:()=>void di(),disabled:P,children:[P&&u.jsx(Se,{size:14,className:"spin","aria-hidden":"true"}),F?"结束控制":"归还给 Agent"]}):u.jsxs("button",{type:"button",className:"browser-live-control-button",onClick:()=>void Pr(),disabled:!zr||P||d.state!=="agent-controlled"||d.availability!=="ready",children:[P&&u.jsx(Se,{size:14,className:"spin","aria-hidden":"true"}),d.controlledByAnotherViewer?"其他设备操作中":F?"开始控制":"接管浏览器"]}))]}),(ee??Cr)&&u.jsx("div",{className:"browser-live-error",role:"alert",children:ee??Cr})]}),De&&u.jsx("div",{className:"browser-live-unlock-backdrop",role:"presentation",onMouseDown:i=>{i.target===i.currentTarget&&!de&&(be(!1),D(""),Le(null))},children:u.jsxs("form",{className:"browser-live-unlock-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"browser-live-unlock-title",onSubmit:i=>{i.preventDefault(),fi()},children:[u.jsxs("div",{className:"browser-live-unlock-heading",children:[u.jsx(Xr,{size:18,"aria-hidden":"true"}),u.jsx("strong",{id:"browser-live-unlock-title",children:"远程解锁 Windows"})]}),u.jsx("label",{htmlFor:"browser-live-unlock-password",children:"Windows 密码或 PIN"}),u.jsx("input",{id:"browser-live-unlock-password",type:"password",autoComplete:"off",autoFocus:!0,maxLength:256,value:he,disabled:de,onChange:i=>D(i.target.value)}),Ne&&u.jsx("p",{role:"alert",children:Ne}),u.jsxs("div",{className:"browser-live-unlock-actions",children:[u.jsx("button",{type:"button",className:"browser-live-control-button is-return",disabled:de,onClick:()=>{be(!1),D(""),Le(null)},children:"取消"}),u.jsxs("button",{type:"submit",className:"browser-live-control-button",disabled:de||!he,children:[de&&u.jsx(Se,{size:14,className:"spin","aria-hidden":"true"}),"解锁"]})]})]})})]}),document.body)}export{Pn as decodePcm16Base64,Yn as default,Nn as encodePcm16Base64,qn as isStaleControlReply,An as prepareVoiceAudio,zn as remoteFieldContains,ri as remoteShortcutModifier,ti as selectBrowserLiveSessionId,Dn as shouldOfferVisualTakeover,Fn as touchScrollDelta};
@@ -1 +0,0 @@
1
- import{r as c,d as Q,j as e,R as V,e as X,A as K,P as W,f as Y}from"./index-DKm9ESDq.js";import{C as Z,a as G}from"./types-VnQ_cKrp.js";import{a as ee,D as te,P as ae,b as se,c as re,d as le,e as ne,N as oe,f as ce,g as ie,h as de,i as he,F as ue,j as pe,S as je}from"./file-types-DKkhMnUV.js";import{X as B}from"./x-DP1nC4qG.js";import{A as xe,C as fe,F as ge}from"./trash-2-BrfgMjfL.js";import{c as U,A as O,U as me}from"./collaboration-CQhzjwS_.js";import{C as _}from"./chevron-down-DhZV290h.js";const be={folder:{icon:ue,label:"文件夹"},code:{icon:he,label:"代码文件"},style:{icon:X,label:"样式文件"},image:{icon:de,label:"图片文件"},video:{icon:ie,label:"视频文件"},audio:{icon:ce,label:"音频文件"},markdown:{icon:oe,label:"Markdown 文件"},text:{icon:ne,label:"文本文件"},json:{icon:le,label:"JSON 文件"},archive:{icon:re,label:"压缩文件"},spreadsheet:{icon:se,label:"表格文件"},presentation:{icon:ae,label:"演示文件"},database:{icon:te,label:"数据库文件"},file:{icon:ee,label:"文件"}};function ve(t,s){return s==="directory"?"folder":pe(t)}const M=t=>t.replace(/\\/g,"/").replace(/\/+$/,"")||"/";function ye(t,s){for(const f of s){if(!(f!=null&&f.trim()))continue;const g=M(f);if(g.split("/").some(u=>u==="."||u===".."))continue;const m=t.map(M).filter(u=>g===u||g.startsWith(u==="/"?"/":`${u}/`)).sort((u,p)=>p.length-u.length)[0];if(m)return{root:m,current:g}}const o=t[0]?M(t[0]):"";return{root:o,current:o}}function Ne(t,s){const o=M(t),f=M(s),m=[{label:o==="/"?"/":o.split("/").filter(Boolean).pop()||o,path:o}];if(f===o)return m;const u=f.slice(o==="/"?1:o.length+1);let p=o;for(const d of u.split("/").filter(Boolean))p=p==="/"?`/${d}`:`${p}/${d}`,m.push({label:d,path:p});return m}function ke({open:t,initialPath:s,onCancel:o,onConfirm:f}){const[g,m]=c.useState([]),[u,p]=c.useState(""),[d,j]=c.useState(""),[w,l]=c.useState([]),[i,x]=c.useState(!1),[k,v]=c.useState(""),[a,h]=c.useState(!1),[C,y]=c.useState(!1),D=c.useMemo(()=>u&&d?Ne(u,d):[],[u,d]),S=async n=>{if(window.agentApi){x(!0),y(!1),v(""),j(n),l([]);try{const b=await window.agentApi.listProjectDirectories(n);l(b),y(!0)}catch(b){v(b instanceof Error?b.message:"无法读取目录")}finally{x(!1)}}};if(c.useEffect(()=>{if(!t||!window.agentApi)return;let n=!1;return x(!0),v(""),p(""),j(""),y(!1),l([]),window.agentApi.getProjectPickerLocation().then(async({roots:b,initialPath:E})=>{if(n)return;m(b);const T=ye(b,[s,E]);p(T.root),T.current?await S(T.current):v("未配置可用的宿主机目录")}).catch(b=>{n||v(b instanceof Error?b.message:"无法读取宿主机目录")}).finally(()=>{n||x(!1)}),()=>{n=!0}},[t,s]),c.useEffect(()=>{if(!t)return;const n=b=>{b.key==="Escape"&&o()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,o]),!t)return null;const $=n=>{p(n),S(n)},I=()=>{D.length<=1||S(D[D.length-2].path)},z=async()=>{if(!(!d||!C||a)){h(!0),v("");try{await f(d)}catch(n){v(n instanceof Error?n.message:"项目导入失败")}finally{h(!1)}}};return Q.createPortal(e.jsx("div",{className:"host-project-picker-backdrop",role:"presentation",onMouseDown:n=>{n.target===n.currentTarget&&o()},children:e.jsxs("section",{className:"host-project-picker",role:"dialog","aria-modal":"true","aria-labelledby":"host-project-picker-title",children:[e.jsxs("header",{className:"host-project-picker-header",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"host-project-picker-title",children:"选择宿主机项目"}),e.jsx("p",{children:"文件将直接在运行 AgentRoam 的机器上读写"})]}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:o,"aria-label":"关闭目录选择器",title:"关闭",children:e.jsx(B,{size:16,"aria-hidden":"true"})})]}),g.length>1&&e.jsxs("label",{className:"host-project-picker-root",children:[e.jsx("span",{children:"根目录"}),e.jsx("select",{value:u,onChange:n=>$(n.target.value),children:g.map(n=>e.jsx("option",{value:n,children:n},n))})]}),e.jsxs("nav",{className:"host-project-picker-nav","aria-label":"当前目录",children:[e.jsx("button",{type:"button",className:"ui-icon-button",onClick:I,disabled:D.length<=1,"aria-label":"返回上级目录",title:"返回上级目录",children:e.jsx(xe,{size:16,"aria-hidden":"true"})}),e.jsxs("div",{className:"host-project-picker-breadcrumbs",children:[!d&&e.jsx("span",{children:i?"正在定位工作目录…":"未能加载工作目录"}),D.map((n,b)=>e.jsxs("span",{children:[b>0&&e.jsx("i",{children:"/"}),e.jsx("button",{type:"button",onClick:()=>void S(n.path),children:n.label})]},n.path))]}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>d&&void S(d),disabled:!d||i,"aria-label":"刷新目录",title:"刷新目录",children:e.jsx(V,{size:15,"aria-hidden":"true"})})]}),u==="/"&&e.jsx("div",{className:"host-project-picker-warning",children:"当前允许访问宿主机根目录,请谨慎选择项目。"}),e.jsx("div",{className:"host-project-picker-list","aria-busy":i,children:i?e.jsx("div",{className:"host-project-picker-state",children:"正在读取目录…"}):k?e.jsx("div",{className:"host-project-picker-state is-error",children:k}):w.length===0?e.jsx("div",{className:"host-project-picker-state",children:"此目录为空"}):w.map(n=>{const b=ve(n.name,n.kind),{icon:E,label:T}=be[b],R=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`host-project-picker-entry-icon is-${b}`,"aria-hidden":"true",children:e.jsx(E,{size:18,strokeWidth:1.8})}),e.jsx("span",{className:"host-project-picker-name",children:n.name})]});return n.kind==="file"?e.jsx("div",{className:"host-project-picker-row is-file",title:T,children:R},`${n.name}:${n.path}`):e.jsxs("button",{type:"button",className:"host-project-picker-row is-directory",onClick:()=>void S(n.path),title:T,children:[R,n.hasChildren&&e.jsx("span",{className:"host-project-picker-chevron","aria-hidden":"true",children:e.jsx(fe,{size:16})})]},`${n.name}:${n.path}`)})}),e.jsxs("footer",{className:"host-project-picker-footer",children:[e.jsx("code",{title:d,children:d}),e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"host-project-picker-cancel",onClick:o,children:"取消"}),e.jsx("button",{type:"button",className:"host-project-picker-confirm",disabled:!d||!C||i||a,onClick:()=>void z(),children:a?"正在导入…":"选择此文件夹"})]})]})]})}),document.body)}function we(t,s){return[...new Map([...t,...s].map(o=>[o.id,o])).values()]}function Ce({value:t,onChange:s}){const[o,f]=c.useState(""),[g,m]=c.useState({data:[],nextCursor:null,total:0}),[u,p]=c.useState(!0),[d,j]=c.useState(""),[w,l]=c.useState(0),i=c.useRef(0),x=c.useRef(!1);c.useEffect(()=>{const a=++i.current;let h=!0;x.current=!0,p(!0),j(""),m({data:[],nextCursor:null,total:0});const C=setTimeout(()=>{U({action:"sessionCatalog",query:o,limit:20}).then(y=>{h&&a===i.current&&m(y)}).catch(y=>{h&&a===i.current&&j(y instanceof Error?y.message:"无法加载会话")}).finally(()=>{h&&a===i.current&&(x.current=!1,p(!1))})},o?200:0);return()=>{h=!1,clearTimeout(C)}},[o,w]);const k=async()=>{if(x.current||!g.nextCursor)return;const a=i.current;x.current=!0,p(!0),j("");try{const h=await U({action:"sessionCatalog",query:o,limit:20,cursor:g.nextCursor});a===i.current&&m(C=>({...h,data:we(C.data,h.data)}))}catch(h){a===i.current&&j(h instanceof Error?h.message:"加载更多失败")}finally{a===i.current&&(x.current=!1,p(!1))}},v=new Set(t.map(a=>a.id));return e.jsxs("section",{className:"collab-monitor-picker","aria-label":"关联原始会话",children:[e.jsx("div",{className:"collab-monitor-heading",children:e.jsxs("strong",{children:["关联原始会话 ",e.jsxs("small",{children:["选填 · 已选 ",t.length]})]})}),e.jsx("p",{className:"collab-muted",children:"运行中的在前。关联后作为监控对象,恢复或交接时才介入。"}),t.length>0&&e.jsx("div",{className:"collab-monitor-selected","aria-label":"已选会话",children:t.map(a=>e.jsxs("span",{title:`${O[a.agentType]} · ${a.cwd}`,children:[e.jsx(K,{agentType:a.agentType,size:14}),e.jsx("span",{children:a.title}),e.jsx("button",{type:"button","aria-label":`取消关联${a.title}`,onClick:()=>s(t.filter(h=>h.id!==a.id)),children:e.jsx(B,{size:13})})]},a.id))}),e.jsxs("label",{className:"collab-monitor-search",children:[e.jsx(je,{size:15}),e.jsx("input",{"aria-label":"搜索所有原始会话",placeholder:"搜索所有会话的标题、目录或 Agent",value:o,onChange:a=>f(a.target.value)})]}),e.jsxs("div",{className:"collab-monitor-results","aria-label":"原始会话候选","aria-busy":u,onScroll:a=>{const h=a.currentTarget;h.scrollHeight-h.scrollTop-h.clientHeight<64&&k()},children:[g.data.map(a=>e.jsxs("label",{className:"collab-monitor-row",children:[e.jsx("input",{type:"checkbox","aria-label":`关联${a.title}`,checked:v.has(a.id),disabled:!v.has(a.id)&&t.length>=200,onChange:h=>s(h.target.checked?[...t,{id:a.id,agentType:a.agentType,title:a.title,cwd:a.cwd,projectId:a.projectId}]:t.filter(C=>C.id!==a.id))}),e.jsx(K,{agentType:a.agentType,size:18}),e.jsxs("span",{children:[e.jsx("strong",{children:a.title}),e.jsxs("small",{children:[O[a.agentType]," · ",a.cwd]})]}),e.jsx("em",{className:a.status==="running"?"is-running":"",children:a.status==="running"?"运行中":a.status==="failed"?"异常":a.status==="completed"?"已完成":"空闲"})]},a.id)),!u&&!d&&!g.data.length&&e.jsx("p",{className:"collab-muted",children:o?"没有匹配的会话":"暂无可接入会话"}),u&&e.jsx("p",{className:"collab-muted",role:"status",children:"正在加载会话…"}),g.nextCursor&&!d&&e.jsxs("button",{type:"button",className:"collab-monitor-more",disabled:u,onClick:()=>void k(),children:["加载更多(已显示 ",g.data.length," / ",g.total,")"]})]}),d&&e.jsxs("p",{className:"collab-error",role:"alert",children:[d," ",e.jsx("button",{type:"button",onClick:()=>l(a=>a+1),children:"重新加载"})]})]})}function P({children:t,...s}){return e.jsxs("span",{className:"collab-select",children:[e.jsx("select",{...s,children:t}),e.jsx(_,{size:16,"aria-hidden":"true"})]})}function H(t){return{id:crypto.randomUUID(),name:t===0?"群主":`成员 ${t}`,agentType:"codex",role:""}}function Se({member:t,index:s,owner:o,supervisor:f,health:g,onChange:m,onRemove:u}){const[p,d]=c.useState([]),[j,w]=c.useState([]);return c.useEffect(()=>{let l=!0;return d([]),w([]),t.agentType==="customer-agent"?(window.agentApi.getSettings().then(i=>{l&&w(i.profiles.map(({id:x,name:k,modelId:v})=>({id:x,name:k,modelId:v})))}).catch(()=>{}),()=>{l=!1}):(window.agentApi.listAgentModels(t.agentType).then(i=>{l&&d(i.models)}).catch(()=>{}),()=>{l=!1})},[t.agentType]),e.jsxs("fieldset",{className:"collab-member-editor",children:[e.jsxs("legend",{children:[o?e.jsx(Z,{size:14}):e.jsx(me,{size:14}),o?"群主":`成员 ${s}`,f?" · 监工":""]}),u&&e.jsx("button",{type:"button",className:"collab-remove","aria-label":`移除${t.name}`,onClick:u,children:e.jsx(B,{size:16})}),e.jsxs("div",{className:"collab-editor-fields",children:[e.jsxs("label",{children:["名称",e.jsx("input",{value:t.name,maxLength:100,onChange:l=>m({...t,name:l.target.value}),required:!0})]}),e.jsxs("label",{children:["Agent",e.jsx(P,{value:t.agentType,onChange:l=>m({...t,agentType:l.target.value,model:void 0,profileId:void 0}),children:G.map(l=>{var i,x;return e.jsxs("option",{value:l,disabled:((i=g.find(k=>k.agentType===l))==null?void 0:i.available)===!1,children:[O[l],((x=g.find(k=>k.agentType===l))==null?void 0:x.available)===!1?" · 不可用":""]},l)})})]}),e.jsxs("label",{className:"collab-model-field",children:["模型",t.agentType==="customer-agent"?e.jsxs(P,{value:t.profileId||"",onChange:l=>{const i=j.find(x=>x.id===l.target.value);m({...t,profileId:i==null?void 0:i.id,model:i?{id:i.modelId}:void 0})},children:[e.jsx("option",{value:"",children:"沿用默认模型"}),j.map(l=>e.jsxs("option",{value:l.id,children:[l.name," · ",l.modelId]},l.id))]}):e.jsxs(P,{value:t.model?`${t.model.providerID||""}|${t.model.id}`:"",onChange:l=>{const i=p.find(x=>`${x.providerID||""}|${x.id}`===l.target.value);m({...t,model:i?{id:i.id,...i.providerID?{providerID:i.providerID}:{}}:void 0})},children:[e.jsx("option",{value:"",children:"沿用默认模型"}),p.map(l=>e.jsxs("option",{value:`${l.providerID||""}|${l.id}`,children:[l.displayName||l.id,l.providerDisplayName?` · ${l.providerDisplayName}`:""]},`${l.providerID}|${l.id}`))]})]})]}),e.jsxs("details",{className:"collab-role-options",open:f||void 0,children:[e.jsxs("summary",{children:[e.jsx("span",{children:"定位与职责"}),e.jsx("span",{className:"collab-muted",children:t.role.trim()?"已设置":o?"默认安排与汇总":"留空由群主分配"}),e.jsx(_,{size:14})]}),e.jsx("textarea",{"aria-label":`${o?"群主":`成员 ${s}`}的定位与职责(选填)`,rows:2,maxLength:8e3,value:t.role,placeholder:f?"重点看什么:异常暂停、任务交接和交付。允许怎么处理:原任务内自动恢复、继续、协调交接;业务取舍或无法恢复时提醒我决策。":o?"负责拆解目标、分配任务、验收和汇总成果":"例如:负责实现接口;留空由群主自动分配",onChange:l=>m({...t,role:l.target.value})}),f&&e.jsx("p",{className:"collab-muted",children:"在职责中写明关注内容、判断标准、允许的恢复与交接,以及何时提醒你或等待决策。"})]})]})}function ze({cwd:t,initialGroup:s,health:o,onClose:f,onCreated:g}){var q;const[m,u]=c.useState((s==null?void 0:s.name)||""),[p,d]=c.useState((s==null?void 0:s.cwd)||t||""),[j,w]=c.useState(()=>s?structuredClone(s.members):[H(0),H(1)]),[l,i]=c.useState((s==null?void 0:s.ownerId)||j[0].id),[x,k]=c.useState((s==null?void 0:s.maxParallel)||3),[v,a]=c.useState(()=>{var r;return structuredClone(((r=s==null?void 0:s.monitoring)==null?void 0:r.targets)??[])}),[h,C]=c.useState(s?((q=s.monitoring)==null?void 0:q.supervisorId)??"":j[0].id),[y,D]=c.useState(!1),[S,$]=c.useState(""),[I,z]=c.useState(!1),[n,b]=c.useState(!!(s!=null&&s.cwd)),[E,T]=c.useState(!1),R=async()=>{if($(""),Y()){z(!0);return}T(!0);try{const r=await window.agentApi.openFileDialog();r&&(d(r),b(!0))}catch(r){$(r instanceof Error?r.message:"无法选择工作目录")}finally{T(!1)}};return c.useEffect(()=>{const r=N=>{N.key==="Escape"&&!y&&!I&&!E&&f()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[f,y,I,E]),e.jsxs("div",{className:"collab-modal-backdrop",onMouseDown:r=>{r.target===r.currentTarget&&!y&&f()},children:[e.jsxs("form",{className:"collab-create",role:"dialog","aria-modal":"true","aria-labelledby":"collab-create-title",onSubmit:async r=>{r.preventDefault(),D(!0),$("");try{if(!p.trim())throw new Error("请先选择工作目录");const N=j.find(L=>{var F;return((F=o.find(J=>J.agentType===L.agentType))==null?void 0:F.available)===!1});if(N&&!s)throw new Error(`${N.name} 选择的 Agent 当前不可用`);const A=await U({...s?{action:"updateGroup",groupId:s.id}:{action:"createGroup"},group:{name:m.trim()||"协作群",cwd:p.trim(),ownerId:l,members:j,maxParallel:Math.min(x,j.length),...v.length?{monitoring:{targets:v,...h?{supervisorId:h}:{}}}:{}}});g(A)}catch(N){$(N instanceof Error?N.message:String(N))}finally{D(!1)}},children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("span",{className:"collab-eyebrow",children:"一起完成一件事"}),e.jsx("h2",{id:"collab-create-title",children:s?"修改协作群":"拉个协作群"})]}),e.jsx("button",{type:"button","aria-label":"关闭群设置",onClick:f,disabled:y,children:e.jsx(B,{size:20})})]}),e.jsxs("div",{className:"collab-create-scroll",children:[e.jsxs("div",{className:"collab-group-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"群名称"}),e.jsx("input",{autoFocus:!0,value:m,maxLength:100,placeholder:"例如:产品开发小组",onChange:r=>u(r.target.value)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"工作目录"}),e.jsxs("button",{type:"button",className:"collab-directory-picker","aria-label":"选择工作目录","aria-haspopup":"dialog","aria-expanded":I,title:p||"选择工作目录",disabled:y||E,onClick:()=>void R(),children:[e.jsx(ge,{size:16,"aria-hidden":"true"}),e.jsx("span",{className:p?void 0:"collab-muted",children:E?"正在选择…":p||"选择工作目录"}),e.jsx(W,{size:16,"aria-hidden":"true"})]})]})]}),e.jsx("p",{className:"collab-create-hint collab-muted",children:s?"配置保存后用于新讨论,已有讨论和聊天记录保留。":"Agent 可重复加入,职责留空由群主分配。"}),j.map((r,N)=>e.jsx(Se,{member:r,index:N,owner:r.id===l,supervisor:v.length>0&&r.id===h,health:o,onChange:A=>w(L=>L.map(F=>F.id===A.id?A:F)),onRemove:r.id!==l&&j.length>2?()=>{r.id===h&&C(""),w(A=>A.filter(L=>L.id!==r.id))}:void 0},r.id)),e.jsxs("div",{className:"collab-create-actions",children:[e.jsxs("label",{children:["群主",e.jsx(P,{value:l,onChange:r=>i(r.target.value),children:j.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))})]}),e.jsxs("button",{type:"button",disabled:j.length>=20,onClick:()=>w(r=>[...r,H(r.length)]),children:[e.jsx(W,{size:16}),"添加成员"]}),e.jsxs("label",{children:["最多同时工作",e.jsx(P,{value:Math.min(x,j.length),onChange:r=>k(Number(r.target.value)),children:j.map((r,N)=>e.jsxs("option",{value:N+1,children:[N+1," 人"]},N+1))})]})]}),e.jsx(Ce,{value:v,onChange:a}),v.length>0&&e.jsxs("label",{className:"collab-supervisor-select",children:["监工",e.jsxs(P,{"aria-label":"选择监工成员",value:h,onChange:r=>C(r.target.value),children:[e.jsx("option",{value:"",children:"仅关联,不启用监工"}),j.map(r=>e.jsxs("option",{value:r.id,children:[r.name," · ",O[r.agentType]]},r.id))]}),e.jsx("small",{className:"collab-muted",children:"复用该成员的 Agent、模型和职责,关闭看板后继续监管。"})]})]}),S&&e.jsx("p",{className:"collab-error",role:"alert",children:S}),e.jsxs("footer",{children:[e.jsx("span",{className:"collab-muted",children:"职责可以留空,发送任务后由群主分配。"}),e.jsx("button",{className:"collab-primary",disabled:y||E||!p.trim(),type:"submit",children:y?"正在保存…":s?"保存修改":"创建并打开群"})]})]}),e.jsx(ke,{open:I,initialPath:n?p:void 0,onCancel:()=>z(!1),onConfirm:r=>{d(r),b(!0),z(!1),$("")}})]})}export{ze as C,ke as H};
@@ -1 +0,0 @@
1
- import{r as t,u as P,j as e,R as I,P as S,A as O,d as g}from"./index-DKm9ESDq.js";import{C as $,a as _,b as B}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{C as G}from"./CollaborationCreateDialog-BmgYdwe7.js";import{c as R,U as z,A as T}from"./collaboration-CQhzjwS_.js";import{p as M}from"./SessionDashboardBridge-Bx4EXtos.js";import{X as H}from"./x-DP1nC4qG.js";import{S as U,F as Y}from"./file-types-DKkhMnUV.js";import{P as q,T as F}from"./trash-2-BrfgMjfL.js";import{C as Q}from"./types-VnQ_cKrp.js";import{A as X}from"./arrow-right-Cqqb1zqH.js";import"./chevron-down-DhZV290h.js";function J(){const[u,m]=t.useState([]),[x,j]=t.useState(!0),[h,n]=t.useState(""),i=t.useRef(0),r=t.useCallback(async()=>{const l=++i.current;j(!0);try{const o=await R({action:"groups"});i.current===l&&(m(o),n(""))}catch(o){i.current===l&&n(o instanceof Error?o.message:String(o))}finally{i.current===l&&j(!1)}},[]);return t.useEffect(()=>{r();const l=()=>{r()};return window.addEventListener("focus",l),()=>{i.current++,window.removeEventListener("focus",l)}},[r]),{groups:u,loading:x,error:h,refresh:r}}function re({onOpen:u,onChanged:m,onClose:x,cwd:j}){const{groups:h,loading:n,error:i,refresh:r}=J(),[l,o]=t.useState(""),[c,b]=t.useState(null),[f,w]=t.useState(null),[p,y]=t.useState(!1),[v,N]=t.useState(""),[D,L]=t.useState([]),E=P(s=>s.skin);t.useEffect(()=>{!n&&window.parent!==window&&window.parent.postMessage({type:$},window.location.origin)},[n]),t.useEffect(()=>{document.documentElement.setAttribute("data-skin",E)},[E]),t.useEffect(()=>{let s=!0;return window.agentApi.getRuntimeHealth().then(a=>{s&&L(a)}).catch(()=>{}),()=>{s=!1}},[]);const C=s=>{u?u(s):window.parent!==window?window.parent.postMessage({type:_,groupId:s.id,title:s.name},window.location.origin):location.assign(`?view=collaboration&groupId=${encodeURIComponent(s.id)}`)},A=(s,a)=>{m==null||m(s,a),window.parent!==window&&window.parent.postMessage({type:B,groupId:s,...a?{title:a.name}:{deleted:!0}},window.location.origin),r()},k=h.filter(s=>`${s.name} ${s.cwd} ${s.members.map(a=>a.name).join(" ")}`.toLowerCase().includes(l.trim().toLowerCase()));return e.jsxs("main",{className:"collab-dashboard",children:[e.jsxs("header",{className:"collab-dashboard-heading",children:[e.jsxs("div",{children:[e.jsx("span",{className:"collab-eyebrow",children:"协作空间"}),e.jsxs("h1",{children:["群聊列表 ",e.jsx("small",{children:h.length})]}),e.jsx("p",{className:"collab-muted",children:"找到你的群,继续上次的协作。"})]}),e.jsxs("div",{className:"collab-dashboard-tools",children:[e.jsx("button",{onClick:()=>M({kind:"dashboard"}),children:"Dashboard"}),e.jsx("button",{"aria-label":"刷新群列表",title:"刷新群列表",disabled:n,onClick:()=>void r(),children:e.jsx(I,{size:17})}),e.jsxs("button",{className:"collab-primary",onClick:()=>b("new"),children:[e.jsx(S,{size:17}),"新增群聊"]}),x&&e.jsx("button",{"aria-label":"关闭群看板",onClick:x,children:e.jsx(H,{size:18})})]})]}),e.jsxs("label",{className:"collab-dashboard-search",children:[e.jsx(U,{size:17}),e.jsx("input",{"aria-label":"搜索群聊",placeholder:"搜索群名、成员或工作目录",value:l,onChange:s=>o(s.target.value)})]}),i&&e.jsxs("div",{className:"collab-error",role:"alert",children:[i,e.jsx("button",{onClick:()=>void r(),children:"重试"})]}),n&&h.length===0?e.jsx("div",{className:"collab-dashboard-empty",role:"status",children:"正在加载已保存的群…"}):!i&&k.length===0?e.jsxs("div",{className:"collab-dashboard-empty",children:[e.jsx(z,{size:32}),e.jsx("h2",{children:l?"没有找到匹配的群":"还没有协作群"}),e.jsx("p",{children:l?"换个关键词试试。":"选一位群主和成员,一起完成任务。"}),!l&&e.jsxs("button",{className:"collab-primary",onClick:()=>b("new"),children:[e.jsx(S,{size:16}),"新建第一个群"]})]}):e.jsx("section",{className:"collab-dashboard-grid","aria-label":"已保存的群聊","aria-busy":n,children:k.map(s=>{const a=s.members.find(d=>d.id===s.ownerId);return e.jsxs("article",{className:"collab-group-card",children:[e.jsxs("div",{className:"collab-card-heading",children:[e.jsxs("button",{className:"collab-card-title",onClick:()=>C(s),title:s.name,children:[e.jsx(z,{size:20}),e.jsx("h2",{children:s.name})]}),e.jsxs("div",{className:"collab-card-actions",children:[e.jsx("button",{"aria-label":`修改${s.name}`,title:"修改群设置",onClick:()=>b(s),children:e.jsx(q,{size:16})}),e.jsx("button",{"aria-label":`删除${s.name}`,title:"删除群聊",onClick:()=>{N(""),w(s)},children:e.jsx(F,{size:16})})]})]}),e.jsxs("p",{className:"collab-card-owner",children:[e.jsx(Q,{size:14}),e.jsxs("span",{children:["群主 · ",a==null?void 0:a.name]}),e.jsx("span",{className:"collab-muted",children:a&&T[a.agentType]})]}),e.jsxs("div",{className:"collab-card-members","aria-label":`${s.members.length} 名群成员`,children:[s.members.slice(0,7).map(d=>e.jsx("span",{title:`${d.name} · ${T[d.agentType]}`,children:e.jsx(O,{agentType:d.agentType,size:18})},d.id)),e.jsxs("small",{children:[s.members.length," 人 · 最多 ",s.maxParallel," 人并行"]})]}),e.jsxs("p",{className:"collab-card-path",title:s.cwd,children:[e.jsx(Y,{size:14}),e.jsx("span",{children:s.cwd})]}),e.jsxs("footer",{children:[e.jsxs("time",{dateTime:s.createdAt,children:[new Date(s.createdAt).toLocaleDateString("zh-CN")," 创建"]}),e.jsxs("button",{onClick:()=>C(s),children:["进入群聊",e.jsx(X,{size:16})]})]})]},s.id)})}),c&&g.createPortal(e.jsx(G,{cwd:j,initialGroup:c==="new"?void 0:c,health:D,onClose:()=>b(null),onCreated:s=>{const a=c==="new";b(null),A(s.id,s),a&&C(s)}},c==="new"?"new":c.id),document.body),f&&g.createPortal(e.jsx("div",{className:"collab-modal-backdrop",children:e.jsxs("section",{className:"collab-delete-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"collab-delete-title","aria-describedby":"collab-delete-description",children:[e.jsxs("h2",{id:"collab-delete-title",children:["删除“",f.name,"”?"]}),e.jsx("p",{id:"collab-delete-description",children:"删除后将停止监工并取消关联定时任务,原始业务会话和工作目录文件会保留。进行中的协作需要先停止。"}),v&&e.jsx("p",{className:"collab-error",role:"alert",children:v}),e.jsxs("footer",{children:[e.jsx("button",{autoFocus:!0,disabled:p,onClick:()=>w(null),children:"取消"}),e.jsx("button",{className:"collab-delete-confirm",disabled:p,onClick:async()=>{y(!0),N("");try{await R({action:"deleteGroup",groupId:f.id}),A(f.id),w(null)}catch(s){N(s instanceof Error?s.message:String(s))}finally{y(!1)}},children:p?"正在删除…":"确认删除"})]})]})}),document.body)]})}export{re as default};
@@ -1,6 +0,0 @@
1
- import{c as Re,r as c,j as e,A as W,k as Ce,l as Ae,u as Le,P as xe,M as Pe,m as Oe}from"./index-DKm9ESDq.js";import{r as Ie,p as Fe,C as Be}from"./artifact-links-73OZyi5W.js";import{p as _e,a as Ue,n as Ge,M as He,H as We,S as Ye}from"./composer-file-routing-D9orqwzY.js";import{p as Ke}from"./SessionDashboardBridge-Bx4EXtos.js";import{S as Ve}from"./shield-check-CrjI2wPR.js";import{A as Z,U as X,c as R,D as je}from"./collaboration-CQhzjwS_.js";import{X as $e}from"./x-DP1nC4qG.js";import{b as ie,C as Ze}from"./types-VnQ_cKrp.js";import{c as Je}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{L as ve}from"./loader-circle-DIW9tlEz.js";import{I as Qe}from"./image-plus-nplydLA5.js";/**
2
- * @license lucide-react v0.468.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Xe=Re("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]),et=8;function tt(s,u){return s.split(/(\[[^\]\n]+\]\([^\n)]+\))/g).flatMap(r=>{const a=_e(r),m=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(r);if(!m||a.some(f=>f.type==="artifact"||f.type==="link"))return a;const p=m[2].trim().replace(/^<|>$/g,"");if(/^[A-Za-z][\w+.-]*:/.test(p)&&!/^[A-Za-z]:[\\/]/.test(p))return a;const n=Ie(p,u);return n?[{type:"artifact",label:m[1],path:n,raw:r}]:a})}function le({text:s,cwd:u}){const r=c.useId(),a=c.useRef(null),[m,p]=c.useState(!1),[n,f]=c.useState(!1);return c.useEffect(()=>{const o=a.current;if(!o)return;const l=()=>{const $=Number.parseFloat(getComputedStyle(o).lineHeight);p(o.scrollHeight>$*et+1)};l();const h=new ResizeObserver(l);return h.observe(o),()=>h.disconnect()},[s]),e.jsxs(e.Fragment,{children:[e.jsx("div",{id:r,ref:a,className:"collab-message-text","data-collapsed":!n,children:tt(s,u).map((o,l)=>{if(o.type==="text")return o.value;if(o.type==="code")return e.jsx("code",{children:o.value},l);if(o.type==="link")return e.jsx("a",{href:o.href,target:"_blank",rel:"noopener noreferrer",children:o.label},l);const h=Ie(o.path,u);return h?e.jsx("button",{type:"button",className:"collab-message-path",title:o.line?`${h}:${o.line}`:h,"aria-label":`查看文件:${o.label}`,onClick:()=>{Fe(h)||window.agentApi.openExternal(/^https?:\/\//i.test(h)?h:`file://${h}`)},children:o.label},l):o.raw})}),m&&e.jsx("button",{type:"button",className:"collab-message-toggle","aria-expanded":n,"aria-controls":r,onClick:()=>f(o=>!o),children:n?"收起":"展开全文"})]})}function st({group:s}){var r;if(!((r=s.monitoring)!=null&&r.targets.length))return null;const u=s.members.find(a=>{var m;return a.id===((m=s.monitoring)==null?void 0:m.supervisorId)});return e.jsxs("div",{className:"collab-supervision-summary",children:[e.jsxs("div",{children:[e.jsx(Ve,{size:14}),e.jsxs("span",{children:[u?`监工 · ${u.name}`:"已关联"," · ",s.monitoring.targets.length," 条原始会话"]})]}),e.jsx("button",{onClick:()=>Ke({kind:"dashboard"}),children:"查看监工与决策"})]})}function ye(s,u,r){var f,o;const a=r==="sender"?s.senderAgentType:s.recipientAgentType;if(a)return a;const m=s[r];if(!m||m==="你"||m===u.name)return;const p=s.direction==="received"?"sender":s.direction==="sent"?"recipient":void 0;if(r===p){const l=((f=u.monitoring)==null?void 0:f.targets.filter(h=>(s.sessionId?h.id===s.sessionId:h.title===m)&&(m===s.sessionTitle||m===h.title)))??[];if(l.length===1)return l[0].agentType}const n=u.members.filter(l=>l.name===m);if(n.length===1)return n[0].agentType;if(m==="监工")return(o=u.members.find(l=>{var h;return l.id===((h=u.monitoring)==null?void 0:h.supervisorId)}))==null?void 0:o.agentType}function nt({message:s,group:u}){const r=ye(s,u,"sender"),a=ye(s,u,"recipient"),m=r?`${s.sender} · ${Z[r]}`:s.sender,p=a?`${s.recipient} · ${Z[a]}`:s.recipient,n=s.sender==="你"&&!r,f=s.direction==="received"?"收到消息":s.direction==="sent"?"发出消息":"监工动态";return e.jsxs("article",{className:`collab-message collab-supervision-message is-${s.direction}`,"data-supervision-message":s.id,"aria-label":`${f}:${s.title}`,children:[e.jsx("span",{className:`collab-avatar collab-supervision-avatar${n?" collab-avatar--user":""}`,role:"img","aria-label":m,title:m,children:r?e.jsx(W,{agentType:r,size:20}):n?"你":e.jsx(X,{size:18,"aria-hidden":"true"})}),e.jsxs("div",{className:"collab-message-body",children:[e.jsxs("div",{className:"collab-supervision-message-heading",children:[e.jsx("strong",{children:s.title}),e.jsx("span",{children:s.historical?"历史监工记录":f})]}),e.jsxs("div",{className:"collab-supervision-message-route","aria-label":`${s.sender}${s.recipient?` → ${s.recipient}`:""}`,children:[e.jsxs("span",{className:"collab-supervision-participant",title:m,children:[r&&e.jsx(W,{agentType:r,size:13}),e.jsx("span",{children:s.sender})]}),s.recipient&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsxs("span",{className:"collab-supervision-participant",title:p,children:[a&&e.jsx(W,{agentType:a,size:13}),e.jsx("span",{children:s.recipient})]})]})]}),s.sessionTitle&&e.jsxs("div",{className:"collab-supervision-message-source",title:s.sessionTitle,children:["来源会话:",s.sessionTitle]}),e.jsx(le,{text:s.content,cwd:s.cwd||u.cwd})]}),e.jsx("time",{dateTime:s.createdAt,title:new Date(s.createdAt).toLocaleString("zh-CN"),children:new Date(s.createdAt).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})})]})}function we(s,u){return[...new Map([...s,...u].map(r=>[r.id,r])).values()].sort((r,a)=>r.createdAt.localeCompare(a.createdAt)||(r.sequence??0)-(a.sequence??0)||r.id.localeCompare(a.id))}function at(s,u){return[...s.filter(r=>r.kind!=="progress").map(r=>({kind:"discussion",message:r})),...u.map(r=>({kind:"supervision",message:r}))].sort((r,a)=>r.message.createdAt.localeCompare(a.message.createdAt)||(r.kind==="supervision"&&a.kind==="supervision"?(r.message.sequence??0)-(a.message.sequence??0):0)||r.message.id.localeCompare(a.message.id))}function rt(s){const u=Ce(),[r,a]=c.useState([]),[m,p]=c.useState(""),[n,f]=c.useState(!0),[o,l]=c.useState(!1),[h,$]=c.useState(null),k=c.useRef({groupId:s,generation:0,latest:0,before:null,loaded:!1,older:!1});c.useEffect(()=>{const i={groupId:s,generation:k.current.generation+1,latest:0,before:null,loaded:!1,older:!1};k.current=i,a([]),p(""),$(null),f(!0),l(!1)},[s]),c.useEffect(()=>{if(!u)return;const i=k.current;let v=!0,j=!1;const w=async()=>{if(!(j||!s||!Ae())){j=!0;try{const N=await R({action:"supervisionMessages",groupId:s,limit:100,...i.loaded?{afterSequence:i.latest}:{}});if(!v)return;a(D=>we(D,N.messages)),i.loaded||(i.before=N.nextBefore,$(N.nextBefore)),i.latest=Math.max(i.latest,N.latestSequence),i.loaded=!0,p("")}catch(N){v&&p(`监工消息加载失败:${N instanceof Error?N.message:String(N)}`)}finally{j=!1,v&&f(!1)}}};w();const z=setInterval(()=>{w()},2e3);return()=>{v=!1,clearInterval(z)}},[u,s]);const T=c.useCallback(async()=>{const i=k.current;if(!(i.groupId!==s||i.before===null||i.older)){i.older=!0,l(!0);try{const v=await R({action:"supervisionMessages",groupId:s,beforeSequence:i.before,limit:100});if(k.current!==i)return;a(j=>we(j,v.messages)),i.before=v.nextBefore,$(v.nextBefore),p("")}catch(v){k.current===i&&p(`历史监工消息加载失败:${v instanceof Error?v.message:String(v)}`)}finally{i.older=!1,k.current===i&&l(!1)}}},[s]);return{messages:r,error:m,loading:n,loadingOlder:o,hasOlder:h!==null,loadOlder:T}}function Ne({images:s,onPreview:u,onRemove:r}){return s.length?e.jsx("div",{className:`collab-images${r?" is-draft":""}`,"aria-label":r?"待发送图片":"消息图片",children:s.map((a,m)=>e.jsxs("div",{className:"collab-image",children:[e.jsx("button",{type:"button",className:"collab-image-preview","aria-label":`查看图片 ${m+1}`,onClick:()=>u(a),children:e.jsx("img",{src:a,alt:`图片 ${m+1}`,loading:"lazy"})}),r&&e.jsx("button",{type:"button",className:"collab-image-remove","aria-label":`移除图片 ${m+1}`,onClick:()=>r(m),children:e.jsx($e,{size:13})})]},m))}):null}const Se=10,it=20*1024*1024;function lt(s){if(s===void 0)return;if(!Array.isArray(s)||s.length>Se)throw new ie(`每条消息最多添加 ${Se} 张图片`);let u=0;for(const r of s){if(typeof r!="string"||!/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(r))throw new ie("图片格式无效,仅支持 JPG、PNG、GIF 和 WebP");u+=r.length}if(u>it)throw new ie("图片总大小超过限制,请减少图片或压缩后重试")}const Q={text:"",images:[]};function ct(s,u,r){const a=`${s}:${u||"new"}`,[m,p]=c.useState({}),[n,f]=c.useState({}),o=c.useRef(),l=m[a]??Q,h=T=>{p(i=>({...i,[a]:T(i[a]??Q)}))},$=async T=>{if(T.length){f(i=>({...i,[a]:(i[a]??0)+1}));try{const i=await Ue(T,async v=>{const j=await Ge(v);return new Promise((w,z)=>{const N=new FileReader;N.onload=()=>w(String(N.result)),N.onerror=()=>z(new Error("无法读取图片")),N.readAsDataURL(j)})});(i.attachments.length||i.unsupportedImages.length||i.failedImages.length)&&r("无法添加部分图片,仅支持 JPG、PNG、GIF 和 WebP。"),i.images.length&&h(v=>({...v,images:[...v.images,...i.images]}))}catch(i){r(i instanceof Error?i.message:"无法添加图片")}finally{f(i=>({...i,[a]:Math.max(0,(i[a]??1)-1)}))}}},k=async T=>{var j;if(n[a]||!l.text.trim()&&!l.images.length)return!1;try{lt(l.images)}catch(w){return r(w instanceof Error?w.message:"图片无效"),!1}(((j=o.current)==null?void 0:j.key)!==a||o.current.draft!==l)&&(o.current={key:a,draft:l,id:crypto.randomUUID()});let i=a;return await T(l.text,o.current.id,l.images,w=>{var z;i=`${s}:${w}`,p(N=>({...N,[a]:Q,[i]:N[a]??l})),((z=o.current)==null?void 0:z.draft)===l&&(o.current.key=i)})?(p(w=>w[i]===l?{...w,[i]:Q}:w),!0):!1};return{draft:l.text,images:l.images,reading:!!n[a],addImages:$,submit:k,setDraft:T=>h(i=>({...i,text:T})),removeImage:T=>h(i=>({...i,images:i.images.filter((v,j)=>j!==T)}))}}function ot(s,u){const r=Ce(),[a,m]=c.useState(null),[p,n]=c.useState([]),[f,o]=c.useState(null),[l,h]=c.useState(null),[$,k]=c.useState(""),[T,i]=c.useState(!1),v=c.useRef(0),j=c.useRef(null),w=c.useRef(!1),z=c.useRef(null),N=()=>{v.current++,i(!0)},D=()=>{v.current--,i(v.current>0)},y=c.useRef({groupId:s,selected:f,revision:-1});y.current.groupId=s,y.current.selected=f;const O=c.useCallback(g=>{y.current.selected=g,y.current.revision=-1,o(g),h(null),k("");try{g&&localStorage.setItem(`collaboration:${s}:discussion`,g)}catch{}},[s]),P=c.useCallback(async()=>{const g=await R({action:"discussions",groupId:s});return y.current.groupId===s&&n(g),g},[s]);c.useEffect(()=>{let g=!0;return m(null),n([]),O(null),Promise.all([R({action:"group",groupId:s}),P()]).then(([x,E])=>{var C,I;if(!g)return;m(x);let A=null;try{A=localStorage.getItem(`collaboration:${s}:discussion`)}catch{}A=u||new URLSearchParams(window.location.search).get("discussionId")||A,O(((C=E.find(M=>M.id===A))==null?void 0:C.id)||((I=E[0])==null?void 0:I.id)||null)}).catch(x=>{g&&k(x.message)}),()=>{g=!1}},[s,P,O,u]),c.useEffect(()=>{if(!r||!f)return;let g=!0,x=!1;const E=async()=>{if(!(x||!Ae())){x=!0;try{const C=await R({action:"discussion",discussionId:f,afterRevision:y.current.revision<0?void 0:y.current.revision});if(!g||y.current.selected!==f)return;if(!("unchanged"in C)&&C.revision>=y.current.revision&&(y.current.revision=C.revision,h(C),await P()),z.current){const I=z.current;k(M=>M===I?"":M),z.current=null}}catch(C){g&&(z.current=C instanceof Error?C.message:String(C),k(z.current))}finally{x=!1}}};E();const A=setInterval(()=>{E()},1200);return()=>{g=!1,clearInterval(A)}},[r,f,P]);const Y=()=>(j.current||(N(),j.current=(async()=>{const g=await R({action:"createDiscussion",groupId:s});return y.current.groupId!==s?null:(O(g.id),y.current.revision=g.revision,h(g),await P(),g)})().finally(()=>{j.current=null,D()})),j.current),F=async g=>{if(!(!r||!f)){N();try{const x=await R({action:g,discussionId:f});y.current.selected===f&&x.revision>=y.current.revision&&(y.current.revision=x.revision,h(x))}catch(x){k(x instanceof Error?x.message:String(x))}finally{D()}}},K=async g=>{if(!(!f||(l==null?void 0:l.mode)===g)){N();try{const x=await R({action:"setMode",discussionId:f,mode:g});y.current.selected===f&&x.revision>=y.current.revision&&(y.current.revision=x.revision,h(x))}catch(x){k(x instanceof Error?x.message:String(x))}finally{D()}}},ee=async(g,x,E,A)=>{var C;if(w.current)return!1;w.current=!0,N(),k("");try{const I=f||((C=await Y())==null?void 0:C.id);if(!I)return!1;f||A==null||A(I);const M=await R({action:"send",discussionId:I,text:g,messageId:x,...E!=null&&E.length?{images:E}:{}});return y.current.selected===I&&M.revision>=y.current.revision&&(y.current.revision=M.revision,h(M)),await P(),!0}catch(I){return k(I instanceof Error?I.message:String(I)),!1}finally{w.current=!1,D()}},J=async(g,x)=>{const E=await R({action:"updateRole",groupId:s,memberId:g,role:x});y.current.groupId===s&&m(E)};return{group:l!=null&&l.groupSnapshot&&a?{...l.groupSnapshot,name:a.name}:a,history:p,selected:f,discussion:l,error:$,busy:T,select:O,create:Y,act:F,setMode:K,send:ee,setError:k,updateRole:J}}function ke({member:s,isUser:u=!1,isOwner:r=!1}){const a=u?"你":s?`${s.name} · ${Z[s.agentType]}${r?" · 群主":""}`:"协作动态";return e.jsxs("span",{className:`collab-avatar${u?" collab-avatar--user":""}`,role:"img","aria-label":a,title:a,children:[u?"你":s?e.jsx(W,{agentType:s.agentType,size:20}):e.jsx(X,{size:18,"aria-hidden":"true"}),r&&e.jsx(Ze,{className:"collab-avatar-crown",size:13,"aria-hidden":"true"})]})}function dt({message:s,discussionId:u,onError:r}){var o;const[a,m]=c.useState(""),[p,n]=c.useState(!1);if(!s.question||s.question.resolved)return e.jsxs("span",{className:"collab-muted",children:[e.jsx(Be,{size:12})," 已处理"]});const f=async(l,h)=>{n(!0);try{await R({action:"answer",discussionId:u,questionId:s.question.id,answer:l,...h===void 0?{}:{selectedIndices:[h]}})}catch($){r($ instanceof Error?$.message:String($))}finally{n(!1)}};return e.jsxs("div",{className:"collab-question",children:[(o=s.question.options)==null?void 0:o.map((l,h)=>e.jsx("button",{disabled:p,onClick:()=>{f(l.label,h)},title:l.description,children:l.label},h)),e.jsxs("form",{onSubmit:l=>{l.preventDefault(),a.trim()&&f(a)},children:[e.jsx("input",{"aria-label":"回答成员问题",value:a,onChange:l=>m(l.target.value),placeholder:"输入回复"}),e.jsx("button",{disabled:p||!a.trim(),children:"回复"})]})]})}function Nt({groupId:s,initialDiscussionId:u}){var pe,ge;const r=s||new URLSearchParams(location.search).get("groupId")||"",{group:a,history:m,selected:p,discussion:n,error:f,busy:o,select:l,create:h,act:$,setMode:k,send:T,setError:i,updateRole:v}=ot(r,u),j=rt(r),{draft:w,setDraft:z,images:N,reading:D,addImages:y,removeImage:O,submit:P}=ct(r,p,i),[Y,F]=c.useState(!1),[K,ee]=c.useState(null),[J,g]=c.useState(null),x=c.useRef(null),E=c.useRef(null),[A,C]=c.useState(null),[I,M]=c.useState(0),ce=Le(t=>t.skin);c.useEffect(()=>{document.documentElement.setAttribute("data-skin",ce)},[ce]);const oe=!!f||!!a&&(!p||!!n);c.useEffect(()=>{oe&&window.parent!==window&&window.parent.postMessage({type:Je,groupId:r},window.location.origin)},[oe,r]);const de=c.useRef(null),te=c.useRef(null),G=c.useRef(!0);if(c.useEffect(()=>{var t;G.current&&((t=de.current)==null||t.scrollIntoView({block:"end"}))},[n==null?void 0:n.messages.length,j.messages.length,p]),c.useEffect(()=>{G.current=!0},[p]),!a)return e.jsx("div",{className:"collab-loading",children:f?e.jsx("p",{role:"alert",children:f}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"collab-spin"}),"正在打开协作群…"]})});const L=a.members.find(t=>t.id===a.ownerId),B=((n==null?void 0:n.mode)??"task-graph")==="chat",_=A?a.members.filter(t=>`${t.name} ${t.id}`.toLowerCase().includes(A.query.toLowerCase())):[],Te=(t,d)=>{const S=/(?:^|\s)@([^\s@]{0,30})$/.exec(t.slice(0,d));C(S?{query:S[1],start:d-S[1].length-1}:null),M(0)},ue=t=>{const d=E.current;if(!A||!d)return;const S=d.selectionStart??w.length,q=`@${t.name} `;z(w.slice(0,A.start)+q+w.slice(S)),C(null),requestAnimationFrame(()=>{d.focus();const U=A.start+q.length;d.setSelectionRange(U,U)})},V=(n==null?void 0:n.tasks.filter(t=>t.status==="running"))||[],se=(n==null?void 0:n.status)==="running"?n.tasks.filter(t=>t.status==="queued"):[],ne=se.filter(t=>t.result==="等待工作目录空闲"),ae=(n==null?void 0:n.planning)||(n==null?void 0:n.status)==="running"&&n.ownerPending&&V.length===0,H=!ae&&V.length===0&&se.length>0,Ee=ne.length>0?`${ne.length} 个任务等待工作目录空闲,空闲后会自动继续。`:"任务排队中,等待前置任务完成。",fe=H?ne.length>0?"等待工作目录空闲":"任务排队中":n?je[n.status]:"准备好了",re=at((n==null?void 0:n.messages)??[],j.messages),ze=t=>{l(t),F(!1),C(null),G.current=!0},me=async()=>{var t;try{await h()&&(F(!1),C(null),(t=E.current)==null||t.focus())}catch(d){i(d instanceof Error?d.message:String(d))}},he=async()=>{o||D||await P(T)&&(C(null),G.current=!0)};return e.jsxs("div",{className:"collab-page",children:[e.jsx(He,{image:J?{src:J,alt:"群聊图片"}:null,onClose:()=>g(null)}),Y&&e.jsx("button",{className:"collab-drawer-mask","aria-label":"关闭成员栏",onClick:()=>F(!1)}),e.jsxs("aside",{className:`collab-sidebar${Y?" is-open":""}`,children:[e.jsxs("header",{className:"collab-sidebar-heading",children:[e.jsx("div",{className:"collab-group-icon",children:e.jsx(X,{size:22})}),e.jsxs("div",{children:[e.jsxs("span",{className:"collab-eyebrow",children:["协作群 · ",a.members.length," 人"]}),e.jsx("h2",{children:a.name})]}),e.jsx("button",{className:"collab-mobile-close","aria-label":"收起群成员",onClick:()=>F(!1),children:e.jsx($e,{size:18})})]}),e.jsxs("div",{className:"collab-roster","aria-label":"群成员",children:[e.jsx("span",{className:"collab-section-label",children:"群成员"}),[L,...a.members.filter(t=>t.id!==L.id)].map(t=>{var be;const d=V.find(b=>b.memberId===t.id),S=t.id===L.id&&(n==null?void 0:n.planning),q=se.find(b=>b.memberId===t.id),De=(n==null?void 0:n.messages.some(b=>b.memberId===t.id&&b.question&&!b.question.resolved))?"等待你回复":S?"正在安排":d?"正在执行":q?q.result==="等待工作目录空闲"?"等待目录空闲":"排队中":"空闲";return e.jsxs("div",{className:`collab-roster-member${S||d?" is-working":""}`,children:[e.jsxs("button",{onClick:()=>ee(b=>b===t.id?null:t.id),"aria-expanded":K===t.id,children:[e.jsx(ke,{member:t,isOwner:t.id===L.id}),e.jsxs("span",{className:"collab-member-name",children:[e.jsx("strong",{children:t.name}),e.jsx("small",{children:Z[t.agentType]})]}),e.jsx("span",{className:"collab-member-status",children:De})]}),e.jsx("p",{className:K===t.id?"is-expanded":void 0,children:t.role||(n==null?void 0:n.roles[t.id])||"等待群主分配定位"}),K===t.id&&e.jsxs("div",{className:"collab-member-detail",children:[e.jsx("small",{children:((be=t.model)==null?void 0:be.id)||"默认模型"}),e.jsxs("form",{className:"collab-role-form",onSubmit:b=>{b.preventDefault();const Me=new FormData(b.currentTarget).get("role");v(t.id,String(Me||"")).catch(qe=>i(qe.message))},children:[e.jsxs("label",{children:["定位与职责",e.jsx("textarea",{name:"role",defaultValue:t.role,rows:3,maxLength:8e3,placeholder:"留空由群主分配"},t.role)]}),e.jsx("button",{type:"submit",children:"保存职责"})]}),n==null?void 0:n.tasks.filter(b=>b.memberId===t.id).map(b=>e.jsxs("div",{children:[b.title,e.jsx("span",{children:b.status==="completed"?"已完成":b.status==="running"?"执行中":b.status==="queued"?"等待依赖或空闲":b.status==="failed"?"失败":b.status==="cancelled"?"已取消":"已中断"}),b.result&&e.jsxs("details",{children:[e.jsx("summary",{children:"查看结果"}),e.jsx(le,{text:b.result,cwd:b.cwd||a.cwd})]})]},b.id)),n==null?void 0:n.messages.filter(b=>b.memberId===t.id&&b.kind==="progress").slice(-20).map(b=>e.jsx("small",{children:b.content},b.id))]})]},t.id)})]}),e.jsxs("section",{className:"collab-history","aria-label":"群聊记录",children:[e.jsxs("header",{children:[e.jsxs("span",{className:"collab-section-label",children:[e.jsx(We,{size:13}),"群聊记录"]}),e.jsx("button",{disabled:o,"aria-label":"新建群讨论",title:"新讨论",onClick:()=>{me()},children:e.jsx(xe,{size:17})})]}),e.jsx("div",{className:"collab-history-list",children:m.length?m.map(t=>e.jsxs("button",{className:p===t.id?"is-selected":"","aria-current":p===t.id?"page":void 0,onClick:()=>{ze(t.id)},children:[e.jsx("strong",{children:t.title}),e.jsxs("span",{children:[e.jsx("time",{children:new Date(t.updatedAt).toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}),e.jsx("small",{children:je[t.status]})]})]},t.id)):e.jsx("p",{className:"collab-muted",children:(pe=a.monitoring)!=null&&pe.targets.length?"监工动态持续保存在群内,普通讨论会列在这里。":"发送第一条任务,记录会保存在这里。"})})]}),e.jsxs("footer",{className:"collab-sidebar-footer",title:a.cwd,children:[e.jsx(st,{group:a}),a.cwd]})]}),e.jsxs("main",{className:"collab-conversation",children:[e.jsxs("header",{className:"collab-conversation-heading",children:[e.jsx("button",{className:"collab-mobile-menu","aria-label":"展开群成员和群聊记录",onClick:()=>F(!0),children:e.jsx(Pe,{size:20})}),e.jsxs("div",{className:"collab-discussion-title",children:[e.jsx("h1",{children:(n==null?void 0:n.title)||((ge=a.monitoring)!=null&&ge.targets.length?"监工动态":"开始一起做事")}),e.jsx("span",{className:"collab-discussion-status","data-status":H?"queued":(n==null?void 0:n.status)||"idle",role:"status","aria-label":fe,title:fe})]}),e.jsxs("div",{className:"collab-heading-actions",children:[n&&e.jsxs("div",{className:"collab-mode-toggle",role:"group","aria-label":"讨论模式",children:[e.jsx("button",{"aria-pressed":!B,disabled:o||!B,title:"每条消息交给群主安排;@成员 仍直接指派",onClick:()=>{k("task-graph")},children:"编排"}),e.jsx("button",{"aria-pressed":B,disabled:o||B,title:"@成员直接指派 · @群主安排分工 · 无 @ 静默",onClick:()=>{k("chat")},children:"@直聊"})]}),n&&["running","waiting"].includes(n.status)&&e.jsx("button",{className:"collab-heading-stop",disabled:o,onClick:()=>{$("stop")},children:e.jsxs("span",{className:"collab-heading-action-content",children:[e.jsx(Ye,{size:12,fill:"currentColor",strokeWidth:0}),"停止"]})}),n&&["waiting","interrupted","stopped"].includes(n.status)&&e.jsx("button",{className:"collab-heading-resume",disabled:o,onClick:()=>{$("resume")},children:e.jsx("span",{className:"collab-heading-action-content",children:"继续协作"})}),e.jsx("button",{className:"collab-heading-new",disabled:o,onClick:()=>{me()},children:e.jsxs("span",{className:"collab-heading-action-content",children:[e.jsx(xe,{size:14}),"新讨论"]})})]})]}),e.jsxs("div",{ref:te,className:"collab-messages",onScroll:()=>{const t=te.current;t&&(G.current=t.scrollHeight-t.scrollTop-t.clientHeight<120)},children:[j.error&&e.jsx("p",{className:"collab-error",role:"alert",children:j.error}),j.hasOlder&&e.jsx("button",{className:"collab-supervision-load",disabled:j.loadingOlder,onClick:async()=>{G.current=!1;const t=te.current,d=(t==null?void 0:t.scrollHeight)??0;await j.loadOlder(),requestAnimationFrame(()=>{t&&(t.scrollTop+=t.scrollHeight-d)})},children:j.loadingOlder?"正在加载…":"查看更早的监工消息"}),j.loading&&!re.length&&e.jsx("p",{className:"collab-muted",role:"status",children:"正在加载群内消息…"}),!re.length&&!j.loading&&e.jsxs("div",{className:"collab-empty",children:[e.jsx("span",{className:"collab-empty-icon",children:e.jsx(X,{size:34})}),e.jsx("h2",{children:"把目标交给这个群。"}),e.jsx("p",{children:B?e.jsxs(e.Fragment,{children:["在群里 @ 成员直接做事,或 @群主 让它拆解安排。",e.jsx("br",{}),"没有 @ 的消息不会触发回应。"]}):e.jsxs(e.Fragment,{children:[L.name,"会安排分工,成员会在这里汇报进展。",e.jsx("br",{}),"@某位成员可直接指派;不 @ 则由",L.name,"安排。"]})}),e.jsx("div",{className:"collab-empty-members",children:a.members.map(t=>e.jsxs("span",{children:[e.jsx(W,{agentType:t.agentType,size:17}),t.name]},t.id))})]}),re.map(t=>{var q;if(t.kind==="supervision")return e.jsx(nt,{message:t.message,group:a},`supervision:${t.message.id}`);const d=t.message,S=a.members.find(U=>U.id===d.memberId);return e.jsxs("article",{className:`collab-message collab-message--${d.kind}`,children:[e.jsx(ke,{member:S,isUser:d.kind==="user",isOwner:d.kind!=="user"&&(S==null?void 0:S.id)===L.id}),e.jsxs("div",{className:"collab-message-body",children:[e.jsx(Ne,{images:d.images??[],onPreview:g}),e.jsx(le,{text:d.content,cwd:((q=n==null?void 0:n.tasks.find(U=>U.id===d.taskId))==null?void 0:q.cwd)||a.cwd}),d.kind==="question"&&p&&e.jsx(dt,{message:d,discussionId:p,onError:i})]}),e.jsx("time",{dateTime:d.createdAt,children:new Date(d.createdAt).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})})]},`discussion:${d.id}`)}),(ae||V.length>0||H)&&e.jsxs("div",{className:`collab-live-status${H?" is-queued":""}`,role:"status",children:[H?e.jsx(Xe,{size:14,"aria-hidden":"true"}):e.jsx(ve,{size:14,className:"collab-spin","aria-hidden":"true"}),e.jsx("span",{children:ae?`${L.name}正在安排下一步`:H?Ee:V.map(t=>{var d;return`${(d=a.members.find(S=>S.id===t.memberId))==null?void 0:d.name}:${t.title}`}).join(" · ")})]}),e.jsx("div",{ref:de})]}),e.jsxs("div",{className:"collab-composer-area",children:[f&&e.jsx("p",{className:"collab-error",role:"alert",children:f}),e.jsxs("div",{className:"collab-composer",children:[e.jsx(Ne,{images:N,onPreview:g,onRemove:O}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,"aria-label":"选择群聊图片",onChange:t=>{const d=Array.from(t.target.files??[]);t.target.value="",y(d)}}),A&&_.length>0&&e.jsx("ul",{className:"collab-mention-list",role:"listbox","aria-label":"选择要提及的成员",children:_.map((t,d)=>e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":d===I,className:d===I?"is-active":"",title:t.id===L.id?"提及群主:触发一轮安排":`指派给 ${t.name}`,onMouseDown:S=>{S.preventDefault(),ue(t)},children:[e.jsx(W,{agentType:t.agentType,size:15}),e.jsx("span",{children:t.name}),e.jsx("small",{children:t.id===L.id?"群主 · 安排分工":Z[t.agentType]})]})},t.id))}),e.jsx("textarea",{ref:E,"aria-label":"发送群消息",value:w,placeholder:B?"@成员 或 @群主,说说要做什么…":"告诉群主,你想完成什么…",rows:3,onPaste:t=>{const d=Array.from(t.clipboardData.items).filter(S=>S.type.startsWith("image/")).flatMap(S=>{const q=S.getAsFile();return q?[q]:[]});d.length&&(t.preventDefault(),y(d))},onChange:t=>{z(t.target.value),Te(t.target.value,t.target.selectionStart??t.target.value.length)},onBlur:()=>C(null),onKeyDown:t=>{const d=_[I];if(A&&_.length>0&&d){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault(),M(S=>t.key==="ArrowDown"?(S+1)%_.length:(S-1+_.length)%_.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),ue(d);return}if(t.key==="Escape"){t.preventDefault(),C(null);return}}t.key==="Enter"&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),he())}}),e.jsxs("footer",{children:[e.jsx("button",{type:"button",className:"collab-add-image","aria-label":"添加群聊图片",title:"添加图片",disabled:o||D,onClick:()=>{var t;return(t=x.current)==null?void 0:t.click()},children:e.jsx(Qe,{size:18})}),e.jsx("span",{children:D?"正在处理图片…":w.includes("@")?"@成员 直接指派,不打扰群主;@群主 触发一轮安排":B?"chat 模式:@成员 直接指派 · @群主 安排分工 · 无 @ 不会回应":(n==null?void 0:n.status)==="running"?"补充要求会交给群主继续安排":"由群主安排分工与并行"}),e.jsx("button",{"aria-label":"发送群消息",className:"collab-primary",disabled:o||D||!w.trim()&&!N.length||(n==null?void 0:n.status)==="stopping",onClick:()=>{he()},children:e.jsx(Oe,{size:20})})]})]}),e.jsx("small",{className:"collab-composer-hint",children:"Enter 发送 · Shift+Enter 换行 · 群聊记录自动保存"})]})]})]})}export{Nt as default};
@@ -1,11 +0,0 @@
1
- import{c as se,r as a,j as s,e as oe}from"./index-DKm9ESDq.js";import{S as de,F as Z,a as ue,D as fe,P as pe,b as xe,c as he,d as me,e as je,N as be,f as ye,g as ve,h as ze,i as ke,j as Ne}from"./file-types-DKkhMnUV.js";import{X as Fe}from"./x-DP1nC4qG.js";import{L as _}from"./loader-circle-DIW9tlEz.js";import{C as P}from"./chevron-down-DhZV290h.js";import{C as S,F as T}from"./trash-2-BrfgMjfL.js";/**
2
- * @license lucide-react v0.468.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ge=se("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
7
- * @license lucide-react v0.468.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const $e=se("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function R(i){const p=i.replace(/\/{2,}/g,"/");return p.length>1?p.replace(/\/+$/,""):p}function re(i){const p=R(i),c=p.lastIndexOf("/");return c<=0?"/":p.slice(0,c)}function te(i,p){const c=R(i),d=R(p);return d==="/"?c.startsWith("/"):c.startsWith(`${d}/`)}function Ie(i,p){const c=R(i);if(!te(p,c))return[];const d=re(p);if(d===c)return[c];const u=d.slice(c==="/"?1:c.length+1),I=[c];let v=c;for(const N of u.split("/").filter(Boolean))v=v==="/"?`/${N}`:`${v}/${N}`,I.push(v);return I}const Le={code:{icon:ke,color:"#7aa2f7",label:"代码文件"},style:{icon:oe,color:"#bb9af7",label:"样式文件"},image:{icon:ze,color:"#9ece6a",label:"图片文件"},video:{icon:ve,color:"#f7768e",label:"视频文件"},audio:{icon:ye,color:"#c099ff",label:"音频文件"},markdown:{icon:be,color:"#73daca",label:"Markdown 文件"},text:{icon:je,color:"#a9b1d6",label:"文本文件"},json:{icon:me,color:"#e0af68",label:"JSON 文件"},archive:{icon:he,color:"#ff9e64",label:"压缩文件"},spreadsheet:{icon:xe,color:"#9ece6a",label:"表格文件"},presentation:{icon:pe,color:"#f7768e",label:"演示文件"},database:{icon:fe,color:"#2ac3de",label:"数据库文件"},file:{icon:ue,color:"#c8c8d0",label:"文件"}};function De(i){return Le[Ne(i)]}function ee(i){return i<1024?`${i}B`:i<1024*1024?`${(i/1024).toFixed(1)}K`:i<1024*1024*1024?`${(i/1024/1024).toFixed(1)}M`:`${(i/1024/1024/1024).toFixed(1)}G`}function Me({gateway:i,onOpenFile:p,selectedPath:c,ready:d,cwd:u,followCwd:I,initialRoot:v,initialFollow:N=!0,onTreeStateChange:x,revealRequest:b}){const g=i.request,W=i.subscribe,[f,ne]=a.useState(null),[w,M]=a.useState(""),[O,B]=a.useState(""),[le,L]=a.useState(!N),[A,ae]=a.useState(""),y=a.useRef(new Map),D=a.useRef(null),H=a.useRef(null),C=a.useRef(0),J=a.useRef(0),[,ie]=a.useState(0),E=()=>ie(e=>e+1),z=a.useCallback(async(e,r)=>{const t={path:e,depth:r,expanded:!0,children:null,loading:!0};y.current.set(e,t),E();try{const n=await g("fs:list",{path:e});t.children=n.entries,g("fs:watch",{path:e}).catch(()=>{})}catch(n){t.children=[],t.error=(n==null?void 0:n.message)??"read failed"}return t.loading=!1,E(),t},[g]),F=!!I&&!le,m=a.useCallback(e=>{const r=e.length>1?e.replace(/\/+$/,""):e;D.current=r,y.current.clear(),ne({path:r,depth:0,expanded:!1,children:null,loading:!1}),B(r)},[]);a.useEffect(()=>{!d||!u||!F||D.current!==u&&(m(u),x==null||x(u,!0))},[d,u,F,m]),a.useEffect(()=>{!d||!v||N||D.current||(L(!0),m(v))},[d,v,N,m]),a.useEffect(()=>{d&&g("hello").then(e=>{ae(e.home),F&&!u&&!D.current&&m(e.home)}).catch(()=>{})},[d,u,F,g,m]);const K=()=>{let e=O.trim();e&&(e==="~"?e=A||u||"/":e.startsWith("~/")?e=`${A||u||""}${e.slice(1)}`:e.startsWith("/")||(e=`${u||(f==null?void 0:f.path)||A||"/"}/${e}`),e=e.replace(/\/+/g,"/"),L(!0),m(e),x==null||x(e,!1))},ce=()=>{L(!1),u&&(m(u),x==null||x(u,!0))},V=a.useCallback(async e=>{let r=y.current.get(e);r||(r={path:e,depth:0,expanded:!1,children:null,loading:!1},y.current.set(e,r)),r.expanded?r.expanded=!1:(r.expanded=!0,!r.children&&!r.loading&&await z(e,r.depth)),E()},[z]),G=a.useCallback(async(e,r)=>{let t=y.current.get(e);t?!t.children&&!t.loading&&await z(e,r):t=await z(e,r),t.expanded=!0,E()},[z]),X=a.useCallback(async(e,r)=>{const t=re(e);let n=(f==null?void 0:f.path)??t;te(e,n)||(n=t,L(!0),m(n),x==null||x(n,!1));const l=Ie(n,e);for(let j=0;j<l.length;j+=1){if(C.current!==r)return;await G(l[j],j)}const k=()=>{var h;if(C.current!==r)return;const j=Array.from(((h=H.current)==null?void 0:h.querySelectorAll("[data-tree-path]"))??[]).find($=>$.dataset.treePath===e);j==null||j.scrollIntoView({block:"center",inline:"nearest"})};requestAnimationFrame(()=>requestAnimationFrame(k))},[m,x,G,f==null?void 0:f.path]);a.useEffect(()=>{!d||!b||J.current!==b.requestId&&(J.current=b.requestId,C.current=b.requestId,X(b.path,b.requestId))},[d,X,b==null?void 0:b.requestId]),a.useEffect(()=>W("fs:event",e=>{for(const r of e.events??[]){const t=r.path;t===c&&window.dispatchEvent(new CustomEvent("file-changed",{detail:t}));const n=t.slice(0,t.lastIndexOf("/"))||"/",l=y.current.get(n);l!=null&&l.expanded&&l.children&&!l.loading&&z(n,l.depth).catch(()=>{})}}),[W,c,z]);const q=(e,r)=>e.endsWith("/")?e+r:`${e}/${r}`,Q=w.trim().toLowerCase(),U=(e,r)=>{var l;if(!Q||r.name.toLowerCase().includes(Q))return!0;if(!r.dir)return!1;const t=q(e,r.name),n=(l=y.current.get(t))==null?void 0:l.children;return(n==null?void 0:n.some(k=>U(t,k)))??!1},Y=(e,r,t)=>r.filter(n=>U(e,n)).map(n=>{const l=q(e,n.name);if(n.dir){const h=y.current.get(l),$=(h==null?void 0:h.expanded)??!1;return s.jsxs("div",{children:[s.jsxs("div",{className:"tree-row",onClick:()=>V(l),style:{paddingLeft:6+t*12},children:[s.jsx("span",{className:"tree-disclosure","aria-hidden":"true",children:h!=null&&h.loading?s.jsx(_,{className:"tree-spin",size:13}):$?s.jsx(P,{size:13}):s.jsx(S,{size:13})}),s.jsx("span",{className:"tree-entry-icon tree-folder-icon","aria-hidden":"true",children:$?s.jsx(T,{size:16}):s.jsx(Z,{size:16})}),s.jsx("span",{className:"tree-entry-name",children:n.name})]}),$&&(h.error?s.jsx("div",{className:"tree-error",role:"alert",style:{paddingLeft:22+t*12},children:h.error}):h.children?Y(l,h.children,t+1):s.jsx("div",{className:"tree-row",style:{paddingLeft:22+t*12,color:"#556"},children:"…"}))]},l)}const k=De(n.name),j=k.icon;return s.jsxs("div",{className:"tree-row","data-tree-path":l,"data-selected":l===c?"1":void 0,onClick:()=>p(l),title:`${k.label} · ${l} · ${ee(n.size)}`,style:{paddingLeft:6+t*12},children:[s.jsx("span",{className:"tree-disclosure","aria-hidden":"true"}),s.jsx("span",{className:"tree-entry-icon",style:{color:k.color},"aria-hidden":"true",children:s.jsx(j,{size:16,strokeWidth:1.8})}),s.jsx("span",{className:"tree-entry-name",children:n.name}),s.jsx("span",{className:"tree-size",children:ee(n.size)})]},l)});if(!f)return s.jsx("div",{style:{padding:14,fontSize:12,color:"#556"},children:F?d?"等待终端目录…":"连接中…":"…"});const o=y.current.get(f.path);return s.jsxs("div",{className:"tree-scroll",ref:H,children:[s.jsxs("div",{className:"tree-location",children:[s.jsx("input",{value:O,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key==="Enter"&&K()},placeholder:"输入目录路径","aria-label":"文件树目录路径",spellCheck:!1}),s.jsx("button",{tabIndex:-1,onClick:K,title:"定位目录","aria-label":"定位目录",children:s.jsx(ge,{size:14,"aria-hidden":"true"})}),s.jsx("button",{tabIndex:-1,onClick:ce,title:"跟随终端目录","aria-label":"跟随终端目录","data-active":F?"1":void 0,children:s.jsx($e,{size:14,"aria-hidden":"true"})})]}),s.jsxs("div",{className:"tree-filter",children:[s.jsx(de,{size:14,"aria-hidden":"true"}),s.jsx("input",{value:w,onChange:e=>M(e.target.value),placeholder:"筛选已加载文件","aria-label":"筛选文件树"}),w&&s.jsx("button",{tabIndex:-1,onClick:()=>M(""),"aria-label":"清除筛选",children:s.jsx(Fe,{size:13,"aria-hidden":"true"})})]}),s.jsxs("div",{className:"tree-row",onClick:()=>V(f.path),children:[s.jsx("span",{className:"tree-disclosure","aria-hidden":"true",children:o!=null&&o.loading?s.jsx(_,{className:"tree-spin",size:13}):o!=null&&o.expanded?s.jsx(P,{size:13}):s.jsx(S,{size:13})}),s.jsx("span",{className:"tree-entry-icon tree-folder-icon","aria-hidden":"true",children:o!=null&&o.expanded?s.jsx(T,{size:16}):s.jsx(Z,{size:16})}),s.jsx("span",{className:"tree-entry-name",style:{direction:"rtl",textAlign:"left"},children:f.path})]}),(o==null?void 0:o.expanded)&&(o.error?s.jsx("div",{className:"tree-error",role:"alert",children:o.error}):o.children?Y(f.path,o.children,1):s.jsx("div",{className:"tree-row",style:{paddingLeft:24,color:"#556"},children:"…"}))]})}export{Me as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./index-DKm9ESDq.js";import{F as d}from"./FilePreview-CevPpP6E.js";import m from"./FileTree-CagcHV1N.js";import{X as f}from"./x-DP1nC4qG.js";import"./artifact-links-73OZyi5W.js";import"./rotate-ccw-O4wnfQP7.js";import"./loader-circle-DIW9tlEz.js";import"./trash-2-BrfgMjfL.js";import"./download-D3xZPWnZ.js";import"./file-types-DKkhMnUV.js";import"./chevron-down-DhZV290h.js";function C({open:a,tab:s,gateway:r,cwd:l,selectedPath:i,revealRequest:n,onTabChange:o,onSelectPath:t,onClose:p}){return a?e.jsxs("section",{className:`desktop-file-workspace${i?" has-preview":""}`,"aria-label":"我的文件",children:[e.jsxs("aside",{className:"desktop-file-drawer",children:[e.jsxs("header",{className:"desktop-file-drawer-header",children:[e.jsxs("div",{className:"desktop-file-drawer-tabs",role:"tablist","aria-label":"文件工作区视图",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":s==="files",className:s==="files"?"is-active":"",onClick:()=>o("files"),children:"文件"}),e.jsx("button",{type:"button",role:"tab","aria-selected":s==="history",className:s==="history"?"is-active":"",onClick:()=>o("history"),children:"历史"})]}),e.jsx("button",{type:"button",className:"desktop-file-workspace-close ui-icon-button ui-icon-button--small",onClick:p,"aria-label":"关闭我的文件",title:"关闭",children:e.jsx(f,{size:15,"aria-hidden":"true"})})]}),s==="files"?l?e.jsx(m,{gateway:r,ready:!0,followCwd:!0,cwd:l,onOpenFile:c=>t(c),selectedPath:i,revealRequest:n}):e.jsx("div",{className:"desktop-file-workspace-empty",children:"请先选择一个项目目录"}):e.jsxs("div",{className:"desktop-file-workspace-empty",children:[e.jsx("strong",{children:"终端历史在 Web 控制台中可用"}),e.jsx("span",{children:"Electron 当前没有终端上下文,因此不会提供填入或执行操作。"})]}),e.jsxs("footer",{className:"desktop-file-drawer-footer",children:[e.jsx("span",{}),"实时同步"]})]}),i&&e.jsx("div",{className:"desktop-file-preview",children:e.jsx(d,{path:i,gateway:r,onClose:()=>t(null)})})]}):null}export{C as default};
@@ -1,5 +0,0 @@
1
- import{r as a,b as p,j as e}from"./index-DKm9ESDq.js";import{F as w}from"./page-BG97oPXr.js";import{R as y}from"./rotate-cw-CCJtlAtB.js";import"./RunningSessionsIcon-B8Cr2-hp.js";import"./x-DP1nC4qG.js";import"./chevron-down-DhZV290h.js";import"./artifact-links-73OZyi5W.js";import"./trash-2-BrfgMjfL.js";import"./external-link-Cwu5rEgp.js";import"./clipboard-BvwmdR4z.js";import"./CollaborationTabBridge-Dxq4G1Uk.js";import"./SessionDashboardBridge-Bx4EXtos.js";import"./RemoteDesktopTabBridge-Cp9mLtcY.js";const g=new Set(["127.0.0.1","localhost","[::1]"]);function h(s,t){const o=new URL(s),r=new URL(t);return g.has(o.hostname)&&o.hostname!==r.hostname&&(o.hostname=r.hostname),o.toString()}function P({visible:s}){const[t,o]=a.useState(null),[r,n]=a.useState("loading"),[u,m]=a.useState(0);a.useEffect(()=>{if(!s||t)return;let i=!1;return n("loading"),fetch("/api/flow-studio/config",{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error("Flow Studio config request failed");const d=await c.json();if(!d.entryUrl)throw new Error("Flow Studio entry is not configured");const l=new URL(d.entryUrl);if(l.protocol!=="http:"&&l.protocol!=="https:")throw new Error("Flow Studio entry URL is invalid");i||o(h(l.toString(),p()))}).catch(()=>{i||n("error")}),()=>{i=!0}},[u,t,s]),a.useEffect(()=>{if(!t||r!=="loading")return;const i=window.setTimeout(()=>n("error"),3e4);return()=>window.clearTimeout(i)},[t,r]);const f=()=>{o(null),n("loading"),m(i=>i+1)};return e.jsxs("div",{style:{position:"absolute",inset:0,background:"var(--ui-term-col-bg, #101014)"},"aria-busy":r==="loading",children:[t&&e.jsx("iframe",{src:t,title:"Flow Studio 数字人",referrerPolicy:"no-referrer",allow:"camera; microphone; autoplay; clipboard-read; clipboard-write; fullscreen",allowFullScreen:!0,onLoad:()=>n("ready"),onError:()=>n("error"),className:r==="ready"?"flow-frame flow-frame-ready":"flow-frame",style:{display:"block",width:"100%",height:"100%",border:0,background:"var(--ui-term-col-bg, #101014)"}},t),r==="loading"&&e.jsx(w,{}),r==="error"&&e.jsxs("div",{role:r==="error"?"alert":"status","aria-live":"polite",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:"var(--ui-text, #e5e7eb)",background:"var(--ui-term-col-bg, #101014)"},children:[e.jsx("strong",{children:r==="error"?"无法打开 Flow Studio":"正在打开 Flow Studio"}),r==="error"&&e.jsxs("button",{type:"button","aria-label":"重试加载 Flow Studio",onClick:f,title:"重新加载 Flow Studio",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,width:"auto",height:32,padding:"0 10px",border:"1px solid var(--ui-muted-border, #3b3d46)",borderRadius:6,background:"transparent",color:"inherit",cursor:"pointer"},children:[e.jsx(y,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"重试"})]})]}),e.jsx("style",{jsx:!0,children:`
2
- .flow-frame { opacity: 0; transform: translateY(8px) scale(.995); transition: opacity 420ms ease, transform 520ms cubic-bezier(.2,.8,.2,1); }
3
- .flow-frame-ready { opacity: 1; transform: none; }
4
- @media (prefers-reduced-motion: reduce) { .flow-frame { transform: none; transition: none; } }
5
- `})]})}export{P as default,h as resolveFlowStudioFrameUrl};