@dxos/plugin-space 0.7.4 → 0.7.5-feature-compute.4d9d99a

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