@memberjunction/ng-conversations 6.3.0-edge.0 → 6.3.0-edge.2

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 (272) hide show
  1. package/README.md +60 -22
  2. package/dist/assets/edge-ai.worker.js +35168 -0
  3. package/dist/lib/components/agent/agent-instance-editor-modal.component.d.ts +186 -0
  4. package/dist/lib/components/agent/agent-instance-editor-modal.component.d.ts.map +1 -0
  5. package/dist/lib/components/agent/agent-instance-editor-modal.component.js +2202 -0
  6. package/dist/lib/components/agent/agent-instance-editor-modal.component.js.map +1 -0
  7. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts +39 -6
  8. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts.map +1 -1
  9. package/dist/lib/components/artifact/artifact-share-modal.component.js +773 -204
  10. package/dist/lib/components/artifact/artifact-share-modal.component.js.map +1 -1
  11. package/dist/lib/components/collection/collection-tree.component.d.ts.map +1 -1
  12. package/dist/lib/components/collection/collection-tree.component.js +19 -18
  13. package/dist/lib/components/collection/collection-tree.component.js.map +1 -1
  14. package/dist/lib/components/collection/collection-view.component.d.ts +6 -4
  15. package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -1
  16. package/dist/lib/components/collection/collection-view.component.js +35 -17
  17. package/dist/lib/components/collection/collection-view.component.js.map +1 -1
  18. package/dist/lib/components/collection/collections-full-view.component.d.ts +1 -0
  19. package/dist/lib/components/collection/collections-full-view.component.d.ts.map +1 -1
  20. package/dist/lib/components/collection/collections-full-view.component.js +108 -106
  21. package/dist/lib/components/collection/collections-full-view.component.js.map +1 -1
  22. package/dist/lib/components/composer/ai-composer.component.d.ts +15 -1
  23. package/dist/lib/components/composer/ai-composer.component.d.ts.map +1 -1
  24. package/dist/lib/components/composer/ai-composer.component.js +43 -4
  25. package/dist/lib/components/composer/ai-composer.component.js.map +1 -1
  26. package/dist/lib/components/conversation/conversation-agent-picker.component.d.ts +20 -2
  27. package/dist/lib/components/conversation/conversation-agent-picker.component.d.ts.map +1 -1
  28. package/dist/lib/components/conversation/conversation-agent-picker.component.js +378 -62
  29. package/dist/lib/components/conversation/conversation-agent-picker.component.js.map +1 -1
  30. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +94 -18
  31. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
  32. package/dist/lib/components/conversation/conversation-chat-area.component.js +732 -439
  33. package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
  34. package/dist/lib/components/conversation/conversation-list.component.d.ts +19 -1
  35. package/dist/lib/components/conversation/conversation-list.component.d.ts.map +1 -1
  36. package/dist/lib/components/conversation/conversation-list.component.js +184 -89
  37. package/dist/lib/components/conversation/conversation-list.component.js.map +1 -1
  38. package/dist/lib/components/export/export-modal.component.d.ts +7 -2
  39. package/dist/lib/components/export/export-modal.component.d.ts.map +1 -1
  40. package/dist/lib/components/export/export-modal.component.js +13 -2
  41. package/dist/lib/components/export/export-modal.component.js.map +1 -1
  42. package/dist/lib/components/library/library-create-dialog.component.d.ts +136 -0
  43. package/dist/lib/components/library/library-create-dialog.component.d.ts.map +1 -0
  44. package/dist/lib/components/library/library-create-dialog.component.js +1620 -0
  45. package/dist/lib/components/library/library-create-dialog.component.js.map +1 -0
  46. package/dist/lib/components/library/library-full-view.component.d.ts +10 -4
  47. package/dist/lib/components/library/library-full-view.component.d.ts.map +1 -1
  48. package/dist/lib/components/library/library-full-view.component.js +216 -40
  49. package/dist/lib/components/library/library-full-view.component.js.map +1 -1
  50. package/dist/lib/components/library/library-remote-drive-pane.component.d.ts +97 -0
  51. package/dist/lib/components/library/library-remote-drive-pane.component.d.ts.map +1 -0
  52. package/dist/lib/components/library/library-remote-drive-pane.component.js +1229 -0
  53. package/dist/lib/components/library/library-remote-drive-pane.component.js.map +1 -0
  54. package/dist/lib/components/library/library-workspace.component.d.ts +293 -0
  55. package/dist/lib/components/library/library-workspace.component.d.ts.map +1 -0
  56. package/dist/lib/components/library/library-workspace.component.js +5121 -0
  57. package/dist/lib/components/library/library-workspace.component.js.map +1 -0
  58. package/dist/lib/components/library/library.models.d.ts +192 -0
  59. package/dist/lib/components/library/library.models.d.ts.map +1 -0
  60. package/dist/lib/components/library/library.models.js +2 -0
  61. package/dist/lib/components/library/library.models.js.map +1 -0
  62. package/dist/lib/components/message/agent-handoff-card.component.js +1 -1
  63. package/dist/lib/components/message/agent-handoff-card.component.js.map +1 -1
  64. package/dist/lib/components/message/conversation-message-rating.component.d.ts +5 -0
  65. package/dist/lib/components/message/conversation-message-rating.component.d.ts.map +1 -1
  66. package/dist/lib/components/message/conversation-message-rating.component.js +72 -16
  67. package/dist/lib/components/message/conversation-message-rating.component.js.map +1 -1
  68. package/dist/lib/components/message/message-input.component.d.ts +33 -14
  69. package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
  70. package/dist/lib/components/message/message-input.component.js +142 -75
  71. package/dist/lib/components/message/message-input.component.js.map +1 -1
  72. package/dist/lib/components/message/message-item.component.d.ts +51 -4
  73. package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
  74. package/dist/lib/components/message/message-item.component.js +640 -399
  75. package/dist/lib/components/message/message-item.component.js.map +1 -1
  76. package/dist/lib/components/message/message-list.component.d.ts +15 -1
  77. package/dist/lib/components/message/message-list.component.d.ts.map +1 -1
  78. package/dist/lib/components/message/message-list.component.js +75 -3
  79. package/dist/lib/components/message/message-list.component.js.map +1 -1
  80. package/dist/lib/components/navigation/conversation-navigation.component.js +9 -9
  81. package/dist/lib/components/navigation/conversation-navigation.component.js.map +1 -1
  82. package/dist/lib/components/overlay/chat-overlay.component.d.ts +94 -6
  83. package/dist/lib/components/overlay/chat-overlay.component.d.ts.map +1 -1
  84. package/dist/lib/components/overlay/chat-overlay.component.js +249 -59
  85. package/dist/lib/components/overlay/chat-overlay.component.js.map +1 -1
  86. package/dist/lib/components/project/project-form-modal.component.d.ts +6 -0
  87. package/dist/lib/components/project/project-form-modal.component.d.ts.map +1 -1
  88. package/dist/lib/components/project/project-form-modal.component.js +81 -61
  89. package/dist/lib/components/project/project-form-modal.component.js.map +1 -1
  90. package/dist/lib/components/project/project-selector.component.d.ts +5 -0
  91. package/dist/lib/components/project/project-selector.component.d.ts.map +1 -1
  92. package/dist/lib/components/project/project-selector.component.js +11 -4
  93. package/dist/lib/components/project/project-selector.component.js.map +1 -1
  94. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts +55 -0
  95. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts.map +1 -0
  96. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js +974 -0
  97. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js.map +1 -0
  98. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts +66 -0
  99. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts.map +1 -0
  100. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js +253 -0
  101. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js.map +1 -0
  102. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts +80 -0
  103. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts.map +1 -0
  104. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js +49 -0
  105. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js.map +1 -0
  106. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts +54 -0
  107. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts.map +1 -0
  108. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js +386 -0
  109. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js.map +1 -0
  110. package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts +28 -1
  111. package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts.map +1 -1
  112. package/dist/lib/components/realtime/capture/realtime-capture-channel.js +53 -1
  113. package/dist/lib/components/realtime/capture/realtime-capture-channel.js.map +1 -1
  114. package/dist/lib/components/realtime/channels/client-context-channel.d.ts.map +1 -1
  115. package/dist/lib/components/realtime/channels/client-context-channel.js +23 -7
  116. package/dist/lib/components/realtime/channels/client-context-channel.js.map +1 -1
  117. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts +1 -0
  118. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map +1 -1
  119. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js +15 -2
  120. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js.map +1 -1
  121. package/dist/lib/components/realtime/media/media-channel.d.ts +32 -11
  122. package/dist/lib/components/realtime/media/media-channel.d.ts.map +1 -1
  123. package/dist/lib/components/realtime/media/media-channel.js +186 -23
  124. package/dist/lib/components/realtime/media/media-channel.js.map +1 -1
  125. package/dist/lib/components/realtime/media/realtime-media-surface.component.d.ts +9 -1
  126. package/dist/lib/components/realtime/media/realtime-media-surface.component.d.ts.map +1 -1
  127. package/dist/lib/components/realtime/media/realtime-media-surface.component.js +33 -10
  128. package/dist/lib/components/realtime/media/realtime-media-surface.component.js.map +1 -1
  129. package/dist/lib/components/realtime/realtime-agent-banner.component.js +3 -3
  130. package/dist/lib/components/realtime/realtime-agent-banner.component.js.map +1 -1
  131. package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts.map +1 -1
  132. package/dist/lib/components/realtime/realtime-agent-picker.component.js +3 -3
  133. package/dist/lib/components/realtime/realtime-agent-picker.component.js.map +1 -1
  134. package/dist/lib/components/realtime/realtime-composer.component.js +6 -4
  135. package/dist/lib/components/realtime/realtime-composer.component.js.map +1 -1
  136. package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts +82 -33
  137. package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts.map +1 -1
  138. package/dist/lib/components/realtime/realtime-session-overlay.component.js +521 -191
  139. package/dist/lib/components/realtime/realtime-session-overlay.component.js.map +1 -1
  140. package/dist/lib/components/realtime/realtime-session-state.d.ts.map +1 -1
  141. package/dist/lib/components/realtime/realtime-session-state.js +1 -1
  142. package/dist/lib/components/realtime/realtime-session-state.js.map +1 -1
  143. package/dist/lib/components/realtime/realtime-session-thread.component.d.ts.map +1 -1
  144. package/dist/lib/components/realtime/realtime-session-thread.component.js +90 -5
  145. package/dist/lib/components/realtime/realtime-session-thread.component.js.map +1 -1
  146. package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts.map +1 -1
  147. package/dist/lib/components/realtime/realtime-surface-stage.model.js +2 -1
  148. package/dist/lib/components/realtime/realtime-surface-stage.model.js.map +1 -1
  149. package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts +11 -4
  150. package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts.map +1 -1
  151. package/dist/lib/components/realtime/realtime-surface-tab-style.js +24 -5
  152. package/dist/lib/components/realtime/realtime-surface-tab-style.js.map +1 -1
  153. package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts +7 -9
  154. package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts.map +1 -1
  155. package/dist/lib/components/realtime/realtime-surface-tabs.model.js +25 -15
  156. package/dist/lib/components/realtime/realtime-surface-tabs.model.js.map +1 -1
  157. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts +30 -1
  158. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts.map +1 -1
  159. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js +150 -2
  160. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js.map +1 -1
  161. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts +101 -3
  162. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts.map +1 -1
  163. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js +503 -55
  164. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js.map +1 -1
  165. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts +48 -5
  166. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts.map +1 -1
  167. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js +249 -53
  168. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js.map +1 -1
  169. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts.map +1 -1
  170. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js +1 -1
  171. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js.map +1 -1
  172. package/dist/lib/components/search/search-panel.component.d.ts +10 -0
  173. package/dist/lib/components/search/search-panel.component.d.ts.map +1 -1
  174. package/dist/lib/components/search/search-panel.component.js +25 -3
  175. package/dist/lib/components/search/search-panel.component.js.map +1 -1
  176. package/dist/lib/components/share/share-modal.component.d.ts.map +1 -1
  177. package/dist/lib/components/share/share-modal.component.js +181 -127
  178. package/dist/lib/components/share/share-modal.component.js.map +1 -1
  179. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts +14 -1
  180. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts.map +1 -1
  181. package/dist/lib/components/sidebar/conversation-sidebar.component.js +50 -11
  182. package/dist/lib/components/sidebar/conversation-sidebar.component.js.map +1 -1
  183. package/dist/lib/components/sidebar/my-agents-section.component.d.ts +78 -0
  184. package/dist/lib/components/sidebar/my-agents-section.component.d.ts.map +1 -0
  185. package/dist/lib/components/sidebar/my-agents-section.component.js +450 -0
  186. package/dist/lib/components/sidebar/my-agents-section.component.js.map +1 -0
  187. package/dist/lib/components/task/tasks-full-view.component.d.ts +31 -8
  188. package/dist/lib/components/task/tasks-full-view.component.d.ts.map +1 -1
  189. package/dist/lib/components/task/tasks-full-view.component.js +701 -497
  190. package/dist/lib/components/task/tasks-full-view.component.js.map +1 -1
  191. package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
  192. package/dist/lib/components/workspace/conversation-workspace.component.js +15 -2
  193. package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
  194. package/dist/lib/composer-plugins/base-conversation-mention.provider.d.ts +1 -0
  195. package/dist/lib/composer-plugins/base-conversation-mention.provider.d.ts.map +1 -1
  196. package/dist/lib/composer-plugins/base-conversation-mention.provider.js +13 -1
  197. package/dist/lib/composer-plugins/base-conversation-mention.provider.js.map +1 -1
  198. package/dist/lib/conversations.module.d.ts +78 -71
  199. package/dist/lib/conversations.module.d.ts.map +1 -1
  200. package/dist/lib/conversations.module.js +68 -1
  201. package/dist/lib/conversations.module.js.map +1 -1
  202. package/dist/lib/models/agent-turn.model.d.ts +7 -1
  203. package/dist/lib/models/agent-turn.model.d.ts.map +1 -1
  204. package/dist/lib/models/agent-turn.model.js.map +1 -1
  205. package/dist/lib/services/agent-state.service.d.ts.map +1 -1
  206. package/dist/lib/services/agent-state.service.js +14 -3
  207. package/dist/lib/services/agent-state.service.js.map +1 -1
  208. package/dist/lib/services/artifact-permission.service.d.ts.map +1 -1
  209. package/dist/lib/services/artifact-permission.service.js +14 -3
  210. package/dist/lib/services/artifact-permission.service.js.map +1 -1
  211. package/dist/lib/services/artifact-state.service.d.ts.map +1 -1
  212. package/dist/lib/services/artifact-state.service.js +43 -11
  213. package/dist/lib/services/artifact-state.service.js.map +1 -1
  214. package/dist/lib/services/conversation-agent.service.d.ts +31 -21
  215. package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
  216. package/dist/lib/services/conversation-agent.service.js +84 -35
  217. package/dist/lib/services/conversation-agent.service.js.map +1 -1
  218. package/dist/lib/services/conversation-tasks-filter.d.ts +59 -2
  219. package/dist/lib/services/conversation-tasks-filter.d.ts.map +1 -1
  220. package/dist/lib/services/conversation-tasks-filter.js +222 -18
  221. package/dist/lib/services/conversation-tasks-filter.js.map +1 -1
  222. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts +85 -0
  223. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts.map +1 -0
  224. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js +257 -0
  225. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js.map +1 -0
  226. package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts +85 -0
  227. package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts.map +1 -0
  228. package/dist/lib/services/edge-ai/edge-ai-protocol.js +10 -0
  229. package/dist/lib/services/edge-ai/edge-ai-protocol.js.map +1 -0
  230. package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts +90 -0
  231. package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts.map +1 -0
  232. package/dist/lib/services/edge-ai/edge-ai-worker-host.js +386 -0
  233. package/dist/lib/services/edge-ai/edge-ai-worker-host.js.map +1 -0
  234. package/dist/lib/services/edge-ai/edge-ai.worker.d.ts +13 -0
  235. package/dist/lib/services/edge-ai/edge-ai.worker.d.ts.map +1 -0
  236. package/dist/lib/services/edge-ai/edge-ai.worker.js +201 -0
  237. package/dist/lib/services/edge-ai/edge-ai.worker.js.map +1 -0
  238. package/dist/lib/services/export.service.d.ts +64 -0
  239. package/dist/lib/services/export.service.d.ts.map +1 -1
  240. package/dist/lib/services/export.service.js +185 -6
  241. package/dist/lib/services/export.service.js.map +1 -1
  242. package/dist/lib/services/library-creation.service.d.ts +304 -0
  243. package/dist/lib/services/library-creation.service.d.ts.map +1 -0
  244. package/dist/lib/services/library-creation.service.js +1244 -0
  245. package/dist/lib/services/library-creation.service.js.map +1 -0
  246. package/dist/lib/services/realtime-pairing.d.ts +3 -3
  247. package/dist/lib/services/realtime-pairing.js +4 -4
  248. package/dist/lib/services/realtime-pairing.js.map +1 -1
  249. package/dist/lib/services/realtime-session-review.service.d.ts +14 -0
  250. package/dist/lib/services/realtime-session-review.service.d.ts.map +1 -1
  251. package/dist/lib/services/realtime-session-review.service.js +46 -4
  252. package/dist/lib/services/realtime-session-review.service.js.map +1 -1
  253. package/dist/lib/services/realtime-session.service.d.ts.map +1 -1
  254. package/dist/lib/services/realtime-session.service.js +2 -1
  255. package/dist/lib/services/realtime-session.service.js.map +1 -1
  256. package/dist/lib/services/search.service.d.ts +19 -2
  257. package/dist/lib/services/search.service.d.ts.map +1 -1
  258. package/dist/lib/services/search.service.js +99 -36
  259. package/dist/lib/services/search.service.js.map +1 -1
  260. package/dist/lib/utils/agent-handoff-map.js +1 -1
  261. package/dist/lib/utils/agent-handoff-map.js.map +1 -1
  262. package/dist/lib/utils/agent-turn-routing.js +1 -1
  263. package/dist/lib/utils/agent-turn-routing.js.map +1 -1
  264. package/dist/lib/utils/decision-routing.d.ts +5 -2
  265. package/dist/lib/utils/decision-routing.d.ts.map +1 -1
  266. package/dist/lib/utils/decision-routing.js +9 -4
  267. package/dist/lib/utils/decision-routing.js.map +1 -1
  268. package/dist/public-api.d.ts +15 -0
  269. package/dist/public-api.d.ts.map +1 -1
  270. package/dist/public-api.js +17 -1
  271. package/dist/public-api.js.map +1 -1
  272. package/package.json +42 -37
