@dxos/shell 0.6.14-main.f49f251 → 0.6.14-staging.0f558a0

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 (90) hide show
  1. package/dist/bundle/shell.mjs +5152 -5049
  2. package/dist/bundle/shell.mjs.map +1 -1
  3. package/dist/bundle/shell.umd.js +57 -57
  4. package/dist/bundle/shell.umd.js.map +1 -1
  5. package/dist/bundle/style.css +1 -1
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/react.mjs +50 -53
  8. package/dist/lib/browser/react.mjs.map +3 -3
  9. package/dist/lib/browser/testing/index.mjs +3 -39
  10. package/dist/lib/browser/testing/index.mjs.map +4 -4
  11. package/dist/lib/node/chunk-Q7SFCCGT.cjs +33 -0
  12. package/dist/lib/node/chunk-Q7SFCCGT.cjs.map +7 -0
  13. package/dist/lib/node/meta.json +1 -0
  14. package/dist/lib/node/react.cjs +4760 -0
  15. package/dist/lib/node/react.cjs.map +7 -0
  16. package/dist/lib/node/react.css +7 -0
  17. package/dist/lib/node/react.css.map +7 -0
  18. package/dist/lib/node/testing/index.cjs +183 -0
  19. package/dist/lib/node/testing/index.cjs.map +7 -0
  20. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  21. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  22. package/dist/lib/node-esm/meta.json +1 -0
  23. package/dist/lib/node-esm/react.css +7 -0
  24. package/dist/lib/node-esm/react.css.map +7 -0
  25. package/dist/lib/node-esm/react.mjs +4806 -0
  26. package/dist/lib/node-esm/react.mjs.map +7 -0
  27. package/dist/lib/node-esm/testing/index.mjs +163 -0
  28. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  29. package/dist/types/src/components/DeviceList/DeviceListItem.d.ts.map +1 -1
  30. package/dist/types/src/components/DeviceList/DeviceListItem.js +4 -10
  31. package/dist/types/src/components/DeviceList/DeviceListItem.js.map +1 -1
  32. package/dist/types/src/components/IdentityList/SpaceMemberList.stories.js +2 -2
  33. package/dist/types/src/components/IdentityList/SpaceMemberList.stories.js.map +1 -1
  34. package/dist/types/src/components/InvitationList/InvitationList.stories.js +10 -10
  35. package/dist/types/src/components/InvitationList/InvitationList.stories.js.map +1 -1
  36. package/dist/types/src/components/Panel/Action.d.ts +2 -0
  37. package/dist/types/src/components/Panel/Action.d.ts.map +1 -1
  38. package/dist/types/src/components/Panel/Action.js +16 -14
  39. package/dist/types/src/components/Panel/Action.js.map +1 -1
  40. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  41. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +13 -6
  42. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  43. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +1 -0
  44. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  45. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
  46. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +3 -3
  47. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  48. package/dist/types/src/panels/IdentityPanel/useEdgeAgentsHandlers.d.ts.map +1 -1
  49. package/dist/types/src/panels/IdentityPanel/useEdgeAgentsHandlers.js +5 -0
  50. package/dist/types/src/panels/IdentityPanel/useEdgeAgentsHandlers.js.map +1 -1
  51. package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts.map +1 -1
  52. package/dist/types/src/panels/SpacePanel/SpacePanel.js +2 -2
  53. package/dist/types/src/panels/SpacePanel/SpacePanel.js.map +1 -1
  54. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js +15 -15
  55. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js.map +1 -1
  56. package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts +1 -0
  57. package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts.map +1 -1
  58. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -1
  59. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +5 -3
  60. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -1
  61. package/dist/types/src/playwright/invitations-manager.d.ts +1 -2
  62. package/dist/types/src/playwright/invitations-manager.d.ts.map +1 -1
  63. package/dist/types/src/playwright/invitations-manager.js +11 -4
  64. package/dist/types/src/playwright/invitations-manager.js.map +1 -1
  65. package/dist/types/src/playwright/invitations.spec.js +13 -9
  66. package/dist/types/src/playwright/invitations.spec.js.map +1 -1
  67. package/dist/types/src/testing/index.d.ts +0 -1
  68. package/dist/types/src/testing/index.d.ts.map +1 -1
  69. package/dist/types/src/testing/index.js +1 -1
  70. package/dist/types/src/testing/index.js.map +1 -1
  71. package/dist/types/src/testing/shell-manager.d.ts.map +1 -1
  72. package/dist/types/src/testing/shell-manager.js +2 -0
  73. package/dist/types/src/testing/shell-manager.js.map +1 -1
  74. package/package.json +38 -27
  75. package/src/components/DeviceList/DeviceListItem.tsx +38 -42
  76. package/src/components/IdentityList/SpaceMemberList.stories.tsx +1 -1
  77. package/src/components/InvitationList/InvitationList.stories.tsx +1 -1
  78. package/src/components/Panel/Action.tsx +40 -31
  79. package/src/panels/IdentityPanel/IdentityPanel.tsx +13 -3
  80. package/src/panels/IdentityPanel/IdentityPanelProps.ts +1 -0
  81. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +5 -3
  82. package/src/panels/IdentityPanel/useEdgeAgentsHandlers.ts +7 -0
  83. package/src/panels/SpacePanel/SpacePanel.stories.tsx +1 -1
  84. package/src/panels/SpacePanel/SpacePanel.tsx +2 -1
  85. package/src/panels/SpacePanel/SpacePanelProps.ts +1 -0
  86. package/src/panels/SpacePanel/steps/SpaceManager.tsx +5 -3
  87. package/src/playwright/invitations-manager.ts +10 -4
  88. package/src/playwright/invitations.spec.ts +14 -9
  89. package/src/testing/index.ts +2 -1
  90. package/src/testing/shell-manager.ts +2 -0
