agentroam-runtime-darwin-arm64 0.2.0-preview.81 → 0.2.0-preview.83

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 (379) 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 +26 -25
  5. package/runtime/.next/app-path-routes-manifest.json +1 -1
  6. package/runtime/.next/build-manifest.json +10 -10
  7. package/runtime/.next/prerender-manifest.json +1 -1
  8. package/runtime/.next/react-loadable-manifest.json +4 -4
  9. package/runtime/.next/required-server-files.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/answer/route.js +1 -1
  16. package/runtime/.next/server/app/api/agent/codex-sharing/route.js +1 -1
  17. package/runtime/.next/server/app/api/agent/composer/route.js +1 -0
  18. package/runtime/.next/server/app/api/agent/composer/route.js.nft.json +1 -0
  19. package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
  20. package/runtime/.next/server/app/api/agent/model/route.js +1 -1
  21. package/runtime/.next/server/app/api/agent/models/route.js +1 -1
  22. package/runtime/.next/server/app/api/agent/run/route.js +1 -1
  23. package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
  24. package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
  25. package/runtime/.next/server/app/api/agent/stream/route.js +2 -2
  26. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
  27. package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
  28. package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
  29. package/runtime/.next/server/app/api/business/route.js +1 -1
  30. package/runtime/.next/server/app/api/calendar/route.js +2 -2
  31. package/runtime/.next/server/app/api/client-logs/route.js +1 -1
  32. package/runtime/.next/server/app/api/collaboration/route.js +2 -2
  33. package/runtime/.next/server/app/api/engine-threads/route.js +1 -1
  34. package/runtime/.next/server/app/api/engine-threads.body +1 -1
  35. package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
  36. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
  37. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +2 -2
  38. package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
  39. package/runtime/.next/server/app/api/flow-studio/config/route.js +1 -1
  40. package/runtime/.next/server/app/api/internal/todo-bootstrap/route.js +1 -1
  41. package/runtime/.next/server/app/api/internal/todo-mcp/route.js +1 -1
  42. package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
  43. package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
  44. package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
  45. package/runtime/.next/server/app/api/mcp/servers.body +1 -1
  46. package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
  47. package/runtime/.next/server/app/api/memory/route.js +1 -1
  48. package/runtime/.next/server/app/api/messaging/route.js +1 -1
  49. package/runtime/.next/server/app/api/notifications/[id]/ack/route.js +1 -1
  50. package/runtime/.next/server/app/api/notifications/[id]/route.js +1 -1
  51. package/runtime/.next/server/app/api/notifications/route.js +1 -1
  52. package/runtime/.next/server/app/api/notifications/stream/route.js +2 -2
  53. package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
  54. package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
  55. package/runtime/.next/server/app/api/projects/check/route.js +1 -1
  56. package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
  57. package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
  58. package/runtime/.next/server/app/api/projects/route.js +1 -1
  59. package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
  60. package/runtime/.next/server/app/api/push/unsubscribe/route.js +2 -2
  61. package/runtime/.next/server/app/api/push/vapid/route.js +2 -2
  62. package/runtime/.next/server/app/api/push/vapid.body +1 -1
  63. package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
  64. package/runtime/.next/server/app/api/session-images/[id]/route.js +1 -1
  65. package/runtime/.next/server/app/api/session-views/route.js +1 -1
  66. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/route.js +1 -1
  67. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/stop/route.js +1 -1
  68. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/route.js +1 -1
  69. package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +2 -2
  70. package/runtime/.next/server/app/api/sessions/[id]/engine-switches/route.js +1 -1
  71. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
  72. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -1
  73. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
  74. package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
  75. package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js +1 -1
  76. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
  77. package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
  78. package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
  79. package/runtime/.next/server/app/api/sessions/[id]/switch-engine/route.js +1 -1
  80. package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
  81. package/runtime/.next/server/app/api/sessions/[id]/thread-history/route.js +1 -1
  82. package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
  83. package/runtime/.next/server/app/api/sessions/parallel/route.js +1 -1
  84. package/runtime/.next/server/app/api/sessions/route.js +1 -1
  85. package/runtime/.next/server/app/api/settings/route.js +1 -1
  86. package/runtime/.next/server/app/api/skills/route.js +1 -1
  87. package/runtime/.next/server/app/api/todos/[id]/commands/route.js +1 -1
  88. package/runtime/.next/server/app/api/todos/[id]/executions/route.js +1 -1
  89. package/runtime/.next/server/app/api/todos/[id]/route.js +1 -1
  90. package/runtime/.next/server/app/api/todos/route.js +1 -1
  91. package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
  92. package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
  93. package/runtime/.next/server/app/api/tools/route.js +1 -1
  94. package/runtime/.next/server/app/api/update/check/route.js +1 -1
  95. package/runtime/.next/server/app/api/update/install/route.js +1 -1
  96. package/runtime/.next/server/app/api/update/status/route.js +1 -1
  97. package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
  98. package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
  99. package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
  100. package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
  101. package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
  102. package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
  103. package/runtime/.next/server/app/api/web-console/computer-settings/route.js +1 -1
  104. package/runtime/.next/server/app/api/web-console/computers/route.js +1 -1
  105. package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
  106. package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
  107. package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
  108. package/runtime/.next/server/app/api/workspace-changes/route.js +1 -1
  109. package/runtime/.next/server/app/web/page.js +4 -4
  110. package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
  111. package/runtime/.next/server/app-paths-manifest.json +39 -38
  112. package/runtime/.next/server/chunks/1298.js +1 -1
  113. package/runtime/.next/server/chunks/5303.js +2 -2
  114. package/runtime/.next/server/chunks/5801.js +1 -1
  115. package/runtime/.next/server/chunks/6703.js +1 -1
  116. package/runtime/.next/server/chunks/9119.js +3 -3
  117. package/runtime/.next/server/chunks/9457.js +1 -1
  118. package/runtime/.next/server/middleware-build-manifest.js +1 -1
  119. package/runtime/.next/server/middleware-react-loadable-manifest.js +1 -1
  120. package/runtime/.next/server/pages/404.html +1 -1
  121. package/runtime/.next/server/pages/500.html +1 -1
  122. package/runtime/.next/server/server-reference-manifest.json +1 -1
  123. package/runtime/.next/static/chunks/20.2eb9bc3a5b4d410b.js +1 -0
  124. package/runtime/.next/static/chunks/325-0818ba5a4060a0e8.js +1 -0
  125. package/runtime/.next/static/chunks/34.c7dbf7ffc8914be9.js +1 -0
  126. package/runtime/.next/static/chunks/686.7b5c444243fcf29a.js +1 -0
  127. package/runtime/.next/static/chunks/app/web/error-828d278147a0619d.js +1 -0
  128. package/runtime/.next/static/chunks/app/web/layout-1127176e7e88e395.js +1 -0
  129. package/runtime/.next/static/chunks/app/web/page-8adf166584b0088e.js +1 -0
  130. package/runtime/.next/static/chunks/{main-68faabab5d101471.js → main-9c08f7656f9692e6.js} +1 -1
  131. package/runtime/.next/static/chunks/main-app-07d67f2d4e96ecb8.js +1 -0
  132. package/runtime/.next/static/chunks/{webpack-f51a057f833e73eb.js → webpack-040c7a20dd455025.js} +1 -1
  133. package/runtime/.next/static/css/645d4c94ea111811.css +1 -0
  134. package/runtime/lib/remote-control/application/paced-video-sender.mjs +20 -1
  135. package/runtime/lib/remote-control/application/remote-video-session.mjs +18 -4
  136. package/runtime/lib/remote-control/infrastructure/native-video-encoder.mjs +15 -2
  137. package/runtime/lib/remote-control/infrastructure/werift-video-transport.mjs +3 -1
  138. package/runtime/lib/remote-control/remote-authorization.mjs +2 -2
  139. package/runtime/lib/remote-control/remote-video-signal.mjs +2 -0
  140. package/runtime/lib/todo-completion-worker.mjs +45 -0
  141. package/runtime/lib/tunnel-control.mjs +1 -1
  142. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
  143. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
  144. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
  145. package/runtime/node_modules/.package-lock.json +129 -129
  146. package/runtime/node_modules/@agent/core/dist/index.js +295 -70
  147. package/runtime/node_modules/@agent/native-runtime/dist/index.js +498 -150
  148. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +75 -79
  149. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +52 -52
  150. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-2g5j09ba.mjs +16 -0
  151. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-59ydwk0g.mjs +17 -0
  152. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-q4cwy1ja.mjs → core-664d5mmy.mjs} +2 -2
  153. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-zn1abzvs.mjs → core-70sfhqm6.mjs} +2 -2
  154. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-95gcz3n1.mjs +38 -0
  155. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-ew5sfvfe.mjs +39 -0
  156. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-gjhs7gf6.mjs +20 -0
  157. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-kvdt1szx.mjs +18 -0
  158. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-p654hjkr.mjs +22 -0
  159. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-q9bjbxkv.mjs +19 -0
  160. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-samdvsjh.mjs +33 -0
  161. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-x6bt758j.mjs +17 -0
  162. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +12 -12
  163. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +22 -22
  164. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +26 -26
  165. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +22 -23
  166. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +84 -83
  167. package/runtime/node_modules/caniuse-lite/package.json +1 -1
  168. package/runtime/node_modules/mediabunny/README.md +4 -0
  169. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +225 -136
  170. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +10 -10
  171. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +11 -11
  172. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +225 -136
  173. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +225 -136
  174. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.worker.js +8 -0
  175. package/runtime/node_modules/mediabunny/dist/modules/src/adts/adts-demuxer.js +4 -0
  176. package/runtime/node_modules/mediabunny/dist/modules/src/aes.js +6 -4
  177. package/runtime/node_modules/mediabunny/dist/modules/src/hls/hls-demuxer.js +6 -0
  178. package/runtime/node_modules/mediabunny/dist/modules/src/hls/hls-segmented-input.js +17 -5
  179. package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-boxes.js +2 -1
  180. package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-demuxer.js +62 -12
  181. package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-muxer.js +34 -18
  182. package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-demuxer.js +3 -0
  183. package/runtime/node_modules/mediabunny/dist/modules/src/media-sink.js +3 -8
  184. package/runtime/node_modules/mediabunny/dist/modules/src/media-source.js +5 -12
  185. package/runtime/node_modules/mediabunny/dist/modules/src/misc.js +19 -5
  186. package/runtime/node_modules/mediabunny/dist/modules/src/mp3/mp3-demuxer.js +4 -0
  187. package/runtime/node_modules/mediabunny/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.js +22 -13
  188. package/runtime/node_modules/mediabunny/dist/modules/src/mpeg-ts/mpeg-ts-muxer.js +2 -2
  189. package/runtime/node_modules/mediabunny/dist/modules/src/segmented-input.js +70 -65
  190. package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
  191. package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
  192. package/runtime/node_modules/mediabunny/dist/modules/src/worker.js +26 -0
  193. package/runtime/node_modules/mediabunny/package.json +1 -1
  194. package/runtime/node_modules/mediabunny/src/adts/adts-demuxer.ts +5 -0
  195. package/runtime/node_modules/mediabunny/src/aes.ts +7 -4
  196. package/runtime/node_modules/mediabunny/src/hls/hls-demuxer.ts +7 -0
  197. package/runtime/node_modules/mediabunny/src/hls/hls-segmented-input.ts +19 -6
  198. package/runtime/node_modules/mediabunny/src/isobmff/isobmff-boxes.ts +2 -1
  199. package/runtime/node_modules/mediabunny/src/isobmff/isobmff-demuxer.ts +74 -14
  200. package/runtime/node_modules/mediabunny/src/isobmff/isobmff-muxer.ts +37 -19
  201. package/runtime/node_modules/mediabunny/src/matroska/matroska-demuxer.ts +4 -0
  202. package/runtime/node_modules/mediabunny/src/media-sink.ts +3 -12
  203. package/runtime/node_modules/mediabunny/src/media-source.ts +5 -20
  204. package/runtime/node_modules/mediabunny/src/metadata.ts +1 -0
  205. package/runtime/node_modules/mediabunny/src/misc.ts +26 -5
  206. package/runtime/node_modules/mediabunny/src/mp3/mp3-demuxer.ts +5 -0
  207. package/runtime/node_modules/mediabunny/src/mpeg-ts/mpeg-ts-demuxer.ts +30 -19
  208. package/runtime/node_modules/mediabunny/src/mpeg-ts/mpeg-ts-muxer.ts +2 -2
  209. package/runtime/node_modules/mediabunny/src/segmented-input.ts +76 -79
  210. package/runtime/node_modules/mediabunny/src/version.ts +1 -1
  211. package/runtime/node_modules/mediabunny/src/worker.ts +28 -0
  212. package/runtime/package-lock.json +162 -162
  213. package/runtime/server.js +1 -1
  214. package/runtime/webapp/dist/assets/AIHubView-HV2FIroL.js +1 -0
  215. package/runtime/webapp/dist/assets/{AgentManager-dXI31b0a.js → AgentManager-C4zPGI-Y.js} +2 -2
  216. package/runtime/webapp/dist/assets/AiHubPane-CEjQjdqT.js +1 -0
  217. package/runtime/webapp/dist/assets/App-CS2wVlfV.js +68 -0
  218. package/runtime/webapp/dist/assets/BrowserLivePanel-BwtEM-IV.js +61 -0
  219. package/runtime/webapp/dist/assets/{CalendarPage-BbYdGYWn.js → CalendarPage-DY8pZK7d.js} +1 -1
  220. package/runtime/webapp/dist/assets/{CalendarView-QfbrlL9X.js → CalendarView-CuBzp-g8.js} +1 -1
  221. package/runtime/webapp/dist/assets/{CollaborationCreateDialog-CWhmFQtA.js → CollaborationCreateDialog-DsXkxAd1.js} +1 -1
  222. package/runtime/webapp/dist/assets/{CollaborationDashboard-XL5SnFOu.js → CollaborationDashboard-CvE5vaOh.js} +1 -1
  223. package/runtime/webapp/dist/assets/{CollaborationPage-B1tiqgnG.js → CollaborationPage-Cjeo60S0.js} +2 -2
  224. package/runtime/webapp/dist/assets/{FilePreview-CPY6dP8Q.js → FilePreview-CyXKv1Cu.js} +9 -9
  225. package/runtime/webapp/dist/assets/{FileTree-BBgrOian.js → FileTree-DNI9VhEp.js} +2 -2
  226. package/runtime/webapp/dist/assets/FileWorkspaceDrawer-DRluuYWn.js +1 -0
  227. package/runtime/webapp/dist/assets/FlowStudioPane-CKlzxza_.js +5 -0
  228. package/runtime/webapp/dist/assets/{HostProjectPicker-DN_vGqQb.js → HostProjectPicker-CjlxN2ct.js} +1 -1
  229. package/runtime/webapp/dist/assets/{LSPServerList-B-R7HDSP.js → LSPServerList-BbAS_sm-.js} +1 -1
  230. package/runtime/webapp/dist/assets/{MCPServerList-CTc0iAwT.js → MCPServerList-DkVUlKEJ.js} +1 -1
  231. package/runtime/webapp/dist/assets/{MemoryViewer-Dzh_miRv.js → MemoryViewer-Ywl80xth.js} +1 -1
  232. package/runtime/webapp/dist/assets/NewSessionWindow-B4H26X5c.js +1 -0
  233. package/runtime/webapp/dist/assets/RemoteDesktopPage-B4q2I23i.js +1 -0
  234. package/runtime/webapp/dist/assets/{RemoteDesktopTabBridge-BA_HQv3V.js → RemoteDesktopTabBridge-B_cCKi7K.js} +1 -1
  235. package/runtime/webapp/dist/assets/{RunningSessionsIcon-BvFSI9OF.js → RunningSessionsIcon-Cz8_524L.js} +1 -1
  236. package/runtime/webapp/dist/assets/{SessionDashboard-DcPPoXe2.js → SessionDashboard-DXPSvNsY.js} +1 -1
  237. package/runtime/webapp/dist/assets/{SessionDashboardBridge-CjoeUy-v.js → SessionDashboardBridge-7BjKdfN8.js} +1 -1
  238. package/runtime/webapp/dist/assets/{SettingsPanel-DmdXDQUm.js → SettingsPanel-C78O9_ho.js} +2 -2
  239. package/runtime/webapp/dist/assets/{SkillManager-CS_skFZj.js → SkillManager-BdkBUxhH.js} +1 -1
  240. package/runtime/webapp/dist/assets/{TaskPaneTerminal-BFHDRCb9.js → TaskPaneTerminal-B2WKBysj.js} +1 -1
  241. package/runtime/webapp/dist/assets/{TerminalPane-Dr_nY9pI.js → TerminalPane-CxGcN85G.js} +1 -1
  242. package/runtime/webapp/dist/assets/TodoPage-CdzjZR2O.js +1 -0
  243. package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-FEEApB15.js → abnfDiagram-VCTEODGH-DFIXyU71.js} +1 -1
  244. package/runtime/webapp/dist/assets/{arc-CycwMc2c.js → arc-CLpaLEla.js} +1 -1
  245. package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-BFq9JapX.js → architectureDiagram-5GKGNRK7-Df8T0lx0.js} +1 -1
  246. package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-DkOJ55Ag.js → blockDiagram-I7D4REHJ-jCoyPZhV.js} +1 -1
  247. package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-CRvi_3RM.js → c4Diagram-7LVT6UL2-DsZuTCuo.js} +1 -1
  248. package/runtime/webapp/dist/assets/{calendar-days-CLwKstxM.js → calendar-days-BIRmYMrW.js} +1 -1
  249. package/runtime/webapp/dist/assets/channel-0IyV-PVi.js +1 -0
  250. package/runtime/webapp/dist/assets/{check-8EVJMrTV.js → check-DCU8YHqr.js} +1 -1
  251. package/runtime/webapp/dist/assets/{chevron-down-ChNxfI2x.js → chevron-down-BUEiUZA7.js} +1 -1
  252. package/runtime/webapp/dist/assets/{chevron-right-Cbkc_d70.js → chevron-right-B_ITnckH.js} +1 -1
  253. package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-Cklzvs8u.js → chunk-2Q5K7J3B-BEZp3wuG.js} +1 -1
  254. package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-NxozE5UP.js → chunk-5VM5RSS4-BGGDhFwD.js} +1 -1
  255. package/runtime/webapp/dist/assets/{chunk-F27PBJKO-Dyb8E7YM.js → chunk-F27PBJKO-Mqzm4ODE.js} +1 -1
  256. package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-BqbMMc1n.js → chunk-IMKFNOWR-DtnGgUQJ.js} +1 -1
  257. package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-do0R2H6U.js → chunk-JWPE2WC7-By3kXE4y.js} +1 -1
  258. package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-B2HIaynf.js → chunk-POPQ4Y6H-BTHuMHN1.js} +1 -1
  259. package/runtime/webapp/dist/assets/{chunk-SVP7TREG-C_zmjkwn.js → chunk-SVP7TREG-BeWH1pvB.js} +1 -1
  260. package/runtime/webapp/dist/assets/{chunk-TICWLB2K-Dh2bZgM1.js → chunk-TICWLB2K-oiekJTZh.js} +1 -1
  261. package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-CnqciVDz.js → chunk-XXDRQBXY-B7CKqUBs.js} +1 -1
  262. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-Dm5zwUmQ.js +1 -0
  263. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-Dm5zwUmQ.js +1 -0
  264. package/runtime/webapp/dist/assets/{client-I0ZVCjOI.js → client-BpqlZTm2.js} +1 -1
  265. package/runtime/webapp/dist/assets/{codeSyntax-C8n4_KZS.js → codeSyntax-GjP28nDI.js} +3 -3
  266. package/runtime/webapp/dist/assets/{collaboration-lVxWL5ce.js → collaboration-CYS2Soeh.js} +1 -1
  267. package/runtime/webapp/dist/assets/composer-file-routing-DHdpFYk8.js +6 -0
  268. package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-CulKVUkj.js → cose-bilkent-JH36ORCC-BmhhO76e.js} +1 -1
  269. package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-C1LUI1_G.js → cynefin-OW5HDTMX-BesIxLGS.js} +1 -1
  270. package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-D3Ymzw_P.js → cynefinDiagram-5FMLGOSQ-DdF6XhwX.js} +1 -1
  271. package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-DRaL0cGu.js → dagre-GXQ25YYZ-CxUfRr5w.js} +1 -1
  272. package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-D8gLHoZo.js → diagram-S7CK7UJ4-zSD7nygh.js} +1 -1
  273. package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-CaVU0aQT.js → diagram-UQ7AKVKN-CgirUu7t.js} +1 -1
  274. package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-LFAKRvZz.js → diagram-VSXAHHWV-CkI9kDpP.js} +1 -1
  275. package/runtime/webapp/dist/assets/{diagram-VX7I27RA-DXpxUERc.js → diagram-VX7I27RA-ZfbGJBGR.js} +1 -1
  276. package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-vAiik55G.js → diagram-Z3DM3KII-CA44IJP4.js} +1 -1
  277. package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-MaFL7Kgb.js → ebnfDiagram-PWID7BFC-CVwSxyot.js} +1 -1
  278. package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-DuEu79B3.js → erDiagram-RLTQ6QDP-DwjlVHEs.js} +1 -1
  279. package/runtime/webapp/dist/assets/{file-types-ZVLWtslN.js → file-types-Dj25tuty.js} +1 -1
  280. package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-BAQ6nP2D.js → flowDiagram-HODETNUW-CEt0pwA8.js} +1 -1
  281. package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-C48VBnPy.js → ganttDiagram-EL5Y4UJY-CNsj7gWS.js} +3 -3
  282. package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-BfWAh9Kr.js → gitGraphDiagram-WWUBYQGX-ERbll1_Q.js} +1 -1
  283. package/runtime/webapp/dist/assets/{history-D4E3D_aM.js → history-DTS97eAH.js} +1 -1
  284. package/runtime/webapp/dist/assets/{image-plus-DQV_EEAN.js → image-plus-BmlwMe18.js} +1 -1
  285. package/runtime/webapp/dist/assets/index-C30NoLsn.js +500 -0
  286. package/runtime/webapp/dist/assets/index-COFV-DUC.css +1 -0
  287. package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-BM7P_-u_.js → infoDiagram-27XIBGKW-BiMEmJW5.js} +1 -1
  288. package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-Cwd8XR-p.js → ishikawaDiagram-5VMMS53U-CPlJXmF2.js} +1 -1
  289. package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-MOgiksTh.js → journeyDiagram-3NMN7TZE-DJJ-qvlw.js} +1 -1
  290. package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-DulC5OLL.js → kanban-definition-UXKFOSKX-PHmavvDJ.js} +1 -1
  291. package/runtime/webapp/dist/assets/{layout-Dku9sXQ7.js → layout-DH5OfcVL.js} +1 -1
  292. package/runtime/webapp/dist/assets/{linear-B3-dddD7.js → linear-DQek-QDQ.js} +1 -1
  293. package/runtime/webapp/dist/assets/{list-todo-Bik5IY2r.js → list-todo-DULblcsU.js} +1 -1
  294. package/runtime/webapp/dist/assets/{locate-fixed-CHkezEEh.js → locate-fixed-B3zScPI-.js} +1 -1
  295. package/runtime/webapp/dist/assets/{mermaid.core-CRRXKysA.js → mermaid.core-D6eHnLLU.js} +5 -5
  296. package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-CaaP-nEb.js → mindmap-definition-YA3MSWOX-D0TkZusX.js} +1 -1
  297. package/runtime/webapp/dist/assets/{mobileViewport-CekmYKqS.js → mobileViewport-BhIxH-zP.js} +1 -1
  298. package/runtime/webapp/dist/assets/{new-session-window-BfDMd-h3.css → new-session-window-DIU2v1uh.css} +1 -1
  299. package/runtime/webapp/dist/assets/new-session-window-bxVA-U3Y.js +191 -0
  300. package/runtime/webapp/dist/assets/page-DyPXAvyj.js +86 -0
  301. package/runtime/webapp/dist/assets/{pause-BsmUCuwZ.js → pause-C793N3J1.js} +1 -1
  302. package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-BqybPEwk.js → pegDiagram-XKGWAZYB-DMIjPBzH.js} +1 -1
  303. package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-BX1H2lh2.js → pieDiagram-E7YTZNPT-DctF47JZ.js} +1 -1
  304. package/runtime/webapp/dist/assets/{pin-BsEEYq8M.js → pin-BLVakDSL.js} +1 -1
  305. package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-Btnywv1k.js → quadrantDiagram-AXDQQJYC-JnwbWWwT.js} +1 -1
  306. package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-Da_TV1ER.js → railroadDiagram-O6MQD6OU-DcpHMNVP.js} +1 -1
  307. package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-5V1Aow9h.js → requirementDiagram-BXWQKSXE-C-fRbIOI.js} +1 -1
  308. package/runtime/webapp/dist/assets/{rotate-ccw-BbSby0GQ.js → rotate-ccw-CyZK_Om1.js} +1 -1
  309. package/runtime/webapp/dist/assets/{rotate-cw-BMdX-ln4.js → rotate-cw-ChAt9mcI.js} +1 -1
  310. package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-D_OIVihV.js → sankeyDiagram-P5KCCOFB-Sb34Y9Ep.js} +1 -1
  311. package/runtime/webapp/dist/assets/{send-Cb7EWSJF.js → send-DlrISC4K.js} +1 -1
  312. package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-LKeF5Mri.js → sequenceDiagram-WJ2MYXX4-BeHoOpkJ.js} +1 -1
  313. package/runtime/webapp/dist/assets/{session-dashboard-BFqNDCc8.js → session-dashboard-D1JY1ka0.js} +1 -1
  314. package/runtime/webapp/dist/assets/{session-tree-BK_qaCnb.js → session-tree-Q-jABJNB.js} +1 -1
  315. package/runtime/webapp/dist/assets/{shield-check-C-r87aMq.js → shield-check-Bzd1i1OQ.js} +1 -1
  316. package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-B6j7Q_MN.js → sizeCapture-INFHLROL-DspvE2eQ.js} +1 -1
  317. package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-zhPFqHdQ.js → stateDiagram-D77RDMKH-oBIvmRy9.js} +1 -1
  318. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-DXD2F0in.js +1 -0
  319. package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-C_FCENx1.js → swimlanes-42K2YHIH-CAdrbVmI.js} +1 -1
  320. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CXpNu-5Z.js +8 -0
  321. package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-C3DBXjDU.js → timeline-definition-24CTP7MA-BtWjc4KI.js} +1 -1
  322. package/runtime/webapp/dist/assets/{trash-2-DjggJGbw.js → trash-2-DwFoTvHX.js} +1 -1
  323. package/runtime/webapp/dist/assets/{types-BQCEWNQz.js → types-COzZsLPY.js} +1 -1
  324. package/runtime/webapp/dist/assets/{use-session-activity-BbTXGW7Z.js → use-session-activity-BRhj0V5U.js} +1 -1
  325. package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-CssdTIB0.js → vennDiagram-4TSXK5OY-Be4H6PYr.js} +1 -1
  326. package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-C58K2vVU.js → wardleyDiagram-VM6X3IG4-COVxCAu8.js} +1 -1
  327. package/runtime/webapp/dist/assets/{web-B4y8vdRZ.js → web-BdMHTzmo.js} +1 -1
  328. package/runtime/webapp/dist/assets/{web-D9rJZXHW.js → web-Qg6ZVe1T.js} +1 -1
  329. package/runtime/webapp/dist/assets/{x-BYUglEo9.js → x-CoIXF2eL.js} +1 -1
  330. package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-CQi8bD6A.js → xychartDiagram-S5SC5T6Z-J_S9eMK9.js} +1 -1
  331. package/runtime/webapp/dist/assets/{zoom-out-iMMWRXJs.js → zoom-out-C10hb0zX.js} +1 -1
  332. package/runtime/webapp/dist/index.html +2 -2
  333. package/runtime/ws-server.mjs +5 -0
  334. package/runtime/.next/static/chunks/106.b2050e53421795af.js +0 -1
  335. package/runtime/.next/static/chunks/20.7bd5212774091396.js +0 -1
  336. package/runtime/.next/static/chunks/34.40a88b70750502fb.js +0 -1
  337. package/runtime/.next/static/chunks/753-90c7dd1ba08be9be.js +0 -1
  338. package/runtime/.next/static/chunks/app/web/error-30cea9cffce0ebc2.js +0 -1
  339. package/runtime/.next/static/chunks/app/web/layout-d8a4f4131e7f2330.js +0 -1
  340. package/runtime/.next/static/chunks/app/web/page-b0da5ef19349a66b.js +0 -1
  341. package/runtime/.next/static/chunks/main-app-30a478479a347a9e.js +0 -1
  342. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-0e6mn0ck.mjs +0 -17
  343. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-0ssqfy51.mjs +0 -18
  344. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-82ghff97.mjs +0 -39
  345. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-82yhcz2x.mjs +0 -17
  346. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-b8jr1m8m.mjs +0 -23
  347. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-cj0jh226.mjs +0 -17
  348. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-ebtbxtjf.mjs +0 -28
  349. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-pb4erfqh.mjs +0 -42
  350. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-rs058s2g.mjs +0 -16
  351. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-w6pv4szb.mjs +0 -18
  352. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-wjeh40nr.mjs +0 -20
  353. package/runtime/webapp/dist/assets/AIHubView-CM6ugXG3.js +0 -1
  354. package/runtime/webapp/dist/assets/AiHubPane-DFzC3nbd.js +0 -1
  355. package/runtime/webapp/dist/assets/App-mF6ELC07.js +0 -68
  356. package/runtime/webapp/dist/assets/BrowserLivePanel-CamAULwS.js +0 -61
  357. package/runtime/webapp/dist/assets/FileWorkspaceDrawer-BXDuKlrL.js +0 -1
  358. package/runtime/webapp/dist/assets/FlowStudioPane-lnjLcd9c.js +0 -5
  359. package/runtime/webapp/dist/assets/NewSessionWindow-zjqAUfKb.js +0 -1
  360. package/runtime/webapp/dist/assets/RemoteDesktopPage-9AhztqA2.js +0 -1
  361. package/runtime/webapp/dist/assets/TodoPage-guIvBCW0.js +0 -1
  362. package/runtime/webapp/dist/assets/artifact-links-B0ApmgK6.js +0 -2
  363. package/runtime/webapp/dist/assets/channel-BwDuyJO4.js +0 -1
  364. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BfyV8P0w.js +0 -1
  365. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BfyV8P0w.js +0 -1
  366. package/runtime/webapp/dist/assets/composer-file-routing-qSvJpT-v.js +0 -6
  367. package/runtime/webapp/dist/assets/download-BE31-Qm0.js +0 -6
  368. package/runtime/webapp/dist/assets/index-DSgLFE4Q.js +0 -489
  369. package/runtime/webapp/dist/assets/index-zQk0NCEB.css +0 -1
  370. package/runtime/webapp/dist/assets/loader-circle-C5C-IzGK.js +0 -6
  371. package/runtime/webapp/dist/assets/new-session-window-Dgl7UWPR.js +0 -190
  372. package/runtime/webapp/dist/assets/page-_fFyRId-.js +0 -86
  373. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-DWnBZAiI.js +0 -1
  374. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-DOZCbCJP.js +0 -8
  375. /package/runtime/.next/static/{5rv6PMhU7yq1sI1ClFWRU → XwGGZtJQeU5VoGqV-1dyI}/_buildManifest.js +0 -0
  376. /package/runtime/.next/static/{5rv6PMhU7yq1sI1ClFWRU → XwGGZtJQeU5VoGqV-1dyI}/_ssgManifest.js +0 -0
  377. /package/runtime/.next/static/chunks/{183-dbd3e343da4ba103.js → 183-5019797f0b42210b.js} +0 -0
  378. /package/runtime/.next/static/chunks/{3cc391f0-4ff886cecc4d6d79.js → 3cc391f0-6cd083946ece156d.js} +0 -0
  379. /package/runtime/.next/static/chunks/app/_not-found/{page-c0fc9b6684d4f0ca.js → page-cffe4d626dcef5fd.js} +0 -0
