@dxos/plugin-space 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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 (258) hide show
  1. package/dist/lib/browser/app-graph-builder-MGK5HWPZ.mjs +288 -0
  2. package/dist/lib/browser/app-graph-builder-MGK5HWPZ.mjs.map +7 -0
  3. package/dist/lib/browser/app-graph-serializer-FOWFLYGU.mjs +80 -0
  4. package/dist/lib/browser/app-graph-serializer-FOWFLYGU.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-23RVI5FZ.mjs +539 -0
  6. package/dist/lib/browser/chunk-23RVI5FZ.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-NU7WDVGN.mjs +23 -0
  8. package/dist/lib/browser/chunk-NU7WDVGN.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-PQXZCNAU.mjs +13 -0
  10. package/dist/lib/browser/chunk-PQXZCNAU.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-S6B7627U.mjs +1809 -0
  12. package/dist/lib/browser/chunk-S6B7627U.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-UDWHTKB5.mjs +136 -0
  14. package/dist/lib/browser/chunk-UDWHTKB5.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-54VE4GTA.mjs → chunk-ULA2UQJ4.mjs} +25 -15
  16. package/dist/lib/browser/chunk-ULA2UQJ4.mjs.map +7 -0
  17. package/dist/lib/browser/identity-created-FYGS6TBH.mjs +28 -0
  18. package/dist/lib/browser/identity-created-FYGS6TBH.mjs.map +7 -0
  19. package/dist/lib/browser/index.mjs +219 -3480
  20. package/dist/lib/browser/index.mjs.map +4 -4
  21. package/dist/lib/browser/intent-resolver-QVR4MSJV.mjs +555 -0
  22. package/dist/lib/browser/intent-resolver-QVR4MSJV.mjs.map +7 -0
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/react-root-IP2ZB245.mjs +28 -0
  25. package/dist/lib/browser/react-root-IP2ZB245.mjs.map +7 -0
  26. package/dist/lib/browser/react-surface-BT3EHB6V.mjs +225 -0
  27. package/dist/lib/browser/react-surface-BT3EHB6V.mjs.map +7 -0
  28. package/dist/lib/browser/schema-5W3DSY2E.mjs +24 -0
  29. package/dist/lib/browser/schema-5W3DSY2E.mjs.map +7 -0
  30. package/dist/lib/browser/settings-PHPCXX33.mjs +24 -0
  31. package/dist/lib/browser/settings-PHPCXX33.mjs.map +7 -0
  32. package/dist/lib/browser/spaces-ready-K47RR7N2.mjs +199 -0
  33. package/dist/lib/browser/spaces-ready-K47RR7N2.mjs.map +7 -0
  34. package/dist/lib/browser/state-INJ63O57.mjs +47 -0
  35. package/dist/lib/browser/state-INJ63O57.mjs.map +7 -0
  36. package/dist/lib/browser/types/index.mjs +6 -4
  37. package/dist/lib/node/app-graph-builder-ZIUBXRPA.cjs +291 -0
  38. package/dist/lib/node/app-graph-builder-ZIUBXRPA.cjs.map +7 -0
  39. package/dist/lib/node/app-graph-serializer-VQOGHKXL.cjs +88 -0
  40. package/dist/lib/node/app-graph-serializer-VQOGHKXL.cjs.map +7 -0
  41. package/dist/lib/node/chunk-N2FS7PRA.cjs +1807 -0
  42. package/dist/lib/node/chunk-N2FS7PRA.cjs.map +7 -0
  43. package/dist/lib/node/chunk-OVGKWJOC.cjs +567 -0
  44. package/dist/lib/node/chunk-OVGKWJOC.cjs.map +7 -0
  45. package/dist/lib/node/chunk-U6DYXAR3.cjs +153 -0
  46. package/dist/lib/node/chunk-U6DYXAR3.cjs.map +7 -0
  47. package/dist/lib/node/{chunk-YF2AQ7KP.cjs → chunk-WAJKBO3J.cjs} +31 -20
  48. package/dist/lib/node/chunk-WAJKBO3J.cjs.map +7 -0
  49. package/dist/lib/node/{chunk-46S3JOES.cjs → chunk-WZR6OAN3.cjs} +9 -12
  50. package/dist/lib/node/chunk-WZR6OAN3.cjs.map +7 -0
  51. package/dist/lib/node/chunk-YZKNRFHU.cjs +43 -0
  52. package/dist/lib/node/chunk-YZKNRFHU.cjs.map +7 -0
  53. package/dist/lib/node/identity-created-AXI64BLE.cjs +44 -0
  54. package/dist/lib/node/identity-created-AXI64BLE.cjs.map +7 -0
  55. package/dist/lib/node/index.cjs +203 -3468
  56. package/dist/lib/node/index.cjs.map +4 -4
  57. package/dist/lib/node/intent-resolver-MLENGECT.cjs +553 -0
  58. package/dist/lib/node/intent-resolver-MLENGECT.cjs.map +7 -0
  59. package/dist/lib/node/meta.json +1 -1
  60. package/dist/lib/node/react-root-3OX5Z5CX.cjs +50 -0
  61. package/dist/lib/node/react-root-3OX5Z5CX.cjs.map +7 -0
  62. package/dist/lib/node/react-surface-5NYCMXSM.cjs +221 -0
  63. package/dist/lib/node/react-surface-5NYCMXSM.cjs.map +7 -0
  64. package/dist/lib/node/schema-YN7WVFRX.cjs +40 -0
  65. package/dist/lib/node/schema-YN7WVFRX.cjs.map +7 -0
  66. package/dist/lib/node/{meta.cjs → settings-5QYFWNH7.cjs} +19 -13
  67. package/dist/lib/node/settings-5QYFWNH7.cjs.map +7 -0
  68. package/dist/lib/node/spaces-ready-FQNAKR7G.cjs +210 -0
  69. package/dist/lib/node/spaces-ready-FQNAKR7G.cjs.map +7 -0
  70. package/dist/lib/node/state-57UE3DYE.cjs +61 -0
  71. package/dist/lib/node/state-57UE3DYE.cjs.map +7 -0
  72. package/dist/lib/node/types/index.cjs +19 -17
  73. package/dist/lib/node/types/index.cjs.map +2 -2
  74. package/dist/lib/node-esm/app-graph-builder-TERVM2SL.mjs +289 -0
  75. package/dist/lib/node-esm/app-graph-builder-TERVM2SL.mjs.map +7 -0
  76. package/dist/lib/node-esm/app-graph-serializer-GZRSWHEN.mjs +81 -0
  77. package/dist/lib/node-esm/app-graph-serializer-GZRSWHEN.mjs.map +7 -0
  78. package/dist/lib/node-esm/chunk-2TQ2AJEZ.mjs +137 -0
  79. package/dist/lib/node-esm/chunk-2TQ2AJEZ.mjs.map +7 -0
  80. package/dist/lib/node-esm/chunk-6RSVVEPS.mjs +24 -0
  81. package/dist/lib/node-esm/chunk-6RSVVEPS.mjs.map +7 -0
  82. package/dist/lib/node-esm/chunk-DIKRH2IK.mjs +1810 -0
  83. package/dist/lib/node-esm/chunk-DIKRH2IK.mjs.map +7 -0
  84. package/dist/lib/node-esm/{chunk-2MNFEB23.mjs → chunk-ICCM4YRJ.mjs} +5 -7
  85. package/dist/lib/node-esm/chunk-ICCM4YRJ.mjs.map +7 -0
  86. package/dist/lib/node-esm/chunk-PGH5L7MV.mjs +540 -0
  87. package/dist/lib/node-esm/chunk-PGH5L7MV.mjs.map +7 -0
  88. package/dist/lib/node-esm/{chunk-CDZETPO7.mjs → chunk-TRNZQEEN.mjs} +25 -15
  89. package/dist/lib/node-esm/chunk-TRNZQEEN.mjs.map +7 -0
  90. package/dist/lib/node-esm/identity-created-3CGEXNPO.mjs +29 -0
  91. package/dist/lib/node-esm/identity-created-3CGEXNPO.mjs.map +7 -0
  92. package/dist/lib/node-esm/index.mjs +219 -3480
  93. package/dist/lib/node-esm/index.mjs.map +4 -4
  94. package/dist/lib/node-esm/intent-resolver-BLW4RM6X.mjs +556 -0
  95. package/dist/lib/node-esm/intent-resolver-BLW4RM6X.mjs.map +7 -0
  96. package/dist/lib/node-esm/meta.json +1 -1
  97. package/dist/lib/node-esm/react-root-7XXGP56B.mjs +29 -0
  98. package/dist/lib/node-esm/react-root-7XXGP56B.mjs.map +7 -0
  99. package/dist/lib/node-esm/react-surface-R2ECJSFB.mjs +226 -0
  100. package/dist/lib/node-esm/react-surface-R2ECJSFB.mjs.map +7 -0
  101. package/dist/lib/node-esm/schema-LOR2EVGY.mjs +25 -0
  102. package/dist/lib/node-esm/schema-LOR2EVGY.mjs.map +7 -0
  103. package/dist/lib/node-esm/settings-H6MXTEQM.mjs +25 -0
  104. package/dist/lib/node-esm/settings-H6MXTEQM.mjs.map +7 -0
  105. package/dist/lib/node-esm/spaces-ready-HKAQG5SA.mjs +200 -0
  106. package/dist/lib/node-esm/spaces-ready-HKAQG5SA.mjs.map +7 -0
  107. package/dist/lib/node-esm/state-VYA6OFHD.mjs +48 -0
  108. package/dist/lib/node-esm/state-VYA6OFHD.mjs.map +7 -0
  109. package/dist/lib/node-esm/types/index.mjs +6 -4
  110. package/dist/types/src/SpacePlugin.d.ts +3 -22
  111. package/dist/types/src/SpacePlugin.d.ts.map +1 -1
  112. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  113. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  114. package/dist/types/src/capabilities/app-graph-serializer.d.ts +4 -0
  115. package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -0
  116. package/dist/types/src/capabilities/capabilities.d.ts +22 -0
  117. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  118. package/dist/types/src/capabilities/identity-created.d.ts +4 -0
  119. package/dist/types/src/capabilities/identity-created.d.ts.map +1 -0
  120. package/dist/types/src/capabilities/index.d.ts +197 -0
  121. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  122. package/dist/types/src/capabilities/intent-resolver.d.ts +9 -0
  123. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  124. package/dist/types/src/capabilities/react-root.d.ts +7 -0
  125. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  126. package/dist/types/src/capabilities/react-surface.d.ts +7 -0
  127. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  128. package/dist/types/src/capabilities/schema.d.ts +4 -0
  129. package/dist/types/src/capabilities/schema.d.ts.map +1 -0
  130. package/dist/types/src/capabilities/settings.d.ts +4 -0
  131. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  132. package/dist/types/src/capabilities/spaces-ready.d.ts +4 -0
  133. package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -0
  134. package/dist/types/src/capabilities/state.d.ts +5 -0
  135. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  136. package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts +6 -0
  137. package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts.map +1 -0
  138. package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts +7 -0
  139. package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts.map +1 -0
  140. package/dist/types/src/components/AdvancedObjectSettings/index.d.ts +2 -0
  141. package/dist/types/src/components/AdvancedObjectSettings/index.d.ts.map +1 -0
  142. package/dist/types/src/components/AwaitingObject.d.ts +1 -2
  143. package/dist/types/src/components/AwaitingObject.d.ts.map +1 -1
  144. package/dist/types/src/components/BaseObjectSettings.d.ts +6 -0
  145. package/dist/types/src/components/BaseObjectSettings.d.ts.map +1 -0
  146. package/dist/types/src/components/CollectionMain.d.ts +1 -2
  147. package/dist/types/src/components/CollectionMain.d.ts.map +1 -1
  148. package/dist/types/src/components/CollectionSection.d.ts +1 -2
  149. package/dist/types/src/components/CollectionSection.d.ts.map +1 -1
  150. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts +2 -5
  151. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
  152. package/dist/types/src/components/CreateDialog/CreateObjectDialog.stories.d.ts.map +1 -1
  153. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +9 -11
  154. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
  155. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts +1 -2
  156. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
  157. package/dist/types/src/components/JoinDialog.d.ts +1 -2
  158. package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
  159. package/dist/types/src/components/MenuFooter.d.ts +1 -2
  160. package/dist/types/src/components/MenuFooter.d.ts.map +1 -1
  161. package/dist/types/src/components/PersistenceStatus.d.ts +1 -2
  162. package/dist/types/src/components/PersistenceStatus.d.ts.map +1 -1
  163. package/dist/types/src/components/PopoverAddSpace.d.ts +3 -0
  164. package/dist/types/src/components/PopoverAddSpace.d.ts.map +1 -0
  165. package/dist/types/src/components/PopoverRenameObject.d.ts +1 -2
  166. package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -1
  167. package/dist/types/src/components/PopoverRenameSpace.d.ts +1 -2
  168. package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -1
  169. package/dist/types/src/components/ShareSpaceButton.d.ts +2 -3
  170. package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -1
  171. package/dist/types/src/components/SpacePluginSettings.d.ts +1 -2
  172. package/dist/types/src/components/SpacePluginSettings.d.ts.map +1 -1
  173. package/dist/types/src/components/SpacePresence.d.ts +4 -5
  174. package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
  175. package/dist/types/src/components/SpacePresence.stories.d.ts +2 -3
  176. package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -1
  177. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts +1 -2
  178. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts.map +1 -1
  179. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts +3 -5
  180. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts.map +1 -1
  181. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.stories.d.ts.map +1 -1
  182. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts +1 -2
  183. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts.map +1 -1
  184. package/dist/types/src/components/SyncStatus/Space.d.ts +2 -3
  185. package/dist/types/src/components/SyncStatus/Space.d.ts.map +1 -1
  186. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts +3 -4
  187. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts.map +1 -1
  188. package/dist/types/src/components/index.d.ts +3 -1
  189. package/dist/types/src/components/index.d.ts.map +1 -1
  190. package/dist/types/src/events.d.ts +9 -0
  191. package/dist/types/src/events.d.ts.map +1 -0
  192. package/dist/types/src/index.d.ts +3 -5
  193. package/dist/types/src/index.d.ts.map +1 -1
  194. package/dist/types/src/meta.d.ts +2 -4
  195. package/dist/types/src/meta.d.ts.map +1 -1
  196. package/dist/types/src/translations.d.ts +21 -0
  197. package/dist/types/src/translations.d.ts.map +1 -1
  198. package/dist/types/src/types/collection.d.ts +2 -2
  199. package/dist/types/src/types/thread.d.ts +34 -34
  200. package/dist/types/src/types/types.d.ts +41 -37
  201. package/dist/types/src/types/types.d.ts.map +1 -1
  202. package/dist/types/src/util.d.ts +10 -8
  203. package/dist/types/src/util.d.ts.map +1 -1
  204. package/dist/types/tsconfig.tsbuildinfo +1 -1
  205. package/package.json +41 -47
  206. package/src/SpacePlugin.tsx +141 -1410
  207. package/src/capabilities/app-graph-builder.ts +319 -0
  208. package/src/capabilities/app-graph-serializer.ts +73 -0
  209. package/src/capabilities/capabilities.ts +28 -0
  210. package/src/capabilities/identity-created.ts +26 -0
  211. package/src/capabilities/index.ts +18 -0
  212. package/src/capabilities/intent-resolver.ts +536 -0
  213. package/src/capabilities/react-root.tsx +20 -0
  214. package/src/capabilities/react-surface.tsx +210 -0
  215. package/src/capabilities/schema.ts +27 -0
  216. package/src/capabilities/settings.ts +17 -0
  217. package/src/capabilities/spaces-ready.ts +230 -0
  218. package/src/capabilities/state.ts +45 -0
  219. package/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx +72 -0
  220. package/src/components/AdvancedObjectSettings/ForeignKeys.tsx +51 -0
  221. package/src/components/AdvancedObjectSettings/index.ts +5 -0
  222. package/src/components/AwaitingObject.tsx +5 -11
  223. package/src/components/{DefaultObjectSettings.tsx → BaseObjectSettings.tsx} +9 -2
  224. package/src/components/CreateDialog/CreateObjectDialog.stories.tsx +1 -3
  225. package/src/components/CreateDialog/CreateObjectDialog.tsx +43 -35
  226. package/src/components/CreateDialog/CreateObjectPanel.tsx +139 -105
  227. package/src/components/CreateDialog/CreateSpaceDialog.tsx +18 -9
  228. package/src/components/JoinDialog.tsx +27 -19
  229. package/src/components/PopoverAddSpace.tsx +46 -0
  230. package/src/components/SpacePluginSettings.tsx +5 -10
  231. package/src/components/SpacePresence.stories.tsx +2 -2
  232. package/src/components/SpacePresence.tsx +7 -7
  233. package/src/components/SpaceSettings/SpaceSettingsDialog.tsx +16 -1
  234. package/src/components/SpaceSettings/SpaceSettingsPanel.stories.tsx +5 -1
  235. package/src/components/SpaceSettings/SpaceSettingsPanel.tsx +30 -8
  236. package/src/components/SyncStatus/InlineSyncStatus.tsx +2 -2
  237. package/src/components/SyncStatus/SyncStatus.tsx +2 -1
  238. package/src/components/index.ts +3 -1
  239. package/src/events.ts +18 -0
  240. package/src/index.ts +3 -7
  241. package/src/meta.ts +2 -3
  242. package/src/translations.ts +7 -0
  243. package/src/types/types.ts +32 -51
  244. package/src/util.tsx +45 -29
  245. package/dist/lib/browser/chunk-54VE4GTA.mjs.map +0 -7
  246. package/dist/lib/browser/chunk-73BCBSLP.mjs +0 -15
  247. package/dist/lib/browser/chunk-73BCBSLP.mjs.map +0 -7
  248. package/dist/lib/browser/meta.mjs +0 -11
  249. package/dist/lib/browser/meta.mjs.map +0 -7
  250. package/dist/lib/node/chunk-46S3JOES.cjs.map +0 -7
  251. package/dist/lib/node/chunk-YF2AQ7KP.cjs.map +0 -7
  252. package/dist/lib/node/meta.cjs.map +0 -7
  253. package/dist/lib/node-esm/chunk-2MNFEB23.mjs.map +0 -7
  254. package/dist/lib/node-esm/chunk-CDZETPO7.mjs.map +0 -7
  255. package/dist/lib/node-esm/meta.mjs +0 -12
  256. package/dist/lib/node-esm/meta.mjs.map +0 -7
  257. package/dist/types/src/components/DefaultObjectSettings.d.ts +0 -7
  258. package/dist/types/src/components/DefaultObjectSettings.d.ts.map +0 -1
