@memberjunction/ng-conversations 6.2.2 → 6.3.0-edge.1

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 (252) hide show
  1. package/README.md +49 -24
  2. package/dist/assets/edge-ai.worker.js +32515 -0
  3. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts +39 -6
  4. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts.map +1 -1
  5. package/dist/lib/components/artifact/artifact-share-modal.component.js +620 -74
  6. package/dist/lib/components/artifact/artifact-share-modal.component.js.map +1 -1
  7. package/dist/lib/components/collection/artifact-create-modal.component.js +4 -4
  8. package/dist/lib/components/collection/artifact-create-modal.component.js.map +1 -1
  9. package/dist/lib/components/collection/collection-form-modal.component.js +3 -3
  10. package/dist/lib/components/collection/collection-form-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 +109 -107
  21. package/dist/lib/components/collection/collections-full-view.component.js.map +1 -1
  22. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +76 -11
  23. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
  24. package/dist/lib/components/conversation/conversation-chat-area.component.js +236 -50
  25. package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
  26. package/dist/lib/components/conversation/conversation-list.component.d.ts +49 -1
  27. package/dist/lib/components/conversation/conversation-list.component.d.ts.map +1 -1
  28. package/dist/lib/components/conversation/conversation-list.component.js +151 -41
  29. package/dist/lib/components/conversation/conversation-list.component.js.map +1 -1
  30. package/dist/lib/components/conversation/conversation-remote-browser-controller.d.ts +11 -3
  31. package/dist/lib/components/conversation/conversation-remote-browser-controller.d.ts.map +1 -1
  32. package/dist/lib/components/conversation/conversation-remote-browser-controller.js +40 -4
  33. package/dist/lib/components/conversation/conversation-remote-browser-controller.js.map +1 -1
  34. package/dist/lib/components/export/export-modal.component.d.ts +7 -2
  35. package/dist/lib/components/export/export-modal.component.d.ts.map +1 -1
  36. package/dist/lib/components/export/export-modal.component.js +13 -2
  37. package/dist/lib/components/export/export-modal.component.js.map +1 -1
  38. package/dist/lib/components/library/library-create-dialog.component.d.ts +136 -0
  39. package/dist/lib/components/library/library-create-dialog.component.d.ts.map +1 -0
  40. package/dist/lib/components/library/library-create-dialog.component.js +1620 -0
  41. package/dist/lib/components/library/library-create-dialog.component.js.map +1 -0
  42. package/dist/lib/components/library/library-full-view.component.d.ts +10 -4
  43. package/dist/lib/components/library/library-full-view.component.d.ts.map +1 -1
  44. package/dist/lib/components/library/library-full-view.component.js +216 -40
  45. package/dist/lib/components/library/library-full-view.component.js.map +1 -1
  46. package/dist/lib/components/library/library-remote-drive-pane.component.d.ts +97 -0
  47. package/dist/lib/components/library/library-remote-drive-pane.component.d.ts.map +1 -0
  48. package/dist/lib/components/library/library-remote-drive-pane.component.js +1229 -0
  49. package/dist/lib/components/library/library-remote-drive-pane.component.js.map +1 -0
  50. package/dist/lib/components/library/library-workspace.component.d.ts +265 -0
  51. package/dist/lib/components/library/library-workspace.component.d.ts.map +1 -0
  52. package/dist/lib/components/library/library-workspace.component.js +4420 -0
  53. package/dist/lib/components/library/library-workspace.component.js.map +1 -0
  54. package/dist/lib/components/library/library.models.d.ts +162 -0
  55. package/dist/lib/components/library/library.models.d.ts.map +1 -0
  56. package/dist/lib/components/library/library.models.js +2 -0
  57. package/dist/lib/components/library/library.models.js.map +1 -0
  58. package/dist/lib/components/message/conversation-message-rating.component.d.ts +5 -0
  59. package/dist/lib/components/message/conversation-message-rating.component.d.ts.map +1 -1
  60. package/dist/lib/components/message/conversation-message-rating.component.js +72 -16
  61. package/dist/lib/components/message/conversation-message-rating.component.js.map +1 -1
  62. package/dist/lib/components/message/message-input.component.d.ts +26 -14
  63. package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
  64. package/dist/lib/components/message/message-input.component.js +91 -56
  65. package/dist/lib/components/message/message-input.component.js.map +1 -1
  66. package/dist/lib/components/message/message-item.component.d.ts +35 -1
  67. package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
  68. package/dist/lib/components/message/message-item.component.js +583 -392
  69. package/dist/lib/components/message/message-item.component.js.map +1 -1
  70. package/dist/lib/components/message/message-list.component.d.ts.map +1 -1
  71. package/dist/lib/components/message/message-list.component.js +2 -0
  72. package/dist/lib/components/message/message-list.component.js.map +1 -1
  73. package/dist/lib/components/navigation/conversation-navigation.component.js +9 -9
  74. package/dist/lib/components/navigation/conversation-navigation.component.js.map +1 -1
  75. package/dist/lib/components/overlay/chat-overlay.component.d.ts +94 -6
  76. package/dist/lib/components/overlay/chat-overlay.component.d.ts.map +1 -1
  77. package/dist/lib/components/overlay/chat-overlay.component.js +249 -59
  78. package/dist/lib/components/overlay/chat-overlay.component.js.map +1 -1
  79. package/dist/lib/components/project/project-form-modal.component.d.ts +6 -0
  80. package/dist/lib/components/project/project-form-modal.component.d.ts.map +1 -1
  81. package/dist/lib/components/project/project-form-modal.component.js +81 -61
  82. package/dist/lib/components/project/project-form-modal.component.js.map +1 -1
  83. package/dist/lib/components/project/project-selector.component.d.ts +5 -0
  84. package/dist/lib/components/project/project-selector.component.d.ts.map +1 -1
  85. package/dist/lib/components/project/project-selector.component.js +11 -4
  86. package/dist/lib/components/project/project-selector.component.js.map +1 -1
  87. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts +55 -0
  88. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts.map +1 -0
  89. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js +944 -0
  90. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js.map +1 -0
  91. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts +66 -0
  92. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts.map +1 -0
  93. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js +253 -0
  94. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js.map +1 -0
  95. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts +80 -0
  96. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts.map +1 -0
  97. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js +49 -0
  98. package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js.map +1 -0
  99. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts +54 -0
  100. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts.map +1 -0
  101. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js +386 -0
  102. package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js.map +1 -0
  103. package/dist/lib/components/realtime/channels/client-context-channel.d.ts +20 -4
  104. package/dist/lib/components/realtime/channels/client-context-channel.d.ts.map +1 -1
  105. package/dist/lib/components/realtime/channels/client-context-channel.js +62 -8
  106. package/dist/lib/components/realtime/channels/client-context-channel.js.map +1 -1
  107. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts +1 -0
  108. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map +1 -1
  109. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js +15 -2
  110. package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js.map +1 -1
  111. package/dist/lib/components/realtime/realtime-agent-banner.component.js +2 -2
  112. package/dist/lib/components/realtime/realtime-agent-banner.component.js.map +1 -1
  113. package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts.map +1 -1
  114. package/dist/lib/components/realtime/realtime-agent-picker.component.js +3 -3
  115. package/dist/lib/components/realtime/realtime-agent-picker.component.js.map +1 -1
  116. package/dist/lib/components/realtime/realtime-composer.component.js +5 -3
  117. package/dist/lib/components/realtime/realtime-composer.component.js.map +1 -1
  118. package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts +81 -32
  119. package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts.map +1 -1
  120. package/dist/lib/components/realtime/realtime-session-overlay.component.js +506 -185
  121. package/dist/lib/components/realtime/realtime-session-overlay.component.js.map +1 -1
  122. package/dist/lib/components/realtime/realtime-session-thread.component.d.ts.map +1 -1
  123. package/dist/lib/components/realtime/realtime-session-thread.component.js +89 -4
  124. package/dist/lib/components/realtime/realtime-session-thread.component.js.map +1 -1
  125. package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts.map +1 -1
  126. package/dist/lib/components/realtime/realtime-surface-stage.model.js +2 -1
  127. package/dist/lib/components/realtime/realtime-surface-stage.model.js.map +1 -1
  128. package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts +4 -4
  129. package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts.map +1 -1
  130. package/dist/lib/components/realtime/realtime-surface-tab-style.js +5 -5
  131. package/dist/lib/components/realtime/realtime-surface-tab-style.js.map +1 -1
  132. package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts +7 -9
  133. package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts.map +1 -1
  134. package/dist/lib/components/realtime/realtime-surface-tabs.model.js +12 -13
  135. package/dist/lib/components/realtime/realtime-surface-tabs.model.js.map +1 -1
  136. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts +27 -0
  137. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts.map +1 -1
  138. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js +141 -2
  139. package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js.map +1 -1
  140. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts +101 -3
  141. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts.map +1 -1
  142. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js +503 -55
  143. package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js.map +1 -1
  144. package/dist/lib/components/realtime/remote-browser/remote-browser-tools.d.ts.map +1 -1
  145. package/dist/lib/components/realtime/remote-browser/remote-browser-tools.js +2 -2
  146. package/dist/lib/components/realtime/remote-browser/remote-browser-tools.js.map +1 -1
  147. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts +48 -5
  148. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts.map +1 -1
  149. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js +249 -53
  150. package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js.map +1 -1
  151. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts.map +1 -1
  152. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js +1 -1
  153. package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js.map +1 -1
  154. package/dist/lib/components/search/search-panel.component.d.ts +10 -0
  155. package/dist/lib/components/search/search-panel.component.d.ts.map +1 -1
  156. package/dist/lib/components/search/search-panel.component.js +25 -3
  157. package/dist/lib/components/search/search-panel.component.js.map +1 -1
  158. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts +28 -1
  159. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts.map +1 -1
  160. package/dist/lib/components/sidebar/conversation-sidebar.component.js +51 -6
  161. package/dist/lib/components/sidebar/conversation-sidebar.component.js.map +1 -1
  162. package/dist/lib/components/task/tasks-full-view.component.d.ts +31 -8
  163. package/dist/lib/components/task/tasks-full-view.component.d.ts.map +1 -1
  164. package/dist/lib/components/task/tasks-full-view.component.js +692 -497
  165. package/dist/lib/components/task/tasks-full-view.component.js.map +1 -1
  166. package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
  167. package/dist/lib/components/workspace/conversation-workspace.component.js +15 -2
  168. package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
  169. package/dist/lib/conversations.module.d.ts +66 -61
  170. package/dist/lib/conversations.module.d.ts.map +1 -1
  171. package/dist/lib/conversations.module.js +60 -1
  172. package/dist/lib/conversations.module.js.map +1 -1
  173. package/dist/lib/events/chat-events.d.ts +45 -0
  174. package/dist/lib/events/chat-events.d.ts.map +1 -1
  175. package/dist/lib/events/chat-events.js +64 -0
  176. package/dist/lib/events/chat-events.js.map +1 -1
  177. package/dist/lib/models/agent-turn.model.d.ts +7 -1
  178. package/dist/lib/models/agent-turn.model.d.ts.map +1 -1
  179. package/dist/lib/models/agent-turn.model.js.map +1 -1
  180. package/dist/lib/services/agent-state.service.d.ts.map +1 -1
  181. package/dist/lib/services/agent-state.service.js +14 -3
  182. package/dist/lib/services/agent-state.service.js.map +1 -1
  183. package/dist/lib/services/artifact-permission.service.d.ts.map +1 -1
  184. package/dist/lib/services/artifact-permission.service.js +14 -3
  185. package/dist/lib/services/artifact-permission.service.js.map +1 -1
  186. package/dist/lib/services/artifact-state.service.d.ts.map +1 -1
  187. package/dist/lib/services/artifact-state.service.js +43 -11
  188. package/dist/lib/services/artifact-state.service.js.map +1 -1
  189. package/dist/lib/services/conversation-agent.service.d.ts +8 -3
  190. package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
  191. package/dist/lib/services/conversation-agent.service.js +9 -3
  192. package/dist/lib/services/conversation-agent.service.js.map +1 -1
  193. package/dist/lib/services/conversation-tasks-filter.d.ts +59 -2
  194. package/dist/lib/services/conversation-tasks-filter.d.ts.map +1 -1
  195. package/dist/lib/services/conversation-tasks-filter.js +222 -18
  196. package/dist/lib/services/conversation-tasks-filter.js.map +1 -1
  197. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts +85 -0
  198. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts.map +1 -0
  199. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js +257 -0
  200. package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js.map +1 -0
  201. package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts +85 -0
  202. package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts.map +1 -0
  203. package/dist/lib/services/edge-ai/edge-ai-protocol.js +10 -0
  204. package/dist/lib/services/edge-ai/edge-ai-protocol.js.map +1 -0
  205. package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts +90 -0
  206. package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts.map +1 -0
  207. package/dist/lib/services/edge-ai/edge-ai-worker-host.js +386 -0
  208. package/dist/lib/services/edge-ai/edge-ai-worker-host.js.map +1 -0
  209. package/dist/lib/services/edge-ai/edge-ai.worker.d.ts +13 -0
  210. package/dist/lib/services/edge-ai/edge-ai.worker.d.ts.map +1 -0
  211. package/dist/lib/services/edge-ai/edge-ai.worker.js +201 -0
  212. package/dist/lib/services/edge-ai/edge-ai.worker.js.map +1 -0
  213. package/dist/lib/services/export.service.d.ts +64 -0
  214. package/dist/lib/services/export.service.d.ts.map +1 -1
  215. package/dist/lib/services/export.service.js +185 -6
  216. package/dist/lib/services/export.service.js.map +1 -1
  217. package/dist/lib/services/library-creation.service.d.ts +304 -0
  218. package/dist/lib/services/library-creation.service.d.ts.map +1 -0
  219. package/dist/lib/services/library-creation.service.js +1244 -0
  220. package/dist/lib/services/library-creation.service.js.map +1 -0
  221. package/dist/lib/services/realtime-audio-recorder.d.ts +10 -8
  222. package/dist/lib/services/realtime-audio-recorder.d.ts.map +1 -1
  223. package/dist/lib/services/realtime-audio-recorder.js +28 -12
  224. package/dist/lib/services/realtime-audio-recorder.js.map +1 -1
  225. package/dist/lib/services/realtime-pairing.d.ts +3 -3
  226. package/dist/lib/services/realtime-pairing.js +4 -4
  227. package/dist/lib/services/realtime-pairing.js.map +1 -1
  228. package/dist/lib/services/realtime-session-review.service.d.ts +14 -0
  229. package/dist/lib/services/realtime-session-review.service.d.ts.map +1 -1
  230. package/dist/lib/services/realtime-session-review.service.js +46 -4
  231. package/dist/lib/services/realtime-session-review.service.js.map +1 -1
  232. package/dist/lib/services/realtime-session.service.d.ts +10 -3
  233. package/dist/lib/services/realtime-session.service.d.ts.map +1 -1
  234. package/dist/lib/services/realtime-session.service.js +8 -3
  235. package/dist/lib/services/realtime-session.service.js.map +1 -1
  236. package/dist/lib/services/search.service.d.ts +19 -2
  237. package/dist/lib/services/search.service.d.ts.map +1 -1
  238. package/dist/lib/services/search.service.js +99 -36
  239. package/dist/lib/services/search.service.js.map +1 -1
  240. package/dist/lib/utils/agent-artifact-summary.d.ts +1 -1
  241. package/dist/lib/utils/agent-artifact-summary.d.ts.map +1 -1
  242. package/dist/lib/utils/agent-artifact-summary.js +1 -1
  243. package/dist/lib/utils/agent-artifact-summary.js.map +1 -1
  244. package/dist/lib/utils/decision-routing.d.ts +5 -2
  245. package/dist/lib/utils/decision-routing.d.ts.map +1 -1
  246. package/dist/lib/utils/decision-routing.js +9 -4
  247. package/dist/lib/utils/decision-routing.js.map +1 -1
  248. package/dist/public-api.d.ts +13 -0
  249. package/dist/public-api.d.ts.map +1 -1
  250. package/dist/public-api.js +15 -1
  251. package/dist/public-api.js.map +1 -1
  252. package/package.json +42 -37
