@opengeni/react 6.35.1-canary.45051251770001 → 6.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1122) hide show
  1. package/dist/app/app-state.js +32 -32
  2. package/dist/app/components/Composer.js +43 -43
  3. package/dist/app/components/add-card-dialog.js +1 -1
  4. package/dist/app/components/add-card.js +2 -2
  5. package/dist/app/components/agent/agent-capability-picker.js +9 -9
  6. package/dist/app/components/agents/agent-can-use.js +47 -47
  7. package/dist/app/components/agents/agent-form-page.js +139 -139
  8. package/dist/app/components/agents/agent-page.js +122 -122
  9. package/dist/app/components/agents/agent-setup-sections.js +74 -74
  10. package/dist/app/components/agents/agent-skills.js +13 -13
  11. package/dist/app/components/agents/agent-trigger-chat-field.js +6 -6
  12. package/dist/app/components/agents/agent-trigger-dialog.js +31 -31
  13. package/dist/app/components/agents/agent-trigger-picker.js +8 -8
  14. package/dist/app/components/agents/agents-page.js +87 -87
  15. package/dist/app/components/agents/composer-agent-chip.js +59 -59
  16. package/dist/app/components/agents/session-agent-chip.js +55 -55
  17. package/dist/app/components/artifacts/app-package.js +11 -11
  18. package/dist/app/components/artifacts/artifact-browse-controls.js +3 -3
  19. package/dist/app/components/artifacts/artifact-library.js +28 -28
  20. package/dist/app/components/artifacts/artifact-page-chrome.js +1 -1
  21. package/dist/app/components/artifacts/artifact-viewer.js +65 -65
  22. package/dist/app/components/artifacts/chat-interactive-block.js +27 -27
  23. package/dist/app/components/artifacts/copy-artifact-link.js +1 -1
  24. package/dist/app/components/artifacts/file-reach-dialog.js +12 -12
  25. package/dist/app/components/artifacts/inline-chat-image.js +52 -52
  26. package/dist/app/components/artifacts/retained-file-preview.js +58 -58
  27. package/dist/app/components/artifacts/retained-text-preview.js +8 -8
  28. package/dist/app/components/artifacts/site-actions.js +12 -12
  29. package/dist/app/components/artifacts/site-audience.js +7 -7
  30. package/dist/app/components/artifacts/site-conversations.js +34 -34
  31. package/dist/app/components/artifacts/site-data.js +26 -26
  32. package/dist/app/components/artifacts/site-public-link.js +3 -3
  33. package/dist/app/components/artifacts/site-publishing-page.js +69 -69
  34. package/dist/app/components/artifacts/site-publishing.js +54 -54
  35. package/dist/app/components/artifacts/site-settings.js +68 -68
  36. package/dist/app/components/artifacts/site-version-menu.js +9 -9
  37. package/dist/app/components/billing-class-mark.js +8 -8
  38. package/dist/app/components/capabilities/capability-detail-sheet.js +16 -16
  39. package/dist/app/components/capabilities/capability-logo-source.js +28 -28
  40. package/dist/app/components/capabilities/capability-logo.js +1 -1
  41. package/dist/app/components/capabilities/connection-account-picker.js +2 -2
  42. package/dist/app/components/capabilities/connector-tool-permissions.js +8 -8
  43. package/dist/app/components/capabilities/native-connect-setup.js +32 -32
  44. package/dist/app/components/capabilities/own-logins-shared-heads-up.js +6 -6
  45. package/dist/app/components/capabilities/perform-capability-action.js +4 -4
  46. package/dist/app/components/capabilities/prepared-mcp-setup-card.js +31 -31
  47. package/dist/app/components/capabilities/session-capability-card.js +146 -146
  48. package/dist/app/components/capabilities/session-chrome-card.js +49 -49
  49. package/dist/app/components/capabilities/session-connect-inputs-card.js +33 -33
  50. package/dist/app/components/capabilities/session-custom-mcp-card.js +38 -38
  51. package/dist/app/components/capabilities/session-github-card.js +44 -44
  52. package/dist/app/components/capabilities/session-machine-card.js +50 -50
  53. package/dist/app/components/capabilities/session-personal-github-card.js +32 -32
  54. package/dist/app/components/capabilities/session-plugin-card.js +21 -21
  55. package/dist/app/components/capabilities/use-capabilities-catalog.js +1 -1
  56. package/dist/app/components/capabilities/use-connection-accounts.js +3 -3
  57. package/dist/app/components/chat-payment-pages.js +2 -2
  58. package/dist/app/components/command-menu/chat-status.js +26 -26
  59. package/dist/app/components/command-menu/chat-switcher.js +86 -86
  60. package/dist/app/components/command-menu/command-menu.js +109 -109
  61. package/dist/app/components/command-menu/shortcut-sheet.js +23 -23
  62. package/dist/app/components/composer-capabilities-menu-body.js +7 -7
  63. package/dist/app/components/composer-mobile-plus-panel.js +29 -29
  64. package/dist/app/components/composer-mobile-plus.js +3 -3
  65. package/dist/app/components/credit-required-gate.js +6 -6
  66. package/dist/app/components/credit-required-prompt.js +24 -24
  67. package/dist/app/components/credits/checkout-credits-celebration.js +1 -1
  68. package/dist/app/components/credits/checkout-return.js +1 -1
  69. package/dist/app/components/credits/coupon-redeem.js +1 -1
  70. package/dist/app/components/credits/credit-refusal-notice.js +8 -8
  71. package/dist/app/components/credits/own-subscription-plan-notice.js +3 -3
  72. package/dist/app/components/desktop/app-shots.js +9 -9
  73. package/dist/app/components/desktop/app-update.js +3 -3
  74. package/dist/app/components/desktop/computer-use.js +3 -3
  75. package/dist/app/components/desktop/this-computer.js +6 -6
  76. package/dist/app/components/feedback.js +10 -10
  77. package/dist/app/components/follow-up-repository-menu-body.js +14 -14
  78. package/dist/app/components/follow-up-repository-picker.js +1 -1
  79. package/dist/app/components/github-app-connect-launcher.js +2 -2
  80. package/dist/app/components/in-app-help-link.js +3 -3
  81. package/dist/app/components/knowledge/agent-learning-settings.js +3 -3
  82. package/dist/app/components/machines/connect-machine-dialog.js +25 -25
  83. package/dist/app/components/manual-repository-editor.js +3 -3
  84. package/dist/app/components/markdown.js +16 -16
  85. package/dist/app/components/model-identity.js +3 -3
  86. package/dist/app/components/models/models-ui.js +17 -17
  87. package/dist/app/components/models/provider-mark.js +3 -3
  88. package/dist/app/components/models/subscription-usage.js +5 -5
  89. package/dist/app/components/my-things.js +15 -15
  90. package/dist/app/components/own-where-it-works.js +10 -10
  91. package/dist/app/components/personal-resource-attachment-surface.js +4 -4
  92. package/dist/app/components/pickers.js +12 -12
  93. package/dist/app/components/rail/channel-create-dialog.js +6 -6
  94. package/dist/app/components/rail/project-glyph.js +52 -52
  95. package/dist/app/components/rail/project-profile.js +73 -73
  96. package/dist/app/components/rail/rail-context.js +2 -2
  97. package/dist/app/components/rail/rail-sections.js +155 -155
  98. package/dist/app/components/rail/session-header.js +124 -124
  99. package/dist/app/components/rail/session-list.js +154 -154
  100. package/dist/app/components/rail/session-row-content.js +7 -7
  101. package/dist/app/components/rail/session-row-hover-details.js +37 -37
  102. package/dist/app/components/rail/session-shell.js +192 -192
  103. package/dist/app/components/rail/site-session-group-heading.js +36 -36
  104. package/dist/app/components/repository-picker.js +14 -14
  105. package/dist/app/components/secrets/session-secrets-panel.js +4 -4
  106. package/dist/app/components/session/agent-configuration-panel.js +48 -48
  107. package/dist/app/components/session/artifact-session-page.js +7 -7
  108. package/dist/app/components/session/banners.js +20 -20
  109. package/dist/app/components/session/chat-avatar.js +52 -52
  110. package/dist/app/components/session/console-new-conversation.js +111 -111
  111. package/dist/app/components/session/descendant-requests.js +109 -109
  112. package/dist/app/components/session/editable-artifacts-workspace.js +59 -59
  113. package/dist/app/components/session/failed-session-banner.js +30 -30
  114. package/dist/app/components/session/failure-recovery-boundary.js +3 -3
  115. package/dist/app/components/session/human-input-delegation-record.js +3 -3
  116. package/dist/app/components/session/human-input.js +86 -86
  117. package/dist/app/components/session/inspector.js +142 -142
  118. package/dist/app/components/session/linked-panel.js +3 -3
  119. package/dist/app/components/session/message-actions.js +10 -10
  120. package/dist/app/components/session/model-recovery-notice.js +4 -4
  121. package/dist/app/components/session/new-session-settings-menu.js +28 -28
  122. package/dist/app/components/session/new-session-setup-strip.js +55 -55
  123. package/dist/app/components/session/pull-request-panel.js +25 -25
  124. package/dist/app/components/session/sandbox-recovery-actions.js +3 -3
  125. package/dist/app/components/session/sandbox-switcher.js +22 -22
  126. package/dist/app/components/session/sandbox-workspace.js +118 -118
  127. package/dist/app/components/session/search-markdown-highlight.js +17 -17
  128. package/dist/app/components/session/search-results-view.js +18 -18
  129. package/dist/app/components/session/session-admin-access.js +13 -13
  130. package/dist/app/components/session/session-admission-notice.js +11 -11
  131. package/dist/app/components/session/session-avatar-picker.js +59 -59
  132. package/dist/app/components/session/session-avatar.js +54 -54
  133. package/dist/app/components/session/session-machine-access-notice.js +11 -11
  134. package/dist/app/components/session/session-profile-dialog.js +70 -70
  135. package/dist/app/components/session/session-profile-editor.js +71 -71
  136. package/dist/app/components/session/session-retention.js +6 -6
  137. package/dist/app/components/session/session-search-dialog.js +20 -20
  138. package/dist/app/components/session/session-skill-reviews.js +5 -5
  139. package/dist/app/components/session/session-tenancy-control.js +26 -26
  140. package/dist/app/components/session/session-unattended-setting.js +1 -1
  141. package/dist/app/components/session/session-usage-limit-section.js +11 -11
  142. package/dist/app/components/session/share-chat-dialog.js +10 -10
  143. package/dist/app/components/session/subagents.js +23 -23
  144. package/dist/app/components/session/subscription-account-indicator.js +25 -25
  145. package/dist/app/components/session/subscription-account-menu.js +7 -7
  146. package/dist/app/components/session-connectors-menu-body.js +10 -10
  147. package/dist/app/components/settings/row-select.js +6 -6
  148. package/dist/app/components/toaster.js +2 -2
  149. package/dist/app/components/transcription-settings.js +10 -10
  150. package/dist/app/components/ui/destructive-confirm.js +10 -10
  151. package/dist/app/components/usage/usage-entry.js +8 -8
  152. package/dist/app/components/window-bar.js +24 -24
  153. package/dist/app/components/workspace-composer-plus.js +43 -43
  154. package/dist/app/components/workspace-reach.js +6 -6
  155. package/dist/app/embed/session-app.js +398 -398
  156. package/dist/app/lib/actions/actions-provider.js +18 -18
  157. package/dist/app/lib/agent-capabilities.js +4 -4
  158. package/dist/app/lib/app-connect-card.js +14 -14
  159. package/dist/app/lib/app-shared-key-dialog.js +8 -8
  160. package/dist/app/lib/app-surfaces.js +1 -1
  161. package/dist/app/lib/app-sync-opt-in.js +4 -4
  162. package/dist/app/lib/codex-usage-query.js +3 -3
  163. package/dist/app/lib/composer-agent.js +2 -2
  164. package/dist/app/lib/composer-connectors.js +32 -32
  165. package/dist/app/lib/composer-send-blocking.js +3 -3
  166. package/dist/app/lib/console-site.js +6 -6
  167. package/dist/app/lib/console-text.js +2 -2
  168. package/dist/app/lib/deployment-free-model.js +2 -2
  169. package/dist/app/lib/events.js +29 -29
  170. package/dist/app/lib/failed-session-copy.js +6 -6
  171. package/dist/app/lib/feedback-capture.js +2 -2
  172. package/dist/app/lib/free-credit-gap.js +2 -2
  173. package/dist/app/lib/model-access-onboarding.js +5 -5
  174. package/dist/app/lib/model-policy.js +1 -1
  175. package/dist/app/lib/move-chat-to-machine.js +5 -5
  176. package/dist/app/lib/personal-resource-attachments.js +1 -1
  177. package/dist/app/lib/session-branch-cache.js +19 -19
  178. package/dist/app/lib/session-create.js +5 -5
  179. package/dist/app/lib/session-group-pagination.js +19 -19
  180. package/dist/app/lib/session-hover-facts.js +26 -26
  181. package/dist/app/lib/session-list-dirty-scopes.js +20 -20
  182. package/dist/app/lib/session-model.js +3 -3
  183. package/dist/app/lib/session-rail.js +16 -16
  184. package/dist/app/lib/session-rename.js +4 -4
  185. package/dist/app/lib/sessions-group.js +23 -23
  186. package/dist/app/lib/site-tool-consent-dialog.js +23 -23
  187. package/dist/app/lib/site-tool-consent.js +1 -1
  188. package/dist/app/lib/turn-failure-analytics.js +8 -8
  189. package/dist/app/lib/unavailable-session-model.js +2 -2
  190. package/dist/app/lib/use-artifact-catalog.js +2 -2
  191. package/dist/app/lib/use-duplicate-site.js +4 -4
  192. package/dist/app/lib/use-follow-up-repositories.js +5 -5
  193. package/dist/app/lib/use-personal-resource-attachment.js +2 -2
  194. package/dist/app/lib/use-workspace-machines.js +9 -9
  195. package/dist/app/lib/use-workspace-model-catalog.js +7 -7
  196. package/dist/app/lib/use-workspace-rigs.js +6 -6
  197. package/dist/app/lib/workspace-navigation-preference.js +5 -5
  198. package/dist/app/lib/workspace-scope-context.js +4 -4
  199. package/dist/app/routes/app-page-view.js +17 -17
  200. package/dist/app/routes/app-page.js +2 -2
  201. package/dist/app/routes/artifacts.js +152 -152
  202. package/dist/app/routes/retained-artifact.js +108 -108
  203. package/dist/app/routes/session-unavailable.js +5 -5
  204. package/dist/app/routes/session.js +249 -249
  205. package/dist/app/routes/sessions-index-hydration.js +6 -6
  206. package/dist/app/routes/sessions-index.js +207 -207
  207. package/dist/app/routes/site-view.js +200 -200
  208. package/dist/artifacts-document.js +4 -4
  209. package/dist/artifacts-presentation.js +7 -7
  210. package/dist/artifacts-spreadsheet.js +4 -4
  211. package/dist/artifacts.js +50 -50
  212. package/dist/automation-model.js +7 -7
  213. package/dist/automations.js +65 -65
  214. package/dist/browser-viewer-EIEMRVFF.js +23 -0
  215. package/dist/chat-interactive-block-FV37LWYZ.js +22 -0
  216. package/dist/chunk-2COBAJC7.js +818 -0
  217. package/dist/chunk-2HS3IUXE.js +170 -0
  218. package/dist/chunk-2JTMFYCT.js +296 -0
  219. package/dist/chunk-2JXKP4M6.js +114 -0
  220. package/dist/chunk-2P5K7CBH.js +269 -0
  221. package/dist/chunk-2XGRHMRI.js +250 -0
  222. package/dist/chunk-332BYSAZ.js +65 -0
  223. package/dist/chunk-3EM5GTP3.js +158 -0
  224. package/dist/chunk-3L5ATO4A.js +52 -0
  225. package/dist/chunk-3S3PJB7J.js +107 -0
  226. package/dist/chunk-3SBKYPNM.js +270 -0
  227. package/dist/chunk-3Z7VA6ET.js +114 -0
  228. package/dist/chunk-43BRJBEV.js +207 -0
  229. package/dist/chunk-46LZO4ZO.js +188 -0
  230. package/dist/chunk-46ZC5VNC.js +38 -0
  231. package/dist/chunk-4AH4EEHE.js +298 -0
  232. package/dist/chunk-4D3YJNVN.js +270 -0
  233. package/dist/chunk-4E5QVAT4.js +4480 -0
  234. package/dist/chunk-4E5QVAT4.js.map +1 -0
  235. package/dist/chunk-4I4RTI4D.js +37 -0
  236. package/dist/chunk-4KASGJTF.js +287 -0
  237. package/dist/chunk-4RUKLIOF.js +1263 -0
  238. package/dist/chunk-4UU7FN3I.js +650 -0
  239. package/dist/chunk-4VEIBNC2.js +427 -0
  240. package/dist/chunk-4VEIBNC2.js.map +1 -0
  241. package/dist/chunk-4ZRNASBF.js +2551 -0
  242. package/dist/chunk-5EJBPQI2.js +41 -0
  243. package/dist/chunk-5G4IGG7F.js +209 -0
  244. package/dist/chunk-5JAYZOAW.js +131 -0
  245. package/dist/chunk-5JOKVDSR.js +789 -0
  246. package/dist/chunk-5MP3G7ZV.js +1236 -0
  247. package/dist/chunk-5OVRMKP5.js +42 -0
  248. package/dist/chunk-5SGTRULO.js +1184 -0
  249. package/dist/chunk-5SOL4INY.js +572 -0
  250. package/dist/chunk-5Y34P32B.js +27 -0
  251. package/dist/chunk-62HIKJ5F.js +72 -0
  252. package/dist/chunk-62T2ZPD5.js +266 -0
  253. package/dist/chunk-63VNZRLY.js +386 -0
  254. package/dist/chunk-6CDBX3XG.js +33 -0
  255. package/dist/chunk-6D3D2JWY.js +278 -0
  256. package/dist/chunk-6DOIINY4.js +201 -0
  257. package/dist/chunk-6DQBUKGJ.js +112 -0
  258. package/dist/chunk-6SETNFNH.js +1399 -0
  259. package/dist/chunk-6XYFMHNT.js +56 -0
  260. package/dist/chunk-6YU3WV2P.js +33 -0
  261. package/dist/chunk-6YUHDFOZ.js +351 -0
  262. package/dist/chunk-72EOXOR7.js +1185 -0
  263. package/dist/chunk-72ND4ALI.js +532 -0
  264. package/dist/chunk-757LE32E.js +283 -0
  265. package/dist/chunk-7S2S4MXR.js +138 -0
  266. package/dist/chunk-7SYCHMXS.js +200 -0
  267. package/dist/chunk-7TVAPQOV.js +5089 -0
  268. package/dist/chunk-7UDLRDHK.js +214 -0
  269. package/dist/chunk-7YLQCMZP.js +357 -0
  270. package/dist/chunk-A5GX3CAE.js +849 -0
  271. package/dist/chunk-A7EBV2EB.js +318 -0
  272. package/dist/chunk-AB5SPXUR.js +114 -0
  273. package/dist/chunk-AHVQGL5A.js +202 -0
  274. package/dist/chunk-AI77ZKEV.js +26 -0
  275. package/dist/chunk-AIX2D6RB.js +1019 -0
  276. package/dist/chunk-AVSIHP7Q.js +192 -0
  277. package/dist/chunk-AWK23Q32.js +107 -0
  278. package/dist/chunk-AYVWA6KD.js +432 -0
  279. package/dist/chunk-AYZXE4IM.js +2553 -0
  280. package/dist/chunk-AZGGSPTE.js +124 -0
  281. package/dist/chunk-B45TB4HY.js +931 -0
  282. package/dist/chunk-BIUJHNVR.js +46 -0
  283. package/dist/chunk-BJUOKUE5.js +234 -0
  284. package/dist/chunk-BPEEVMKH.js +292 -0
  285. package/dist/chunk-BPHPAGYF.js +74 -0
  286. package/dist/chunk-BXMND6YU.js +307 -0
  287. package/dist/chunk-C6OM2SRG.js +117 -0
  288. package/dist/chunk-CIRCUDKF.js +1309 -0
  289. package/dist/chunk-CLKR4UG3.js +403 -0
  290. package/dist/chunk-CPX6BHER.js +554 -0
  291. package/dist/chunk-CVC4RO7D.js +155 -0
  292. package/dist/chunk-D3YJAQGK.js +103 -0
  293. package/dist/chunk-DFQ72BLS.js +1024 -0
  294. package/dist/chunk-DG65PJOZ.js +4564 -0
  295. package/dist/chunk-DNAXAS5R.js +406 -0
  296. package/dist/chunk-DO247ITS.js +175 -0
  297. package/dist/chunk-DONBARLL.js +154 -0
  298. package/dist/chunk-DTLXQ3ZU.js +373 -0
  299. package/dist/chunk-EAXTACI4.js +274 -0
  300. package/dist/chunk-EDPH7AJH.js +412 -0
  301. package/dist/chunk-EER3B3G5.js +10036 -0
  302. package/dist/chunk-EER3B3G5.js.map +1 -0
  303. package/dist/chunk-EFKQHCGJ.js +276 -0
  304. package/dist/chunk-EILSPMVD.js +133 -0
  305. package/dist/chunk-EK7KIETS.js +211 -0
  306. package/dist/chunk-EMWT6GOK.js +437 -0
  307. package/dist/chunk-EO22NST7.js +259 -0
  308. package/dist/chunk-ER5MYLIE.js +256 -0
  309. package/dist/chunk-ES5HKVQF.js +234 -0
  310. package/dist/chunk-EXRQ5ATC.js +738 -0
  311. package/dist/chunk-EXRQ5ATC.js.map +1 -0
  312. package/dist/chunk-F26YBYAZ.js +111 -0
  313. package/dist/chunk-F6QP4GSK.js +515 -0
  314. package/dist/chunk-F7QEO7M2.js +851 -0
  315. package/dist/chunk-FJFGDLXB.js +12 -0
  316. package/dist/chunk-FLLJ2WXW.js +113 -0
  317. package/dist/chunk-FMBJKMT4.js +107 -0
  318. package/dist/chunk-FPN4I4CG.js +3690 -0
  319. package/dist/chunk-FUXFJTXL.js +3070 -0
  320. package/dist/chunk-FXFOKD7A.js +449 -0
  321. package/dist/chunk-FZI4QOAV.js +3996 -0
  322. package/dist/chunk-FZI4QOAV.js.map +1 -0
  323. package/dist/chunk-G6SSSX5R.js +158 -0
  324. package/dist/chunk-GBGCMHBB.js +608 -0
  325. package/dist/chunk-GIHE7U3Y.js +174 -0
  326. package/dist/chunk-GJ4GTYOD.js +372 -0
  327. package/dist/chunk-GLSDWNFV.js +432 -0
  328. package/dist/chunk-GMGAW3T6.js +278 -0
  329. package/dist/chunk-GNGI6XFN.js +43 -0
  330. package/dist/chunk-GO5VIAA7.js +264 -0
  331. package/dist/chunk-GSW4YHZE.js +229 -0
  332. package/dist/chunk-GUC6IWEY.js +407 -0
  333. package/dist/chunk-GWAY3SO5.js +15 -0
  334. package/dist/chunk-GXOTNT5D.js +168 -0
  335. package/dist/chunk-GZZCVF76.js +3851 -0
  336. package/dist/chunk-H4VMHFOX.js +214 -0
  337. package/dist/chunk-HA5RFQAF.js +110 -0
  338. package/dist/chunk-HFROJDFQ.js +118 -0
  339. package/dist/chunk-HHFFPE67.js +220 -0
  340. package/dist/chunk-HJLHGXWL.js +103 -0
  341. package/dist/chunk-HKNMNL7B.js +2984 -0
  342. package/dist/chunk-HT7MBHLY.js +1021 -0
  343. package/dist/chunk-I5FSUZVW.js +584 -0
  344. package/dist/chunk-IINQO425.js +246 -0
  345. package/dist/chunk-IIXNEOK4.js +1022 -0
  346. package/dist/chunk-IM3WA5AL.js +311 -0
  347. package/dist/chunk-IX4P4OGR.js +399 -0
  348. package/dist/chunk-IX5VHZYS.js +129 -0
  349. package/dist/chunk-JB3TSUZO.js +263 -0
  350. package/dist/chunk-JIC6RLUB.js +27 -0
  351. package/dist/chunk-JNJIZCTN.js +172 -0
  352. package/dist/chunk-JNV5ZPUV.js +828 -0
  353. package/dist/chunk-JPQFVR24.js +50 -0
  354. package/dist/chunk-JPZVMXDP.js +1333 -0
  355. package/dist/chunk-JVPF34MX.js +215 -0
  356. package/dist/chunk-KED67KAF.js +85 -0
  357. package/dist/chunk-KJ72GMZ2.js +378 -0
  358. package/dist/chunk-KTGKGHEA.js +75 -0
  359. package/dist/chunk-KU77XHWB.js +285 -0
  360. package/dist/chunk-KVPQUADA.js +5915 -0
  361. package/dist/chunk-KVPQUADA.js.map +1 -0
  362. package/dist/chunk-KXBLLFOO.js +249 -0
  363. package/dist/chunk-L6WVCO6D.js +61 -0
  364. package/dist/chunk-LIOZ2MXJ.js +380 -0
  365. package/dist/chunk-LIOZ2MXJ.js.map +1 -0
  366. package/dist/chunk-LPEFULJY.js +73 -0
  367. package/dist/chunk-LRMGPO7E.js +98 -0
  368. package/dist/chunk-LVKTKORH.js +121 -0
  369. package/dist/chunk-MCPKUVMQ.js +99 -0
  370. package/dist/chunk-MFLU3466.js +99 -0
  371. package/dist/chunk-MIUJ3EH5.js +60 -0
  372. package/dist/chunk-MIUMNTIJ.js +175 -0
  373. package/dist/chunk-ML46TXRM.js +113 -0
  374. package/dist/chunk-MO3XJQN2.js +629 -0
  375. package/dist/chunk-MQRHTOQ2.js +218 -0
  376. package/dist/chunk-MVYQDBE6.js +79 -0
  377. package/dist/chunk-NIPON7YB.js +850 -0
  378. package/dist/chunk-NIPON7YB.js.map +1 -0
  379. package/dist/chunk-NPBEUU22.js +196 -0
  380. package/dist/chunk-NSXKGS2K.js +178 -0
  381. package/dist/chunk-NUEFORM6.js +2317 -0
  382. package/dist/chunk-NZOFNQNC.js +176 -0
  383. package/dist/chunk-O664PL2U.js +47 -0
  384. package/dist/chunk-O664PL2U.js.map +1 -0
  385. package/dist/chunk-OATXCLTY.js +211 -0
  386. package/dist/chunk-OG3ELROW.js +538 -0
  387. package/dist/chunk-OI4WS7FW.js +162 -0
  388. package/dist/chunk-OITGZUDC.js +82 -0
  389. package/dist/chunk-OKD2LBMK.js +333 -0
  390. package/dist/chunk-OLFOGAWU.js +273 -0
  391. package/dist/chunk-OLFOGAWU.js.map +1 -0
  392. package/dist/chunk-OSA4CGST.js +134 -0
  393. package/dist/chunk-OXYAKUFU.js +401 -0
  394. package/dist/chunk-OYMSMU5O.js +396 -0
  395. package/dist/chunk-P4NZ72KY.js +162 -0
  396. package/dist/chunk-PBYL2VIM.js +379 -0
  397. package/dist/chunk-PDW3OOSZ.js +505 -0
  398. package/dist/chunk-PGRKTQIW.js +523 -0
  399. package/dist/chunk-PPQJIVGM.js +175 -0
  400. package/dist/chunk-PYMQM65Y.js +125 -0
  401. package/dist/chunk-Q273Q33U.js +166 -0
  402. package/dist/chunk-Q4CLS2HL.js +340 -0
  403. package/dist/chunk-QA5UNVHD.js +85 -0
  404. package/dist/chunk-QFOBUA2J.js +428 -0
  405. package/dist/chunk-QLIM4D56.js +1095 -0
  406. package/dist/chunk-QMQF5U2D.js +20 -0
  407. package/dist/chunk-QNOWKKZ4.js +40 -0
  408. package/dist/chunk-QPOUPVPD.js +144 -0
  409. package/dist/chunk-QTJAQ6DS.js +48 -0
  410. package/dist/chunk-QUOFP3G7.js +404 -0
  411. package/dist/chunk-QVOTPOXK.js +29 -0
  412. package/dist/chunk-QYZ5RVGM.js +184 -0
  413. package/dist/chunk-R7CVDKRN.js +2580 -0
  414. package/dist/chunk-RB7MXNZD.js +639 -0
  415. package/dist/chunk-RDZQFZOQ.js +187 -0
  416. package/dist/chunk-RIHKEGWS.js +194 -0
  417. package/dist/chunk-ROSB7GF6.js +57 -0
  418. package/dist/chunk-RP3YMYCX.js +723 -0
  419. package/dist/chunk-RPHXJHNX.js +271 -0
  420. package/dist/chunk-RVC3M66H.js +191 -0
  421. package/dist/chunk-S3OTJAAC.js +283 -0
  422. package/dist/chunk-SBWPMVRN.js +56 -0
  423. package/dist/chunk-SERECSAR.js +138 -0
  424. package/dist/chunk-SHSEF3GJ.js +187 -0
  425. package/dist/chunk-SMS2M3RG.js +772 -0
  426. package/dist/chunk-SRDHDIRQ.js +177 -0
  427. package/dist/chunk-SXRYA7NN.js +389 -0
  428. package/dist/chunk-SYA3WYG4.js +1187 -0
  429. package/dist/chunk-SYYFA7W7.js +23 -0
  430. package/dist/chunk-T2QDSTBH.js +371 -0
  431. package/dist/chunk-TFSCGFYV.js +251 -0
  432. package/dist/chunk-TGCKZOSX.js +246 -0
  433. package/dist/chunk-THILLYQM.js +132 -0
  434. package/dist/chunk-TI6LGUEZ.js +2412 -0
  435. package/dist/chunk-TSY6YZL2.js +366 -0
  436. package/dist/chunk-TW2RHTLH.js +3321 -0
  437. package/dist/chunk-TWA5G277.js +141 -0
  438. package/dist/chunk-TZZ2S4XI.js +247 -0
  439. package/dist/chunk-U5D3K53R.js +58 -0
  440. package/dist/chunk-UECD27LX.js +251 -0
  441. package/dist/chunk-UFJDETKG.js +108 -0
  442. package/dist/chunk-UHCFYX4I.js +570 -0
  443. package/dist/chunk-UHTURYJO.js +898 -0
  444. package/dist/chunk-UJH63JT3.js +67 -0
  445. package/dist/chunk-UOLDS6S5.js +1152 -0
  446. package/dist/chunk-UUE3OGXI.js +84 -0
  447. package/dist/chunk-UUNJ2E57.js +391 -0
  448. package/dist/chunk-UYQVWRAH.js +199 -0
  449. package/dist/chunk-UYWVK7JQ.js +234 -0
  450. package/dist/chunk-UYWWUEL4.js +126 -0
  451. package/dist/chunk-V4CQKX5H.js +48 -0
  452. package/dist/chunk-V4QM7GDQ.js +3176 -0
  453. package/dist/chunk-V5Y74WII.js +91 -0
  454. package/dist/chunk-VGGZLUQK.js +129 -0
  455. package/dist/chunk-VGX636MB.js +311 -0
  456. package/dist/chunk-VGZLFQO2.js +773 -0
  457. package/dist/chunk-VJWZATNF.js +137 -0
  458. package/dist/chunk-VMWCIC2N.js +50 -0
  459. package/dist/chunk-VPWKTIU5.js +227 -0
  460. package/dist/chunk-VXOLG6YB.js +469 -0
  461. package/dist/chunk-W2NAU5VB.js +1628 -0
  462. package/dist/chunk-WGORKMR3.js +353 -0
  463. package/dist/chunk-WMIDELSJ.js +391 -0
  464. package/dist/chunk-WSOSGL2G.js +383 -0
  465. package/dist/chunk-WXUUOM4X.js +400 -0
  466. package/dist/chunk-WZ74QHLE.js +4863 -0
  467. package/dist/chunk-WZ74QHLE.js.map +1 -0
  468. package/dist/chunk-X2OWM2ME.js +1870 -0
  469. package/dist/chunk-X6UMGG4T.js +68 -0
  470. package/dist/chunk-XDXKB25W.js +93 -0
  471. package/dist/chunk-XE4PHI74.js +231 -0
  472. package/dist/chunk-XHF2XNU5.js +73 -0
  473. package/dist/chunk-XLJ4SQFS.js +230 -0
  474. package/dist/chunk-XOD4FX6M.js +2434 -0
  475. package/dist/chunk-XODQ2GPF.js +3110 -0
  476. package/dist/chunk-XT54RTAM.js +441 -0
  477. package/dist/chunk-YAVW5OJ5.js +131 -0
  478. package/dist/chunk-YDQHFJM2.js +83 -0
  479. package/dist/chunk-YH6O6OQ6.js +1356 -0
  480. package/dist/chunk-YIKPC2QP.js +794 -0
  481. package/dist/chunk-ZD7PKYC4.js +335 -0
  482. package/dist/chunk-ZEQYHEWP.js +406 -0
  483. package/dist/chunk-ZP3QCPYG.js +21 -0
  484. package/dist/chunk-ZRVUCTSI.js +265 -0
  485. package/dist/chunk-ZSI3ITRK.js +449 -0
  486. package/dist/chunk-ZZMEQCIZ.js +236 -0
  487. package/dist/components/browser-viewer.d.ts +4 -1
  488. package/dist/composer.js +35 -35
  489. package/dist/computer-viewer-ZBY3BPYW.js +21 -0
  490. package/dist/connect.js +30 -30
  491. package/dist/connection-step-up-JQ4OFSQN.js +145 -0
  492. package/dist/desktop-dictation.js +24 -24
  493. package/dist/desktop.js +2 -2
  494. package/dist/editor.js +2 -2
  495. package/dist/embedded-new-voice-ZB5XLKLU.js +25 -0
  496. package/dist/embedded-voice-MZJISDCS.js +25 -0
  497. package/dist/fleet-decision-row-LG3SYVR3.js +361 -0
  498. package/dist/human-input-model.d.ts +2 -0
  499. package/dist/in-chat-connect-model.js +6 -6
  500. package/dist/index.js +298 -298
  501. package/dist/interaction.d.ts +2 -0
  502. package/dist/interaction.js +11 -9
  503. package/dist/interaction.js.map +1 -1
  504. package/dist/latest-question-QWJTXMFA.js +1 -1
  505. package/dist/machine-request-model.js +1 -1
  506. package/dist/machines.js +8 -8
  507. package/dist/meetings-recorder.js +1 -1
  508. package/dist/meetings.js +116 -116
  509. package/dist/messages/en.d.ts +12 -0
  510. package/dist/messages.js +1 -1
  511. package/dist/model-levels.js +2 -2
  512. package/dist/model-picker-model.js +2 -2
  513. package/dist/model-policy-picker-menu-5Y72PLNF.js +23 -0
  514. package/dist/model-policy.js +1 -1
  515. package/dist/payment-page-card-YPSXRHBA.js +226 -0
  516. package/dist/platform-activity-row-ZU4MEBNK.js +156 -0
  517. package/dist/queue-surface-implementation-6Q25RPH6.js +932 -0
  518. package/dist/realtime.js +17 -17
  519. package/dist/recorder-host-JD4GWJ2Z.js +80 -0
  520. package/dist/recordings.js +3 -3
  521. package/dist/sandbox-files-HCLEEJMU.js +28 -0
  522. package/dist/session-app.js +398 -398
  523. package/dist/session-connect-cards-DRKEN3Z4.js +27 -0
  524. package/dist/session-list-model.js +3 -3
  525. package/dist/session-realtime-IZOTTRH6.js +30 -0
  526. package/dist/session-realtime.js +2 -2
  527. package/dist/session-ui.js +95 -95
  528. package/dist/session.js +42 -42
  529. package/dist/sites.js +3 -3
  530. package/dist/terminal.js +2 -2
  531. package/dist/this-computer.js +3 -3
  532. package/dist/timeline-annotation-markers-WWXNJOXI.js +157 -0
  533. package/dist/timeline-annotation-selection-ZKRIQFIQ.js +208 -0
  534. package/dist/timeline-annotations-dialog-4IMKTOXJ.js +283 -0
  535. package/dist/timeline-model.js +58 -58
  536. package/dist/ui/access-list.js +23 -23
  537. package/dist/ui/cadence-picker.js +7 -7
  538. package/dist/ui/choice-cards.js +3 -3
  539. package/dist/ui/confirm-dialog.js +2 -2
  540. package/dist/ui/copy-field.js +3 -3
  541. package/dist/ui/detail-page.js +5 -5
  542. package/dist/ui/detail-sheet.js +5 -5
  543. package/dist/ui/diff-view.js +3 -3
  544. package/dist/ui/disclosure.js +6 -6
  545. package/dist/ui/email-chips-input.js +3 -3
  546. package/dist/ui/field.js +2 -2
  547. package/dist/ui/flush-form-page.js +7 -7
  548. package/dist/ui/form-dialog.js +6 -6
  549. package/dist/ui/list-row.js +6 -6
  550. package/dist/ui/load-failure.js +3 -3
  551. package/dist/ui/relative-time.js +3 -3
  552. package/dist/ui/revision-history.js +13 -13
  553. package/dist/ui/role-select.js +11 -11
  554. package/dist/ui/select-menu.js +5 -5
  555. package/dist/ui/settings-nav.js +6 -6
  556. package/dist/ui/sheet.js +2 -2
  557. package/dist/ui/usage-meter.js +4 -4
  558. package/dist/usage.js +3 -3
  559. package/dist/workbench.js +11 -11
  560. package/package.json +5 -6
  561. package/src/components/browser-viewer.tsx +109 -72
  562. package/src/components/secret-question-field.tsx +2 -1
  563. package/src/human-input-model.ts +53 -10
  564. package/src/interaction.ts +2 -0
  565. package/src/messages/en.ts +12 -0
  566. package/src/model-policy.ts +3 -1
  567. package/dist/browser-viewer-5DCULGWS.js +0 -23
  568. package/dist/chat-interactive-block-ISMUKH3P.js +0 -22
  569. package/dist/chunk-22NKV5QE.js +0 -133
  570. package/dist/chunk-25SCFA2X.js +0 -794
  571. package/dist/chunk-2NJRDH3Z.js +0 -4480
  572. package/dist/chunk-2NJRDH3Z.js.map +0 -1
  573. package/dist/chunk-2O5EDTVB.js +0 -723
  574. package/dist/chunk-2R7AOT3Y.js +0 -400
  575. package/dist/chunk-2XQFDRP6.js +0 -234
  576. package/dist/chunk-34XY4PWB.js +0 -2412
  577. package/dist/chunk-37J33BLN.js +0 -107
  578. package/dist/chunk-3AXHBU7K.js +0 -818
  579. package/dist/chunk-3B4D4BV7.js +0 -270
  580. package/dist/chunk-3EQMXU5V.js +0 -403
  581. package/dist/chunk-3QUDVXDR.js +0 -227
  582. package/dist/chunk-3SKJO525.js +0 -215
  583. package/dist/chunk-3Y2VSFYS.js +0 -26
  584. package/dist/chunk-3Y7IJPHB.js +0 -3321
  585. package/dist/chunk-3YLXGP2I.js +0 -515
  586. package/dist/chunk-4AUUNEQY.js +0 -15
  587. package/dist/chunk-4D4XXJJJ.js +0 -379
  588. package/dist/chunk-4DW5QEAP.js +0 -201
  589. package/dist/chunk-4KF5I3H5.js +0 -335
  590. package/dist/chunk-4PG2BEQA.js +0 -175
  591. package/dist/chunk-4SW3EUNM.js +0 -83
  592. package/dist/chunk-4T2KWNYX.js +0 -378
  593. package/dist/chunk-4TTWUMDP.js +0 -168
  594. package/dist/chunk-4WKITG7P.js +0 -132
  595. package/dist/chunk-4YXA5UO3.js +0 -287
  596. package/dist/chunk-4ZCTHNOA.js +0 -298
  597. package/dist/chunk-52BUMJQB.js +0 -98
  598. package/dist/chunk-53ZK2JFE.js +0 -538
  599. package/dist/chunk-5ABIZ7YT.js +0 -371
  600. package/dist/chunk-5AHIKB3O.js +0 -449
  601. package/dist/chunk-5DEP55DK.js +0 -251
  602. package/dist/chunk-5ERDSF2C.js +0 -79
  603. package/dist/chunk-5G55HNJB.js +0 -412
  604. package/dist/chunk-62AHHCFV.js +0 -340
  605. package/dist/chunk-644P2VLV.js +0 -407
  606. package/dist/chunk-6F34IWSA.js +0 -47
  607. package/dist/chunk-6F34IWSA.js.map +0 -1
  608. package/dist/chunk-6QDXVH45.js +0 -114
  609. package/dist/chunk-6TBA45QF.js +0 -12
  610. package/dist/chunk-6Y3EFN4Q.js +0 -265
  611. package/dist/chunk-73P7NEOX.js +0 -52
  612. package/dist/chunk-7CLQ7RQV.js +0 -828
  613. package/dist/chunk-7M57K6K5.js +0 -505
  614. package/dist/chunk-7QORJTVI.js +0 -3690
  615. package/dist/chunk-ABO54U65.js +0 -108
  616. package/dist/chunk-ANCI6T7S.js +0 -406
  617. package/dist/chunk-AO27D7GY.js +0 -1021
  618. package/dist/chunk-ATQ3O5E6.js +0 -144
  619. package/dist/chunk-AXBSHKRP.js +0 -246
  620. package/dist/chunk-AZC5P5PV.js +0 -131
  621. package/dist/chunk-B6YDINPE.js +0 -68
  622. package/dist/chunk-BJNSS4UV.js +0 -399
  623. package/dist/chunk-BKYHS4IH.js +0 -276
  624. package/dist/chunk-BOCDCQYX.js +0 -41
  625. package/dist/chunk-BOP5TAUU.js +0 -229
  626. package/dist/chunk-BPD6VRVH.js +0 -432
  627. package/dist/chunk-BSAKPNKY.js +0 -263
  628. package/dist/chunk-BUBEMKK3.js +0 -4845
  629. package/dist/chunk-BUBEMKK3.js.map +0 -1
  630. package/dist/chunk-BXKNGFX5.js +0 -5089
  631. package/dist/chunk-CBHZXVSI.js +0 -207
  632. package/dist/chunk-CGEAOUXW.js +0 -246
  633. package/dist/chunk-CGWLKFQF.js +0 -2580
  634. package/dist/chunk-CIDJMJ44.js +0 -380
  635. package/dist/chunk-CIDJMJ44.js.map +0 -1
  636. package/dist/chunk-CNLR3MVZ.js +0 -175
  637. package/dist/chunk-CPN7JXYV.js +0 -93
  638. package/dist/chunk-DDCDQ4BF.js +0 -2551
  639. package/dist/chunk-DK5L6E4G.js +0 -391
  640. package/dist/chunk-DMDJPQCR.js +0 -5903
  641. package/dist/chunk-DMDJPQCR.js.map +0 -1
  642. package/dist/chunk-DNNW2FSP.js +0 -256
  643. package/dist/chunk-DRPIGAMM.js +0 -4564
  644. package/dist/chunk-DUZZB4C6.js +0 -283
  645. package/dist/chunk-DWH35C5X.js +0 -56
  646. package/dist/chunk-DWW2MA3S.js +0 -278
  647. package/dist/chunk-E4NQIEA3.js +0 -85
  648. package/dist/chunk-E4SAFP76.js +0 -112
  649. package/dist/chunk-EO7NZKIX.js +0 -249
  650. package/dist/chunk-EQSANTUC.js +0 -84
  651. package/dist/chunk-EVHNQCEM.js +0 -214
  652. package/dist/chunk-EVRLHFIG.js +0 -187
  653. package/dist/chunk-FAVXYNTK.js +0 -67
  654. package/dist/chunk-FRDJUZ6E.js +0 -91
  655. package/dist/chunk-FWRKCWQO.js +0 -141
  656. package/dist/chunk-G65TM5FL.js +0 -166
  657. package/dist/chunk-G7TU7QDO.js +0 -432
  658. package/dist/chunk-GGIPEZLL.js +0 -849
  659. package/dist/chunk-GKA5LFYR.js +0 -21
  660. package/dist/chunk-GMQFRX2V.js +0 -406
  661. package/dist/chunk-HE5BTYPR.js +0 -37
  662. package/dist/chunk-HI6TPRY5.js +0 -1356
  663. package/dist/chunk-HLNSIXSJ.js +0 -357
  664. package/dist/chunk-HUKGLWAY.js +0 -174
  665. package/dist/chunk-HUTQJY3F.js +0 -23
  666. package/dist/chunk-HWDHA4KS.js +0 -137
  667. package/dist/chunk-HWDKTGNX.js +0 -1263
  668. package/dist/chunk-HWOJ7JSO.js +0 -20
  669. package/dist/chunk-HWOYJOKK.js +0 -266
  670. package/dist/chunk-HXVKXFIC.js +0 -56
  671. package/dist/chunk-HYVRYGY3.js +0 -270
  672. package/dist/chunk-I5ZTAMDP.js +0 -27
  673. package/dist/chunk-IGVRNMXK.js +0 -154
  674. package/dist/chunk-IHNCZONS.js +0 -230
  675. package/dist/chunk-IIUBCLH6.js +0 -437
  676. package/dist/chunk-IQKLWMIF.js +0 -373
  677. package/dist/chunk-IQWAFZGW.js +0 -191
  678. package/dist/chunk-J3GK2LZP.js +0 -292
  679. package/dist/chunk-J4OOKDRV.js +0 -40
  680. package/dist/chunk-JBNCFLMW.js +0 -3996
  681. package/dist/chunk-JBNCFLMW.js.map +0 -1
  682. package/dist/chunk-JY4ACIKP.js +0 -194
  683. package/dist/chunk-KDZ7WKYY.js +0 -192
  684. package/dist/chunk-KGTZGR4F.js +0 -172
  685. package/dist/chunk-KKIJYI7N.js +0 -351
  686. package/dist/chunk-KLOB3IXX.js +0 -175
  687. package/dist/chunk-KMZUIWL6.js +0 -107
  688. package/dist/chunk-KUYTRUIE.js +0 -214
  689. package/dist/chunk-KYDLVMKA.js +0 -99
  690. package/dist/chunk-KZQDP2JM.js +0 -155
  691. package/dist/chunk-L22AVXXW.js +0 -187
  692. package/dist/chunk-L5AQCKRR.js +0 -311
  693. package/dist/chunk-LG3WCCUT.js +0 -188
  694. package/dist/chunk-LRE7WH6D.js +0 -1095
  695. package/dist/chunk-LSQP22UI.js +0 -176
  696. package/dist/chunk-LTNBDO5B.js +0 -72
  697. package/dist/chunk-LUUFLV27.js +0 -113
  698. package/dist/chunk-M2KDPKQC.js +0 -126
  699. package/dist/chunk-M5FX5KH5.js +0 -629
  700. package/dist/chunk-MD27CX2K.js +0 -1022
  701. package/dist/chunk-MEUAI3B7.js +0 -199
  702. package/dist/chunk-MFYH4N6I.js +0 -650
  703. package/dist/chunk-MPW67ODY.js +0 -639
  704. package/dist/chunk-MRNOTVGF.js +0 -366
  705. package/dist/chunk-MTOWY5MX.js +0 -307
  706. package/dist/chunk-MVLHO6AU.js +0 -441
  707. package/dist/chunk-N4AHWDN2.js +0 -121
  708. package/dist/chunk-NABGUV6O.js +0 -48
  709. package/dist/chunk-NH6OLIQD.js +0 -1628
  710. package/dist/chunk-NKCK4LBK.js +0 -103
  711. package/dist/chunk-NNE73MK2.js +0 -1333
  712. package/dist/chunk-NPKFHO6N.js +0 -584
  713. package/dist/chunk-NRRRO3NJ.js +0 -851
  714. package/dist/chunk-NSLCRIQ6.js +0 -386
  715. package/dist/chunk-NUZNJSL5.js +0 -285
  716. package/dist/chunk-NYTKZQ2V.js +0 -234
  717. package/dist/chunk-O4UAH7WR.js +0 -427
  718. package/dist/chunk-O4UAH7WR.js.map +0 -1
  719. package/dist/chunk-OAEI3MUO.js +0 -50
  720. package/dist/chunk-OCWCZRVU.js +0 -3110
  721. package/dist/chunk-ODR2Q4JQ.js +0 -1236
  722. package/dist/chunk-ODWNT3XC.js +0 -3176
  723. package/dist/chunk-OE6XABJ3.js +0 -269
  724. package/dist/chunk-OEGJWY2U.js +0 -3851
  725. package/dist/chunk-OHJXHKQT.js +0 -162
  726. package/dist/chunk-OJE3WTHK.js +0 -391
  727. package/dist/chunk-OJNZTTQE.js +0 -353
  728. package/dist/chunk-OMYNOB7U.js +0 -124
  729. package/dist/chunk-OX234K6A.js +0 -1399
  730. package/dist/chunk-OYJ7KP6H.js +0 -1152
  731. package/dist/chunk-OZGG6TS7.js +0 -554
  732. package/dist/chunk-P5DGNIGZ.js +0 -773
  733. package/dist/chunk-PCSRHFRF.js +0 -75
  734. package/dist/chunk-PGDGX6PO.js +0 -178
  735. package/dist/chunk-PGMXITPB.js +0 -85
  736. package/dist/chunk-PHNLFMBS.js +0 -158
  737. package/dist/chunk-PJF47YJJ.js +0 -202
  738. package/dist/chunk-PMBZMVKE.js +0 -33
  739. package/dist/chunk-PNLVWZSM.js +0 -211
  740. package/dist/chunk-PQ7WJAKL.js +0 -74
  741. package/dist/chunk-PTLRNXWE.js +0 -200
  742. package/dist/chunk-PTSRBKQC.js +0 -118
  743. package/dist/chunk-PX64T6XV.js +0 -134
  744. package/dist/chunk-PYS63BC6.js +0 -138
  745. package/dist/chunk-QHPB7VSA.js +0 -111
  746. package/dist/chunk-QJQTLBT3.js +0 -73
  747. package/dist/chunk-QR74WLXN.js +0 -65
  748. package/dist/chunk-QZSIADFZ.js +0 -523
  749. package/dist/chunk-R2T4IUNB.js +0 -29
  750. package/dist/chunk-R6CFPY3F.js +0 -278
  751. package/dist/chunk-R6OBJ7LF.js +0 -131
  752. package/dist/chunk-R6WQLIFX.js +0 -73
  753. package/dist/chunk-R7QHNWYL.js +0 -1309
  754. package/dist/chunk-R7ZIFQ7D.js +0 -738
  755. package/dist/chunk-R7ZIFQ7D.js.map +0 -1
  756. package/dist/chunk-RCKXQ2RY.js +0 -3070
  757. package/dist/chunk-RCN3SVJC.js +0 -211
  758. package/dist/chunk-RDTZN6HR.js +0 -372
  759. package/dist/chunk-RET43Z3F.js +0 -43
  760. package/dist/chunk-REUQ464X.js +0 -898
  761. package/dist/chunk-RIOTQESW.js +0 -107
  762. package/dist/chunk-RPJC2JCE.js +0 -209
  763. package/dist/chunk-RT2GW3LO.js +0 -10035
  764. package/dist/chunk-RT2GW3LO.js.map +0 -1
  765. package/dist/chunk-RULIWGQ6.js +0 -2984
  766. package/dist/chunk-RWZ5XML5.js +0 -103
  767. package/dist/chunk-RYWPD5WU.js +0 -572
  768. package/dist/chunk-RYYBQ4PW.js +0 -129
  769. package/dist/chunk-S44ADSZG.js +0 -236
  770. package/dist/chunk-SB3LGY34.js +0 -27
  771. package/dist/chunk-SG4FA5CX.js +0 -33
  772. package/dist/chunk-SMCHRNUL.js +0 -129
  773. package/dist/chunk-SMSEI6VH.js +0 -184
  774. package/dist/chunk-SNACGK3Z.js +0 -177
  775. package/dist/chunk-SOZTO34S.js +0 -2553
  776. package/dist/chunk-SP7XRRGB.js +0 -428
  777. package/dist/chunk-STA75WRF.js +0 -383
  778. package/dist/chunk-SUO5NPEX.js +0 -318
  779. package/dist/chunk-T2NC7ALH.js +0 -333
  780. package/dist/chunk-T3OUZVHU.js +0 -250
  781. package/dist/chunk-T4YOQ6DF.js +0 -789
  782. package/dist/chunk-TGG3ODCS.js +0 -99
  783. package/dist/chunk-TLR2SX7T.js +0 -2317
  784. package/dist/chunk-TXCGPEWC.js +0 -243
  785. package/dist/chunk-TXCGPEWC.js.map +0 -1
  786. package/dist/chunk-TZGJPDZL.js +0 -259
  787. package/dist/chunk-U7KNZEMU.js +0 -271
  788. package/dist/chunk-UDDZDC2Q.js +0 -772
  789. package/dist/chunk-UFIETNB2.js +0 -469
  790. package/dist/chunk-UFRXYZCJ.js +0 -125
  791. package/dist/chunk-UILJ5INQ.js +0 -170
  792. package/dist/chunk-UJ4DLPYG.js +0 -449
  793. package/dist/chunk-UKDLZ76A.js +0 -2434
  794. package/dist/chunk-UMYCZQSL.js +0 -1870
  795. package/dist/chunk-UPRN4FBY.js +0 -38
  796. package/dist/chunk-UQBYKWGG.js +0 -311
  797. package/dist/chunk-UQR5RZ5I.js +0 -218
  798. package/dist/chunk-UWPSCSIZ.js +0 -57
  799. package/dist/chunk-UYLO2JP2.js +0 -158
  800. package/dist/chunk-V2YSF3MJ.js +0 -114
  801. package/dist/chunk-VAJQQKSG.js +0 -283
  802. package/dist/chunk-VDHWFRTL.js +0 -58
  803. package/dist/chunk-VLDKWGHD.js +0 -61
  804. package/dist/chunk-VLODMRE3.js +0 -138
  805. package/dist/chunk-VM6BM3NV.js +0 -389
  806. package/dist/chunk-VRVB2XSO.js +0 -117
  807. package/dist/chunk-W2PBDF4F.js +0 -231
  808. package/dist/chunk-W7BNYXRT.js +0 -296
  809. package/dist/chunk-WCA777NS.js +0 -1187
  810. package/dist/chunk-WDDAHRBC.js +0 -404
  811. package/dist/chunk-WEXKKIPB.js +0 -1024
  812. package/dist/chunk-WG7OVUCV.js +0 -401
  813. package/dist/chunk-WMW4AXVG.js +0 -570
  814. package/dist/chunk-WRMMZYZC.js +0 -931
  815. package/dist/chunk-WYICOILE.js +0 -50
  816. package/dist/chunk-WYNXSYTH.js +0 -532
  817. package/dist/chunk-X62OJCQW.js +0 -234
  818. package/dist/chunk-XBFNNP6B.js +0 -608
  819. package/dist/chunk-XDXPGA3N.js +0 -850
  820. package/dist/chunk-XDXPGA3N.js.map +0 -1
  821. package/dist/chunk-XFP3AIZO.js +0 -247
  822. package/dist/chunk-XSL5GKL3.js +0 -110
  823. package/dist/chunk-XVXYLCSC.js +0 -82
  824. package/dist/chunk-XX2J7H2J.js +0 -196
  825. package/dist/chunk-Y6CNWBV3.js +0 -264
  826. package/dist/chunk-YEFIICAN.js +0 -46
  827. package/dist/chunk-YJBRNXFL.js +0 -1184
  828. package/dist/chunk-YP4SNX4P.js +0 -220
  829. package/dist/chunk-YQ6AYWGT.js +0 -162
  830. package/dist/chunk-YWKJSF3R.js +0 -396
  831. package/dist/chunk-Z3EQ3XBB.js +0 -114
  832. package/dist/chunk-ZD67RM6G.js +0 -60
  833. package/dist/chunk-ZMCVED5L.js +0 -1185
  834. package/dist/chunk-ZOTNM76R.js +0 -42
  835. package/dist/chunk-ZP7BJXQ5.js +0 -113
  836. package/dist/chunk-ZRNDPAED.js +0 -274
  837. package/dist/chunk-ZUQKQP3T.js +0 -251
  838. package/dist/chunk-ZVT2KQTH.js +0 -48
  839. package/dist/chunk-ZXDIEGD5.js +0 -1019
  840. package/dist/computer-viewer-KLRAA56S.js +0 -21
  841. package/dist/connection-step-up-PWIIW3KK.js +0 -145
  842. package/dist/embedded-new-voice-P2RCFI3X.js +0 -25
  843. package/dist/embedded-voice-HY5F4D2I.js +0 -25
  844. package/dist/fleet-decision-row-UEXT7NAN.js +0 -361
  845. package/dist/model-policy-picker-menu-AAGNLTEG.js +0 -23
  846. package/dist/payment-page-card-MHTYJHCW.js +0 -226
  847. package/dist/platform-activity-row-7VAPGRZQ.js +0 -156
  848. package/dist/queue-surface-implementation-AE5P3PSA.js +0 -932
  849. package/dist/recorder-host-I53BQIRX.js +0 -80
  850. package/dist/sandbox-files-LGE7EDX2.js +0 -28
  851. package/dist/session-connect-cards-QNL7WRKJ.js +0 -27
  852. package/dist/session-realtime-ZMXMK5EV.js +0 -30
  853. package/dist/timeline-annotation-markers-5RICTVVW.js +0 -157
  854. package/dist/timeline-annotation-selection-ITAHBOFW.js +0 -208
  855. package/dist/timeline-annotations-dialog-7PGBTPVD.js +0 -283
  856. /package/dist/{browser-viewer-5DCULGWS.js.map → browser-viewer-EIEMRVFF.js.map} +0 -0
  857. /package/dist/{chat-interactive-block-ISMUKH3P.js.map → chat-interactive-block-FV37LWYZ.js.map} +0 -0
  858. /package/dist/{chunk-3AXHBU7K.js.map → chunk-2COBAJC7.js.map} +0 -0
  859. /package/dist/{chunk-UILJ5INQ.js.map → chunk-2HS3IUXE.js.map} +0 -0
  860. /package/dist/{chunk-W7BNYXRT.js.map → chunk-2JTMFYCT.js.map} +0 -0
  861. /package/dist/{chunk-V2YSF3MJ.js.map → chunk-2JXKP4M6.js.map} +0 -0
  862. /package/dist/{chunk-OE6XABJ3.js.map → chunk-2P5K7CBH.js.map} +0 -0
  863. /package/dist/{chunk-T3OUZVHU.js.map → chunk-2XGRHMRI.js.map} +0 -0
  864. /package/dist/{chunk-QR74WLXN.js.map → chunk-332BYSAZ.js.map} +0 -0
  865. /package/dist/{chunk-UYLO2JP2.js.map → chunk-3EM5GTP3.js.map} +0 -0
  866. /package/dist/{chunk-73P7NEOX.js.map → chunk-3L5ATO4A.js.map} +0 -0
  867. /package/dist/{chunk-RIOTQESW.js.map → chunk-3S3PJB7J.js.map} +0 -0
  868. /package/dist/{chunk-HYVRYGY3.js.map → chunk-3SBKYPNM.js.map} +0 -0
  869. /package/dist/{chunk-6QDXVH45.js.map → chunk-3Z7VA6ET.js.map} +0 -0
  870. /package/dist/{chunk-CBHZXVSI.js.map → chunk-43BRJBEV.js.map} +0 -0
  871. /package/dist/{chunk-LG3WCCUT.js.map → chunk-46LZO4ZO.js.map} +0 -0
  872. /package/dist/{chunk-UPRN4FBY.js.map → chunk-46ZC5VNC.js.map} +0 -0
  873. /package/dist/{chunk-4ZCTHNOA.js.map → chunk-4AH4EEHE.js.map} +0 -0
  874. /package/dist/{chunk-3B4D4BV7.js.map → chunk-4D3YJNVN.js.map} +0 -0
  875. /package/dist/{chunk-HE5BTYPR.js.map → chunk-4I4RTI4D.js.map} +0 -0
  876. /package/dist/{chunk-4YXA5UO3.js.map → chunk-4KASGJTF.js.map} +0 -0
  877. /package/dist/{chunk-HWDKTGNX.js.map → chunk-4RUKLIOF.js.map} +0 -0
  878. /package/dist/{chunk-MFYH4N6I.js.map → chunk-4UU7FN3I.js.map} +0 -0
  879. /package/dist/{chunk-DDCDQ4BF.js.map → chunk-4ZRNASBF.js.map} +0 -0
  880. /package/dist/{chunk-BOCDCQYX.js.map → chunk-5EJBPQI2.js.map} +0 -0
  881. /package/dist/{chunk-RPJC2JCE.js.map → chunk-5G4IGG7F.js.map} +0 -0
  882. /package/dist/{chunk-AZC5P5PV.js.map → chunk-5JAYZOAW.js.map} +0 -0
  883. /package/dist/{chunk-T4YOQ6DF.js.map → chunk-5JOKVDSR.js.map} +0 -0
  884. /package/dist/{chunk-ODR2Q4JQ.js.map → chunk-5MP3G7ZV.js.map} +0 -0
  885. /package/dist/{chunk-ZOTNM76R.js.map → chunk-5OVRMKP5.js.map} +0 -0
  886. /package/dist/{chunk-YJBRNXFL.js.map → chunk-5SGTRULO.js.map} +0 -0
  887. /package/dist/{chunk-RYWPD5WU.js.map → chunk-5SOL4INY.js.map} +0 -0
  888. /package/dist/{chunk-SB3LGY34.js.map → chunk-5Y34P32B.js.map} +0 -0
  889. /package/dist/{chunk-LTNBDO5B.js.map → chunk-62HIKJ5F.js.map} +0 -0
  890. /package/dist/{chunk-HWOYJOKK.js.map → chunk-62T2ZPD5.js.map} +0 -0
  891. /package/dist/{chunk-NSLCRIQ6.js.map → chunk-63VNZRLY.js.map} +0 -0
  892. /package/dist/{chunk-PMBZMVKE.js.map → chunk-6CDBX3XG.js.map} +0 -0
  893. /package/dist/{chunk-R6CFPY3F.js.map → chunk-6D3D2JWY.js.map} +0 -0
  894. /package/dist/{chunk-4DW5QEAP.js.map → chunk-6DOIINY4.js.map} +0 -0
  895. /package/dist/{chunk-E4SAFP76.js.map → chunk-6DQBUKGJ.js.map} +0 -0
  896. /package/dist/{chunk-OX234K6A.js.map → chunk-6SETNFNH.js.map} +0 -0
  897. /package/dist/{chunk-HXVKXFIC.js.map → chunk-6XYFMHNT.js.map} +0 -0
  898. /package/dist/{chunk-SG4FA5CX.js.map → chunk-6YU3WV2P.js.map} +0 -0
  899. /package/dist/{chunk-KKIJYI7N.js.map → chunk-6YUHDFOZ.js.map} +0 -0
  900. /package/dist/{chunk-ZMCVED5L.js.map → chunk-72EOXOR7.js.map} +0 -0
  901. /package/dist/{chunk-WYNXSYTH.js.map → chunk-72ND4ALI.js.map} +0 -0
  902. /package/dist/{chunk-DUZZB4C6.js.map → chunk-757LE32E.js.map} +0 -0
  903. /package/dist/{chunk-VLODMRE3.js.map → chunk-7S2S4MXR.js.map} +0 -0
  904. /package/dist/{chunk-PTLRNXWE.js.map → chunk-7SYCHMXS.js.map} +0 -0
  905. /package/dist/{chunk-BXKNGFX5.js.map → chunk-7TVAPQOV.js.map} +0 -0
  906. /package/dist/{chunk-EVHNQCEM.js.map → chunk-7UDLRDHK.js.map} +0 -0
  907. /package/dist/{chunk-HLNSIXSJ.js.map → chunk-7YLQCMZP.js.map} +0 -0
  908. /package/dist/{chunk-GGIPEZLL.js.map → chunk-A5GX3CAE.js.map} +0 -0
  909. /package/dist/{chunk-SUO5NPEX.js.map → chunk-A7EBV2EB.js.map} +0 -0
  910. /package/dist/{chunk-Z3EQ3XBB.js.map → chunk-AB5SPXUR.js.map} +0 -0
  911. /package/dist/{chunk-PJF47YJJ.js.map → chunk-AHVQGL5A.js.map} +0 -0
  912. /package/dist/{chunk-3Y2VSFYS.js.map → chunk-AI77ZKEV.js.map} +0 -0
  913. /package/dist/{chunk-ZXDIEGD5.js.map → chunk-AIX2D6RB.js.map} +0 -0
  914. /package/dist/{chunk-KDZ7WKYY.js.map → chunk-AVSIHP7Q.js.map} +0 -0
  915. /package/dist/{chunk-37J33BLN.js.map → chunk-AWK23Q32.js.map} +0 -0
  916. /package/dist/{chunk-G7TU7QDO.js.map → chunk-AYVWA6KD.js.map} +0 -0
  917. /package/dist/{chunk-SOZTO34S.js.map → chunk-AYZXE4IM.js.map} +0 -0
  918. /package/dist/{chunk-OMYNOB7U.js.map → chunk-AZGGSPTE.js.map} +0 -0
  919. /package/dist/{chunk-WRMMZYZC.js.map → chunk-B45TB4HY.js.map} +0 -0
  920. /package/dist/{chunk-YEFIICAN.js.map → chunk-BIUJHNVR.js.map} +0 -0
  921. /package/dist/{chunk-NYTKZQ2V.js.map → chunk-BJUOKUE5.js.map} +0 -0
  922. /package/dist/{chunk-J3GK2LZP.js.map → chunk-BPEEVMKH.js.map} +0 -0
  923. /package/dist/{chunk-PQ7WJAKL.js.map → chunk-BPHPAGYF.js.map} +0 -0
  924. /package/dist/{chunk-MTOWY5MX.js.map → chunk-BXMND6YU.js.map} +0 -0
  925. /package/dist/{chunk-VRVB2XSO.js.map → chunk-C6OM2SRG.js.map} +0 -0
  926. /package/dist/{chunk-R7QHNWYL.js.map → chunk-CIRCUDKF.js.map} +0 -0
  927. /package/dist/{chunk-3EQMXU5V.js.map → chunk-CLKR4UG3.js.map} +0 -0
  928. /package/dist/{chunk-OZGG6TS7.js.map → chunk-CPX6BHER.js.map} +0 -0
  929. /package/dist/{chunk-KZQDP2JM.js.map → chunk-CVC4RO7D.js.map} +0 -0
  930. /package/dist/{chunk-NKCK4LBK.js.map → chunk-D3YJAQGK.js.map} +0 -0
  931. /package/dist/{chunk-WEXKKIPB.js.map → chunk-DFQ72BLS.js.map} +0 -0
  932. /package/dist/{chunk-DRPIGAMM.js.map → chunk-DG65PJOZ.js.map} +0 -0
  933. /package/dist/{chunk-GMQFRX2V.js.map → chunk-DNAXAS5R.js.map} +0 -0
  934. /package/dist/{chunk-CNLR3MVZ.js.map → chunk-DO247ITS.js.map} +0 -0
  935. /package/dist/{chunk-IGVRNMXK.js.map → chunk-DONBARLL.js.map} +0 -0
  936. /package/dist/{chunk-IQKLWMIF.js.map → chunk-DTLXQ3ZU.js.map} +0 -0
  937. /package/dist/{chunk-ZRNDPAED.js.map → chunk-EAXTACI4.js.map} +0 -0
  938. /package/dist/{chunk-5G55HNJB.js.map → chunk-EDPH7AJH.js.map} +0 -0
  939. /package/dist/{chunk-BKYHS4IH.js.map → chunk-EFKQHCGJ.js.map} +0 -0
  940. /package/dist/{chunk-22NKV5QE.js.map → chunk-EILSPMVD.js.map} +0 -0
  941. /package/dist/{chunk-PNLVWZSM.js.map → chunk-EK7KIETS.js.map} +0 -0
  942. /package/dist/{chunk-IIUBCLH6.js.map → chunk-EMWT6GOK.js.map} +0 -0
  943. /package/dist/{chunk-TZGJPDZL.js.map → chunk-EO22NST7.js.map} +0 -0
  944. /package/dist/{chunk-DNNW2FSP.js.map → chunk-ER5MYLIE.js.map} +0 -0
  945. /package/dist/{chunk-2XQFDRP6.js.map → chunk-ES5HKVQF.js.map} +0 -0
  946. /package/dist/{chunk-QHPB7VSA.js.map → chunk-F26YBYAZ.js.map} +0 -0
  947. /package/dist/{chunk-3YLXGP2I.js.map → chunk-F6QP4GSK.js.map} +0 -0
  948. /package/dist/{chunk-NRRRO3NJ.js.map → chunk-F7QEO7M2.js.map} +0 -0
  949. /package/dist/{chunk-6TBA45QF.js.map → chunk-FJFGDLXB.js.map} +0 -0
  950. /package/dist/{chunk-LUUFLV27.js.map → chunk-FLLJ2WXW.js.map} +0 -0
  951. /package/dist/{chunk-KMZUIWL6.js.map → chunk-FMBJKMT4.js.map} +0 -0
  952. /package/dist/{chunk-7QORJTVI.js.map → chunk-FPN4I4CG.js.map} +0 -0
  953. /package/dist/{chunk-RCKXQ2RY.js.map → chunk-FUXFJTXL.js.map} +0 -0
  954. /package/dist/{chunk-5AHIKB3O.js.map → chunk-FXFOKD7A.js.map} +0 -0
  955. /package/dist/{chunk-PHNLFMBS.js.map → chunk-G6SSSX5R.js.map} +0 -0
  956. /package/dist/{chunk-XBFNNP6B.js.map → chunk-GBGCMHBB.js.map} +0 -0
  957. /package/dist/{chunk-HUKGLWAY.js.map → chunk-GIHE7U3Y.js.map} +0 -0
  958. /package/dist/{chunk-RDTZN6HR.js.map → chunk-GJ4GTYOD.js.map} +0 -0
  959. /package/dist/{chunk-BPD6VRVH.js.map → chunk-GLSDWNFV.js.map} +0 -0
  960. /package/dist/{chunk-DWW2MA3S.js.map → chunk-GMGAW3T6.js.map} +0 -0
  961. /package/dist/{chunk-RET43Z3F.js.map → chunk-GNGI6XFN.js.map} +0 -0
  962. /package/dist/{chunk-Y6CNWBV3.js.map → chunk-GO5VIAA7.js.map} +0 -0
  963. /package/dist/{chunk-BOP5TAUU.js.map → chunk-GSW4YHZE.js.map} +0 -0
  964. /package/dist/{chunk-644P2VLV.js.map → chunk-GUC6IWEY.js.map} +0 -0
  965. /package/dist/{chunk-4AUUNEQY.js.map → chunk-GWAY3SO5.js.map} +0 -0
  966. /package/dist/{chunk-4TTWUMDP.js.map → chunk-GXOTNT5D.js.map} +0 -0
  967. /package/dist/{chunk-OEGJWY2U.js.map → chunk-GZZCVF76.js.map} +0 -0
  968. /package/dist/{chunk-KUYTRUIE.js.map → chunk-H4VMHFOX.js.map} +0 -0
  969. /package/dist/{chunk-XSL5GKL3.js.map → chunk-HA5RFQAF.js.map} +0 -0
  970. /package/dist/{chunk-PTSRBKQC.js.map → chunk-HFROJDFQ.js.map} +0 -0
  971. /package/dist/{chunk-YP4SNX4P.js.map → chunk-HHFFPE67.js.map} +0 -0
  972. /package/dist/{chunk-RWZ5XML5.js.map → chunk-HJLHGXWL.js.map} +0 -0
  973. /package/dist/{chunk-RULIWGQ6.js.map → chunk-HKNMNL7B.js.map} +0 -0
  974. /package/dist/{chunk-AO27D7GY.js.map → chunk-HT7MBHLY.js.map} +0 -0
  975. /package/dist/{chunk-NPKFHO6N.js.map → chunk-I5FSUZVW.js.map} +0 -0
  976. /package/dist/{chunk-AXBSHKRP.js.map → chunk-IINQO425.js.map} +0 -0
  977. /package/dist/{chunk-MD27CX2K.js.map → chunk-IIXNEOK4.js.map} +0 -0
  978. /package/dist/{chunk-UQBYKWGG.js.map → chunk-IM3WA5AL.js.map} +0 -0
  979. /package/dist/{chunk-BJNSS4UV.js.map → chunk-IX4P4OGR.js.map} +0 -0
  980. /package/dist/{chunk-SMCHRNUL.js.map → chunk-IX5VHZYS.js.map} +0 -0
  981. /package/dist/{chunk-BSAKPNKY.js.map → chunk-JB3TSUZO.js.map} +0 -0
  982. /package/dist/{chunk-I5ZTAMDP.js.map → chunk-JIC6RLUB.js.map} +0 -0
  983. /package/dist/{chunk-KGTZGR4F.js.map → chunk-JNJIZCTN.js.map} +0 -0
  984. /package/dist/{chunk-7CLQ7RQV.js.map → chunk-JNV5ZPUV.js.map} +0 -0
  985. /package/dist/{chunk-OAEI3MUO.js.map → chunk-JPQFVR24.js.map} +0 -0
  986. /package/dist/{chunk-NNE73MK2.js.map → chunk-JPZVMXDP.js.map} +0 -0
  987. /package/dist/{chunk-3SKJO525.js.map → chunk-JVPF34MX.js.map} +0 -0
  988. /package/dist/{chunk-E4NQIEA3.js.map → chunk-KED67KAF.js.map} +0 -0
  989. /package/dist/{chunk-4T2KWNYX.js.map → chunk-KJ72GMZ2.js.map} +0 -0
  990. /package/dist/{chunk-PCSRHFRF.js.map → chunk-KTGKGHEA.js.map} +0 -0
  991. /package/dist/{chunk-NUZNJSL5.js.map → chunk-KU77XHWB.js.map} +0 -0
  992. /package/dist/{chunk-EO7NZKIX.js.map → chunk-KXBLLFOO.js.map} +0 -0
  993. /package/dist/{chunk-VLDKWGHD.js.map → chunk-L6WVCO6D.js.map} +0 -0
  994. /package/dist/{chunk-QJQTLBT3.js.map → chunk-LPEFULJY.js.map} +0 -0
  995. /package/dist/{chunk-52BUMJQB.js.map → chunk-LRMGPO7E.js.map} +0 -0
  996. /package/dist/{chunk-N4AHWDN2.js.map → chunk-LVKTKORH.js.map} +0 -0
  997. /package/dist/{chunk-TGG3ODCS.js.map → chunk-MCPKUVMQ.js.map} +0 -0
  998. /package/dist/{chunk-KYDLVMKA.js.map → chunk-MFLU3466.js.map} +0 -0
  999. /package/dist/{chunk-ZD67RM6G.js.map → chunk-MIUJ3EH5.js.map} +0 -0
  1000. /package/dist/{chunk-KLOB3IXX.js.map → chunk-MIUMNTIJ.js.map} +0 -0
  1001. /package/dist/{chunk-ZP7BJXQ5.js.map → chunk-ML46TXRM.js.map} +0 -0
  1002. /package/dist/{chunk-M5FX5KH5.js.map → chunk-MO3XJQN2.js.map} +0 -0
  1003. /package/dist/{chunk-UQR5RZ5I.js.map → chunk-MQRHTOQ2.js.map} +0 -0
  1004. /package/dist/{chunk-5ERDSF2C.js.map → chunk-MVYQDBE6.js.map} +0 -0
  1005. /package/dist/{chunk-XX2J7H2J.js.map → chunk-NPBEUU22.js.map} +0 -0
  1006. /package/dist/{chunk-PGDGX6PO.js.map → chunk-NSXKGS2K.js.map} +0 -0
  1007. /package/dist/{chunk-TLR2SX7T.js.map → chunk-NUEFORM6.js.map} +0 -0
  1008. /package/dist/{chunk-LSQP22UI.js.map → chunk-NZOFNQNC.js.map} +0 -0
  1009. /package/dist/{chunk-RCN3SVJC.js.map → chunk-OATXCLTY.js.map} +0 -0
  1010. /package/dist/{chunk-53ZK2JFE.js.map → chunk-OG3ELROW.js.map} +0 -0
  1011. /package/dist/{chunk-YQ6AYWGT.js.map → chunk-OI4WS7FW.js.map} +0 -0
  1012. /package/dist/{chunk-XVXYLCSC.js.map → chunk-OITGZUDC.js.map} +0 -0
  1013. /package/dist/{chunk-T2NC7ALH.js.map → chunk-OKD2LBMK.js.map} +0 -0
  1014. /package/dist/{chunk-PX64T6XV.js.map → chunk-OSA4CGST.js.map} +0 -0
  1015. /package/dist/{chunk-WG7OVUCV.js.map → chunk-OXYAKUFU.js.map} +0 -0
  1016. /package/dist/{chunk-YWKJSF3R.js.map → chunk-OYMSMU5O.js.map} +0 -0
  1017. /package/dist/{chunk-OHJXHKQT.js.map → chunk-P4NZ72KY.js.map} +0 -0
  1018. /package/dist/{chunk-4D4XXJJJ.js.map → chunk-PBYL2VIM.js.map} +0 -0
  1019. /package/dist/{chunk-7M57K6K5.js.map → chunk-PDW3OOSZ.js.map} +0 -0
  1020. /package/dist/{chunk-QZSIADFZ.js.map → chunk-PGRKTQIW.js.map} +0 -0
  1021. /package/dist/{chunk-4PG2BEQA.js.map → chunk-PPQJIVGM.js.map} +0 -0
  1022. /package/dist/{chunk-UFRXYZCJ.js.map → chunk-PYMQM65Y.js.map} +0 -0
  1023. /package/dist/{chunk-G65TM5FL.js.map → chunk-Q273Q33U.js.map} +0 -0
  1024. /package/dist/{chunk-62AHHCFV.js.map → chunk-Q4CLS2HL.js.map} +0 -0
  1025. /package/dist/{chunk-PGMXITPB.js.map → chunk-QA5UNVHD.js.map} +0 -0
  1026. /package/dist/{chunk-SP7XRRGB.js.map → chunk-QFOBUA2J.js.map} +0 -0
  1027. /package/dist/{chunk-LRE7WH6D.js.map → chunk-QLIM4D56.js.map} +0 -0
  1028. /package/dist/{chunk-HWOJ7JSO.js.map → chunk-QMQF5U2D.js.map} +0 -0
  1029. /package/dist/{chunk-J4OOKDRV.js.map → chunk-QNOWKKZ4.js.map} +0 -0
  1030. /package/dist/{chunk-ATQ3O5E6.js.map → chunk-QPOUPVPD.js.map} +0 -0
  1031. /package/dist/{chunk-ZVT2KQTH.js.map → chunk-QTJAQ6DS.js.map} +0 -0
  1032. /package/dist/{chunk-WDDAHRBC.js.map → chunk-QUOFP3G7.js.map} +0 -0
  1033. /package/dist/{chunk-R2T4IUNB.js.map → chunk-QVOTPOXK.js.map} +0 -0
  1034. /package/dist/{chunk-SMSEI6VH.js.map → chunk-QYZ5RVGM.js.map} +0 -0
  1035. /package/dist/{chunk-CGWLKFQF.js.map → chunk-R7CVDKRN.js.map} +0 -0
  1036. /package/dist/{chunk-MPW67ODY.js.map → chunk-RB7MXNZD.js.map} +0 -0
  1037. /package/dist/{chunk-EVRLHFIG.js.map → chunk-RDZQFZOQ.js.map} +0 -0
  1038. /package/dist/{chunk-JY4ACIKP.js.map → chunk-RIHKEGWS.js.map} +0 -0
  1039. /package/dist/{chunk-UWPSCSIZ.js.map → chunk-ROSB7GF6.js.map} +0 -0
  1040. /package/dist/{chunk-2O5EDTVB.js.map → chunk-RP3YMYCX.js.map} +0 -0
  1041. /package/dist/{chunk-U7KNZEMU.js.map → chunk-RPHXJHNX.js.map} +0 -0
  1042. /package/dist/{chunk-IQWAFZGW.js.map → chunk-RVC3M66H.js.map} +0 -0
  1043. /package/dist/{chunk-VAJQQKSG.js.map → chunk-S3OTJAAC.js.map} +0 -0
  1044. /package/dist/{chunk-DWH35C5X.js.map → chunk-SBWPMVRN.js.map} +0 -0
  1045. /package/dist/{chunk-PYS63BC6.js.map → chunk-SERECSAR.js.map} +0 -0
  1046. /package/dist/{chunk-L22AVXXW.js.map → chunk-SHSEF3GJ.js.map} +0 -0
  1047. /package/dist/{chunk-UDDZDC2Q.js.map → chunk-SMS2M3RG.js.map} +0 -0
  1048. /package/dist/{chunk-SNACGK3Z.js.map → chunk-SRDHDIRQ.js.map} +0 -0
  1049. /package/dist/{chunk-VM6BM3NV.js.map → chunk-SXRYA7NN.js.map} +0 -0
  1050. /package/dist/{chunk-WCA777NS.js.map → chunk-SYA3WYG4.js.map} +0 -0
  1051. /package/dist/{chunk-HUTQJY3F.js.map → chunk-SYYFA7W7.js.map} +0 -0
  1052. /package/dist/{chunk-5ABIZ7YT.js.map → chunk-T2QDSTBH.js.map} +0 -0
  1053. /package/dist/{chunk-ZUQKQP3T.js.map → chunk-TFSCGFYV.js.map} +0 -0
  1054. /package/dist/{chunk-CGEAOUXW.js.map → chunk-TGCKZOSX.js.map} +0 -0
  1055. /package/dist/{chunk-4WKITG7P.js.map → chunk-THILLYQM.js.map} +0 -0
  1056. /package/dist/{chunk-34XY4PWB.js.map → chunk-TI6LGUEZ.js.map} +0 -0
  1057. /package/dist/{chunk-MRNOTVGF.js.map → chunk-TSY6YZL2.js.map} +0 -0
  1058. /package/dist/{chunk-3Y7IJPHB.js.map → chunk-TW2RHTLH.js.map} +0 -0
  1059. /package/dist/{chunk-FWRKCWQO.js.map → chunk-TWA5G277.js.map} +0 -0
  1060. /package/dist/{chunk-XFP3AIZO.js.map → chunk-TZZ2S4XI.js.map} +0 -0
  1061. /package/dist/{chunk-VDHWFRTL.js.map → chunk-U5D3K53R.js.map} +0 -0
  1062. /package/dist/{chunk-5DEP55DK.js.map → chunk-UECD27LX.js.map} +0 -0
  1063. /package/dist/{chunk-ABO54U65.js.map → chunk-UFJDETKG.js.map} +0 -0
  1064. /package/dist/{chunk-WMW4AXVG.js.map → chunk-UHCFYX4I.js.map} +0 -0
  1065. /package/dist/{chunk-REUQ464X.js.map → chunk-UHTURYJO.js.map} +0 -0
  1066. /package/dist/{chunk-FAVXYNTK.js.map → chunk-UJH63JT3.js.map} +0 -0
  1067. /package/dist/{chunk-OYJ7KP6H.js.map → chunk-UOLDS6S5.js.map} +0 -0
  1068. /package/dist/{chunk-EQSANTUC.js.map → chunk-UUE3OGXI.js.map} +0 -0
  1069. /package/dist/{chunk-OJE3WTHK.js.map → chunk-UUNJ2E57.js.map} +0 -0
  1070. /package/dist/{chunk-MEUAI3B7.js.map → chunk-UYQVWRAH.js.map} +0 -0
  1071. /package/dist/{chunk-X62OJCQW.js.map → chunk-UYWVK7JQ.js.map} +0 -0
  1072. /package/dist/{chunk-M2KDPKQC.js.map → chunk-UYWWUEL4.js.map} +0 -0
  1073. /package/dist/{chunk-NABGUV6O.js.map → chunk-V4CQKX5H.js.map} +0 -0
  1074. /package/dist/{chunk-ODWNT3XC.js.map → chunk-V4QM7GDQ.js.map} +0 -0
  1075. /package/dist/{chunk-FRDJUZ6E.js.map → chunk-V5Y74WII.js.map} +0 -0
  1076. /package/dist/{chunk-RYYBQ4PW.js.map → chunk-VGGZLUQK.js.map} +0 -0
  1077. /package/dist/{chunk-L5AQCKRR.js.map → chunk-VGX636MB.js.map} +0 -0
  1078. /package/dist/{chunk-P5DGNIGZ.js.map → chunk-VGZLFQO2.js.map} +0 -0
  1079. /package/dist/{chunk-HWDHA4KS.js.map → chunk-VJWZATNF.js.map} +0 -0
  1080. /package/dist/{chunk-WYICOILE.js.map → chunk-VMWCIC2N.js.map} +0 -0
  1081. /package/dist/{chunk-3QUDVXDR.js.map → chunk-VPWKTIU5.js.map} +0 -0
  1082. /package/dist/{chunk-UFIETNB2.js.map → chunk-VXOLG6YB.js.map} +0 -0
  1083. /package/dist/{chunk-NH6OLIQD.js.map → chunk-W2NAU5VB.js.map} +0 -0
  1084. /package/dist/{chunk-OJNZTTQE.js.map → chunk-WGORKMR3.js.map} +0 -0
  1085. /package/dist/{chunk-DK5L6E4G.js.map → chunk-WMIDELSJ.js.map} +0 -0
  1086. /package/dist/{chunk-STA75WRF.js.map → chunk-WSOSGL2G.js.map} +0 -0
  1087. /package/dist/{chunk-2R7AOT3Y.js.map → chunk-WXUUOM4X.js.map} +0 -0
  1088. /package/dist/{chunk-UMYCZQSL.js.map → chunk-X2OWM2ME.js.map} +0 -0
  1089. /package/dist/{chunk-B6YDINPE.js.map → chunk-X6UMGG4T.js.map} +0 -0
  1090. /package/dist/{chunk-CPN7JXYV.js.map → chunk-XDXKB25W.js.map} +0 -0
  1091. /package/dist/{chunk-W2PBDF4F.js.map → chunk-XE4PHI74.js.map} +0 -0
  1092. /package/dist/{chunk-R6WQLIFX.js.map → chunk-XHF2XNU5.js.map} +0 -0
  1093. /package/dist/{chunk-IHNCZONS.js.map → chunk-XLJ4SQFS.js.map} +0 -0
  1094. /package/dist/{chunk-UKDLZ76A.js.map → chunk-XOD4FX6M.js.map} +0 -0
  1095. /package/dist/{chunk-OCWCZRVU.js.map → chunk-XODQ2GPF.js.map} +0 -0
  1096. /package/dist/{chunk-MVLHO6AU.js.map → chunk-XT54RTAM.js.map} +0 -0
  1097. /package/dist/{chunk-R6OBJ7LF.js.map → chunk-YAVW5OJ5.js.map} +0 -0
  1098. /package/dist/{chunk-4SW3EUNM.js.map → chunk-YDQHFJM2.js.map} +0 -0
  1099. /package/dist/{chunk-HI6TPRY5.js.map → chunk-YH6O6OQ6.js.map} +0 -0
  1100. /package/dist/{chunk-25SCFA2X.js.map → chunk-YIKPC2QP.js.map} +0 -0
  1101. /package/dist/{chunk-4KF5I3H5.js.map → chunk-ZD7PKYC4.js.map} +0 -0
  1102. /package/dist/{chunk-ANCI6T7S.js.map → chunk-ZEQYHEWP.js.map} +0 -0
  1103. /package/dist/{chunk-GKA5LFYR.js.map → chunk-ZP3QCPYG.js.map} +0 -0
  1104. /package/dist/{chunk-6Y3EFN4Q.js.map → chunk-ZRVUCTSI.js.map} +0 -0
  1105. /package/dist/{chunk-UJ4DLPYG.js.map → chunk-ZSI3ITRK.js.map} +0 -0
  1106. /package/dist/{chunk-S44ADSZG.js.map → chunk-ZZMEQCIZ.js.map} +0 -0
  1107. /package/dist/{computer-viewer-KLRAA56S.js.map → computer-viewer-ZBY3BPYW.js.map} +0 -0
  1108. /package/dist/{connection-step-up-PWIIW3KK.js.map → connection-step-up-JQ4OFSQN.js.map} +0 -0
  1109. /package/dist/{embedded-new-voice-P2RCFI3X.js.map → embedded-new-voice-ZB5XLKLU.js.map} +0 -0
  1110. /package/dist/{embedded-voice-HY5F4D2I.js.map → embedded-voice-MZJISDCS.js.map} +0 -0
  1111. /package/dist/{fleet-decision-row-UEXT7NAN.js.map → fleet-decision-row-LG3SYVR3.js.map} +0 -0
  1112. /package/dist/{model-policy-picker-menu-AAGNLTEG.js.map → model-policy-picker-menu-5Y72PLNF.js.map} +0 -0
  1113. /package/dist/{payment-page-card-MHTYJHCW.js.map → payment-page-card-YPSXRHBA.js.map} +0 -0
  1114. /package/dist/{platform-activity-row-7VAPGRZQ.js.map → platform-activity-row-ZU4MEBNK.js.map} +0 -0
  1115. /package/dist/{queue-surface-implementation-AE5P3PSA.js.map → queue-surface-implementation-6Q25RPH6.js.map} +0 -0
  1116. /package/dist/{recorder-host-I53BQIRX.js.map → recorder-host-JD4GWJ2Z.js.map} +0 -0
  1117. /package/dist/{sandbox-files-LGE7EDX2.js.map → sandbox-files-HCLEEJMU.js.map} +0 -0
  1118. /package/dist/{session-connect-cards-QNL7WRKJ.js.map → session-connect-cards-DRKEN3Z4.js.map} +0 -0
  1119. /package/dist/{session-realtime-ZMXMK5EV.js.map → session-realtime-IZOTTRH6.js.map} +0 -0
  1120. /package/dist/{timeline-annotation-markers-5RICTVVW.js.map → timeline-annotation-markers-WWXNJOXI.js.map} +0 -0
  1121. /package/dist/{timeline-annotation-selection-ITAHBOFW.js.map → timeline-annotation-selection-ZKRIQFIQ.js.map} +0 -0
  1122. /package/dist/{timeline-annotations-dialog-7PGBTPVD.js.map → timeline-annotations-dialog-4IMKTOXJ.js.map} +0 -0