@@ -1,61 +0,0 @@
1
- var ri=t=>{throw TypeError(t)};var Li=(t,e,r)=>e.has(t)||ri("Cannot "+r);var ii=(t,e,r)=>e.has(t)?ri("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);var yr=(t,e,r)=>(Li(t,e,"access private method"),r);import{c as je,j as h,r as d,B as zi,a as br,z as ni}from"./index-DSgLFE4Q.js";import{L as Ae}from"./loader-circle-C5C-IzGK.js";import{C as Fi}from"./chevron-down-ChNxfI2x.js";import{d as Vi,E as Bi}from"./RemoteDesktopTabBridge-BA_HQv3V.js";import{M as si,Z as Oi,a as Ui}from"./zoom-out-iMMWRXJs.js";import{R as Wi}from"./rotate-ccw-BbSby0GQ.js";import{X as $i}from"./x-BYUglEo9.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 Hi=je("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 gr=je("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 oi=je("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 Ki=je("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 Xi=je("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"}]]);/**
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 ai=je("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["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 er=je("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 ci=je("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 Yi=je("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 li=je("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=je("Volume2",[["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"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
57
- * @license lucide-react v0.468.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const _i=je("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 ui({label:t,title:e,value:r,busy:n,disabled:s,compact:u,onChange:l,children:m}){return h.jsxs("span",{className:`live-view-select${u?" live-view-select--compact":""}`,children:[h.jsx("select",{"aria-label":t,"aria-busy":n,title:e,value:r,disabled:s||n,onChange:a=>l(a.target.value),children:m}),n?h.jsx("span",{className:"live-view-select-icon",role:"status","aria-label":`${t}正在切换`,children:h.jsx(Ae,{size:14,className:"spin","aria-hidden":"true"})}):h.jsx(Fi,{size:14,className:"live-view-select-icon","aria-hidden":"true"})]})}function Gi({disabled:t,onPaste:e,onError:r}){const[n,s]=d.useState(!1),[u,l]=d.useState(!1),m=d.useRef(null),a=d.useRef(!1),p=d.useRef(!0),k=d.useRef(!t);k.current=!t,d.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),d.useEffect(()=>{var C;u&&((C=m.current)==null||C.focus({preventScroll:!0}))},[u]);const b=async C=>{if(!(a.current||t)){a.current=!0,s(!0),r(null);try{const R=await C();if(!p.current||!k.current)return;if(R===null){l(!0),r("浏览器限制读取剪贴板,请长按“系统粘贴”使用系统菜单,粘贴后自动输入电脑");return}if(!R)throw new Error("剪贴板里没有文字");await e(R),p.current&&l(!1)}catch(R){p.current&&r(R instanceof Error?R.message:"粘贴失败,请重试")}finally{a.current=!1,p.current&&s(!1)}}};return u?h.jsx("input",{ref:m,className:"browser-live-native-paste","aria-label":"系统粘贴",placeholder:"系统粘贴",disabled:t||n,defaultValue:"",autoCapitalize:"none",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onPaste:C=>{C.preventDefault();const R=C.clipboardData.getData("text/plain");b(()=>Promise.resolve(R))}}):h.jsx("button",{type:"button",disabled:t||n,title:"直接粘贴当前手机或电脑剪贴板的文字",onClick:()=>void b(Vi),children:n?"粘贴中…":"粘贴"})}const Ji=5e3,Qi=1e4;class en{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?Ji:Qi;return{state:n>=s?"stalled":"streaming",silentForMs:n}}}const hi="cli-desktop:primary",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 Rr(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 tn(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 jr(t,e){const r=t-e>>>0;return r!==0&&r<2147483648}function rn(t,e){return Number.isSafeInteger(t==null?void 0:t.sourceRevision)&&t.sourceRevision>=0&&Rr(t,e)&&Rr({x:t.sourceX,y:t.sourceY,width:t.width,height:t.height},e)&&(t.sourceX!==t.x||t.sourceY!==t.y)}var nn=ArrayBuffer,Z=Uint8Array,rr=Uint16Array,sn=Int16Array,ir=Int32Array,wr=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},Nt=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},on=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++]},an=["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||an[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,_),!r)throw n;return n},di=function(t,e,r){for(var n=0,s=0;n<r;++n)s|=t[e++]<<(n<<3);return s},cn=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},ln=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,u=n>>2&1,l=n&3,m=n>>6;n&8&&_(0);var a=6-s,p=l==3?4:l,k=di(t,a,p);a+=p;var b=m?1<<m:s,C=di(t,a,b)+(m==1&&256),R=C;if(!s){var H=1<<10+(t[5]>>3);R=H+(H>>3)*(t[5]&7)}R>2145386496&&_(1);var M=new Z((e==1?C||R:e?0:R)+12);return M[0]=1,M[4]=4,M[8]=8,{b:a+b,y:0,l:0,d:k,w:e&&e!=1?e:M.subarray(12),e:R,o:new ir(M.buffer,0,3),u:C,c:u,m:Math.min(131072,R)}}else if((r>>4|t[3]<<20)==25481893)return cn(t,4)+8;_(0)},tt=function(t){for(var e=0;1<<e<=t;++e);return e-1},At=function(t,e,r){var n=(e<<3)+4,s=(t[e]&15)+5;s>r&&_(3);for(var u=1<<s,l=u,m=-1,a=-1,p=-1,k=u,b=new nn(512+(u<<2)),C=new sn(b,0,256),R=new rr(b,0,256),H=new rr(b,512,u),M=512+(u<<1),L=new Z(b,M,u),ue=new Z(b,M+u);m<255&&l>0;){var U=tt(l+1),P=n>>3,ee=(1<<U+1)-1,F=(t[P]|t[P+1]<<8|t[P+2]<<16)>>(n&7)&ee,j=(1<<U)-1,g=ee-l-1,K=F&j;if(K<g?(n+=U,F=K):(n+=U+1,F>j&&(F-=g)),C[++m]=--F,F==-1?(l+=F,L[--k]=m):l-=F,!F)do{var B=n>>3;a=(t[B]|t[B+1]<<8)>>(n&7)&3,n+=2,m+=a}while(a==3)}(m>255||l)&&_(0);for(var O=0,Q=(u>>1)+(u>>3)+3,te=u-1,A=0;A<=m;++A){var N=C[A];if(N<1){R[A]=-N;continue}for(p=0;p<N;++p){L[O]=A;do O=O+Q&te;while(O>=k)}}for(O&&_(0),p=0;p<u;++p){var v=R[L[p]]++,$=ue[p]=s-tt(v);H[p]=(v<<$)-u}return[n+7>>3,{b:s,s:L,n:ue,t:H}]},un=function(t,e){var r=0,n=-1,s=new Z(292),u=t[e],l=s.subarray(0,256),m=s.subarray(256,268),a=new rr(s.buffer,268);if(u<128){var p=At(t,e+1,6),k=p[0],b=p[1];e+=u;var C=k<<3,R=t[e];R||_(0);for(var H=0,M=0,L=b.b,ue=L,U=(++e<<3)-8+tt(R);U-=L,!(U<C);){var P=U>>3;if(H+=(t[P]|t[P+1]<<8)>>(U&7)&(1<<L)-1,l[++n]=b.s[H],U-=ue,U<C)break;P=U>>3,M+=(t[P]|t[P+1]<<8)>>(U&7)&(1<<ue)-1,l[++n]=b.s[M],L=b.n[H],H=b.t[H],ue=b.n[M],M=b.t[M]}++n>255&&_(0)}else{for(n=u-127;r<n;r+=2){var ee=t[++e];l[r]=ee>>4,l[r+1]=ee&15}++e}var F=0;for(r=0;r<n;++r){var j=l[r];j>11&&_(0),F+=j&&1<<j-1}var g=tt(F)+1,K=1<<g,B=K-F;for(B&B-1&&_(0),l[n++]=tt(B)+1,r=0;r<n;++r){var j=l[r];++m[l[r]=j&&g+1-j]}var O=new Z(K<<1),Q=O.subarray(0,K),te=O.subarray(K);for(a[g]=0,r=g;r>0;--r){var A=a[r];Nt(te,r,A,a[r-1]=A+m[r]*(1<<g-r))}for(a[0]!=K&&_(0),r=0;r<n;++r){var N=l[r];if(N){var v=a[N];Nt(Q,r,v,a[N]=v+(1<<g-N))}}return[e,{n:te,b:g,s:Q}]},hn=At(new Z([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],dn=At(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],fn=At(new Z([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],gi=function(t,e){for(var r=t.length,n=new ir(r),s=0;s<r;++s)n[s]=e,e+=1<<t[s];return n},Er=new Z(new ir([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),pn=gi(Er,0),Mr=new Z(new ir([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),mn=gi(Mr,3),It=function(t,e,r){var n=t.length,s=e.length,u=t[n-1],l=(1<<r.b)-1,m=-r.b;u||_(0);for(var a=0,p=r.b,k=(n<<3)-8+tt(u)-p,b=-1;k>m&&b<s;){var C=k>>3,R=(t[C]|t[C+1]<<8|t[C+2]<<16)>>(k&7);a=(a<<p|R)&l,e[++b]=r.s[a],k-=p=r.n[a]}(k!=m||b+1!=s)&&_(0)},vn=function(t,e,r){var n=6,s=e.length,u=s+3>>2,l=u<<1,m=u+l;It(t.subarray(n,n+=t[0]|t[1]<<8),e.subarray(0,u),r),It(t.subarray(n,n+=t[2]|t[3]<<8),e.subarray(u,l),r),It(t.subarray(n,n+=t[4]|t[5]<<8),e.subarray(l,m),r),It(t.subarray(n),e.subarray(m),r)},yn=function(t,e,r){var n,s=e.b,u=t[s],l=u>>1&3;e.l=u&1;var m=u>>3|t[s+1]<<5|t[s+2]<<13,a=(s+=3)+m;if(l==1)return s>=t.length?void 0:(e.b=s+1,r?(Nt(r,t[s],e.y,e.y+=m),r):Nt(new Z(m),t[s]));if(!(a>t.length)){if(l==0)return e.b=a,r?(r.set(t.subarray(s,a),e.y),e.y+=m,r):wr(t,s,a);if(l==2){var p=t[s],k=p&3,b=p>>2&3,C=p>>4,R=0,H=0;k<2?b&1?C|=t[++s]<<4|(b&2&&t[++s]<<12):C=p>>3:(H=b,b<2?(C|=(t[++s]&63)<<4,R=t[s]>>6|t[++s]<<2):b==2?(C|=t[++s]<<4|(t[++s]&3)<<12,R=t[s]>>2|t[++s]<<6):(C|=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),L=M.length-C;if(k==0)M.set(t.subarray(s,s+=C),L);else if(k==1)Nt(M,t[s++],L);else{var ue=e.h;if(k==2){var U=un(t,s);R+=s-(s=U[0]),e.h=ue=U[1]}else ue||_(0);(H?vn:It)(t.subarray(s,s+=R),M.subarray(L),ue)}var P=t[s++];if(P){P==255?P=(t[s++]|t[s++]<<8)+32512:P>127&&(P=P-128<<8|t[s++]);var ee=t[s++];ee&3&&_(0);for(var F=[dn,fn,hn],j=2;j>-1;--j){var g=ee>>(j<<1)+2&3;if(g==1){var K=new Z([0,0,t[s++]]);F[j]={s:K.subarray(2,3),n:K.subarray(0,1),t:new rr(K.buffer,0,1),b:0}}else g==2?(n=At(t,s,9-(j&1)),s=n[0],F[j]=n[1]):g==3&&(e.t||_(0),F[j]=e.t[j])}var B=e.t=F,O=B[0],Q=B[1],te=B[2],A=t[a-1];A||_(0);var N=(a<<3)-8+tt(A)-te.b,v=N>>3,$=0,be=(t[v]|t[v+1]<<8)>>(N&7)&(1<<te.b)-1;v=(N-=Q.b)>>3;var Ee=(t[v]|t[v+1]<<8)>>(N&7)&(1<<Q.b)-1;v=(N-=O.b)>>3;var Le=(t[v]|t[v+1]<<8)>>(N&7)&(1<<O.b)-1;for(++P;--P;){var me=te.s[be],I=te.n[be],q=O.s[Le],ge=O.n[Le],he=Q.s[Ee],ze=Q.n[Ee];v=(N-=he)>>3;var pt=1<<he,Fe=pt+((t[v]|t[v+1]<<8|t[v+2]<<16|t[v+3]<<24)>>>(N&7)&pt-1);v=(N-=Mr[q])>>3;var Me=mn[q]+((t[v]|t[v+1]<<8|t[v+2]<<16)>>(N&7)&(1<<Mr[q])-1);v=(N-=Er[me])>>3;var qe=pn[me]+((t[v]|t[v+1]<<8|t[v+2]<<16)>>(N&7)&(1<<Er[me])-1);if(v=(N-=I)>>3,be=te.t[be]+((t[v]|t[v+1]<<8)>>(N&7)&(1<<I)-1),v=(N-=ge)>>3,Le=O.t[Le]+((t[v]|t[v+1]<<8)>>(N&7)&(1<<ge)-1),v=(N-=ze)>>3,Ee=Q.t[Ee]+((t[v]|t[v+1]<<8)>>(N&7)&(1<<ze)-1),Fe>3)e.o[2]=e.o[1],e.o[1]=e.o[0],e.o[0]=Fe-=3;else{var Se=Fe-(qe!=0);Se?(Fe=Se==3?e.o[0]-1:e.o[Se],Se>1&&(e.o[2]=e.o[1]),e.o[1]=e.o[0],e.o[0]=Fe):Fe=e.o[0]}for(var j=0;j<qe;++j)M[$+j]=M[L+j];$+=qe,L+=qe;var we=$-Fe;if(we<0){var He=-we,qt=e.e+we;He>Me&&(He=Me);for(var j=0;j<He;++j)M[$+j]=e.w[qt+j];$+=He,Me-=He,we=0}for(var j=0;j<Me;++j)M[$+j]=M[we+j];$+=Me}if($!=L)for(;L<M.length;)M[$++]=M[L++];else $=M.length;r?e.y+=$:M=wr(M,0,$)}else if(r){if(e.y+=C,L)for(var j=0;j<C;++j)M[j]=M[L+j]}else L&&(M=wr(M,L));return e.b=a,M}_(2)}},bn=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 u=t[n];r.set(u,s),s+=u.length}return r};function gn(t,e){for(var r=[],n=+!e,s=0,u=0;t.length;){var l=ln(t,n||e);if(typeof l=="object"){for(n?(e=null,l.w.length==l.u&&(r.push(e=l.w),u+=l.u)):(r.push(e),l.e=0);!l.l;){var m=yn(t,l,e);m||_(5),e?l.e=l.y:(r.push(m),u+=m.length,on(l.w,0,m.length),l.w.set(m,l.w.length-m.length))}s=l.b+l.c*4}else s=l;t=t.subarray(s)}return bn(r,u)}const ft=30,kr=10,wn=new TextEncoder,kn=new TextDecoder("utf-8",{fatal:!0});function nr(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),a=>a.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((a,p)=>n[p]!==a)||String.fromCharCode(...n.subarray(12,16))!=="IHDR")throw new Error("Invalid PNG header");const u=new DataView(n.buffer,n.byteOffset,n.byteLength),l=u.getUint32(16),m=u.getUint32(20);if(l<1||m<1||l>z.tileSize||m>z.tileSize||e!==void 0&&l!==e||r!==void 0&&m!==r)throw new Error("Invalid PNG dimensions");return n}function xn(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 Cn(t){return t.version===1&&t.kind==="tiles"&&typeof t.epoch=="string"&&t.epoch.length>0&&wn.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 wi(t){if(t[0]===65&&t[1]===82&&t[2]===67&&t[3]===90)return wi(Rn(t));if(t.length<ft||t.length>z.maxMessageBytes||[65,82,67,86,1,1].some((a,p)=>t[p]!==a))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||ft+r+n*kr>t.length)throw new Error("Invalid compound binary lengths");const s={version:1,kind:"tiles",epoch:kn.decode(t.subarray(ft,ft+r)),revision:e.getFloat64(8),sequence:e.getFloat64(16),rtpTimestamp:e.getUint32(24),tiles:[]};let u=ft+r;const l=new Set,m=new Set;for(let a=0;a<n;a++){if(u+kr>t.length)throw new Error("Truncated compound tile");const p={cacheId:e.getUint16(u),x:e.getUint16(u+2),y:e.getUint16(u+4),width:e.getUint8(u+6),height:e.getUint8(u+7)},k=e.getUint16(u+8);u+=kr;const b=`${p.x},${p.y}`;if(!xn(p)||l.has(b)||u+k>t.length)throw new Error("Invalid compound tile bounds");if(l.add(b),k){if(m.has(p.cacheId))throw new Error("Duplicate compound cache insertion");m.add(p.cacheId),p.data=nr(t.subarray(u,u+k),p.width,p.height),u+=k}s.tiles.push(p)}if(u!==t.length||!Cn(s))throw new Error("Invalid compound binary batch");return s}function Rn(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<ft||e>z.maxMessageBytes)throw new Error("Invalid compound output length");const r=t.subarray(8);if([40,181,47,253].some((b,C)=>r[C]!==b))throw new Error("Invalid Zstd magic");const n=r[4],s=(n&32)!==0,u=n>>>6;if(n&27)throw new Error("Unsupported Zstd dictionary/reserved bits");let l=5;if(!s){const b=r[l++],C=2**(10+(b>>>3));if(C+C/8*(b&7)>65536)throw new Error("Compound Zstd window too large")}const m=u===0?s?1:0:u===1?2:u===2?4:8;if(!m||l+m>r.length)throw new Error("Zstd content size required");let a=0;for(let b=0;b<m;b++)a+=r[l+b]*2**(8*b);if(m===2&&(a+=256),a!==e)throw new Error("Zstd content size differs");l+=m;let p=!1;for(;!p;){if(l+3>r.length)throw new Error("Truncated Zstd block");const b=r[l]|r[l+1]<<8|r[l+2]<<16;l+=3,p=(b&1)!==0;const C=b>>>1&3,R=b>>>3;if(C===3||R>131072)throw new Error("Invalid Zstd block");if(l+=C===1?1:R,l>r.length)throw new Error("Truncated Zstd payload")}if(n&4&&(l+=4),l!==r.length)throw new Error("Trailing compound Zstd data");const k=gn(r,new Uint8Array(e));if(k.length!==e||k[3]!==86)throw new Error("Invalid decompressed compound packet");return k}function tr(t){return Number.isInteger(t)&&Number(t)>=0&&Number(t)<=4294967295}function jn(t){return Number.isSafeInteger(t)&&Number(t)>=0}async function En(t){const e=nr(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((u,l)=>{const m=new Image;m.onload=()=>u(m),m.onerror=()=>l(new Error("PNG decode failed")),m.src=n});return{source:s,width:s.naturalWidth,height:s.naturalHeight,close:()=>{s.src=""}}}finally{URL.revokeObjectURL(n)}}class fi{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??En}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 u=()=>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=u,s.channel.onmessage=l=>this.receive(l.data),s.channel.onclose=()=>this.stop(),s.channel.readyState==="open"&&u(),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(!tr(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=wi(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(!tn(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(!jn(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=>Rr(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(!tr(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(!rn(n,{width:this.width,height:this.height})||!tr(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,u=this.options.getCanvas(),l=u==null?void 0:u.getContext("2d"),m=!!s&&s.revision===n.sourceRevision&&!!l;m&&(l.clearRect(n.x,n.y,n.width,n.height),l.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:m})}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(!tr(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 u=this.options.getCanvas(),l=u==null?void 0:u.getContext("2d");if(!l)throw new Error("Canvas unavailable");for(const m of e.tiles){if(!this.validTile(m,e.binary))throw new Error("Invalid tile bounds");let a=this.assets.get(m.key);if(e.binary&&a&&m.data!==void 0)throw new Error("Compound cache slot already occupied");if(!a){if(typeof m.data!="string"&&!(m.data instanceof Uint8Array))throw new Error("Missing cached tile");nr(m.data,m.width,m.height);const p=await this.decodeImage(m.data);if(this.stopped||this.generation!==r){p.close();return}if(p.width!==m.width||p.height!==m.height||this.cachePixels+m.width*m.height>z.maxCachePixels||this.assets.size>=z.maxCacheEntries)throw p.close(),new Error("Compound image cache limit exceeded");a=p,this.assets.set(m.key,a),n.set(m.key,a),this.cachePixels+=m.width*m.height}if(a.width!==m.width||a.height!==m.height)throw new Error("Cached tile dimensions differ");if(this.stopped||this.generation!==r)return;l.drawImage(a.source,m.x,m.y,m.width,m.height)}if(this.stopped||this.generation!==r)return;this.sourceRtp=this.sourceRtp===void 0||jr(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[l,m]of n)this.assets.get(l)===m&&(this.assets.delete(l),this.cachePixels-=m.width*m.height,m.close());this.decoding=!1,this.decodingBytes=0;const u=this.batches.shift();this.pending=null,!this.stopped&&u&&u.epoch===this.epoch&&u.revision===this.revision&&this.applyTiles(u)}}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||jr(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,u;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,(u=r.getContext("2d"))==null||u.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 Mn{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=u=>this.receive(u.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)){nr(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 p;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&&!jr(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 u=this.local&&Date.now()-this.local.at<150?this.local:e,l=u.x*n.width,m=u.y*n.height,a=(k,b,C)=>typeof k=="number"&&Number.isFinite(k)?Math.max(0,Math.min(C,k)):b;if(this.image)s.drawImage(this.image,l-a(e.hotX,0,128),m-a(e.hotY,0,128),a(e.drawWidth,this.image.naturalWidth,128),a(e.drawHeight,this.image.naturalHeight,128));else{s.save(),s.translate(l,m);const k=a(e.pixelScale,1,4);s.scale(k,k),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",(p=n.parentElement)==null||p.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 pi(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 xr=()=>Object.assign(new Error("输入会话已切换"),{code:"ECANCELED"});class Sn{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=u=>this.receipt(u.data),s.onclose=()=>{if(this.reliable===s&&(this.reliable=void 0),!this.stopped)for(const u of this.pending.values())this.fallback(u)}}}};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(pi(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(xr());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(),pi(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(xr());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((u,l)=>{this.queue.push({index:s,sequence:n,input:{...e,direct:{stream:this.stream,sequence:n,index:s}},fallback:r,resolve:u,reject:l}),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(u=>{var m;const l=(m=u==null?void 0:u.input)==null?void 0:m.error;l&&this.onError(new Error(l))}).catch(u=>{(u==null?void 0:u.code)!=="ECANCELED"&&this.onError(u)})},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(xr());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 Tn{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 In{constructor(e){this.peer=e,this.policy=new Tn,this.applied=new Map,this.unsupported=new WeakSet}apply(e,r){var m;if(!((m=e.receiver)!=null&&m.visible))return this.restore(),{playoutControl:!1};const n=this.policy.observe(e.receiver,e.jitterMs,r),s=this.peer.getReceivers().find(a=>{var p;return((p=a.track)==null?void 0:p.kind)==="video"});if(!s||this.unsupported.has(s))return{playoutControl:!1};const u="jitterBufferTarget"in s?"jitterBufferTarget":"playoutDelayHint"in s?"playoutDelayHint":void 0;if(!u)return{playoutControl:!1};if(n!==void 0){const a=u==="jitterBufferTarget"?n:n/1e3,p=this.applied.has(s)?this.applied.get(s).original:s[u];try{if(s[u]=a,!Number.isFinite(s[u])||Math.abs(s[u]-a)>.001)throw new Error("Receiver ignored playout target");this.applied.set(s,{key:u,original:p,value:a})}catch{return this.unsupported.add(s),this.restoreReceiver(s),{playoutControl:!1}}}const l=this.applied.get(s);return l?{playoutControl:!0,playoutTargetMs:l.value*(l.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 Nn{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 Pt,Sr;class Pn{constructor(){ii(this,Pt);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,n=!1){n&&this.reset(),this.points.size||(this.origin=r,this.moved=!1),this.points.set(e,r),this.points.size>1&&(this.moved=!0),this.originDistance=yr(this,Pt,Sr).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;if(this.points.size!==2)return null;const u=[...this.points.values()],l=k=>({x:(k[0].x+k[1].x)/2,y:(k[0].y+k[1].y)/2}),m=k=>Math.hypot(k[0].x-k[1].x,k[0].y-k[1].y),a=m(s),p=this.originDistance>0?m(u)/this.originDistance:1;return{scale:a>0?m(u)/a:1,distanceRatio:p,from:l(s),to:l(u),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===2&&(this.originDistance=yr(this,Pt,Sr).call(this)),this.points.size||this.reset(),s}}Pt=new WeakSet,Sr=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 An(t,e,r){const n=Math.max(t.top,e.top-r.top),s=Math.max(t.left,e.left-r.left),u=Math.min(t.top+t.height,e.top+e.height-r.top),l=Math.min(t.left+t.width,e.left+e.width-r.left);return{top:n,left:s,height:Math.max(0,u-n),width:Math.max(0,l-s)}}function mi(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 qn(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 u=null,l=null;const m=()=>{let C=mi(e);if(n&&s&&!e.document.fullscreenElement){const R={top:0,left:0,width:e.innerWidth,height:e.innerHeight};C=r?R:An(R,mi(n),s.getBoundingClientRect())}for(const[R,H]of Object.entries(C))t.style.setProperty(`--browser-live-${R}`,`${H}px`)},a=()=>{u!==null&&e.cancelAnimationFrame(u),u=e.requestAnimationFrame(()=>{u=null,m()}),l!==null&&e.clearTimeout(l),l=e.setTimeout(m,250)},p=[e,e.document];e.visualViewport&&p.push(e.visualViewport),n&&(p.push(n),p.push(n.document),n.visualViewport&&p.push(n.visualViewport));const k=["resize","scroll","orientationchange","pageshow","visibilitychange","fullscreenchange","transitionend"];for(const C of p)for(const R of k)C.addEventListener(R,a);const b=s&&typeof ResizeObserver<"u"?new ResizeObserver(a):null;return s&&(b==null||b.observe(s)),m(),()=>{for(const C of p)for(const R of k)C.removeEventListener(R,a);u!==null&&e.cancelAnimationFrame(u),l!==null&&e.clearTimeout(l),b==null||b.disconnect();for(const C of["top","left","width","height"])t.style.removeProperty(`--browser-live-${C}`)}}const J=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0;function Dn(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 Ln(t){var r,n,s;const e=new Set;for(const u of t??[]){if(((r=u.mimeType)==null?void 0:r.toLowerCase())!=="video/h264")continue;const l=(s=(n=/(?:^|;)\s*profile-level-id=([0-9a-f]{6})/i.exec(u.sdpFmtpLine??""))==null?void 0:n[1])==null?void 0:s.toLowerCase();l!=null&&l.startsWith("64")&&e.add("high"),(!l||l.startsWith("42"))&&e.add("baseline")}return[...e]}function zn(){var e;if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities!="function")return["baseline"];const t=Ln((e=RTCRtpReceiver.getCapabilities("video"))==null?void 0:e.codecs);return t.length?t:["baseline"]}function Fn(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 Vn(t,e,r=Date.now(),n){const u=[...typeof t.values=="function"?t.values():t],l=u.find(I=>I.type==="inbound-rtp"&&(I.kind==="video"||I.mediaType==="video"));if(!l)return null;const m=u.find(I=>I.id===l.codecId),a=u.find(I=>I.type==="candidate-pair"&&I.state==="succeeded"&&(I.nominated===!0||I.selected===!0)),p=u.find(I=>I.id===(a==null?void 0:a.localCandidateId)),k=u.find(I=>I.id===(a==null?void 0:a.remoteCandidateId)),b=[p==null?void 0:p.candidateType,k==null?void 0:k.candidateType].map(String),C=["relay","srflx","prflx","host"].find(I=>b.includes(I))??void 0,R=J(l.bytesReceived)??0,H=J(l.packetsReceived)??0,M=J(l.packetsLost)??0,L=J(l.framesDropped)??0,ue=e?Math.max(1,r-e.at):0,U=e?Math.max(0,H-e.packetsReceived):0,P=e?Math.max(0,M-e.packetsLost):0,ee=e?Math.max(0,L-e.framesDropped):0,F=J(a==null?void 0:a.currentRoundTripTime),j=J(l.jitter),g=typeof l.decoderImplementation=="string"?l.decoderImplementation.slice(0,120):void 0,K=typeof l.powerEfficientDecoder=="boolean"?l.powerEfficientDecoder:void 0,B=g!==void 0||K!==void 0?{implementation:g,powerEfficient:K,acceleration:K===!0?"hardware":K===!1?"software":"unknown"}:void 0,O=J(l.framesDecoded),Q=J(l.totalDecodeTime),te=e!==null&&O!==void 0&&e.framesDecoded!==void 0&&O>=e.framesDecoded&&L>=e.framesDropped&&r>e.at&&r-e.at<=5e3,A=te?O-e.framesDecoded:void 0,N=te&&A>0&&Q!==void 0&&(e==null?void 0:e.totalDecodeTime)!==void 0&&Q>=e.totalDecodeTime?(Q-e.totalDecodeTime)*1e3/A:void 0,v=((e==null?void 0:e.sequence)??0)+1,$=J(l.jitterBufferEmittedCount),be=e&&$!==void 0&&e.jitterBufferEmittedCount!==void 0&&r>e.at&&r-e.at<=5e3?$-e.jitterBufferEmittedCount:0,Ee=I=>{const q=J(l[I]),ge=e==null?void 0:e[I];if(be<=0||q===void 0||ge===void 0||q<ge)return;const he=(q-ge)*1e3/be;return Number.isFinite(he)&&he>=0&&he<=6e4?he:void 0},Le={jitterBufferMs:Ee("jitterBufferDelay"),jitterBufferTargetMs:Ee("jitterBufferTargetDelay"),jitterBufferMinimumMs:Ee("jitterBufferMinimumDelay")},me={...n?{receiver:{sequence:v,visible:n.visible,viewport:n.viewport,width:J(l.frameWidth),height:J(l.frameHeight),...Object.fromEntries(Object.entries(Le).filter(([,I])=>I!==void 0)),...te?{intervalMs:r-e.at,decodedFrames:A,...N!==void 0?{decodeMs:N}:{},...A+ee>0?{droppedRatio:ee/(A+ee)}:{},...Number.isFinite(n.presentationDelayMs)?{presentationDelayMs:n.presentationDelayMs}:{}}:{}}}:{},codec:typeof(m==null?void 0:m.mimeType)=="string"?m.mimeType.replace(/^video\//i,""):void 0,codecProfile:Fn(m==null?void 0:m.sdpFmtpLine),decoder:B,width:J(l.frameWidth),height:J(l.frameHeight),fps:J(l.framesPerSecond),rttMs:F!==void 0?F*1e3:void 0,jitterMs:j!==void 0?j*1e3:void 0,lossRate:U+P>0?P/(U+P):0,droppedFrames:ee,receiveBitrate:e?Math.max(0,Math.round((R-e.bytesReceived)*8e3/ue)):void 0,availableBitrate:J(a==null?void 0:a.availableIncomingBitrate),candidateType:C,protocol:(p==null?void 0:p.protocol)==="tcp"||(k==null?void 0:k.protocol)==="tcp"?"tcp":a?"udp":void 0};for(const I of Object.keys(me))me[I]===void 0&&delete me[I];return{sample:me,cursor:{at:r,bytesReceived:R,packetsReceived:H,packetsLost:M,framesDropped:L,sequence:v,...Q!==void 0?{totalDecodeTime:Q}:{},...O!==void 0?{framesDecoded:O}:{},...Object.fromEntries(["jitterBufferDelay","jitterBufferTargetDelay","jitterBufferMinimumDelay","jitterBufferEmittedCount"].map(I=>[I,J(l[I])]).filter(([,I])=>I!==void 0))}}}function Bn(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 On(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 Un={"agent-controlled":"Agent 操作中","handoff-requested":"正在交接","user-controlled":"你正在操作","return-requested":"正在归还",resyncing:"Agent 正在同步页面"},Wn={smooth:"流畅",hd:"高清",original:"原画"};function Cr(t){return t==="desktop"?"桌面屏幕":t==="ego-browser"?"ego-browser":"内置 Browser"}function vi(t,e,r){var n,s;return t||(((n=e.find(u=>u.agentSessionId===r))==null?void 0:n.id)??((s=e[0])==null?void 0:s.id)??null)}function $n(t){return!!(t&&t.availability==="ready"&&!t.isController&&!t.controlledByAnotherViewer&&(t.state==="agent-controlled"||t.state==="handoff-requested"))}function yi(t){return(t==null?void 0:t.backend)==="desktop"&&t.platform==="darwin"?"Meta":"Control"}function bi(t){return[t.altKey?"Alt":"",t.ctrlKey?"Control":"",t.metaKey?"Meta":"",t.shiftKey?"Shift":""].filter(Boolean)}function Hn(t){const e=new Uint8Array(t.length*2),r=new DataView(e.buffer);for(let s=0;s<t.length;s+=1){const u=Math.max(-1,Math.min(1,t[s]));r.setInt16(s*2,u<0?u*32768:u*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 Kn(t,e){const r=atob(t),n=Math.floor(r.length/2/e),s=Array.from({length:e},()=>new Float32Array(n));for(let u=0;u<n;u+=1)for(let l=0;l<e;l+=1){const m=(u*e+l)*2,a=r.charCodeAt(m)|r.charCodeAt(m+1)<<8;s[l][u]=(a&32768?a-65536:a)/32768}return s}async function Xn(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 C of s.getTracks())C.stop()}),t.aborted)return null;const u=window.AudioContext,l=new u({latencyHint:"interactive"});e.push(()=>{l.close().catch(()=>{})});const m=new u({latencyHint:"interactive"});if(e.push(()=>{m.close().catch(()=>{})}),await Promise.all([l.resume(),m.resume()]),t.aborted)return null;const a=m.createGain();a.connect(m.destination);const p=l.createMediaStreamSource(s),k=l.createScriptProcessor(2048,1,1),b=l.createGain();return b.gain.value=0,p.connect(k),k.connect(b),b.connect(l.destination),n=!0,{stream:s,microphoneContext:l,remoteContext:m,remoteGain:a,source:p,processor:k,sink:b,dispose:r}}finally{t.removeEventListener("abort",r),n||r()}}function Yn(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 Zn=2;function _n(t,e,r,n,s=.02){if(!t||!e||!e.width||!e.height)return!1;const u=t.x/e.width-s,l=t.y/e.height-s,m=(t.x+t.w)/e.width+s,a=(t.y+t.h)/e.height+s;return r>=u&&r<=m&&n>=l&&n<=a}function Gn(t,e,r=Zn){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 os({open:t,active:e=!0,embedded:r=!1,agentSessionId:n,sessionDesktop:s,onClose:u,onFullscreenChange:l}){const m=d.useContext(zi),a=typeof window>"u"?void 0:window.browserLiveApi,p=s!==void 0,k=(s==null?void 0:s.expanded)===!0,b=p&&t&&e,[C,R]=d.useState(null);d.useEffect(()=>{var x;const i=(x=a==null?void 0:a.readDesktopLockState)==null?void 0:x.bind(a);if(!b||!i){R(null);return}const c=new AbortController;let o;const y=async()=>{const w=await i(c.signal).catch(()=>null);c.signal.aborted||(R(w),o=setTimeout(y,2e3))};return y(),()=>{c.abort(),clearTimeout(o)}},[a,b]);const H=d.useRef(u);H.current=u;const M=d.useRef(null),L=d.useRef(null);d.useLayoutEffect(()=>{if(!(!t||r||!M.current))return qn(M.current,window,document.body.dataset.remoteDesktop==="1")},[t,r,k]);const[ue,U]=d.useState(!1),P=p?k:ue;d.useEffect(()=>{l==null||l(P)},[P,l]);const ee=async()=>{const i=L.current;if(i){if(P){document.fullscreenElement===i&&await document.exitFullscreen().catch(()=>{}),U(!1);return}U(!0),i.requestFullscreen&&await i.requestFullscreen().catch(()=>{})}};d.useEffect(()=>{if(!t){U(!1);return}if(p&&!k)return;const i=L.current,c=()=>U(document.fullscreenElement===i),o=y=>{y.key==="Escape"&&(document.fullscreenElement===i||i!=null&&i.classList.contains("is-fullscreen"))&&(y.preventDefault(),y.stopPropagation(),document.fullscreenElement===i&&document.exitFullscreen().catch(()=>{}),p?H.current():U(!1))};return document.addEventListener("fullscreenchange",c),document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("fullscreenchange",c),document.removeEventListener("keydown",o,!0),i&&document.fullscreenElement===i&&document.exitFullscreen().catch(()=>{})}},[t,p,k]);const[F,j]=d.useState([]),[g,K]=d.useState(null),[B,O]=d.useState(null),[Q,te]=d.useState("hd"),[A,N]=d.useState(null),[v,$]=d.useState(null),[be,Ee]=d.useState(!1),[Le,me]=d.useState(0),[I,q]=d.useState(null),[ge,he]=d.useState(!1),[ze,pt]=d.useState(null),[Fe,Me]=d.useState(!1),[qe,Se]=d.useState(""),[we,He]=d.useState(!1),[qt,rt]=d.useState(null),[De,mt]=d.useState(1),Tr=d.useRef(De);Tr.current=De;const[W,vt]=d.useState(!1),[it,ki]=d.useState({width:0,height:0}),de=d.useRef(null),nt=d.useRef(null),Dt=d.useRef(!1),Ke=d.useRef(null),Xe=d.useRef(new Pn),yt=d.useRef(De),Lt=d.useRef(null);d.useLayoutEffect(()=>{yt.current=De;const i=Lt.current,c=de.current,o=c==null?void 0:c.querySelector(".browser-live-image-hit-area");if(!i||!c||!o)return;const y=o.getBoundingClientRect();c.scrollLeft+=y.left+i.x*y.width-i.clientX,c.scrollTop+=y.top+i.y*y.height-i.clientY,Lt.current=null},[De]);const Ye=d.useRef(null),[Te,zt]=d.useState(!1),st=d.useRef(!1),Ft=d.useRef(0),Ze=d.useRef(null);d.useEffect(()=>{t||(Me(!1),Se(""),rt(null))},[t]);const[xi,bt]=d.useState(!1),gt=d.useRef(null),Vt=d.useRef(0),Ie=d.useRef("none"),oe=d.useRef(null),sr=d.useRef(null),[Ir,Bt]=d.useState(null),[wt,Ci]=d.useState(!1),Nr=d.useRef(null),[Ve,Ne]=d.useState("off"),[Pr,kt]=d.useState(null),Je=d.useRef(null),re=d.useRef(null),ie=d.useRef(null),Ot=d.useRef(0),Be=d.useRef(null),Ar=d.useRef(null),qr=d.useRef(null),_e=d.useRef(null),fe=d.useRef(null),ve=d.useRef(null),ot=d.useRef(null),Qe=d.useRef(new en),xt=d.useRef(!1),[Dr,Ut]=d.useState(null),[Oe,Ct]=d.useState("idle"),[Wt,Lr]=d.useState(!1),[$t,zr]=d.useState(!1),Ht=d.useRef(!1),Kt=d.useRef(!1),Rt=d.useRef(null),or=d.useRef(null),ar=d.useRef(null),cr=d.useRef(null),lr=d.useRef(null),Xt=d.useRef(null),at=d.useRef(null),ct=d.useRef(0),Fr=d.useRef(0),jt=d.useRef(0),Yt=d.useRef(null);d.useLayoutEffect(()=>{st.current=Te,Te&&bt(!1)},[Te]);const f=d.useMemo(()=>F.find(i=>i.id===g)??null,[g,F]),V=(f==null?void 0:f.backend)==="desktop",Vr=V&&(f==null?void 0:f.platform)==="win32",Ri=(f==null?void 0:f.availability)==="unavailable"&&(f==null?void 0:f.capabilityErrorCode)==="desktop-locked",T=!p&&(f==null?void 0:f.isController)&&f.state==="user-controlled",lt=f==null?void 0:f.audioCapabilities,ut=!!(lt!=null&&lt.fullDuplex&&lt.systemAudio&&lt.microphonePlayback&&lt.selfPlaybackExclusion),et=!!(f!=null&&f.online&&f.availability==="ready"&&!f.controlledByAnotherViewer),ur=!p&&$n(f),Et=ge||(f==null?void 0:f.state)==="handoff-requested";d.useEffect(()=>{if(!t||!a||!g||p){Bt(null);return}let i=!0;const c=()=>{const y=performance.now();a.request("browser:ping",{t:y}).then(()=>{i&&Bt(Math.round(performance.now()-y))}).catch(()=>{i&&Bt(null)})};c();const o=window.setInterval(c,3e3);return()=>{i=!1,window.clearInterval(o),Bt(null)}},[a,t,g,p]),d.useEffect(()=>{const i=navigator;if(!T||!i.wakeLock)return;let c=!1,o=null;return i.wakeLock.request("screen").then(y=>{if(c){y.release();return}o=y,Nr.current=y}).catch(()=>{}),()=>{c=!0,o==null||o.release().catch(()=>{}),Nr.current=null}},[T]);const ht=(v==null?void 0:v.viewport)??(f==null?void 0:f.viewport),hr=ht&&it.width&&it.height?Math.min(it.width/ht.width,it.height/ht.height):null;d.useEffect(()=>{var i;mt(1),vt(!1),nt.current=null,Xe.current.reset(),Lt.current=null,Ze.current=null,(i=de.current)==null||i.scrollTo(0,0)},[t,g]),d.useEffect(()=>{const i=de.current;if(!t||!i)return;const c=new ResizeObserver(()=>{ki({width:i.clientWidth,height:i.clientHeight})});return c.observe(i),()=>c.disconnect()},[t,V,k]),d.useEffect(()=>{const i=de.current;if(!t||!i||!T||W)return;const c=o=>o.preventDefault();return i.addEventListener("wheel",c,{passive:!1}),()=>i.removeEventListener("wheel",c)},[t,T,W]);const ji=d.useCallback(()=>{Ft.current+=1;const i=Ye.current;i&&(Te?(i.blur(),zt(!1)):(br.flushSync(()=>vt(!1)),i.focus({preventScroll:!0})))},[Te]);d.useEffect(()=>{var i;(!e||!T||W)&&(Ft.current+=1,(i=Ye.current)==null||i.blur(),zt(!1))},[e,T,W,Te]);const Zt=d.useCallback(i=>{const c=(v==null?void 0:v.viewport)??(f==null?void 0:f.viewport),o=de.current,y=o==null?void 0:o.querySelector(".browser-live-image-hit-area");if(!i||!c||!o||!y)return;const x=y.getBoundingClientRect(),w=o.getBoundingClientRect(),S=x.top+i.y/c.height*x.height,E=S+i.h/c.height*x.height,D=16;S>=w.top+D&&E<=w.bottom-D||(o.scrollTop+=S-(w.top+Math.max(D,w.height*.3)))},[v==null?void 0:v.viewport,f==null?void 0:f.viewport]);d.useEffect(()=>{if(!Te||!Ze.current)return;const i=window.setTimeout(()=>Zt(Ze.current),420);return()=>window.clearTimeout(i)},[Te,it.width,it.height,Zt]);const dr=d.useCallback((i,c=!1)=>{var y;const o=i&&typeof i.input=="object"&&i.input!==null?i.input:i;if(typeof(o==null?void 0:o.editable)=="boolean"){if(!o.editable&&o.kind==="control"){Ze.current=null;return}if(o.editable){const x=o.bounds,w=x&&["x","y","w","h"].every(S=>typeof x[S]=="number")?{x:x.x,y:x.y,w:x.w,h:x.h}:null;w&&(Ze.current=w),c&&!st.current&&!window.matchMedia("(pointer: coarse)").matches&&((y=Ye.current)==null||y.focus({preventScroll:!0})),st.current?Zt(w??Ze.current):bt(!0)}else Ze.current=null}},[Zt]),Pe=d.useCallback((i=!0)=>{var x,w,S,E,D;(x=Yt.current)==null||x.abort(),Yt.current=null;const c=Rt.current;Rt.current=null;for(const X of(c==null?void 0:c.getTracks())??[])X.stop();(w=ar.current)==null||w.disconnect(),(S=cr.current)==null||S.disconnect(),(E=lr.current)==null||E.disconnect(),ar.current=null,cr.current=null,lr.current=null;const o=or.current;or.current=null,o&&o.close().catch(()=>{});const y=Xt.current;Xt.current=null,(D=at.current)==null||D.disconnect(),at.current=null,ct.current=0,jt.current=0,y&&y.close().catch(()=>{}),Ht.current=!1,Kt.current=!1,Lr(!1),zr(!1),Ct("idle"),i&&a&&g&&a.request("browser:webrtc",{sessionId:g,data:{kind:"audio-stop"}}).catch(()=>{})},[a,g]),Br=d.useCallback(i=>{var Ce;if(Kt.current||typeof i.data!="string")return;const c=Xt.current,o=Number(i.sampleRate),y=Number(i.channels);if(!c||!Number.isSafeInteger(o)||!Number.isSafeInteger(y)||y<1||y>2)return;const x=Kn(i.data,y);if(!((Ce=x[0])!=null&&Ce.length))return;const w=c.createBuffer(y,x[0].length,o);for(let ae=0;ae<y;ae+=1)w.copyToChannel(x[ae],ae);const S=c.createBufferSource();S.buffer=w;const E=at.current;if(!E)return;S.connect(E);const D=c.currentTime,X=Math.max(D+.02,ct.current);ct.current=X-D>.35?D+.02:X,S.start(ct.current),ct.current+=w.duration},[]),Ei=d.useCallback(async()=>{var c;if(!a||!g||!T||!ut||document.visibilityState!=="visible")return;const i=new AbortController;(c=Yt.current)==null||c.abort(),Yt.current=i,q(null),Ct("starting");try{const o=await Xn(i.signal);if(!o||i.signal.aborted||document.visibilityState!=="visible"){o==null||o.dispose();return}const{stream:y,microphoneContext:x,remoteContext:w,remoteGain:S,source:E,processor:D,sink:X}=o;Rt.current=y,or.current=x,ar.current=E,cr.current=D,lr.current=X,Xt.current=w,at.current=S,Fr.current=0,D.onaudioprocess=Ce=>{if(i.signal.aborted||Ht.current||!Rt.current||!a||!g||jt.current>=4)return;const ae=new Float32Array(Ce.inputBuffer.getChannelData(0));jt.current+=1,a.request("browser:webrtc",{sessionId:g,data:{kind:"audio-microphone",sequence:++Fr.current,sampleRate:x.sampleRate,channels:1,data:Hn(ae)}}).catch(()=>{}).finally(()=>{jt.current=Math.max(0,jt.current-1)})},await a.request("browser:webrtc",{sessionId:g,data:{kind:"audio-start"}})}catch(o){if(i.signal.aborted)return;Pe(!1),Ct("failed"),q(o instanceof Error?o.message:"无法开始语音")}},[a,T,g,Pe,ut]);d.useEffect(()=>{t&&e&&T&&ut||Oe!=="idle"&&Pe(!0)},[e,Oe,T,t,Pe,ut]),d.useEffect(()=>{const i=()=>{document.visibilityState!=="visible"&&Oe!=="idle"&&Pe(!0)};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[Oe,Pe]),d.useEffect(()=>()=>Pe(!0),[Pe]);const Or=d.useMemo(()=>[{urls:"stun:stun.l.google.com:19302"}],[]),Ur=d.useCallback(async(i,c,o,y,x,w)=>{var E,D,X,Ce,ae,Ge;if(!a||!i||!c)return;let S;try{const Re=re.current;re.current=null,(E=ie.current)==null||E.stop(),ie.current=null,(D=_e.current)==null||D.stop(),(X=fe.current)==null||X.stop(),fe.current=null,(Ce=ve.current)==null||Ce.stop(),ve.current=null,(ae=ot.current)==null||ae.stop(),Re==null||Re.close();let Y=re.current;if(!Y){Y=new RTCPeerConnection({iceServers:o!=null&&o.length?o:Or}),S=new Nn(Y,w),ie.current=S;const se=new fi({getVideo:()=>Be.current,getCanvas:()=>Ar.current});se.attach(Y);const ce=new Mn({getVideo:()=>Be.current,getCanvas:()=>qr.current});ce.attach(Y),(Ge=_e.current)==null||Ge.stop(),_e.current=ce;const dt=new Sn(y,x===2?2:1,le=>q(le.message));dt.setVisible(document.visibilityState!=="hidden"),dt.attach(Y),fe.current=dt,ve.current=new In(Y),ot.current=se,Y.onicecandidate=le=>{!le.candidate||re.current!==Y||a.request("browser:webrtc",{sessionId:i,data:{kind:"ice",candidate:le.candidate.toJSON(),...w?{attemptId:w}:{}}}).catch(()=>{})},Y.ontrack=le=>{if(re.current!==Y)return;const $e=Be.current;$e&&le.streams[0]&&($e.srcObject=le.streams[0],$e.play().catch(()=>{}))},Y.onconnectionstatechange=()=>{if(re.current!==Y)return;const le=Y==null?void 0:Y.connectionState;le==="connected"?Ne("live"):(le==="failed"||le==="disconnected"||le==="closed")&&Ne("failed")},re.current=Y}const ne=await S.answer(c);if(!ne||ie.current!==S)return;Ne("connecting"),await a.request("browser:webrtc",{sessionId:i,data:{kind:"answer",sdp:ne.toJSON(),...w?{attemptId:w}:{}}})}catch(Re){if(S?ie.current!==S:ie.current!==null)return;a.request("browser:webrtc",{sessionId:i,data:{kind:"viewer-trace",event:"negotiation-failed",attemptId:w,error:Re instanceof Error?Re.message.slice(0,300):"WebRTC negotiation failed"}}).catch(()=>{}),Ne("failed")}},[a,Or]),Wr=d.useCallback((i,c)=>{if(c){if(c.kind==="quality-state"&&["smooth","hd","original"].includes(String(c.quality))){te(String(c.quality)),N(null),typeof c.error=="string"&&q(c.error);return}if(c.kind==="audio-system"){Br(c);return}if(c.kind==="audio-state"){const o=String(c.state);["idle","starting","live","failed"].includes(o)&&Ct(o),typeof c.error=="string"&&(q(c.error),Pe(!1),Ct("failed"));return}if(c.kind==="offer"){typeof c.warning=="string"&&q(c.warning),Ur(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 o=c.candidate,y=ie.current;y&&o&&y.addIceCandidate(o,c.attemptId).catch(()=>{});return}if(c.kind==="state"){if(c.attemptId!==void 0&&ie.current&&!ie.current.accepts(c.attemptId))return;const o=String(c.state);o==="connected"?Ne("live"):(o==="failed"||o==="disconnected"||o==="closed")&&Ne("failed")}}},[Ur,Br,Pe]),[Ue,$r]=d.useState(null);d.useEffect(()=>{if(!v){$r(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,o=!1;const y=new Image;return y.src=i,y.decode().then(()=>{c||(o=!0,$r(i))}).catch(()=>{}),()=>{c=!0,!o&&i.startsWith("blob:")&&URL.revokeObjectURL(i)}},[v]),d.useEffect(()=>()=>{Ue!=null&&Ue.startsWith("blob:")&&URL.revokeObjectURL(Ue)},[Ue]);const ke=d.useCallback(i=>{p&&(i.id!==hi||i.backend!=="desktop")||(j(c=>{const o=c.findIndex(x=>x.id===i.id);if(o>=0&&Yn(c[o],i))return c;if(o<0)return[i,...c];const y=[...c];return y[o]=i,y.sort((x,w)=>w.updatedAt-x.updatedAt)}),K(c=>p?i.id:vi(c,[i],n)),he(!1))},[n,p]),_t=d.useCallback(async()=>{if(!(!a||!t)){Ee(!0),q(null);try{const i=await a.request("browser:list"),c=p?i.sessions.filter(o=>o.id===hi&&o.backend==="desktop"):i.sessions;j(c),K(o=>{var x;const y=o&&c.some(w=>w.id===o)?o:null;return p?((x=c[0])==null?void 0:x.id)??null:vi(y,c,n)}),g&&!p&&await a.request("browser:watch",{sessionId:g}).then(o=>ke(o.session)).catch(()=>{}),me(o=>o+1)}catch(i){q(i instanceof Error?i.message:"无法读取浏览器会话")}finally{Ee(!1)}}},[n,a,ke,t,g,p]);d.useEffect(()=>{if(!(!t||!a))return _t(),a.onEvent(i=>{var c,o,y,x,w,S;if(i.type==="browser:connection"){(c=_e.current)==null||c.stop(),(o=fe.current)==null||o.stop(),fe.current=null,(y=ve.current)==null||y.stop(),ve.current=null,(x=ot.current)==null||x.stop(),(w=re.current)==null||w.close(),re.current=null,(S=ie.current)==null||S.stop(),ie.current=null,Ne("off"),he(!1),j([]),$(null),i.connected===!0?_t():q("远程连接已断开,正在重新连接");return}if(i.type==="browser:frame"){if(i.sessionDesktop===!0!==p||p&&!b)return;const E=i;E.sessionId===g&&$(E);return}if(i.type==="browser:webrtc"){if(p)return;const E=i.data;i.sessionId===g&&Wr(g,E);return}if(i.session&&typeof i.session=="object"&&ke(i.session),i.type==="browser:closed"){const E=i.session;E&&(j(D=>D.filter(X=>X.id!==E.id)),E.id===g&&($(null),K(null)))}})},[a,Wr,ke,t,_t,g,p,b]),d.useEffect(()=>{if(!(!t||!a||!g||p))return $(null),q(null),xt.current=!1,Ut(null),a.request("browser:watch",{sessionId:g}).then(i=>ke(i.session)).catch(i=>q(i instanceof Error?i.message:"无法观看浏览器")),()=>{a.request("browser:unwatch").catch(()=>{})}},[a,ke,t,g,p]),d.useEffect(()=>{if(!b||!a||!g)return;let i=!0;return a.request("browser:desktop-watch",{sessionId:g,expanded:k}).then(({session:c})=>{i&&(ke(c),q(null))}).catch(c=>{i&&q(c instanceof Error?c.message:"无法观看桌面")}),()=>{i=!1}},[b,a,g,k,Le,ke]),d.useEffect(()=>{if(!(!b||!a||!g))return()=>{a.request("browser:desktop-unwatch").catch(()=>{})}},[b,a,g]),d.useEffect(()=>{p&&!b&&$(null)},[p,b]),d.useEffect(()=>{var i,c,o,y,x,w,S,E,D,X,Ce,ae;if(!t||!a||!T||!V||!g){xt.current=!1,Ut(null),Ot.current=0,(i=_e.current)==null||i.stop(),(c=fe.current)==null||c.stop(),fe.current=null,(o=ve.current)==null||o.stop(),ve.current=null,(y=ot.current)==null||y.stop(),(x=re.current)==null||x.close(),re.current=null,(w=ie.current)==null||w.stop(),ie.current=null,Be.current&&(Be.current.srcObject=null),Je.current=null,kt(null),Ne("off");return}return(S=_e.current)==null||S.stop(),(E=fe.current)==null||E.stop(),fe.current=null,(D=ve.current)==null||D.stop(),ve.current=null,(X=ot.current)==null||X.stop(),(Ce=re.current)==null||Ce.close(),re.current=null,(ae=ie.current)==null||ae.stop(),ie.current=null,Je.current=null,kt(null),Ne("connecting"),Qe.current.begin(performance.now()),a.request("browser:webrtc",{sessionId:g,data:{kind:"start",inputVersion:2,receiverProfiles:zn(),...fi.supported()?{compoundVersion:1}:{}}}).catch(()=>Ne("failed")),()=>{var Ge,Re,Y,ne,se,ce;(Ge=_e.current)==null||Ge.stop(),(Re=fe.current)==null||Re.stop(),fe.current=null,(Y=ve.current)==null||Y.stop(),ve.current=null,(ne=ot.current)==null||ne.stop(),(se=re.current)==null||se.close(),re.current=null,(ce=ie.current)==null||ce.stop(),ie.current=null,Be.current&&(Be.current.srcObject=null),Je.current=null,kt(null),a.request("browser:webrtc",{sessionId:g,data:{kind:"stop"}}).catch(()=>{})}},[a,T,V,t,g,Le]),d.useEffect(()=>{if(!t||!T||!V||Ve!=="failed"||Ot.current>=2)return;const i=window.setTimeout(()=>{Ot.current+=1,me(c=>c+1)},2e3*(Ot.current+1));return()=>window.clearTimeout(i)},[t,T,V,Ve]),d.useEffect(()=>{if(!a||!g||Ve!=="live"){Je.current=null,kt(null);return}let i=!0,c=!1;const o=Be.current,y=typeof(o==null?void 0:o.requestVideoFrameCallback)=="function";let x,w=null,S=!1,E=0,D,X=-1/0,Ce=0;Qe.current.begin(performance.now());const ae=ne=>{if(!i||document.visibilityState==="hidden")return;const se=performance.now(),ce=Qe.current.observe(ne,se);ce&&(!S||se-E>=2e3)&&(S=!0,E=se,a.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"playback-ready"}}).catch(()=>{})),ce&&xt.current&&(xt.current=!1,Ut(null),a.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"stall-recovered",...w?{sample:w}:{}}}).catch(()=>{}))};if(y&&o){const ne=(se,ce)=>{ae(ce.presentedFrames),document.visibilityState!=="hidden"&&Number.isFinite(ce.expectedDisplayTime)&&(D=Math.max(0,se-ce.expectedDisplayTime),X=performance.now()),i&&(x=o.requestVideoFrameCallback(ne))};x=o.requestVideoFrameCallback(ne)}const Ge=()=>{var ne,se;Je.current=null,D=void 0,X=-1/0,(ne=fe.current)==null||ne.setVisible(document.visibilityState!=="hidden"),document.visibilityState==="hidden"&&((se=ve.current)==null||se.stop()),document.visibilityState!=="hidden"&&Qe.current.resume(performance.now())};document.addEventListener("visibilitychange",Ge);const Re=async()=>{var se,ce,dt;const ne=re.current;if(!(!ne||c)){c=!0;try{const le=await ne.getStats().catch(()=>null);if(!i||ne!==re.current)return;const $e=performance.now(),ye=le&&Vn(le,Je.current,Date.now(),{visible:document.visibilityState!=="hidden",...$e-X<=2e3?{presentationDelayMs:D}:{},viewport:{width:((se=de.current)==null?void 0:se.clientWidth)??0,height:((ce=de.current)==null?void 0:ce.clientHeight)??0,pixelRatio:Math.min(4,Math.max(1,window.devicePixelRatio||1)),zoom:Math.min(4,Math.max(1,Tr.current))}});if(ye){ye.sample.receiver&&(ye.sample.receiver.sequence=++Ce);const Qt=(dt=ve.current)==null?void 0:dt.apply(ye.sample,$e);Qt&&ye.sample.receiver&&Object.assign(ye.sample.receiver,Qt),Je.current=ye.cursor,w=ye.sample,kt(ye.sample),a.request("browser:webrtc",{sessionId:g,data:{kind:"stats",...ye.sample}}).catch(()=>{})}const ei=Dn(o,ye==null?void 0:ye.cursor.framesDecoded);y||ae(ei);const Di=y||ei!==void 0||!(o!=null&&o.videoWidth);if(document.visibilityState!=="hidden"&&Di&&Qe.current.evaluate($e).state==="stalled"){const Qt=Qe.current.evaluate($e);Qe.current.begin($e),Ne(ti=>ti==="live"?"failed":ti),xt.current=!0,Ut("实时画面超时,已切换为 JPEG 兜底画面"),a.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"jpeg-fallback",silentForMs:Qt.silentForMs,...w?{sample:w}:{}}}).catch(()=>{})}}catch{}finally{c=!1}}};Re();const Y=window.setInterval(()=>void Re(),1e3);return()=>{i=!1,S&&a.request("browser:webrtc",{sessionId:g,data:{kind:"viewer-trace",event:"jpeg-fallback"}}).catch(()=>{}),window.clearInterval(Y),x!==void 0&&(o==null||o.cancelVideoFrameCallback(x)),document.removeEventListener("visibilitychange",Ge)}},[a,g,Ve]);const Hr=d.useCallback(async()=>{if(!(!a||!f||p)){he(!0),q(null);try{const i=await a.request("browser:takeover",{sessionId:f.id});ke(i.session)}catch(i){he(!1),q(i instanceof Error?i.message:"无法接管浏览器")}}},[a,ke,f,p]),Mi=d.useCallback(async()=>{if(!(!a||!f)){he(!0),q(null);try{const i=await a.request("browser:return",{sessionId:f.id});ke(i.session)}catch(i){he(!1),q(i instanceof Error?i.message:"无法归还浏览器")}}},[a,ke,f]),fr=d.useCallback(async(i,c)=>{if(!(!a||!g)){pt(i),q(null);try{await a.request("browser:system",{sessionId:g,action:i,...c?{password:c}:{}}),window.setTimeout(()=>me(o=>o+1),800)}catch(o){q(o instanceof Error?o.message:"系统操作失败")}finally{pt(null)}}},[a,g]),Si=d.useCallback(async()=>{if(!(!a||!g||!qe)){He(!0),rt(null);try{await a.request("browser:system",{sessionId:g,action:"unlock",password:qe}),Se(""),Me(!1),window.setTimeout(()=>me(i=>i+1),2500)}catch(i){rt(i instanceof Error?i.message:"解锁失败")}finally{Se(""),He(!1)}}},[a,g,qe]),Mt=d.useCallback(i=>{var y,x;if(!a||B||A||!(f!=null&&f.isController)||f.state!=="user-controlled")return Promise.resolve(null);i.kind==="pointer"&&((y=_e.current)==null||y.localPoint(i));const c={...i,mobile:window.matchMedia("(pointer: coarse)").matches},o=w=>a.request("browser:input",{sessionId:f.id,input:w});return(((x=fe.current)==null?void 0:x.dispatch(c,o))??o(c)).then(w=>{var S;if((S=w==null?void 0:w.input)!=null&&S.error)throw new Error(w.input.error);return w}).catch(w=>((w==null?void 0:w.code)!=="ECANCELED"&&q(w instanceof Error?w.message:"浏览器输入失败"),null))},[a,f,B,A]),G=d.useCallback(i=>{Mt(i)},[Mt]),xe=d.useCallback((i,c,o=[])=>{G({kind:"key",action:"down",key:i,code:c,text:"",modifiers:o}),G({kind:"key",action:"up",key:i,code:c,text:"",modifiers:o})},[G]),St=d.useCallback(i=>{xe(i,`Key${i.toUpperCase()}`,[yi(f)])},[xe,f]),Ti=d.useCallback(async i=>{var w,S;if(!a||!(f!=null&&f.isController)||f.state!=="user-controlled"||B||A)throw new Error("连接正在切换,请稍后重试");const c={kind:"key",action:"down",text:i,key:"",code:"",modifiers:[],mobile:window.matchMedia("(pointer: coarse)").matches},o=E=>a.request("browser:input",{sessionId:f.id,input:E}),y=await(((w=fe.current)==null?void 0:w.dispatch(c,o))??o(c)),x=(S=y==null?void 0:y.input)==null?void 0:S.error;if(x)throw new Error(x)},[a,f,B,A]),pr=d.useCallback((i,c,o=!1)=>{const y=++Ft.current;Mt({kind:"pointer",action:"up",...i,button:"left",...c&&c>1?{click:c}:{}}).then(x=>{y===Ft.current&&dr(x,o)})},[dr,Mt]),Gt=d.useRef(!1),Jt=d.useRef(""),Kr=d.useCallback(i=>{const c=Jt.current;if(i!==c){if(i.startsWith(c)){const o=i.slice(c.length);o&&G({kind:"key",action:"down",text:o,key:"",code:"",modifiers:[]})}Jt.current=i}},[G]),pe=(f==null?void 0:f.displays)??null,Xr=i=>{if(!T||W)return;const c=Ye.current,o=i.code==="KeyA"&&!i.shiftKey&&!i.altKey&&(yi(f)==="Meta"?i.metaKey:i.ctrlKey);c&&i.target===c&&o&&(i.preventDefault(),c.value="",Jt.current=""),!(i.target===Ye.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:bi(i)}),["Backspace","Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Escape"].includes(i.key)&&i.preventDefault())},Yr=i=>{!T||W||i.target===Ye.current&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey||G({kind:"key",action:"up",key:i.key,code:i.code,modifiers:bi(i)})};d.useEffect(()=>{if(!A)return;const i=window.setTimeout(()=>{N(null),q("画质切换未完成,请刷新画面后重试")},14e3);return()=>window.clearTimeout(i)},[A]),d.useEffect(()=>{N(null),te("hd")},[t,g]);const Ii=i=>{!a||!et||B||A||!g||(N(i),a.request("browser:webrtc",{sessionId:g,data:{kind:"quality",quality:i}}).catch(c=>{N(null),q(c instanceof Error?c.message:"画质切换失败")}))};d.useEffect(()=>{if(!B)return;if(pe!=null&&pe.some(c=>c.id===B&&c.selected)){O(null);return}const i=window.setTimeout(()=>{O(null),q("切换屏幕未完成,请刷新画面后重试")},14e3);return()=>window.clearTimeout(i)},[pe,B]),d.useEffect(()=>{O(null)},[t,g]);const mr=d.useRef(0),Ni=d.useCallback(i=>{!a||B||A||!g||!et||!(pe!=null&&pe.some(c=>c.id===i&&!c.selected))||(O(i),a.request("browser:set-display",{sessionId:g,displayId:i}).catch(c=>{O(null),q(c instanceof Error?c.message:"切换屏幕失败")}))},[a,pe,g,et,B,A]),We=d.useCallback(i=>{const c=i.currentTarget.getBoundingClientRect(),o=(v==null?void 0:v.viewport)??(f==null?void 0:f.viewport);if(!o)return null;const y=Math.min(c.width/o.width,c.height/o.height),x=o.width*y,w=o.height*y,S=(c.width-x)/2,E=(c.height-w)/2,D=(i.clientX-c.left-S)/x,X=(i.clientY-c.top-E)/w;return D<0||D>1||X<0||X>1?null:{x:D,y:X}},[v==null?void 0:v.viewport,f==null?void 0:f.viewport]);if(!t||typeof document>"u")return null;const Zr=(f==null?void 0:f.online)&&!f.controlledByAnotherViewer,Pi=(f==null?void 0:f.availability)==="unavailable"?V?"桌面直播不可用":"浏览器直播不可用":(f==null?void 0:f.availability)==="starting"?"正在连接画面":V&&(f==null?void 0:f.state)==="agent-controlled"?"未被远程控制":f?Un[f.state]:V?"等待桌面直播":"等待浏览器",_r=(f==null?void 0:f.availability)==="unavailable"?V?"桌面直播不可用":"浏览器直播不可用":(f==null?void 0:f.availability)==="starting"?"正在连接画面":F.length?"等待第一帧":V||p?"暂无桌面直播":"暂无浏览器直播",Ai=(f==null?void 0:f.availability)==="unavailable"?f.capabilityError||(V?"需要在桌面 App 中开启并授予屏幕录制权限":"当前浏览器不支持实时画面传输"):F.length?"画面开始后会自动显示":V||p?"在桌面 App 设置中开启「桌面直播与远程控制」后,画面会出现在这里":"Agent 开始浏览网页后,会话会出现在这里",qi=Bn(Pr),Gr=On(Pr),Jr=Ve==="live"?qi||"WebRTC 实时流":Ve==="connecting"?"正在连接 WebRTC":Ue?"JPEG 兜底":null,vr=v&&Ue&&(!p||(f==null?void 0:f.availability)==="ready"),Tt=b&&C===!0?"电脑已锁屏,解锁后自动恢复桌面画面":null;if(s&&!k)return h.jsxs("button",{type:"button",className:"session-desktop-preview",onClick:s.onExpand,"aria-label":"全屏查看桌面",children:[vr?h.jsx("img",{src:Ue,alt:"实时桌面预览",draggable:!1}):h.jsx("span",{className:"session-desktop-preview-empty",children:Tt||I||(f==null?void 0:f.capabilityError)||(be?"正在连接桌面":_r)}),vr&&Tt&&h.jsx("span",{className:"session-desktop-lock-notice",children:Tt}),h.jsxs("span",{className:"session-desktop-preview-expand",children:[h.jsx(si,{size:14,"aria-hidden":"true"}),"全屏"]})]});const Qr=h.jsxs("div",{ref:M,className:`browser-live-backdrop${r?" browser-live-backdrop--embedded":""}${p?" browser-live-backdrop--session":""}`,style:{visibility:e?void 0:"hidden",pointerEvents:e?void 0:"none"},"aria-hidden":!e,"data-tab-swipe-ignore":!0,role:"presentation",onMouseDown:i=>{!r&&i.target===i.currentTarget&&u()},children:[h.jsxs("section",{ref:L,className:`browser-live-panel ${P?"is-fullscreen":""}${p?" browser-live-panel--session":""}`,role:r?"region":"dialog","aria-modal":r?void 0:!0,"aria-label":p?"会话桌面":"浏览器直播",children:[h.jsxs("header",{className:"browser-live-header",children:[h.jsxs("div",{className:"browser-live-heading",children:[h.jsx(ni,{size:17,"aria-hidden":"true"}),h.jsxs("div",{children:[h.jsx("strong",{children:p?"桌面":"浏览器直播"}),h.jsx("span",{children:s?`${s.status} · 只读`:f?Cr(f.backend):"实时观看与接管"})]}),!p&&m]}),h.jsxs("div",{className:"browser-live-header-actions",children:[!p&&h.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>void ee(),title:P?"退出全屏":"全屏","aria-label":P?"退出全屏":"全屏","aria-pressed":P,children:P?h.jsx(er,{size:17}):h.jsx(si,{size:17})}),h.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>void _t(),title:"刷新画面与会话","aria-label":"刷新直播画面与会话",children:h.jsx(Wi,{size:15,className:be?"spin":void 0,"aria-hidden":"true"})}),h.jsx("button",{type:"button",className:"ui-icon-button",onClick:u,title:p?"退出全屏":"关闭","aria-label":p?"退出全屏":"关闭浏览器直播",children:p?h.jsx(er,{size:17,"aria-hidden":"true"}):h.jsx($i,{size:17,"aria-hidden":"true"})})]})]}),h.jsxs("div",{className:`browser-live-surface ${T?"is-controlling":""} has-zoom ${T&&!W&&wt?"has-quickkeys":""}`,children:[Tt&&h.jsx("span",{className:"session-desktop-lock-notice",role:"status",children:Tt}),h.jsxs("div",{className:"browser-live-zoom",role:"group","aria-label":"桌面画面缩放",children:[P&&!p&&h.jsxs("button",{type:"button","aria-label":"退出全屏",title:"退出全屏",onClick:()=>void ee(),children:[h.jsx(er,{size:15,"aria-hidden":"true"}),"退出全屏"]}),F.length>1&&h.jsx("div",{className:"browser-live-session-tabs",role:"tablist","aria-label":"切换直播屏幕",children:F.map(i=>h.jsx("button",{type:"button",role:"tab","aria-selected":i.id===g,className:i.id===g?"is-active":"",title:`${Cr(i.backend)} · ${i.title||"浏览器"}`,onClick:()=>K(i.id),children:i.title||Cr(i.backend)},i.id))}),!p&&V&&pe&&pe.length>1&&h.jsx(ui,{label:"选择直播屏幕",title:et?"选择直播屏幕":"其他设备控制中或画面暂不可用",value:(pe.find(i=>i.selected)??pe[0]).id,busy:!!B,disabled:!v||!et||A||pe.length<2,onChange:Ni,children:pe.map((i,c)=>h.jsx("option",{value:i.id,children:`第 ${c+1} 屏${i.primary?"(主屏)":""}`},i.id))}),!p&&V&&h.jsxs(ui,{label:"视频画质",title:et?"视频画质":"其他设备控制中或画面暂不可用",value:Q,busy:A!==null,disabled:!et||!!B,compact:!0,onChange:Ii,children:[h.jsx("option",{value:"smooth",children:"流畅"}),h.jsx("option",{value:"hd",children:"高清"}),h.jsx("option",{value:"original",children:"原画"})]}),V&&T&&ut&&Oe!=="live"&&h.jsxs("button",{type:"button","aria-label":"开始语音",title:"开始双向语音",disabled:Oe==="starting",onClick:()=>void Ei(),children:[Oe==="starting"?h.jsx(Ae,{size:15,className:"spin","aria-hidden":"true"}):h.jsx(ai,{size:15,"aria-hidden":"true"}),Oe==="starting"?"正在连接":"开始语音"]}),V&&T&&ut&&Oe==="live"&&h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":Wt?"取消麦克风静音":"麦克风静音","aria-pressed":Wt,title:Wt?"打开麦克风":"关闭麦克风",onClick:()=>{var c;const i=!Ht.current;Ht.current=i;for(const o of((c=Rt.current)==null?void 0:c.getAudioTracks())??[])o.enabled=!i;Lr(i)},children:Wt?h.jsx(Xi,{size:15,"aria-hidden":"true"}):h.jsx(ai,{size:15,"aria-hidden":"true"})}),h.jsx("button",{type:"button","aria-label":$t?"取消扬声器静音":"扬声器静音","aria-pressed":$t,title:$t?"打开电脑声音":"关闭电脑声音",onClick:()=>{const i=!Kt.current;Kt.current=i,at.current&&(at.current.gain.value=i?0:1),zr(i),i&&(ct.current=0)},children:$t?h.jsx(_i,{size:15,"aria-hidden":"true"}):h.jsx(Zi,{size:15,"aria-hidden":"true"})}),h.jsx("button",{type:"button","aria-label":"结束语音",title:"结束双向语音",onClick:()=>Pe(!0),children:h.jsx(Yi,{size:15,"aria-hidden":"true"})})]}),h.jsx("button",{type:"button","aria-label":"缩小桌面画面",title:"缩小",disabled:!v||De<=.5,onClick:()=>mt(i=>Math.max(.5,i-.25)),children:h.jsx(Oi,{size:16})}),h.jsxs("output",{"aria-label":"桌面缩放比例",children:[Math.round(De*100),"%"]}),h.jsx("button",{type:"button","aria-label":"放大桌面画面",title:"放大",disabled:!v||De>=5,onClick:()=>mt(i=>Math.min(5,i+.25)),children:h.jsx(Ui,{size:16})}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>{var i;mt(1),vt(!1),(i=de.current)==null||i.scrollTo(0,0)},children:"适应窗口"}),h.jsxs("button",{type:"button","aria-label":"移动桌面画面","aria-pressed":W,title:"拖动或滚动画面,不发送远程输入",disabled:!v,onClick:()=>vt(i=>!i),children:[h.jsx(Hi,{size:15}),"移动画面"]}),!p&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:`browser-live-keyboard ${Te?"is-typing":""}`,children:[h.jsxs("button",{type:"button","aria-label":"唤起键盘","aria-pressed":Te,title:"唤起/收起键盘(无法识别输入框时可手动唤起)",className:xi&&!Te?"is-hint":void 0,disabled:!v||!T,onPointerDown:i=>i.preventDefault(),onClick:()=>{bt(!1),ji()},children:[h.jsx(gr,{size:15}),"键盘"]}),h.jsx("input",{ref:Ye,className:"browser-live-mobile-input","aria-label":"浏览器键盘输入",tabIndex:-1,disabled:!v||!T,defaultValue:"",inputMode:"text",autoCapitalize:"none",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onFocus:()=>{vt(!1),st.current=!0,zt(!0),bt(!1)},onKeyDown:Xr,onKeyUp:Yr,onCompositionStart:()=>{Gt.current=!0},onCompositionEnd:i=>{Gt.current=!1,W||Kr(i.target.value)},onBlur:i=>{st.current=!1,Gt.current=!1,Jt.current="",i.target.value="",zt(!1)},onChange:i=>{!W&&!Gt.current&&Kr(i.target.value)}})]}),h.jsxs("button",{type:"button","aria-label":"快捷键条","aria-pressed":wt,title:"展开/收起快捷键(Esc/Tab/复制/粘贴/方向键)",disabled:!v||!T,onClick:()=>Ci(i=>!i),children:[h.jsx(gr,{size:15}),wt?"收起":"快捷键"]}),h.jsxs("button",{type:"button","aria-label":"窗口控制",title:"全屏看不到左上角按钮时用:第 1 次点=退出全屏(ESC + Ctrl+Cmd+F),第 2 次点=关闭窗口(Cmd+W)",disabled:!v||!T,onClick:()=>{const i=Date.now();if(i-mr.current<2500){xe("w","KeyW",["Meta"]),mr.current=0;return}mr.current=i,xe("Escape","Escape"),window.setTimeout(()=>{xe("f","KeyF",["Control","Meta"])},150)},children:[h.jsx(gr,{size:15}),"窗口"]})]}),!p&&Vr&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button","aria-label":"锁屏",title:"锁屏(锁屏后仍可从空态区唤醒或远程解锁)",disabled:!v||!!ze,onClick:()=>void fr("lock"),children:[ze==="lock"?h.jsx(Ae,{size:15,className:"spin"}):h.jsx(Ki,{size:15}),"锁屏"]}),h.jsxs("button",{type:"button","aria-label":"唤醒屏幕",title:"唤醒显示器或锁屏界面",disabled:!!ze,onClick:()=>void fr("wake"),children:[ze==="wake"?h.jsx(Ae,{size:15,className:"spin"}):h.jsx(li,{size:15}),"唤醒"]})]})]}),T&&!W&&wt&&h.jsxs("div",{className:"browser-live-quickkeys",role:"group","aria-label":"快捷键",children:[h.jsx("button",{type:"button",disabled:!v,onClick:()=>xe("Escape","Escape"),children:"Esc"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>xe("Tab","Tab"),children:"Tab"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>St("c"),children:"复制"}),h.jsx(Gi,{disabled:!v||!!B||!!A,onPaste:Ti,onError:q},g),h.jsx("button",{type:"button",disabled:!v,onClick:()=>St("a"),children:"全选"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>St("z"),children:"撤销"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>St("s"),children:"保存"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>St("f"),children:"查找"}),h.jsx("button",{type:"button",disabled:!v,title:"退出当前前台应用(Cmd+Q)",onClick:()=>xe("q","KeyQ",["Meta"]),children:"⌘Q"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>xe("ArrowLeft","ArrowLeft"),children:"←"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>xe("ArrowUp","ArrowUp"),children:"↑"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>xe("ArrowDown","ArrowDown"),children:"↓"}),h.jsx("button",{type:"button",disabled:!v,onClick:()=>xe("ArrowRight","ArrowRight"),children:"→"})]}),!(T&&!W&&wt)&&h.jsx("div",{className:"browser-live-touch-hint",children:p?"拖动画面 · 双指缩放":ur?"画面当前为只读 · 点击画面开始控制":"滑动滚动 · 轻点点击 · 双击打开 · 长按拖动 · 按住1秒右键 · 双指缩放"}),h.jsxs("div",{ref:de,className:"browser-live-viewport",onMouseDown:i=>{st.current&&i.preventDefault()},children:[vr?h.jsxs("div",{className:"browser-live-image-hit-area",style:hr&&ht?{width:ht.width*hr*De,height:ht.height*hr*De,cursor:W?"grab":void 0}:void 0,tabIndex:T&&!W?0:-1,onContextMenu:i=>i.preventDefault(),onPointerDown:i=>{if(i.pointerType==="touch"){i.preventDefault(),Xe.current.down(i.pointerId,{x:i.clientX,y:i.clientY},i.isPrimary),Ke.current=T&&!W?We(i):null;const o=Ke.current;o&&V&&(f==null?void 0:f.platform)==="darwin"&&Mt({kind:"pointer",action:"move",...o,probe:!0}).then(y=>{Ke.current===o&&dr(y)}),i.currentTarget.setPointerCapture(i.pointerId),oe.current&&window.clearTimeout(oe.current),Ie.current="none",gt.current=T&&!W?{x:i.clientX,y:i.clientY}:null,Vt.current=i.timeStamp,gt.current&&(oe.current=window.setTimeout(()=>{Ie.current="armed"},550));return}if(W&&de.current){const o=de.current;nt.current={x:i.clientX,y:i.clientY,left:o.scrollLeft,top:o.scrollTop},i.currentTarget.setPointerCapture(i.pointerId);return}if(!T)return;const c=We(i);c&&(Dt.current=!0,i.currentTarget.setPointerCapture(i.pointerId),G({kind:"pointer",action:"down",...c,button:"left"}))},onPointerMove:i=>{if(i.pointerType==="touch"){i.preventDefault();const o=Xe.current.move(i.pointerId,{x:i.clientX,y:i.clientY}),y=de.current;if(!o||!y)return;const x=o.pointers===2&&Math.abs(o.distanceRatio-1)>.05,w=Math.max(.5,Math.min(5,yt.current*o.scale));if(x&&w!==yt.current){const E=i.currentTarget.getBoundingClientRect();Lt.current={x:(o.from.x-E.left)/E.width,y:(o.from.y-E.top)/E.height,clientX:o.to.x,clientY:o.to.y},yt.current=w,br.flushSync(()=>mt(w));return}if(oe.current&&(window.clearTimeout(oe.current),oe.current=null),Ie.current==="armed"&&gt.current&&Ke.current&&(Ie.current="drag",G({kind:"pointer",action:"down",...Ke.current,button:"left"})),Ie.current==="drag"){const E=We(i);E&&G({kind:"pointer",action:"move",...E,button:"left"});return}const S=yt.current<=1.001;if(T&&!W&&(o.pointers>=2||S)){const E=Gn(o.from,o.to);if(E){const D=Ke.current??We(i);D&&G({kind:"pointer",action:"wheel",...D,...E})}return}y.scrollLeft+=o.from.x-o.to.x,y.scrollTop+=o.from.y-o.to.y;return}if(W&&nt.current&&de.current){const o=nt.current;de.current.scrollTo(o.left+o.x-i.clientX,o.top+o.y-i.clientY);return}if(!T)return;if(!Dt.current){const o=We(i);o&&G({kind:"pointer",action:"move",...o,button:"left"});return}const c=We(i);c&&G({kind:"pointer",action:"move",...c,button:"left"})},onPointerUp:i=>{if(i.pointerType==="touch"){i.preventDefault(),oe.current&&(window.clearTimeout(oe.current),oe.current=null);const o=We(i);Ke.current=null;const y=Xe.current.up(i.pointerId,{x:i.clientX,y:i.clientY});if(Ie.current==="armed"){Ie.current="none";const x=i.timeStamp-Vt.current;if(y&&x>=800&&o&&T&&!W){Xe.current.reset(),G({kind:"pointer",action:"down",...o,button:"right"}),G({kind:"pointer",action:"up",...o,button:"right"});return}}if(Ie.current==="drag"){Ie.current="none",Xe.current.reset(),o&&T&&G({kind:"pointer",action:"up",...o,button:"left"});return}if(y&&o&&T&&!W){const x=(v==null?void 0:v.viewport)??(f==null?void 0:f.viewport);if(_n(Ze.current,x,o.x,o.y)){const E=Ye.current;E&&document.activeElement!==E&&E.focus({preventScroll:!0}),bt(!1)}const w=sr.current;w!==null&&Date.now()-w.at<400&&x!==void 0&&Math.hypot((o.x-w.x)*x.width,(o.y-w.y)*x.height)<x.width*.03?(G({kind:"pointer",action:"down",...o,button:"left",click:2}),pr(o,2,!0),sr.current=null):(G({kind:"pointer",action:"down",...o,button:"left"}),pr(o,void 0,!0),sr.current={at:Date.now(),x:o.x,y:o.y})}return}if(W){nt.current=null;return}if(!T)return;const c=We(i);Dt.current=!1,c&&pr(c)},onPointerCancel:i=>{Xe.current.up(i.pointerId,{x:i.clientX,y:i.clientY},!0),nt.current=null,Dt.current=!1,Ke.current=null,oe.current&&(window.clearTimeout(oe.current),oe.current=null),Ie.current="none",gt.current=null,Vt.current=0},onLostPointerCapture:i=>{Xe.current.up(i.pointerId,{x:i.clientX,y:i.clientY},!0),oe.current&&(window.clearTimeout(oe.current),oe.current=null),Ie.current="none",gt.current=null,Vt.current=0},onWheel:i=>{if(!T||W)return;const c=We(i);c&&G({kind:"pointer",action:"wheel",...c,deltaX:i.deltaX,deltaY:i.deltaY})},onKeyDown:Xr,onKeyUp:Yr,children:[h.jsx("img",{src:Ue,alt:(f==null?void 0:f.title)||"浏览器实时画面",draggable:!1,decoding:"async"}),h.jsx("video",{ref:Be,className:`browser-live-video ${Ve==="live"?"is-live":""}`,"aria-label":V?"桌面实时视频流":"浏览器实时视频流",autoPlay:!0,playsInline:!0,muted:!0}),h.jsx("canvas",{ref:Ar,className:"browser-live-compound","aria-hidden":"true",style:{display:Ve==="live"?"block":"none",visibility:"hidden"}}),h.jsx("canvas",{ref:qr,className:"browser-live-compound browser-live-cursor","aria-hidden":"true",style:{display:Ve==="live"?"block":"none",visibility:"hidden"}}),A&&h.jsxs("div",{className:"browser-live-quality-pending",role:"status",children:[h.jsx(Ae,{size:13,className:"spin","aria-hidden":"true"}),"正在切换至",Wn[A]??A,"画质…"]})]}):h.jsxs("div",{className:"browser-live-empty",children:[be||(f==null?void 0:f.availability)==="starting"?h.jsx(Ae,{size:22,className:"spin","aria-hidden":"true"}):h.jsx(ni,{size:24,"aria-hidden":"true"}),h.jsx("strong",{children:be?p?"正在连接桌面":"正在连接浏览器":_r}),h.jsx("span",{children:Ai}),!p&&Ri&&h.jsxs("div",{role:"group","aria-label":"锁屏远程操作",style:{display:"flex",gap:8,marginTop:12},children:[h.jsxs("button",{type:"button",className:"browser-live-control-button",disabled:!!ze,onClick:()=>void fr("wake"),children:[ze==="wake"?h.jsx(Ae,{size:14,className:"spin","aria-hidden":"true"}):h.jsx(li,{size:14,"aria-hidden":"true"}),"唤醒屏幕"]}),Vr&&h.jsxs("button",{type:"button",className:"browser-live-control-button",disabled:we,onClick:()=>{rt(null),Me(!0)},children:[h.jsx(oi,{size:14,"aria-hidden":"true"}),"远程解锁"]})]})]}),ur&&h.jsx("button",{type:"button",className:"browser-live-takeover-prompt","aria-label":Et?"正在开始控制远程桌面":"点击画面开始控制远程桌面",disabled:Et||!Zr||(f==null?void 0:f.state)!=="agent-controlled",onClick:()=>void Hr(),children:h.jsxs("span",{className:"browser-live-takeover-card","aria-live":"polite",children:[h.jsx("span",{className:"browser-live-takeover-icon","aria-hidden":"true",children:Et?h.jsx(Ae,{size:20,className:"spin"}):h.jsx(ci,{size:20})}),h.jsxs("span",{children:[h.jsx("strong",{children:Et?"正在开始控制":"点击画面开始控制"}),h.jsx("small",{children:Et?"正在把鼠标和键盘切换到你的设备":`当前画面只读,点击不会发送到${V?" Mac":"浏览器"}`})]})]})})]}),P&&!p&&h.jsxs("button",{type:"button",className:"browser-live-exit-fullscreen",onClick:()=>void ee(),children:[h.jsx(er,{size:14,"aria-hidden":"true"}),"退出全屏"]}),T&&!W&&h.jsxs("div",{className:"browser-live-control-cue",children:[h.jsx(ci,{size:13,"aria-hidden":"true"}),h.jsxs("span",{children:[V?"当前输入会发送到本机":"当前输入会发送到浏览器",V&&Jr?` · ${Jr}`:"",V&&Gr?` · ${Gr}`:"",Ir!=null?` · 控制 ${Ir}ms`:""]})]})]}),!P&&h.jsxs("footer",{className:"browser-live-footer",children:[h.jsxs("div",{className:"browser-live-location",children:[h.jsx("span",{className:`browser-live-status-dot is-${(f==null?void 0:f.state)??"idle"}`,"aria-hidden":"true"}),h.jsxs("div",{children:[h.jsx("strong",{children:Pi}),h.jsx("span",{title:f==null?void 0:f.url,children:(f==null?void 0:f.capabilityError)||(V?ur?"点击画面开始控制后,单击和拖拽才会发送到本机":"本机屏幕":f==null?void 0:f.url)||I||"等待可观看的直播会话"})]}),(f==null?void 0:f.url)&&!V&&h.jsx(Bi,{size:13,"aria-hidden":"true"})]}),f&&(T?h.jsxs("button",{type:"button",className:"browser-live-control-button is-return",onClick:()=>void Mi(),disabled:ge,children:[ge&&h.jsx(Ae,{size:14,className:"spin","aria-hidden":"true"}),V?"结束控制":"归还给 Agent"]}):h.jsxs("button",{type:"button",className:"browser-live-control-button",onClick:()=>void Hr(),disabled:!Zr||ge||f.state!=="agent-controlled"||f.availability!=="ready",children:[ge&&h.jsx(Ae,{size:14,className:"spin","aria-hidden":"true"}),f.controlledByAnotherViewer?"其他设备操作中":V?"开始控制":"接管浏览器"]}))]}),(I??Dr)&&h.jsx("div",{className:"browser-live-error",role:"alert",children:I??Dr})]}),Fe&&h.jsx("div",{className:"browser-live-unlock-backdrop",role:"presentation",onMouseDown:i=>{i.target===i.currentTarget&&!we&&(Me(!1),Se(""),rt(null))},children:h.jsxs("form",{className:"browser-live-unlock-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"browser-live-unlock-title",onSubmit:i=>{i.preventDefault(),Si()},children:[h.jsxs("div",{className:"browser-live-unlock-heading",children:[h.jsx(oi,{size:18,"aria-hidden":"true"}),h.jsx("strong",{id:"browser-live-unlock-title",children:"远程解锁 Windows"})]}),h.jsx("label",{htmlFor:"browser-live-unlock-password",children:"Windows 密码或 PIN"}),h.jsx("input",{id:"browser-live-unlock-password",type:"password",autoComplete:"off",autoFocus:!0,maxLength:256,value:qe,disabled:we,onChange:i=>Se(i.target.value)}),qt&&h.jsx("p",{role:"alert",children:qt}),h.jsxs("div",{className:"browser-live-unlock-actions",children:[h.jsx("button",{type:"button",className:"browser-live-control-button is-return",disabled:we,onClick:()=>{Me(!1),Se(""),rt(null)},children:"取消"}),h.jsxs("button",{type:"submit",className:"browser-live-control-button",disabled:we||!qe,children:[we&&h.jsx(Ae,{size:14,className:"spin","aria-hidden":"true"}),"解锁"]})]})]})})]});return r?Qr:br.createPortal(Qr,document.body)}export{Kn as decodePcm16Base64,os as default,Hn as encodePcm16Base64,Yn as isStaleControlReply,Xn as prepareVoiceAudio,_n as remoteFieldContains,yi as remoteShortcutModifier,vi as selectBrowserLiveSessionId,$n as shouldOfferVisualTakeover,Gn as touchScrollDelta};
@@ -1 +0,0 @@
1
- import{j as e}from"./index-DSgLFE4Q.js";import{F as d}from"./FilePreview-CPY6dP8Q.js";import m from"./FileTree-BBgrOian.js";import{X as f}from"./x-BYUglEo9.js";import"./artifact-links-B0ApmgK6.js";import"./rotate-ccw-BbSby0GQ.js";import"./loader-circle-C5C-IzGK.js";import"./trash-2-DjggJGbw.js";import"./check-8EVJMrTV.js";import"./download-BE31-Qm0.js";import"./file-types-ZVLWtslN.js";import"./locate-fixed-CHkezEEh.js";import"./chevron-down-ChNxfI2x.js";import"./chevron-right-Cbkc_d70.js";function z({open:a,tab:s,gateway:r,cwd:l,selectedPath:i,revealRequest:p,onTabChange:o,onSelectPath:t,onClose:n}){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:n,"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:p}):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{z as default};
@@ -1,5 +0,0 @@
1
- import{r as a,e as p,j as e}from"./index-DSgLFE4Q.js";import{F as w}from"./page-_fFyRId-.js";import{R as y}from"./rotate-cw-BMdX-ln4.js";import"./RunningSessionsIcon-BvFSI9OF.js";import"./x-BYUglEo9.js";import"./chevron-down-ChNxfI2x.js";import"./check-8EVJMrTV.js";import"./trash-2-DjggJGbw.js";import"./RemoteDesktopTabBridge-BA_HQv3V.js";import"./chevron-right-Cbkc_d70.js";import"./calendar-days-CLwKstxM.js";import"./artifact-links-B0ApmgK6.js";import"./mobileViewport-CekmYKqS.js";import"./pin-BsEEYq8M.js";import"./CollaborationTabBridge-Dxq4G1Uk.js";import"./SessionDashboardBridge-CjoeUy-v.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 A({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{A as default,h as resolveFlowStudioFrameUrl};
@@ -1 +0,0 @@
1
- import{r,u as f,j as a}from"./index-DSgLFE4Q.js";import{c as g,r as h,u as j,S as v,T as x,C as k}from"./new-session-window-Dgl7UWPR.js";import{X as y}from"./x-BYUglEo9.js";import"./artifact-links-B0ApmgK6.js";import"./composer-file-routing-qSvJpT-v.js";import"./loader-circle-C5C-IzGK.js";import"./RemoteDesktopTabBridge-BA_HQv3V.js";import"./check-8EVJMrTV.js";import"./RunningSessionsIcon-BvFSI9OF.js";import"./trash-2-DjggJGbw.js";import"./download-BE31-Qm0.js";import"./file-types-ZVLWtslN.js";import"./list-todo-Bik5IY2r.js";import"./chevron-right-Cbkc_d70.js";import"./chevron-down-ChNxfI2x.js";import"./session-tree-BK_qaCnb.js";import"./zoom-out-iMMWRXJs.js";import"./rotate-ccw-BbSby0GQ.js";import"./use-session-activity-BbTXGW7Z.js";import"./client-I0ZVCjOI.js";import"./HostProjectPicker-DN_vGqQb.js";function J(){const[m]=r.useState(()=>g()),[i,u]=r.useState(()=>{const t=h(window.location.search);return{agentType:(t==null?void 0:t.agentType)??"customer-agent",projectId:null,cwd:(t==null?void 0:t.workspacePath)??""}}),[e,n]=r.useState(null),[p,w]=r.useState([]),[s,c]=r.useState(""),l=f(t=>t.skin);r.useEffect(()=>{document.documentElement.setAttribute("data-skin",l)},[l]),r.useEffect(()=>{document.title=e!=null&&e.title?`${e.title} · AgentRoam`:"新建会话 · AgentRoam"},[e==null?void 0:e.title]),r.useEffect(()=>{let t=!0;return j.getState().loadFromSystem(),window.agentApi.getRuntimeHealth().then(o=>{t&&w(o)}).catch(()=>{}),()=>{t=!1}},[]);const d=async(t,o)=>{if(o){n(o);return}try{const S=await window.agentApi.getSession(t,{limit:1,view:"core"});n(S),c("")}catch{c("无法打开会话,请重试")}};return a.jsxs("main",{className:"new-session-window","aria-label":"会话小窗",children:[a.jsx(v,{viewedSessionId:(e==null?void 0:e.id)??null}),s&&a.jsx("div",{className:"new-session-window-error",role:"alert",children:s}),a.jsx(x,{draft:e?void 0:i,onDraftChange:u,children:a.jsx(k,{agentStore:m,desktopTaskPane:!0,activeAgentType:(e==null?void 0:e.agentType)??i.agentType,selectedProjectId:(e==null?void 0:e.projectId)??i.projectId,selectedSessionId:(e==null?void 0:e.id)??null,sessionSummary:e??void 0,sessionTitle:(e==null?void 0:e.title)??"新建会话",paneControls:a.jsx("button",{type:"button",className:"ui-icon-button new-session-window-close","aria-label":"关闭会话小窗",title:"关闭会话小窗",onClick:()=>window.close(),children:a.jsx(y,{size:17,"aria-hidden":"true"})}),workspacePath:(e==null?void 0:e.cwd)??i.cwd,runtimeHealth:p,focusComposerNonce:1,sessionCreationPending:!e&&!i.projectId,onSessionCreated:(t,o)=>d(t,o),onSelectSession:(t,o)=>{d(t,o)},onParallelSessionSelected:t=>{n(t)}})})]})}export{J as default};
@@ -1 +0,0 @@
1
- import{r as t,u as r,j as u}from"./index-DSgLFE4Q.js";import l from"./BrowserLivePanel-CamAULwS.js";import{R as f,a as d,b as w,r as g}from"./RemoteDesktopTabBridge-BA_HQv3V.js";import"./loader-circle-C5C-IzGK.js";import"./chevron-down-ChNxfI2x.js";import"./zoom-out-iMMWRXJs.js";import"./rotate-ccw-BbSby0GQ.js";import"./x-BYUglEo9.js";function v(){const[s,n]=t.useState(!1),[c,i]=t.useState(!1),[a,m]=t.useState(r.getState().skin);t.useEffect(()=>r.subscribe(e=>m(e.skin)),[]),t.useEffect(()=>{document.documentElement.dataset.skin=a,document.body.dataset.remoteDesktop="1"},[a]),t.useEffect(()=>{const e=E=>{const o=g(E,location.origin,window.parent);o!==null&&(n(o),o&&i(!0))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]),t.useEffect(()=>{if(!s)return;const e=requestAnimationFrame(()=>{window.parent.postMessage({type:f},location.origin)});return()=>cancelAnimationFrame(e)},[s]);const p=t.useCallback(e=>{window.parent.postMessage({type:d,fullscreen:e},location.origin)},[]);return u.jsx(l,{onFullscreenChange:p,open:c,active:s,onClose:()=>{i(!1),n(!1),window.parent.postMessage({type:w},location.origin)}})}export{v as default};
@@ -1 +0,0 @@
1
- import o from"./CalendarPage-BbYdGYWn.js";import"./index-DSgLFE4Q.js";import"./CalendarView-QfbrlL9X.js";import"./calendar-days-CLwKstxM.js";import"./x-BYUglEo9.js";import"./chevron-right-Cbkc_d70.js";import"./locate-fixed-CHkezEEh.js";import"./list-todo-Bik5IY2r.js";import"./chevron-down-ChNxfI2x.js";import"./check-8EVJMrTV.js";import"./pause-BsmUCuwZ.js";export{o as default};
@@ -1,2 +0,0 @@
1
- const p="agent-webapp:artifact-open:v1";function u(e){if(/[\0\r\n]/.test(e))return!1;try{const t=new URL(e);return(t.protocol==="http:"||t.protocol==="https:")&&/\.(mp4|webm|mov|m4v|mp3|wav|m4a|aac|ogg|flac|png|jpe?g|gif|webp|pdf)$/i.test(t.pathname)}catch{return!1}}function o(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(e)}function c(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==p||!Number.isSafeInteger(t.requestId)||Number(t.requestId)<1||typeof t.path!="string"||!(o(t.path)||t.path.startsWith("~/")||u(t.path))||t.path.includes("\0")||t.path.includes(`
2
- `)||t.path.includes("\r")||t.revealOnly!==void 0&&(t.revealOnly!==!0||u(t.path))?null:t}function h(e,t,i){return e.origin!==t||e.source!==i?null:c(e.data)}let l=0;function f(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(e)}function d(e,t,i){const r=e.trim();if(!r||/[\0\r\n]/.test(r))return null;if(u(r))return r;if(r.startsWith("~/")){const n=r.slice(2);return!n||n.split(/[\\/]/).includes("..")?null:i?d(n,i):r}if(f(r))return r;if(!t||!f(t))return null;const s=r.replaceAll("\\","/").split("/").filter(n=>n&&n!==".");if(s.length===0||s.some(n=>n===".."))return null;const a=/^[A-Za-z]:[\\/]/.test(t)||t.startsWith("\\\\")?"\\":"/";return`${t.replace(/[\\/]+$/,"")}${a}${s.join(a)}`}function b(e,t=window,i){return t.parent===t?!1:(l+=1,t.parent.postMessage({type:p,requestId:l,path:e,...i?{revealOnly:i}:{}},t.location.origin),!0)}export{h as a,u as i,b as p,d as r};
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-CRRXKysA.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-TICWLB2K-Dh2bZgM1.js";import{_ as i}from"./mermaid.core-CRRXKysA.js";import"./chunk-5VM5RSS4-NxozE5UP.js";import"./chunk-XXDRQBXY-CnqciVDz.js";import"./chunk-POPQ4Y6H-B2HIaynf.js";import"./chunk-F27PBJKO-Dyb8E7YM.js";import"./index-DSgLFE4Q.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-TICWLB2K-Dh2bZgM1.js";import{_ as i}from"./mermaid.core-CRRXKysA.js";import"./chunk-5VM5RSS4-NxozE5UP.js";import"./chunk-XXDRQBXY-CnqciVDz.js";import"./chunk-POPQ4Y6H-B2HIaynf.js";import"./chunk-F27PBJKO-Dyb8E7YM.js";import"./index-DSgLFE4Q.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
@@ -1,6 +0,0 @@
1
- import{c as j,l as C,r as g,a as N,j as d}from"./index-DSgLFE4Q.js";import{i as _}from"./artifact-links-B0ApmgK6.js";import{L as P}from"./loader-circle-C5C-IzGK.js";import{X as R}from"./x-BYUglEo9.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 q=j("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),z=/!?\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|[ \t]*(?:~\/|\/|[A-Za-z]:[\\/])[^)\n]+|[^():\n]+\.(?:png|jpe?g|gif|webp|bmp|ico|svg|mp4|webm|mov|m4v))\)/gi,M=/`([^`\n]+)`/g;function G(t){let l=!1;return t.split(/(^[ \t]*```[^\n]*(?:\n|$))/m).map(s=>/^[ \t]*```/.test(s)?(l=!l,s):l?s:s.replace(/(!?\[[^\]\n]+\])\(<\s*((?:https?:\/\/|~\/|\/|[A-Za-z]:[\\/])[^<>\r\n]+?)\s*>\)/g,"$1($2)")).join("")}const O=/https?:\/\/[^\s`<>"'()[\],。;!?]+|(?:~\/|\/|[A-Za-z]:[\\/])[^\s`<>"'()[\],。;!?]*\.[A-Za-z0-9]{1,10}(?::[1-9]\d*)?/gi,S=/:codex-file-citation\{([^}\n]*)\}/g,L=/([A-Za-z][\w-]*)="([^"\n]*)"/g,D=/\uE200visualize\uE202([^\uE201\n]+)\uE201/g;function x(t,l=!1){const s=l&&!/^[A-Za-z][\w+.-]*:/.test(t)&&/\.(png|jpe?g|gif|webp|bmp|ico|svg|mp4|webm|mov|m4v)$/i.test(t);if(!(t.startsWith("/")||t.startsWith("~/")||/^[A-Za-z]:[\\/]/.test(t)||s)||t.includes("?")||t.includes("#")||/[\0\r\n]/.test(t))return null;const i=t.match(/^(.*):([1-9]\d*)$/);return i?{path:i[1],line:Number(i[2])}:{path:t}}function U(t){const l={};for(const p of t.matchAll(L)){const r=p[1];if(r!=="path"&&r!=="purpose"&&r!=="artifact_kind"||l[r]!==void 0)return null;l[r]=p[2]}if(t.replace(L,"").trim())return null;const s=x(l.path??"");if(!s||s.line!==void 0)return null;const i=s.path.slice(s.path.lastIndexOf("/")+1)||s.path;return{path:s.path,label:i}}function F(t){try{const l=JSON.parse(t);if(!l||typeof l!="object"||Array.isArray(l))return null;const{path:s,title:i,mode:p}=l;if(typeof s!="string"||i!==void 0&&typeof i!="string"||p!==void 0&&typeof p!="string")return null;const r=x(s);if(!r||r.line!==void 0)return null;const n=(i==null?void 0:i.trim())||r.path.slice(r.path.lastIndexOf("/")+1)||r.path;return{path:r.path,label:n}}catch{return null}}function K(t,l){const s=[];let i=0;const p=[...[...t.matchAll(z)].map(r=>({kind:"markdown",match:r})),...[...t.matchAll(S)].map(r=>({kind:"citation",match:r})),...[...t.matchAll(D)].map(r=>({kind:"visualize",match:r})),...[...t.matchAll(M)].map(r=>({kind:"code",match:r})),...[...t.matchAll(O)].filter(r=>/^https?:\/\//i.test(r[0])||!/[\w:/\\]/.test(t[(r.index??0)-1]??"")).map(r=>({kind:"bare",match:r}))].sort((r,n)=>(r.match.index??0)-(n.match.index??0));for(const r of p){const{match:n}=r,o=n.index??0;if(o<i)continue;if(o>i&&s.push({type:"text",value:t.slice(i,o)}),r.kind==="code"){const a=n[1],u=/\.[A-Za-z0-9]{1,10}(?::[1-9]\d*)?$/.test(a)?x(a):null;s.push(u||_(a)?{type:"artifact",label:a,path:(u==null?void 0:u.path)??a,...u!=null&&u.line?{line:u.line}:{},raw:n[0]}:{type:"code",value:a}),i=o+n[0].length;continue}if(r.kind==="bare"){const a=n[0],u=x(a);s.push(u||_(a)?{type:"artifact",label:a,path:(u==null?void 0:u.path)??a,...u!=null&&u.line?{line:u.line}:{},raw:a}:/^https?:\/\//i.test(a)?{type:"link",label:a,href:a}:{type:"text",value:a}),i=o+a.length;continue}if(r.kind==="citation"){const a=U(n[1]);s.push(a?{type:"artifact",label:a.label,path:a.path,raw:n[0]}:{type:"text",value:n[0]}),i=o+n[0].length;continue}if(r.kind==="visualize"){const a=F(n[1]);s.push(a?{type:"artifact",label:a.label,path:a.path,raw:n[0]}:{type:"text",value:n[0]}),i=o+n[0].length;continue}const c=n[2];if(_(c))s.push({type:"artifact",label:n[1],path:c,raw:n[0]});else if(/^https?:\/\//i.test(c))s.push({type:"link",label:n[1],href:c});else{const a=x(c.trim(),!0);a?s.push({type:"artifact",label:n[1],path:a.path,...a.line?{line:a.line}:{},raw:n[0]}):s.push({type:"text",value:n[0]})}i=o+n[0].length}return i<t.length&&s.push({type:"text",value:t.slice(i)}),s.length>0?s:[{type:"text",value:t}]}function J(t){return K(t)}const W="agentroam:task-pane-web-link";function H(t){var s;if(typeof window>"u"||typeof window.dispatchEvent!="function"||!C()&&typeof((s=window.agentApi)==null?void 0:s.taskPageOpen)!="function")return!1;let l;try{l=new URL(t)}catch{return!1}return l.protocol!=="http:"&&l.protocol!=="https:"?!1:!window.dispatchEvent(new CustomEvent(W,{cancelable:!0,detail:{url:l.toString()}}))}function Q(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const E=()=>({scale:1,x:0,y:0});function w(t,l,s={x:0,y:0}){const i=Math.min(6,Math.max(1,l));if(i===1)return E();const p=i/t.scale;return{scale:i,x:s.x-(s.x-t.x)*p,y:s.y-(s.y-t.y)*p}}function Z(t,l,s){if(!l.length||l.length!==s.length)return t;const i=o=>({x:o.reduce((c,a)=>c+a.x,0)/o.length,y:o.reduce((c,a)=>c+a.y,0)/o.length}),p=i(l),r=i(s);let n=t;if(l.length===2){const o=a=>Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y),c=o(l);c>0&&(n=w(t,t.scale*o(s)/c,p))}return n.scale===1?n:{...n,x:n.x+r.x-p.x,y:n.y+r.y-p.y}}function tt({image:t,onClose:l}){const[s,i]=g.useState(E),[p,r]=g.useState(0),[n,o]=g.useState(null),c=(n==null?void 0:n.image)===t?n:null,a=(c==null?void 0:c.src)??(t==null?void 0:t.src),u=(c==null?void 0:c.status)==="failed",A=!!(t!=null&&t.loadOriginal&&(c==null?void 0:c.status)!=="ready"&&!u),k=g.useRef(null),f=g.useRef(new Map),I=g.useRef(!1);g.useEffect(()=>{if(!(t!=null&&t.loadOriginal)){o(null);return}let e=!1;return o({image:t,status:"loading"}),t.loadOriginal().then(y=>{e||o({image:t,src:y,status:"decoding"})}).catch(()=>{e||o({image:t,status:"failed"})}),()=>{e=!0}},[t,p]);const v=(e,y)=>{const h=k.current.getBoundingClientRect();return{x:e-h.left-h.width/2,y:y-h.top-h.height/2}};return g.useEffect(()=>{i(E()),f.current.clear()},[t==null?void 0:t.src]),g.useEffect(()=>{const e=k.current;if(!t||!e)return;const y=m=>{m.preventDefault();const T=v(m.clientX,m.clientY);i(b=>w(b,b.scale*Math.exp(-m.deltaY*.002),T))},h=m=>m.preventDefault();return e.addEventListener("wheel",y,{passive:!1}),e.addEventListener("gesturestart",h,{passive:!1}),e.addEventListener("gesturechange",h,{passive:!1}),()=>{e.removeEventListener("wheel",y),e.removeEventListener("gesturestart",h),e.removeEventListener("gesturechange",h)}},[t==null?void 0:t.src]),g.useEffect(()=>{if(!t)return;const e=document.body.style.overflow,y=h=>{h.key==="Escape"&&l()};return document.body.style.overflow="hidden",window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y),document.body.style.overflow=e}},[t,l]),t?N.createPortal(d.jsxs("div",{ref:k,className:"message-image-lightbox",role:"dialog","aria-modal":"true","aria-label":"图片预览","aria-busy":A,onClick:e=>{e.target===e.currentTarget&&!I.current&&l()},onPointerDown:e=>{e.target.closest("button")||e.button!==0||(f.current.size||(I.current=!1),f.current.set(e.pointerId,v(e.clientX,e.clientY)),e.target.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!f.current.has(e.pointerId))return;const y=[...f.current.values()].slice(0,2),h=f.current.get(e.pointerId),m=v(e.clientX,e.clientY);Math.hypot(m.x-h.x,m.y-h.y)>2&&(I.current=!0),f.current.set(e.pointerId,m);const T=[...f.current.values()].slice(0,2);i(b=>Z(b,y,T))},onPointerUp:e=>f.current.delete(e.pointerId),onPointerCancel:e=>f.current.delete(e.pointerId),onLostPointerCapture:e=>f.current.delete(e.pointerId),children:[a&&d.jsx("img",{className:"message-image-lightbox__image",src:a,alt:t.alt,draggable:!1,onLoad:()=>o(e=>(e==null?void 0:e.image)===t&&e.status==="decoding"?{...e,status:"ready"}:e),onError:()=>{(c==null?void 0:c.status)==="decoding"&&o({image:t,status:"failed"})},style:{transform:`translate(${s.x}px, ${s.y}px) scale(${s.scale})`}}),(A||u)&&d.jsx("div",{className:"message-image-lightbox__status",role:"status","aria-live":"polite",children:A?d.jsxs(d.Fragment,{children:[d.jsx(P,{className:"message-image-spinner",size:22,"aria-hidden":"true"}),d.jsx("span",{children:"正在加载原图…"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"原图加载失败"}),d.jsx("button",{type:"button",onClick:()=>r(e=>e+1),children:"重试"})]})}),d.jsxs("div",{className:"message-image-lightbox__toolbar",children:[d.jsx("button",{type:"button","aria-label":"缩小图片",disabled:s.scale<=1,onClick:()=>i(e=>w(e,e.scale/1.5)),children:"−"}),d.jsxs("span",{"aria-live":"polite",children:[Math.round(s.scale*100),"%"]}),d.jsx("button",{type:"button","aria-label":"放大图片",disabled:s.scale>=6,onClick:()=>i(e=>w(e,e.scale*1.5)),children:"+"}),d.jsx("button",{type:"button",onClick:()=>i(E()),children:"恢复"})]}),d.jsx("button",{type:"button",className:"message-image-lightbox__close",onClick:l,"aria-label":"关闭图片预览",title:"关闭",autoFocus:!0,children:d.jsx(R,{size:22,"aria-hidden":"true"})})]}),document.body):null}const $=new Set(["image/jpeg","image/png","image/gif","image/webp"]);async function et(t,l){const s=[],i=[],p=[];for(const n of t){const o=n.type.trim().toLowerCase();o.startsWith("image/")?$.has(o)?s.push(n):p.push(n):i.push(n)}const r=await Promise.all(s.map(async n=>{try{return{file:n,dataUrl:await l(n)}}catch{return{file:n,dataUrl:null}}}));return{images:r.flatMap(n=>n.dataUrl?[n.dataUrl]:[]),attachments:i,unsupportedImages:p,failedImages:r.flatMap(n=>n.dataUrl?[]:[n.file])}}export{tt as M,q as S,W as T,et as a,Q as i,G as n,J as p,H as r};
@@ -1,6 +0,0 @@
1
- import{c as o}from"./index-DSgLFE4Q.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 a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};