@@ -1 +1 @@
1
- {"version":3,"file":"remote-browser-surface.component.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/remote-browser/remote-browser-surface.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAAE,iBAAiB,EAAE,SAAS,EAAc,YAAY,EAAE,KAAK,EAAE,MAAM,EACtF,MAAM,EAAE,SAAS,EAAE,MAAM,EAClC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;;;;;;IAwJ9D,+BAAyE;IACvE,wBAA2D;IAAC,gCAC9D;IAAA,iBAAO;;;;IAGP,kCAQC;IADC,iMAAS,yBAAkB,KAAC;IAE5B,wBAAqH;IACvH,iBAAS;;;IAPP,sDAAsC;IAGtC,yFAAoE;;IAGhD,cAAoC;IAAC,AAArC,oDAAoC,sCAAqC;;;IAY3F,gCAAuE;;;IAIzE,+BAA4B;IAC1B,iCA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;YAAA,YAAwC;YAAA,iBAAO;YAC/F,gGAAmB;YAKnB,kGAAsB;YAaxB,iBAAM;YACN,8BAAyB;YAkBrB,AAFA,AAfF,uFAAiB,4EAee,4EAEvB;YAMb,AADE,iBAAM,EACF;;YA9CoB,eAAiC;YAAjC,8CAAiC;YAC3B,eAA0C;YAA1C,mEAA0C;YACjD,cAA0B;YAA1B,4CAA0B;YAAC,cAAwC;YAAxC,4DAAwC;YACxF,cAIC;YAJD,0CAIC;YACD,cAYC;YAZD,6CAYC;YAGD,eAqBC;YArBD,sEAqBC;4BAjDG,YAAY,EAAE,mBAAmB;;iFAiMhC,6BAA6B;cApMzC,SAAS;6BACI,IAAI,YACN,oCAAoC,WACrC,CAAC,YAAY,EAAE,mBAAmB,CAAC,mBAC3B,uBAAuB,CAAC,MAAM,YACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDT;;kBA+IA,KAAK;;kBAQL,KAAK;;kBAQL,KAAK;;kBA0BL,KAAK;;kBAyBL,KAAK;;kBAeL,MAAM;;kBAMN,KAAK;;kBAOL,KAAK;;kBAGL,MAAM;;kBA8BN,SAAS;mBAAC,aAAa;;kBAGvB,SAAS;mBAAC,cAAc;;kFArId,6BAA6B","sourcesContent":["import {\n ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy,\n OnInit, Output, ViewChild, inject\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SharedGenericModule } from '@memberjunction/ng-shared-generic';\n\n/** How often the surface polls the server for a fresh page screenshot while bound (~1.4 fps). */\nconst SNAPSHOT_POLL_MS = 700;\n\n/** Min interval between forwarded pointer-move samples during takeover (~20 moves/sec). */\nconst POINTER_MOVE_THROTTLE_MS = 50;\n\n/** Min interval between forwarded scroll samples during takeover; the deltas coalesce between sends (~25/sec). */\nconst SCROLL_THROTTLE_MS = 40;\n\n/** Radius (px) of the synthetic cursor ring drawn on the overlay so the user can see their pointer. */\nconst SYNTHETIC_CURSOR_RADIUS = 6;\n\n/** A keyboard modifier held during a relayed human input (Shift-click selection, Ctrl/Cmd+key chords). */\nexport type RemoteBrowserModifier = 'Shift' | 'Control' | 'Alt' | 'Meta';\n\n/**\n * One human-takeover input the surface emits to the channel while the user \"drives\" the live view.\n * Mirrors the server's `RemoteBrowserHumanInput` union (flattened for transport): pointer\n * moves/clicks/down/up and scrolls carry VIEWPORT coordinates, a scroll also carries wheel deltas, a key\n * carries the pressed key string. Pointer clicks/down/up and keys also carry any held `modifiers`.\n */\nexport interface RemoteBrowserHumanInputEvent {\n /** Which input occurred. */\n kind: 'pointer-move' | 'pointer-click' | 'pointer-down' | 'pointer-up' | 'key' | 'text' | 'scroll';\n /** Viewport X (pointer + scroll kinds only). */\n x?: number;\n /** Viewport Y (pointer + scroll kinds only). */\n y?: number;\n /** Mouse button (pointer-click / -down / -up only). */\n button?: 'left' | 'middle' | 'right';\n /** The pressed key (key kind only). */\n key?: string;\n /** The pasted clipboard text (text kind only) — inserted into the remote page's focused element. */\n text?: string;\n /** Horizontal wheel delta in pixels (scroll kind only; positive = right). */\n deltaX?: number;\n /** Vertical wheel delta in pixels (scroll kind only; positive = down). */\n deltaY?: number;\n /** Modifier keys held during the input (pointer-click / -down / -up and key kinds). */\n modifiers?: RemoteBrowserModifier[];\n}\n\n/**\n * Keys forwarded into the page during takeover even though they aren't single printable characters —\n * navigation/editing keys the page (not the host app) should receive. `preventDefault` is applied only to\n * forwarded keys so the host app's own shortcuts on un-forwarded keys still work.\n */\nconst FORWARDED_CONTROL_KEYS = new Set<string>([\n 'Enter', 'Tab', 'Backspace', 'Delete', 'Escape',\n 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight',\n 'Home', 'End', 'PageUp', 'PageDown',\n]);\n\n/**\n * The modifier keys themselves — pressing one alone is never forwarded as a key (it only rides as a\n * modifier on the NEXT non-modifier key / click), so the page never receives a lone `'Shift'` keypress.\n */\nconst MODIFIER_KEYS = new Set<string>(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock']);\n\n/**\n * Maps a display-space pointer position on the live canvas to the server browser's VIEWPORT pixel space.\n *\n * The canvas's internal resolution (`canvasWidth`/`canvasHeight`, set from each pushed frame) IS the\n * viewport pixel space; the canvas is displayed scaled to its bounding rect. So a display point maps as\n * `vx = (clientX - rect.left) / rect.width * canvasWidth` (and likewise for y), rounded to ints. Returns\n * `null` for a zero-size rect or un-sized canvas (divide-by-zero / not-ready guard).\n *\n * Pure + framework-free so it's unit-testable without a DOM.\n *\n * @param clientX The pointer's viewport X in the DOM (`event.clientX`).\n * @param clientY The pointer's viewport Y in the DOM (`event.clientY`).\n * @param rect The canvas's bounding rect (`getBoundingClientRect()`).\n * @param canvasWidth The canvas's internal pixel width (= frame/viewport width).\n * @param canvasHeight The canvas's internal pixel height (= frame/viewport height).\n * @returns Integer viewport coordinates, or `null` when mapping isn't possible.\n */\nexport function MapToViewportCoords(\n clientX: number,\n clientY: number,\n rect: { left: number; top: number; width: number; height: number },\n canvasWidth: number,\n canvasHeight: number,\n): { x: number; y: number } | null {\n if (rect.width <= 0 || rect.height <= 0 || canvasWidth <= 0 || canvasHeight <= 0) {\n return null;\n }\n const x = Math.round((clientX - rect.left) / rect.width * canvasWidth);\n const y = Math.round((clientY - rect.top) / rect.height * canvasHeight);\n return { x, y };\n}\n\n/**\n * One snapshot of the server-hosted browser — the shape the surface's {@link RemoteBrowserSurfaceComponent.Fetch}\n * callback resolves to. Mirrors the server's `RemoteBrowserSnapshot` query payload.\n */\nexport interface RemoteBrowserSnapshotView {\n /** The current page screenshot as raw base64 PNG, or `null` when none is available yet. */\n ScreenshotBase64: string | null;\n /** The current page URL, or `null` when no page is loaded. */\n CurrentUrl: string | null;\n}\n\n/**\n * Fetches one {@link RemoteBrowserSnapshotView} from the server. Supplied by the channel\n * plugin (it owns the session id + GraphQL provider). Best-effort by contract: resolves to\n * `null` on any failure rather than throwing, so the surface keeps the last good frame.\n */\nexport type RemoteBrowserSnapshotFetcher = () => Promise<RemoteBrowserSnapshotView | null>;\n\n/**\n * Reads the remote page's CURRENT text selection for copy-out (the mirror of the `'text'` paste-in path).\n * Supplied by the channel plugin (it owns the session id + GraphQL provider). Best-effort by contract:\n * resolves to `''` on any failure / when nothing is selected rather than throwing, so a best-effort copy\n * never breaks the live view.\n */\nexport type RemoteBrowserSelectionFetcher = () => Promise<string>;\n\n/**\n * LIVE REMOTE-BROWSER surface (`mj-realtime-remote-browser-surface`) — the Browser channel\n * tab's pane. It renders the SERVER-hosted browser the agent drives: a refreshing screenshot\n * `<img>` with the current URL above it and a small \"live\" indicator. The agent's\n * `browser_*` tools mutate the page through the channel plugin; this surface only PERCEIVES\n * it, polling its {@link Fetch} callback every {@link SNAPSHOT_POLL_MS} ms while bound and on screen.\n *\n * The surface is transport-agnostic — it never touches GraphQL directly. The channel plugin\n * wires the {@link Fetch} callback (closing over the session id + provider) in `BindSurface`\n * before the surface's first change detection, so the `ngOnInit` poll has it. Polling stops\n * in `ngOnDestroy` (the channel left the session / the overlay was torn down) so no traffic\n * continues after unbind, and pauses while the surface is out of sight ({@link Visible}).\n * View-only in v1 — there is no takeover input.\n *\n * ### Two render paths: pushed screencast (preferred) vs. snapshot poll (fallback)\n * When the backend advertises the `ScreenStreaming` capability, the server PUSHES encoded CDP\n * frames and the channel plugin sets {@link Streaming} = `true`. In that mode the surface paints\n * each frame onto a `<canvas>` via {@link RenderFrame} and DOES NOT start the poll. When streaming\n * is off (capability absent or start failed) the original behavior is unchanged: the surface polls\n * {@link Fetch} every {@link SNAPSHOT_POLL_MS} ms and renders the screenshot `<img>`.\n */\n@Component({\n standalone: true,\n selector: 'mj-realtime-remote-browser-surface',\n imports: [CommonModule, SharedGenericModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"rb-surface\">\n <div class=\"rb-bar\">\n <span class=\"rb-live\" [class.rb-live--on]=\"HasSnapshot\" aria-hidden=\"true\"></span>\n <span class=\"rb-live-label\">{{ HasSnapshot ? 'Live' : 'Connecting…' }}</span>\n <span class=\"rb-url\" [title]=\"CurrentUrl || ''\">{{ CurrentUrl || 'No page loaded yet' }}</span>\n @if (CanTakeOver) {\n <span class=\"rb-driving\" title=\"Click and type to control the live page\">\n <i class=\"fa-solid fa-hand-pointer\" aria-hidden=\"true\"></i> You're driving\n </span>\n }\n @if (AudioAvailable) {\n <button\n type=\"button\"\n class=\"rb-speaker\"\n [class.rb-speaker--muted]=\"AudioMuted\"\n [attr.aria-pressed]=\"!AudioMuted\"\n [attr.aria-label]=\"AudioMuted ? 'Unmute browser audio' : 'Mute browser audio'\"\n [title]=\"AudioMuted ? 'Unmute browser audio' : 'Mute browser audio'\"\n (click)=\"ToggleAudioMuted()\"\n >\n <i class=\"fa-solid\" [class.fa-volume-high]=\"!AudioMuted\" [class.fa-volume-xmark]=\"AudioMuted\" aria-hidden=\"true\"></i>\n </button>\n }\n </div>\n <div class=\"rb-viewport\">\n @if (Streaming) {\n <div class=\"rb-canvas-stack\" [class.rb-hidden]=\"!HasFrame\">\n <canvas #frameCanvas class=\"rb-screenshot\" [class.rb-screenshot--interactive]=\"CanTakeOver\"></canvas>\n @if (CanTakeOver) {\n <!-- Synthetic cursor overlay: same internal resolution + CSS box as the frame canvas, so a\n point drawn at viewport coords aligns exactly. CDP screencast frames don't include the OS\n cursor, so we render the user's pointer locally for immediate, round-trip-free feedback. -->\n <canvas #cursorCanvas class=\"rb-screenshot rb-cursor-overlay\"></canvas>\n }\n </div>\n @if (!HasFrame) {\n <div class=\"rb-placeholder\">\n <mj-loading text=\"Waiting for the browser…\" size=\"medium\"></mj-loading>\n </div>\n }\n } @else if (ScreenshotDataUrl) {\n <img class=\"rb-screenshot\" [src]=\"ScreenshotDataUrl\" alt=\"Live view of the shared browser\" />\n } @else {\n <div class=\"rb-placeholder\">\n <mj-loading text=\"Waiting for the browser…\" size=\"medium\"></mj-loading>\n </div>\n }\n </div>\n </div>\n `,\n styles: [`\n :host { display: block; height: 100%; }\n .rb-surface {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: var(--mj-bg-surface-sunken);\n }\n .rb-bar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--mj-border-subtle);\n background: var(--mj-bg-surface);\n font-size: 0.8125rem;\n color: var(--mj-text-secondary);\n }\n .rb-live {\n width: 8px;\n height: 8px;\n border-radius: var(--mj-radius-full, 50%);\n background: var(--mj-text-disabled);\n flex: 0 0 auto;\n }\n .rb-live--on {\n background: var(--mj-status-success);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-status-success) 25%, transparent);\n }\n .rb-live-label {\n flex: 0 0 auto;\n font-weight: 600;\n color: var(--mj-text-primary);\n }\n .rb-url {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-family: var(--mj-font-mono, monospace);\n }\n .rb-viewport {\n flex: 1 1 auto;\n min-height: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: auto;\n padding: 12px;\n }\n .rb-screenshot {\n max-width: 100%;\n max-height: 100%;\n object-fit: contain;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 6px);\n box-shadow: var(--mj-shadow-sm, 0 1px 3px color-mix(in srgb, var(--mj-text-primary) 12%, transparent));\n background: var(--mj-bg-surface);\n }\n .rb-screenshot--interactive {\n /* Hide the OS cursor — we render a synthetic cursor on the overlay so there's exactly one pointer\n and it reads naturally for clicking on a web page (not the old crosshair). */\n cursor: none;\n outline: none;\n }\n .rb-screenshot--interactive:focus-visible {\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 25%, transparent);\n }\n /* Frame canvas + synthetic-cursor overlay share one box; the stack shrinks to the frame canvas so the\n absolutely-positioned overlay (inset:0, same object-fit) lines up pixel-for-pixel with it. */\n .rb-canvas-stack {\n position: relative;\n display: inline-flex;\n max-width: 100%;\n max-height: 100%;\n min-height: 0;\n }\n .rb-cursor-overlay {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n /* Transparent passthrough layer — no chrome of its own, and never steals pointer/wheel events from\n the frame canvas underneath (those listeners drive takeover). */\n border: none;\n box-shadow: none;\n background: transparent;\n pointer-events: none;\n }\n .rb-driving {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 2px 8px;\n border-radius: var(--mj-radius-full, 999px);\n font-size: 0.75rem;\n font-weight: 600;\n color: var(--mj-brand-primary);\n background: color-mix(in srgb, var(--mj-brand-primary) 12%, transparent);\n }\n .rb-placeholder {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .rb-hidden {\n display: none;\n }\n .rb-speaker {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 6px);\n background: var(--mj-bg-surface);\n color: var(--mj-brand-primary);\n cursor: pointer;\n font-size: 0.8125rem;\n transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;\n }\n .rb-speaker:hover {\n background: var(--mj-bg-surface-hover);\n }\n .rb-speaker:focus-visible {\n outline: none;\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 25%, transparent);\n }\n .rb-speaker--muted {\n color: var(--mj-text-muted);\n }\n `]\n})\nexport class RemoteBrowserSurfaceComponent implements OnInit, OnDestroy {\n /** Snapshot fetcher supplied by the channel plugin (closes over the session id + provider). */\n @Input() Fetch: RemoteBrowserSnapshotFetcher | null = null;\n\n /**\n * Selection fetcher for copy-out, supplied by the channel plugin (closes over the session id + provider).\n * On a local `copy` / Cmd+C over the live canvas the surface calls this to read the remote page's\n * selection, then writes it to the local clipboard. Best-effort: when unset or it resolves to `''`, the\n * copy is a no-op (the local clipboard is left untouched).\n */\n @Input() FetchSelection: RemoteBrowserSelectionFetcher | null = null;\n\n /**\n * Whether the surface is on screen, set by the channel plugin when the host reports it\n * (`OnSurfaceVisibilityChange`). Out of sight, the snapshot poll pauses: nobody sees it, and the\n * agent's frames come from the channel's own video bridge. Back in sight, the surface fetches a\n * snapshot at once and polls again. The pushed screencast is unaffected.\n */\n @Input()\n set Visible(value: boolean) {\n if (value === this._visible) {\n return;\n }\n this._visible = value;\n if (!value) {\n this.stopPolling();\n } else if (this.initialized) {\n this.resumePolling();\n }\n }\n get Visible(): boolean {\n return this._visible;\n }\n private _visible = true;\n\n /**\n * Whether the server is PUSHING live screencast frames for this session (the backend advertised the\n * `ScreenStreaming` capability and the start succeeded). When `true` the surface paints pushed frames\n * onto its `<canvas>` via {@link RenderFrame} and does NOT poll; when `false` it uses the snapshot\n * `<img>` poll fallback. Set by the channel plugin in `BindSurface` from the start-screencast result.\n *\n * The start-screencast result is async, so this may flip to `true` AFTER `ngOnInit` has already begun\n * polling — the setter tears the poll down in that case so the two render paths never run at once.\n */\n @Input()\n set Streaming(value: boolean) {\n if (value === this._streaming) {\n return;\n }\n this._streaming = value;\n if (value) {\n // Late flip after the poll-fallback already started: stop polling, switch to canvas frames.\n this.stopPolling();\n this.zone.run(() => this.cdr.markForCheck());\n }\n // Takeover only attaches on the canvas path — (de)attach as streaming flips.\n this.syncTakeoverListeners();\n }\n get Streaming(): boolean {\n return this._streaming;\n }\n private _streaming = false;\n\n /**\n * Whether HUMAN TAKEOVER is enabled — the user watching the live view can click/type into the page and\n * those events are relayed into the server browser (Collaborative control). Takeover only attaches to the\n * canvas render path (pushed screencast); the `<img>` poll fallback stays view-only. When enabled while\n * already streaming the setter attaches listeners; flipping it off (or streaming off) detaches them.\n */\n @Input()\n set Interactive(value: boolean) {\n if (value === this._interactive) {\n return;\n }\n this._interactive = value;\n this.syncTakeoverListeners();\n this.zone.run(() => this.cdr.markForCheck());\n }\n get Interactive(): boolean {\n return this._interactive;\n }\n private _interactive = false;\n\n /** Emits each human-takeover input (pointer move/click, key) the user performs on the live canvas. */\n @Output() HumanInput = new EventEmitter<RemoteBrowserHumanInputEvent>();\n\n /**\n * Whether the live tab-audio stream is available — the channel sets this `true` when the server confirms\n * it is pushing audio. Drives whether the speaker toggle renders in the live-view bar.\n */\n @Input() AudioAvailable = false;\n\n /**\n * Whether tab audio is currently muted. Two-way: the channel sets the initial value (un-muted when audio\n * starts) and the toggle updates it; {@link AudioMutedChange} relays each user change to the channel,\n * which mutes/unmutes the player.\n */\n @Input() AudioMuted = false;\n\n /** Emits the new muted state each time the user toggles the speaker (two-way `AudioMuted`). */\n @Output() AudioMutedChange = new EventEmitter<boolean>();\n\n /** Toggles the speaker mute state and relays it to the channel (which mutes/unmutes the audio player). */\n public ToggleAudioMuted(): void {\n this.AudioMuted = !this.AudioMuted;\n this.AudioMutedChange.emit(this.AudioMuted);\n }\n\n /** True when takeover is both enabled AND on the canvas path — drives the cursor + \"driving\" pill. */\n public get CanTakeOver(): boolean {\n return this._interactive && this._streaming;\n }\n\n /**\n * True while the user is actively driving the remote browser with the keyboard — the takeover canvas\n * holds focus. The host overlay reads this to stand down its own global keyboard shortcuts (e.g.\n * T-to-type opening the local composer) so keystrokes go to the remote page, not the local input.\n */\n public get IsCapturingInput(): boolean {\n return this.surfaceFocused && this.CanTakeOver;\n }\n\n /** The current screenshot as a `data:` URL, or `null` before the first snapshot arrives. */\n public ScreenshotDataUrl: string | null = null;\n /** The current page URL reported by the server, or `null` when none. */\n public CurrentUrl: string | null = null;\n /** Whether at least one pushed screencast frame has been painted (drives the canvas placeholder). */\n public HasFrame = false;\n\n /** The canvas the pushed screencast frames are painted onto (present only while {@link Streaming}). */\n @ViewChild('frameCanvas') private frameCanvas?: ElementRef<HTMLCanvasElement>;\n\n /** The transparent overlay the synthetic cursor is drawn onto (present only while {@link CanTakeOver}). */\n @ViewChild('cursorCanvas') private cursorCanvas?: ElementRef<HTMLCanvasElement>;\n\n /** Whether at least one screenshot OR frame has been rendered (drives the \"Live\" indicator). */\n public get HasSnapshot(): boolean {\n return this.ScreenshotDataUrl !== null || this.HasFrame;\n }\n\n private readonly cdr = inject(ChangeDetectorRef);\n private readonly zone = inject(NgZone);\n /** Active poll timer; `null` when polling is stopped. */\n private pollTimer: ReturnType<typeof setInterval> | null = null;\n /** Guards against overlapping polls when a request runs longer than the interval. */\n private polling = false;\n /** Set on destroy so an in-flight poll's late resolution doesn't touch a torn-down view. */\n private destroyed = false;\n /** Set in `ngOnInit`: polling starts there, so a visibility change before it must not start it early. */\n private initialized = false;\n /** Reused decode target for pushed frames — avoids allocating an `Image` per frame. */\n private readonly frameImage = new Image();\n /** The most recent un-painted frame data URL, drained on the next animation frame (drop-old coalescing). */\n private pendingFrameDataUrl: string | null = null;\n /** True while a paint is scheduled, so rapid frames coalesce to one `requestAnimationFrame`. */\n private framePaintScheduled = false;\n\n /** The canvas element takeover listeners are currently bound to, or `null` when detached. */\n private takeoverCanvas: HTMLCanvasElement | null = null;\n /** Timestamp (ms) of the last forwarded pointer-move, for throttling the high-frequency stream. */\n private lastPointerMoveAt = 0;\n /** Timestamp (ms) of the last forwarded scroll, for throttling the high-frequency wheel stream. */\n private lastScrollAt = 0;\n /** Horizontal wheel delta accumulated since the last forwarded scroll (coalesced across throttled events). */\n private pendingScrollDeltaX = 0;\n /** Vertical wheel delta accumulated since the last forwarded scroll (coalesced across throttled events). */\n private pendingScrollDeltaY = 0;\n\n /** Last canvas-relative mouse position in VIEWPORT pixel space, or `null` when the pointer is off-canvas. */\n private cursorViewportPoint: { x: number; y: number } | null = null;\n /** True while a synthetic-cursor repaint is queued, so rapid moves coalesce to one `requestAnimationFrame`. */\n private cursorPaintScheduled = false;\n\n /**\n * True while the user is mid-drag on the canvas (a `mousedown` not yet released) — drives forwarding\n * intermediate moves as a drag and emitting the closing `pointer-up`. Click-drag text selection relies on\n * this so the drag relays as down → moves → up rather than a single discrete click.\n */\n private dragging = false;\n\n /**\n * True when the most recent `mousedown`→`mouseup` actually MOVED (a real drag), so the synthetic `click`\n * the browser fires right after should be suppressed — the drag's down/move/up already conveyed the intent,\n * and a trailing click would collapse a just-made text selection.\n */\n private suppressNextClick = false;\n\n /** Viewport point of the active drag's mousedown, used to tell a real drag from a stationary click. */\n private dragStartPoint: { x: number; y: number } | null = null;\n\n /**\n * True while the takeover canvas currently HOLDS keyboard focus. The host overlay reads this (via\n * {@link IsCapturingInput}) to suppress its own global key shortcuts (e.g. T-to-type) so the user's\n * keystrokes land in the remote browser, not the local composer — fixing the \"greedy textbox\" focus theft.\n */\n private surfaceFocused = false;\n\n /** Bound handlers — stored so the exact same references can be removed on detach. */\n private readonly onCanvasMouseMove = (e: MouseEvent): void => this.handlePointerMove(e);\n private readonly onCanvasMouseDown = (e: MouseEvent): void => this.handlePointerDown(e);\n private readonly onCanvasMouseUp = (e: MouseEvent): void => this.handlePointerUp(e);\n private readonly onCanvasClick = (e: MouseEvent): void => this.handlePointerClick(e);\n private readonly onCanvasKeyDown = (e: KeyboardEvent): void => this.handleKeyDown(e);\n private readonly onCanvasPaste = (e: ClipboardEvent): void => this.handlePaste(e);\n private readonly onCanvasCopy = (e: ClipboardEvent): void => this.handleCopy(e);\n private readonly onCanvasMouseLeave = (): void => this.handleMouseLeave();\n private readonly onCanvasWheel = (e: WheelEvent): void => this.handleWheel(e);\n private readonly onCanvasFocus = (): void => { this.surfaceFocused = true; };\n private readonly onCanvasBlur = (): void => { this.surfaceFocused = false; };\n\n ngOnInit(): void {\n this.initialized = true;\n this.resumePolling();\n }\n\n ngOnDestroy(): void {\n this.destroyed = true;\n this.stopPolling();\n this.detachTakeoverListeners();\n }\n\n /**\n * Polls now and every {@link SNAPSHOT_POLL_MS} ms, unless the server pushes frames (the poll would be redundant\n * traffic) or the surface is out of sight.\n */\n private resumePolling(): void {\n if (this.Streaming || !this._visible || this.destroyed) {\n return;\n }\n void this.pollOnce();\n this.startPolling();\n }\n\n /** Starts the interval poll OUTSIDE Angular's zone so it doesn't trigger CD on every tick. */\n private startPolling(): void {\n if (this.pollTimer !== null) {\n return;\n }\n this.zone.runOutsideAngular(() => {\n this.pollTimer = setInterval(() => void this.pollOnce(), SNAPSHOT_POLL_MS);\n });\n }\n\n /** Stops the interval poll (no further snapshot requests are issued). */\n private stopPolling(): void {\n if (this.pollTimer !== null) {\n clearInterval(this.pollTimer);\n this.pollTimer = null;\n }\n }\n\n /**\n * Fetches one snapshot and applies it to the view. Best-effort: the fetcher resolves to\n * `null` on failure (the prior frame stays on screen) so a single failed poll never breaks\n * the live view. Skips when a prior poll is still in flight, the fetcher isn't wired, or\n * after destroy.\n */\n private async pollOnce(): Promise<void> {\n if (this.polling || this.destroyed || !this.Fetch) {\n return;\n }\n this.polling = true;\n try {\n const snapshot = await this.Fetch();\n this.applySnapshot(snapshot);\n } catch {\n // Defensive — the fetcher is contractually non-throwing, but never let a poll break the view.\n } finally {\n this.polling = false;\n }\n }\n\n /** Applies a fetched snapshot to the view fields and triggers OnPush change detection. */\n private applySnapshot(snapshot: RemoteBrowserSnapshotView | null): void {\n if (this.destroyed) {\n return;\n }\n const base64 = snapshot?.ScreenshotBase64 ?? null;\n const nextUrl = snapshot?.CurrentUrl ?? null;\n const nextDataUrl = base64 ? `data:image/png;base64,${base64}` : this.ScreenshotDataUrl;\n if (nextDataUrl === this.ScreenshotDataUrl && nextUrl === this.CurrentUrl) {\n return; // nothing changed — skip the CD pass\n }\n this.ScreenshotDataUrl = nextDataUrl;\n this.CurrentUrl = nextUrl;\n // Re-enter the zone for the OnPush update (the poll runs outside Angular).\n this.zone.run(() => this.cdr.markForCheck());\n }\n\n /**\n * Paints one PUSHED screencast frame (base64 JPEG) onto the canvas. Called by the channel plugin for\n * each frame the server pushes while {@link Streaming}. Coalesces a burst of frames to one paint per\n * animation frame (the newest wins) so a fast stream never floods the main thread, and reuses a single\n * `Image` decode target to avoid per-frame allocation. No-op after destroy or when not in streaming mode.\n *\n * @param dataBase64 The frame image as raw base64 JPEG (no `data:` prefix).\n */\n public RenderFrame(dataBase64: string): void {\n if (this.destroyed || !this.Streaming || !dataBase64) {\n return;\n }\n this.pendingFrameDataUrl = `data:image/jpeg;base64,${dataBase64}`;\n if (this.framePaintScheduled) {\n return; // a paint is already queued — it will pick up this newest frame\n }\n this.framePaintScheduled = true;\n this.zone.runOutsideAngular(() => requestAnimationFrame(() => this.paintPendingFrame()));\n }\n\n /**\n * Updates the URL shown above the live view. In streaming (canvas) mode the snapshot poll is stopped, so\n * the channel pushes the current URL here after a navigation/action reports one — otherwise the bar would\n * stay stuck on \"No page loaded yet\" even though the page is live. No-op for an unchanged / empty value.\n *\n * @param url The current page URL, or null/empty to leave the bar unchanged.\n */\n public SetCurrentUrl(url: string | null | undefined): void {\n if (this.destroyed || !url || url === this.CurrentUrl) {\n return;\n }\n this.CurrentUrl = url;\n this.zone.run(() => this.cdr.markForCheck());\n }\n\n /** Drains the most recent pending frame onto the canvas (drop-old coalescing target). */\n private paintPendingFrame(): void {\n this.framePaintScheduled = false;\n const dataUrl = this.pendingFrameDataUrl;\n this.pendingFrameDataUrl = null;\n if (this.destroyed || !dataUrl) {\n return;\n }\n this.frameImage.onload = () => this.drawFrameImage();\n this.frameImage.src = dataUrl;\n }\n\n /** Draws the decoded frame image onto the canvas, sizing the canvas to the frame on the first paint. */\n private drawFrameImage(): void {\n const canvas = this.frameCanvas?.nativeElement;\n if (this.destroyed || !canvas) {\n return;\n }\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return;\n }\n const { naturalWidth: w, naturalHeight: h } = this.frameImage;\n if (w > 0 && h > 0 && (canvas.width !== w || canvas.height !== h)) {\n canvas.width = w;\n canvas.height = h;\n }\n ctx.drawImage(this.frameImage, 0, 0);\n if (!this.HasFrame) {\n // First frame arrived — re-enter the zone to clear the placeholder + flip the \"Live\" indicator,\n // and attach takeover listeners now that the canvas element exists in the DOM.\n this.zone.run(() => {\n this.HasFrame = true;\n this.cdr.markForCheck();\n });\n this.syncTakeoverListeners();\n }\n }\n\n // ----- human takeover (Collaborative control) --------------------------------------------\n\n /**\n * Attaches or detaches the canvas takeover listeners so they're bound exactly when takeover is live —\n * {@link CanTakeOver} is true AND the canvas element exists. Idempotent: re-binds only when the target\n * canvas changed, detaches when the conditions no longer hold. Safe to call from any state-flip path\n * (the `Interactive`/`Streaming` setters, the first-frame paint, destroy).\n */\n private syncTakeoverListeners(): void {\n const canvas = this.CanTakeOver && !this.destroyed ? (this.frameCanvas?.nativeElement ?? null) : null;\n if (canvas === this.takeoverCanvas) {\n return; // already in the desired state\n }\n this.detachTakeoverListeners();\n if (canvas) {\n this.attachTakeoverListeners(canvas);\n }\n }\n\n /** Binds the pointer/keyboard/wheel listeners to the canvas OUTSIDE the zone (mousemove/wheel are high-frequency). */\n private attachTakeoverListeners(canvas: HTMLCanvasElement): void {\n canvas.tabIndex = 0; // focusable so it can receive keydown\n // Marks this canvas as a keyboard-capturing surface so the host overlay's global shortcuts (e.g.\n // T-to-type) stand down while it holds focus — see the overlay's isKeyboardCapturingSurfaceFocused().\n canvas.setAttribute('data-mj-capture-keys', '');\n this.zone.runOutsideAngular(() => {\n canvas.addEventListener('mousemove', this.onCanvasMouseMove);\n canvas.addEventListener('mousedown', this.onCanvasMouseDown);\n canvas.addEventListener('mouseup', this.onCanvasMouseUp);\n canvas.addEventListener('click', this.onCanvasClick);\n canvas.addEventListener('keydown', this.onCanvasKeyDown);\n // Paste-in / copy-out: the focused canvas receives the local clipboard `paste` / `copy` events; we\n // relay paste text into the remote page and write the remote selection to the local clipboard.\n canvas.addEventListener('paste', this.onCanvasPaste);\n canvas.addEventListener('copy', this.onCanvasCopy);\n canvas.addEventListener('mouseleave', this.onCanvasMouseLeave);\n canvas.addEventListener('focus', this.onCanvasFocus);\n canvas.addEventListener('blur', this.onCanvasBlur);\n // `passive: false` so preventDefault stops the host page from scrolling while the user drives the page.\n canvas.addEventListener('wheel', this.onCanvasWheel, { passive: false });\n });\n this.takeoverCanvas = canvas;\n }\n\n /** Removes the listeners from the currently-bound canvas (no-op when none are bound) and clears the cursor. */\n private detachTakeoverListeners(): void {\n const canvas = this.takeoverCanvas;\n if (!canvas) {\n return;\n }\n canvas.removeEventListener('mousemove', this.onCanvasMouseMove);\n canvas.removeEventListener('mousedown', this.onCanvasMouseDown);\n canvas.removeEventListener('mouseup', this.onCanvasMouseUp);\n canvas.removeEventListener('click', this.onCanvasClick);\n canvas.removeEventListener('keydown', this.onCanvasKeyDown);\n canvas.removeEventListener('paste', this.onCanvasPaste);\n canvas.removeEventListener('copy', this.onCanvasCopy);\n canvas.removeEventListener('mouseleave', this.onCanvasMouseLeave);\n canvas.removeEventListener('focus', this.onCanvasFocus);\n canvas.removeEventListener('blur', this.onCanvasBlur);\n canvas.removeEventListener('wheel', this.onCanvasWheel);\n canvas.removeAttribute('data-mj-capture-keys');\n this.takeoverCanvas = null;\n this.cursorViewportPoint = null;\n this.dragging = false;\n this.suppressNextClick = false;\n this.dragStartPoint = null;\n this.surfaceFocused = false;\n this.clearSyntheticCursor();\n }\n\n /**\n * Pointer-move → tracks the cursor for the synthetic-cursor overlay (every move, immediate, no\n * round-trip) AND emits a throttled viewport-mapped move to the server. Runs outside the zone (no CD\n * per move).\n */\n private handlePointerMove(event: MouseEvent): void {\n const point = this.toViewportCoords(event);\n if (point) {\n // Always update the local cursor for instant feedback — independent of the server-relay throttle.\n this.cursorViewportPoint = point;\n this.scheduleCursorPaint();\n }\n const now = Date.now();\n if (now - this.lastPointerMoveAt < POINTER_MOVE_THROTTLE_MS) {\n return;\n }\n this.lastPointerMoveAt = now;\n if (point) {\n this.emitInput({ kind: 'pointer-move', x: point.x, y: point.y });\n }\n }\n\n /** Mouse leaves the canvas → hide the synthetic cursor (nothing to relay). */\n private handleMouseLeave(): void {\n this.cursorViewportPoint = null;\n this.scheduleCursorPaint();\n }\n\n /**\n * Wheel/trackpad/Magic-Mouse scroll over the canvas → forwards a viewport-mapped scroll to the server.\n * Calls `preventDefault` so the host page doesn't scroll while the user drives the live page. Throttled\n * to {@link SCROLL_THROTTLE_MS}, coalescing the skipped deltas so no scroll distance is lost.\n */\n private handleWheel(event: WheelEvent): void {\n event.preventDefault();\n this.pendingScrollDeltaX += event.deltaX;\n this.pendingScrollDeltaY += event.deltaY;\n const point = this.toViewportCoords(event);\n if (point) {\n this.cursorViewportPoint = point;\n this.scheduleCursorPaint();\n }\n const now = Date.now();\n if (now - this.lastScrollAt < SCROLL_THROTTLE_MS) {\n return; // accumulate into pendingScrollDelta* until the throttle window opens\n }\n this.lastScrollAt = now;\n const target = point ?? this.cursorViewportPoint;\n if (target && (this.pendingScrollDeltaX !== 0 || this.pendingScrollDeltaY !== 0)) {\n this.emitInput({ kind: 'scroll', x: target.x, y: target.y, deltaX: this.pendingScrollDeltaX, deltaY: this.pendingScrollDeltaY });\n this.pendingScrollDeltaX = 0;\n this.pendingScrollDeltaY = 0;\n }\n }\n\n /**\n * Mouse-down on the canvas → focuses the canvas (so subsequent keys are captured) and BEGINS a drag:\n * emits a `pointer-down` and arms drag mode so the following moves relay as drag motion and the matching\n * `pointer-up` closes it. This is what makes click-drag text selection work (rather than a discrete click).\n */\n private handlePointerDown(event: MouseEvent): void {\n this.takeoverCanvas?.focus();\n const point = this.toViewportCoords(event);\n if (!point) {\n return;\n }\n this.dragging = true;\n this.dragStartPoint = point;\n this.suppressNextClick = false;\n this.cursorViewportPoint = point;\n this.scheduleCursorPaint();\n this.emitInput({ kind: 'pointer-down', x: point.x, y: point.y, button: this.mapButton(event.button), modifiers: this.collectModifiers(event) });\n }\n\n /**\n * Mouse-up on the canvas → closes a drag with a `pointer-up` at the release point, disarming drag mode.\n * If the pointer actually moved between down and up, marks the following synthetic `click` to be suppressed\n * (so the drag selection isn't immediately collapsed by a trailing click).\n */\n private handlePointerUp(event: MouseEvent): void {\n if (!this.dragging) {\n return;\n }\n this.dragging = false;\n const point = this.toViewportCoords(event);\n if (point) {\n const start = this.dragStartPoint;\n this.suppressNextClick = !!start && (start.x !== point.x || start.y !== point.y);\n this.emitInput({ kind: 'pointer-up', x: point.x, y: point.y, button: this.mapButton(event.button), modifiers: this.collectModifiers(event) });\n }\n this.dragStartPoint = null;\n }\n\n /**\n * Click → emits a viewport-mapped click WITH any held modifiers (e.g. Shift-click text selection). The\n * server browser receives the press/release of a drag via {@link handlePointerDown}/{@link handlePointerUp};\n * a plain click (down+up with no motion) still fires this `click` event, so a simple click relays as one\n * click action — but we skip emitting it when it terminates a real drag (where down/up already covered it).\n */\n private handlePointerClick(event: MouseEvent): void {\n this.takeoverCanvas?.focus();\n if (this.suppressNextClick) {\n // This click terminates a real drag (selection) — the down/move/up already conveyed it.\n this.suppressNextClick = false;\n return;\n }\n const point = this.toViewportCoords(event);\n if (point) {\n this.emitInput({ kind: 'pointer-click', x: point.x, y: point.y, button: this.mapButton(event.button), modifiers: this.collectModifiers(event) });\n }\n }\n\n /**\n * Keydown → forwards printable keys, a curated set of control keys ({@link FORWARDED_CONTROL_KEYS}), AND\n * any key combined with a Ctrl/Cmd/Alt modifier (so combos like Ctrl/Cmd+A select-all, Cmd+C/Cmd+V relay).\n * Calls `preventDefault` + `stopPropagation` ONLY on forwarded keys, so (a) the host app keeps its own\n * shortcuts on un-forwarded keys and (b) forwarded keys never bubble to the host overlay's global shortcuts\n * (the T-to-type focus-steal). Lone modifier keys are never forwarded — they ride as `modifiers` on the\n * next key/click.\n */\n private handleKeyDown(event: KeyboardEvent): void {\n const key = event.key;\n if (MODIFIER_KEYS.has(key)) {\n return; // a modifier on its own is not a keypress — it rides on the next key/click\n }\n const isPrintable = key.length === 1;\n const hasComboModifier = event.ctrlKey || event.metaKey || event.altKey;\n // Cmd/Ctrl+C and Cmd/Ctrl+V are handled by the dedicated `copy` / `paste` listeners (which read/write the\n // LOCAL clipboard) — don't ALSO relay them as a keypress, or paste would double-fire and copy would send a\n // useless Ctrl+C to the remote page. The browser fires the matching clipboard event for these chords.\n const isClipboardChord = (event.ctrlKey || event.metaKey) && (key === 'c' || key === 'v' || key === 'C' || key === 'V');\n const isForwardable = !isClipboardChord && (isPrintable || FORWARDED_CONTROL_KEYS.has(key) || hasComboModifier);\n if (!isForwardable) {\n return; // leave non-forwarded keys to the host app (and clipboard chords to copy/paste handlers)\n }\n event.preventDefault();\n // Stop the keystroke from reaching document-level handlers (e.g. the overlay's T-to-type) so the user's\n // typing lands in the remote browser, not the local composer.\n event.stopPropagation();\n this.emitInput({ kind: 'key', key, modifiers: this.collectModifiers(event) });\n }\n\n /**\n * Paste-in: a local `paste` (Cmd/Ctrl+V or context-menu paste) over the canvas → reads the LOCAL clipboard\n * text and relays it as a `'text'` human input, which the server inserts into the remote page's focused\n * element (the VNC/remote-desktop paste model — no remote-clipboard sync). `preventDefault` keeps the host\n * app from also acting on the paste; empty/non-text clipboards are a no-op.\n */\n private handlePaste(event: ClipboardEvent): void {\n event.preventDefault();\n event.stopPropagation();\n const text = event.clipboardData?.getData('text') ?? '';\n if (text.length === 0) {\n return; // nothing (or no text) on the clipboard — paste nothing\n }\n this.emitInput({ kind: 'text', text });\n }\n\n /**\n * Copy-out: a local `copy` (Cmd/Ctrl+C or context-menu copy) over the canvas → reads the REMOTE page's\n * current selection via {@link FetchSelection} and writes it to the LOCAL clipboard (the mirror of paste-in).\n * `preventDefault` stops the host app from copying its own empty selection. Best-effort throughout: when the\n * fetcher is unwired, resolves to `''`, or `navigator.clipboard` is unavailable / denies permission, the copy\n * is silently a no-op — it never throws and never breaks the live view.\n */\n private handleCopy(event: ClipboardEvent): void {\n event.preventDefault();\n event.stopPropagation();\n const fetchSelection = this.FetchSelection;\n if (!fetchSelection) {\n return;\n }\n void (async (): Promise<void> => {\n try {\n const text = await fetchSelection();\n if (text.length > 0 && navigator.clipboard?.writeText) {\n await navigator.clipboard.writeText(text);\n }\n } catch {\n // Best-effort: a denied clipboard permission or a failed selection read leaves the local clipboard\n // untouched rather than surfacing an error during takeover.\n }\n })();\n }\n\n /**\n * Collects the modifier keys currently held during a DOM mouse/keyboard event into the relayed\n * {@link RemoteBrowserModifier} list (empty when none are held).\n *\n * @param event The DOM event whose modifier flags to read.\n * @returns The held modifiers, in a stable order.\n */\n private collectModifiers(event: MouseEvent | KeyboardEvent): RemoteBrowserModifier[] {\n const modifiers: RemoteBrowserModifier[] = [];\n if (event.shiftKey) { modifiers.push('Shift'); }\n if (event.ctrlKey) { modifiers.push('Control'); }\n if (event.altKey) { modifiers.push('Alt'); }\n if (event.metaKey) { modifiers.push('Meta'); }\n return modifiers;\n }\n\n /** Re-enters the zone to emit one human input (so subscribers see it inside Angular). */\n private emitInput(input: RemoteBrowserHumanInputEvent): void {\n this.zone.run(() => this.HumanInput.emit(input));\n }\n\n /**\n * Maps a DOM pointer event on the live canvas to VIEWPORT coordinates via {@link MapToViewportCoords}\n * (the pure, unit-tested mapping). Returns `null` when no canvas is bound or mapping isn't possible yet.\n *\n * @param event The pointer event on the canvas.\n * @returns The integer viewport coordinates, or `null` when mapping isn't possible yet.\n */\n private toViewportCoords(event: MouseEvent): { x: number; y: number } | null {\n const canvas = this.takeoverCanvas;\n if (!canvas) {\n return null;\n }\n return MapToViewportCoords(event.clientX, event.clientY, canvas.getBoundingClientRect(), canvas.width, canvas.height);\n }\n\n // ----- synthetic cursor (local feedback — CDP frames don't include the OS cursor) -----------\n\n /**\n * Schedules a synthetic-cursor repaint on the next animation frame, coalescing a burst of moves to one\n * paint (the newest position wins). Runs outside the zone — drawing the cursor never triggers Angular CD.\n */\n private scheduleCursorPaint(): void {\n if (this.cursorPaintScheduled) {\n return;\n }\n this.cursorPaintScheduled = true;\n this.zone.runOutsideAngular(() => requestAnimationFrame(() => this.paintSyntheticCursor()));\n }\n\n /**\n * Draws (or clears) the synthetic cursor on the overlay canvas at {@link cursorViewportPoint}. The overlay\n * shares the frame canvas's internal resolution (sized here to match), so a point drawn at viewport coords\n * aligns exactly with the page underneath. A small brand-tinted ring with a center dot reads as a pointer\n * without obscuring what it's over. No-op after destroy or when the overlay isn't mounted.\n */\n private paintSyntheticCursor(): void {\n this.cursorPaintScheduled = false;\n const overlay = this.cursorCanvas?.nativeElement;\n const frame = this.frameCanvas?.nativeElement;\n if (this.destroyed || !overlay || !frame) {\n return;\n }\n // Keep the overlay's internal resolution locked to the frame canvas so coordinate spaces match.\n if (overlay.width !== frame.width || overlay.height !== frame.height) {\n overlay.width = frame.width;\n overlay.height = frame.height;\n }\n const ctx = overlay.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.clearRect(0, 0, overlay.width, overlay.height);\n const point = this.cursorViewportPoint;\n if (!point) {\n return; // pointer left the canvas — leave the overlay cleared\n }\n const ring = this.resolveCssColor('--mj-brand-primary', '#264FAF');\n ctx.beginPath();\n ctx.arc(point.x, point.y, SYNTHETIC_CURSOR_RADIUS, 0, Math.PI * 2);\n ctx.lineWidth = 2;\n ctx.strokeStyle = ring;\n ctx.stroke();\n ctx.beginPath();\n ctx.arc(point.x, point.y, 1.5, 0, Math.PI * 2);\n ctx.fillStyle = ring;\n ctx.fill();\n }\n\n /** Clears the synthetic-cursor overlay (e.g. on detach). No-op when the overlay isn't mounted. */\n private clearSyntheticCursor(): void {\n const overlay = this.cursorCanvas?.nativeElement;\n const ctx = overlay?.getContext('2d');\n if (overlay && ctx) {\n ctx.clearRect(0, 0, overlay.width, overlay.height);\n }\n }\n\n /**\n * Resolves a CSS custom property (design token) to its computed color value off the host element, so the\n * canvas-drawn cursor honors theming. Falls back to the supplied default when the token is unset or the\n * host isn't measurable.\n *\n * @param token The CSS custom property name (e.g. `'--mj-brand-primary'`).\n * @param fallback The color to use when the token resolves empty.\n * @returns The resolved color string.\n */\n private resolveCssColor(token: string, fallback: string): string {\n const host = this.frameCanvas?.nativeElement;\n if (!host) {\n return fallback;\n }\n const value = getComputedStyle(host).getPropertyValue(token).trim();\n return value.length > 0 ? value : fallback;\n }\n\n /** Maps a DOM `MouseEvent.button` (0/1/2) to the relayed button union, defaulting to `'left'`. */\n private mapButton(button: number): 'left' | 'middle' | 'right' {\n if (button === 1) {\n return 'middle';\n }\n if (button === 2) {\n return 'right';\n }\n return 'left';\n }\n}\n"]}
1
+ {"version":3,"file":"remote-browser-surface.component.js","source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AAI,YACN,oCAAoC,WACrC,CAAC,YAAY,EAAE,mBAAmB,CAAC,mBAC3B,uBAAuB,CAAC,MAAM,YACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GT;;kBA8PA,KAAK;;kBAQL,KAAK;;kBAQL,KAAK;;kBA0BL,KAAK;;kBAyBL,KAAK;;kBAeL,MAAM;;kBAMN,MAAM;;kBAMN,KAAK;;kBAOL,KAAK;;kBAGL,MAAM;;kBAuBN,KAAK;;kBAEL,KAAK;;kBAEL,KAAK;;kBAEL,KAAK;;kBAmCL,SAAS;mBAAC,YAAY;;kBAGtB,SAAS;mBAAC,aAAa;;kBAGvB,SAAS;mBAAC,cAAc;;kFAhLd,6BAA6B","sourcesContent":["import {\n AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, NgZone,\n OnDestroy, OnInit, Output, ViewChild, inject\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';\nimport { SharedGenericModule } from '@memberjunction/ng-shared-generic';\nimport { IsAllowedExternalMediaUrl } from '../media/media-channel-state';\n\n/** One visited page / browser action entry persisted or reconstructed for session review. */\nexport interface RemoteBrowserHistoryEntry {\n Url: string;\n VisitedAt?: string;\n ActionLabel?: string;\n Detail?: string;\n}\n\n/** Versioned state-of-record persisted by {@link RemoteBrowserChannel} for session resume & review. */\nexport interface SerializedRemoteBrowserState {\n V: 1;\n CurrentUrl: string | null;\n History: RemoteBrowserHistoryEntry[];\n ScreenshotDataUrl?: string | null;\n}\n\nconst RASTER_DATA_URL_RE = /^data:image\\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/;\n\n/** Validates that a persisted screenshot string is an inline raster PNG/JPEG/WebP data URL (never SVG/script). */\nexport function IsSafeRasterImageDataUrl(value: string | null | undefined): boolean {\n return typeof value === 'string' && RASTER_DATA_URL_RE.test(value);\n}\n\n/** How often the surface polls the server for a fresh page screenshot while bound (~1.4 fps). */\nconst SNAPSHOT_POLL_MS = 700;\n\n/** Min interval between forwarded pointer-move samples during takeover (~20 moves/sec). */\nconst POINTER_MOVE_THROTTLE_MS = 50;\n\n/** Min interval between forwarded scroll samples during takeover; the deltas coalesce between sends (~25/sec). */\nconst SCROLL_THROTTLE_MS = 40;\n\n/** Debounce delay (ms) before forwarding a ResizeObserver viewport change to the server. */\nconst VIEWPORT_RESIZE_DEBOUNCE_MS = 120;\n\n/** Radius (px) of the synthetic cursor ring drawn on the overlay so the user can see their pointer. */\nconst SYNTHETIC_CURSOR_RADIUS = 6;\n\n/** Usable drawer viewport dimensions (CSS pixels) reported by {@link RemoteBrowserSurfaceComponent.ViewportResize}. */\nexport interface RemoteBrowserViewportSize {\n /** Usable viewport width in CSS pixels. */\n Width: number;\n /** Usable viewport height in CSS pixels. */\n Height: number;\n}\n\n/** A keyboard modifier held during a relayed human input (Shift-click selection, Ctrl/Cmd+key chords). */\nexport type RemoteBrowserModifier = 'Shift' | 'Control' | 'Alt' | 'Meta';\n\n/**\n * One human-takeover input the surface emits to the channel while the user \"drives\" the live view.\n * Mirrors the server's `RemoteBrowserHumanInput` union (flattened for transport): pointer\n * moves/clicks/down/up and scrolls carry VIEWPORT coordinates, a scroll also carries wheel deltas, a key\n * carries the pressed key string. Pointer clicks/down/up and keys also carry any held `modifiers`.\n */\nexport interface RemoteBrowserHumanInputEvent {\n /** Which input occurred. */\n kind: 'pointer-move' | 'pointer-click' | 'pointer-down' | 'pointer-up' | 'key' | 'text' | 'scroll';\n /** Viewport X (pointer + scroll kinds only). */\n x?: number;\n /** Viewport Y (pointer + scroll kinds only). */\n y?: number;\n /** Mouse button (pointer-click / -down / -up only). */\n button?: 'left' | 'middle' | 'right';\n /** The pressed key (key kind only). */\n key?: string;\n /** The pasted clipboard text (text kind only) — inserted into the remote page's focused element. */\n text?: string;\n /** Horizontal wheel delta in pixels (scroll kind only; positive = right). */\n deltaX?: number;\n /** Vertical wheel delta in pixels (scroll kind only; positive = down). */\n deltaY?: number;\n /** Modifier keys held during the input (pointer-click / -down / -up and key kinds). */\n modifiers?: RemoteBrowserModifier[];\n}\n\n/**\n * Keys forwarded into the page during takeover even though they aren't single printable characters —\n * navigation/editing keys the page (not the host app) should receive. `preventDefault` is applied only to\n * forwarded keys so the host app's own shortcuts on un-forwarded keys still work.\n */\nconst FORWARDED_CONTROL_KEYS = new Set<string>([\n 'Enter', 'Tab', 'Backspace', 'Delete', 'Escape',\n 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight',\n 'Home', 'End', 'PageUp', 'PageDown',\n]);\n\n/**\n * The modifier keys themselves — pressing one alone is never forwarded as a key (it only rides as a\n * modifier on the NEXT non-modifier key / click), so the page never receives a lone `'Shift'` keypress.\n */\nconst MODIFIER_KEYS = new Set<string>(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock']);\n\n/**\n * Maps a display-space pointer position on the live canvas to the server browser's VIEWPORT pixel space.\n *\n * The canvas's internal resolution (`canvasWidth`/`canvasHeight`, set from each pushed frame) IS the\n * viewport pixel space; the canvas is displayed scaled to its bounding rect. So a display point maps as\n * `vx = (clientX - rect.left) / rect.width * canvasWidth` (and likewise for y), rounded to ints. Returns\n * `null` for a zero-size rect or un-sized canvas (divide-by-zero / not-ready guard).\n *\n * Pure + framework-free so it's unit-testable without a DOM.\n *\n * @param clientX The pointer's viewport X in the DOM (`event.clientX`).\n * @param clientY The pointer's viewport Y in the DOM (`event.clientY`).\n * @param rect The canvas's bounding rect (`getBoundingClientRect()`).\n * @param canvasWidth The canvas's internal pixel width (= frame/viewport width).\n * @param canvasHeight The canvas's internal pixel height (= frame/viewport height).\n * @returns Integer viewport coordinates, or `null` when mapping isn't possible.\n */\nexport function MapToViewportCoords(\n clientX: number,\n clientY: number,\n rect: { left: number; top: number; width: number; height: number },\n canvasWidth: number,\n canvasHeight: number,\n): { x: number; y: number } | null {\n if (rect.width <= 0 || rect.height <= 0 || canvasWidth <= 0 || canvasHeight <= 0) {\n return null;\n }\n const x = Math.round((clientX - rect.left) / rect.width * canvasWidth);\n const y = Math.round((clientY - rect.top) / rect.height * canvasHeight);\n return { x, y };\n}\n\n/**\n * Computes the largest CSS display box (in integer pixels) that fits within `viewportWidth × viewportHeight`\n * while preserving the frame's exact aspect ratio (`frameWidth / frameHeight`).\n *\n * Pure + framework-free so it's unit-testable without a DOM.\n *\n * @param viewportWidth Usable container width in CSS pixels.\n * @param viewportHeight Usable container height in CSS pixels.\n * @param frameWidth Frame bitmap width in pixels.\n * @param frameHeight Frame bitmap height in pixels.\n * @returns Fitted CSS display box `{ Width, Height }`, or `null` when any dimension is non-positive.\n */\nexport function ComputeFittedFrameSize(\n viewportWidth: number,\n viewportHeight: number,\n frameWidth: number,\n frameHeight: number,\n): RemoteBrowserViewportSize | null {\n if (\n !Number.isFinite(viewportWidth) ||\n !Number.isFinite(viewportHeight) ||\n !Number.isFinite(frameWidth) ||\n !Number.isFinite(frameHeight) ||\n viewportWidth <= 0 ||\n viewportHeight <= 0 ||\n frameWidth <= 0 ||\n frameHeight <= 0\n ) {\n return null;\n }\n const scale = Math.min(viewportWidth / frameWidth, viewportHeight / frameHeight);\n return {\n Width: Math.max(1, Math.round(frameWidth * scale)),\n Height: Math.max(1, Math.round(frameHeight * scale)),\n };\n}\n\n/**\n * One snapshot of the server-hosted browser — the shape the surface's {@link RemoteBrowserSurfaceComponent.Fetch}\n * callback resolves to. Mirrors the server's `RemoteBrowserSnapshot` query payload.\n */\nexport interface RemoteBrowserSnapshotView {\n /** The current page screenshot as raw base64 PNG, or `null` when none is available yet. */\n ScreenshotBase64: string | null;\n /** The current page URL, or `null` when no page is loaded. */\n CurrentUrl: string | null;\n}\n\n/**\n * Fetches one {@link RemoteBrowserSnapshotView} from the server. Supplied by the channel\n * plugin (it owns the session id + GraphQL provider). Best-effort by contract: resolves to\n * `null` on any failure rather than throwing, so the surface keeps the last good frame.\n */\nexport type RemoteBrowserSnapshotFetcher = () => Promise<RemoteBrowserSnapshotView | null>;\n\n/**\n * Reads the remote page's CURRENT text selection for copy-out (the mirror of the `'text'` paste-in path).\n * Supplied by the channel plugin (it owns the session id + GraphQL provider). Best-effort by contract:\n * resolves to `''` on any failure / when nothing is selected rather than throwing, so a best-effort copy\n * never breaks the live view.\n */\nexport type RemoteBrowserSelectionFetcher = () => Promise<string>;\n\n/**\n * LIVE REMOTE-BROWSER surface (`mj-realtime-remote-browser-surface`) — the Browser channel\n * tab's pane. It renders the SERVER-hosted browser the agent drives: a refreshing screenshot\n * `<img>` with the current URL above it and a small \"live\" indicator. The agent's\n * `browser_*` tools mutate the page through the channel plugin; this surface only PERCEIVES\n * it, polling its {@link Fetch} callback every {@link SNAPSHOT_POLL_MS} ms while bound and on screen.\n *\n * The surface is transport-agnostic — it never touches GraphQL directly. The channel plugin\n * wires the {@link Fetch} callback (closing over the session id + provider) in `BindSurface`\n * before the surface's first change detection, so the `ngOnInit` poll has it. Polling stops\n * in `ngOnDestroy` (the channel left the session / the overlay was torn down) so no traffic\n * continues after unbind, and pauses while the surface is out of sight ({@link Visible}).\n * View-only in v1 — there is no takeover input.\n *\n * ### Two render paths: pushed screencast (preferred) vs. snapshot poll (fallback)\n * When the backend advertises the `ScreenStreaming` capability, the server PUSHES encoded CDP\n * frames and the channel plugin sets {@link Streaming} = `true`. In that mode the surface paints\n * each frame onto a `<canvas>` via {@link RenderFrame} and DOES NOT start the poll. When streaming\n * is off (capability absent or start failed) the original behavior is unchanged: the surface polls\n * {@link Fetch} every {@link SNAPSHOT_POLL_MS} ms and renders the screenshot `<img>`.\n */\n@Component({\n standalone: true,\n selector: 'mj-realtime-remote-browser-surface',\n imports: [CommonModule, SharedGenericModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"rb-surface\">\n <div class=\"rb-bar\">\n <span class=\"rb-live\" [class.rb-live--on]=\"!ReadOnly && HasSnapshot\" aria-hidden=\"true\"></span>\n <span class=\"rb-live-label\">{{ ReadOnly ? 'Session snapshot' : (HasSnapshot ? 'Live' : 'Connecting…') }}</span>\n @if (ReadOnly && SafeExternalUrl(CurrentUrl); as safeHref) {\n <a class=\"rb-url rb-url--link\"\n [href]=\"safeHref\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n [title]=\"CurrentUrl || ''\">{{ CurrentUrl }}</a>\n <a class=\"rb-open-btn\"\n [href]=\"safeHref\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n aria-label=\"Open page in a new tab\"\n title=\"Open in new tab\">\n <i class=\"fa-solid fa-arrow-up-right-from-square\" aria-hidden=\"true\"></i>\n </a>\n } @else {\n <span class=\"rb-url\" [title]=\"CurrentUrl || ''\">{{ CurrentUrl || 'No page loaded yet' }}</span>\n }\n @if (CanTakeOver && !ReadOnly) {\n <span class=\"rb-driving\" title=\"Click and type to control the live page\">\n <i class=\"fa-solid fa-hand-pointer\" aria-hidden=\"true\"></i> You're driving\n </span>\n }\n @if (AudioAvailable && !ReadOnly) {\n <button\n type=\"button\"\n class=\"rb-speaker\"\n [class.rb-speaker--muted]=\"AudioMuted\"\n [attr.aria-pressed]=\"!AudioMuted\"\n [attr.aria-label]=\"AudioMuted ? 'Unmute browser audio' : 'Mute browser audio'\"\n [title]=\"AudioMuted ? 'Unmute browser audio' : 'Mute browser audio'\"\n (click)=\"ToggleAudioMuted()\"\n >\n <i class=\"fa-solid\" [class.fa-volume-high]=\"!AudioMuted\" [class.fa-volume-xmark]=\"AudioMuted\" aria-hidden=\"true\"></i>\n </button>\n }\n </div>\n <div #viewportEl class=\"rb-viewport\" [class.rb-viewport--review]=\"ReadOnly\">\n @if (ReadOnly) {\n @if (SafeScreenshotUrl; as reviewImg) {\n <div class=\"rb-review-stage\">\n <img class=\"rb-screenshot\" [src]=\"reviewImg\" alt=\"Saved view of the shared browser\" />\n </div>\n } @else if (SafeIframeUrl; as frameSrc) {\n <div class=\"rb-review-stage\">\n <iframe\n class=\"rb-iframe\"\n [src]=\"frameSrc\"\n [title]=\"CurrentUrl || 'Last visited browser page'\"\n sandbox=\"allow-scripts allow-same-origin allow-forms allow-popups\"\n referrerpolicy=\"no-referrer\"\n ></iframe>\n </div>\n }\n @if (ReviewHistory.length > 0) {\n <details class=\"rb-history\" [open]=\"!SafeScreenshotUrl && !SafeIframeUrl\">\n <summary class=\"rb-history__heading\">Visited pages ({{ ReviewHistory.length }})</summary>\n <ul class=\"rb-history__list\">\n @for (entry of ReviewHistory; track $index) {\n <li class=\"rb-history__item\">\n @if (entry.ActionLabel) {\n <span class=\"rb-history__action\">{{ entry.ActionLabel }}</span>\n }\n @if (SafeExternalUrl(entry.Url); as link) {\n <a class=\"rb-history__url\" [href]=\"link\" target=\"_blank\" rel=\"noopener noreferrer\" [title]=\"entry.Url\">\n {{ entry.Url }}\n </a>\n } @else {\n <span class=\"rb-history__url\">{{ entry.Url }}</span>\n }\n @if (entry.Detail) {\n <span class=\"rb-history__detail\">{{ entry.Detail }}</span>\n }\n </li>\n }\n </ul>\n </details>\n } @else if (!SafeScreenshotUrl && !SafeIframeUrl) {\n <div class=\"rb-placeholder\">\n <span class=\"rb-empty-note\">Browser session ended without a saved snapshot.</span>\n </div>\n }\n } @else if (Streaming) {\n <div class=\"rb-canvas-stack\" [class.rb-hidden]=\"!HasFrame\">\n <canvas #frameCanvas class=\"rb-screenshot\" [class.rb-screenshot--interactive]=\"CanTakeOver\"></canvas>\n @if (CanTakeOver) {\n <!-- Synthetic cursor overlay: same internal resolution + CSS box as the frame canvas, so a\n point drawn at viewport coords aligns exactly. CDP screencast frames don't include the OS\n cursor, so we render the user's pointer locally for immediate, round-trip-free feedback. -->\n <canvas #cursorCanvas class=\"rb-screenshot rb-cursor-overlay\"></canvas>\n }\n </div>\n @if (!HasFrame) {\n <div class=\"rb-placeholder\">\n <mj-loading text=\"Waiting for the browser…\" size=\"medium\"></mj-loading>\n </div>\n }\n } @else if (ScreenshotDataUrl) {\n <img class=\"rb-screenshot\" [src]=\"ScreenshotDataUrl\" alt=\"Live view of the shared browser\" />\n } @else {\n <div class=\"rb-placeholder\">\n <mj-loading text=\"Waiting for the browser…\" size=\"medium\"></mj-loading>\n </div>\n }\n </div>\n </div>\n `,\n styles: [`\n :host { display: block; height: 100%; }\n .rb-surface {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: var(--mj-bg-surface-sunken);\n }\n .rb-bar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid var(--mj-border-subtle);\n background: var(--mj-bg-surface);\n font-size: 0.8125rem;\n color: var(--mj-text-secondary);\n }\n .rb-live {\n width: 8px;\n height: 8px;\n border-radius: var(--mj-radius-full, 50%);\n background: var(--mj-text-disabled);\n flex: 0 0 auto;\n }\n .rb-live--on {\n background: var(--mj-status-success);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-status-success) 25%, transparent);\n }\n .rb-live-label {\n flex: 0 0 auto;\n font-weight: 600;\n color: var(--mj-text-primary);\n }\n .rb-url {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-family: var(--mj-font-mono, monospace);\n }\n .rb-viewport {\n flex: 1 1 auto;\n min-height: 0;\n min-width: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n padding: 0;\n }\n .rb-screenshot {\n max-width: 100%;\n max-height: 100%;\n width: auto;\n height: auto;\n object-fit: contain;\n border: none;\n border-radius: 0;\n box-shadow: none;\n background: var(--mj-bg-surface);\n display: block;\n }\n .rb-screenshot--interactive {\n /* Hide the OS cursor — we render a synthetic cursor on the overlay so there's exactly one pointer\n and it reads naturally for clicking on a web page (not the old crosshair). */\n cursor: none;\n outline: none;\n }\n .rb-screenshot--interactive:focus-visible {\n box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--mj-brand-primary) 35%, transparent);\n }\n /* Frame canvas + synthetic-cursor overlay share one box; the stack shrinks to the frame canvas so the\n absolutely-positioned overlay (inset:0, same object-fit) lines up pixel-for-pixel with it. */\n .rb-canvas-stack {\n position: relative;\n display: inline-flex;\n max-width: 100%;\n max-height: 100%;\n min-height: 0;\n }\n .rb-cursor-overlay {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n /* Transparent passthrough layer — no chrome of its own, and never steals pointer/wheel events from\n the frame canvas underneath (those listeners drive takeover). */\n border: none;\n box-shadow: none;\n background: transparent;\n pointer-events: none;\n }\n .rb-driving {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 2px 8px;\n border-radius: var(--mj-radius-full, 999px);\n font-size: 0.75rem;\n font-weight: 600;\n color: var(--mj-brand-primary);\n background: color-mix(in srgb, var(--mj-brand-primary) 12%, transparent);\n }\n .rb-placeholder {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .rb-hidden {\n display: none;\n }\n .rb-speaker {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 6px);\n background: var(--mj-bg-surface);\n color: var(--mj-brand-primary);\n cursor: pointer;\n font-size: 0.8125rem;\n transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;\n }\n .rb-speaker:hover {\n background: var(--mj-bg-surface-hover);\n }\n .rb-speaker:focus-visible {\n outline: none;\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 25%, transparent);\n }\n .rb-speaker--muted {\n color: var(--mj-text-muted);\n }\n .rb-url--link {\n color: var(--mj-brand-primary);\n text-decoration: none;\n }\n .rb-url--link:hover {\n text-decoration: underline;\n }\n .rb-viewport--review {\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n gap: 8px;\n padding: 8px;\n overflow: hidden;\n }\n .rb-review-stage {\n flex: 1 1 auto;\n min-height: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: auto;\n }\n .rb-iframe {\n width: 100%;\n height: 100%;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 6px);\n background: #ffffff;\n }\n .rb-open-btn {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 26px;\n height: 26px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 6px);\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n text-decoration: none;\n font-size: 0.75rem;\n }\n .rb-open-btn:hover {\n color: var(--mj-brand-primary);\n background: var(--mj-bg-surface-hover);\n }\n .rb-history {\n flex: 0 0 auto;\n border: 1px solid var(--mj-border-subtle);\n border-radius: var(--mj-radius-md, 6px);\n background: var(--mj-bg-surface);\n padding: 8px 12px;\n max-height: 180px;\n overflow: auto;\n }\n .rb-history__heading {\n font-size: 0.75rem;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n color: var(--mj-text-muted);\n cursor: pointer;\n user-select: none;\n }\n .rb-history[open] .rb-history__heading {\n margin-bottom: 8px;\n }\n .rb-history__list {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n .rb-history__item {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 6px 8px;\n border-radius: 6px;\n background: var(--mj-bg-surface-sunken);\n font-size: 0.8125rem;\n }\n .rb-history__action {\n font-size: 0.75rem;\n font-weight: 600;\n color: var(--mj-text-secondary);\n }\n .rb-history__url {\n color: var(--mj-brand-primary);\n font-family: var(--mj-font-mono, monospace);\n word-break: break-all;\n text-decoration: none;\n }\n .rb-history__url:hover {\n text-decoration: underline;\n }\n .rb-history__detail {\n color: var(--mj-text-secondary);\n font-size: 0.75rem;\n }\n .rb-empty-note {\n color: var(--mj-text-muted);\n font-size: 0.875rem;\n }\n `]\n})\nexport class RemoteBrowserSurfaceComponent implements OnInit, AfterViewInit, OnDestroy {\n /** Snapshot fetcher supplied by the channel plugin (closes over the session id + provider). */\n @Input() Fetch: RemoteBrowserSnapshotFetcher | null = null;\n\n /**\n * Selection fetcher for copy-out, supplied by the channel plugin (closes over the session id + provider).\n * On a local `copy` / Cmd+C over the live canvas the surface calls this to read the remote page's\n * selection, then writes it to the local clipboard. Best-effort: when unset or it resolves to `''`, the\n * copy is a no-op (the local clipboard is left untouched).\n */\n @Input() FetchSelection: RemoteBrowserSelectionFetcher | null = null;\n\n /**\n * Whether the surface is on screen, set by the channel plugin when the host reports it\n * (`OnSurfaceVisibilityChange`). Out of sight, the snapshot poll pauses: nobody sees it, and the\n * agent's frames come from the channel's own video bridge. Back in sight, the surface fetches a\n * snapshot at once and polls again. The pushed screencast is unaffected.\n */\n @Input()\n set Visible(value: boolean) {\n if (value === this._visible) {\n return;\n }\n this._visible = value;\n if (!value) {\n this.stopPolling();\n } else if (this.initialized) {\n this.resumePolling();\n }\n }\n get Visible(): boolean {\n return this._visible;\n }\n private _visible = true;\n\n /**\n * Whether the server is PUSHING live screencast frames for this session (the backend advertised the\n * `ScreenStreaming` capability and the start succeeded). When `true` the surface paints pushed frames\n * onto its `<canvas>` via {@link RenderFrame} and does NOT poll; when `false` it uses the snapshot\n * `<img>` poll fallback. Set by the channel plugin in `BindSurface` from the start-screencast result.\n *\n * The start-screencast result is async, so this may flip to `true` AFTER `ngOnInit` has already begun\n * polling — the setter tears the poll down in that case so the two render paths never run at once.\n */\n @Input()\n set Streaming(value: boolean) {\n if (value === this._streaming) {\n return;\n }\n this._streaming = value;\n if (value) {\n // Late flip after the poll-fallback already started: stop polling, switch to canvas frames.\n this.stopPolling();\n this.zone.run(() => this.cdr.markForCheck());\n }\n // Takeover only attaches on the canvas path — (de)attach as streaming flips.\n this.syncTakeoverListeners();\n }\n get Streaming(): boolean {\n return this._streaming;\n }\n private _streaming = false;\n\n /**\n * Whether HUMAN TAKEOVER is enabled — the user watching the live view can click/type into the page and\n * those events are relayed into the server browser (Collaborative control). Takeover only attaches to the\n * canvas render path (pushed screencast); the `<img>` poll fallback stays view-only. When enabled while\n * already streaming the setter attaches listeners; flipping it off (or streaming off) detaches them.\n */\n @Input()\n set Interactive(value: boolean) {\n if (value === this._interactive) {\n return;\n }\n this._interactive = value;\n this.syncTakeoverListeners();\n this.zone.run(() => this.cdr.markForCheck());\n }\n get Interactive(): boolean {\n return this._interactive;\n }\n private _interactive = false;\n\n /** Emits each human-takeover input (pointer move/click, key) the user performs on the live canvas. */\n @Output() HumanInput = new EventEmitter<RemoteBrowserHumanInputEvent>();\n\n /**\n * Emits the usable drawer viewport size (`{ Width, Height }` below the toolbar) when the first frame\n * arrives and whenever the user resizes or maximizes/restores the pane (debounced, keeping the latest size).\n */\n @Output() ViewportResize = new EventEmitter<RemoteBrowserViewportSize>();\n\n /**\n * Whether the live tab-audio stream is available — the channel sets this `true` when the server confirms\n * it is pushing audio. Drives whether the speaker toggle renders in the live-view bar.\n */\n @Input() AudioAvailable = false;\n\n /**\n * Whether tab audio is currently muted. Two-way: the channel sets the initial value (un-muted when audio\n * starts) and the toggle updates it; {@link AudioMutedChange} relays each user change to the channel,\n * which mutes/unmutes the player.\n */\n @Input() AudioMuted = false;\n\n /** Emits the new muted state each time the user toggles the speaker (two-way `AudioMuted`). */\n @Output() AudioMutedChange = new EventEmitter<boolean>();\n\n /** Toggles the speaker mute state and relays it to the channel (which mutes/unmutes the audio player). */\n public ToggleAudioMuted(): void {\n this.AudioMuted = !this.AudioMuted;\n this.AudioMutedChange.emit(this.AudioMuted);\n }\n\n /** True when takeover is both enabled AND on the canvas path — drives the cursor + \"driving\" pill. */\n public get CanTakeOver(): boolean {\n return this._interactive && this._streaming;\n }\n\n /**\n * True while the user is actively driving the remote browser with the keyboard — the takeover canvas\n * holds focus. The host overlay reads this to stand down its own global keyboard shortcuts (e.g.\n * T-to-type opening the local composer) so keystrokes go to the remote page, not the local input.\n */\n public get IsCapturingInput(): boolean {\n return this.surfaceFocused && this.CanTakeOver;\n }\n\n /** Read-only session review mode: disables live polling/takeover and renders saved snapshot/history. */\n @Input() public ReadOnly = false;\n /** Visited page history shown in read-only review mode. */\n @Input() public ReviewHistory: readonly RemoteBrowserHistoryEntry[] = [];\n /** The current screenshot as a `data:` URL, or `null` before the first snapshot arrives. */\n @Input() public ScreenshotDataUrl: string | null = null;\n /** The current page URL reported by the server, or `null` when none. */\n @Input() public CurrentUrl: string | null = null;\n /** Whether at least one pushed screencast frame has been painted (drives the canvas placeholder). */\n public HasFrame = false;\n\n private readonly sanitizer = inject(DomSanitizer);\n private cachedIframeKey: string | null = null;\n private cachedIframeValue: SafeResourceUrl | null = null;\n\n /** Returns `ScreenshotDataUrl` only when it is a safe inline raster image data URL. */\n public get SafeScreenshotUrl(): string | null {\n return IsSafeRasterImageDataUrl(this.ScreenshotDataUrl) ? this.ScreenshotDataUrl : null;\n }\n\n /**\n * Returns a sanitized `SafeResourceUrl` for the last visited `http(s)` page when no saved\n * screenshot is available in review mode, so past sessions still display the last page.\n */\n public get SafeIframeUrl(): SafeResourceUrl | null {\n const safe = this.SafeExternalUrl(this.CurrentUrl);\n if (!safe) {\n return null;\n }\n if (this.cachedIframeKey !== safe) {\n this.cachedIframeKey = safe;\n this.cachedIframeValue = this.sanitizer.bypassSecurityTrustResourceUrl(safe);\n }\n return this.cachedIframeValue;\n }\n\n /** Returns `url` only when it uses an explicit http/https origin. */\n public SafeExternalUrl(url: string | null | undefined): string | null {\n return IsAllowedExternalMediaUrl(url) ? url!.trim() : null;\n }\n\n /** The usable area below the toolbar whose dimensions drive remote viewport resizing. */\n @ViewChild('viewportEl') private viewportEl?: ElementRef<HTMLElement>;\n\n /** The canvas the pushed screencast frames are painted onto (present only while {@link Streaming}). */\n @ViewChild('frameCanvas') private frameCanvas?: ElementRef<HTMLCanvasElement>;\n\n /** The transparent overlay the synthetic cursor is drawn onto (present only while {@link CanTakeOver}). */\n @ViewChild('cursorCanvas') private cursorCanvas?: ElementRef<HTMLCanvasElement>;\n\n /** Whether at least one screenshot OR frame has been rendered (drives the \"Live\" indicator). */\n public get HasSnapshot(): boolean {\n return this.ScreenshotDataUrl !== null || this.HasFrame;\n }\n\n private readonly cdr = inject(ChangeDetectorRef);\n private readonly zone = inject(NgZone);\n /** Active poll timer; `null` when polling is stopped. */\n private pollTimer: ReturnType<typeof setInterval> | null = null;\n /** Guards against overlapping polls when a request runs longer than the interval. */\n private polling = false;\n /** Set on destroy so an in-flight poll's late resolution doesn't touch a torn-down view. */\n private destroyed = false;\n /** Set in `ngOnInit`: polling starts there, so a visibility change before it must not start it early. */\n private initialized = false;\n /** Reused decode target for pushed frames — avoids allocating an `Image` per frame. */\n private readonly frameImage = new Image();\n /** The most recent un-painted frame data URL, drained on the next animation frame (drop-old coalescing). */\n private pendingFrameDataUrl: string | null = null;\n /** True while a paint is scheduled, so rapid frames coalesce to one `requestAnimationFrame`. */\n private framePaintScheduled = false;\n\n /** Active ResizeObserver watching {@link viewportEl}; `null` when not attached. */\n private resizeObserver: ResizeObserver | null = null;\n /** Pending debounce timer for {@link ViewportResize} emissions during a divider drag / pane resize. */\n private resizeDebounceTimer: ReturnType<typeof setTimeout> | null = null;\n /** Most recent measured usable viewport size (`{ Width, Height }`). */\n private latestViewportSize: RemoteBrowserViewportSize | null = null;\n /** Last viewport size emitted through {@link ViewportResize}, used to deduplicate unchanged measurements. */\n private lastEmittedViewportSize: RemoteBrowserViewportSize | null = null;\n\n /** The canvas element takeover listeners are currently bound to, or `null` when detached. */\n private takeoverCanvas: HTMLCanvasElement | null = null;\n /** Timestamp (ms) of the last forwarded pointer-move, for throttling the high-frequency stream. */\n private lastPointerMoveAt = 0;\n /** Timestamp (ms) of the last forwarded scroll, for throttling the high-frequency wheel stream. */\n private lastScrollAt = 0;\n /** Horizontal wheel delta accumulated since the last forwarded scroll (coalesced across throttled events). */\n private pendingScrollDeltaX = 0;\n /** Vertical wheel delta accumulated since the last forwarded scroll (coalesced across throttled events). */\n private pendingScrollDeltaY = 0;\n\n /** Last canvas-relative mouse position in VIEWPORT pixel space, or `null` when the pointer is off-canvas. */\n private cursorViewportPoint: { x: number; y: number } | null = null;\n /** True while a synthetic-cursor repaint is queued, so rapid moves coalesce to one `requestAnimationFrame`. */\n private cursorPaintScheduled = false;\n\n /**\n * True while the user is mid-drag on the canvas (a `mousedown` not yet released) — drives forwarding\n * intermediate moves as a drag and emitting the closing `pointer-up`. Click-drag text selection relies on\n * this so the drag relays as down → moves → up rather than a single discrete click.\n */\n private dragging = false;\n\n /**\n * True when the most recent `mousedown`→`mouseup` actually MOVED (a real drag), so the synthetic `click`\n * the browser fires right after should be suppressed — the drag's down/move/up already conveyed the intent,\n * and a trailing click would collapse a just-made text selection.\n */\n private suppressNextClick = false;\n\n /** Viewport point of the active drag's mousedown, used to tell a real drag from a stationary click. */\n private dragStartPoint: { x: number; y: number } | null = null;\n\n /**\n * True while the takeover canvas currently HOLDS keyboard focus. The host overlay reads this (via\n * {@link IsCapturingInput}) to suppress its own global key shortcuts (e.g. T-to-type) so the user's\n * keystrokes land in the remote browser, not the local composer — fixing the \"greedy textbox\" focus theft.\n */\n private surfaceFocused = false;\n\n /** Bound handlers — stored so the exact same references can be removed on detach. */\n private readonly onCanvasMouseMove = (e: MouseEvent): void => this.handlePointerMove(e);\n private readonly onCanvasMouseDown = (e: MouseEvent): void => this.handlePointerDown(e);\n private readonly onCanvasMouseUp = (e: MouseEvent): void => this.handlePointerUp(e);\n private readonly onCanvasClick = (e: MouseEvent): void => this.handlePointerClick(e);\n private readonly onCanvasKeyDown = (e: KeyboardEvent): void => this.handleKeyDown(e);\n private readonly onCanvasPaste = (e: ClipboardEvent): void => this.handlePaste(e);\n private readonly onCanvasCopy = (e: ClipboardEvent): void => this.handleCopy(e);\n private readonly onCanvasMouseLeave = (): void => this.handleMouseLeave();\n private readonly onCanvasWheel = (e: WheelEvent): void => this.handleWheel(e);\n private readonly onCanvasFocus = (): void => { this.surfaceFocused = true; };\n private readonly onCanvasBlur = (): void => { this.surfaceFocused = false; };\n\n ngOnInit(): void {\n this.initialized = true;\n this.resumePolling();\n }\n\n ngAfterViewInit(): void {\n this.attachViewportResizeObserver();\n }\n\n ngOnDestroy(): void {\n this.destroyed = true;\n this.stopPolling();\n this.detachViewportResizeObserver();\n this.detachTakeoverListeners();\n }\n\n /**\n * Polls now and every {@link SNAPSHOT_POLL_MS} ms, unless the server pushes frames (the poll would be redundant\n * traffic) or the surface is out of sight.\n */\n private resumePolling(): void {\n if (this.ReadOnly || this.Streaming || !this._visible || this.destroyed) {\n return;\n }\n void this.pollOnce();\n this.startPolling();\n }\n\n /** Starts the interval poll OUTSIDE Angular's zone so it doesn't trigger CD on every tick. */\n private startPolling(): void {\n if (this.pollTimer !== null) {\n return;\n }\n this.zone.runOutsideAngular(() => {\n this.pollTimer = setInterval(() => void this.pollOnce(), SNAPSHOT_POLL_MS);\n });\n }\n\n /** Stops the interval poll (no further snapshot requests are issued). */\n private stopPolling(): void {\n if (this.pollTimer !== null) {\n clearInterval(this.pollTimer);\n this.pollTimer = null;\n }\n }\n\n /**\n * Fetches one snapshot and applies it to the view. Best-effort: the fetcher resolves to\n * `null` on failure (the prior frame stays on screen) so a single failed poll never breaks\n * the live view. Skips when a prior poll is still in flight, the fetcher isn't wired, or\n * after destroy.\n */\n private async pollOnce(): Promise<void> {\n if (this.polling || this.destroyed || !this.Fetch) {\n return;\n }\n this.polling = true;\n try {\n const snapshot = await this.Fetch();\n this.applySnapshot(snapshot);\n } catch {\n // Defensive — the fetcher is contractually non-throwing, but never let a poll break the view.\n } finally {\n this.polling = false;\n }\n }\n\n /** Applies a fetched snapshot to the view fields and triggers OnPush change detection. */\n private applySnapshot(snapshot: RemoteBrowserSnapshotView | null): void {\n if (this.destroyed) {\n return;\n }\n const hadSnapshot = this.HasSnapshot;\n const base64 = snapshot?.ScreenshotBase64 ?? null;\n const nextUrl = snapshot?.CurrentUrl ?? null;\n const nextDataUrl = base64 ? `data:image/png;base64,${base64}` : this.ScreenshotDataUrl;\n if (nextDataUrl === this.ScreenshotDataUrl && nextUrl === this.CurrentUrl) {\n return; // nothing changed — skip the CD pass\n }\n this.ScreenshotDataUrl = nextDataUrl;\n this.CurrentUrl = nextUrl;\n // Re-enter the zone for the OnPush update (the poll runs outside Angular).\n this.zone.run(() => this.cdr.markForCheck());\n if (!hadSnapshot && this.HasSnapshot) {\n this.notifyInitialViewportSize();\n }\n }\n\n /**\n * Paints one PUSHED screencast frame (base64 JPEG) onto the canvas. Called by the channel plugin for\n * each frame the server pushes while {@link Streaming}. Coalesces a burst of frames to one paint per\n * animation frame (the newest wins) so a fast stream never floods the main thread, and reuses a single\n * `Image` decode target to avoid per-frame allocation. No-op after destroy or when not in streaming mode.\n *\n * @param dataBase64 The frame image as raw base64 JPEG (no `data:` prefix).\n */\n public RenderFrame(dataBase64: string): void {\n if (this.destroyed || !this.Streaming || !dataBase64) {\n return;\n }\n this.pendingFrameDataUrl = `data:image/jpeg;base64,${dataBase64}`;\n if (this.framePaintScheduled) {\n return; // a paint is already queued — it will pick up this newest frame\n }\n this.framePaintScheduled = true;\n this.zone.runOutsideAngular(() => requestAnimationFrame(() => this.paintPendingFrame()));\n }\n\n /**\n * Updates the URL shown above the live view. In streaming (canvas) mode the snapshot poll is stopped, so\n * the channel pushes the current URL here after a navigation/action reports one — otherwise the bar would\n * stay stuck on \"No page loaded yet\" even though the page is live. No-op for an unchanged / empty value.\n *\n * @param url The current page URL, or null/empty to leave the bar unchanged.\n */\n public SetCurrentUrl(url: string | null | undefined): void {\n if (this.destroyed || !url || url === this.CurrentUrl) {\n return;\n }\n this.CurrentUrl = url;\n this.zone.run(() => this.cdr.markForCheck());\n }\n\n /** Drains the most recent pending frame onto the canvas (drop-old coalescing target). */\n private paintPendingFrame(): void {\n this.framePaintScheduled = false;\n const dataUrl = this.pendingFrameDataUrl;\n this.pendingFrameDataUrl = null;\n if (this.destroyed || !dataUrl) {\n return;\n }\n this.frameImage.onload = () => this.drawFrameImage();\n this.frameImage.src = dataUrl;\n }\n\n /** Draws the decoded frame image onto the canvas, sizing the canvas to the frame on the first paint. */\n private drawFrameImage(): void {\n const canvas = this.frameCanvas?.nativeElement;\n if (this.destroyed || !canvas) {\n return;\n }\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return;\n }\n const { naturalWidth: w, naturalHeight: h } = this.frameImage;\n if (w > 0 && h > 0 && (canvas.width !== w || canvas.height !== h)) {\n canvas.width = w;\n canvas.height = h;\n this.updateCanvasDisplaySize();\n if (this.cursorViewportPoint) {\n this.scheduleCursorPaint();\n } else {\n const overlay = this.cursorCanvas?.nativeElement;\n if (overlay && (overlay.width !== w || overlay.height !== h)) {\n overlay.width = w;\n overlay.height = h;\n }\n }\n }\n ctx.drawImage(this.frameImage, 0, 0);\n if (!this.HasFrame) {\n // First frame arrived — re-enter the zone to clear the placeholder + flip the \"Live\" indicator,\n // attach takeover listeners now that the canvas element exists in the DOM, and report the usable\n // drawer viewport size so the server resizes the remote page in place.\n this.zone.run(() => {\n this.HasFrame = true;\n this.cdr.markForCheck();\n });\n this.syncTakeoverListeners();\n this.updateCanvasDisplaySize();\n this.notifyInitialViewportSize();\n }\n }\n\n // ----- viewport measurement & resize observation ------------------------------------------\n\n /**\n * Attaches a `ResizeObserver` to `.rb-viewport` (the usable space below the toolbar) outside Angular's\n * zone. Sends the usable width and height when the first frame arrives and whenever the user drags the\n * divider or maximizes/restores the pane (debounced, keeping the latest size).\n */\n private attachViewportResizeObserver(): void {\n const el = this.viewportEl?.nativeElement;\n if (this.ReadOnly || !el || this.destroyed) {\n return;\n }\n const initial = this.measureViewport();\n if (initial) {\n this.latestViewportSize = initial;\n this.updateCanvasDisplaySize();\n if (this.HasSnapshot) {\n this.emitViewportResizeImmediate(initial);\n }\n }\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n this.zone.runOutsideAngular(() => {\n this.resizeObserver = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n if (this.destroyed) {\n return;\n }\n const latestEntry = entries.length > 0 ? entries[entries.length - 1] : undefined;\n const measured = this.measureViewport(latestEntry);\n if (!measured) {\n return;\n }\n this.latestViewportSize = measured;\n this.updateCanvasDisplaySize();\n if (this.HasSnapshot) {\n this.scheduleViewportResizeEmit();\n }\n });\n this.resizeObserver.observe(el);\n });\n }\n\n /** Disconnects the `ResizeObserver` and cancels any pending debounce timer. */\n private detachViewportResizeObserver(): void {\n if (this.resizeDebounceTimer !== null) {\n clearTimeout(this.resizeDebounceTimer);\n this.resizeDebounceTimer = null;\n }\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = null;\n }\n }\n\n /**\n * Measures the usable viewport container (`.rb-viewport`) in integer CSS pixels, preferring a\n * `ResizeObserverEntry`'s `contentRect` and falling back to `clientWidth`/`clientHeight` or\n * `getBoundingClientRect()`. Returns `null` when the element has zero or non-finite dimensions.\n */\n private measureViewport(entry?: ResizeObserverEntry): RemoteBrowserViewportSize | null {\n const contentWidth = entry?.contentRect?.width ?? 0;\n const contentHeight = entry?.contentRect?.height ?? 0;\n const el = this.viewportEl?.nativeElement;\n const rect = el?.getBoundingClientRect?.();\n const rawWidth = contentWidth > 0 ? contentWidth : (el && el.clientWidth > 0 ? el.clientWidth : (rect?.width ?? 0));\n const rawHeight = contentHeight > 0 ? contentHeight : (el && el.clientHeight > 0 ? el.clientHeight : (rect?.height ?? 0));\n const width = Math.floor(rawWidth);\n const height = Math.floor(rawHeight);\n if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {\n return null;\n }\n return { Width: width, Height: height };\n }\n\n /** Sends the current usable viewport size immediately when the first frame/snapshot arrives. */\n private notifyInitialViewportSize(): void {\n if (this.ReadOnly) {\n return;\n }\n const size = this.measureViewport() ?? this.latestViewportSize;\n if (!size) {\n return;\n }\n this.latestViewportSize = size;\n this.emitViewportResizeImmediate(size);\n }\n\n /** Debounces rapid `ResizeObserver` notifications, keeping {@link latestViewportSize}. */\n private scheduleViewportResizeEmit(): void {\n if (this.resizeDebounceTimer !== null) {\n clearTimeout(this.resizeDebounceTimer);\n }\n this.zone.runOutsideAngular(() => {\n this.resizeDebounceTimer = setTimeout(() => {\n this.resizeDebounceTimer = null;\n if (this.destroyed || !this.latestViewportSize) {\n return;\n }\n this.emitViewportResizeIfChanged(this.latestViewportSize);\n }, VIEWPORT_RESIZE_DEBOUNCE_MS);\n });\n }\n\n /** Clears any pending debounce timer and emits `size` immediately if it changed. */\n private emitViewportResizeImmediate(size: RemoteBrowserViewportSize): void {\n if (this.resizeDebounceTimer !== null) {\n clearTimeout(this.resizeDebounceTimer);\n this.resizeDebounceTimer = null;\n }\n this.emitViewportResizeIfChanged(size);\n }\n\n /** Emits `size` through {@link ViewportResize} when it differs from {@link lastEmittedViewportSize}. */\n private emitViewportResizeIfChanged(size: RemoteBrowserViewportSize): void {\n if (\n this.lastEmittedViewportSize &&\n this.lastEmittedViewportSize.Width === size.Width &&\n this.lastEmittedViewportSize.Height === size.Height\n ) {\n return;\n }\n this.lastEmittedViewportSize = { Width: size.Width, Height: size.Height };\n this.zone.run(() => this.ViewportResize.emit({ Width: size.Width, Height: size.Height }));\n }\n\n /**\n * Sizes the frame canvas's CSS box (and thus `.rb-canvas-stack` + `.rb-cursor-overlay`) to fit the\n * usable `.rb-viewport` area while preserving the frame's exact aspect ratio (`canvas.width / canvas.height`),\n * so the frame fills the pane edge-to-edge (including when maximized above `1280 × 800`) and clicks\n * always map accurately via {@link MapToViewportCoords}.\n */\n private updateCanvasDisplaySize(): void {\n const canvas = this.frameCanvas?.nativeElement;\n if (!canvas) {\n return;\n }\n const viewport = this.latestViewportSize ?? this.measureViewport();\n if (!viewport || canvas.width <= 0 || canvas.height <= 0) {\n canvas.style.width = '';\n canvas.style.height = '';\n return;\n }\n const fitted = ComputeFittedFrameSize(viewport.Width, viewport.Height, canvas.width, canvas.height);\n if (!fitted) {\n canvas.style.width = '';\n canvas.style.height = '';\n return;\n }\n canvas.style.width = `${fitted.Width}px`;\n canvas.style.height = `${fitted.Height}px`;\n }\n\n // ----- human takeover (Collaborative control) --------------------------------------------\n\n /**\n * Attaches or detaches the canvas takeover listeners so they're bound exactly when takeover is live —\n * {@link CanTakeOver} is true AND the canvas element exists. Idempotent: re-binds only when the target\n * canvas changed, detaches when the conditions no longer hold. Safe to call from any state-flip path\n * (the `Interactive`/`Streaming` setters, the first-frame paint, destroy).\n */\n private syncTakeoverListeners(): void {\n const canvas = this.CanTakeOver && !this.destroyed ? (this.frameCanvas?.nativeElement ?? null) : null;\n if (canvas === this.takeoverCanvas) {\n return; // already in the desired state\n }\n this.detachTakeoverListeners();\n if (canvas) {\n this.attachTakeoverListeners(canvas);\n }\n }\n\n /** Binds the pointer/keyboard/wheel listeners to the canvas OUTSIDE the zone (mousemove/wheel are high-frequency). */\n private attachTakeoverListeners(canvas: HTMLCanvasElement): void {\n canvas.tabIndex = 0; // focusable so it can receive keydown\n // Marks this canvas as a keyboard-capturing surface so the host overlay's global shortcuts (e.g.\n // T-to-type) stand down while it holds focus — see the overlay's isKeyboardCapturingSurfaceFocused().\n canvas.setAttribute('data-mj-capture-keys', '');\n this.zone.runOutsideAngular(() => {\n canvas.addEventListener('mousemove', this.onCanvasMouseMove);\n canvas.addEventListener('mousedown', this.onCanvasMouseDown);\n canvas.addEventListener('mouseup', this.onCanvasMouseUp);\n canvas.addEventListener('click', this.onCanvasClick);\n canvas.addEventListener('keydown', this.onCanvasKeyDown);\n // Paste-in / copy-out: the focused canvas receives the local clipboard `paste` / `copy` events; we\n // relay paste text into the remote page and write the remote selection to the local clipboard.\n canvas.addEventListener('paste', this.onCanvasPaste);\n canvas.addEventListener('copy', this.onCanvasCopy);\n canvas.addEventListener('mouseleave', this.onCanvasMouseLeave);\n canvas.addEventListener('focus', this.onCanvasFocus);\n canvas.addEventListener('blur', this.onCanvasBlur);\n // `passive: false` so preventDefault stops the host page from scrolling while the user drives the page.\n canvas.addEventListener('wheel', this.onCanvasWheel, { passive: false });\n });\n this.takeoverCanvas = canvas;\n }\n\n /** Removes the listeners from the currently-bound canvas (no-op when none are bound) and clears the cursor. */\n private detachTakeoverListeners(): void {\n const canvas = this.takeoverCanvas;\n if (!canvas) {\n return;\n }\n canvas.removeEventListener('mousemove', this.onCanvasMouseMove);\n canvas.removeEventListener('mousedown', this.onCanvasMouseDown);\n canvas.removeEventListener('mouseup', this.onCanvasMouseUp);\n canvas.removeEventListener('click', this.onCanvasClick);\n canvas.removeEventListener('keydown', this.onCanvasKeyDown);\n canvas.removeEventListener('paste', this.onCanvasPaste);\n canvas.removeEventListener('copy', this.onCanvasCopy);\n canvas.removeEventListener('mouseleave', this.onCanvasMouseLeave);\n canvas.removeEventListener('focus', this.onCanvasFocus);\n canvas.removeEventListener('blur', this.onCanvasBlur);\n canvas.removeEventListener('wheel', this.onCanvasWheel);\n canvas.removeAttribute('data-mj-capture-keys');\n this.takeoverCanvas = null;\n this.cursorViewportPoint = null;\n this.dragging = false;\n this.suppressNextClick = false;\n this.dragStartPoint = null;\n this.surfaceFocused = false;\n this.clearSyntheticCursor();\n }\n\n /**\n * Pointer-move → tracks the cursor for the synthetic-cursor overlay (every move, immediate, no\n * round-trip) AND emits a throttled viewport-mapped move to the server. Runs outside the zone (no CD\n * per move).\n */\n private handlePointerMove(event: MouseEvent): void {\n const point = this.toViewportCoords(event);\n if (point) {\n // Always update the local cursor for instant feedback — independent of the server-relay throttle.\n this.cursorViewportPoint = point;\n this.scheduleCursorPaint();\n }\n const now = Date.now();\n if (now - this.lastPointerMoveAt < POINTER_MOVE_THROTTLE_MS) {\n return;\n }\n this.lastPointerMoveAt = now;\n if (point) {\n this.emitInput({ kind: 'pointer-move', x: point.x, y: point.y });\n }\n }\n\n /** Mouse leaves the canvas → hide the synthetic cursor (nothing to relay). */\n private handleMouseLeave(): void {\n this.cursorViewportPoint = null;\n this.scheduleCursorPaint();\n }\n\n /**\n * Wheel/trackpad/Magic-Mouse scroll over the canvas → forwards a viewport-mapped scroll to the server.\n * Calls `preventDefault` so the host page doesn't scroll while the user drives the live page. Throttled\n * to {@link SCROLL_THROTTLE_MS}, coalescing the skipped deltas so no scroll distance is lost.\n */\n private handleWheel(event: WheelEvent): void {\n event.preventDefault();\n this.pendingScrollDeltaX += event.deltaX;\n this.pendingScrollDeltaY += event.deltaY;\n const point = this.toViewportCoords(event);\n if (point) {\n this.cursorViewportPoint = point;\n this.scheduleCursorPaint();\n }\n const now = Date.now();\n if (now - this.lastScrollAt < SCROLL_THROTTLE_MS) {\n return; // accumulate into pendingScrollDelta* until the throttle window opens\n }\n this.lastScrollAt = now;\n const target = point ?? this.cursorViewportPoint;\n if (target && (this.pendingScrollDeltaX !== 0 || this.pendingScrollDeltaY !== 0)) {\n this.emitInput({ kind: 'scroll', x: target.x, y: target.y, deltaX: this.pendingScrollDeltaX, deltaY: this.pendingScrollDeltaY });\n this.pendingScrollDeltaX = 0;\n this.pendingScrollDeltaY = 0;\n }\n }\n\n /**\n * Mouse-down on the canvas → focuses the canvas (so subsequent keys are captured) and BEGINS a drag:\n * emits a `pointer-down` and arms drag mode so the following moves relay as drag motion and the matching\n * `pointer-up` closes it. This is what makes click-drag text selection work (rather than a discrete click).\n */\n private handlePointerDown(event: MouseEvent): void {\n this.takeoverCanvas?.focus();\n const point = this.toViewportCoords(event);\n if (!point) {\n return;\n }\n this.dragging = true;\n this.dragStartPoint = point;\n this.suppressNextClick = false;\n this.cursorViewportPoint = point;\n this.scheduleCursorPaint();\n this.emitInput({ kind: 'pointer-down', x: point.x, y: point.y, button: this.mapButton(event.button), modifiers: this.collectModifiers(event) });\n }\n\n /**\n * Mouse-up on the canvas → closes a drag with a `pointer-up` at the release point, disarming drag mode.\n * If the pointer actually moved between down and up, marks the following synthetic `click` to be suppressed\n * (so the drag selection isn't immediately collapsed by a trailing click).\n */\n private handlePointerUp(event: MouseEvent): void {\n if (!this.dragging) {\n return;\n }\n this.dragging = false;\n const point = this.toViewportCoords(event);\n if (point) {\n const start = this.dragStartPoint;\n this.suppressNextClick = !!start && (start.x !== point.x || start.y !== point.y);\n this.emitInput({ kind: 'pointer-up', x: point.x, y: point.y, button: this.mapButton(event.button), modifiers: this.collectModifiers(event) });\n }\n this.dragStartPoint = null;\n }\n\n /**\n * Click → emits a viewport-mapped click WITH any held modifiers (e.g. Shift-click text selection). The\n * server browser receives the press/release of a drag via {@link handlePointerDown}/{@link handlePointerUp};\n * a plain click (down+up with no motion) still fires this `click` event, so a simple click relays as one\n * click action — but we skip emitting it when it terminates a real drag (where down/up already covered it).\n */\n private handlePointerClick(event: MouseEvent): void {\n this.takeoverCanvas?.focus();\n if (this.suppressNextClick) {\n // This click terminates a real drag (selection) — the down/move/up already conveyed it.\n this.suppressNextClick = false;\n return;\n }\n const point = this.toViewportCoords(event);\n if (point) {\n this.emitInput({ kind: 'pointer-click', x: point.x, y: point.y, button: this.mapButton(event.button), modifiers: this.collectModifiers(event) });\n }\n }\n\n /**\n * Keydown → forwards printable keys, a curated set of control keys ({@link FORWARDED_CONTROL_KEYS}), AND\n * any key combined with a Ctrl/Cmd/Alt modifier (so combos like Ctrl/Cmd+A select-all, Cmd+C/Cmd+V relay).\n * Calls `preventDefault` + `stopPropagation` ONLY on forwarded keys, so (a) the host app keeps its own\n * shortcuts on un-forwarded keys and (b) forwarded keys never bubble to the host overlay's global shortcuts\n * (the T-to-type focus-steal). Lone modifier keys are never forwarded — they ride as `modifiers` on the\n * next key/click.\n */\n private handleKeyDown(event: KeyboardEvent): void {\n const key = event.key;\n if (MODIFIER_KEYS.has(key)) {\n return; // a modifier on its own is not a keypress — it rides on the next key/click\n }\n const isPrintable = key.length === 1;\n const hasComboModifier = event.ctrlKey || event.metaKey || event.altKey;\n // Cmd/Ctrl+C and Cmd/Ctrl+V are handled by the dedicated `copy` / `paste` listeners (which read/write the\n // LOCAL clipboard) — don't ALSO relay them as a keypress, or paste would double-fire and copy would send a\n // useless Ctrl+C to the remote page. The browser fires the matching clipboard event for these chords.\n const isClipboardChord = (event.ctrlKey || event.metaKey) && (key === 'c' || key === 'v' || key === 'C' || key === 'V');\n const isForwardable = !isClipboardChord && (isPrintable || FORWARDED_CONTROL_KEYS.has(key) || hasComboModifier);\n if (!isForwardable) {\n return; // leave non-forwarded keys to the host app (and clipboard chords to copy/paste handlers)\n }\n event.preventDefault();\n // Stop the keystroke from reaching document-level handlers (e.g. the overlay's T-to-type) so the user's\n // typing lands in the remote browser, not the local composer.\n event.stopPropagation();\n this.emitInput({ kind: 'key', key, modifiers: this.collectModifiers(event) });\n }\n\n /**\n * Paste-in: a local `paste` (Cmd/Ctrl+V or context-menu paste) over the canvas → reads the LOCAL clipboard\n * text and relays it as a `'text'` human input, which the server inserts into the remote page's focused\n * element (the VNC/remote-desktop paste model — no remote-clipboard sync). `preventDefault` keeps the host\n * app from also acting on the paste; empty/non-text clipboards are a no-op.\n */\n private handlePaste(event: ClipboardEvent): void {\n event.preventDefault();\n event.stopPropagation();\n const text = event.clipboardData?.getData('text') ?? '';\n if (text.length === 0) {\n return; // nothing (or no text) on the clipboard — paste nothing\n }\n this.emitInput({ kind: 'text', text });\n }\n\n /**\n * Copy-out: a local `copy` (Cmd/Ctrl+C or context-menu copy) over the canvas → reads the REMOTE page's\n * current selection via {@link FetchSelection} and writes it to the LOCAL clipboard (the mirror of paste-in).\n * `preventDefault` stops the host app from copying its own empty selection. Best-effort throughout: when the\n * fetcher is unwired, resolves to `''`, or `navigator.clipboard` is unavailable / denies permission, the copy\n * is silently a no-op — it never throws and never breaks the live view.\n */\n private handleCopy(event: ClipboardEvent): void {\n event.preventDefault();\n event.stopPropagation();\n const fetchSelection = this.FetchSelection;\n if (!fetchSelection) {\n return;\n }\n void (async (): Promise<void> => {\n try {\n const text = await fetchSelection();\n if (text.length > 0 && navigator.clipboard?.writeText) {\n await navigator.clipboard.writeText(text);\n }\n } catch {\n // Best-effort: a denied clipboard permission or a failed selection read leaves the local clipboard\n // untouched rather than surfacing an error during takeover.\n }\n })();\n }\n\n /**\n * Collects the modifier keys currently held during a DOM mouse/keyboard event into the relayed\n * {@link RemoteBrowserModifier} list (empty when none are held).\n *\n * @param event The DOM event whose modifier flags to read.\n * @returns The held modifiers, in a stable order.\n */\n private collectModifiers(event: MouseEvent | KeyboardEvent): RemoteBrowserModifier[] {\n const modifiers: RemoteBrowserModifier[] = [];\n if (event.shiftKey) { modifiers.push('Shift'); }\n if (event.ctrlKey) { modifiers.push('Control'); }\n if (event.altKey) { modifiers.push('Alt'); }\n if (event.metaKey) { modifiers.push('Meta'); }\n return modifiers;\n }\n\n /** Re-enters the zone to emit one human input (so subscribers see it inside Angular). */\n private emitInput(input: RemoteBrowserHumanInputEvent): void {\n this.zone.run(() => this.HumanInput.emit(input));\n }\n\n /**\n * Maps a DOM pointer event on the live canvas to VIEWPORT coordinates via {@link MapToViewportCoords}\n * (the pure, unit-tested mapping). Returns `null` when no canvas is bound or mapping isn't possible yet.\n *\n * @param event The pointer event on the canvas.\n * @returns The integer viewport coordinates, or `null` when mapping isn't possible yet.\n */\n private toViewportCoords(event: MouseEvent): { x: number; y: number } | null {\n const canvas = this.takeoverCanvas;\n if (!canvas) {\n return null;\n }\n return MapToViewportCoords(event.clientX, event.clientY, canvas.getBoundingClientRect(), canvas.width, canvas.height);\n }\n\n // ----- synthetic cursor (local feedback — CDP frames don't include the OS cursor) -----------\n\n /**\n * Schedules a synthetic-cursor repaint on the next animation frame, coalescing a burst of moves to one\n * paint (the newest position wins). Runs outside the zone — drawing the cursor never triggers Angular CD.\n */\n private scheduleCursorPaint(): void {\n if (this.cursorPaintScheduled) {\n return;\n }\n this.cursorPaintScheduled = true;\n this.zone.runOutsideAngular(() => requestAnimationFrame(() => this.paintSyntheticCursor()));\n }\n\n /**\n * Draws (or clears) the synthetic cursor on the overlay canvas at {@link cursorViewportPoint}. The overlay\n * shares the frame canvas's internal resolution (sized here to match), so a point drawn at viewport coords\n * aligns exactly with the page underneath. A small brand-tinted ring with a center dot reads as a pointer\n * without obscuring what it's over. No-op after destroy or when the overlay isn't mounted.\n */\n private paintSyntheticCursor(): void {\n this.cursorPaintScheduled = false;\n const overlay = this.cursorCanvas?.nativeElement;\n const frame = this.frameCanvas?.nativeElement;\n if (this.destroyed || !overlay || !frame) {\n return;\n }\n // Keep the overlay's internal resolution locked to the frame canvas so coordinate spaces match.\n if (overlay.width !== frame.width || overlay.height !== frame.height) {\n overlay.width = frame.width;\n overlay.height = frame.height;\n }\n const ctx = overlay.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.clearRect(0, 0, overlay.width, overlay.height);\n const point = this.cursorViewportPoint;\n if (!point) {\n return; // pointer left the canvas — leave the overlay cleared\n }\n const ring = this.resolveCssColor('--mj-brand-primary', '#264FAF');\n ctx.beginPath();\n ctx.arc(point.x, point.y, SYNTHETIC_CURSOR_RADIUS, 0, Math.PI * 2);\n ctx.lineWidth = 2;\n ctx.strokeStyle = ring;\n ctx.stroke();\n ctx.beginPath();\n ctx.arc(point.x, point.y, 1.5, 0, Math.PI * 2);\n ctx.fillStyle = ring;\n ctx.fill();\n }\n\n /** Clears the synthetic-cursor overlay (e.g. on detach). No-op when the overlay isn't mounted. */\n private clearSyntheticCursor(): void {\n const overlay = this.cursorCanvas?.nativeElement;\n const ctx = overlay?.getContext('2d');\n if (overlay && ctx) {\n ctx.clearRect(0, 0, overlay.width, overlay.height);\n }\n }\n\n /**\n * Resolves a CSS custom property (design token) to its computed color value off the host element, so the\n * canvas-drawn cursor honors theming. Falls back to the supplied default when the token is unset or the\n * host isn't measurable.\n *\n * @param token The CSS custom property name (e.g. `'--mj-brand-primary'`).\n * @param fallback The color to use when the token resolves empty.\n * @returns The resolved color string.\n */\n private resolveCssColor(token: string, fallback: string): string {\n const host = this.frameCanvas?.nativeElement;\n if (!host) {\n return fallback;\n }\n const value = getComputedStyle(host).getPropertyValue(token).trim();\n return value.length > 0 ? value : fallback;\n }\n\n /** Maps a DOM `MouseEvent.button` (0/1/2) to the relayed button union, defaulting to `'left'`. */\n private mapButton(button: number): 'left' | 'middle' | 'right' {\n if (button === 1) {\n return 'middle';\n }\n if (button === 2) {\n return 'right';\n }\n return 'left';\n }\n}\n"]}
@@ -1,27 +1,68 @@
1
+ import { OnDestroy, OnInit } from '@angular/core';
1
2
  import { DataSnapshot } from '@memberjunction/core';
