@dxos/plugin-space 0.6.8-main.046e6cf

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 (109) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +15 -0
  3. package/dist/lib/browser/chunk-DTVUOG2C.mjs +95 -0
  4. package/dist/lib/browser/chunk-DTVUOG2C.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-LZEGRS7H.mjs +35 -0
  6. package/dist/lib/browser/chunk-LZEGRS7H.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +2660 -0
  8. package/dist/lib/browser/index.mjs.map +7 -0
  9. package/dist/lib/browser/meta.json +1 -0
  10. package/dist/lib/browser/meta.mjs +13 -0
  11. package/dist/lib/browser/meta.mjs.map +7 -0
  12. package/dist/lib/browser/types/index.mjs +21 -0
  13. package/dist/lib/browser/types/index.mjs.map +7 -0
  14. package/dist/lib/node/chunk-6CNYF6YU.cjs +60 -0
  15. package/dist/lib/node/chunk-6CNYF6YU.cjs.map +7 -0
  16. package/dist/lib/node/chunk-CVZPI2P3.cjs +120 -0
  17. package/dist/lib/node/chunk-CVZPI2P3.cjs.map +7 -0
  18. package/dist/lib/node/index.cjs +2682 -0
  19. package/dist/lib/node/index.cjs.map +7 -0
  20. package/dist/lib/node/meta.cjs +34 -0
  21. package/dist/lib/node/meta.cjs.map +7 -0
  22. package/dist/lib/node/meta.json +1 -0
  23. package/dist/lib/node/types/index.cjs +43 -0
  24. package/dist/lib/node/types/index.cjs.map +7 -0
  25. package/dist/types/src/SpacePlugin.d.ts +27 -0
  26. package/dist/types/src/SpacePlugin.d.ts.map +1 -0
  27. package/dist/types/src/components/AwaitingObject.d.ts +5 -0
  28. package/dist/types/src/components/AwaitingObject.d.ts.map +1 -0
  29. package/dist/types/src/components/CollectionMain.d.ts +6 -0
  30. package/dist/types/src/components/CollectionMain.d.ts.map +1 -0
  31. package/dist/types/src/components/CollectionSection.d.ts +6 -0
  32. package/dist/types/src/components/CollectionSection.d.ts.map +1 -0
  33. package/dist/types/src/components/EmptySpace.d.ts +3 -0
  34. package/dist/types/src/components/EmptySpace.d.ts.map +1 -0
  35. package/dist/types/src/components/EmptyTree.d.ts +3 -0
  36. package/dist/types/src/components/EmptyTree.d.ts.map +1 -0
  37. package/dist/types/src/components/MenuFooter.d.ts +6 -0
  38. package/dist/types/src/components/MenuFooter.d.ts.map +1 -0
  39. package/dist/types/src/components/MissingObject.d.ts +5 -0
  40. package/dist/types/src/components/MissingObject.d.ts.map +1 -0
  41. package/dist/types/src/components/PersistenceStatus.d.ts +6 -0
  42. package/dist/types/src/components/PersistenceStatus.d.ts.map +1 -0
  43. package/dist/types/src/components/PopoverRenameObject.d.ts +6 -0
  44. package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -0
  45. package/dist/types/src/components/PopoverRenameSpace.d.ts +6 -0
  46. package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -0
  47. package/dist/types/src/components/ShareSpaceButton.d.ts +8 -0
  48. package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -0
  49. package/dist/types/src/components/ShareSpaceButton.stories.d.ts +98 -0
  50. package/dist/types/src/components/ShareSpaceButton.stories.d.ts.map +1 -0
  51. package/dist/types/src/components/SpaceMain/SpaceMain.d.ts +10 -0
  52. package/dist/types/src/components/SpaceMain/SpaceMain.d.ts.map +1 -0
  53. package/dist/types/src/components/SpaceMain/SpaceMembersSection.d.ts +6 -0
  54. package/dist/types/src/components/SpaceMain/SpaceMembersSection.d.ts.map +1 -0
  55. package/dist/types/src/components/SpaceMain/index.d.ts +2 -0
  56. package/dist/types/src/components/SpaceMain/index.d.ts.map +1 -0
  57. package/dist/types/src/components/SpacePresence.d.ts +34 -0
  58. package/dist/types/src/components/SpacePresence.d.ts.map +1 -0
  59. package/dist/types/src/components/SpacePresence.stories.d.ts +97 -0
  60. package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -0
  61. package/dist/types/src/components/SpaceSettings.d.ts +6 -0
  62. package/dist/types/src/components/SpaceSettings.d.ts.map +1 -0
  63. package/dist/types/src/components/index.d.ts +15 -0
  64. package/dist/types/src/components/index.d.ts.map +1 -0
  65. package/dist/types/src/index.d.ts +9 -0
  66. package/dist/types/src/index.d.ts.map +1 -0
  67. package/dist/types/src/meta.d.ts +26 -0
  68. package/dist/types/src/meta.d.ts.map +1 -0
  69. package/dist/types/src/translations.d.ts +83 -0
  70. package/dist/types/src/translations.d.ts.map +1 -0
  71. package/dist/types/src/types/collection.d.ts +18 -0
  72. package/dist/types/src/types/collection.d.ts.map +1 -0
  73. package/dist/types/src/types/index.d.ts +4 -0
  74. package/dist/types/src/types/index.d.ts.map +1 -0
  75. package/dist/types/src/types/thread.d.ts +225 -0
  76. package/dist/types/src/types/thread.d.ts.map +1 -0
  77. package/dist/types/src/types/types.d.ts +54 -0
  78. package/dist/types/src/types/types.d.ts.map +1 -0
  79. package/dist/types/src/util.d.ts +85 -0
  80. package/dist/types/src/util.d.ts.map +1 -0
  81. package/package.json +101 -0
  82. package/src/SpacePlugin.tsx +1234 -0
  83. package/src/components/AwaitingObject.tsx +118 -0
  84. package/src/components/CollectionMain.tsx +33 -0
  85. package/src/components/CollectionSection.tsx +20 -0
  86. package/src/components/EmptySpace.tsx +25 -0
  87. package/src/components/EmptyTree.tsx +25 -0
  88. package/src/components/MenuFooter.tsx +33 -0
  89. package/src/components/MissingObject.tsx +54 -0
  90. package/src/components/PersistenceStatus.tsx +87 -0
  91. package/src/components/PopoverRenameObject.tsx +54 -0
  92. package/src/components/PopoverRenameSpace.tsx +44 -0
  93. package/src/components/ShareSpaceButton.stories.tsx +23 -0
  94. package/src/components/ShareSpaceButton.tsx +27 -0
  95. package/src/components/SpaceMain/SpaceMain.tsx +81 -0
  96. package/src/components/SpaceMain/SpaceMembersSection.tsx +205 -0
  97. package/src/components/SpaceMain/index.ts +5 -0
  98. package/src/components/SpacePresence.stories.tsx +102 -0
  99. package/src/components/SpacePresence.tsx +244 -0
  100. package/src/components/SpaceSettings.tsx +34 -0
  101. package/src/components/index.ts +18 -0
  102. package/src/index.ts +15 -0
  103. package/src/meta.ts +31 -0
  104. package/src/translations.ts +92 -0
  105. package/src/types/collection.ts +16 -0
  106. package/src/types/index.ts +7 -0
  107. package/src/types/thread.ts +68 -0
  108. package/src/types/types.ts +81 -0
  109. package/src/util.tsx +642 -0
