@dxos/plugin-thread 0.8.4-main.7ace549 → 0.8.4-main.937b3ca

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 (337) hide show
  1. package/dist/lib/browser/app-graph-builder-SPAZN5XL.mjs +188 -0
  2. package/dist/lib/browser/app-graph-builder-SPAZN5XL.mjs.map +7 -0
  3. package/dist/lib/browser/blueprint-definition-UQ63QKQG.mjs +17 -0
  4. package/dist/lib/browser/blueprint-definition-UQ63QKQG.mjs.map +7 -0
  5. package/dist/lib/browser/blueprints/index.mjs +8 -0
  6. package/dist/lib/browser/call-manager-YBRTG6T3.mjs +26 -0
  7. package/dist/lib/browser/call-manager-YBRTG6T3.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-KOBXMDCI.mjs → chunk-DLO2G3DM.mjs} +14 -12
  9. package/dist/lib/browser/chunk-DLO2G3DM.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-ZCW3NSDZ.mjs → chunk-ERK254BS.mjs} +68 -51
  11. package/dist/lib/browser/chunk-ERK254BS.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-TAWDJPMD.mjs +293 -0
  13. package/dist/lib/browser/chunk-TAWDJPMD.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-VZICDGBW.mjs +1813 -0
  15. package/dist/lib/browser/chunk-VZICDGBW.mjs.map +7 -0
  16. package/dist/lib/browser/{blueprint-definition-TQ4JFMZZ.mjs → chunk-ZFLSTQSE.mjs} +39 -34
  17. package/dist/lib/browser/chunk-ZFLSTQSE.mjs.map +7 -0
  18. package/dist/lib/browser/index.mjs +100 -90
  19. package/dist/lib/browser/index.mjs.map +4 -4
  20. package/dist/lib/browser/markdown-TSXOA3GV.mjs +210 -0
  21. package/dist/lib/browser/markdown-TSXOA3GV.mjs.map +7 -0
  22. package/dist/lib/browser/meta.json +1 -1
  23. package/dist/lib/browser/operation-resolver-MDMEBYH2.mjs +441 -0
  24. package/dist/lib/browser/operation-resolver-MDMEBYH2.mjs.map +7 -0
  25. package/dist/lib/browser/react-root-Q7U5D3DA.mjs +25 -0
  26. package/dist/lib/browser/react-root-Q7U5D3DA.mjs.map +7 -0
  27. package/dist/lib/browser/{react-surface-AUQQSQQC.mjs → react-surface-WDZQSDWH.mjs} +32 -33
  28. package/dist/lib/browser/react-surface-WDZQSDWH.mjs.map +7 -0
  29. package/dist/lib/browser/{repair-JFJLEM2O.mjs → repair-TDKAFAGH.mjs} +12 -9
  30. package/dist/lib/browser/repair-TDKAFAGH.mjs.map +7 -0
  31. package/dist/lib/browser/settings-OOKKVXV7.mjs +32 -0
  32. package/dist/lib/browser/settings-OOKKVXV7.mjs.map +7 -0
  33. package/dist/lib/browser/state-3LKZHDRI.mjs +24 -0
  34. package/dist/lib/browser/state-3LKZHDRI.mjs.map +7 -0
  35. package/dist/lib/browser/types/index.mjs +5 -4
  36. package/dist/lib/node-esm/app-graph-builder-3LJAPDUW.mjs +189 -0
  37. package/dist/lib/node-esm/app-graph-builder-3LJAPDUW.mjs.map +7 -0
  38. package/dist/lib/node-esm/blueprint-definition-MZZXXL37.mjs +18 -0
  39. package/dist/lib/node-esm/blueprint-definition-MZZXXL37.mjs.map +7 -0
  40. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  41. package/dist/lib/node-esm/call-manager-MMCTNFOH.mjs +27 -0
  42. package/dist/lib/node-esm/call-manager-MMCTNFOH.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-3RD3IVVD.mjs +1814 -0
  44. package/dist/lib/node-esm/chunk-3RD3IVVD.mjs.map +7 -0
  45. package/dist/lib/node-esm/{blueprint-definition-TSX5HHW7.mjs → chunk-AQHPP6ZX.mjs} +39 -34
  46. package/dist/lib/node-esm/chunk-AQHPP6ZX.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-ARTUUKTM.mjs +294 -0
  48. package/dist/lib/node-esm/chunk-ARTUUKTM.mjs.map +7 -0
  49. package/dist/lib/node-esm/{chunk-PZH2EDU5.mjs → chunk-KRBZBJRI.mjs} +14 -12
  50. package/dist/lib/node-esm/chunk-KRBZBJRI.mjs.map +7 -0
  51. package/dist/lib/node-esm/{chunk-7KZWZS2U.mjs → chunk-QP3KQOPQ.mjs} +68 -51
  52. package/dist/lib/node-esm/chunk-QP3KQOPQ.mjs.map +7 -0
  53. package/dist/lib/node-esm/index.mjs +100 -90
  54. package/dist/lib/node-esm/index.mjs.map +4 -4
  55. package/dist/lib/node-esm/markdown-N2UJ3D6L.mjs +211 -0
  56. package/dist/lib/node-esm/markdown-N2UJ3D6L.mjs.map +7 -0
  57. package/dist/lib/node-esm/meta.json +1 -1
  58. package/dist/lib/node-esm/operation-resolver-7PHDJZA2.mjs +442 -0
  59. package/dist/lib/node-esm/operation-resolver-7PHDJZA2.mjs.map +7 -0
  60. package/dist/lib/node-esm/react-root-SZIGQRDZ.mjs +26 -0
  61. package/dist/lib/node-esm/react-root-SZIGQRDZ.mjs.map +7 -0
  62. package/dist/lib/node-esm/{react-surface-AMVESEF4.mjs → react-surface-24PNWUDX.mjs} +32 -33
  63. package/dist/lib/node-esm/react-surface-24PNWUDX.mjs.map +7 -0
  64. package/dist/lib/node-esm/{repair-RMLR24YR.mjs → repair-LHLLGXKF.mjs} +12 -9
  65. package/dist/lib/node-esm/repair-LHLLGXKF.mjs.map +7 -0
  66. package/dist/lib/node-esm/settings-LXZQXSPL.mjs +33 -0
  67. package/dist/lib/node-esm/settings-LXZQXSPL.mjs.map +7 -0
  68. package/dist/lib/node-esm/state-YYAK5ENM.mjs +25 -0
  69. package/dist/lib/node-esm/state-YYAK5ENM.mjs.map +7 -0
  70. package/dist/lib/node-esm/types/index.mjs +5 -4
  71. package/dist/types/src/ThreadPlugin.d.ts +2 -1
  72. package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
  73. package/dist/types/src/blueprints/index.d.ts +2 -0
  74. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  75. package/dist/types/src/blueprints/thread-blueprint.d.ts +21 -0
  76. package/dist/types/src/blueprints/thread-blueprint.d.ts.map +1 -0
  77. package/dist/types/src/calls/call-manager.d.ts +40 -30
  78. package/dist/types/src/calls/call-manager.d.ts.map +1 -1
  79. package/dist/types/src/calls/call-swarm-synchronizer.d.ts +2 -2
  80. package/dist/types/src/calls/call-swarm-synchronizer.d.ts.map +1 -1
  81. package/dist/types/src/calls/media-manager.d.ts +1 -1
  82. package/dist/types/src/calls/media-manager.d.ts.map +1 -1
  83. package/dist/types/src/calls/util/calls-service.d.ts +1 -1
  84. package/dist/types/src/calls/util/calls-service.d.ts.map +1 -1
  85. package/dist/types/src/calls/util/task-scheduling.d.ts +2 -2
  86. package/dist/types/src/calls/util/task-scheduling.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  88. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  89. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  90. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  92. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  94. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/call-manager/call-manager.d.ts +6 -0
  96. package/dist/types/src/capabilities/call-manager/call-manager.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/call-manager/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/call-manager/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/index.d.ts +10 -17
  100. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  101. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  104. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  106. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  107. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  108. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  109. package/dist/types/src/capabilities/react-root/index.d.ts +6 -0
  110. package/dist/types/src/capabilities/react-root/index.d.ts.map +1 -0
  111. package/dist/types/src/capabilities/react-root/react-root.d.ts +9 -0
  112. package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -0
  113. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  114. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  115. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  116. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  117. package/dist/types/src/capabilities/repair/index.d.ts +3 -0
  118. package/dist/types/src/capabilities/repair/index.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/repair/repair.d.ts +6 -0
  120. package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -0
  121. package/dist/types/src/capabilities/settings/index.d.ts +3 -0
  122. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  123. package/dist/types/src/capabilities/settings/settings.d.ts +5 -0
  124. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  125. package/dist/types/src/capabilities/state/index.d.ts +3 -0
  126. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/state/state.d.ts +7 -0
  128. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  129. package/dist/types/src/components/Call/Call.d.ts.map +1 -1
  130. package/dist/types/src/components/Call/Toolbar.d.ts.map +1 -1
  131. package/dist/types/src/components/CallSidebar.d.ts.map +1 -1
  132. package/dist/types/src/components/ChannelContainer.d.ts +4 -5
  133. package/dist/types/src/components/ChannelContainer.d.ts.map +1 -1
  134. package/dist/types/src/components/ChannelContainer.stories.d.ts +1 -1
  135. package/dist/types/src/components/ChannelContainer.stories.d.ts.map +1 -1
  136. package/dist/types/src/components/ChatContainer.d.ts +1 -1
  137. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  138. package/dist/types/src/components/Comments.stories.d.ts.map +1 -1
  139. package/dist/types/src/components/CommentsThreadContainer.d.ts.map +1 -1
  140. package/dist/types/src/components/Lobby/Lobby.d.ts.map +1 -1
  141. package/dist/types/src/components/Media/VideoObject.d.ts +1 -1
  142. package/dist/types/src/components/Media/VideoObject.stories.d.ts +1 -1
  143. package/dist/types/src/components/MessageContainer.d.ts +3 -4
  144. package/dist/types/src/components/MessageContainer.d.ts.map +1 -1
  145. package/dist/types/src/components/Participant/Participant.d.ts.map +1 -1
  146. package/dist/types/src/components/ThreadCompanion.d.ts.map +1 -1
  147. package/dist/types/src/components/ThreadSettings.d.ts +4 -2
  148. package/dist/types/src/components/ThreadSettings.d.ts.map +1 -1
  149. package/dist/types/src/components/index.d.ts +2 -2
  150. package/dist/types/src/components/index.d.ts.map +1 -1
  151. package/dist/types/src/extensions/threads.d.ts +7 -2
  152. package/dist/types/src/extensions/threads.d.ts.map +1 -1
  153. package/dist/types/src/functions/create-proposals.d.ts.map +1 -1
  154. package/dist/types/src/hooks/analytics.d.ts +1 -2
  155. package/dist/types/src/hooks/analytics.d.ts.map +1 -1
  156. package/dist/types/src/index.d.ts +1 -1
  157. package/dist/types/src/index.d.ts.map +1 -1
  158. package/dist/types/src/meta.d.ts +2 -2
  159. package/dist/types/src/meta.d.ts.map +1 -1
  160. package/dist/types/src/testing/stories.d.ts +2 -1
  161. package/dist/types/src/testing/stories.d.ts.map +1 -1
  162. package/dist/types/src/types/Channel.d.ts +691 -12
  163. package/dist/types/src/types/Channel.d.ts.map +1 -1
  164. package/dist/types/src/types/capabilities.d.ts +23 -0
  165. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  166. package/dist/types/src/types/index.d.ts +1 -0
  167. package/dist/types/src/types/index.d.ts.map +1 -1
  168. package/dist/types/src/types/types.d.ts +3182 -295
  169. package/dist/types/src/types/types.d.ts.map +1 -1
  170. package/dist/types/tsconfig.tsbuildinfo +1 -1
  171. package/package.json +86 -69
  172. package/src/ThreadPlugin.tsx +50 -80
  173. package/src/blueprints/index.ts +5 -0
  174. package/src/blueprints/thread-blueprint.ts +32 -0
  175. package/src/calls/call-manager.ts +76 -52
  176. package/src/calls/call-swarm-synchronizer.ts +2 -2
  177. package/src/calls/media-manager.ts +1 -1
  178. package/src/calls/util/calls-service.ts +1 -1
  179. package/src/calls/util/task-scheduling.ts +4 -4
  180. package/src/capabilities/app-graph-builder/app-graph-builder.ts +201 -0
  181. package/src/capabilities/app-graph-builder/index.ts +7 -0
  182. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  183. package/src/capabilities/blueprint-definition/index.ts +7 -0
  184. package/src/capabilities/call-manager/call-manager.ts +26 -0
  185. package/src/capabilities/call-manager/index.ts +7 -0
  186. package/src/capabilities/index.ts +10 -14
  187. package/src/capabilities/markdown/index.ts +7 -0
  188. package/src/capabilities/markdown/markdown.ts +83 -0
  189. package/src/capabilities/operation-resolver/index.ts +7 -0
  190. package/src/capabilities/operation-resolver/operation-resolver.ts +400 -0
  191. package/src/capabilities/react-root/index.ts +7 -0
  192. package/src/capabilities/react-root/react-root.tsx +20 -0
  193. package/src/capabilities/react-surface/index.ts +7 -0
  194. package/src/capabilities/react-surface/react-surface.tsx +97 -0
  195. package/src/capabilities/repair/index.ts +7 -0
  196. package/src/capabilities/{repair.ts → repair/repair.ts} +21 -10
  197. package/src/capabilities/settings/index.ts +7 -0
  198. package/src/capabilities/settings/settings.ts +33 -0
  199. package/src/capabilities/state/index.ts +7 -0
  200. package/src/capabilities/state/state.ts +22 -0
  201. package/src/components/Call/Call.tsx +7 -3
  202. package/src/components/Call/Toolbar.tsx +28 -20
  203. package/src/components/CallSidebar.tsx +4 -2
  204. package/src/components/ChannelContainer.stories.tsx +10 -8
  205. package/src/components/ChannelContainer.tsx +18 -16
  206. package/src/components/Chat.stories.tsx +6 -6
  207. package/src/components/ChatContainer.tsx +7 -7
  208. package/src/components/Comments.stories.tsx +21 -18
  209. package/src/components/CommentsThreadContainer.tsx +9 -9
  210. package/src/components/Lobby/Lobby.tsx +8 -6
  211. package/src/components/Media/AudioStream.tsx +2 -2
  212. package/src/components/Media/VideoObject.tsx +1 -1
  213. package/src/components/MessageContainer.tsx +53 -24
  214. package/src/components/Participant/Participant.tsx +31 -18
  215. package/src/components/ResponsiveGrid/ResponsiveContainer.tsx +1 -1
  216. package/src/components/ResponsiveGrid/ResponsiveGrid.tsx +1 -1
  217. package/src/components/ResponsiveGrid/ResponsiveGridItem.tsx +1 -1
  218. package/src/components/ThreadCompanion.tsx +69 -64
  219. package/src/components/ThreadSettings.tsx +6 -1
  220. package/src/components/command-extension.ts +2 -2
  221. package/src/components/index.ts +2 -5
  222. package/src/extensions/threads.ts +75 -41
  223. package/src/functions/create-proposals.ts +5 -4
  224. package/src/hooks/analytics.ts +23 -20
  225. package/src/index.ts +1 -1
  226. package/src/meta.ts +2 -2
  227. package/src/testing/stories.ts +15 -11
  228. package/src/types/Channel.ts +9 -5
  229. package/src/types/capabilities.ts +34 -0
  230. package/src/types/index.ts +1 -0
  231. package/src/types/types.ts +160 -73
  232. package/dist/lib/browser/ChannelContainer-L7MKV7DS.mjs +0 -17
  233. package/dist/lib/browser/ChatContainer-KPY4BAUE.mjs +0 -16
  234. package/dist/lib/browser/app-graph-builder-TWJ2UCOZ.mjs +0 -171
  235. package/dist/lib/browser/app-graph-builder-TWJ2UCOZ.mjs.map +0 -7
  236. package/dist/lib/browser/blueprint-definition-TQ4JFMZZ.mjs.map +0 -7
  237. package/dist/lib/browser/call-manager-4YFT4XA6.mjs +0 -25
  238. package/dist/lib/browser/call-manager-4YFT4XA6.mjs.map +0 -7
  239. package/dist/lib/browser/chunk-ALZKJOZK.mjs +0 -989
  240. package/dist/lib/browser/chunk-ALZKJOZK.mjs.map +0 -7
  241. package/dist/lib/browser/chunk-ANTFU4JB.mjs +0 -25
  242. package/dist/lib/browser/chunk-ANTFU4JB.mjs.map +0 -7
  243. package/dist/lib/browser/chunk-CFC7LEPD.mjs +0 -18
  244. package/dist/lib/browser/chunk-CFC7LEPD.mjs.map +0 -7
  245. package/dist/lib/browser/chunk-JDJPMI7V.mjs +0 -143
  246. package/dist/lib/browser/chunk-JDJPMI7V.mjs.map +0 -7
  247. package/dist/lib/browser/chunk-KOBXMDCI.mjs.map +0 -7
  248. package/dist/lib/browser/chunk-NPT5S6N4.mjs +0 -611
  249. package/dist/lib/browser/chunk-NPT5S6N4.mjs.map +0 -7
  250. package/dist/lib/browser/chunk-QM34EZQK.mjs +0 -20
  251. package/dist/lib/browser/chunk-QM34EZQK.mjs.map +0 -7
  252. package/dist/lib/browser/chunk-TLOOZTRD.mjs +0 -377
  253. package/dist/lib/browser/chunk-TLOOZTRD.mjs.map +0 -7
  254. package/dist/lib/browser/chunk-ZCW3NSDZ.mjs.map +0 -7
  255. package/dist/lib/browser/intent-resolver-G33FT3NO.mjs +0 -355
  256. package/dist/lib/browser/intent-resolver-G33FT3NO.mjs.map +0 -7
  257. package/dist/lib/browser/markdown-WFZFYJBQ.mjs +0 -172
  258. package/dist/lib/browser/markdown-WFZFYJBQ.mjs.map +0 -7
  259. package/dist/lib/browser/react-root-ED7PHA44.mjs +0 -29
  260. package/dist/lib/browser/react-root-ED7PHA44.mjs.map +0 -7
  261. package/dist/lib/browser/react-surface-AUQQSQQC.mjs.map +0 -7
  262. package/dist/lib/browser/repair-JFJLEM2O.mjs.map +0 -7
  263. package/dist/lib/browser/settings-E6IOLK46.mjs +0 -23
  264. package/dist/lib/browser/settings-E6IOLK46.mjs.map +0 -7
  265. package/dist/lib/browser/state-UYPLBGZJ.mjs +0 -35
  266. package/dist/lib/browser/state-UYPLBGZJ.mjs.map +0 -7
  267. package/dist/lib/node-esm/ChannelContainer-FYONOOZ6.mjs +0 -18
  268. package/dist/lib/node-esm/ChannelContainer-FYONOOZ6.mjs.map +0 -7
  269. package/dist/lib/node-esm/ChatContainer-TLQG23K7.mjs +0 -17
  270. package/dist/lib/node-esm/ChatContainer-TLQG23K7.mjs.map +0 -7
  271. package/dist/lib/node-esm/app-graph-builder-VD6I2V5H.mjs +0 -172
  272. package/dist/lib/node-esm/app-graph-builder-VD6I2V5H.mjs.map +0 -7
  273. package/dist/lib/node-esm/blueprint-definition-TSX5HHW7.mjs.map +0 -7
  274. package/dist/lib/node-esm/call-manager-UMUXEYH5.mjs +0 -26
  275. package/dist/lib/node-esm/call-manager-UMUXEYH5.mjs.map +0 -7
  276. package/dist/lib/node-esm/chunk-2AEIN5MI.mjs +0 -22
  277. package/dist/lib/node-esm/chunk-2AEIN5MI.mjs.map +0 -7
  278. package/dist/lib/node-esm/chunk-7KZWZS2U.mjs.map +0 -7
  279. package/dist/lib/node-esm/chunk-AB42KYF3.mjs +0 -990
  280. package/dist/lib/node-esm/chunk-AB42KYF3.mjs.map +0 -7
  281. package/dist/lib/node-esm/chunk-ATNY37UV.mjs +0 -27
  282. package/dist/lib/node-esm/chunk-ATNY37UV.mjs.map +0 -7
  283. package/dist/lib/node-esm/chunk-E5HNHFYH.mjs +0 -378
  284. package/dist/lib/node-esm/chunk-E5HNHFYH.mjs.map +0 -7
  285. package/dist/lib/node-esm/chunk-FF3QVPY4.mjs +0 -612
  286. package/dist/lib/node-esm/chunk-FF3QVPY4.mjs.map +0 -7
  287. package/dist/lib/node-esm/chunk-P2M364TO.mjs +0 -144
  288. package/dist/lib/node-esm/chunk-P2M364TO.mjs.map +0 -7
  289. package/dist/lib/node-esm/chunk-PZH2EDU5.mjs.map +0 -7
  290. package/dist/lib/node-esm/chunk-RT6NRL2I.mjs +0 -19
  291. package/dist/lib/node-esm/chunk-RT6NRL2I.mjs.map +0 -7
  292. package/dist/lib/node-esm/intent-resolver-4PX3WXQG.mjs +0 -356
  293. package/dist/lib/node-esm/intent-resolver-4PX3WXQG.mjs.map +0 -7
  294. package/dist/lib/node-esm/markdown-CSR5MAPZ.mjs +0 -173
  295. package/dist/lib/node-esm/markdown-CSR5MAPZ.mjs.map +0 -7
  296. package/dist/lib/node-esm/react-root-DZN324JA.mjs +0 -30
  297. package/dist/lib/node-esm/react-root-DZN324JA.mjs.map +0 -7
  298. package/dist/lib/node-esm/react-surface-AMVESEF4.mjs.map +0 -7
  299. package/dist/lib/node-esm/repair-RMLR24YR.mjs.map +0 -7
  300. package/dist/lib/node-esm/settings-RGZHWDSO.mjs +0 -24
  301. package/dist/lib/node-esm/settings-RGZHWDSO.mjs.map +0 -7
  302. package/dist/lib/node-esm/state-XNWOLBNE.mjs +0 -36
  303. package/dist/lib/node-esm/state-XNWOLBNE.mjs.map +0 -7
  304. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  305. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  306. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  307. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  308. package/dist/types/src/capabilities/call-manager.d.ts +0 -5
  309. package/dist/types/src/capabilities/call-manager.d.ts.map +0 -1
  310. package/dist/types/src/capabilities/capabilities.d.ts +0 -27
  311. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  312. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  313. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  314. package/dist/types/src/capabilities/markdown.d.ts +0 -4
  315. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  316. package/dist/types/src/capabilities/react-root.d.ts +0 -7
  317. package/dist/types/src/capabilities/react-root.d.ts.map +0 -1
  318. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  319. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  320. package/dist/types/src/capabilities/repair.d.ts +0 -4
  321. package/dist/types/src/capabilities/repair.d.ts.map +0 -1
  322. package/dist/types/src/capabilities/settings.d.ts +0 -4
  323. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  324. package/dist/types/src/capabilities/state.d.ts +0 -7
  325. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  326. package/src/capabilities/app-graph-builder.ts +0 -194
  327. package/src/capabilities/blueprint-definition.ts +0 -38
  328. package/src/capabilities/call-manager.ts +0 -20
  329. package/src/capabilities/capabilities.ts +0 -33
  330. package/src/capabilities/intent-resolver.ts +0 -311
  331. package/src/capabilities/markdown.ts +0 -71
  332. package/src/capabilities/react-root.tsx +0 -17
  333. package/src/capabilities/react-surface.tsx +0 -91
  334. package/src/capabilities/settings.ts +0 -19
  335. package/src/capabilities/state.ts +0 -26
  336. /package/dist/lib/browser/{ChannelContainer-L7MKV7DS.mjs.map → blueprints/index.mjs.map} +0 -0
  337. /package/dist/lib/{browser/ChatContainer-KPY4BAUE.mjs.map → node-esm/blueprints/index.mjs.map} +0 -0