2
- import { BaseArtifactViewerPluginComponent } from '@memberjunction/ng-artifacts';
3
+ import { ArtifactNavigationAnchor, BaseArtifactViewerPluginComponent } from '@memberjunction/ng-artifacts';
3
4
  import { WhiteboardState } from '@memberjunction/ng-whiteboard';
4
5
  import * as i0 from "@angular/core";
5
6
  /**
6
- * ARTIFACT VIEWER PLUGIN for saved whiteboards — renders the session-channel board
7
- * artifact (a {@link WhiteboardState.ToJSON} payload) as a read-only snapshot with the
8
- * same export affordances the live board offers (Download HTML / Download SVG / Print).
7
+ * ARTIFACT VIEWER PLUGIN for saved and inline OLE whiteboards (§ 3.4.1 / D12).
8
+ *
9
+ * Supports two modes controlled by `[readonly]`:
10
+ * 1. **Read-Only Mode (`[readonly]="true"`, default)**: Renders `<mj-whiteboard-snapshot>`
11
+ * with export controls (Download HTML / Download SVG / Print).
12
+ * 2. **Inline OLE Canvas Mode (`[readonly]="false"`)**: Renders the full interactive
13
+ * `<mj-realtime-whiteboard-host [State]="EditableBoardState" [ShowFocusToggle]="false">`
14
+ * canvas (pen, sticky notes, shapes, connectors, text, undo/redo, zoom/pan, pages) and
15
+ * emits `ContentCommitted` with `state.ToJSON()` when the user commits edits.
9
16
  *
10
17
  * Resolved dynamically by the artifact plugin host via the MJ ClassFactory (keyed by the
11
18
  * artifact type's DriverClass), which instantiates the class ONCE with a bare `new` to
12
19
  * discover the component type — so this class must stay constructible outside an Angular
13
20
  * injection context (no `inject()` field initializers, no constructor DI).
14
21
  */