@@ -0,0 +1,4760 @@
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 react_exports = {};
30
+ __export(react_exports, {
31
+ Action: () => Action,
32
+ Actions: () => Actions,
33
+ AgentConfig: () => AgentConfig,
34
+ AuthCode: () => AuthCode,
35
+ BifurcatedAction: () => BifurcatedAction,
36
+ Centered: () => Centered,
37
+ ClipboardContext: () => ClipboardContext,
38
+ ClipboardProvider: () => ClipboardProvider,
39
+ CloseButton: () => CloseButton,
40
+ CompoundButton: () => CompoundButton,
41
+ ConfirmReset: () => ConfirmReset,
42
+ ConfirmResetImpl: () => ConfirmResetImpl,
43
+ CopyButton: () => CopyButton,
44
+ CopyButtonIconOnly: () => CopyButtonIconOnly,
45
+ DeviceList: () => DeviceList,
46
+ Emoji: () => Emoji,
47
+ EmojiPickerBlock: () => EmojiPickerBlock,
48
+ EmojiPickerToolbarButton: () => EmojiPickerToolbarButton,
49
+ Heading: () => Heading,
50
+ HuePickerBlock: () => HuePickerBlock,
51
+ HuePickerToolbarButton: () => HuePickerToolbarButton,
52
+ IdentityDialog: () => IdentityDialog,
53
+ IdentityListItem: () => IdentityListItem,
54
+ IdentityPanel: () => IdentityPanel,
55
+ IdentityPanelImpl: () => IdentityPanelImpl,
56
+ Input: () => Input,
57
+ InvitationList: () => InvitationList,
58
+ InvitationListContainer: () => InvitationListContainer,
59
+ InvitationListItem: () => InvitationListItem,
60
+ InvitationListItemImpl: () => InvitationListItemImpl,
61
+ InvitationManager: () => InvitationManager,
62
+ JoinDialog: () => JoinDialog,
63
+ JoinPanel: () => JoinPanel,
64
+ JoinPanelImpl: () => JoinPanelImpl,
65
+ Label: () => Label,
66
+ Shell: () => Shell,
67
+ ShellContext: () => ShellContext,
68
+ ShellProvider: () => ShellProvider,
69
+ SpaceDialog: () => SpaceDialog,
70
+ SpaceListItem: () => SpaceListItem,
71
+ SpaceMemberList: () => SpaceMemberList,
72
+ SpaceMemberListImpl: () => SpaceMemberListImpl,
73
+ SpacePanel: () => SpacePanel,
74
+ SpacePanelImpl: () => SpacePanelImpl,
75
+ StatusPanel: () => StatusPanel,
76
+ StepHeading: () => StepHeading,
77
+ Viewport: () => Viewport,
78
+ activeBgColor: () => activeBgColor,
79
+ activeStrokeColor: () => activeStrokeColor,
80
+ activeTextColor: () => activeTextColor,
81
+ cancelledBgColor: () => cancelledBgColor,
82
+ cancelledStrokeColor: () => cancelledStrokeColor,
83
+ cancelledTextColor: () => cancelledTextColor,
84
+ createViewportScope: () => createViewportScope,
85
+ errorBgColor: () => errorBgColor,
86
+ errorStrokeColor: () => errorStrokeColor,
87
+ errorTextColor: () => errorTextColor,
88
+ inactiveBgColor: () => inactiveBgColor,
89
+ inactiveStrokeColor: () => inactiveStrokeColor,
90
+ inactiveTextColor: () => inactiveTextColor,
91
+ osTranslations: () => osTranslations,
92
+ resolvedBgColor: () => resolvedBgColor,
93
+ resolvedStrokeColor: () => resolvedStrokeColor,
94
+ resolvedTextColor: () => resolvedTextColor,
95
+ runShell: () => runShell,
96
+ stepStyles: () => stepStyles,
97
+ successBgColor: () => successBgColor,
98
+ successStrokeColor: () => successStrokeColor,
99
+ successTextColor: () => successTextColor,
100
+ useClipboardContext: () => useClipboardContext,
101
+ useShell: () => useShell,
102
+ useViewportContext: () => useViewportContext
103
+ });
104
+ module.exports = __toCommonJS(react_exports);
105
+ var import_chunk_Q7SFCCGT = require("./chunk-Q7SFCCGT.cjs");
106
+ var import_react = require("@phosphor-icons/react");
107
+ var import_react2 = __toESM(require("react"));
108
+ var import_react_ui = require("@dxos/react-ui");
109
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
110
+ var import_react3 = require("@phosphor-icons/react");
111
+ var import_react4 = __toESM(require("react"));
112
+ var import_react_ui2 = require("@dxos/react-ui");
113
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
114
+ var import_react5 = __toESM(require("react"));
115
+ var import_react6 = __toESM(require("react"));
116
+ var import_react_ui3 = require("@dxos/react-ui");
117
+ var import_react_ui_theme3 = require("@dxos/react-ui-theme");
118
+ var import_data = __toESM(require("@emoji-mart/data"));
119
+ var import_react7 = __toESM(require("@emoji-mart/react"));
120
+ var import_react8 = require("@phosphor-icons/react");
121
+ var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
122
+ var import_react9 = __toESM(require("react"));
123
+ var import_react_ui4 = require("@dxos/react-ui");
124
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
125
+ var import_react10 = require("@phosphor-icons/react");
126
+ var import_react_use_controllable_state2 = require("@radix-ui/react-use-controllable-state");
127
+ var import_react11 = __toESM(require("react"));
128
+ var import_react_ui5 = require("@dxos/react-ui");
129
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
130
+ var import_react12 = __toESM(require("react"));
131
+ var import_display_name = require("@dxos/display-name");
132
+ var import_echo = require("@dxos/react-client/echo");
133
+ var import_react_ui6 = require("@dxos/react-ui");
134
+ var import_react_ui_theme6 = require("@dxos/react-ui-theme");
135
+ var import_util = require("@dxos/util");
136
+ var import_react13 = __toESM(require("react"));
137
+ var import_react_client = require("@dxos/react-client");
138
+ var import_echo2 = require("@dxos/react-client/echo");
139
+ var import_react_ui7 = require("@dxos/react-ui");
140
+ var import_react_ui_theme7 = require("@dxos/react-ui-theme");
141
+ var import_react14 = require("@phosphor-icons/react");
142
+ var import_react15 = __toESM(require("react"));
143
+ var import_react_ui8 = require("@dxos/react-ui");
144
+ var import_react_ui_theme8 = require("@dxos/react-ui-theme");
145
+ var import_react16 = require("@phosphor-icons/react");
146
+ var import_react17 = __toESM(require("react"));
147
+ var import_display_name2 = require("@dxos/display-name");
148
+ var import_halo = require("@dxos/react-client/halo");
149
+ var import_mesh = require("@dxos/react-client/mesh");
150
+ var import_react_ui9 = require("@dxos/react-ui");
151
+ var import_react_ui_theme9 = require("@dxos/react-ui-theme");
152
+ var import_util2 = require("@dxos/util");
153
+ var import_react18 = require("@phosphor-icons/react");
154
+ var import_date_fns = require("date-fns");
155
+ var import_react19 = __toESM(require("react"));
156
+ var import_invitations = require("@dxos/react-client/invitations");
157
+ var import_react_ui10 = require("@dxos/react-ui");
158
+ var import_react_ui_theme10 = require("@dxos/react-ui-theme");
159
+ var import_util3 = require("@dxos/util");
160
+ var import_react20 = __toESM(require("react"));
161
+ var import_react_ui_theme11 = require("@dxos/react-ui-theme");
162
+ var import_react21 = __toESM(require("react"));
163
+ var import_echo3 = require("@dxos/react-client/echo");
164
+ var import_react22 = __toESM(require("react"));
165
+ var import_react_ui11 = require("@dxos/react-ui");
166
+ var import_react_ui_theme12 = require("@dxos/react-ui-theme");
167
+ var import_react23 = require("@phosphor-icons/react");
168
+ var import_react_use_controllable_state3 = require("@radix-ui/react-use-controllable-state");
169
+ var import_react24 = __toESM(require("react"));
170
+ var import_react_ui12 = require("@dxos/react-ui");
171
+ var import_react_ui_theme13 = require("@dxos/react-ui-theme");
172
+ var import_react25 = __toESM(require("react"));
173
+ var import_react_ui_theme14 = require("@dxos/react-ui-theme");
174
+ var import_react26 = require("@phosphor-icons/react");
175
+ var import_react27 = __toESM(require("react"));
176
+ var import_react_ui13 = require("@dxos/react-ui");
177
+ var import_react_ui_theme15 = require("@dxos/react-ui-theme");
178
+ var import_react28 = __toESM(require("react"));
179
+ var import_react_ui_theme16 = require("@dxos/react-ui-theme");
180
+ var import_react29 = __toESM(require("react"));
181
+ var import_react_ui_theme17 = require("@dxos/react-ui-theme");
182
+ var import_react30 = __toESM(require("react"));
183
+ var import_react_ui_theme18 = require("@dxos/react-ui-theme");
184
+ var import_react31 = __toESM(require("react"));
185
+ var import_react_ui14 = require("@dxos/react-ui");
186
+ var import_react32 = __toESM(require("react"));
187
+ var import_react_ui_theme19 = require("@dxos/react-ui-theme");
188
+ var import_react_tabster = require("@fluentui/react-tabster");
189
+ var import_react_context = require("@radix-ui/react-context");
190
+ var import_react_use_controllable_state4 = require("@radix-ui/react-use-controllable-state");
191
+ var import_react33 = __toESM(require("react"));
192
+ var import_react_ui15 = require("@dxos/react-ui");
193
+ var import_react_ui_theme20 = require("@dxos/react-ui-theme");
194
+ var import_react34 = __toESM(require("react"));
195
+ var import_react_ui16 = require("@dxos/react-ui");
196
+ var import_react_ui_theme21 = require("@dxos/react-ui-theme");
197
+ var import_util4 = require("@dxos/util");
198
+ var import_react35 = __toESM(require("react"));
199
+ var import_react_ui17 = require("@dxos/react-ui");
200
+ var import_react36 = require("@phosphor-icons/react");
201
+ var import_react37 = __toESM(require("react"));
202
+ var import_display_name3 = require("@dxos/display-name");
203
+ var import_invariant = require("@dxos/invariant");
204
+ var import_log = require("@dxos/log");
205
+ var import_react_client2 = require("@dxos/react-client");
206
+ var import_halo2 = require("@dxos/react-client/halo");
207
+ var import_invitations2 = require("@dxos/react-client/invitations");
208
+ var import_mesh2 = require("@dxos/react-client/mesh");
209
+ var import_react_ui18 = require("@dxos/react-ui");
210
+ var import_react_ui_theme22 = require("@dxos/react-ui-theme");
211
+ var import_util5 = require("@dxos/util");
212
+ var import_react38 = require("@xstate/react");
213
+ var import_xstate = require("xstate");
214
+ var import_log2 = require("@dxos/log");
215
+ var import_react39 = __toESM(require("react"));
216
+ var import_log3 = require("@dxos/log");
217
+ var import_react_client3 = require("@dxos/react-client");
218
+ var import_halo3 = require("@dxos/react-client/halo");
219
+ var import_invitations3 = require("@dxos/react-client/invitations");
220
+ var import_react40 = __toESM(require("react"));
221
+ var import_log4 = require("@dxos/log");
222
+ var import_react_ui19 = require("@dxos/react-ui");
223
+ var import_util6 = require("@dxos/util");
224
+ var import_react_client4 = require("@dxos/react-client");
225
+ var import_react41 = require("react");
226
+ var import_invariant2 = require("@dxos/invariant");
227
+ var import_services = require("@dxos/protocols/proto/dxos/client/services");
228
+ var import_metadata = require("@dxos/protocols/proto/dxos/echo/metadata");
229
+ var import_react_client5 = require("@dxos/react-client");
230
+ var import_react42 = require("react");
231
+ var import_invariant3 = require("@dxos/invariant");
232
+ var import_log5 = require("@dxos/log");
233
+ var import_react_client6 = require("@dxos/react-client");
234
+ var import_invitations4 = require("@dxos/react-client/invitations");
235
+ var import_react43 = require("@phosphor-icons/react");
236
+ var import_react44 = __toESM(require("react"));
237
+ var import_react_qr_rounded = require("react-qr-rounded");
238
+ var import_react_ui20 = require("@dxos/react-ui");
239
+ var import_react_ui_theme23 = require("@dxos/react-ui-theme");
240
+ var import_util7 = require("@dxos/util");
241
+ var import_invitations5 = require("@dxos/react-client/invitations");
242
+ var import_react45 = require("@phosphor-icons/react");
243
+ var import_react46 = __toESM(require("react"));
244
+ var import_log6 = require("@dxos/log");
245
+ var import_react_ui21 = require("@dxos/react-ui");
246
+ var import_react_ui_theme24 = require("@dxos/react-ui-theme");
247
+ var import_react47 = __toESM(require("react"));
248
+ var import_log7 = require("@dxos/log");
249
+ var import_react_client7 = require("@dxos/react-client");
250
+ var import_halo4 = require("@dxos/react-client/halo");
251
+ var import_react_ui22 = require("@dxos/react-ui");
252
+ var import_react48 = require("@phosphor-icons/react");
253
+ var import_react49 = __toESM(require("react"));
254
+ var import_react_ui23 = require("@dxos/react-ui");
255
+ var import_react_ui_theme25 = require("@dxos/react-ui-theme");
256
+ var import_react50 = require("@xstate/react");
257
+ var import_react51 = require("react");
258
+ var import_xstate2 = require("xstate");
259
+ var import_log8 = require("@dxos/log");
260
+ var import_react_client8 = require("@dxos/react-client");
261
+ var import_invitations6 = require("@dxos/react-client/invitations");
262
+ var import_react52 = require("@phosphor-icons/react");
263
+ var import_react53 = __toESM(require("react"));
264
+ var import_react_ui24 = require("@dxos/react-ui");
265
+ var import_react_ui_theme26 = require("@dxos/react-ui-theme");
266
+ var import_react54 = __toESM(require("react"));
267
+ var import_display_name4 = require("@dxos/display-name");
268
+ var import_react_ui25 = require("@dxos/react-ui");
269
+ var import_react_ui_theme27 = require("@dxos/react-ui-theme");
270
+ var import_util8 = require("@dxos/util");
271
+ var import_react55 = __toESM(require("react"));
272
+ var import_log9 = require("@dxos/log");
273
+ var import_react_client9 = require("@dxos/react-client");
274
+ var import_react_ui26 = require("@dxos/react-ui");
275
+ var import_react56 = __toESM(require("react"));
276
+ var import_react_ui27 = require("@dxos/react-ui");
277
+ var import_react57 = __toESM(require("react"));
278
+ var import_log10 = require("@dxos/log");
279
+ var import_react_ui28 = require("@dxos/react-ui");
280
+ var import_react58 = __toESM(require("react"));
281
+ var import_react_ui29 = require("@dxos/react-ui");
282
+ var import_react_ui_theme28 = require("@dxos/react-ui-theme");
283
+ var import_react59 = __toESM(require("react"));
284
+ var import_invitations7 = require("@dxos/react-client/invitations");
285
+ var import_react_ui30 = require("@dxos/react-ui");
286
+ var import_react_ui_theme29 = require("@dxos/react-ui-theme");
287
+ var import_util9 = require("@dxos/util");
288
+ var import_invitations8 = require("@dxos/react-client/invitations");
289
+ var import_react60 = require("@phosphor-icons/react");
290
+ var import_react61 = __toESM(require("react"));
291
+ var import_log11 = require("@dxos/log");
292
+ var import_invitations9 = require("@dxos/react-client/invitations");
293
+ var import_react_ui31 = require("@dxos/react-ui");
294
+ var import_react62 = require("@xstate/react");
295
+ var import_xstate3 = require("xstate");
296
+ var import_log12 = require("@dxos/log");
297
+ var import_react63 = require("@phosphor-icons/react");
298
+ var import_react64 = __toESM(require("react"));
299
+ var import_log13 = require("@dxos/log");
300
+ var import_react_client10 = require("@dxos/react-client");
301
+ var import_echo4 = require("@dxos/react-client/echo");
302
+ var import_invitations10 = require("@dxos/react-client/invitations");
303
+ var import_react_ui32 = require("@dxos/react-ui");
304
+ var import_react_ui_theme30 = require("@dxos/react-ui-theme");
305
+ var import_react65 = __toESM(require("react"));
306
+ var import_react_ui33 = require("@dxos/react-ui");
307
+ var import_react66 = __toESM(require("react"));
308
+ var import_react_ui34 = require("@dxos/react-ui");
309
+ var import_react67 = __toESM(require("react"));
310
+ var import_client = require("react-dom/client");
311
+ var import_client_protocol = require("@dxos/client-protocol");
312
+ var import_react_client11 = require("@dxos/react-client");
313
+ var import_react_ui35 = require("@dxos/react-ui");
314
+ var import_react_ui_theme31 = require("@dxos/react-ui-theme");
315
+ var import_rpc_tunnel = require("@dxos/rpc-tunnel");
316
+ var import_react68 = __toESM(require("react"));
317
+ var import_log14 = require("@dxos/log");
318
+ var import_react_client12 = require("@dxos/react-client");
319
+ var import_react_client13 = require("@dxos/react-client");
320
+ var import_echo5 = require("@dxos/react-client/echo");
321
+ var import_react69 = __toESM(require("react"));
322
+ var import_react_ui36 = require("@dxos/react-ui");
323
+ var import_react70 = __toESM(require("react"));
324
+ var import_react_ui37 = require("@dxos/react-ui");
325
+ var import_async = require("@dxos/async");
326
+ var import_client_protocol2 = require("@dxos/client-protocol");
327
+ var import_invariant4 = require("@dxos/invariant");
328
+ var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
329
+ var import_rpc = require("@dxos/rpc");
330
+ var import_react71 = __toESM(require("react"));
331
+ var import_react_client14 = require("@dxos/react-client");
332
+ var import_halo5 = require("@dxos/react-client/halo");
333
+ var import_react_ui_theme32 = require("@dxos/react-ui-theme");
334
+ var import_async2 = require("@dxos/async");
335
+ var import_react_client15 = require("@dxos/react-client");
336
+ var AgentConfig = ({ agentStatus, validationMessage, onAgentDestroy, onAgentCreate, onAgentRefresh }) => {
337
+ const { t } = (0, import_react_ui.useTranslation)("os");
338
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
339
+ className: (0, import_react_ui_theme.mx)(import_react_ui_theme.descriptionText, "text-center mbs-4")
340
+ }, t("agent heading")), validationMessage && /* @__PURE__ */ import_react2.default.createElement("p", {
341
+ role: "alert",
342
+ className: (0, import_react_ui_theme.mx)((0, import_react_ui_theme.valenceColorText)("error"), "mlb-2")
343
+ }, validationMessage), agentStatus === "created" || agentStatus === "creating" || agentStatus === "getting" || agentStatus === "destroying" ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", {
344
+ role: "group",
345
+ className: "mlb-2 flex gap-2 items-center",
346
+ "aria-describedby": "devices-panel.create-agent.description"
347
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Avatar.Root, {
348
+ status: agentStatus === "created" ? "warning" : "inactive",
349
+ variant: "square"
350
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Avatar.Frame, {
351
+ classNames: "place-self-center"
352
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react.Database, {
353
+ weight: "duotone",
354
+ width: 24,
355
+ height: 24,
356
+ x: 8,
357
+ y: 8,
358
+ ...agentStatus !== "created" && {
359
+ className: "opacity-50"
360
+ }
361
+ })), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Avatar.Label, {
362
+ classNames: "flex-1 text-sm truncate"
363
+ }, t(agentStatus === "created" ? "agent requested label" : agentStatus === "creating" ? "creating agent label" : agentStatus === "destroying" ? "destroying agent label" : "getting agent label"))), agentStatus === "created" && /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Root, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Trigger, {
364
+ asChild: true
365
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Button, {
366
+ variant: "ghost",
367
+ classNames: "pli-0 is-[--rail-action] bs-[--rail-action]",
368
+ "data-testid": "agent.destroy",
369
+ onClick: onAgentDestroy
370
+ }, /* @__PURE__ */ import_react2.default.createElement("span", {
371
+ className: "sr-only"
372
+ }, t("destroy agent label")), /* @__PURE__ */ import_react2.default.createElement(import_react.Power, {
373
+ className: (0, import_react_ui_theme.getSize)(5)
374
+ }))), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Portal, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Content, {
375
+ side: "bottom",
376
+ classNames: "z-50"
377
+ }, t("destroy agent label"))))), agentStatus === "created" && /* @__PURE__ */ import_react2.default.createElement("p", {
378
+ id: "devices-panel.create-agent.description",
379
+ className: (0, import_react_ui_theme.mx)(import_react_ui_theme.descriptionText, "mlb-2")
380
+ }, t("agent requested description"))) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Button, {
381
+ variant: "ghost",
382
+ classNames: "mlb-2 is-full justify-start gap-2 !pis-0 !pie-3",
383
+ "data-testid": agentStatus === "creatable" ? "devices-panel.create-agent" : "devices-panel.agent-error",
384
+ onClick: agentStatus === "creatable" ? onAgentCreate : onAgentRefresh,
385
+ "aria-describedby": "devices-panel.create-agent.description"
386
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
387
+ role: "img",
388
+ className: (0, import_react_ui_theme.mx)((0, import_react_ui_theme.getSize)(8), "m-1 rounded-sm bg-input grid place-items-center")
389
+ }, agentStatus === "creatable" ? /* @__PURE__ */ import_react2.default.createElement(import_react.Plus, {
390
+ weight: "light",
391
+ className: (0, import_react_ui_theme.getSize)(6)
392
+ }) : /* @__PURE__ */ import_react2.default.createElement(import_react.ArrowsClockwise, {
393
+ weight: "light",
394
+ className: (0, import_react_ui_theme.getSize)(6)
395
+ })), /* @__PURE__ */ import_react2.default.createElement("span", {
396
+ className: "grow font-medium text-start"
397
+ }, t(agentStatus === "creatable" ? "create agent label" : ""))), agentStatus === "creatable" && /* @__PURE__ */ import_react2.default.createElement("div", {
398
+ role: "none",
399
+ className: "space-y-2",
400
+ id: "devices-panel.create-agent.description"
401
+ }, /* @__PURE__ */ import_react2.default.createElement("p", {
402
+ className: import_react_ui_theme.descriptionText
403
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Trans, {
404
+ t,
405
+ i18nKey: "create agent clickwrap",
406
+ components: {
407
+ tosLink: /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Link, {
408
+ target: "_blank",
409
+ rel: "noreferrer"
410
+ })
411
+ }
412
+ })), /* @__PURE__ */ import_react2.default.createElement("p", {
413
+ className: import_react_ui_theme.descriptionText
414
+ }, t("create agent description")))));
415
+ };
416
+ var ClipboardContext = /* @__PURE__ */ (0, import_react5.createContext)({
417
+ textValue: "",
418
+ setTextValue: async (_) => {
419
+ }
420
+ });
421
+ var useClipboardContext = () => (0, import_react5.useContext)(ClipboardContext);
422
+ var ClipboardProvider = ({ children }) => {
423
+ const [textValue, setInternalTextValue] = (0, import_react5.useState)("");
424
+ const setTextValue = (0, import_react5.useCallback)(async (nextValue) => {
425
+ await navigator.clipboard.writeText(nextValue);
426
+ return setInternalTextValue(nextValue);
427
+ }, []);
428
+ return /* @__PURE__ */ import_react5.default.createElement(ClipboardContext.Provider, {
429
+ value: {
430
+ textValue,
431
+ setTextValue
432
+ }
433
+ }, children);
434
+ };
435
+ var inactiveLabelStyles = "invisible bs-px -mbe-px overflow-hidden";
436
+ var CopyButton = ({ value, classNames, iconProps: iconProps2, ...props }) => {
437
+ const { t } = (0, import_react_ui2.useTranslation)("os");
438
+ const { textValue, setTextValue } = useClipboardContext();
439
+ const isCopied = textValue === value;
440
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Button, {
441
+ ...props,
442
+ classNames: [
443
+ "inline-flex flex-col justify-center",
444
+ classNames
445
+ ],
446
+ onClick: () => setTextValue(value),
447
+ "data-testid": "copy-invitation"
448
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
449
+ role: "none",
450
+ className: (0, import_react_ui_theme2.mx)("flex gap-1 items-center", isCopied && inactiveLabelStyles)
451
+ }, /* @__PURE__ */ import_react4.default.createElement("span", {
452
+ className: "pli-1"
453
+ }, t("copy invitation code label")), /* @__PURE__ */ import_react4.default.createElement(import_react3.Copy, {
454
+ className: (0, import_react_ui_theme2.getSize)(5),
455
+ ...iconProps2
456
+ })), /* @__PURE__ */ import_react4.default.createElement("div", {
457
+ role: "none",
458
+ className: (0, import_react_ui_theme2.mx)("flex gap-1 items-center", !isCopied && inactiveLabelStyles)
459
+ }, /* @__PURE__ */ import_react4.default.createElement("span", {
460
+ className: "pli-1"
461
+ }, t("copy success label")), /* @__PURE__ */ import_react4.default.createElement(import_react3.Check, {
462
+ className: (0, import_react_ui_theme2.getSize)(5),
463
+ ...iconProps2
464
+ })));
465
+ };
466
+ var CopyButtonIconOnly = ({ value, classNames, iconProps: iconProps2, variant, ...props }) => {
467
+ const { t } = (0, import_react_ui2.useTranslation)("os");
468
+ const { textValue, setTextValue } = useClipboardContext();
469
+ const isCopied = textValue === value;
470
+ const label = isCopied ? t("copy success label") : t("copy invitation code label");
471
+ const [open, setOpen] = (0, import_react4.useState)(false);
472
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Root, {
473
+ delayDuration: 1500,
474
+ open,
475
+ onOpenChange: setOpen
476
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Content, {
477
+ side: "bottom",
478
+ sideOffset: 12,
479
+ classNames: "z-30"
480
+ }, /* @__PURE__ */ import_react4.default.createElement("span", null, label), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Arrow, null))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Trigger, {
481
+ "aria-label": label,
482
+ ...props,
483
+ onClick: () => setTextValue(value).then(() => setOpen(true)),
484
+ "data-testid": "copy-invitation",
485
+ asChild: true
486
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Button, {
487
+ variant,
488
+ classNames: [
489
+ "inline-flex flex-col justify-center",
490
+ classNames
491
+ ]
492
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react3.Copy, {
493
+ className: (0, import_react_ui_theme2.getSize)(5),
494
+ ...iconProps2
495
+ }))));
496
+ };
497
+ var CompoundButton = ({ children, description, before, after, variant = "default", elevation: propsElevation, slots = {}, ...buttonProps }) => {
498
+ const labelId = (0, import_react_ui3.useId)("compoundButton-label");
499
+ const descriptionId = (0, import_react_ui3.useId)("compoundButton-description");
500
+ const { tx } = (0, import_react_ui3.useThemeContext)();
501
+ const elevation = (0, import_react_ui3.useElevationContext)(propsElevation);
502
+ const styleProps = {
503
+ ...buttonProps,
504
+ variant,
505
+ elevation,
506
+ textWrap: true
507
+ };
508
+ const buttonClassName = tx("button.root", "button button--compound", styleProps, "flex items-center gap-4 plb-2.5", slots.root?.className);
509
+ return /* @__PURE__ */ import_react6.default.createElement("button", {
510
+ ...buttonProps,
511
+ ...slots.root,
512
+ className: buttonClassName,
513
+ "aria-labelledby": labelId,
514
+ ...description && {
515
+ "aria-describedby": descriptionId
516
+ }
517
+ }, before && /* @__PURE__ */ import_react6.default.createElement("div", {
518
+ role: "none",
519
+ className: "grow-0"
520
+ }, before), /* @__PURE__ */ import_react6.default.createElement("div", {
521
+ role: "none",
522
+ ...slots.middle,
523
+ className: (0, import_react_ui_theme3.mx)("grow whitespace-normal flex flex-col gap-1 text-left", slots.middle?.className)
524
+ }, /* @__PURE__ */ import_react6.default.createElement("p", {
525
+ ...slots.label,
526
+ id: labelId,
527
+ className: (0, import_react_ui_theme3.mx)(slots.label?.className)
528
+ }, children), description && /* @__PURE__ */ import_react6.default.createElement("p", {
529
+ id: descriptionId,
530
+ ...slots.description,
531
+ className: (0, import_react_ui_theme3.mx)("text-xs mbe-1 font-normal", variant === "primary" ? import_react_ui_theme3.descriptionTextPrimary : import_react_ui_theme3.descriptionText, slots.description?.className)
532
+ }, description)), after && /* @__PURE__ */ import_react6.default.createElement("div", {
533
+ role: "none",
534
+ className: "grow-0"
535
+ }, after));
536
+ };
537
+ var EmojiPickerToolbarButton = ({ disabled, defaultEmoji, emoji, onChangeEmoji, classNames }) => {
538
+ const { t } = (0, import_react_ui4.useTranslation)("os");
539
+ const { themeMode } = (0, import_react_ui4.useThemeContext)();
540
+ const [_emojiValue, setEmojiValue] = (0, import_react_use_controllable_state.useControllableState)({
541
+ prop: emoji,
542
+ onChange: onChangeEmoji,
543
+ defaultProp: defaultEmoji
544
+ });
545
+ const [emojiPickerOpen, setEmojiPickerOpen] = (0, import_react9.useState)(false);
546
+ const suppressNextTooltip = (0, import_react9.useRef)(false);
547
+ const [triggerTooltipOpen, setTriggerTooltipOpen] = (0, import_react9.useState)(false);
548
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Root, {
549
+ open: triggerTooltipOpen,
550
+ onOpenChange: (nextOpen) => {
551
+ if (suppressNextTooltip.current) {
552
+ setTriggerTooltipOpen(false);
553
+ suppressNextTooltip.current = false;
554
+ } else {
555
+ setTriggerTooltipOpen(nextOpen);
556
+ }
557
+ }
558
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Root, {
559
+ open: emojiPickerOpen,
560
+ onOpenChange: (nextOpen) => {
561
+ setEmojiPickerOpen(nextOpen);
562
+ suppressNextTooltip.current = true;
563
+ }
564
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Trigger, {
565
+ asChild: true
566
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Trigger, {
567
+ asChild: true
568
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Toolbar.Button, {
569
+ classNames: [
570
+ "gap-2 text-2xl plb-1",
571
+ classNames
572
+ ],
573
+ disabled
574
+ }, /* @__PURE__ */ import_react9.default.createElement("span", {
575
+ className: "sr-only"
576
+ }, t("select emoji label")), /* @__PURE__ */ import_react9.default.createElement(import_react8.UserCircle, {
577
+ className: (0, import_react_ui_theme4.getSize)(5)
578
+ })))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Content, {
579
+ side: "bottom",
580
+ classNames: "z-50"
581
+ }, t("select emoji label"), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Arrow, null))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Content, {
582
+ side: "bottom",
583
+ onKeyDownCapture: (event) => {
584
+ if (event.key === "Escape") {
585
+ event.stopPropagation();
586
+ setEmojiPickerOpen(false);
587
+ suppressNextTooltip.current = true;
588
+ }
589
+ }
590
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react7.default, {
591
+ data: import_data.default,
592
+ onEmojiSelect: ({ native }) => {
593
+ if (native) {
594
+ setEmojiValue(native);
595
+ setEmojiPickerOpen(false);
596
+ }
597
+ },
598
+ autoFocus: true,
599
+ maxFrequentRows: 0,
600
+ noCountryFlags: true,
601
+ theme: themeMode
602
+ }), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Arrow, null))));
603
+ };
604
+ var EmojiPickerBlock = ({ disabled, defaultEmoji, emoji, onChangeEmoji, onClickClear }) => {
605
+ const { t } = (0, import_react_ui4.useTranslation)("os");
606
+ const [isMd] = (0, import_react_ui4.useMediaQuery)("md", {
607
+ ssr: false
608
+ });
609
+ const [emojiValue, setEmojiValue] = (0, import_react_use_controllable_state.useControllableState)({
610
+ prop: emoji,
611
+ onChange: onChangeEmoji,
612
+ defaultProp: defaultEmoji
613
+ });
614
+ const [emojiPickerOpen, setEmojiPickerOpen] = (0, import_react9.useState)(false);
615
+ return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Root, {
616
+ open: emojiPickerOpen,
617
+ onOpenChange: setEmojiPickerOpen
618
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Trigger, {
619
+ asChild: true
620
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Button, {
621
+ variant: "ghost",
622
+ classNames: "gap-2 text-2xl plb-1",
623
+ disabled
624
+ }, /* @__PURE__ */ import_react9.default.createElement("span", {
625
+ className: "sr-only"
626
+ }, t("select emoji label")), /* @__PURE__ */ import_react9.default.createElement("span", {
627
+ className: "grow pis-14"
628
+ }, emojiValue), /* @__PURE__ */ import_react9.default.createElement(import_react8.CaretDown, {
629
+ className: (0, import_react_ui_theme4.getSize)(4)
630
+ }))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Content, {
631
+ side: "right",
632
+ sideOffset: isMd ? 0 : -310,
633
+ onKeyDownCapture: (event) => {
634
+ if (event.key === "Escape") {
635
+ event.stopPropagation();
636
+ setEmojiPickerOpen(false);
637
+ }
638
+ }
639
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react7.default, {
640
+ data: import_data.default,
641
+ onEmojiSelect: ({ native }) => {
642
+ if (native) {
643
+ setEmojiValue(native);
644
+ setEmojiPickerOpen(false);
645
+ }
646
+ },
647
+ autoFocus: true,
648
+ maxFrequentRows: 0,
649
+ noCountryFlags: true
650
+ }), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Arrow, null))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Trigger, {
651
+ asChild: true
652
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Button, {
653
+ variant: "ghost",
654
+ onClick: onClickClear,
655
+ disabled
656
+ }, /* @__PURE__ */ import_react9.default.createElement("span", {
657
+ className: "sr-only"
658
+ }, t("clear label")), /* @__PURE__ */ import_react9.default.createElement(import_react8.ArrowCounterClockwise, null))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Content, {
659
+ style: {
660
+ zIndex: 70
661
+ },
662
+ side: "right"
663
+ }, t("clear label"), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Arrow, null)))));
664
+ };
665
+ var HuePreview = ({ hue }) => {
666
+ const { tx } = (0, import_react_ui5.useThemeContext)();
667
+ const size = 20;
668
+ return /* @__PURE__ */ import_react11.default.createElement("svg", {
669
+ width: size,
670
+ height: size,
671
+ viewBox: `0 0 ${size} ${size}`
672
+ }, /* @__PURE__ */ import_react11.default.createElement("rect", {
673
+ x: 0,
674
+ y: 0,
675
+ width: size,
676
+ height: size,
677
+ className: tx("hue.fill", "select--hue__preview", {
678
+ hue
679
+ })
680
+ }));
681
+ };
682
+ var hueTokens = Object.keys(import_react_ui_theme5.hueTokenThemes).slice(0, 16);
683
+ var HuePickerToolbarButton = ({ disabled, hue, onChangeHue, classNames, defaultHue }) => {
684
+ const { t } = (0, import_react_ui5.useTranslation)("os");
685
+ const [hueValue, setHueValue] = (0, import_react_use_controllable_state2.useControllableState)({
686
+ prop: hue,
687
+ onChange: onChangeHue,
688
+ defaultProp: defaultHue
689
+ });
690
+ const [huePickerOpen, setHuePickerOpen] = (0, import_react11.useState)(false);
691
+ const suppressNextTooltip = (0, import_react11.useRef)(false);
692
+ const [triggerTooltipOpen, setTriggerTooltipOpen] = (0, import_react11.useState)(false);
693
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Root, {
694
+ open: triggerTooltipOpen,
695
+ onOpenChange: (nextOpen) => {
696
+ if (suppressNextTooltip.current) {
697
+ setTriggerTooltipOpen(false);
698
+ suppressNextTooltip.current = false;
699
+ } else {
700
+ setTriggerTooltipOpen(nextOpen);
701
+ }
702
+ }
703
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Root, {
704
+ modal: false,
705
+ open: huePickerOpen,
706
+ onOpenChange: (nextOpen) => {
707
+ setHuePickerOpen(nextOpen);
708
+ suppressNextTooltip.current = true;
709
+ }
710
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Trigger, {
711
+ asChild: true
712
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Trigger, {
713
+ asChild: true
714
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Toolbar.Button, {
715
+ classNames: (0, import_react_ui_theme5.mx)("gap-2 plb-1", classNames),
716
+ disabled
717
+ }, /* @__PURE__ */ import_react11.default.createElement("span", {
718
+ className: "sr-only"
719
+ }, t("select hue label")), /* @__PURE__ */ import_react11.default.createElement(import_react10.Palette, {
720
+ className: (0, import_react_ui_theme5.getSize)(5)
721
+ })))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Content, {
722
+ side: "bottom",
723
+ classNames: "z-50"
724
+ }, t("select hue label"), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Arrow, null))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Content, {
725
+ side: "bottom",
726
+ classNames: "!w-40"
727
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Viewport, {
728
+ classNames: "grid grid-cols-4"
729
+ }, hueTokens.map((hue2) => {
730
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.CheckboxItem, {
731
+ key: hue2,
732
+ checked: hue2 === hueValue,
733
+ onCheckedChange: () => setHueValue(hue2),
734
+ classNames: "px-0 py-2 items-center justify-center"
735
+ }, /* @__PURE__ */ import_react11.default.createElement(HuePreview, {
736
+ hue: hue2
737
+ }));
738
+ })))));
739
+ };
740
+ var HuePickerBlock = ({ disabled, hue, onChangeHue, defaultHue, onClickClear }) => {
741
+ const { t } = (0, import_react_ui5.useTranslation)("os");
742
+ const [hueValue, setHueValue] = (0, import_react_use_controllable_state2.useControllableState)({
743
+ prop: hue,
744
+ onChange: onChangeHue,
745
+ defaultProp: defaultHue
746
+ });
747
+ return /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Root, {
748
+ modal: false
749
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Trigger, {
750
+ asChild: true
751
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Button, {
752
+ variant: "ghost",
753
+ classNames: "gap-2 plb-1",
754
+ disabled
755
+ }, /* @__PURE__ */ import_react11.default.createElement("span", {
756
+ className: "sr-only"
757
+ }, t("select hue label")), /* @__PURE__ */ import_react11.default.createElement("div", {
758
+ role: "none",
759
+ className: "pis-14 grow flex items-center justify-center gap-2"
760
+ }, /* @__PURE__ */ import_react11.default.createElement(HuePreview, {
761
+ hue: hueValue
762
+ }), /* @__PURE__ */ import_react11.default.createElement("span", null, t(`${hueValue} label`))), /* @__PURE__ */ import_react11.default.createElement(import_react10.CaretDown, {
763
+ className: (0, import_react_ui_theme5.getSize)(4)
764
+ }))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Content, {
765
+ side: "right"
766
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Viewport, null, Object.keys(import_react_ui_theme5.hueTokenThemes).map((hue2) => {
767
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.CheckboxItem, {
768
+ key: hue2,
769
+ checked: hue2 === hueValue,
770
+ onCheckedChange: () => setHueValue(hue2)
771
+ }, /* @__PURE__ */ import_react11.default.createElement(HuePreview, {
772
+ hue: hue2
773
+ }), /* @__PURE__ */ import_react11.default.createElement("span", {
774
+ className: "grow"
775
+ }, t(`${hue2} label`)), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.ItemIndicator, null, /* @__PURE__ */ import_react11.default.createElement(import_react10.Check, null)));
776
+ })), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Arrow, null))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Root, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Trigger, {
777
+ asChild: true
778
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Button, {
779
+ variant: "ghost",
780
+ onClick: onClickClear,
781
+ disabled
782
+ }, /* @__PURE__ */ import_react11.default.createElement("span", {
783
+ className: "sr-only"
784
+ }, t("clear label")), /* @__PURE__ */ import_react11.default.createElement(import_react10.ArrowCounterClockwise, null))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Content, {
785
+ style: {
786
+ zIndex: 70
787
+ },
788
+ side: "right"
789
+ }, t("clear label"), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Arrow, null)))));
790
+ };
791
+ var IdentityListItem = /* @__PURE__ */ (0, import_react12.forwardRef)(({ identity, presence, onClick, classNames, ...props }, forwardedRef) => {
792
+ const fallbackValue = (0, import_util.keyToFallback)(identity.identityKey);
793
+ const labelId = (0, import_react_ui6.useId)("identityListItem__label");
794
+ const displayName = identity.profile?.displayName ?? (0, import_display_name.generateName)(identity.identityKey.toHex());
795
+ return /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.ListItem.Root, {
796
+ ...props,
797
+ classNames: (0, import_react_ui_theme6.mx)("flex gap-2 pis-3 pie-1 items-center", onClick && "cursor-pointer", classNames),
798
+ onClick: () => onClick?.(),
799
+ "data-testid": "identity-list-item",
800
+ labelId,
801
+ ref: forwardedRef
802
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Root, {
803
+ status: presence === import_echo.SpaceMember.PresenceState.ONLINE ? "active" : "inactive",
804
+ labelId,
805
+ hue: identity.profile?.data?.hue || fallbackValue.hue
806
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Frame, {
807
+ classNames: "place-self-center"
808
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Fallback, {
809
+ text: identity.profile?.data?.emoji || fallbackValue.emoji
810
+ })), /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Label, {
811
+ classNames: "text-sm truncate pli-2"
812
+ }, displayName)));
813
+ });
814
+ var SpaceMemberList = ({ spaceKey, includeSelf, onSelect }) => {
815
+ const client = (0, import_react_client.useClient)();
816
+ const allUnsortedMembers = (0, import_echo2.useMembers)(spaceKey);
817
+ const members = (0, import_react13.useMemo)(() => includeSelf ? allUnsortedMembers.sort((member) => member.identity.identityKey.equals(client.halo.identity.get().identityKey) ? -1 : 1) : allUnsortedMembers.filter((member) => !member.identity.identityKey.equals(client.halo.identity.get().identityKey)), [
818
+ allUnsortedMembers
819
+ ]);
820
+ return /* @__PURE__ */ import_react13.default.createElement(SpaceMemberListImpl, {
821
+ members,
822
+ onSelect
823
+ });
824
+ };
825
+ var SpaceMemberListImpl = ({ members, onSelect }) => {
826
+ const { t } = (0, import_react_ui7.useTranslation)("os");
827
+ const visibleMembers = members.filter((member) => member.identity);
828
+ return visibleMembers.length > 0 ? /* @__PURE__ */ import_react13.default.createElement(import_react_ui7.List, {
829
+ classNames: "flex flex-col gap-2",
830
+ "data-testid": "space-members-list"
831
+ }, visibleMembers.map((member) => {
832
+ return /* @__PURE__ */ import_react13.default.createElement(IdentityListItem, {
833
+ key: member.identity.identityKey.toHex(),
834
+ identity: member.identity,
835
+ presence: member.presence,
836
+ onClick: onSelect && (() => onSelect(member))
837
+ });
838
+ })) : /* @__PURE__ */ import_react13.default.createElement("div", {
839
+ role: "none",
840
+ className: "grow flex items-center p-2"
841
+ }, /* @__PURE__ */ import_react13.default.createElement("p", {
842
+ className: (0, import_react_ui_theme7.mx)(import_react_ui_theme7.descriptionText, "text-center is-full mlb-2")
843
+ }, t("empty space members message")));
844
+ };
845
+ var iconProps = {
846
+ weight: "duotone",
847
+ width: 24,
848
+ height: 24,
849
+ x: 8,
850
+ y: 8
851
+ };
852
+ var DeviceListItem = /* @__PURE__ */ (0, import_react17.forwardRef)(({ device, onClickAdd, onClickEdit, onClickReset, onClickRecover, onClickJoinExisting, classNames, connectionState, onAgentDestroy: _, ...props }, forwardedRef) => {
853
+ const { t } = (0, import_react_ui9.useTranslation)("os");
854
+ const fallbackValue = (0, import_util2.keyToFallback)(device.deviceKey);
855
+ const labelId = (0, import_react_ui9.useId)("identityListItem__label");
856
+ const displayName = device.profile ? t("device name placeholder", {
857
+ os: device.profile.os,
858
+ platform: device.profile.platform
859
+ }) : (0, import_display_name2.generateName)(device.deviceKey.toHex());
860
+ const isCurrent = device.kind === import_halo.DeviceKind.CURRENT;
861
+ return /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.ListItem.Root, {
862
+ ...props,
863
+ classNames: [
864
+ "flex gap-2 items-center mlb-2",
865
+ classNames
866
+ ],
867
+ "data-testid": `device-list-item${isCurrent ? "-current" : ""}`,
868
+ labelId,
869
+ ref: forwardedRef
870
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Root, {
871
+ status: isCurrent && connectionState === import_mesh.ConnectionState.OFFLINE ? "error" : device.presence === import_halo.Device.PresenceState.ONLINE ? "active" : "inactive",
872
+ labelId,
873
+ hue: fallbackValue.hue,
874
+ variant: "square"
875
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Frame, {
876
+ classNames: "place-self-center"
877
+ }, device.profile?.type ? device.profile.type === import_halo.DeviceType.AGENT_MANAGED ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Database, iconProps) : device.profile.type === import_halo.DeviceType.BROWSER ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Compass, iconProps) : device.profile.type === import_halo.DeviceType.NATIVE ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Desktop, iconProps) : [
878
+ import_halo.DeviceType.AGENT,
879
+ import_halo.DeviceType.AGENT_MANAGED
880
+ ].includes(device.profile.type) ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Robot, iconProps) : device.profile.type === import_halo.DeviceType.MOBILE ? /* @__PURE__ */ import_react17.default.createElement(import_react16.DeviceMobile, iconProps) : /* @__PURE__ */ import_react17.default.createElement(import_react16.Devices, iconProps) : /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Fallback, {
881
+ text: fallbackValue.emoji
882
+ })), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Label, {
883
+ classNames: "flex-1 text-sm truncate"
884
+ }, displayName), isCurrent && /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Tag, {
885
+ color: "primary"
886
+ }, t("current device tag label")), device.kind === import_halo.DeviceKind.CURRENT && /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Root, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Trigger, {
887
+ asChild: true
888
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Button, {
889
+ variant: "ghost",
890
+ classNames: "pli-0 is-[--rail-action] bs-[--rail-action]",
891
+ "data-testid": `device-list-item${isCurrent ? "-current" : ""}.options`
892
+ }, /* @__PURE__ */ import_react17.default.createElement("span", {
893
+ className: "sr-only"
894
+ }, t("more options label")), /* @__PURE__ */ import_react17.default.createElement(import_react16.DotsThree, {
895
+ className: (0, import_react_ui_theme9.getSize)(5)
896
+ }))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Content, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Item, {
897
+ "data-testid": "device-list-item-current.join-existing",
898
+ onClick: onClickJoinExisting
899
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react16.ShareFat, {
900
+ className: (0, import_react_ui_theme9.getSize)(5)
901
+ }), t("choose join new identity label")), onClickRecover && /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Item, {
902
+ "data-testid": "device-list-item-current.recover",
903
+ onClick: onClickRecover
904
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react16.FirstAidKit, {
905
+ className: (0, import_react_ui_theme9.getSize)(5)
906
+ }), t("choose recover identity label")), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Item, {
907
+ "data-testid": "device-list-item-current.reset",
908
+ onClick: onClickReset
909
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react16.Power, {
910
+ className: (0, import_react_ui_theme9.getSize)(5)
911
+ }), t("reset device label")))))));
912
+ });
913
+ var DeviceList = ({ devices, connectionState, onClickAdd, onClickEdit, onClickReset, onClickRecover, onClickJoinExisting, onAgentDestroy }) => {
914
+ const { t } = (0, import_react_ui8.useTranslation)("os");
915
+ return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, /* @__PURE__ */ import_react15.default.createElement("h2", {
916
+ className: (0, import_react_ui_theme8.mx)(import_react_ui_theme8.descriptionText, "text-center mbs-4")
917
+ }, t("devices heading")), devices.length > 0 && /* @__PURE__ */ import_react15.default.createElement(import_react_ui8.List, null, devices.map((device) => {
918
+ return /* @__PURE__ */ import_react15.default.createElement(DeviceListItem, {
919
+ key: device.deviceKey.toHex(),
920
+ device,
921
+ onClickEdit: () => onClickEdit?.(device),
922
+ onClickReset,
923
+ onClickRecover,
924
+ onClickJoinExisting,
925
+ connectionState,
926
+ onAgentDestroy
927
+ });
928
+ })), /* @__PURE__ */ import_react15.default.createElement(import_react_ui8.Button, {
929
+ variant: "ghost",
930
+ classNames: "justify-start gap-2 !pis-0 !pie-3 is-full",
931
+ "data-testid": "devices-panel.create-invitation",
932
+ onClick: onClickAdd
933
+ }, /* @__PURE__ */ import_react15.default.createElement("div", {
934
+ role: "img",
935
+ className: (0, import_react_ui_theme8.mx)((0, import_react_ui_theme8.getSize)(8), "m-1 rounded-sm bg-input grid place-items-center")
936
+ }, /* @__PURE__ */ import_react15.default.createElement(import_react14.Plus, {
937
+ weight: "light",
938
+ className: (0, import_react_ui_theme8.getSize)(6)
939
+ })), /* @__PURE__ */ import_react15.default.createElement("span", {
940
+ className: "grow font-medium text-start"
941
+ }, t("choose add device label")), /* @__PURE__ */ import_react15.default.createElement(import_react14.CaretRight, {
942
+ weight: "bold",
943
+ className: (0, import_react_ui_theme8.getSize)(4)
944
+ })));
945
+ };
946
+ var AuthCode = (props) => {
947
+ const { code, large, classNames } = props;
948
+ const l = code?.length ?? 0;
949
+ const left = code?.slice(0, l / 2);
950
+ const right = code?.slice(l / 2);
951
+ const codeRef = (0, import_react20.useRef)(null);
952
+ const handleClick = () => {
953
+ if (codeRef.current) {
954
+ const selection = window.getSelection();
955
+ selection?.removeAllRanges();
956
+ const range = document.createRange();
957
+ range.selectNodeContents(codeRef.current);
958
+ selection?.addRange(range);
959
+ }
960
+ void navigator.clipboard.writeText(code ?? "");
961
+ };
962
+ return /* @__PURE__ */ import_react20.default.createElement("span", {
963
+ className: (0, import_react_ui_theme11.mx)(large ? "text-6xl" : "text-2xl", "font-mono pli-2.5 rounded cursor-pointer", classNames),
964
+ onClick: handleClick,
965
+ ref: codeRef
966
+ }, /* @__PURE__ */ import_react20.default.createElement("span", {
967
+ className: "mie-[0.4em]"
968
+ }, left), /* @__PURE__ */ import_react20.default.createElement("span", null, right));
969
+ };
970
+ var InvitationListItem = (props) => {
971
+ const { invitation } = props;
972
+ const invitationStatus = (0, import_invitations.useInvitationStatus)(invitation);
973
+ return /* @__PURE__ */ import_react19.default.createElement(InvitationListItemImpl, {
974
+ ...props,
975
+ invitationStatus
976
+ });
977
+ };
978
+ var avatarProps = {
979
+ size: 10,
980
+ variant: "circle"
981
+ };
982
+ var AvatarStackEffect = ({ animation, status, reverseEffects }) => {
983
+ const { tx } = (0, import_react_ui10.useThemeContext)();
984
+ return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement("span", {
985
+ role: "none",
986
+ className: (0, import_react_ui_theme10.mx)("absolute inline-end-auto opacity-20", reverseEffects ? "inline-start-3" : "inline-start-1", (0, import_react_ui_theme10.getSize)(avatarProps.size))
987
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
988
+ role: "none",
989
+ className: tx("avatar.ring", "avatar__ring", {
990
+ ...avatarProps,
991
+ status,
992
+ animation
993
+ }),
994
+ style: {
995
+ animationDelay: "400ms"
996
+ }
997
+ })), /* @__PURE__ */ import_react19.default.createElement("span", {
998
+ role: "none",
999
+ className: (0, import_react_ui_theme10.mx)("absolute inline-end-auto opacity-50", reverseEffects ? "inline-start-2" : "inline-start-2", (0, import_react_ui_theme10.getSize)(avatarProps.size))
1000
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1001
+ role: "none",
1002
+ className: tx("avatar.ring", "avatar__ring", {
1003
+ ...avatarProps,
1004
+ status,
1005
+ animation
1006
+ }),
1007
+ style: {
1008
+ animationDelay: "200ms"
1009
+ }
1010
+ })));
1011
+ };
1012
+ var InvitationListItemImpl = ({ invitation, invitationStatus: propsInvitationStatus, send, onClickRemove, createInvitationUrl, reverseEffects, ...props }) => {
1013
+ const { t } = (0, import_react_ui10.useTranslation)("os");
1014
+ const { cancel, status: invitationStatus, invitationCode, authCode, multiUse, shareable } = propsInvitationStatus;
1015
+ const isCancellable = !([
1016
+ import_invitations.Invitation.State.ERROR,
1017
+ import_invitations.Invitation.State.TIMEOUT,
1018
+ import_invitations.Invitation.State.CANCELLED
1019
+ ].indexOf(invitationStatus) >= 0);
1020
+ const showShare = shareable && (multiUse || [
1021
+ import_invitations.Invitation.State.INIT,
1022
+ import_invitations.Invitation.State.CONNECTING,
1023
+ import_invitations.Invitation.State.CONNECTED
1024
+ ].indexOf(invitationStatus) >= 0);
1025
+ const showAuthCode = invitationStatus === import_invitations.Invitation.State.READY_FOR_AUTHENTICATION;
1026
+ const handleClickRemove = (0, import_react19.useCallback)(() => onClickRemove?.(invitation), [
1027
+ invitation,
1028
+ onClickRemove
1029
+ ]);
1030
+ const invitationUrl = invitationCode && createInvitationUrl(invitationCode);
1031
+ const invitationId = invitation?.get().invitationId;
1032
+ const invitationHasLifetime = invitation?.get().lifetime;
1033
+ const invitationTimeLeft = invitation?.expiry ? (0, import_date_fns.formatDistanceToNow)(invitation?.expiry, {
1034
+ addSuffix: true
1035
+ }) : void 0;
1036
+ const avatarAnimation = [
1037
+ import_invitations.Invitation.State.INIT,
1038
+ import_invitations.Invitation.State.CONNECTING,
1039
+ import_invitations.Invitation.State.CONNECTED,
1040
+ import_invitations.Invitation.State.READY_FOR_AUTHENTICATION,
1041
+ import_invitations.Invitation.State.AUTHENTICATING
1042
+ ].includes(invitationStatus) ? "pulse" : "none";
1043
+ const avatarError = [
1044
+ import_invitations.Invitation.State.ERROR,
1045
+ import_invitations.Invitation.State.TIMEOUT,
1046
+ import_invitations.Invitation.State.CANCELLED
1047
+ ].includes(invitationStatus);
1048
+ const avatarGreen = [
1049
+ import_invitations.Invitation.State.CONNECTED,
1050
+ import_invitations.Invitation.State.READY_FOR_AUTHENTICATION,
1051
+ import_invitations.Invitation.State.AUTHENTICATING,
1052
+ import_invitations.Invitation.State.SUCCESS
1053
+ ].includes(invitationStatus);
1054
+ const avatarStatus = avatarError ? "error" : avatarGreen ? "active" : "inactive";
1055
+ return /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.ListItem.Root, {
1056
+ id: invitationCode,
1057
+ ...props,
1058
+ classNames: [
1059
+ "flex gap-2 pis-3 pie-1 items-center relative",
1060
+ props.classNames
1061
+ ]
1062
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.ListItem.Heading, {
1063
+ classNames: "sr-only"
1064
+ }, t(multiUse ? "invite many list item label" : "invite one list item label")), multiUse && /* @__PURE__ */ import_react19.default.createElement(AvatarStackEffect, {
1065
+ status: avatarStatus,
1066
+ animation: avatarAnimation,
1067
+ reverseEffects
1068
+ }), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Root, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Avatar.Root, {
1069
+ ...avatarProps,
1070
+ animation: avatarAnimation,
1071
+ status: avatarStatus
1072
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Trigger, {
1073
+ asChild: true
1074
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Avatar.Frame, {
1075
+ tabIndex: 0,
1076
+ classNames: [
1077
+ import_react_ui_theme10.focusRing,
1078
+ "relative rounded-full place-self-center"
1079
+ ]
1080
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Avatar.Fallback, {
1081
+ text: (0, import_util3.hexToEmoji)(invitationId)
1082
+ })))), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Portal, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Content, {
1083
+ side: "left",
1084
+ classNames: "z-[70]"
1085
+ }, t(multiUse ? "invite many qr label" : "invite one qr label"), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Arrow, null)))), showShare && invitationUrl ? /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Root, null, /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Trigger, {
1086
+ asChild: true
1087
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Button, {
1088
+ variant: "ghost",
1089
+ classNames: "grow justify-start font-medium",
1090
+ onClick: () => send({
1091
+ type: "selectInvitation",
1092
+ invitation
1093
+ }),
1094
+ "data-testid": "show-qrcode"
1095
+ }, /* @__PURE__ */ import_react19.default.createElement("span", null, t("open share panel label")))), /* @__PURE__ */ import_react19.default.createElement(CopyButtonIconOnly, {
1096
+ variant: "ghost",
1097
+ value: invitationUrl
1098
+ })), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Portal, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Content, {
1099
+ side: "left",
1100
+ classNames: "z-[70]"
1101
+ }, invitationHasLifetime && /* @__PURE__ */ import_react19.default.createElement("span", null, "Expires ", invitationTimeLeft)))) : showAuthCode ? /* @__PURE__ */ import_react19.default.createElement(AuthCode, {
1102
+ code: authCode,
1103
+ classNames: "grow"
1104
+ }) : invitationStatus === import_invitations.Invitation.State.CONNECTING ? /* @__PURE__ */ import_react19.default.createElement("span", {
1105
+ className: "pli-2 grow text-neutral-500"
1106
+ }, "Connecting...") : invitationStatus === import_invitations.Invitation.State.AUTHENTICATING ? /* @__PURE__ */ import_react19.default.createElement("span", {
1107
+ className: "pli-2 grow text-neutral-500"
1108
+ }, "Authenticating...") : invitationStatus === import_invitations.Invitation.State.ERROR || invitationStatus === import_invitations.Invitation.State.TIMEOUT ? /* @__PURE__ */ import_react19.default.createElement("span", {
1109
+ className: "pli-2 grow text-neutral-500"
1110
+ }, "Failed") : invitationStatus === import_invitations.Invitation.State.CANCELLED ? /* @__PURE__ */ import_react19.default.createElement("span", {
1111
+ className: "pli-2 grow text-neutral-500"
1112
+ }, "Cancelled") : invitationStatus === import_invitations.Invitation.State.SUCCESS ? /* @__PURE__ */ import_react19.default.createElement("span", {
1113
+ className: "pli-2 grow truncate"
1114
+ }, "User joined") : !shareable ? /* @__PURE__ */ import_react19.default.createElement("span", {
1115
+ className: "pli-2 grow text-neutral-500"
1116
+ }, "Pending Invitation") : /* @__PURE__ */ import_react19.default.createElement("span", {
1117
+ className: "grow"
1118
+ }, " "), isCancellable ? /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Button, {
1119
+ variant: "ghost",
1120
+ classNames: "flex gap-1 pli-0",
1121
+ onClick: cancel,
1122
+ "data-testid": "cancel-invitation"
1123
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1124
+ className: "sr-only"
1125
+ }, t("cancel invitation label")), /* @__PURE__ */ import_react19.default.createElement(import_react18.X, {
1126
+ className: (0, import_react_ui_theme10.getSize)(4)
1127
+ })) : /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Button, {
1128
+ variant: "ghost",
1129
+ classNames: "flex gap-1 pli-0",
1130
+ onClick: handleClickRemove,
1131
+ "data-testid": "remove-invitation"
1132
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1133
+ className: "sr-only"
1134
+ }, t("remove invitation label")), /* @__PURE__ */ import_react19.default.createElement(import_react18.X, {
1135
+ className: (0, import_react_ui_theme10.getSize)(4)
1136
+ })));
1137
+ };
1138
+ var InvitationList = ({ invitations, send, ...invitationProps }) => {
1139
+ const { className, InvitationListItem: Item = InvitationListItem } = invitationProps;
1140
+ return /* @__PURE__ */ import_react22.default.createElement(import_react_ui11.List, {
1141
+ classNames: (0, import_react_ui_theme12.mx)("flex flex-col gap-2", className)
1142
+ }, invitations.map((invitation) => {
1143
+ const value = invitation.get().invitationId;
1144
+ return /* @__PURE__ */ import_react22.default.createElement(Item, {
1145
+ key: value,
1146
+ send,
1147
+ invitation,
1148
+ ...invitationProps
1149
+ });
1150
+ }));
1151
+ };
1152
+ var InvitationListContainer = ({ spaceKey, createInvitationUrl, send }) => {
1153
+ const space = (0, import_echo3.useSpace)(spaceKey);
1154
+ const invitations = (0, import_echo3.useSpaceInvitations)(spaceKey);
1155
+ const handleClickRemove = (0, import_react21.useCallback)((invitation) => {
1156
+ void invitation.cancel();
1157
+ }, [
1158
+ space
1159
+ ]);
1160
+ return /* @__PURE__ */ import_react21.default.createElement(InvitationList, {
1161
+ invitations,
1162
+ onClickRemove: handleClickRemove,
1163
+ createInvitationUrl,
1164
+ send
1165
+ });
1166
+ };
1167
+ var defaultActions = {
1168
+ noopAction: {
1169
+ label: "No-op",
1170
+ description: "",
1171
+ icon: import_react23.Placeholder,
1172
+ onClick: () => {
1173
+ }
1174
+ }
1175
+ };
1176
+ var BifurcatedAction = /* @__PURE__ */ (0, import_react24.forwardRef)((props, forwardedRef) => {
1177
+ const { classNames, variant, isFull = true, actions = defaultActions, activeAction: propsActiveAction, onChangeActiveAction, defaultActiveAction, "data-testid": testId, ...rest } = props;
1178
+ const dropdownTestId = testId && `${testId}.more`;
1179
+ const [activeActionKey2 = Object.keys(actions)[0], setActiveAction] = (0, import_react_use_controllable_state3.useControllableState)({
1180
+ prop: propsActiveAction,
1181
+ onChange: onChangeActiveAction,
1182
+ defaultProp: defaultActiveAction
1183
+ });
1184
+ const activeAction = actions[activeActionKey2] ?? {};
1185
+ const { t } = (0, import_react_ui12.useTranslation)("os");
1186
+ return /* @__PURE__ */ import_react24.default.createElement("div", {
1187
+ role: "none",
1188
+ className: (0, import_react_ui_theme13.mx)("mbs-2 flex gap-px items-center", isFull && "is-full")
1189
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.Button, {
1190
+ ...rest,
1191
+ classNames: [
1192
+ "bs-11 flex-1 min-is-0 flex gap-2 rounded-ie-none",
1193
+ classNames
1194
+ ],
1195
+ ref: forwardedRef,
1196
+ variant,
1197
+ "data-testid": testId,
1198
+ onClick: activeAction.onClick
1199
+ }, activeAction.icon && /* @__PURE__ */ import_react24.default.createElement(activeAction.icon, {
1200
+ className: (0, import_react_ui_theme13.getSize)(5)
1201
+ }), /* @__PURE__ */ import_react24.default.createElement("span", null, activeAction.label)), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Root, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Trigger, {
1202
+ asChild: true
1203
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.Button, {
1204
+ classNames: [
1205
+ "bs-11 flex-none rounded-is-none",
1206
+ classNames
1207
+ ],
1208
+ "data-testid": dropdownTestId
1209
+ }, /* @__PURE__ */ import_react24.default.createElement("span", {
1210
+ className: "sr-only"
1211
+ }, t("invite options label")), /* @__PURE__ */ import_react24.default.createElement(import_react23.CaretDown, {
1212
+ className: (0, import_react_ui_theme13.getSize)(4)
1213
+ }))), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Portal, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Content, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Viewport, null, Object.entries(actions).map(([id, action]) => {
1214
+ return /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.CheckboxItem, {
1215
+ key: id,
1216
+ "aria-labelledby": `${id}__label`,
1217
+ "aria-describedby": `${id}__description`,
1218
+ checked: activeActionKey2 === id,
1219
+ onCheckedChange: (checked) => checked && setActiveAction(id),
1220
+ classNames: "gap-2",
1221
+ "data-testid": action.testId
1222
+ }, action.icon && /* @__PURE__ */ import_react24.default.createElement(action.icon, {
1223
+ className: (0, import_react_ui_theme13.getSize)(5)
1224
+ }), /* @__PURE__ */ import_react24.default.createElement("div", {
1225
+ role: "none",
1226
+ className: "flex-1 min-is-0 space-b-1"
1227
+ }, /* @__PURE__ */ import_react24.default.createElement("p", {
1228
+ id: `${id}__label`
1229
+ }, action.label), action.description && /* @__PURE__ */ import_react24.default.createElement("p", {
1230
+ id: `${id}__description`,
1231
+ className: import_react_ui_theme13.descriptionText
1232
+ }, action.description)), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.ItemIndicator, {
1233
+ asChild: true
1234
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react23.Check, {
1235
+ weight: "bold",
1236
+ className: (0, import_react_ui_theme13.getSize)(4)
1237
+ })));
1238
+ })), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Arrow, null)))));
1239
+ });
1240
+ var Action = /* @__PURE__ */ (0, import_react24.forwardRef)((props, forwardedRef) => {
1241
+ const { children, classNames, variant, isFull = true, ...rest } = props;
1242
+ return /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.Button, {
1243
+ ...rest,
1244
+ classNames: [
1245
+ isFull && "is-full",
1246
+ "bs-11 flex gap-2 mbs-2",
1247
+ classNames
1248
+ ],
1249
+ ref: forwardedRef,
1250
+ variant
1251
+ }, children);
1252
+ });
1253
+ var Actions = /* @__PURE__ */ (0, import_react25.forwardRef)(({ classNames, children, ...props }, forwardedRef) => {
1254
+ return /* @__PURE__ */ import_react25.default.createElement("div", {
1255
+ ...props,
1256
+ className: (0, import_react_ui_theme14.mx)("flex flex-col gap-2 mbs-2", Array.isArray(children) && children.length > 1 ? "justify-between" : "justify-center", classNames),
1257
+ ref: forwardedRef
1258
+ }, children);
1259
+ });
1260
+ var CloseButton = ({ onDone, ...props }) => {
1261
+ const { t } = (0, import_react_ui13.useTranslation)("os");
1262
+ return /* @__PURE__ */ import_react27.default.createElement(import_react_ui13.Button, {
1263
+ variant: "ghost",
1264
+ classNames: (0, import_react_ui_theme15.mx)("plb-0 pli-2 absolute block-start-0 inline-end-0 z-[1]"),
1265
+ onClick: () => onDone?.(),
1266
+ ...props
1267
+ }, /* @__PURE__ */ import_react27.default.createElement(import_react26.X, {
1268
+ weight: "bold",
1269
+ className: (0, import_react_ui_theme15.getSize)(4)
1270
+ }), /* @__PURE__ */ import_react27.default.createElement("span", {
1271
+ className: "sr-only"
1272
+ }, t("exit label")));
1273
+ };
1274
+ var Emoji = ({ text, className }) => {
1275
+ const size = 14;
1276
+ return /* @__PURE__ */ import_react28.default.createElement("div", {
1277
+ role: "none",
1278
+ className: (0, import_react_ui_theme16.mx)((0, import_react_ui_theme16.getSize)(size), "rounded relative pointer-events-none", className)
1279
+ }, /* @__PURE__ */ import_react28.default.createElement("svg", {
1280
+ viewBox: `0 0 ${size * 4} ${size * 4}`,
1281
+ width: size * 4,
1282
+ height: size * 4
1283
+ }, /* @__PURE__ */ import_react28.default.createElement("text", {
1284
+ x: "50%",
1285
+ y: "50%",
1286
+ textAnchor: "middle",
1287
+ dominantBaseline: "middle",
1288
+ baselineShift: "-0.25rem",
1289
+ fontSize: "2.25rem"
1290
+ }, text)));
1291
+ };
1292
+ var Centered = (props) => {
1293
+ const { children } = props;
1294
+ return /* @__PURE__ */ import_react28.default.createElement("div", {
1295
+ role: "none",
1296
+ className: "absolute inset-0 flex items-center justify-center"
1297
+ }, children);
1298
+ };
1299
+ var Heading = /* @__PURE__ */ (0, import_react29.forwardRef)(({ titleId, title, titleSrOnly, children, corner }, forwardedRef) => {
1300
+ return /* @__PURE__ */ import_react29.default.createElement("div", {
1301
+ role: "none",
1302
+ className: "pbe-2 relative",
1303
+ ref: forwardedRef
1304
+ }, corner, /* @__PURE__ */ import_react29.default.createElement("h1", {
1305
+ ...!titleSrOnly && {
1306
+ id: titleId
1307
+ },
1308
+ className: (0, import_react_ui_theme17.mx)(import_react_ui_theme17.descriptionText, "text-center mlb-2", titleSrOnly && "invisible")
1309
+ }, title), titleSrOnly && /* @__PURE__ */ import_react29.default.createElement("span", {
1310
+ id: titleId
1311
+ }, title), children);
1312
+ });
1313
+ var Label = (props) => {
1314
+ const { children } = props;
1315
+ return /* @__PURE__ */ import_react30.default.createElement("span", {
1316
+ className: (0, import_react_ui_theme18.mx)(import_react_ui_theme18.descriptionText, "text-center mli-6 whitespace-normal")
1317
+ }, children);
1318
+ };
1319
+ var Input = ({ validationMessage, label, ...props }) => {
1320
+ return /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.Root, null, /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.Label, null, label), /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.TextInput, {
1321
+ ...props,
1322
+ classNames: "plb-3 mbs-2 text-center"
1323
+ }), /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.DescriptionAndValidation, null, validationMessage && /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.Validation, null, validationMessage)));
1324
+ };
1325
+ var StepHeading = /* @__PURE__ */ (0, import_react32.forwardRef)(({ children, className, ...props }, forwardedRef) => {
1326
+ return /* @__PURE__ */ import_react32.default.createElement("h2", {
1327
+ ...props,
1328
+ className: (0, import_react_ui_theme19.mx)("font-normal text-sm mbe-4 mli-1 text-center", className),
1329
+ ref: forwardedRef
1330
+ }, children);
1331
+ });
1332
+ var VIEWPORT_NAME = "Viewport";
1333
+ var VIEWS_NAME = "ViewportViews";
1334
+ var VIEW_NAME = "ViewportView";
1335
+ var [createViewportContext, createViewportScope] = (0, import_react_context.createContextScope)(VIEWPORT_NAME, []);
1336
+ var [ViewportProvider, useViewportContext] = createViewportContext(VIEWPORT_NAME);
1337
+ var ViewportRoot = ({ __viewportScope, classNames, children, defaultActiveView, activeView: propsActiveView, focusManaged = false, onActiveViewChange, ...props }) => {
1338
+ const [activeView = "never", setActiveView] = (0, import_react_use_controllable_state4.useControllableState)({
1339
+ prop: propsActiveView,
1340
+ defaultProp: defaultActiveView,
1341
+ onChange: onActiveViewChange
1342
+ });
1343
+ return /* @__PURE__ */ import_react33.default.createElement(ViewportProvider, {
1344
+ focusManaged,
1345
+ activeView,
1346
+ setActiveView,
1347
+ scope: __viewportScope
1348
+ }, /* @__PURE__ */ import_react33.default.createElement("div", {
1349
+ role: "region",
1350
+ "aria-live": "polite",
1351
+ ...props,
1352
+ className: (0, import_react_ui_theme20.mx)("is-full overflow-hidden", classNames)
1353
+ }, children));
1354
+ };
1355
+ ViewportRoot.displayName = VIEWPORT_NAME;
1356
+ var ViewportViews = ({ classNames, children, ...props }) => {
1357
+ const size = {
1358
+ inlineSize: `${Math.ceil(children.length) * 100}%`
1359
+ };
1360
+ return /* @__PURE__ */ import_react33.default.createElement("div", {
1361
+ role: "none",
1362
+ style: size,
1363
+ ...props,
1364
+ className: (0, import_react_ui_theme20.mx)("flex", classNames)
1365
+ }, children);
1366
+ };
1367
+ ViewportViews.displayName = VIEWS_NAME;
1368
+ var ViewportView = /* @__PURE__ */ (0, import_react33.forwardRef)(({ __viewportScope, classNames, children, id, ...props }, forwardedRef) => {
1369
+ const { activeView, focusManaged } = useViewportContext(VIEW_NAME, __viewportScope);
1370
+ const isActive = id === activeView;
1371
+ const ref = (0, import_react_ui15.useForwardedRef)(forwardedRef);
1372
+ const { findFirstFocusable } = (0, import_react_tabster.useFocusFinders)();
1373
+ (0, import_react33.useEffect)(() => {
1374
+ if (!focusManaged && isActive && document.body.hasAttribute("data-is-keyboard") && ref.current) {
1375
+ findFirstFocusable(ref.current)?.focus();
1376
+ }
1377
+ }, [
1378
+ focusManaged,
1379
+ ref.current,
1380
+ isActive
1381
+ ]);
1382
+ return /* @__PURE__ */ import_react33.default.createElement("section", {
1383
+ ...props,
1384
+ ...!isActive && {
1385
+ "aria-hidden": true
1386
+ },
1387
+ className: (0, import_react_ui_theme20.mx)("min-is-0 flex-1 flex flex-col", isActive ? "order-2" : "order-4 invisible", classNames),
1388
+ ref
1389
+ }, children);
1390
+ });
1391
+ ViewportView.displayName = VIEW_NAME;
1392
+ var Viewport = {
1393
+ Root: ViewportRoot,
1394
+ Views: ViewportViews,
1395
+ View: ViewportView
1396
+ };
1397
+ var SpaceListItem = /* @__PURE__ */ (0, import_react34.forwardRef)(({ space, onClick }, ref) => {
1398
+ const fallbackValue = (0, import_util4.keyToEmoji)(space.key);
1399
+ const labelId = (0, import_react_ui16.useId)("identityListItem__label");
1400
+ const displayName = space.properties.name ?? (0, import_util4.humanize)(space.key.toHex());
1401
+ return /* @__PURE__ */ import_react34.default.createElement("li", {
1402
+ className: (0, import_react_ui_theme21.mx)("flex gap-2 items-center mbe-2", onClick && "cursor-pointer"),
1403
+ onClick: () => onClick?.(),
1404
+ ref,
1405
+ "data-testid": "space-list-item"
1406
+ }, /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Root, {
1407
+ labelId
1408
+ }, /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Frame, null, /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Fallback, {
1409
+ text: fallbackValue
1410
+ })), /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Label, {
1411
+ classNames: "text-sm truncate"
1412
+ }, displayName)));
1413
+ });
1414
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/identityMachine.ts";
1415
+ var identityMachine = (0, import_xstate.createMachine)({
1416
+ id: "identity",
1417
+ predictableActionArguments: true,
1418
+ context: {
1419
+ identity: null,
1420
+ identitySubscribable: null
1421
+ },
1422
+ initial: "choosingAction",
1423
+ invoke: {
1424
+ src: (context) => context.identitySubscribable
1425
+ },
1426
+ states: {
1427
+ unknown: {
1428
+ always: [
1429
+ {
1430
+ cond: "initiallyManagingDeviceInvitation",
1431
+ target: "managingDeviceInvitation",
1432
+ actions: "log"
1433
+ },
1434
+ {
1435
+ target: "choosingAction",
1436
+ actions: "log"
1437
+ }
1438
+ ]
1439
+ },
1440
+ choosingAction: {},
1441
+ managingDeviceInvitation: {},
1442
+ confirmingResetStorage: {},
1443
+ confirmingRecover: {},
1444
+ confirmingJoinNewIdentity: {}
1445
+ },
1446
+ on: {
1447
+ unchooseAction: {
1448
+ target: ".choosingAction",
1449
+ actions: [
1450
+ "unsetInvitation",
1451
+ "log"
1452
+ ]
1453
+ },
1454
+ deselectInvitation: {
1455
+ target: ".choosingAction",
1456
+ actions: [
1457
+ "unsetInvitation",
1458
+ "log"
1459
+ ]
1460
+ },
1461
+ selectInvitation: {
1462
+ target: ".managingDeviceInvitation",
1463
+ actions: [
1464
+ "setInvitation",
1465
+ "log"
1466
+ ]
1467
+ },
1468
+ chooseJoinNewIdentity: {
1469
+ target: ".confirmingJoinNewIdentity",
1470
+ actions: "log"
1471
+ },
1472
+ chooseRecoverIdentity: {
1473
+ target: ".confirmingRecover",
1474
+ actions: "log"
1475
+ },
1476
+ chooseResetStorage: {
1477
+ target: ".confirmingResetStorage",
1478
+ actions: "log"
1479
+ }
1480
+ }
1481
+ }, {
1482
+ guards: {
1483
+ initiallyManagingDeviceInvitation: ({ initialDisposition }, _event) => initialDisposition === "manage-device-invitation"
1484
+ },
1485
+ actions: {
1486
+ setIdentity: (0, import_xstate.assign)({
1487
+ identity: (context, event) => event?.identity ?? null
1488
+ }),
1489
+ setInvitation: (0, import_xstate.assign)({
1490
+ invitation: (context, event) => event?.invitation ?? null
1491
+ }),
1492
+ unsetInvitation: (0, import_xstate.assign)({
1493
+ invitation: () => void 0
1494
+ }),
1495
+ log: (context, event) => {
1496
+ (0, import_log2.log)("[transition]", {
1497
+ event,
1498
+ context
1499
+ }, {
1500
+ F: __dxlog_file,
1501
+ L: 98,
1502
+ S: void 0,
1503
+ C: (f, a) => f(...a)
1504
+ });
1505
+ }
1506
+ }
1507
+ });
1508
+ var useIdentityMachine = (client, options) => {
1509
+ return (0, import_react38.useMachine)(identityMachine, {
1510
+ ...options,
1511
+ context: {
1512
+ ...options?.context,
1513
+ identity: client.halo.identity.get(),
1514
+ identitySubscribable: client.halo.identity.map((identity) => ({
1515
+ type: "setIdentity",
1516
+ identity
1517
+ }))
1518
+ }
1519
+ });
1520
+ };
1521
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx";
1522
+ var IdentityActionChooser = (props) => {
1523
+ const { send } = props;
1524
+ const client = (0, import_react_client3.useClient)();
1525
+ const invitations = (0, import_halo3.useHaloInvitations)();
1526
+ const createInvitation = () => {
1527
+ invitations.forEach((invitation2) => invitation2.cancel());
1528
+ const invitation = client.halo.share();
1529
+ if (client.config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
1530
+ const subscription = invitation.subscribe((invitation2) => {
1531
+ const invitationCode = import_invitations3.InvitationEncoder.encode(invitation2);
1532
+ if (invitation2.state === import_invitations3.Invitation.State.CONNECTING) {
1533
+ import_log3.log.info(JSON.stringify({
1534
+ invitationCode,
1535
+ authCode: invitation2.authCode
1536
+ }), void 0, {
1537
+ F: __dxlog_file2,
1538
+ L: 29,
1539
+ S: void 0,
1540
+ C: (f, a) => f(...a)
1541
+ });
1542
+ subscription.unsubscribe();
1543
+ }
1544
+ });
1545
+ }
1546
+ send?.({
1547
+ type: "selectInvitation",
1548
+ invitation
1549
+ });
1550
+ };
1551
+ const isProduction = client.config.values.runtime?.app?.env?.DX_ENVIRONMENT === "production";
1552
+ return /* @__PURE__ */ import_react39.default.createElement(IdentityActionChooserImpl, {
1553
+ ...props,
1554
+ onClickAdd: createInvitation,
1555
+ onClickJoinExisting: () => send?.({
1556
+ type: "chooseJoinNewIdentity"
1557
+ }),
1558
+ onClickRecover: isProduction ? void 0 : () => send?.({
1559
+ type: "chooseRecoverIdentity"
1560
+ }),
1561
+ onClickReset: () => send?.({
1562
+ type: "chooseResetStorage"
1563
+ })
1564
+ });
1565
+ };
1566
+ var IdentityActionChooserImpl = ({ devices, connectionState, agentHostingEnabled, onClickAdd, onClickJoinExisting, onClickRecover, onClickReset, ...agentProps }) => {
1567
+ const edgeDeviceAvailable = devices.find((device) => device.profile?.type === import_halo3.DeviceType.AGENT_MANAGED && device.profile?.os?.toUpperCase() === "EDGE");
1568
+ return /* @__PURE__ */ import_react39.default.createElement("div", {
1569
+ role: "none",
1570
+ className: "bs-40 grow overflow-y-auto overflow-x-hidden"
1571
+ }, /* @__PURE__ */ import_react39.default.createElement(DeviceList, {
1572
+ devices,
1573
+ connectionState,
1574
+ onClickAdd,
1575
+ onClickJoinExisting,
1576
+ onClickRecover: agentProps.agentStatus === "created" ? onClickRecover : void 0,
1577
+ onClickReset,
1578
+ onAgentDestroy: agentProps.onAgentDestroy
1579
+ }), !edgeDeviceAvailable && agentHostingEnabled && /* @__PURE__ */ import_react39.default.createElement(AgentConfig, agentProps));
1580
+ };
1581
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/useEdgeAgentsHandlers.ts";
1582
+ var useEdgeAgentHandlers = ({ identity }) => {
1583
+ const [validationMessage, setValidationMessage] = (0, import_react41.useState)("");
1584
+ const [lastReceivedStatus, setLastReceivedStatus] = (0, import_react41.useState)(import_services.QueryAgentStatusResponse.AgentStatus.UNKNOWN);
1585
+ const [agentStatus, setAgentStatus] = (0, import_react41.useState)("getting");
1586
+ const client = (0, import_react_client5.useClient)();
1587
+ const agentHostingEnabled = Boolean(client.config.values.runtime?.client?.edgeFeatures?.agents);
1588
+ const handleStatus = (status) => {
1589
+ switch (status) {
1590
+ case import_services.QueryAgentStatusResponse.AgentStatus.ACTIVE:
1591
+ case import_services.QueryAgentStatusResponse.AgentStatus.INACTIVE:
1592
+ setAgentStatus("created");
1593
+ break;
1594
+ case import_services.QueryAgentStatusResponse.AgentStatus.NOT_FOUND:
1595
+ setAgentStatus("creatable");
1596
+ break;
1597
+ case import_services.QueryAgentStatusResponse.AgentStatus.UNKNOWN:
1598
+ setAgentStatus("getting");
1599
+ break;
1600
+ }
1601
+ };
1602
+ (0, import_react41.useEffect)(() => {
1603
+ const stream = client.services.services.EdgeAgentService?.queryAgentStatus();
1604
+ stream?.subscribe(({ status }) => {
1605
+ setLastReceivedStatus(status);
1606
+ handleStatus(status);
1607
+ });
1608
+ return () => {
1609
+ void stream?.close().catch(() => {
1610
+ });
1611
+ };
1612
+ }, []);
1613
+ const onAgentCreate = async () => {
1614
+ (0, import_invariant2.invariant)(identity, "Identity not found", {
1615
+ F: __dxlog_file3,
1616
+ L: 58,
1617
+ S: void 0,
1618
+ A: [
1619
+ "identity",
1620
+ "'Identity not found'"
1621
+ ]
1622
+ });
1623
+ const service = client.services.services.EdgeAgentService;
1624
+ if (!service) {
1625
+ setAgentStatus("error");
1626
+ setValidationMessage("Agent service not initialized.");
1627
+ return;
1628
+ }
1629
+ if (!agentHostingEnabled) {
1630
+ setAgentStatus("error");
1631
+ setValidationMessage("Edge agents are disabled in config.");
1632
+ return;
1633
+ }
1634
+ setAgentStatus("creating");
1635
+ setValidationMessage("");
1636
+ try {
1637
+ await service.createAgent();
1638
+ await Promise.all(client.spaces.get().map((space) => space?.internal.setEdgeReplicationPreference(import_metadata.EdgeReplicationSetting.ENABLED)));
1639
+ setAgentStatus("created");
1640
+ } catch (err) {
1641
+ setAgentStatus("error");
1642
+ setValidationMessage(`Error creating an agent: ${err.message}`);
1643
+ }
1644
+ };
1645
+ const onAgentDestroy = async () => {
1646
+ setValidationMessage("Agents are non-destructible.");
1647
+ };
1648
+ const onAgentRefresh = async () => {
1649
+ setValidationMessage("");
1650
+ handleStatus(lastReceivedStatus);
1651
+ };
1652
+ return {
1653
+ onAgentCreate,
1654
+ onAgentDestroy,
1655
+ onAgentRefresh,
1656
+ validationMessage,
1657
+ agentStatus,
1658
+ agentHostingEnabled
1659
+ };
1660
+ };
1661
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/useKubeAgentHandlers.ts";
1662
+ var useKubeAgentHandlers = ({ invitations, identity }) => {
1663
+ const [validationMessage, setValidationMessage] = (0, import_react42.useState)("");
1664
+ const [agentStatus, setAgentStatus] = (0, import_react42.useState)("getting");
1665
+ const agentHostingProviderClient = (0, import_react_client6.useAgentHostingClient)();
1666
+ const client = (0, import_react_client6.useClient)();
1667
+ const updateAgentStatus = async () => {
1668
+ if (agentHostingProviderClient) {
1669
+ setAgentStatus("getting");
1670
+ try {
1671
+ const agentId = await agentHostingProviderClient?.getAgent(identity?.identityKey.truncate() ?? "never");
1672
+ if (agentId) {
1673
+ setAgentStatus("created");
1674
+ } else {
1675
+ setAgentStatus("creatable");
1676
+ }
1677
+ } catch (err) {
1678
+ setAgentStatus("error");
1679
+ setValidationMessage(`Couldn\u2019t check agent status: ${err.message}`);
1680
+ }
1681
+ } else {
1682
+ setAgentStatus("error");
1683
+ setValidationMessage("No agent provider configured.");
1684
+ }
1685
+ };
1686
+ const createAgent = async (invitationCode) => {
1687
+ (0, import_invariant3.invariant)(identity, "Identity not found", {
1688
+ F: __dxlog_file4,
1689
+ L: 50,
1690
+ S: void 0,
1691
+ A: [
1692
+ "identity",
1693
+ "'Identity not found'"
1694
+ ]
1695
+ });
1696
+ if (agentHostingProviderClient) {
1697
+ setAgentStatus("creating");
1698
+ setValidationMessage("");
1699
+ try {
1700
+ const agentId = await agentHostingProviderClient?.createAgent(invitationCode, identity.identityKey.truncate());
1701
+ if (agentId) {
1702
+ setAgentStatus("created");
1703
+ } else {
1704
+ setAgentStatus("creatable");
1705
+ setValidationMessage("Error creating agent.");
1706
+ }
1707
+ } catch (err) {
1708
+ setValidationMessage(`Error creating agent: ${err.message}`);
1709
+ return updateAgentStatus();
1710
+ }
1711
+ } else {
1712
+ setAgentStatus("error");
1713
+ setValidationMessage("No agent provider configured.");
1714
+ }
1715
+ };
1716
+ const destroyAgent = async () => {
1717
+ (0, import_invariant3.invariant)(identity, "Identity not found", {
1718
+ F: __dxlog_file4,
1719
+ L: 73,
1720
+ S: void 0,
1721
+ A: [
1722
+ "identity",
1723
+ "'Identity not found'"
1724
+ ]
1725
+ });
1726
+ if (agentHostingProviderClient) {
1727
+ setAgentStatus("destroying");
1728
+ setValidationMessage("");
1729
+ try {
1730
+ await agentHostingProviderClient?.destroyAgent(identity.identityKey.truncate());
1731
+ setAgentStatus("creatable");
1732
+ } catch (err) {
1733
+ setValidationMessage(`Error destroying agent: ${err.message}`);
1734
+ return updateAgentStatus();
1735
+ }
1736
+ } else {
1737
+ setAgentStatus("error");
1738
+ setValidationMessage("No agent provider configured.");
1739
+ }
1740
+ };
1741
+ (0, import_react42.useEffect)(() => {
1742
+ void updateAgentStatus();
1743
+ }, []);
1744
+ const handleAgentCreate = (0, import_react42.useCallback)(async (invitation) => {
1745
+ const invitationCode = import_invitations4.InvitationEncoder.encode(invitation);
1746
+ if (invitation.state === import_invitations4.Invitation.State.CONNECTING) {
1747
+ import_log5.log.info(JSON.stringify({
1748
+ invitationCode,
1749
+ authCode: invitation.authCode
1750
+ }), void 0, {
1751
+ F: __dxlog_file4,
1752
+ L: 97,
1753
+ S: void 0,
1754
+ C: (f, a) => f(...a)
1755
+ });
1756
+ return createAgent(invitationCode);
1757
+ }
1758
+ }, []);
1759
+ const onAgentCreate = async () => {
1760
+ invitations.forEach((invitation2) => invitation2.cancel());
1761
+ const invitation = client.halo.share({
1762
+ type: import_invitations4.Invitation.Type.INTERACTIVE,
1763
+ authMethod: import_invitations4.Invitation.AuthMethod.NONE,
1764
+ multiUse: true
1765
+ });
1766
+ invitation.subscribe(handleAgentCreate);
1767
+ };
1768
+ const onAgentRefresh = async () => {
1769
+ setValidationMessage("");
1770
+ await updateAgentStatus();
1771
+ };
1772
+ return {
1773
+ onAgentCreate,
1774
+ onAgentDestroy: destroyAgent,
1775
+ onAgentRefresh,
1776
+ validationMessage,
1777
+ agentStatus,
1778
+ agentHostingEnabled: !!agentHostingProviderClient
1779
+ };
1780
+ };
1781
+ var useAgentHandlers = (params) => {
1782
+ const client = (0, import_react_client4.useClient)();
1783
+ if (client.config.values?.runtime?.client?.edgeFeatures?.agents) {
1784
+ return useEdgeAgentHandlers(params);
1785
+ } else {
1786
+ return useKubeAgentHandlers(params);
1787
+ }
1788
+ };
1789
+ var invitationStatusValue = /* @__PURE__ */ new Map([
1790
+ [
1791
+ import_invitations5.Invitation.State.ERROR,
1792
+ -3
1793
+ ],
1794
+ [
1795
+ import_invitations5.Invitation.State.TIMEOUT,
1796
+ -2
1797
+ ],
1798
+ [
1799
+ import_invitations5.Invitation.State.CANCELLED,
1800
+ -1
1801
+ ],
1802
+ [
1803
+ import_invitations5.Invitation.State.INIT,
1804
+ 0
1805
+ ],
1806
+ [
1807
+ import_invitations5.Invitation.State.CONNECTING,
1808
+ 1
1809
+ ],
1810
+ [
1811
+ import_invitations5.Invitation.State.CONNECTED,
1812
+ 2
1813
+ ],
1814
+ [
1815
+ import_invitations5.Invitation.State.READY_FOR_AUTHENTICATION,
1816
+ 3
1817
+ ],
1818
+ [
1819
+ import_invitations5.Invitation.State.AUTHENTICATING,
1820
+ 4
1821
+ ],
1822
+ [
1823
+ import_invitations5.Invitation.State.SUCCESS,
1824
+ 5
1825
+ ]
1826
+ ]);
1827
+ var InvitationManagerView = ({ children, ...props }) => {
1828
+ return /* @__PURE__ */ import_react44.default.createElement(Viewport.View, {
1829
+ ...props,
1830
+ classNames: "grow flex flex-col justify-around items-center"
1831
+ }, children);
1832
+ };
1833
+ var InvitationManager = ({ invitationUrl, active, send, status, multiUse, authCode, id = "0" }) => {
1834
+ const { t } = (0, import_react_ui20.useTranslation)("os");
1835
+ const qrLabel = (0, import_react_ui20.useId)("invitation-manager__qr-code");
1836
+ const statusValue = multiUse ? 0 : invitationStatusValue.get(status) ?? 0;
1837
+ const showAuthCode = statusValue === 3;
1838
+ const emoji = (0, import_util7.hexToEmoji)(id);
1839
+ const activeView = (0, import_react44.useMemo)(() => {
1840
+ if (multiUse) {
1841
+ return "showing qr";
1842
+ }
1843
+ switch (true) {
1844
+ case statusValue === 5:
1845
+ case statusValue < 0:
1846
+ return "showing final";
1847
+ case statusValue === 3:
1848
+ return "showing auth code";
1849
+ default:
1850
+ return "showing qr";
1851
+ }
1852
+ }, [
1853
+ statusValue
1854
+ ]);
1855
+ return /* @__PURE__ */ import_react44.default.createElement(import_react44.default.Fragment, null, /* @__PURE__ */ import_react44.default.createElement(Viewport.Root, {
1856
+ activeView,
1857
+ classNames: "grow plb-1"
1858
+ }, /* @__PURE__ */ import_react44.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react44.default.createElement(InvitationManagerView, {
1859
+ id: "showing qr",
1860
+ emoji
1861
+ }, /* @__PURE__ */ import_react44.default.createElement("p", {
1862
+ className: "text-sm mlb-1 font-normal text-center"
1863
+ }, t(multiUse ? "invite many qr label" : "invite one qr label")), /* @__PURE__ */ import_react44.default.createElement("div", {
1864
+ role: "none",
1865
+ className: (0, import_react_ui_theme23.mx)(import_react_ui_theme23.descriptionText, "is-full max-is-[14rem] relative")
1866
+ }, /* @__PURE__ */ import_react44.default.createElement(import_react_qr_rounded.QR, {
1867
+ rounding: 100,
1868
+ backgroundColor: "transparent",
1869
+ color: "currentColor",
1870
+ className: (0, import_react_ui_theme23.mx)("is-full bs-full p-2", showAuthCode && "invisible"),
1871
+ "aria-labelledby": qrLabel,
1872
+ errorCorrectionLevel: "Q",
1873
+ cutout: true
1874
+ }, invitationUrl ?? "never"), /* @__PURE__ */ import_react44.default.createElement(Centered, null, /* @__PURE__ */ import_react44.default.createElement(Emoji, {
1875
+ text: emoji
1876
+ }))), /* @__PURE__ */ import_react44.default.createElement("span", {
1877
+ id: qrLabel,
1878
+ className: "sr-only"
1879
+ }, t("qr label")), /* @__PURE__ */ import_react44.default.createElement(CopyButton, {
1880
+ variant: "ghost",
1881
+ value: invitationUrl ?? "never"
1882
+ })), /* @__PURE__ */ import_react44.default.createElement(InvitationManagerView, {
1883
+ id: "showing auth code"
1884
+ }, /* @__PURE__ */ import_react44.default.createElement(Label, null, t("auth code message")), /* @__PURE__ */ import_react44.default.createElement(AuthCode, {
1885
+ code: authCode,
1886
+ large: true,
1887
+ classNames: "text-black dark:text-white"
1888
+ }), /* @__PURE__ */ import_react44.default.createElement(Label, null, t("auth other device emoji message")), emoji && /* @__PURE__ */ import_react44.default.createElement(Emoji, {
1889
+ text: emoji
1890
+ })), /* @__PURE__ */ import_react44.default.createElement(InvitationManagerView, {
1891
+ id: "showing final"
1892
+ }, statusValue > 0 ? /* @__PURE__ */ import_react44.default.createElement(import_react43.Check, {
1893
+ className: (0, import_react_ui_theme23.mx)("m-1.5", (0, import_react_ui_theme23.getSize)(6))
1894
+ }) : /* @__PURE__ */ import_react44.default.createElement(import_react43.X, {
1895
+ className: (0, import_react_ui_theme23.mx)("m-1.5", (0, import_react_ui_theme23.getSize)(6))
1896
+ })))), /* @__PURE__ */ import_react44.default.createElement(Actions, {
1897
+ classNames: "mbs-4"
1898
+ }, /* @__PURE__ */ import_react44.default.createElement(Action, {
1899
+ disabled: !active,
1900
+ onClick: () => send?.({
1901
+ type: "deselectInvitation"
1902
+ })
1903
+ }, t("back label"))));
1904
+ };
1905
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/steps/ConfirmReset.tsx";
1906
+ var ConfirmReset = ({ active, onCancel, onConfirm, mode }) => {
1907
+ const { t } = (0, import_react_ui21.useTranslation)("os");
1908
+ const [validationMessage, setValidationMessage] = (0, import_react46.useState)("");
1909
+ const [pending, setPending] = (0, import_react46.useState)(false);
1910
+ const processReset = async () => {
1911
+ setPending(true);
1912
+ return onConfirm?.().then(() => setPending(false), (error) => {
1913
+ import_log6.log.catch(error, void 0, {
1914
+ F: __dxlog_file5,
1915
+ L: 38,
1916
+ S: void 0,
1917
+ C: (f, a) => f(...a)
1918
+ });
1919
+ setValidationMessage(t("failed to reset identity message"));
1920
+ setPending(false);
1921
+ });
1922
+ };
1923
+ return /* @__PURE__ */ import_react46.default.createElement(ConfirmResetImpl, {
1924
+ disabled: !active,
1925
+ pending,
1926
+ validationMessage,
1927
+ onConfirm: processReset,
1928
+ onCancel,
1929
+ mode
1930
+ });
1931
+ };
1932
+ var ConfirmResetImpl = ({ disabled, pending, validationMessage, onConfirm, onCancel, mode }) => {
1933
+ const { t } = (0, import_react_ui21.useTranslation)("os");
1934
+ const confirmationValue = t("confirmation value");
1935
+ const [inputValue, setInputValue] = (0, import_react46.useState)("");
1936
+ const testIdAffix = mode === "join new identity" ? "join-new-identity" : mode === "recover" ? "recover" : "reset-storage";
1937
+ return /* @__PURE__ */ import_react46.default.createElement(import_react46.default.Fragment, null, /* @__PURE__ */ import_react46.default.createElement("div", {
1938
+ role: "none",
1939
+ className: "grow flex flex-col gap-2 justify-center"
1940
+ }, /* @__PURE__ */ import_react46.default.createElement(import_react_ui21.Message.Root, {
1941
+ valence: "error"
1942
+ }, /* @__PURE__ */ import_react46.default.createElement(import_react_ui21.Message.Title, null, /* @__PURE__ */ import_react46.default.createElement(import_react45.Warning, {
1943
+ className: (0, import_react_ui_theme24.mx)((0, import_react_ui_theme24.getSize)(6), "inline mie-2")
1944
+ }), t("sign out chooser title")), /* @__PURE__ */ import_react46.default.createElement(import_react_ui21.Message.Body, null, t("sign out chooser message"))), /* @__PURE__ */ import_react46.default.createElement(Input, {
1945
+ validationMessage,
1946
+ label: /* @__PURE__ */ import_react46.default.createElement(StepHeading, {
1947
+ className: "text-start mlb-2"
1948
+ }, t(mode === "join new identity" ? "join new identity input label" : mode === "recover" ? "recover reset input label" : "reset storage input label", {
1949
+ confirmationValue
1950
+ })),
1951
+ disabled,
1952
+ "data-testid": `${testIdAffix}.reset-identity-input`,
1953
+ placeholder: t("confirmation placeholder", {
1954
+ confirmationValue
1955
+ }),
1956
+ onChange: ({ target: { value } }) => setInputValue(value)
1957
+ })), /* @__PURE__ */ import_react46.default.createElement(Actions, null, onCancel && /* @__PURE__ */ import_react46.default.createElement(Action, {
1958
+ disabled,
1959
+ onClick: onCancel,
1960
+ "data-testid": `${testIdAffix}.reset-identity-cancel`
1961
+ }, t("cancel label")), onConfirm && /* @__PURE__ */ import_react46.default.createElement(Action, {
1962
+ variant: "destructive",
1963
+ disabled: disabled || pending || inputValue !== confirmationValue,
1964
+ onClick: onConfirm,
1965
+ "data-testid": `${testIdAffix}.reset-identity-confirm`
1966
+ }, pending ? t("reset in progress label") : t("reset device label"))));
1967
+ };
1968
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/IdentityPanel.tsx";
1969
+ var viewStyles = "pbs-1 pbe-3 pli-3";
1970
+ var getHueValue = (identity) => identity?.profile?.data?.hue || (0, import_util5.hexToHue)(identity?.identityKey.toHex() ?? "0");
1971
+ var getEmojiValue = (identity) => identity?.profile?.data?.emoji || (0, import_util5.hexToEmoji)(identity?.identityKey.toHex() ?? "0");
1972
+ var IdentityHeading = ({ titleId, title, identity, hideRecover, onDone, onUpdateProfile, connectionState, onChangeConnectionState }) => {
1973
+ const client = (0, import_react_client2.useClient)();
1974
+ const fallbackValue = (0, import_util5.keyToFallback)(identity.identityKey);
1975
+ const { t } = (0, import_react_ui18.useTranslation)("os");
1976
+ const [displayName, setDisplayName] = (0, import_react37.useState)(identity.profile?.displayName ?? "");
1977
+ const [emoji, setEmojiDirectly] = (0, import_react37.useState)(getEmojiValue(identity));
1978
+ const [hue, setHueDirectly] = (0, import_react37.useState)(getHueValue(identity));
1979
+ const { textValue, setTextValue } = useClipboardContext();
1980
+ const identityHex = identity.identityKey.toHex();
1981
+ const publicKeyCopied = textValue === identityHex;
1982
+ const setEmoji = (nextEmoji) => {
1983
+ setEmojiDirectly(nextEmoji);
1984
+ void onUpdateProfile?.({
1985
+ ...identity.profile,
1986
+ data: {
1987
+ ...identity.profile?.data,
1988
+ emoji: nextEmoji
1989
+ }
1990
+ });
1991
+ };
1992
+ const setHue = (nextHue) => {
1993
+ setHueDirectly(nextHue);
1994
+ void onUpdateProfile?.({
1995
+ ...identity.profile,
1996
+ data: {
1997
+ ...identity.profile?.data,
1998
+ hue: nextHue
1999
+ }
2000
+ });
2001
+ };
2002
+ const handleRecoveryCode = async () => {
2003
+ (0, import_invariant.invariant)(client.services.services.IdentityService, "IdentityService not available", {
2004
+ F: __dxlog_file6,
2005
+ L: 77,
2006
+ S: void 0,
2007
+ A: [
2008
+ "client.services.services.IdentityService",
2009
+ "'IdentityService not available'"
2010
+ ]
2011
+ });
2012
+ const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
2013
+ void setTextValue(seedphrase);
2014
+ };
2015
+ const isConnected = connectionState === import_mesh2.ConnectionState.ONLINE;
2016
+ return /* @__PURE__ */ import_react37.default.createElement(Heading, {
2017
+ titleId,
2018
+ title,
2019
+ corner: /* @__PURE__ */ import_react37.default.createElement(CloseButton, {
2020
+ onDone
2021
+ })
2022
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Root, {
2023
+ size: 16,
2024
+ variant: "circle",
2025
+ status: isConnected ? "active" : "error",
2026
+ hue: hue || fallbackValue.hue
2027
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Root, {
2028
+ classNames: "flex justify-center"
2029
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Frame, {
2030
+ classNames: "relative z-[2] -mli-4 chromatic-ignore"
2031
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Fallback, {
2032
+ text: emoji || fallbackValue.emoji
2033
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Label, {
2034
+ classNames: "sr-only",
2035
+ "data-testid": "identityHeading.displayName"
2036
+ }, identity.profile?.displayName ?? (0, import_display_name3.generateName)(identity.identityKey.toHex())), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Input.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Input.Label, {
2037
+ srOnly: true
2038
+ }, t("display name input label")), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Input.TextInput, {
2039
+ variant: "subdued",
2040
+ "data-testid": "display-name-input",
2041
+ placeholder: t("display name input placeholder"),
2042
+ classNames: "mbs-2 text-center font-light text-xl",
2043
+ value: displayName,
2044
+ onChange: ({ target: { value } }) => setDisplayName(value),
2045
+ onBlur: ({ target: { value } }) => onUpdateProfile?.({
2046
+ ...identity.profile,
2047
+ displayName: value
2048
+ })
2049
+ })), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Root, {
2050
+ classNames: "flex justify-center items-center gap-1 pt-3"
2051
+ }, /* @__PURE__ */ import_react37.default.createElement(EmojiPickerToolbarButton, {
2052
+ emoji,
2053
+ onChangeEmoji: setEmoji,
2054
+ classNames: "bs-[--rail-action]"
2055
+ }), /* @__PURE__ */ import_react37.default.createElement(HuePickerToolbarButton, {
2056
+ hue,
2057
+ onChangeHue: setHue,
2058
+ classNames: "bs-[--rail-action]"
2059
+ }), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Trigger, {
2060
+ asChild: true
2061
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Button, {
2062
+ classNames: "bs-[--rail-action]",
2063
+ "data-testid": "update-profile-form-copy-key",
2064
+ onClick: () => setTextValue(identityHex)
2065
+ }, /* @__PURE__ */ import_react37.default.createElement("span", {
2066
+ className: "sr-only"
2067
+ }, t(publicKeyCopied ? "copy success label" : "copy self public key label")), /* @__PURE__ */ import_react37.default.createElement(import_react36.Key, {
2068
+ className: (0, import_react_ui_theme22.getSize)(5)
2069
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Portal, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Content, {
2070
+ side: "bottom",
2071
+ classNames: "z-50"
2072
+ }, t(publicKeyCopied ? "copy success label" : "copy self public key label"), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Arrow, null)))), !hideRecover && /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Trigger, {
2073
+ asChild: true
2074
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Button, {
2075
+ classNames: "bs-[--rail-action]",
2076
+ onClick: handleRecoveryCode
2077
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react36.FirstAidKit, {
2078
+ className: (0, import_react_ui_theme22.getSize)(5)
2079
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Portal, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Content, {
2080
+ side: "bottom",
2081
+ classNames: "z-50"
2082
+ }, t("create recovery code label"), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Arrow, null)))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Trigger, {
2083
+ asChild: true
2084
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Button, {
2085
+ classNames: [
2086
+ "bs-[--rail-action]",
2087
+ !isConnected && "text-error-500"
2088
+ ],
2089
+ onClick: () => onChangeConnectionState?.(isConnected ? import_mesh2.ConnectionState.OFFLINE : import_mesh2.ConnectionState.ONLINE)
2090
+ }, /* @__PURE__ */ import_react37.default.createElement("span", {
2091
+ className: "sr-only"
2092
+ }, t(isConnected ? "disconnect label" : "connect label")), isConnected ? /* @__PURE__ */ import_react37.default.createElement(import_react36.PlugsConnected, {
2093
+ className: (0, import_react_ui_theme22.getSize)(5)
2094
+ }) : /* @__PURE__ */ import_react37.default.createElement(import_react36.Plugs, {
2095
+ className: (0, import_react_ui_theme22.getSize)(5)
2096
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Portal, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Content, {
2097
+ side: "bottom",
2098
+ classNames: "z-50"
2099
+ }, t(isConnected ? "disconnect label" : "connect label"), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Arrow, null)))))));
2100
+ };
2101
+ var IdentityPanelImpl = (props) => {
2102
+ const { identity, titleId, activeView, onUpdateProfile, onResetStorage, onRecover, onJoinNewIdentity, IdentityActionChooser: IdentityActionChooserComponent = IdentityActionChooser, InvitationManager: InvitationManagerComponent = InvitationManager, connectionState, onChangeConnectionState, onDone, ...rest } = props;
2103
+ const { t } = (0, import_react_ui18.useTranslation)("os");
2104
+ const title = (0, import_react37.useMemo)(() => {
2105
+ switch (activeView) {
2106
+ case "device invitation manager":
2107
+ return t("choose add device label");
2108
+ default:
2109
+ return t("identity heading");
2110
+ }
2111
+ }, [
2112
+ activeView,
2113
+ t
2114
+ ]);
2115
+ const onCancelReset = () => rest.send?.("unchooseAction");
2116
+ const hideRecover = rest.agentStatus !== "created";
2117
+ return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement(IdentityHeading, {
2118
+ identity,
2119
+ titleId,
2120
+ title,
2121
+ hideRecover,
2122
+ onDone,
2123
+ onUpdateProfile,
2124
+ connectionState,
2125
+ onChangeConnectionState
2126
+ }), /* @__PURE__ */ import_react37.default.createElement(Viewport.Root, {
2127
+ activeView
2128
+ }, /* @__PURE__ */ import_react37.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2129
+ id: "identity action chooser",
2130
+ classNames: viewStyles
2131
+ }, /* @__PURE__ */ import_react37.default.createElement(IdentityActionChooserComponent, {
2132
+ active: activeView === "identity action chooser",
2133
+ ...rest,
2134
+ connectionState
2135
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2136
+ id: "device invitation manager",
2137
+ classNames: viewStyles
2138
+ }, /* @__PURE__ */ import_react37.default.createElement(InvitationManagerComponent, {
2139
+ active: activeView === "device invitation manager",
2140
+ ...rest,
2141
+ invitationUrl: rest.createInvitationUrl(rest.invitationCode)
2142
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2143
+ classNames: viewStyles,
2144
+ id: "confirm join new identity"
2145
+ }, /* @__PURE__ */ import_react37.default.createElement(ConfirmReset, {
2146
+ active: activeView === "confirm join new identity",
2147
+ ...rest,
2148
+ mode: "join new identity",
2149
+ onConfirm: onJoinNewIdentity,
2150
+ onCancel: onCancelReset
2151
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2152
+ classNames: viewStyles,
2153
+ id: "confirm recover"
2154
+ }, /* @__PURE__ */ import_react37.default.createElement(ConfirmReset, {
2155
+ active: activeView === "confirm recover",
2156
+ ...rest,
2157
+ mode: "recover",
2158
+ onConfirm: onRecover,
2159
+ onCancel: onCancelReset
2160
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2161
+ classNames: viewStyles,
2162
+ id: "confirm reset storage"
2163
+ }, /* @__PURE__ */ import_react37.default.createElement(ConfirmReset, {
2164
+ active: activeView === "confirm reset storage",
2165
+ ...rest,
2166
+ mode: "reset storage",
2167
+ onConfirm: onResetStorage,
2168
+ onCancel: onCancelReset
2169
+ })))));
2170
+ };
2171
+ var IdentityPanelWithInvitationImpl = ({ invitation, ...props }) => {
2172
+ const invitationStatus = (0, import_invitations2.useInvitationStatus)(invitation);
2173
+ return /* @__PURE__ */ import_react37.default.createElement(IdentityPanelImpl, {
2174
+ ...props,
2175
+ ...invitationStatus
2176
+ });
2177
+ };
2178
+ var IdentityPanel = ({ titleId: propsTitleId, createInvitationUrl = (code) => code, initialDisposition = "default", ...props }) => {
2179
+ const titleId = (0, import_react_ui18.useId)("identityPanel__heading", propsTitleId);
2180
+ const client = (0, import_react_client2.useClient)();
2181
+ const devices = (0, import_halo2.useDevices)();
2182
+ const identity = (0, import_halo2.useIdentity)();
2183
+ const invitations = (0, import_halo2.useHaloInvitations)();
2184
+ const agentProps = useAgentHandlers({
2185
+ identity,
2186
+ invitations
2187
+ });
2188
+ if (!identity) {
2189
+ import_log.log.error("IdentityPanel rendered with no active identity.", void 0, {
2190
+ F: __dxlog_file6,
2191
+ L: 288,
2192
+ S: void 0,
2193
+ C: (f, a) => f(...a)
2194
+ });
2195
+ return null;
2196
+ }
2197
+ const [identityState, identitySend, identityService] = useIdentityMachine(client, {
2198
+ context: {
2199
+ initialDisposition
2200
+ }
2201
+ });
2202
+ const { swarm: connectionState } = (0, import_mesh2.useNetworkStatus)();
2203
+ const handleChangeConnectionState = async (nextState) => client?.mesh.updateConfig(nextState);
2204
+ (0, import_react37.useEffect)(() => {
2205
+ const subscription = identityService.subscribe((state) => {
2206
+ (0, import_log.log)("[state]", state, {
2207
+ F: __dxlog_file6,
2208
+ L: 301,
2209
+ S: void 0,
2210
+ C: (f, a) => f(...a)
2211
+ });
2212
+ });
2213
+ return subscription.unsubscribe;
2214
+ }, [
2215
+ identityService
2216
+ ]);
2217
+ const activeView = (0, import_react37.useMemo)(() => {
2218
+ switch (true) {
2219
+ case identityState.matches("choosingAction"):
2220
+ return "identity action chooser";
2221
+ case identityState.matches("managingDeviceInvitation"):
2222
+ return "device invitation manager";
2223
+ case identityState.matches("confirmingResetStorage"):
2224
+ return "confirm reset storage";
2225
+ case identityState.matches("confirmingRecover"):
2226
+ return "confirm recover";
2227
+ case identityState.matches("confirmingJoinNewIdentity"):
2228
+ return "confirm join new identity";
2229
+ default:
2230
+ return "identity action chooser";
2231
+ }
2232
+ }, [
2233
+ identityState
2234
+ ]);
2235
+ const onUpdateProfile = async (profile) => {
2236
+ identitySend({
2237
+ type: "updateProfile"
2238
+ });
2239
+ await client.halo.updateProfile(profile);
2240
+ };
2241
+ const implProps = {
2242
+ ...props,
2243
+ identity,
2244
+ devices,
2245
+ activeView,
2246
+ send: identitySend,
2247
+ titleId,
2248
+ createInvitationUrl,
2249
+ onUpdateProfile,
2250
+ connectionState,
2251
+ onChangeConnectionState: handleChangeConnectionState,
2252
+ ...agentProps
2253
+ };
2254
+ return identityState.context.invitation ? /* @__PURE__ */ import_react37.default.createElement(IdentityPanelWithInvitationImpl, {
2255
+ ...implProps,
2256
+ invitation: identityState.context.invitation
2257
+ }) : /* @__PURE__ */ import_react37.default.createElement(IdentityPanelImpl, implProps);
2258
+ };
2259
+ var JoinHeading = /* @__PURE__ */ (0, import_react49.forwardRef)(({ mode, titleId, exitActionParent, onExit }, forwardedRef) => {
2260
+ const { t } = (0, import_react_ui23.useTranslation)("os");
2261
+ const exitButton = /* @__PURE__ */ import_react49.default.createElement(import_react_ui23.Button, {
2262
+ variant: "ghost",
2263
+ ...onExit && {
2264
+ onClick: onExit
2265
+ },
2266
+ classNames: (0, import_react_ui_theme25.mx)(import_react_ui_theme25.descriptionText, "plb-0 pli-2 absolute block-start-0 inline-end-0 z-[1]"),
2267
+ "data-testid": "join-exit"
2268
+ }, /* @__PURE__ */ import_react49.default.createElement(import_react48.X, {
2269
+ weight: "bold",
2270
+ className: (0, import_react_ui_theme25.getSize)(4)
2271
+ }), /* @__PURE__ */ import_react49.default.createElement("span", {
2272
+ className: "sr-only"
2273
+ }, t("exit label")));
2274
+ return /* @__PURE__ */ import_react49.default.createElement(Heading, {
2275
+ ref: forwardedRef,
2276
+ titleId,
2277
+ title: t(mode === "halo-only" ? "selecting identity heading" : "joining space heading"),
2278
+ ...mode === "halo-only" ? {
2279
+ titleSrOnly: true
2280
+ } : {
2281
+ corner: exitActionParent ? /* @__PURE__ */ (0, import_react49.cloneElement)(exitActionParent, {}, exitButton) : exitButton
2282
+ },
2283
+ titleSrOnly: mode === "halo-only"
2284
+ });
2285
+ });
2286
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/joinMachine.ts";
2287
+ var getInvitationSubscribable = (Kind, invitation) => {
2288
+ (0, import_log8.log)("[subscribing to invitation]", invitation, {
2289
+ F: __dxlog_file7,
2290
+ L: 90,
2291
+ S: void 0,
2292
+ C: (f, a) => f(...a)
2293
+ });
2294
+ return {
2295
+ subscribe: (next, onError, complete) => invitation.subscribe((invitation2) => {
2296
+ switch (invitation2.state) {
2297
+ case import_invitations6.Invitation.State.CONNECTING: {
2298
+ (0, import_log8.log)("[invitation connecting]", {
2299
+ Kind,
2300
+ invitation: invitation2
2301
+ }, {
2302
+ F: __dxlog_file7,
2303
+ L: 101,
2304
+ S: void 0,
2305
+ C: (f, a) => f(...a)
2306
+ });
2307
+ return next({
2308
+ type: `connecting${Kind}Invitation`,
2309
+ invitation: invitation2
2310
+ });
2311
+ }
2312
+ case import_invitations6.Invitation.State.CONNECTED: {
2313
+ (0, import_log8.log)("[invitation connected]", {
2314
+ Kind,
2315
+ invitation: invitation2
2316
+ }, {
2317
+ F: __dxlog_file7,
2318
+ L: 106,
2319
+ S: void 0,
2320
+ C: (f, a) => f(...a)
2321
+ });
2322
+ return next({
2323
+ type: `connected${Kind}Invitation`,
2324
+ invitation: invitation2
2325
+ });
2326
+ }
2327
+ case import_invitations6.Invitation.State.READY_FOR_AUTHENTICATION: {
2328
+ (0, import_log8.log)("[invitation ready for authentication]", {
2329
+ Kind,
2330
+ invitation: invitation2
2331
+ }, {
2332
+ F: __dxlog_file7,
2333
+ L: 111,
2334
+ S: void 0,
2335
+ C: (f, a) => f(...a)
2336
+ });
2337
+ return next({
2338
+ type: `readyForAuthentication${Kind}Invitation`,
2339
+ invitation: invitation2
2340
+ });
2341
+ }
2342
+ case import_invitations6.Invitation.State.AUTHENTICATING: {
2343
+ (0, import_log8.log)("[invitation authenticating]", {
2344
+ Kind,
2345
+ invitation: invitation2
2346
+ }, {
2347
+ F: __dxlog_file7,
2348
+ L: 116,
2349
+ S: void 0,
2350
+ C: (f, a) => f(...a)
2351
+ });
2352
+ return next({
2353
+ type: `authenticating${Kind}Invitation`,
2354
+ invitation: invitation2
2355
+ });
2356
+ }
2357
+ case import_invitations6.Invitation.State.SUCCESS: {
2358
+ (0, import_log8.log)("[invitation success]", {
2359
+ Kind,
2360
+ invitation: invitation2
2361
+ }, {
2362
+ F: __dxlog_file7,
2363
+ L: 121,
2364
+ S: void 0,
2365
+ C: (f, a) => f(...a)
2366
+ });
2367
+ next({
2368
+ type: `success${Kind}Invitation`,
2369
+ invitation: invitation2
2370
+ });
2371
+ return complete?.();
2372
+ }
2373
+ case import_invitations6.Invitation.State.CANCELLED: {
2374
+ import_log8.log.warn("[invitation cancelled]", {
2375
+ Kind
2376
+ }, {
2377
+ F: __dxlog_file7,
2378
+ L: 127,
2379
+ S: void 0,
2380
+ C: (f, a) => f(...a)
2381
+ });
2382
+ return next({
2383
+ type: `fail${Kind}Invitation`,
2384
+ reason: "cancelled"
2385
+ });
2386
+ }
2387
+ case import_invitations6.Invitation.State.TIMEOUT: {
2388
+ import_log8.log.error("[invitation timeout]", {
2389
+ Kind
2390
+ }, {
2391
+ F: __dxlog_file7,
2392
+ L: 132,
2393
+ S: void 0,
2394
+ C: (f, a) => f(...a)
2395
+ });
2396
+ return next({
2397
+ type: `fail${Kind}Invitation`,
2398
+ reason: "timeout"
2399
+ });
2400
+ }
2401
+ }
2402
+ }, (error) => {
2403
+ if (error instanceof import_react_client8.AlreadyJoinedError) {
2404
+ (0, import_log8.log)("[already joined]", {
2405
+ Kind,
2406
+ error
2407
+ }, {
2408
+ F: __dxlog_file7,
2409
+ L: 139,
2410
+ S: void 0,
2411
+ C: (f, a) => f(...a)
2412
+ });
2413
+ next({
2414
+ type: `success${Kind}Invitation`,
2415
+ invitation: invitation.get()
2416
+ });
2417
+ return complete?.();
2418
+ }
2419
+ import_log8.log.error("[invitation errored]", {
2420
+ Kind,
2421
+ error
2422
+ }, {
2423
+ F: __dxlog_file7,
2424
+ L: 144,
2425
+ S: void 0,
2426
+ C: (f, a) => f(...a)
2427
+ });
2428
+ next({
2429
+ type: `fail${Kind}Invitation`,
2430
+ reason: "error"
2431
+ });
2432
+ return onError?.(error);
2433
+ })
2434
+ };
2435
+ };
2436
+ var acceptingInvitationTemplate = (Kind, successTarget) => {
2437
+ const config = {
2438
+ initial: `unknown${Kind}`,
2439
+ states: {
2440
+ [`unknown${Kind}`]: {
2441
+ always: [
2442
+ {
2443
+ cond: ({ mode }) => mode === "halo-only" && Kind === "Space",
2444
+ target: "#join.finishingJoiningHalo"
2445
+ },
2446
+ {
2447
+ cond: (context) => !!context[Kind.toLowerCase()].unredeemedCode,
2448
+ target: `acceptingRedeemed${Kind}Invitation`,
2449
+ actions: [
2450
+ `redeem${Kind}InvitationCode`,
2451
+ `invalidate${Kind}InvitationCode`,
2452
+ "log"
2453
+ ]
2454
+ },
2455
+ {
2456
+ target: `inputting${Kind}InvitationCode`,
2457
+ actions: "log"
2458
+ }
2459
+ ]
2460
+ },
2461
+ [`inputting${Kind}InvitationCode`]: {},
2462
+ [`acceptingRedeemed${Kind}Invitation`]: {
2463
+ invoke: {
2464
+ src: (context) => context[Kind.toLowerCase()].invitationSubscribable
2465
+ },
2466
+ initial: `unknown${Kind}Invitation`,
2467
+ states: {
2468
+ [`unknown${Kind}Invitation`]: {
2469
+ always: [
2470
+ {
2471
+ cond: (context) => {
2472
+ if (Kind !== "Space") {
2473
+ return false;
2474
+ } else {
2475
+ const spaceKey = context.space.invitation?.spaceKey?.toHex();
2476
+ const succeededKeys = context.space.succeededKeys;
2477
+ return spaceKey ? !!succeededKeys?.has(spaceKey) : false;
2478
+ }
2479
+ },
2480
+ target: successTarget,
2481
+ actions: "log"
2482
+ },
2483
+ {
2484
+ cond: (context) => {
2485
+ const invitation = context[Kind.toLowerCase()].invitation;
2486
+ return !invitation || invitation?.state === import_invitations6.Invitation.State.CONNECTING;
2487
+ },
2488
+ target: `connecting${Kind}Invitation`,
2489
+ actions: "log"
2490
+ },
2491
+ {
2492
+ target: `inputting${Kind}VerificationCode`,
2493
+ actions: "log"
2494
+ }
2495
+ ]
2496
+ },
2497
+ [`connecting${Kind}Invitation`]: {},
2498
+ [`inputting${Kind}VerificationCode`]: {},
2499
+ [`authenticating${Kind}VerificationCode`]: {
2500
+ on: {
2501
+ [`readyForAuthentication${Kind}Invitation`]: {
2502
+ target: `authenticationFailing${Kind}VerificationCode`,
2503
+ actions: [
2504
+ "setInvitation",
2505
+ "log"
2506
+ ]
2507
+ }
2508
+ }
2509
+ },
2510
+ [`authenticationFailing${Kind}VerificationCode`]: {},
2511
+ [`failing${Kind}Invitation`]: {},
2512
+ [`success${Kind}Invitation`]: {}
2513
+ },
2514
+ on: {
2515
+ [`reset${Kind}Invitation`]: {
2516
+ target: `#join${Kind === "Halo" ? ".choosingIdentity" : ""}.accepting${Kind}Invitation.unknown${Kind}`,
2517
+ actions: [
2518
+ "resetInvitation",
2519
+ "log"
2520
+ ]
2521
+ },
2522
+ [`connecting${Kind}Invitation`]: {
2523
+ target: `.connecting${Kind}Invitation`,
2524
+ actions: [
2525
+ "setInvitation",
2526
+ "log"
2527
+ ]
2528
+ },
2529
+ [`connected${Kind}Invitation`]: {
2530
+ target: `.connecting${Kind}Invitation`,
2531
+ actions: [
2532
+ "setInvitation",
2533
+ "log"
2534
+ ]
2535
+ },
2536
+ [`readyForAuthentication${Kind}Invitation`]: {
2537
+ target: `.inputting${Kind}VerificationCode`,
2538
+ actions: [
2539
+ "setInvitation",
2540
+ "log"
2541
+ ]
2542
+ },
2543
+ [`authenticating${Kind}Invitation`]: {
2544
+ target: `.authenticating${Kind}VerificationCode`,
2545
+ actions: [
2546
+ "setInvitation",
2547
+ "log"
2548
+ ]
2549
+ },
2550
+ [`success${Kind}Invitation`]: {
2551
+ target: successTarget,
2552
+ actions: [
2553
+ "setInvitation",
2554
+ "log"
2555
+ ]
2556
+ },
2557
+ [`fail${Kind}Invitation`]: {
2558
+ target: `.failing${Kind}Invitation`,
2559
+ actions: [
2560
+ (0, import_xstate2.assign)({
2561
+ [Kind.toLowerCase()]: (context, event) => ({
2562
+ ...context[Kind.toLowerCase()],
2563
+ failReason: event.reason
2564
+ })
2565
+ }),
2566
+ "log"
2567
+ ]
2568
+ }
2569
+ }
2570
+ }
2571
+ },
2572
+ on: {
2573
+ [`set${Kind}InvitationCode`]: {
2574
+ target: `.acceptingRedeemed${Kind}Invitation`,
2575
+ actions: [
2576
+ (0, import_xstate2.assign)({
2577
+ [Kind.toLowerCase()]: (context, event) => ({
2578
+ ...context[Kind.toLowerCase()],
2579
+ unredeemedCode: event.code,
2580
+ succeededKeys: event.succeededKeys
2581
+ })
2582
+ }),
2583
+ `redeem${Kind}InvitationCode`,
2584
+ `invalidate${Kind}InvitationCode`,
2585
+ "log"
2586
+ ]
2587
+ }
2588
+ }
2589
+ };
2590
+ return config;
2591
+ };
2592
+ var joinMachine = (0, import_xstate2.createMachine)({
2593
+ id: "join",
2594
+ predictableActionArguments: true,
2595
+ context: {
2596
+ initialDisposition: "default",
2597
+ mode: "default",
2598
+ identity: null,
2599
+ halo: {},
2600
+ space: {}
2601
+ },
2602
+ initial: "unknown",
2603
+ states: {
2604
+ unknown: {
2605
+ always: [
2606
+ {
2607
+ cond: "existingIdentity",
2608
+ target: "resettingIdentity",
2609
+ actions: "log"
2610
+ },
2611
+ {
2612
+ cond: "initiallyAcceptingHaloInvitation",
2613
+ target: "#join.choosingIdentity.acceptingHaloInvitation",
2614
+ actions: "log"
2615
+ },
2616
+ {
2617
+ cond: "initiallyRecoveringIdentity",
2618
+ target: "#join.choosingIdentity.recoveringIdentity",
2619
+ actions: "log"
2620
+ },
2621
+ {
2622
+ cond: "noSelectedIdentity",
2623
+ target: "choosingIdentity",
2624
+ actions: "log"
2625
+ },
2626
+ {
2627
+ target: "acceptingSpaceInvitation",
2628
+ actions: "log"
2629
+ }
2630
+ ]
2631
+ },
2632
+ // TODO(wittjosiah): Remove.
2633
+ choosingIdentity: {
2634
+ initial: "unknownAuthMethod",
2635
+ states: {
2636
+ unknownAuthMethod: {
2637
+ always: [
2638
+ {
2639
+ cond: "hasHaloUnredeemedCode",
2640
+ target: "acceptingHaloInvitation",
2641
+ actions: "log"
2642
+ },
2643
+ {
2644
+ target: "choosingAuthMethod",
2645
+ actions: "log"
2646
+ }
2647
+ ]
2648
+ },
2649
+ choosingAuthMethod: {},
2650
+ recoveringIdentity: {},
2651
+ creatingIdentity: {},
2652
+ acceptingHaloInvitation: acceptingInvitationTemplate("Halo", "#join.acceptingSpaceInvitation"),
2653
+ confirmingAddedIdentity: {}
2654
+ },
2655
+ on: {
2656
+ recoverIdentity: {
2657
+ target: ".recoveringIdentity",
2658
+ actions: "log"
2659
+ },
2660
+ createIdentity: {
2661
+ target: ".creatingIdentity",
2662
+ actions: "log"
2663
+ },
2664
+ acceptHaloInvitation: {
2665
+ target: ".acceptingHaloInvitation",
2666
+ actions: "log"
2667
+ },
2668
+ addIdentity: {
2669
+ target: ".confirmingAddedIdentity",
2670
+ actions: "log"
2671
+ },
2672
+ selectIdentity: {
2673
+ target: "acceptingSpaceInvitation",
2674
+ actions: [
2675
+ "setIdentity",
2676
+ "log"
2677
+ ]
2678
+ },
2679
+ deselectAuthMethod: {
2680
+ target: ".choosingAuthMethod",
2681
+ actions: "log"
2682
+ }
2683
+ }
2684
+ },
2685
+ // TODO(wittjosiah): Factor out to a machine handling recovery and device invitations.
2686
+ resettingIdentity: {},
2687
+ acceptingSpaceInvitation: acceptingInvitationTemplate("Space", "#join.finishingJoiningSpace"),
2688
+ finishingJoiningSpace: {
2689
+ type: "final"
2690
+ },
2691
+ finishingJoiningHalo: {
2692
+ type: "final"
2693
+ }
2694
+ },
2695
+ on: {
2696
+ resetIdentity: {
2697
+ target: "choosingIdentity",
2698
+ actions: "unsetIdentity"
2699
+ }
2700
+ }
2701
+ }, {
2702
+ guards: {
2703
+ existingIdentity: ({ identity, mode }, _event) => mode === "halo-only" && !!identity,
2704
+ noSelectedIdentity: ({ identity }, _event) => !identity,
2705
+ initiallyAcceptingHaloInvitation: ({ identity, initialDisposition }, _event) => !identity && initialDisposition === "accept-halo-invitation",
2706
+ initiallyRecoveringIdentity: ({ identity, initialDisposition }, _event) => !identity && initialDisposition === "recover-identity",
2707
+ hasHaloUnredeemedCode: ({ halo }, _event) => !!halo.unredeemedCode,
2708
+ noSpaceInvitation: ({ space }, _event) => !space.invitation && !space.unredeemedCode
2709
+ },
2710
+ actions: {
2711
+ setIdentity: (0, import_xstate2.assign)({
2712
+ identity: (context, event) => event.identity
2713
+ }),
2714
+ unsetIdentity: (0, import_xstate2.assign)({
2715
+ identity: () => null
2716
+ }),
2717
+ resetInvitation: (0, import_xstate2.assign)({
2718
+ halo: (context, event) => {
2719
+ if (event.type !== "resetHaloInvitation") {
2720
+ return context.halo;
2721
+ }
2722
+ if (context.halo.invitationObservable) {
2723
+ void context.halo.invitationObservable.cancel();
2724
+ }
2725
+ return {
2726
+ ...context.halo,
2727
+ invitation: void 0,
2728
+ invitationObservable: void 0,
2729
+ invitationSubscribable: void 0
2730
+ };
2731
+ },
2732
+ space: (context, event) => {
2733
+ if (event.type !== "resetSpaceInvitation") {
2734
+ return context.space;
2735
+ }
2736
+ if (context.space.invitationObservable) {
2737
+ void context.space.invitationObservable.cancel();
2738
+ }
2739
+ return {
2740
+ ...context.space,
2741
+ invitation: void 0,
2742
+ invitationObservable: void 0,
2743
+ invitationSubscribable: void 0
2744
+ };
2745
+ }
2746
+ }),
2747
+ setInvitation: (0, import_xstate2.assign)({
2748
+ halo: (context, event) => event.type.includes("Halo") ? {
2749
+ ...context.halo,
2750
+ invitation: event.invitation
2751
+ } : context.halo,
2752
+ space: (context, event) => event.type.includes("Space") ? {
2753
+ ...context.space,
2754
+ invitation: event.invitation
2755
+ } : context.space
2756
+ }),
2757
+ log: (context, event) => {
2758
+ (0, import_log8.log)("[transition]", {
2759
+ event,
2760
+ haloInvitation: context.halo.invitation,
2761
+ spaceInvitation: context.space.invitation
2762
+ }, {
2763
+ F: __dxlog_file7,
2764
+ L: 425,
2765
+ S: void 0,
2766
+ C: (f, a) => f(...a)
2767
+ });
2768
+ }
2769
+ }
2770
+ });
2771
+ var defaultCodeFromUrl = (invitationType, text) => {
2772
+ try {
2773
+ const searchParams = new URLSearchParams(text.substring(text.lastIndexOf("?")));
2774
+ return searchParams.get(`${invitationType}InvitationCode`) ?? searchParams.get(`${invitationType}Invitation`) ?? searchParams.get("invitationCode") ?? searchParams.get("invitation") ?? text;
2775
+ } catch (err) {
2776
+ import_log8.log.catch(err, void 0, {
2777
+ F: __dxlog_file7,
2778
+ L: 452,
2779
+ S: void 0,
2780
+ C: (f, a) => f(...a)
2781
+ });
2782
+ return text;
2783
+ }
2784
+ };
2785
+ var useJoinMachine = (client, options) => {
2786
+ const redeemHaloInvitationCode = (0, import_react51.useCallback)(({ halo }) => {
2787
+ if (halo.unredeemedCode) {
2788
+ try {
2789
+ const invitation = import_invitations6.InvitationEncoder.decode(defaultCodeFromUrl("halo", halo.unredeemedCode));
2790
+ const invitationObservable = client.halo.join(invitation);
2791
+ return {
2792
+ ...halo,
2793
+ invitationObservable,
2794
+ invitationSubscribable: getInvitationSubscribable("Halo", invitationObservable)
2795
+ };
2796
+ } catch (err) {
2797
+ import_log8.log.error("Could not redeem device invitation code", err, {
2798
+ F: __dxlog_file7,
2799
+ L: 473,
2800
+ S: void 0,
2801
+ C: (f, a) => f(...a)
2802
+ });
2803
+ return halo;
2804
+ }
2805
+ } else {
2806
+ return halo;
2807
+ }
2808
+ }, [
2809
+ client
2810
+ ]);
2811
+ const redeemSpaceInvitationCode = (0, import_react51.useCallback)(({ space }) => {
2812
+ if (space.unredeemedCode) {
2813
+ try {
2814
+ const invitation = import_invitations6.InvitationEncoder.decode(defaultCodeFromUrl("space", space.unredeemedCode));
2815
+ const invitationObservable = client.spaces.join(invitation);
2816
+ return {
2817
+ ...space,
2818
+ invitationObservable,
2819
+ invitationSubscribable: getInvitationSubscribable("Space", invitationObservable)
2820
+ };
2821
+ } catch (err) {
2822
+ import_log8.log.error("Could not redeem space invitation code", err, {
2823
+ F: __dxlog_file7,
2824
+ L: 495,
2825
+ S: void 0,
2826
+ C: (f, a) => f(...a)
2827
+ });
2828
+ return space;
2829
+ }
2830
+ } else {
2831
+ return space;
2832
+ }
2833
+ }, [
2834
+ client
2835
+ ]);
2836
+ const invalidateHaloInvitationCode = (0, import_react51.useCallback)(({ halo }) => {
2837
+ if (halo.unredeemedCode) {
2838
+ options?.onInvalidateInvitationCode?.(halo.unredeemedCode);
2839
+ return {
2840
+ ...halo,
2841
+ unredeemedCode: void 0
2842
+ };
2843
+ } else {
2844
+ return halo;
2845
+ }
2846
+ }, [
2847
+ options?.onInvalidateInvitationCode
2848
+ ]);
2849
+ const invalidateSpaceInvitationCode = (0, import_react51.useCallback)(({ space }) => {
2850
+ if (space.unredeemedCode) {
2851
+ options?.onInvalidateInvitationCode?.(space.unredeemedCode);
2852
+ return {
2853
+ ...space,
2854
+ unredeemedCode: void 0
2855
+ };
2856
+ } else {
2857
+ return space;
2858
+ }
2859
+ }, [
2860
+ options?.onInvalidateInvitationCode
2861
+ ]);
2862
+ return (0, import_react50.useMachine)(joinMachine, {
2863
+ ...options,
2864
+ actions: {
2865
+ ...options?.actions,
2866
+ redeemHaloInvitationCode: (0, import_xstate2.assign)({
2867
+ halo: redeemHaloInvitationCode
2868
+ }),
2869
+ redeemSpaceInvitationCode: (0, import_xstate2.assign)({
2870
+ space: redeemSpaceInvitationCode
2871
+ }),
2872
+ invalidateHaloInvitationCode: (0, import_xstate2.assign)({
2873
+ halo: invalidateHaloInvitationCode
2874
+ }),
2875
+ invalidateSpaceInvitationCode: (0, import_xstate2.assign)({
2876
+ space: invalidateSpaceInvitationCode
2877
+ })
2878
+ }
2879
+ });
2880
+ };
2881
+ var AdditionMethodChooser = (viewStateProps) => {
2882
+ const disabled = !viewStateProps.active;
2883
+ const { send } = viewStateProps;
2884
+ const { t } = (0, import_react_ui24.useTranslation)("os");
2885
+ const sharedButtonProps = {
2886
+ disabled,
2887
+ after: /* @__PURE__ */ import_react53.default.createElement(import_react52.CaretRight, {
2888
+ className: (0, import_react_ui_theme26.getSize)(4),
2889
+ weight: "bold"
2890
+ }),
2891
+ slots: {
2892
+ label: {
2893
+ className: "text-sm"
2894
+ }
2895
+ }
2896
+ };
2897
+ return /* @__PURE__ */ import_react53.default.createElement(import_react53.default.Fragment, null, /* @__PURE__ */ import_react53.default.createElement(StepHeading, null, t("addition method chooser title")), /* @__PURE__ */ import_react53.default.createElement("div", {
2898
+ role: "none",
2899
+ className: "flex flex-col gap-1 grow"
2900
+ }, /* @__PURE__ */ import_react53.default.createElement(CompoundButton, {
2901
+ ...sharedButtonProps,
2902
+ description: t("create identity description"),
2903
+ before: /* @__PURE__ */ import_react53.default.createElement(import_react52.Plus, {
2904
+ className: (0, import_react_ui_theme26.getSize)(6)
2905
+ }),
2906
+ onClick: () => send({
2907
+ type: "createIdentity"
2908
+ }),
2909
+ "data-autofocus": "choosingAuthMethod",
2910
+ "data-testid": "identity-chooser.create-identity"
2911
+ }, t("create identity label")), /* @__PURE__ */ import_react53.default.createElement(CompoundButton, {
2912
+ ...sharedButtonProps,
2913
+ description: t("join identity description"),
2914
+ before: /* @__PURE__ */ import_react53.default.createElement(import_react52.QrCode, {
2915
+ className: (0, import_react_ui_theme26.getSize)(6)
2916
+ }),
2917
+ onClick: () => send({
2918
+ type: "acceptHaloInvitation"
2919
+ }),
2920
+ "data-testid": "identity-chooser.join-identity"
2921
+ }, t("join identity label")), /* @__PURE__ */ import_react53.default.createElement(CompoundButton, {
2922
+ ...sharedButtonProps,
2923
+ description: t("recover identity description"),
2924
+ before: /* @__PURE__ */ import_react53.default.createElement(import_react52.Textbox, {
2925
+ className: (0, import_react_ui_theme26.getSize)(6)
2926
+ }),
2927
+ onClick: () => send({
2928
+ type: "recoverIdentity"
2929
+ }),
2930
+ "data-testid": "identity-chooser.recover-identity"
2931
+ }, t("recover identity label"))));
2932
+ };
2933
+ var IdentityAdded = (props) => {
2934
+ const { mode, addedIdentity, active, send, onDone, doneActionParent } = props;
2935
+ const disabled = !active;
2936
+ const { t } = (0, import_react_ui25.useTranslation)("os");
2937
+ const addedIdentityHex = addedIdentity?.identityKey.toHex() ?? "0";
2938
+ const fallbackValue = (0, import_util8.hexToFallback)(addedIdentityHex);
2939
+ const labelId = (0, import_react_ui25.useId)("identityListItem__label");
2940
+ const displayName = addedIdentity?.profile?.displayName ?? (addedIdentity && (0, import_display_name4.generateName)(addedIdentityHex));
2941
+ const doneAction = /* @__PURE__ */ import_react54.default.createElement(Action, {
2942
+ ...onDone && {
2943
+ onClick: () => onDone(null)
2944
+ },
2945
+ disabled,
2946
+ "data-autofocus": "confirmingAddedIdentity",
2947
+ "data-testid": "identity-added-done"
2948
+ }, /* @__PURE__ */ import_react54.default.createElement("span", null, t("done label")));
2949
+ return /* @__PURE__ */ import_react54.default.createElement(import_react54.default.Fragment, null, /* @__PURE__ */ import_react54.default.createElement(StepHeading, null, t("identity added label")), /* @__PURE__ */ import_react54.default.createElement("div", {
2950
+ role: "none",
2951
+ className: "grow flex flex-col items-center justify-center text-center gap-2"
2952
+ }, /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Root, {
2953
+ status: "active",
2954
+ labelId,
2955
+ hue: addedIdentity?.profile?.data?.hue || fallbackValue.hue
2956
+ }, /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Frame, null, /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Fallback, {
2957
+ text: addedIdentity?.profile?.data?.emoji || fallbackValue.emoji
2958
+ })), /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Label, {
2959
+ classNames: (0, import_react_ui_theme27.mx)("text-lg truncate", !addedIdentity?.profile?.displayName && "font-mono")
2960
+ }, displayName))), /* @__PURE__ */ import_react54.default.createElement(Actions, null, mode === "halo-only" ? doneActionParent ? /* @__PURE__ */ (0, import_react54.cloneElement)(doneActionParent, {}, doneAction) : doneAction : /* @__PURE__ */ import_react54.default.createElement(Action, {
2961
+ variant: "primary",
2962
+ disabled: disabled || !addedIdentity,
2963
+ onClick: () => addedIdentity && send({
2964
+ type: "selectIdentity",
2965
+ identity: addedIdentity
2966
+ }),
2967
+ "data-autofocus": "confirmingAddedIdentity"
2968
+ }, t("continue label"))));
2969
+ };
2970
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/steps/IdentityInput.tsx";
2971
+ var IdentityInput = (props) => {
2972
+ const { send, method } = props;
2973
+ const isRecover = method === "recover identity";
2974
+ const client = (0, import_react_client9.useClient)();
2975
+ const { t } = (0, import_react_ui26.useTranslation)("os");
2976
+ const [validationMessage, setValidationMessage] = (0, import_react55.useState)("");
2977
+ const createIdentity = (value) => {
2978
+ if (isRecover) {
2979
+ void client.halo.recoverIdentity({
2980
+ seedphrase: value
2981
+ }).then((identity) => {
2982
+ send?.({
2983
+ type: "selectIdentity",
2984
+ identity
2985
+ });
2986
+ }, (error) => {
2987
+ import_log9.log.catch(error, void 0, {
2988
+ F: __dxlog_file8,
2989
+ L: 38,
2990
+ S: void 0,
2991
+ C: (f, a) => f(...a)
2992
+ });
2993
+ setValidationMessage(t("failed to recover identity message"));
2994
+ });
2995
+ } else {
2996
+ void client.halo.createIdentity({
2997
+ displayName: value
2998
+ }).then((identity) => {
2999
+ send?.({
3000
+ type: "selectIdentity",
3001
+ identity
3002
+ });
3003
+ }, (error) => {
3004
+ import_log9.log.catch(error, void 0, {
3005
+ F: __dxlog_file8,
3006
+ L: 48,
3007
+ S: void 0,
3008
+ C: (f, a) => f(...a)
3009
+ });
3010
+ setValidationMessage(t("failed to create identity message"));
3011
+ });
3012
+ }
3013
+ };
3014
+ return /* @__PURE__ */ import_react55.default.createElement(IdentityInputImpl, {
3015
+ ...props,
3016
+ onDisplayNameConfirm: createIdentity,
3017
+ validationMessage
3018
+ });
3019
+ };
3020
+ var IdentityInputImpl = (props) => {
3021
+ const { method, send, active, onDisplayNameConfirm, validationMessage } = props;
3022
+ const disabled = !active;
3023
+ const { t } = (0, import_react_ui26.useTranslation)("os");
3024
+ const [inputValue, setInputValue] = (0, import_react55.useState)("");
3025
+ const isRecover = method === "recover identity";
3026
+ return /* @__PURE__ */ import_react55.default.createElement(import_react55.default.Fragment, null, /* @__PURE__ */ import_react55.default.createElement("div", {
3027
+ role: "none",
3028
+ className: "grow flex flex-col justify-center"
3029
+ }, /* @__PURE__ */ import_react55.default.createElement(Input, {
3030
+ validationMessage,
3031
+ label: /* @__PURE__ */ import_react55.default.createElement(StepHeading, null, t(isRecover ? "recover identity input label" : "new identity input label")),
3032
+ disabled,
3033
+ "data-testid": "identity-input",
3034
+ placeholder: isRecover ? "Type your recovery phrase" : "Type a display name",
3035
+ onChange: ({ target: { value } }) => setInputValue(value)
3036
+ })), /* @__PURE__ */ import_react55.default.createElement(Actions, null, /* @__PURE__ */ import_react55.default.createElement(Action, {
3037
+ variant: "ghost",
3038
+ disabled,
3039
+ onClick: () => send?.({
3040
+ type: "deselectAuthMethod"
3041
+ }),
3042
+ "data-testid": `${method === "recover identity" ? "recover" : "create"}-identity-input-back`
3043
+ }, t("back label")), /* @__PURE__ */ import_react55.default.createElement(Action, {
3044
+ variant: "primary",
3045
+ disabled,
3046
+ onClick: () => onDisplayNameConfirm?.(inputValue),
3047
+ "data-testid": `${method === "recover identity" ? "recover" : "create"}-identity-input-continue`
3048
+ }, t("continue label"))));
3049
+ };
3050
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/steps/InvitationInput.tsx";
3051
+ var invitationCodeFromUrl = (text) => {
3052
+ try {
3053
+ const searchParams = new URLSearchParams(text.substring(text.lastIndexOf("?")));
3054
+ const invitation = searchParams.get("spaceInvitationCode") ?? searchParams.get("deviceInvitationCode");
3055
+ return invitation ?? text;
3056
+ } catch (err) {
3057
+ import_log10.log.catch(err, void 0, {
3058
+ F: __dxlog_file9,
3059
+ L: 25,
3060
+ S: void 0,
3061
+ C: (f, a) => f(...a)
3062
+ });
3063
+ return text;
3064
+ }
3065
+ };
3066
+ var InvitationInput = (props) => {
3067
+ const { Kind, active, send, unredeemedCode, onExit, exitActionParent, onDone, doneActionParent, succeededKeys } = props;
3068
+ const disabled = !active;
3069
+ const { t } = (0, import_react_ui28.useTranslation)("os");
3070
+ const [inputValue, setInputValue] = (0, import_react57.useState)(unredeemedCode ?? "");
3071
+ (0, import_react57.useEffect)(() => {
3072
+ unredeemedCode && setInputValue(unredeemedCode ?? "");
3073
+ }, [
3074
+ unredeemedCode
3075
+ ]);
3076
+ const handleNext = () => {
3077
+ if (inputValue.trim().length === 0) {
3078
+ return;
3079
+ }
3080
+ send({
3081
+ type: `set${Kind}InvitationCode`,
3082
+ code: invitationCodeFromUrl(inputValue),
3083
+ ...Kind === "Space" && {
3084
+ succeededKeys
3085
+ }
3086
+ });
3087
+ };
3088
+ const exitAction = /* @__PURE__ */ import_react57.default.createElement(Action, {
3089
+ variant: "ghost",
3090
+ disabled,
3091
+ ...onExit ? {
3092
+ onClick: () => onExit()
3093
+ } : {
3094
+ onClick: () => onDone?.(null)
3095
+ },
3096
+ "data-testid": "join-exit"
3097
+ }, t("cancel label"));
3098
+ return /* @__PURE__ */ import_react57.default.createElement(import_react57.default.Fragment, null, /* @__PURE__ */ import_react57.default.createElement("div", {
3099
+ role: "none",
3100
+ className: "grow flex flex-col justify-center"
3101
+ }, /* @__PURE__ */ import_react57.default.createElement(Input, {
3102
+ label: /* @__PURE__ */ import_react57.default.createElement(StepHeading, null, t("invitation input label")),
3103
+ // TODO(burdon): Translation.
3104
+ placeholder: "Type an invitation code",
3105
+ disabled,
3106
+ value: inputValue,
3107
+ onChange: ({ target: { value } }) => setInputValue(value),
3108
+ "data-autofocus": `inputting${Kind}InvitationCode`,
3109
+ "data-testid": `${Kind.toLowerCase()}-invitation-input`,
3110
+ onKeyUp: ({ key }) => key === "Enter" && handleNext()
3111
+ })), /* @__PURE__ */ import_react57.default.createElement(Actions, null, Kind === "Halo" ? null : exitActionParent ? /* @__PURE__ */ (0, import_react57.cloneElement)(exitActionParent, {}, exitAction) : doneActionParent ? /* @__PURE__ */ (0, import_react57.cloneElement)(doneActionParent, {}, exitAction) : exitAction, /* @__PURE__ */ import_react57.default.createElement(Action, {
3112
+ variant: "primary",
3113
+ disabled: disabled || inputValue.trim().length === 0,
3114
+ onClick: handleNext,
3115
+ "data-testid": `${Kind.toLowerCase()}-invitation-input-continue`
3116
+ }, t("continue label"))));
3117
+ };
3118
+ var InvitationActions = ({
3119
+ // `invitationState` does report correct state, but here we evaluate whether `failReason` is a better source of truth
3120
+ // for the UI in particular.
3121
+ invitationState,
3122
+ onInvitationCancel,
3123
+ active,
3124
+ send,
3125
+ Kind,
3126
+ failReason
3127
+ }) => {
3128
+ const { t } = (0, import_react_ui29.useTranslation)("os");
3129
+ if (failReason) {
3130
+ return /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, /* @__PURE__ */ import_react58.default.createElement(StepHeading, {
3131
+ className: import_react_ui_theme28.descriptionText
3132
+ }, t(failReason === "timeout" ? "timeout status label" : failReason === "cancelled" ? "cancelled status label" : "error status label")), /* @__PURE__ */ import_react58.default.createElement("div", {
3133
+ role: "none",
3134
+ className: "grow"
3135
+ }), /* @__PURE__ */ import_react58.default.createElement(Actions, null, /* @__PURE__ */ import_react58.default.createElement(Action, {
3136
+ disabled: !active,
3137
+ onClick: () => send({
3138
+ type: `reset${Kind}Invitation`
3139
+ }),
3140
+ "data-testid": "invitation-rescuer-reset"
3141
+ }, t("reset label"))));
3142
+ } else {
3143
+ return /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, /* @__PURE__ */ import_react58.default.createElement(StepHeading, {
3144
+ className: import_react_ui_theme28.descriptionText
3145
+ }, t("connecting status label")), /* @__PURE__ */ import_react58.default.createElement("div", {
3146
+ role: "none",
3147
+ className: "grow"
3148
+ }), /* @__PURE__ */ import_react58.default.createElement(Actions, null, /* @__PURE__ */ import_react58.default.createElement(Action, {
3149
+ disabled: true,
3150
+ classNames: "order-2",
3151
+ "data-testid": "next"
3152
+ }, t("next label")), /* @__PURE__ */ import_react58.default.createElement(Action, {
3153
+ disabled: !active,
3154
+ onClick: onInvitationCancel,
3155
+ "data-testid": "invitation-rescuer-cancel"
3156
+ }, t("cancel label"))));
3157
+ }
3158
+ };
3159
+ var InvitationRescuer = (props) => {
3160
+ const { Kind, invitationState, active, send } = props;
3161
+ const { t } = (0, import_react_ui29.useTranslation)("os");
3162
+ return /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, typeof invitationState === "undefined" ? /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, /* @__PURE__ */ import_react58.default.createElement("div", {
3163
+ role: "none",
3164
+ className: "grow flex flex-col justify-center"
3165
+ }, /* @__PURE__ */ import_react58.default.createElement(StepHeading, {
3166
+ className: import_react_ui_theme28.descriptionText
3167
+ }, "There was a problem joining the space")), /* @__PURE__ */ import_react58.default.createElement(Actions, null, /* @__PURE__ */ import_react58.default.createElement(Action, {
3168
+ disabled: !active,
3169
+ "data-testid": "invitation-rescuer-blank-reset",
3170
+ onClick: () => send({
3171
+ type: `reset${Kind}Invitation`
3172
+ })
3173
+ }, t("reset label")))) : /* @__PURE__ */ import_react58.default.createElement(InvitationActions, props));
3174
+ };
3175
+ var pinLength = 6;
3176
+ var InvitationAuthenticator = ({ failed, Kind, authMethod, active, pending, invitationId, onInvitationAuthenticate, onInvitationCancel }) => {
3177
+ const disabled = !active || pending;
3178
+ const { t } = (0, import_react_ui30.useTranslation)("os");
3179
+ const invitationType = Kind.toLowerCase();
3180
+ const [authCode, setAuthCode] = (0, import_react59.useState)("");
3181
+ const onChange = ({ target: { value } }) => {
3182
+ setAuthCode(value);
3183
+ if (value.length === pinLength) {
3184
+ document.querySelector(`[data-autofocus-pinlength="${invitationType}"]`)?.focus();
3185
+ }
3186
+ };
3187
+ return /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, /* @__PURE__ */ import_react59.default.createElement("div", {
3188
+ role: "none",
3189
+ className: "grow flex flex-col justify-center gap-4"
3190
+ }, /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.Root, failed && {
3191
+ validationValence: "error"
3192
+ }, /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.Label, {
3193
+ asChild: true
3194
+ }, authMethod === import_invitations7.Invitation.AuthMethod.SHARED_SECRET ? /* @__PURE__ */ import_react59.default.createElement(StepHeading, null, t("auth code input label")) : /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, /* @__PURE__ */ import_react59.default.createElement(StepHeading, {
3195
+ className: import_react_ui_theme29.descriptionText
3196
+ }, t("authenticating label")), /* @__PURE__ */ import_react59.default.createElement("div", {
3197
+ role: "none",
3198
+ className: "grow"
3199
+ }))), authMethod === import_invitations7.Invitation.AuthMethod.SHARED_SECRET && /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.PinInput, {
3200
+ disabled,
3201
+ length: pinLength,
3202
+ onChange,
3203
+ inputMode: "numeric",
3204
+ autoComplete: "off",
3205
+ pattern: "\\d*",
3206
+ "data-autofocus": `connecting${Kind}Invitation inputting${Kind}VerificationCode authenticationFailing${Kind}VerificationCode authenticating${Kind}VerificationCode`,
3207
+ "data-prevent-ios-autofocus": true,
3208
+ "data-testid": `${invitationType}-auth-code-input`,
3209
+ "data-1p-ignore": true
3210
+ }), failed && /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.DescriptionAndValidation, {
3211
+ classNames: "text-center"
3212
+ }, /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.Validation, null, t("failed to authenticate message")))), invitationId && authMethod === import_invitations7.Invitation.AuthMethod.SHARED_SECRET && /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, /* @__PURE__ */ import_react59.default.createElement(Label, null, t("auth other device emoji message")), /* @__PURE__ */ import_react59.default.createElement("div", {
3213
+ className: "flex justify-center"
3214
+ }, /* @__PURE__ */ import_react59.default.createElement(Emoji, {
3215
+ text: (0, import_util9.hexToEmoji)(invitationId)
3216
+ })))), /* @__PURE__ */ import_react59.default.createElement(Actions, null, /* @__PURE__ */ import_react59.default.createElement(Action, {
3217
+ variant: "ghost",
3218
+ disabled,
3219
+ onClick: () => onInvitationCancel?.(),
3220
+ "data-testid": `${invitationType}-invitation-authenticator-cancel`
3221
+ }, t("cancel label")), /* @__PURE__ */ import_react59.default.createElement(Action, {
3222
+ variant: "primary",
3223
+ disabled,
3224
+ onClick: () => onInvitationAuthenticate?.(authCode),
3225
+ "data-autofocus-pinlength": invitationType,
3226
+ "data-testid": `${invitationType}-invitation-authenticator-next`
3227
+ }, t("next label"))));
3228
+ };
3229
+ var stepStyles = "pbs-1 pbe-3 pli-3";
3230
+ var inactiveBgColor = "bg-neutral-100 dark:bg-neutral-600";
3231
+ var activeBgColor = "bg-primary-500 dark:bg-primary-400";
3232
+ var successBgColor = "bg-success-500 dark:bg-success-400";
3233
+ var errorBgColor = "bg-error-500 dark:bg-error-400";
3234
+ var cancelledBgColor = "bg-warning-500 dark:bg-warning-400";
3235
+ var inactiveTextColor = "text-neutral-100 dark:text-neutral-600";
3236
+ var activeTextColor = "text-primary-400 dark:text-primary-500";
3237
+ var successTextColor = "text-success-400 dark:text-success-500";
3238
+ var errorTextColor = "text-error-400 dark:text-error-500";
3239
+ var cancelledTextColor = "text-warning-400 dark:text-warning-500";
3240
+ var inactiveStrokeColor = "stroke-neutral-100 dark:stroke-neutral-700";
3241
+ var activeStrokeColor = "stroke-primary-400 dark:stroke-primary-150";
3242
+ var successStrokeColor = "stroke-success-300 dark:stroke-primary-400";
3243
+ var errorStrokeColor = "stroke-error-300 dark:stroke-error-500";
3244
+ var cancelledStrokeColor = "stroke-warning-300 dark:stroke-warning-500";
3245
+ var resolvedStrokeColor = (status) => status === import_invitations8.Invitation.State.ERROR ? errorStrokeColor : status === import_invitations8.Invitation.State.CANCELLED || status === import_invitations8.Invitation.State.TIMEOUT ? cancelledStrokeColor : successStrokeColor;
3246
+ var resolvedBgColor = (status) => status === import_invitations8.Invitation.State.ERROR ? errorBgColor : status === import_invitations8.Invitation.State.CANCELLED || status === import_invitations8.Invitation.State.TIMEOUT ? cancelledBgColor : successBgColor;
3247
+ var resolvedTextColor = (status) => status === import_invitations8.Invitation.State.ERROR ? errorTextColor : status === import_invitations8.Invitation.State.CANCELLED || status === import_invitations8.Invitation.State.TIMEOUT ? cancelledTextColor : successTextColor;
3248
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/JoinPanel.tsx";
3249
+ var JoinPanelImpl = (props) => {
3250
+ const {
3251
+ titleId,
3252
+ send,
3253
+ activeView,
3254
+ failed,
3255
+ mode,
3256
+ unredeemedCodes,
3257
+ invitationIds,
3258
+ invitationStates,
3259
+ invitationAuthMethods,
3260
+ succeededKeys,
3261
+ failReasons,
3262
+ onExit,
3263
+ onHaloDone,
3264
+ // onSpaceDone,
3265
+ exitActionParent,
3266
+ doneActionParent,
3267
+ onHaloInvitationCancel,
3268
+ onSpaceInvitationCancel,
3269
+ onHaloInvitationAuthenticate,
3270
+ onSpaceInvitationAuthenticate,
3271
+ onCancelResetStorage,
3272
+ onConfirmResetStorage,
3273
+ IdentityInput: IdentityInputComponent = IdentityInput,
3274
+ ConfirmReset: ConfirmResetComponent = ConfirmReset
3275
+ } = props;
3276
+ return /* @__PURE__ */ import_react47.default.createElement(import_react47.default.Fragment, null, mode !== "halo-only" && /* @__PURE__ */ import_react47.default.createElement(JoinHeading, {
3277
+ titleId,
3278
+ mode,
3279
+ onExit,
3280
+ exitActionParent
3281
+ }), /* @__PURE__ */ import_react47.default.createElement(Viewport.Root, {
3282
+ focusManaged: true,
3283
+ activeView
3284
+ }, /* @__PURE__ */ import_react47.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3285
+ classNames: stepStyles,
3286
+ id: "addition method chooser"
3287
+ }, /* @__PURE__ */ import_react47.default.createElement(AdditionMethodChooser, {
3288
+ send,
3289
+ active: activeView === "addition method chooser"
3290
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3291
+ classNames: stepStyles,
3292
+ id: "reset storage confirmation"
3293
+ }, /* @__PURE__ */ import_react47.default.createElement(ConfirmResetComponent, {
3294
+ send,
3295
+ active: activeView === "reset storage confirmation",
3296
+ onCancel: onCancelResetStorage,
3297
+ onConfirm: onConfirmResetStorage
3298
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3299
+ classNames: stepStyles,
3300
+ id: "create identity input"
3301
+ }, /* @__PURE__ */ import_react47.default.createElement(IdentityInputComponent, {
3302
+ send,
3303
+ method: "create identity",
3304
+ active: activeView === "create identity input"
3305
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3306
+ classNames: stepStyles,
3307
+ id: "recover identity input"
3308
+ }, /* @__PURE__ */ import_react47.default.createElement(IdentityInputComponent, {
3309
+ send,
3310
+ method: "recover identity",
3311
+ active: activeView === "recover identity input"
3312
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3313
+ classNames: stepStyles,
3314
+ id: "halo invitation input"
3315
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationInput, {
3316
+ send,
3317
+ Kind: "Halo",
3318
+ active: activeView === "halo invitation input",
3319
+ ...unredeemedCodes?.Halo && {
3320
+ unredeemedCode: unredeemedCodes.Halo
3321
+ },
3322
+ ...succeededKeys?.Halo && {
3323
+ succeededKeys: succeededKeys.Halo
3324
+ }
3325
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3326
+ classNames: stepStyles,
3327
+ id: "halo invitation rescuer"
3328
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationRescuer, {
3329
+ send,
3330
+ Kind: "Halo",
3331
+ active: activeView === "halo invitation rescuer",
3332
+ invitationState: invitationStates?.Halo,
3333
+ onInvitationCancel: onHaloInvitationCancel,
3334
+ failReason: failReasons?.Halo
3335
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3336
+ classNames: stepStyles,
3337
+ id: "halo invitation authenticator"
3338
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationAuthenticator, {
3339
+ send,
3340
+ Kind: "Halo",
3341
+ invitationId: invitationIds?.Halo,
3342
+ authMethod: invitationAuthMethods?.Halo,
3343
+ active: activeView === "halo invitation authenticator",
3344
+ onInvitationCancel: onHaloInvitationCancel,
3345
+ onInvitationAuthenticate: onHaloInvitationAuthenticate,
3346
+ ...failed.has("Halo") && {
3347
+ failed: true
3348
+ }
3349
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3350
+ classNames: stepStyles,
3351
+ id: "identity added"
3352
+ }, /* @__PURE__ */ import_react47.default.createElement(IdentityAdded, {
3353
+ send,
3354
+ mode,
3355
+ active: activeView === "identity added",
3356
+ doneActionParent,
3357
+ onDone: onHaloDone
3358
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3359
+ classNames: stepStyles,
3360
+ id: "space invitation input"
3361
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationInput, {
3362
+ send,
3363
+ Kind: "Space",
3364
+ active: activeView === "space invitation input",
3365
+ ...unredeemedCodes?.Space && {
3366
+ unredeemedCode: unredeemedCodes.Space
3367
+ },
3368
+ ...succeededKeys?.Space && {
3369
+ succeededKeys: succeededKeys.Space
3370
+ },
3371
+ onExit,
3372
+ exitActionParent
3373
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3374
+ classNames: stepStyles,
3375
+ id: "space invitation rescuer"
3376
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationRescuer, {
3377
+ send,
3378
+ Kind: "Space",
3379
+ active: activeView === "space invitation rescuer",
3380
+ invitationState: invitationStates?.Space,
3381
+ onInvitationCancel: onSpaceInvitationCancel,
3382
+ failReason: failReasons?.Space
3383
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3384
+ classNames: stepStyles,
3385
+ id: "space invitation authenticator"
3386
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationAuthenticator, {
3387
+ send,
3388
+ Kind: "Space",
3389
+ invitationId: invitationIds?.Space,
3390
+ authMethod: invitationAuthMethods?.Space,
3391
+ active: activeView === "space invitation authenticator",
3392
+ onInvitationCancel: onSpaceInvitationCancel,
3393
+ onInvitationAuthenticate: onSpaceInvitationAuthenticate,
3394
+ ...failed.has("Space") && {
3395
+ failed: true
3396
+ }
3397
+ })))));
3398
+ };
3399
+ var JoinPanel = ({ titleId: propsTitleId, mode = "default", initialDisposition = "default", initialInvitationCode, exitActionParent, onExit, doneActionParent, onDone: propsOnDone, onCancelResetStorage }) => {
3400
+ const client = (0, import_react_client7.useClient)();
3401
+ const identity = (0, import_halo4.useIdentity)();
3402
+ const { hasIosKeyboard } = (0, import_react_ui22.useThemeContext)();
3403
+ const titleId = (0, import_react_ui22.useId)("joinPanel__heading", propsTitleId);
3404
+ const [joinState, joinSend, joinService] = useJoinMachine(client, {
3405
+ context: {
3406
+ mode,
3407
+ initialDisposition,
3408
+ identity,
3409
+ ...initialInvitationCode && {
3410
+ [mode === "halo-only" ? "halo" : "space"]: {
3411
+ unredeemedCode: initialInvitationCode
3412
+ }
3413
+ }
3414
+ }
3415
+ });
3416
+ (0, import_react47.useEffect)(() => {
3417
+ const subscription = joinService.subscribe((state) => {
3418
+ (0, import_log7.log)("[state]", state, {
3419
+ F: __dxlog_file10,
3420
+ L: 210,
3421
+ S: void 0,
3422
+ C: (f, a) => f(...a)
3423
+ });
3424
+ });
3425
+ return subscription.unsubscribe;
3426
+ }, [
3427
+ joinService
3428
+ ]);
3429
+ (0, import_react47.useEffect)(() => {
3430
+ const stateStack = joinState.configuration[0].id.split(".");
3431
+ const innermostState = stateStack[stateStack.length - 1];
3432
+ const autoFocusValue = innermostState === "finishingJoining" ? "successSpaceInvitation" : innermostState;
3433
+ const $nextAutofocus = document.querySelector(`[data-autofocus~="${autoFocusValue}"]`);
3434
+ if ($nextAutofocus && !(hasIosKeyboard && $nextAutofocus.hasAttribute("data-prevent-ios-autofocus"))) {
3435
+ $nextAutofocus.focus();
3436
+ }
3437
+ }, [
3438
+ joinState.value,
3439
+ hasIosKeyboard
3440
+ ]);
3441
+ const activeView = (0, import_react47.useMemo)(() => {
3442
+ switch (true) {
3443
+ case joinState.matches({
3444
+ choosingIdentity: "choosingAuthMethod"
3445
+ }):
3446
+ return "addition method chooser";
3447
+ case joinState.matches("resettingIdentity"):
3448
+ return "reset storage confirmation";
3449
+ case joinState.matches({
3450
+ choosingIdentity: "creatingIdentity"
3451
+ }):
3452
+ return "create identity input";
3453
+ case joinState.matches({
3454
+ choosingIdentity: "recoveringIdentity"
3455
+ }):
3456
+ return "recover identity input";
3457
+ case joinState.matches({
3458
+ choosingIdentity: {
3459
+ acceptingHaloInvitation: "inputtingHaloInvitationCode"
3460
+ }
3461
+ }):
3462
+ return "halo invitation input";
3463
+ case [
3464
+ {
3465
+ choosingIdentity: {
3466
+ acceptingHaloInvitation: {
3467
+ acceptingRedeemedHaloInvitation: "connectingHaloInvitation"
3468
+ }
3469
+ }
3470
+ },
3471
+ {
3472
+ choosingIdentity: {
3473
+ acceptingHaloInvitation: {
3474
+ acceptingRedeemedHaloInvitation: "failingHaloInvitation"
3475
+ }
3476
+ }
3477
+ }
3478
+ ].some(joinState.matches):
3479
+ return "halo invitation rescuer";
3480
+ case [
3481
+ {
3482
+ choosingIdentity: {
3483
+ acceptingHaloInvitation: {
3484
+ acceptingRedeemedHaloInvitation: "inputtingHaloVerificationCode"
3485
+ }
3486
+ }
3487
+ },
3488
+ {
3489
+ choosingIdentity: {
3490
+ acceptingHaloInvitation: {
3491
+ acceptingRedeemedHaloInvitation: "authenticatingHaloVerificationCode"
3492
+ }
3493
+ }
3494
+ },
3495
+ {
3496
+ choosingIdentity: {
3497
+ acceptingHaloInvitation: {
3498
+ acceptingRedeemedHaloInvitation: "authenticationFailingHaloVerificationCode"
3499
+ }
3500
+ }
3501
+ }
3502
+ ].some(joinState.matches):
3503
+ return "halo invitation authenticator";
3504
+ case [
3505
+ {
3506
+ choosingIdentity: {
3507
+ acceptingHaloInvitation: {
3508
+ acceptingRedeemedHaloInvitation: "successHaloInvitation"
3509
+ }
3510
+ }
3511
+ },
3512
+ "finishingJoiningHalo"
3513
+ ].some(joinState.matches):
3514
+ return "halo invitation accepted";
3515
+ case joinState.matches({
3516
+ choosingIdentity: "confirmingAddedIdentity"
3517
+ }):
3518
+ return "identity added";
3519
+ case joinState.matches({
3520
+ acceptingSpaceInvitation: "inputtingSpaceInvitationCode"
3521
+ }):
3522
+ return "space invitation input";
3523
+ case [
3524
+ {
3525
+ acceptingSpaceInvitation: {
3526
+ acceptingRedeemedSpaceInvitation: "connectingSpaceInvitation"
3527
+ }
3528
+ },
3529
+ {
3530
+ acceptingSpaceInvitation: {
3531
+ acceptingRedeemedSpaceInvitation: "failingSpaceInvitation"
3532
+ }
3533
+ }
3534
+ ].some(joinState.matches):
3535
+ return "space invitation rescuer";
3536
+ case [
3537
+ {
3538
+ acceptingSpaceInvitation: {
3539
+ acceptingRedeemedSpaceInvitation: "inputtingSpaceVerificationCode"
3540
+ }
3541
+ },
3542
+ {
3543
+ acceptingSpaceInvitation: {
3544
+ acceptingRedeemedSpaceInvitation: "authenticatingSpaceVerificationCode"
3545
+ }
3546
+ },
3547
+ {
3548
+ acceptingSpaceInvitation: {
3549
+ acceptingRedeemedSpaceInvitation: "authenticationFailingSpaceVerificationCode"
3550
+ }
3551
+ }
3552
+ ].some(joinState.matches):
3553
+ return "space invitation authenticator";
3554
+ case joinState.matches("finishingJoiningSpace"):
3555
+ return "space invitation accepted";
3556
+ default:
3557
+ return "never";
3558
+ }
3559
+ }, [
3560
+ joinState
3561
+ ]);
3562
+ (0, import_react47.useEffect)(() => {
3563
+ switch (activeView) {
3564
+ case "halo invitation accepted":
3565
+ onHaloDone();
3566
+ break;
3567
+ case "space invitation accepted":
3568
+ onSpaceDone();
3569
+ break;
3570
+ }
3571
+ }, [
3572
+ activeView
3573
+ ]);
3574
+ const failed = (0, import_react47.useMemo)(() => {
3575
+ const result = /* @__PURE__ */ new Set();
3576
+ switch (true) {
3577
+ case joinState.matches({
3578
+ choosingIdentity: {
3579
+ acceptingHaloInvitation: {
3580
+ acceptingRedeemedHaloInvitation: "authenticationFailingHaloVerificationCode"
3581
+ }
3582
+ }
3583
+ }):
3584
+ result.add("Halo");
3585
+ break;
3586
+ case joinState.matches({
3587
+ acceptingSpaceInvitation: {
3588
+ acceptingRedeemedSpaceInvitation: "authenticationFailingSpaceVerificationCode"
3589
+ }
3590
+ }):
3591
+ result.add("Space");
3592
+ break;
3593
+ }
3594
+ return result;
3595
+ }, [
3596
+ joinState
3597
+ ]);
3598
+ const unredeemedCodes = (0, import_react47.useMemo)(() => ({
3599
+ Halo: joinState.context.halo.unredeemedCode,
3600
+ Space: joinState.context.space.unredeemedCode
3601
+ }), [
3602
+ joinState
3603
+ ]);
3604
+ const spaces = (0, import_react_client7.useMulticastObservable)(client.spaces);
3605
+ const succeededKeys = (0, import_react47.useMemo)(() => ({
3606
+ Space: spaces ? new Set(spaces.map(({ key }) => key.toHex())) : void 0
3607
+ }), [
3608
+ spaces
3609
+ ]);
3610
+ const invitationStates = (0, import_react47.useMemo)(() => ({
3611
+ Halo: joinState.context.halo.invitationObservable?.get().state,
3612
+ Space: joinState.context.space.invitationObservable?.get().state
3613
+ }), [
3614
+ joinState
3615
+ ]);
3616
+ const invitationAuthMethods = (0, import_react47.useMemo)(() => ({
3617
+ Halo: joinState.context.halo.invitationObservable?.get().authMethod,
3618
+ Space: joinState.context.space.invitationObservable?.get().authMethod
3619
+ }), [
3620
+ joinState
3621
+ ]);
3622
+ const invitationIds = (0, import_react47.useMemo)(() => ({
3623
+ Halo: joinState.context.halo.invitationObservable?.get().invitationId,
3624
+ Space: joinState.context.space.invitationObservable?.get().invitationId
3625
+ }), [
3626
+ joinState
3627
+ ]);
3628
+ const failReasons = (0, import_react47.useMemo)(() => ({
3629
+ Halo: joinState.context.halo.failReason,
3630
+ Space: joinState.context.space.failReason
3631
+ }), [
3632
+ joinState
3633
+ ]);
3634
+ const onHaloDone = (0, import_react47.useCallback)(() => {
3635
+ propsOnDone?.({
3636
+ identityKey: joinState.context.halo.invitation?.identityKey ?? null,
3637
+ swarmKey: joinState.context.halo.invitation?.swarmKey ?? null,
3638
+ spaceKey: joinState.context.halo.invitation?.spaceKey ?? null,
3639
+ target: joinState.context.halo.invitation?.target ?? null
3640
+ });
3641
+ }, [
3642
+ joinState,
3643
+ propsOnDone
3644
+ ]);
3645
+ const onSpaceDone = (0, import_react47.useCallback)(() => {
3646
+ propsOnDone?.({
3647
+ identityKey: joinState.context.space.invitation?.identityKey ?? null,
3648
+ swarmKey: joinState.context.space.invitation?.swarmKey ?? null,
3649
+ spaceKey: joinState.context.space.invitation?.spaceKey ?? null,
3650
+ target: joinState.context.space.invitation?.target ?? null
3651
+ });
3652
+ }, [
3653
+ joinState,
3654
+ propsOnDone
3655
+ ]);
3656
+ const onConfirmResetStorage = (0, import_react47.useCallback)(() => client.reset().then(() => {
3657
+ joinSend({
3658
+ type: "resetIdentity"
3659
+ });
3660
+ }), [
3661
+ client,
3662
+ joinSend
3663
+ ]);
3664
+ return /* @__PURE__ */ import_react47.default.createElement(JoinPanelImpl, {
3665
+ titleId,
3666
+ mode,
3667
+ send: joinSend,
3668
+ activeView,
3669
+ failed,
3670
+ failReasons,
3671
+ pending: [
3672
+ "connecting",
3673
+ "authenticating"
3674
+ ].some((str) => joinState?.configuration[0].id.includes(str)),
3675
+ unredeemedCodes,
3676
+ invitationIds,
3677
+ invitationStates,
3678
+ invitationAuthMethods,
3679
+ succeededKeys,
3680
+ identity,
3681
+ onExit,
3682
+ exitActionParent,
3683
+ doneActionParent,
3684
+ onHaloDone,
3685
+ onSpaceDone,
3686
+ onHaloInvitationCancel: () => joinState.context.halo.invitationObservable?.cancel(),
3687
+ onSpaceInvitationCancel: () => joinState.context.space.invitationObservable?.cancel(),
3688
+ onHaloInvitationAuthenticate: (authCode) => {
3689
+ joinSend({
3690
+ type: "authenticateHaloVerificationCode"
3691
+ });
3692
+ return joinState.context.halo.invitationObservable?.authenticate(authCode);
3693
+ },
3694
+ onSpaceInvitationAuthenticate: (authCode) => {
3695
+ joinSend({
3696
+ type: "authenticateSpaceVerificationCode"
3697
+ });
3698
+ return joinState.context.space.invitationObservable?.authenticate(authCode);
3699
+ },
3700
+ onConfirmResetStorage,
3701
+ onCancelResetStorage
3702
+ });
3703
+ };
3704
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/spaceMachine.ts";
3705
+ var spaceMachine = (0, import_xstate3.createMachine)({
3706
+ id: "space",
3707
+ predictableActionArguments: true,
3708
+ context: {
3709
+ space: null
3710
+ },
3711
+ initial: "managingSpace",
3712
+ states: {
3713
+ managingSpace: {},
3714
+ managingSpaceInvitation: {}
3715
+ },
3716
+ on: {
3717
+ deselectInvitation: {
3718
+ target: ".managingSpace",
3719
+ actions: [
3720
+ "unsetInvitation",
3721
+ "log"
3722
+ ]
3723
+ },
3724
+ selectInvitation: {
3725
+ target: ".managingSpaceInvitation",
3726
+ actions: [
3727
+ "setInvitation",
3728
+ "log"
3729
+ ]
3730
+ }
3731
+ }
3732
+ }, {
3733
+ actions: {
3734
+ setInvitation: (0, import_xstate3.assign)({
3735
+ invitation: (context, event) => event?.invitation ?? null
3736
+ }),
3737
+ unsetInvitation: (0, import_xstate3.assign)({
3738
+ invitation: () => void 0
3739
+ }),
3740
+ log: (context, event) => {
3741
+ (0, import_log12.log)("[transition]", {
3742
+ event,
3743
+ context
3744
+ }, {
3745
+ F: __dxlog_file11,
3746
+ L: 53,
3747
+ S: void 0,
3748
+ C: (f, a) => f(...a)
3749
+ });
3750
+ }
3751
+ }
3752
+ });
3753
+ var useSpaceMachine = (options) => {
3754
+ return (0, import_react62.useMachine)(spaceMachine, {
3755
+ ...options,
3756
+ context: {
3757
+ ...options?.context
3758
+ }
3759
+ });
3760
+ };
3761
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/steps/SpaceManager.tsx";
3762
+ var activeActionKey = "dxos:react-shell/space-manager/active-action";
3763
+ var handleInvitationEvent = (invitation, subscription) => {
3764
+ const invitationCode = import_invitations10.InvitationEncoder.encode(invitation);
3765
+ if (invitation.state === import_invitations10.Invitation.State.CONNECTING) {
3766
+ import_log13.log.info(JSON.stringify({
3767
+ invitationCode,
3768
+ authCode: invitation.authCode
3769
+ }), void 0, {
3770
+ F: __dxlog_file12,
3771
+ L: 40,
3772
+ S: void 0,
3773
+ C: (f, a) => f(...a)
3774
+ });
3775
+ subscription.unsubscribe();
3776
+ }
3777
+ };
3778
+ var SpaceManager = (props) => {
3779
+ const { space, target } = props;
3780
+ const { t } = (0, import_react_ui32.useTranslation)("os");
3781
+ const config = (0, import_react_client10.useConfig)();
3782
+ const invitations = (0, import_echo4.useSpaceInvitations)(space?.key);
3783
+ const inviteActions = {
3784
+ inviteOne: {
3785
+ label: t("invite one label"),
3786
+ description: t("invite one description"),
3787
+ icon: import_react63.UserPlus,
3788
+ testId: "spaces-panel.invite-one",
3789
+ onClick: (0, import_react64.useCallback)(() => {
3790
+ const invitation = space.share?.({
3791
+ type: import_invitations10.Invitation.Type.INTERACTIVE,
3792
+ authMethod: import_invitations10.Invitation.AuthMethod.SHARED_SECRET,
3793
+ multiUse: false,
3794
+ target
3795
+ });
3796
+ if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
3797
+ const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
3798
+ }
3799
+ }, [
3800
+ space,
3801
+ target
3802
+ ])
3803
+ },
3804
+ inviteMany: {
3805
+ label: t("invite many label"),
3806
+ description: t("invite many description"),
3807
+ icon: import_react63.UsersThree,
3808
+ testId: "spaces-panel.invite-many",
3809
+ onClick: (0, import_react64.useCallback)(() => {
3810
+ const invitation = space.share?.({
3811
+ type: import_invitations10.Invitation.Type.DELEGATED,
3812
+ authMethod: import_invitations10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY,
3813
+ multiUse: true,
3814
+ target
3815
+ });
3816
+ if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
3817
+ const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
3818
+ }
3819
+ }, [
3820
+ space,
3821
+ target
3822
+ ])
3823
+ }
3824
+ };
3825
+ return /* @__PURE__ */ import_react64.default.createElement(SpaceManagerImpl, {
3826
+ ...props,
3827
+ invitations,
3828
+ inviteActions
3829
+ });
3830
+ };
3831
+ var headingFragment = "pis-3 pie-1 plb-1 mbe-1 font-medium";
3832
+ var SpaceManagerImpl = (props) => {
3833
+ const { active, space, createInvitationUrl, send, inviteActions: propsInviteActions, invitations, showInactiveInvitations, SpaceMemberList: SpaceMemberListComponent = SpaceMemberList, InvitationList: InvitationListComponent = InvitationList } = props;
3834
+ const { t } = (0, import_react_ui32.useTranslation)("os");
3835
+ const inviteActions = propsInviteActions ?? {
3836
+ noopInvite: {
3837
+ label: t("create space invitation label"),
3838
+ description: "",
3839
+ icon: import_react63.Placeholder,
3840
+ onClick: () => {
3841
+ }
3842
+ }
3843
+ };
3844
+ const [activeAction, setInternalActiveAction] = (0, import_react64.useState)(localStorage.getItem(activeActionKey) ?? "inviteMany");
3845
+ const setActiveAction = (nextAction) => {
3846
+ setInternalActiveAction(nextAction);
3847
+ localStorage.setItem(activeActionKey, nextAction);
3848
+ };
3849
+ const visibleInvitations = showInactiveInvitations ? invitations : invitations?.filter((invitation) => ![
3850
+ import_invitations10.Invitation.State.CANCELLED
3851
+ ].includes(invitation.get().state));
3852
+ return /* @__PURE__ */ import_react64.default.createElement(import_react64.default.Fragment, null, /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Root, {
3853
+ classNames: "grow shrink basis-28 -mli-2"
3854
+ }, /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Viewport, {
3855
+ classNames: "is-full pie-2"
3856
+ }, !!visibleInvitations?.length && /* @__PURE__ */ import_react64.default.createElement(import_react64.default.Fragment, null, /* @__PURE__ */ import_react64.default.createElement("h3", {
3857
+ className: (0, import_react_ui_theme30.mx)(headingFragment, import_react_ui_theme30.descriptionText)
3858
+ }, t("invitation list heading")), /* @__PURE__ */ import_react64.default.createElement(InvitationListComponent, {
3859
+ className: "mb-2",
3860
+ send,
3861
+ invitations: visibleInvitations ?? [],
3862
+ onClickRemove: (invitation) => invitation.cancel(),
3863
+ createInvitationUrl
3864
+ }), /* @__PURE__ */ import_react64.default.createElement("h3", {
3865
+ className: (0, import_react_ui_theme30.mx)(headingFragment, import_react_ui_theme30.descriptionText, "mbs-2")
3866
+ }, t("space member list heading"))), /* @__PURE__ */ import_react64.default.createElement(SpaceMemberListComponent, {
3867
+ spaceKey: space.key,
3868
+ includeSelf: true
3869
+ })), /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Scrollbar, {
3870
+ orientation: "vertical"
3871
+ }, /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Thumb, null))), /* @__PURE__ */ import_react64.default.createElement(Actions, null, /* @__PURE__ */ import_react64.default.createElement(BifurcatedAction, {
3872
+ disabled: !active,
3873
+ actions: inviteActions,
3874
+ activeAction,
3875
+ onChangeActiveAction: setActiveAction,
3876
+ "data-testid": "spaces-panel.create-invitation"
3877
+ })));
3878
+ };
3879
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/SpacePanel.tsx";
3880
+ var SpacePanelHeading = ({ titleId, space, onDone }) => {
3881
+ const { t } = (0, import_react_ui31.useTranslation)("os");
3882
+ const name = space.properties.name;
3883
+ return /* @__PURE__ */ import_react61.default.createElement(Heading, {
3884
+ titleId,
3885
+ title: t("space panel heading"),
3886
+ corner: /* @__PURE__ */ import_react61.default.createElement(CloseButton, {
3887
+ "data-testid": "identity-panel-done",
3888
+ onDone
3889
+ })
3890
+ }, /* @__PURE__ */ import_react61.default.createElement("div", {
3891
+ role: "none",
3892
+ className: "flex gap-4 items-center justify-center mlb-4"
3893
+ }, /* @__PURE__ */ import_react61.default.createElement(import_react60.Planet, {
3894
+ size: 32,
3895
+ weight: "light"
3896
+ }), /* @__PURE__ */ import_react61.default.createElement("div", {
3897
+ className: "block text-start font-light text-xl"
3898
+ }, name ?? space.key.truncate())));
3899
+ };
3900
+ var SpacePanelImpl = (props) => {
3901
+ const { titleId, activeView, space, hideHeading, target, SpaceManager: SpaceManagerComponent = SpaceManager, InvitationManager: InvitationManagerComponent = InvitationManager, ...rest } = props;
3902
+ return /* @__PURE__ */ import_react61.default.createElement(import_react61.default.Fragment, null, !hideHeading && /* @__PURE__ */ import_react61.default.createElement(SpacePanelHeading, {
3903
+ ...rest,
3904
+ titleId,
3905
+ space
3906
+ }), /* @__PURE__ */ import_react61.default.createElement(Viewport.Root, {
3907
+ activeView
3908
+ }, /* @__PURE__ */ import_react61.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react61.default.createElement(Viewport.View, {
3909
+ id: "space manager",
3910
+ classNames: stepStyles
3911
+ }, /* @__PURE__ */ import_react61.default.createElement(SpaceManagerComponent, {
3912
+ active: activeView === "space manager",
3913
+ space,
3914
+ target,
3915
+ ...rest
3916
+ })), /* @__PURE__ */ import_react61.default.createElement(Viewport.View, {
3917
+ id: "space invitation manager",
3918
+ classNames: stepStyles
3919
+ }, /* @__PURE__ */ import_react61.default.createElement(InvitationManagerComponent, {
3920
+ active: activeView === "space invitation manager",
3921
+ ...rest,
3922
+ invitationUrl: props.invitationUrl
3923
+ })))));
3924
+ };
3925
+ var SpacePanelWithInvitationImpl = ({ invitation, ...props }) => {
3926
+ const invitationStatus = (0, import_invitations9.useInvitationStatus)(invitation);
3927
+ return /* @__PURE__ */ import_react61.default.createElement(SpacePanelImpl, {
3928
+ ...props,
3929
+ ...invitationStatus,
3930
+ invitationUrl: props.createInvitationUrl(invitationStatus.invitationCode)
3931
+ });
3932
+ };
3933
+ var SpacePanel = ({ titleId: propsTitleId, createInvitationUrl = (code) => code, ...props }) => {
3934
+ const titleId = (0, import_react_ui31.useId)("spacePanel__heading", propsTitleId);
3935
+ const [spaceState, spaceSend, spaceService] = useSpaceMachine({
3936
+ context: {
3937
+ space: props.space
3938
+ }
3939
+ });
3940
+ (0, import_react61.useEffect)(() => {
3941
+ const subscription = spaceService.subscribe((state) => {
3942
+ (0, import_log11.log)("[state]", state, {
3943
+ F: __dxlog_file13,
3944
+ L: 95,
3945
+ S: void 0,
3946
+ C: (f, a) => f(...a)
3947
+ });
3948
+ });
3949
+ return subscription.unsubscribe;
3950
+ }, [
3951
+ spaceService
3952
+ ]);
3953
+ const activeView = (0, import_react61.useMemo)(() => {
3954
+ switch (true) {
3955
+ case spaceState.matches("managingSpace"):
3956
+ return "space manager";
3957
+ case spaceState.matches("managingSpaceInvitation"):
3958
+ return "space invitation manager";
3959
+ default:
3960
+ return "never";
3961
+ }
3962
+ }, [
3963
+ spaceState
3964
+ ]);
3965
+ const implProps = {
3966
+ ...props,
3967
+ activeView,
3968
+ send: spaceSend,
3969
+ titleId,
3970
+ createInvitationUrl
3971
+ };
3972
+ return spaceState.context.invitation ? (
3973
+ // TODO(wittjosiah): Unused? Remove?
3974
+ /* @__PURE__ */ import_react61.default.createElement(SpacePanelWithInvitationImpl, {
3975
+ ...implProps,
3976
+ invitation: spaceState.context.invitation
3977
+ })
3978
+ ) : /* @__PURE__ */ import_react61.default.createElement(SpacePanelImpl, implProps);
3979
+ };
3980
+ var StatusPanel = ({ titleId }) => {
3981
+ const { t } = (0, import_react_ui33.useTranslation)("os");
3982
+ return /* @__PURE__ */ import_react65.default.createElement("div", {
3983
+ className: "grid place-items-center p-2 gap-2"
3984
+ }, /* @__PURE__ */ import_react65.default.createElement("p", {
3985
+ id: titleId,
3986
+ className: "font-medium text-center"
3987
+ }, t("resetting message")), /* @__PURE__ */ import_react65.default.createElement(import_react_ui33.Status, {
3988
+ indeterminate: true
3989
+ }, t("resetting message")));
3990
+ };
3991
+ var IdentityDialog = (props) => {
3992
+ const titleId = (0, import_react_ui17.useId)("identityDialog__title", props.title);
3993
+ return /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Root, {
3994
+ defaultOpen: true,
3995
+ onOpenChange: (open) => open || props.onDone?.()
3996
+ }, /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Portal, null, /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Overlay, null, /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Content, {
3997
+ "aria-labelledby": titleId,
3998
+ onOpenAutoFocus: (e) => e.preventDefault()
3999
+ }, /* @__PURE__ */ import_react35.default.createElement(ClipboardProvider, null, /* @__PURE__ */ import_react35.default.createElement(IdentityPanel, {
4000
+ ...props,
4001
+ titleId,
4002
+ doneActionParent: /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Close, {
4003
+ asChild: true
4004
+ })
4005
+ }))))));
4006
+ };
4007
+ var JoinDialog = (joinPanelProps) => {
4008
+ const titleId = (0, import_react_ui34.useId)("joinDialog__title");
4009
+ const { height } = (0, import_react_ui34.useVisualViewport)();
4010
+ return /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Root, {
4011
+ defaultOpen: true,
4012
+ onOpenChange: (open) => open || (joinPanelProps.onExit ? joinPanelProps.onExit() : joinPanelProps.onDone?.(null))
4013
+ }, /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Portal, null, /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Overlay, {
4014
+ classNames: "backdrop-blur",
4015
+ ...height && {
4016
+ style: {
4017
+ blockSize: `${height}px`
4018
+ }
4019
+ }
4020
+ }, /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Content, {
4021
+ "aria-labelledby": titleId
4022
+ }, /* @__PURE__ */ import_react66.default.createElement(JoinPanel, {
4023
+ ...joinPanelProps,
4024
+ titleId,
4025
+ exitActionParent: /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Cancel, {
4026
+ asChild: true
4027
+ }),
4028
+ doneActionParent: /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Action, {
4029
+ asChild: true
4030
+ })
4031
+ })))));
4032
+ };
4033
+ var SpaceDialog = (spacePanelProps) => {
4034
+ const titleId = (0, import_react_ui36.useId)("spaceDialog__title");
4035
+ return /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Root, {
4036
+ defaultOpen: true,
4037
+ onOpenChange: (open) => open || spacePanelProps.onDone?.()
4038
+ }, /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Portal, null, /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Overlay, null, /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Content, {
4039
+ "aria-labelledby": titleId
4040
+ }, /* @__PURE__ */ import_react69.default.createElement(ClipboardProvider, null, /* @__PURE__ */ import_react69.default.createElement(SpacePanel, {
4041
+ ...spacePanelProps,
4042
+ titleId,
4043
+ doneActionParent: /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Close, {
4044
+ asChild: true
4045
+ })
4046
+ }))))));
4047
+ };
4048
+ var StatusDialog = () => {
4049
+ const titleId = (0, import_react_ui37.useId)("statusDialog__title");
4050
+ return /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Root, {
4051
+ open: true
4052
+ }, /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Portal, null, /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Overlay, null, /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Content, {
4053
+ "aria-labelledby": titleId
4054
+ }, /* @__PURE__ */ import_react70.default.createElement(StatusPanel, {
4055
+ titleId
4056
+ })))));
4057
+ };
4058
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/composites/Shell/Shell.tsx";
4059
+ var blurActiveElement = () => document.activeElement?.blur?.();
4060
+ var Shell = ({ runtime }) => {
4061
+ const [{ layout, invitationCode, spaceKey, spaceId, target }, setLayout] = (0, import_react68.useState)({
4062
+ layout: runtime.layout,
4063
+ invitationCode: runtime.invitationCode,
4064
+ spaceKey: runtime.spaceKey,
4065
+ spaceId: runtime.spaceId,
4066
+ target: runtime.target
4067
+ });
4068
+ const [{ invitationUrl, deviceInvitationParam, spaceInvitationParam }, setInvitationUrl] = (0, import_react68.useState)({
4069
+ invitationUrl: runtime.invitationUrl,
4070
+ deviceInvitationParam: runtime.deviceInvitationParam,
4071
+ spaceInvitationParam: runtime.spaceInvitationParam
4072
+ });
4073
+ const client = (0, import_react_client12.useClient)();
4074
+ const space = (0, import_echo5.useSpace)(spaceId ?? spaceKey);
4075
+ const createDeviceInvitationUrl = (invitationCode2) => {
4076
+ const baseUrl = new URL(invitationUrl);
4077
+ baseUrl.searchParams.set(deviceInvitationParam, invitationCode2);
4078
+ return baseUrl.toString();
4079
+ };
4080
+ const createSpaceInvitationUrl = (invitationCode2) => {
4081
+ const baseUrl = new URL(invitationUrl);
4082
+ baseUrl.searchParams.set(spaceInvitationParam, invitationCode2);
4083
+ return baseUrl.toString();
4084
+ };
4085
+ (0, import_react68.useEffect)(() => {
4086
+ const unsubscribeLayout = runtime.layoutUpdate.on((request) => setLayout(request));
4087
+ const unsubscribeInvitationUrl = runtime.invitationUrlUpdate.on((request) => setInvitationUrl(request));
4088
+ return () => {
4089
+ unsubscribeLayout();
4090
+ unsubscribeInvitationUrl();
4091
+ };
4092
+ }, [
4093
+ runtime
4094
+ ]);
4095
+ (0, import_react68.useEffect)(() => {
4096
+ if (layout === import_react_client13.ShellLayout.SPACE && !space) {
4097
+ import_log14.log.warn("No space found for shell space invitations.", void 0, {
4098
+ F: __dxlog_file14,
4099
+ L: 67,
4100
+ S: void 0,
4101
+ C: (f, a) => f(...a)
4102
+ });
4103
+ const timeout = setTimeout(async () => {
4104
+ await runtime.setAppContext({
4105
+ display: import_react_client13.ShellDisplay.NONE
4106
+ });
4107
+ runtime.setLayout({
4108
+ layout: import_react_client13.ShellLayout.DEFAULT
4109
+ });
4110
+ });
4111
+ return () => clearTimeout(timeout);
4112
+ }
4113
+ }, [
4114
+ runtime,
4115
+ layout,
4116
+ space
4117
+ ]);
4118
+ switch (layout) {
4119
+ case import_react_client13.ShellLayout.STATUS:
4120
+ return /* @__PURE__ */ import_react68.default.createElement(StatusDialog, null);
4121
+ case import_react_client13.ShellLayout.INITIALIZE_IDENTITY:
4122
+ case import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION:
4123
+ case import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_RECOVERY:
4124
+ return /* @__PURE__ */ import_react68.default.createElement(JoinDialog, {
4125
+ mode: "halo-only",
4126
+ initialDisposition: layout === import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_RECOVERY ? "recover-identity" : layout === import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION ? "accept-halo-invitation" : "default",
4127
+ initialInvitationCode: invitationCode,
4128
+ onCancelResetStorage: () => runtime.setLayout({
4129
+ layout: import_react_client13.ShellLayout.IDENTITY
4130
+ }),
4131
+ onDone: async () => {
4132
+ blurActiveElement();
4133
+ await runtime.setAppContext({
4134
+ display: import_react_client13.ShellDisplay.NONE
4135
+ });
4136
+ runtime.setLayout({
4137
+ layout: import_react_client13.ShellLayout.DEFAULT
4138
+ });
4139
+ }
4140
+ });
4141
+ case import_react_client13.ShellLayout.IDENTITY:
4142
+ case import_react_client13.ShellLayout.SHARE_IDENTITY:
4143
+ case import_react_client13.ShellLayout.EDIT_PROFILE:
4144
+ return /* @__PURE__ */ import_react68.default.createElement(IdentityDialog, {
4145
+ createInvitationUrl: createDeviceInvitationUrl,
4146
+ onResetStorage: async () => {
4147
+ runtime.setLayout({
4148
+ layout: import_react_client13.ShellLayout.STATUS
4149
+ });
4150
+ await client.reset();
4151
+ return runtime.setAppContext({
4152
+ display: import_react_client13.ShellDisplay.NONE,
4153
+ reset: true
4154
+ });
4155
+ },
4156
+ onRecover: async () => {
4157
+ runtime.setLayout({
4158
+ layout: import_react_client13.ShellLayout.STATUS
4159
+ });
4160
+ await client.reset();
4161
+ return runtime.setAppContext({
4162
+ display: import_react_client13.ShellDisplay.NONE,
4163
+ reset: true,
4164
+ target: "recoverIdentity"
4165
+ });
4166
+ },
4167
+ onJoinNewIdentity: async () => {
4168
+ runtime.setLayout({
4169
+ layout: import_react_client13.ShellLayout.STATUS
4170
+ });
4171
+ await client.reset();
4172
+ return runtime.setAppContext({
4173
+ display: import_react_client13.ShellDisplay.NONE,
4174
+ reset: true,
4175
+ target: "deviceInvitation"
4176
+ });
4177
+ },
4178
+ onDone: async () => {
4179
+ blurActiveElement();
4180
+ await runtime.setAppContext({
4181
+ display: import_react_client13.ShellDisplay.NONE
4182
+ });
4183
+ runtime.setLayout({
4184
+ layout: import_react_client13.ShellLayout.DEFAULT
4185
+ });
4186
+ },
4187
+ initialDisposition: layout === import_react_client13.ShellLayout.SHARE_IDENTITY ? "manage-device-invitation" : "default"
4188
+ });
4189
+ case import_react_client13.ShellLayout.SPACE:
4190
+ return space ? /* @__PURE__ */ import_react68.default.createElement(SpaceDialog, {
4191
+ space,
4192
+ target,
4193
+ createInvitationUrl: createSpaceInvitationUrl,
4194
+ onDone: async () => {
4195
+ blurActiveElement();
4196
+ await runtime.setAppContext({
4197
+ display: import_react_client13.ShellDisplay.NONE
4198
+ });
4199
+ runtime.setLayout({
4200
+ layout: import_react_client13.ShellLayout.DEFAULT
4201
+ });
4202
+ }
4203
+ }) : null;
4204
+ case import_react_client13.ShellLayout.JOIN_SPACE:
4205
+ return /* @__PURE__ */ import_react68.default.createElement(JoinDialog, {
4206
+ initialInvitationCode: invitationCode,
4207
+ onDone: async (result) => {
4208
+ blurActiveElement();
4209
+ const target2 = result?.target ?? void 0;
4210
+ await runtime.setAppContext({
4211
+ display: import_react_client13.ShellDisplay.NONE,
4212
+ spaceKey: result?.spaceKey ?? void 0,
4213
+ target: target2
4214
+ });
4215
+ runtime.setLayout({
4216
+ layout: import_react_client13.ShellLayout.DEFAULT
4217
+ });
4218
+ },
4219
+ onExit: async () => {
4220
+ blurActiveElement();
4221
+ await runtime.setAppContext({
4222
+ display: import_react_client13.ShellDisplay.NONE
4223
+ });
4224
+ runtime.setLayout({
4225
+ layout: import_react_client13.ShellLayout.DEFAULT
4226
+ });
4227
+ }
4228
+ });
4229
+ default:
4230
+ return null;
4231
+ }
4232
+ };
4233
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/composites/Shell/shell-runtime.ts";
4234
+ var ShellRuntimeImpl = class {
4235
+ constructor(_port) {
4236
+ this._port = _port;
4237
+ this.layoutUpdate = new import_async.Event();
4238
+ this.invitationUrlUpdate = new import_async.Event();
4239
+ this._layout = import_iframe.ShellLayout.DEFAULT;
4240
+ this._invitationUrl = typeof window !== "undefined" ? window.location.origin : void 0;
4241
+ this._deviceInvitationParam = "deviceInvitationCode";
4242
+ this._spaceInvitationParam = "spaceInvitationCode";
4243
+ }
4244
+ get layout() {
4245
+ return this._layout;
4246
+ }
4247
+ get invitationCode() {
4248
+ return this._invitationCode;
4249
+ }
4250
+ /** @deprecated Use spaceId. */
4251
+ get spaceKey() {
4252
+ return this._spaceKey;
4253
+ }
4254
+ get spaceId() {
4255
+ return this._spaceId;
4256
+ }
4257
+ get invitationUrl() {
4258
+ return this._invitationUrl;
4259
+ }
4260
+ get deviceInvitationParam() {
4261
+ return this._deviceInvitationParam;
4262
+ }
4263
+ get spaceInvitationParam() {
4264
+ return this._spaceInvitationParam;
4265
+ }
4266
+ setLayout({ layout, invitationCode, spaceKey, spaceId }) {
4267
+ this._layout = layout;
4268
+ this._invitationCode = invitationCode;
4269
+ this._spaceKey = spaceKey;
4270
+ this._spaceId = spaceId;
4271
+ this.layoutUpdate.emit({
4272
+ layout,
4273
+ invitationCode,
4274
+ spaceKey,
4275
+ spaceId
4276
+ });
4277
+ }
4278
+ setInvitationUrl({ invitationUrl, deviceInvitationParam, spaceInvitationParam }) {
4279
+ this._invitationUrl = invitationUrl;
4280
+ this._deviceInvitationParam = deviceInvitationParam;
4281
+ this._spaceInvitationParam = spaceInvitationParam;
4282
+ this.invitationUrlUpdate.emit({
4283
+ invitationUrl,
4284
+ deviceInvitationParam,
4285
+ spaceInvitationParam
4286
+ });
4287
+ }
4288
+ async setAppContext(context) {
4289
+ (0, import_invariant4.invariant)(this._appRpc, "runtime not open", {
4290
+ F: __dxlog_file15,
4291
+ L: 83,
4292
+ S: this,
4293
+ A: [
4294
+ "this._appRpc",
4295
+ "'runtime not open'"
4296
+ ]
4297
+ });
4298
+ await this._appRpc.rpc.AppService.setContext(context);
4299
+ }
4300
+ async open() {
4301
+ this._appRpc = (0, import_rpc.createProtoRpcPeer)({
4302
+ requested: import_client_protocol2.appServiceBundle,
4303
+ exposed: import_client_protocol2.shellServiceBundle,
4304
+ handlers: {
4305
+ ShellService: {
4306
+ setLayout: async (request) => {
4307
+ this._layout = request.layout;
4308
+ this._invitationCode = request.invitationCode;
4309
+ this._spaceKey = request.spaceKey;
4310
+ this._spaceId = request.spaceId;
4311
+ this.layoutUpdate.emit(request);
4312
+ },
4313
+ setInvitationUrl: async (request) => {
4314
+ this._invitationUrl = request.invitationUrl;
4315
+ this._deviceInvitationParam = request.deviceInvitationParam;
4316
+ this._spaceInvitationParam = request.spaceInvitationParam;
4317
+ this.invitationUrlUpdate.emit(request);
4318
+ }
4319
+ }
4320
+ },
4321
+ port: this._port
4322
+ });
4323
+ await this._appRpc.open();
4324
+ }
4325
+ async close() {
4326
+ await this._appRpc?.close();
4327
+ this._appRpc = void 0;
4328
+ }
4329
+ };
4330
+ var en_US_exports = {};
4331
+ (0, import_chunk_Q7SFCCGT.__export)(en_US_exports, {
4332
+ os: () => os
4333
+ });
4334
+ var os = {
4335
+ "manage profile label": "Manage identity",
4336
+ "identity offline description": "Offline",
4337
+ "sidebar label": "DXOS sidebar",
4338
+ "copy invitation code label": "Copy URL",
4339
+ "copy success label": "Copied",
4340
+ "copy self public key label": "Copy public key",
4341
+ "open share panel label": "View QR code",
4342
+ "joining space heading": "Joining space",
4343
+ "join space heading": "Enter space invitation",
4344
+ "halo heading": "Initialize device identity",
4345
+ "exit label": "Exit",
4346
+ "identity selector title": "Join as",
4347
+ "identity radio group title": "Select an identity you\u2019ve associated with this device already",
4348
+ "add identity label": "Add",
4349
+ "continue label": "Continue",
4350
+ "back label": "Back",
4351
+ "next label": "Next",
4352
+ "close label": "Close",
4353
+ "auth choices label": "Choose an identity",
4354
+ "create identity label": "Create an identity",
4355
+ "create identity description": "Create a new identity.",
4356
+ "recover identity label": "Use a seed phrase",
4357
+ "recover identity description": "Enter your seed phrase to log in manually.",
4358
+ "join identity label": "Use another device",
4359
+ "join identity description": "Add this device to an identity you\u2019re already logged into on another device.",
4360
+ "deselect identity label": "Back to identities",
4361
+ "addition method chooser title": "An identity is required to continue",
4362
+ "new identity input label": "Set display name",
4363
+ "recover identity input label": "Type or paste your seed phrase",
4364
+ "failed to create identity message": "Failed to create an identity.",
4365
+ "failed to recover identity message": "Failed to recover an identity from the provided seed phrase.",
4366
+ "failed to authenticate message": "Incorrect code.",
4367
+ "identity added label": "Created identity & added to this device:",
4368
+ "join space as identity heading": "<part>as </part><part><icon/><label>{{labelValue}}</label></part>",
4369
+ "error status label": "Failed",
4370
+ "timeout status label": "Timed out",
4371
+ "cancelled status label": "Cancelled",
4372
+ "init status label": "Ready to connect",
4373
+ "connecting status label": "Connecting\u2026",
4374
+ "connected status label": "Enter authentication code",
4375
+ "authenticating status label": "Enter authentication code",
4376
+ "success status label": "Success",
4377
+ "cancel label": "Cancel",
4378
+ "done label": "Done",
4379
+ "reset label": "Start over",
4380
+ "auth code input label": "Enter the verification code",
4381
+ "invitation input label": "Paste an invitation code or URL",
4382
+ "create device invitation label": "Add device",
4383
+ "create space invitation label": "Invite",
4384
+ "qr label": "Scan to accept invitation",
4385
+ "empty invitations message": "No pending invitations",
4386
+ "empty device list message": "No devices authenticated other than this device.",
4387
+ "show all spaces label": "All spaces",
4388
+ "all spaces label": "All spaces",
4389
+ "create space label": "Create a new space",
4390
+ "join space label": "Join a space",
4391
+ "show current space label": "Current space",
4392
+ "view space invitations label": "View space invitations",
4393
+ "toggle sidebar label": "Open/close sidebar",
4394
+ "open sidebar label": "Open sidebar",
4395
+ "close sidebar label": "Close sidebar",
4396
+ "welcome message": "Welcome",
4397
+ "selecting identity heading": "Selecting identity",
4398
+ "devices heading": "Devices",
4399
+ "identity heading": "Profile settings",
4400
+ "choose add device label": "Add device",
4401
+ "choose devices label": "Manage devices",
4402
+ "choose profile label": "Edit profile",
4403
+ "choose sign out label": "Reset storage",
4404
+ "choose join new identity label": "Join existing device",
4405
+ "empty space members message": "There is nobody in this space yet.",
4406
+ "back to all invitations label": "Back to all invitations",
4407
+ "invitation heading": "Invitation",
4408
+ "invitation list heading": "Invitations",
4409
+ "device invitation list heading": "Pending device invitations",
4410
+ "space invitation list heading": "Pending invitations",
4411
+ "device list heading": "Devices",
4412
+ "space member list heading": "Members",
4413
+ "space panel heading": "Space membership",
4414
+ "auth code message": "Enter the following auth code on the joining device.",
4415
+ "auth other device emoji message": "Be sure the other device shows the following symbol:",
4416
+ "display name input label": "Display name",
4417
+ "display name input placeholder": "Enter a display name",
4418
+ "invite one label": "Single-use invitation",
4419
+ "invite one description": "Only one user may join.",
4420
+ "invite one qr label": "Single-use invitation",
4421
+ "invite one list item label": "Active single-use invitation",
4422
+ "invite many label": "Multi-use invitation",
4423
+ "invite many description": "Anyone with the link can join.",
4424
+ "invite many qr label": "Multi-use invitation",
4425
+ "invite many list item label": "Active multi-use invitation",
4426
+ "invite options label": "Change the active invite option.",
4427
+ "reset in progress label": "Resetting...",
4428
+ "confirm label": "Confirm",
4429
+ "reset storage input label": "WARNING: This will delete all data on this device. Type {{confirmationValue}} to continue.",
4430
+ "join new identity input label": "WARNING: To join an existing device all data on this device will be deleted. Type {{confirmationValue}} to continue.",
4431
+ "failed to reset identity message": "Failed to reset identity.",
4432
+ "confirmation value": "RESET",
4433
+ "confirmation placeholder": "Enter {{confirmationValue}} to continue.",
4434
+ "sign out chooser title": "Danger zone",
4435
+ "sign out chooser message": "Proceeding with the action below will erase all data on this device.",
4436
+ "join new identity label": "Join a new identity",
4437
+ "reset device label": "Reset storage",
4438
+ "reset device confirm message": "Are you sure you want to reset your device? All data will be lost.",
4439
+ "emoji and color label": "Emoji and color",
4440
+ "clear label": "Use default",
4441
+ "select emoji label": "Avatar emoji",
4442
+ "select hue label": "Avatar background color",
4443
+ "resetting message": "One moment while the device is reset\u2026",
4444
+ "red label": "Red",
4445
+ "orange label": "Orange",
4446
+ "amber label": "Amber",
4447
+ "yellow label": "Yellow",
4448
+ "lime label": "Lime",
4449
+ "green label": "Green",
4450
+ "emerald label": "Emerald",
4451
+ "teal label": "Teal",
4452
+ "cyan label": "Cyan",
4453
+ "sky label": "Sky",
4454
+ "blue label": "Blue",
4455
+ "indigo label": "Indigo",
4456
+ "violet label": "Violet",
4457
+ "purple label": "Purple",
4458
+ "fuchsia label": "Fuchsia",
4459
+ "pink label": "Pink",
4460
+ "rose label": "Rose",
4461
+ "current device tag label": "This device",
4462
+ "device name placeholder": "{{platform}} on {{os}}",
4463
+ "more options label": "More options",
4464
+ "disconnect label": "Go offline.",
4465
+ "connect label": "Go online.",
4466
+ "edit device label": "Edit device name & avatar",
4467
+ "agent heading": "Agent",
4468
+ "create agent clickwrap": 'By creating an agent, you agree to our <tosLink href="https://dxos.org/tos">Terms of\xA0Service</tosLink>.',
4469
+ "create agent description": "Creating an agent helps keep your devices and peers in-sync. An agent is like any other device, but since it\u2019s always online your changes will sync even when all your physical devices are\xA0asleep.",
4470
+ "create agent label": "Start an agent",
4471
+ "destroy agent label": "Shut down agent",
4472
+ "agent device label": "Your agent",
4473
+ "shell fallback title": "Shell failed to connect",
4474
+ "creating agent label": "Starting agent\u2026",
4475
+ "destroying agent label": "Stopping agent\u2026",
4476
+ "getting agent label": "Checking agent status\u2026",
4477
+ "agent requested label": "Agent requested",
4478
+ "agent requested description": "The agent service is creating an agent for you. Once the agent connects, it will display in the devices list.",
4479
+ "authenticating label": "Authenticating\u2026",
4480
+ "create recovery code label": "Create recovery code",
4481
+ "choose recover identity label": "Recover identity"
4482
+ };
4483
+ var osTranslations = {
4484
+ "en-US": en_US_exports
4485
+ };
4486
+ var runShell = async (config = new import_react_client11.Config()) => {
4487
+ const runtime = new ShellRuntimeImpl((0, import_rpc_tunnel.createIFramePort)({
4488
+ channel: import_client_protocol.DEFAULT_SHELL_CHANNEL
4489
+ }));
4490
+ await runtime.open();
4491
+ try {
4492
+ const services = new import_react_client11.ClientServicesProxy((0, import_rpc_tunnel.createIFramePort)({
4493
+ channel: import_client_protocol.DEFAULT_CLIENT_CHANNEL
4494
+ }));
4495
+ (0, import_client.createRoot)(document.getElementById("root")).render(/* @__PURE__ */ import_react67.default.createElement(import_react67.StrictMode, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.ThemeProvider, {
4496
+ tx: import_react_ui_theme31.defaultTx,
4497
+ resourceExtensions: [
4498
+ osTranslations
4499
+ ]
4500
+ }, /* @__PURE__ */ import_react67.default.createElement(import_react_client11.ClientProvider, {
4501
+ config,
4502
+ services,
4503
+ noBanner: true
4504
+ }, /* @__PURE__ */ import_react67.default.createElement(ClipboardProvider, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Tooltip.Provider, null, /* @__PURE__ */ import_react67.default.createElement(import_react_client11.AgentHostingProvider, null, /* @__PURE__ */ import_react67.default.createElement(Shell, {
4505
+ runtime
4506
+ }))))))));
4507
+ } catch {
4508
+ (0, import_client.createRoot)(document.getElementById("root")).render(/* @__PURE__ */ import_react67.default.createElement(import_react67.StrictMode, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.ThemeProvider, {
4509
+ tx: import_react_ui_theme31.defaultTx,
4510
+ resourceExtensions: [
4511
+ osTranslations
4512
+ ]
4513
+ }, /* @__PURE__ */ import_react67.default.createElement(Fallback, {
4514
+ onClose: () => runtime.setAppContext({
4515
+ display: import_react_client11.ShellDisplay.NONE
4516
+ })
4517
+ }))));
4518
+ }
4519
+ };
4520
+ var Fallback = ({ onClose }) => {
4521
+ const { t } = (0, import_react_ui35.useTranslation)("os");
4522
+ return /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Root, {
4523
+ modal: true,
4524
+ open: true,
4525
+ onOpenChange: () => onClose?.()
4526
+ }, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Overlay, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Content, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Title, null, t("shell fallback title")), /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Close, {
4527
+ asChild: true,
4528
+ onClick: () => onClose?.()
4529
+ }, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Button, {
4530
+ variant: "primary"
4531
+ }, t("close label"))))));
4532
+ };
4533
+ var MemoryShellRuntime = class {
4534
+ constructor({ layout, invitationCode, spaceKey, invitationUrl, deviceInvitationParam, spaceInvitationParam } = {}) {
4535
+ this.layoutUpdate = new import_async2.Event();
4536
+ this.invitationUrlUpdate = new import_async2.Event();
4537
+ this.contextUpdate = new import_async2.Event();
4538
+ this._layout = layout ?? import_react_client15.ShellLayout.DEFAULT;
4539
+ this._invitationCode = invitationCode;
4540
+ this._spaceKey = spaceKey;
4541
+ this._invitationUrl = invitationUrl ?? window.location.origin;
4542
+ this._deviceInvitationParam = deviceInvitationParam ?? "deviceInvitationCode";
4543
+ this._spaceInvitationParam = spaceInvitationParam ?? "spaceInvitationCode";
4544
+ }
4545
+ get layout() {
4546
+ return this._layout;
4547
+ }
4548
+ get invitationCode() {
4549
+ return this._invitationCode;
4550
+ }
4551
+ get spaceKey() {
4552
+ return this._spaceKey;
4553
+ }
4554
+ get invitationUrl() {
4555
+ return this._invitationUrl;
4556
+ }
4557
+ get deviceInvitationParam() {
4558
+ return this._deviceInvitationParam;
4559
+ }
4560
+ get spaceInvitationParam() {
4561
+ return this._spaceInvitationParam;
4562
+ }
4563
+ setLayout(request) {
4564
+ this._layout = request.layout;
4565
+ this._invitationCode = request.invitationCode;
4566
+ this._spaceKey = request.spaceKey;
4567
+ this.layoutUpdate.emit(request);
4568
+ }
4569
+ setInvitationUrl(request) {
4570
+ this._invitationUrl = request.invitationUrl;
4571
+ this._deviceInvitationParam = request.deviceInvitationParam;
4572
+ this._spaceInvitationParam = request.spaceInvitationParam;
4573
+ this.invitationUrlUpdate.emit(request);
4574
+ }
4575
+ async setAppContext(context) {
4576
+ this.contextUpdate.emit(context);
4577
+ }
4578
+ };
4579
+ var ShellContext = /* @__PURE__ */ (0, import_react71.createContext)({});
4580
+ var useShell = () => {
4581
+ const client = (0, import_react_client14.useClient)();
4582
+ const { runtime, setDisplay } = (0, import_react71.useContext)(ShellContext);
4583
+ const setLayout = async (layout, options) => {
4584
+ if (runtime) {
4585
+ if (layout === import_react_client14.ShellLayout.DEFAULT) {
4586
+ setDisplay?.(import_react_client14.ShellDisplay.NONE);
4587
+ } else {
4588
+ setDisplay?.(import_react_client14.ShellDisplay.FULLSCREEN);
4589
+ }
4590
+ runtime.setLayout({
4591
+ layout,
4592
+ ...options
4593
+ });
4594
+ }
4595
+ await client.shell.open(layout, options);
4596
+ };
4597
+ return {
4598
+ setLayout
4599
+ };
4600
+ };
4601
+ var ShellProvider = ({ space, deviceInvitationCode, spaceInvitationCode, onJoinedSpace, children }) => {
4602
+ const client = (0, import_react_client14.useClient)();
4603
+ const identity = (0, import_halo5.useIdentity)();
4604
+ const [display, setDisplay] = (0, import_react71.useState)(!identity || spaceInvitationCode || deviceInvitationCode ? import_react_client14.ShellDisplay.FULLSCREEN : import_react_client14.ShellDisplay.NONE);
4605
+ const shellRuntime = (0, import_react71.useMemo)(() => {
4606
+ if (client.config.get("runtime.app.env.DX_VAULT") !== "false") {
4607
+ return;
4608
+ }
4609
+ if (spaceInvitationCode) {
4610
+ return new MemoryShellRuntime({
4611
+ layout: import_react_client14.ShellLayout.JOIN_SPACE,
4612
+ invitationCode: spaceInvitationCode
4613
+ });
4614
+ }
4615
+ if (deviceInvitationCode) {
4616
+ return new MemoryShellRuntime({
4617
+ layout: import_react_client14.ShellLayout.INITIALIZE_IDENTITY,
4618
+ invitationCode: deviceInvitationCode
4619
+ });
4620
+ }
4621
+ return new MemoryShellRuntime({
4622
+ layout: identity ? import_react_client14.ShellLayout.DEFAULT : import_react_client14.ShellLayout.INITIALIZE_IDENTITY
4623
+ });
4624
+ }, [
4625
+ client,
4626
+ identity,
4627
+ spaceInvitationCode,
4628
+ deviceInvitationCode
4629
+ ]);
4630
+ const handleKeyDown = (0, import_react71.useCallback)((event) => {
4631
+ if (!space || !shellRuntime) {
4632
+ return;
4633
+ }
4634
+ const modifier = event.ctrlKey || event.metaKey;
4635
+ if (event.key === ">" && event.shiftKey && modifier) {
4636
+ shellRuntime.setLayout({
4637
+ layout: import_react_client14.ShellLayout.SHARE_IDENTITY
4638
+ });
4639
+ setDisplay(import_react_client14.ShellDisplay.FULLSCREEN);
4640
+ } else if (event.key === "." && modifier) {
4641
+ shellRuntime.setLayout({
4642
+ layout: import_react_client14.ShellLayout.SPACE,
4643
+ spaceKey: space.key
4644
+ });
4645
+ setDisplay(import_react_client14.ShellDisplay.FULLSCREEN);
4646
+ }
4647
+ }, [
4648
+ space,
4649
+ shellRuntime
4650
+ ]);
4651
+ (0, import_react71.useEffect)(() => {
4652
+ if (!shellRuntime) {
4653
+ return;
4654
+ }
4655
+ window.addEventListener("keydown", handleKeyDown);
4656
+ return () => window.removeEventListener("keydown", handleKeyDown);
4657
+ }, [
4658
+ shellRuntime,
4659
+ handleKeyDown
4660
+ ]);
4661
+ (0, import_react71.useEffect)(() => {
4662
+ if (!shellRuntime) {
4663
+ return;
4664
+ }
4665
+ return shellRuntime.contextUpdate.on(({ display: display2, spaceKey }) => {
4666
+ if (display2) {
4667
+ setDisplay(display2);
4668
+ }
4669
+ onJoinedSpace?.(spaceKey);
4670
+ });
4671
+ }, [
4672
+ shellRuntime
4673
+ ]);
4674
+ return /* @__PURE__ */ import_react71.default.createElement(import_react71.default.Fragment, null, shellRuntime && /* @__PURE__ */ import_react71.default.createElement("div", {
4675
+ className: (0, import_react_ui_theme32.mx)(display === import_react_client14.ShellDisplay.NONE ? "hidden" : "")
4676
+ }, /* @__PURE__ */ import_react71.default.createElement(Shell, {
4677
+ runtime: shellRuntime
4678
+ })), /* @__PURE__ */ import_react71.default.createElement(ShellContext.Provider, {
4679
+ value: {
4680
+ runtime: shellRuntime,
4681
+ setDisplay
4682
+ }
4683
+ }, children));
4684
+ };
4685
+ // Annotate the CommonJS export names for ESM import in node:
4686
+ 0 && (module.exports = {
4687
+ Action,
4688
+ Actions,
4689
+ AgentConfig,
4690
+ AuthCode,
4691
+ BifurcatedAction,
4692
+ Centered,
4693
+ ClipboardContext,
4694
+ ClipboardProvider,
4695
+ CloseButton,
4696
+ CompoundButton,
4697
+ ConfirmReset,
4698
+ ConfirmResetImpl,
4699
+ CopyButton,
4700
+ CopyButtonIconOnly,
4701
+ DeviceList,
4702
+ Emoji,
4703
+ EmojiPickerBlock,
4704
+ EmojiPickerToolbarButton,
4705
+ Heading,
4706
+ HuePickerBlock,
4707
+ HuePickerToolbarButton,
4708
+ IdentityDialog,
4709
+ IdentityListItem,
4710
+ IdentityPanel,
4711
+ IdentityPanelImpl,
4712
+ Input,
4713
+ InvitationList,
4714
+ InvitationListContainer,
4715
+ InvitationListItem,
4716
+ InvitationListItemImpl,
4717
+ InvitationManager,
4718
+ JoinDialog,
4719
+ JoinPanel,
4720
+ JoinPanelImpl,
4721
+ Label,
4722
+ Shell,
4723
+ ShellContext,
4724
+ ShellProvider,
4725
+ SpaceDialog,
4726
+ SpaceListItem,
4727
+ SpaceMemberList,
4728
+ SpaceMemberListImpl,
4729
+ SpacePanel,
4730
+ SpacePanelImpl,
4731
+ StatusPanel,
4732
+ StepHeading,
4733
+ Viewport,
4734
+ activeBgColor,
4735
+ activeStrokeColor,
4736
+ activeTextColor,
4737
+ cancelledBgColor,
4738
+ cancelledStrokeColor,
4739
+ cancelledTextColor,
4740
+ createViewportScope,
4741
+ errorBgColor,
4742
+ errorStrokeColor,
4743
+ errorTextColor,
4744
+ inactiveBgColor,
4745
+ inactiveStrokeColor,
4746
+ inactiveTextColor,
4747
+ osTranslations,
4748
+ resolvedBgColor,
4749
+ resolvedStrokeColor,
4750
+ resolvedTextColor,
4751
+ runShell,
4752
+ stepStyles,
4753
+ successBgColor,
4754
+ successStrokeColor,
4755
+ successTextColor,
4756
+ useClipboardContext,
4757
+ useShell,
4758
+ useViewportContext
4759
+ });
4760
+ //# sourceMappingURL=react.cjs.map