@@ -1,4845 +0,0 @@
1
- "use client";
2
- import {
3
- InteractionInterventionBanner,
4
- isInteractionControlUnavailable,
5
- isNonRetryableInteractionError,
6
- isSourcePlacementChangedError,
7
- isSourcePlacementElsewhereError,
8
- useInteractionInterventions,
9
- useInteractionInvalidation,
10
- useViewerMenuDismiss
11
- } from "./chunk-CIDJMJ44.js";
12
- import {
13
- interactionHostPlatform
14
- } from "./chunk-ZUWF4NF7.js";
15
- import {
16
- useClientConfigFlags
17
- } from "./chunk-XESA3B7W.js";
18
- import {
19
- STREAM_CLOSE_REASON_NORMAL,
20
- STREAM_KIND_BROWSER,
21
- STREAM_ROLE_CLIENT,
22
- decodeStreamFrame,
23
- decodeStreamOpenAck,
24
- encodeStreamClose,
25
- encodeStreamOpen
26
- } from "./chunk-TNEZNMSN.js";
27
- import {
28
- copyTextToClipboard
29
- } from "./chunk-PEHTX3V7.js";
30
- import {
31
- formatBytes
32
- } from "./chunk-UIK52VL4.js";
33
- import {
34
- usePageLiveActivity
35
- } from "./chunk-SW4S6I5E.js";
36
- import {
37
- useEmbeddedBrowserInteraction
38
- } from "./chunk-BVUAHAQX.js";
39
- import {
40
- cn
41
- } from "./chunk-TXS65BB2.js";
42
- import {
43
- useOpenGeniText
44
- } from "./chunk-DMDJPQCR.js";
45
-
46
- // src/components/browser-viewer.tsx
47
- import { interactionControlFailureFromError } from "@opengeni/sdk/interaction";
48
- import {
49
- BugIcon,
50
- ArchiveIcon,
51
- ArrowLeftIcon,
52
- ArrowRightIcon,
53
- CheckIcon,
54
- ChevronDownIcon,
55
- CircleAlertIcon,
56
- DownloadIcon,
57
- FileCheck2Icon,
58
- Globe2Icon,
59
- LoaderCircleIcon,
60
- MonitorIcon,
61
- PlusIcon,
62
- RefreshCwIcon,
63
- RotateCcwIcon,
64
- SaveIcon,
65
- UserRoundIcon,
66
- XIcon,
67
- ZapIcon
68
- } from "lucide-react";
69
- import {
70
- useCallback as useCallback8,
71
- useEffect as useEffect9,
72
- useId,
73
- useLayoutEffect as useLayoutEffect2,
74
- useMemo as useMemo2,
75
- useRef as useRef9,
76
- useState as useState9
77
- } from "react";
78
-
79
- // src/hooks/use-browser-frame-stream.ts
80
- import {
81
- browserFrameSocketUrl,
82
- decodeBrowserFrameMessage
83
- } from "@opengeni/sdk/interaction";
84
- import { useCallback, useEffect, useRef, useState } from "react";
85
- import { errorMessage } from "@opengeni/contracts/values";
86
- var RELAY_TAG_OPEN = 1;
87
- var RELAY_TAG_OPEN_ACK = 2;
88
- var RELAY_TAG_FRAME = 3;
89
- var RELAY_TAG_CLOSE = 4;
90
- var MAX_AUTOMATIC_RECONNECTS_WITHOUT_A_FRAME = 2;
91
- function useBrowserFrameStream(options) {
92
- const t = useOpenGeniText();
93
- const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
94
- const pageLive = usePageLiveActivity();
95
- const enabled = (options.enabled ?? true) && pageLive;
96
- const [nonce, setNonce] = useState(0);
97
- const [result, setResult] = useState({
98
- state: "idle",
99
- frame: null,
100
- attachment: null,
101
- error: null
102
- });
103
- const latestRef = useRef({
104
- key: "",
105
- sequence: -1
106
- });
107
- const factoryRef = useRef(options.webSocketFactory);
108
- const streamRef = useRef(options.stream);
109
- factoryRef.current = options.webSocketFactory;
110
- streamRef.current = options.stream;
111
- const reconnect = useCallback(() => setNonce((value) => value + 1), []);
112
- useEffect(() => {
113
- const browserSessionId = options.browserSessionId;
114
- const targetId = options.targetId;
115
- if (!enabled || !browserSessionId || !targetId || typeof window === "undefined") {
116
- setResult({ state: "idle", frame: null, attachment: null, error: null });
117
- return;
118
- }
119
- latestRef.current = { key: "", sequence: -1 };
120
- setResult({
121
- state: "attaching",
122
- frame: null,
123
- attachment: null,
124
- error: null
125
- });
126
- let disposed = false;
127
- let socket = null;
128
- let socketHandlers = null;
129
- let reconnectTimer = null;
130
- let expiryTimer = null;
131
- let failures = 0;
132
- let controllerGeneration = null;
133
- let activeAttachment = null;
134
- let activeStream = null;
135
- let attachmentExpiresAt = 0;
136
- let lastRelaySequence = null;
137
- let relayAccepted = false;
138
- let pendingFrame = null;
139
- let decodingFrame = false;
140
- const attachmentAbort = new AbortController();
141
- const clearSocket = (terminateProducer = false) => {
142
- if (!socket) return;
143
- const current = socket;
144
- const handlers = socketHandlers;
145
- if (terminateProducer && activeStream?.kind === "relay" && socket.readyState === 1) {
146
- try {
147
- socket.send(
148
- relayDatagram(
149
- RELAY_TAG_CLOSE,
150
- encodeStreamClose({
151
- channelId: activeStream.channel.channelId,
152
- reason: STREAM_CLOSE_REASON_NORMAL,
153
- message: "viewer detached"
154
- })
155
- )
156
- );
157
- } catch {
158
- }
159
- }
160
- if (handlers) {
161
- current.removeEventListener("open", handlers.open);
162
- current.removeEventListener("message", handlers.message);
163
- current.removeEventListener("error", handlers.error);
164
- current.removeEventListener("close", handlers.close);
165
- }
166
- if (current.readyState === 0 || current.readyState === 1) {
167
- current.close(1e3, "viewer detached");
168
- }
169
- socket = null;
170
- socketHandlers = null;
171
- pendingFrame = null;
172
- };
173
- const scheduleReconnect = () => {
174
- if (disposed || reconnectTimer) return;
175
- if (failures >= MAX_AUTOMATIC_RECONNECTS_WITHOUT_A_FRAME) return;
176
- const delay = Math.min(5e3, 250 * 2 ** Math.min(failures, 5));
177
- failures += 1;
178
- setResult((current) => ({ ...current, state: "reconnecting" }));
179
- reconnectTimer = setTimeout(() => {
180
- reconnectTimer = null;
181
- connectSocket();
182
- }, delay);
183
- };
184
- const fail = (cause, reconnectAutomatically = true) => {
185
- if (disposed) return;
186
- const error = cause instanceof Error ? cause : new Error(String(cause));
187
- setResult((current) => ({ ...current, state: "error", error }));
188
- clearSocket();
189
- if (reconnectAutomatically) scheduleReconnect();
190
- };
191
- const onOpen = (source) => {
192
- if (disposed || source !== socket) return;
193
- if (activeStream?.kind === "relay") {
194
- const body = encodeStreamOpen({
195
- channel: {
196
- ...activeStream.channel,
197
- kind: STREAM_KIND_BROWSER
198
- },
199
- token: activeStream.token,
200
- role: STREAM_ROLE_CLIENT,
201
- resumeFromSeq: lastRelaySequence === null ? "0" : (BigInt(lastRelaySequence) + 1n).toString()
202
- });
203
- try {
204
- source.send(relayDatagram(RELAY_TAG_OPEN, body));
205
- } catch (error) {
206
- fail(error);
207
- }
208
- return;
209
- }
210
- setResult((current) => ({ ...current, state: "live", error: null }));
211
- };
212
- const drainLatestFrame = async () => {
213
- if (decodingFrame) return;
214
- decodingFrame = true;
215
- try {
216
- while (pendingFrame) {
217
- if (disposed) break;
218
- const pending = pendingFrame;
219
- pendingFrame = null;
220
- const { bytes, source } = pending;
221
- const frame = decodeBrowserFrameMessage(bytes);
222
- if (disposed || source !== socket) continue;
223
- if (frame.browserSessionId !== browserSessionId || frame.targetId !== targetId) {
224
- throw new Error("browser frame belongs to another resource");
225
- }
226
- if (!controllerGeneration || frame.controllerGeneration !== controllerGeneration) {
227
- throw new Error("browser frame belongs to a stale controller");
228
- }
229
- const key = `${browserSessionId}:${targetId}:${frame.controllerGeneration}:${frame.targetGeneration}:${frame.documentGeneration}`;
230
- if (latestRef.current.key === key && frame.sequence <= latestRef.current.sequence)
231
- continue;
232
- latestRef.current = { key, sequence: frame.sequence };
233
- failures = 0;
234
- setResult((current) => ({
235
- ...current,
236
- state: "live",
237
- frame,
238
- error: null
239
- }));
240
- }
241
- } catch (cause) {
242
- fail(cause);
243
- } finally {
244
- decodingFrame = false;
245
- if (!disposed && pendingFrame) void drainLatestFrame();
246
- }
247
- };
248
- const onMessage = (source, event) => {
249
- void (async () => {
250
- try {
251
- const bytes = await messageBytes(event.data);
252
- if (disposed || source !== socket) return;
253
- let frameBytes = bytes;
254
- if (activeStream?.kind === "relay") {
255
- if (bytes.length < 1) throw new Error("browser relay returned an empty message");
256
- const tag = bytes[0];
257
- const body = bytes.subarray(1);
258
- if (tag === RELAY_TAG_OPEN_ACK) {
259
- const ack = decodeStreamOpenAck(body);
260
- if (!ack.accepted) {
261
- activeAttachment = null;
262
- activeStream = null;
263
- attachmentExpiresAt = 0;
264
- throw new Error(ack.error?.message ?? "browser stream was rejected by the relay");
265
- }
266
- relayAccepted = true;
267
- return;
268
- }
269
- if (tag === RELAY_TAG_CLOSE) {
270
- activeAttachment = null;
271
- activeStream = null;
272
- attachmentExpiresAt = 0;
273
- lastRelaySequence = null;
274
- relayAccepted = false;
275
- fail(new Error("Browser frame source ended."), false);
276
- return;
277
- }
278
- if (tag !== RELAY_TAG_FRAME || !relayAccepted) return;
279
- const relayFrame = decodeStreamFrame(body);
280
- lastRelaySequence = relayFrame.seq;
281
- frameBytes = relayFrame.data;
282
- }
283
- pendingFrame = { bytes: frameBytes, source };
284
- void drainLatestFrame();
285
- } catch (cause) {
286
- fail(cause);
287
- }
288
- })();
289
- };
290
- const onError = (source) => {
291
- if (source !== socket) return;
292
- fail(new Error(t("hooks.useBrowserFrameStream.browserViewLostConnection")));
293
- };
294
- const onClose = (source) => {
295
- if (disposed || source !== socket) return;
296
- clearSocket();
297
- scheduleReconnect();
298
- };
299
- const connectSocket = () => {
300
- if (disposed) return;
301
- clearSocket();
302
- if (!activeAttachment || !activeStream || attachmentExpiresAt <= Date.now() + 1e3) {
303
- void attach();
304
- return;
305
- }
306
- relayAccepted = false;
307
- setResult((current) => ({
308
- ...current,
309
- state: "connecting",
310
- error: null
311
- }));
312
- const createSocket = factoryRef.current ?? ((url, protocols) => new WebSocket(url, protocols));
313
- const openedSocket = createSocket(
314
- activeStream.kind === "relay" ? activeStream.url : browserFrameSocketUrl(activeAttachment, streamRef.current),
315
- activeStream.kind === "direct_websocket" ? [...activeStream.protocols] : []
316
- );
317
- latestRef.current = { key: "", sequence: -1 };
318
- socket = openedSocket;
319
- socketHandlers = {
320
- open: () => onOpen(openedSocket),
321
- message: (event) => onMessage(openedSocket, event),
322
- error: () => onError(openedSocket),
323
- close: () => onClose(openedSocket)
324
- };
325
- openedSocket.binaryType = "arraybuffer";
326
- openedSocket.addEventListener("open", socketHandlers.open);
327
- openedSocket.addEventListener("message", socketHandlers.message);
328
- openedSocket.addEventListener("error", socketHandlers.error);
329
- openedSocket.addEventListener("close", socketHandlers.close);
330
- };
331
- const attach = async () => {
332
- if (disposed) return;
333
- clearSocket();
334
- if (expiryTimer) clearTimeout(expiryTimer);
335
- setResult((current) => ({
336
- ...current,
337
- state: current.attachment ? "reconnecting" : "attaching",
338
- error: null
339
- }));
340
- try {
341
- const attachment = await client.attachBrowserSession(
342
- workspaceId,
343
- browserSessionId,
344
- {
345
- targetId,
346
- expiresInSeconds: 120,
347
- ...streamRef.current ? { stream: streamRef.current } : {}
348
- },
349
- { signal: attachmentAbort.signal }
350
- );
351
- if (disposed) return;
352
- if (attachment.browserSessionId !== browserSessionId || attachment.targetId !== targetId) {
353
- throw new Error("browser attachment does not match the requested resource");
354
- }
355
- controllerGeneration = attachment.controllerGeneration;
356
- activeAttachment = attachment;
357
- activeStream = attachment.stream;
358
- attachmentExpiresAt = Date.parse(attachment.expiresAt);
359
- lastRelaySequence = null;
360
- relayAccepted = false;
361
- setResult((current) => ({
362
- ...current,
363
- state: "connecting",
364
- attachment: {
365
- browserSessionId: attachment.browserSessionId,
366
- controllerGeneration: attachment.controllerGeneration,
367
- targetId: attachment.targetId,
368
- expiresAt: attachment.expiresAt,
369
- ...attachment.fencedInputBatches === true ? { fencedInputBatches: true } : {},
370
- ...attachment.focusedInputObservations === true ? { focusedInputObservations: true } : {}
371
- },
372
- error: null
373
- }));
374
- const refreshIn = Number.isFinite(attachmentExpiresAt) ? Math.max(1e3, attachmentExpiresAt - Date.now() - 5e3) : 6e4;
375
- expiryTimer = setTimeout(() => {
376
- if (disposed) return;
377
- clearSocket(true);
378
- activeAttachment = null;
379
- activeStream = null;
380
- attachmentExpiresAt = 0;
381
- void attach();
382
- }, refreshIn);
383
- connectSocket();
384
- } catch (cause) {
385
- if (attachmentAbort.signal.aborted || disposed) return;
386
- fail(cause, !isPlacementGenerationLossError(cause));
387
- }
388
- };
389
- void attach();
390
- return () => {
391
- disposed = true;
392
- attachmentAbort.abort();
393
- if (reconnectTimer) clearTimeout(reconnectTimer);
394
- if (expiryTimer) clearTimeout(expiryTimer);
395
- clearSocket(true);
396
- };
397
- }, [client, enabled, nonce, options.browserSessionId, options.targetId, workspaceId, t]);
398
- return { ...result, reconnect };
399
- }
400
- function relayDatagram(tag, body) {
401
- const message = new Uint8Array(body.length + 1);
402
- message[0] = tag;
403
- message.set(body, 1);
404
- return message.buffer;
405
- }
406
- async function messageBytes(value) {
407
- if (value instanceof ArrayBuffer) return new Uint8Array(value);
408
- if (ArrayBuffer.isView(value)) {
409
- return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();
410
- }
411
- if (typeof Blob !== "undefined" && value instanceof Blob) {
412
- return new Uint8Array(await value.arrayBuffer());
413
- }
414
- throw new Error("browser frame stream returned a non-binary message");
415
- }
416
- function isPlacementGenerationLossError(cause) {
417
- const message = errorMessage(cause);
418
- return /placement instance changed|controller authority changed/i.test(message);
419
- }
420
-
421
- // src/hooks/use-attached-browsers.ts
422
- import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
423
- function useAttachedBrowsers(options = {}) {
424
- const { client, workspaceId, workspaceInteractionEvent, workspaceInteractionConnectionState } = useEmbeddedBrowserInteraction(options);
425
- const enabled = options.enabled ?? true;
426
- const includeDisconnected = options.includeDisconnected ?? false;
427
- const [state, setState] = useState2(() => emptyState(workspaceId, enabled));
428
- const requestRef = useRef2({
429
- id: 0,
430
- controller: null
431
- });
432
- const mountedRef = useRef2(true);
433
- const visible = state.workspaceId === workspaceId ? state : emptyState(workspaceId, enabled);
434
- const cancelLoad = useCallback2(() => {
435
- const id = requestRef.current.id + 1;
436
- requestRef.current.controller?.abort();
437
- requestRef.current = { id, controller: null };
438
- }, []);
439
- const load = useCallback2(
440
- async (foreground) => {
441
- if (!enabled) return;
442
- const id = requestRef.current.id + 1;
443
- requestRef.current.controller?.abort();
444
- const controller = new AbortController();
445
- requestRef.current = { id, controller };
446
- setState((current) => ({
447
- ...current.workspaceId === workspaceId ? current : emptyState(workspaceId, true),
448
- loading: foreground,
449
- refreshing: !foreground,
450
- error: foreground || current.workspaceId !== workspaceId ? null : current.error
451
- }));
452
- try {
453
- const response = await client.listAttachedBrowsers(workspaceId, {
454
- includeDisconnected,
455
- signal: controller.signal
456
- });
457
- if (!mountedRef.current || requestRef.current.id !== id) return;
458
- setState({
459
- workspaceId,
460
- revision: response.revision,
461
- bridges: response.bridges,
462
- devices: sortDevices(response.devices),
463
- loading: false,
464
- refreshing: false,
465
- error: null
466
- });
467
- } catch (cause) {
468
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
469
- return;
470
- setState((current) => ({
471
- ...current.workspaceId === workspaceId ? current : emptyState(workspaceId, true),
472
- loading: false,
473
- refreshing: false,
474
- error: cause instanceof Error ? cause : new Error(String(cause))
475
- }));
476
- } finally {
477
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
478
- }
479
- },
480
- [client, enabled, includeDisconnected, workspaceId]
481
- );
482
- const refresh = useCallback2(async () => await load(false), [load]);
483
- useEffect2(() => {
484
- mountedRef.current = true;
485
- if (!enabled) {
486
- cancelLoad();
487
- setState(emptyState(workspaceId, false));
488
- return;
489
- }
490
- void load(true);
491
- return () => {
492
- mountedRef.current = false;
493
- cancelLoad();
494
- };
495
- }, [cancelLoad, enabled, load, workspaceId]);
496
- useInteractionInvalidation({
497
- workspaceId,
498
- key: `${workspaceId}:${includeDisconnected}`,
499
- enabled,
500
- event: workspaceInteractionEvent,
501
- connectionState: workspaceInteractionConnectionState,
502
- knownRevision: visible.revision,
503
- refresh,
504
- fallbackPollIntervalMs: options.pollIntervalMs
505
- });
506
- return {
507
- revision: visible.revision,
508
- bridges: visible.bridges,
509
- devices: visible.devices,
510
- loading: visible.loading,
511
- refreshing: visible.refreshing,
512
- error: visible.error,
513
- refresh
514
- };
515
- }
516
- function emptyState(workspaceId, loading) {
517
- return {
518
- workspaceId,
519
- revision: 0,
520
- bridges: [],
521
- devices: [],
522
- loading,
523
- refreshing: false,
524
- error: null
525
- };
526
- }
527
- function sortDevices(devices) {
528
- return [...devices].sort(
529
- (left, right) => Number(right.state === "connected") - Number(left.state === "connected") || timestamp(right.lastSeenAt) - timestamp(left.lastSeenAt) || left.name.localeCompare(right.name)
530
- );
531
- }
532
- function timestamp(value) {
533
- const parsed = Date.parse(value);
534
- return Number.isFinite(parsed) ? parsed : 0;
535
- }
536
-
537
- // src/hooks/use-browser-identities.ts
538
- import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
539
- function useBrowserIdentities(options = {}) {
540
- const { client, workspaceId, workspaceInteractionEvent, workspaceInteractionConnectionState } = useEmbeddedBrowserInteraction(options);
541
- const enabled = options.enabled ?? true;
542
- const includeArchived = options.includeArchived ?? false;
543
- const [state, setState] = useState3(() => emptyState2(workspaceId, enabled));
544
- const [mutationCount, setMutationCount] = useState3(0);
545
- const requestRef = useRef3({
546
- id: 0,
547
- controller: null
548
- });
549
- const mountedRef = useRef3(true);
550
- const visibleState = state.workspaceId === workspaceId ? state : emptyState2(workspaceId, enabled);
551
- const cancelLoad = useCallback3(() => {
552
- const id = requestRef.current.id + 1;
553
- requestRef.current.controller?.abort();
554
- requestRef.current = { id, controller: null };
555
- }, []);
556
- const load = useCallback3(
557
- async (foreground) => {
558
- if (!enabled) return;
559
- const id = requestRef.current.id + 1;
560
- requestRef.current.controller?.abort();
561
- const controller = new AbortController();
562
- requestRef.current = { id, controller };
563
- setState((current) => ({
564
- ...current.workspaceId === workspaceId ? current : emptyState2(workspaceId, true),
565
- loading: foreground,
566
- refreshing: !foreground,
567
- error: foreground || current.workspaceId !== workspaceId ? null : current.error
568
- }));
569
- try {
570
- const response = await client.listBrowserIdentities(workspaceId, {
571
- includeArchived,
572
- signal: controller.signal
573
- });
574
- if (!mountedRef.current || requestRef.current.id !== id) return;
575
- setState({
576
- workspaceId,
577
- revision: response.revision,
578
- identities: sortIdentities(response.identities),
579
- loading: false,
580
- refreshing: false,
581
- error: null
582
- });
583
- } catch (cause) {
584
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
585
- return;
586
- setState((current) => ({
587
- ...current.workspaceId === workspaceId ? current : emptyState2(workspaceId, true),
588
- loading: false,
589
- refreshing: false,
590
- error: cause instanceof Error ? cause : new Error(String(cause))
591
- }));
592
- } finally {
593
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
594
- }
595
- },
596
- [client, enabled, includeArchived, workspaceId]
597
- );
598
- const refresh = useCallback3(async () => await load(false), [load]);
599
- useEffect3(() => {
600
- mountedRef.current = true;
601
- if (!enabled) {
602
- cancelLoad();
603
- setState(emptyState2(workspaceId, false));
604
- return;
605
- }
606
- void load(true);
607
- return () => {
608
- mountedRef.current = false;
609
- cancelLoad();
610
- };
611
- }, [cancelLoad, enabled, load, workspaceId]);
612
- useInteractionInvalidation({
613
- workspaceId,
614
- key: workspaceId,
615
- enabled,
616
- event: workspaceInteractionEvent,
617
- connectionState: workspaceInteractionConnectionState,
618
- knownRevision: visibleState.revision,
619
- refresh
620
- });
621
- const mutate = useCallback3(async (operation) => {
622
- setMutationCount((count) => count + 1);
623
- try {
624
- return await operation();
625
- } finally {
626
- if (mountedRef.current) setMutationCount((count) => Math.max(0, count - 1));
627
- }
628
- }, []);
629
- const create = useCallback3(
630
- async (request) => await mutate(async () => {
631
- const response = await client.createBrowserIdentity(workspaceId, {
632
- ...request,
633
- operationId: request.operationId ?? crypto.randomUUID()
634
- });
635
- setState((current) => mergeIdentity(current, workspaceId, response.identity));
636
- return response;
637
- }),
638
- [client, mutate, workspaceId]
639
- );
640
- const revisions = useCallback3(
641
- async (identityId) => await client.listBrowserRevisions(workspaceId, identityId),
642
- [client, workspaceId]
643
- );
644
- const update = useCallback3(
645
- async (identityId, request) => await mutate(async () => {
646
- const response = await client.updateBrowserIdentity(workspaceId, identityId, {
647
- ...request,
648
- operationId: request.operationId ?? crypto.randomUUID()
649
- });
650
- setState(
651
- (current) => mergeIdentity(current, workspaceId, response.identity, includeArchived)
652
- );
653
- return response;
654
- }),
655
- [client, includeArchived, mutate, workspaceId]
656
- );
657
- const publish = useCallback3(
658
- async (browserSessionId, request) => await mutate(async () => {
659
- const response = await client.publishBrowserRevision(workspaceId, browserSessionId, {
660
- ...request,
661
- operationId: request.operationId ?? crypto.randomUUID()
662
- });
663
- setState((current) => mergeIdentity(current, workspaceId, response.identity));
664
- return response;
665
- }),
666
- [client, mutate, workspaceId]
667
- );
668
- return {
669
- revision: visibleState.revision,
670
- identities: visibleState.identities,
671
- loading: visibleState.loading,
672
- refreshing: visibleState.refreshing,
673
- mutating: mutationCount > 0,
674
- error: visibleState.error,
675
- refresh,
676
- create,
677
- update,
678
- revisions,
679
- publish
680
- };
681
- }
682
- function emptyState2(workspaceId, loading) {
683
- return {
684
- workspaceId,
685
- revision: 0,
686
- identities: [],
687
- loading,
688
- refreshing: false,
689
- error: null
690
- };
691
- }
692
- function sortIdentities(identities) {
693
- return [...identities].sort(
694
- (left, right) => timestamp2(right.updatedAt) - timestamp2(left.updatedAt) || left.name.localeCompare(right.name)
695
- );
696
- }
697
- function timestamp2(value) {
698
- const parsed = Date.parse(value);
699
- return Number.isFinite(parsed) ? parsed : 0;
700
- }
701
- function mergeIdentity(current, workspaceId, identity, includeArchived = false) {
702
- if (current.workspaceId !== workspaceId) return current;
703
- return {
704
- ...current,
705
- identities: sortIdentities(
706
- identity.status === "archived" && !includeArchived ? current.identities.filter((candidate) => candidate.id !== identity.id) : [...current.identities.filter((candidate) => candidate.id !== identity.id), identity]
707
- ),
708
- error: null
709
- };
710
- }
711
-
712
- // src/hooks/use-browser-downloads.ts
713
- import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
714
- function useBrowserDownloads(options) {
715
- const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
716
- const browserSessionId = options.browserSessionId;
717
- const enabled = (options.enabled ?? true) && browserSessionId !== null;
718
- const pageLive = usePageLiveActivity();
719
- const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2e3);
720
- const scope = browserSessionId ?? "none";
721
- const [state, setState] = useState4(() => emptyState3(scope, enabled));
722
- const [saving, setSaving] = useState4({});
723
- const visible = state.scope === scope ? state : emptyState3(scope, enabled);
724
- const requestRef = useRef4({
725
- id: 0,
726
- controller: null
727
- });
728
- const mountedRef = useRef4(true);
729
- const retryOperationsRef = useRef4(/* @__PURE__ */ new Map());
730
- const cancelLoad = useCallback4(() => {
731
- requestRef.current.controller?.abort();
732
- requestRef.current = { id: requestRef.current.id + 1, controller: null };
733
- }, []);
734
- const load = useCallback4(
735
- async (foreground) => {
736
- if (!enabled || !browserSessionId) return;
737
- const id = requestRef.current.id + 1;
738
- requestRef.current.controller?.abort();
739
- const controller = new AbortController();
740
- requestRef.current = { id, controller };
741
- setState((current) => ({
742
- ...current.scope === scope ? current : emptyState3(scope, true),
743
- loading: foreground,
744
- refreshing: !foreground,
745
- error: foreground || current.scope !== scope ? null : current.error
746
- }));
747
- try {
748
- const response = await client.listBrowserDownloads(workspaceId, browserSessionId, {
749
- signal: controller.signal
750
- });
751
- if (!mountedRef.current || requestRef.current.id !== id) return;
752
- setState({
753
- scope,
754
- downloads: sortDownloads(response.downloads),
755
- loading: false,
756
- refreshing: false,
757
- error: null
758
- });
759
- } catch (cause) {
760
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
761
- return;
762
- setState((current) => ({
763
- ...current.scope === scope ? current : emptyState3(scope, true),
764
- loading: false,
765
- refreshing: false,
766
- error: asError(cause)
767
- }));
768
- } finally {
769
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
770
- }
771
- },
772
- [browserSessionId, client, enabled, scope, workspaceId]
773
- );
774
- const refresh = useCallback4(async () => await load(false), [load]);
775
- useEffect4(() => {
776
- retryOperationsRef.current.clear();
777
- setSaving({});
778
- }, [scope]);
779
- useEffect4(() => {
780
- mountedRef.current = true;
781
- if (!enabled) {
782
- cancelLoad();
783
- setState(emptyState3(scope, false));
784
- return () => {
785
- mountedRef.current = false;
786
- cancelLoad();
787
- };
788
- }
789
- void load(true);
790
- return () => {
791
- mountedRef.current = false;
792
- cancelLoad();
793
- };
794
- }, [cancelLoad, enabled, load, scope]);
795
- useEffect4(() => {
796
- if (!enabled || !pageLive || Object.keys(saving).length > 0) return;
797
- const timer = setInterval(() => {
798
- if (!requestRef.current.controller) void refresh();
799
- }, pollIntervalMs);
800
- return () => clearInterval(timer);
801
- }, [enabled, pageLive, pollIntervalMs, refresh, saving]);
802
- const saveToWorkspace = useCallback4(
803
- async (downloadId, destinationPath, saveOptions = {}) => {
804
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
805
- const overwrite = saveOptions.overwrite ?? false;
806
- const attemptKey = `${browserSessionId}\0${downloadId}\0${destinationPath}\0${overwrite}`;
807
- const operationId = saveOptions.operationId ?? retryOperationsRef.current.get(attemptKey) ?? crypto.randomUUID();
808
- retryOperationsRef.current.set(attemptKey, operationId);
809
- setSaving((current) => ({ ...current, [downloadId]: (current[downloadId] ?? 0) + 1 }));
810
- try {
811
- const response = await client.saveBrowserDownload(
812
- workspaceId,
813
- browserSessionId,
814
- downloadId,
815
- { operationId, destinationPath, overwrite }
816
- );
817
- retryOperationsRef.current.delete(attemptKey);
818
- if (mountedRef.current) {
819
- setState(
820
- (current) => current.scope === scope ? {
821
- ...current,
822
- downloads: sortDownloads([
823
- ...current.downloads.filter((download) => download.id !== response.download.id),
824
- response.download
825
- ]),
826
- error: null
827
- } : current
828
- );
829
- }
830
- return response;
831
- } finally {
832
- if (mountedRef.current) {
833
- setSaving((current) => {
834
- const count = (current[downloadId] ?? 1) - 1;
835
- if (count > 0) return { ...current, [downloadId]: count };
836
- const { [downloadId]: _removed, ...rest } = current;
837
- return rest;
838
- });
839
- }
840
- }
841
- },
842
- [browserSessionId, client, scope, workspaceId]
843
- );
844
- return {
845
- downloads: visible.downloads,
846
- loading: visible.loading,
847
- refreshing: visible.refreshing,
848
- savingDownloadIds: Object.keys(saving),
849
- error: visible.error,
850
- refresh,
851
- saveToWorkspace
852
- };
853
- }
854
- function emptyState3(scope, loading) {
855
- return {
856
- scope,
857
- downloads: [],
858
- loading,
859
- refreshing: false,
860
- error: null
861
- };
862
- }
863
- function sortDownloads(downloads) {
864
- return [...downloads].sort(
865
- (left, right) => right.startedAt.localeCompare(left.startedAt) || left.id.localeCompare(right.id)
866
- );
867
- }
868
- function asError(cause) {
869
- return cause instanceof Error ? cause : new Error(String(cause));
870
- }
871
-
872
- // src/hooks/use-browser-session.ts
873
- import { OpenGeniApiError } from "@opengeni/sdk";
874
- import { useCallback as useCallback5, useEffect as useEffect5, useRef as useRef5, useState as useState5 } from "react";
875
- function useBrowserSession(options) {
876
- const t = useOpenGeniText();
877
- const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
878
- const browserSessionId = options.browserSessionId;
879
- const enabled = (options.enabled ?? true) && browserSessionId !== null;
880
- const sourceRef = useRef5({ client, workspaceId, browserSessionId, enabled });
881
- if (sourceRef.current.client !== client || sourceRef.current.workspaceId !== workspaceId || sourceRef.current.browserSessionId !== browserSessionId || sourceRef.current.enabled !== enabled) {
882
- sourceRef.current = { client, workspaceId, browserSessionId, enabled };
883
- }
884
- const source = sourceRef.current;
885
- const semanticObservationEnabled = options.semanticObservationEnabled ?? true;
886
- const semanticObservationEnabledRef = useRef5(semanticObservationEnabled);
887
- semanticObservationEnabledRef.current = semanticObservationEnabled;
888
- const previousSemanticObservationRef = useRef5({
889
- browserSessionId,
890
- enabled: semanticObservationEnabled
891
- });
892
- const pageLive = usePageLiveActivity();
893
- const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2e3);
894
- const refusedObservationPageRef = useRef5(null);
895
- const [state, setState] = useState5(() => ({ ...emptyState4(browserSessionId, enabled), source }));
896
- const visible = state.source === source && state.browserSessionId === browserSessionId ? state : { ...emptyState4(browserSessionId, enabled), source };
897
- const refreshBlocked = isNonRetryableInteractionError(visible.error);
898
- const inputFailureRef = useRef5(visible.inputFailure);
899
- inputFailureRef.current = visible.inputFailure;
900
- const selectedTargetIdRef = useRef5(visible.selectedTargetId);
901
- selectedTargetIdRef.current = visible.selectedTargetId;
902
- const selectionRevisionRef = useRef5(0);
903
- const actionResultOrderRef = useRef5({ next: 0, settled: 0 });
904
- const selectedTargetRef = useRef5(
905
- visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null
906
- );
907
- selectedTargetRef.current = visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null;
908
- const observationRef = useRef5({ browserSessionId, observation: visible.observation });
909
- const lastObservationAtRef = useRef5(0);
910
- if (observationRef.current.browserSessionId !== browserSessionId) {
911
- observationRef.current = {
912
- browserSessionId,
913
- observation: visible.observation
914
- };
915
- } else {
916
- observationRef.current.observation = visible.observation;
917
- }
918
- const requestRef = useRef5({
919
- id: 0,
920
- controller: null
921
- });
922
- const mutationRef = useRef5({
923
- browserSessionId,
924
- source,
925
- count: 0,
926
- needsInventoryReconcile: false
927
- });
928
- const mountedRef = useRef5(true);
929
- const isCurrentSource = useCallback5(
930
- () => mountedRef.current && sourceRef.current === source,
931
- [source]
932
- );
933
- const invalidateRefresh = useCallback5(() => {
934
- const id = requestRef.current.id + 1;
935
- requestRef.current.controller?.abort();
936
- requestRef.current = { id, controller: null };
937
- }, []);
938
- const refreshInventory = useCallback5(
939
- async (checkInput = false, observeSelectedTarget = true) => {
940
- if (!enabled || !browserSessionId || !isCurrentSource()) return;
941
- const checkedInputFailure = inputFailureRef.current;
942
- const id = requestRef.current.id + 1;
943
- requestRef.current.controller?.abort();
944
- const controller = new AbortController();
945
- requestRef.current = { id, controller };
946
- try {
947
- const [session, targetResponse] = await Promise.all([
948
- client.getBrowserSession(workspaceId, browserSessionId, {
949
- signal: controller.signal
950
- }),
951
- client.listBrowserTargets(workspaceId, browserSessionId, {
952
- signal: controller.signal
953
- })
954
- ]);
955
- if (!isCurrentSource() || requestRef.current.id !== id) return;
956
- const selected = chooseTarget(targetResponse.targets, selectedTargetIdRef.current);
957
- selectedTargetIdRef.current = selected?.id ?? null;
958
- selectedTargetRef.current = selected;
959
- const previousObservation = observationRef.current.browserSessionId === browserSessionId ? observationRef.current.observation : null;
960
- const retainedObservation = selected && previousObservation && sameObservationTarget(previousObservation, selected) ? previousObservation : null;
961
- observationRef.current = {
962
- browserSessionId,
963
- observation: retainedObservation
964
- };
965
- setState(
966
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? {
967
- ...current,
968
- session,
969
- targets: targetResponse.targets,
970
- selectedTargetId: selected?.id ?? null,
971
- observation: retainedObservation,
972
- loading: false,
973
- error: null,
974
- // Media and background polling cannot confirm an input outcome.
975
- // Only an explicit fresh check clears the notice it began with.
976
- inputFailure: checkInput && session.id === browserSessionId && targetResponse.browserSessionId === browserSessionId && current.inputFailure === checkedInputFailure ? null : current.inputFailure
977
- } : current
978
- );
979
- if (!selected || !observeSelectedTarget || !semanticObservationEnabledRef.current || refusedObservationPageRef.current === observedPageKey(selected))
980
- return;
981
- try {
982
- const observation = await client.observeBrowserTarget(
983
- workspaceId,
984
- browserSessionId,
985
- selected.id,
986
- { signal: controller.signal }
987
- );
988
- if (!isCurrentSource() || requestRef.current.id !== id) return;
989
- const currentSelected = selectedTargetRef.current;
990
- if (observationRef.current.browserSessionId !== browserSessionId || currentSelected?.id !== selected.id || observation.browserSessionId !== browserSessionId || observation.target.id !== selected.id || observation.target.controllerGeneration !== currentSelected.controllerGeneration || observation.target.targetGeneration !== currentSelected.targetGeneration)
991
- return;
992
- selectedTargetRef.current = observation.target;
993
- observationRef.current = { browserSessionId, observation };
994
- lastObservationAtRef.current = Date.now();
995
- setState(
996
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId && current.selectedTargetId === observation.target.id ? {
997
- ...current,
998
- observation,
999
- targets: replaceTarget(current.targets, observation.target)
1000
- } : current
1001
- );
1002
- } catch (cause) {
1003
- if (controller.signal.aborted || !isCurrentSource() || requestRef.current.id !== id)
1004
- return;
1005
- if (isFinalObservationRefusal(cause))
1006
- refusedObservationPageRef.current = observedPageKey(selected);
1007
- }
1008
- } catch (cause) {
1009
- if (controller.signal.aborted || !isCurrentSource() || requestRef.current.id !== id) return;
1010
- setState(
1011
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? {
1012
- ...current,
1013
- loading: false,
1014
- error: cause instanceof Error ? cause : new Error(String(cause))
1015
- } : current
1016
- );
1017
- } finally {
1018
- if (requestRef.current.id === id) {
1019
- requestRef.current = { id, controller: null };
1020
- }
1021
- }
1022
- },
1023
- [browserSessionId, client, enabled, isCurrentSource, source, workspaceId]
1024
- );
1025
- const refresh = useCallback5(async () => await refreshInventory(true), [refreshInventory]);
1026
- const refreshSemantic = useCallback5(async () => {
1027
- if (!enabled || !browserSessionId || !isCurrentSource()) return;
1028
- const target = selectedTargetRef.current;
1029
- if (!target || refusedObservationPageRef.current === observedPageKey(target)) return;
1030
- const id = requestRef.current.id + 1;
1031
- requestRef.current.controller?.abort();
1032
- const controller = new AbortController();
1033
- requestRef.current = { id, controller };
1034
- try {
1035
- const observation = await client.observeBrowserTarget(
1036
- workspaceId,
1037
- browserSessionId,
1038
- target.id,
1039
- { signal: controller.signal }
1040
- );
1041
- if (!isCurrentSource() || requestRef.current.id !== id) return;
1042
- if (!sameObservationTarget(observation, selectedTargetRef.current)) return;
1043
- observationRef.current = { browserSessionId, observation };
1044
- lastObservationAtRef.current = Date.now();
1045
- setState(
1046
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId && current.selectedTargetId === target.id ? { ...current, observation } : current
1047
- );
1048
- } catch (cause) {
1049
- if (isFinalObservationRefusal(cause) && requestRef.current.id === id)
1050
- refusedObservationPageRef.current = observedPageKey(target);
1051
- } finally {
1052
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
1053
- }
1054
- }, [browserSessionId, client, enabled, isCurrentSource, source, workspaceId]);
1055
- useEffect5(() => {
1056
- mountedRef.current = true;
1057
- if (!enabled) {
1058
- invalidateRefresh();
1059
- setState({ ...emptyState4(browserSessionId, false), source });
1060
- return;
1061
- }
1062
- setState(
1063
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? { ...current, loading: true } : { ...emptyState4(browserSessionId, true), source }
1064
- );
1065
- void refreshInventory();
1066
- return () => {
1067
- mountedRef.current = false;
1068
- invalidateRefresh();
1069
- };
1070
- }, [browserSessionId, enabled, invalidateRefresh, isCurrentSource, refreshInventory, source]);
1071
- useEffect5(() => {
1072
- const previous = previousSemanticObservationRef.current;
1073
- previousSemanticObservationRef.current = {
1074
- browserSessionId,
1075
- enabled: semanticObservationEnabled
1076
- };
1077
- if (enabled && semanticObservationEnabled && previous.browserSessionId === browserSessionId && !previous.enabled) {
1078
- const currentObservation = observationRef.current.observation;
1079
- if (currentObservation && sameObservationTarget(currentObservation, selectedTargetRef.current) && Date.now() - lastObservationAtRef.current < pollIntervalMs) {
1080
- return;
1081
- }
1082
- observationRef.current = { browserSessionId, observation: null };
1083
- setState(
1084
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? { ...current, observation: null } : current
1085
- );
1086
- void refreshSemantic();
1087
- }
1088
- }, [
1089
- browserSessionId,
1090
- enabled,
1091
- isCurrentSource,
1092
- pollIntervalMs,
1093
- refreshSemantic,
1094
- semanticObservationEnabled,
1095
- source
1096
- ]);
1097
- useEffect5(() => {
1098
- if (!enabled || !pageLive || visible.mutating || refreshBlocked) return;
1099
- const timer = setInterval(() => {
1100
- if (!requestRef.current.controller) void refreshInventory();
1101
- }, pollIntervalMs);
1102
- return () => clearInterval(timer);
1103
- }, [enabled, pageLive, pollIntervalMs, refreshInventory, refreshBlocked, visible.mutating]);
1104
- useEffect5(() => {
1105
- if (!enabled || !browserSessionId || !pageLive || refreshBlocked) return;
1106
- let disposed = false;
1107
- const heartbeat = () => {
1108
- if (!isCurrentSource()) return;
1109
- void client.heartbeatBrowserSession(workspaceId, browserSessionId).catch(() => {
1110
- if (!disposed) void refreshInventory();
1111
- });
1112
- };
1113
- const timer = setInterval(heartbeat, 3e4);
1114
- return () => {
1115
- disposed = true;
1116
- clearInterval(timer);
1117
- };
1118
- }, [
1119
- browserSessionId,
1120
- client,
1121
- enabled,
1122
- isCurrentSource,
1123
- pageLive,
1124
- refreshInventory,
1125
- refreshBlocked,
1126
- workspaceId
1127
- ]);
1128
- const runMutation = useCallback5(
1129
- async (scopeBrowserSessionId, operation, selectionRead = false, changesInventory = false) => {
1130
- if (!enabled || !isCurrentSource()) {
1131
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1132
- }
1133
- const selectionRevision = ++selectionRevisionRef.current;
1134
- invalidateRefresh();
1135
- const readRequestId = requestRef.current.id;
1136
- if (mutationRef.current.browserSessionId !== scopeBrowserSessionId || mutationRef.current.source !== source) {
1137
- mutationRef.current = {
1138
- browserSessionId: scopeBrowserSessionId,
1139
- source,
1140
- count: 0,
1141
- needsInventoryReconcile: false
1142
- };
1143
- }
1144
- mutationRef.current.count += 1;
1145
- setState(
1146
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === scopeBrowserSessionId ? { ...current, mutating: true, error: null } : current
1147
- );
1148
- try {
1149
- return await operation(selectionRevision, readRequestId);
1150
- } catch (cause) {
1151
- const error = cause instanceof Error ? cause : new Error(String(cause));
1152
- if (!selectionRead || requestRef.current.id === readRequestId) {
1153
- setState(
1154
- (current) => isCurrentSource() && selectionRevisionRef.current === selectionRevision && current.source === source && current.browserSessionId === scopeBrowserSessionId ? { ...current, error } : current
1155
- );
1156
- }
1157
- throw error;
1158
- } finally {
1159
- if (mutationRef.current.browserSessionId === scopeBrowserSessionId && mutationRef.current.source === source) {
1160
- if (changesInventory && (selectionRevisionRef.current !== selectionRevision || requestRef.current.id !== readRequestId)) {
1161
- mutationRef.current.needsInventoryReconcile = true;
1162
- }
1163
- mutationRef.current.count = Math.max(0, mutationRef.current.count - 1);
1164
- const mutating = mutationRef.current.count > 0;
1165
- setState(
1166
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === scopeBrowserSessionId ? { ...current, mutating } : current
1167
- );
1168
- if (!mutating && mutationRef.current.needsInventoryReconcile && isCurrentSource()) {
1169
- mutationRef.current.needsInventoryReconcile = false;
1170
- void refreshInventory(false, false);
1171
- }
1172
- }
1173
- }
1174
- },
1175
- [enabled, invalidateRefresh, isCurrentSource, refreshInventory, source, t]
1176
- );
1177
- const selectTarget = useCallback5(
1178
- async (targetId) => {
1179
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1180
- return await runMutation(
1181
- browserSessionId,
1182
- async (selectionRevision, readRequestId) => {
1183
- const isCurrentSelection = () => isCurrentSource() && selectionRevisionRef.current === selectionRevision;
1184
- const isCurrentSelectionRead = () => isCurrentSelection() && requestRef.current.id === readRequestId;
1185
- let targets = visible.targets;
1186
- let target;
1187
- let observation;
1188
- try {
1189
- observation = await client.selectBrowserTarget(workspaceId, browserSessionId, targetId);
1190
- target = observation.target;
1191
- } catch (cause) {
1192
- if (!isCurrentSelectionRead() || !isMissingBrowserTarget(cause)) throw cause;
1193
- const response = await client.listBrowserTargets(workspaceId, browserSessionId);
1194
- if (!isCurrentSelectionRead()) throw cause;
1195
- targets = response.targets;
1196
- const fallback = chooseTarget(targets, null);
1197
- if (!fallback) {
1198
- selectedTargetIdRef.current = null;
1199
- selectedTargetRef.current = null;
1200
- observationRef.current = { browserSessionId, observation: null };
1201
- setState(
1202
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1203
- ...current,
1204
- targets,
1205
- selectedTargetId: null,
1206
- observation: null
1207
- } : current
1208
- );
1209
- throw cause;
1210
- }
1211
- observation = await client.selectBrowserTarget(
1212
- workspaceId,
1213
- browserSessionId,
1214
- fallback.id
1215
- );
1216
- target = observation.target;
1217
- }
1218
- if (!isCurrentSelectionRead()) return target;
1219
- selectedTargetIdRef.current = target.id;
1220
- selectedTargetRef.current = target;
1221
- observationRef.current = { browserSessionId, observation };
1222
- lastObservationAtRef.current = Date.now();
1223
- setState(
1224
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1225
- ...current,
1226
- targets: replaceTarget(targets, target).map((candidate) => ({
1227
- ...candidate,
1228
- selected: candidate.id === target.id
1229
- })),
1230
- selectedTargetId: target.id,
1231
- observation
1232
- } : current
1233
- );
1234
- return target;
1235
- },
1236
- true
1237
- );
1238
- },
1239
- [browserSessionId, client, isCurrentSource, runMutation, source, visible.targets, workspaceId]
1240
- );
1241
- const openTarget = useCallback5(
1242
- async (url) => {
1243
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1244
- return await runMutation(
1245
- browserSessionId,
1246
- async (selectionRevision, readRequestId) => {
1247
- const isCurrentSelection = () => isCurrentSource() && selectionRevisionRef.current === selectionRevision;
1248
- const isCurrentSelectionRead = () => isCurrentSelection() && requestRef.current.id === readRequestId;
1249
- const observation = await client.openBrowserTarget(
1250
- workspaceId,
1251
- browserSessionId,
1252
- url === void 0 ? {} : { url }
1253
- );
1254
- const target = observation.target;
1255
- if (!isCurrentSource()) return target;
1256
- if (!isCurrentSelectionRead()) return target;
1257
- selectedTargetIdRef.current = target.id;
1258
- selectedTargetRef.current = target;
1259
- observationRef.current = { browserSessionId, observation };
1260
- lastObservationAtRef.current = Date.now();
1261
- setState(
1262
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1263
- ...current,
1264
- targets: [
1265
- ...current.targets.map((candidate) => ({
1266
- ...candidate,
1267
- selected: false
1268
- })),
1269
- target
1270
- ],
1271
- selectedTargetId: target.id,
1272
- observation
1273
- } : current
1274
- );
1275
- return target;
1276
- },
1277
- false,
1278
- true
1279
- );
1280
- },
1281
- [browserSessionId, client, isCurrentSource, runMutation, source, workspaceId]
1282
- );
1283
- const closeTarget = useCallback5(
1284
- async (targetId) => {
1285
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1286
- await runMutation(
1287
- browserSessionId,
1288
- async (selectionRevision, readRequestId) => {
1289
- const isCurrentSelection = () => isCurrentSource() && selectionRevisionRef.current === selectionRevision;
1290
- const isCurrentSelectionRead = () => isCurrentSelection() && requestRef.current.id === readRequestId;
1291
- const response = await client.closeBrowserTarget(workspaceId, browserSessionId, targetId);
1292
- if (!isCurrentSource()) return;
1293
- if (!isCurrentSelectionRead()) return;
1294
- const selected = chooseTarget(response.targets, selectedTargetIdRef.current);
1295
- const observed = selected ? await client.observeBrowserTarget(workspaceId, browserSessionId, selected.id) : null;
1296
- if (!isCurrentSource()) return;
1297
- if (!isCurrentSelectionRead()) return;
1298
- const observation = observed && selected && observed.browserSessionId === browserSessionId && observed.target.id === selected.id && observed.target.controllerGeneration === selected.controllerGeneration && observed.target.targetGeneration === selected.targetGeneration ? observed : null;
1299
- const currentTarget = observation?.target ?? selected;
1300
- selectedTargetIdRef.current = currentTarget?.id ?? null;
1301
- selectedTargetRef.current = currentTarget;
1302
- observationRef.current = { browserSessionId, observation };
1303
- if (observation) lastObservationAtRef.current = Date.now();
1304
- setState(
1305
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1306
- ...current,
1307
- targets: currentTarget ? replaceTarget(response.targets, currentTarget) : response.targets,
1308
- selectedTargetId: currentTarget?.id ?? null,
1309
- observation
1310
- } : current
1311
- );
1312
- },
1313
- false,
1314
- true
1315
- );
1316
- },
1317
- [browserSessionId, client, isCurrentSource, runMutation, source, workspaceId]
1318
- );
1319
- const dispatchAction = useCallback5(
1320
- async (action, operationId, frame, observationMode = "none") => {
1321
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1322
- if (!enabled || !isCurrentSource()) {
1323
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1324
- }
1325
- if (!selectedTargetRef.current) {
1326
- throw new Error("The browser page is not ready for input.");
1327
- }
1328
- if (frame && frame.browserSessionId !== browserSessionId) {
1329
- throw new Error("The displayed browser frame belongs to another BrowserSession.");
1330
- }
1331
- const currentObservation = observationRef.current.browserSessionId === browserSessionId ? observationRef.current.observation : null;
1332
- const fence = frame ? {
1333
- targetId: frame.targetId,
1334
- expectedTargetGeneration: frame.targetGeneration,
1335
- expectedDocumentGeneration: frame.documentGeneration,
1336
- expectedFrameId: frame.frameId
1337
- } : currentObservation && sameObservationTarget(currentObservation, selectedTargetRef.current) ? {
1338
- targetId: currentObservation.target.id,
1339
- expectedTargetGeneration: currentObservation.target.targetGeneration,
1340
- expectedDocumentGeneration: currentObservation.target.documentGeneration,
1341
- expectedFrameId: currentObservation.frameId
1342
- } : null;
1343
- if (!fence) {
1344
- throw new Error("The browser page is not ready for input.");
1345
- }
1346
- const expectedControllerGeneration = frame?.controllerGeneration ?? currentObservation.target.controllerGeneration;
1347
- const selectionRevision = selectionRevisionRef.current;
1348
- const resultOrder = ++actionResultOrderRef.current.next;
1349
- let resultDocumentGeneration = fence.expectedDocumentGeneration;
1350
- const isCurrentResultView = () => {
1351
- const selected = selectedTargetRef.current;
1352
- return isCurrentSource() && selectionRevisionRef.current === selectionRevision && selected?.browserSessionId === browserSessionId && selected.id === fence.targetId && selected.controllerGeneration === expectedControllerGeneration && selected.targetGeneration === fence.expectedTargetGeneration && (selected.documentGeneration === fence.expectedDocumentGeneration || selected.documentGeneration === resultDocumentGeneration);
1353
- };
1354
- const canProjectResult = () => isCurrentResultView() && resultOrder >= actionResultOrderRef.current.settled;
1355
- const settleResult = () => {
1356
- if (!canProjectResult()) return false;
1357
- actionResultOrderRef.current.settled = resultOrder;
1358
- invalidateRefresh();
1359
- return true;
1360
- };
1361
- try {
1362
- const receipt = await client.actInBrowser(workspaceId, browserSessionId, {
1363
- operationId,
1364
- ...fence,
1365
- observationMode,
1366
- action
1367
- });
1368
- resultDocumentGeneration = receipt.observation?.target.documentGeneration ?? fence.expectedDocumentGeneration;
1369
- const settled = receipt.state === "completed" || receipt.state === "failed" || receipt.state === "outcome_unknown";
1370
- if (!canProjectResult() || settled && !settleResult()) return receipt;
1371
- const receivedObservation = receipt.observation;
1372
- const selectedTarget = selectedTargetRef.current;
1373
- let projectedObservation = null;
1374
- if (settled && receivedObservation && canProjectResult() && receipt.browserSessionId === browserSessionId && receipt.controllerGeneration === expectedControllerGeneration && receipt.targetId === fence.targetId && observationRef.current.browserSessionId === browserSessionId && receivedObservation.browserSessionId === browserSessionId && selectedTarget?.browserSessionId === browserSessionId && selectedTarget.id === fence.targetId && receivedObservation.target.id === fence.targetId && selectedTarget.controllerGeneration === expectedControllerGeneration && receivedObservation.target.controllerGeneration === expectedControllerGeneration && selectedTarget.targetGeneration === fence.expectedTargetGeneration && receivedObservation.target.targetGeneration === fence.expectedTargetGeneration && (selectedTarget.documentGeneration === fence.expectedDocumentGeneration || selectedTarget.documentGeneration === receivedObservation.target.documentGeneration)) {
1375
- projectedObservation = receivedObservation;
1376
- observationRef.current = {
1377
- browserSessionId,
1378
- observation: receivedObservation
1379
- };
1380
- selectedTargetRef.current = receivedObservation.target;
1381
- lastObservationAtRef.current = Date.now();
1382
- }
1383
- setState(
1384
- (current) => isCurrentResultView() && current.source === source && current.browserSessionId === browserSessionId && current.actionResultOrder <= resultOrder ? {
1385
- ...current,
1386
- actionResultOrder: settled ? resultOrder : current.actionResultOrder,
1387
- error: receipt.state === "completed" ? null : current.error,
1388
- inputFailure: receipt.state === "completed" ? current.inputFailure : {
1389
- operationId: receipt.operationId,
1390
- state: receipt.state,
1391
- error: receipt.error
1392
- },
1393
- ...projectedObservation ? {
1394
- observation: projectedObservation,
1395
- targets: replaceTarget(current.targets, projectedObservation.target)
1396
- } : {}
1397
- } : current
1398
- );
1399
- return receipt;
1400
- } catch (cause) {
1401
- const error = cause instanceof Error ? cause : new Error(String(cause));
1402
- if (settleResult()) {
1403
- setState(
1404
- (current) => isCurrentResultView() && current.source === source && current.browserSessionId === browserSessionId && current.actionResultOrder <= resultOrder ? { ...current, error, actionResultOrder: resultOrder } : current
1405
- );
1406
- }
1407
- throw error;
1408
- }
1409
- },
1410
- [browserSessionId, client, enabled, invalidateRefresh, isCurrentSource, source, workspaceId, t]
1411
- );
1412
- const act = useCallback5(
1413
- async (action, operationId = crypto.randomUUID()) => await dispatchAction(action, operationId, null),
1414
- [dispatchAction]
1415
- );
1416
- const actFromFrame = useCallback5(
1417
- async (action, frame, operationId = crypto.randomUUID(), observationMode = "none") => await dispatchAction(action, operationId, frame, observationMode),
1418
- [dispatchAction]
1419
- );
1420
- const observeForInput = useCallback5(async () => {
1421
- const target = selectedTargetRef.current;
1422
- if (!enabled || !isCurrentSource()) {
1423
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1424
- }
1425
- if (!browserSessionId || !target)
1426
- throw new Error(t("hooks.useBrowserSession.noBrowserTabIsSelected"));
1427
- const observation = await client.observeBrowserTarget(workspaceId, browserSessionId, target.id);
1428
- if (!isCurrentSource() || observation.browserSessionId !== browserSessionId || !sameObservationTarget(observation, selectedTargetRef.current)) {
1429
- throw new Error(t("hooks.useBrowserSession.theBrowserPageChangedOpen"));
1430
- }
1431
- refusedObservationPageRef.current = null;
1432
- return observation;
1433
- }, [browserSessionId, client, enabled, isCurrentSource, workspaceId, t]);
1434
- const actFromObservation = useCallback5(
1435
- async (action, observation) => {
1436
- if (!sameObservationTarget(observation, selectedTargetRef.current)) {
1437
- throw new Error(t("hooks.useBrowserSession.theBrowserPageChangedOpen"));
1438
- }
1439
- return await dispatchAction(action, crypto.randomUUID(), {
1440
- browserSessionId: observation.browserSessionId,
1441
- controllerGeneration: observation.target.controllerGeneration,
1442
- targetId: observation.target.id,
1443
- targetGeneration: observation.target.targetGeneration,
1444
- documentGeneration: observation.target.documentGeneration,
1445
- frameId: observation.frameId
1446
- });
1447
- },
1448
- [dispatchAction, t]
1449
- );
1450
- const diagnostics = useCallback5(
1451
- async (diagnosticOptions = {}) => {
1452
- if (!enabled || !isCurrentSource()) {
1453
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1454
- }
1455
- const targetId = selectedTargetIdRef.current;
1456
- if (!browserSessionId || !targetId) {
1457
- throw new Error(t("hooks.useBrowserSession.noBrowserTabIsSelected"));
1458
- }
1459
- return await client.listBrowserDiagnostics(
1460
- workspaceId,
1461
- browserSessionId,
1462
- targetId,
1463
- diagnosticOptions
1464
- );
1465
- },
1466
- [browserSessionId, client, enabled, isCurrentSource, workspaceId, t]
1467
- );
1468
- const readClipboard = useCallback5(async () => {
1469
- if (!enabled || !isCurrentSource()) {
1470
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1471
- }
1472
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1473
- const clipboard = await client.readBrowserClipboard(workspaceId, browserSessionId);
1474
- if (!isCurrentSource() || clipboard.browserSessionId !== browserSessionId) {
1475
- throw new Error("Browser clipboard belongs to another BrowserSession.");
1476
- }
1477
- return clipboard;
1478
- }, [browserSessionId, client, enabled, isCurrentSource, workspaceId, t]);
1479
- return {
1480
- session: visible.session,
1481
- targets: visible.targets,
1482
- selectedTarget: visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null,
1483
- observation: visible.observation,
1484
- loading: visible.loading,
1485
- mutating: visible.mutating,
1486
- error: visible.error,
1487
- inputFailure: visible.inputFailure,
1488
- refresh,
1489
- observeForInput,
1490
- actFromObservation,
1491
- selectTarget,
1492
- openTarget,
1493
- closeTarget,
1494
- act,
1495
- actFromFrame,
1496
- readClipboard,
1497
- diagnostics
1498
- };
1499
- }
1500
- function emptyState4(browserSessionId, loading) {
1501
- return {
1502
- browserSessionId,
1503
- session: null,
1504
- targets: [],
1505
- selectedTargetId: null,
1506
- observation: null,
1507
- loading,
1508
- mutating: false,
1509
- error: null,
1510
- inputFailure: null,
1511
- actionResultOrder: 0
1512
- };
1513
- }
1514
- function chooseTarget(targets, preferredId) {
1515
- return targets.find((target) => target.id === preferredId) ?? targets.find((target) => target.selected && target.kind === "page") ?? targets.find((target) => target.kind === "page") ?? targets[0] ?? null;
1516
- }
1517
- function replaceTarget(targets, target) {
1518
- const next = targets.filter((candidate) => candidate.id !== target.id);
1519
- next.push(target);
1520
- return next.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
1521
- }
1522
- function sameObservationTarget(observation, target) {
1523
- return target !== null && observation.browserSessionId === target.browserSessionId && observation.target.id === target.id && observation.target.controllerGeneration === target.controllerGeneration && observation.target.targetGeneration === target.targetGeneration && observation.target.documentGeneration === target.documentGeneration;
1524
- }
1525
- function isMissingBrowserTarget(error) {
1526
- return error instanceof OpenGeniApiError && error.code === "target_not_found";
1527
- }
1528
- function observedPageKey(target) {
1529
- return JSON.stringify([
1530
- target.browserSessionId,
1531
- target.id,
1532
- target.controllerGeneration,
1533
- target.targetGeneration,
1534
- target.documentGeneration,
1535
- target.url
1536
- ]);
1537
- }
1538
- function isFinalObservationRefusal(error) {
1539
- return isNonRetryableInteractionError(error) && error.status >= 400 && error.status < 500;
1540
- }
1541
-
1542
- // src/hooks/use-browser-sessions.ts
1543
- import { useCallback as useCallback6, useEffect as useEffect6, useMemo, useRef as useRef6, useState as useState6 } from "react";
1544
- function useBrowserSessions(options = {}) {
1545
- const {
1546
- client,
1547
- workspaceId,
1548
- registerSessionReconciler,
1549
- workspaceInteractionEvent,
1550
- workspaceInteractionConnectionState
1551
- } = useEmbeddedBrowserInteraction(options);
1552
- const enabled = options.enabled ?? true;
1553
- const [state, setState] = useState6(() => emptyState5(workspaceId, enabled));
1554
- const requestRef = useRef6({
1555
- id: 0,
1556
- controller: null
1557
- });
1558
- const loadQueueRef = useRef6(null);
1559
- const mountedRef = useRef6(true);
1560
- const visibleState = state.workspaceId === workspaceId ? state : emptyState5(workspaceId, enabled);
1561
- const cancelLoad = useCallback6(() => {
1562
- loadQueueRef.current = null;
1563
- const id = requestRef.current.id + 1;
1564
- requestRef.current.controller?.abort();
1565
- requestRef.current = { id, controller: null };
1566
- }, []);
1567
- const loadOnce = useCallback6(
1568
- async (foreground) => {
1569
- if (!enabled) return;
1570
- const id = requestRef.current.id + 1;
1571
- requestRef.current.controller?.abort();
1572
- const controller = new AbortController();
1573
- requestRef.current = { id, controller };
1574
- setState((current) => ({
1575
- ...current.workspaceId === workspaceId ? current : emptyState5(workspaceId, true),
1576
- active: true,
1577
- loading: foreground,
1578
- refreshing: !foreground,
1579
- error: foreground || current.workspaceId !== workspaceId ? null : current.error
1580
- }));
1581
- try {
1582
- const response = await client.listBrowserSessions(workspaceId, {
1583
- signal: controller.signal
1584
- });
1585
- if (!mountedRef.current || requestRef.current.id !== id) return;
1586
- setState({
1587
- workspaceId,
1588
- active: true,
1589
- revision: response.revision,
1590
- sessions: sortBrowserSessions(response.sessions),
1591
- loading: false,
1592
- refreshing: false,
1593
- error: null
1594
- });
1595
- } catch (cause) {
1596
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
1597
- return;
1598
- const error = cause instanceof Error ? cause : new Error(String(cause));
1599
- setState((current) => ({
1600
- ...current.workspaceId === workspaceId ? current : emptyState5(workspaceId, true),
1601
- loading: false,
1602
- refreshing: false,
1603
- error
1604
- }));
1605
- } finally {
1606
- if (requestRef.current.id === id) {
1607
- requestRef.current = { id, controller: null };
1608
- }
1609
- }
1610
- },
1611
- [client, enabled, workspaceId]
1612
- );
1613
- const load = useCallback6(
1614
- (foreground) => {
1615
- const current = loadQueueRef.current;
1616
- if (current) {
1617
- current.pending = true;
1618
- return current.promise;
1619
- }
1620
- const queue = { pending: false, promise: Promise.resolve() };
1621
- loadQueueRef.current = queue;
1622
- queue.promise = Promise.resolve().then(async () => {
1623
- while (loadQueueRef.current === queue) {
1624
- queue.pending = false;
1625
- await loadOnce(foreground);
1626
- foreground = false;
1627
- if (!queue.pending) break;
1628
- }
1629
- if (loadQueueRef.current === queue) loadQueueRef.current = null;
1630
- }).finally(() => {
1631
- if (loadQueueRef.current === queue) loadQueueRef.current = null;
1632
- });
1633
- return queue.promise;
1634
- },
1635
- [loadOnce]
1636
- );
1637
- const refresh = useCallback6(async () => await load(false), [load]);
1638
- useEffect6(() => {
1639
- mountedRef.current = true;
1640
- if (!enabled) {
1641
- cancelLoad();
1642
- setState(emptyState5(workspaceId, false));
1643
- return;
1644
- }
1645
- void load(true);
1646
- return () => {
1647
- mountedRef.current = false;
1648
- cancelLoad();
1649
- };
1650
- }, [cancelLoad, enabled, load, workspaceId]);
1651
- useInteractionInvalidation({
1652
- workspaceId,
1653
- key: workspaceId,
1654
- enabled,
1655
- event: workspaceInteractionEvent,
1656
- connectionState: workspaceInteractionConnectionState,
1657
- knownRevision: visibleState.revision,
1658
- refresh,
1659
- fallbackPollIntervalMs: options.pollIntervalMs
1660
- });
1661
- useEffect6(() => {
1662
- if (!enabled || !options.sessionId) return;
1663
- return registerSessionReconciler(options.sessionId, `browser-sessions:${workspaceId}`, refresh);
1664
- }, [enabled, options.sessionId, refresh, registerSessionReconciler, workspaceId]);
1665
- const create = useCallback6(
1666
- async (request) => {
1667
- const response = await client.createBrowserSession(workspaceId, {
1668
- ...request,
1669
- operationId: request.operationId ?? crypto.randomUUID()
1670
- });
1671
- setState((current) => mergeSession(current, workspaceId, response.session));
1672
- return response;
1673
- },
1674
- [client, workspaceId]
1675
- );
1676
- const end = useCallback6(
1677
- async (browserSessionId, operationId = crypto.randomUUID()) => {
1678
- const response = await client.endBrowserSession(workspaceId, browserSessionId, {
1679
- operationId
1680
- });
1681
- setState((current) => mergeSession(current, workspaceId, response.session));
1682
- return response;
1683
- },
1684
- [client, workspaceId]
1685
- );
1686
- const suspend = useCallback6(
1687
- async (browserSessionId, operationId = crypto.randomUUID()) => {
1688
- const response = await client.suspendBrowserSession(workspaceId, browserSessionId, {
1689
- operationId
1690
- });
1691
- setState((current) => mergeSession(current, workspaceId, response.session));
1692
- return response;
1693
- },
1694
- [client, workspaceId]
1695
- );
1696
- const resume = useCallback6(
1697
- async (browserSessionId, operationId = crypto.randomUUID()) => {
1698
- const response = await client.resumeBrowserSession(workspaceId, browserSessionId, {
1699
- operationId
1700
- });
1701
- setState((current) => mergeSession(current, workspaceId, response.session));
1702
- return response;
1703
- },
1704
- [client, workspaceId]
1705
- );
1706
- const relevantSessions = useMemo(
1707
- () => options.sessionId ? visibleState.sessions.filter(
1708
- (session) => session.associations.some((association) => association.sessionId === options.sessionId)
1709
- ) : [],
1710
- [options.sessionId, visibleState.sessions]
1711
- );
1712
- return {
1713
- revision: visibleState.revision,
1714
- sessions: visibleState.sessions,
1715
- relevantSessions,
1716
- // A disabled registry is deliberately empty. Expose the first re-enabled
1717
- // render as loading so consumers do not reconcile against that empty gap.
1718
- loading: enabled ? !visibleState.active || visibleState.loading : false,
1719
- refreshing: visibleState.refreshing,
1720
- error: visibleState.error,
1721
- refresh,
1722
- create,
1723
- suspend,
1724
- resume,
1725
- end
1726
- };
1727
- }
1728
- function emptyState5(workspaceId, loading) {
1729
- return {
1730
- workspaceId,
1731
- active: false,
1732
- revision: 0,
1733
- sessions: [],
1734
- loading,
1735
- refreshing: false,
1736
- error: null
1737
- };
1738
- }
1739
- function sortBrowserSessions(sessions) {
1740
- return [...sessions].sort((left, right) => {
1741
- const live = Number(isLiveBrowser(right)) - Number(isLiveBrowser(left));
1742
- return live || timestamp3(right.lastUsedAt) - timestamp3(left.lastUsedAt) || left.id.localeCompare(right.id);
1743
- });
1744
- }
1745
- function isLiveBrowser(session) {
1746
- return !["ending", "ended", "failed", "lost"].includes(session.lifecycle);
1747
- }
1748
- function timestamp3(value) {
1749
- const parsed = Date.parse(value);
1750
- return Number.isFinite(parsed) ? parsed : 0;
1751
- }
1752
- function mergeSession(current, workspaceId, session) {
1753
- if (current.workspaceId !== workspaceId) return current;
1754
- const sessions = current.sessions.filter((candidate) => candidate.id !== session.id);
1755
- sessions.push(session);
1756
- return { ...current, sessions: sortBrowserSessions(sessions), error: null };
1757
- }
1758
-
1759
- // src/hooks/use-site-auth-connections.ts
1760
- import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef7, useState as useState7 } from "react";
1761
- function useSiteAuthConnections(options = {}) {
1762
- const { client, workspaceId, workspaceInteractionEvent, workspaceInteractionConnectionState } = useEmbeddedBrowserInteraction(options);
1763
- const enabled = options.enabled ?? true;
1764
- const includeArchived = options.includeArchived ?? false;
1765
- const key = `${workspaceId}:${includeArchived ? "all" : "active"}`;
1766
- const [state, setState] = useState7(() => emptyState6(key, enabled));
1767
- const [mutationCount, setMutationCount] = useState7(0);
1768
- const requestRef = useRef7({
1769
- id: 0,
1770
- controller: null
1771
- });
1772
- const mountedRef = useRef7(true);
1773
- const visible = state.key === key ? state : emptyState6(key, enabled);
1774
- const cancelLoad = useCallback7(() => {
1775
- requestRef.current.controller?.abort();
1776
- requestRef.current = { id: requestRef.current.id + 1, controller: null };
1777
- }, []);
1778
- const load = useCallback7(
1779
- async (foreground) => {
1780
- if (!enabled) return;
1781
- const id = requestRef.current.id + 1;
1782
- requestRef.current.controller?.abort();
1783
- const controller = new AbortController();
1784
- requestRef.current = { id, controller };
1785
- setState((current) => ({
1786
- ...current.key === key ? current : emptyState6(key, true),
1787
- loading: foreground,
1788
- refreshing: !foreground,
1789
- error: foreground || current.key !== key ? null : current.error
1790
- }));
1791
- try {
1792
- const response = await client.listSiteAuthConnections(workspaceId, {
1793
- includeArchived,
1794
- signal: controller.signal
1795
- });
1796
- if (!mountedRef.current || requestRef.current.id !== id) return;
1797
- setState({
1798
- key,
1799
- revision: response.revision,
1800
- connections: sortConnections(response.connections),
1801
- loading: false,
1802
- refreshing: false,
1803
- error: null
1804
- });
1805
- } catch (cause) {
1806
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
1807
- return;
1808
- setState((current) => ({
1809
- ...current.key === key ? current : emptyState6(key, true),
1810
- loading: false,
1811
- refreshing: false,
1812
- error: asError2(cause)
1813
- }));
1814
- } finally {
1815
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
1816
- }
1817
- },
1818
- [client, enabled, includeArchived, key, workspaceId]
1819
- );
1820
- const refresh = useCallback7(async () => await load(false), [load]);
1821
- useEffect7(() => {
1822
- mountedRef.current = true;
1823
- if (!enabled) {
1824
- cancelLoad();
1825
- setState(emptyState6(key, false));
1826
- return;
1827
- }
1828
- void load(true);
1829
- return () => {
1830
- mountedRef.current = false;
1831
- cancelLoad();
1832
- };
1833
- }, [cancelLoad, enabled, key, load]);
1834
- useInteractionInvalidation({
1835
- workspaceId,
1836
- key,
1837
- enabled,
1838
- event: workspaceInteractionEvent,
1839
- connectionState: workspaceInteractionConnectionState,
1840
- knownRevision: visible.revision,
1841
- refresh
1842
- });
1843
- const mutate = useCallback7(async (operation) => {
1844
- setMutationCount((count) => count + 1);
1845
- try {
1846
- return await operation();
1847
- } finally {
1848
- if (mountedRef.current) setMutationCount((count) => Math.max(0, count - 1));
1849
- }
1850
- }, []);
1851
- const merge = useCallback7(
1852
- (connection) => {
1853
- setState((current) => {
1854
- if (current.key !== key) return current;
1855
- const connections = current.connections.filter(
1856
- (candidate) => candidate.id !== connection.id
1857
- );
1858
- if (includeArchived || connection.status !== "archived") connections.push(connection);
1859
- return { ...current, connections: sortConnections(connections), error: null };
1860
- });
1861
- },
1862
- [includeArchived, key]
1863
- );
1864
- const create = useCallback7(
1865
- async (request) => await mutate(async () => {
1866
- const response = await client.createSiteAuthConnection(workspaceId, {
1867
- ...request,
1868
- operationId: request.operationId ?? crypto.randomUUID()
1869
- });
1870
- merge(response.connection);
1871
- return response;
1872
- }),
1873
- [client, merge, mutate, workspaceId]
1874
- );
1875
- const update = useCallback7(
1876
- async (connectionId, request) => await mutate(async () => {
1877
- const response = await client.updateSiteAuthConnection(workspaceId, connectionId, {
1878
- ...request,
1879
- operationId: request.operationId ?? crypto.randomUUID()
1880
- });
1881
- merge(response.connection);
1882
- return response;
1883
- }),
1884
- [client, merge, mutate, workspaceId]
1885
- );
1886
- return {
1887
- revision: visible.revision,
1888
- connections: visible.connections,
1889
- loading: visible.loading,
1890
- refreshing: visible.refreshing,
1891
- mutating: mutationCount > 0,
1892
- error: visible.error,
1893
- refresh,
1894
- create,
1895
- update
1896
- };
1897
- }
1898
- function emptyState6(key, loading) {
1899
- return {
1900
- key,
1901
- revision: 0,
1902
- connections: [],
1903
- loading,
1904
- refreshing: false,
1905
- error: null
1906
- };
1907
- }
1908
- function sortConnections(connections) {
1909
- return [...connections].sort(
1910
- (left, right) => Number(left.status === "archived") - Number(right.status === "archived") || left.name.localeCompare(right.name) || left.accountLabel.localeCompare(right.accountLabel)
1911
- );
1912
- }
1913
- function asError2(cause) {
1914
- return cause instanceof Error ? cause : new Error(String(cause));
1915
- }
1916
-
1917
- // src/components/browser-input.ts
1918
- var HUMAN_BROWSER_HOME_URL = "https://www.google.com/";
1919
- var HUMAN_BROWSER_SEARCH_URL = "https://www.google.com/search?q=";
1920
- function normalizeBrowserAddress(value) {
1921
- const trimmed = value.trim();
1922
- if (!trimmed) return null;
1923
- if (/^(?:https?|about):/iu.test(trimmed)) {
1924
- try {
1925
- const url = new URL(trimmed);
1926
- return ["http:", "https:", "about:"].includes(url.protocol) ? url.href : null;
1927
- } catch {
1928
- return `${HUMAN_BROWSER_SEARCH_URL}${encodeURIComponent(trimmed)}`;
1929
- }
1930
- }
1931
- const isLocal = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])(?::\d+)?(?:[/?#]|$)/iu.test(trimmed);
1932
- const looksLikeHost = !/\s/u.test(trimmed) && (isLocal || /^(?:[^./\s]+\.)+[^./\s]+(?::\d+)?(?:[/?#]|$)/u.test(trimmed));
1933
- if (!looksLikeHost) return `${HUMAN_BROWSER_SEARCH_URL}${encodeURIComponent(trimmed)}`;
1934
- try {
1935
- return new URL(`${isLocal ? "http" : "https"}://${trimmed}`).href;
1936
- } catch {
1937
- return `${HUMAN_BROWSER_SEARCH_URL}${encodeURIComponent(trimmed)}`;
1938
- }
1939
- }
1940
- function browserKey(event, hostPlatform = interactionHostPlatform()) {
1941
- if (["Alt", "AltGraph", "Control", "Meta", "Shift"].includes(event.key)) return null;
1942
- const special = /* @__PURE__ */ new Set([
1943
- "Enter",
1944
- "Tab",
1945
- "Escape",
1946
- "Backspace",
1947
- "Delete",
1948
- "ArrowUp",
1949
- "ArrowDown",
1950
- "ArrowLeft",
1951
- "ArrowRight"
1952
- ]);
1953
- const modified = event.altKey || event.ctrlKey || event.metaKey;
1954
- if (!modified && !special.has(event.key)) return null;
1955
- const parts = [];
1956
- if (event.ctrlKey) parts.push(hostPlatform === "mac" ? "Control" : "Mod");
1957
- if (event.altKey) parts.push("Alt");
1958
- if (event.metaKey) parts.push(hostPlatform === "mac" ? "Mod" : "Meta");
1959
- if (event.shiftKey) parts.push("Shift");
1960
- parts.push(event.key === " " ? "Space" : event.key);
1961
- return parts.join("+");
1962
- }
1963
-
1964
- // src/components/browser-select-control.tsx
1965
- import { useEffect as useEffect8, useLayoutEffect, useRef as useRef8, useState as useState8 } from "react";
1966
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1967
- function focusedSelect(observation) {
1968
- if (observation.semantic?.kind !== "snapshot") return null;
1969
- const pending = [...observation.semantic.roots];
1970
- while (pending.length) {
1971
- const node = pending.pop();
1972
- if (node.children) pending.push(...node.children);
1973
- if (node.ref !== observation.focusedRef || !node.actions.includes("select") || node.native?.platform !== "dom")
1974
- continue;
1975
- const data = node.native.data;
1976
- if (!data || data.kind !== "native-select" || typeof data.multiple !== "boolean" || typeof data.disabled !== "boolean" || !Array.isArray(data.options) || data.options.length > 200)
1977
- return null;
1978
- if (data.options.some(
1979
- (option) => !option || typeof option.value !== "string" || typeof option.label !== "string" || typeof option.selected !== "boolean" || typeof option.disabled !== "boolean"
1980
- ))
1981
- return null;
1982
- return { node, control: data };
1983
- }
1984
- return null;
1985
- }
1986
- function BrowserSelectControl(props) {
1987
- const t = useOpenGeniText();
1988
- const [snapshot, setSnapshot] = useState8(null);
1989
- const [open, setOpen] = useState8(false);
1990
- const [busy, setBusy] = useState8(false);
1991
- const [error, setError] = useState8(null);
1992
- const [values, setValues] = useState8([]);
1993
- const [anchor, setAnchor] = useState8(null);
1994
- const popupRef = useRef8(null);
1995
- const [position, setPosition] = useState8(null);
1996
- const panelRef = useRef8(null);
1997
- const request = useRef8(0);
1998
- const optionKeys = useRef8(/* @__PURE__ */ new WeakMap());
1999
- const nextOptionKey = useRef8(0);
2000
- const optionKey = (option) => {
2001
- let key = optionKeys.current.get(option);
2002
- if (key === void 0) {
2003
- key = ++nextOptionKey.current;
2004
- optionKeys.current.set(option, key);
2005
- }
2006
- return key;
2007
- };
2008
- useEffect8(
2009
- () => () => {
2010
- request.current += 1;
2011
- },
2012
- []
2013
- );
2014
- useEffect8(() => {
2015
- if (props.activation === void 0) return;
2016
- ++request.current;
2017
- const observation = props.activation?.observation;
2018
- const selected2 = observation ? focusedSelect(observation) : null;
2019
- setSnapshot(selected2 && observation ? observation : null);
2020
- setAnchor(selected2 ? props.activation.anchor : null);
2021
- setOpen(Boolean(selected2));
2022
- setBusy(false);
2023
- setError(null);
2024
- setValues(
2025
- selected2?.control.options.filter((option) => option.selected).map((option) => option.value) ?? []
2026
- );
2027
- }, [props.activation]);
2028
- useEffect8(() => {
2029
- if (open && !busy) panelRef.current?.focus({ preventScroll: true });
2030
- }, [open, busy]);
2031
- useLayoutEffect(() => {
2032
- if (!anchor || !open) {
2033
- setPosition(null);
2034
- return;
2035
- }
2036
- const place = () => {
2037
- const popup = popupRef.current;
2038
- const parent = popup?.parentElement;
2039
- if (!popup || !parent) return;
2040
- setPosition({
2041
- x: Math.max(12, Math.min(anchor.x, parent.clientWidth - popup.offsetWidth - 12)),
2042
- y: Math.max(12, Math.min(anchor.y, parent.clientHeight - popup.offsetHeight - 12)),
2043
- height: Math.max(48, parent.clientHeight - 60)
2044
- });
2045
- };
2046
- place();
2047
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
2048
- if (popupRef.current?.parentElement) observer?.observe(popupRef.current.parentElement);
2049
- if (popupRef.current) observer?.observe(popupRef.current);
2050
- return () => observer?.disconnect();
2051
- }, [anchor, open, busy, snapshot, error]);
2052
- const selected = snapshot ? focusedSelect(snapshot) : null;
2053
- const ambiguousValue = (value) => (selected?.control.options.filter((option) => option.value === value || option.label === value).length ?? 0) !== 1;
2054
- const load = async () => {
2055
- const current = ++request.current;
2056
- setOpen(true);
2057
- setBusy(true);
2058
- setSnapshot(null);
2059
- setError(null);
2060
- setAnchor(null);
2061
- try {
2062
- const observation = await props.observe();
2063
- if (current !== request.current) return;
2064
- setSnapshot(observation);
2065
- setValues(
2066
- focusedSelect(observation)?.control.options.filter((option) => option.selected).map((option) => option.value) ?? []
2067
- );
2068
- } catch (cause) {
2069
- if (current === request.current)
2070
- setError(
2071
- cause instanceof Error ? cause.message : t("browserSelectControl.couldNotReadOptions")
2072
- );
2073
- } finally {
2074
- if (current === request.current) setBusy(false);
2075
- }
2076
- };
2077
- const apply = async (next) => {
2078
- if (!snapshot || !selected || busy) return;
2079
- const current = ++request.current;
2080
- setBusy(true);
2081
- setError(null);
2082
- try {
2083
- const receipt = await props.act(
2084
- { type: "select", locator: { kind: "ref", ref: selected.node.ref }, values: next },
2085
- snapshot
2086
- );
2087
- if (receipt.state !== "completed")
2088
- throw new Error(
2089
- receipt.error?.message ?? t("browserSelectControl.selectionDidNotComplete")
2090
- );
2091
- if (current === request.current) {
2092
- setOpen(false);
2093
- setSnapshot(null);
2094
- props.onDismiss?.();
2095
- }
2096
- } catch (cause) {
2097
- if (current === request.current) {
2098
- setError(
2099
- cause instanceof Error ? cause.message : t("browserSelectControl.selectionFailedReadTheOptions")
2100
- );
2101
- setSnapshot(null);
2102
- }
2103
- } finally {
2104
- if (current === request.current) setBusy(false);
2105
- }
2106
- };
2107
- if (props.manualFallback === false && !open) return null;
2108
- return /* @__PURE__ */ jsxs(
2109
- "div",
2110
- {
2111
- ref: popupRef,
2112
- className: "absolute z-10 max-w-[calc(100%-1.5rem)] text-og-control",
2113
- style: anchor && open ? {
2114
- left: position?.x ?? anchor.x,
2115
- top: position?.y ?? anchor.y
2116
- } : { bottom: 12, left: 12 },
2117
- children: [
2118
- props.manualFallback !== false && (!anchor || !open) || error ? /* @__PURE__ */ jsx(
2119
- "button",
2120
- {
2121
- type: "button",
2122
- className: "rounded-og-sm border border-og-border bg-og-bg px-2 py-1 text-og-fg",
2123
- disabled: busy,
2124
- onClick: () => void load(),
2125
- "aria-expanded": open,
2126
- children: t("browserSelectControl.chooseOption")
2127
- }
2128
- ) : null,
2129
- open ? /* @__PURE__ */ jsxs(
2130
- "section",
2131
- {
2132
- ref: panelRef,
2133
- tabIndex: -1,
2134
- "aria-label": t("browserSelectControl.pageSelectionOptions"),
2135
- style: position ? { maxHeight: Math.min(288, position.height) } : void 0,
2136
- onKeyDown: (event) => {
2137
- if (event.key !== "Escape") return;
2138
- event.preventDefault();
2139
- event.stopPropagation();
2140
- ++request.current;
2141
- setOpen(false);
2142
- setSnapshot(null);
2143
- setBusy(false);
2144
- props.onDismiss?.();
2145
- },
2146
- className: "mt-1 max-h-72 w-72 max-w-full overflow-auto rounded-og-sm border border-og-border bg-og-bg p-3 text-og-fg shadow-lg",
2147
- children: [
2148
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
2149
- /* @__PURE__ */ jsx("strong", { children: selected?.node.name || t("browserSelectControl.pageOptions") }),
2150
- /* @__PURE__ */ jsx(
2151
- "button",
2152
- {
2153
- type: "button",
2154
- disabled: busy,
2155
- onClick: () => {
2156
- ++request.current;
2157
- setOpen(false);
2158
- setSnapshot(null);
2159
- props.onDismiss?.();
2160
- },
2161
- "aria-label": t("browserSelectControl.closePageOptions"),
2162
- children: t("browserSelectControl.close")
2163
- }
2164
- )
2165
- ] }),
2166
- busy ? /* @__PURE__ */ jsx("p", { role: "status", children: t("browserSelectControl.loading") }) : error ? /* @__PURE__ */ jsx("p", { role: "alert", children: error }) : !selected ? /* @__PURE__ */ jsx("p", { children: t("browserSelectControl.clickADropdownInThe") }) : selected.control.disabled ? /* @__PURE__ */ jsx("p", { children: t("browserSelectControl.thisControlIsDisabled") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2167
- selected.control.options.map((option) => {
2168
- const ambiguous = ambiguousValue(option.value);
2169
- const disabled = busy || option.disabled || ambiguous;
2170
- return selected.control.multiple ? /* @__PURE__ */ jsxs("label", { className: "my-1 flex items-center gap-2", children: [
2171
- /* @__PURE__ */ jsx(
2172
- "input",
2173
- {
2174
- type: "checkbox",
2175
- disabled,
2176
- checked: values.includes(option.value),
2177
- onChange: (event) => setValues(
2178
- event.target.checked ? [...values, option.value] : values.filter((value) => value !== option.value)
2179
- )
2180
- }
2181
- ),
2182
- option.label || t("browserSelectControl.empty"),
2183
- ambiguous ? ` ${t("browserSelectControl.ambiguousValue")}` : ""
2184
- ] }, optionKey(option)) : /* @__PURE__ */ jsxs(
2185
- "button",
2186
- {
2187
- type: "button",
2188
- disabled,
2189
- "aria-pressed": option.selected,
2190
- className: "my-1 block w-full rounded-og-sm border border-og-border px-2 py-1 text-left disabled:opacity-50",
2191
- onClick: () => void apply([option.value]),
2192
- children: [
2193
- option.label || t("browserSelectControl.empty"),
2194
- option.selected ? " \u2713" : "",
2195
- ambiguous ? ` ${t("browserSelectControl.ambiguousValue")}` : ""
2196
- ]
2197
- },
2198
- optionKey(option)
2199
- );
2200
- }),
2201
- selected.control.multiple ? /* @__PURE__ */ jsx(
2202
- "button",
2203
- {
2204
- type: "button",
2205
- disabled: busy || values.some(ambiguousValue),
2206
- onClick: () => void apply(values),
2207
- children: t("browserSelectControl.applySelection")
2208
- }
2209
- ) : null
2210
- ] })
2211
- ]
2212
- }
2213
- ) : null
2214
- ]
2215
- }
2216
- );
2217
- }
2218
-
2219
- // src/components/browser-viewer.tsx
2220
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2221
- var STALE_BROWSER_END_MAX_ATTEMPTS = 3;
2222
- var STALE_BROWSER_END_RETRY_BASE_MS = 5e3;
2223
- function staleBrowserEndRetryDelayMs(cause, failedAttempts) {
2224
- const status = cause?.status;
2225
- if (typeof status === "number" && status >= 400 && status < 500) return null;
2226
- if (failedAttempts >= STALE_BROWSER_END_MAX_ATTEMPTS) return null;
2227
- return STALE_BROWSER_END_RETRY_BASE_MS * 2 ** (failedAttempts - 1);
2228
- }
2229
- function BrowserViewer({
2230
- sessionId,
2231
- enabled = true,
2232
- active = true,
2233
- className,
2234
- onNotify,
2235
- webSocketFactory,
2236
- renderEmpty,
2237
- createLinkedComputer,
2238
- onOpenComputer,
2239
- initialBrowserSessionId,
2240
- onBrowserSessionIdChange,
2241
- browserExtensionSetupUrl,
2242
- ...override
2243
- }) {
2244
- const t = useOpenGeniText();
2245
- const registry = useBrowserSessions({ ...override, sessionId, enabled });
2246
- const attached = useAttachedBrowsers({ ...override, enabled });
2247
- const { client: configClient } = useEmbeddedBrowserInteraction(override);
2248
- const browserExtensionName = useClientConfigFlags(configClient).browserExtension?.name;
2249
- const onlineAttachedBridges = useMemo2(
2250
- () => attached.bridges.filter((bridge) => bridge.state === "online"),
2251
- [attached.bridges]
2252
- );
2253
- const profiles = useBrowserIdentities({ ...override, enabled, includeArchived: true });
2254
- const siteAuth = useSiteAuthConnections({
2255
- ...override,
2256
- enabled: enabled && profiles.identities.length > 0
2257
- });
2258
- const createRegistryBrowser = registry.create;
2259
- const refreshRegistry = registry.refresh;
2260
- const loadProfileRevisions = profiles.revisions;
2261
- const liveSessions = useMemo2(
2262
- () => registry.sessions.filter((session) => isLiveBrowser2(session)),
2263
- [registry.sessions]
2264
- );
2265
- const attachedGenerationLoss = useMemo2(
2266
- () => attachedChromeGenerationLoss(registry.sessions),
2267
- [registry.sessions]
2268
- );
2269
- const endedGenerationLossRef = useRef9(/* @__PURE__ */ new Set());
2270
- const endStaleBrowserAttemptsRef = useRef9(/* @__PURE__ */ new Map());
2271
- const endStaleBrowser = registry.end;
2272
- useEffect9(() => {
2273
- if (!enabled) return;
2274
- for (const session of registry.sessions) {
2275
- if (session.lifecycle !== "lost" || session.failureCode !== "controller_transition_expired" || session.placement.kind !== "attached_device") {
2276
- continue;
2277
- }
2278
- if (endedGenerationLossRef.current.has(session.id)) continue;
2279
- endedGenerationLossRef.current.add(session.id);
2280
- void endStaleBrowser(session.id).catch((cause) => {
2281
- const attempts = (endStaleBrowserAttemptsRef.current.get(session.id) ?? 0) + 1;
2282
- endStaleBrowserAttemptsRef.current.set(session.id, attempts);
2283
- const delay = staleBrowserEndRetryDelayMs(cause, attempts);
2284
- if (delay === null) return;
2285
- setTimeout(() => endedGenerationLossRef.current.delete(session.id), delay);
2286
- });
2287
- }
2288
- }, [enabled, endStaleBrowser, registry.sessions]);
2289
- const relevant = useMemo2(
2290
- () => registry.relevantSessions.filter((session) => isLiveBrowser2(session)),
2291
- [registry.relevantSessions]
2292
- );
2293
- const latestRelevantBrowser = registry.relevantSessions[0];
2294
- const unavailableBrowser = latestRelevantBrowser?.lifecycle === "lost" || latestRelevantBrowser?.lifecycle === "failed" ? latestRelevantBrowser : void 0;
2295
- const [selection, setSelection] = useState9(
2296
- () => initialBrowserSessionId ? { sessionId: initialBrowserSessionId, pinned: true } : null
2297
- );
2298
- const selectBrowserSession = useCallback8(
2299
- (next) => {
2300
- setSelection(next);
2301
- onBrowserSessionIdChange?.(next?.sessionId ?? null);
2302
- },
2303
- [onBrowserSessionIdChange]
2304
- );
2305
- const interventions = useInteractionInterventions({
2306
- ...override,
2307
- enabled,
2308
- resourceKind: "browser_session"
2309
- });
2310
- const [creating, setCreating] = useState9(false);
2311
- const [savingProfile, setSavingProfile] = useState9(false);
2312
- const [baseRevisionOrdinal, setBaseRevisionOrdinal] = useState9(null);
2313
- const [profileHistory, setProfileHistory] = useState9(null);
2314
- const [resumeAttempt, setResumeAttempt] = useState9(null);
2315
- const resumeAttemptsRef = useRef9(/* @__PURE__ */ new Map());
2316
- const previousSessionIdRef = useRef9(sessionId);
2317
- const seenInterventionIdsRef = useRef9(/* @__PURE__ */ new Set());
2318
- const diagnosticRequestRef = useRef9(0);
2319
- const viewportFocusHandoffRef = useRef9(null);
2320
- const [diagnosticsView, setDiagnosticsView] = useState9(null);
2321
- const notifyError = useCallback8(
2322
- (cause, fallback) => {
2323
- const message = cause instanceof Error ? cause.message : fallback;
2324
- onNotify?.({ kind: "error", message });
2325
- },
2326
- [onNotify]
2327
- );
2328
- useEffect9(() => {
2329
- if (previousSessionIdRef.current !== sessionId) {
2330
- previousSessionIdRef.current = sessionId;
2331
- setSelection(
2332
- initialBrowserSessionId ? { sessionId: initialBrowserSessionId, pinned: true } : null
2333
- );
2334
- }
2335
- }, [initialBrowserSessionId, sessionId]);
2336
- useEffect9(() => {
2337
- if (!enabled || registry.loading) return;
2338
- const selectedStillLive = liveSessions.some((session) => session.id === selection?.sessionId);
2339
- if (selection?.pinned && selectedStillLive) return;
2340
- const preferred = relevant[0] ?? null;
2341
- if (!preferred) {
2342
- if (selection) selectBrowserSession(null);
2343
- return;
2344
- }
2345
- if (!selectedStillLive || !selection?.pinned) {
2346
- if (selection?.sessionId !== preferred.id || selection.pinned) {
2347
- selectBrowserSession({ sessionId: preferred.id, pinned: false });
2348
- }
2349
- }
2350
- }, [enabled, liveSessions, registry.loading, relevant, selectBrowserSession, selection]);
2351
- const selectedRegistrySession = useMemo2(
2352
- () => liveSessions.find((session) => session.id === selection?.sessionId) ?? null,
2353
- [liveSessions, selection?.sessionId]
2354
- );
2355
- const interventionCounts = useMemo2(
2356
- () => countInterventions(interventions.interventions),
2357
- [interventions.interventions]
2358
- );
2359
- const selectedInterventions = useMemo2(
2360
- () => interventions.interventions.filter(
2361
- (intervention) => intervention.resourceId === selection?.sessionId
2362
- ),
2363
- [interventions.interventions, selection?.sessionId]
2364
- );
2365
- const controllerReady = selectedRegistrySession?.lifecycle === "active";
2366
- const resumeSession = registry.resume;
2367
- const [hasLiveFrame, setHasLiveFrame] = useState9(false);
2368
- const wakeBrowser = useCallback8(
2369
- async (session, retry = false) => {
2370
- const current = resumeAttemptsRef.current.get(session.id);
2371
- if (current?.running || !retry && current) return;
2372
- const operationId = current && !current.terminal ? current.operationId : crypto.randomUUID();
2373
- const attempt = {
2374
- operationId,
2375
- running: true,
2376
- terminal: false,
2377
- error: null
2378
- };
2379
- resumeAttemptsRef.current.set(session.id, attempt);
2380
- setResumeAttempt({ sessionId: session.id, attempt });
2381
- try {
2382
- const response = await resumeSession(session.id, operationId);
2383
- if (response.operation.state !== "completed") {
2384
- throw Object.assign(
2385
- new Error(
2386
- response.operation.error?.message ?? t("browserViewer.browserCouldNotReopen2")
2387
- ),
2388
- { terminal: true }
2389
- );
2390
- }
2391
- resumeAttemptsRef.current.delete(session.id);
2392
- setResumeAttempt((visible) => visible?.sessionId === session.id ? null : visible);
2393
- } catch (cause) {
2394
- const error = cause instanceof Error ? cause : new Error(String(cause));
2395
- const failed = {
2396
- operationId,
2397
- running: false,
2398
- terminal: typeof cause === "object" && cause !== null && "terminal" in cause ? cause.terminal === true : false,
2399
- error
2400
- };
2401
- resumeAttemptsRef.current.set(session.id, failed);
2402
- setResumeAttempt({ sessionId: session.id, attempt: failed });
2403
- notifyError(error, t("browserViewer.couldNotReopenThisBrowser"));
2404
- }
2405
- },
2406
- [notifyError, resumeSession, t]
2407
- );
2408
- useEffect9(() => {
2409
- if (!selectedRegistrySession) return;
2410
- if (selectedRegistrySession.lifecycle === "active") {
2411
- resumeAttemptsRef.current.delete(selectedRegistrySession.id);
2412
- setResumeAttempt(
2413
- (visible) => visible?.sessionId === selectedRegistrySession.id ? null : visible
2414
- );
2415
- }
2416
- }, [selectedRegistrySession]);
2417
- const browser = useBrowserSession({
2418
- ...override,
2419
- browserSessionId: selection?.sessionId ?? null,
2420
- enabled: enabled && selection !== null && controllerReady,
2421
- semanticObservationEnabled: active && !hasLiveFrame
2422
- });
2423
- useEffect9(() => {
2424
- if (!isSourcePlacementChangedError(browser.error, "browser_session")) return;
2425
- void refreshRegistry();
2426
- }, [browser.error, refreshRegistry]);
2427
- const downloads = useBrowserDownloads({
2428
- ...override,
2429
- browserSessionId: selection?.sessionId ?? null,
2430
- enabled: enabled && diagnosticsView !== null && controllerReady && browser.session?.capabilities.downloads === true
2431
- });
2432
- const loadBrowserDiagnostics = browser.diagnostics;
2433
- useEffect9(() => {
2434
- for (const intervention of interventions.interventions) {
2435
- if (seenInterventionIdsRef.current.has(intervention.id)) continue;
2436
- seenInterventionIdsRef.current.add(intervention.id);
2437
- onNotify?.({
2438
- kind: "info",
2439
- message: `${interventionTitle(t, intervention)}: ${intervention.reason}`
2440
- });
2441
- }
2442
- }, [interventions.interventions, onNotify, t]);
2443
- const resolveIntervention = useCallback8(
2444
- (intervention, outcome) => {
2445
- void interventions.resolve(intervention.id, {
2446
- expectedVersion: intervention.version,
2447
- outcome
2448
- }).then(() => {
2449
- onNotify?.({
2450
- kind: "info",
2451
- message: outcome === "completed" ? t("browserViewer.agentNotifiedContinuingWork") : t("browserViewer.requestCancelled")
2452
- });
2453
- }).catch((cause) => notifyError(cause, t("browserViewer.couldNotUpdateTheBrowser")));
2454
- },
2455
- [interventions, notifyError, onNotify, t]
2456
- );
2457
- const frames = useBrowserFrameStream({
2458
- ...override,
2459
- browserSessionId: selection?.sessionId ?? null,
2460
- targetId: browser.selectedTarget?.id ?? null,
2461
- enabled: enabled && selection !== null && controllerReady && browser.selectedTarget !== null && browser.session?.capabilities.liveFrames === true,
2462
- stream: { format: "jpeg", quality: 76, maxWidth: 1920, maxHeight: 1200 },
2463
- ...webSocketFactory ? { webSocketFactory } : {}
2464
- });
2465
- const receivedFrame = frameMatchesSelectedTarget(
2466
- frames.frame,
2467
- browser.session,
2468
- browser.selectedTarget
2469
- ) ? frames.frame : null;
2470
- const displayedFrame = useMemo2(
2471
- () => receivedFrame ? { ...receivedFrame, data: receivedFrame.data.slice().buffer } : null,
2472
- [receivedFrame]
2473
- );
2474
- const frameIsLive = frames.state === "live" && displayedFrame !== null;
2475
- useEffect9(() => {
2476
- setHasLiveFrame(frameIsLive);
2477
- }, [frameIsLive]);
2478
- const supportsLiveFrames = (browser.session ?? selectedRegistrySession)?.capabilities.liveFrames === true;
2479
- const controlUnavailable = isInteractionControlUnavailable(browser.error);
2480
- const connectionError = controlUnavailable ? browser.error : frames.error ?? browser.error;
2481
- const selectedPlacement = (browser.session ?? selectedRegistrySession)?.placement;
2482
- const selectedChromeGenerationLoss = selectedPlacement?.kind === "attached_device" && isAttachedChromeGenerationLossError(connectionError);
2483
- const replacementChromeDevice = selectedChromeGenerationLoss && selectedPlacement.kind === "attached_device" ? attached.devices.find((candidate) => candidate.id === selectedPlacement.deviceId) : null;
2484
- const displayConnectionState = connectionError && (!frameIsLive || controlUnavailable) ? "error" : !browser.session ? "connecting" : supportsLiveFrames ? frames.state === "live" && !displayedFrame ? "connecting" : frames.state : "semantic";
2485
- const selectedProfile = useMemo2(
2486
- () => profiles.identities.find(
2487
- (identity) => identity.id === (browser.session?.identityId ?? selectedRegistrySession?.identityId)
2488
- ) ?? null,
2489
- [browser.session?.identityId, profiles.identities, selectedRegistrySession?.identityId]
2490
- );
2491
- const selectedProfileAuth = useMemo2(
2492
- () => selectedProfile ? siteAuth.connections.filter(
2493
- (connection) => connection.preferredIdentityId === selectedProfile.id
2494
- ) : [],
2495
- [selectedProfile, siteAuth.connections]
2496
- );
2497
- useEffect9(() => {
2498
- diagnosticRequestRef.current += 1;
2499
- setDiagnosticsView(null);
2500
- }, [browser.session?.id, browser.selectedTarget?.id]);
2501
- const loadDiagnostics = useCallback8(() => {
2502
- const browserSessionId = browser.session?.id;
2503
- const targetId = browser.selectedTarget?.id;
2504
- if (!browserSessionId || !targetId) return;
2505
- const requestId = diagnosticRequestRef.current + 1;
2506
- diagnosticRequestRef.current = requestId;
2507
- setDiagnosticsView((current) => ({
2508
- browserSessionId,
2509
- targetId,
2510
- loading: true,
2511
- batch: current?.browserSessionId === browserSessionId && current.targetId === targetId ? current.batch : null,
2512
- error: null
2513
- }));
2514
- void loadBrowserDiagnostics({ limit: 100 }).then((batch) => {
2515
- if (diagnosticRequestRef.current !== requestId) return;
2516
- setDiagnosticsView({ browserSessionId, targetId, loading: false, batch, error: null });
2517
- }).catch((cause) => {
2518
- if (diagnosticRequestRef.current !== requestId) return;
2519
- setDiagnosticsView({
2520
- browserSessionId,
2521
- targetId,
2522
- loading: false,
2523
- batch: null,
2524
- error: cause instanceof Error ? cause : new Error(String(cause))
2525
- });
2526
- });
2527
- }, [browser.selectedTarget?.id, browser.session?.id, loadBrowserDiagnostics]);
2528
- const closeDiagnostics = useCallback8(() => {
2529
- diagnosticRequestRef.current += 1;
2530
- setDiagnosticsView(null);
2531
- }, []);
2532
- const refreshDiagnostics = useCallback8(() => {
2533
- loadDiagnostics();
2534
- if (browser.session?.capabilities.downloads) void downloads.refresh();
2535
- }, [browser.session?.capabilities.downloads, downloads, loadDiagnostics]);
2536
- const saveDownload = useCallback8(
2537
- async (downloadId, destinationPath, overwrite) => {
2538
- const response = await downloads.saveToWorkspace(downloadId, destinationPath, { overwrite });
2539
- onNotify?.({
2540
- kind: "info",
2541
- message: t("browserViewer.filenameSavedToDestinationpath", {
2542
- filename: response.download.filename,
2543
- destinationPath: response.destinationPath
2544
- })
2545
- });
2546
- return response;
2547
- },
2548
- [downloads, onNotify, t]
2549
- );
2550
- useEffect9(() => {
2551
- const identityId = browser.session?.identityId ?? selectedRegistrySession?.identityId;
2552
- const revisionId = browser.session?.baseRevisionId ?? selectedRegistrySession?.baseRevisionId;
2553
- if (!identityId) {
2554
- setBaseRevisionOrdinal(null);
2555
- setProfileHistory(null);
2556
- return;
2557
- }
2558
- let disposed = false;
2559
- setBaseRevisionOrdinal(null);
2560
- setProfileHistory({ identityId, loading: true, revisions: [] });
2561
- void loadProfileRevisions(identityId).then((response) => {
2562
- if (!disposed) {
2563
- setBaseRevisionOrdinal(
2564
- revisionId ? response.revisions.find((revision) => revision.id === revisionId)?.ordinal ?? null : null
2565
- );
2566
- setProfileHistory({ identityId, loading: false, revisions: response.revisions });
2567
- }
2568
- }).catch(() => {
2569
- if (!disposed) setProfileHistory({ identityId, loading: false, revisions: [] });
2570
- });
2571
- return () => {
2572
- disposed = true;
2573
- };
2574
- }, [
2575
- browser.session?.baseRevisionId,
2576
- browser.session?.identityId,
2577
- loadProfileRevisions,
2578
- selectedRegistrySession?.baseRevisionId,
2579
- selectedRegistrySession?.identityId
2580
- ]);
2581
- const createBrowser = useCallback8(
2582
- (choice = { kind: "clean" }) => {
2583
- if (creating) return;
2584
- const identity = choice.kind === "profile" ? profiles.identities.find((candidate) => candidate.id === choice.identityId) : null;
2585
- if (choice.kind === "profile" && (!identity || identity.status !== "active")) {
2586
- onNotify?.({
2587
- kind: "error",
2588
- message: t("browserViewer.thisBrowserProfileIsNo")
2589
- });
2590
- return;
2591
- }
2592
- const device = choice.kind === "attached" ? choice.device : null;
2593
- const browserName = device?.profileLabel ?? device?.name ?? (identity ? `${identity.name} browser` : t("browserViewer.browser"));
2594
- setCreating(true);
2595
- void (async () => {
2596
- let linkedComputer = null;
2597
- let computerViewUnavailable = false;
2598
- if (createLinkedComputer) {
2599
- try {
2600
- linkedComputer = await createLinkedComputer(
2601
- `${browserName} desktop`,
2602
- device ? { kind: "attached_device", deviceId: device.id } : void 0
2603
- );
2604
- } catch {
2605
- computerViewUnavailable = true;
2606
- }
2607
- }
2608
- const response = await createRegistryBrowser({
2609
- sessionId,
2610
- name: browserName,
2611
- // Human-created browsers are always ordinary visual Chromium/Chrome.
2612
- // Lightpanda remains an agent-only optimization requested explicitly
2613
- // through browser_open; if an agent creates one it is still visible in
2614
- // the shared BrowserSession switcher.
2615
- headless: false,
2616
- initialUrl: HUMAN_BROWSER_HOME_URL,
2617
- ...device ? {
2618
- placement: {
2619
- kind: "attached_device",
2620
- deviceId: device.id
2621
- }
2622
- } : {},
2623
- ...linkedComputer ? {
2624
- linkedComputerSessionId: linkedComputer.id,
2625
- placement: linkedComputer.placement
2626
- } : {},
2627
- ...identity ? {
2628
- identityId: identity.id,
2629
- ...choice.kind === "profile" && choice.baseRevisionId ? { baseRevisionId: choice.baseRevisionId } : {}
2630
- } : {}
2631
- });
2632
- selectBrowserSession({ sessionId: response.session.id, pinned: true });
2633
- if (computerViewUnavailable) {
2634
- onNotify?.({
2635
- kind: "info",
2636
- message: t("browserViewer.browserOpenedDesktopViewIs")
2637
- });
2638
- }
2639
- })().catch((cause) => notifyError(cause, t("browserViewer.couldNotOpenABrowser"))).finally(() => setCreating(false));
2640
- },
2641
- [
2642
- createLinkedComputer,
2643
- createRegistryBrowser,
2644
- creating,
2645
- notifyError,
2646
- onNotify,
2647
- selectBrowserSession,
2648
- profiles.identities,
2649
- sessionId,
2650
- t
2651
- ]
2652
- );
2653
- const saveProfileVersion = useCallback8(
2654
- async (newProfileName) => {
2655
- const session = browser.session;
2656
- if (!session || savingProfile || !session.capabilities.identityPublication) return false;
2657
- setSavingProfile(true);
2658
- try {
2659
- let identity = selectedProfile;
2660
- if (!identity) {
2661
- const name = newProfileName?.trim() ?? "";
2662
- if (!name) return false;
2663
- identity = profiles.identities.find(
2664
- (candidate) => candidate.status === "active" && candidate.revisionCount === 0 && candidate.name.localeCompare(name, void 0, { sensitivity: "base" }) === 0
2665
- ) ?? (await profiles.create({ name })).identity;
2666
- }
2667
- const response = await profiles.publish(session.id, {
2668
- identityId: identity.id,
2669
- expectedHeadGeneration: identity.headGeneration,
2670
- advanceDefault: true
2671
- });
2672
- setBaseRevisionOrdinal(response.revision.ordinal);
2673
- setProfileHistory((current) => ({
2674
- identityId: response.identity.id,
2675
- loading: false,
2676
- revisions: current?.identityId === response.identity.id ? [
2677
- ...current.revisions.filter((revision) => revision.id !== response.revision.id),
2678
- response.revision
2679
- ] : [response.revision]
2680
- }));
2681
- await Promise.all([browser.refresh(), registry.refresh()]);
2682
- onNotify?.({
2683
- kind: "info",
2684
- message: response.outcome === "saved_as_default" ? t("browserViewer.nameVersionOrdinalSavedFor", {
2685
- name: response.identity.name,
2686
- ordinal: response.revision.ordinal
2687
- }) : t("browserViewer.nameVersionOrdinalSavedAnother", {
2688
- name: response.identity.name,
2689
- ordinal: response.revision.ordinal
2690
- })
2691
- });
2692
- return true;
2693
- } catch (cause) {
2694
- notifyError(cause, t("browserViewer.couldNotSaveThisBrowser"));
2695
- return false;
2696
- } finally {
2697
- setSavingProfile(false);
2698
- }
2699
- },
2700
- [browser, notifyError, onNotify, profiles, registry, savingProfile, selectedProfile, t]
2701
- );
2702
- const updateProfile = useCallback8(
2703
- async (identity, update) => {
2704
- if (savingProfile) return false;
2705
- setSavingProfile(true);
2706
- try {
2707
- const response = await profiles.update(identity.id, {
2708
- expectedVersion: identity.version,
2709
- ...update
2710
- });
2711
- if (update.defaultRevisionId) {
2712
- const ordinal = profileHistory?.revisions.find(
2713
- (revision) => revision.id === update.defaultRevisionId
2714
- )?.ordinal;
2715
- onNotify?.({
2716
- kind: "info",
2717
- message: ordinal ? t("browserViewer.nameVersionOpensByDefault", {
2718
- name: response.identity.name,
2719
- ordinal
2720
- }) : t("browserViewer.nameOpensByDefault", { name: response.identity.name })
2721
- });
2722
- } else if (update.status === "archived") {
2723
- onNotify?.({
2724
- kind: "info",
2725
- message: t("browserViewer.nameHiddenFromNewBrowsers", { name: response.identity.name })
2726
- });
2727
- } else if (update.status === "active") {
2728
- onNotify?.({ kind: "info", message: `${response.identity.name} restored.` });
2729
- }
2730
- return true;
2731
- } catch (cause) {
2732
- notifyError(cause, t("browserViewer.couldNotUpdateThisBrowser"));
2733
- await profiles.refresh().catch(() => void 0);
2734
- return false;
2735
- } finally {
2736
- setSavingProfile(false);
2737
- }
2738
- },
2739
- [notifyError, onNotify, profileHistory?.revisions, profiles, savingProfile, t]
2740
- );
2741
- if (!enabled) return null;
2742
- if (registry.loading && liveSessions.length === 0) {
2743
- return /* @__PURE__ */ jsx2(
2744
- BrowserNotice,
2745
- {
2746
- icon: /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "animate-spin" }),
2747
- text: t("browserViewer.findingBrowsers"),
2748
- ...className ? { className } : {}
2749
- }
2750
- );
2751
- }
2752
- if (liveSessions.length === 0) {
2753
- if (renderEmpty && !unavailableBrowser)
2754
- return /* @__PURE__ */ jsx2(Fragment2, { children: renderEmpty(() => createBrowser(), creating) });
2755
- return /* @__PURE__ */ jsx2(
2756
- "div",
2757
- {
2758
- className: cn("flex h-full min-h-0 items-center justify-center bg-og-bg p-6", className),
2759
- children: /* @__PURE__ */ jsxs2("div", { className: "max-w-sm text-center", children: [
2760
- /* @__PURE__ */ jsx2("span", { className: "mx-auto grid size-10 place-items-center rounded-og-md border border-og-border bg-og-surface-1 text-og-fg-muted", children: /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-4.5" }) }),
2761
- unavailableBrowser && !attachedGenerationLoss ? /* @__PURE__ */ jsx2(BrowserUnavailableNotice, { session: unavailableBrowser }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
2762
- /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: attachedGenerationLoss ? t("browserViewer.chromeReconnectedOpenAFresh") : t("browserViewer.noBrowserOpen") }),
2763
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-control leading-5 text-og-fg-muted", children: attachedGenerationLoss ? t("browserViewer.thisChromeProfileIsLive") : t("browserViewer.aBrowserAppearsHereWhen") })
2764
- ] }),
2765
- /* @__PURE__ */ jsx2(
2766
- BrowserLaunchMenu,
2767
- {
2768
- attachedBridges: onlineAttachedBridges,
2769
- attachedDevices: attached.devices,
2770
- identities: profiles.identities,
2771
- creating,
2772
- mutatingProfile: savingProfile,
2773
- onCreate: createBrowser,
2774
- onRestore: (identity) => updateProfile(identity, { status: "active" }),
2775
- setupUrl: browserExtensionSetupUrl,
2776
- extensionName: browserExtensionName,
2777
- prominent: true
2778
- }
2779
- ),
2780
- registry.error ? /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-control text-og-danger", children: registry.error.message }) : null
2781
- ] })
2782
- }
2783
- );
2784
- }
2785
- return /* @__PURE__ */ jsxs2(
2786
- "div",
2787
- {
2788
- className: cn("relative flex h-full min-h-0 flex-col overflow-hidden bg-og-bg", className),
2789
- children: [
2790
- /* @__PURE__ */ jsx2(
2791
- BrowserToolbar,
2792
- {
2793
- sessions: liveSessions,
2794
- relevantSessionIds: new Set(relevant.map((session) => session.id)),
2795
- selectedSessionId: selection?.sessionId ?? null,
2796
- identities: profiles.identities,
2797
- attachedBridges: onlineAttachedBridges,
2798
- attachedDevices: attached.devices,
2799
- selectedProfile,
2800
- baseRevisionOrdinal,
2801
- profileHistory,
2802
- authConnections: selectedProfileAuth,
2803
- creating,
2804
- savingProfile,
2805
- refreshing: registry.refreshing || attached.refreshing,
2806
- interventionCounts,
2807
- onSelect: (browserSessionId) => selectBrowserSession({ sessionId: browserSessionId, pinned: true }),
2808
- onFollow: () => {
2809
- const preferred = relevant[0];
2810
- if (preferred) selectBrowserSession({ sessionId: preferred.id, pinned: false });
2811
- },
2812
- onCreate: createBrowser,
2813
- onSaveProfile: saveProfileVersion,
2814
- onUpdateProfile: updateProfile,
2815
- onOpenProfileVersion: (identityId, baseRevisionId) => createBrowser({ kind: "profile", identityId, baseRevisionId }),
2816
- onRefresh: () => void Promise.all([registry.refresh(), attached.refresh()]),
2817
- setupUrl: browserExtensionSetupUrl,
2818
- extensionName: browserExtensionName
2819
- }
2820
- ),
2821
- /* @__PURE__ */ jsx2(
2822
- InteractionInterventionBanner,
2823
- {
2824
- interventions: selectedInterventions,
2825
- activeTargetId: browser.selectedTarget?.id ?? null,
2826
- mutating: interventions.mutating,
2827
- onOpen: (intervention) => void browser.selectTarget(intervention.targetId).catch((cause) => notifyError(cause, t("browserViewer.couldNotOpenTheRequested"))),
2828
- onResolve: resolveIntervention
2829
- }
2830
- ),
2831
- !selectedRegistrySession ? /* @__PURE__ */ jsx2(
2832
- BrowserUnselectedPanel,
2833
- {
2834
- unavailableBrowser,
2835
- peerCount: liveSessions.length,
2836
- creating,
2837
- onCreate: () => createBrowser()
2838
- }
2839
- ) : !controllerReady ? /* @__PURE__ */ jsx2(
2840
- BrowserLifecyclePanel,
2841
- {
2842
- session: selectedRegistrySession,
2843
- attempt: resumeAttempt?.sessionId === selectedRegistrySession.id ? resumeAttempt.attempt : null,
2844
- onResume: () => void wakeBrowser(selectedRegistrySession, true)
2845
- }
2846
- ) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
2847
- /* @__PURE__ */ jsx2(
2848
- BrowserTabs,
2849
- {
2850
- targets: browser.targets,
2851
- selectedTargetId: browser.selectedTarget?.id ?? null,
2852
- mutating: savingProfile,
2853
- tabControl: browser.session?.capabilities.tabs === true,
2854
- onSelect: (targetId) => void browser.selectTarget(targetId).catch((cause) => notifyError(cause, t("browserViewer.couldNotSwitchTabs"))),
2855
- onClose: (targetId) => void browser.closeTarget(targetId).catch((cause) => notifyError(cause, t("browserViewer.couldNotCloseTheTab"))),
2856
- onOpen: () => void browser.openTarget(HUMAN_BROWSER_HOME_URL).catch((cause) => notifyError(cause, t("browserViewer.couldNotOpenATab")))
2857
- }
2858
- ),
2859
- /* @__PURE__ */ jsx2(
2860
- BrowserAddressBar,
2861
- {
2862
- target: browser.selectedTarget,
2863
- loading: browser.loading || browser.mutating || savingProfile,
2864
- onNavigate: (url) => void browser.act({ type: "navigate", url }).catch((cause) => notifyError(cause, t("browserViewer.couldNotNavigate"))),
2865
- onHistory: async (direction) => {
2866
- try {
2867
- const action = { type: "history", direction };
2868
- if (receivedFrame) await browser.actFromFrame(action, receivedFrame);
2869
- else {
2870
- if (!browser.observation)
2871
- throw new Error("The browser page is not ready for input.");
2872
- await browser.actFromObservation(action, browser.observation);
2873
- }
2874
- } catch (cause) {
2875
- notifyError(
2876
- cause,
2877
- direction === "back" ? t("browserViewer.couldNotGoBack") : t("browserViewer.couldNotGoForward")
2878
- );
2879
- }
2880
- },
2881
- onReload: () => {
2882
- const url = browser.selectedTarget?.url;
2883
- if (url)
2884
- void browser.act({ type: "navigate", url }).catch((cause) => notifyError(cause, t("browserViewer.couldNotReload")));
2885
- }
2886
- }
2887
- ),
2888
- browser.inputFailure ? /* @__PURE__ */ jsxs2(
2889
- "div",
2890
- {
2891
- role: "alert",
2892
- "aria-label": t("browserViewer.browserInputStatus"),
2893
- className: "flex shrink-0 items-center gap-2 border-t border-og-border bg-og-surface-1 px-3 py-2 text-og-xs",
2894
- children: [
2895
- /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-4 shrink-0 text-og-status-failed" }),
2896
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
2897
- /* @__PURE__ */ jsx2("span", { className: "font-medium", children: browser.inputFailure.state === "failed" ? t("browserViewer.browserInputFailed") : t("browserViewer.inputResultUnknown") }),
2898
- /* @__PURE__ */ jsx2("p", { className: "text-og-fg-subtle", children: browser.inputFailure.error?.message ?? t("browserViewer.inspectThePageBeforeContinuing") })
2899
- ] }),
2900
- /* @__PURE__ */ jsx2(
2901
- "button",
2902
- {
2903
- type: "button",
2904
- onClick: () => void browser.refresh(),
2905
- className: "shrink-0 rounded border border-og-border px-2 py-1 transition hover:bg-og-surface-2",
2906
- children: t("browserViewer.checkBrowser")
2907
- }
2908
- )
2909
- ]
2910
- }
2911
- ) : null,
2912
- /* @__PURE__ */ jsxs2("div", { className: "relative flex min-h-0 min-w-0 flex-1 overflow-hidden", children: [
2913
- /* @__PURE__ */ jsx2(
2914
- BrowserViewport,
2915
- {
2916
- focusHandoffRef: viewportFocusHandoffRef,
2917
- focusScope: JSON.stringify([
2918
- selection?.sessionId,
2919
- browser.selectedTarget?.id,
2920
- browser.selectedTarget?.targetGeneration
2921
- ]),
2922
- frame: displayedFrame,
2923
- connectionState: displayConnectionState,
2924
- supportsLiveFrames,
2925
- connectionError,
2926
- controlUnavailable,
2927
- observation: browser.observation,
2928
- mutating: browser.mutating || savingProfile,
2929
- activityLabel: savingProfile ? t("browserViewer.savingBrowserVersion") : void 0,
2930
- clipboardEnabled: browser.session?.capabilities.clipboard === true,
2931
- inputBatchAttachment: frames.attachment,
2932
- onAction: async (action, frame) => {
2933
- const focusedInput = frame && action.type === "pointer" && action.action === "click" && (action.button === void 0 || action.button === "left") && frames.attachment?.focusedInputObservations === true && frames.attachment.browserSessionId === frame.browserSessionId && frames.attachment.controllerGeneration === frame.controllerGeneration && frames.attachment.targetId === frame.targetId && Date.parse(frames.attachment.expiresAt) > Date.now();
2934
- const receipt = frame ? await browser.actFromFrame(
2935
- action,
2936
- frame,
2937
- void 0,
2938
- focusedInput ? "input" : "none"
2939
- ) : await browser.act(action);
2940
- if (receipt.state !== "completed") {
2941
- throw new Error(
2942
- receipt.error?.message ?? t("browserViewer.browserInputDidNotComplete")
2943
- );
2944
- }
2945
- return receipt;
2946
- },
2947
- onReadClipboard: browser.readClipboard,
2948
- onObserveForInput: browser.observeForInput,
2949
- onSelectFromObservation: browser.actFromObservation,
2950
- onReconnect: selectedChromeGenerationLoss ? () => {
2951
- if (replacementChromeDevice) {
2952
- createBrowser({ kind: "attached", device: replacementChromeDevice });
2953
- }
2954
- } : () => {
2955
- void browser.refresh();
2956
- frames.reconnect();
2957
- },
2958
- reconnectLabel: selectedChromeGenerationLoss && replacementChromeDevice ? t("browserViewer.openAFreshConnectedChrome") : void 0,
2959
- reconnectMessage: selectedChromeGenerationLoss ? t("browserViewer.chromeReconnectedOpenAFresh") : void 0,
2960
- onError: (cause) => notifyError(cause, t("browserViewer.browserInputFailed2"))
2961
- },
2962
- JSON.stringify([
2963
- selection?.sessionId,
2964
- browser.selectedTarget?.id,
2965
- browser.selectedTarget?.targetGeneration,
2966
- browser.selectedTarget?.documentGeneration,
2967
- frames.attachment?.controllerGeneration
2968
- ])
2969
- ),
2970
- diagnosticsView ? /* @__PURE__ */ jsx2(
2971
- BrowserDiagnosticsDrawer,
2972
- {
2973
- session: browser.session,
2974
- profile: selectedProfile,
2975
- target: browser.selectedTarget,
2976
- observation: browser.observation,
2977
- baseRevisionOrdinal,
2978
- state: diagnosticsView,
2979
- downloads: downloads.downloads,
2980
- downloadsEnabled: browser.session?.capabilities.downloads === true,
2981
- downloadsLoading: downloads.loading,
2982
- downloadsRefreshing: downloads.refreshing,
2983
- downloadsError: downloads.error,
2984
- savingDownloadIds: downloads.savingDownloadIds,
2985
- onSaveDownload: saveDownload,
2986
- onRefreshDownloads: () => void downloads.refresh(),
2987
- onRefresh: refreshDiagnostics,
2988
- onClose: closeDiagnostics
2989
- }
2990
- ) : null
2991
- ] }),
2992
- /* @__PURE__ */ jsx2(
2993
- BrowserStatusBar,
2994
- {
2995
- session: browser.session,
2996
- profile: selectedProfile,
2997
- target: browser.selectedTarget,
2998
- observation: browser.observation,
2999
- inputFailure: browser.inputFailure,
3000
- connectionState: displayConnectionState,
3001
- refreshing: registry.refreshing,
3002
- diagnosticsOpen: diagnosticsView !== null,
3003
- onOpenComputer: browser.session?.linkedComputerSessionId && onOpenComputer ? () => {
3004
- const computerSessionId = browser.session?.linkedComputerSessionId;
3005
- if (computerSessionId) onOpenComputer(computerSessionId);
3006
- } : void 0,
3007
- onDiagnostics: diagnosticsView ? closeDiagnostics : loadDiagnostics
3008
- }
3009
- )
3010
- ] })
3011
- ]
3012
- }
3013
- );
3014
- }
3015
- function BrowserLifecyclePanel(props) {
3016
- const t = useOpenGeniText();
3017
- const failed = props.attempt?.error ?? null;
3018
- const label = failed ? t("browserViewer.browserCouldNotReopen") : props.session.lifecycle === "suspending" ? t("browserViewer.savingBrowserState") : props.session.lifecycle === "restoring" || props.attempt?.running ? t("browserViewer.openingBrowser") : props.session.lifecycle === "starting" ? t("browserViewer.startingBrowser") : t("browserViewer.browserIsSleeping");
3019
- const detail = failed ? failed.message : props.session.lifecycle === "suspended" ? t("browserViewer.itsPrivateStateIsSaved") : t("browserViewer.theBrowserWillReconnectHere");
3020
- return /* @__PURE__ */ jsx2("div", { className: "grid min-h-0 flex-1 place-items-center bg-og-bg p-6 text-center", children: /* @__PURE__ */ jsxs2("div", { className: "max-w-sm", children: [
3021
- /* @__PURE__ */ jsx2("span", { className: "mx-auto grid size-10 place-items-center rounded-og-md border border-og-border bg-og-surface-1 text-og-fg-muted", children: failed ? /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-4.5 text-og-danger" }) : /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-4.5 animate-spin" }) }),
3022
- /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: label }),
3023
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-control leading-5 text-og-fg-muted", children: detail }),
3024
- failed || props.session.lifecycle === "suspended" && !props.attempt?.running ? /* @__PURE__ */ jsx2(
3025
- "button",
3026
- {
3027
- type: "button",
3028
- onClick: props.onResume,
3029
- className: "mt-4 inline-flex h-8 items-center rounded-og-sm border border-og-primary-border bg-og-primary px-3 text-og-control font-medium text-og-primary-fg transition hover:bg-og-primary-hover",
3030
- children: t("browserViewer.openBrowser")
3031
- }
3032
- ) : null
3033
- ] }) });
3034
- }
3035
- function BrowserToolbar(props) {
3036
- const t = useOpenGeniText();
3037
- const detailsRef = useViewerMenuDismiss();
3038
- const selected = props.sessions.find((session) => session.id === props.selectedSessionId);
3039
- const current = props.sessions.filter((session) => props.relevantSessionIds.has(session.id));
3040
- const others = props.sessions.filter((session) => !props.relevantSessionIds.has(session.id));
3041
- const choose = (id) => {
3042
- props.onSelect(id);
3043
- detailsRef.current?.removeAttribute("open");
3044
- };
3045
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-og-border bg-og-surface-1 px-2", children: [
3046
- /* @__PURE__ */ jsxs2("details", { ref: detailsRef, className: "min-w-0", children: [
3047
- /* @__PURE__ */ jsxs2("summary", { className: "flex h-7 max-w-52 cursor-pointer list-none items-center gap-2 rounded-og-sm px-2 text-og-control text-og-fg transition hover:bg-og-surface-2 [&::-webkit-details-marker]:hidden", children: [
3048
- /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3049
- /* @__PURE__ */ jsx2("span", { className: "truncate font-medium", children: selected?.name ?? t("browserViewer.browser") }),
3050
- (props.interventionCounts.get(selected?.id ?? "") ?? 0) > 0 ? /* @__PURE__ */ jsx2("span", { className: "size-1.5 shrink-0 rounded-full bg-og-status-waiting" }) : null,
3051
- /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3 shrink-0 text-og-fg-subtle" })
3052
- ] }),
3053
- /* @__PURE__ */ jsxs2("div", { className: "absolute left-2 top-10 z-30 flex max-h-[calc(100%-3rem)] w-72 max-w-[calc(100%-1rem)] flex-col overflow-hidden rounded-og-md border border-og-border bg-og-surface-1 p-1 shadow-xl", children: [
3054
- /* @__PURE__ */ jsxs2("div", { className: "min-h-0 max-h-96 overflow-y-auto overscroll-contain", children: [
3055
- /* @__PURE__ */ jsx2(
3056
- BrowserSessionGroup,
3057
- {
3058
- label: t("browserViewer.currentAgent"),
3059
- sessions: current,
3060
- identities: props.identities,
3061
- selectedId: props.selectedSessionId,
3062
- interventionCounts: props.interventionCounts,
3063
- onSelect: choose
3064
- }
3065
- ),
3066
- /* @__PURE__ */ jsx2(
3067
- BrowserSessionGroup,
3068
- {
3069
- label: t("browserViewer.workspaceBrowsers"),
3070
- sessions: others,
3071
- identities: props.identities,
3072
- selectedId: props.selectedSessionId,
3073
- interventionCounts: props.interventionCounts,
3074
- onSelect: choose
3075
- }
3076
- )
3077
- ] }),
3078
- /* @__PURE__ */ jsxs2("div", { className: "mt-1 flex shrink-0 gap-1 border-t border-og-border pt-1", children: [
3079
- current.length > 0 ? /* @__PURE__ */ jsx2(MenuButton, { onClick: props.onFollow, children: t("browserViewer.followAgent") }) : null,
3080
- /* @__PURE__ */ jsxs2(MenuButton, { onClick: () => props.onCreate(), disabled: props.creating, children: [
3081
- /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" }),
3082
- " ",
3083
- t("browserViewer.newBrowser")
3084
- ] })
3085
- ] })
3086
- ] })
3087
- ] }),
3088
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate text-og-xs text-og-fg-subtle", children: placementLabel(t, selected) }),
3089
- /* @__PURE__ */ jsx2(
3090
- BrowserProfileMenu,
3091
- {
3092
- session: selected ?? null,
3093
- identity: props.selectedProfile,
3094
- baseRevisionOrdinal: props.baseRevisionOrdinal,
3095
- history: props.profileHistory,
3096
- authConnections: props.authConnections,
3097
- saving: props.savingProfile,
3098
- onSave: props.onSaveProfile,
3099
- onUpdate: props.onUpdateProfile,
3100
- onOpenVersion: props.onOpenProfileVersion
3101
- }
3102
- ),
3103
- /* @__PURE__ */ jsx2(
3104
- "button",
3105
- {
3106
- type: "button",
3107
- onClick: props.onRefresh,
3108
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg",
3109
- "aria-label": t("browserViewer.refreshBrowsers"),
3110
- children: /* @__PURE__ */ jsx2(RefreshCwIcon, { className: cn("size-3.5", props.refreshing && "animate-spin") })
3111
- }
3112
- ),
3113
- /* @__PURE__ */ jsx2(
3114
- BrowserLaunchMenu,
3115
- {
3116
- attachedBridges: props.attachedBridges,
3117
- attachedDevices: props.attachedDevices,
3118
- identities: props.identities,
3119
- creating: props.creating,
3120
- mutatingProfile: props.savingProfile,
3121
- onCreate: props.onCreate,
3122
- onRestore: (identity) => props.onUpdateProfile(identity, { status: "active" }),
3123
- setupUrl: props.setupUrl,
3124
- extensionName: props.extensionName
3125
- }
3126
- )
3127
- ] });
3128
- }
3129
- function BrowserUnselectedPanel(props) {
3130
- const t = useOpenGeniText();
3131
- return /* @__PURE__ */ jsx2("div", { className: "grid min-h-0 flex-1 place-items-center bg-og-bg p-6 text-center", children: /* @__PURE__ */ jsxs2("div", { className: "max-w-sm", children: [
3132
- /* @__PURE__ */ jsx2("span", { className: "mx-auto grid size-10 place-items-center rounded-og-md border border-og-border bg-og-surface-1 text-og-fg-muted", children: /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-4.5" }) }),
3133
- props.unavailableBrowser ? /* @__PURE__ */ jsx2(BrowserUnavailableNotice, { session: props.unavailableBrowser }) : /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: t("browserViewer.noBrowserForThisAgent") }),
3134
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-control leading-5 text-og-fg-muted", children: props.peerCount === 1 ? t("browserViewer.oneWorkspaceBrowserIsAvailable") : t("browserViewer.peercountWorkspaceBrowsersAreAvailable", {
3135
- peerCount: props.peerCount
3136
- }) }),
3137
- /* @__PURE__ */ jsxs2(
3138
- "button",
3139
- {
3140
- type: "button",
3141
- disabled: props.creating,
3142
- onClick: props.onCreate,
3143
- className: "mt-4 inline-flex h-8 items-center gap-1.5 rounded-og-sm border border-og-primary-border bg-og-primary px-3 text-og-control font-medium text-og-primary-fg transition hover:bg-og-primary-hover disabled:cursor-not-allowed disabled:opacity-50",
3144
- children: [
3145
- /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" }),
3146
- props.creating ? t("browserViewer.opening") : t("browserViewer.newBrowser")
3147
- ]
3148
- }
3149
- )
3150
- ] }) });
3151
- }
3152
- function BrowserUnavailableNotice({ session }) {
3153
- const t = useOpenGeniText();
3154
- const reason = session.failureCode === "provider_deadline_rotation" ? t("browserViewer.theComputerRunningItReached") : session.failureCode === "source_placement_changed" ? t("browserViewer.thisChatMovedToAnother") : session.failureCode === "idle_released" ? t("browserViewer.itStoppedAfterItWent") : session.lifecycle === "failed" ? t("browserViewer.itStoppedUnexpectedly") : t("browserViewer.theConnectionToItWas");
3155
- return /* @__PURE__ */ jsxs2("div", { role: "status", children: [
3156
- /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: t("browserViewer.browserUnavailable") }),
3157
- /* @__PURE__ */ jsx2("p", { className: "mt-1 break-words text-og-control leading-5 text-og-fg-muted", children: t("browserViewer.nameReasonOpenANew", { name: session.name, reason }) })
3158
- ] });
3159
- }
3160
- function BrowserSessionGroup(props) {
3161
- const t = useOpenGeniText();
3162
- if (props.sessions.length === 0) return null;
3163
- return /* @__PURE__ */ jsxs2("div", { className: "py-1", children: [
3164
- /* @__PURE__ */ jsx2("p", { className: "px-2 pb-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: props.label }),
3165
- props.sessions.map((session) => {
3166
- const identity = props.identities.find((candidate) => candidate.id === session.identityId);
3167
- const interventionCount = props.interventionCounts.get(session.id) ?? 0;
3168
- return /* @__PURE__ */ jsxs2(
3169
- "button",
3170
- {
3171
- type: "button",
3172
- "aria-label": `${session.name}${identity ? ` \xB7 ${identity.name}` : ""} \xB7 ${placementLabel(t, session)}`,
3173
- "aria-pressed": session.id === props.selectedId,
3174
- onClick: () => props.onSelect(session.id),
3175
- className: cn(
3176
- "flex w-full items-center gap-2 rounded-og-sm px-2 py-1.5 text-left transition hover:bg-og-surface-2",
3177
- session.id === props.selectedId && "bg-og-surface-2"
3178
- ),
3179
- children: [
3180
- /* @__PURE__ */ jsx2(
3181
- "span",
3182
- {
3183
- className: cn(
3184
- "size-1.5 rounded-full",
3185
- session.lifecycle === "active" ? "bg-og-status-running" : "bg-og-fg-subtle"
3186
- )
3187
- }
3188
- ),
3189
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3190
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: session.name }),
3191
- /* @__PURE__ */ jsxs2("span", { className: "block truncate text-og-xs text-og-fg-subtle", children: [
3192
- identity ? `${identity.name} \xB7 ` : "",
3193
- placementLabel(t, session)
3194
- ] })
3195
- ] }),
3196
- interventionCount > 0 ? /* @__PURE__ */ jsx2("span", { className: "rounded-full bg-og-status-waiting/12 px-1.5 py-0.5 text-[10px] font-medium text-og-status-waiting", children: interventionCount }) : null
3197
- ]
3198
- },
3199
- session.id
3200
- );
3201
- })
3202
- ] });
3203
- }
3204
- function BrowserLaunchMenu(props) {
3205
- const t = useOpenGeniText();
3206
- const detailsRef = useViewerMenuDismiss();
3207
- const choose = (choice) => {
3208
- detailsRef.current?.removeAttribute("open");
3209
- props.onCreate(choice);
3210
- };
3211
- const restore = async (identity) => {
3212
- if (await props.onRestore(identity)) detailsRef.current?.removeAttribute("open");
3213
- };
3214
- const busy = props.creating || props.mutatingProfile;
3215
- const activeIdentities = props.identities.filter((identity) => identity.status === "active");
3216
- const archivedIdentities = props.identities.filter((identity) => identity.status === "archived");
3217
- return /* @__PURE__ */ jsxs2("details", { ref: detailsRef, className: cn(props.prominent && "mt-4 inline-block"), children: [
3218
- /* @__PURE__ */ jsxs2(
3219
- "summary",
3220
- {
3221
- onClick: (event) => {
3222
- if (busy) event.preventDefault();
3223
- },
3224
- className: cn(
3225
- "cursor-pointer list-none items-center justify-center gap-1.5 text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg [&::-webkit-details-marker]:hidden",
3226
- props.prominent ? "inline-flex h-8 rounded-og-sm border border-og-border bg-og-surface-1 px-3 text-og-control font-medium text-og-fg" : "grid size-7 place-items-center rounded-og-sm",
3227
- busy && "pointer-events-none opacity-50"
3228
- ),
3229
- "aria-label": t("browserViewer.newBrowser"),
3230
- children: [
3231
- busy ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" }),
3232
- props.prominent ? t("browserViewer.newBrowser") : null,
3233
- props.prominent ? /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3" }) : null
3234
- ]
3235
- }
3236
- ),
3237
- /* @__PURE__ */ jsxs2(
3238
- "div",
3239
- {
3240
- className: cn(
3241
- "absolute z-40 max-h-[calc(100%-3rem)] w-72 max-w-[calc(100%-1rem)] overflow-y-auto rounded-og-md border border-og-border bg-og-surface-1 p-1 text-left shadow-xl",
3242
- props.prominent ? "left-1/2 top-2 -translate-x-1/2" : "right-2 top-10"
3243
- ),
3244
- children: [
3245
- props.attachedDevices.length > 0 || props.attachedBridges.length > 0 ? /* @__PURE__ */ jsxs2("div", { className: "pb-1", children: [
3246
- /* @__PURE__ */ jsx2("p", { className: "px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: t("browserViewer.connectedChrome") }),
3247
- props.attachedDevices.map((device) => /* @__PURE__ */ jsxs2(
3248
- "button",
3249
- {
3250
- type: "button",
3251
- onClick: () => choose({ kind: "attached", device }),
3252
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3253
- children: [
3254
- /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3255
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3256
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: device.profileLabel ?? device.name }),
3257
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-xs text-og-fg-subtle", children: t("browserViewer.openTabs", {
3258
- browserName: device.browserName,
3259
- count: device.tabCount
3260
- }) })
3261
- ] }),
3262
- /* @__PURE__ */ jsx2("span", { className: "size-1.5 shrink-0 rounded-full bg-og-status-running" })
3263
- ]
3264
- },
3265
- `${device.workspaceId}:${device.id}`
3266
- )),
3267
- props.attachedBridges.length > 0 ? props.setupUrl ? /* @__PURE__ */ jsxs2(
3268
- "a",
3269
- {
3270
- href: props.setupUrl,
3271
- target: "_blank",
3272
- rel: "noreferrer",
3273
- onClick: () => detailsRef.current?.removeAttribute("open"),
3274
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3275
- children: [
3276
- /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3277
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3278
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: props.attachedDevices.length > 0 ? t("browserViewer.connectAnotherChromeProfile") : t("browserViewer.connectThisChromeProfile") }),
3279
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-xs text-og-fg-subtle", children: t("browserViewer.machineConnectedChromeExtensionMissing") })
3280
- ] })
3281
- ]
3282
- }
3283
- ) : /* @__PURE__ */ jsxs2("div", { className: "flex w-full items-center gap-2 px-2 py-2 text-left", children: [
3284
- /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3285
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3286
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: t("browserViewer.chromeConnectionReady") }),
3287
- /* @__PURE__ */ jsx2("span", { className: "block text-og-xs leading-4 text-og-fg-subtle", children: t("browserViewer.installTheOpengeniBrowserExtension", {
3288
- extensionName: props.extensionName ?? "Opengeni Browser"
3289
- }) })
3290
- ] })
3291
- ] }) : null
3292
- ] }) : null,
3293
- /* @__PURE__ */ jsx2(
3294
- "p",
3295
- {
3296
- className: cn(
3297
- "px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle",
3298
- (props.attachedDevices.length > 0 || props.attachedBridges.length > 0) && "border-t border-og-border"
3299
- ),
3300
- children: t("browserViewer.openIsolatedBrowser")
3301
- }
3302
- ),
3303
- /* @__PURE__ */ jsxs2(
3304
- "button",
3305
- {
3306
- type: "button",
3307
- onClick: () => choose({ kind: "clean" }),
3308
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3309
- children: [
3310
- /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-3.5 text-og-fg-muted" }),
3311
- /* @__PURE__ */ jsxs2("span", { children: [
3312
- /* @__PURE__ */ jsx2("span", { className: "block text-og-control text-og-fg", children: t("browserViewer.freshBrowser") }),
3313
- /* @__PURE__ */ jsx2("span", { className: "block text-og-xs text-og-fg-subtle", children: t("browserViewer.visualBrowserNoSavedState") })
3314
- ] })
3315
- ]
3316
- }
3317
- ),
3318
- activeIdentities.length > 0 ? /* @__PURE__ */ jsx2("div", { className: "mt-1 border-t border-og-border pt-1", children: activeIdentities.map((identity) => /* @__PURE__ */ jsxs2(
3319
- "button",
3320
- {
3321
- type: "button",
3322
- onClick: () => choose({ kind: "profile", identityId: identity.id }),
3323
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3324
- children: [
3325
- /* @__PURE__ */ jsx2(UserRoundIcon, { className: "size-3.5 text-og-fg-muted" }),
3326
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0", children: [
3327
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: identity.name }),
3328
- /* @__PURE__ */ jsx2("span", { className: "block text-og-xs text-og-fg-subtle", children: identity.defaultRevisionId ? t("browserViewer.savedVersions", { count: identity.revisionCount }) : t("browserViewer.readyForFirstSignIn") })
3329
- ] })
3330
- ]
3331
- },
3332
- identity.id
3333
- )) }) : null,
3334
- archivedIdentities.length > 0 ? /* @__PURE__ */ jsxs2("details", { className: "mt-1 border-t border-og-border pt-1", children: [
3335
- /* @__PURE__ */ jsxs2("summary", { className: "flex cursor-pointer list-none items-center gap-1.5 rounded-og-sm px-2 py-1.5 text-og-xs text-og-fg-subtle transition hover:bg-og-surface-2 hover:text-og-fg [&::-webkit-details-marker]:hidden", children: [
3336
- /* @__PURE__ */ jsx2(ArchiveIcon, { className: "size-3" }),
3337
- " ",
3338
- t("browserViewer.hiddenProfilesLength", { length: archivedIdentities.length }),
3339
- /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "ml-auto size-3" })
3340
- ] }),
3341
- archivedIdentities.map((identity) => /* @__PURE__ */ jsxs2(
3342
- "button",
3343
- {
3344
- type: "button",
3345
- disabled: busy,
3346
- onClick: () => void restore(identity),
3347
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2 disabled:opacity-50",
3348
- children: [
3349
- /* @__PURE__ */ jsx2(RotateCcwIcon, { className: "size-3.5 text-og-fg-muted" }),
3350
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate text-og-control text-og-fg", children: t("browserViewer.restoreName", { name: identity.name }) })
3351
- ]
3352
- },
3353
- identity.id
3354
- ))
3355
- ] }) : null
3356
- ]
3357
- }
3358
- )
3359
- ] });
3360
- }
3361
- function BrowserProfileMenu(props) {
3362
- const t = useOpenGeniText();
3363
- const detailsRef = useViewerMenuDismiss();
3364
- const nameInputId = useId();
3365
- const [name, setName] = useState9("");
3366
- const attached = props.session?.placement.kind === "attached_device";
3367
- const canSave = (props.session?.capabilities.identityPublication ?? false) && props.identity?.status !== "archived";
3368
- const revisions = props.identity && props.history?.identityId === props.identity.id ? [...props.history.revisions].sort((left, right) => right.ordinal - left.ordinal) : [];
3369
- const save = async (newProfileName) => {
3370
- if (await props.onSave(newProfileName)) {
3371
- setName("");
3372
- detailsRef.current?.removeAttribute("open");
3373
- }
3374
- };
3375
- const openVersion = (identityId, baseRevisionId) => {
3376
- detailsRef.current?.removeAttribute("open");
3377
- props.onOpenVersion(identityId, baseRevisionId);
3378
- };
3379
- const versionLabel = attached ? "live" : props.identity ? props.baseRevisionOrdinal ? `v${props.baseRevisionOrdinal}` : props.session?.baseRevisionId ? "saved" : "unsaved" : "temporary";
3380
- return /* @__PURE__ */ jsxs2("details", { ref: detailsRef, className: "min-w-0", children: [
3381
- /* @__PURE__ */ jsxs2("summary", { className: "flex h-7 max-w-40 cursor-pointer list-none items-center gap-1.5 rounded-og-sm px-2 text-og-xs text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg [&::-webkit-details-marker]:hidden", children: [
3382
- props.saving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }) : attached ? /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3" }) : /* @__PURE__ */ jsx2(UserRoundIcon, { className: "size-3" }),
3383
- /* @__PURE__ */ jsx2("span", { className: "truncate", children: attached ? props.session?.name : props.identity?.name ?? t("browserViewer.temporary") }),
3384
- attached || props.identity ? /* @__PURE__ */ jsxs2("span", { className: "shrink-0 text-og-fg-subtle", children: [
3385
- "\xB7 ",
3386
- versionLabel
3387
- ] }) : null,
3388
- /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3 shrink-0 text-og-fg-subtle" })
3389
- ] }),
3390
- /* @__PURE__ */ jsxs2("div", { className: "absolute right-2 top-10 z-40 max-h-[calc(100%-3rem)] w-72 max-w-[calc(100%-1rem)] overflow-y-auto rounded-og-md border border-og-border bg-og-surface-1 p-3 shadow-xl", children: [
3391
- /* @__PURE__ */ jsxs2("div", { className: "flex items-start gap-2", children: [
3392
- /* @__PURE__ */ jsx2("span", { className: "grid size-7 shrink-0 place-items-center rounded-og-sm bg-og-surface-2 text-og-fg-muted", children: attached ? /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx2(UserRoundIcon, { className: "size-3.5" }) }),
3393
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0", children: [
3394
- /* @__PURE__ */ jsx2("p", { className: "truncate text-og-control font-medium text-og-fg", children: attached ? props.session?.name : props.identity?.name ?? t("browserViewer.temporaryBrowser") }),
3395
- /* @__PURE__ */ jsx2("p", { className: "mt-0.5 text-og-xs leading-4 text-og-fg-subtle", children: attached ? t("browserViewer.thisSessionDrivesTheExisting") : props.identity?.status === "archived" ? t("browserViewer.hiddenFromNewBrowsersThis") : props.identity ? props.baseRevisionOrdinal ? t("browserViewer.startedFromVersionBaserevisionordinal", {
3396
- baseRevisionOrdinal: props.baseRevisionOrdinal
3397
- }) : t("browserViewer.notSavedYet") : t("browserViewer.thisBrowserIsNotReusable") })
3398
- ] })
3399
- ] }),
3400
- props.identity && revisions.length > 0 ? /* @__PURE__ */ jsxs2("div", { className: "mt-3 border-t border-og-border pt-2", children: [
3401
- /* @__PURE__ */ jsx2("p", { className: "px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: t("browserViewer.savedVersions2") }),
3402
- /* @__PURE__ */ jsx2("div", { className: "mt-1 max-h-40 overflow-y-auto", children: revisions.map((revision) => {
3403
- const isDefault = revision.id === props.identity?.defaultRevisionId;
3404
- const isCurrent = revision.ordinal === props.baseRevisionOrdinal;
3405
- const materialization = revisionMaterializationSummary(t, revision);
3406
- return /* @__PURE__ */ jsxs2(
3407
- "div",
3408
- {
3409
- className: "flex w-full items-center gap-1 rounded-og-sm transition hover:bg-og-surface-2",
3410
- children: [
3411
- /* @__PURE__ */ jsxs2(
3412
- "button",
3413
- {
3414
- type: "button",
3415
- disabled: props.saving || props.identity?.status === "archived",
3416
- "aria-label": t("browserViewer.openNameVersionOrdinal", {
3417
- name: props.identity.name,
3418
- ordinal: revision.ordinal
3419
- }),
3420
- onClick: () => openVersion(props.identity.id, revision.id),
3421
- className: "flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left disabled:opacity-50",
3422
- children: [
3423
- /* @__PURE__ */ jsx2("span", { className: "grid size-4 place-items-center text-og-fg-muted", children: isCurrent ? /* @__PURE__ */ jsx2(CheckIcon, { className: "size-3.5 text-og-accent" }) : null }),
3424
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3425
- /* @__PURE__ */ jsx2("span", { className: "block text-og-control text-og-fg", children: t("browserViewer.versionOrdinal", { ordinal: revision.ordinal }) }),
3426
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-[10px] text-og-fg-subtle", children: materialization.label })
3427
- ] }),
3428
- isCurrent ? /* @__PURE__ */ jsx2("span", { className: "text-[10px] text-og-fg-subtle", children: t("browserViewer.current") }) : null
3429
- ]
3430
- }
3431
- ),
3432
- /* @__PURE__ */ jsx2(
3433
- "button",
3434
- {
3435
- type: "button",
3436
- disabled: isDefault || props.saving || props.identity?.status === "archived",
3437
- "aria-label": isDefault ? t("browserViewer.nameVersionOrdinalIsThe", {
3438
- name: props.identity.name,
3439
- ordinal: revision.ordinal
3440
- }) : t("browserViewer.useNameVersionOrdinalBy", {
3441
- name: props.identity.name,
3442
- ordinal: revision.ordinal
3443
- }),
3444
- title: isDefault ? t("browserViewer.defaultVersion") : t("browserViewer.useByDefault"),
3445
- onClick: () => void props.onUpdate(props.identity, { defaultRevisionId: revision.id }),
3446
- className: "mr-1 shrink-0 rounded-og-sm px-2 py-1 text-[10px] text-og-fg-subtle transition hover:bg-og-surface-3 hover:text-og-fg disabled:cursor-default disabled:opacity-70",
3447
- children: isDefault ? t("browserViewer.default") : t("browserViewer.makeDefault")
3448
- }
3449
- )
3450
- ]
3451
- },
3452
- revision.id
3453
- );
3454
- }) }),
3455
- /* @__PURE__ */ jsx2("p", { className: "mt-1 px-2 text-[10px] leading-4 text-og-fg-subtle", children: t("browserViewer.changingTheDefaultAffectsOnly") })
3456
- ] }) : props.identity && props.history?.identityId === props.identity.id && props.history.loading ? /* @__PURE__ */ jsxs2("p", { className: "mt-3 flex items-center gap-1.5 border-t border-og-border px-2 pt-2 text-og-xs text-og-fg-subtle", children: [
3457
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }),
3458
- " ",
3459
- t("browserViewer.loadingSavedVersions")
3460
- ] }) : null,
3461
- props.identity && props.authConnections.length > 0 ? /* @__PURE__ */ jsxs2("div", { className: "mt-3 border-t border-og-border pt-2", children: [
3462
- /* @__PURE__ */ jsx2("p", { className: "px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: t("browserViewer.loginHealth") }),
3463
- /* @__PURE__ */ jsx2("div", { className: "mt-1 space-y-1", children: props.authConnections.map((connection) => {
3464
- const health = siteAuthHealth(t, connection);
3465
- return /* @__PURE__ */ jsxs2(
3466
- "div",
3467
- {
3468
- className: "flex items-start gap-2 rounded-og-sm px-2 py-1.5",
3469
- children: [
3470
- /* @__PURE__ */ jsx2("span", { className: cn("mt-1 size-1.5 shrink-0 rounded-full", health.dotClass) }),
3471
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3472
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: connection.name }),
3473
- /* @__PURE__ */ jsxs2("span", { className: "block truncate text-[10px] text-og-fg-subtle", children: [
3474
- connection.accountLabel,
3475
- " \xB7 ",
3476
- health.label
3477
- ] })
3478
- ] })
3479
- ]
3480
- },
3481
- connection.id
3482
- );
3483
- }) })
3484
- ] }) : null,
3485
- canSave ? props.identity ? /* @__PURE__ */ jsxs2(
3486
- "button",
3487
- {
3488
- type: "button",
3489
- onClick: () => void save(),
3490
- disabled: props.saving,
3491
- className: "mt-3 flex h-8 w-full items-center justify-center gap-1.5 rounded-og-sm border border-og-border bg-og-surface-2 px-3 text-og-control font-medium text-og-fg transition hover:bg-og-surface-3 disabled:opacity-50",
3492
- children: [
3493
- props.saving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx2(SaveIcon, { className: "size-3.5" }),
3494
- props.saving ? t("browserViewer.savingBrowserVersion") : t("browserViewer.saveNewVersion")
3495
- ]
3496
- }
3497
- ) : /* @__PURE__ */ jsxs2(
3498
- "form",
3499
- {
3500
- className: "mt-3",
3501
- onSubmit: (event) => {
3502
- event.preventDefault();
3503
- if (name.trim()) void save(name);
3504
- },
3505
- children: [
3506
- /* @__PURE__ */ jsx2("label", { className: "text-og-xs font-medium text-og-fg-muted", htmlFor: nameInputId, children: t("browserViewer.profileName") }),
3507
- /* @__PURE__ */ jsxs2("div", { className: "mt-1 flex gap-1.5", children: [
3508
- /* @__PURE__ */ jsx2(
3509
- "input",
3510
- {
3511
- id: nameInputId,
3512
- value: name,
3513
- onInput: (event) => setName(event.currentTarget.value),
3514
- maxLength: 200,
3515
- placeholder: t("browserViewer.work"),
3516
- className: "h-8 min-w-0 flex-1 rounded-og-sm border border-og-border bg-og-bg px-2 text-og-control text-og-fg placeholder:text-og-fg-subtle focus:border-og-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent"
3517
- }
3518
- ),
3519
- /* @__PURE__ */ jsxs2(
3520
- "button",
3521
- {
3522
- type: "submit",
3523
- disabled: !name.trim() || props.saving,
3524
- className: "inline-flex h-8 items-center gap-1 rounded-og-sm border border-og-primary-border bg-og-primary text-og-primary-fg px-2.5 text-og-control font-medium transition hover:bg-og-primary-hover disabled:opacity-50",
3525
- children: [
3526
- props.saving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx2(SaveIcon, { className: "size-3.5" }),
3527
- t("browserViewer.save")
3528
- ]
3529
- }
3530
- )
3531
- ] })
3532
- ]
3533
- }
3534
- ) : /* @__PURE__ */ jsx2("p", { className: "mt-3 rounded-og-sm bg-og-surface-2 px-2.5 py-2 text-og-xs text-og-fg-subtle", children: attached ? t("browserViewer.chromeKeepsThisProfileS") : props.identity?.status === "archived" ? t("browserViewer.restoreThisProfileBeforeSaving") : t("browserViewer.thisBrowserCannotSaveReusable") }),
3535
- !attached && props.identity ? /* @__PURE__ */ jsxs2(
3536
- "button",
3537
- {
3538
- type: "button",
3539
- disabled: props.saving,
3540
- onClick: () => void props.onUpdate(props.identity, {
3541
- status: props.identity.status === "active" ? "archived" : "active"
3542
- }),
3543
- className: "mt-2 flex h-8 w-full items-center justify-center gap-1.5 rounded-og-sm px-3 text-og-control text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-50",
3544
- children: [
3545
- props.identity.status === "active" ? /* @__PURE__ */ jsx2(ArchiveIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx2(RotateCcwIcon, { className: "size-3.5" }),
3546
- props.identity.status === "active" ? t("browserViewer.hideFromNewBrowsers") : t("browserViewer.restoreProfile")
3547
- ]
3548
- }
3549
- ) : null,
3550
- canSave ? /* @__PURE__ */ jsx2("p", { className: "mt-2 text-[10px] leading-4 text-og-fg-subtle", children: t("browserViewer.savingRestartsThisBrowserSave") }) : null
3551
- ] })
3552
- ] });
3553
- }
3554
- function revisionMaterializationSummary(t, revision) {
3555
- const materializations = revision.components.map((component) => component.materialization);
3556
- const placementBound = materializations.find(
3557
- (materialization) => materialization.portability === "placement_bound"
3558
- );
3559
- if (placementBound) {
3560
- return {
3561
- label: placementBound.reason ? t("browserViewer.thisMachineOnlyReason", { reason: placementBound.reason }) : t("browserViewer.thisMachineOnly")
3562
- };
3563
- }
3564
- const providerBound = materializations.find(
3565
- (materialization) => materialization.portability === "provider_bound"
3566
- );
3567
- if (providerBound) {
3568
- return {
3569
- label: providerBound.reason ? t("browserViewer.providerBoundReason", { reason: providerBound.reason }) : t("browserViewer.providerBound")
3570
- };
3571
- }
3572
- return { label: t("browserViewer.portableBrowserData") };
3573
- }
3574
- function siteAuthHealth(t, connection) {
3575
- switch (connection.verificationState) {
3576
- case "verified":
3577
- return { label: t("browserViewer.verified"), dotClass: "bg-og-status-running" };
3578
- case "needs_repair":
3579
- return { label: t("browserViewer.signInNeedsAttention"), dotClass: "bg-og-status-waiting" };
3580
- case "failed":
3581
- return { label: t("browserViewer.verificationFailed"), dotClass: "bg-og-status-failed" };
3582
- case "unknown":
3583
- return { label: t("browserViewer.notCheckedYet"), dotClass: "bg-og-fg-subtle" };
3584
- }
3585
- }
3586
- function MenuButton(props) {
3587
- return /* @__PURE__ */ jsx2(
3588
- "button",
3589
- {
3590
- type: "button",
3591
- onClick: props.onClick,
3592
- disabled: props.disabled,
3593
- className: "flex h-7 flex-1 items-center justify-center gap-1 rounded-og-sm px-2 text-og-control text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-50",
3594
- children: props.children
3595
- }
3596
- );
3597
- }
3598
- function BrowserTabs(props) {
3599
- const t = useOpenGeniText();
3600
- const pages = props.targets.filter((target) => target.kind === "page" || target.kind === "popup");
3601
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-9 shrink-0 items-end gap-px overflow-x-auto border-b border-og-border bg-og-surface-1 px-1 pt-1", children: [
3602
- pages.map((target) => /* @__PURE__ */ jsxs2(
3603
- "div",
3604
- {
3605
- className: cn(
3606
- "group flex h-8 min-w-24 max-w-48 items-center rounded-t-og-sm border border-b-0 border-transparent px-2",
3607
- target.id === props.selectedTargetId ? "border-og-border bg-og-bg text-og-fg" : "text-og-fg-muted hover:bg-og-surface-1"
3608
- ),
3609
- children: [
3610
- /* @__PURE__ */ jsx2(
3611
- "button",
3612
- {
3613
- type: "button",
3614
- onClick: () => props.onSelect(target.id),
3615
- className: "min-w-0 flex-1 truncate text-left text-og-control",
3616
- children: target.title || shortUrl(target.url)
3617
- }
3618
- ),
3619
- props.tabControl ? /* @__PURE__ */ jsx2(
3620
- "button",
3621
- {
3622
- type: "button",
3623
- onClick: () => props.onClose(target.id),
3624
- disabled: props.mutating,
3625
- className: "ml-1 grid size-4 shrink-0 place-items-center rounded opacity-0 transition hover:bg-og-surface-3 group-hover:opacity-100 focus:opacity-100 disabled:opacity-30",
3626
- "aria-label": t("browserViewer.closeTitle", { title: target.title || "tab" }),
3627
- children: /* @__PURE__ */ jsx2(XIcon, { className: "size-3" })
3628
- }
3629
- ) : null
3630
- ]
3631
- },
3632
- target.id
3633
- )),
3634
- props.tabControl ? /* @__PURE__ */ jsx2(
3635
- "button",
3636
- {
3637
- type: "button",
3638
- onClick: props.onOpen,
3639
- disabled: props.mutating,
3640
- className: "mb-1 grid size-6 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-40",
3641
- "aria-label": t("browserViewer.newTab"),
3642
- children: /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" })
3643
- }
3644
- ) : null
3645
- ] });
3646
- }
3647
- function BrowserAddressBar(props) {
3648
- const t = useOpenGeniText();
3649
- const [draft, setDraft] = useState9(props.target?.url ?? "");
3650
- const focusedRef = useRef9(false);
3651
- const historyPendingRef = useRef9(false);
3652
- const [historyPending, setHistoryPending] = useState9(false);
3653
- useEffect9(() => {
3654
- if (!focusedRef.current) setDraft(props.target?.url ?? "");
3655
- }, [props.target?.id, props.target?.url]);
3656
- const submit = (event) => {
3657
- event.preventDefault();
3658
- if (historyPendingRef.current) return;
3659
- const normalized = normalizeBrowserAddress(draft);
3660
- if (normalized) props.onNavigate(normalized);
3661
- };
3662
- const navigateHistory = async (direction) => {
3663
- if (!props.target || props.loading || historyPendingRef.current) return;
3664
- historyPendingRef.current = true;
3665
- setHistoryPending(true);
3666
- try {
3667
- await props.onHistory(direction);
3668
- } finally {
3669
- historyPendingRef.current = false;
3670
- setHistoryPending(false);
3671
- }
3672
- };
3673
- return /* @__PURE__ */ jsxs2(
3674
- "form",
3675
- {
3676
- onSubmit: submit,
3677
- "aria-busy": historyPending || void 0,
3678
- className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-og-border bg-og-bg px-2",
3679
- children: [
3680
- ["back", "forward"].map((direction) => /* @__PURE__ */ jsx2(
3681
- "button",
3682
- {
3683
- type: "button",
3684
- onClick: () => void navigateHistory(direction),
3685
- disabled: !props.target || props.loading,
3686
- "aria-disabled": historyPending || void 0,
3687
- className: cn(
3688
- "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-35",
3689
- historyPending && "opacity-50"
3690
- ),
3691
- "aria-label": direction === "back" ? t("browserViewer.back") : t("browserViewer.forward"),
3692
- title: direction === "back" ? t("browserViewer.back") : t("browserViewer.forward"),
3693
- children: direction === "back" ? /* @__PURE__ */ jsx2(ArrowLeftIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx2(ArrowRightIcon, { className: "size-3.5" })
3694
- },
3695
- direction
3696
- )),
3697
- /* @__PURE__ */ jsx2(
3698
- "button",
3699
- {
3700
- type: "button",
3701
- onClick: props.onReload,
3702
- disabled: !props.target || props.loading || historyPending,
3703
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-35",
3704
- "aria-label": t("browserViewer.reload"),
3705
- children: /* @__PURE__ */ jsx2(
3706
- RefreshCwIcon,
3707
- {
3708
- className: cn("size-3.5", (props.loading || historyPending) && "animate-spin")
3709
- }
3710
- )
3711
- }
3712
- ),
3713
- /* @__PURE__ */ jsxs2("div", { className: "flex h-7 min-w-0 flex-1 items-center gap-2 rounded-og-sm border border-og-border bg-og-surface-1 px-2 focus-within:border-og-accent/60", children: [
3714
- /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-3 shrink-0 text-og-fg-subtle" }),
3715
- /* @__PURE__ */ jsx2(
3716
- "input",
3717
- {
3718
- value: draft,
3719
- onChange: (event) => setDraft(event.target.value),
3720
- onFocus: () => {
3721
- focusedRef.current = true;
3722
- },
3723
- onBlur: () => {
3724
- focusedRef.current = false;
3725
- },
3726
- onKeyDown: (event) => {
3727
- if (event.key !== "Enter") return;
3728
- event.preventDefault();
3729
- if (historyPendingRef.current) return;
3730
- const normalized = normalizeBrowserAddress(draft);
3731
- if (normalized) props.onNavigate(normalized);
3732
- },
3733
- disabled: !props.target,
3734
- className: "min-w-0 flex-1 bg-transparent text-og-control text-og-fg placeholder:text-og-fg-subtle focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50",
3735
- "aria-label": t("browserViewer.address"),
3736
- spellCheck: false,
3737
- placeholder: t("browserViewer.searchOrEnterAddress")
3738
- }
3739
- )
3740
- ] })
3741
- ]
3742
- }
3743
- );
3744
- }
3745
- function BrowserViewport(props) {
3746
- const t = useOpenGeniText();
3747
- const canvasRef = useRef9(null);
3748
- const inputRef = useRef9(null);
3749
- const [selectPopup, setSelectPopup] = useState9(null);
3750
- const inputSequenceRef = useRef9(0);
3751
- const dismissSelectPopup = useCallback8(() => {
3752
- inputSequenceRef.current += 1;
3753
- setSelectPopup({ observation: null, anchor: null });
3754
- }, []);
3755
- const composingRef = useRef9(false);
3756
- const pointerStartRef = useRef9(null);
3757
- const lastClickRef = useRef9(null);
3758
- const wheelRef = useRef9(null);
3759
- const pendingTextRef = useRef9(null);
3760
- const actionRef = useRef9(props.onAction);
3761
- const readClipboardRef = useRef9(props.onReadClipboard);
3762
- const observeInputRef = useRef9(props.onObserveForInput);
3763
- const errorRef = useRef9(props.onError);
3764
- const actionTailRef = useRef9(Promise.resolve());
3765
- const actionQueueEpochRef = useRef9(0);
3766
- const queuedTypingRef = useRef9(null);
3767
- const queuedFrameRef = useRef9(null);
3768
- const currentFrameRef = useRef9(props.frame);
3769
- const paintedFrameRef = useRef9(null);
3770
- const [paintedFrame, setPaintedFrame] = useState9(null);
3771
- const decodingFrameRef = useRef9(false);
3772
- const mountedRef = useRef9(true);
3773
- actionRef.current = props.onAction;
3774
- readClipboardRef.current = props.onReadClipboard;
3775
- observeInputRef.current = props.onObserveForInput;
3776
- errorRef.current = props.onError;
3777
- const clearBufferedInput = useCallback8(() => {
3778
- dismissSelectPopup();
3779
- if (wheelRef.current?.timer) clearTimeout(wheelRef.current.timer);
3780
- if (pendingTextRef.current?.timer) clearTimeout(pendingTextRef.current.timer);
3781
- wheelRef.current = null;
3782
- pendingTextRef.current = null;
3783
- queuedTypingRef.current = null;
3784
- pointerStartRef.current = null;
3785
- lastClickRef.current = null;
3786
- composingRef.current = false;
3787
- if (inputRef.current) inputRef.current.value = "";
3788
- }, [dismissSelectPopup]);
3789
- const paintQueuedFrames = useCallback8(() => {
3790
- if (decodingFrameRef.current) return;
3791
- decodingFrameRef.current = true;
3792
- void (async () => {
3793
- try {
3794
- while (mountedRef.current) {
3795
- const frame = queuedFrameRef.current;
3796
- queuedFrameRef.current = null;
3797
- if (!frame) break;
3798
- let objectUrl = null;
3799
- try {
3800
- const blob = new Blob([frame.data], {
3801
- type: frame.mediaType
3802
- });
3803
- if (typeof createImageBitmap === "function") {
3804
- const bitmap = await createImageBitmap(blob);
3805
- try {
3806
- const canvas2 = canvasRef.current;
3807
- if (mountedRef.current && canvas2 && currentFrameRef.current && sameBrowserDocument(frame, currentFrameRef.current)) {
3808
- paintCanvas(canvas2, bitmap, frame.width, frame.height);
3809
- paintedFrameRef.current = frame;
3810
- setPaintedFrame(frame);
3811
- }
3812
- } finally {
3813
- bitmap.close();
3814
- }
3815
- continue;
3816
- }
3817
- objectUrl = URL.createObjectURL(blob);
3818
- const image = await loadImage(objectUrl);
3819
- const canvas = canvasRef.current;
3820
- if (mountedRef.current && canvas && currentFrameRef.current && sameBrowserDocument(frame, currentFrameRef.current)) {
3821
- paintCanvas(canvas, image, frame.width, frame.height);
3822
- paintedFrameRef.current = frame;
3823
- setPaintedFrame(frame);
3824
- }
3825
- } catch (cause) {
3826
- if (mountedRef.current && currentFrameRef.current && sameBrowserDocument(frame, currentFrameRef.current))
3827
- errorRef.current(cause);
3828
- } finally {
3829
- if (objectUrl) URL.revokeObjectURL(objectUrl);
3830
- }
3831
- }
3832
- } finally {
3833
- decodingFrameRef.current = false;
3834
- if (mountedRef.current && queuedFrameRef.current) paintQueuedFrames();
3835
- }
3836
- })();
3837
- }, []);
3838
- useLayoutEffect2(() => {
3839
- const keyboardInput = inputRef.current;
3840
- const focusHandoff = props.focusHandoffRef;
3841
- mountedRef.current = true;
3842
- if (focusHandoff.current === props.focusScope) {
3843
- keyboardInput?.focus({ preventScroll: true });
3844
- }
3845
- focusHandoff.current = null;
3846
- return () => {
3847
- if (document.activeElement === keyboardInput) {
3848
- focusHandoff.current = props.focusScope;
3849
- }
3850
- mountedRef.current = false;
3851
- actionQueueEpochRef.current += 1;
3852
- queuedFrameRef.current = null;
3853
- clearBufferedInput();
3854
- };
3855
- }, [clearBufferedInput, props.focusHandoffRef, props.focusScope]);
3856
- useLayoutEffect2(() => {
3857
- if (currentFrameRef.current && !props.frame) {
3858
- actionQueueEpochRef.current += 1;
3859
- clearBufferedInput();
3860
- }
3861
- currentFrameRef.current = props.frame;
3862
- if (!props.frame) {
3863
- queuedFrameRef.current = null;
3864
- paintedFrameRef.current = null;
3865
- setPaintedFrame(null);
3866
- return;
3867
- }
3868
- queuedFrameRef.current = props.frame;
3869
- paintQueuedFrames();
3870
- }, [clearBufferedInput, paintQueuedFrames, props.frame]);
3871
- const enqueue = useCallback8(
3872
- (action, frame, after, selectAnchor) => {
3873
- const inputSequence = ++inputSequenceRef.current;
3874
- setSelectPopup({ observation: null, anchor: null });
3875
- frame = frame ? {
3876
- browserSessionId: frame.browserSessionId,
3877
- controllerGeneration: frame.controllerGeneration,
3878
- targetId: frame.targetId,
3879
- targetGeneration: frame.targetGeneration,
3880
- documentGeneration: frame.documentGeneration,
3881
- frameId: frame.frameId
3882
- } : null;
3883
- const epoch = actionQueueEpochRef.current;
3884
- const attachment = props.inputBatchAttachment;
3885
- const canBatchTyping = action.type === "type" && !after && frame && attachment?.fencedInputBatches === true && attachment.browserSessionId === frame.browserSessionId && attachment.controllerGeneration === frame.controllerGeneration && attachment.targetId === frame.targetId && Date.parse(attachment.expiresAt) > Date.now();
3886
- const previous = queuedTypingRef.current;
3887
- if (canBatchTyping && frame && previous && previous.epoch === epoch && sameFrameFence(previous.frame, frame) && previous.actions.length < 16) {
3888
- previous.actions.push(action);
3889
- return;
3890
- }
3891
- const typing = canBatchTyping && frame ? { actions: [action], frame, epoch } : null;
3892
- queuedTypingRef.current = typing;
3893
- actionTailRef.current = actionTailRef.current.catch(() => void 0).then(async () => {
3894
- if (!mountedRef.current || epoch !== actionQueueEpochRef.current) return;
3895
- if (queuedTypingRef.current === typing) queuedTypingRef.current = null;
3896
- const dispatchedAction = typing && typing.actions.length > 1 ? { type: "batch", actions: typing.actions, fenceEachAction: true } : action;
3897
- const receipt = await actionRef.current(dispatchedAction, frame);
3898
- if (!mountedRef.current || epoch !== actionQueueEpochRef.current) return;
3899
- const keyboardSelect = dispatchedAction.type === "press" && dispatchedAction.key === "Alt+ArrowDown";
3900
- if ((selectAnchor || keyboardSelect) && inputSequence === inputSequenceRef.current) {
3901
- const observation = keyboardSelect ? await observeInputRef.current() : receipt.observation;
3902
- if (mountedRef.current && epoch === actionQueueEpochRef.current && inputSequence === inputSequenceRef.current && observation) {
3903
- setSelectPopup({ observation, anchor: selectAnchor ?? null });
3904
- }
3905
- }
3906
- await after?.(receipt);
3907
- }).catch((cause) => {
3908
- if (!mountedRef.current || epoch !== actionQueueEpochRef.current) return;
3909
- actionQueueEpochRef.current += 1;
3910
- clearBufferedInput();
3911
- errorRef.current(cause);
3912
- });
3913
- },
3914
- [clearBufferedInput, props.inputBatchAttachment]
3915
- );
3916
- const point = useCallback8(
3917
- (frame, clientX, clientY) => browserPoint(canvasRef.current, frame, clientX, clientY),
3918
- []
3919
- );
3920
- const flushPendingText = useCallback8(() => {
3921
- const pending = pendingTextRef.current;
3922
- if (!pending) return;
3923
- clearTimeout(pending.timer);
3924
- pendingTextRef.current = null;
3925
- enqueue({ type: "type", text: pending.text }, pending.frame);
3926
- }, [enqueue]);
3927
- const flushPendingClick = useCallback8(() => {
3928
- lastClickRef.current = null;
3929
- }, []);
3930
- const flushPendingWheel = useCallback8(() => {
3931
- const batch = wheelRef.current;
3932
- if (!batch) return;
3933
- if (batch.timer) clearTimeout(batch.timer);
3934
- wheelRef.current = null;
3935
- enqueue(
3936
- {
3937
- type: "pointer",
3938
- action: "scroll",
3939
- x: batch.x,
3940
- y: batch.y,
3941
- deltaX: batch.deltaX,
3942
- deltaY: batch.deltaY
3943
- },
3944
- batch.frame
3945
- );
3946
- }, [enqueue]);
3947
- const pointerDown = (event) => {
3948
- const frame = paintedFrameRef.current;
3949
- if (!frame || event.button !== 0) return;
3950
- event.preventDefault();
3951
- dismissSelectPopup();
3952
- flushPendingWheel();
3953
- flushPendingText();
3954
- pointerStartRef.current = {
3955
- x: event.clientX,
3956
- y: event.clientY,
3957
- pointerId: event.pointerId,
3958
- frame
3959
- };
3960
- event.currentTarget.setPointerCapture?.(event.pointerId);
3961
- inputRef.current?.focus({ preventScroll: true });
3962
- };
3963
- const pointerUp = (event) => {
3964
- const start = pointerStartRef.current;
3965
- pointerStartRef.current = null;
3966
- if (!start || start.pointerId !== event.pointerId) return;
3967
- const from = point(start.frame, start.x, start.y);
3968
- const to = point(start.frame, event.clientX, event.clientY);
3969
- if (!from || !to) return;
3970
- if (Math.hypot(event.clientX - start.x, event.clientY - start.y) > 5) {
3971
- flushPendingClick();
3972
- enqueue(
3973
- {
3974
- type: "pointer",
3975
- action: "drag",
3976
- x: from.x,
3977
- y: from.y,
3978
- endX: to.x,
3979
- endY: to.y
3980
- },
3981
- start.frame
3982
- );
3983
- return;
3984
- }
3985
- const now = Date.now();
3986
- const previous = lastClickRef.current;
3987
- if (previous && now - previous.at < 280 && Math.hypot(previous.x - to.x, previous.y - to.y) < 6 && sameFrameFence(previous.frame, start.frame)) {
3988
- lastClickRef.current = null;
3989
- enqueue({ type: "pointer", action: "click", clickCount: 2, x: to.x, y: to.y }, start.frame);
3990
- return;
3991
- }
3992
- lastClickRef.current = { at: now, x: to.x, y: to.y, frame: start.frame };
3993
- const viewportBounds = canvasRef.current?.parentElement?.getBoundingClientRect();
3994
- enqueue(
3995
- { type: "pointer", action: "click", x: to.x, y: to.y },
3996
- start.frame,
3997
- void 0,
3998
- viewportBounds ? { x: event.clientX - viewportBounds.left, y: event.clientY - viewportBounds.top + 8 } : void 0
3999
- );
4000
- };
4001
- const contextMenu = (event) => {
4002
- event.preventDefault();
4003
- const frame = paintedFrameRef.current;
4004
- if (!frame) return;
4005
- flushPendingWheel();
4006
- flushPendingText();
4007
- flushPendingClick();
4008
- const at = point(frame, event.clientX, event.clientY);
4009
- if (at) enqueue({ type: "pointer", action: "click", x: at.x, y: at.y, button: "right" }, frame);
4010
- };
4011
- const wheel = (event) => {
4012
- dismissSelectPopup();
4013
- const frame = paintedFrameRef.current;
4014
- if (!frame) return;
4015
- const at = point(frame, event.clientX, event.clientY);
4016
- if (!at) return;
4017
- flushPendingText();
4018
- flushPendingClick();
4019
- event.preventDefault();
4020
- let pending = wheelRef.current;
4021
- if (pending && (!sameBrowserDocument(pending.frame, frame) || Math.hypot(pending.x - at.x, pending.y - at.y) > 6)) {
4022
- flushPendingWheel();
4023
- pending = null;
4024
- }
4025
- wheelRef.current = {
4026
- x: at.x,
4027
- y: at.y,
4028
- deltaX: (pending?.deltaX ?? 0) + event.deltaX,
4029
- deltaY: (pending?.deltaY ?? 0) + event.deltaY,
4030
- frame,
4031
- // Retain the first event's deadline so a continuous gesture keeps moving.
4032
- timer: pending?.timer ?? setTimeout(flushPendingWheel, 45)
4033
- };
4034
- };
4035
- const keyDown = (event) => {
4036
- if (composingRef.current || event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) {
4037
- return;
4038
- }
4039
- dismissSelectPopup();
4040
- flushPendingWheel();
4041
- const command = event.metaKey || event.ctrlKey;
4042
- if (props.clipboardEnabled && command && !event.altKey && ["c", "v"].includes(event.key.toLowerCase())) {
4043
- flushPendingText();
4044
- return;
4045
- }
4046
- const key = browserKey(event);
4047
- if (!key) return;
4048
- event.preventDefault();
4049
- flushPendingText();
4050
- flushPendingClick();
4051
- enqueue({ type: "press", key }, paintedFrameRef.current);
4052
- };
4053
- const finishCopy = useCallback8(async () => {
4054
- const clipboard = await readClipboardRef.current();
4055
- if (!mountedRef.current) return;
4056
- if (clipboard.text.length === 0) return;
4057
- if (!await copyTextToClipboard(clipboard.text)) {
4058
- throw new Error(t("browserViewer.browserTextCouldNotBe"));
4059
- }
4060
- }, [t]);
4061
- const copy = (event) => {
4062
- if (!props.clipboardEnabled) return;
4063
- event.preventDefault();
4064
- flushPendingWheel();
4065
- flushPendingText();
4066
- flushPendingClick();
4067
- enqueue({ type: "clipboard", operation: "copy" }, paintedFrameRef.current, finishCopy);
4068
- };
4069
- const paste = (event) => {
4070
- if (!props.clipboardEnabled) return;
4071
- event.preventDefault();
4072
- flushPendingWheel();
4073
- flushPendingText();
4074
- flushPendingClick();
4075
- enqueue(
4076
- {
4077
- type: "clipboard",
4078
- operation: "paste",
4079
- text: event.clipboardData.getData("text/plain")
4080
- },
4081
- paintedFrameRef.current
4082
- );
4083
- };
4084
- const input = (value, nativeComposing = false) => {
4085
- dismissSelectPopup();
4086
- if (composingRef.current || nativeComposing) return;
4087
- if (!value) return;
4088
- flushPendingWheel();
4089
- flushPendingClick();
4090
- const pending = pendingTextRef.current;
4091
- if (pending && sameOptionalBrowserFrame(pending.frame, paintedFrameRef.current)) {
4092
- clearTimeout(pending.timer);
4093
- pending.text += value;
4094
- pending.timer = setTimeout(flushPendingText, 16);
4095
- } else {
4096
- flushPendingText();
4097
- pendingTextRef.current = {
4098
- text: value,
4099
- frame: paintedFrameRef.current,
4100
- timer: setTimeout(flushPendingText, 16)
4101
- };
4102
- }
4103
- if (inputRef.current) inputRef.current.value = "";
4104
- };
4105
- const compositionStart = () => {
4106
- composingRef.current = true;
4107
- };
4108
- const compositionEnd = (event) => {
4109
- composingRef.current = false;
4110
- input(event.currentTarget.value || event.data);
4111
- };
4112
- const showCanvas = !props.controlUnavailable && props.frame !== null && paintedFrame !== null && sameBrowserDocument(props.frame, paintedFrame);
4113
- return /* @__PURE__ */ jsxs2("div", { className: "relative min-h-0 flex-1 overflow-hidden bg-black", children: [
4114
- /* @__PURE__ */ jsx2(
4115
- "canvas",
4116
- {
4117
- ref: canvasRef,
4118
- className: cn(
4119
- "absolute inset-0 m-auto max-h-full max-w-full touch-none focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-og-accent",
4120
- !showCanvas && "invisible"
4121
- ),
4122
- onPointerDown: pointerDown,
4123
- onPointerUp: pointerUp,
4124
- onPointerCancel: () => {
4125
- pointerStartRef.current = null;
4126
- },
4127
- onContextMenu: contextMenu,
4128
- onWheel: wheel,
4129
- "aria-label": t("browserViewer.interactiveBrowserPage")
4130
- }
4131
- ),
4132
- /* @__PURE__ */ jsx2(
4133
- "textarea",
4134
- {
4135
- ref: inputRef,
4136
- disabled: props.controlUnavailable,
4137
- defaultValue: "",
4138
- onInput: (event) => input(event.currentTarget.value, event.nativeEvent.isComposing),
4139
- onCompositionStart: compositionStart,
4140
- onCompositionEnd: compositionEnd,
4141
- onKeyDown: keyDown,
4142
- onCopy: copy,
4143
- onPaste: paste,
4144
- className: "pointer-events-none absolute left-1/2 top-1/2 size-px resize-none overflow-hidden opacity-0",
4145
- "aria-label": t("browserViewer.browserKeyboardInput"),
4146
- "aria-keyshortcuts": "Alt+ArrowDown",
4147
- autoCapitalize: "off",
4148
- autoCorrect: "off",
4149
- spellCheck: false
4150
- }
4151
- ),
4152
- !showCanvas ? /* @__PURE__ */ jsx2(
4153
- SemanticBrowserFallback,
4154
- {
4155
- observation: props.observation,
4156
- connectionState: props.connectionState,
4157
- supportsLiveFrames: props.supportsLiveFrames,
4158
- error: props.connectionError,
4159
- controlUnavailable: props.controlUnavailable,
4160
- onAction: (action) => enqueue(action, null),
4161
- onReconnect: props.onReconnect,
4162
- reconnectLabel: props.reconnectLabel,
4163
- reconnectMessage: props.reconnectMessage
4164
- }
4165
- ) : null,
4166
- showCanvas ? /* @__PURE__ */ jsx2(
4167
- BrowserSelectControl,
4168
- {
4169
- manualFallback: props.inputBatchAttachment?.focusedInputObservations !== true,
4170
- activation: selectPopup,
4171
- onDismiss: () => inputRef.current?.focus({ preventScroll: true }),
4172
- observe: async () => {
4173
- flushPendingText();
4174
- flushPendingWheel();
4175
- await actionTailRef.current;
4176
- if (!mountedRef.current) throw new Error(t("browserViewer.theBrowserPageChanged"));
4177
- return await props.onObserveForInput();
4178
- },
4179
- act: props.onSelectFromObservation
4180
- }
4181
- ) : null,
4182
- props.mutating ? /* @__PURE__ */ jsxs2("div", { className: "pointer-events-none absolute right-3 top-3 flex items-center gap-1.5 rounded-full border border-white/10 bg-black/65 px-2.5 py-1 text-[11px] text-white/80 backdrop-blur", children: [
4183
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }),
4184
- " ",
4185
- props.activityLabel ?? t("browserViewer.acting")
4186
- ] }) : null
4187
- ] });
4188
- }
4189
- function SemanticBrowserFallback(props) {
4190
- const t = useOpenGeniText();
4191
- const controlFailure = interactionControlFailureFromError(props.error);
4192
- const elsewhere = isSourcePlacementElsewhereError(props.error, "browser_session");
4193
- const { controlUnavailable } = props;
4194
- const generationLoss = Boolean(props.reconnectMessage);
4195
- const nodes = semanticNodes(
4196
- props.observation?.semantic?.kind === "snapshot" ? props.observation.semantic.roots : []
4197
- );
4198
- const interactive = nodes.filter((node) => node.actions.includes("click")).slice(0, 8);
4199
- return /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 grid place-items-center bg-og-bg p-6", children: /* @__PURE__ */ jsxs2("div", { className: "w-full max-w-md rounded-og-lg border border-og-border bg-og-surface-1 p-4 shadow-lg", children: [
4200
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
4201
- props.error ? /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-4 text-og-danger" }) : props.connectionState === "semantic" ? /* @__PURE__ */ jsx2(ZapIcon, { className: "size-4 text-og-fg-muted" }) : /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-4 animate-spin text-og-fg-muted" }),
4202
- /* @__PURE__ */ jsx2("p", { className: "text-og-menu font-medium text-og-fg", children: generationLoss ? t("browserViewer.chromeReconnectedOpenAFresh") : controlUnavailable ? t("browserViewer.browserControlsUnavailable") : props.error ? props.supportsLiveFrames ? t("browserViewer.liveViewDisconnected") : t("browserViewer.browserUnavailable") : props.connectionState === "semantic" ? t("browserViewer.semanticBrowser") : browserConnectionLabel(t, props.connectionState) })
4203
- ] }),
4204
- props.error || props.reconnectMessage ? /* @__PURE__ */ jsx2("p", { className: "mt-2 text-og-control leading-5 text-og-fg-muted", children: props.reconnectMessage ?? (elsewhere ? t("browserViewer.chatIsOnAnotherComputer") : controlFailure?.message ?? props.error?.message) }) : null,
4205
- interactive.length > 0 && !controlUnavailable ? /* @__PURE__ */ jsxs2("div", { className: "mt-3 border-t border-og-border pt-3", children: [
4206
- /* @__PURE__ */ jsx2("p", { className: "mb-2 text-og-xs text-og-fg-subtle", children: props.supportsLiveFrames ? t("browserViewer.pageControlsRemainAvailable") : t("browserViewer.availablePageControls") }),
4207
- /* @__PURE__ */ jsx2("div", { className: "flex flex-wrap gap-1.5", children: interactive.map((node) => /* @__PURE__ */ jsx2(
4208
- "button",
4209
- {
4210
- type: "button",
4211
- onClick: () => props.onAction({
4212
- type: "click",
4213
- locator: { kind: "ref", ref: node.ref }
4214
- }),
4215
- className: "rounded-og-sm border border-og-border bg-og-surface-1 px-2 py-1 text-og-control text-og-fg transition hover:bg-og-surface-2",
4216
- children: node.name || node.role
4217
- },
4218
- node.ref
4219
- )) })
4220
- ] }) : null,
4221
- props.error && (!generationLoss || props.reconnectLabel) ? /* @__PURE__ */ jsx2(
4222
- "button",
4223
- {
4224
- type: "button",
4225
- onClick: props.onReconnect,
4226
- className: "mt-3 text-og-control font-medium og-link",
4227
- children: props.reconnectLabel ?? (controlFailure?.retryable === false ? t("browserViewer.tryAgain") : t("browserViewer.reconnect"))
4228
- }
4229
- ) : null
4230
- ] }) });
4231
- }
4232
- function BrowserStatusBar(props) {
4233
- const t = useOpenGeniText();
4234
- const errors = (props.observation?.diagnostics.consoleErrorCount ?? 0) + (props.observation?.diagnostics.pageErrorCount ?? 0);
4235
- const failed = props.observation?.diagnostics.failedRequestCount ?? 0;
4236
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-7 shrink-0 items-center gap-2 border-t border-og-border bg-og-surface-1 px-2 text-og-xs text-og-fg-subtle", children: [
4237
- /* @__PURE__ */ jsx2(
4238
- "span",
4239
- {
4240
- className: cn(
4241
- "size-1.5 rounded-full",
4242
- props.connectionState === "live" || props.connectionState === "semantic" ? "bg-og-status-running" : "bg-og-fg-subtle"
4243
- )
4244
- }
4245
- ),
4246
- /* @__PURE__ */ jsx2("span", { children: props.connectionState === "live" ? t("browserViewer.live") : props.connectionState === "semantic" ? t("browserViewer.semantic") : browserConnectionLabel(t, props.connectionState) }),
4247
- props.inputFailure ? /* @__PURE__ */ jsx2("span", { className: "text-og-status-failed", children: props.inputFailure.state === "failed" ? t("browserViewer.inputFailed") : t("browserViewer.inputResultUnknown") }) : null,
4248
- /* @__PURE__ */ jsx2("span", { children: props.profile?.name ?? t("browserViewer.temporaryBrowser") }),
4249
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate", children: props.target?.title }),
4250
- props.refreshing ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }) : null,
4251
- props.onOpenComputer ? /* @__PURE__ */ jsxs2(
4252
- "button",
4253
- {
4254
- type: "button",
4255
- onClick: props.onOpenComputer,
4256
- className: "flex items-center gap-1 rounded px-1.5 py-0.5 transition hover:bg-og-surface-2 hover:text-og-fg",
4257
- "aria-label": t("browserViewer.openThisBrowserWindowIn"),
4258
- children: [
4259
- /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3" }),
4260
- t("browserViewer.desktop")
4261
- ]
4262
- }
4263
- ) : null,
4264
- /* @__PURE__ */ jsxs2(
4265
- "button",
4266
- {
4267
- type: "button",
4268
- onClick: props.onDiagnostics,
4269
- "aria-expanded": props.diagnosticsOpen,
4270
- "aria-controls": "browser-diagnostics-drawer",
4271
- className: cn(
4272
- "flex items-center gap-1 rounded px-1.5 py-0.5 transition hover:bg-og-surface-2 hover:text-og-fg",
4273
- props.diagnosticsOpen && "bg-og-surface-2 text-og-fg"
4274
- ),
4275
- children: [
4276
- /* @__PURE__ */ jsx2(BugIcon, { className: "size-3" }),
4277
- errors + failed > 0 ? errors + failed : t("browserViewer.debug")
4278
- ]
4279
- }
4280
- )
4281
- ] });
4282
- }
4283
- function BrowserDiagnosticsDrawer(props) {
4284
- const t = useOpenGeniText();
4285
- const session = props.session;
4286
- const diagnostics = props.observation?.diagnostics;
4287
- const semanticMode = props.observation?.semantic ? t("browserViewer.semanticPageStructureAvailable") : props.observation?.screenshot ? t("browserViewer.visualFallbackInUse") : t("browserViewer.waitingForPageObservation");
4288
- return /* @__PURE__ */ jsxs2(
4289
- "aside",
4290
- {
4291
- id: "browser-diagnostics-drawer",
4292
- role: "region",
4293
- "aria-label": t("browserViewer.browserDiagnostics"),
4294
- className: "absolute inset-y-0 right-0 z-40 flex min-h-0 w-full max-w-md flex-col border-l border-og-border bg-og-surface-1 shadow-2xl",
4295
- children: [
4296
- /* @__PURE__ */ jsxs2("div", { className: "flex min-h-11 shrink-0 items-center gap-2 border-b border-og-border px-3 py-2", children: [
4297
- /* @__PURE__ */ jsx2(BugIcon, { className: "size-4 shrink-0 text-og-fg-muted" }),
4298
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
4299
- /* @__PURE__ */ jsx2("p", { className: "text-og-control font-semibold text-og-fg", children: t("browserViewer.browserDiagnostics") }),
4300
- /* @__PURE__ */ jsx2("p", { className: "truncate text-og-xs text-og-fg-subtle", children: props.target?.title || shortUrl(props.target?.url ?? "") || t("browserViewer.currentTab") })
4301
- ] }),
4302
- /* @__PURE__ */ jsx2(
4303
- "button",
4304
- {
4305
- type: "button",
4306
- onClick: props.onRefresh,
4307
- disabled: props.state.loading,
4308
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-40",
4309
- "aria-label": t("browserViewer.refreshBrowserDiagnostics"),
4310
- children: /* @__PURE__ */ jsx2(RefreshCwIcon, { className: cn("size-3.5", props.state.loading && "animate-spin") })
4311
- }
4312
- ),
4313
- /* @__PURE__ */ jsx2(
4314
- "button",
4315
- {
4316
- type: "button",
4317
- onClick: props.onClose,
4318
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg",
4319
- "aria-label": t("browserViewer.closeBrowserDiagnostics"),
4320
- children: /* @__PURE__ */ jsx2(XIcon, { className: "size-3.5" })
4321
- }
4322
- )
4323
- ] }),
4324
- /* @__PURE__ */ jsxs2("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [
4325
- /* @__PURE__ */ jsxs2("section", { className: "border-b border-og-border p-3", "aria-labelledby": "browser-runtime-title", children: [
4326
- /* @__PURE__ */ jsx2(
4327
- "h3",
4328
- {
4329
- id: "browser-runtime-title",
4330
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4331
- children: t("browserViewer.runtime")
4332
- }
4333
- ),
4334
- /* @__PURE__ */ jsxs2("dl", { className: "mt-2 grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-og-xs", children: [
4335
- /* @__PURE__ */ jsx2(
4336
- DiagnosticFact,
4337
- {
4338
- label: t("browserViewer.engine"),
4339
- value: browserEngineLabel(t, session)
4340
- }
4341
- ),
4342
- /* @__PURE__ */ jsx2(
4343
- DiagnosticFact,
4344
- {
4345
- label: t("browserViewer.driver"),
4346
- value: session?.driverId ?? t("browserViewer.unavailable")
4347
- }
4348
- ),
4349
- /* @__PURE__ */ jsx2(
4350
- DiagnosticFact,
4351
- {
4352
- label: t("browserViewer.placement"),
4353
- value: placementLabel(t, session ?? void 0)
4354
- }
4355
- ),
4356
- /* @__PURE__ */ jsx2(
4357
- DiagnosticFact,
4358
- {
4359
- label: t("browserViewer.profile"),
4360
- value: props.profile ? `${props.profile.name}${props.baseRevisionOrdinal ? ` \xB7 v${props.baseRevisionOrdinal}` : ""}` : t("browserViewer.temporary")
4361
- }
4362
- ),
4363
- /* @__PURE__ */ jsx2(
4364
- DiagnosticFact,
4365
- {
4366
- label: t("browserViewer.controller"),
4367
- value: shortGeneration(t, session?.controller?.controllerGeneration)
4368
- }
4369
- ),
4370
- /* @__PURE__ */ jsx2(
4371
- DiagnosticFact,
4372
- {
4373
- label: t("browserViewer.network"),
4374
- value: session?.networkRouteId ? t("browserViewer.customRoute") : t("browserViewer.placementDefault")
4375
- }
4376
- ),
4377
- /* @__PURE__ */ jsx2(DiagnosticFact, { label: t("browserViewer.observation"), value: semanticMode })
4378
- ] })
4379
- ] }),
4380
- /* @__PURE__ */ jsxs2("section", { className: "border-b border-og-border p-3", "aria-labelledby": "browser-page-title", children: [
4381
- /* @__PURE__ */ jsx2(
4382
- "h3",
4383
- {
4384
- id: "browser-page-title",
4385
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4386
- children: t("browserViewer.tabDiagnostics")
4387
- }
4388
- ),
4389
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-xs text-og-fg-subtle", children: t("browserViewer.includesEarlierPagesInThis") }),
4390
- /* @__PURE__ */ jsxs2("dl", { className: "mt-2 grid grid-cols-2 gap-2", children: [
4391
- /* @__PURE__ */ jsx2(
4392
- DiagnosticCount,
4393
- {
4394
- label: t("browserViewer.consoleErrors"),
4395
- value: diagnostics?.consoleErrorCount
4396
- }
4397
- ),
4398
- /* @__PURE__ */ jsx2(
4399
- DiagnosticCount,
4400
- {
4401
- label: t("browserViewer.pageErrors"),
4402
- value: diagnostics?.pageErrorCount
4403
- }
4404
- ),
4405
- /* @__PURE__ */ jsx2(
4406
- DiagnosticCount,
4407
- {
4408
- label: t("browserViewer.failedRequests"),
4409
- value: diagnostics?.failedRequestCount
4410
- }
4411
- ),
4412
- /* @__PURE__ */ jsx2(
4413
- DiagnosticCount,
4414
- {
4415
- label: t("browserViewer.downloads"),
4416
- value: diagnostics?.downloadCount
4417
- }
4418
- )
4419
- ] }),
4420
- session?.failureCode ? /* @__PURE__ */ jsx2("p", { className: "mt-2 rounded-og-sm border border-og-danger/30 bg-og-danger/5 px-2.5 py-2 text-og-xs text-og-danger", children: t("browserViewer.browserStateFailurecode", { failureCode: session.failureCode }) }) : null
4421
- ] }),
4422
- props.downloadsEnabled ? /* @__PURE__ */ jsx2(
4423
- BrowserDownloadsPanel,
4424
- {
4425
- downloads: props.downloads,
4426
- loading: props.downloadsLoading,
4427
- refreshing: props.downloadsRefreshing,
4428
- error: props.downloadsError,
4429
- savingDownloadIds: props.savingDownloadIds,
4430
- onSave: props.onSaveDownload,
4431
- onRefresh: props.onRefreshDownloads
4432
- }
4433
- ) : null,
4434
- /* @__PURE__ */ jsxs2("section", { className: "p-3", "aria-labelledby": "browser-events-title", children: [
4435
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-2", children: [
4436
- /* @__PURE__ */ jsx2(
4437
- "h3",
4438
- {
4439
- id: "browser-events-title",
4440
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4441
- children: t("browserViewer.recentEvents")
4442
- }
4443
- ),
4444
- props.state.batch?.truncated ? /* @__PURE__ */ jsx2("span", { className: "text-[10px] text-og-fg-subtle", children: t("browserViewer.newest100") }) : null
4445
- ] }),
4446
- props.state.loading && !props.state.batch ? /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 py-6 text-og-control text-og-fg-muted", children: [
4447
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }),
4448
- " ",
4449
- t("browserViewer.loadingDiagnostics")
4450
- ] }) : props.state.error ? /* @__PURE__ */ jsxs2("div", { className: "py-5", children: [
4451
- /* @__PURE__ */ jsx2("p", { className: "text-og-control text-og-danger", children: props.state.error.message }),
4452
- /* @__PURE__ */ jsx2(
4453
- "button",
4454
- {
4455
- type: "button",
4456
- onClick: props.onRefresh,
4457
- className: "mt-2 text-og-control font-medium og-link",
4458
- children: t("browserViewer.tryAgain")
4459
- }
4460
- )
4461
- ] }) : props.state.batch?.entries.length ? /* @__PURE__ */ jsx2("ol", { className: "mt-2 space-y-2", children: props.state.batch.entries.map((entry) => /* @__PURE__ */ jsxs2(
4462
- "li",
4463
- {
4464
- className: "rounded-og-sm border border-og-border bg-og-bg p-2.5",
4465
- children: [
4466
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-[10px] text-og-fg-subtle", children: [
4467
- /* @__PURE__ */ jsx2(
4468
- "span",
4469
- {
4470
- className: cn(
4471
- "font-semibold uppercase tracking-wide",
4472
- diagnosticTone(entry.level)
4473
- ),
4474
- children: diagnosticKindLabel(t, entry.kind)
4475
- }
4476
- ),
4477
- /* @__PURE__ */ jsx2("span", { className: "ml-auto", children: formatDiagnosticTime(t, entry.occurredAt) })
4478
- ] }),
4479
- /* @__PURE__ */ jsx2("p", { className: "mt-1 whitespace-pre-wrap break-words text-og-xs leading-5 text-og-fg", children: entry.message }),
4480
- entry.url || entry.filename || entry.method || entry.status ? /* @__PURE__ */ jsx2("p", { className: "mt-1 truncate font-og-mono text-[10px] text-og-fg-subtle", children: [entry.method, entry.status, entry.filename, entry.url].filter((value) => value !== null).join(" \xB7 ") }) : null
4481
- ]
4482
- },
4483
- entry.sequence
4484
- )) }) : /* @__PURE__ */ jsx2("p", { className: "py-6 text-og-control text-og-fg-muted", children: t("browserViewer.noDiagnosticsForThisTab") })
4485
- ] })
4486
- ] })
4487
- ]
4488
- }
4489
- );
4490
- }
4491
- function BrowserDownloadsPanel(props) {
4492
- const t = useOpenGeniText();
4493
- const [paths, setPaths] = useState9({});
4494
- const [overwrite, setOverwrite] = useState9({});
4495
- const [savedPaths, setSavedPaths] = useState9({});
4496
- const [errors, setErrors] = useState9({});
4497
- const saving = useMemo2(() => new Set(props.savingDownloadIds), [props.savingDownloadIds]);
4498
- const save = (download) => {
4499
- const destinationPath = (paths[download.id] ?? defaultDownloadDestination(download)).trim();
4500
- if (!destinationPath || saving.has(download.id)) return;
4501
- setErrors((current) => ({ ...current, [download.id]: "" }));
4502
- void props.onSave(download.id, destinationPath, overwrite[download.id] ?? false).then((response) => {
4503
- setSavedPaths((current) => ({ ...current, [download.id]: response.destinationPath }));
4504
- }).catch((cause) => {
4505
- setErrors((current) => ({
4506
- ...current,
4507
- [download.id]: cause instanceof Error ? cause.message : t("browserViewer.couldNotSaveThisDownload")
4508
- }));
4509
- });
4510
- };
4511
- return /* @__PURE__ */ jsxs2("section", { className: "border-b border-og-border p-3", "aria-labelledby": "browser-downloads-title", children: [
4512
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
4513
- /* @__PURE__ */ jsx2(DownloadIcon, { className: "size-3.5 text-og-fg-muted" }),
4514
- /* @__PURE__ */ jsx2(
4515
- "h3",
4516
- {
4517
- id: "browser-downloads-title",
4518
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4519
- children: t("browserViewer.downloads")
4520
- }
4521
- ),
4522
- props.refreshing ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "ml-auto size-3 animate-spin text-og-fg-muted" }) : null
4523
- ] }),
4524
- props.loading ? /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 py-5 text-og-control text-og-fg-muted", children: [
4525
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }),
4526
- " ",
4527
- t("browserViewer.loadingDownloads")
4528
- ] }) : props.error ? /* @__PURE__ */ jsxs2("div", { className: "py-4", children: [
4529
- /* @__PURE__ */ jsx2("p", { className: "text-og-control text-og-danger", children: props.error.message }),
4530
- /* @__PURE__ */ jsx2(
4531
- "button",
4532
- {
4533
- type: "button",
4534
- onClick: props.onRefresh,
4535
- className: "mt-2 text-og-control font-medium og-link",
4536
- children: t("browserViewer.tryAgain")
4537
- }
4538
- )
4539
- ] }) : props.downloads.length === 0 ? /* @__PURE__ */ jsx2("p", { className: "py-4 text-og-control text-og-fg-muted", children: t("browserViewer.noFilesDownloadedYet") }) : /* @__PURE__ */ jsx2("ol", { className: "mt-2 space-y-2", children: props.downloads.map((download) => {
4540
- const destinationPath = paths[download.id] ?? defaultDownloadDestination(download);
4541
- const isSaving = saving.has(download.id);
4542
- const isSaved = savedPaths[download.id] === destinationPath;
4543
- return /* @__PURE__ */ jsxs2(
4544
- "li",
4545
- {
4546
- className: "rounded-og-sm border border-og-border bg-og-bg p-2.5",
4547
- children: [
4548
- /* @__PURE__ */ jsxs2("div", { className: "flex min-w-0 items-start gap-2", children: [
4549
- /* @__PURE__ */ jsx2("span", { className: "mt-0.5 grid size-6 shrink-0 place-items-center rounded bg-og-surface-2 text-og-fg-muted", children: isSaved ? /* @__PURE__ */ jsx2(FileCheck2Icon, { className: "size-3.5 text-og-status-idle" }) : /* @__PURE__ */ jsx2(DownloadIcon, { className: "size-3.5" }) }),
4550
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
4551
- /* @__PURE__ */ jsx2(
4552
- "p",
4553
- {
4554
- className: "truncate text-og-xs font-medium text-og-fg",
4555
- title: download.filename,
4556
- children: download.filename
4557
- }
4558
- ),
4559
- /* @__PURE__ */ jsx2("p", { className: "mt-0.5 text-[10px] text-og-fg-subtle", children: downloadStatusLabel(t, download) })
4560
- ] })
4561
- ] }),
4562
- download.status === "completed" ? /* @__PURE__ */ jsxs2("div", { className: "mt-2", children: [
4563
- /* @__PURE__ */ jsxs2("div", { className: "flex gap-1.5", children: [
4564
- /* @__PURE__ */ jsx2(
4565
- "input",
4566
- {
4567
- type: "text",
4568
- value: destinationPath,
4569
- onInput: (event) => {
4570
- const value = event.currentTarget.value;
4571
- setPaths((current) => ({ ...current, [download.id]: value }));
4572
- setErrors((current) => ({ ...current, [download.id]: "" }));
4573
- },
4574
- onKeyDown: (event) => {
4575
- if (event.key === "Enter") save(download);
4576
- },
4577
- disabled: isSaving,
4578
- "aria-label": t("browserViewer.workspacePathForFilename", {
4579
- filename: download.filename
4580
- }),
4581
- className: "h-7 min-w-0 flex-1 rounded-og-sm border border-og-border bg-og-surface-1 px-2 font-og-mono text-[10px] text-og-fg transition focus:border-og-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50"
4582
- }
4583
- ),
4584
- /* @__PURE__ */ jsxs2(
4585
- "button",
4586
- {
4587
- type: "button",
4588
- onClick: () => save(download),
4589
- disabled: isSaving || !destinationPath.trim() || isSaved && !overwrite[download.id],
4590
- className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-og-sm border border-og-border bg-og-surface-1 px-2 text-[10px] font-medium text-og-fg transition hover:bg-og-surface-2 disabled:opacity-40",
4591
- children: [
4592
- isSaving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsx2(SaveIcon, { className: "size-3" }),
4593
- isSaving ? t("browserViewer.saving") : isSaved ? t("browserViewer.saved") : overwrite[download.id] ? t("browserViewer.replace") : t("browserViewer.save")
4594
- ]
4595
- }
4596
- )
4597
- ] }),
4598
- /* @__PURE__ */ jsxs2("label", { className: "mt-1.5 flex w-fit items-center gap-1.5 text-[10px] text-og-fg-subtle", children: [
4599
- /* @__PURE__ */ jsx2(
4600
- "input",
4601
- {
4602
- type: "checkbox",
4603
- checked: overwrite[download.id] ?? false,
4604
- onChange: (event) => {
4605
- setOverwrite((current) => ({
4606
- ...current,
4607
- [download.id]: event.currentTarget.checked
4608
- }));
4609
- setErrors((current) => ({ ...current, [download.id]: "" }));
4610
- },
4611
- disabled: isSaving,
4612
- className: "size-3 accent-og-accent"
4613
- }
4614
- ),
4615
- t("browserViewer.replaceAnExistingWorkspaceFile")
4616
- ] }),
4617
- errors[download.id] ? /* @__PURE__ */ jsx2("p", { className: "mt-1.5 break-words text-[10px] text-og-danger", children: errors[download.id] }) : null
4618
- ] }) : null
4619
- ]
4620
- },
4621
- download.id
4622
- );
4623
- }) })
4624
- ] });
4625
- }
4626
- function downloadStatusLabel(t, download) {
4627
- if (download.status === "completed") return formatBytes(download.receivedBytes);
4628
- if (download.status === "in_progress") {
4629
- const received = formatBytes(download.receivedBytes);
4630
- return download.totalBytes === null ? t("browserViewer.downloadingReceived", { received }) : t("browserViewer.downloadingReceivedOfBytes", {
4631
- received,
4632
- bytes: formatBytes(download.totalBytes)
4633
- });
4634
- }
4635
- if (download.status === "cancelled") return t("browserViewer.cancelled");
4636
- if (download.status === "unavailable") return t("browserViewer.noLongerAvailable");
4637
- return t("browserViewer.downloadFailed");
4638
- }
4639
- function defaultDownloadDestination(download) {
4640
- const leaf = download.filename.split(/[\\/]/u).at(-1)?.trim() ?? "";
4641
- const portable = leaf.normalize("NFC").replace(/[<>:"|?*\u0000-\u001f\u007f]/gu, "-").replace(/[ .]+$/u, "");
4642
- if (portable.length === 0 || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(portable)) {
4643
- return `download-${download.id.slice(0, 8)}`;
4644
- }
4645
- return portable;
4646
- }
4647
- function DiagnosticFact(props) {
4648
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
4649
- /* @__PURE__ */ jsx2("dt", { className: "text-og-fg-subtle", children: props.label }),
4650
- /* @__PURE__ */ jsx2("dd", { className: "min-w-0 truncate text-og-fg", title: props.value, children: props.value })
4651
- ] });
4652
- }
4653
- function DiagnosticCount(props) {
4654
- const t = useOpenGeniText();
4655
- return /* @__PURE__ */ jsxs2("div", { className: "rounded-og-sm border border-og-border bg-og-bg px-2.5 py-2", children: [
4656
- /* @__PURE__ */ jsx2("dt", { className: "text-[10px] text-og-fg-subtle", children: props.label }),
4657
- /* @__PURE__ */ jsx2(
4658
- "dd",
4659
- {
4660
- className: cn(
4661
- "mt-0.5 text-og-sm font-semibold",
4662
- props.value ? "text-og-fg" : "text-og-fg-muted"
4663
- ),
4664
- children: props.value ?? t("browserViewer.unavailable")
4665
- }
4666
- )
4667
- ] });
4668
- }
4669
- function browserEngineLabel(t, session) {
4670
- if (!session) return t("browserViewer.unavailable");
4671
- const version = session.engineVersion ? ` ${session.engineVersion}` : "";
4672
- return `${session.engine}${version} \xB7 ${session.headless ? "headless" : "headed"}`;
4673
- }
4674
- function shortGeneration(t, value) {
4675
- if (!value) return t("browserViewer.unavailable");
4676
- return value.length > 16 ? `${value.slice(0, 8)}\u2026${value.slice(-6)}` : value;
4677
- }
4678
- function diagnosticKindLabel(t, kind) {
4679
- switch (kind) {
4680
- case "console":
4681
- return t("browserViewer.console");
4682
- case "page_error":
4683
- return t("browserViewer.pageError");
4684
- case "failed_request":
4685
- return t("browserViewer.request");
4686
- case "download":
4687
- return t("browserViewer.download");
4688
- }
4689
- }
4690
- function diagnosticTone(level) {
4691
- if (level === "error") return "text-og-danger";
4692
- if (level === "warning") return "text-og-status-waiting";
4693
- return "text-og-fg-muted";
4694
- }
4695
- function formatDiagnosticTime(t, value) {
4696
- const date = new Date(value);
4697
- return Number.isNaN(date.getTime()) ? "" : date.toLocaleTimeString(t.locale, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
4698
- }
4699
- function BrowserNotice(props) {
4700
- return /* @__PURE__ */ jsx2(
4701
- "div",
4702
- {
4703
- className: cn(
4704
- "grid h-full place-items-center bg-og-bg text-og-control text-og-fg-muted",
4705
- props.className
4706
- ),
4707
- children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
4708
- props.icon,
4709
- props.text
4710
- ] })
4711
- }
4712
- );
4713
- }
4714
- function paintCanvas(canvas, image, width, height) {
4715
- canvas.width = width;
4716
- canvas.height = height;
4717
- const context = canvas.getContext("2d", { alpha: false });
4718
- if (!context) throw new Error("Browser canvas is unavailable.");
4719
- context.drawImage(image, 0, 0, width, height);
4720
- }
4721
- function loadImage(url) {
4722
- return new Promise((resolve, reject) => {
4723
- const image = new Image();
4724
- image.onload = () => resolve(image);
4725
- image.onerror = () => reject(new Error("Browser frame image could not be decoded."));
4726
- image.src = url;
4727
- });
4728
- }
4729
- function browserPoint(canvas, frame, clientX, clientY) {
4730
- if (!canvas || !frame) return null;
4731
- const rect = canvas.getBoundingClientRect();
4732
- if (rect.width <= 0 || rect.height <= 0) return null;
4733
- const pixelX = (clientX - rect.left) / rect.width * frame.width;
4734
- const pixelY = (clientY - rect.top) / rect.height * frame.height;
4735
- return {
4736
- x: Math.max(0, pixelX / frame.deviceScaleFactor),
4737
- y: Math.max(0, pixelY / frame.deviceScaleFactor)
4738
- };
4739
- }
4740
- function semanticNodes(roots) {
4741
- const result = [];
4742
- const stack = [...roots].reverse();
4743
- while (stack.length > 0) {
4744
- const node = stack.pop();
4745
- result.push(node);
4746
- if (node.children) stack.push(...[...node.children].reverse());
4747
- }
4748
- return result;
4749
- }
4750
- function frameMatchesSelectedTarget(frame, session, target) {
4751
- return Boolean(
4752
- frame && session && target && frame.browserSessionId === session.id && frame.targetId === target.id && frame.targetGeneration === target.targetGeneration && frame.documentGeneration === target.documentGeneration
4753
- );
4754
- }
4755
- function sameFrameFence(left, right) {
4756
- return sameBrowserDocument(left, right) && left.frameId === right.frameId;
4757
- }
4758
- function sameBrowserDocument(left, right) {
4759
- return left.browserSessionId === right.browserSessionId && left.controllerGeneration === right.controllerGeneration && left.targetId === right.targetId && left.targetGeneration === right.targetGeneration && left.documentGeneration === right.documentGeneration;
4760
- }
4761
- function sameOptionalBrowserFrame(left, right) {
4762
- return left === null || right === null ? left === right : sameFrameFence(left, right);
4763
- }
4764
- function isLiveBrowser2(session) {
4765
- return !["ending", "ended", "failed", "lost"].includes(session.lifecycle);
4766
- }
4767
- function attachedChromeGenerationLoss(sessions) {
4768
- const lost = sessions.find(
4769
- (session) => session.lifecycle === "lost" && session.failureCode === "controller_transition_expired" && session.placement.kind === "attached_device"
4770
- );
4771
- return lost?.placement.kind === "attached_device" ? { deviceId: lost.placement.deviceId } : null;
4772
- }
4773
- function isAttachedChromeGenerationLossError(error) {
4774
- if (!error) return false;
4775
- return /placement instance changed|controller authority changed/i.test(error.message);
4776
- }
4777
- function countInterventions(interventions) {
4778
- const counts = /* @__PURE__ */ new Map();
4779
- for (const intervention of interventions) {
4780
- counts.set(intervention.resourceId, (counts.get(intervention.resourceId) ?? 0) + 1);
4781
- }
4782
- return counts;
4783
- }
4784
- function interventionTitle(t, intervention) {
4785
- switch (intervention.kind) {
4786
- case "manual_login":
4787
- return t("browserViewer.signInNeeded");
4788
- case "mfa":
4789
- return t("browserViewer.verificationNeeded");
4790
- case "external_action":
4791
- case "confirmation":
4792
- return t("browserViewer.actionNeeded");
4793
- case "other":
4794
- return t("browserViewer.browserNeedsYourHelp");
4795
- }
4796
- }
4797
- function placementLabel(t, session) {
4798
- if (!session) return "";
4799
- switch (session.placement.kind) {
4800
- case "sandbox_group":
4801
- return t("browserViewer.agentSandbox");
4802
- case "connected_machine":
4803
- return t("browserViewer.connectedMachine");
4804
- case "attached_device":
4805
- return t("browserViewer.yourBrowser");
4806
- case "external_provider":
4807
- return t("browserViewer.cloudBrowser");
4808
- }
4809
- }
4810
- function browserConnectionLabel(t, state) {
4811
- switch (state) {
4812
- case "attaching":
4813
- return t("browserViewer.openingBrowser");
4814
- case "connecting":
4815
- return t("browserViewer.connecting");
4816
- case "reconnecting":
4817
- return t("browserViewer.reconnecting");
4818
- case "error":
4819
- return t("browserViewer.disconnected");
4820
- case "semantic":
4821
- return t("browserViewer.semantic");
4822
- default:
4823
- return t("browserViewer.waitingForBrowser");
4824
- }
4825
- }
4826
- function shortUrl(value) {
4827
- try {
4828
- return new URL(value).hostname || value;
4829
- } catch {
4830
- return value;
4831
- }
4832
- }
4833
-
4834
- export {
4835
- useSiteAuthConnections,
4836
- useAttachedBrowsers,
4837
- useBrowserSessions,
4838
- useBrowserIdentities,
4839
- useBrowserSession,
4840
- useBrowserDownloads,
4841
- useBrowserFrameStream,
4842
- staleBrowserEndRetryDelayMs,
4843
- BrowserViewer
4844
- };
4845
- //# sourceMappingURL=chunk-BUBEMKK3.js.map