@@ -43,6 +43,7 @@ export declare class ConversationRemoteBrowserController {
43
43
  private provider;
44
44
  private pushSub;
45
45
  private conversationId;
46
+ private standbyConversationId;
46
47
  private currentUrl;
47
48
  private stateVersion;
48
49
  private disposed;
@@ -57,6 +58,13 @@ export declare class ConversationRemoteBrowserController {
57
58
  get OwnsTools(): boolean;
58
59
  /** Connects the controller to the agent client (tool dispatch) and the provider (server calls, pushed frames). */
59
60
  Initialize(agentClient: AgentClientService, provider: GraphQLDataProvider | null): void;
61
+ /**
62
+ * Registers the `browser_*` tools for `conversationId` in standby mode when `AllowRemoteBrowser` is enabled,
63
+ * so an agent turn can call `browser_OpenUrl` (auto-opening the browser drawer) before the user manually
64
+ * opens the drawer. Does not start a server browser or light the header button until {@link Open} or
65
+ * {@link ExecuteBrowserTool} runs.
66
+ */
67
+ SetConversation(conversationId: string | null): void;
60
68
  /**
61
69
  * Opens the browser for `conversationId` and claims the `browser_*` tools. A browser this controller
62
70
  * held for a different conversation is ended first.
@@ -85,10 +93,10 @@ export declare class ConversationRemoteBrowserController {
85
93
  /** What the agent is told about the browser. */
86
94
  GetAppContextSnapshot(): ConversationRemoteBrowserContextSnapshot;
87
95
  /**
88
- * Adds the browser to an app context while it is open: its state under
89
- * `AdditionalContext.RemoteBrowser`, and, while this controller owns them, the `browser_*` tools
96
+ * Adds the browser to an app context while it is open or in standby for an allowed conversation: its state
97
+ * under `AdditionalContext.RemoteBrowser`, and, while this controller owns them, the `browser_*` tools
90
98
  * under `Capabilities.Tools`, the tier an agent run reads a surface's tools from. Returns `base`
91
- * unchanged while no browser is open.
99
+ * unchanged while no browser is open or in standby.
92
100
  */
93
101
  WithBrowserContext(base: Record<string, unknown> | null): Record<string, unknown> | null;
94
102
  /** Ends the browser and releases the tools, push subscription and channel. */
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-remote-browser-controller.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/conversation/conversation-remote-browser-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,mBAAmB,EAAoB,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6DAA6D,CAAC;AAG5G,mHAAmH;AACnH,MAAM,WAAW,wCAAwC;IACvD,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CA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AAE,MAAM,GAAG,IAAI;IAWzC;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAcnC,yFAAyF;IAClF,WAAW,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI;IAOhE,oFAAoF;IAC7E,aAAa,IAAI,IAAI;IAI5B,gHAAgH;IACnG,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAKxF,qEAAqE;IACxD,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAkB1J,gDAAgD;IACzC,qBAAqB,IAAI,wCAAwC;IAIxE;;;;;OAKG;IACI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAe/F,8EAA8E;IACvE,OAAO,IAAI,IAAI;IAQtB;;;OAGG;IACI,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAwClD,8FAA8F;IAC9F,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;IAqBjC,OAAO,CAAC,oBAAoB;CAqB7B"}
1
+ {"version":3,"file":"conversation-remote-browser-controller.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/conversation/conversation-remote-browser-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,mBA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AAM,GAAG,IAAI;IAwClD,8FAA8F;IAC9F,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;IAqBjC,OAAO,CAAC,oBAAoB;CAqB7B"}
@@ -43,6 +43,7 @@ export class ConversationRemoteBrowserController {
43
43
  provider = null;
44
44
  pushSub = null;
45
45
  conversationId = null;
46
+ standbyConversationId = null;
46
47
  currentUrl = null;
47
48
  stateVersion = 0;
48
49
  disposed = false;
@@ -74,6 +75,32 @@ export class ConversationRemoteBrowserController {
74
75
  this.pushSub?.unsubscribe();
75
76
  this.pushSub = provider?.PushStatusUpdates().subscribe((raw) => this.HandlePushMessage(raw)) ?? null;
76
77
  }
78
+ /**
79
+ * Registers the `browser_*` tools for `conversationId` in standby mode when `AllowRemoteBrowser` is enabled,
80
+ * so an agent turn can call `browser_OpenUrl` (auto-opening the browser drawer) before the user manually
81
+ * opens the drawer. Does not start a server browser or light the header button until {@link Open} or
82
+ * {@link ExecuteBrowserTool} runs.
83
+ */
84
+ SetConversation(conversationId) {
85
+ const nextId = conversationId?.trim() || null;
86
+ if (!nextId) {
87
+ if (!this.standbyConversationId) {
88
+ return;
89
+ }
90
+ this.standbyConversationId = null;
91
+ if (!this.conversationId) {
92
+ this.unregisterBrowserTools();
93
+ }
94
+ this.changed();
95
+ return;
96
+ }
97
+ if (this.standbyConversationId && UUIDsEqual(this.standbyConversationId, nextId) && this.OwnsTools) {
98
+ return;
99
+ }
100
+ this.standbyConversationId = nextId;
101
+ this.registerBrowserTools();
102
+ this.changed();
103
+ }
77
104
  /**
78
105
  * Opens the browser for `conversationId` and claims the `browser_*` tools. A browser this controller
79
106
  * held for a different conversation is ended first.
@@ -94,7 +121,13 @@ export class ConversationRemoteBrowserController {
94
121
  */
95
122
  async Close() {
96
123
  const conversationId = this.conversationId;
124
+ const hadStandby = this.standbyConversationId !== null;
125
+ this.standbyConversationId = null;
97
126
  if (!conversationId) {
127
+ if (hadStandby) {
128
+ this.unregisterBrowserTools();
129
+ this.changed();
130
+ }
98
131
  return;
99
132
  }
100
133
  // Unbinding reads the session ID synchronously, so it must run before the ID is cleared.
@@ -123,6 +156,9 @@ export class ConversationRemoteBrowserController {
123
156
  }
124
157
  /** Runs one `browser_*` tool against this conversation's browser. */
125
158
  async ExecuteBrowserTool(toolName, params) {
159
+ if (!this.conversationId && this.standbyConversationId) {
160
+ this.Open(this.standbyConversationId);
161
+ }
126
162
  if (!this.conversationId) {
127
163
  return { Success: false, ErrorMessage: 'No browser is open for this conversation.' };
128
164
  }
@@ -145,13 +181,13 @@ export class ConversationRemoteBrowserController {
145
181
  return { Open: this.conversationId !== null, CurrentUrl: this.currentUrl };
146
182
  }
147
183
  /**
148
- * Adds the browser to an app context while it is open: its state under
149
- * `AdditionalContext.RemoteBrowser`, and, while this controller owns them, the `browser_*` tools
184
+ * Adds the browser to an app context while it is open or in standby for an allowed conversation: its state
185
+ * under `AdditionalContext.RemoteBrowser`, and, while this controller owns them, the `browser_*` tools
150
186
  * under `Capabilities.Tools`, the tier an agent run reads a surface's tools from. Returns `base`
151
- * unchanged while no browser is open.
187
+ * unchanged while no browser is open or in standby.
152
188
  */
153
189
  WithBrowserContext(base) {
154
- if (!this.conversationId) {
190
+ if (!this.conversationId && !this.standbyConversationId) {
155
191
  return base;
156
192
  }
157
193
  const context = base ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-remote-browser-controller.js","sourceRoot":"","sources":["../../../../src/lib/components/conversation/conversation-remote-browser-controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAuB,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAG7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAEzF,OAAO,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAyB7H;;;G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IAAI,CAAC;QAClB,OAAO;YACL,SAAS,EAAE,mBAAmB;YAC9B,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,QAAQ,CAAC;YACvB,CAAC;YACD,IAAI,cAAc;gBAChB,OAAO,IAAI,CAAC,cAAc,CAAC;YAC7B,CAAC;YACD,kGAAkG;YAClG,eAAe,EAAE,CAAC,IAAY,EAAE,EAAE;gBAChC,MAAM,KAAK,GAAG,0DAA0D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,CAAC;YACD,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS;YAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;YAC7B,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;YAChC,mBAAmB,EAAE,CAAI,KAAa,EAAE,SAAoC,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAI,KAAK,EAAE,SAAS,CAAC;SAC/H,CAAC;IACJ,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/G,CAAC","sourcesContent":["import { Subscription } from 'rxjs';\nimport { JSONObject, JSONValue } from '@memberjunction/ai';\nimport { ClientToolMetadata } from '@memberjunction/ai-core-plus';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { GraphQLDataProvider, SafeGraphQLError } from '@memberjunction/graphql-dataprovider';\nimport { AgentClientService } from '@memberjunction/ng-agent-client';\nimport { RealtimeChannelContext } from '@memberjunction/realtime-runtime';\nimport { RemoteBrowserChannel } from '../realtime/remote-browser/remote-browser-channel';\nimport { RemoteBrowserSurfaceComponent } from '../realtime/remote-browser/remote-browser-surface.component';\nimport { REMOTE_BROWSER_TOOL_DEFINITIONS, REMOTE_BROWSER_TOOL_NAMES } from '../realtime/remote-browser/remote-browser-tools';\n\n/** What a text agent is told about the conversation's browser, as `appContext.AdditionalContext.RemoteBrowser`. */\nexport interface ConversationRemoteBrowserContextSnapshot {\n Open: boolean;\n CurrentUrl: string | null;\n}\n\n/**\n * Options for constructing a {@link ConversationRemoteBrowserController}.\n */\nexport interface ConversationRemoteBrowserControllerOptions {\n /** Invoked when an agent's `browser_*` tool runs, so the UI can show the browser drawer. */\n OnAutoOpenSurface?: () => void;\n /** Invoked when the browser opens or closes, or its URL changes. */\n OnStateChange?: () => void;\n /**\n * Invoked once when the server refuses this conversation a browser (not enabled, not the caller's, over\n * the cap). The controller has already closed it, which stops the live view's polling.\n */\n OnSessionRefused?: (message: string) => void;\n /** Optional custom GraphQL executor (used by unit tests; defaults to the provider's `ExecuteGQL`). */\n ExecuteServerAction?: <T>(query: string, variables: Record<string, JSONValue>) => Promise<T | null>;\n}\n\n/**\n * The `extensions.code` the server sets on a refusal that asking again cannot change (browsers not enabled,\n * not the caller's, over a cap): MJServer's `RemoteBrowserRefusedError`.\n */\nconst REMOTE_BROWSER_REFUSED = 'REMOTE_BROWSER_REFUSED';\n\nconst END_REMOTE_BROWSER_SESSION_MUTATION = `\n mutation EndRemoteBrowserSession($agentSessionID: String!) {\n EndRemoteBrowserSession(agentSessionID: $agentSessionID)\n }\n`;\n\n/**\n * The `browser_*` tools a text conversation's agents get: all but AchieveGoal, whose goal loop clicks\n * and navigates on its own, past the click guard (the server refuses goal runs for a conversation too).\n */\nconst TEXT_BROWSER_TOOLS = REMOTE_BROWSER_TOOL_DEFINITIONS.filter((def) => def.Name !== REMOTE_BROWSER_TOOL_NAMES.AchieveGoal);\n\n/** The text browser tools in the shape an agent run reads from `appContext.Capabilities.Tools`. */\nconst BROWSER_TOOL_METADATA: ClientToolMetadata[] = TEXT_BROWSER_TOOLS.map((def) => ({\n Name: def.Name,\n Description: def.Description,\n InputSchema: (def.ParametersSchema ?? {}) as Record<string, unknown>,\n}));\n\ntype ClientToolHandler = ReturnType<AgentClientService['GetRegisteredTools']>[number]['Handler'];\n\n/**\n * Gives one text conversation (`MJ: Conversations`) a live Remote Browser its agents can drive.\n *\n * The browser belongs to the conversation that opened it ({@link Open}); the controller captures that\n * ID, so a later conversation switch still stops and ends the right browser ({@link Close}).\n *\n * Agents reach the browser through the `browser_*` client tools. Their handlers live in\n * `AgentClientService`, whose registry is app-wide, so they are registered only while this\n * controller's browser is open, and removed on close only if this controller still owns them (a chat\n * area that opened a browser later takes them over). The tools are advertised to this conversation's\n * agent runs alone, through `appContext.Capabilities.Tools` ({@link WithBrowserContext}).\n */\nexport class ConversationRemoteBrowserController {\n private readonly channel = new RemoteBrowserChannel();\n private readonly options: ConversationRemoteBrowserControllerOptions;\n private readonly handlers = new Map<string, ClientToolHandler>();\n private agentClient: AgentClientService | null = null;\n private provider: GraphQLDataProvider | null = null;\n private pushSub: Subscription | null = null;\n private conversationId: string | null = null;\n private currentUrl: string | null = null;\n private stateVersion = 0;\n private disposed = false;\n\n constructor(options: ConversationRemoteBrowserControllerOptions = {}) {\n this.options = options;\n this.channel.Initialize(this.createChannelContext());\n }\n\n /** The conversation whose browser is open, or `null` when none is. */\n public get ConversationId(): string | null {\n return this.conversationId;\n }\n\n /** The browser's last known URL. */\n public get CurrentUrl(): string | null {\n return this.currentUrl;\n }\n\n /** Bumps on every open, close and URL change, so a host can cache what it derives from the state. */\n public get StateVersion(): number {\n return this.stateVersion;\n }\n\n /** Whether the app-wide registry holds THIS controller's `browser_*` handlers. */\n public get OwnsTools(): boolean {\n const registered = this.agentClient?.GetRegisteredTools() ?? [];\n return this.handlers.size > 0 && Array.from(this.handlers).every(([name, handler]) => registered.find((t) => t.Name === name)?.Handler === handler);\n }\n\n /** Connects the controller to the agent client (tool dispatch) and the provider (server calls, pushed frames). */\n public Initialize(agentClient: AgentClientService, provider: GraphQLDataProvider | null): void {\n this.agentClient = agentClient;\n this.provider = provider;\n this.pushSub?.unsubscribe();\n this.pushSub = provider?.PushStatusUpdates().subscribe((raw: string) => this.HandlePushMessage(raw)) ?? null;\n }\n\n /**\n * Opens the browser for `conversationId` and claims the `browser_*` tools. A browser this controller\n * held for a different conversation is ended first.\n */\n public Open(conversationId: string): void {\n if (this.conversationId && UUIDsEqual(this.conversationId, conversationId)) {\n this.registerBrowserTools();\n return;\n }\n void this.Close();\n this.conversationId = conversationId;\n this.registerBrowserTools();\n this.changed();\n }\n\n /**\n * Ends the conversation's browser: stops its streams, gives up the tools this controller still owns,\n * and ends the server browser so no Chromium process (or billed hosted browser) is left running.\n */\n public async Close(): Promise<void> {\n const conversationId = this.conversationId;\n if (!conversationId) {\n return;\n }\n // Unbinding reads the session ID synchronously, so it must run before the ID is cleared.\n this.channel.UnbindSurface();\n this.unregisterBrowserTools();\n this.conversationId = null;\n this.currentUrl = null;\n this.changed();\n await this.executeServerAction(END_REMOTE_BROWSER_SESSION_MUTATION, { agentSessionID: conversationId });\n }\n\n /** Binds the drawer's live surface (starts the screencast, audio and human takeover). */\n public BindSurface(surface: RemoteBrowserSurfaceComponent): void {\n this.channel.BindSurface(surface);\n if (this.currentUrl) {\n surface.SetCurrentUrl(this.currentUrl);\n }\n }\n\n /** Unbinds the surface when the drawer is hidden; the browser itself stays open. */\n public UnbindSurface(): void {\n this.channel.UnbindSurface();\n }\n\n /** Navigates the browser, e.g. from the drawer's URL bar; a refusal or failure comes back in `ErrorMessage`. */\n public async Navigate(url: string): Promise<{ Success: boolean; ErrorMessage?: string }> {\n const result = await this.ExecuteBrowserTool(REMOTE_BROWSER_TOOL_NAMES.OpenUrl, { url });\n return { Success: result.Success, ErrorMessage: result.ErrorMessage };\n }\n\n /** Runs one `browser_*` tool against this conversation's browser. */\n public async ExecuteBrowserTool(toolName: string, params: Record<string, unknown>): Promise<{ Success: boolean; Data?: JSONValue; ErrorMessage?: string }> {\n if (!this.conversationId) {\n return { Success: false, ErrorMessage: 'No browser is open for this conversation.' };\n }\n this.options.OnAutoOpenSurface?.();\n const raw = await this.channel.ApplyAgentTool(toolName, JSON.stringify(params ?? {}));\n let result: { success?: boolean; currentUrl?: string; detail?: string; error?: string };\n try {\n result = JSON.parse(raw);\n } catch {\n return { Success: true, Data: { raw } };\n }\n this.setUrl(result.currentUrl);\n return result.success === false\n ? { Success: false, Data: result as JSONObject, ErrorMessage: result.error ?? result.detail ?? 'Browser tool execution failed.' }\n : { Success: true, Data: result as JSONObject };\n }\n\n /** What the agent is told about the browser. */\n public GetAppContextSnapshot(): ConversationRemoteBrowserContextSnapshot {\n return { Open: this.conversationId !== null, CurrentUrl: this.currentUrl };\n }\n\n /**\n * Adds the browser to an app context while it is open: its state under\n * `AdditionalContext.RemoteBrowser`, and, while this controller owns them, the `browser_*` tools\n * under `Capabilities.Tools`, the tier an agent run reads a surface's tools from. Returns `base`\n * unchanged while no browser is open.\n */\n public WithBrowserContext(base: Record<string, unknown> | null): Record<string, unknown> | null {\n if (!this.conversationId) {\n return base;\n }\n const context = base ?? {};\n const additional = asRecord(context['AdditionalContext']);\n const capabilities = asRecord(context['Capabilities']);\n const tools = Array.isArray(capabilities['Tools']) ? (capabilities['Tools'] as ClientToolMetadata[]) : [];\n return {\n ...context,\n AdditionalContext: { ...additional, RemoteBrowser: this.GetAppContextSnapshot() },\n ...(this.OwnsTools ? { Capabilities: { ...capabilities, Tools: [...tools, ...BROWSER_TOOL_METADATA] } } : {}),\n };\n }\n\n /** Ends the browser and releases the tools, push subscription and channel. */\n public Dispose(): void {\n this.disposed = true;\n void this.Close();\n this.pushSub?.unsubscribe();\n this.pushSub = null;\n this.channel.Dispose();\n }\n\n /**\n * Routes a pushed `RemoteBrowserScreencastFrame` or `RemoteBrowserAudioChunk` to the channel when it\n * belongs to this controller's browser.\n */\n public HandlePushMessage(rawMessage: string): void {\n if (!this.conversationId || !rawMessage) {\n return;\n }\n let message: {\n resolver?: string;\n type?: string;\n agentSessionID?: string;\n currentUrl?: string | null;\n dataBase64?: string;\n sampleRate?: number;\n channels?: number;\n seq?: number;\n };\n try {\n const outer = JSON.parse(rawMessage) as Record<string, unknown>;\n message = typeof outer['message'] === 'string' ? JSON.parse(outer['message']) : outer;\n } catch {\n return; // Not JSON: an unrelated status update.\n }\n if (message.resolver !== 'RemoteBrowserActionResolver' || !message.agentSessionID || !UUIDsEqual(message.agentSessionID, this.conversationId)) {\n return;\n }\n if (typeof message.dataBase64 !== 'string') {\n return;\n }\n if (message.type === 'RemoteBrowserScreencastFrame') {\n this.channel.OnScreencastFrame(message.dataBase64, message.currentUrl ?? null);\n this.setUrl(message.currentUrl);\n } else if (message.type === 'RemoteBrowserAudioChunk') {\n this.channel.OnAudioChunk({\n dataBase64: message.dataBase64,\n codec: 'webm-opus',\n sampleRate: message.sampleRate ?? 48000,\n channels: message.channels ?? 2,\n seq: message.seq ?? 0,\n });\n }\n }\n\n /** Records a new URL; frames repeat the same one, so only a real change notifies the host. */\n private setUrl(url: string | null | undefined): void {\n const next = url?.trim();\n if (next && next !== this.currentUrl) {\n this.currentUrl = next;\n this.changed();\n }\n }\n\n private changed(): void {\n this.stateVersion++;\n if (!this.disposed) {\n this.options.OnStateChange?.();\n }\n }\n\n private registerBrowserTools(): void {\n const agentClient = this.agentClient;\n if (!agentClient) {\n return;\n }\n for (const def of TEXT_BROWSER_TOOLS) {\n let handler = this.handlers.get(def.Name);\n if (!handler) {\n handler = (params: Record<string, unknown>) => this.ExecuteBrowserTool(def.Name, params);\n this.handlers.set(def.Name, handler);\n }\n agentClient.RegisterTool({ Name: def.Name, Description: def.Description, ParameterSchema: (def.ParametersSchema ?? {}) as JSONObject, Handler: handler });\n }\n const sessionId = this.provider?.sessionId;\n if (sessionId && (!agentClient.IsActive || agentClient.SessionId !== sessionId)) {\n agentClient.StartSession(sessionId);\n }\n }\n\n private unregisterBrowserTools(): void {\n const registered = this.agentClient?.GetRegisteredTools() ?? [];\n for (const [name, handler] of this.handlers) {\n if (registered.find((t) => t.Name === name)?.Handler === handler) {\n this.agentClient?.UnregisterTool(name);\n }\n }\n }\n\n private async executeServerAction<T>(query: string, variables: Record<string, JSONValue>): Promise<T | null> {\n try {\n if (this.options.ExecuteServerAction) {\n return await this.options.ExecuteServerAction<T>(query, variables);\n }\n return this.provider ? (((await this.provider.ExecuteGQL(query, variables)) as T) ?? null) : null;\n } catch (err) {\n if (err instanceof SafeGraphQLError && err.Code === REMOTE_BROWSER_REFUSED) {\n // Asking again gets the same answer: close, so the live view stops polling, and say why once. Only\n // for the browser still open: a refusal for one already left (its End, after a switch) changes nothing.\n if (UUIDsEqual(variables['agentSessionID'] as string | null, this.conversationId)) {\n void this.Close();\n this.options.OnSessionRefused?.(err.message);\n }\n } else {\n console.warn('[ConversationRemoteBrowserController] GraphQL execution failed:', err);\n }\n return null;\n }\n }\n\n private createChannelContext(): RealtimeChannelContext {\n const self = this;\n return {\n AgentName: 'ConversationAgent',\n get Provider(): GraphQLDataProvider | null {\n return self.provider;\n },\n get AgentSessionID(): string | null {\n return self.conversationId;\n },\n // The channel narrates page changes as notes; a text conversation only needs the URL out of them.\n SendContextNote: (text: string) => {\n const match = /^\\[browser\\] (?:current page|the page changed to): (\\S+)/.exec(text);\n self.setUrl(match?.[1]);\n },\n RequestSave: () => undefined,\n SetFocusMode: () => undefined,\n SaveAsArtifact: async () => null,\n ExecuteServerAction: <T>(query: string, variables: Record<string, JSONValue>) => self.executeServerAction<T>(query, variables),\n };\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n"]}
1
+ {"version":3,"file":"conversation-remote-browser-controller.js","sourceRoot":"","sources":["../../../../src/lib/components/conversation/conversation-remote-browser-controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAuB,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAG7F,OAAO,EAAE,oBAAoB,EAAE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GAAG,IAAI,CAAC;QAClB,OAAO;YACL,SAAS,EAAE,mBAAmB;YAC9B,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,QAAQ,CAAC;YACvB,CAAC;YACD,IAAI,cAAc;gBAChB,OAAO,IAAI,CAAC,cAAc,CAAC;YAC7B,CAAC;YACD,kGAAkG;YAClG,eAAe,EAAE,CAAC,IAAY,EAAE,EAAE;gBAChC,MAAM,KAAK,GAAG,0DAA0D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1B,CAAC;YACD,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS;YAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;YAC7B,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;YAChC,mBAAmB,EAAE,CAAI,KAAa,EAAE,SAAoC,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAI,KAAK,EAAE,SAAS,CAAC;SAC/H,CAAC;IACJ,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/G,CAAC","sourcesContent":["import { Subscription } from 'rxjs';\nimport { JSONObject, JSONValue } from '@memberjunction/ai';\nimport { ClientToolMetadata } from '@memberjunction/ai-core-plus';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { GraphQLDataProvider, SafeGraphQLError } from '@memberjunction/graphql-dataprovider';\nimport { AgentClientService } from '@memberjunction/ng-agent-client';\nimport { RealtimeChannelContext } from '@memberjunction/realtime-runtime';\nimport { RemoteBrowserChannel } from '../realtime/remote-browser/remote-browser-channel';\nimport { RemoteBrowserSurfaceComponent } from '../realtime/remote-browser/remote-browser-surface.component';\nimport { REMOTE_BROWSER_TOOL_DEFINITIONS, REMOTE_BROWSER_TOOL_NAMES } from '../realtime/remote-browser/remote-browser-tools';\n\n/** What a text agent is told about the conversation's browser, as `appContext.AdditionalContext.RemoteBrowser`. */\nexport interface ConversationRemoteBrowserContextSnapshot {\n Open: boolean;\n CurrentUrl: string | null;\n}\n\n/**\n * Options for constructing a {@link ConversationRemoteBrowserController}.\n */\nexport interface ConversationRemoteBrowserControllerOptions {\n /** Invoked when an agent's `browser_*` tool runs, so the UI can show the browser drawer. */\n OnAutoOpenSurface?: () => void;\n /** Invoked when the browser opens or closes, or its URL changes. */\n OnStateChange?: () => void;\n /**\n * Invoked once when the server refuses this conversation a browser (not enabled, not the caller's, over\n * the cap). The controller has already closed it, which stops the live view's polling.\n */\n OnSessionRefused?: (message: string) => void;\n /** Optional custom GraphQL executor (used by unit tests; defaults to the provider's `ExecuteGQL`). */\n ExecuteServerAction?: <T>(query: string, variables: Record<string, JSONValue>) => Promise<T | null>;\n}\n\n/**\n * The `extensions.code` the server sets on a refusal that asking again cannot change (browsers not enabled,\n * not the caller's, over a cap): MJServer's `RemoteBrowserRefusedError`.\n */\nconst REMOTE_BROWSER_REFUSED = 'REMOTE_BROWSER_REFUSED';\n\nconst END_REMOTE_BROWSER_SESSION_MUTATION = `\n mutation EndRemoteBrowserSession($agentSessionID: String!) {\n EndRemoteBrowserSession(agentSessionID: $agentSessionID)\n }\n`;\n\n/**\n * The `browser_*` tools a text conversation's agents get: all but AchieveGoal, whose goal loop clicks\n * and navigates on its own, past the click guard (the server refuses goal runs for a conversation too).\n */\nconst TEXT_BROWSER_TOOLS = REMOTE_BROWSER_TOOL_DEFINITIONS.filter((def) => def.Name !== REMOTE_BROWSER_TOOL_NAMES.AchieveGoal);\n\n/** The text browser tools in the shape an agent run reads from `appContext.Capabilities.Tools`. */\nconst BROWSER_TOOL_METADATA: ClientToolMetadata[] = TEXT_BROWSER_TOOLS.map((def) => ({\n Name: def.Name,\n Description: def.Description,\n InputSchema: (def.ParametersSchema ?? {}) as Record<string, unknown>,\n}));\n\ntype ClientToolHandler = ReturnType<AgentClientService['GetRegisteredTools']>[number]['Handler'];\n\n/**\n * Gives one text conversation (`MJ: Conversations`) a live Remote Browser its agents can drive.\n *\n * The browser belongs to the conversation that opened it ({@link Open}); the controller captures that\n * ID, so a later conversation switch still stops and ends the right browser ({@link Close}).\n *\n * Agents reach the browser through the `browser_*` client tools. Their handlers live in\n * `AgentClientService`, whose registry is app-wide, so they are registered only while this\n * controller's browser is open, and removed on close only if this controller still owns them (a chat\n * area that opened a browser later takes them over). The tools are advertised to this conversation's\n * agent runs alone, through `appContext.Capabilities.Tools` ({@link WithBrowserContext}).\n */\nexport class ConversationRemoteBrowserController {\n private readonly channel = new RemoteBrowserChannel();\n private readonly options: ConversationRemoteBrowserControllerOptions;\n private readonly handlers = new Map<string, ClientToolHandler>();\n private agentClient: AgentClientService | null = null;\n private provider: GraphQLDataProvider | null = null;\n private pushSub: Subscription | null = null;\n private conversationId: string | null = null;\n private standbyConversationId: string | null = null;\n private currentUrl: string | null = null;\n private stateVersion = 0;\n private disposed = false;\n\n constructor(options: ConversationRemoteBrowserControllerOptions = {}) {\n this.options = options;\n this.channel.Initialize(this.createChannelContext());\n }\n\n /** The conversation whose browser is open, or `null` when none is. */\n public get ConversationId(): string | null {\n return this.conversationId;\n }\n\n /** The browser's last known URL. */\n public get CurrentUrl(): string | null {\n return this.currentUrl;\n }\n\n /** Bumps on every open, close and URL change, so a host can cache what it derives from the state. */\n public get StateVersion(): number {\n return this.stateVersion;\n }\n\n /** Whether the app-wide registry holds THIS controller's `browser_*` handlers. */\n public get OwnsTools(): boolean {\n const registered = this.agentClient?.GetRegisteredTools() ?? [];\n return this.handlers.size > 0 && Array.from(this.handlers).every(([name, handler]) => registered.find((t) => t.Name === name)?.Handler === handler);\n }\n\n /** Connects the controller to the agent client (tool dispatch) and the provider (server calls, pushed frames). */\n public Initialize(agentClient: AgentClientService, provider: GraphQLDataProvider | null): void {\n this.agentClient = agentClient;\n this.provider = provider;\n this.pushSub?.unsubscribe();\n this.pushSub = provider?.PushStatusUpdates().subscribe((raw: string) => this.HandlePushMessage(raw)) ?? null;\n }\n\n /**\n * Registers the `browser_*` tools for `conversationId` in standby mode when `AllowRemoteBrowser` is enabled,\n * so an agent turn can call `browser_OpenUrl` (auto-opening the browser drawer) before the user manually\n * opens the drawer. Does not start a server browser or light the header button until {@link Open} or\n * {@link ExecuteBrowserTool} runs.\n */\n public SetConversation(conversationId: string | null): void {\n const nextId = conversationId?.trim() || null;\n if (!nextId) {\n if (!this.standbyConversationId) {\n return;\n }\n this.standbyConversationId = null;\n if (!this.conversationId) {\n this.unregisterBrowserTools();\n }\n this.changed();\n return;\n }\n if (this.standbyConversationId && UUIDsEqual(this.standbyConversationId, nextId) && this.OwnsTools) {\n return;\n }\n this.standbyConversationId = nextId;\n this.registerBrowserTools();\n this.changed();\n }\n\n /**\n * Opens the browser for `conversationId` and claims the `browser_*` tools. A browser this controller\n * held for a different conversation is ended first.\n */\n public Open(conversationId: string): void {\n if (this.conversationId && UUIDsEqual(this.conversationId, conversationId)) {\n this.registerBrowserTools();\n return;\n }\n void this.Close();\n this.conversationId = conversationId;\n this.registerBrowserTools();\n this.changed();\n }\n\n /**\n * Ends the conversation's browser: stops its streams, gives up the tools this controller still owns,\n * and ends the server browser so no Chromium process (or billed hosted browser) is left running.\n */\n public async Close(): Promise<void> {\n const conversationId = this.conversationId;\n const hadStandby = this.standbyConversationId !== null;\n this.standbyConversationId = null;\n if (!conversationId) {\n if (hadStandby) {\n this.unregisterBrowserTools();\n this.changed();\n }\n return;\n }\n // Unbinding reads the session ID synchronously, so it must run before the ID is cleared.\n this.channel.UnbindSurface();\n this.unregisterBrowserTools();\n this.conversationId = null;\n this.currentUrl = null;\n this.changed();\n await this.executeServerAction(END_REMOTE_BROWSER_SESSION_MUTATION, { agentSessionID: conversationId });\n }\n\n /** Binds the drawer's live surface (starts the screencast, audio and human takeover). */\n public BindSurface(surface: RemoteBrowserSurfaceComponent): void {\n this.channel.BindSurface(surface);\n if (this.currentUrl) {\n surface.SetCurrentUrl(this.currentUrl);\n }\n }\n\n /** Unbinds the surface when the drawer is hidden; the browser itself stays open. */\n public UnbindSurface(): void {\n this.channel.UnbindSurface();\n }\n\n /** Navigates the browser, e.g. from the drawer's URL bar; a refusal or failure comes back in `ErrorMessage`. */\n public async Navigate(url: string): Promise<{ Success: boolean; ErrorMessage?: string }> {\n const result = await this.ExecuteBrowserTool(REMOTE_BROWSER_TOOL_NAMES.OpenUrl, { url });\n return { Success: result.Success, ErrorMessage: result.ErrorMessage };\n }\n\n /** Runs one `browser_*` tool against this conversation's browser. */\n public async ExecuteBrowserTool(toolName: string, params: Record<string, unknown>): Promise<{ Success: boolean; Data?: JSONValue; ErrorMessage?: string }> {\n if (!this.conversationId && this.standbyConversationId) {\n this.Open(this.standbyConversationId);\n }\n if (!this.conversationId) {\n return { Success: false, ErrorMessage: 'No browser is open for this conversation.' };\n }\n this.options.OnAutoOpenSurface?.();\n const raw = await this.channel.ApplyAgentTool(toolName, JSON.stringify(params ?? {}));\n let result: { success?: boolean; currentUrl?: string; detail?: string; error?: string };\n try {\n result = JSON.parse(raw);\n } catch {\n return { Success: true, Data: { raw } };\n }\n this.setUrl(result.currentUrl);\n return result.success === false\n ? { Success: false, Data: result as JSONObject, ErrorMessage: result.error ?? result.detail ?? 'Browser tool execution failed.' }\n : { Success: true, Data: result as JSONObject };\n }\n\n /** What the agent is told about the browser. */\n public GetAppContextSnapshot(): ConversationRemoteBrowserContextSnapshot {\n return { Open: this.conversationId !== null, CurrentUrl: this.currentUrl };\n }\n\n /**\n * Adds the browser to an app context while it is open or in standby for an allowed conversation: its state\n * under `AdditionalContext.RemoteBrowser`, and, while this controller owns them, the `browser_*` tools\n * under `Capabilities.Tools`, the tier an agent run reads a surface's tools from. Returns `base`\n * unchanged while no browser is open or in standby.\n */\n public WithBrowserContext(base: Record<string, unknown> | null): Record<string, unknown> | null {\n if (!this.conversationId && !this.standbyConversationId) {\n return base;\n }\n const context = base ?? {};\n const additional = asRecord(context['AdditionalContext']);\n const capabilities = asRecord(context['Capabilities']);\n const tools = Array.isArray(capabilities['Tools']) ? (capabilities['Tools'] as ClientToolMetadata[]) : [];\n return {\n ...context,\n AdditionalContext: { ...additional, RemoteBrowser: this.GetAppContextSnapshot() },\n ...(this.OwnsTools ? { Capabilities: { ...capabilities, Tools: [...tools, ...BROWSER_TOOL_METADATA] } } : {}),\n };\n }\n\n /** Ends the browser and releases the tools, push subscription and channel. */\n public Dispose(): void {\n this.disposed = true;\n void this.Close();\n this.pushSub?.unsubscribe();\n this.pushSub = null;\n this.channel.Dispose();\n }\n\n /**\n * Routes a pushed `RemoteBrowserScreencastFrame` or `RemoteBrowserAudioChunk` to the channel when it\n * belongs to this controller's browser.\n */\n public HandlePushMessage(rawMessage: string): void {\n if (!this.conversationId || !rawMessage) {\n return;\n }\n let message: {\n resolver?: string;\n type?: string;\n agentSessionID?: string;\n currentUrl?: string | null;\n dataBase64?: string;\n sampleRate?: number;\n channels?: number;\n seq?: number;\n };\n try {\n const outer = JSON.parse(rawMessage) as Record<string, unknown>;\n message = typeof outer['message'] === 'string' ? JSON.parse(outer['message']) : outer;\n } catch {\n return; // Not JSON: an unrelated status update.\n }\n if (message.resolver !== 'RemoteBrowserActionResolver' || !message.agentSessionID || !UUIDsEqual(message.agentSessionID, this.conversationId)) {\n return;\n }\n if (typeof message.dataBase64 !== 'string') {\n return;\n }\n if (message.type === 'RemoteBrowserScreencastFrame') {\n this.channel.OnScreencastFrame(message.dataBase64, message.currentUrl ?? null);\n this.setUrl(message.currentUrl);\n } else if (message.type === 'RemoteBrowserAudioChunk') {\n this.channel.OnAudioChunk({\n dataBase64: message.dataBase64,\n codec: 'webm-opus',\n sampleRate: message.sampleRate ?? 48000,\n channels: message.channels ?? 2,\n seq: message.seq ?? 0,\n });\n }\n }\n\n /** Records a new URL; frames repeat the same one, so only a real change notifies the host. */\n private setUrl(url: string | null | undefined): void {\n const next = url?.trim();\n if (next && next !== this.currentUrl) {\n this.currentUrl = next;\n this.changed();\n }\n }\n\n private changed(): void {\n this.stateVersion++;\n if (!this.disposed) {\n this.options.OnStateChange?.();\n }\n }\n\n private registerBrowserTools(): void {\n const agentClient = this.agentClient;\n if (!agentClient) {\n return;\n }\n for (const def of TEXT_BROWSER_TOOLS) {\n let handler = this.handlers.get(def.Name);\n if (!handler) {\n handler = (params: Record<string, unknown>) => this.ExecuteBrowserTool(def.Name, params);\n this.handlers.set(def.Name, handler);\n }\n agentClient.RegisterTool({ Name: def.Name, Description: def.Description, ParameterSchema: (def.ParametersSchema ?? {}) as JSONObject, Handler: handler });\n }\n const sessionId = this.provider?.sessionId;\n if (sessionId && (!agentClient.IsActive || agentClient.SessionId !== sessionId)) {\n agentClient.StartSession(sessionId);\n }\n }\n\n private unregisterBrowserTools(): void {\n const registered = this.agentClient?.GetRegisteredTools() ?? [];\n for (const [name, handler] of this.handlers) {\n if (registered.find((t) => t.Name === name)?.Handler === handler) {\n this.agentClient?.UnregisterTool(name);\n }\n }\n }\n\n private async executeServerAction<T>(query: string, variables: Record<string, JSONValue>): Promise<T | null> {\n try {\n if (this.options.ExecuteServerAction) {\n return await this.options.ExecuteServerAction<T>(query, variables);\n }\n return this.provider ? (((await this.provider.ExecuteGQL(query, variables)) as T) ?? null) : null;\n } catch (err) {\n if (err instanceof SafeGraphQLError && err.Code === REMOTE_BROWSER_REFUSED) {\n // Asking again gets the same answer: close, so the live view stops polling, and say why once. Only\n // for the browser still open: a refusal for one already left (its End, after a switch) changes nothing.\n if (UUIDsEqual(variables['agentSessionID'] as string | null, this.conversationId)) {\n void this.Close();\n this.options.OnSessionRefused?.(err.message);\n }\n } else {\n console.warn('[ConversationRemoteBrowserController] GraphQL execution failed:', err);\n }\n return null;\n }\n }\n\n private createChannelContext(): RealtimeChannelContext {\n const self = this;\n return {\n AgentName: 'ConversationAgent',\n get Provider(): GraphQLDataProvider | null {\n return self.provider;\n },\n get AgentSessionID(): string | null {\n return self.conversationId;\n },\n // The channel narrates page changes as notes; a text conversation only needs the URL out of them.\n SendContextNote: (text: string) => {\n const match = /^\\[browser\\] (?:current page|the page changed to): (\\S+)/.exec(text);\n self.setUrl(match?.[1]);\n },\n RequestSave: () => undefined,\n SetFocusMode: () => undefined,\n SaveAsArtifact: async () => null,\n ExecuteServerAction: <T>(query: string, variables: Record<string, JSONValue>) => self.executeServerAction<T>(query, variables),\n };\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { MJConversationEntity, type ConversationScope } from '@memberjunction/core-entities';
3
3
  import { UserInfo } from '@memberjunction/core';
4
- import { ExportService, ExportFormat, ExportOptions, ExportBranding } from '../../services/export.service';
4
+ import { ExportService, ExportFormat, ExportOptions, ExportBranding, ExportArtifactLinkTarget } from '../../services/export.service';
5
5
  import { DialogService } from '../../services/dialog.service';
6
6
  import { ToastService } from '../../services/toast.service';
7
7
  import * as i0 from "@angular/core";
@@ -41,6 +41,11 @@ export declare class ExportModalComponent {
41
41
  * exports Main.
42
42
  */
43
43
  Scope: ConversationScope | null;
44
+ /**
45
+ * Builds a link that opens an exported artifact in the app (this package has no router, so
46
+ * the host supplies it). Null exports artifacts with their IDs only.
47
+ */
48
+ ArtifactLink: ((target: ExportArtifactLinkTarget) => string | null) | null;
44
49
  Cancelled: EventEmitter<void>;
45
50
  /**
46
51
  * @deprecated Use {@link Cancelled}.
@@ -133,6 +138,6 @@ export declare class ExportModalComponent {
133
138
  onCancel(): void;
134
139
  private resetForm;
135
140
  static ɵfac: i0.ɵɵFactoryDeclaration<ExportModalComponent, never>;
136
- static ɵcmp: i0.ɵɵComponentDeclaration<ExportModalComponent, "mj-export-modal", never, { "IsVisible": { "alias": "IsVisible"; "required": false; }; "isVisible": { "alias": "isVisible"; "required": false; }; "Conversation": { "alias": "Conversation"; "required": false; }; "conversation": { "alias": "conversation"; "required": false; }; "CurrentUser": { "alias": "CurrentUser"; "required": false; }; "currentUser": { "alias": "currentUser"; "required": false; }; "Branding": { "alias": "Branding"; "required": false; }; "branding": { "alias": "branding"; "required": false; }; "Scope": { "alias": "Scope"; "required": false; }; }, { "Cancelled": "Cancelled"; "cancelled": "cancelled"; "Exported": "Exported"; "exported": "exported"; }, never, never, false, never>;
141
+ static ɵcmp: i0.ɵɵComponentDeclaration<ExportModalComponent, "mj-export-modal", never, { "IsVisible": { "alias": "IsVisible"; "required": false; }; "isVisible": { "alias": "isVisible"; "required": false; }; "Conversation": { "alias": "Conversation"; "required": false; }; "conversation": { "alias": "conversation"; "required": false; }; "CurrentUser": { "alias": "CurrentUser"; "required": false; }; "currentUser": { "alias": "currentUser"; "required": false; }; "Branding": { "alias": "Branding"; "required": false; }; "branding": { "alias": "branding"; "required": false; }; "Scope": { "alias": "Scope"; "required": false; }; "ArtifactLink": { "alias": "ArtifactLink"; "required": false; }; }, { "Cancelled": "Cancelled"; "cancelled": "cancelled"; "Exported": "Exported"; "exported": "exported"; }, never, never, false, never>;
137
142
  }
138
143
  //# sourceMappingURL=export-modal.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"export-modal.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/export/export-modal.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAiB,MAAM,eAAe,CAAC;AACvE,OAAO,EAAsB,oBAAoB,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,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C,QAAQ,IAAI,IAAI;IAIhB,OAAO,CAAC,SAAS;yCAhTN,oBAAoB;2CAApB,oBAAoB;CA6ThC"}
1
+ {"version":3,"file":"export-modal.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/export/export-modal.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAiB,MAAM,eAAe,CAAC;AACvE,OAAO,EAAsB,oBAAoB,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACrI,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;;AAE5D,qBA6Ua,oBAAoB;IAqP7B,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,YAAY;IAtPtB,OAAO,CAAC,UAAU,CAAS;IAC3B,IACI,SAAS,CAAC,KAAK,EAAE,OAAO,EAY3B;IACD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,yCAAyC;IACzC,IAAI,SAAS,IAAI,OAAO,CAEvB;IACD,yCAAyC;IACzC,IAAa,SAAS,CAAC,KAAK,EAAE,OAAO,EAEpC;IAEQ,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAE7C,4CAA4C;IAC5C,IAAa,YAAY,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,EAEhE;IACD,4CAA4C;IAC5C,IAAI,YAAY,IAAI,oBAAoB,GAAG,SAAS,CAEnD;IACQ,WAAW,EAAG,QAAQ,CAAC;IAEhC,2CAA2C;IAC3C,IAAa,WAAW,CAAC,KAAK,EAAE,QAAQ,EAEvC;IACD,2CAA2C;IAC3C,IAAI,WAAW,IAAI,QAAQ,CAE1B;IAC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ExB;IAED,2CAA2C;IAC3C,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,SAAS,IAAI,OAAO,CAOvB;IAED,yCAAyC;IACzC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,OAAO;eAEkB,YAAY;;;;QAuBnC;IAEF,uCAAuC;IACvC,IAAI,OAAO;eA1Bc,YAAY;;;;QA4BpC;IACD,uCAAuC;IACvC,IAAI,OAAO,CAAC,KAAK;eA9BQ,YAAY;;;;OA8BpB,EAEhB;gBAGS,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY;IAGpC,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAMxC,4CAA4C;IAC5C,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIlC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAsC/B,wCAAwC;IAClC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,QAAQ,IAAI,IAAI;IAKhB,wCAAwC;IACxC,QAAQ,IAAI,IAAI;IAIhB,OAAO,CAAC,SAAS;yCA1TN,oBAAoB;2CAApB,oBAAoB;CAuUhC"}
@@ -284,6 +284,11 @@ export class ExportModalComponent {
284
284
  * exports Main.
285
285
  */
286
286
  Scope = null;
287
+ /**
288
+ * Builds a link that opens an exported artifact in the app (this package has no router, so
289
+ * the host supplies it). Null exports artifacts with their IDs only.
290
+ */
291
+ ArtifactLink = null;
287
292
  Cancelled = new EventEmitter();
288
293
  /**
289
294
  * @deprecated Use {@link Cancelled}.
@@ -377,7 +382,8 @@ export class ExportModalComponent {
377
382
  return {
378
383
  ...this.ExportOptions,
379
384
  includeTheme: brandingOn,
380
- branding: brandingOn ? (this.Branding ?? undefined) : undefined
385
+ branding: brandingOn ? (this.Branding ?? undefined) : undefined,
386
+ artifactLink: this.ArtifactLink ?? undefined
381
387
  };
382
388
  }
383
389
  get ExportTitle() {
@@ -388,7 +394,10 @@ export class ExportModalComponent {
388
394
  return this.ExportTitle;
389
395
  }
390
396
  get CanExport() {
397
+ // Without a conversation OnExport has nothing to export, so the button is disabled
398
+ // rather than doing nothing when clicked.
391
399
  return !this.IsExporting &&
400
+ !!this.Conversation &&
392
401
  !!this.SelectedFormat &&
393
402
  (this.ExportOptions.includeMessages === true);
394
403
  }
@@ -499,7 +508,7 @@ export class ExportModalComponent {
499
508
  this.IsVisible = false;
500
509
  }
501
510
  static ɵfac = function ExportModalComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ExportModalComponent)(i0.ɵɵdirectiveInject(i1.ExportService), i0.ɵɵdirectiveInject(i2.DialogService), i0.ɵɵdirectiveInject(i3.ToastService)); };
502
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ExportModalComponent, selectors: [["mj-export-modal"]], inputs: { IsVisible: "IsVisible", isVisible: "isVisible", Conversation: "Conversation", conversation: "conversation", CurrentUser: "CurrentUser", currentUser: "currentUser", Branding: "Branding", branding: "branding", Scope: "Scope" }, outputs: { Cancelled: "Cancelled", cancelled: "cancelled", Exported: "Exported", exported: "exported" }, standalone: false, decls: 1, vars: 1, consts: [[3, "Title", "Width", "Height", "Visible"], [3, "Close", "Title", "Width", "Height", "Visible"], [1, "export-modal-content"], [1, "format-section"], [1, "section-title"], [1, "fa-solid", "fa-file-export"], [1, "section-description"], [1, "format-options"], [1, "format-option", 3, "selected"], [1, "options-section"], [1, "fa-solid", "fa-sliders"], [1, "option-checkboxes"], [1, "checkbox-label"], ["type", "checkbox", 3, "ngModelChange", "ngModel", "disabled"], [1, "format-specific-options"], [1, "error-message"], [1, "loading-indicator"], ["mjButton", "", 3, "click", "disabled"], [1, "fa-solid", "fa-times"], ["mjButton", "", "variant", "primary", 3, "click", "disabled"], [1, "fa-solid", "fa-download"], [1, "format-option", 3, "click"], [1, "format-details"], [1, "format-name"], [1, "format-description"], [1, "fa-solid", "fa-check-circle", "check-icon"], [1, "subsection-title"], [1, "mj-input", "theme-mode-select", 3, "ngModelChange", "ngModel", "disabled"], ["value", "light"], ["value", "dark"], [1, "fa-solid", "fa-exclamation-triangle"], ["text", "Exporting conversation...", "size", "small"]], template: function ExportModalComponent_Template(rf, ctx) { if (rf & 1) {
511
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ExportModalComponent, selectors: [["mj-export-modal"]], inputs: { IsVisible: "IsVisible", isVisible: "isVisible", Conversation: "Conversation", conversation: "conversation", CurrentUser: "CurrentUser", currentUser: "currentUser", Branding: "Branding", branding: "branding", Scope: "Scope", ArtifactLink: "ArtifactLink" }, outputs: { Cancelled: "Cancelled", cancelled: "cancelled", Exported: "Exported", exported: "exported" }, standalone: false, decls: 1, vars: 1, consts: [[3, "Title", "Width", "Height", "Visible"], [3, "Close", "Title", "Width", "Height", "Visible"], [1, "export-modal-content"], [1, "format-section"], [1, "section-title"], [1, "fa-solid", "fa-file-export"], [1, "section-description"], [1, "format-options"], [1, "format-option", 3, "selected"], [1, "options-section"], [1, "fa-solid", "fa-sliders"], [1, "option-checkboxes"], [1, "checkbox-label"], ["type", "checkbox", 3, "ngModelChange", "ngModel", "disabled"], [1, "format-specific-options"], [1, "error-message"], [1, "loading-indicator"], ["mjButton", "", 3, "click", "disabled"], [1, "fa-solid", "fa-times"], ["mjButton", "", "variant", "primary", 3, "click", "disabled"], [1, "fa-solid", "fa-download"], [1, "format-option", 3, "click"], [1, "format-details"], [1, "format-name"], [1, "format-description"], [1, "fa-solid", "fa-check-circle", "check-icon"], [1, "subsection-title"], [1, "mj-input", "theme-mode-select", 3, "ngModelChange", "ngModel", "disabled"], ["value", "light"], ["value", "dark"], [1, "fa-solid", "fa-exclamation-triangle"], ["text", "Exporting conversation...", "size", "small"]], template: function ExportModalComponent_Template(rf, ctx) { if (rf & 1) {
503
512
  i0.ɵɵconditionalCreate(0, ExportModalComponent_Conditional_0_Template, 40, 15, "mj-dialog", 0);
504
513
  } if (rf & 2) {
505
514
  i0.ɵɵconditional(ctx.isVisible ? 0 : -1);
@@ -665,6 +674,8 @@ export class ExportModalComponent {
665
674
  type: Input
666
675
  }], Scope: [{
667
676
  type: Input
677
+ }], ArtifactLink: [{
678
+ type: Input
668
679
  }], Cancelled: [{
669
680
  type: Output
670
681
  }], cancelled: [{
@@ -1 +1 @@
1
- {"version":3,"file":"export-modal.component.js","sourceRoot":"","sources":["../../../../src/lib/components/export/export-modal.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAgD,MAAM,+BAA+B,CAAC;AAEjH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;;;;;;;;;;IAqChC,wBAAmD;;;;IAVvD,+BAGuC;IAArC,yNAAS,oCAA0B,KAAC;IACpC,oBAA6B;IAE3B,AADF,+BAA4B,cACD;IAAA,YAAiB;IAAA,iBAAM;IAChD,+BAAgC;IAAA,YAAwB;IAC1D,AAD0D,iBAAM,EAC1D;IACN,0GAAuC;IAGzC,iBAAM;;;;IAVJ,qEAAkD;IAE/C,cAAqB;IAArB,6BAAqB;IAEG,eAAiB;IAAjB,oCAAiB;IACV,eAAwB;IAAxB,2CAAwB;IAE1D,cAEC;IAFD,oEAEC;;;;IAiCD,AADF,iCAA8B,gBAI2D;IADrF,gWAAwC;IAF1C,iBAGuF;IACvF,4BAAM;IAAA,gCAAgB;IAAA,iBAAO;IAC7B,6BAAO;IAAA,YAAkB;IAC3B,AAD2B,iBAAQ,EAC3B;;;IAJJ,cAAwC;IAAxC,iEAAwC;IACxC,qHAAoF;IAE/E,eAAkB;IAAlB,yCAAkB;;;;IAM3B,AADF,+BAAqC,aACN;IAAA,4BAAY;IAAA,iBAAK;IAE5C,AADF,iCAA8B,gBAID;IADzB,8VAAuC;IAFzC,iBAG2B;IAC3B,4BAAM;IAAA,4BAAY;IAAA,iBAAO;IACzB,6BAAO;IAAA,4CAA4B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IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,wCAAwC;IACxC,QAAQ;QACN,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG;YACnB,eAAe,EAAE,IAAI;YACrB,eAAe,EAAE,IAAI;YACrB,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;YAC7B,SAAS,EAAE,OAAO;SACnB,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;8GA5TU,oBAAoB;6DAApB,oBAAoB;YAzU7B,8FAAiB;;YAAjB,wCAyIC;;;iFAgMQ,oBAAoB;cA7UhC,SAAS;6BACI,KAAK,YACP,iBAAiB,YACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2IP;;kBAiMF,KAAK;;kBAuBL,KAAK;;kBAIL,KAAK;;kBAGL,KAAK;;kBAOL,KAAK;;kBAGL,KAAK;;kBAYL,KAAK;;kBAGL,KAAK;;kBAYL,KAAK;;kBACL,MAAM;;kBASN,MAAM;;kBACN,MAAM;;kBASN,MAAM;;kFAzFI,oBAAoB","sourcesContent":["import { Component, EventEmitter, Input, Output } from '@angular/core';\nimport { ConversationEngine, MJConversationEntity, type ConversationScope } from '@memberjunction/core-entities';\nimport { UserInfo } from '@memberjunction/core';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { ExportService, ExportFormat, ExportOptions, ExportBranding } from '../../services/export.service';\nimport { DialogService } from '../../services/dialog.service';\nimport { ToastService } from '../../services/toast.service';\n\n@Component({\n standalone: false,\n selector: 'mj-export-modal',\n template: `\n @if (isVisible) {\n <mj-dialog\n [Title]=\"exportTitle\"\n [Width]=\"600\"\n [Height]=\"600\"\n [Visible]=\"true\"\n (Close)=\"onCancel()\">\n <div class=\"export-modal-content\">\n <section class=\"format-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-file-export\"></i>\n Export Format\n </h3>\n <p class=\"section-description\">\n Choose a format to export this conversation:\n </p>\n <div class=\"format-options\">\n @for (format of formats; track format.value) {\n <div\n class=\"format-option\"\n [class.selected]=\"selectedFormat === format.value\"\n (click)=\"selectFormat(format.value)\">\n <i [class]=\"format.icon\"></i>\n <div class=\"format-details\">\n <div class=\"format-name\">{{ format.name }}</div>\n <div class=\"format-description\">{{ format.description }}</div>\n </div>\n @if (selectedFormat === format.value) {\n <i class=\"fa-solid fa-check-circle check-icon\"></i>\n }\n </div>\n }\n </div>\n </section>\n <section class=\"options-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-sliders\"></i>\n Export Options\n </h3>\n <div class=\"option-checkboxes\">\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeMessages\"\n [disabled]=\"isExporting\">\n <span>Include messages</span>\n <small>Export all conversation messages</small>\n </label>\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeMetadata\"\n [disabled]=\"isExporting\">\n <span>Include metadata</span>\n <small>Add creation date, IDs, and other metadata</small>\n </label>\n <!-- Branding applies to EVERY format (HTML gets theme colors + logo +\n footer; markdown/text/JSON get the title and attribution), so it\n belongs here rather than under HTML Options. Shown for HTML even with\n no host branding, because it still snapshots the app's theme. -->\n @if (selectedFormat === 'html' || branding) {\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeTheme\"\n [disabled]=\"isExporting || (selectedFormat === 'html' && !exportOptions.includeCSS)\">\n <span>Include branding</span>\n <small>{{ brandingHint }}</small>\n </label>\n }\n </div>\n @if (selectedFormat === 'json') {\n <div class=\"format-specific-options\">\n <h4 class=\"subsection-title\">JSON Options</h4>\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.prettyPrint\"\n [disabled]=\"isExporting\">\n <span>Pretty print</span>\n <small>Format JSON with indentation</small>\n </label>\n </div>\n }\n @if (selectedFormat === 'html') {\n <div class=\"format-specific-options\">\n <h4 class=\"subsection-title\">HTML Options</h4>\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeCSS\"\n [disabled]=\"isExporting\">\n <span>Include CSS styling</span>\n <small>Embed styles for better presentation</small>\n </label>\n <!-- Which palette gets baked in — NOT the mode the app happens to be in.\n Exporting from a dark session would otherwise put dark text on the\n export's white page. -->\n @if (exportOptions.includeTheme && exportOptions.includeCSS) {\n <label class=\"checkbox-label\">\n <span>Theme</span>\n <select\n class=\"mj-input theme-mode-select\"\n [(ngModel)]=\"exportOptions.themeMode\"\n [disabled]=\"isExporting\">\n <option value=\"light\">Light</option>\n <option value=\"dark\">Dark</option>\n </select>\n <small>Palette baked into the exported file</small>\n </label>\n }\n </div>\n }\n </section>\n @if (errorMessage) {\n <div class=\"error-message\">\n <i class=\"fa-solid fa-exclamation-triangle\"></i>\n {{ errorMessage }}\n </div>\n }\n @if (isExporting) {\n <div class=\"loading-indicator\">\n <mj-loading text=\"Exporting conversation...\" size=\"small\"></mj-loading>\n </div>\n }\n </div>\n <mj-dialog-actions>\n <button mjButton [disabled]=\"isExporting\" (click)=\"onCancel()\">\n <i class=\"fa-solid fa-times\"></i>\n Cancel\n </button>\n <button mjButton variant=\"primary\" [disabled]=\"!canExport\" (click)=\"onExport()\">\n <i class=\"fa-solid fa-download\"></i>\n Export\n </button>\n </mj-dialog-actions>\n </mj-dialog>\n }\n `,\n styles: [`\n .export-modal-content {\n padding: 20px;\n max-height: calc(600px - 120px);\n overflow-y: auto;\n }\n\n section {\n margin-bottom: 24px;\n }\n\n .section-title {\n display: flex;\n align-items: center;\n gap: 8px;\n margin: 0 0 8px 0;\n font-size: 16px;\n font-weight: 600;\n color: var(--mj-text-primary);\n }\n\n .section-title i {\n color: var(--mj-brand-primary);\n }\n\n .section-description {\n margin: 0 0 16px 0;\n color: var(--mj-text-muted);\n font-size: 14px;\n }\n\n .format-options {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .format-option {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px;\n border: 2px solid var(--mj-border-strong);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.2s;\n background: var(--mj-bg-surface-card);\n }\n\n .format-option:hover {\n border-color: var(--mj-brand-primary);\n background: var(--mj-bg-surface-sunken);\n }\n\n .format-option.selected {\n border-color: var(--mj-brand-primary);\n background: color-mix(in srgb, var(--mj-brand-primary) 20%, var(--mj-bg-surface-card));\n }\n\n .format-option > i.fa-solid,\n .format-option > i.fas {\n font-size: 24px;\n color: var(--mj-text-muted);\n width: 32px;\n text-align: center;\n }\n\n .format-option.selected > i.fa-solid,\n .format-option.selected > i.fas {\n color: var(--mj-brand-primary);\n }\n\n .format-details {\n flex: 1;\n }\n\n .format-name {\n font-weight: 500;\n font-size: 14px;\n margin-bottom: 2px;\n }\n\n .format-description {\n font-size: 12px;\n color: var(--mj-text-muted);\n }\n\n .check-icon {\n font-size: 20px;\n color: var(--mj-status-success);\n }\n\n .option-checkboxes {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .checkbox-label {\n display: flex;\n flex-direction: column;\n gap: 4px;\n cursor: pointer;\n padding: 8px;\n border-radius: 4px;\n transition: background 0.2s;\n }\n\n .checkbox-label:hover {\n background: var(--mj-bg-surface-sunken);\n }\n\n .checkbox-label input[type=\"checkbox\"] {\n margin-right: 8px;\n cursor: pointer;\n }\n\n .checkbox-label > span {\n display: inline-flex;\n align-items: center;\n font-size: 14px;\n font-weight: 500;\n }\n\n .checkbox-label input[type=\"checkbox\"]:disabled {\n cursor: not-allowed;\n }\n\n .theme-mode-select {\n margin-left: 8px;\n padding: 2px 6px;\n font-size: 13px;\n }\n\n .checkbox-label small {\n margin-left: 28px;\n font-size: 12px;\n color: var(--mj-text-muted);\n }\n\n .format-specific-options {\n margin-top: 16px;\n padding-top: 16px;\n border-top: 1px solid var(--mj-border-default);\n }\n\n .subsection-title {\n margin: 0 0 12px 0;\n font-size: 14px;\n font-weight: 600;\n color: var(--mj-text-secondary);\n }\n\n .error-message {\n display: flex;\n align-items: center;\n gap: 8px;\n color: var(--mj-status-error);\n font-size: 13px;\n margin-top: 15px;\n padding: 10px 12px;\n background: color-mix(in srgb, var(--mj-status-error) 15%, var(--mj-bg-surface));\n border-left: 3px solid var(--mj-status-error);\n border-radius: 4px;\n }\n\n .loading-indicator {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-top: 15px;\n padding: 12px;\n background: var(--mj-bg-surface-sunken);\n border-radius: 4px;\n color: var(--mj-text-muted);\n }\n\n mj-dialog-actions {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n padding: 15px 20px;\n border-top: 1px solid var(--mj-border-default);\n }\n\n mj-dialog-actions button i {\n margin-right: 6px;\n }\n `]\n})\nexport class ExportModalComponent {\n private _isVisible = false;\n @Input()\n set IsVisible(value: boolean) {\n const opening = value && !this._isVisible;\n this._isVisible = value;\n if (opening) {\n // Fresh open: \"Include branding\" defaults ON only when the host explicitly\n // configured export branding — plain MJ Explorer keeps today's unthemed file.\n // NOTE this reads `branding`, so a host binding both in one change-detection\n // pass must bind [branding] FIRST (Angular sets inputs in template order).\n // chat-area's template does; a host mounting with isVisible already true and\n // branding bound after would get the checkbox defaulted off.\n this.ExportOptions.includeTheme = !!this.Branding;\n }\n }\n get IsVisible(): boolean {\n return this._isVisible;\n }\n\n /** @deprecated Use {@link IsVisible}. */\n get isVisible(): boolean {\n return this.IsVisible;\n }\n /** @deprecated Use {@link IsVisible}. */\n @Input() set isVisible(value: boolean) {\n this.IsVisible = value;\n }\n\n @Input() Conversation?: MJConversationEntity;\n\n /** @deprecated Use {@link Conversation}. */\n @Input() set conversation(value: MJConversationEntity | undefined) {\n this.Conversation = value;\n }\n /** @deprecated Use {@link Conversation}. */\n get conversation(): MJConversationEntity | undefined {\n return this.Conversation;\n }\n @Input() CurrentUser!: UserInfo;\n\n /** @deprecated Use {@link CurrentUser}. */\n @Input() set currentUser(value: UserInfo) {\n this.CurrentUser = value;\n }\n /** @deprecated Use {@link CurrentUser}. */\n get currentUser(): UserInfo {\n return this.CurrentUser;\n }\n /**\n * Host-supplied export branding (theme tokens / logo / title). When set, the\n * HTML format's \"Include branding\" checkbox defaults on and the branding is\n * passed to {@link ExportService} on export. See `ExportBranding`.\n */\n @Input() Branding: ExportBranding | null = null;\n\n /** @deprecated Use {@link Branding}. */\n @Input() set branding(value: ExportBranding | null) {\n this.Branding = value;\n }\n /** @deprecated Use {@link Branding}. */\n get branding(): ExportBranding | null {\n return this.Branding;\n }\n\n /**\n * The scope to export: the view the person has open. Null, or a scope of another conversation,\n * exports Main.\n */\n @Input() Scope: ConversationScope | null = null;\n @Output() Cancelled = new EventEmitter<void>();\n\n /**\n * @deprecated Use {@link Cancelled}.\n *\n * The same emitter under the old binding name, so a template still binding\n * (cancelled) keeps working. Must stay AFTER Cancelled: class fields\n * initialise in order, and the other way round this captures undefined.\n */\n @Output() cancelled = this.Cancelled;\n @Output() Exported = new EventEmitter<void>();\n\n /**\n * @deprecated Use {@link Exported}.\n *\n * The same emitter under the old binding name, so a template still binding\n * (exported) keeps working. Must stay AFTER Exported: class fields\n * initialise in order, and the other way round this captures undefined.\n */\n @Output() exported = this.Exported;\n\n SelectedFormat: ExportFormat | null = 'markdown';\n\n /** @deprecated Use {@link SelectedFormat}. */\n get selectedFormat(): ExportFormat | null {\n return this.SelectedFormat;\n }\n /** @deprecated Use {@link SelectedFormat}. */\n set selectedFormat(value: ExportFormat | null) {\n this.SelectedFormat = value;\n }\n IsExporting = false;\n\n /** @deprecated Use {@link IsExporting}. */\n get isExporting() {\n return this.IsExporting;\n }\n /** @deprecated Use {@link IsExporting}. */\n set isExporting(value) {\n this.IsExporting = value;\n }\n ErrorMessage = '';\n\n /** @deprecated Use {@link ErrorMessage}. */\n get errorMessage() {\n return this.ErrorMessage;\n }\n /** @deprecated Use {@link ErrorMessage}. */\n set errorMessage(value) {\n this.ErrorMessage = value;\n }\n\n ExportOptions: ExportOptions = {\n includeMessages: true,\n includeMetadata: true,\n prettyPrint: true,\n includeCSS: true,\n includeTheme: false,\n themeMode: 'light'\n };\n\n /** @deprecated Use {@link ExportOptions}. */\n get exportOptions(): ExportOptions {\n return this.ExportOptions;\n }\n /** @deprecated Use {@link ExportOptions}. */\n set exportOptions(value: ExportOptions) {\n this.ExportOptions = value;\n }\n\n /** Format-aware hint under the \"Include branding\" checkbox. */\n get BrandingHint(): string {\n if (this.SelectedFormat === 'html') {\n if (!this.ExportOptions.includeCSS) {\n return 'Requires \"Include CSS styling\"';\n }\n return `Embed the app's theme colors${this.Branding?.logoUrl ? ', logo,' : ''} and attribution line`;\n }\n const logo = this.Branding?.logoUrl && this.SelectedFormat === 'markdown' ? ', logo,' : '';\n return `Add the title${logo} and attribution line`;\n }\n\n /** @deprecated Use {@link BrandingHint}. */\n get brandingHint(): string {\n return this.BrandingHint;\n }\n\n /**\n * The options actually handed to the service. `includeTheme` is the user's INTENT;\n * this resolves it against the selected format:\n *\n * - HTML with the stylesheet off cannot carry branding (a full-size unstyled logo and\n * an unstyled footer would leak), so it drops.\n * - `includeCSS` is an HTML-only concern and must NOT decide anything for\n * markdown / text / JSON — resolving here rather than mutating `includeTheme` is\n * what keeps an HTML-format toggle from silently following the user into another\n * format.\n */\n private resolveExportOptions(): ExportOptions {\n const unstyledHtml = this.SelectedFormat === 'html' && !this.ExportOptions.includeCSS;\n const brandingOn = !!this.ExportOptions.includeTheme && !unstyledHtml;\n return {\n ...this.ExportOptions,\n includeTheme: brandingOn,\n branding: brandingOn ? (this.Branding ?? undefined) : undefined\n };\n }\n\n get ExportTitle(): string {\n return `Export: ${this.Conversation?.Name || 'Conversation'}`;\n }\n\n /** @deprecated Use {@link ExportTitle}. */\n get exportTitle(): string {\n return this.ExportTitle;\n }\n\n get CanExport(): boolean {\n return !this.IsExporting &&\n !!this.SelectedFormat &&\n (this.ExportOptions.includeMessages === true);\n }\n\n /** @deprecated Use {@link CanExport}. */\n get canExport(): boolean {\n return this.CanExport;\n }\n\n Formats = [\n {\n value: 'markdown' as ExportFormat,\n name: 'Markdown',\n description: 'Formatted text with markdown syntax',\n icon: 'fa-solid fa-file-alt'\n },\n {\n value: 'json' as ExportFormat,\n name: 'JSON',\n description: 'Structured data format',\n icon: 'fa-solid fa-code'\n },\n {\n value: 'html' as ExportFormat,\n name: 'HTML',\n description: 'Web page format',\n icon: 'fa-solid fa-file-code'\n },\n {\n value: 'text' as ExportFormat,\n name: 'Plain Text',\n description: 'Simple text file',\n icon: 'fa-solid fa-file'\n }\n ];\n\n /** @deprecated Use {@link Formats}. */\n get formats() {\n return this.Formats;\n }\n /** @deprecated Use {@link Formats}. */\n set formats(value) {\n this.Formats = value;\n }\n\n constructor(\n private exportService: ExportService,\n private dialogService: DialogService,\n private toastService: ToastService\n ) {}\n\n SelectFormat(format: ExportFormat): void {\n if (!this.IsExporting) {\n this.SelectedFormat = format;\n }\n }\n\n /** @deprecated Use {@link SelectFormat}. */\n selectFormat(format: ExportFormat): void {\n return this.SelectFormat(format);\n }\n\n async OnExport(): Promise<void> {\n if (!this.CanExport || !this.Conversation) {\n return;\n }\n\n if (!this.ExportOptions.includeMessages) {\n this.ErrorMessage = 'At least \"Include messages\" must be selected';\n return;\n }\n\n this.IsExporting = true;\n this.ErrorMessage = '';\n const conversationId = this.Conversation.ID;\n\n try {\n const scope = this.Scope && UUIDsEqual(this.Scope.ConversationID, conversationId)\n ? this.Scope\n : ConversationEngine.TrunkScope(conversationId);\n await this.exportService.ExportConversation(\n conversationId,\n scope,\n this.SelectedFormat!,\n this.CurrentUser,\n this.resolveExportOptions()\n );\n\n this.toastService.success('Conversation exported successfully');\n this.Exported.emit();\n this.resetForm();\n } catch (error) {\n console.error('Error exporting conversation:', error);\n this.ErrorMessage = error instanceof Error ? error.message : 'Failed to export conversation';\n this.toastService.error(this.ErrorMessage);\n } finally {\n this.IsExporting = false;\n }\n }\n\n /** @deprecated Use {@link OnExport}. */\n async onExport(): Promise<void> {\n return this.OnExport();\n }\n\n OnCancel(): void {\n this.Cancelled.emit();\n this.resetForm();\n }\n\n /** @deprecated Use {@link OnCancel}. */\n onCancel(): void {\n return this.OnCancel();\n }\n\n private resetForm(): void {\n this.SelectedFormat = 'markdown';\n this.ErrorMessage = '';\n this.ExportOptions = {\n includeMessages: true,\n includeMetadata: true,\n prettyPrint: true,\n includeCSS: true,\n includeTheme: !!this.Branding,\n themeMode: 'light'\n };\n this.IsVisible = false;\n }\n}\n"]}
1
+ {"version":3,"file":"export-modal.component.js","sourceRoot":"","sources":["../../../../src/lib/components/export/export-modal.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAgD,MAAM,+BAA+B,CAAC;AAEjH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;;;;;;;;;;IAqChC,wBAAmD;;;;IAVvD,+BAGuC;IAArC,yNAAS,oCAA0B,KAAC;IACpC,oBAA6B;IAE3B,AADF,+BAA4B,cACD;IAAA,YAAiB;IAAA,iBAAM;IAChD,+BAAgC;IAAA,YAAwB;IAC1D,AAD0D,iBAAM,EAC1D;IACN,0GAAuC;IAGzC,iBAAM;;;;IAVJ,qEAAkD;IAE/C,cAAqB;IAArB,6BAAqB;IAEG,eAAiB;IAAjB,oCAAiB;IACV,eAAwB;IAAxB,2CAAwB;IAE1D,cAEC;IAFD,oEAEC;;;;IAiCD,AADF,iCAA8B,gBAI2D;IADrF,g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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2IP;;kBAiMF,KAAK;;kBAuBL,KAAK;;kBAIL,KAAK;;kBAGL,KAAK;;kBAOL,KAAK;;kBAGL,KAAK;;kBAYL,KAAK;;kBAGL,KAAK;;kBAYL,KAAK;;kBAML,KAAK;;kBACL,MAAM;;kBASN,MAAM;;kBACN,MAAM;;kBASN,MAAM;;kFA/FI,oBAAoB","sourcesContent":["import { Component, EventEmitter, Input, Output } from '@angular/core';\nimport { ConversationEngine, MJConversationEntity, type ConversationScope } from '@memberjunction/core-entities';\nimport { UserInfo } from '@memberjunction/core';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { ExportService, ExportFormat, ExportOptions, ExportBranding, ExportArtifactLinkTarget } from '../../services/export.service';\nimport { DialogService } from '../../services/dialog.service';\nimport { ToastService } from '../../services/toast.service';\n\n@Component({\n standalone: false,\n selector: 'mj-export-modal',\n template: `\n @if (isVisible) {\n <mj-dialog\n [Title]=\"exportTitle\"\n [Width]=\"600\"\n [Height]=\"600\"\n [Visible]=\"true\"\n (Close)=\"onCancel()\">\n <div class=\"export-modal-content\">\n <section class=\"format-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-file-export\"></i>\n Export Format\n </h3>\n <p class=\"section-description\">\n Choose a format to export this conversation:\n </p>\n <div class=\"format-options\">\n @for (format of formats; track format.value) {\n <div\n class=\"format-option\"\n [class.selected]=\"selectedFormat === format.value\"\n (click)=\"selectFormat(format.value)\">\n <i [class]=\"format.icon\"></i>\n <div class=\"format-details\">\n <div class=\"format-name\">{{ format.name }}</div>\n <div class=\"format-description\">{{ format.description }}</div>\n </div>\n @if (selectedFormat === format.value) {\n <i class=\"fa-solid fa-check-circle check-icon\"></i>\n }\n </div>\n }\n </div>\n </section>\n <section class=\"options-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-sliders\"></i>\n Export Options\n </h3>\n <div class=\"option-checkboxes\">\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeMessages\"\n [disabled]=\"isExporting\">\n <span>Include messages</span>\n <small>Export all conversation messages</small>\n </label>\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeMetadata\"\n [disabled]=\"isExporting\">\n <span>Include metadata</span>\n <small>Add creation date, IDs, and other metadata</small>\n </label>\n <!-- Branding applies to EVERY format (HTML gets theme colors + logo +\n footer; markdown/text/JSON get the title and attribution), so it\n belongs here rather than under HTML Options. Shown for HTML even with\n no host branding, because it still snapshots the app's theme. -->\n @if (selectedFormat === 'html' || branding) {\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeTheme\"\n [disabled]=\"isExporting || (selectedFormat === 'html' && !exportOptions.includeCSS)\">\n <span>Include branding</span>\n <small>{{ brandingHint }}</small>\n </label>\n }\n </div>\n @if (selectedFormat === 'json') {\n <div class=\"format-specific-options\">\n <h4 class=\"subsection-title\">JSON Options</h4>\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.prettyPrint\"\n [disabled]=\"isExporting\">\n <span>Pretty print</span>\n <small>Format JSON with indentation</small>\n </label>\n </div>\n }\n @if (selectedFormat === 'html') {\n <div class=\"format-specific-options\">\n <h4 class=\"subsection-title\">HTML Options</h4>\n <label class=\"checkbox-label\">\n <input\n type=\"checkbox\"\n [(ngModel)]=\"exportOptions.includeCSS\"\n [disabled]=\"isExporting\">\n <span>Include CSS styling</span>\n <small>Embed styles for better presentation</small>\n </label>\n <!-- Which palette gets baked in — NOT the mode the app happens to be in.\n Exporting from a dark session would otherwise put dark text on the\n export's white page. -->\n @if (exportOptions.includeTheme && exportOptions.includeCSS) {\n <label class=\"checkbox-label\">\n <span>Theme</span>\n <select\n class=\"mj-input theme-mode-select\"\n [(ngModel)]=\"exportOptions.themeMode\"\n [disabled]=\"isExporting\">\n <option value=\"light\">Light</option>\n <option value=\"dark\">Dark</option>\n </select>\n <small>Palette baked into the exported file</small>\n </label>\n }\n </div>\n }\n </section>\n @if (errorMessage) {\n <div class=\"error-message\">\n <i class=\"fa-solid fa-exclamation-triangle\"></i>\n {{ errorMessage }}\n </div>\n }\n @if (isExporting) {\n <div class=\"loading-indicator\">\n <mj-loading text=\"Exporting conversation...\" size=\"small\"></mj-loading>\n </div>\n }\n </div>\n <mj-dialog-actions>\n <button mjButton [disabled]=\"isExporting\" (click)=\"onCancel()\">\n <i class=\"fa-solid fa-times\"></i>\n Cancel\n </button>\n <button mjButton variant=\"primary\" [disabled]=\"!canExport\" (click)=\"onExport()\">\n <i class=\"fa-solid fa-download\"></i>\n Export\n </button>\n </mj-dialog-actions>\n </mj-dialog>\n }\n `,\n styles: [`\n .export-modal-content {\n padding: 20px;\n max-height: calc(600px - 120px);\n overflow-y: auto;\n }\n\n section {\n margin-bottom: 24px;\n }\n\n .section-title {\n display: flex;\n align-items: center;\n gap: 8px;\n margin: 0 0 8px 0;\n font-size: 16px;\n font-weight: 600;\n color: var(--mj-text-primary);\n }\n\n .section-title i {\n color: var(--mj-brand-primary);\n }\n\n .section-description {\n margin: 0 0 16px 0;\n color: var(--mj-text-muted);\n font-size: 14px;\n }\n\n .format-options {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .format-option {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px;\n border: 2px solid var(--mj-border-strong);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.2s;\n background: var(--mj-bg-surface-card);\n }\n\n .format-option:hover {\n border-color: var(--mj-brand-primary);\n background: var(--mj-bg-surface-sunken);\n }\n\n .format-option.selected {\n border-color: var(--mj-brand-primary);\n background: color-mix(in srgb, var(--mj-brand-primary) 20%, var(--mj-bg-surface-card));\n }\n\n .format-option > i.fa-solid,\n .format-option > i.fas {\n font-size: 24px;\n color: var(--mj-text-muted);\n width: 32px;\n text-align: center;\n }\n\n .format-option.selected > i.fa-solid,\n .format-option.selected > i.fas {\n color: var(--mj-brand-primary);\n }\n\n .format-details {\n flex: 1;\n }\n\n .format-name {\n font-weight: 500;\n font-size: 14px;\n margin-bottom: 2px;\n }\n\n .format-description {\n font-size: 12px;\n color: var(--mj-text-muted);\n }\n\n .check-icon {\n font-size: 20px;\n color: var(--mj-status-success);\n }\n\n .option-checkboxes {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .checkbox-label {\n display: flex;\n flex-direction: column;\n gap: 4px;\n cursor: pointer;\n padding: 8px;\n border-radius: 4px;\n transition: background 0.2s;\n }\n\n .checkbox-label:hover {\n background: var(--mj-bg-surface-sunken);\n }\n\n .checkbox-label input[type=\"checkbox\"] {\n margin-right: 8px;\n cursor: pointer;\n }\n\n .checkbox-label > span {\n display: inline-flex;\n align-items: center;\n font-size: 14px;\n font-weight: 500;\n }\n\n .checkbox-label input[type=\"checkbox\"]:disabled {\n cursor: not-allowed;\n }\n\n .theme-mode-select {\n margin-left: 8px;\n padding: 2px 6px;\n font-size: 13px;\n }\n\n .checkbox-label small {\n margin-left: 28px;\n font-size: 12px;\n color: var(--mj-text-muted);\n }\n\n .format-specific-options {\n margin-top: 16px;\n padding-top: 16px;\n border-top: 1px solid var(--mj-border-default);\n }\n\n .subsection-title {\n margin: 0 0 12px 0;\n font-size: 14px;\n font-weight: 600;\n color: var(--mj-text-secondary);\n }\n\n .error-message {\n display: flex;\n align-items: center;\n gap: 8px;\n color: var(--mj-status-error);\n font-size: 13px;\n margin-top: 15px;\n padding: 10px 12px;\n background: color-mix(in srgb, var(--mj-status-error) 15%, var(--mj-bg-surface));\n border-left: 3px solid var(--mj-status-error);\n border-radius: 4px;\n }\n\n .loading-indicator {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-top: 15px;\n padding: 12px;\n background: var(--mj-bg-surface-sunken);\n border-radius: 4px;\n color: var(--mj-text-muted);\n }\n\n mj-dialog-actions {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n padding: 15px 20px;\n border-top: 1px solid var(--mj-border-default);\n }\n\n mj-dialog-actions button i {\n margin-right: 6px;\n }\n `]\n})\nexport class ExportModalComponent {\n private _isVisible = false;\n @Input()\n set IsVisible(value: boolean) {\n const opening = value && !this._isVisible;\n this._isVisible = value;\n if (opening) {\n // Fresh open: \"Include branding\" defaults ON only when the host explicitly\n // configured export branding — plain MJ Explorer keeps today's unthemed file.\n // NOTE this reads `branding`, so a host binding both in one change-detection\n // pass must bind [branding] FIRST (Angular sets inputs in template order).\n // chat-area's template does; a host mounting with isVisible already true and\n // branding bound after would get the checkbox defaulted off.\n this.ExportOptions.includeTheme = !!this.Branding;\n }\n }\n get IsVisible(): boolean {\n return this._isVisible;\n }\n\n /** @deprecated Use {@link IsVisible}. */\n get isVisible(): boolean {\n return this.IsVisible;\n }\n /** @deprecated Use {@link IsVisible}. */\n @Input() set isVisible(value: boolean) {\n this.IsVisible = value;\n }\n\n @Input() Conversation?: MJConversationEntity;\n\n /** @deprecated Use {@link Conversation}. */\n @Input() set conversation(value: MJConversationEntity | undefined) {\n this.Conversation = value;\n }\n /** @deprecated Use {@link Conversation}. */\n get conversation(): MJConversationEntity | undefined {\n return this.Conversation;\n }\n @Input() CurrentUser!: UserInfo;\n\n /** @deprecated Use {@link CurrentUser}. */\n @Input() set currentUser(value: UserInfo) {\n this.CurrentUser = value;\n }\n /** @deprecated Use {@link CurrentUser}. */\n get currentUser(): UserInfo {\n return this.CurrentUser;\n }\n /**\n * Host-supplied export branding (theme tokens / logo / title). When set, the\n * HTML format's \"Include branding\" checkbox defaults on and the branding is\n * passed to {@link ExportService} on export. See `ExportBranding`.\n */\n @Input() Branding: ExportBranding | null = null;\n\n /** @deprecated Use {@link Branding}. */\n @Input() set branding(value: ExportBranding | null) {\n this.Branding = value;\n }\n /** @deprecated Use {@link Branding}. */\n get branding(): ExportBranding | null {\n return this.Branding;\n }\n\n /**\n * The scope to export: the view the person has open. Null, or a scope of another conversation,\n * exports Main.\n */\n @Input() Scope: ConversationScope | null = null;\n\n /**\n * Builds a link that opens an exported artifact in the app (this package has no router, so\n * the host supplies it). Null exports artifacts with their IDs only.\n */\n @Input() ArtifactLink: ((target: ExportArtifactLinkTarget) => string | null) | null = null;\n @Output() Cancelled = new EventEmitter<void>();\n\n /**\n * @deprecated Use {@link Cancelled}.\n *\n * The same emitter under the old binding name, so a template still binding\n * (cancelled) keeps working. Must stay AFTER Cancelled: class fields\n * initialise in order, and the other way round this captures undefined.\n */\n @Output() cancelled = this.Cancelled;\n @Output() Exported = new EventEmitter<void>();\n\n /**\n * @deprecated Use {@link Exported}.\n *\n * The same emitter under the old binding name, so a template still binding\n * (exported) keeps working. Must stay AFTER Exported: class fields\n * initialise in order, and the other way round this captures undefined.\n */\n @Output() exported = this.Exported;\n\n SelectedFormat: ExportFormat | null = 'markdown';\n\n /** @deprecated Use {@link SelectedFormat}. */\n get selectedFormat(): ExportFormat | null {\n return this.SelectedFormat;\n }\n /** @deprecated Use {@link SelectedFormat}. */\n set selectedFormat(value: ExportFormat | null) {\n this.SelectedFormat = value;\n }\n IsExporting = false;\n\n /** @deprecated Use {@link IsExporting}. */\n get isExporting() {\n return this.IsExporting;\n }\n /** @deprecated Use {@link IsExporting}. */\n set isExporting(value) {\n this.IsExporting = value;\n }\n ErrorMessage = '';\n\n /** @deprecated Use {@link ErrorMessage}. */\n get errorMessage() {\n return this.ErrorMessage;\n }\n /** @deprecated Use {@link ErrorMessage}. */\n set errorMessage(value) {\n this.ErrorMessage = value;\n }\n\n ExportOptions: ExportOptions = {\n includeMessages: true,\n includeMetadata: true,\n prettyPrint: true,\n includeCSS: true,\n includeTheme: false,\n themeMode: 'light'\n };\n\n /** @deprecated Use {@link ExportOptions}. */\n get exportOptions(): ExportOptions {\n return this.ExportOptions;\n }\n /** @deprecated Use {@link ExportOptions}. */\n set exportOptions(value: ExportOptions) {\n this.ExportOptions = value;\n }\n\n /** Format-aware hint under the \"Include branding\" checkbox. */\n get BrandingHint(): string {\n if (this.SelectedFormat === 'html') {\n if (!this.ExportOptions.includeCSS) {\n return 'Requires \"Include CSS styling\"';\n }\n return `Embed the app's theme colors${this.Branding?.logoUrl ? ', logo,' : ''} and attribution line`;\n }\n const logo = this.Branding?.logoUrl && this.SelectedFormat === 'markdown' ? ', logo,' : '';\n return `Add the title${logo} and attribution line`;\n }\n\n /** @deprecated Use {@link BrandingHint}. */\n get brandingHint(): string {\n return this.BrandingHint;\n }\n\n /**\n * The options actually handed to the service. `includeTheme` is the user's INTENT;\n * this resolves it against the selected format:\n *\n * - HTML with the stylesheet off cannot carry branding (a full-size unstyled logo and\n * an unstyled footer would leak), so it drops.\n * - `includeCSS` is an HTML-only concern and must NOT decide anything for\n * markdown / text / JSON — resolving here rather than mutating `includeTheme` is\n * what keeps an HTML-format toggle from silently following the user into another\n * format.\n */\n private resolveExportOptions(): ExportOptions {\n const unstyledHtml = this.SelectedFormat === 'html' && !this.ExportOptions.includeCSS;\n const brandingOn = !!this.ExportOptions.includeTheme && !unstyledHtml;\n return {\n ...this.ExportOptions,\n includeTheme: brandingOn,\n branding: brandingOn ? (this.Branding ?? undefined) : undefined,\n artifactLink: this.ArtifactLink ?? undefined\n };\n }\n\n get ExportTitle(): string {\n return `Export: ${this.Conversation?.Name || 'Conversation'}`;\n }\n\n /** @deprecated Use {@link ExportTitle}. */\n get exportTitle(): string {\n return this.ExportTitle;\n }\n\n get CanExport(): boolean {\n // Without a conversation OnExport has nothing to export, so the button is disabled\n // rather than doing nothing when clicked.\n return !this.IsExporting &&\n !!this.Conversation &&\n !!this.SelectedFormat &&\n (this.ExportOptions.includeMessages === true);\n }\n\n /** @deprecated Use {@link CanExport}. */\n get canExport(): boolean {\n return this.CanExport;\n }\n\n Formats = [\n {\n value: 'markdown' as ExportFormat,\n name: 'Markdown',\n description: 'Formatted text with markdown syntax',\n icon: 'fa-solid fa-file-alt'\n },\n {\n value: 'json' as ExportFormat,\n name: 'JSON',\n description: 'Structured data format',\n icon: 'fa-solid fa-code'\n },\n {\n value: 'html' as ExportFormat,\n name: 'HTML',\n description: 'Web page format',\n icon: 'fa-solid fa-file-code'\n },\n {\n value: 'text' as ExportFormat,\n name: 'Plain Text',\n description: 'Simple text file',\n icon: 'fa-solid fa-file'\n }\n ];\n\n /** @deprecated Use {@link Formats}. */\n get formats() {\n return this.Formats;\n }\n /** @deprecated Use {@link Formats}. */\n set formats(value) {\n this.Formats = value;\n }\n\n constructor(\n private exportService: ExportService,\n private dialogService: DialogService,\n private toastService: ToastService\n ) {}\n\n SelectFormat(format: ExportFormat): void {\n if (!this.IsExporting) {\n this.SelectedFormat = format;\n }\n }\n\n /** @deprecated Use {@link SelectFormat}. */\n selectFormat(format: ExportFormat): void {\n return this.SelectFormat(format);\n }\n\n async OnExport(): Promise<void> {\n if (!this.CanExport || !this.Conversation) {\n return;\n }\n\n if (!this.ExportOptions.includeMessages) {\n this.ErrorMessage = 'At least \"Include messages\" must be selected';\n return;\n }\n\n this.IsExporting = true;\n this.ErrorMessage = '';\n const conversationId = this.Conversation.ID;\n\n try {\n const scope = this.Scope && UUIDsEqual(this.Scope.ConversationID, conversationId)\n ? this.Scope\n : ConversationEngine.TrunkScope(conversationId);\n await this.exportService.ExportConversation(\n conversationId,\n scope,\n this.SelectedFormat!,\n this.CurrentUser,\n this.resolveExportOptions()\n );\n\n this.toastService.success('Conversation exported successfully');\n this.Exported.emit();\n this.resetForm();\n } catch (error) {\n console.error('Error exporting conversation:', error);\n this.ErrorMessage = error instanceof Error ? error.message : 'Failed to export conversation';\n this.toastService.error(this.ErrorMessage);\n } finally {\n this.IsExporting = false;\n }\n }\n\n /** @deprecated Use {@link OnExport}. */\n async onExport(): Promise<void> {\n return this.OnExport();\n }\n\n OnCancel(): void {\n this.Cancelled.emit();\n this.resetForm();\n }\n\n /** @deprecated Use {@link OnCancel}. */\n onCancel(): void {\n return this.OnCancel();\n }\n\n private resetForm(): void {\n this.SelectedFormat = 'markdown';\n this.ErrorMessage = '';\n this.ExportOptions = {\n includeMessages: true,\n includeMetadata: true,\n prettyPrint: true,\n includeCSS: true,\n includeTheme: !!this.Branding,\n themeMode: 'light'\n };\n this.IsVisible = false;\n }\n}\n"]}