15
- export declare class WhiteboardArtifactViewerComponent extends BaseArtifactViewerPluginComponent {
22
+ export declare class WhiteboardArtifactViewerComponent extends BaseArtifactViewerPluginComponent implements OnInit, OnDestroy {
16
23
  /** Memoized parse — keyed by the raw content string so version switches re-parse. */
17
24
  private parsedForJson;
18
25
  private parsedState;
26
+ private editableState;
27
+ private stateChangeSub;
28
+ private selectionChangeSub;
29
+ private hasUncommittedChanges;
30
+ private suppressStateChangeTracking;
31
+ private suppressSelectionEmit;
32
+ ngOnInit(): void;
33
+ /**
34
+ * Selects the target element when host {@link NavigationAnchor} provides `ElementID` (`NW-6`).
35
+ */
36
+ protected onNavigationAnchorChanged(anchor: ArtifactNavigationAnchor): void;
37
+ /** Whether the inline editable board has unsaved changes waiting to be committed. */
38
+ get IsDirty(): boolean;
39
+ /** Declares that WhiteboardArtifactViewerComponent supports inline OLE canvas editing when `[readonly]="false"`. */
40
+ get SupportsInlineEdit(): boolean;
41
+ CaptureRenderedThumbnail(): Promise<string | null>;
19
42
  /** Raw board payload fed to the snapshot component (setter-driven re-parse there). */
20
43
  get ContentJson(): string;
21
44
  /** Rehydrated board engine for export/snapshot duty (null when content is malformed). */
22
45
  get BoardState(): WhiteboardState | null;
46
+ /**
47
+ * Always-non-null {@link WhiteboardState} used when `[readonly]="false"` so even a brand-new
48
+ * inline Whiteboard can be drawn on immediately.
49
+ */
50
+ get EditableBoardState(): WhiteboardState;
23
51
  get HasBoard(): boolean;
24
52
  get hasDisplayContent(): boolean;
53
+ ngOnDestroy(): void;
54
+ /**
55
+ * Emits the current serialized `WhiteboardState.ToJSON()` payload on `ContentCommitted`
56
+ * so the host (OLE block host or artifact viewer panel) persists a new `MJ: Artifact Versions` record.
57
+ * Keeps `parsedForJson` synchronized with the committed JSON so the host's updated version input
58
+ * does not recreate `editableState` mid-session.
59
+ */
60
+ CommitCurrentState(): void;
61
+ /**
62
+ * Emits the current serialized `WhiteboardState.ToJSON()` payload on `ContentCommitted`
63
+ * so the host (OLE block host or artifact viewer panel) persists a new `MJ: Artifact Versions` record.
64
+ */
65
+ OnCommitInlineChanges(): void;
25
66
  GetCurrentStateSnapshot(): DataSnapshot | null;
26
67
  /** Download the board as one self-contained HTML document. */
27
68
  OnDownloadHtml(): void;
@@ -33,6 +74,8 @@ export declare class WhiteboardArtifactViewerComponent extends BaseArtifactViewe
33
74
  * the popup is blocked this is a logged no-op — nothing breaks, the user can retry.
34
75
  */
35
76
  OnPrint(): void;
77
+ private syncEditableState;
78
+ private teardownStateSub;
36
79
  private buildExportHtml;
37
80
  private downloadBlob;
38
81
  private static exportDateStamp;
@@ -1 +1 @@
1
- {"version":3,"file":"whiteboard-artifact-viewer.component.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAEwB,eAAe,EAC7C,MAAM,+BAA+B,CAAC;;AAEvC;;;;;;;;;GASG;AACH,qBAyEa,iCAAkC,SAAQ,iCAAiC;IACtF,qFAAqF;IACrF,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,WAAW,CAAgC;IAEnD,sFAAsF;IACtF,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,yFAAyF;IACzF,IAAW,UAAU,IAAI,eAAe,GAAG,IAAI,CAO9C;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,IAAoB,iBAAiB,IAAI,OAAO,CAE/C;IAEe,uBAAuB,IAAI,YAAY,GAAG,IAAI;IAe9D,8DAA8D;IACvD,cAAc,IAAI,IAAI;IAQ7B,uDAAuD;IAChD,aAAa,IAAI,IAAI;IAQ5B;;;;OAIG;IACI,OAAO,IAAI,IAAI;IAiBtB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,MAAM,CAAC,eAAe;yCApGnB,iCAAiC;2CAAjC,iCAAiC;CAuG7C;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
1
+ {"version":3,"file":"whiteboard-artifact-viewer.component.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.ts"],"names":[],"mappings":"AAAA,OAA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