@@ -0,0 +1,2682 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var node_exports = {};
30
+ __export(node_exports, {
31
+ ActorSchema: () => import_chunk_CVZPI2P3.ActorSchema,
32
+ AwaitingObject: () => AwaitingObject,
33
+ COMPOSER_SPACE_LOCK: () => COMPOSER_SPACE_LOCK,
34
+ ChannelType: () => import_chunk_CVZPI2P3.ChannelType,
35
+ CollectionMain: () => CollectionMain,
36
+ CollectionSection: () => CollectionSection,
37
+ CollectionType: () => import_chunk_CVZPI2P3.CollectionType,
38
+ ContactType: () => import_chunk_CVZPI2P3.ContactType,
39
+ EmptySpace: () => EmptySpace,
40
+ EmptyTree: () => EmptyTree,
41
+ FullPresence: () => FullPresence,
42
+ MenuFooter: () => MenuFooter,
43
+ MessageType: () => import_chunk_CVZPI2P3.MessageType,
44
+ MissingObject: () => MissingObject,
45
+ PersistenceStatus: () => PersistenceStatus,
46
+ PopoverRenameObject: () => PopoverRenameObject,
47
+ PopoverRenameSpace: () => PopoverRenameSpace,
48
+ SHARED: () => SHARED,
49
+ SPACES: () => SPACES,
50
+ SPACE_DIRECTORY_HANDLE: () => import_chunk_CVZPI2P3.SPACE_DIRECTORY_HANDLE,
51
+ SPACE_PLUGIN: () => import_chunk_6CNYF6YU.SPACE_PLUGIN,
52
+ SPACE_PLUGIN_SHORT_ID: () => import_chunk_6CNYF6YU.SPACE_PLUGIN_SHORT_ID,
53
+ SPACE_TYPE: () => SPACE_TYPE,
54
+ ShareSpaceButton: () => ShareSpaceButton,
55
+ ShareSpaceButtonImpl: () => ShareSpaceButtonImpl,
56
+ SmallPresence: () => SmallPresence,
57
+ SmallPresenceLive: () => SmallPresenceLive,
58
+ SpaceAction: () => import_chunk_6CNYF6YU.SpaceAction,
59
+ SpaceMain: () => SpaceMain,
60
+ SpacePlugin: () => SpacePlugin,
61
+ SpacePresence: () => SpacePresence,
62
+ SpaceSettings: () => SpaceSettings,
63
+ ThreadStatus: () => import_chunk_CVZPI2P3.ThreadStatus,
64
+ ThreadType: () => import_chunk_CVZPI2P3.ThreadType,
65
+ cloneObject: () => cloneObject,
66
+ constructObjectActionGroups: () => constructObjectActionGroups,
67
+ constructObjectActions: () => constructObjectActions,
68
+ constructSpaceActionGroups: () => constructSpaceActionGroups,
69
+ constructSpaceActions: () => constructSpaceActions,
70
+ constructSpaceNode: () => constructSpaceNode,
71
+ createObjectNode: () => createObjectNode,
72
+ default: () => src_default,
73
+ getActiveSpace: () => getActiveSpace,
74
+ getNestedObjects: () => getNestedObjects,
75
+ getSpaceDisplayName: () => getSpaceDisplayName,
76
+ memoizeQuery: () => memoizeQuery,
77
+ parseSpacePlugin: () => parseSpacePlugin,
78
+ translations: () => translations_default
79
+ });
80
+ module.exports = __toCommonJS(node_exports);
81
+ var import_chunk_6CNYF6YU = require("./chunk-6CNYF6YU.cjs");
82
+ var import_chunk_CVZPI2P3 = require("./chunk-CVZPI2P3.cjs");
83
+ var import_react = require("@phosphor-icons/react");
84
+ var import_signals_core = require("@preact/signals-core");
85
+ var import_react2 = __toESM(require("react"));
86
+ var import_app_framework = require("@dxos/app-framework");
87
+ var import_async = require("@dxos/async");
88
+ var import_echo_schema = require("@dxos/echo-schema");
89
+ var import_local_storage = require("@dxos/local-storage");
90
+ var import_log = require("@dxos/log");
91
+ var import_migrations = require("@dxos/migrations");
92
+ var import_plugin_attention = require("@dxos/plugin-attention");
93
+ var import_plugin_client = require("@dxos/plugin-client");
94
+ var import_plugin_graph = require("@dxos/plugin-graph");
95
+ var import_meta = require("@dxos/plugin-observability/meta");
96
+ var import_react_client = require("@dxos/react-client");
97
+ var import_echo = require("@dxos/react-client/echo");
98
+ var import_react_ui = require("@dxos/react-ui");
99
+ var import_react3 = require("@dxos/shell/react");
100
+ var import_util = require("@dxos/util");
101
+ var import_react4 = require("@phosphor-icons/react");
102
+ var import_react5 = __toESM(require("react"));
103
+ var import_app_framework2 = require("@dxos/app-framework");
104
+ var import_react_client2 = require("@dxos/react-client");
105
+ var import_echo2 = require("@dxos/react-client/echo");
106
+ var import_react_ui2 = require("@dxos/react-ui");
107
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
108
+ var import_react6 = __toESM(require("react"));
109
+ var import_react_ui3 = require("@dxos/react-ui");
110
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
111
+ var import_react7 = __toESM(require("react"));
112
+ var import_react_ui4 = require("@dxos/react-ui");
113
+ var import_react8 = __toESM(require("react"));
114
+ var import_react_ui5 = require("@dxos/react-ui");
115
+ var import_react_ui_theme3 = require("@dxos/react-ui-theme");
116
+ var import_react9 = __toESM(require("react"));
117
+ var import_react_ui6 = require("@dxos/react-ui");
118
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
119
+ var import_react10 = require("@phosphor-icons/react");
120
+ var import_react11 = __toESM(require("react"));
121
+ var import_echo3 = require("@dxos/client/echo");
122
+ var import_react_client3 = require("@dxos/react-client");
123
+ var import_react_ui7 = require("@dxos/react-ui");
124
+ var import_react12 = require("@phosphor-icons/react");
125
+ var import_react13 = __toESM(require("react"));
126
+ var import_app_framework3 = require("@dxos/app-framework");
127
+ var import_echo_schema2 = require("@dxos/echo-schema");
128
+ var import_invariant = require("@dxos/invariant");
129
+ var import_migrations2 = require("@dxos/migrations");
130
+ var import_plugin_graph2 = require("@dxos/plugin-graph");
131
+ var import_echo4 = require("@dxos/react-client/echo");
132
+ var import_react14 = __toESM(require("react"));
133
+ var import_app_framework4 = require("@dxos/app-framework");
134
+ var import_react_ui8 = require("@dxos/react-ui");
135
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
136
+ var import_react15 = require("@phosphor-icons/react");
137
+ var import_react16 = __toESM(require("react"));
138
+ var import_async2 = require("@dxos/async");
139
+ var import_react_ui9 = require("@dxos/react-ui");
140
+ var import_react_ui_theme6 = require("@dxos/react-ui-theme");
141
+ var import_react17 = __toESM(require("react"));
142
+ var import_log2 = require("@dxos/log");
143
+ var import_react_ui10 = require("@dxos/react-ui");
144
+ var import_react18 = __toESM(require("react"));
145
+ var import_react_ui11 = require("@dxos/react-ui");
146
+ var import_react19 = __toESM(require("react"));
147
+ var import_app_framework5 = require("@dxos/app-framework");
148
+ var import_react_ui12 = require("@dxos/react-ui");
149
+ var import_react20 = require("@phosphor-icons/react");
150
+ var import_react21 = __toESM(require("react"));
151
+ var import_app_framework6 = require("@dxos/app-framework");
152
+ var import_echo5 = require("@dxos/react-client/echo");
153
+ var import_react_ui13 = require("@dxos/react-ui");
154
+ var import_react_ui_theme7 = require("@dxos/react-ui-theme");
155
+ var import_react22 = require("@dxos/shell/react");
156
+ var import_react23 = require("@phosphor-icons/react");
157
+ var import_react24 = __toESM(require("react"));
158
+ var import_app_framework7 = require("@dxos/app-framework");
159
+ var import_echo6 = require("@dxos/react-client/echo");
160
+ var import_invitations = require("@dxos/react-client/invitations");
161
+ var import_invitations2 = require("@dxos/react-client/invitations");
162
+ var import_react_ui14 = require("@dxos/react-ui");
163
+ var import_react_ui_theme8 = require("@dxos/react-ui-theme");
164
+ var import_react25 = require("@dxos/shell/react");
165
+ var import_react26 = __toESM(require("react"));
166
+ var import_app_framework8 = require("@dxos/app-framework");
167
+ var import_display_name = require("@dxos/display-name");
168
+ var import_react_client4 = require("@dxos/react-client");
169
+ var import_echo7 = require("@dxos/react-client/echo");
170
+ var import_halo = require("@dxos/react-client/halo");
171
+ var import_react_ui15 = require("@dxos/react-ui");
172
+ var import_react_ui_attention = require("@dxos/react-ui-attention");
173
+ var import_util2 = require("@dxos/util");
174
+ var import_react27 = __toESM(require("react"));
175
+ var import_app_framework9 = require("@dxos/app-framework");
176
+ var import_plugin_settings = require("@dxos/plugin-settings");
177
+ var import_react_ui16 = require("@dxos/react-ui");
178
+ var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
179
+ var TOAST_TIMEOUT = 24e4;
180
+ var AwaitingObject = ({ id }) => {
181
+ const [open, setOpen] = (0, import_react5.useState)(true);
182
+ const [waiting, setWaiting] = (0, import_react5.useState)(true);
183
+ const [found, setFound] = (0, import_react5.useState)(false);
184
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
185
+ const intentPlugin = (0, import_app_framework2.useResolvePlugin)(import_app_framework2.parseIntentPlugin);
186
+ const navigationPlugin = (0, import_app_framework2.useResolvePlugin)(import_app_framework2.parseNavigationPlugin);
187
+ const client = (0, import_react_client2.useClient)();
188
+ const objects = (0, import_echo2.useQuery)(client.spaces);
189
+ (0, import_react5.useEffect)(() => {
190
+ if (!id) {
191
+ return;
192
+ }
193
+ const timeout = setTimeout(() => {
194
+ setWaiting(false);
195
+ }, WAIT_FOR_OBJECT_TIMEOUT);
196
+ () => clearTimeout(timeout);
197
+ }, [
198
+ id
199
+ ]);
200
+ (0, import_react5.useEffect)(() => {
201
+ if (objects.findIndex((object) => (0, import_echo2.fullyQualifiedId)(object) === id) > -1) {
202
+ setFound(true);
203
+ if (navigationPlugin?.provides.location.active === id) {
204
+ setOpen(false);
205
+ }
206
+ }
207
+ }, [
208
+ id,
209
+ objects,
210
+ intentPlugin
211
+ ]);
212
+ const handleClose = async () => intentPlugin?.provides.intent.dispatch({
213
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
214
+ action: import_chunk_6CNYF6YU.SpaceAction.WAIT_FOR_OBJECT,
215
+ data: {
216
+ id: void 0
217
+ }
218
+ });
219
+ const handleNavigate = () => {
220
+ void intentPlugin?.provides.intent.dispatch({
221
+ action: import_app_framework2.NavigationAction.OPEN,
222
+ data: {
223
+ activeParts: {
224
+ main: [
225
+ id
226
+ ]
227
+ }
228
+ }
229
+ });
230
+ void handleClose();
231
+ };
232
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Root, {
233
+ open,
234
+ duration: TOAST_TIMEOUT,
235
+ onOpenChange: setOpen
236
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Body, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Title, {
237
+ classNames: "flex items-center gap-2"
238
+ }, found ? /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
239
+ className: (0, import_react_ui_theme.getSize)(5)
240
+ }), /* @__PURE__ */ import_react5.default.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(import_react4.CircleNotch, {
241
+ className: (0, import_react_ui_theme.mx)((0, import_react_ui_theme.getSize)(5), "animate-spin")
242
+ }), /* @__PURE__ */ import_react5.default.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(import_react4.CircleDashed, {
243
+ className: (0, import_react_ui_theme.getSize)(5)
244
+ }), /* @__PURE__ */ import_react5.default.createElement("span", null, t("object not found label")))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Description, null, t(found ? "found object description" : waiting ? "waiting for object description" : "object not found description"))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Actions, null, found ? /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Action, {
245
+ altText: t("go to object alt"),
246
+ asChild: true
247
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
248
+ variant: "primary",
249
+ onClick: handleNavigate
250
+ }, t("go to object label"))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Close, {
251
+ asChild: true
252
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
253
+ onClick: handleClose
254
+ }, t("close label", {
255
+ ns: "appkit"
256
+ })))) : /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Toast.Close, {
257
+ asChild: true
258
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
259
+ onClick: handleClose
260
+ }, t(waiting ? "close label" : "confirm label", {
261
+ ns: "appkit"
262
+ })))));
263
+ };
264
+ var CollectionMain = ({ collection }) => {
265
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
266
+ return /* @__PURE__ */ import_react6.default.createElement("div", {
267
+ role: "none",
268
+ className: (0, import_react_ui_theme2.mx)(import_react_ui_theme2.baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
269
+ "data-testid": "composer.firstRunMessage"
270
+ }, /* @__PURE__ */ import_react6.default.createElement("p", {
271
+ role: "alert",
272
+ className: (0, import_react_ui_theme2.mx)(import_react_ui_theme2.descriptionText, "border border-dashed border-neutral-400/50 rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
273
+ }, collection.name ?? t("unnamed collection label")));
274
+ };
275
+ var CollectionSection = ({ collection }) => {
276
+ const { t } = (0, import_react_ui4.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
277
+ return /* @__PURE__ */ import_react7.default.createElement("div", {
278
+ className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
279
+ }, /* @__PURE__ */ import_react7.default.createElement("span", {
280
+ className: "truncate"
281
+ }, collection.name ?? t("unnamed collection label")));
282
+ };
283
+ var EmptySpace = () => {
284
+ const { t } = (0, import_react_ui5.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
285
+ return /* @__PURE__ */ import_react8.default.createElement("div", {
286
+ role: "none",
287
+ className: (0, import_react_ui_theme3.mx)("p-2 mli-2 mbe-2 text-center border border-dashed border-neutral-400/50 rounded-lg", import_react_ui_theme3.descriptionText)
288
+ }, t("empty space message"));
289
+ };
290
+ var EmptyTree = () => {
291
+ const { t } = (0, import_react_ui6.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
292
+ return /* @__PURE__ */ import_react9.default.createElement("div", {
293
+ role: "none",
294
+ className: (0, import_react_ui_theme4.mx)("p-2 mli-2 mbe-2 text-center border border-dashed border-neutral-400/50 rounded-lg", import_react_ui_theme4.descriptionText)
295
+ }, t("empty tree message"));
296
+ };
297
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/util.tsx";
298
+ var SPACES = `${import_chunk_6CNYF6YU.SPACE_PLUGIN}-spaces`;
299
+ var SPACE_TYPE = "dxos.org/type/Space";
300
+ var COMPOSER_SPACE_LOCK = "dxos.org/plugin/space/lock";
301
+ var SHARED = "shared-spaces";
302
+ var EMPTY_ARRAY = [];
303
+ var memoizeQuery = (spaceOrEcho, filter, options) => {
304
+ const key = (0, import_echo4.isSpace)(spaceOrEcho) ? spaceOrEcho.id : void 0;
305
+ const query = (0, import_plugin_graph2.memoize)(() => (0, import_echo4.isSpace)(spaceOrEcho) ? spaceOrEcho.db.query(filter, options) : spaceOrEcho?.query(filter, options), key);
306
+ const unsubscribe = (0, import_plugin_graph2.memoize)(() => query?.subscribe(), key);
307
+ (0, import_plugin_graph2.cleanup)(() => unsubscribe?.());
308
+ return query?.objects ?? EMPTY_ARRAY;
309
+ };
310
+ var getSpaceDisplayName = (space, { personal, namesCache = {} } = {}) => {
311
+ return space.state.get() === import_echo4.SpaceState.SPACE_READY && (space.properties.name?.length ?? 0) > 0 ? space.properties.name : namesCache[space.id] ? namesCache[space.id] : personal ? [
312
+ "personal space label",
313
+ {
314
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
315
+ }
316
+ ] : [
317
+ "unnamed space label",
318
+ {
319
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
320
+ }
321
+ ];
322
+ };
323
+ var getCollectionGraphNodePartials = ({ collection, space, resolve }) => {
324
+ return {
325
+ acceptPersistenceClass: /* @__PURE__ */ new Set([
326
+ "echo"
327
+ ]),
328
+ acceptPersistenceKey: /* @__PURE__ */ new Set([
329
+ space.id
330
+ ]),
331
+ role: "branch",
332
+ onRearrangeChildren: (nextOrder) => {
333
+ collection.objects = nextOrder.filter(import_echo4.isEchoObject);
334
+ },
335
+ onTransferStart: (child, index) => {
336
+ if (!collection.objects.includes(child.data)) {
337
+ if (typeof index !== "undefined") {
338
+ collection.objects.splice(index, 0, child.data);
339
+ } else {
340
+ collection.objects.push(child.data);
341
+ }
342
+ }
343
+ },
344
+ onTransferEnd: (child, destination) => {
345
+ const index = collection.objects.indexOf(child.data);
346
+ if (index > -1) {
347
+ collection.objects.splice(index, 1);
348
+ }
349
+ },
350
+ onCopy: async (child, index) => {
351
+ const newObject = await cloneObject(child.data, resolve);
352
+ space.db.add(newObject);
353
+ if (typeof index !== "undefined") {
354
+ collection.objects.splice(index, 0, newObject);
355
+ } else {
356
+ collection.objects.push(newObject);
357
+ }
358
+ }
359
+ };
360
+ };
361
+ var checkPendingMigration = (space) => {
362
+ return space.state.get() === import_echo4.SpaceState.SPACE_REQUIRES_MIGRATION || space.state.get() === import_echo4.SpaceState.SPACE_READY && !!import_migrations2.Migrations.versionProperty && space.properties[import_migrations2.Migrations.versionProperty] !== import_migrations2.Migrations.targetVersion;
363
+ };
364
+ var constructSpaceNode = ({ space, personal, namesCache, resolve }) => {
365
+ const hasPendingMigration = checkPendingMigration(space);
366
+ const collection = space.state.get() === import_echo4.SpaceState.SPACE_READY && space.properties[import_chunk_CVZPI2P3.CollectionType.typename];
367
+ const partials = space.state.get() === import_echo4.SpaceState.SPACE_READY && collection instanceof import_chunk_CVZPI2P3.CollectionType ? getCollectionGraphNodePartials({
368
+ collection,
369
+ space,
370
+ resolve
371
+ }) : {};
372
+ return {
373
+ id: space.id,
374
+ type: SPACE_TYPE,
375
+ data: space,
376
+ properties: {
377
+ ...partials,
378
+ label: getSpaceDisplayName(space, {
379
+ personal,
380
+ namesCache
381
+ }),
382
+ description: space.state.get() === import_echo4.SpaceState.SPACE_READY && space.properties.description,
383
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Planet, props),
384
+ iconSymbol: "ph--planet--regular",
385
+ disabled: space.state.get() !== import_echo4.SpaceState.SPACE_READY || hasPendingMigration,
386
+ testId: "spacePlugin.space"
387
+ }
388
+ };
389
+ };
390
+ var constructSpaceActionGroups = ({ space, dispatch }) => {
391
+ const state = space.state.get();
392
+ const hasPendingMigration = checkPendingMigration(space);
393
+ const getId = (id) => `${id}/${space.id}`;
394
+ if (state !== import_echo4.SpaceState.SPACE_READY || hasPendingMigration) {
395
+ return [];
396
+ }
397
+ const collection = space.properties[import_chunk_CVZPI2P3.CollectionType.typename];
398
+ const actions = [
399
+ {
400
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT),
401
+ type: import_plugin_graph2.ACTION_GROUP_TYPE,
402
+ data: import_plugin_graph2.actionGroupSymbol,
403
+ properties: {
404
+ label: [
405
+ "create object in space label",
406
+ {
407
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
408
+ }
409
+ ],
410
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Plus, props),
411
+ iconSymbol: "ph--plus--regular",
412
+ disposition: "toolbar",
413
+ // TODO(wittjosiah): This is currently a navtree feature. Address this with cmd+k integration.
414
+ // mainAreaDisposition: 'in-flow',
415
+ menuType: "searchList",
416
+ testId: "spacePlugin.createObject"
417
+ },
418
+ nodes: [
419
+ {
420
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT.replace("object", "collection")),
421
+ type: import_plugin_graph2.ACTION_TYPE,
422
+ data: () => dispatch([
423
+ {
424
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
425
+ action: import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT,
426
+ data: {
427
+ target: collection,
428
+ object: (0, import_echo_schema2.create)(import_chunk_CVZPI2P3.CollectionType, {
429
+ objects: [],
430
+ views: {}
431
+ })
432
+ }
433
+ },
434
+ {
435
+ action: import_app_framework3.NavigationAction.OPEN
436
+ }
437
+ ]),
438
+ properties: {
439
+ label: [
440
+ "create collection label",
441
+ {
442
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
443
+ }
444
+ ],
445
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.CardsThree, props),
446
+ iconSymbol: "ph--cards-three--regular",
447
+ testId: "spacePlugin.createCollection"
448
+ }
449
+ }
450
+ ]
451
+ }
452
+ ];
453
+ return actions;
454
+ };
455
+ var constructSpaceActions = ({ space, dispatch, personal, migrating }) => {
456
+ const state = space.state.get();
457
+ const hasPendingMigration = checkPendingMigration(space);
458
+ const getId = (id) => `${id}/${space.id}`;
459
+ const actions = [];
460
+ if (hasPendingMigration) {
461
+ actions.push({
462
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.MIGRATE),
463
+ type: import_plugin_graph2.ACTION_GROUP_TYPE,
464
+ data: async () => {
465
+ await dispatch({
466
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
467
+ action: import_chunk_6CNYF6YU.SpaceAction.MIGRATE,
468
+ data: {
469
+ space
470
+ }
471
+ });
472
+ },
473
+ properties: {
474
+ label: [
475
+ "migrate space label",
476
+ {
477
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
478
+ }
479
+ ],
480
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Database, props),
481
+ iconSymbol: "ph--database--regular",
482
+ disposition: "toolbar",
483
+ mainAreaDisposition: "in-flow",
484
+ disabled: migrating || import_migrations2.Migrations.running(space)
485
+ }
486
+ });
487
+ }
488
+ if (state === import_echo4.SpaceState.SPACE_READY && !hasPendingMigration) {
489
+ const locked = space.properties[COMPOSER_SPACE_LOCK];
490
+ actions.push({
491
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.SHARE),
492
+ type: import_plugin_graph2.ACTION_TYPE,
493
+ data: async () => {
494
+ if (locked) {
495
+ return;
496
+ }
497
+ await dispatch({
498
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
499
+ action: import_chunk_6CNYF6YU.SpaceAction.SHARE,
500
+ data: {
501
+ spaceId: space.id
502
+ }
503
+ });
504
+ },
505
+ properties: {
506
+ label: [
507
+ "share space label",
508
+ {
509
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
510
+ }
511
+ ],
512
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Users, props),
513
+ iconSymbol: "ph--users--regular",
514
+ disabled: locked,
515
+ keyBinding: {
516
+ macos: "meta+.",
517
+ windows: "alt+."
518
+ },
519
+ mainAreaDisposition: "absent"
520
+ }
521
+ }, {
522
+ id: locked ? getId(import_chunk_6CNYF6YU.SpaceAction.UNLOCK) : getId(import_chunk_6CNYF6YU.SpaceAction.LOCK),
523
+ type: import_plugin_graph2.ACTION_TYPE,
524
+ data: async () => {
525
+ await dispatch({
526
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
527
+ action: locked ? import_chunk_6CNYF6YU.SpaceAction.UNLOCK : import_chunk_6CNYF6YU.SpaceAction.LOCK,
528
+ data: {
529
+ space
530
+ }
531
+ });
532
+ },
533
+ properties: {
534
+ label: [
535
+ locked ? "unlock space label" : "lock space label",
536
+ {
537
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
538
+ }
539
+ ],
540
+ icon: locked ? (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.LockSimpleOpen, props) : (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.LockSimple, props),
541
+ iconSymbol: locked ? "ph--lock-simple-open--regular" : "ph--lock-simple--regular"
542
+ }
543
+ }, {
544
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.RENAME),
545
+ type: import_plugin_graph2.ACTION_TYPE,
546
+ data: async (params) => {
547
+ await dispatch({
548
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
549
+ action: import_chunk_6CNYF6YU.SpaceAction.RENAME,
550
+ data: {
551
+ space,
552
+ ...params
553
+ }
554
+ });
555
+ },
556
+ properties: {
557
+ label: [
558
+ "rename space label",
559
+ {
560
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
561
+ }
562
+ ],
563
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.PencilSimpleLine, props),
564
+ iconSymbol: "ph--pencil-simple-line--regular",
565
+ keyBinding: {
566
+ macos: "shift+F6",
567
+ windows: "shift+F6"
568
+ },
569
+ mainAreaDisposition: "absent"
570
+ }
571
+ });
572
+ }
573
+ if (state !== import_echo4.SpaceState.SPACE_INACTIVE && !hasPendingMigration) {
574
+ actions.push({
575
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.CLOSE),
576
+ type: import_plugin_graph2.ACTION_TYPE,
577
+ data: async () => {
578
+ await dispatch({
579
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
580
+ action: import_chunk_6CNYF6YU.SpaceAction.CLOSE,
581
+ data: {
582
+ space
583
+ }
584
+ });
585
+ },
586
+ properties: {
587
+ label: [
588
+ "close space label",
589
+ {
590
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
591
+ }
592
+ ],
593
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.X, props),
594
+ iconSymbol: "ph--x--regular",
595
+ mainAreaDisposition: "menu",
596
+ disabled: personal
597
+ }
598
+ });
599
+ }
600
+ if (state === import_echo4.SpaceState.SPACE_INACTIVE) {
601
+ actions.push({
602
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.OPEN),
603
+ type: import_plugin_graph2.ACTION_TYPE,
604
+ data: async () => {
605
+ await dispatch({
606
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
607
+ action: import_chunk_6CNYF6YU.SpaceAction.OPEN,
608
+ data: {
609
+ space
610
+ }
611
+ });
612
+ },
613
+ properties: {
614
+ label: [
615
+ "open space label",
616
+ {
617
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
618
+ }
619
+ ],
620
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.ClockCounterClockwise, props),
621
+ iconSymbol: "ph--clock-counter-clockwise--regular",
622
+ disposition: "toolbar",
623
+ mainAreaDisposition: "in-flow"
624
+ }
625
+ });
626
+ }
627
+ return actions;
628
+ };
629
+ var createObjectNode = ({ object, space, resolve }) => {
630
+ const type = (0, import_echo_schema2.getTypename)(object);
631
+ if (!type) {
632
+ return void 0;
633
+ }
634
+ const metadata = resolve(type);
635
+ if (Object.keys(metadata).length === 0) {
636
+ return void 0;
637
+ }
638
+ const partials = object instanceof import_chunk_CVZPI2P3.CollectionType ? getCollectionGraphNodePartials({
639
+ collection: object,
640
+ space,
641
+ resolve
642
+ }) : metadata.graphProps;
643
+ return {
644
+ id: (0, import_echo4.fullyQualifiedId)(object),
645
+ type,
646
+ data: object,
647
+ properties: {
648
+ ...partials,
649
+ label: metadata.label?.(object) || object.name || metadata.placeholder || [
650
+ "unnamed object label",
651
+ {
652
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
653
+ }
654
+ ],
655
+ icon: metadata.icon ?? (() => /* @__PURE__ */ import_react13.default.createElement(import_react12.Placeholder, null)),
656
+ iconSymbol: metadata.iconSymbol ?? "ph--placeholder--regular",
657
+ testId: "spacePlugin.object",
658
+ persistenceClass: "echo",
659
+ persistenceKey: space?.id
660
+ }
661
+ };
662
+ };
663
+ var constructObjectActionGroups = ({ object, dispatch }) => {
664
+ if (!(object instanceof import_chunk_CVZPI2P3.CollectionType)) {
665
+ return [];
666
+ }
667
+ const collection = object;
668
+ const getId = (id) => `${id}/${(0, import_echo4.fullyQualifiedId)(object)}`;
669
+ const actions = [
670
+ {
671
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT),
672
+ type: import_plugin_graph2.ACTION_GROUP_TYPE,
673
+ data: import_plugin_graph2.actionGroupSymbol,
674
+ properties: {
675
+ label: [
676
+ "create object in collection label",
677
+ {
678
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
679
+ }
680
+ ],
681
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Plus, props),
682
+ iconSymbol: "ph--plus--regular",
683
+ disposition: "toolbar",
684
+ // TODO(wittjosiah): This is currently a navtree feature. Address this with cmd+k integration.
685
+ // mainAreaDisposition: 'in-flow',
686
+ menuType: "searchList",
687
+ testId: "spacePlugin.createObject"
688
+ },
689
+ nodes: [
690
+ {
691
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT.replace("object", "collection")),
692
+ type: import_plugin_graph2.ACTION_TYPE,
693
+ data: () => dispatch([
694
+ {
695
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
696
+ action: import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT,
697
+ data: {
698
+ target: collection,
699
+ object: (0, import_echo_schema2.create)(import_chunk_CVZPI2P3.CollectionType, {
700
+ objects: [],
701
+ views: {}
702
+ })
703
+ }
704
+ },
705
+ {
706
+ action: import_app_framework3.NavigationAction.OPEN
707
+ }
708
+ ]),
709
+ properties: {
710
+ label: [
711
+ "create collection label",
712
+ {
713
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
714
+ }
715
+ ],
716
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.CardsThree, props),
717
+ iconSymbol: "ph--cards-three--regular",
718
+ testId: "spacePlugin.createCollection"
719
+ }
720
+ }
721
+ ]
722
+ }
723
+ ];
724
+ return actions;
725
+ };
726
+ var constructObjectActions = ({ node, dispatch }) => {
727
+ const object = node.data;
728
+ const getId = (id) => `${id}/${(0, import_echo4.fullyQualifiedId)(object)}`;
729
+ const actions = [
730
+ {
731
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.RENAME_OBJECT),
732
+ type: import_plugin_graph2.ACTION_TYPE,
733
+ data: async (params) => {
734
+ await dispatch({
735
+ action: import_chunk_6CNYF6YU.SpaceAction.RENAME_OBJECT,
736
+ data: {
737
+ object,
738
+ ...params
739
+ }
740
+ });
741
+ },
742
+ properties: {
743
+ label: [
744
+ object instanceof import_chunk_CVZPI2P3.CollectionType ? "rename collection label" : "rename object label",
745
+ {
746
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
747
+ }
748
+ ],
749
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.PencilSimpleLine, props),
750
+ iconSymbol: "ph--pencil-simple-line--regular",
751
+ // TODO(wittjosiah): Doesn't work.
752
+ // keyBinding: 'shift+F6',
753
+ testId: "spacePlugin.renameObject"
754
+ }
755
+ },
756
+ {
757
+ id: getId(import_chunk_6CNYF6YU.SpaceAction.REMOVE_OBJECT),
758
+ type: import_plugin_graph2.ACTION_TYPE,
759
+ data: async () => {
760
+ const graph = (0, import_plugin_graph2.getGraph)(node);
761
+ const collection = graph.nodes(node, {
762
+ relation: "inbound"
763
+ }).find(({ data }) => data instanceof import_chunk_CVZPI2P3.CollectionType)?.data;
764
+ await dispatch([
765
+ {
766
+ action: import_chunk_6CNYF6YU.SpaceAction.REMOVE_OBJECT,
767
+ data: {
768
+ object,
769
+ collection
770
+ }
771
+ }
772
+ ]);
773
+ },
774
+ properties: {
775
+ label: [
776
+ object instanceof import_chunk_CVZPI2P3.CollectionType ? "delete collection label" : "delete object label",
777
+ {
778
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
779
+ }
780
+ ],
781
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Trash, props),
782
+ iconSymbol: "ph--trash--regular",
783
+ keyBinding: object instanceof import_chunk_CVZPI2P3.CollectionType ? void 0 : "shift+meta+Backspace",
784
+ testId: "spacePlugin.deleteObject"
785
+ }
786
+ },
787
+ {
788
+ id: getId("copy-link"),
789
+ type: import_plugin_graph2.ACTION_TYPE,
790
+ data: async () => {
791
+ const url = `${window.location.origin}/${(0, import_echo4.fullyQualifiedId)(object)}`;
792
+ await navigator.clipboard.writeText(url);
793
+ },
794
+ properties: {
795
+ label: [
796
+ "copy link label",
797
+ {
798
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
799
+ }
800
+ ],
801
+ icon: (props) => /* @__PURE__ */ import_react13.default.createElement(import_react12.Link, props),
802
+ iconSymbol: "ph--link--regular",
803
+ testId: "spacePlugin.copyLink"
804
+ }
805
+ }
806
+ ];
807
+ return actions;
808
+ };
809
+ var getActiveSpace = (graph, active) => {
810
+ if (!active) {
811
+ return;
812
+ }
813
+ const node = graph.findNode(active);
814
+ if (!node || !(0, import_echo_schema2.isReactiveObject)(node.data)) {
815
+ return;
816
+ }
817
+ return (0, import_echo4.getSpace)(node.data);
818
+ };
819
+ var getNestedObjects = async (object, resolve) => {
820
+ const type = (0, import_echo_schema2.getTypename)(object);
821
+ if (!type) {
822
+ return [];
823
+ }
824
+ const metadata = resolve(type);
825
+ const loadReferences = metadata.loadReferences;
826
+ if (typeof loadReferences !== "function") {
827
+ return [];
828
+ }
829
+ const objects = await loadReferences(object);
830
+ const nested = await Promise.all(objects.map((object2) => getNestedObjects(object2, resolve)));
831
+ return [
832
+ ...objects,
833
+ ...nested.flat()
834
+ ];
835
+ };
836
+ var cloneObject = async (object, resolve) => {
837
+ const schema = (0, import_echo_schema2.getSchema)(object);
838
+ const typename = schema ? (0, import_echo_schema2.getEchoObjectAnnotation)(schema)?.typename ?? import_echo_schema2.EXPANDO_TYPENAME : import_echo_schema2.EXPANDO_TYPENAME;
839
+ const metadata = resolve(typename);
840
+ const serializer = metadata.serializer;
841
+ (0, import_invariant.invariant)(serializer, `No serializer for type: ${typename}`, {
842
+ F: __dxlog_file,
843
+ L: 639,
844
+ S: void 0,
845
+ A: [
846
+ "serializer",
847
+ "`No serializer for type: ${typename}`"
848
+ ]
849
+ });
850
+ const content = await serializer.serialize({
851
+ object
852
+ });
853
+ return serializer.deserialize({
854
+ content,
855
+ newId: true
856
+ });
857
+ };
858
+ var MenuFooter = ({ object }) => {
859
+ const { t } = (0, import_react_ui7.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
860
+ const client = (0, import_react_client3.useClient)();
861
+ const space = (0, import_echo3.getSpace)(object);
862
+ const spaceName = space ? getSpaceDisplayName(space, {
863
+ personal: client.spaces.default === space
864
+ }) : "";
865
+ return space ? /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui7.DropdownMenu.Separator, null), /* @__PURE__ */ import_react11.default.createElement(import_react_ui7.DropdownMenu.GroupLabel, null, t("menu footer label")), /* @__PURE__ */ import_react11.default.createElement("dl", {
866
+ className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
867
+ }, /* @__PURE__ */ import_react11.default.createElement("dt", {
868
+ className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
869
+ }, t("location label")), /* @__PURE__ */ import_react11.default.createElement("dd", {
870
+ className: "line-clamp-3"
871
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react10.Planet, {
872
+ className: "inline-block mie-1"
873
+ }), (0, import_react_ui7.toLocalizedString)(spaceName, t)))) : null;
874
+ };
875
+ var WAIT_FOR_OBJECT_TIMEOUT2 = 1e3;
876
+ var MissingObject = ({ id }) => {
877
+ const { t } = (0, import_react_ui8.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
878
+ const [waiting, setWaiting] = (0, import_react14.useState)(false);
879
+ const intentPlugin = (0, import_app_framework4.useResolvePlugin)(import_app_framework4.parseIntentPlugin);
880
+ (0, import_react14.useEffect)(() => {
881
+ if (!intentPlugin) {
882
+ return;
883
+ }
884
+ const timeout = setTimeout(async () => {
885
+ setWaiting(true);
886
+ await intentPlugin.provides.intent.dispatch({
887
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
888
+ action: import_chunk_6CNYF6YU.SpaceAction.WAIT_FOR_OBJECT,
889
+ data: {
890
+ id
891
+ }
892
+ });
893
+ }, WAIT_FOR_OBJECT_TIMEOUT2);
894
+ return () => clearTimeout(timeout);
895
+ }, [
896
+ intentPlugin,
897
+ id
898
+ ]);
899
+ return /* @__PURE__ */ import_react14.default.createElement("div", {
900
+ role: "none",
901
+ className: (0, import_react_ui_theme5.mx)(import_react_ui_theme5.baseSurface, "min-bs-screen is-full flex items-center justify-center p-8")
902
+ }, waiting ? /* @__PURE__ */ import_react14.default.createElement("p", {
903
+ role: "alert",
904
+ className: (0, import_react_ui_theme5.mx)(import_react_ui_theme5.descriptionText, "border border-dashed border-neutral-400/50 rounded-lg flex items-center justify-center p-8 font-normal text-lg")
905
+ }, t("missing object message")) : /* @__PURE__ */ import_react14.default.createElement(import_react_ui8.Status, {
906
+ indeterminate: true,
907
+ "aria-label": "Initializing"
908
+ }));
909
+ };
910
+ var Status2;
911
+ (function(Status3) {
912
+ Status3[Status3["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
913
+ Status3[Status3["PENDING"] = 1] = "PENDING";
914
+ Status3[Status3["ERROR"] = 2] = "ERROR";
915
+ })(Status2 || (Status2 = {}));
916
+ var PersistenceStatus = ({ db }) => {
917
+ const { t } = (0, import_react_ui9.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
918
+ const [displayMessage, setDisplayMessage] = (0, import_react16.useState)(false);
919
+ const [status, naturalSetStatus] = (0, import_react16.useState)(0);
920
+ const [prevStatus, setPrevStatus] = (0, import_react16.useState)(0);
921
+ const _setStatus = (0, import_async2.debounce)(naturalSetStatus, 500);
922
+ (0, import_react16.useEffect)(() => {
923
+ setPrevStatus(status);
924
+ if (prevStatus !== status && status === 0) {
925
+ setDisplayMessage(true);
926
+ const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
927
+ return () => clearTimeout(timeout);
928
+ }
929
+ }, [
930
+ status
931
+ ]);
932
+ switch (status) {
933
+ case 2:
934
+ return /* @__PURE__ */ import_react16.default.createElement("div", {
935
+ className: "flex items-center"
936
+ }, /* @__PURE__ */ import_react16.default.createElement(import_react15.Warning, {
937
+ className: (0, import_react_ui_theme6.mx)((0, import_react_ui_theme6.getSize)(4), "me-1")
938
+ }), /* @__PURE__ */ import_react16.default.createElement("span", {
939
+ className: (0, import_react_ui_theme6.mx)("text-sm", import_react_ui_theme6.warningText)
940
+ }, t("persistence error label")));
941
+ case 1:
942
+ return /* @__PURE__ */ import_react16.default.createElement("div", {
943
+ className: "flex items-center"
944
+ }, /* @__PURE__ */ import_react16.default.createElement(import_react15.ArrowsCounterClockwise, {
945
+ className: (0, import_react_ui_theme6.mx)((0, import_react_ui_theme6.getSize)(4), "me-1")
946
+ }), /* @__PURE__ */ import_react16.default.createElement("span", {
947
+ className: (0, import_react_ui_theme6.mx)("text-sm", import_react_ui_theme6.staticPlaceholderText)
948
+ }, t("persistence pending label")));
949
+ case 0:
950
+ default:
951
+ return /* @__PURE__ */ import_react16.default.createElement(import_react_ui9.Tooltip.Root, {
952
+ delayDuration: 400
953
+ }, /* @__PURE__ */ import_react16.default.createElement(import_react_ui9.Tooltip.Trigger, {
954
+ role: "status",
955
+ className: "flex items-center"
956
+ }, /* @__PURE__ */ import_react16.default.createElement(import_react15.CheckCircle, {
957
+ className: (0, import_react_ui_theme6.mx)((0, import_react_ui_theme6.getSize)(4), "me-1")
958
+ }), displayMessage && /* @__PURE__ */ import_react16.default.createElement("span", {
959
+ className: (0, import_react_ui_theme6.mx)("text-sm", import_react_ui_theme6.staticPlaceholderText)
960
+ }, t("persisted locally label"))), /* @__PURE__ */ import_react16.default.createElement(import_react_ui9.Tooltip.Portal, null, /* @__PURE__ */ import_react16.default.createElement(import_react_ui9.Tooltip.Content, {
961
+ classNames: "z-10"
962
+ }, t("persisted locally message"), /* @__PURE__ */ import_react16.default.createElement(import_react_ui9.Tooltip.Arrow, null))));
963
+ }
964
+ };
965
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
966
+ var PopoverRenameObject = ({ object: obj }) => {
967
+ const { t } = (0, import_react_ui10.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
968
+ const doneButton = (0, import_react17.useRef)(null);
969
+ const object = obj;
970
+ const [name, setName] = (0, import_react17.useState)(object.name || object.title || "");
971
+ const handleDone = (0, import_react17.useCallback)(() => {
972
+ try {
973
+ object.name = name;
974
+ } catch {
975
+ try {
976
+ object.title = name;
977
+ } catch (err) {
978
+ import_log2.log.error("Failed to rename object", {
979
+ err
980
+ }, {
981
+ F: __dxlog_file2,
982
+ L: 28,
983
+ S: void 0,
984
+ C: (f, a) => f(...a)
985
+ });
986
+ }
987
+ }
988
+ }, [
989
+ object,
990
+ name
991
+ ]);
992
+ return /* @__PURE__ */ import_react17.default.createElement("div", {
993
+ role: "none",
994
+ className: "p-1 flex gap-2"
995
+ }, /* @__PURE__ */ import_react17.default.createElement("div", {
996
+ role: "none",
997
+ className: "flex-1"
998
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui10.Input.Root, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui10.Input.Label, {
999
+ srOnly: true
1000
+ }, t("object name label")), /* @__PURE__ */ import_react17.default.createElement(import_react_ui10.Input.TextInput, {
1001
+ placeholder: t("object title placeholder"),
1002
+ value: name,
1003
+ "data-testid": "spacePlugin.renameObject.input",
1004
+ onChange: ({ target: { value } }) => setName(value),
1005
+ onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
1006
+ }))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui10.Popover.Close, {
1007
+ asChild: true
1008
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui10.Button, {
1009
+ ref: doneButton,
1010
+ classNames: "self-stretch",
1011
+ onClick: handleDone
1012
+ }, t("done label", {
1013
+ ns: "os"
1014
+ }))));
1015
+ };
1016
+ var PopoverRenameSpace = ({ space }) => {
1017
+ const { t } = (0, import_react_ui11.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1018
+ const doneButton = (0, import_react18.useRef)(null);
1019
+ const [name, setName] = (0, import_react18.useState)(space.properties.name ?? "");
1020
+ const handleDone = (0, import_react18.useCallback)(() => {
1021
+ space.properties.name = name;
1022
+ }, [
1023
+ space,
1024
+ name
1025
+ ]);
1026
+ return /* @__PURE__ */ import_react18.default.createElement("div", {
1027
+ role: "none",
1028
+ className: "p-1 flex gap-2"
1029
+ }, /* @__PURE__ */ import_react18.default.createElement("div", {
1030
+ role: "none",
1031
+ className: "flex-1"
1032
+ }, /* @__PURE__ */ import_react18.default.createElement(import_react_ui11.Input.Root, null, /* @__PURE__ */ import_react18.default.createElement(import_react_ui11.Input.Label, {
1033
+ srOnly: true
1034
+ }, t("space name label")), /* @__PURE__ */ import_react18.default.createElement(import_react_ui11.Input.TextInput, {
1035
+ defaultValue: space.properties.name ?? "",
1036
+ placeholder: t("unnamed space label"),
1037
+ onChange: ({ target: { value } }) => setName(value),
1038
+ // TODO(wittjosiah): Ideally this should access the popover context to close the popover.
1039
+ // Currently this is not possible because Radix does not expose the popover context.
1040
+ onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
1041
+ }))), /* @__PURE__ */ import_react18.default.createElement(import_react_ui11.Popover.Close, {
1042
+ asChild: true
1043
+ }, /* @__PURE__ */ import_react18.default.createElement(import_react_ui11.Button, {
1044
+ ref: doneButton,
1045
+ classNames: "self-stretch",
1046
+ onClick: handleDone
1047
+ }, t("done label", {
1048
+ ns: "os"
1049
+ }))));
1050
+ };
1051
+ var ShareSpaceButton = ({ spaceId }) => {
1052
+ const dispatch = (0, import_app_framework5.useIntentDispatcher)();
1053
+ return /* @__PURE__ */ import_react19.default.createElement(ShareSpaceButtonImpl, {
1054
+ onClick: () => dispatch({
1055
+ action: import_chunk_6CNYF6YU.SpaceAction.SHARE,
1056
+ data: {
1057
+ spaceId
1058
+ }
1059
+ })
1060
+ });
1061
+ };
1062
+ var ShareSpaceButtonImpl = ({ onClick }) => {
1063
+ const { t } = (0, import_react_ui12.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1064
+ return /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Button, {
1065
+ "data-testid": "spacePlugin.shareSpaceButton",
1066
+ onClick,
1067
+ classNames: "mli-1"
1068
+ }, t("share space label"));
1069
+ };
1070
+ var activeActionKeyStorageKey = "dxos:react-shell/space-manager/active-action";
1071
+ var Presence = import_echo6.SpaceMember.PresenceState;
1072
+ var handleCreateInvitationUrl = (invitationCode) => `${origin}?spaceInvitationCode=${invitationCode}`;
1073
+ var SpaceMemberList = ({ members }) => {
1074
+ return members.length > 0 ? /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.List, {
1075
+ classNames: "col-start-2 col-end-5 gap-y-1 grid grid-cols-subgrid items-center"
1076
+ }, members.map((member) => /* @__PURE__ */ import_react24.default.createElement(import_react25.IdentityListItem, {
1077
+ classNames: "contents",
1078
+ key: member.identity.identityKey.toHex(),
1079
+ identity: member.identity,
1080
+ presence: member.presence
1081
+ }))) : null;
1082
+ };
1083
+ var SpaceMembersSection = ({ space }) => {
1084
+ const { t } = (0, import_react_ui14.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1085
+ const invitations = (0, import_echo6.useSpaceInvitations)(space.key);
1086
+ const { dispatch } = (0, import_app_framework7.useIntent)();
1087
+ const handleCloseDialog = () => dispatch({
1088
+ action: import_app_framework7.LayoutAction.SET_LAYOUT,
1089
+ data: {
1090
+ element: "dialog",
1091
+ state: false
1092
+ }
1093
+ });
1094
+ const handleInvitationSelect = ({ invitation: invitationObservable }) => {
1095
+ const invitation = invitationObservable.get();
1096
+ void dispatch({
1097
+ action: import_app_framework7.LayoutAction.SET_LAYOUT,
1098
+ data: {
1099
+ element: "dialog",
1100
+ component: "dxos.org/plugin/space/InvitationManagerDialog",
1101
+ subject: {
1102
+ invitationUrl: handleCreateInvitationUrl(import_invitations.InvitationEncoder.encode(invitation)),
1103
+ send: handleCloseDialog,
1104
+ status: invitation.state,
1105
+ type: invitation.type,
1106
+ authCode: invitation.authCode,
1107
+ id: invitation.invitationId
1108
+ }
1109
+ }
1110
+ });
1111
+ };
1112
+ const inviteActions = {
1113
+ inviteOne: {
1114
+ label: t("invite one label", {
1115
+ ns: "os"
1116
+ }),
1117
+ description: t("invite one description", {
1118
+ ns: "os"
1119
+ }),
1120
+ icon: import_react23.UserPlus,
1121
+ onClick: (0, import_react24.useCallback)(() => {
1122
+ space.share?.({
1123
+ type: import_invitations2.Invitation.Type.INTERACTIVE,
1124
+ authMethod: import_invitations2.Invitation.AuthMethod.SHARED_SECRET
1125
+ });
1126
+ }, [
1127
+ space
1128
+ ])
1129
+ },
1130
+ inviteMany: {
1131
+ label: t("invite many label", {
1132
+ ns: "os"
1133
+ }),
1134
+ description: t("invite many description", {
1135
+ ns: "os"
1136
+ }),
1137
+ icon: import_react23.UsersThree,
1138
+ onClick: (0, import_react24.useCallback)(() => {
1139
+ space.share?.({
1140
+ type: import_invitations2.Invitation.Type.INTERACTIVE,
1141
+ authMethod: import_invitations2.Invitation.AuthMethod.NONE,
1142
+ multiUse: true
1143
+ });
1144
+ }, [
1145
+ space
1146
+ ])
1147
+ }
1148
+ };
1149
+ const [activeActionKey, setInternalActiveActionKey] = (0, import_react24.useState)(localStorage.getItem(activeActionKeyStorageKey) ?? "inviteOne");
1150
+ const setActiveActionKey = (nextKey) => {
1151
+ setInternalActiveActionKey(nextKey);
1152
+ localStorage.setItem(activeActionKeyStorageKey, nextKey);
1153
+ };
1154
+ const activeAction = inviteActions[activeActionKey] ?? {};
1155
+ const members = (0, import_echo6.useMembers)(space.key).reduce((acc, member) => {
1156
+ acc[member.presence].push(member);
1157
+ return acc;
1158
+ }, {
1159
+ [Presence.ONLINE]: [],
1160
+ [Presence.OFFLINE]: []
1161
+ });
1162
+ return /* @__PURE__ */ import_react24.default.createElement("section", {
1163
+ className: "mbe-4 col-span-3 grid gap-y-2 grid-cols-subgrid auto-rows-min"
1164
+ }, /* @__PURE__ */ import_react24.default.createElement("h2", {
1165
+ className: "contents"
1166
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react23.UsersThree, {
1167
+ weight: "duotone",
1168
+ className: (0, import_react_ui_theme8.mx)((0, import_react_ui_theme8.getSize)(5), "place-self-center")
1169
+ }), /* @__PURE__ */ import_react24.default.createElement("span", {
1170
+ className: "text-lg col-span-2"
1171
+ }, t("space members label"))), /* @__PURE__ */ import_react24.default.createElement("h3", {
1172
+ className: "col-start-2 col-span-3 text-sm italic fg-description"
1173
+ }, t("invitations heading")), invitations.length > 0 && /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.List, {
1174
+ classNames: "col-start-2 col-span-2 gap-y-2 grid grid-cols-[var(--rail-size)_1fr_var(--rail-action)_var(--rail-action)]"
1175
+ }, invitations.map((invitation) => /* @__PURE__ */ import_react24.default.createElement(import_react25.InvitationListItem, {
1176
+ reverseEffects: true,
1177
+ classNames: "pis-0 pie-0 gap-0 col-span-4 grid grid-cols-subgrid",
1178
+ key: invitation.get().invitationId,
1179
+ invitation,
1180
+ send: handleInvitationSelect,
1181
+ createInvitationUrl: handleCreateInvitationUrl
1182
+ }))), /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.ButtonGroup, {
1183
+ classNames: "col-start-2 col-end-4 grid grid-cols-[1fr_var(--rail-action)] place-self-grow gap-px"
1184
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.Button, {
1185
+ classNames: "gap-2",
1186
+ onClick: activeAction.onClick
1187
+ }, /* @__PURE__ */ import_react24.default.createElement(activeAction.icon, {
1188
+ className: (0, import_react_ui_theme8.getSize)(5)
1189
+ }), /* @__PURE__ */ import_react24.default.createElement("span", null, t(activeAction.label, {
1190
+ ns: "os"
1191
+ }))), /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.Root, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.Trigger, {
1192
+ asChild: true
1193
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.Button, {
1194
+ classNames: "pli-0"
1195
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react23.CaretDown, {
1196
+ className: (0, import_react_ui_theme8.getSize)(4)
1197
+ }))), /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.Content, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.Viewport, null, Object.entries(inviteActions).map(([id, action]) => {
1198
+ return /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.CheckboxItem, {
1199
+ key: id,
1200
+ "aria-labelledby": `${id}__label`,
1201
+ "aria-describedby": `${id}__description`,
1202
+ checked: activeActionKey === id,
1203
+ onCheckedChange: (checked) => checked && setActiveActionKey(id),
1204
+ classNames: "gap-2"
1205
+ }, action.icon && /* @__PURE__ */ import_react24.default.createElement(action.icon, {
1206
+ className: (0, import_react_ui_theme8.getSize)(5)
1207
+ }), /* @__PURE__ */ import_react24.default.createElement("div", {
1208
+ role: "none",
1209
+ className: "flex-1 min-is-0 space-b-1"
1210
+ }, /* @__PURE__ */ import_react24.default.createElement("p", {
1211
+ id: `${id}__label`
1212
+ }, t(action.label, {
1213
+ ns: "os"
1214
+ })), action.description && /* @__PURE__ */ import_react24.default.createElement("p", {
1215
+ id: `${id}__description`,
1216
+ className: import_react_ui_theme8.descriptionText
1217
+ }, t(action.description, {
1218
+ ns: "os"
1219
+ }))), /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.ItemIndicator, {
1220
+ asChild: true
1221
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react23.Check, {
1222
+ className: (0, import_react_ui_theme8.getSize)(4)
1223
+ })));
1224
+ })), /* @__PURE__ */ import_react24.default.createElement(import_react_ui14.DropdownMenu.Arrow, null)))), members[Presence.ONLINE].length + members[Presence.OFFLINE].length < 1 ? /* @__PURE__ */ import_react24.default.createElement("p", {
1225
+ className: (0, import_react_ui_theme8.mx)(import_react_ui_theme8.descriptionText, "text-center is-full mlb-2")
1226
+ }, t("empty space members message", {
1227
+ ns: "os"
1228
+ })) : /* @__PURE__ */ import_react24.default.createElement(import_react24.default.Fragment, null, /* @__PURE__ */ import_react24.default.createElement("h3", {
1229
+ className: "col-start-2 col-end-5 text-sm italic fg-description"
1230
+ }, t("active space members heading", {
1231
+ count: members[Presence.ONLINE].length
1232
+ })), /* @__PURE__ */ import_react24.default.createElement(SpaceMemberList, {
1233
+ members: members[Presence.ONLINE]
1234
+ }), /* @__PURE__ */ import_react24.default.createElement("h3", {
1235
+ className: "col-start-2 col-end-5 text-sm italic fg-description"
1236
+ }, t("inactive space members heading", {
1237
+ count: members[Presence.OFFLINE].length
1238
+ })), /* @__PURE__ */ import_react24.default.createElement(SpaceMemberList, {
1239
+ members: members[Presence.OFFLINE]
1240
+ })));
1241
+ };
1242
+ var KeyShortcuts = () => {
1243
+ const { t } = (0, import_react_ui13.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1244
+ return /* @__PURE__ */ import_react21.default.createElement("section", {
1245
+ className: "mbe-4 col-span-4 md:col-start-5 md:col-end-7 grid grid-cols-subgrid gap-y-2 auto-rows-min"
1246
+ }, /* @__PURE__ */ import_react21.default.createElement("h2", {
1247
+ className: "contents"
1248
+ }, /* @__PURE__ */ import_react21.default.createElement(import_react20.Command, {
1249
+ weight: "duotone",
1250
+ className: (0, import_react_ui_theme7.mx)((0, import_react_ui_theme7.getSize)(5), "place-self-center")
1251
+ }), /* @__PURE__ */ import_react21.default.createElement("span", {
1252
+ className: "text-lg col-span-2 md:col-span-1"
1253
+ }, t("keyshortcuts label"))), /* @__PURE__ */ import_react21.default.createElement("div", {
1254
+ role: "none",
1255
+ className: "col-start-2 col-end-4 md:col-end-5 pie-2"
1256
+ }, /* @__PURE__ */ import_react21.default.createElement(import_app_framework6.Surface, {
1257
+ role: "keyshortcuts"
1258
+ })));
1259
+ };
1260
+ var spaceMainLayout = "grid gap-y-2 auto-rows-min before:bs-2 before:col-span-5 grid-cols-[var(--rail-size)_var(--rail-size)_1fr_var(--rail-size)] md:grid-cols-[var(--rail-size)_var(--rail-size)_minmax(max-content,1fr)_var(--rail-size)_var(--rail-size)_minmax(max-content,2fr)_var(--rail-size)]";
1261
+ var SpaceMain = ({ space, role }) => {
1262
+ const state = space.state.get();
1263
+ const ready = state === import_echo5.SpaceState.SPACE_READY;
1264
+ const Root = role === "main" ? import_react_ui13.Main.Content : "div";
1265
+ return /* @__PURE__ */ import_react21.default.createElement(import_react22.ClipboardProvider, null, /* @__PURE__ */ import_react21.default.createElement(Root, {
1266
+ ...role === "main" ? {
1267
+ classNames: [
1268
+ import_react_ui_theme7.topbarBlockPaddingStart,
1269
+ "min-bs-dvh",
1270
+ spaceMainLayout
1271
+ ]
1272
+ } : {
1273
+ role: "none",
1274
+ className: (0, import_react_ui_theme7.mx)(import_react_ui_theme7.topbarBlockPaddingStart, "row-span-2", spaceMainLayout)
1275
+ },
1276
+ "data-testid": `spacePlugin.${role}`,
1277
+ "data-isready": ready ? "true" : "false"
1278
+ }, ready && /* @__PURE__ */ import_react21.default.createElement(SpaceMembersSection, {
1279
+ space
1280
+ }), /* @__PURE__ */ import_react21.default.createElement(KeyShortcuts, null)));
1281
+ };
1282
+ var REFRESH_INTERVAL = 5e3;
1283
+ var ACTIVITY_DURATION = 3e4;
1284
+ var noViewers = new import_util2.ComplexMap(import_react_client4.PublicKey.hash);
1285
+ var getName = (identity) => identity.profile?.displayName ?? (0, import_display_name.generateName)(identity.identityKey.toHex());
1286
+ var SpacePresence = ({ object, spaceKey }) => {
1287
+ const density = (0, import_react_ui15.useDensityContext)();
1288
+ const spacePlugin = (0, import_app_framework8.usePlugin)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1289
+ const client = (0, import_react_client4.useClient)();
1290
+ const identity = (0, import_halo.useIdentity)();
1291
+ const space = spaceKey ? client.spaces.get(spaceKey) : (0, import_echo7.getSpace)(object);
1292
+ const spaceMembers = (0, import_echo7.useMembers)(space?.key);
1293
+ const [_moment, setMoment] = (0, import_react26.useState)(Date.now());
1294
+ (0, import_react26.useEffect)(() => {
1295
+ const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
1296
+ return () => clearInterval(interval);
1297
+ }, []);
1298
+ const memberOnline = (0, import_react26.useCallback)((member) => member.presence === 1, []);
1299
+ const memberIsNotSelf = (0, import_react26.useCallback)((member) => !identity?.identityKey.equals(member.identity.identityKey), [
1300
+ identity?.identityKey
1301
+ ]);
1302
+ if (!identity || !spacePlugin || !space) {
1303
+ return null;
1304
+ }
1305
+ const spaceState = spacePlugin.provides.space;
1306
+ const currentObjectViewers = spaceState.viewersByObject[(0, import_echo7.fullyQualifiedId)(object)] ?? noViewers;
1307
+ const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
1308
+ const objectView = currentObjectViewers.get(member.identity.identityKey);
1309
+ const lastSeen = objectView?.lastSeen ?? -Infinity;
1310
+ const currentlyAttended = objectView?.currentlyAttended ?? false;
1311
+ return {
1312
+ ...member,
1313
+ currentlyAttended,
1314
+ lastSeen
1315
+ };
1316
+ }).toSorted((a, b) => a.lastSeen - b.lastSeen);
1317
+ return density === "fine" ? /* @__PURE__ */ import_react26.default.createElement(SmallPresence, {
1318
+ count: membersForObject.length
1319
+ }) : /* @__PURE__ */ import_react26.default.createElement(FullPresence, {
1320
+ members: membersForObject
1321
+ });
1322
+ };
1323
+ var FullPresence = (props) => {
1324
+ const { size = 9, onMemberClick } = props;
1325
+ const members = (0, import_react_ui15.useDefaultValue)(props.members, []);
1326
+ if (members.length === 0) {
1327
+ return null;
1328
+ }
1329
+ return /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.AvatarGroup.Root, {
1330
+ size,
1331
+ classNames: "mbs-2 mie-4",
1332
+ "data-testid": "spacePlugin.presence"
1333
+ }, members.slice(0, 3).map((member, i) => /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Root, {
1334
+ key: member.identity.identityKey.toHex()
1335
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Trigger, null, /* @__PURE__ */ import_react26.default.createElement(PrensenceAvatar, {
1336
+ identity: member.identity,
1337
+ group: true,
1338
+ match: member.currentlyAttended,
1339
+ index: members.length - i,
1340
+ onClick: () => onMemberClick?.(member)
1341
+ })), /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Portal, null, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Content, {
1342
+ side: "bottom"
1343
+ }, /* @__PURE__ */ import_react26.default.createElement("span", null, getName(member.identity)), /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Arrow, null))))), members.length > 3 && /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Root, null, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Trigger, null, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.AvatarGroupItem.Root, {
1344
+ status: "inactive"
1345
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Avatar.Frame, {
1346
+ style: {
1347
+ zIndex: members.length - 4
1348
+ }
1349
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Avatar.Fallback, {
1350
+ text: `+${members.length - 3}`
1351
+ })))), /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Portal, null, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Content, {
1352
+ side: "bottom"
1353
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Arrow, null), /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.List, {
1354
+ classNames: "max-h-56 overflow-y-auto"
1355
+ }, members.map((member) => /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.ListItem.Root, {
1356
+ key: member.identity.identityKey.toHex(),
1357
+ classNames: "flex gap-2 items-center cursor-pointer mbe-2",
1358
+ onClick: () => onMemberClick?.(member),
1359
+ "data-testid": "identity-list-item"
1360
+ }, /* @__PURE__ */ import_react26.default.createElement(PrensenceAvatar, {
1361
+ identity: member.identity,
1362
+ showName: true,
1363
+ match: member.currentlyAttended
1364
+ }))))))));
1365
+ };
1366
+ var PrensenceAvatar = ({ identity, showName, match, group, index, onClick }) => {
1367
+ const Root = group ? import_react_ui15.AvatarGroupItem.Root : import_react_ui15.Avatar.Root;
1368
+ const status = match ? "current" : "active";
1369
+ const fallbackValue = (0, import_util2.keyToFallback)(identity.identityKey);
1370
+ return /* @__PURE__ */ import_react26.default.createElement(Root, {
1371
+ status,
1372
+ hue: identity.profile?.data?.hue || fallbackValue.hue
1373
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Avatar.Frame, {
1374
+ "data-testid": "spacePlugin.presence.member",
1375
+ "data-status": status,
1376
+ ...index ? {
1377
+ style: {
1378
+ zIndex: index
1379
+ }
1380
+ } : {},
1381
+ onClick: () => onClick?.()
1382
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Avatar.Fallback, {
1383
+ text: identity.profile?.data?.emoji || fallbackValue.emoji
1384
+ })), showName && /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Avatar.Label, {
1385
+ classNames: "text-sm truncate pli-2"
1386
+ }, getName(identity)));
1387
+ };
1388
+ var SmallPresenceLive = ({ viewers, onCloseClick }) => {
1389
+ const [moment, setMoment] = (0, import_react26.useState)(Date.now());
1390
+ (0, import_react26.useEffect)(() => {
1391
+ const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
1392
+ return () => clearInterval(interval);
1393
+ }, []);
1394
+ const activeViewers = viewers ? Array.from(viewers.values()).filter(({ lastSeen }) => moment - lastSeen < ACTIVITY_DURATION) : [];
1395
+ return /* @__PURE__ */ import_react26.default.createElement(SmallPresence, {
1396
+ count: activeViewers.length,
1397
+ onCloseClick
1398
+ });
1399
+ };
1400
+ var SmallPresence = ({ count, onCloseClick }) => {
1401
+ const { t } = (0, import_react_ui15.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1402
+ return /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Root, null, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Trigger, {
1403
+ asChild: true
1404
+ }, /* @__PURE__ */ import_react26.default.createElement(import_react_ui_attention.AttentionGlyphCloseButton, {
1405
+ presence: count > 1 ? "many" : count === 1 ? "one" : "none",
1406
+ classNames: "self-center mie-1",
1407
+ onClick: onCloseClick
1408
+ })), /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Portal, null, /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Content, {
1409
+ side: "bottom",
1410
+ classNames: "z-[70]"
1411
+ }, /* @__PURE__ */ import_react26.default.createElement("span", null, t("presence label", {
1412
+ count
1413
+ })), /* @__PURE__ */ import_react26.default.createElement(import_react_ui15.Tooltip.Arrow, null))));
1414
+ };
1415
+ var SpaceSettings = ({ settings }) => {
1416
+ const { t } = (0, import_react_ui16.useTranslation)(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1417
+ const dispatch = (0, import_app_framework9.useIntentDispatcher)();
1418
+ return /* @__PURE__ */ import_react27.default.createElement(import_react27.default.Fragment, null, /* @__PURE__ */ import_react27.default.createElement(import_plugin_settings.SettingsValue, {
1419
+ label: t("show hidden spaces label")
1420
+ }, /* @__PURE__ */ import_react27.default.createElement(import_react_ui16.Input.Switch, {
1421
+ checked: settings.showHidden,
1422
+ onCheckedChange: (checked) => dispatch({
1423
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
1424
+ action: import_chunk_6CNYF6YU.SpaceAction.TOGGLE_HIDDEN,
1425
+ data: {
1426
+ state: !!checked
1427
+ }
1428
+ })
1429
+ })));
1430
+ };
1431
+ var translations_default = [
1432
+ {
1433
+ "en-US": {
1434
+ [import_chunk_6CNYF6YU.SPACE_PLUGIN]: {
1435
+ "plugin name": "Spaces",
1436
+ "first run message": "Nothing selected.",
1437
+ "create space label": "Create a new space",
1438
+ "join space label": "Join a space",
1439
+ "empty space message": "No documents",
1440
+ "empty tree message": "No spaces",
1441
+ "unnamed space label": "New space",
1442
+ "closed space label": "Closed",
1443
+ "loading space label": "Loading space\u2026",
1444
+ "lock space label": "Lock space",
1445
+ "unlock space label": "Unlock space",
1446
+ "rename space label": "Rename space",
1447
+ "active space label": "Active space:",
1448
+ "space name label": "Space name",
1449
+ "object name label": "Object name",
1450
+ "close space label": "Close space",
1451
+ "open space label": "Open space",
1452
+ "export data label": "Export data",
1453
+ "import data label": "Import data",
1454
+ "migrate space label": "Migrate space",
1455
+ "share space": "Share space",
1456
+ "save space to disk label": "Save to disk",
1457
+ "load space from disk label": "Load from disk",
1458
+ "confirm restore title": "Overwrite files in this space?",
1459
+ "confirm restore body": "Restoring from a backup will overwrite the contents of any documents that match.",
1460
+ "upload file message": "Drag file here or click to browse",
1461
+ "object title placeholder": "Type a title here\u2026",
1462
+ "personal space label": "Personal Space",
1463
+ "spaces label": "Spaces",
1464
+ "show hidden spaces label": "Show closed spaces",
1465
+ "save files to directory label": "Save files to disk",
1466
+ "select path label": "Select path",
1467
+ "rename collection label": "Rename collection",
1468
+ "rename object label": "Rename item",
1469
+ "duplicate object label": "Duplicate item",
1470
+ "delete collection label": "Delete collection",
1471
+ "delete object label": "Delete item",
1472
+ "collection deleted label": "Collection deleted",
1473
+ "object deleted label": "Item deleted",
1474
+ "go to object label": "Open item",
1475
+ "found object label": "Ready.",
1476
+ "found object description": "The requested object is now available.",
1477
+ "waiting for object label": "Loading\u2026",
1478
+ "waiting for object description": "The requested object is still being synchronized.",
1479
+ "object not found label": "Nothing found.",
1480
+ "object not found description": "The requested object has not been found yet. Ensure there are enough peers online in the space with an updated copy.",
1481
+ "missing object message": "Object not available.",
1482
+ "missing object description": "The requested object has not been found yet. Ensure there are enough peers online in the space with an updated copy.",
1483
+ "create collection label": "Create collection",
1484
+ "unnamed object label": "New object",
1485
+ "unnamed collection label": "New collection",
1486
+ "create object in space label": "Add to space",
1487
+ "create object in collection label": "Add to collection",
1488
+ "share space label": "Share",
1489
+ "space members label": "Space members",
1490
+ "active space members heading": "Online ({{count}})",
1491
+ "inactive space members heading": "Offline ({{count}})",
1492
+ "presence label_zero": "No other viewers",
1493
+ "presence label_one": "1 other viewer",
1494
+ "presence label_other": "{{count}} other viewers",
1495
+ "persisted locally label": "Changes saved locally.",
1496
+ "persisted locally message": "All changes have been saved to disk on this device.",
1497
+ "persistence pending label": "Saving\u2026",
1498
+ "persistence error label": "Error saving changes.",
1499
+ "more actions label": "More actions",
1500
+ "invitations heading": "Invitations",
1501
+ "keyshortcuts label": "Keyboard shortcuts",
1502
+ "menu footer label": "Details",
1503
+ "location label": "Located in",
1504
+ "space limit label": "Space Limit Reached",
1505
+ "space limit description": "This space has reached the maximum number of objects for the beta. This limit includes deleted objects currently, but those can be permanently removed with the cleanup action.",
1506
+ "space limit close label": "Close",
1507
+ "remove deleted objects label": "Cleanup",
1508
+ "remove deleted objects alt": "Permanently remove deleted objects to free up space.",
1509
+ "copy link label": "Copy link"
1510
+ }
1511
+ }
1512
+ }
1513
+ ];
1514
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/SpacePlugin.tsx";
1515
+ var ACTIVE_NODE_BROADCAST_INTERVAL = 3e4;
1516
+ var OBJECT_ID_LENGTH = 60;
1517
+ var SPACE_MAX_OBJECTS = 500;
1518
+ var DIRECTORY_TYPE = "text/directory";
1519
+ var parseSpacePlugin = (plugin) => Array.isArray(plugin?.provides.space?.enabled) ? plugin : void 0;
1520
+ var SpacePlugin = ({ firstRun, onFirstRun } = {}) => {
1521
+ const settings = new import_local_storage.LocalStorageStore(import_chunk_6CNYF6YU.SPACE_PLUGIN);
1522
+ const state = new import_local_storage.LocalStorageStore(import_chunk_6CNYF6YU.SPACE_PLUGIN, {
1523
+ awaiting: void 0,
1524
+ spaceNames: {},
1525
+ viewersByObject: {},
1526
+ viewersByIdentity: new import_util.ComplexMap(import_react_client.PublicKey.hash),
1527
+ sdkMigrationRunning: {}
1528
+ });
1529
+ const subscriptions = new import_async.EventSubscriptions();
1530
+ const spaceSubscriptions = new import_async.EventSubscriptions();
1531
+ const graphSubscriptions = /* @__PURE__ */ new Map();
1532
+ let clientPlugin;
1533
+ let intentPlugin;
1534
+ let navigationPlugin;
1535
+ let attentionPlugin;
1536
+ const onSpaceReady = async () => {
1537
+ if (!clientPlugin || !navigationPlugin || !attentionPlugin) {
1538
+ return;
1539
+ }
1540
+ const client = clientPlugin.provides.client;
1541
+ const location = navigationPlugin.provides.location;
1542
+ const attention = attentionPlugin.provides.attention;
1543
+ const defaultSpace = client.spaces.default;
1544
+ if (typeof defaultSpace.properties[COMPOSER_SPACE_LOCK] !== "boolean") {
1545
+ defaultSpace.properties[COMPOSER_SPACE_LOCK] = true;
1546
+ }
1547
+ const { objects: [spacesOrder] } = await defaultSpace.db.query(import_echo.Filter.schema(import_echo.Expando, {
1548
+ key: SHARED
1549
+ })).run();
1550
+ if (!spacesOrder) {
1551
+ defaultSpace.db.add((0, import_echo.create)({
1552
+ key: SHARED,
1553
+ order: []
1554
+ }));
1555
+ }
1556
+ subscriptions.add(client.spaces.subscribe(async (spaces) => {
1557
+ if (defaultSpace.state.get() === import_echo.SpaceState.SPACE_REQUIRES_MIGRATION) {
1558
+ await defaultSpace.internal.migrate();
1559
+ }
1560
+ spaces.filter((space) => space.state.get() === import_echo.SpaceState.SPACE_READY).forEach((space) => {
1561
+ subscriptions.add((0, import_signals_core.effect)(() => {
1562
+ state.values.spaceNames[space.id] = space.properties.name;
1563
+ }));
1564
+ });
1565
+ }).unsubscribe);
1566
+ subscriptions.add((0, import_signals_core.effect)(() => {
1567
+ const send = () => {
1568
+ const spaces = client.spaces.get();
1569
+ const identity = client.halo.identity.get();
1570
+ if (identity && location.active) {
1571
+ const ids = (0, import_app_framework.openIds)(location.active);
1572
+ const idsBySpace = (0, import_util.reduceGroupBy)(ids, (id) => {
1573
+ const [spaceId] = id.split(":");
1574
+ return spaceId;
1575
+ });
1576
+ for (const space of spaces) {
1577
+ if (!idsBySpace.has(space.id)) {
1578
+ idsBySpace.set(space.id, []);
1579
+ }
1580
+ }
1581
+ for (const [spaceId, ids2] of idsBySpace) {
1582
+ const space = spaces.find((space2) => space2.id === spaceId);
1583
+ if (!space) {
1584
+ continue;
1585
+ }
1586
+ const removed = location.closed ? [
1587
+ location.closed
1588
+ ].flat() : [];
1589
+ void space.postMessage("viewing", {
1590
+ identityKey: identity.identityKey.toHex(),
1591
+ attended: attention.attended ? [
1592
+ ...attention.attended
1593
+ ] : [],
1594
+ added: ids2,
1595
+ // TODO(Zan): When we re-open a part, we should remove it from the removed list in the navigation plugin.
1596
+ removed: removed.filter((id) => !ids2.includes(id))
1597
+ }).catch((err) => {
1598
+ import_log.log.warn("Failed to broadcast active node for presence.", {
1599
+ err: err.message
1600
+ }, {
1601
+ F: __dxlog_file3,
1602
+ L: 223,
1603
+ S: void 0,
1604
+ C: (f, a) => f(...a)
1605
+ });
1606
+ });
1607
+ }
1608
+ }
1609
+ };
1610
+ send();
1611
+ const interval = setInterval(() => send(), ACTIVE_NODE_BROADCAST_INTERVAL);
1612
+ return () => clearInterval(interval);
1613
+ }));
1614
+ subscriptions.add(client.spaces.subscribe((spaces) => {
1615
+ spaceSubscriptions.clear();
1616
+ spaces.forEach((space) => {
1617
+ spaceSubscriptions.add(space.listen("viewing", (message) => {
1618
+ const { added, removed, attended } = message.payload;
1619
+ const identityKey = import_react_client.PublicKey.safeFrom(message.payload.identityKey);
1620
+ if (identityKey && Array.isArray(added) && Array.isArray(removed)) {
1621
+ added.forEach((id) => {
1622
+ if (typeof id === "string") {
1623
+ if (!(id in state.values.viewersByObject)) {
1624
+ state.values.viewersByObject[id] = new import_util.ComplexMap(import_react_client.PublicKey.hash);
1625
+ }
1626
+ state.values.viewersByObject[id].set(identityKey, {
1627
+ lastSeen: Date.now(),
1628
+ currentlyAttended: new Set(attended).has(id)
1629
+ });
1630
+ if (!state.values.viewersByIdentity.has(identityKey)) {
1631
+ state.values.viewersByIdentity.set(identityKey, /* @__PURE__ */ new Set());
1632
+ }
1633
+ state.values.viewersByIdentity.get(identityKey).add(id);
1634
+ }
1635
+ });
1636
+ removed.forEach((id) => {
1637
+ if (typeof id === "string") {
1638
+ state.values.viewersByObject[id]?.delete(identityKey);
1639
+ state.values.viewersByIdentity.get(identityKey)?.delete(id);
1640
+ }
1641
+ });
1642
+ }
1643
+ }));
1644
+ });
1645
+ }).unsubscribe);
1646
+ };
1647
+ return {
1648
+ meta: import_chunk_6CNYF6YU.meta_default,
1649
+ ready: async (plugins) => {
1650
+ settings.prop({
1651
+ key: "showHidden",
1652
+ storageKey: "show-hidden",
1653
+ type: import_local_storage.LocalStorageStore.bool({
1654
+ allowUndefined: true
1655
+ })
1656
+ });
1657
+ state.prop({
1658
+ key: "spaceNames",
1659
+ storageKey: "space-names",
1660
+ type: import_local_storage.LocalStorageStore.json()
1661
+ });
1662
+ navigationPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseNavigationPlugin);
1663
+ attentionPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_attention.parseAttentionPlugin);
1664
+ clientPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin);
1665
+ intentPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin);
1666
+ if (!clientPlugin || !intentPlugin) {
1667
+ return;
1668
+ }
1669
+ const client = clientPlugin.provides.client;
1670
+ const dispatch = intentPlugin.provides.intent.dispatch;
1671
+ const handleFirstRun = async () => {
1672
+ const defaultSpace = client.spaces.default;
1673
+ const personalSpaceCollection = (0, import_echo.create)(import_chunk_CVZPI2P3.CollectionType, {
1674
+ objects: [],
1675
+ views: {}
1676
+ });
1677
+ defaultSpace.properties[import_chunk_CVZPI2P3.CollectionType.typename] = personalSpaceCollection;
1678
+ if (import_migrations.Migrations.versionProperty) {
1679
+ defaultSpace.properties[import_migrations.Migrations.versionProperty] = import_migrations.Migrations.targetVersion;
1680
+ }
1681
+ await onFirstRun?.({
1682
+ client,
1683
+ dispatch
1684
+ });
1685
+ };
1686
+ client.spaces.isReady.subscribe(async (ready) => {
1687
+ if (ready) {
1688
+ await clientPlugin?.provides.client.spaces.default.waitUntilReady();
1689
+ if (firstRun) {
1690
+ void firstRun?.wait().then(handleFirstRun);
1691
+ } else {
1692
+ await handleFirstRun();
1693
+ }
1694
+ await onSpaceReady();
1695
+ }
1696
+ });
1697
+ },
1698
+ unload: async () => {
1699
+ settings.close();
1700
+ spaceSubscriptions.clear();
1701
+ subscriptions.clear();
1702
+ graphSubscriptions.forEach((cb) => cb());
1703
+ graphSubscriptions.clear();
1704
+ },
1705
+ provides: {
1706
+ space: state.values,
1707
+ settings: settings.values,
1708
+ translations: [
1709
+ ...translations_default,
1710
+ import_react3.osTranslations
1711
+ ],
1712
+ root: () => state.values.awaiting ? /* @__PURE__ */ import_react2.default.createElement(AwaitingObject, {
1713
+ id: state.values.awaiting
1714
+ }) : null,
1715
+ metadata: {
1716
+ records: {
1717
+ [import_chunk_CVZPI2P3.CollectionType.typename]: {
1718
+ placeholder: [
1719
+ "unnamed collection label",
1720
+ {
1721
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
1722
+ }
1723
+ ],
1724
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.CardsThree, props),
1725
+ iconSymbol: "ph--cards-three--regular",
1726
+ // TODO(wittjosiah): Move out of metadata.
1727
+ loadReferences: (collection) => (0, import_echo.loadObjectReferences)(collection, (collection2) => [
1728
+ ...collection2.objects,
1729
+ ...Object.values(collection2.views)
1730
+ ])
1731
+ }
1732
+ }
1733
+ },
1734
+ echo: {
1735
+ schema: [
1736
+ import_chunk_CVZPI2P3.CollectionType
1737
+ ]
1738
+ },
1739
+ surface: {
1740
+ component: ({ data, role, ...rest }) => {
1741
+ const primary = data.active ?? data.object;
1742
+ switch (role) {
1743
+ case "article":
1744
+ case "main":
1745
+ return (0, import_echo.isSpace)(primary) && primary.state.get() === import_echo.SpaceState.SPACE_READY ? /* @__PURE__ */ import_react2.default.createElement(import_app_framework.Surface, {
1746
+ data: {
1747
+ active: primary.properties[import_chunk_CVZPI2P3.CollectionType.typename]
1748
+ },
1749
+ role,
1750
+ ...rest
1751
+ }) : primary instanceof import_chunk_CVZPI2P3.CollectionType ? {
1752
+ node: /* @__PURE__ */ import_react2.default.createElement(CollectionMain, {
1753
+ collection: primary
1754
+ }),
1755
+ disposition: "fallback"
1756
+ } : typeof primary === "string" && primary.length === OBJECT_ID_LENGTH ? /* @__PURE__ */ import_react2.default.createElement(MissingObject, {
1757
+ id: primary
1758
+ }) : null;
1759
+ case "tree--empty":
1760
+ switch (true) {
1761
+ case data.plugin === import_chunk_6CNYF6YU.SPACE_PLUGIN:
1762
+ return /* @__PURE__ */ import_react2.default.createElement(EmptyTree, null);
1763
+ case ((0, import_plugin_graph.isGraphNode)(data.activeNode) && (0, import_echo.isSpace)(data.activeNode.data)):
1764
+ return /* @__PURE__ */ import_react2.default.createElement(EmptySpace, null);
1765
+ default:
1766
+ return null;
1767
+ }
1768
+ case "dialog":
1769
+ if (data.component === "dxos.org/plugin/space/InvitationManagerDialog") {
1770
+ return /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Dialog.Content, null, /* @__PURE__ */ import_react2.default.createElement(import_react3.ClipboardProvider, null, /* @__PURE__ */ import_react2.default.createElement(import_react3.InvitationManager, {
1771
+ active: true,
1772
+ ...data.subject
1773
+ })));
1774
+ } else {
1775
+ return null;
1776
+ }
1777
+ case "popover":
1778
+ if (data.component === "dxos.org/plugin/space/RenameSpacePopover" && (0, import_echo.isSpace)(data.subject)) {
1779
+ return /* @__PURE__ */ import_react2.default.createElement(PopoverRenameSpace, {
1780
+ space: data.subject
1781
+ });
1782
+ }
1783
+ if (data.component === "dxos.org/plugin/space/RenameObjectPopover" && (0, import_echo_schema.isReactiveObject)(data.subject)) {
1784
+ return /* @__PURE__ */ import_react2.default.createElement(PopoverRenameObject, {
1785
+ object: data.subject
1786
+ });
1787
+ }
1788
+ return null;
1789
+ case "presence--glyph": {
1790
+ return (0, import_echo_schema.isReactiveObject)(data.object) ? /* @__PURE__ */ import_react2.default.createElement(SmallPresenceLive, {
1791
+ viewers: state.values.viewersByObject[(0, import_echo.fullyQualifiedId)(data.object)],
1792
+ onCloseClick: () => {
1793
+ const objectId = (0, import_echo.fullyQualifiedId)(data.object);
1794
+ return intentPlugin?.provides.intent.dispatch({
1795
+ action: import_app_framework.NavigationAction.CLOSE,
1796
+ data: {
1797
+ activeParts: {
1798
+ main: [
1799
+ objectId
1800
+ ],
1801
+ sidebar: [
1802
+ objectId
1803
+ ],
1804
+ complementary: [
1805
+ objectId
1806
+ ]
1807
+ }
1808
+ }
1809
+ });
1810
+ }
1811
+ }) : /* @__PURE__ */ import_react2.default.createElement(SmallPresence, {
1812
+ count: 0
1813
+ });
1814
+ }
1815
+ case "navbar-start": {
1816
+ return null;
1817
+ }
1818
+ case "navbar-end": {
1819
+ if (!(0, import_echo.isEchoObject)(data.object) && !(0, import_echo.isSpace)(data.object)) {
1820
+ return null;
1821
+ }
1822
+ const space = (0, import_echo.isSpace)(data.object) ? data.object : (0, import_echo.getSpace)(data.object);
1823
+ const object = (0, import_echo.isSpace)(data.object) ? data.object.state.get() === import_echo.SpaceState.SPACE_READY ? space?.properties[import_chunk_CVZPI2P3.CollectionType.typename] : void 0 : data.object;
1824
+ return space && object ? {
1825
+ node: /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(SpacePresence, {
1826
+ object
1827
+ }), space.properties[COMPOSER_SPACE_LOCK] ? null : /* @__PURE__ */ import_react2.default.createElement(ShareSpaceButton, {
1828
+ spaceId: space.id
1829
+ })),
1830
+ disposition: "hoist"
1831
+ } : null;
1832
+ }
1833
+ case "section":
1834
+ return data.object instanceof import_chunk_CVZPI2P3.CollectionType ? /* @__PURE__ */ import_react2.default.createElement(CollectionSection, {
1835
+ collection: data.object
1836
+ }) : null;
1837
+ case "settings":
1838
+ return data.plugin === import_chunk_6CNYF6YU.meta_default.id ? /* @__PURE__ */ import_react2.default.createElement(SpaceSettings, {
1839
+ settings: settings.values
1840
+ }) : null;
1841
+ case "menu-footer":
1842
+ if (!(0, import_echo.isEchoObject)(data.object)) {
1843
+ return null;
1844
+ } else {
1845
+ return /* @__PURE__ */ import_react2.default.createElement(MenuFooter, {
1846
+ object: data.object
1847
+ });
1848
+ }
1849
+ default:
1850
+ return null;
1851
+ }
1852
+ }
1853
+ },
1854
+ graph: {
1855
+ builder: (plugins) => {
1856
+ const clientPlugin2 = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin);
1857
+ const metadataPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseMetadataResolverPlugin);
1858
+ const graphPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseGraphPlugin);
1859
+ const client = clientPlugin2?.provides.client;
1860
+ const dispatch = intentPlugin?.provides.intent.dispatch;
1861
+ const resolve = metadataPlugin?.provides.metadata.resolver;
1862
+ const graph = graphPlugin?.provides.graph;
1863
+ if (!graph || !dispatch || !resolve || !client) {
1864
+ return [];
1865
+ }
1866
+ return [
1867
+ // Create spaces group node.
1868
+ (0, import_plugin_graph.createExtension)({
1869
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/root`,
1870
+ filter: (node) => node.id === "root",
1871
+ connector: () => {
1872
+ const isReady = (0, import_plugin_graph.toSignal)((onChange) => {
1873
+ let defaultSpaceUnsubscribe;
1874
+ client.spaces.isReady.subscribe((ready) => {
1875
+ if (ready) {
1876
+ defaultSpaceUnsubscribe = client.spaces.default.state.subscribe(() => onChange()).unsubscribe;
1877
+ }
1878
+ });
1879
+ return () => defaultSpaceUnsubscribe?.();
1880
+ }, () => client.spaces.isReady.get() && client.spaces.default.state.get() === import_echo.SpaceState.SPACE_READY);
1881
+ if (!isReady) {
1882
+ return [];
1883
+ }
1884
+ return [
1885
+ {
1886
+ id: SPACES,
1887
+ type: SPACES,
1888
+ properties: {
1889
+ label: [
1890
+ "spaces label",
1891
+ {
1892
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
1893
+ }
1894
+ ],
1895
+ palette: "teal",
1896
+ testId: "spacePlugin.spaces",
1897
+ role: "branch",
1898
+ childrenPersistenceClass: "echo",
1899
+ onRearrangeChildren: async (nextOrder) => {
1900
+ graph._sortEdges(SPACES, "outbound", nextOrder.map(({ id }) => id));
1901
+ const { objects: [spacesOrder] } = await client.spaces.default.db.query(import_echo.Filter.schema(import_echo.Expando, {
1902
+ key: SHARED
1903
+ })).run();
1904
+ if (spacesOrder) {
1905
+ spacesOrder.order = nextOrder.map(({ id }) => id);
1906
+ } else {
1907
+ import_log.log.warn("spaces order object not found", void 0, {
1908
+ F: __dxlog_file3,
1909
+ L: 526,
1910
+ S: void 0,
1911
+ C: (f, a) => f(...a)
1912
+ });
1913
+ }
1914
+ }
1915
+ }
1916
+ }
1917
+ ];
1918
+ }
1919
+ }),
1920
+ // Create space nodes.
1921
+ (0, import_plugin_graph.createExtension)({
1922
+ id: SPACES,
1923
+ filter: (node) => node.id === SPACES,
1924
+ actions: () => [
1925
+ {
1926
+ id: import_chunk_6CNYF6YU.SpaceAction.CREATE,
1927
+ data: async () => {
1928
+ await dispatch([
1929
+ {
1930
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
1931
+ action: import_chunk_6CNYF6YU.SpaceAction.CREATE
1932
+ },
1933
+ {
1934
+ action: import_app_framework.NavigationAction.OPEN
1935
+ }
1936
+ ]);
1937
+ },
1938
+ properties: {
1939
+ label: [
1940
+ "create space label",
1941
+ {
1942
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
1943
+ }
1944
+ ],
1945
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.Plus, props),
1946
+ iconSymbol: "ph--plus--regular",
1947
+ disposition: "toolbar",
1948
+ testId: "spacePlugin.createSpace"
1949
+ }
1950
+ },
1951
+ {
1952
+ id: import_chunk_6CNYF6YU.SpaceAction.JOIN,
1953
+ data: async () => {
1954
+ await dispatch([
1955
+ {
1956
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
1957
+ action: import_chunk_6CNYF6YU.SpaceAction.JOIN
1958
+ },
1959
+ {
1960
+ action: import_app_framework.NavigationAction.OPEN
1961
+ }
1962
+ ]);
1963
+ },
1964
+ properties: {
1965
+ label: [
1966
+ "join space label",
1967
+ {
1968
+ ns: import_chunk_6CNYF6YU.SPACE_PLUGIN
1969
+ }
1970
+ ],
1971
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.SignIn, props),
1972
+ iconSymbol: "ph--sign-in--regular",
1973
+ testId: "spacePlugin.joinSpace"
1974
+ }
1975
+ }
1976
+ ],
1977
+ connector: () => {
1978
+ const spaces = (0, import_plugin_graph.toSignal)((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
1979
+ if (!spaces) {
1980
+ return;
1981
+ }
1982
+ const [spacesOrder] = memoizeQuery(client.spaces.default, import_echo.Filter.schema(import_echo.Expando, {
1983
+ key: SHARED
1984
+ }));
1985
+ const order = spacesOrder?.order ?? [];
1986
+ const orderMap = new Map(order.map((id, index) => [
1987
+ id,
1988
+ index
1989
+ ]));
1990
+ return [
1991
+ ...spaces.filter((space) => orderMap.has(space.id)).sort((a, b) => orderMap.get(a.id) - orderMap.get(b.id)),
1992
+ ...spaces.filter((space) => !orderMap.has(space.id))
1993
+ ].filter((space) => settings.values.showHidden ? true : space.state.get() !== import_echo.SpaceState.SPACE_INACTIVE).map((space) => constructSpaceNode({
1994
+ space,
1995
+ personal: space === client.spaces.default,
1996
+ namesCache: state.values.spaceNames,
1997
+ resolve
1998
+ }));
1999
+ }
2000
+ }),
2001
+ // Find an object by its fully qualified id.
2002
+ (0, import_plugin_graph.createExtension)({
2003
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/objects`,
2004
+ resolver: ({ id }) => {
2005
+ const [spaceId, objectId] = id.split(":");
2006
+ const space = client.spaces.get().find((space2) => space2.id === spaceId);
2007
+ if (!space) {
2008
+ return;
2009
+ }
2010
+ const state2 = (0, import_plugin_graph.toSignal)((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
2011
+ if (state2 !== import_echo.SpaceState.SPACE_READY) {
2012
+ return;
2013
+ }
2014
+ const store = (0, import_plugin_graph.memoize)(() => (0, import_signals_core.signal)(space.db.getObjectById(objectId)), id);
2015
+ (0, import_plugin_graph.memoize)(() => {
2016
+ if (!store.value) {
2017
+ void space.db.loadObjectById(objectId).then((o) => store.value = o);
2018
+ }
2019
+ }, id);
2020
+ const object = store.value;
2021
+ if (!object) {
2022
+ return;
2023
+ }
2024
+ return createObjectNode({
2025
+ object,
2026
+ space,
2027
+ resolve
2028
+ });
2029
+ }
2030
+ }),
2031
+ // Create space actions and action groups.
2032
+ (0, import_plugin_graph.createExtension)({
2033
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/actions`,
2034
+ filter: (node) => (0, import_echo.isSpace)(node.data),
2035
+ actionGroups: ({ node }) => constructSpaceActionGroups({
2036
+ space: node.data,
2037
+ dispatch
2038
+ }),
2039
+ actions: ({ node }) => {
2040
+ const space = node.data;
2041
+ return constructSpaceActions({
2042
+ space,
2043
+ dispatch,
2044
+ personal: space === client.spaces.default,
2045
+ migrating: state.values.sdkMigrationRunning[space.id]
2046
+ });
2047
+ }
2048
+ }),
2049
+ // Create nodes for objects in the root collection of a space.
2050
+ (0, import_plugin_graph.createExtension)({
2051
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/root-collection`,
2052
+ filter: (node) => (0, import_echo.isSpace)(node.data),
2053
+ connector: ({ node }) => {
2054
+ const space = node.data;
2055
+ const state2 = (0, import_plugin_graph.toSignal)((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
2056
+ if (state2 !== import_echo.SpaceState.SPACE_READY) {
2057
+ return;
2058
+ }
2059
+ const collection = space.properties[import_chunk_CVZPI2P3.CollectionType.typename];
2060
+ if (!collection) {
2061
+ return;
2062
+ }
2063
+ return collection.objects.filter(import_util.nonNullable).map((object) => createObjectNode({
2064
+ object,
2065
+ space,
2066
+ resolve
2067
+ })).filter(import_util.nonNullable);
2068
+ }
2069
+ }),
2070
+ // Create collection actions and action groups.
2071
+ (0, import_plugin_graph.createExtension)({
2072
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/object-actions`,
2073
+ filter: (node) => (0, import_echo.isEchoObject)(node.data),
2074
+ actionGroups: ({ node }) => constructObjectActionGroups({
2075
+ object: node.data,
2076
+ dispatch
2077
+ }),
2078
+ actions: ({ node }) => constructObjectActions({
2079
+ node,
2080
+ dispatch
2081
+ })
2082
+ }),
2083
+ // Create nodes for objects in collections.
2084
+ (0, import_plugin_graph.createExtension)({
2085
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/collection-objects`,
2086
+ filter: (node) => node.data instanceof import_chunk_CVZPI2P3.CollectionType,
2087
+ connector: ({ node }) => {
2088
+ const collection = node.data;
2089
+ const space = (0, import_echo.getSpace)(collection);
2090
+ if (!space) {
2091
+ return;
2092
+ }
2093
+ return collection.objects.filter(import_util.nonNullable).map((object) => createObjectNode({
2094
+ object,
2095
+ space,
2096
+ resolve
2097
+ })).filter(import_util.nonNullable);
2098
+ }
2099
+ })
2100
+ ];
2101
+ },
2102
+ serializer: (plugins) => {
2103
+ const dispatch = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin)?.provides.intent.dispatch;
2104
+ if (!dispatch) {
2105
+ return [];
2106
+ }
2107
+ return [
2108
+ {
2109
+ inputType: SPACES,
2110
+ outputType: DIRECTORY_TYPE,
2111
+ serialize: (node) => ({
2112
+ name: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["spaces label"],
2113
+ data: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["spaces label"],
2114
+ type: DIRECTORY_TYPE
2115
+ }),
2116
+ deserialize: () => {
2117
+ }
2118
+ },
2119
+ {
2120
+ inputType: SPACE_TYPE,
2121
+ outputType: DIRECTORY_TYPE,
2122
+ serialize: (node) => ({
2123
+ name: node.properties.name ?? translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["unnamed space label"],
2124
+ data: node.properties.name ?? translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["unnamed space label"],
2125
+ type: DIRECTORY_TYPE
2126
+ }),
2127
+ deserialize: async (data) => {
2128
+ const result = await dispatch({
2129
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
2130
+ action: import_chunk_6CNYF6YU.SpaceAction.CREATE,
2131
+ data: {
2132
+ name: data.name
2133
+ }
2134
+ });
2135
+ return result?.data.space;
2136
+ }
2137
+ },
2138
+ {
2139
+ inputType: import_chunk_CVZPI2P3.CollectionType.typename,
2140
+ outputType: DIRECTORY_TYPE,
2141
+ serialize: (node) => ({
2142
+ name: node.properties.name ?? translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["unnamed collection label"],
2143
+ data: node.properties.name ?? translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["unnamed collection label"],
2144
+ type: DIRECTORY_TYPE
2145
+ }),
2146
+ deserialize: async (data, ancestors) => {
2147
+ const space = ancestors.find(import_echo.isSpace);
2148
+ const collection = ancestors.findLast((ancestor) => ancestor instanceof import_chunk_CVZPI2P3.CollectionType) ?? space?.properties[import_chunk_CVZPI2P3.CollectionType.typename];
2149
+ if (!space || !collection) {
2150
+ return;
2151
+ }
2152
+ const result = await dispatch({
2153
+ plugin: import_chunk_6CNYF6YU.SPACE_PLUGIN,
2154
+ action: import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT,
2155
+ data: {
2156
+ target: collection,
2157
+ object: (0, import_echo.create)(import_chunk_CVZPI2P3.CollectionType, {
2158
+ name: data.name,
2159
+ objects: [],
2160
+ views: {}
2161
+ })
2162
+ }
2163
+ });
2164
+ return result?.data.object;
2165
+ }
2166
+ }
2167
+ ];
2168
+ }
2169
+ },
2170
+ intent: {
2171
+ resolver: async (intent, plugins) => {
2172
+ const clientPlugin2 = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin);
2173
+ const client = clientPlugin2?.provides.client;
2174
+ switch (intent.action) {
2175
+ case import_chunk_6CNYF6YU.SpaceAction.WAIT_FOR_OBJECT: {
2176
+ state.values.awaiting = intent.data?.id;
2177
+ return {
2178
+ data: true
2179
+ };
2180
+ }
2181
+ case import_chunk_6CNYF6YU.SpaceAction.CREATE: {
2182
+ if (!client) {
2183
+ return;
2184
+ }
2185
+ const space = await client.spaces.create(intent.data);
2186
+ await space.waitUntilReady();
2187
+ const collection = (0, import_echo.create)(import_chunk_CVZPI2P3.CollectionType, {
2188
+ objects: [],
2189
+ views: {}
2190
+ });
2191
+ space.properties[import_chunk_CVZPI2P3.CollectionType.typename] = collection;
2192
+ if (import_migrations.Migrations.versionProperty) {
2193
+ space.properties[import_migrations.Migrations.versionProperty] = import_migrations.Migrations.targetVersion;
2194
+ }
2195
+ return {
2196
+ data: {
2197
+ space,
2198
+ id: space.id,
2199
+ activeParts: {
2200
+ main: [
2201
+ space.id
2202
+ ]
2203
+ }
2204
+ },
2205
+ intents: [
2206
+ [
2207
+ {
2208
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2209
+ data: {
2210
+ name: "space.create",
2211
+ properties: {
2212
+ spaceId: space.id
2213
+ }
2214
+ }
2215
+ }
2216
+ ]
2217
+ ]
2218
+ };
2219
+ }
2220
+ case import_chunk_6CNYF6YU.SpaceAction.JOIN: {
2221
+ if (client) {
2222
+ const { space } = await client.shell.joinSpace({
2223
+ invitationCode: intent.data?.invitationCode
2224
+ });
2225
+ if (space) {
2226
+ return {
2227
+ data: {
2228
+ space,
2229
+ id: space.id,
2230
+ activeParts: {
2231
+ main: [
2232
+ space.id
2233
+ ]
2234
+ }
2235
+ },
2236
+ intents: [
2237
+ [
2238
+ {
2239
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2240
+ data: {
2241
+ name: "space.join",
2242
+ properties: {
2243
+ spaceId: space.id
2244
+ }
2245
+ }
2246
+ }
2247
+ ]
2248
+ ]
2249
+ };
2250
+ }
2251
+ }
2252
+ break;
2253
+ }
2254
+ case import_chunk_6CNYF6YU.SpaceAction.SHARE: {
2255
+ const spaceId = intent.data?.spaceId;
2256
+ if (clientPlugin2 && typeof spaceId === "string") {
2257
+ if (!navigationPlugin?.provides.location.active) {
2258
+ return;
2259
+ }
2260
+ const target = (0, import_app_framework.firstIdInPart)(navigationPlugin?.provides.location.active, "main");
2261
+ const result = await clientPlugin2.provides.client.shell.shareSpace({
2262
+ spaceId,
2263
+ target
2264
+ });
2265
+ return {
2266
+ data: result,
2267
+ intents: [
2268
+ [
2269
+ {
2270
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2271
+ data: {
2272
+ name: "space.share",
2273
+ properties: {
2274
+ spaceId,
2275
+ members: result.members?.length,
2276
+ error: result.error?.message,
2277
+ cancelled: result.cancelled
2278
+ }
2279
+ }
2280
+ }
2281
+ ]
2282
+ ]
2283
+ };
2284
+ }
2285
+ break;
2286
+ }
2287
+ case import_chunk_6CNYF6YU.SpaceAction.LOCK: {
2288
+ const space = intent.data?.space;
2289
+ if ((0, import_echo.isSpace)(space)) {
2290
+ space.properties[COMPOSER_SPACE_LOCK] = true;
2291
+ return {
2292
+ data: true,
2293
+ intents: [
2294
+ [
2295
+ {
2296
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2297
+ data: {
2298
+ name: "space.lock",
2299
+ properties: {
2300
+ spaceId: space.id
2301
+ }
2302
+ }
2303
+ }
2304
+ ]
2305
+ ]
2306
+ };
2307
+ }
2308
+ break;
2309
+ }
2310
+ case import_chunk_6CNYF6YU.SpaceAction.UNLOCK: {
2311
+ const space = intent.data?.space;
2312
+ if ((0, import_echo.isSpace)(space)) {
2313
+ space.properties[COMPOSER_SPACE_LOCK] = false;
2314
+ return {
2315
+ data: true,
2316
+ intents: [
2317
+ [
2318
+ {
2319
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2320
+ data: {
2321
+ name: "space.unlock",
2322
+ properties: {
2323
+ spaceId: space.id
2324
+ }
2325
+ }
2326
+ }
2327
+ ]
2328
+ ]
2329
+ };
2330
+ }
2331
+ break;
2332
+ }
2333
+ case import_chunk_6CNYF6YU.SpaceAction.RENAME: {
2334
+ const { caller, space } = intent.data ?? {};
2335
+ if (typeof caller === "string" && (0, import_echo.isSpace)(space)) {
2336
+ return {
2337
+ intents: [
2338
+ [
2339
+ {
2340
+ action: import_app_framework.LayoutAction.SET_LAYOUT,
2341
+ data: {
2342
+ element: "popover",
2343
+ anchorId: `dxos.org/ui/${caller}/${space.id}`,
2344
+ component: "dxos.org/plugin/space/RenameSpacePopover",
2345
+ subject: space
2346
+ }
2347
+ }
2348
+ ]
2349
+ ]
2350
+ };
2351
+ }
2352
+ break;
2353
+ }
2354
+ case import_chunk_6CNYF6YU.SpaceAction.OPEN: {
2355
+ const space = intent.data?.space;
2356
+ if ((0, import_echo.isSpace)(space)) {
2357
+ await space.open();
2358
+ return {
2359
+ data: true
2360
+ };
2361
+ }
2362
+ break;
2363
+ }
2364
+ case import_chunk_6CNYF6YU.SpaceAction.CLOSE: {
2365
+ const space = intent.data?.space;
2366
+ if ((0, import_echo.isSpace)(space)) {
2367
+ await space.close();
2368
+ return {
2369
+ data: true
2370
+ };
2371
+ }
2372
+ break;
2373
+ }
2374
+ case import_chunk_6CNYF6YU.SpaceAction.MIGRATE: {
2375
+ const space = intent.data?.space;
2376
+ if ((0, import_echo.isSpace)(space)) {
2377
+ if (space.state.get() === import_echo.SpaceState.SPACE_REQUIRES_MIGRATION) {
2378
+ state.values.sdkMigrationRunning[space.id] = true;
2379
+ await space.internal.migrate();
2380
+ state.values.sdkMigrationRunning[space.id] = false;
2381
+ }
2382
+ const result = await import_migrations.Migrations.migrate(space, intent.data?.version);
2383
+ return {
2384
+ data: result,
2385
+ intents: [
2386
+ [
2387
+ {
2388
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2389
+ data: {
2390
+ name: "space.migrate",
2391
+ properties: {
2392
+ spaceId: space.id,
2393
+ version: intent.data?.version
2394
+ }
2395
+ }
2396
+ }
2397
+ ]
2398
+ ]
2399
+ };
2400
+ }
2401
+ break;
2402
+ }
2403
+ case import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT: {
2404
+ const object = intent.data?.object ?? intent.data?.result;
2405
+ if (!(0, import_echo_schema.isReactiveObject)(object)) {
2406
+ return;
2407
+ }
2408
+ const space = (0, import_echo.isSpace)(intent.data?.target) ? intent.data?.target : (0, import_echo.getSpace)(intent.data?.target);
2409
+ if (!space) {
2410
+ return;
2411
+ }
2412
+ if (space.db.coreDatabase.getAllObjectIds().length >= SPACE_MAX_OBJECTS) {
2413
+ return {
2414
+ data: false,
2415
+ intents: [
2416
+ [
2417
+ {
2418
+ action: import_app_framework.LayoutAction.SET_LAYOUT,
2419
+ data: {
2420
+ element: "toast",
2421
+ subject: {
2422
+ id: `${import_chunk_6CNYF6YU.SPACE_PLUGIN}/space-limit`,
2423
+ title: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["space limit label"],
2424
+ description: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["space limit description"],
2425
+ duration: 5e3,
2426
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.Warning, props),
2427
+ iconSymbol: "ph--warning--regular",
2428
+ actionLabel: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["remove deleted objects label"],
2429
+ actionAlt: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["remove deleted objects alt"],
2430
+ // TODO(wittjosiah): Use OS namespace.
2431
+ closeLabel: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN]["space limit close label"],
2432
+ onAction: () => space.db.coreDatabase.unlinkDeletedObjects()
2433
+ }
2434
+ }
2435
+ }
2436
+ ],
2437
+ [
2438
+ {
2439
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2440
+ data: {
2441
+ name: "space.limit",
2442
+ properties: {
2443
+ spaceId: space.id
2444
+ }
2445
+ }
2446
+ }
2447
+ ]
2448
+ ]
2449
+ };
2450
+ }
2451
+ if (intent.data?.target instanceof import_chunk_CVZPI2P3.CollectionType) {
2452
+ intent.data?.target.objects.push(object);
2453
+ } else if ((0, import_echo.isSpace)(intent.data?.target)) {
2454
+ const collection = space.properties[import_chunk_CVZPI2P3.CollectionType.typename];
2455
+ if (collection instanceof import_chunk_CVZPI2P3.CollectionType) {
2456
+ collection.objects.push(object);
2457
+ } else {
2458
+ const collection2 = (0, import_echo.create)(import_chunk_CVZPI2P3.CollectionType, {
2459
+ objects: [
2460
+ object
2461
+ ],
2462
+ views: {}
2463
+ });
2464
+ space.properties[import_chunk_CVZPI2P3.CollectionType.typename] = collection2;
2465
+ }
2466
+ }
2467
+ return {
2468
+ data: {
2469
+ id: object.id,
2470
+ object,
2471
+ activeParts: {
2472
+ main: [
2473
+ (0, import_echo.fullyQualifiedId)(object)
2474
+ ]
2475
+ }
2476
+ },
2477
+ intents: [
2478
+ [
2479
+ {
2480
+ action: import_meta.ObservabilityAction.SEND_EVENT,
2481
+ data: {
2482
+ name: "space.object.add",
2483
+ properties: {
2484
+ spaceId: space.id,
2485
+ objectId: object.id,
2486
+ typename: (0, import_echo.getTypename)(object)
2487
+ }
2488
+ }
2489
+ }
2490
+ ]
2491
+ ]
2492
+ };
2493
+ }
2494
+ case import_chunk_6CNYF6YU.SpaceAction.REMOVE_OBJECT: {
2495
+ const object = intent.data?.object ?? intent.data?.result;
2496
+ const space = (0, import_echo.getSpace)(object);
2497
+ if (!((0, import_echo.isEchoObject)(object) && space)) {
2498
+ return;
2499
+ }
2500
+ const resolve = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseMetadataResolverPlugin)?.provides.metadata.resolver;
2501
+ const activeParts = navigationPlugin?.provides.location.active;
2502
+ const openObjectIds = new Set((0, import_app_framework.openIds)(activeParts ?? {}));
2503
+ if (!intent.undo && resolve) {
2504
+ const parentCollection = intent.data?.collection ?? space.properties[import_chunk_CVZPI2P3.CollectionType.typename];
2505
+ const nestedObjects = await getNestedObjects(object, resolve);
2506
+ const deletionData = {
2507
+ object,
2508
+ parentCollection,
2509
+ index: parentCollection instanceof import_chunk_CVZPI2P3.CollectionType ? parentCollection.objects.indexOf(object) : -1,
2510
+ nestedObjects,
2511
+ wasActive: [
2512
+ object,
2513
+ ...nestedObjects
2514
+ ].map((obj) => (0, import_echo.fullyQualifiedId)(obj)).filter((id) => openObjectIds.has(id))
2515
+ };
2516
+ if (deletionData.wasActive.length > 0) {
2517
+ await intentPlugin?.provides.intent.dispatch({
2518
+ action: import_app_framework.NavigationAction.CLOSE,
2519
+ data: {
2520
+ activeParts: {
2521
+ main: deletionData.wasActive,
2522
+ sidebar: deletionData.wasActive,
2523
+ complementary: deletionData.wasActive
2524
+ }
2525
+ }
2526
+ });
2527
+ }
2528
+ if (parentCollection instanceof import_chunk_CVZPI2P3.CollectionType) {
2529
+ const index = parentCollection.objects.indexOf(object);
2530
+ if (index !== -1) {
2531
+ parentCollection.objects.splice(index, 1);
2532
+ }
2533
+ }
2534
+ deletionData.nestedObjects.forEach((obj) => {
2535
+ space.db.remove(obj);
2536
+ });
2537
+ space.db.remove(object);
2538
+ const undoMessageKey = object instanceof import_chunk_CVZPI2P3.CollectionType ? "collection deleted label" : "object deleted label";
2539
+ return {
2540
+ data: true,
2541
+ undoable: {
2542
+ // Consider using a translation key here.
2543
+ message: translations_default[0]["en-US"][import_chunk_6CNYF6YU.SPACE_PLUGIN][undoMessageKey],
2544
+ data: deletionData
2545
+ }
2546
+ };
2547
+ } else {
2548
+ const undoData = intent.data;
2549
+ if (undoData && (0, import_echo.isEchoObject)(undoData.object) && undoData.parentCollection instanceof import_chunk_CVZPI2P3.CollectionType) {
2550
+ const restoredObject = space.db.add(undoData.object);
2551
+ undoData.nestedObjects.forEach((obj) => {
2552
+ space.db.add(obj);
2553
+ });
2554
+ if (undoData.index !== -1) {
2555
+ undoData.parentCollection.objects.splice(undoData.index, 0, restoredObject);
2556
+ }
2557
+ if (undoData.wasActive.length > 0) {
2558
+ await intentPlugin?.provides.intent.dispatch({
2559
+ action: import_app_framework.NavigationAction.OPEN,
2560
+ data: {
2561
+ activeParts: {
2562
+ main: undoData.wasActive
2563
+ }
2564
+ }
2565
+ });
2566
+ }
2567
+ return {
2568
+ data: true
2569
+ };
2570
+ }
2571
+ return {
2572
+ data: false
2573
+ };
2574
+ }
2575
+ }
2576
+ case import_chunk_6CNYF6YU.SpaceAction.RENAME_OBJECT: {
2577
+ const object = intent.data?.object ?? intent.data?.result;
2578
+ const caller = intent.data?.caller;
2579
+ if ((0, import_echo_schema.isReactiveObject)(object) && caller) {
2580
+ return {
2581
+ intents: [
2582
+ [
2583
+ {
2584
+ action: import_app_framework.LayoutAction.SET_LAYOUT,
2585
+ data: {
2586
+ element: "popover",
2587
+ anchorId: `dxos.org/ui/${caller}/${(0, import_echo.fullyQualifiedId)(object)}`,
2588
+ component: "dxos.org/plugin/space/RenameObjectPopover",
2589
+ subject: object
2590
+ }
2591
+ }
2592
+ ]
2593
+ ]
2594
+ };
2595
+ }
2596
+ break;
2597
+ }
2598
+ case import_chunk_6CNYF6YU.SpaceAction.DUPLICATE_OBJECT: {
2599
+ const originalObject = intent.data?.object ?? intent.data?.result;
2600
+ const resolve = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseMetadataResolverPlugin)?.provides.metadata.resolver;
2601
+ if (!(0, import_echo.isEchoObject)(originalObject) || !resolve) {
2602
+ return;
2603
+ }
2604
+ const newObject = await cloneObject(originalObject, resolve);
2605
+ return {
2606
+ intents: [
2607
+ [
2608
+ {
2609
+ action: import_chunk_6CNYF6YU.SpaceAction.ADD_OBJECT,
2610
+ data: {
2611
+ object: newObject,
2612
+ target: intent.data?.target
2613
+ }
2614
+ }
2615
+ ]
2616
+ ]
2617
+ };
2618
+ }
2619
+ case import_chunk_6CNYF6YU.SpaceAction.TOGGLE_HIDDEN: {
2620
+ settings.values.showHidden = intent.data?.state ?? !settings.values.showHidden;
2621
+ return {
2622
+ data: true
2623
+ };
2624
+ }
2625
+ }
2626
+ }
2627
+ }
2628
+ }
2629
+ };
2630
+ };
2631
+ var src_default = SpacePlugin;
2632
+ // Annotate the CommonJS export names for ESM import in node:
2633
+ 0 && (module.exports = {
2634
+ ActorSchema,
2635
+ AwaitingObject,
2636
+ COMPOSER_SPACE_LOCK,
2637
+ ChannelType,
2638
+ CollectionMain,
2639
+ CollectionSection,
2640
+ CollectionType,
2641
+ ContactType,
2642
+ EmptySpace,
2643
+ EmptyTree,
2644
+ FullPresence,
2645
+ MenuFooter,
2646
+ MessageType,
2647
+ MissingObject,
2648
+ PersistenceStatus,
2649
+ PopoverRenameObject,
2650
+ PopoverRenameSpace,
2651
+ SHARED,
2652
+ SPACES,
2653
+ SPACE_DIRECTORY_HANDLE,
2654
+ SPACE_PLUGIN,
2655
+ SPACE_PLUGIN_SHORT_ID,
2656
+ SPACE_TYPE,
2657
+ ShareSpaceButton,
2658
+ ShareSpaceButtonImpl,
2659
+ SmallPresence,
2660
+ SmallPresenceLive,
2661
+ SpaceAction,
2662
+ SpaceMain,
2663
+ SpacePlugin,
2664
+ SpacePresence,
2665
+ SpaceSettings,
2666
+ ThreadStatus,
2667
+ ThreadType,
2668
+ cloneObject,
2669
+ constructObjectActionGroups,
2670
+ constructObjectActions,
2671
+ constructSpaceActionGroups,
2672
+ constructSpaceActions,
2673
+ constructSpaceNode,
2674
+ createObjectNode,
2675
+ getActiveSpace,
2676
+ getNestedObjects,
2677
+ getSpaceDisplayName,
2678
+ memoizeQuery,
2679
+ parseSpacePlugin,
2680
+ translations
2681
+ });
2682
+ //# sourceMappingURL=index.cjs.map