@@ -0,0 +1,1813 @@
1
+ import {
2
+ useDebugMode,
3
+ useOnEditAnalytics,
4
+ useStatus
5
+ } from "./chunk-DLO2G3DM.mjs";
6
+ import {
7
+ getMessageMetadata
8
+ } from "./chunk-CP7E2HRE.mjs";
9
+ import {
10
+ ThreadCapabilities,
11
+ ThreadOperation,
12
+ meta
13
+ } from "./chunk-TAWDJPMD.mjs";
14
+
15
+ // src/components/Call/Call.tsx
16
+ import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
17
+ import React9 from "react";
18
+ import { useCapability as useCapability3 } from "@dxos/app-framework/react";
19
+
20
+ // src/components/Media/AudioStream.tsx
21
+ import React, { useEffect, useRef } from "react";
22
+ var AudioStream = ({ tracks }) => {
23
+ const mediaStreamRef = useRef(new MediaStream());
24
+ const ref = useRef(null);
25
+ useEffect(() => {
26
+ const audio = ref.current;
27
+ if (!audio) {
28
+ return;
29
+ }
30
+ const mediaStream = mediaStreamRef.current;
31
+ audio.srcObject = mediaStream;
32
+ }, []);
33
+ const resetSrcObject = () => {
34
+ const audio = ref.current;
35
+ const mediaStream = mediaStreamRef.current;
36
+ if (!audio || !mediaStream) {
37
+ return;
38
+ }
39
+ audio.addEventListener("canplay", () => audio.play(), {
40
+ once: true
41
+ });
42
+ audio.srcObject = mediaStream;
43
+ };
44
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("audio", {
45
+ ref,
46
+ autoPlay: true
47
+ }), tracks.map((track) => /* @__PURE__ */ React.createElement(AudioTrack, {
48
+ key: track.id,
49
+ track,
50
+ mediaStream: mediaStreamRef.current,
51
+ resetSrcObject
52
+ })));
53
+ };
54
+ var AudioTrack = ({ track, mediaStream, resetSrcObject }) => {
55
+ useEffect(() => {
56
+ const currentTrack = track;
57
+ mediaStream.addTrack(currentTrack);
58
+ resetSrcObject();
59
+ return () => {
60
+ mediaStream.removeTrack(currentTrack);
61
+ resetSrcObject();
62
+ };
63
+ }, [
64
+ track,
65
+ mediaStream
66
+ ]);
67
+ return null;
68
+ };
69
+
70
+ // src/components/Media/VideoObject.tsx
71
+ import React2, { forwardRef, memo, useEffect as useEffect2, useRef as useRef2 } from "react";
72
+ import { mx } from "@dxos/ui-theme";
73
+ var VideoObject = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ videoStream, classNames, flip, contain, ...rest }, ref) => {
74
+ const internalRef = useRef2(null);
75
+ useEffect2(() => {
76
+ const video = internalRef.current;
77
+ if (video && videoStream) {
78
+ video.srcObject = videoStream;
79
+ video.setAttribute("autoplay", "true");
80
+ video.setAttribute("playsinline", "true");
81
+ }
82
+ }, [
83
+ videoStream,
84
+ internalRef.current
85
+ ]);
86
+ return /* @__PURE__ */ React2.createElement("video", {
87
+ className: mx("is-full aspect-video", flip && "scale-x-[-1]", contain ? "object-contain" : "object-cover", classNames),
88
+ ref: (v) => {
89
+ internalRef.current = v;
90
+ if (ref === null) {
91
+ return;
92
+ }
93
+ if (typeof ref === "function") {
94
+ ref(v);
95
+ } else {
96
+ ref.current = v;
97
+ }
98
+ },
99
+ ...rest
100
+ });
101
+ }));
102
+ VideoObject.displayName = "VideoObject";
103
+
104
+ // src/components/Participant/Participant.tsx
105
+ import { useAtomValue } from "@effect-atom/atom-react";
106
+ import React6, { memo as memo2, useMemo as useMemo2 } from "react";
107
+ import { useCapability } from "@dxos/app-framework/react";
108
+
109
+ // src/components/ResponsiveGrid/ResponsiveContainer.tsx
110
+ import React3 from "react";
111
+ import { mx as mx2 } from "@dxos/ui-theme";
112
+ var ResponsiveContainer = ({ children }) => {
113
+ return (
114
+ // Outer container that takes full size of parent.
115
+ /* @__PURE__ */ React3.createElement("div", {
116
+ role: "none",
117
+ className: "relative flex is-full bs-full"
118
+ }, /* @__PURE__ */ React3.createElement("div", {
119
+ role: "none",
120
+ className: "absolute inset-0 flex justify-center items-center"
121
+ }, /* @__PURE__ */ React3.createElement("div", {
122
+ role: "none",
123
+ className: mx2("max-bs-full max-is-full is-auto bs-auto aspect-video")
124
+ }, children)))
125
+ );
126
+ };
127
+
128
+ // src/components/ResponsiveGrid/ResponsiveGrid.tsx
129
+ import React4, { useCallback, useEffect as useEffect3, useLayoutEffect, useMemo, useState } from "react";
130
+ import { useResizeDetector } from "react-resize-detector";
131
+ import { invariant } from "@dxos/invariant";
132
+ import { mx as mx3 } from "@dxos/ui-theme";
133
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/components/ResponsiveGrid/ResponsiveGrid.tsx";
134
+ var ASPECT_RATIO = 16 / 9;
135
+ var MIN_GALLERY_HEIGHT = 250;
136
+ var DEFAULT_GAP = 8;
137
+ var maxImageSize = "is-[2560px] bs-[1440px]";
138
+ var defaultGetId = (item) => item.id;
139
+ var ResponsiveGrid = ({ classNames, Cell, gap = DEFAULT_GAP, getId: getId2 = defaultGetId, items, pinned, autoHideGallery = false, debug, onPinnedChange }) => {
140
+ const { width: containerWidth = 0, height: containerHeight = 0, ref: containerRef } = useResizeDetector({
141
+ refreshRate: 100
142
+ });
143
+ const [dividerHeight, setDividerHeight] = useState(0);
144
+ useEffect3(() => {
145
+ if (containerWidth && containerHeight) {
146
+ const { height: height2 } = fitAspectRatio(containerWidth, containerHeight, ASPECT_RATIO);
147
+ setDividerHeight(Math.min(height2, containerHeight - MIN_GALLERY_HEIGHT));
148
+ }
149
+ }, [
150
+ containerWidth,
151
+ containerHeight
152
+ ]);
153
+ const pinnedItem = useMemo(() => items.find((item) => getId2(item) === pinned), [
154
+ items,
155
+ pinned
156
+ ]);
157
+ const mainItems = useMemo(() => items.filter((item) => getId2(item) !== pinned), [
158
+ items,
159
+ pinned
160
+ ]);
161
+ const hideGallery = autoHideGallery && pinnedItem !== void 0;
162
+ const [{ time, columns, cellWidth }, setLayout] = useState({
163
+ time: 0,
164
+ columns: 0,
165
+ cellWidth: 0
166
+ });
167
+ const { width = 0, height = 0, ref: gridContainerRef } = useResizeDetector({
168
+ refreshRate: 200
169
+ });
170
+ useEffect3(() => {
171
+ if (containerHeight && width && height) {
172
+ const layout = calculateLayout(width, height, mainItems.length, gap);
173
+ setLayout({
174
+ time: Date.now(),
175
+ ...layout
176
+ });
177
+ }
178
+ }, [
179
+ containerHeight,
180
+ width,
181
+ height,
182
+ mainItems.length,
183
+ gap,
184
+ pinned
185
+ ]);
186
+ const [bounds, setBounds] = useState([]);
187
+ useLayoutEffect(() => {
188
+ if (!hideGallery && !gridContainerRef.current || !containerHeight) {
189
+ return;
190
+ }
191
+ const t = setTimeout(() => {
192
+ setBounds(items.filter((item) => !hideGallery || item === pinnedItem).map((item) => {
193
+ invariant(containerRef.current, void 0, {
194
+ F: __dxlog_file,
195
+ L: 117,
196
+ S: void 0,
197
+ A: [
198
+ "containerRef.current",
199
+ ""
200
+ ]
201
+ });
202
+ const el = containerRef.current.querySelector(`[data-grid-item="${getId2(item)}"]`);
203
+ if (!el) {
204
+ return null;
205
+ }
206
+ const bounds2 = getRelativeBounds(containerRef.current, el);
207
+ return [
208
+ item,
209
+ bounds2
210
+ ];
211
+ }).filter((item) => item !== null));
212
+ });
213
+ return () => clearTimeout(t);
214
+ }, [
215
+ containerHeight,
216
+ items,
217
+ pinnedItem,
218
+ hideGallery,
219
+ time
220
+ ]);
221
+ const handleClick = useCallback((item) => onPinnedChange?.(getId2(item) === pinned ? void 0 : getId2(item)), [
222
+ pinned,
223
+ onPinnedChange
224
+ ]);
225
+ return /* @__PURE__ */ React4.createElement("div", {
226
+ ref: containerRef,
227
+ className: mx3("relative is-full bs-full", classNames)
228
+ }, /* @__PURE__ */ React4.createElement("div", {
229
+ className: "absolute inset-0 flex flex-col grow gap-2"
230
+ }, pinnedItem && /* @__PURE__ */ React4.createElement("div", {
231
+ className: mx3("flex grow-[2] shrink overflow-hidden justify-center items-center", hideGallery && "bs-full"),
232
+ style: hideGallery ? {} : {
233
+ height: dividerHeight
234
+ }
235
+ }, /* @__PURE__ */ React4.createElement(SoloItem, {
236
+ id: getId2(pinnedItem),
237
+ debug
238
+ })), !hideGallery && /* @__PURE__ */ React4.createElement("div", {
239
+ ref: gridContainerRef,
240
+ className: "flex grow-[1] overflow-hidden justify-center items-center",
241
+ style: hideGallery ? {} : {
242
+ minHeight: MIN_GALLERY_HEIGHT
243
+ }
244
+ }, mainItems.length === 1 && /* @__PURE__ */ React4.createElement("div", {
245
+ style: {
246
+ width: cellWidth
247
+ },
248
+ className: "flex bs-full"
249
+ }, /* @__PURE__ */ React4.createElement(SoloItem, {
250
+ id: getId2(mainItems[0]),
251
+ debug
252
+ })), mainItems.length > 1 && columns > 0 && /* @__PURE__ */ React4.createElement("div", {
253
+ role: "grid",
254
+ style: {
255
+ display: "grid",
256
+ gridTemplateColumns: `repeat(${columns}, ${cellWidth}px)`,
257
+ gap: `${gap}px`
258
+ }
259
+ }, mainItems.map((item) => /* @__PURE__ */ React4.createElement("div", {
260
+ key: getId2(item),
261
+ "data-grid-item": getId2(item),
262
+ className: mx3("aspect-video max-bs-full max-is-full is-auto bs-auto", debug && "border border-primary-500")
263
+ }))))), /* @__PURE__ */ React4.createElement("div", {
264
+ className: mx3(debug && "opacity-10")
265
+ }, bounds.map(([item, bounds2]) => /* @__PURE__ */ React4.createElement(Cell, {
266
+ key: getId2(item),
267
+ classNames: "absolute transition-all duration-500",
268
+ item,
269
+ style: bounds2,
270
+ pinned: getId2(item) === pinned,
271
+ onClick: items.length > 1 ? handleClick : void 0
272
+ }))));
273
+ };
274
+ var SoloItem = ({ debug, id }) => {
275
+ return /* @__PURE__ */ React4.createElement(ResponsiveContainer, null, /* @__PURE__ */ React4.createElement("div", {
276
+ "data-grid-item": id,
277
+ className: mx3("aspect-video overflow-hidden", debug && "z-20 border-2 border-primary-500")
278
+ }, /* @__PURE__ */ React4.createElement("img", {
279
+ alt: "placeholder video",
280
+ className: mx3("opacity-0", maxImageSize)
281
+ })));
282
+ };
283
+ var getRelativeBounds = (container, el) => {
284
+ const containerRect = container.getBoundingClientRect();
285
+ const elementRect = el.getBoundingClientRect();
286
+ return {
287
+ top: elementRect.top - containerRect.top,
288
+ left: elementRect.left - containerRect.left,
289
+ width: elementRect.width,
290
+ height: elementRect.height
291
+ };
292
+ };
293
+ var calculateLayout = (containerWidth, containerHeight, count, gap, aspectRatio = ASPECT_RATIO) => {
294
+ if (count === 0) {
295
+ return {
296
+ columns: 1,
297
+ cellWidth: 1
298
+ };
299
+ }
300
+ let minWastedSpace = Infinity;
301
+ let bestColumns = 1;
302
+ let cellWidth = 0;
303
+ for (let rows = 1; rows <= count; rows++) {
304
+ const cols = Math.ceil(count / rows);
305
+ const { width: itemWidth, height: itemHeight } = fitItemsToGrid(containerWidth, containerHeight, cols, rows, aspectRatio, gap);
306
+ const usedWidth = itemWidth * cols + gap * cols - 1;
307
+ const usedHeight = itemHeight * rows + gap * rows - 1;
308
+ const wastedSpace = containerWidth * containerHeight - usedWidth * usedHeight;
309
+ if (wastedSpace < minWastedSpace) {
310
+ minWastedSpace = wastedSpace;
311
+ bestColumns = cols;
312
+ cellWidth = itemWidth;
313
+ }
314
+ }
315
+ return {
316
+ columns: bestColumns,
317
+ cellWidth
318
+ };
319
+ };
320
+ var fitItemsToGrid = (outerWidth, outerHeight, numCols, numRows, aspectRatio, gap) => {
321
+ const availableWidth = outerWidth - gap * (numCols - 1);
322
+ const availableHeight = outerHeight - gap * (numRows - 1);
323
+ const maxCellWidth = availableWidth / numCols;
324
+ const maxCellHeight = availableHeight / numRows;
325
+ return fitAspectRatio(maxCellWidth, maxCellHeight, aspectRatio);
326
+ };
327
+ var fitAspectRatio = (outerWidth, outerHeight, aspectRatio) => {
328
+ if (outerWidth <= 0 || outerHeight <= 0 || aspectRatio <= 0) {
329
+ return {
330
+ width: 0,
331
+ height: 0
332
+ };
333
+ }
334
+ let width = outerWidth;
335
+ let height = width / aspectRatio;
336
+ if (height > outerHeight) {
337
+ height = outerHeight;
338
+ width = height * aspectRatio;
339
+ }
340
+ return {
341
+ width,
342
+ height
343
+ };
344
+ };
345
+
346
+ // src/components/ResponsiveGrid/ResponsiveGridItem.tsx
347
+ import React5, { useEffect as useEffect4, useState as useState2 } from "react";
348
+ import { Icon, IconButton, useTranslation } from "@dxos/react-ui";
349
+ import { Waveform } from "@dxos/react-ui-sfx";
350
+ import { groupHoverControlItemWithTransition, mx as mx4 } from "@dxos/ui-theme";
351
+ var ResponsiveGridItem = ({ children, classNames, item, style, name, self, pinned, screenshare, video, mute, wave, speaking, onClick }) => {
352
+ const { t } = useTranslation(meta.id);
353
+ const iconProps = {
354
+ wave: {
355
+ icon: "ph--hand-waving--duotone",
356
+ label: t("icon wave"),
357
+ classNames: "animate-pulse bg-orange-500"
358
+ },
359
+ mute: {
360
+ icon: "ph--microphone-slash--regular",
361
+ label: t("icon muted")
362
+ }
363
+ };
364
+ const props = wave && !pinned ? iconProps.wave : mute ? iconProps.mute : speaking ? iconProps.speaking : void 0;
365
+ const [speakingIndicator, setSpeakingIndicator] = useState2(speaking);
366
+ useEffect4(() => {
367
+ if (speaking) {
368
+ setSpeakingIndicator(true);
369
+ } else {
370
+ const timeout = setTimeout(() => {
371
+ setSpeakingIndicator(false);
372
+ }, 1e3);
373
+ return () => clearTimeout(timeout);
374
+ }
375
+ }, [
376
+ speaking
377
+ ]);
378
+ return /* @__PURE__ */ React5.createElement("div", {
379
+ className: mx4("relative is-full bs-full group", "rounded-md outline outline-2 outline-neutral-900 transition-[outline-color] duration-500", speakingIndicator ? "outline-green-500" : !video && "outline-separator", classNames),
380
+ style
381
+ }, children, onClick && /* @__PURE__ */ React5.createElement("div", {
382
+ className: "z-10 absolute top-1 right-1 flex"
383
+ }, /* @__PURE__ */ React5.createElement(IconButton, {
384
+ classNames: mx4("p-1 min-bs-1 rounded", groupHoverControlItemWithTransition),
385
+ iconOnly: true,
386
+ icon: pinned ? "ph--x--regular" : "ph--arrows-out--regular",
387
+ size: pinned ? 5 : 4,
388
+ label: pinned ? t("icon unpin") : t("icon pin"),
389
+ onClick: () => onClick?.(item)
390
+ })), name && /* @__PURE__ */ React5.createElement("div", {
391
+ className: "z-10 absolute bottom-1 left-8 right-1 flex justify-end gap-1 items-center"
392
+ }, screenshare && /* @__PURE__ */ React5.createElement(Icon, {
393
+ icon: "ph--broadcast--regular",
394
+ size: pinned ? 5 : 4
395
+ }), /* @__PURE__ */ React5.createElement("div", {
396
+ className: mx4("bg-neutral-800 text-neutral-100 plb-0.5 truncate rounded", pinned ? "pli-2" : "pli-1 text-xs")
397
+ }, name)), /* @__PURE__ */ React5.createElement("div", {
398
+ className: "z-10 absolute bottom-1 left-1 flex"
399
+ }, speaking && /* @__PURE__ */ React5.createElement(Waveform, {
400
+ active: true,
401
+ size: pinned ? 5 : 4
402
+ }) || props && /* @__PURE__ */ React5.createElement(IconButton, {
403
+ classNames: mx4("p-1 min-bs-1 rounded", props?.classNames),
404
+ icon: props?.icon,
405
+ label: props?.label,
406
+ size: pinned ? 5 : 4,
407
+ iconOnly: true
408
+ })));
409
+ };
410
+
411
+ // src/components/Participant/Participant.tsx
412
+ var SCREENSHARE_SUFFIX = "_screenshare";
413
+ var Participant = /* @__PURE__ */ memo2(({ item: user, debug, ...props }) => {
414
+ const call = useCapability(ThreadCapabilities.CallManager);
415
+ const self = useAtomValue(call.selfAtom);
416
+ const media = useAtomValue(call.mediaAtom);
417
+ const isSelf = self.id !== void 0 && user.id !== void 0 && user.id.startsWith(self.id);
418
+ const isScreenshare = user.id?.endsWith(SCREENSHARE_SUFFIX);
419
+ const pulledVideoStream = useMemo2(() => {
420
+ if (isSelf) {
421
+ return void 0;
422
+ }
423
+ const trackName = isScreenshare && user.tracks?.screenshareEnabled ? user.tracks?.screenshare : !isScreenshare && user.tracks?.videoEnabled ? user.tracks?.video : void 0;
424
+ return trackName ? media.pulledVideoStreams[trackName]?.stream : void 0;
425
+ }, [
426
+ isSelf,
427
+ isScreenshare,
428
+ media.pulledVideoStreams,
429
+ user.tracks?.screenshare,
430
+ user.tracks?.video,
431
+ user.tracks?.screenshareEnabled,
432
+ user.tracks?.videoEnabled
433
+ ]);
434
+ const videoStream = useMemo2(() => {
435
+ if (isSelf) {
436
+ return isScreenshare ? media.screenshareVideoStream : media.videoStream;
437
+ }
438
+ return pulledVideoStream;
439
+ }, [
440
+ isSelf,
441
+ isScreenshare,
442
+ media.videoStream,
443
+ media.screenshareVideoStream,
444
+ pulledVideoStream
445
+ ]);
446
+ return /* @__PURE__ */ React6.createElement(ResponsiveGridItem, {
447
+ ...props,
448
+ item: user,
449
+ name: user.name,
450
+ self: isSelf,
451
+ screenshare: !!media.screenshareVideoStream,
452
+ video: media.videoEnabled,
453
+ mute: user ? !user.tracks?.audioEnabled : false,
454
+ wave: user.raisedHand,
455
+ speaking: user.speaking,
456
+ debug
457
+ }, /* @__PURE__ */ React6.createElement(VideoObject, {
458
+ videoStream,
459
+ flip: isSelf && !isScreenshare,
460
+ contain: !!isScreenshare,
461
+ classNames: "rounded-md"
462
+ }));
463
+ });
464
+ Participant.displayName = "Participant";
465
+
466
+ // src/components/Participant/ParticipantGrid.tsx
467
+ import React7, { useEffect as useEffect5, useMemo as useMemo3, useState as useState3 } from "react";
468
+ var getId = (user) => user.id;
469
+ var ParticipantGrid = ({ classNames, self, users, fullscreen, debug }) => {
470
+ const [pinned, setPinned] = useState3();
471
+ const allUsers = useMemo3(() => {
472
+ const allUsers2 = [];
473
+ users.forEach((user) => {
474
+ if (!user.joined) {
475
+ return;
476
+ }
477
+ allUsers2.push({
478
+ ...user,
479
+ isSelf: user.id === self.id
480
+ });
481
+ if (user.tracks?.screenshareEnabled) {
482
+ const screenshare = {
483
+ ...user,
484
+ id: user.id + SCREENSHARE_SUFFIX,
485
+ tracks: {
486
+ ...user.tracks,
487
+ video: user.tracks.screenshare,
488
+ videoEnabled: user.tracks.screenshareEnabled
489
+ }
490
+ };
491
+ allUsers2.push(screenshare);
492
+ }
493
+ });
494
+ return allUsers2;
495
+ }, [
496
+ self,
497
+ users
498
+ ]);
499
+ useEffect5(() => {
500
+ if (pinned) {
501
+ if (!allUsers.find((user) => user.id === pinned)) {
502
+ setPinned(void 0);
503
+ }
504
+ }
505
+ }, [
506
+ pinned,
507
+ allUsers
508
+ ]);
509
+ const sortedUsers = allUsers.sort((a, b) => {
510
+ if (a.isSelf) {
511
+ return 1;
512
+ } else if (b.isSelf) {
513
+ return -1;
514
+ } else if (a.tracks?.screenshareEnabled) {
515
+ return -1;
516
+ } else if (b.tracks?.screenshareEnabled) {
517
+ return 1;
518
+ } else {
519
+ return 0;
520
+ }
521
+ });
522
+ return /* @__PURE__ */ React7.createElement(ResponsiveGrid, {
523
+ classNames,
524
+ Cell: Participant,
525
+ debug,
526
+ getId,
527
+ items: sortedUsers,
528
+ pinned,
529
+ autoHideGallery: fullscreen,
530
+ onPinnedChange: setPinned
531
+ });
532
+ };
533
+
534
+ // src/components/Call/Toolbar.tsx
535
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
536
+ import React8 from "react";
537
+ import { useAppGraph, useCapability as useCapability2 } from "@dxos/app-framework/react";
538
+ import { Obj } from "@dxos/echo";
539
+ import { Node, useActionRunner } from "@dxos/plugin-graph";
540
+ import { useActions, useNode } from "@dxos/plugin-graph";
541
+ import { Icon as Icon2, IconButton as IconButton2, Toolbar as NaturalToolbar, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
542
+ import { groupHoverControlItemWithTransition as groupHoverControlItemWithTransition2, mx as mx5 } from "@dxos/ui-theme";
543
+ var Toolbar = ({ classNames, channel, participants, autoHideControls = true, onJoin, onLeave }) => {
544
+ const { t } = useTranslation2(meta.id);
545
+ const { graph } = useAppGraph();
546
+ const runAction = useActionRunner();
547
+ const call = useCapability2(ThreadCapabilities.CallManager);
548
+ const media = useAtomValue2(call.mediaAtom);
549
+ const joined = useAtomValue2(call.joinedAtom);
550
+ const raisedHand = useAtomValue2(call.raisedHandAtom);
551
+ const node = useNode(graph, channel && Obj.getDXN(channel).toString());
552
+ const actions = useActions(graph, node?.id).filter((action) => action.properties.disposition === "toolbar");
553
+ const isScreensharing = media.screenshareTrack !== void 0;
554
+ const canSharescreen = typeof navigator.mediaDevices !== "undefined" && navigator.mediaDevices.getDisplayMedia !== void 0;
555
+ return /* @__PURE__ */ React8.createElement("div", {
556
+ className: mx5("z-20 flex justify-center m-8", autoHideControls && groupHoverControlItemWithTransition2)
557
+ }, /* @__PURE__ */ React8.createElement(NaturalToolbar.Root, {
558
+ classNames: [
559
+ "p-2 bg-modalSurface rounded-md shadow-md",
560
+ classNames
561
+ ]
562
+ }, /* @__PURE__ */ React8.createElement(ToggleButton, {
563
+ active: media.audioEnabled,
564
+ state: {
565
+ on: {
566
+ icon: "ph--microphone--regular",
567
+ label: t("mic off"),
568
+ onClick: () => call.turnAudioOff(),
569
+ classNames: "bg-callActive"
570
+ },
571
+ off: {
572
+ icon: "ph--microphone-slash--duotone",
573
+ label: t("mic on"),
574
+ onClick: () => call.turnAudioOn(),
575
+ classNames: [
576
+ joined && "bg-callAlert"
577
+ ]
578
+ }
579
+ }
580
+ }), /* @__PURE__ */ React8.createElement(ToggleButton, {
581
+ active: media.videoEnabled,
582
+ state: {
583
+ on: {
584
+ icon: "ph--video-camera--regular",
585
+ label: t("camera off"),
586
+ onClick: () => call.turnVideoOff()
587
+ },
588
+ off: {
589
+ icon: "ph--video-camera-slash--duotone",
590
+ label: t("camera on"),
591
+ onClick: () => call.turnVideoOn()
592
+ }
593
+ }
594
+ }), participants !== void 0 && /* @__PURE__ */ React8.createElement("div", {
595
+ className: "flex justify-center items-center gap-2 is-[5rem] text-xs text-subdued"
596
+ }, /* @__PURE__ */ React8.createElement(Icon2, {
597
+ icon: "ph--users--regular",
598
+ size: 4
599
+ }), /* @__PURE__ */ React8.createElement("div", null, participants)) || /* @__PURE__ */ React8.createElement(NaturalToolbar.Separator, {
600
+ variant: "gap"
601
+ }), joined && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(ToggleButton, {
602
+ disabled: !canSharescreen,
603
+ active: isScreensharing,
604
+ state: {
605
+ on: {
606
+ icon: "ph--monitor--regular",
607
+ label: t("screenshare off"),
608
+ onClick: () => call.turnScreenshareOff()
609
+ },
610
+ off: {
611
+ icon: "ph--monitor-arrow-up--duotone",
612
+ label: t("screenshare on"),
613
+ onClick: () => call.turnScreenshareOn()
614
+ }
615
+ }
616
+ }), actions.filter((action) => Node.isAction(action)).map((action) => /* @__PURE__ */ React8.createElement(IconButton2, {
617
+ key: action.id,
618
+ ...defaultButtonProps,
619
+ icon: action.properties.icon,
620
+ label: toLocalizedString(action.properties.label, t),
621
+ classNames: action.properties.classNames,
622
+ onClick: () => node && void runAction(action, {
623
+ parent: node
624
+ })
625
+ })), /* @__PURE__ */ React8.createElement(ToggleButton, {
626
+ active: raisedHand,
627
+ state: {
628
+ on: {
629
+ icon: "ph--hand-waving--regular",
630
+ label: t("lower hand"),
631
+ onClick: () => call.setRaisedHand(false),
632
+ classNames: [
633
+ joined && "bg-callAlert"
634
+ ]
635
+ },
636
+ off: {
637
+ icon: "ph--hand-palm--duotone",
638
+ label: t("raise hand"),
639
+ onClick: () => call.setRaisedHand(true)
640
+ }
641
+ }
642
+ })), joined ? /* @__PURE__ */ React8.createElement(IconButton2, {
643
+ variant: "destructive",
644
+ icon: "ph--phone-x--regular",
645
+ label: t("leave call"),
646
+ onClick: onLeave
647
+ }) : /* @__PURE__ */ React8.createElement(IconButton2, {
648
+ variant: "primary",
649
+ icon: "ph--phone-incoming--regular",
650
+ label: t("join call"),
651
+ onClick: onJoin
652
+ })));
653
+ };
654
+ Toolbar.displayName = "MeetingToolbar";
655
+ var defaultButtonProps = {
656
+ size: 5,
657
+ iconOnly: true
658
+ };
659
+ var ToggleButton = ({ active, state }) => /* @__PURE__ */ React8.createElement(IconButton2, {
660
+ ...defaultButtonProps,
661
+ classNames: [
662
+ active ? state.on.classNames ?? "bg-callActive" : state.off.classNames
663
+ ],
664
+ icon: active ? state.on.icon : state.off.icon,
665
+ label: active ? state.on.label : state.off.label,
666
+ onClick: active ? state.on.onClick : state.off.onClick
667
+ });
668
+
669
+ // src/components/Call/Call.tsx
670
+ var CallRoot = ({ children }) => {
671
+ return /* @__PURE__ */ React9.createElement("div", {
672
+ className: "relative flex flex-col grow overflow-hidden"
673
+ }, children);
674
+ };
675
+ CallRoot.displayName = "CallRoot";
676
+ var CallAudio = () => {
677
+ const call = useCapability3(ThreadCapabilities.CallManager);
678
+ const audioTracksToPlay = useAtomValue3(call.audioTracksToPlayAtom);
679
+ return /* @__PURE__ */ React9.createElement(AudioStream, {
680
+ tracks: audioTracksToPlay
681
+ });
682
+ };
683
+ CallAudio.displayName = "CallAudio";
684
+ var CallGrid = ({ fullscreen }) => {
685
+ const debug = useDebugMode();
686
+ const call = useCapability3(ThreadCapabilities.CallManager);
687
+ const self = useAtomValue3(call.selfAtom);
688
+ const users = useAtomValue3(call.usersAtom);
689
+ return /* @__PURE__ */ React9.createElement("div", {
690
+ className: "grid grow p-4 dark:bg-neutral-900"
691
+ }, /* @__PURE__ */ React9.createElement(ParticipantGrid, {
692
+ self,
693
+ users,
694
+ debug,
695
+ fullscreen
696
+ }));
697
+ };
698
+ CallGrid.displayName = "CallGrid";
699
+ var CallToolbar = (props) => {
700
+ return /* @__PURE__ */ React9.createElement("div", {
701
+ className: "absolute bottom-0 left-0 right-0 flex justify-center"
702
+ }, /* @__PURE__ */ React9.createElement(Toolbar, {
703
+ isInRoom: true,
704
+ ...props
705
+ }));
706
+ };
707
+ CallToolbar.displayName = "CallToolbar";
708
+ var Call = {
709
+ Root: CallRoot,
710
+ Grid: CallGrid,
711
+ Audio: CallAudio,
712
+ Toolbar: CallToolbar
713
+ };
714
+
715
+ // src/components/CallDebugPanel.tsx
716
+ import { WebRTCStats } from "@peermetrics/webrtc-stats";
717
+ import React10, { useEffect as useEffect6, useMemo as useMemo4, useState as useState4 } from "react";
718
+ import { truncateKey } from "@dxos/debug";
719
+ import { JsonView, Panel } from "@dxos/devtools";
720
+ import { log } from "@dxos/log";
721
+ import { IconButton as IconButton3, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
722
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/components/CallDebugPanel.tsx";
723
+ var CallDebugPanel = ({ state }) => {
724
+ const { t } = useTranslation3(meta.id);
725
+ const [open, setOpen] = useState4(false);
726
+ const handleToggle = () => setOpen(!open);
727
+ const [showServiceHistory, setShowServiceHistory] = useState4(false);
728
+ const handleToggleServiceHistory = () => setShowServiceHistory(!showServiceHistory);
729
+ const handleCopyRaw = async () => {
730
+ await navigator.clipboard.writeText(JSON.stringify({
731
+ users: state?.call?.users,
732
+ stats
733
+ }, null, 2));
734
+ };
735
+ const [showDetailedWebRTCStats, setShowDetailedWebRTCStats] = useState4(false);
736
+ const handleShowDetailedWebRTCStats = () => setShowDetailedWebRTCStats(!showDetailedWebRTCStats);
737
+ const webrtcStats = useMemo4(() => new WebRTCStats({
738
+ getStatsInterval: 1e3
739
+ }), []);
740
+ const [stats, setStats] = useState4();
741
+ useEffect6(() => {
742
+ const pc = state?.media.peer?.session?.peerConnection;
743
+ const handleStats = (stats2) => {
744
+ setStats(stats2.data);
745
+ };
746
+ let added = false;
747
+ if (pc && showDetailedWebRTCStats) {
748
+ webrtcStats.addConnection({
749
+ pc,
750
+ peerId: 1,
751
+ connectionId: "1"
752
+ });
753
+ webrtcStats.on("stats", handleStats);
754
+ added = true;
755
+ }
756
+ return () => {
757
+ try {
758
+ if (pc && added) {
759
+ webrtcStats.removeConnection({
760
+ pc
761
+ });
762
+ webrtcStats.removeListener("stats", handleStats);
763
+ }
764
+ } catch (error) {
765
+ log.error("error removing webrtc stats", {
766
+ error,
767
+ pc,
768
+ peerId: 1,
769
+ connectionId: "1"
770
+ }, {
771
+ F: __dxlog_file2,
772
+ L: 60,
773
+ S: void 0,
774
+ C: (f, a) => f(...a)
775
+ });
776
+ }
777
+ };
778
+ }, [
779
+ state?.media.peer?.session?.peerConnection,
780
+ showDetailedWebRTCStats
781
+ ]);
782
+ const rows = useMemo4(() => getCallStatusTable(state), [
783
+ state?.call.users,
784
+ state?.media.pulledAudioTracks
785
+ ]);
786
+ return /* @__PURE__ */ React10.createElement(Panel, {
787
+ id: "meeting-status",
788
+ icon: "ph--video-conference--regular",
789
+ open,
790
+ onToggle: handleToggle,
791
+ title: t("meeting status title"),
792
+ info: /* @__PURE__ */ React10.createElement("div", {
793
+ className: "flex items-center gap-2"
794
+ }, " ", state?.call.joined ? "Active" : "Inactive"),
795
+ maxHeight: 0
796
+ }, /* @__PURE__ */ React10.createElement("div", {
797
+ className: "flex flex-col is-full text-xs"
798
+ }, /* @__PURE__ */ React10.createElement("div", {
799
+ className: "flex items-center gap-2 items-center"
800
+ }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
801
+ checked: showDetailedWebRTCStats,
802
+ onCheckedChange: handleShowDetailedWebRTCStats
803
+ }), /* @__PURE__ */ React10.createElement(Input.Label, null, t("show webrtc stats title")))), /* @__PURE__ */ React10.createElement("div", {
804
+ className: "flex items-center gap-2 items-center"
805
+ }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
806
+ checked: showServiceHistory,
807
+ onCheckedChange: handleToggleServiceHistory
808
+ }), /* @__PURE__ */ React10.createElement(Input.Label, null, t("show calls history title")))), /* @__PURE__ */ React10.createElement("div", {
809
+ className: "flex items-center gap-2 items-center"
810
+ }, /* @__PURE__ */ React10.createElement(IconButton3, {
811
+ icon: "ph--copy--regular",
812
+ label: "copy raw",
813
+ onClick: handleCopyRaw
814
+ })), /* @__PURE__ */ React10.createElement(Table, {
815
+ rows
816
+ }), showDetailedWebRTCStats && /* @__PURE__ */ React10.createElement(JsonView, {
817
+ data: {
818
+ stats
819
+ }
820
+ }), showServiceHistory && /* @__PURE__ */ React10.createElement(JsonView, {
821
+ data: {
822
+ history: state?.media.peer?.history.get()
823
+ }
824
+ })));
825
+ };
826
+ var getCallStatusTable = (state) => {
827
+ if (!state || !state.call?.users) {
828
+ return [];
829
+ }
830
+ const self = state.call.self;
831
+ const users = state.call.users.filter((user) => user.id !== self.id).map((user) => {
832
+ const isOk = {
833
+ audio: user.tracks?.audio && state.media.pulledAudioTracks[user.tracks?.audio]?.ctx.disposed === false,
834
+ video: user.tracks?.video && state.media.pulledVideoStreams[user.tracks?.video]?.ctx.disposed === false,
835
+ screenshare: user.tracks?.screenshare && state.media.pulledVideoStreams[user.tracks?.screenshare]?.ctx.disposed === false
836
+ };
837
+ return {
838
+ ...user,
839
+ isOk
840
+ };
841
+ });
842
+ return [
843
+ [
844
+ "users",
845
+ state.call.users.length ?? 0
846
+ ],
847
+ [
848
+ "*self* " + (self?.name ?? truncateKey(self.id, 8)),
849
+ self?.tracks?.audio && state.media.pushedAudioTrack ? "AUD \u2705" : "AUD \u274C",
850
+ self?.tracks?.video && state.media.pushedVideoTrack ? "VID \u2705" : "VID \u274C",
851
+ self?.tracks?.screenshareEnabled ? self.tracks.screenshareEnabled && state.media.pushedScreenshareTrack ? "SCR \u2705" : "SCR \u274C" : void 0
852
+ ],
853
+ ...users.map((user) => [
854
+ user.name ?? truncateKey(user.id, 8),
855
+ user.isOk.audio ? "AUD \u2705" : "AUD \u274C",
856
+ user.isOk.video ? "VID \u2705" : "VID \u274C",
857
+ user.tracks?.screenshareEnabled ? user.isOk.screenshare ? "SCR \u2705" : "SCR \u274C" : void 0
858
+ ]),
859
+ [
860
+ "ICE",
861
+ state.media.peer?.session?.peerConnection.iceConnectionState ?? "no connection"
862
+ ]
863
+ ];
864
+ };
865
+ (function(Unit2) {
866
+ Unit2.KB = (n) => ((n ?? 0) / 1e3).toFixed(2);
867
+ })(Unit || (Unit = {}));
868
+ var Table = ({ rows }) => {
869
+ return /* @__PURE__ */ React10.createElement("div", {
870
+ className: "is-full text-xs font-mono"
871
+ }, rows.map(([prefix, label, value, unit], i) => /* @__PURE__ */ React10.createElement("div", {
872
+ key: i,
873
+ className: "grid grid-cols-[3fr_1fr_1fr_1fr]"
874
+ }, /* @__PURE__ */ React10.createElement("div", {
875
+ className: "p-1"
876
+ }, prefix), /* @__PURE__ */ React10.createElement("div", {
877
+ className: "p-1"
878
+ }, label), /* @__PURE__ */ React10.createElement("div", {
879
+ className: "p-1"
880
+ }, value), /* @__PURE__ */ React10.createElement("div", {
881
+ className: "p-1"
882
+ }, unit))));
883
+ };
884
+ var Unit;
885
+
886
+ // src/components/ChatContainer.tsx
887
+ import React12, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo5, useRef as useRef4, useState as useState6 } from "react";
888
+ import { Obj as Obj2, Ref as Ref2 } from "@dxos/echo";
889
+ import { useMembers } from "@dxos/react-client/echo";
890
+ import { useIdentity as useIdentity2 } from "@dxos/react-client/halo";
891
+ import { Icon as Icon3, ScrollArea, useThemeContext as useThemeContext2, useTranslation as useTranslation5 } from "@dxos/react-ui";
892
+ import { StackItem } from "@dxos/react-ui-stack";
893
+ import { MessageTextbox, Thread as ThreadComponent, threadLayout } from "@dxos/react-ui-thread";
894
+ import { Message } from "@dxos/types";
895
+ import { createBasicExtensions as createBasicExtensions2, createThemeExtensions as createThemeExtensions2, listener } from "@dxos/ui-editor";
896
+ import { mx as mx8 } from "@dxos/ui-theme";
897
+ import { isNonNullable } from "@dxos/util";
898
+
899
+ // src/components/command-extension.ts
900
+ import { HighlightStyle, StreamLanguage, syntaxHighlighting } from "@codemirror/language";
901
+ import { tags } from "@dxos/ui-editor";
902
+ import { mx as mx6 } from "@dxos/ui-theme";
903
+ var parser = StreamLanguage.define({
904
+ startState: () => ({
905
+ count: 0
906
+ }),
907
+ token: (stream, state) => {
908
+ state.count++;
909
+ if (stream.eatSpace()) {
910
+ return null;
911
+ }
912
+ if (state.count === 1 && stream.match(/^(\/\w+)/)) {
913
+ return "tagName";
914
+ }
915
+ stream.next();
916
+ return null;
917
+ }
918
+ });
919
+ var styles = HighlightStyle.define([
920
+ {
921
+ tag: tags.tagName,
922
+ class: mx6("dx-tag dx-tag--indigo text-baseText font-medium")
923
+ }
924
+ ]);
925
+ var command = [
926
+ parser,
927
+ syntaxHighlighting(styles)
928
+ ];
929
+
930
+ // src/components/MessageContainer.tsx
931
+ import { EditorView } from "@codemirror/view";
932
+ import React11, { forwardRef as forwardRef2, useCallback as useCallback2, useEffect as useEffect7, useRef as useRef3, useState as useState5 } from "react";
933
+ import { Surface } from "@dxos/app-framework/react";
934
+ import { Ref } from "@dxos/echo";
935
+ import { useObject } from "@dxos/echo-react";
936
+ import { PublicKey } from "@dxos/react-client";
937
+ import { useIdentity } from "@dxos/react-client/halo";
938
+ import { IconButton as IconButton4, useOnTransition, useThemeContext, useTranslation as useTranslation4 } from "@dxos/react-ui";
939
+ import { useTextEditor } from "@dxos/react-ui-editor";
940
+ import { Card } from "@dxos/react-ui-mosaic";
941
+ import { MessageHeading, MessageRoot } from "@dxos/react-ui-thread";
942
+ import { createBasicExtensions, createThemeExtensions } from "@dxos/ui-editor";
943
+ import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx as mx7 } from "@dxos/ui-theme";
944
+ var buttonGroupClassNames = "flex flex-row items-center gap-0.5 pie-2";
945
+ var buttonClassNames = "!p-1 transition-opacity";
946
+ var MessageContainer = ({ message: messageOrRef, members, editable = false, onDelete, onAcceptProposal }) => {
947
+ const { t } = useTranslation4(meta.id);
948
+ const [message, updateMessage] = useObject(messageOrRef);
949
+ const identity = useIdentity();
950
+ const [editing, setEditing] = useState5(false);
951
+ const textBlockIndex = message?.blocks.findIndex((block) => block._tag === "text") ?? -1;
952
+ const handleEdit = useCallback2(() => setEditing((editing2) => !editing2), []);
953
+ const handleDelete = useCallback2(() => message && onDelete?.(message.id), [
954
+ message,
955
+ onDelete
956
+ ]);
957
+ const handleAcceptProposal = useCallback2(() => message && onAcceptProposal?.(message.id), [
958
+ message,
959
+ onAcceptProposal
960
+ ]);
961
+ const handleTextBlockChange = useCallback2((newText) => {
962
+ updateMessage((m) => {
963
+ const targetBlock = m.blocks[textBlockIndex];
964
+ if (targetBlock && targetBlock._tag === "text") {
965
+ targetBlock.text = newText;
966
+ }
967
+ });
968
+ }, [
969
+ updateMessage,
970
+ textBlockIndex
971
+ ]);
972
+ const textBlock = message && textBlockIndex !== -1 ? message.blocks[textBlockIndex] : void 0;
973
+ useOnEditAnalytics(message, textBlock, !!editing);
974
+ if (!message) {
975
+ return null;
976
+ }
977
+ const senderIdentity = members.find((member) => message.sender.identityDid && member.identity.did === message.sender.identityDid || message.sender.identityKey && PublicKey.equals(member.identity.identityKey, message.sender.identityKey))?.identity;
978
+ const messageMetadata = getMessageMetadata(message.id, senderIdentity);
979
+ const userIsAuthor = identity?.did === messageMetadata.authorId;
980
+ const proposalBlock = message.blocks.find((block) => block._tag === "proposal");
981
+ const references = message.blocks.filter((block) => block._tag === "reference").map((block) => block.reference);
982
+ return /* @__PURE__ */ React11.createElement(MessageRoot, {
983
+ ...messageMetadata,
984
+ classNames: [
985
+ hoverableControls,
986
+ hoverableFocusedWithinControls
987
+ ]
988
+ }, /* @__PURE__ */ React11.createElement(MessageHeading, {
989
+ authorName: messageMetadata.authorName,
990
+ timestamp: messageMetadata.timestamp
991
+ }, /* @__PURE__ */ React11.createElement("div", {
992
+ role: "none",
993
+ className: buttonGroupClassNames
994
+ }, userIsAuthor && editable && /* @__PURE__ */ React11.createElement(IconButton4, {
995
+ "data-testid": editing ? "thread.message.save" : "thread.message.edit",
996
+ variant: "ghost",
997
+ icon: editing ? "ph--check--regular" : "ph--pencil-simple--regular",
998
+ iconOnly: true,
999
+ label: t(editing ? "save message label" : "edit message label"),
1000
+ classNames: [
1001
+ buttonClassNames,
1002
+ hoverableControlItem
1003
+ ],
1004
+ onClick: handleEdit
1005
+ }), proposalBlock && onAcceptProposal && /* @__PURE__ */ React11.createElement(IconButton4, {
1006
+ "data-testid": "thread.message.accept",
1007
+ variant: "ghost",
1008
+ icon: "ph--check--regular",
1009
+ iconOnly: true,
1010
+ label: t("accept proposal label"),
1011
+ classNames: [
1012
+ buttonClassNames,
1013
+ hoverableControlItem
1014
+ ],
1015
+ onClick: handleAcceptProposal
1016
+ }), onDelete && /* @__PURE__ */ React11.createElement(IconButton4, {
1017
+ "data-testid": "thread.message.delete",
1018
+ variant: "ghost",
1019
+ icon: "ph--x--regular",
1020
+ iconOnly: true,
1021
+ label: t("delete message label"),
1022
+ classNames: [
1023
+ buttonClassNames,
1024
+ hoverableControlItem
1025
+ ],
1026
+ onClick: handleDelete
1027
+ }))), textBlock && /* @__PURE__ */ React11.createElement(TextboxBlock, {
1028
+ block: textBlock,
1029
+ isAuthor: userIsAuthor,
1030
+ editing,
1031
+ onSave: handleTextBlockChange
1032
+ }), proposalBlock && /* @__PURE__ */ React11.createElement(ProposalBlock, {
1033
+ block: proposalBlock
1034
+ }), Ref.Array.targets(references).map((reference, index) => /* @__PURE__ */ React11.createElement(MessagePart, {
1035
+ key: index,
1036
+ part: reference
1037
+ })));
1038
+ };
1039
+ var MessagePart = ({ part }) => {
1040
+ return /* @__PURE__ */ React11.createElement(MessageBlockObjectTile, {
1041
+ subject: part
1042
+ });
1043
+ };
1044
+ var TextboxBlock = ({ block, isAuthor, editing, onSave }) => {
1045
+ const { themeMode } = useThemeContext();
1046
+ const inMemoryContentRef = useRef3(block.text);
1047
+ const handleDocumentChange = useCallback2((newState) => {
1048
+ inMemoryContentRef.current = newState;
1049
+ }, []);
1050
+ const saveDocumentChange = useCallback2(() => {
1051
+ onSave?.(inMemoryContentRef.current);
1052
+ }, [
1053
+ onSave
1054
+ ]);
1055
+ useOnTransition(editing, true, false, saveDocumentChange);
1056
+ const { parentRef, focusAttributes, view } = useTextEditor(() => ({
1057
+ initialValue: block.text,
1058
+ extensions: [
1059
+ createBasicExtensions({
1060
+ readOnly: !isAuthor || !editing
1061
+ }),
1062
+ createThemeExtensions({
1063
+ themeMode
1064
+ }),
1065
+ command,
1066
+ EditorView.updateListener.of((update) => {
1067
+ if (update.docChanged) {
1068
+ handleDocumentChange(update.state.doc.toString());
1069
+ }
1070
+ })
1071
+ ]
1072
+ }), [
1073
+ block.text,
1074
+ editing,
1075
+ isAuthor,
1076
+ themeMode,
1077
+ handleDocumentChange
1078
+ ]);
1079
+ useEffect7(() => {
1080
+ editing && view?.focus();
1081
+ }, [
1082
+ editing,
1083
+ view
1084
+ ]);
1085
+ return /* @__PURE__ */ React11.createElement("div", {
1086
+ role: "none",
1087
+ ref: parentRef,
1088
+ className: "mie-4",
1089
+ ...focusAttributes
1090
+ });
1091
+ };
1092
+ var ProposalBlock = ({ block }) => {
1093
+ return /* @__PURE__ */ React11.createElement("div", {
1094
+ role: "none",
1095
+ className: "mie-4 italic"
1096
+ }, block.text);
1097
+ };
1098
+ var MessageBlockObjectTile = /* @__PURE__ */ forwardRef2(({ subject }, forwardedRef) => {
1099
+ let title = subject.name ?? subject.title ?? subject.type ?? "Object";
1100
+ if (typeof title !== "string") {
1101
+ title = title?.content ?? "";
1102
+ }
1103
+ return /* @__PURE__ */ React11.createElement(Card.Root, {
1104
+ className: mx7("grid col-span-3 plb-1 pr-4", hoverableControls, hoverableFocusedWithinControls),
1105
+ ref: forwardedRef
1106
+ }, /* @__PURE__ */ React11.createElement(Surface, {
1107
+ role: "card-content",
1108
+ limit: 1,
1109
+ data: {
1110
+ subject
1111
+ },
1112
+ fallback: title
1113
+ }));
1114
+ });
1115
+
1116
+ // src/components/ChatContainer.tsx
1117
+ var ChatContainer = ({ classNames, space, thread, context, current, autoFocusTextbox }) => {
1118
+ const { t } = useTranslation5(meta.id);
1119
+ const id = Obj2.getDXN(thread).toString();
1120
+ const identity = useIdentity2();
1121
+ const members = useMembers(space?.id);
1122
+ const activity = useStatus(space, id);
1123
+ const [_count, _setCount] = useState6(0);
1124
+ const rerenderEditor = () => _setCount((count) => count + 1);
1125
+ const [autoFocus, setAutoFocus] = useState6(autoFocusTextbox);
1126
+ const threadScrollRef = useRef4(null);
1127
+ const { themeMode } = useThemeContext2();
1128
+ const textboxMetadata = getMessageMetadata(id, identity);
1129
+ const messageRef = useRef4("");
1130
+ const extensions = useMemo5(() => [
1131
+ createBasicExtensions2({
1132
+ placeholder: t("message placeholder")
1133
+ }),
1134
+ createThemeExtensions2({
1135
+ themeMode
1136
+ }),
1137
+ listener({
1138
+ onChange: ({ text }) => messageRef.current = text
1139
+ }),
1140
+ command
1141
+ ], [
1142
+ themeMode,
1143
+ _count
1144
+ ]);
1145
+ const scrollToEnd = (behavior) => setTimeout(() => threadScrollRef.current?.scrollIntoView({
1146
+ behavior,
1147
+ block: "end"
1148
+ }), 10);
1149
+ useLayoutEffect2(() => {
1150
+ scrollToEnd("instant");
1151
+ }, []);
1152
+ const handleCreate = () => {
1153
+ if (!messageRef.current?.length) {
1154
+ return false;
1155
+ }
1156
+ thread.messages.push(Ref2.make(Obj2.make(Message.Message, {
1157
+ created: (/* @__PURE__ */ new Date()).toISOString(),
1158
+ sender: {
1159
+ identityDid: identity.did
1160
+ },
1161
+ blocks: [
1162
+ {
1163
+ _tag: "text",
1164
+ text: messageRef.current
1165
+ }
1166
+ ],
1167
+ properties: context ? {
1168
+ context: Ref2.make(context)
1169
+ } : void 0
1170
+ })));
1171
+ messageRef.current = "";
1172
+ setAutoFocus(true);
1173
+ scrollToEnd("smooth");
1174
+ rerenderEditor();
1175
+ return true;
1176
+ };
1177
+ return /* @__PURE__ */ React12.createElement(ThreadComponent.Root, {
1178
+ current,
1179
+ id,
1180
+ classNames: [
1181
+ "bs-full grid-rows-[1fr_min-content_min-content] overflow-hidden",
1182
+ "transition-[padding-block-end] [[data-sidebar-inline-start-state=open]_&]:lg:pbe-0",
1183
+ classNames
1184
+ ]
1185
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
1186
+ classNames: "col-span-2"
1187
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, {
1188
+ classNames: "overflow-anchored after:overflow-anchor after:block after:bs-px after:-mbs-px [&>div]:min-bs-full [&>div]:!grid [&>div]:grid-rows-[1fr_0]"
1189
+ }, /* @__PURE__ */ React12.createElement("div", {
1190
+ role: "none",
1191
+ className: mx8(threadLayout, "place-self-end")
1192
+ }, thread.messages.map((message) => message.target).filter(isNonNullable).map((message) => /* @__PURE__ */ React12.createElement(MessageContainer, {
1193
+ key: message.id,
1194
+ message,
1195
+ members
1196
+ }))), /* @__PURE__ */ React12.createElement("div", {
1197
+ role: "none",
1198
+ className: "bs-px -mbs-px",
1199
+ ref: threadScrollRef
1200
+ })), /* @__PURE__ */ React12.createElement(ScrollArea.Scrollbar, null, /* @__PURE__ */ React12.createElement(ScrollArea.Thumb, null))), /* @__PURE__ */ React12.createElement(MessageTextbox, {
1201
+ extensions,
1202
+ autoFocus,
1203
+ onSend: handleCreate,
1204
+ ...textboxMetadata
1205
+ }), /* @__PURE__ */ React12.createElement(ThreadComponent.Status, {
1206
+ activity
1207
+ }, t("activity message")));
1208
+ };
1209
+ var ChatContainer_default = ChatContainer;
1210
+
1211
+ // src/components/ChannelContainer.tsx
1212
+ import { Atom, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
1213
+ import React13, { useCallback as useCallback3, useEffect as useEffect8, useMemo as useMemo6, useState as useState7 } from "react";
1214
+ import { useCapabilities, useCapability as useCapability4 } from "@dxos/app-framework/react";
1215
+ import { Context } from "@dxos/context";
1216
+ import { failUndefined } from "@dxos/debug";
1217
+ import { Obj as Obj3 } from "@dxos/echo";
1218
+ import { log as log2 } from "@dxos/log";
1219
+ import { useClient } from "@dxos/react-client";
1220
+ import { getSpace } from "@dxos/react-client/echo";
1221
+ import { useIdentity as useIdentity3 } from "@dxos/react-client/halo";
1222
+ import { ElevationProvider, Input as Input2, useTranslation as useTranslation6 } from "@dxos/react-ui";
1223
+ import { ControlGroup, ControlGroupButton, ControlItemInput } from "@dxos/react-ui-form";
1224
+ import { MenuProvider, ToolbarMenu, createMenuAction, createMenuItemGroup, useMenuActions } from "@dxos/react-ui-menu";
1225
+ import { useSoundEffect } from "@dxos/react-ui-sfx";
1226
+ import { StackItem as StackItem2 } from "@dxos/react-ui-stack";
1227
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/components/ChannelContainer.tsx";
1228
+ var ChannelContainer = ({ role, subject: channel, roomId: roomIdProp, fullscreen }) => {
1229
+ const space = getSpace(channel);
1230
+ const callManager = useCapability4(ThreadCapabilities.CallManager);
1231
+ const joined = useAtomValue4(callManager.joinedAtom);
1232
+ const currentRoomId = useAtomValue4(callManager.roomIdAtom);
1233
+ const attendableId = channel ? Obj3.getDXN(channel).toString() : void 0;
1234
+ const roomId = roomIdProp ?? attendableId ?? failUndefined();
1235
+ const identity = useIdentity3();
1236
+ const isNamed = !!identity?.profile?.displayName;
1237
+ const joinSound = useSoundEffect("JoinCall");
1238
+ const leaveSound = useSoundEffect("LeaveCall");
1239
+ const extensions = useCapabilities(ThreadCapabilities.CallExtension);
1240
+ useEffect8(() => {
1241
+ const ctx = new Context(void 0, {
1242
+ F: __dxlog_file3,
1243
+ L: 55
1244
+ });
1245
+ callManager.left.on(ctx, (roomId2) => {
1246
+ extensions.forEach((extension) => {
1247
+ void extension.onLeave?.(roomId2);
1248
+ });
1249
+ });
1250
+ callManager.callStateUpdated.on(ctx, (state) => {
1251
+ extensions.forEach((extension) => {
1252
+ void extension.onCallStateUpdated?.(state);
1253
+ });
1254
+ });
1255
+ callManager.mediaStateUpdated.on(ctx, (state) => {
1256
+ extensions.forEach((extension) => {
1257
+ void extension.onMediaStateUpdated?.(state);
1258
+ });
1259
+ });
1260
+ return () => {
1261
+ void ctx.dispose();
1262
+ };
1263
+ }, [
1264
+ callManager,
1265
+ extensions
1266
+ ]);
1267
+ const handleJoin = useCallback3(async () => {
1268
+ if (!roomId || !channel) {
1269
+ return;
1270
+ }
1271
+ if (joined) {
1272
+ await callManager.leave();
1273
+ }
1274
+ try {
1275
+ void joinSound.play();
1276
+ callManager.setRoomId(roomId);
1277
+ await callManager.join();
1278
+ await Promise.all(extensions.map((extension) => extension.onJoin?.({
1279
+ channel,
1280
+ roomId
1281
+ })));
1282
+ } catch (err) {
1283
+ log2.catch(err, void 0, {
1284
+ F: __dxlog_file3,
1285
+ L: 99,
1286
+ S: void 0,
1287
+ C: (f, a) => f(...a)
1288
+ });
1289
+ }
1290
+ }, [
1291
+ extensions,
1292
+ channel,
1293
+ roomId,
1294
+ joined
1295
+ ]);
1296
+ const handleLeave = useCallback3(async () => {
1297
+ try {
1298
+ void leaveSound.play();
1299
+ } catch (err) {
1300
+ log2.catch(err, void 0, {
1301
+ F: __dxlog_file3,
1302
+ L: 111,
1303
+ S: void 0,
1304
+ C: (f, a) => f(...a)
1305
+ });
1306
+ } finally {
1307
+ void callManager.turnAudioOff();
1308
+ void callManager.turnVideoOff();
1309
+ void callManager.turnScreenshareOff();
1310
+ void callManager.leave();
1311
+ }
1312
+ }, [
1313
+ extensions,
1314
+ roomId
1315
+ ]);
1316
+ const isJoined = joined && currentRoomId === roomId;
1317
+ return /* @__PURE__ */ React13.createElement(StackItem2.Content, {
1318
+ classNames: isJoined && "bs-full",
1319
+ toolbar: !isJoined
1320
+ }, isJoined && !isNamed && /* @__PURE__ */ React13.createElement(DisplayNameMissing, null), isJoined && isNamed && /* @__PURE__ */ React13.createElement(Call.Root, null, /* @__PURE__ */ React13.createElement(Call.Grid, {
1321
+ fullscreen
1322
+ }), /* @__PURE__ */ React13.createElement(Call.Toolbar, {
1323
+ channel,
1324
+ onLeave: handleLeave
1325
+ })), !isJoined && channel && channel.defaultThread.target && space && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(ChannelToolbar, {
1326
+ attendableId,
1327
+ role,
1328
+ onJoinCall: handleJoin
1329
+ }), /* @__PURE__ */ React13.createElement(ChatContainer_default, {
1330
+ space,
1331
+ thread: channel.defaultThread.target,
1332
+ classNames: "container-max-width"
1333
+ })));
1334
+ };
1335
+ var DisplayNameMissing = () => {
1336
+ const { t } = useTranslation6(meta.id);
1337
+ const client = useClient();
1338
+ const [displayName, setDisplayName] = useState7("");
1339
+ const handleChange = useCallback3((event) => setDisplayName(event.target.value), []);
1340
+ const handleSave = useCallback3(() => client.halo.updateProfile({
1341
+ displayName
1342
+ }), [
1343
+ client,
1344
+ displayName
1345
+ ]);
1346
+ return /* @__PURE__ */ React13.createElement(ControlGroup, {
1347
+ classNames: "p-4 place-content-center"
1348
+ }, /* @__PURE__ */ React13.createElement(ControlItemInput, {
1349
+ title: t("display name label"),
1350
+ description: t("display name description")
1351
+ }, /* @__PURE__ */ React13.createElement(Input2.TextInput, {
1352
+ value: displayName,
1353
+ onChange: handleChange,
1354
+ placeholder: t("display name input placeholder"),
1355
+ classNames: "md:min-is-64"
1356
+ })), /* @__PURE__ */ React13.createElement(ControlGroupButton, {
1357
+ disabled: !displayName,
1358
+ onClick: handleSave
1359
+ }, t("set display name label")));
1360
+ };
1361
+ var useChannelToolbarActions = (onJoinCall) => {
1362
+ const creator = useMemo6(() => Atom.make(() => {
1363
+ return {
1364
+ nodes: [
1365
+ createMenuItemGroup("root", {
1366
+ label: [
1367
+ "channel toolbar title",
1368
+ {
1369
+ ns: meta.id
1370
+ }
1371
+ ]
1372
+ }),
1373
+ createMenuAction("video-call", () => onJoinCall?.(), {
1374
+ label: [
1375
+ "start video call label",
1376
+ {
1377
+ ns: meta.id
1378
+ }
1379
+ ],
1380
+ icon: "ph--video-camera--regular",
1381
+ type: "video-call"
1382
+ })
1383
+ ],
1384
+ edges: [
1385
+ {
1386
+ source: "root",
1387
+ target: "video-call"
1388
+ }
1389
+ ]
1390
+ };
1391
+ }), []);
1392
+ return useMenuActions(creator);
1393
+ };
1394
+ var ChannelToolbar = ({ attendableId, role, onJoinCall }) => {
1395
+ const menuProps = useChannelToolbarActions(onJoinCall);
1396
+ return /* @__PURE__ */ React13.createElement(ElevationProvider, {
1397
+ elevation: role === "section" ? "positioned" : "base"
1398
+ }, /* @__PURE__ */ React13.createElement(MenuProvider, {
1399
+ ...menuProps,
1400
+ attendableId
1401
+ }, /* @__PURE__ */ React13.createElement(ToolbarMenu, {
1402
+ textBlockWidth: true
1403
+ })));
1404
+ };
1405
+
1406
+ // src/components/CallSidebar.tsx
1407
+ import { useAtomValue as useAtomValue5 } from "@effect-atom/atom-react";
1408
+ import React14 from "react";
1409
+ import { useCapability as useCapability5 } from "@dxos/app-framework/react";
1410
+ var CallSidebar = () => {
1411
+ const call = useCapability5(ThreadCapabilities.CallManager);
1412
+ const roomId = useAtomValue5(call.roomIdAtom);
1413
+ return /* @__PURE__ */ React14.createElement(ChannelContainer, {
1414
+ subject: void 0,
1415
+ roomId
1416
+ });
1417
+ };
1418
+
1419
+ // src/components/ThreadCompanion.tsx
1420
+ import { useAtomValue as useAtomValue6 } from "@effect-atom/atom-react";
1421
+ import React18, { useCallback as useCallback5, useMemo as useMemo8 } from "react";
1422
+ import { Common } from "@dxos/app-framework";
1423
+ import { useCapabilities as useCapabilities2, useCapability as useCapability6, useOperationInvoker } from "@dxos/app-framework/react";
1424
+ import { Filter, Obj as Obj6, Query, Relation as Relation3 } from "@dxos/echo";
1425
+ import { Ref as Ref3, useQuery } from "@dxos/react-client/echo";
1426
+ import { useIdentity as useIdentity5 } from "@dxos/react-client/halo";
1427
+ import { useTranslation as useTranslation10 } from "@dxos/react-ui";
1428
+ import { useAttended } from "@dxos/react-ui-attention";
1429
+ import { Layout } from "@dxos/react-ui-mosaic";
1430
+ import { Tabs } from "@dxos/react-ui-tabs";
1431
+ import { AnchoredTo, Thread } from "@dxos/types";
1432
+ import { mx as mx10 } from "@dxos/ui-theme";
1433
+
1434
+ // src/components/CommentsContainer.tsx
1435
+ import React16, { useEffect as useEffect9 } from "react";
1436
+ import { Obj as Obj5, Relation as Relation2 } from "@dxos/echo";
1437
+ import { Callout, Icon as Icon4, Trans, useTranslation as useTranslation8 } from "@dxos/react-ui";
1438
+
1439
+ // src/components/CommentsThreadContainer.tsx
1440
+ import React15, { useCallback as useCallback4, useMemo as useMemo7, useRef as useRef5, useState as useState8 } from "react";
1441
+ import { Obj as Obj4, Relation } from "@dxos/echo";
1442
+ import { useObject as useObject2 } from "@dxos/echo-react";
1443
+ import { getSpace as getSpace2, useMembers as useMembers2 } from "@dxos/react-client/echo";
1444
+ import { useIdentity as useIdentity4 } from "@dxos/react-client/halo";
1445
+ import { IconButton as IconButton5, Tag, Tooltip, useThemeContext as useThemeContext3, useTranslation as useTranslation7 } from "@dxos/react-ui";
1446
+ import { MessageTextbox as MessageTextbox2, Thread as ThreadComponent2 } from "@dxos/react-ui-thread";
1447
+ import { createBasicExtensions as createBasicExtensions3, createThemeExtensions as createThemeExtensions3, listener as listener2 } from "@dxos/ui-editor";
1448
+ import { hoverableControlItem as hoverableControlItem2, hoverableControls as hoverableControls2, hoverableFocusedWithinControls as hoverableFocusedWithinControls2, mx as mx9 } from "@dxos/ui-theme";
1449
+ var CommentsThreadContainer = ({ anchor, current, onAttend, onComment, onResolve, onMessageDelete, onThreadDelete, onAcceptProposal }) => {
1450
+ const { themeMode } = useThemeContext3();
1451
+ const { t } = useTranslation7(meta.id);
1452
+ const identity = useIdentity4();
1453
+ const space = getSpace2(anchor);
1454
+ const members = useMembers2(space?.id);
1455
+ const detached = !anchor.anchor;
1456
+ const thread = Relation.getSource(anchor);
1457
+ const [messages] = useObject2(thread, "messages");
1458
+ const activity = useStatus(space, Obj4.getDXN(thread).toString());
1459
+ const threadScrollRef = useRef5(null);
1460
+ const textboxMetadata = getMessageMetadata(Obj4.getDXN(thread).toString(), identity);
1461
+ const [state, setState] = useState8({});
1462
+ const messageRef = useRef5("");
1463
+ const extensions = useMemo7(() => [
1464
+ createBasicExtensions3({
1465
+ placeholder: t("message placeholder")
1466
+ }),
1467
+ createThemeExtensions3({
1468
+ themeMode
1469
+ }),
1470
+ listener2({
1471
+ onChange: ({ text }) => messageRef.current = text
1472
+ }),
1473
+ command
1474
+ ], [
1475
+ state
1476
+ ]);
1477
+ const scrollToEnd = (behavior) => setTimeout(() => threadScrollRef.current?.scrollIntoView({
1478
+ behavior,
1479
+ block: "end"
1480
+ }), 10);
1481
+ const handleAttend = useCallback4(() => onAttend?.(anchor), [
1482
+ onAttend,
1483
+ anchor
1484
+ ]);
1485
+ const handleResolve = useCallback4(() => onResolve?.(anchor), [
1486
+ onResolve,
1487
+ anchor
1488
+ ]);
1489
+ const handleMessageDelete = useCallback4((id) => onMessageDelete?.(anchor, id), [
1490
+ onMessageDelete,
1491
+ anchor
1492
+ ]);
1493
+ const handleThreadDelete = useCallback4(() => onThreadDelete?.(anchor), [
1494
+ onThreadDelete,
1495
+ anchor
1496
+ ]);
1497
+ const handleAcceptProposal = useCallback4((id) => onAcceptProposal?.(anchor, id), [
1498
+ onAcceptProposal,
1499
+ anchor
1500
+ ]);
1501
+ const handleComment = useCallback4(() => {
1502
+ if (!messageRef.current) {
1503
+ return false;
1504
+ }
1505
+ onComment?.(anchor, messageRef.current);
1506
+ messageRef.current = "";
1507
+ scrollToEnd("instant");
1508
+ setState({});
1509
+ return true;
1510
+ }, [
1511
+ anchor,
1512
+ identity
1513
+ ]);
1514
+ return /* @__PURE__ */ React15.createElement(ThreadComponent2.Root, {
1515
+ id: Obj4.getDXN(thread).toString(),
1516
+ classNames: "pbs-2 border-be border-subduedSeparator last:border-none",
1517
+ current,
1518
+ onClickCapture: handleAttend,
1519
+ onFocusCapture: handleAttend
1520
+ }, /* @__PURE__ */ React15.createElement("div", {
1521
+ role: "none",
1522
+ className: mx9("col-span-2 grid grid-cols-[var(--rail-size)_1fr_min-content]", hoverableControls2, hoverableFocusedWithinControls2)
1523
+ }, detached ? /* @__PURE__ */ React15.createElement(Tooltip.Trigger, {
1524
+ asChild: true,
1525
+ content: t("detached thread label"),
1526
+ side: "top"
1527
+ }, /* @__PURE__ */ React15.createElement(ThreadComponent2.Header, {
1528
+ detached: true
1529
+ }, thread.name)) : /* @__PURE__ */ React15.createElement(ThreadComponent2.Header, null, thread.name), /* @__PURE__ */ React15.createElement("div", {
1530
+ role: "none",
1531
+ className: buttonGroupClassNames
1532
+ }, thread.status === "staged" && /* @__PURE__ */ React15.createElement(Tag, {
1533
+ palette: "neutral"
1534
+ }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ React15.createElement(IconButton5, {
1535
+ "data-testid": "thread.resolve",
1536
+ variant: "ghost",
1537
+ icon: thread?.status === "resolved" ? "ph--check--fill" : "ph--check--regular",
1538
+ iconOnly: true,
1539
+ label: t("resolve thread label"),
1540
+ classNames: [
1541
+ buttonClassNames,
1542
+ thread?.status !== "resolved" && hoverableControlItem2
1543
+ ],
1544
+ onClick: handleResolve
1545
+ }), onThreadDelete && /* @__PURE__ */ React15.createElement(IconButton5, {
1546
+ "data-testid": "thread.delete",
1547
+ variant: "ghost",
1548
+ icon: "ph--x--regular",
1549
+ iconOnly: true,
1550
+ label: t("delete thread label"),
1551
+ classNames: [
1552
+ buttonClassNames,
1553
+ hoverableControlItem2
1554
+ ],
1555
+ onClick: handleThreadDelete
1556
+ }))), messages?.map((ref) => /* @__PURE__ */ React15.createElement(MessageContainer, {
1557
+ key: ref.dxn.toString(),
1558
+ editable: true,
1559
+ message: ref,
1560
+ members,
1561
+ onDelete: handleMessageDelete,
1562
+ onAcceptProposal: handleAcceptProposal
1563
+ })), /* @__PURE__ */ React15.createElement(MessageTextbox2, {
1564
+ extensions,
1565
+ onSend: handleComment,
1566
+ ...textboxMetadata
1567
+ }), /* @__PURE__ */ React15.createElement(ThreadComponent2.Status, {
1568
+ activity
1569
+ }, t("activity message")), /* @__PURE__ */ React15.createElement("div", {
1570
+ role: "none",
1571
+ className: "bs-px -mbs-px",
1572
+ ref: threadScrollRef
1573
+ }));
1574
+ };
1575
+
1576
+ // src/components/CommentsContainer.tsx
1577
+ var CommentsContainer = ({ anchors, currentId, showResolvedThreads, ...props }) => {
1578
+ const { t } = useTranslation8(meta.id);
1579
+ const filteredAnchors = showResolvedThreads ? anchors.filter((anchor) => !!Relation2.getSource(anchor)) : anchors.filter((anchor) => {
1580
+ const thread = Relation2.getSource(anchor);
1581
+ return thread && thread.status !== "resolved";
1582
+ });
1583
+ useEffect9(() => {
1584
+ if (currentId) {
1585
+ document.getElementById(currentId)?.scrollIntoView({
1586
+ behavior: "smooth",
1587
+ block: "end"
1588
+ });
1589
+ }
1590
+ }, [
1591
+ currentId
1592
+ ]);
1593
+ if (filteredAnchors.length === 0) {
1594
+ return /* @__PURE__ */ React16.createElement("div", {
1595
+ role: "none",
1596
+ className: "plb-cardSpacingBlock pli-cardSpacingInline"
1597
+ }, /* @__PURE__ */ React16.createElement(Callout.Root, null, /* @__PURE__ */ React16.createElement(Callout.Title, null, /* @__PURE__ */ React16.createElement(Trans, {
1598
+ t,
1599
+ i18nKey: "no comments message",
1600
+ components: {
1601
+ commentIcon: /* @__PURE__ */ React16.createElement(Icon4, {
1602
+ icon: "ph--chat-text--regular",
1603
+ size: 4,
1604
+ classNames: "inline-block"
1605
+ })
1606
+ }
1607
+ }))));
1608
+ }
1609
+ return /* @__PURE__ */ React16.createElement("div", null, filteredAnchors.map((anchor) => {
1610
+ const thread = Relation2.getSource(anchor);
1611
+ const threadId = Obj5.getDXN(thread).toString();
1612
+ return /* @__PURE__ */ React16.createElement(CommentsThreadContainer, {
1613
+ key: threadId,
1614
+ anchor,
1615
+ current: currentId === threadId,
1616
+ ...props
1617
+ });
1618
+ }));
1619
+ };
1620
+
1621
+ // src/components/ThreadSettings.tsx
1622
+ import React17 from "react";
1623
+ import { useTranslation as useTranslation9 } from "@dxos/react-ui";
1624
+ import { ControlPage } from "@dxos/react-ui-form";
1625
+ var ThreadSettings = ({ settings: _settings }) => {
1626
+ const { t: _t } = useTranslation9(meta.id);
1627
+ return /* @__PURE__ */ React17.createElement(ControlPage, null);
1628
+ };
1629
+
1630
+ // src/components/ThreadCompanion.tsx
1631
+ var initialViewState = {
1632
+ showResolvedThreads: false
1633
+ };
1634
+ var ThreadCompanion = ({ subject }) => {
1635
+ const { t } = useTranslation10(meta.id);
1636
+ const { invokePromise } = useOperationInvoker();
1637
+ const identity = useIdentity5();
1638
+ const subjectId = Obj6.getDXN(subject).toString();
1639
+ const registry = useCapability6(Common.Capability.AtomRegistry);
1640
+ const stateAtom = useCapability6(ThreadCapabilities.State);
1641
+ const viewStoreAtom = useCapability6(ThreadCapabilities.ViewState);
1642
+ const state = useAtomValue6(stateAtom);
1643
+ const viewStore = useAtomValue6(viewStoreAtom);
1644
+ const drafts = state.drafts[subjectId];
1645
+ const viewState = useMemo8(() => {
1646
+ if (!viewStore[subjectId]) {
1647
+ registry.set(viewStoreAtom, {
1648
+ ...viewStore,
1649
+ [subjectId]: {
1650
+ ...initialViewState
1651
+ }
1652
+ });
1653
+ return initialViewState;
1654
+ }
1655
+ return viewStore[subjectId];
1656
+ }, [
1657
+ viewStore,
1658
+ subjectId,
1659
+ registry,
1660
+ viewStoreAtom
1661
+ ]);
1662
+ const { showResolvedThreads } = viewState;
1663
+ const onChangeViewState = useCallback5((nextValue) => {
1664
+ registry.set(viewStoreAtom, {
1665
+ ...registry.get(viewStoreAtom),
1666
+ [subjectId]: {
1667
+ ...registry.get(viewStoreAtom)[subjectId],
1668
+ showResolvedThreads: nextValue === "all"
1669
+ }
1670
+ });
1671
+ }, [
1672
+ registry,
1673
+ viewStoreAtom,
1674
+ subjectId
1675
+ ]);
1676
+ const anchorSorts = useCapabilities2(Common.Capability.AnchorSort);
1677
+ const sort = useMemo8(() => anchorSorts.find(({ key }) => key === Obj6.getTypename(subject))?.sort, [
1678
+ anchorSorts,
1679
+ subject
1680
+ ]);
1681
+ const db = Obj6.getDatabase(subject);
1682
+ const objectsAnchoredTo = useQuery(db, Query.select(Filter.id(subject.id)).targetOf(AnchoredTo.AnchoredTo));
1683
+ const anchors = objectsAnchoredTo.toSorted((a, b) => sort?.(a, b) ?? 0).filter((anchor) => Obj6.instanceOf(Thread.Thread, Relation3.getSource(anchor))).concat(drafts ?? []);
1684
+ const attended = useAttended();
1685
+ const handleAttend = useCallback5((anchor) => {
1686
+ const thread = Relation3.getSource(anchor);
1687
+ const threadId = Obj6.getDXN(thread).toString();
1688
+ if (state.current !== threadId) {
1689
+ registry.set(stateAtom, {
1690
+ ...registry.get(stateAtom),
1691
+ current: threadId
1692
+ });
1693
+ void invokePromise(Common.LayoutOperation.ScrollIntoView, {
1694
+ subject: Obj6.getDXN(subject).toString(),
1695
+ cursor: anchor.anchor,
1696
+ ref: threadId
1697
+ });
1698
+ }
1699
+ }, [
1700
+ state.current,
1701
+ invokePromise,
1702
+ subject,
1703
+ registry,
1704
+ stateAtom
1705
+ ]);
1706
+ const handleComment = useCallback5(async (anchor, text) => {
1707
+ await invokePromise(ThreadOperation.AddMessage, {
1708
+ anchor,
1709
+ subject,
1710
+ sender: {
1711
+ identityDid: identity?.did
1712
+ },
1713
+ text
1714
+ });
1715
+ const thread = Relation3.getSource(anchor);
1716
+ registry.set(stateAtom, {
1717
+ ...registry.get(stateAtom),
1718
+ current: Obj6.getDXN(thread).toString()
1719
+ });
1720
+ }, [
1721
+ invokePromise,
1722
+ identity,
1723
+ subject,
1724
+ registry,
1725
+ stateAtom
1726
+ ]);
1727
+ const handleResolve = useCallback5((anchor) => invokePromise(ThreadOperation.ToggleResolved, {
1728
+ thread: Relation3.getSource(anchor)
1729
+ }), [
1730
+ invokePromise
1731
+ ]);
1732
+ const handleThreadDelete = useCallback5((anchor) => invokePromise(ThreadOperation.Delete, {
1733
+ anchor,
1734
+ subject
1735
+ }), [
1736
+ invokePromise,
1737
+ subject
1738
+ ]);
1739
+ const handleMessageDelete = useCallback5((anchor, messageId) => invokePromise(ThreadOperation.DeleteMessage, {
1740
+ anchor,
1741
+ subject,
1742
+ messageId
1743
+ }), [
1744
+ invokePromise,
1745
+ subject
1746
+ ]);
1747
+ const handleAcceptProposal = useCallback5(async (anchor, messageId) => {
1748
+ const thread = Relation3.getSource(anchor);
1749
+ const messageIndex = thread.messages.findIndex(Ref3.hasObjectId(messageId));
1750
+ const message = thread.messages[messageIndex]?.target;
1751
+ const proposal = message?.blocks.find((block) => block._tag === "proposal");
1752
+ if (!proposal || !anchor.anchor) {
1753
+ return;
1754
+ }
1755
+ await invokePromise(Common.CollaborationOperation.AcceptProposal, {
1756
+ subject,
1757
+ anchor: anchor.anchor,
1758
+ proposal
1759
+ });
1760
+ await invokePromise(ThreadOperation.ToggleResolved, {
1761
+ thread
1762
+ });
1763
+ }, [
1764
+ invokePromise,
1765
+ subject
1766
+ ]);
1767
+ const comments = /* @__PURE__ */ React18.createElement(CommentsContainer, {
1768
+ anchors,
1769
+ currentId: attended.includes(subjectId) ? state.current : void 0,
1770
+ showResolvedThreads,
1771
+ onAttend: handleAttend,
1772
+ onComment: handleComment,
1773
+ onResolve: handleResolve,
1774
+ onMessageDelete: handleMessageDelete,
1775
+ onThreadDelete: handleThreadDelete,
1776
+ onAcceptProposal: handleAcceptProposal
1777
+ });
1778
+ return /* @__PURE__ */ React18.createElement(Layout.Main, {
1779
+ toolbar: true
1780
+ }, /* @__PURE__ */ React18.createElement(Tabs.Root, {
1781
+ value: showResolvedThreads ? "all" : "unresolved",
1782
+ orientation: "horizontal",
1783
+ classNames: [
1784
+ 'contents [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:overflow-y-auto [&_[role="tabpanel"]]:scrollbar-thin'
1785
+ ],
1786
+ onValueChange: onChangeViewState
1787
+ }, /* @__PURE__ */ React18.createElement(Tabs.Tablist, {
1788
+ classNames: mx10("bg-toolbarSurface border-be border-subduedSeparator")
1789
+ }, /* @__PURE__ */ React18.createElement(Tabs.Tab, {
1790
+ value: "unresolved",
1791
+ classNames: "text-sm"
1792
+ }, t("show unresolved label")), /* @__PURE__ */ React18.createElement(Tabs.Tab, {
1793
+ value: "all",
1794
+ classNames: "text-sm"
1795
+ }, t("show all label"))), /* @__PURE__ */ React18.createElement("div", {
1796
+ className: "overflow-y-auto"
1797
+ }, /* @__PURE__ */ React18.createElement(Tabs.Tabpanel, {
1798
+ value: "all"
1799
+ }, showResolvedThreads && comments), /* @__PURE__ */ React18.createElement(Tabs.Tabpanel, {
1800
+ value: "unresolved"
1801
+ }, !showResolvedThreads && comments))));
1802
+ };
1803
+
1804
+ export {
1805
+ Call,
1806
+ CallDebugPanel,
1807
+ ChatContainer,
1808
+ ChannelContainer,
1809
+ CallSidebar,
1810
+ ThreadCompanion,
1811
+ ThreadSettings
1812
+ };
1813
+ //# sourceMappingURL=chunk-VZICDGBW.mjs.map