@@ -0,0 +1,1810 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ SpaceCapabilities
4
+ } from "./chunk-6RSVVEPS.mjs";
5
+ import {
6
+ COMPOSER_SPACE_LOCK,
7
+ getSpaceDisplayName
8
+ } from "./chunk-PGH5L7MV.mjs";
9
+ import {
10
+ CollectionType,
11
+ SpaceAction,
12
+ SpaceForm
13
+ } from "./chunk-TRNZQEEN.mjs";
14
+ import {
15
+ SPACE_PLUGIN
16
+ } from "./chunk-ICCM4YRJ.mjs";
17
+
18
+ // packages/plugins/plugin-space/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx
19
+ import React2, { useCallback as useCallback2, useState } from "react";
20
+ import { ForeignKeySchema } from "@dxos/echo-schema";
21
+ import { getMeta } from "@dxos/react-client/echo";
22
+ import { IconButton as IconButton2, useTranslation as useTranslation2, Separator } from "@dxos/react-ui";
23
+ import { Form } from "@dxos/react-ui-form";
24
+
25
+ // packages/plugins/plugin-space/src/components/AdvancedObjectSettings/ForeignKeys.tsx
26
+ import React, { useCallback } from "react";
27
+ import { IconButton, List, ListItem, useTranslation } from "@dxos/react-ui";
28
+ var ForeignKeys = ({ keys, onDelete }) => {
29
+ return /* @__PURE__ */ React.createElement(List, {
30
+ classNames: "flex flex-col gap-2"
31
+ }, keys.map((key) => /* @__PURE__ */ React.createElement(KeyItem, {
32
+ key: key.id,
33
+ forignKey: key,
34
+ onDelete
35
+ })));
36
+ };
37
+ var KeyItem = ({ forignKey, onDelete }) => {
38
+ const { t } = useTranslation(SPACE_PLUGIN);
39
+ const handleDelete = useCallback(() => {
40
+ onDelete?.(forignKey);
41
+ }, [
42
+ forignKey,
43
+ onDelete
44
+ ]);
45
+ return /* @__PURE__ */ React.createElement(ListItem.Root, {
46
+ classNames: "px-2"
47
+ }, /* @__PURE__ */ React.createElement(ListItem.Heading, {
48
+ classNames: "flex flex-col grow truncate"
49
+ }, /* @__PURE__ */ React.createElement("div", null, forignKey.source), /* @__PURE__ */ React.createElement("div", {
50
+ className: "text-description text-sm truncate"
51
+ }, forignKey.id)), /* @__PURE__ */ React.createElement(ListItem.Endcap, null, /* @__PURE__ */ React.createElement(IconButton, {
52
+ iconOnly: true,
53
+ icon: "ph--x--regular",
54
+ variant: "ghost",
55
+ label: t("delete key"),
56
+ onClick: handleDelete
57
+ })));
58
+ };
59
+
60
+ // packages/plugins/plugin-space/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx
61
+ var initialValues = {
62
+ source: "",
63
+ id: ""
64
+ };
65
+ var AdvancedObjectSettings = ({ object }) => {
66
+ const { t } = useTranslation2(SPACE_PLUGIN);
67
+ const [adding, setAdding] = useState(false);
68
+ const keys = getMeta(object).keys;
69
+ const handleNew = useCallback2(() => setAdding(true), []);
70
+ const handleCancel = useCallback2(() => setAdding(false), []);
71
+ const handleSave = useCallback2((key) => {
72
+ const index = keys.findIndex(({ source, id }) => source === key.source && id === key.id);
73
+ if (index === -1) {
74
+ keys.push(key);
75
+ }
76
+ setAdding(false);
77
+ }, [
78
+ keys
79
+ ]);
80
+ const handleDelete = useCallback2((key) => {
81
+ const index = keys.findIndex(({ source, id }) => source === key.source && id === key.id);
82
+ if (index !== -1) {
83
+ keys.splice(index, 1);
84
+ }
85
+ }, [
86
+ keys
87
+ ]);
88
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Separator, null), /* @__PURE__ */ React2.createElement("div", {
89
+ className: "p-2 flex flex-col gap-4"
90
+ }, /* @__PURE__ */ React2.createElement("h2", null, t("advanced settings label")), /* @__PURE__ */ React2.createElement("div", {
91
+ className: "flex items-center"
92
+ }, /* @__PURE__ */ React2.createElement("h3", {
93
+ className: "text-sm font-semibold"
94
+ }, t("foreign keys")), /* @__PURE__ */ React2.createElement("div", {
95
+ className: "grow"
96
+ }), /* @__PURE__ */ React2.createElement(IconButton2, {
97
+ classNames: adding && "invisible",
98
+ icon: "ph--plus--regular",
99
+ label: t("add key"),
100
+ onClick: handleNew
101
+ })), !adding && /* @__PURE__ */ React2.createElement(ForeignKeys, {
102
+ keys,
103
+ onDelete: handleDelete
104
+ })), adding && /* @__PURE__ */ React2.createElement(Form, {
105
+ schema: ForeignKeySchema,
106
+ values: initialValues,
107
+ onSave: handleSave,
108
+ onCancel: handleCancel
109
+ }));
110
+ };
111
+
112
+ // packages/plugins/plugin-space/src/components/AwaitingObject.tsx
113
+ import { CheckCircle, CircleDashed, CircleNotch } from "@phosphor-icons/react";
114
+ import React3, { useCallback as useCallback3, useEffect, useState as useState2 } from "react";
115
+ import { createIntent, LayoutAction, useIntentDispatcher, useLayout } from "@dxos/app-framework";
116
+ import { useClient } from "@dxos/react-client";
117
+ import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
118
+ import { Button, Toast, useTranslation as useTranslation3 } from "@dxos/react-ui";
119
+ import { getSize, mx } from "@dxos/react-ui-theme";
120
+ var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
121
+ var TOAST_TIMEOUT = 24e4;
122
+ var AwaitingObject = ({ id }) => {
123
+ const [open, setOpen] = useState2(true);
124
+ const [waiting, setWaiting] = useState2(true);
125
+ const [found, setFound] = useState2(false);
126
+ const { t } = useTranslation3(SPACE_PLUGIN);
127
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
128
+ const layout = useLayout();
129
+ const client = useClient();
130
+ const objects = useQuery(client.spaces, Filter.all());
131
+ useEffect(() => {
132
+ if (!id) {
133
+ return;
134
+ }
135
+ const timeout = setTimeout(() => {
136
+ setWaiting(false);
137
+ }, WAIT_FOR_OBJECT_TIMEOUT);
138
+ () => clearTimeout(timeout);
139
+ }, [
140
+ id
141
+ ]);
142
+ useEffect(() => {
143
+ if (objects.findIndex((object) => fullyQualifiedId(object) === id) > -1) {
144
+ setFound(true);
145
+ if (layout.active.includes(id)) {
146
+ setOpen(false);
147
+ }
148
+ }
149
+ }, [
150
+ id,
151
+ objects,
152
+ layout
153
+ ]);
154
+ const handleClose = useCallback3(async () => dispatch(createIntent(SpaceAction.WaitForObject, {
155
+ id: void 0
156
+ })), [
157
+ dispatch
158
+ ]);
159
+ const handleNavigate = useCallback3(() => {
160
+ void dispatch(createIntent(LayoutAction.Open, {
161
+ part: "main",
162
+ subject: [
163
+ id
164
+ ]
165
+ }));
166
+ void handleClose();
167
+ }, [
168
+ id,
169
+ handleClose,
170
+ dispatch
171
+ ]);
172
+ return /* @__PURE__ */ React3.createElement(Toast.Root, {
173
+ open,
174
+ duration: TOAST_TIMEOUT,
175
+ onOpenChange: setOpen
176
+ }, /* @__PURE__ */ React3.createElement(Toast.Body, null, /* @__PURE__ */ React3.createElement(Toast.Title, {
177
+ classNames: "flex items-center gap-2"
178
+ }, found ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(CheckCircle, {
179
+ className: getSize(5)
180
+ }), /* @__PURE__ */ React3.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(CircleNotch, {
181
+ className: mx(getSize(5), "animate-spin")
182
+ }), /* @__PURE__ */ React3.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(CircleDashed, {
183
+ className: getSize(5)
184
+ }), /* @__PURE__ */ React3.createElement("span", null, t("object not found label")))), /* @__PURE__ */ React3.createElement(Toast.Description, null, t(found ? "found object description" : waiting ? "waiting for object description" : "object not found description"))), /* @__PURE__ */ React3.createElement(Toast.Actions, null, found ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Toast.Action, {
185
+ altText: t("go to object alt"),
186
+ asChild: true
187
+ }, /* @__PURE__ */ React3.createElement(Button, {
188
+ variant: "primary",
189
+ onClick: handleNavigate
190
+ }, t("go to object label"))), /* @__PURE__ */ React3.createElement(Toast.Close, {
191
+ asChild: true
192
+ }, /* @__PURE__ */ React3.createElement(Button, {
193
+ onClick: handleClose
194
+ }, t("close label", {
195
+ ns: "appkit"
196
+ })))) : /* @__PURE__ */ React3.createElement(Toast.Close, {
197
+ asChild: true
198
+ }, /* @__PURE__ */ React3.createElement(Button, {
199
+ onClick: handleClose
200
+ }, t(waiting ? "close label" : "confirm label", {
201
+ ns: "appkit"
202
+ })))));
203
+ };
204
+
205
+ // packages/plugins/plugin-space/src/components/BaseObjectSettings.tsx
206
+ import React4 from "react";
207
+ import { Input, useTranslation as useTranslation4 } from "@dxos/react-ui";
208
+ var BaseObjectSettings = ({ object }) => {
209
+ const { t } = useTranslation4(SPACE_PLUGIN);
210
+ const inputRef = React4.useRef(null);
211
+ return /* @__PURE__ */ React4.createElement("div", {
212
+ role: "form",
213
+ className: "flex flex-col w-full p-2 gap-1"
214
+ }, /* @__PURE__ */ React4.createElement(Input.Root, null, /* @__PURE__ */ React4.createElement(Input.Label, null, t("name label")), /* @__PURE__ */ React4.createElement(Input.TextInput, {
215
+ ref: inputRef,
216
+ placeholder: t("name placeholder"),
217
+ value: object.name ?? "",
218
+ onChange: (event) => {
219
+ object.name = event.target.value;
220
+ },
221
+ onKeyDown: (event) => {
222
+ if (event.key === "Enter") {
223
+ inputRef.current?.blur();
224
+ }
225
+ }
226
+ })));
227
+ };
228
+
229
+ // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
230
+ import { pipe } from "effect";
231
+ import React6, { useCallback as useCallback5, useRef } from "react";
232
+ import { Capabilities, chain, createIntent as createIntent2, LayoutAction as LayoutAction2, useCapabilities, useIntentDispatcher as useIntentDispatcher2, usePluginManager as usePluginManager2 } from "@dxos/app-framework";
233
+ import { invariant as invariant2 } from "@dxos/invariant";
234
+ import { useClient as useClient2 } from "@dxos/react-client";
235
+ import { getSpace, isReactiveObject, isSpace, useSpaces } from "@dxos/react-client/echo";
236
+ import { Button as Button2, Dialog, Icon as Icon2, useTranslation as useTranslation6 } from "@dxos/react-ui";
237
+
238
+ // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx
239
+ import React5, { useCallback as useCallback4, useState as useState3 } from "react";
240
+ import { Surface, isSurfaceAvailable, usePluginManager } from "@dxos/app-framework";
241
+ import { getObjectAnnotation } from "@dxos/echo-schema";
242
+ import { invariant } from "@dxos/invariant";
243
+ import { Icon, toLocalizedString, useTranslation as useTranslation5 } from "@dxos/react-ui";
244
+ import { Form as Form2 } from "@dxos/react-ui-form";
245
+ import { SearchList } from "@dxos/react-ui-searchlist";
246
+ import { mx as mx2 } from "@dxos/react-ui-theme";
247
+ import { isNonNullable } from "@dxos/util";
248
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx";
249
+ var useInputSurfaceLookup = (baseData) => {
250
+ const pluginManager = usePluginManager();
251
+ return useCallback4(({ prop, schema, inputProps }) => {
252
+ const composedData = {
253
+ prop,
254
+ schema,
255
+ ...baseData
256
+ };
257
+ if (!isSurfaceAvailable(pluginManager.context, {
258
+ role: "form-input",
259
+ data: composedData
260
+ })) {
261
+ return void 0;
262
+ }
263
+ return /* @__PURE__ */ React5.createElement(Surface, {
264
+ role: "form-input",
265
+ data: composedData,
266
+ ...inputProps
267
+ });
268
+ }, [
269
+ pluginManager,
270
+ baseData
271
+ ]);
272
+ };
273
+ var CreateObjectPanel = ({ classNames, forms, spaces, typename: initialTypename, target: initialTarget, name: initialName, defaultSpaceId, resolve, onCreateObject }) => {
274
+ const { t } = useTranslation5(SPACE_PLUGIN);
275
+ const [typename, setTypename] = useState3(initialTypename);
276
+ const [target, setTarget] = useState3(initialTarget);
277
+ const form = forms.find((form2) => getObjectAnnotation(form2.objectSchema)?.typename === typename);
278
+ const options = forms.map((form2) => getObjectAnnotation(form2.objectSchema)).filter(isNonNullable).sort((a, b) => {
279
+ const nameA = t("typename label", {
280
+ ns: a.typename,
281
+ defaultValue: a.typename
282
+ });
283
+ const nameB = t("typename label", {
284
+ ns: b.typename,
285
+ defaultValue: b.typename
286
+ });
287
+ return nameA.localeCompare(nameB);
288
+ });
289
+ const handleCreateObject = useCallback4(async (props) => {
290
+ if (!form || !target) {
291
+ return;
292
+ }
293
+ await onCreateObject?.({
294
+ form,
295
+ target,
296
+ data: props
297
+ });
298
+ }, [
299
+ onCreateObject,
300
+ form,
301
+ target
302
+ ]);
303
+ const handleSetTypename = useCallback4(async (typename2) => {
304
+ invariant(target, "target is required", {
305
+ F: __dxlog_file,
306
+ L: 94,
307
+ S: void 0,
308
+ A: [
309
+ "target",
310
+ "'target is required'"
311
+ ]
312
+ });
313
+ const form2 = forms.find((form3) => getObjectAnnotation(form3.objectSchema)?.typename === typename2);
314
+ if (form2 && !form2.formSchema) {
315
+ await onCreateObject?.({
316
+ form: form2,
317
+ target
318
+ });
319
+ } else {
320
+ setTypename(typename2);
321
+ }
322
+ }, [
323
+ forms,
324
+ onCreateObject,
325
+ target
326
+ ]);
327
+ const inputSurfaceLookup = useInputSurfaceLookup({
328
+ target
329
+ });
330
+ return /* @__PURE__ */ React5.createElement("div", {
331
+ role: "form",
332
+ className: mx2("flex flex-col gap-2", classNames)
333
+ }, !form ? /* @__PURE__ */ React5.createElement(SelectSchema, {
334
+ options,
335
+ resolve,
336
+ onChange: handleSetTypename
337
+ }) : !target ? /* @__PURE__ */ React5.createElement(SelectSpace, {
338
+ spaces,
339
+ defaultSpaceId,
340
+ onChange: setTarget
341
+ }) : form.formSchema ? /* @__PURE__ */ React5.createElement(Form2, {
342
+ classNames: "!p-0",
343
+ autoFocus: true,
344
+ values: {
345
+ name: initialName
346
+ },
347
+ schema: form.formSchema,
348
+ testId: "create-object-form",
349
+ onSave: handleCreateObject,
350
+ lookupComponent: inputSurfaceLookup
351
+ }) : void 0);
352
+ };
353
+ var SelectSpace = ({ spaces, defaultSpaceId, onChange }) => {
354
+ const { t } = useTranslation5(SPACE_PLUGIN);
355
+ return /* @__PURE__ */ React5.createElement(SearchList.Root, {
356
+ label: t("space input label"),
357
+ classNames: "flex flex-col grow overflow-hidden"
358
+ }, /* @__PURE__ */ React5.createElement(SearchList.Input, {
359
+ autoFocus: true,
360
+ "data-testid": "create-object-form.space-input",
361
+ placeholder: t("space input placeholder"),
362
+ classNames: "px-1 my-2"
363
+ }), /* @__PURE__ */ React5.createElement(SearchList.Content, {
364
+ classNames: "max-bs-[24rem] overflow-auto"
365
+ }, spaces.sort((a, b) => {
366
+ const aName = toLocalizedString(getSpaceDisplayName(a, {
367
+ personal: a.id === defaultSpaceId
368
+ }), t);
369
+ const bName = toLocalizedString(getSpaceDisplayName(b, {
370
+ personal: b.id === defaultSpaceId
371
+ }), t);
372
+ return aName.localeCompare(bName);
373
+ }).map((space) => /* @__PURE__ */ React5.createElement(SearchList.Item, {
374
+ key: space.id,
375
+ value: toLocalizedString(getSpaceDisplayName(space, {
376
+ personal: space.id === defaultSpaceId
377
+ }), t),
378
+ onSelect: () => onChange(space),
379
+ classNames: "flex items-center gap-2"
380
+ }, /* @__PURE__ */ React5.createElement("span", {
381
+ className: "grow truncate"
382
+ }, toLocalizedString(getSpaceDisplayName(space, {
383
+ personal: space.id === defaultSpaceId
384
+ }), t))))));
385
+ };
386
+ var SelectSchema = ({ options, resolve, onChange }) => {
387
+ const { t } = useTranslation5(SPACE_PLUGIN);
388
+ return /* @__PURE__ */ React5.createElement(SearchList.Root, {
389
+ label: t("schema input label"),
390
+ classNames: "flex flex-col grow overflow-hidden"
391
+ }, /* @__PURE__ */ React5.createElement(SearchList.Input, {
392
+ autoFocus: true,
393
+ "data-testid": "create-object-form.schema-input",
394
+ placeholder: t("schema input placeholder"),
395
+ classNames: "px-1 my-2"
396
+ }), /* @__PURE__ */ React5.createElement(SearchList.Content, {
397
+ classNames: "max-bs-[24rem] overflow-auto"
398
+ }, options.map((option) => /* @__PURE__ */ React5.createElement(SearchList.Item, {
399
+ key: option.typename,
400
+ value: t("typename label", {
401
+ ns: option.typename,
402
+ defaultValue: option.typename
403
+ }),
404
+ onSelect: () => onChange(option.typename),
405
+ classNames: "flex items-center gap-2"
406
+ }, /* @__PURE__ */ React5.createElement("span", {
407
+ className: "flex gap-2 items-center grow truncate"
408
+ }, /* @__PURE__ */ React5.createElement(Icon, {
409
+ icon: resolve?.(option.typename).icon ?? "ph--placeholder--regular",
410
+ size: 5
411
+ }), t("typename label", {
412
+ ns: option.typename,
413
+ defaultValue: option.typename
414
+ }))))));
415
+ };
416
+
417
+ // packages/plugins/plugin-space/src/capabilities/index.ts
418
+ import { lazy } from "@dxos/app-framework";
419
+ var AppGraphBuilder = lazy(() => import("./app-graph-builder-TERVM2SL.mjs"));
420
+ var AppGraphSerializer = lazy(() => import("./app-graph-serializer-GZRSWHEN.mjs"));
421
+ var IdentityCreated = lazy(() => import("./identity-created-3CGEXNPO.mjs"));
422
+ var IntentResolver = lazy(() => import("./intent-resolver-BLW4RM6X.mjs"));
423
+ var ReactRoot = lazy(() => import("./react-root-7XXGP56B.mjs"));
424
+ var ReactSurface = lazy(() => import("./react-surface-R2ECJSFB.mjs"));
425
+ var Schema = lazy(() => import("./schema-LOR2EVGY.mjs"));
426
+ var SpaceSettings = lazy(() => import("./settings-H6MXTEQM.mjs"));
427
+ var SpaceState = lazy(() => import("./state-VYA6OFHD.mjs"));
428
+ var SpacesReady = lazy(() => import("./spaces-ready-HKAQG5SA.mjs"));
429
+
430
+ // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
431
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx";
432
+ var CREATE_OBJECT_DIALOG = `${SPACE_PLUGIN}/CreateObjectDialog`;
433
+ var CreateObjectDialog = ({ target, typename, name, shouldNavigate: _shouldNavigate }) => {
434
+ const closeRef = useRef(null);
435
+ const manager = usePluginManager2();
436
+ const { t } = useTranslation6(SPACE_PLUGIN);
437
+ const client = useClient2();
438
+ const spaces = useSpaces();
439
+ const { dispatchPromise: dispatch } = useIntentDispatcher2();
440
+ const forms = useCapabilities(SpaceCapabilities.ObjectForm);
441
+ const resolve = useCallback5((typename2) => manager.context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename2)?.metadata ?? {}, [
442
+ manager
443
+ ]);
444
+ const handleCreateObject = useCallback5(async ({ form, target: _target, data = {} }) => {
445
+ const target2 = isSpace(_target) ? _target.properties[CollectionType.typename]?.target : _target;
446
+ if (!target2) {
447
+ return;
448
+ }
449
+ closeRef.current?.click();
450
+ const space = isSpace(target2) ? target2 : getSpace(target2);
451
+ invariant2(space, "Missing space", {
452
+ F: __dxlog_file2,
453
+ L: 75,
454
+ S: void 0,
455
+ A: [
456
+ "space",
457
+ "'Missing space'"
458
+ ]
459
+ });
460
+ const result = await dispatch(form.getIntent(data, {
461
+ space
462
+ }));
463
+ const object = result.data?.object;
464
+ if (isReactiveObject(object)) {
465
+ const addObjectIntent = createIntent2(SpaceAction.AddObject, {
466
+ target: target2,
467
+ object
468
+ });
469
+ const shouldNavigate = _shouldNavigate ?? (() => true);
470
+ if (shouldNavigate(object)) {
471
+ await dispatch(pipe(addObjectIntent, chain(LayoutAction2.Open, {
472
+ part: "main"
473
+ })));
474
+ } else {
475
+ await dispatch(addObjectIntent);
476
+ }
477
+ }
478
+ }, [
479
+ dispatch,
480
+ resolve
481
+ ]);
482
+ return (
483
+ // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
484
+ // Consider factoring it out to the tabs package.
485
+ /* @__PURE__ */ React6.createElement(Dialog.Content, {
486
+ classNames: "p-0 bs-content max-bs-full md:max-is-[40rem] overflow-hidden"
487
+ }, /* @__PURE__ */ React6.createElement("div", {
488
+ role: "none",
489
+ className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
490
+ }, /* @__PURE__ */ React6.createElement(Dialog.Title, null, t("create object dialog title")), /* @__PURE__ */ React6.createElement(Dialog.Close, {
491
+ asChild: true
492
+ }, /* @__PURE__ */ React6.createElement(Button2, {
493
+ ref: closeRef,
494
+ density: "fine",
495
+ variant: "ghost",
496
+ autoFocus: true
497
+ }, /* @__PURE__ */ React6.createElement(Icon2, {
498
+ icon: "ph--x--regular",
499
+ size: 4
500
+ })))), /* @__PURE__ */ React6.createElement(CreateObjectPanel, {
501
+ classNames: "p-4",
502
+ forms,
503
+ spaces,
504
+ target,
505
+ typename,
506
+ name,
507
+ defaultSpaceId: client.spaces.default.id,
508
+ resolve,
509
+ onCreateObject: handleCreateObject
510
+ }))
511
+ );
512
+ };
513
+
514
+ // packages/plugins/plugin-space/src/components/CreateDialog/CreateSpaceDialog.tsx
515
+ import { Effect } from "effect";
516
+ import React7, { useCallback as useCallback6, useRef as useRef2 } from "react";
517
+ import { createIntent as createIntent3, LayoutAction as LayoutAction3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
518
+ import { Button as Button3, Dialog as Dialog2, Icon as Icon3, useTranslation as useTranslation7 } from "@dxos/react-ui";
519
+ import { Form as Form3 } from "@dxos/react-ui-form";
520
+ var CREATE_SPACE_DIALOG = `${SPACE_PLUGIN}/CreateSpaceDialog`;
521
+ var initialValues2 = {
522
+ edgeReplication: true
523
+ };
524
+ var CreateSpaceDialog = () => {
525
+ const closeRef = useRef2(null);
526
+ const { t } = useTranslation7(SPACE_PLUGIN);
527
+ const { dispatch } = useIntentDispatcher3();
528
+ const handleCreateSpace = useCallback6(async (data) => {
529
+ const program = Effect.gen(function* () {
530
+ const { space } = yield* dispatch(createIntent3(SpaceAction.Create, data));
531
+ yield* dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
532
+ part: "workspace",
533
+ subject: space.id
534
+ }));
535
+ yield* dispatch(createIntent3(SpaceAction.OpenCreateObject, {
536
+ target: space
537
+ }));
538
+ });
539
+ await Effect.runPromise(program);
540
+ }, [
541
+ dispatch
542
+ ]);
543
+ return (
544
+ // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
545
+ // Consider factoring it out to the tabs package.
546
+ /* @__PURE__ */ React7.createElement(Dialog2.Content, {
547
+ classNames: "p-0 bs-content min-bs-[16rem] max-bs-full md:max-is-[32rem] overflow-hidden"
548
+ }, /* @__PURE__ */ React7.createElement("div", {
549
+ role: "none",
550
+ className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
551
+ }, /* @__PURE__ */ React7.createElement(Dialog2.Title, null, t("create space dialog title")), /* @__PURE__ */ React7.createElement(Dialog2.Close, {
552
+ asChild: true
553
+ }, /* @__PURE__ */ React7.createElement(Button3, {
554
+ ref: closeRef,
555
+ density: "fine",
556
+ variant: "ghost",
557
+ autoFocus: true
558
+ }, /* @__PURE__ */ React7.createElement(Icon3, {
559
+ icon: "ph--x--regular",
560
+ size: 4
561
+ })))), /* @__PURE__ */ React7.createElement("div", {
562
+ className: "p-4"
563
+ }, /* @__PURE__ */ React7.createElement(Form3, {
564
+ testId: "create-space-form",
565
+ classNames: "!p-0",
566
+ autoFocus: true,
567
+ values: initialValues2,
568
+ schema: SpaceForm,
569
+ onSave: handleCreateSpace
570
+ })))
571
+ );
572
+ };
573
+
574
+ // packages/plugins/plugin-space/src/components/CollectionMain.tsx
575
+ import React8 from "react";
576
+ import { useTranslation as useTranslation8 } from "@dxos/react-ui";
577
+ import { baseSurface, descriptionText, mx as mx3 } from "@dxos/react-ui-theme";
578
+ var CollectionMain = ({ collection }) => {
579
+ const { t } = useTranslation8(SPACE_PLUGIN);
580
+ return /* @__PURE__ */ React8.createElement("div", {
581
+ role: "none",
582
+ className: mx3(baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
583
+ "data-testid": "composer.firstRunMessage"
584
+ }, /* @__PURE__ */ React8.createElement("p", {
585
+ role: "alert",
586
+ className: mx3(descriptionText, "border border-dashed border-neutral-400/50 rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
587
+ }, collection.name ?? t("unnamed collection label")));
588
+ };
589
+
590
+ // packages/plugins/plugin-space/src/components/CollectionSection.tsx
591
+ import React9 from "react";
592
+ import { useTranslation as useTranslation9 } from "@dxos/react-ui";
593
+ var CollectionSection = ({ collection }) => {
594
+ const { t } = useTranslation9(SPACE_PLUGIN);
595
+ return /* @__PURE__ */ React9.createElement("div", {
596
+ className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
597
+ }, /* @__PURE__ */ React9.createElement("span", {
598
+ className: "truncate"
599
+ }, collection.name ?? t("unnamed collection label")));
600
+ };
601
+
602
+ // packages/plugins/plugin-space/src/components/JoinDialog.tsx
603
+ import React10, { useCallback as useCallback7 } from "react";
604
+ import { createIntent as createIntent4, LayoutAction as LayoutAction4, useAppGraph, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
605
+ import { log } from "@dxos/log";
606
+ import { ObservabilityAction } from "@dxos/plugin-observability/types";
607
+ import { useClient as useClient3 } from "@dxos/react-client";
608
+ import { Dialog as Dialog3 } from "@dxos/react-ui";
609
+ import { JoinPanel } from "@dxos/shell/react";
610
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/JoinDialog.tsx";
611
+ var JOIN_DIALOG = `${SPACE_PLUGIN}/JoinDialog`;
612
+ var JoinDialog = ({ navigableCollections, onDone, ...props }) => {
613
+ const { dispatchPromise: dispatch } = useIntentDispatcher4();
614
+ const client = useClient3();
615
+ const { graph } = useAppGraph();
616
+ const handleDone = useCallback7(async (result) => {
617
+ if (result?.spaceKey) {
618
+ await Promise.all([
619
+ dispatch(createIntent4(LayoutAction4.AddToast, {
620
+ part: "toast",
621
+ subject: {
622
+ id: `${SPACE_PLUGIN}/join-success`,
623
+ duration: 5e3,
624
+ title: [
625
+ "join success label",
626
+ {
627
+ ns: SPACE_PLUGIN
628
+ }
629
+ ],
630
+ closeLabel: [
631
+ "dismiss label",
632
+ {
633
+ ns: SPACE_PLUGIN
634
+ }
635
+ ]
636
+ }
637
+ })),
638
+ dispatch(createIntent4(LayoutAction4.UpdateDialog, {
639
+ part: "dialog",
640
+ options: {
641
+ state: false
642
+ }
643
+ }))
644
+ ]);
645
+ }
646
+ const space = result?.spaceKey ? client.spaces.get(result.spaceKey) : void 0;
647
+ if (!space) {
648
+ log.warn("Space not found", result?.spaceKey, {
649
+ F: __dxlog_file3,
650
+ L: 56,
651
+ S: void 0,
652
+ C: (f, a) => f(...a)
653
+ });
654
+ return;
655
+ }
656
+ await dispatch(createIntent4(LayoutAction4.SwitchWorkspace, {
657
+ part: "workspace",
658
+ subject: space.id
659
+ }));
660
+ const target = result?.target || (navigableCollections ? space?.id : void 0);
661
+ if (target) {
662
+ await graph.waitForPath({
663
+ target
664
+ }).catch(() => {
665
+ });
666
+ await Promise.all([
667
+ dispatch(createIntent4(LayoutAction4.Open, {
668
+ part: "main",
669
+ subject: [
670
+ target
671
+ ]
672
+ })),
673
+ dispatch(createIntent4(LayoutAction4.Expose, {
674
+ part: "navigation",
675
+ subject: target
676
+ }))
677
+ ]);
678
+ }
679
+ await onDone?.(result);
680
+ if (space) {
681
+ await dispatch(createIntent4(ObservabilityAction.SendEvent, {
682
+ name: "space.join",
683
+ properties: {
684
+ spaceId: space.id
685
+ }
686
+ }));
687
+ }
688
+ }, [
689
+ dispatch,
690
+ client,
691
+ graph
692
+ ]);
693
+ return /* @__PURE__ */ React10.createElement(Dialog3.Content, null, /* @__PURE__ */ React10.createElement(JoinPanel, {
694
+ ...props,
695
+ exitActionParent: /* @__PURE__ */ React10.createElement(Dialog3.Close, {
696
+ asChild: true
697
+ }),
698
+ doneActionParent: /* @__PURE__ */ React10.createElement(Dialog3.Close, {
699
+ asChild: true
700
+ }),
701
+ onDone: handleDone
702
+ }));
703
+ };
704
+
705
+ // packages/plugins/plugin-space/src/components/MenuFooter.tsx
706
+ import { Planet } from "@phosphor-icons/react";
707
+ import React11 from "react";
708
+ import { getSpace as getSpace2 } from "@dxos/client/echo";
709
+ import { useClient as useClient4 } from "@dxos/react-client";
710
+ import { DropdownMenu, toLocalizedString as toLocalizedString2, useTranslation as useTranslation10 } from "@dxos/react-ui";
711
+ var MenuFooter = ({ object }) => {
712
+ const { t } = useTranslation10(SPACE_PLUGIN);
713
+ const client = useClient4();
714
+ const space = getSpace2(object);
715
+ const spaceName = space ? getSpaceDisplayName(space, {
716
+ personal: client.spaces.default === space
717
+ }) : "";
718
+ return space ? /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(DropdownMenu.Separator, null), /* @__PURE__ */ React11.createElement(DropdownMenu.GroupLabel, null, t("menu footer label")), /* @__PURE__ */ React11.createElement("dl", {
719
+ className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
720
+ }, /* @__PURE__ */ React11.createElement("dt", {
721
+ className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
722
+ }, t("location label")), /* @__PURE__ */ React11.createElement("dd", {
723
+ className: "line-clamp-3"
724
+ }, /* @__PURE__ */ React11.createElement(Planet, {
725
+ className: "inline-block mie-1"
726
+ }), toLocalizedString2(spaceName, t)))) : null;
727
+ };
728
+
729
+ // packages/plugins/plugin-space/src/components/PersistenceStatus.tsx
730
+ import { ArrowsCounterClockwise, CheckCircle as CheckCircle2, Warning } from "@phosphor-icons/react";
731
+ import React12, { useEffect as useEffect2, useState as useState4 } from "react";
732
+ import { debounce } from "@dxos/async";
733
+ import { Tooltip, useTranslation as useTranslation11 } from "@dxos/react-ui";
734
+ import { getSize as getSize2, mx as mx4, staticPlaceholderText, warningText } from "@dxos/react-ui-theme";
735
+ var Status;
736
+ (function(Status2) {
737
+ Status2[Status2["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
738
+ Status2[Status2["PENDING"] = 1] = "PENDING";
739
+ Status2[Status2["ERROR"] = 2] = "ERROR";
740
+ })(Status || (Status = {}));
741
+ var PersistenceStatus = ({ db }) => {
742
+ const { t } = useTranslation11(SPACE_PLUGIN);
743
+ const [displayMessage, setDisplayMessage] = useState4(false);
744
+ const [status, naturalSetStatus] = useState4(0);
745
+ const [prevStatus, setPrevStatus] = useState4(0);
746
+ const _setStatus = debounce(naturalSetStatus, 500);
747
+ useEffect2(() => {
748
+ setPrevStatus(status);
749
+ if (prevStatus !== status && status === 0) {
750
+ setDisplayMessage(true);
751
+ const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
752
+ return () => clearTimeout(timeout);
753
+ }
754
+ }, [
755
+ status
756
+ ]);
757
+ switch (status) {
758
+ case 2:
759
+ return /* @__PURE__ */ React12.createElement("div", {
760
+ className: "flex items-center"
761
+ }, /* @__PURE__ */ React12.createElement(Warning, {
762
+ className: mx4(getSize2(4), "me-1")
763
+ }), /* @__PURE__ */ React12.createElement("span", {
764
+ className: mx4("text-sm", warningText)
765
+ }, t("persistence error label")));
766
+ case 1:
767
+ return /* @__PURE__ */ React12.createElement("div", {
768
+ className: "flex items-center"
769
+ }, /* @__PURE__ */ React12.createElement(ArrowsCounterClockwise, {
770
+ className: mx4(getSize2(4), "me-1")
771
+ }), /* @__PURE__ */ React12.createElement("span", {
772
+ className: mx4("text-sm", staticPlaceholderText)
773
+ }, t("persistence pending label")));
774
+ case 0:
775
+ default:
776
+ return /* @__PURE__ */ React12.createElement(Tooltip.Root, {
777
+ delayDuration: 400
778
+ }, /* @__PURE__ */ React12.createElement(Tooltip.Trigger, {
779
+ role: "status",
780
+ className: "flex items-center"
781
+ }, /* @__PURE__ */ React12.createElement(CheckCircle2, {
782
+ className: mx4(getSize2(4), "me-1")
783
+ }), displayMessage && /* @__PURE__ */ React12.createElement("span", {
784
+ className: mx4("text-sm", staticPlaceholderText)
785
+ }, t("persisted locally label"))), /* @__PURE__ */ React12.createElement(Tooltip.Portal, null, /* @__PURE__ */ React12.createElement(Tooltip.Content, null, t("persisted locally message"), /* @__PURE__ */ React12.createElement(Tooltip.Arrow, null))));
786
+ }
787
+ };
788
+
789
+ // packages/plugins/plugin-space/src/components/PopoverAddSpace.tsx
790
+ import React13 from "react";
791
+ import { createIntent as createIntent5, LayoutAction as LayoutAction5, useIntentDispatcher as useIntentDispatcher5 } from "@dxos/app-framework";
792
+ import { IconButton as IconButton3, useTranslation as useTranslation12 } from "@dxos/react-ui";
793
+ var POPOVER_ADD_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
794
+ var PopoverAddSpace = () => {
795
+ const { t } = useTranslation12(SPACE_PLUGIN);
796
+ const { dispatchPromise: dispatch } = useIntentDispatcher5();
797
+ return /* @__PURE__ */ React13.createElement("div", {
798
+ role: "none",
799
+ className: "grid grid-cols-1 gap-1 [&>button]:justify-start"
800
+ }, /* @__PURE__ */ React13.createElement(IconButton3, {
801
+ variant: "ghost",
802
+ label: t("create space label"),
803
+ icon: "ph--plus--regular",
804
+ onClick: () => {
805
+ void dispatch(createIntent5(SpaceAction.OpenCreateSpace));
806
+ void dispatch(createIntent5(LayoutAction5.UpdatePopover, {
807
+ part: "popover",
808
+ options: {
809
+ anchorId: "",
810
+ state: false
811
+ }
812
+ }));
813
+ },
814
+ "data-testid": "spacePlugin.createSpace"
815
+ }), /* @__PURE__ */ React13.createElement(IconButton3, {
816
+ variant: "ghost",
817
+ label: t("join space label"),
818
+ icon: "ph--sign-in--regular",
819
+ onClick: () => {
820
+ void dispatch(createIntent5(SpaceAction.Join));
821
+ void dispatch(createIntent5(LayoutAction5.UpdatePopover, {
822
+ part: "popover",
823
+ options: {
824
+ anchorId: "",
825
+ state: false
826
+ }
827
+ }));
828
+ },
829
+ "data-testid": "spacePlugin.joinSpace"
830
+ }));
831
+ };
832
+
833
+ // packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx
834
+ import React14, { useCallback as useCallback8, useRef as useRef3, useState as useState5 } from "react";
835
+ import { log as log2 } from "@dxos/log";
836
+ import { Button as Button4, Input as Input2, Popover, useTranslation as useTranslation13 } from "@dxos/react-ui";
837
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
838
+ var POPOVER_RENAME_OBJECT = `${SPACE_PLUGIN}/PopoverRenameObject`;
839
+ var PopoverRenameObject = ({ object: obj }) => {
840
+ const { t } = useTranslation13(SPACE_PLUGIN);
841
+ const doneButton = useRef3(null);
842
+ const object = obj;
843
+ const [name, setName] = useState5(object.name || object.title || "");
844
+ const handleDone = useCallback8(() => {
845
+ try {
846
+ object.name = name;
847
+ } catch {
848
+ try {
849
+ object.title = name;
850
+ } catch (err) {
851
+ log2.error("Failed to rename object", {
852
+ err
853
+ }, {
854
+ F: __dxlog_file4,
855
+ L: 30,
856
+ S: void 0,
857
+ C: (f, a) => f(...a)
858
+ });
859
+ }
860
+ }
861
+ }, [
862
+ object,
863
+ name
864
+ ]);
865
+ return /* @__PURE__ */ React14.createElement("div", {
866
+ role: "none",
867
+ className: "p-1 flex gap-2"
868
+ }, /* @__PURE__ */ React14.createElement("div", {
869
+ role: "none",
870
+ className: "flex-1"
871
+ }, /* @__PURE__ */ React14.createElement(Input2.Root, null, /* @__PURE__ */ React14.createElement(Input2.Label, {
872
+ srOnly: true
873
+ }, t("object name label")), /* @__PURE__ */ React14.createElement(Input2.TextInput, {
874
+ placeholder: t("object title placeholder"),
875
+ value: name,
876
+ "data-testid": "spacePlugin.renameObject.input",
877
+ onChange: ({ target: { value } }) => setName(value),
878
+ onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
879
+ }))), /* @__PURE__ */ React14.createElement(Popover.Close, {
880
+ asChild: true
881
+ }, /* @__PURE__ */ React14.createElement(Button4, {
882
+ ref: doneButton,
883
+ classNames: "self-stretch",
884
+ onClick: handleDone
885
+ }, t("done label", {
886
+ ns: "os"
887
+ }))));
888
+ };
889
+
890
+ // packages/plugins/plugin-space/src/components/PopoverRenameSpace.tsx
891
+ import React15, { useCallback as useCallback9, useRef as useRef4, useState as useState6 } from "react";
892
+ import { Button as Button5, Input as Input3, Popover as Popover2, useTranslation as useTranslation14 } from "@dxos/react-ui";
893
+ var POPOVER_RENAME_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
894
+ var PopoverRenameSpace = ({ space }) => {
895
+ const { t } = useTranslation14(SPACE_PLUGIN);
896
+ const doneButton = useRef4(null);
897
+ const [name, setName] = useState6(space.properties.name ?? "");
898
+ const handleDone = useCallback9(() => {
899
+ space.properties.name = name;
900
+ }, [
901
+ space,
902
+ name
903
+ ]);
904
+ return /* @__PURE__ */ React15.createElement("div", {
905
+ role: "none",
906
+ className: "p-1 flex gap-2"
907
+ }, /* @__PURE__ */ React15.createElement("div", {
908
+ role: "none",
909
+ className: "flex-1"
910
+ }, /* @__PURE__ */ React15.createElement(Input3.Root, null, /* @__PURE__ */ React15.createElement(Input3.Label, {
911
+ srOnly: true
912
+ }, t("space name label")), /* @__PURE__ */ React15.createElement(Input3.TextInput, {
913
+ defaultValue: space.properties.name ?? "",
914
+ placeholder: t("unnamed space label"),
915
+ onChange: ({ target: { value } }) => setName(value),
916
+ // TODO(wittjosiah): Ideally this should access the popover context to close the popover.
917
+ // Currently this is not possible because Radix does not expose the popover context.
918
+ onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
919
+ }))), /* @__PURE__ */ React15.createElement(Popover2.Close, {
920
+ asChild: true
921
+ }, /* @__PURE__ */ React15.createElement(Button5, {
922
+ ref: doneButton,
923
+ classNames: "self-stretch",
924
+ onClick: handleDone
925
+ }, t("done label", {
926
+ ns: "os"
927
+ }))));
928
+ };
929
+
930
+ // packages/plugins/plugin-space/src/components/ShareSpaceButton.tsx
931
+ import React16 from "react";
932
+ import { createIntent as createIntent6, useIntentDispatcher as useIntentDispatcher6 } from "@dxos/app-framework";
933
+ import { IconButton as IconButton4, useTranslation as useTranslation15 } from "@dxos/react-ui";
934
+ var ShareSpaceButton = ({ space }) => {
935
+ const { dispatchPromise: dispatch } = useIntentDispatcher6();
936
+ return /* @__PURE__ */ React16.createElement(ShareSpaceButtonImpl, {
937
+ onClick: () => dispatch(createIntent6(SpaceAction.Share, {
938
+ space
939
+ }))
940
+ });
941
+ };
942
+ var ShareSpaceButtonImpl = ({ onClick }) => {
943
+ const { t } = useTranslation15(SPACE_PLUGIN);
944
+ return /* @__PURE__ */ React16.createElement(IconButton4, {
945
+ "data-testid": "spacePlugin.shareSpaceButton",
946
+ icon: "ph--users--regular",
947
+ label: t("share space label"),
948
+ onClick
949
+ });
950
+ };
951
+
952
+ // packages/plugins/plugin-space/src/components/SpacePresence.tsx
953
+ import React17, { useCallback as useCallback10, useEffect as useEffect4, useState as useState8 } from "react";
954
+ import { useAppGraph as useAppGraph2, useCapability } from "@dxos/app-framework";
955
+ import { generateName } from "@dxos/display-name";
956
+ import { PublicKey, useClient as useClient5 } from "@dxos/react-client";
957
+ import { getSpace as getSpace3, useMembers, fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
958
+ import { useIdentity } from "@dxos/react-client/halo";
959
+ import { Avatar, AvatarGroup, AvatarGroupItem, Tooltip as Tooltip2, useTranslation as useTranslation16, List as List2, ListItem as ListItem2, useDefaultValue } from "@dxos/react-ui";
960
+ import { AttentionGlyph, useAttended, useAttention } from "@dxos/react-ui-attention";
961
+ import { ComplexMap, keyToFallback } from "@dxos/util";
962
+
963
+ // packages/plugins/plugin-space/src/hooks/usePath.ts
964
+ import { useEffect as useEffect3, useState as useState7 } from "react";
965
+ var usePath = (graph, id, timeout) => {
966
+ const [pathState, setPathState] = useState7(id ? graph.getPath({
967
+ target: id
968
+ }) : void 0);
969
+ useEffect3(() => {
970
+ if (!id && pathState) {
971
+ setPathState(void 0);
972
+ }
973
+ if (pathState?.at(-1) === id || !id) {
974
+ return;
975
+ }
976
+ const frame = requestAnimationFrame(async () => {
977
+ try {
978
+ const path = await graph.waitForPath({
979
+ target: id
980
+ }, {
981
+ timeout
982
+ });
983
+ if (path) {
984
+ setPathState(path);
985
+ }
986
+ } catch {
987
+ }
988
+ });
989
+ return () => cancelAnimationFrame(frame);
990
+ }, [
991
+ graph,
992
+ id,
993
+ timeout,
994
+ pathState
995
+ ]);
996
+ return pathState;
997
+ };
998
+
999
+ // packages/plugins/plugin-space/src/components/SpacePresence.tsx
1000
+ var REFRESH_INTERVAL = 5e3;
1001
+ var ACTIVITY_DURATION = 3e4;
1002
+ var noViewers = new ComplexMap(PublicKey.hash);
1003
+ var getName = (identity) => identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
1004
+ var SpacePresence = ({ object, spaceKey }) => {
1005
+ const spaceState = useCapability(SpaceCapabilities.MutableState);
1006
+ const client = useClient5();
1007
+ const identity = useIdentity();
1008
+ const space = spaceKey ? client.spaces.get(spaceKey) : getSpace3(object);
1009
+ const spaceMembers = useMembers(space?.key);
1010
+ const [_moment, setMoment] = useState8(Date.now());
1011
+ useEffect4(() => {
1012
+ const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
1013
+ return () => clearInterval(interval);
1014
+ }, []);
1015
+ const memberOnline = useCallback10((member) => member.presence === 1, []);
1016
+ const memberIsNotSelf = useCallback10((member) => !identity?.identityKey.equals(member.identity.identityKey), [
1017
+ identity?.identityKey
1018
+ ]);
1019
+ if (!identity || !spaceState || !space) {
1020
+ return null;
1021
+ }
1022
+ const currentObjectViewers = spaceState.viewersByObject[fullyQualifiedId2(object)] ?? noViewers;
1023
+ const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
1024
+ const objectView = currentObjectViewers.get(member.identity.identityKey);
1025
+ const lastSeen = objectView?.lastSeen ?? -Infinity;
1026
+ const currentlyAttended = objectView?.currentlyAttended ?? false;
1027
+ return {
1028
+ ...member,
1029
+ currentlyAttended,
1030
+ lastSeen
1031
+ };
1032
+ }).toSorted((a, b) => a.lastSeen - b.lastSeen);
1033
+ return /* @__PURE__ */ React17.createElement(FullPresence, {
1034
+ members: membersForObject
1035
+ });
1036
+ };
1037
+ var FullPresence = (props) => {
1038
+ const { size = 9, onMemberClick } = props;
1039
+ const members = useDefaultValue(props.members, () => []);
1040
+ if (members.length === 0) {
1041
+ return null;
1042
+ }
1043
+ return /* @__PURE__ */ React17.createElement(AvatarGroup.Root, {
1044
+ size,
1045
+ classNames: "mbs-2 mie-4",
1046
+ "data-testid": "spacePlugin.presence"
1047
+ }, members.slice(0, 3).map((member, i) => /* @__PURE__ */ React17.createElement(Tooltip2.Root, {
1048
+ key: member.identity.identityKey.toHex()
1049
+ }, /* @__PURE__ */ React17.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React17.createElement(PrensenceAvatar, {
1050
+ identity: member.identity,
1051
+ group: true,
1052
+ match: member.currentlyAttended,
1053
+ index: members.length - i,
1054
+ onClick: () => onMemberClick?.(member)
1055
+ })), /* @__PURE__ */ React17.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React17.createElement(Tooltip2.Content, {
1056
+ side: "bottom"
1057
+ }, /* @__PURE__ */ React17.createElement("span", null, getName(member.identity)), /* @__PURE__ */ React17.createElement(Tooltip2.Arrow, null))))), members.length > 3 && /* @__PURE__ */ React17.createElement(Tooltip2.Root, null, /* @__PURE__ */ React17.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React17.createElement(AvatarGroupItem.Root, {
1058
+ status: "inactive"
1059
+ }, /* @__PURE__ */ React17.createElement(Avatar.Frame, {
1060
+ style: {
1061
+ zIndex: members.length - 4
1062
+ }
1063
+ }, /* @__PURE__ */ React17.createElement(Avatar.Fallback, {
1064
+ text: `+${members.length - 3}`
1065
+ })))), /* @__PURE__ */ React17.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React17.createElement(Tooltip2.Content, {
1066
+ side: "bottom"
1067
+ }, /* @__PURE__ */ React17.createElement(Tooltip2.Arrow, null), /* @__PURE__ */ React17.createElement(List2, {
1068
+ classNames: "max-h-56 overflow-y-auto"
1069
+ }, members.map((member) => /* @__PURE__ */ React17.createElement(ListItem2.Root, {
1070
+ key: member.identity.identityKey.toHex(),
1071
+ classNames: "flex gap-2 items-center cursor-pointer mbe-2",
1072
+ onClick: () => onMemberClick?.(member),
1073
+ "data-testid": "identity-list-item"
1074
+ }, /* @__PURE__ */ React17.createElement(PrensenceAvatar, {
1075
+ identity: member.identity,
1076
+ showName: true,
1077
+ match: member.currentlyAttended
1078
+ }))))))));
1079
+ };
1080
+ var PrensenceAvatar = ({ identity, showName, match, group, index, onClick }) => {
1081
+ const Root = group ? AvatarGroupItem.Root : Avatar.Root;
1082
+ const status = match ? "current" : "active";
1083
+ const fallbackValue = keyToFallback(identity.identityKey);
1084
+ return /* @__PURE__ */ React17.createElement(Root, {
1085
+ status,
1086
+ hue: identity.profile?.data?.hue || fallbackValue.hue
1087
+ }, /* @__PURE__ */ React17.createElement(Avatar.Frame, {
1088
+ "data-testid": "spacePlugin.presence.member",
1089
+ "data-status": status,
1090
+ ...index ? {
1091
+ style: {
1092
+ zIndex: index
1093
+ }
1094
+ } : {},
1095
+ onClick: () => onClick?.()
1096
+ }, /* @__PURE__ */ React17.createElement(Avatar.Fallback, {
1097
+ text: identity.profile?.data?.emoji || fallbackValue.emoji
1098
+ })), showName && /* @__PURE__ */ React17.createElement(Avatar.Label, {
1099
+ classNames: "text-sm truncate pli-2"
1100
+ }, getName(identity)));
1101
+ };
1102
+ var SmallPresenceLive = ({ id, open, viewers }) => {
1103
+ const { hasAttention, isAncestor, isRelated } = useAttention(id);
1104
+ const isAttended = hasAttention || isAncestor || isRelated;
1105
+ const { graph } = useAppGraph2();
1106
+ const attended = useAttended();
1107
+ const startOfAttention = attended.at(-1);
1108
+ const path = usePath(graph, startOfAttention);
1109
+ const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
1110
+ const getActiveViewers = (viewers2) => {
1111
+ const moment = Date.now();
1112
+ return Array.from(viewers2.values()).filter((viewer) => moment - viewer.lastSeen < ACTIVITY_DURATION);
1113
+ };
1114
+ const [activeViewers, setActiveViewers] = useState8(viewers ? getActiveViewers(viewers) : []);
1115
+ useEffect4(() => {
1116
+ if (viewers) {
1117
+ setActiveViewers(getActiveViewers(viewers));
1118
+ const interval = setInterval(() => {
1119
+ setActiveViewers(getActiveViewers(viewers));
1120
+ }, REFRESH_INTERVAL);
1121
+ return () => clearInterval(interval);
1122
+ }
1123
+ }, [
1124
+ viewers
1125
+ ]);
1126
+ return /* @__PURE__ */ React17.createElement(SmallPresence, {
1127
+ count: activeViewers.length,
1128
+ attended: isAttended,
1129
+ containsAttended
1130
+ });
1131
+ };
1132
+ var SmallPresence = ({ count = 0, attended, containsAttended }) => {
1133
+ const { t } = useTranslation16(SPACE_PLUGIN);
1134
+ return /* @__PURE__ */ React17.createElement(Tooltip2.Root, null, /* @__PURE__ */ React17.createElement(Tooltip2.Trigger, {
1135
+ asChild: true
1136
+ }, /* @__PURE__ */ React17.createElement(AttentionGlyph, {
1137
+ attended,
1138
+ containsAttended,
1139
+ presence: count > 1 ? "many" : count === 1 ? "one" : "none",
1140
+ classNames: "self-center mie-1"
1141
+ })), /* @__PURE__ */ React17.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React17.createElement(Tooltip2.Content, {
1142
+ side: "bottom"
1143
+ }, /* @__PURE__ */ React17.createElement("span", null, t("presence label", {
1144
+ count
1145
+ })), /* @__PURE__ */ React17.createElement(Tooltip2.Arrow, null))));
1146
+ };
1147
+
1148
+ // packages/plugins/plugin-space/src/components/SpacePluginSettings.tsx
1149
+ import React18 from "react";
1150
+ import { Input as Input4, useTranslation as useTranslation17 } from "@dxos/react-ui";
1151
+ import { DeprecatedFormContainer, DeprecatedFormInput } from "@dxos/react-ui-form";
1152
+ var SpacePluginSettings = ({ settings }) => {
1153
+ const { t } = useTranslation17(SPACE_PLUGIN);
1154
+ return /* @__PURE__ */ React18.createElement(DeprecatedFormContainer, null, /* @__PURE__ */ React18.createElement(DeprecatedFormInput, {
1155
+ label: t("show hidden spaces label")
1156
+ }, /* @__PURE__ */ React18.createElement(Input4.Switch, {
1157
+ checked: settings.showHidden,
1158
+ onCheckedChange: (checked) => settings.showHidden = !!checked
1159
+ })));
1160
+ };
1161
+
1162
+ // packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsPanel.tsx
1163
+ import React19, { useCallback as useCallback11, useState as useState9 } from "react";
1164
+ import { log as log3 } from "@dxos/log";
1165
+ import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
1166
+ import { useClient as useClient6 } from "@dxos/react-client";
1167
+ import { Input as Input5, Toolbar, useTranslation as useTranslation18 } from "@dxos/react-ui";
1168
+ import { DeprecatedFormContainer as DeprecatedFormContainer2, DeprecatedFormInput as DeprecatedFormInput2 } from "@dxos/react-ui-form";
1169
+ import { HuePicker, IconPicker } from "@dxos/react-ui-pickers";
1170
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsPanel.tsx";
1171
+ var SpaceSettingsPanel = ({ space }) => {
1172
+ const { t } = useTranslation18(SPACE_PLUGIN);
1173
+ const client = useClient6();
1174
+ const edgeEnabled = Boolean(client.config.values.runtime?.client?.edgeFeatures?.echoReplicator);
1175
+ const [edgeReplication, setEdgeReplication] = useState9(space.internal.data.edgeReplication === EdgeReplicationSetting.ENABLED);
1176
+ const toggleEdgeReplication = useCallback11(async (next) => {
1177
+ setEdgeReplication(next);
1178
+ await space?.internal.setEdgeReplicationPreference(next ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED).catch((err) => {
1179
+ log3.catch(err, void 0, {
1180
+ F: __dxlog_file5,
1181
+ L: 36,
1182
+ S: void 0,
1183
+ C: (f, a) => f(...a)
1184
+ });
1185
+ setEdgeReplication(!next);
1186
+ });
1187
+ }, [
1188
+ space
1189
+ ]);
1190
+ return /* @__PURE__ */ React19.createElement(DeprecatedFormContainer2, null, /* @__PURE__ */ React19.createElement(DeprecatedFormInput2, {
1191
+ label: t("name label")
1192
+ }, /* @__PURE__ */ React19.createElement(Input5.TextInput, {
1193
+ placeholder: t("unnamed space label"),
1194
+ value: space.properties.name ?? "",
1195
+ onChange: (event) => {
1196
+ space.properties.name = event.target.value;
1197
+ }
1198
+ })), /* @__PURE__ */ React19.createElement(DeprecatedFormInput2, {
1199
+ label: t("icon label")
1200
+ }, /* @__PURE__ */ React19.createElement(Toolbar.Root, null, /* @__PURE__ */ React19.createElement(IconPicker, {
1201
+ value: space.properties.icon,
1202
+ onChange: (nextIcon) => space.properties.icon = nextIcon,
1203
+ onReset: () => {
1204
+ space.properties.icon = void 0;
1205
+ }
1206
+ }))), /* @__PURE__ */ React19.createElement(DeprecatedFormInput2, {
1207
+ label: t("hue label")
1208
+ }, /* @__PURE__ */ React19.createElement(Toolbar.Root, null, /* @__PURE__ */ React19.createElement(HuePicker, {
1209
+ value: space.properties.hue,
1210
+ onChange: (nextHue) => space.properties.hue = nextHue,
1211
+ onReset: () => {
1212
+ space.properties.hue = void 0;
1213
+ }
1214
+ }))), edgeEnabled && /* @__PURE__ */ React19.createElement(DeprecatedFormInput2, {
1215
+ label: t("edge replication label")
1216
+ }, /* @__PURE__ */ React19.createElement(Input5.Switch, {
1217
+ checked: edgeReplication,
1218
+ onCheckedChange: toggleEdgeReplication
1219
+ })));
1220
+ };
1221
+
1222
+ // packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsDialog.tsx
1223
+ import React20, { useMemo, useState as useState10 } from "react";
1224
+ import { Surface as Surface2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
1225
+ import { useClient as useClient7 } from "@dxos/react-client";
1226
+ import { Button as Button6, Clipboard, Dialog as Dialog4, Icon as Icon4, toLocalizedString as toLocalizedString3, useTranslation as useTranslation19 } from "@dxos/react-ui";
1227
+ import { Tabs } from "@dxos/react-ui-tabs";
1228
+ import { SpacePanel } from "@dxos/shell/react";
1229
+ var SPACE_SETTINGS_DIALOG = `${SPACE_PLUGIN}/SpaceSettingsDialog`;
1230
+ var SpaceSettingsDialog = ({ space, target, createInvitationUrl, initialTab = "members", namesCache }) => {
1231
+ const { t } = useTranslation19(SPACE_PLUGIN);
1232
+ const client = useClient7();
1233
+ const [tabsActivePart, setTabsActivePart] = useState10("list");
1234
+ const [selected, setSelected] = useState10(initialTab);
1235
+ const locked = space.properties[COMPOSER_SPACE_LOCK];
1236
+ const name = getSpaceDisplayName(space, {
1237
+ personal: client.spaces.default === space,
1238
+ namesCache
1239
+ });
1240
+ const panels = useCapabilities2(SpaceCapabilities.SettingsPanel);
1241
+ const data = useMemo(() => ({
1242
+ subject: space
1243
+ }), [
1244
+ space
1245
+ ]);
1246
+ return (
1247
+ // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
1248
+ // Consider factoring it out to the tabs package.
1249
+ /* @__PURE__ */ React20.createElement(Dialog4.Content, {
1250
+ classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
1251
+ }, /* @__PURE__ */ React20.createElement("div", {
1252
+ role: "none",
1253
+ className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
1254
+ }, /* @__PURE__ */ React20.createElement(Dialog4.Title, {
1255
+ onClick: () => setTabsActivePart("list"),
1256
+ "aria-description": t("click to return to tablist description"),
1257
+ classNames: "flex cursor-pointer items-center group/title"
1258
+ }, /* @__PURE__ */ React20.createElement(Icon4, {
1259
+ icon: "ph--caret-left--regular",
1260
+ size: 4,
1261
+ classNames: [
1262
+ "@md:hidden",
1263
+ tabsActivePart === "list" && "invisible"
1264
+ ]
1265
+ }), /* @__PURE__ */ React20.createElement("span", {
1266
+ className: tabsActivePart !== "list" ? "group-hover/title:underline @md:group-hover/title:no-underline underline-offset-4 decoration-1" : ""
1267
+ }, toLocalizedString3(name, t))), /* @__PURE__ */ React20.createElement(Dialog4.Close, {
1268
+ asChild: true
1269
+ }, /* @__PURE__ */ React20.createElement(Button6, {
1270
+ density: "fine",
1271
+ variant: "ghost",
1272
+ autoFocus: true
1273
+ }, /* @__PURE__ */ React20.createElement(Icon4, {
1274
+ icon: "ph--x--regular",
1275
+ size: 4
1276
+ })))), /* @__PURE__ */ React20.createElement(Tabs.Root, {
1277
+ orientation: "vertical",
1278
+ value: selected,
1279
+ onValueChange: setSelected,
1280
+ activePart: tabsActivePart,
1281
+ onActivePartChange: setTabsActivePart,
1282
+ classNames: "flex flex-col flex-1 mbs-2"
1283
+ }, /* @__PURE__ */ React20.createElement(Tabs.Viewport, {
1284
+ classNames: "flex-1 min-bs-0"
1285
+ }, /* @__PURE__ */ React20.createElement("div", {
1286
+ role: "none",
1287
+ className: "overflow-y-auto pli-3 @md:pis-2 @md:pie-0 mbe-4 border-r border-separator"
1288
+ }, /* @__PURE__ */ React20.createElement(Tabs.Tablist, {
1289
+ classNames: "flex flex-col max-bs-none min-is-[200px] gap-4 overflow-y-auto"
1290
+ }, /* @__PURE__ */ React20.createElement("div", {
1291
+ role: "none",
1292
+ className: "flex flex-col ml-1"
1293
+ }, /* @__PURE__ */ React20.createElement(Tabs.Tab, {
1294
+ value: "settings"
1295
+ }, t("settings tab label")), /* @__PURE__ */ React20.createElement(Tabs.Tab, {
1296
+ value: "members",
1297
+ disabled: locked
1298
+ }, t("members tab label")), panels.map((panel) => /* @__PURE__ */ React20.createElement(Tabs.Tab, {
1299
+ key: panel.id,
1300
+ value: panel.id
1301
+ }, toLocalizedString3(panel.label, t)))))), /* @__PURE__ */ React20.createElement(Tabs.Tabpanel, {
1302
+ value: "settings",
1303
+ classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
1304
+ }, /* @__PURE__ */ React20.createElement(SpaceSettingsPanel, {
1305
+ space
1306
+ })), /* @__PURE__ */ React20.createElement(Tabs.Tabpanel, {
1307
+ value: "members",
1308
+ classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
1309
+ }, /* @__PURE__ */ React20.createElement(Clipboard.Provider, null, /* @__PURE__ */ React20.createElement(SpacePanel, {
1310
+ space,
1311
+ hideHeading: true,
1312
+ target,
1313
+ createInvitationUrl
1314
+ }))), panels.map((panel) => /* @__PURE__ */ React20.createElement(Tabs.Tabpanel, {
1315
+ key: panel.id,
1316
+ value: panel.id,
1317
+ classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
1318
+ }, /* @__PURE__ */ React20.createElement(Surface2, {
1319
+ role: `space-settings--${panel.id}`,
1320
+ data
1321
+ }))))))
1322
+ );
1323
+ };
1324
+
1325
+ // packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
1326
+ import React21, { useEffect as useEffect6, useState as useState12 } from "react";
1327
+ import { useAppGraph as useAppGraph3 } from "@dxos/app-framework";
1328
+ import { QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
1329
+ import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
1330
+ import { useClient as useClient9 } from "@dxos/react-client";
1331
+ import { Tooltip as Tooltip3, useTranslation as useTranslation20 } from "@dxos/react-ui";
1332
+ import { AttentionGlyph as AttentionGlyph2, useAttended as useAttended2, useAttention as useAttention2 } from "@dxos/react-ui-attention";
1333
+
1334
+ // packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts
1335
+ import { useEffect as useEffect5, useState as useState11 } from "react";
1336
+ import { Context } from "@dxos/context";
1337
+ import { EdgeService } from "@dxos/protocols";
1338
+ import { useClient as useClient8 } from "@dxos/react-client";
1339
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts";
1340
+ var createEmptyEdgeSyncState = () => ({
1341
+ missingOnLocal: 0,
1342
+ missingOnRemote: 0,
1343
+ localDocumentCount: 0,
1344
+ remoteDocumentCount: 0,
1345
+ differentDocuments: 0
1346
+ });
1347
+ var getSyncSummary = (syncMap) => {
1348
+ return Object.entries(syncMap).reduce((summary, [_spaceId, peerState]) => {
1349
+ summary.missingOnLocal += peerState.missingOnLocal;
1350
+ summary.missingOnRemote += peerState.missingOnRemote;
1351
+ summary.localDocumentCount += peerState.localDocumentCount;
1352
+ summary.remoteDocumentCount += peerState.remoteDocumentCount;
1353
+ summary.differentDocuments += peerState.differentDocuments;
1354
+ return summary;
1355
+ }, createEmptyEdgeSyncState());
1356
+ };
1357
+ var isEdgePeerId = (peerId, spaceId) => peerId.startsWith(`${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`);
1358
+ var useSyncState = () => {
1359
+ const client = useClient8();
1360
+ const [spaceState, setSpaceState] = useState11({});
1361
+ useEffect5(() => {
1362
+ const ctx = new Context(void 0, {
1363
+ F: __dxlog_file6,
1364
+ L: 48
1365
+ });
1366
+ const createSubscriptions = (spaces) => {
1367
+ for (const space of spaces) {
1368
+ if (spaceState[space.id]) {
1369
+ continue;
1370
+ }
1371
+ ctx.onDispose(space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
1372
+ const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
1373
+ if (syncState) {
1374
+ setSpaceState((spaceState2) => ({
1375
+ ...spaceState2,
1376
+ [space.id]: syncState
1377
+ }));
1378
+ }
1379
+ }));
1380
+ }
1381
+ };
1382
+ createSubscriptions(client.spaces.get());
1383
+ client.spaces.subscribe((spaces) => {
1384
+ createSubscriptions(spaces);
1385
+ });
1386
+ return () => {
1387
+ void ctx.dispose();
1388
+ };
1389
+ }, [
1390
+ client
1391
+ ]);
1392
+ return spaceState;
1393
+ };
1394
+ var useSpaceSyncState = (space) => {
1395
+ const [spaceState, setSpaceState] = useState11();
1396
+ useEffect5(() => {
1397
+ const ctx = new Context(void 0, {
1398
+ F: __dxlog_file6,
1399
+ L: 87
1400
+ });
1401
+ space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
1402
+ const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
1403
+ if (syncState) {
1404
+ setSpaceState(syncState);
1405
+ }
1406
+ });
1407
+ return () => {
1408
+ void ctx.dispose();
1409
+ };
1410
+ }, [
1411
+ space
1412
+ ]);
1413
+ return spaceState;
1414
+ };
1415
+
1416
+ // packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
1417
+ var useEdgeStatus = () => {
1418
+ const [status, setStatus] = useState12(QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED);
1419
+ const client = useClient9();
1420
+ useEffect6(() => {
1421
+ client.services.services.EdgeAgentService?.queryEdgeStatus().subscribe(({ status: status2 }) => {
1422
+ setStatus(status2);
1423
+ });
1424
+ }, [
1425
+ client
1426
+ ]);
1427
+ return status;
1428
+ };
1429
+ var InlineSyncStatus = ({ space, open }) => {
1430
+ const { t } = useTranslation20(SPACE_PLUGIN);
1431
+ const id = space.id;
1432
+ const { hasAttention, isAncestor, isRelated } = useAttention2(id);
1433
+ const isAttended = hasAttention || isAncestor || isRelated;
1434
+ const { graph } = useAppGraph3();
1435
+ const attended = useAttended2();
1436
+ const startOfAttention = attended.at(-1);
1437
+ const path = usePath(graph, startOfAttention);
1438
+ const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
1439
+ const connectedToEdge = useEdgeStatus() === QueryEdgeStatusResponse.EdgeStatus.CONNECTED;
1440
+ const edgeSyncEnabled = space.internal.data.edgeReplication === EdgeReplicationSetting2.ENABLED;
1441
+ const syncState = useSpaceSyncState(space);
1442
+ const syncing = connectedToEdge && edgeSyncEnabled && syncState && syncState.missingOnLocal > 0;
1443
+ return /* @__PURE__ */ React21.createElement(Tooltip3.Root, null, /* @__PURE__ */ React21.createElement(Tooltip3.Trigger, {
1444
+ asChild: true
1445
+ }, /* @__PURE__ */ React21.createElement(AttentionGlyph2, {
1446
+ syncing,
1447
+ attended: isAttended,
1448
+ containsAttended,
1449
+ classNames: "self-center mie-1"
1450
+ })), /* @__PURE__ */ React21.createElement(Tooltip3.Portal, null, /* @__PURE__ */ React21.createElement(Tooltip3.Content, {
1451
+ side: "bottom",
1452
+ classNames: "z-[70]"
1453
+ }, /* @__PURE__ */ React21.createElement("span", null, t("syncing label")), /* @__PURE__ */ React21.createElement(Tooltip3.Arrow, null))));
1454
+ };
1455
+
1456
+ // packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
1457
+ import React23, { useCallback as useCallback12, useEffect as useEffect8, useState as useState14 } from "react";
1458
+ import { StatusBar } from "@dxos/plugin-status-bar";
1459
+ import { useClient as useClient11 } from "@dxos/react-client";
1460
+ import { Icon as Icon6, Input as Input6, Popover as Popover3, useTranslation as useTranslation22 } from "@dxos/react-ui";
1461
+ import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
1462
+ import { mx as mx6 } from "@dxos/react-ui-theme";
1463
+
1464
+ // packages/plugins/plugin-space/src/components/SyncStatus/Space.tsx
1465
+ import React22, { useEffect as useEffect7, useState as useState13 } from "react";
1466
+ import { useClient as useClient10 } from "@dxos/react-client";
1467
+ import { useSpace } from "@dxos/react-client/echo";
1468
+ import { Icon as Icon5, toLocalizedString as toLocalizedString4, useTranslation as useTranslation21 } from "@dxos/react-ui";
1469
+ import { mx as mx5 } from "@dxos/react-ui-theme";
1470
+ var SYNC_STALLED_TIMEOUT = 5e3;
1471
+ var styles = {
1472
+ barBg: "bg-neutral-50 dark:bg-green-900 text-black",
1473
+ barFg: "bg-neutral-100 bg-green-500",
1474
+ barHover: "dark:hover:bg-green-500"
1475
+ };
1476
+ var useActive = (count) => {
1477
+ const [current, setCurrent] = useState13(count);
1478
+ const [active, setActive] = useState13(false);
1479
+ useEffect7(() => {
1480
+ let t;
1481
+ if (count !== current) {
1482
+ setActive(true);
1483
+ setCurrent(count);
1484
+ t && clearTimeout(t);
1485
+ t = setTimeout(() => {
1486
+ setActive(false);
1487
+ }, SYNC_STALLED_TIMEOUT);
1488
+ }
1489
+ return () => {
1490
+ setActive(false);
1491
+ clearTimeout(t);
1492
+ };
1493
+ }, [
1494
+ count,
1495
+ current
1496
+ ]);
1497
+ return active;
1498
+ };
1499
+ var SpaceRowContainer = ({ spaceId, state }) => {
1500
+ const { t } = useTranslation21(SPACE_PLUGIN);
1501
+ const client = useClient10();
1502
+ const space = useSpace(spaceId);
1503
+ if (!space) {
1504
+ return null;
1505
+ }
1506
+ const spaceName = toLocalizedString4(getSpaceDisplayName(space, {
1507
+ personal: space === client.spaces.default
1508
+ }), t);
1509
+ return /* @__PURE__ */ React22.createElement(SpaceRow, {
1510
+ spaceId,
1511
+ spaceName,
1512
+ state
1513
+ });
1514
+ };
1515
+ var SpaceRow = ({ spaceId, spaceName, state: { localDocumentCount, remoteDocumentCount, missingOnLocal, missingOnRemote } }) => {
1516
+ const downActive = useActive(localDocumentCount);
1517
+ const upActive = useActive(remoteDocumentCount);
1518
+ return /* @__PURE__ */ React22.createElement("div", {
1519
+ className: "flex items-center mx-0.5 gap-0.5 cursor-pointer",
1520
+ title: spaceId,
1521
+ onClick: () => {
1522
+ void navigator.clipboard.writeText(spaceId);
1523
+ }
1524
+ }, /* @__PURE__ */ React22.createElement("span", {
1525
+ className: "is-1/2 truncate"
1526
+ }, spaceName), /* @__PURE__ */ React22.createElement(Icon5, {
1527
+ icon: "ph--arrow-fat-line-left--regular",
1528
+ size: 3,
1529
+ classNames: mx5(downActive && "animate-[pulse_1s_infinite]")
1530
+ }), /* @__PURE__ */ React22.createElement(Candle, {
1531
+ up: {
1532
+ count: remoteDocumentCount,
1533
+ total: remoteDocumentCount + missingOnRemote
1534
+ },
1535
+ down: {
1536
+ count: localDocumentCount,
1537
+ total: localDocumentCount + missingOnLocal
1538
+ },
1539
+ title: spaceId
1540
+ }), /* @__PURE__ */ React22.createElement(Icon5, {
1541
+ icon: "ph--arrow-fat-line-right--regular",
1542
+ size: 3,
1543
+ classNames: mx5(upActive && "animate-[pulse_1s_step-start_infinite]")
1544
+ }));
1545
+ };
1546
+ var Candle = ({ classNames, up, down }) => {
1547
+ return /* @__PURE__ */ React22.createElement("div", {
1548
+ className: mx5("grid grid-cols-[1fr_2rem_1fr] w-full h-3", classNames)
1549
+ }, /* @__PURE__ */ React22.createElement(Bar, {
1550
+ classNames: "justify-end",
1551
+ ...up
1552
+ }), /* @__PURE__ */ React22.createElement("div", {
1553
+ className: "relative"
1554
+ }, /* @__PURE__ */ React22.createElement("div", {
1555
+ className: mx5("absolute inset-0 flex items-center justify-center text-xs", styles.barBg)
1556
+ }, up.total)), /* @__PURE__ */ React22.createElement(Bar, down));
1557
+ };
1558
+ var Bar = ({ classNames, count, total }) => {
1559
+ let p = count / total * 100;
1560
+ if (count < total) {
1561
+ p = Math.min(p, 95);
1562
+ }
1563
+ return /* @__PURE__ */ React22.createElement("div", {
1564
+ className: mx5("relative flex w-full", styles.barBg, classNames)
1565
+ }, /* @__PURE__ */ React22.createElement("div", {
1566
+ className: mx5("shrink-0", styles.barFg),
1567
+ style: {
1568
+ width: `${p}%`
1569
+ }
1570
+ }), count !== total && /* @__PURE__ */ React22.createElement("div", {
1571
+ className: "absolute top-0 bottom-0 flex items-center mx-0.5 text-black text-xs"
1572
+ }, count));
1573
+ };
1574
+
1575
+ // packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts
1576
+ import { Context as Context2 } from "@dxos/context";
1577
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts";
1578
+ var createClientSaveTracker = (client, cb) => {
1579
+ const unsubscribeCallbacks = {};
1580
+ const state = {};
1581
+ const install = (spaces) => {
1582
+ for (const space of spaces) {
1583
+ if (state[space.id]) {
1584
+ continue;
1585
+ }
1586
+ state[space.id] = "saved";
1587
+ unsubscribeCallbacks[space.id] = createSpaceSaveTracker(space, (s) => {
1588
+ state[space.id] = s;
1589
+ cb(Object.values(state).some((s2) => s2 === "saving") ? "saving" : "saved");
1590
+ });
1591
+ }
1592
+ };
1593
+ client.spaces.subscribe((spaces) => {
1594
+ install(spaces);
1595
+ });
1596
+ install(client.spaces.get());
1597
+ return () => {
1598
+ for (const unsubscribe of Object.values(unsubscribeCallbacks)) {
1599
+ unsubscribe();
1600
+ }
1601
+ };
1602
+ };
1603
+ var createSpaceSaveTracker = (space, cb) => {
1604
+ const ctx = new Context2(void 0, {
1605
+ F: __dxlog_file7,
1606
+ L: 40
1607
+ });
1608
+ void space.waitUntilReady().then(() => {
1609
+ if (ctx.disposed) {
1610
+ return;
1611
+ }
1612
+ let hasUnsavedChanges = false;
1613
+ let lastFlushPromise;
1614
+ space.crud.saveStateChanged.on(ctx, ({ unsavedDocuments }) => {
1615
+ hasUnsavedChanges = unsavedDocuments.length > 0;
1616
+ });
1617
+ space.crud.saveStateChanged.debounce(500).on(ctx, () => {
1618
+ if (hasUnsavedChanges) {
1619
+ lastFlushPromise = void 0;
1620
+ cb("saving");
1621
+ } else {
1622
+ const flushPromise = space.crud.flush();
1623
+ lastFlushPromise = flushPromise;
1624
+ void flushPromise.then(() => {
1625
+ if (lastFlushPromise === flushPromise) {
1626
+ cb("saved");
1627
+ }
1628
+ });
1629
+ }
1630
+ });
1631
+ });
1632
+ return () => {
1633
+ void ctx.dispose();
1634
+ };
1635
+ };
1636
+
1637
+ // packages/plugins/plugin-space/src/components/SyncStatus/status.ts
1638
+ var getStatus = ({ offline, saved, needsToUpload, needsToDownload }) => {
1639
+ if (!saved) {
1640
+ return "saving locally";
1641
+ } else if (!offline && needsToDownload) {
1642
+ return "downloading";
1643
+ } else if (!offline && needsToUpload) {
1644
+ return "uploading";
1645
+ } else if (offline && !needsToUpload && !needsToDownload) {
1646
+ return "offline persisted";
1647
+ } else {
1648
+ return "remote synced";
1649
+ }
1650
+ };
1651
+ var getIcon = (status) => {
1652
+ switch (status) {
1653
+ case "saving locally":
1654
+ return "ph--download--regular";
1655
+ case "downloading":
1656
+ return "ph--cloud-arrow-down--regular";
1657
+ case "uploading":
1658
+ return "ph--cloud-arrow-up--regular";
1659
+ case "offline persisted":
1660
+ return "ph--check-circle--regular";
1661
+ case "remote synced":
1662
+ return "ph--cloud-check--regular";
1663
+ }
1664
+ };
1665
+
1666
+ // packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
1667
+ var SyncStatus = () => {
1668
+ const client = useClient11();
1669
+ const state = useSyncState();
1670
+ const [saved, setSaved] = useState14(true);
1671
+ useEffect8(() => {
1672
+ return createClientSaveTracker(client, (state2) => {
1673
+ setSaved(state2 === "saved");
1674
+ });
1675
+ }, []);
1676
+ return /* @__PURE__ */ React23.createElement(SyncStatusIndicator, {
1677
+ state,
1678
+ saved
1679
+ });
1680
+ };
1681
+ var SyncStatusIndicator = ({ state, saved }) => {
1682
+ const { t } = useTranslation22(SPACE_PLUGIN);
1683
+ const summary = getSyncSummary(state);
1684
+ const offline = Object.values(state).length === 0;
1685
+ const needsToUpload = summary.differentDocuments > 0 || summary.missingOnRemote > 0;
1686
+ const needsToDownload = summary.differentDocuments > 0 || summary.missingOnLocal > 0;
1687
+ const status = getStatus({
1688
+ offline,
1689
+ saved,
1690
+ needsToUpload,
1691
+ needsToDownload
1692
+ });
1693
+ const [classNames, setClassNames] = useState14();
1694
+ useEffect8(() => {
1695
+ setClassNames(void 0);
1696
+ if (offline || !needsToUpload && !needsToDownload) {
1697
+ return;
1698
+ }
1699
+ const t2 = setTimeout(() => {
1700
+ setClassNames("text-orange-500");
1701
+ }, SYNC_STALLED_TIMEOUT);
1702
+ return () => clearTimeout(t2);
1703
+ }, [
1704
+ offline,
1705
+ needsToUpload,
1706
+ needsToDownload
1707
+ ]);
1708
+ const title = t(`${status} label`);
1709
+ const icon = /* @__PURE__ */ React23.createElement(Icon6, {
1710
+ icon: getIcon(status),
1711
+ size: 4,
1712
+ classNames
1713
+ });
1714
+ if (offline) {
1715
+ return /* @__PURE__ */ React23.createElement(StatusBar.Item, {
1716
+ title
1717
+ }, icon);
1718
+ } else {
1719
+ return /* @__PURE__ */ React23.createElement(Popover3.Root, null, /* @__PURE__ */ React23.createElement(Popover3.Trigger, {
1720
+ asChild: true
1721
+ }, /* @__PURE__ */ React23.createElement(StatusBar.Button, {
1722
+ title
1723
+ }, icon)), /* @__PURE__ */ React23.createElement(Popover3.Portal, null, /* @__PURE__ */ React23.createElement(Popover3.Content, null, /* @__PURE__ */ React23.createElement(SyncStatusDetail, {
1724
+ state,
1725
+ summary,
1726
+ debug: false
1727
+ }), /* @__PURE__ */ React23.createElement(Popover3.Arrow, null))));
1728
+ }
1729
+ };
1730
+ var SyncStatusDetail = ({ classNames, state, summary, debug }) => {
1731
+ const [showAll, setShowAll] = useState14(false);
1732
+ const { t } = useTranslation22(SPACE_PLUGIN);
1733
+ const entries = Object.entries(state).filter(([_, value]) => showAll || value.missingOnLocal + value.missingOnRemote > 0).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
1734
+ const handleCheckedChange = useCallback12((state2) => setShowAll(state2), [
1735
+ setShowAll
1736
+ ]);
1737
+ return /* @__PURE__ */ React23.createElement("div", {
1738
+ className: mx6("flex flex-col gap-3 p-2 text-xs min-w-96", classNames)
1739
+ }, /* @__PURE__ */ React23.createElement("div", {
1740
+ role: "none",
1741
+ className: "flex items-center"
1742
+ }, /* @__PURE__ */ React23.createElement("h1", {
1743
+ className: "flex-1"
1744
+ }, t("sync status title")), /* @__PURE__ */ React23.createElement("div", {
1745
+ className: "flex items-center gap-2"
1746
+ }, /* @__PURE__ */ React23.createElement(Input6.Root, null, /* @__PURE__ */ React23.createElement(Input6.Label, {
1747
+ classNames: "text-xs"
1748
+ }, t("show all label")), /* @__PURE__ */ React23.createElement(Input6.Checkbox, {
1749
+ checked: showAll,
1750
+ onCheckedChange: handleCheckedChange
1751
+ })))), /* @__PURE__ */ React23.createElement("div", {
1752
+ className: "flex flex-col gap-2"
1753
+ }, entries.length === 0 && /* @__PURE__ */ React23.createElement("div", {
1754
+ role: "none",
1755
+ className: "flex justify-center"
1756
+ }, t("no sync status label")), entries.map(([spaceId, state2]) => /* @__PURE__ */ React23.createElement(SpaceRowContainer, {
1757
+ key: spaceId,
1758
+ spaceId,
1759
+ state: state2
1760
+ }))), debug && /* @__PURE__ */ React23.createElement(SyntaxHighlighter, {
1761
+ language: "json"
1762
+ }, JSON.stringify(summary, null, 2)));
1763
+ };
1764
+
1765
+ export {
1766
+ AdvancedObjectSettings,
1767
+ AwaitingObject,
1768
+ BaseObjectSettings,
1769
+ CREATE_OBJECT_DIALOG,
1770
+ CreateObjectDialog,
1771
+ CREATE_SPACE_DIALOG,
1772
+ CreateSpaceDialog,
1773
+ CollectionMain,
1774
+ CollectionSection,
1775
+ JOIN_DIALOG,
1776
+ JoinDialog,
1777
+ MenuFooter,
1778
+ PersistenceStatus,
1779
+ POPOVER_ADD_SPACE,
1780
+ PopoverAddSpace,
1781
+ POPOVER_RENAME_OBJECT,
1782
+ PopoverRenameObject,
1783
+ POPOVER_RENAME_SPACE,
1784
+ PopoverRenameSpace,
1785
+ ShareSpaceButton,
1786
+ ShareSpaceButtonImpl,
1787
+ SpacePresence,
1788
+ FullPresence,
1789
+ SmallPresenceLive,
1790
+ SmallPresence,
1791
+ SpacePluginSettings,
1792
+ SpaceSettingsPanel,
1793
+ SPACE_SETTINGS_DIALOG,
1794
+ SpaceSettingsDialog,
1795
+ InlineSyncStatus,
1796
+ SyncStatus,
1797
+ SyncStatusIndicator,
1798
+ SyncStatusDetail,
1799
+ AppGraphBuilder,
1800
+ AppGraphSerializer,
1801
+ IdentityCreated,
1802
+ IntentResolver,
1803
+ ReactRoot,
1804
+ ReactSurface,
1805
+ Schema,
1806
+ SpaceSettings,
1807
+ SpaceState,
1808
+ SpacesReady
1809
+ };
1810
+ //# sourceMappingURL=chunk-DIKRH2IK.mjs.map