@arbidocs/blocks 0.4.5 → 0.4.6

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 (131) hide show
  1. package/README.md +46 -6
  2. package/dist/agents/index.cjs +163 -162
  3. package/dist/agents/index.js +6 -5
  4. package/dist/chat/ChatMessageContent.d.ts +16 -0
  5. package/dist/chat/ChatPage.d.ts +11 -8
  6. package/dist/chat/ChatThreads.d.ts +3 -1
  7. package/dist/chat/CitationMark.d.ts +18 -0
  8. package/dist/chat/chat-page-types.d.ts +75 -1
  9. package/dist/chat/index.cjs +126 -117
  10. package/dist/chat/index.d.ts +3 -1
  11. package/dist/chat/index.js +5 -4
  12. package/dist/{chunk-3MIQASHO.cjs → chunk-23XL6SVZ.cjs} +39 -19
  13. package/dist/chunk-23XL6SVZ.cjs.map +1 -0
  14. package/dist/{chunk-ULWRNGGE.cjs → chunk-2ZTONLT5.cjs} +4 -25
  15. package/dist/chunk-2ZTONLT5.cjs.map +1 -0
  16. package/dist/{chunk-O637DUKS.cjs → chunk-56BUD74K.cjs} +28 -28
  17. package/dist/{chunk-O637DUKS.cjs.map → chunk-56BUD74K.cjs.map} +1 -1
  18. package/dist/{chunk-YLOKCIQJ.cjs → chunk-5SLLMK5K.cjs} +421 -115
  19. package/dist/chunk-5SLLMK5K.cjs.map +1 -0
  20. package/dist/{chunk-SS23F63U.cjs → chunk-5ZBP7TCD.cjs} +55 -3
  21. package/dist/chunk-5ZBP7TCD.cjs.map +1 -0
  22. package/dist/{chunk-3PZPRAAR.cjs → chunk-67HGXV4I.cjs} +14 -14
  23. package/dist/{chunk-3PZPRAAR.cjs.map → chunk-67HGXV4I.cjs.map} +1 -1
  24. package/dist/{chunk-RCP6THBS.js → chunk-7OCFHEE6.js} +3 -3
  25. package/dist/{chunk-RCP6THBS.js.map → chunk-7OCFHEE6.js.map} +1 -1
  26. package/dist/{chunk-TX2ZICS7.js → chunk-CPMNAJLF.js} +4 -24
  27. package/dist/chunk-CPMNAJLF.js.map +1 -0
  28. package/dist/{chunk-5XTZFH65.js → chunk-CVFBSUXL.js} +5 -5
  29. package/dist/{chunk-5XTZFH65.js.map → chunk-CVFBSUXL.js.map} +1 -1
  30. package/dist/chunk-DCDVWPMB.cjs +29 -0
  31. package/dist/chunk-DCDVWPMB.cjs.map +1 -0
  32. package/dist/{chunk-TI4UTYRL.js → chunk-EY2RJW27.js} +258 -10
  33. package/dist/chunk-EY2RJW27.js.map +1 -0
  34. package/dist/{chunk-7YADKWZT.js → chunk-G2E3O3HI.js} +3 -3
  35. package/dist/{chunk-7YADKWZT.js.map → chunk-G2E3O3HI.js.map} +1 -1
  36. package/dist/{chunk-6YHWXMPQ.js → chunk-G2T3KTZ3.js} +419 -115
  37. package/dist/chunk-G2T3KTZ3.js.map +1 -0
  38. package/dist/{chunk-2NNTQLBY.js → chunk-IAKUTBPX.js} +4 -4
  39. package/dist/{chunk-2NNTQLBY.js.map → chunk-IAKUTBPX.js.map} +1 -1
  40. package/dist/{chunk-IZHWP6WQ.cjs → chunk-JG4TFS3Z.cjs} +6 -6
  41. package/dist/{chunk-IZHWP6WQ.cjs.map → chunk-JG4TFS3Z.cjs.map} +1 -1
  42. package/dist/chunk-JLOYWXRB.js +1156 -0
  43. package/dist/chunk-JLOYWXRB.js.map +1 -0
  44. package/dist/{chunk-WJZBJUPX.js → chunk-KXMDOTGW.js} +56 -4
  45. package/dist/chunk-KXMDOTGW.js.map +1 -0
  46. package/dist/{chunk-2VBJ763Y.js → chunk-KZJAG7T3.js} +37 -7
  47. package/dist/chunk-KZJAG7T3.js.map +1 -0
  48. package/dist/{chunk-RIL7G7AS.cjs → chunk-MGUHR3JI.cjs} +4 -4
  49. package/dist/{chunk-RIL7G7AS.cjs.map → chunk-MGUHR3JI.cjs.map} +1 -1
  50. package/dist/{chunk-NPKGUQU5.js → chunk-NJL4LIXX.js} +4 -4
  51. package/dist/{chunk-NPKGUQU5.js.map → chunk-NJL4LIXX.js.map} +1 -1
  52. package/dist/{chunk-DN3NFNIA.cjs → chunk-QMDLPO3M.cjs} +266 -10
  53. package/dist/chunk-QMDLPO3M.cjs.map +1 -0
  54. package/dist/chunk-TJMKFY5P.js +27 -0
  55. package/dist/chunk-TJMKFY5P.js.map +1 -0
  56. package/dist/{chunk-3PJCET7H.js → chunk-UHVNYKV2.js} +38 -18
  57. package/dist/chunk-UHVNYKV2.js.map +1 -0
  58. package/dist/{chunk-6CHMNKXC.cjs → chunk-UTYQPVIW.cjs} +11 -11
  59. package/dist/chunk-UTYQPVIW.cjs.map +1 -0
  60. package/dist/{chunk-KHX2BX3S.cjs → chunk-VGOFFCMT.cjs} +37 -5
  61. package/dist/chunk-VGOFFCMT.cjs.map +1 -0
  62. package/dist/{chunk-67MKU5U7.js → chunk-YMHGF6R5.js} +8 -8
  63. package/dist/chunk-YMHGF6R5.js.map +1 -0
  64. package/dist/chunk-YVIOCITQ.cjs +1186 -0
  65. package/dist/chunk-YVIOCITQ.cjs.map +1 -0
  66. package/dist/{chunk-MVNCQDDE.cjs → chunk-ZVPTFTGV.cjs} +4 -4
  67. package/dist/{chunk-MVNCQDDE.cjs.map → chunk-ZVPTFTGV.cjs.map} +1 -1
  68. package/dist/collaboration/index.cjs +38 -37
  69. package/dist/collaboration/index.js +3 -2
  70. package/dist/connect/index.cjs +358 -19
  71. package/dist/connect/index.cjs.map +1 -1
  72. package/dist/connect/index.d.ts +1 -0
  73. package/dist/connect/index.js +341 -9
  74. package/dist/connect/index.js.map +1 -1
  75. package/dist/connection/ConnectedSettings.d.ts +64 -0
  76. package/dist/facts/index.cjs +2 -2
  77. package/dist/facts/index.js +2 -2
  78. package/dist/files/index.cjs +15 -14
  79. package/dist/files/index.cjs.map +1 -1
  80. package/dist/files/index.js +5 -4
  81. package/dist/files/index.js.map +1 -1
  82. package/dist/home/index.cjs +19 -19
  83. package/dist/home/index.js +4 -4
  84. package/dist/index.cjs +526 -477
  85. package/dist/index.cjs.map +1 -1
  86. package/dist/index.js +17 -16
  87. package/dist/index.js.map +1 -1
  88. package/dist/lib/bottom-inset.d.ts +16 -0
  89. package/dist/lib/useElementSize.d.ts +13 -0
  90. package/dist/lib/useFillHeight.d.ts +10 -0
  91. package/dist/settings/account-views.d.ts +55 -0
  92. package/dist/settings/index.cjs +179 -1148
  93. package/dist/settings/index.cjs.map +1 -1
  94. package/dist/settings/index.d.ts +1 -0
  95. package/dist/settings/index.js +10 -1073
  96. package/dist/settings/index.js.map +1 -1
  97. package/dist/shell/InstallPrompt.d.ts +28 -0
  98. package/dist/shell/MobileBars.d.ts +1 -1
  99. package/dist/shell/index.cjs +85 -45
  100. package/dist/shell/index.d.ts +4 -0
  101. package/dist/shell/index.js +3 -3
  102. package/dist/shell/install-instructions.d.ts +19 -0
  103. package/dist/shell/types.d.ts +6 -0
  104. package/dist/shell/use-install-prompt.d.ts +49 -0
  105. package/dist/site/index.cjs +62 -62
  106. package/dist/site/index.js +2 -2
  107. package/dist/studio/index.cjs +78 -77
  108. package/dist/studio/index.cjs.map +1 -1
  109. package/dist/studio/index.js +8 -7
  110. package/dist/studio/index.js.map +1 -1
  111. package/dist/theme/ThemeEditor.d.ts +4 -2
  112. package/dist/workspaces/index.cjs +4 -3
  113. package/dist/workspaces/index.cjs.map +1 -1
  114. package/dist/workspaces/index.js +3 -2
  115. package/dist/workspaces/index.js.map +1 -1
  116. package/package.json +8 -4
  117. package/src/blocks.css +30 -0
  118. package/dist/chunk-2VBJ763Y.js.map +0 -1
  119. package/dist/chunk-3MIQASHO.cjs.map +0 -1
  120. package/dist/chunk-3PJCET7H.js.map +0 -1
  121. package/dist/chunk-67MKU5U7.js.map +0 -1
  122. package/dist/chunk-6CHMNKXC.cjs.map +0 -1
  123. package/dist/chunk-6YHWXMPQ.js.map +0 -1
  124. package/dist/chunk-DN3NFNIA.cjs.map +0 -1
  125. package/dist/chunk-KHX2BX3S.cjs.map +0 -1
  126. package/dist/chunk-SS23F63U.cjs.map +0 -1
  127. package/dist/chunk-TI4UTYRL.js.map +0 -1
  128. package/dist/chunk-TX2ZICS7.js.map +0 -1
  129. package/dist/chunk-ULWRNGGE.cjs.map +0 -1
  130. package/dist/chunk-WJZBJUPX.js.map +0 -1
  131. package/dist/chunk-YLOKCIQJ.cjs.map +0 -1
@@ -0,0 +1,1156 @@
1
+ "use client";
2
+ import { PasswordStrengthInput } from './chunk-VILAPTCB.js';
3
+ import { formatCount } from './chunk-OXF2IFXG.js';
4
+ import { useRestoreFocus } from './chunk-TJMKFY5P.js';
5
+ import { testIdOr, prefixedTestId } from './chunk-7F6CBP3Z.js';
6
+ import { useMemo, useRef, useId, useState } from 'react';
7
+ import { Loader2, Camera, ChevronRight, ChevronDown, Check, Pencil, Mail, CheckCircle2, AlertCircle, Radio, AlertTriangle, LogOut } from 'lucide-react';
8
+ import { Avatar, AvatarImage, AvatarFallback, cn, Input, Button, Tooltip, TooltipTrigger, TooltipContent, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, Collapsible, CollapsibleTrigger, CollapsibleContent, Switch, Checkbox, Badge } from '@arbidocs/react/ui';
9
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
10
+
11
+ var DEFAULT_AVATAR_PICKER_LABELS = {
12
+ uploadingPicture: "Uploading picture",
13
+ changeProfilePicture: "Change profile picture",
14
+ change: "Change"
15
+ };
16
+ function AvatarPicker({
17
+ pictureUrl,
18
+ initials,
19
+ fallbackClassName,
20
+ isUploading,
21
+ disabled,
22
+ onFileChosen,
23
+ testId = "avatar-uploader-input",
24
+ labels
25
+ }) {
26
+ const l = useMemo(() => ({ ...DEFAULT_AVATAR_PICKER_LABELS, ...labels }), [labels]);
27
+ const fileInputRef = useRef(null);
28
+ const handleChange = (e) => {
29
+ const file = e.target.files?.[0];
30
+ e.target.value = "";
31
+ if (file) onFileChosen(file);
32
+ };
33
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "avatar-picker", className: "group/avatar relative shrink-0", children: [
34
+ /* @__PURE__ */ jsxs(Avatar, { className: "h-20 w-20 ring-1 ring-border", children: [
35
+ pictureUrl && /* @__PURE__ */ jsx(AvatarImage, { src: pictureUrl, alt: initials }),
36
+ /* @__PURE__ */ jsx(
37
+ AvatarFallback,
38
+ {
39
+ className: cn("text-2xl font-semibold leading-none text-white", fallbackClassName),
40
+ children: initials
41
+ }
42
+ )
43
+ ] }),
44
+ /* @__PURE__ */ jsx(
45
+ "button",
46
+ {
47
+ type: "button",
48
+ onClick: () => fileInputRef.current?.click(),
49
+ disabled: disabled || isUploading,
50
+ className: cn(
51
+ "absolute inset-0 flex items-center justify-center rounded-full",
52
+ "bg-foreground/70 text-background",
53
+ "opacity-0 focus-visible:opacity-100 group-hover/avatar:opacity-100",
54
+ // Touch has no hover: keep the change affordance visible (lighter scrim over the photo).
55
+ "pointer-coarse:opacity-100",
56
+ "transition-opacity duration-200",
57
+ "disabled:cursor-not-allowed disabled:opacity-100"
58
+ ),
59
+ "aria-label": isUploading ? l.uploadingPicture : l.changeProfilePicture,
60
+ children: isUploading ? /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin" }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-0.5", children: [
61
+ /* @__PURE__ */ jsx(Camera, { className: "h-5 w-5" }),
62
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: l.change })
63
+ ] })
64
+ }
65
+ ),
66
+ /* @__PURE__ */ jsx(
67
+ "span",
68
+ {
69
+ "aria-hidden": "true",
70
+ className: "pointer-events-none absolute -bottom-1 -right-1 flex h-7 w-7 items-center justify-center rounded-full bg-background text-muted-foreground ring-1 ring-border",
71
+ children: /* @__PURE__ */ jsx(Camera, { className: "h-3.5 w-3.5" })
72
+ }
73
+ ),
74
+ /* @__PURE__ */ jsx(
75
+ "input",
76
+ {
77
+ ref: fileInputRef,
78
+ type: "file",
79
+ accept: "image/png,image/jpeg,image/webp,image/gif",
80
+ onChange: handleChange,
81
+ hidden: true,
82
+ className: "hidden",
83
+ "data-testid": testId
84
+ }
85
+ )
86
+ ] });
87
+ }
88
+ var DEFAULT_SETTINGS_DANGER_ZONE_LABELS = {
89
+ dangerZone: "Danger Zone"
90
+ };
91
+ function SettingsPanel({ className, testId, ...props }) {
92
+ return /* @__PURE__ */ jsx(
93
+ "div",
94
+ {
95
+ "data-slot": "settings-panel",
96
+ "data-testid": testId,
97
+ className: cn("mx-auto w-full max-w-xl space-y-6", className),
98
+ ...props
99
+ }
100
+ );
101
+ }
102
+ function SettingsSection({
103
+ icon,
104
+ title,
105
+ description,
106
+ action,
107
+ testId,
108
+ className,
109
+ children,
110
+ ...props
111
+ }) {
112
+ return /* @__PURE__ */ jsxs(
113
+ "section",
114
+ {
115
+ "data-slot": "settings-section",
116
+ "data-testid": testId,
117
+ className: cn("space-y-3", className),
118
+ ...props,
119
+ children: [
120
+ (title || action) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
121
+ title && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
122
+ icon && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground [&_svg]:h-4 [&_svg]:w-4", children: icon }),
123
+ /* @__PURE__ */ jsx("h2", { className: "text-base font-semibold text-foreground", children: title })
124
+ ] }),
125
+ action
126
+ ] }),
127
+ description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }),
128
+ children
129
+ ]
130
+ }
131
+ );
132
+ }
133
+ function SettingsRow({
134
+ label,
135
+ labelFor,
136
+ description,
137
+ children,
138
+ testId,
139
+ className,
140
+ ...props
141
+ }) {
142
+ return /* @__PURE__ */ jsxs(
143
+ "div",
144
+ {
145
+ "data-slot": "settings-row",
146
+ "data-testid": testId,
147
+ className: cn(
148
+ "flex flex-col gap-2 py-2 @xl:flex-row @xl:items-center @xl:justify-between @xl:gap-6",
149
+ className
150
+ ),
151
+ ...props,
152
+ children: [
153
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
154
+ labelFor ? /* @__PURE__ */ jsx("label", { htmlFor: labelFor, className: "text-sm font-medium text-foreground", children: label }) : /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-foreground", children: label }),
155
+ description && /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: description })
156
+ ] }),
157
+ children && /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children })
158
+ ]
159
+ }
160
+ );
161
+ }
162
+ function SettingsCard({ padding = "md", className, ...props }) {
163
+ return /* @__PURE__ */ jsx(
164
+ "div",
165
+ {
166
+ "data-slot": "settings-card",
167
+ className: cn(
168
+ "rounded-lg bg-muted",
169
+ padding === "md" ? "space-y-5 p-5" : "divide-y divide-border p-2",
170
+ className
171
+ ),
172
+ ...props
173
+ }
174
+ );
175
+ }
176
+ function SettingsActionRow({ title, description, onClick, testId }) {
177
+ return /* @__PURE__ */ jsxs(
178
+ "button",
179
+ {
180
+ type: "button",
181
+ onClick,
182
+ "data-slot": "settings-action-row",
183
+ "data-testid": testId,
184
+ className: "flex w-full items-center gap-3 rounded-md px-3 py-3 text-left transition-colors hover:bg-background/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:min-h-11",
185
+ children: [
186
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
187
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-semibold text-foreground", children: title }),
188
+ description && /* @__PURE__ */ jsx("div", { className: "mt-0.5 text-xs leading-relaxed text-muted-foreground", children: description })
189
+ ] }),
190
+ /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 shrink-0 text-muted-foreground" })
191
+ ]
192
+ }
193
+ );
194
+ }
195
+ function SettingsDangerZone({
196
+ isOpen,
197
+ onToggle,
198
+ label,
199
+ title,
200
+ description,
201
+ action,
202
+ labels
203
+ }) {
204
+ const l = useMemo(() => ({ ...DEFAULT_SETTINGS_DANGER_ZONE_LABELS, ...labels }), [labels]);
205
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "settings-danger-zone", className: "mt-8 pt-2", children: [
206
+ /* @__PURE__ */ jsxs(
207
+ "button",
208
+ {
209
+ type: "button",
210
+ onClick: onToggle,
211
+ "aria-expanded": isOpen,
212
+ className: "flex w-full items-center gap-1.5 text-left pointer-coarse:min-h-11",
213
+ children: [
214
+ isOpen ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" }),
215
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-muted-foreground", children: label ?? l.dangerZone })
216
+ ]
217
+ }
218
+ ),
219
+ isOpen && /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between gap-4 rounded-lg bg-destructive/5 p-4", children: [
220
+ /* @__PURE__ */ jsxs("div", { children: [
221
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: title }),
222
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description })
223
+ ] }),
224
+ /* @__PURE__ */ jsx("div", { className: "shrink-0", children: action })
225
+ ] })
226
+ ] });
227
+ }
228
+ var DEFAULT_PROFILE_CARD_LABELS = {
229
+ firstName: "First name",
230
+ lastName: "Last name",
231
+ save: "Save",
232
+ cancel: "Cancel",
233
+ sso: "SSO",
234
+ ssoTooltip: "Your email is managed by your sign-in provider. Change it there and it will sync here automatically on your next sign-in.",
235
+ change: "Change",
236
+ newEmailAddress: "New email address",
237
+ emailPlaceholder: "you@example.com",
238
+ codeWillBeSent: "We\u2019ll send a 3-word verification code to this address.",
239
+ sendCode: "Send code",
240
+ verify: (email) => `Verify ${email}`,
241
+ codePlaceholder: "WORD-WORD-WORD",
242
+ enterCodeHint: "Enter the 3-word code from the email we just sent.",
243
+ confirm: "Confirm",
244
+ resendIn: (seconds) => `Resend in ${seconds}s`,
245
+ resendCode: "Resend code"
246
+ };
247
+ function ProfileCard({
248
+ avatar,
249
+ name,
250
+ email,
251
+ isSso,
252
+ onStartEmailChange,
253
+ emailChange,
254
+ ssoTooltip,
255
+ labels
256
+ }) {
257
+ const l = useMemo(() => ({ ...DEFAULT_PROFILE_CARD_LABELS, ...labels }), [labels]);
258
+ return /* @__PURE__ */ jsxs(SettingsCard, { children: [
259
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-5", children: [
260
+ avatar,
261
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-3", children: [
262
+ name.isEditing ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
263
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 @xl:flex-row", children: [
264
+ /* @__PURE__ */ jsx(
265
+ Input,
266
+ {
267
+ value: name.givenName,
268
+ onChange: (e) => name.onGivenNameChange(e.target.value),
269
+ placeholder: l.firstName,
270
+ className: "flex-1",
271
+ autoFocus: true
272
+ }
273
+ ),
274
+ /* @__PURE__ */ jsx(
275
+ Input,
276
+ {
277
+ value: name.familyName,
278
+ onChange: (e) => name.onFamilyNameChange(e.target.value),
279
+ placeholder: l.lastName,
280
+ className: "flex-1"
281
+ }
282
+ )
283
+ ] }),
284
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
285
+ /* @__PURE__ */ jsxs(
286
+ Button,
287
+ {
288
+ onClick: name.onSave,
289
+ size: "sm",
290
+ disabled: !name.givenName.trim() || name.isSaving,
291
+ children: [
292
+ name.isSaving ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Check, { className: "mr-1 h-4 w-4" }),
293
+ l.save
294
+ ]
295
+ }
296
+ ),
297
+ /* @__PURE__ */ jsx(Button, { onClick: name.onCancel, size: "sm", variant: "ghost", disabled: name.isSaving, children: l.cancel })
298
+ ] })
299
+ ] }) : /* @__PURE__ */ jsx(
300
+ "button",
301
+ {
302
+ type: "button",
303
+ onClick: name.onStartEdit,
304
+ className: "-mx-2 w-full rounded-md px-2 py-1 text-left transition-colors hover:bg-background/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:min-h-11",
305
+ children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
306
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate font-heading text-xl font-semibold text-foreground", children: name.display }),
307
+ /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" })
308
+ ] })
309
+ }
310
+ ),
311
+ !emailChange && /* @__PURE__ */ jsxs("div", { className: "-mx-2 flex min-w-0 items-center gap-2 px-2 py-1", children: [
312
+ /* @__PURE__ */ jsx(Mail, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
313
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm text-muted-foreground", children: email }),
314
+ isSso ? /* @__PURE__ */ jsxs(Tooltip, { children: [
315
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
316
+ "span",
317
+ {
318
+ className: "ml-1 shrink-0 cursor-help rounded bg-background px-1.5 py-0.5 text-xs font-medium text-muted-foreground",
319
+ tabIndex: 0,
320
+ children: l.sso
321
+ }
322
+ ) }),
323
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: ssoTooltip ?? l.ssoTooltip })
324
+ ] }) : /* @__PURE__ */ jsx(
325
+ "button",
326
+ {
327
+ type: "button",
328
+ onClick: onStartEmailChange,
329
+ className: "ml-auto shrink-0 text-xs font-medium text-primary hover:underline pointer-coarse:min-h-11",
330
+ children: l.change
331
+ }
332
+ )
333
+ ] })
334
+ ] })
335
+ ] }),
336
+ emailChange && !isSso && /* @__PURE__ */ jsx("div", { className: "animate-accordion-down overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "space-y-3 rounded-lg bg-background p-4", children: emailChange.step === "enter" ? /* @__PURE__ */ jsxs(Fragment, { children: [
337
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs font-medium text-muted-foreground", children: [
338
+ /* @__PURE__ */ jsx(Mail, { className: "h-3.5 w-3.5" }),
339
+ l.newEmailAddress
340
+ ] }),
341
+ /* @__PURE__ */ jsx(
342
+ Input,
343
+ {
344
+ type: "email",
345
+ value: emailChange.newEmail,
346
+ onChange: (e) => emailChange.onNewEmailChange(e.target.value),
347
+ placeholder: l.emailPlaceholder,
348
+ autoFocus: true
349
+ }
350
+ ),
351
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: l.codeWillBeSent }),
352
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pt-1", children: [
353
+ /* @__PURE__ */ jsxs(
354
+ Button,
355
+ {
356
+ onClick: emailChange.onSendCode,
357
+ size: "sm",
358
+ disabled: !emailChange.newEmail.trim() || emailChange.isSending,
359
+ children: [
360
+ emailChange.isSending ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Mail, { className: "mr-1 h-4 w-4" }),
361
+ l.sendCode
362
+ ]
363
+ }
364
+ ),
365
+ /* @__PURE__ */ jsx(
366
+ Button,
367
+ {
368
+ onClick: emailChange.onCancel,
369
+ size: "sm",
370
+ variant: "ghost",
371
+ disabled: emailChange.isSending,
372
+ children: l.cancel
373
+ }
374
+ )
375
+ ] })
376
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
377
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs font-medium text-muted-foreground", children: [
378
+ /* @__PURE__ */ jsx(Mail, { className: "h-3.5 w-3.5" }),
379
+ l.verify(emailChange.newEmail)
380
+ ] }),
381
+ /* @__PURE__ */ jsx(
382
+ Input,
383
+ {
384
+ value: emailChange.code,
385
+ onChange: (e) => emailChange.onCodeChange(e.target.value.toUpperCase().replace(/\s+/g, "-")),
386
+ className: cn("text-center font-mono tracking-wider"),
387
+ placeholder: l.codePlaceholder,
388
+ autoFocus: true
389
+ }
390
+ ),
391
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: l.enterCodeHint }),
392
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 pt-1", children: [
393
+ /* @__PURE__ */ jsxs(
394
+ Button,
395
+ {
396
+ onClick: emailChange.onConfirm,
397
+ size: "sm",
398
+ disabled: !emailChange.code.trim() || emailChange.isConfirming,
399
+ children: [
400
+ emailChange.isConfirming ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Check, { className: "mr-1 h-4 w-4" }),
401
+ l.confirm
402
+ ]
403
+ }
404
+ ),
405
+ /* @__PURE__ */ jsx(
406
+ Button,
407
+ {
408
+ onClick: () => {
409
+ if (emailChange.cooldownSeconds > 0) return;
410
+ emailChange.onSendCode();
411
+ },
412
+ size: "sm",
413
+ variant: "ghost",
414
+ disabled: emailChange.cooldownSeconds > 0 || emailChange.isSending,
415
+ children: emailChange.cooldownSeconds > 0 ? l.resendIn(emailChange.cooldownSeconds) : l.resendCode
416
+ }
417
+ ),
418
+ /* @__PURE__ */ jsx(
419
+ Button,
420
+ {
421
+ onClick: emailChange.onCancel,
422
+ size: "sm",
423
+ variant: "ghost",
424
+ disabled: emailChange.isConfirming,
425
+ children: l.cancel
426
+ }
427
+ )
428
+ ] })
429
+ ] }) }) })
430
+ ] });
431
+ }
432
+ var DEFAULT_PASSWORD_CHANGE_DIALOG_LABELS = {
433
+ setNewPasswordTitle: "Set New Password",
434
+ changeMasterPasswordTitle: "Change Master Password",
435
+ recoveryDescription: "Set a new password for your recovered account",
436
+ changeDescription: "Change your master password dialog",
437
+ passwordChanged: "Password changed",
438
+ done: "Done",
439
+ recoverySuccessful: "Recovery successful. Set a new master password to continue.",
440
+ currentPassword: "Current Password",
441
+ currentPasswordPlaceholder: "Enter current password",
442
+ masterPassword: "Master Password",
443
+ newPassword: "New Password",
444
+ confirmPassword: "Confirm Password",
445
+ confirmNewPassword: "Confirm New Password",
446
+ workspacesRekeyed: (count) => `${formatCount(count, { one: "workspace", other: "workspaces" })} will be re-keyed with your new password.`,
447
+ cancel: "Cancel",
448
+ settingPassword: "Setting Password...",
449
+ changingPassword: "Changing Password...",
450
+ continue: "Continue",
451
+ changePassword: "Change Password"
452
+ };
453
+ function PasswordChangeDialog({
454
+ open,
455
+ onClose,
456
+ recoveryMode,
457
+ currentPassword,
458
+ onCurrentPasswordChange,
459
+ newPassword,
460
+ onNewPasswordChange,
461
+ confirmPassword,
462
+ onConfirmPasswordChange,
463
+ getUnmetRequirement,
464
+ workspaceCount,
465
+ error,
466
+ isProcessing,
467
+ isSubmitDisabled,
468
+ onSubmit,
469
+ success,
470
+ onDone,
471
+ labels,
472
+ passwordInputLabels,
473
+ testId,
474
+ testIds,
475
+ passwordInputTestIds
476
+ }) {
477
+ const currentPasswordId = useId();
478
+ const l = useMemo(() => ({ ...DEFAULT_PASSWORD_CHANGE_DIALOG_LABELS, ...labels }), [labels]);
479
+ const handleSubmit = (e) => {
480
+ e.preventDefault();
481
+ onSubmit();
482
+ };
483
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => !next && onClose(), children: /* @__PURE__ */ jsxs(
484
+ DialogContent,
485
+ {
486
+ presentation: "sheet",
487
+ className: "sm:max-w-md",
488
+ "data-testid": testIdOr(testId, { testId: "change-password-dialog" }),
489
+ children: [
490
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
491
+ /* @__PURE__ */ jsx(DialogTitle, { children: recoveryMode ? l.setNewPasswordTitle : l.changeMasterPasswordTitle }),
492
+ /* @__PURE__ */ jsx(DialogDescription, { className: "sr-only", children: recoveryMode ? l.recoveryDescription : l.changeDescription })
493
+ ] }),
494
+ success ? /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
495
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-green-text", children: [
496
+ /* @__PURE__ */ jsx(CheckCircle2, { className: "h-5 w-5" }),
497
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: l.passwordChanged })
498
+ ] }),
499
+ success,
500
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
501
+ Button,
502
+ {
503
+ onClick: onDone,
504
+ "data-testid": testIdOr(testIds?.done, { testId: "change-password-done-button" }),
505
+ children: l.done
506
+ }
507
+ ) })
508
+ ] }) : /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
509
+ recoveryMode && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-green-text", children: l.recoverySuccessful }),
510
+ !recoveryMode && /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
511
+ /* @__PURE__ */ jsxs("label", { htmlFor: currentPasswordId, className: "text-sm font-medium text-foreground", children: [
512
+ l.currentPassword,
513
+ " ",
514
+ /* @__PURE__ */ jsx("span", { className: "text-red-text", children: "*" })
515
+ ] }),
516
+ /* @__PURE__ */ jsx(
517
+ Input,
518
+ {
519
+ id: currentPasswordId,
520
+ type: "password",
521
+ value: currentPassword,
522
+ onChange: (e) => onCurrentPasswordChange(e.target.value),
523
+ disabled: isProcessing,
524
+ placeholder: l.currentPasswordPlaceholder,
525
+ autoComplete: "current-password",
526
+ className: "placeholder:text-muted-foreground",
527
+ "data-testid": testIdOr(testIds?.currentInput, {
528
+ testId: "change-password-current-input"
529
+ })
530
+ }
531
+ )
532
+ ] }),
533
+ /* @__PURE__ */ jsx(
534
+ PasswordStrengthInput,
535
+ {
536
+ password: newPassword,
537
+ confirmPassword,
538
+ onPasswordChange: onNewPasswordChange,
539
+ onConfirmPasswordChange,
540
+ showConfirmation: true,
541
+ disabled: isProcessing,
542
+ passwordLabel: recoveryMode ? l.masterPassword : l.newPassword,
543
+ confirmLabel: recoveryMode ? l.confirmPassword : l.confirmNewPassword,
544
+ labels: passwordInputLabels,
545
+ testIds: passwordInputTestIds,
546
+ layout: recoveryMode ? "side-by-side" : "stacked",
547
+ showStrengthIndicator: true,
548
+ getUnmetRequirement
549
+ }
550
+ ),
551
+ workspaceCount > 0 && /* @__PURE__ */ jsx(
552
+ "div",
553
+ {
554
+ className: "rounded-md bg-green-bg p-3",
555
+ "data-testid": testIdOr(testIds?.workspaceCount, {
556
+ testId: "change-password-workspace-count"
557
+ }),
558
+ children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
559
+ /* @__PURE__ */ jsx(CheckCircle2, { className: "h-5 w-5 flex-shrink-0 text-green-text" }),
560
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-green-text", children: l.workspacesRekeyed(workspaceCount) })
561
+ ] })
562
+ }
563
+ ),
564
+ error && /* @__PURE__ */ jsx(
565
+ "div",
566
+ {
567
+ className: "rounded-md bg-red-bg p-3",
568
+ "data-testid": testIdOr(testIds?.error, { testId: "change-password-error" }),
569
+ children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
570
+ /* @__PURE__ */ jsx(AlertCircle, { className: "h-5 w-5 flex-shrink-0 text-red-text" }),
571
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-red-text", children: error })
572
+ ] })
573
+ }
574
+ ),
575
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col-reverse sm:flex-row sm:justify-end gap-3 pt-4", children: [
576
+ !recoveryMode && /* @__PURE__ */ jsx(
577
+ Button,
578
+ {
579
+ type: "button",
580
+ variant: "outline",
581
+ onClick: onClose,
582
+ disabled: isProcessing,
583
+ "data-testid": testIdOr(testIds?.cancel, {
584
+ testId: "change-password-cancel-button"
585
+ }),
586
+ children: l.cancel
587
+ }
588
+ ),
589
+ /* @__PURE__ */ jsx(
590
+ Button,
591
+ {
592
+ type: "submit",
593
+ disabled: isSubmitDisabled,
594
+ className: recoveryMode ? "w-full" : "",
595
+ "data-testid": testIdOr(testIds?.submit, { testId: "change-password-submit-button" }),
596
+ children: isProcessing ? /* @__PURE__ */ jsxs(Fragment, { children: [
597
+ /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
598
+ recoveryMode ? l.settingPassword : l.changingPassword
599
+ ] }) : recoveryMode ? l.continue : l.changePassword
600
+ }
601
+ )
602
+ ] })
603
+ ] })
604
+ ]
605
+ }
606
+ ) });
607
+ }
608
+ var DEFAULT_ACTIVE_SESSIONS_DIALOG_LABELS = {
609
+ title: "Active sessions",
610
+ description: "Devices and agents currently signed in to your account. Ending a session signs it out immediately.",
611
+ noSessions: "No active sessions.",
612
+ thisDevice: "This device",
613
+ agent: "Agent",
614
+ endSession: "End this session"
615
+ };
616
+ var DEFAULT_DELETE_ACCOUNT_DIALOG_LABELS = {
617
+ warningTitle: "Delete your account?",
618
+ warningBefore: "Once deleted, your account will be ",
619
+ warningEmphasis: "immediately closed and you will be logged out",
620
+ warningAfter: ". This action cannot be undone.",
621
+ blockersHeading: "You must resolve these first:",
622
+ cancel: "Cancel",
623
+ continue: "Continue",
624
+ confirmTitle: "Confirm account deletion",
625
+ confirmDescription: "Type your email address to confirm. Your account will be closed immediately and you will be logged out.",
626
+ yourEmail: "Your email",
627
+ back: "Back",
628
+ deleting: "Deleting...",
629
+ deleteAccount: "Delete Account"
630
+ };
631
+ function SessionListRow({
632
+ session,
633
+ onTerminate,
634
+ labels,
635
+ testIds
636
+ }) {
637
+ return /* @__PURE__ */ jsxs(
638
+ "div",
639
+ {
640
+ className: "flex w-full items-center gap-3 border-b border-border/60 px-4 py-3 last:border-b-0",
641
+ "data-testid": prefixedTestId(testIds?.sessionItem, session.id, {
642
+ testId: `session-item-${session.id}`
643
+ }),
644
+ children: [
645
+ /* @__PURE__ */ jsx("span", { className: "flex size-9 shrink-0 items-center justify-center rounded-full bg-muted", children: session.icon }),
646
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
647
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
648
+ /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-semibold text-foreground", children: session.name }),
649
+ session.isCurrent && /* @__PURE__ */ jsx(Badge, { className: "border-transparent bg-accent px-1.5 py-0 text-xs text-accent-foreground shadow-none hover:bg-accent", children: labels.thisDevice }),
650
+ session.isAgent && /* @__PURE__ */ jsx(Badge, { variant: "default", className: "px-1 py-0 text-xs", children: labels.agent })
651
+ ] }),
652
+ /* @__PURE__ */ jsx("div", { className: "mt-0.5 truncate text-xs text-muted-foreground", children: session.detail })
653
+ ] }),
654
+ !session.isCurrent && /* @__PURE__ */ jsxs(Tooltip, { children: [
655
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
656
+ Button,
657
+ {
658
+ type: "button",
659
+ variant: "ghost",
660
+ size: "icon",
661
+ className: "h-8 w-8 shrink-0 text-muted-foreground hover:text-destructive",
662
+ "aria-label": labels.endSession,
663
+ onClick: () => onTerminate(session.id),
664
+ disabled: session.isTerminating,
665
+ "data-testid": prefixedTestId(
666
+ testIds?.terminateSession,
667
+ session.id,
668
+ { testId: `terminate-session-${session.id}-button` },
669
+ "-button"
670
+ ),
671
+ children: session.isTerminating ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(LogOut, { className: "h-4 w-4" })
672
+ }
673
+ ) }),
674
+ /* @__PURE__ */ jsx(TooltipContent, { children: labels.endSession })
675
+ ] })
676
+ ]
677
+ }
678
+ );
679
+ }
680
+ function ActiveSessionsDialog({
681
+ open,
682
+ onOpenChange,
683
+ isLoading,
684
+ sessions,
685
+ onTerminate,
686
+ labels,
687
+ testId,
688
+ testIds
689
+ }) {
690
+ const l = useMemo(() => ({ ...DEFAULT_ACTIVE_SESSIONS_DIALOG_LABELS, ...labels }), [labels]);
691
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
692
+ DialogContent,
693
+ {
694
+ presentation: "sheet",
695
+ className: "sm:max-w-lg",
696
+ "data-testid": testIdOr(testId, { testId: "active-sessions-dialog" }),
697
+ children: [
698
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
699
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
700
+ /* @__PURE__ */ jsx(Radio, { className: "h-6 w-6" }),
701
+ /* @__PURE__ */ jsx(DialogTitle, { children: l.title })
702
+ ] }),
703
+ /* @__PURE__ */ jsx(DialogDescription, { children: l.description })
704
+ ] }),
705
+ isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ jsx(Loader2, { className: "h-5 w-5 animate-spin text-muted-foreground" }) }) : sessions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: l.noSessions }) : /* @__PURE__ */ jsx(
706
+ "div",
707
+ {
708
+ className: "-mx-2 max-h-96 overflow-auto rounded-lg bg-muted",
709
+ "data-testid": testIdOr(testIds?.list, { testId: "session-list" }),
710
+ children: sessions.map((session) => /* @__PURE__ */ jsx(
711
+ SessionListRow,
712
+ {
713
+ session,
714
+ onTerminate,
715
+ labels: l,
716
+ testIds
717
+ },
718
+ session.id
719
+ ))
720
+ }
721
+ )
722
+ ]
723
+ }
724
+ ) });
725
+ }
726
+ function DeleteAccountDialog({
727
+ open,
728
+ onClose,
729
+ step,
730
+ blockers,
731
+ onContinue,
732
+ onBack,
733
+ userEmail,
734
+ confirmEmail,
735
+ onConfirmEmailChange,
736
+ isDeleting,
737
+ onSubmit,
738
+ labels,
739
+ testId,
740
+ testIds
741
+ }) {
742
+ const confirmEmailId = useId();
743
+ const l = useMemo(() => ({ ...DEFAULT_DELETE_ACCOUNT_DIALOG_LABELS, ...labels }), [labels]);
744
+ const emailMatches = confirmEmail.toLowerCase() === userEmail.toLowerCase();
745
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(
746
+ DialogContent,
747
+ {
748
+ presentation: "sheet",
749
+ className: "sm:max-w-md",
750
+ "data-testid": testIdOr(testId, { testId: "delete-account-dialog" }),
751
+ children: step === "warning" ? /* @__PURE__ */ jsxs(Fragment, { children: [
752
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
753
+ /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
754
+ /* @__PURE__ */ jsx(AlertTriangle, { className: "h-5 w-5 text-destructive" }),
755
+ l.warningTitle
756
+ ] }),
757
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
758
+ l.warningBefore,
759
+ /* @__PURE__ */ jsx("strong", { children: l.warningEmphasis }),
760
+ l.warningAfter
761
+ ] })
762
+ ] }),
763
+ blockers.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-yellow-bg p-3 text-sm text-yellow-text", children: [
764
+ /* @__PURE__ */ jsx("p", { className: "mb-1 font-semibold", children: l.blockersHeading }),
765
+ /* @__PURE__ */ jsx("ul", { className: "list-inside list-disc space-y-1", children: blockers.map((blocker) => /* @__PURE__ */ jsx("li", { children: blocker.content }, blocker.key)) })
766
+ ] }),
767
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col-reverse sm:flex-row sm:justify-end gap-2 pt-2", children: [
768
+ /* @__PURE__ */ jsx(
769
+ Button,
770
+ {
771
+ variant: "outline",
772
+ onClick: onClose,
773
+ "data-testid": testIdOr(testIds?.cancel, { testId: "delete-account-cancel-button" }),
774
+ children: l.cancel
775
+ }
776
+ ),
777
+ /* @__PURE__ */ jsx(
778
+ Button,
779
+ {
780
+ variant: "destructive",
781
+ disabled: blockers.length > 0,
782
+ onClick: onContinue,
783
+ "data-testid": testIdOr(testIds?.continue, {
784
+ testId: "delete-account-continue-button"
785
+ }),
786
+ children: l.continue
787
+ }
788
+ )
789
+ ] })
790
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
791
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
792
+ /* @__PURE__ */ jsx(DialogTitle, { children: l.confirmTitle }),
793
+ /* @__PURE__ */ jsx(DialogDescription, { children: l.confirmDescription })
794
+ ] }),
795
+ /* @__PURE__ */ jsxs("div", { children: [
796
+ /* @__PURE__ */ jsx("label", { htmlFor: confirmEmailId, className: "mb-1 block text-sm font-medium", children: l.yourEmail }),
797
+ /* @__PURE__ */ jsx(
798
+ Input,
799
+ {
800
+ id: confirmEmailId,
801
+ type: "email",
802
+ placeholder: userEmail,
803
+ value: confirmEmail,
804
+ onChange: (e) => onConfirmEmailChange(e.target.value),
805
+ autoFocus: true,
806
+ "data-testid": testIdOr(testIds?.emailInput, {
807
+ testId: "delete-account-email-input"
808
+ })
809
+ }
810
+ )
811
+ ] }),
812
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col-reverse sm:flex-row sm:justify-end gap-2 pt-2", children: [
813
+ /* @__PURE__ */ jsx(
814
+ Button,
815
+ {
816
+ variant: "outline",
817
+ onClick: onBack,
818
+ "data-testid": testIdOr(testIds?.back, { testId: "delete-account-back-button" }),
819
+ children: l.back
820
+ }
821
+ ),
822
+ /* @__PURE__ */ jsx(
823
+ Button,
824
+ {
825
+ variant: "destructive",
826
+ disabled: !emailMatches || isDeleting,
827
+ onClick: onSubmit,
828
+ "data-testid": testIdOr(testIds?.submit, { testId: "delete-account-submit-button" }),
829
+ children: isDeleting ? /* @__PURE__ */ jsxs(Fragment, { children: [
830
+ /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
831
+ l.deleting
832
+ ] }) : l.deleteAccount
833
+ }
834
+ )
835
+ ] })
836
+ ] })
837
+ }
838
+ ) });
839
+ }
840
+ var DEFAULT_LOGOUT_DIALOG_LABELS = {
841
+ title: "Logout",
842
+ descriptionAll: "End this session or all active sessions?",
843
+ descriptionThis: "End this session and return to the login page.",
844
+ cancel: "Cancel",
845
+ allSessions: "All sessions",
846
+ offlineTooltip: "Ending all sessions needs a connection \u2014 you can still log out of this device.",
847
+ thisSession: "This session",
848
+ offlineNote: "You\u2019re offline \u2014 ending all sessions needs a connection. You can still log out of this device.",
849
+ activeSessions: (count) => formatCount(count, { one: "active session", other: "active sessions" }),
850
+ workspaces: (count) => formatCount(count, { one: "workspace", other: "workspaces" }),
851
+ ttl: (ttlLabel) => `TTL ${ttlLabel}`
852
+ };
853
+ function SessionRow({
854
+ session,
855
+ icon,
856
+ labels
857
+ }) {
858
+ const { status } = session;
859
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-md bg-muted/50 px-3 py-2", children: [
860
+ icon && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: icon }),
861
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
862
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
863
+ /* @__PURE__ */ jsx("code", { className: "truncate font-mono text-sm", children: session.id.slice(0, 12) }),
864
+ /* @__PURE__ */ jsx(
865
+ Badge,
866
+ {
867
+ variant: status === "agent" ? "default" : "secondary",
868
+ className: "px-1 py-0 text-sm",
869
+ children: status
870
+ }
871
+ )
872
+ ] }),
873
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
874
+ session.ipAddress && /* @__PURE__ */ jsx("span", { children: session.ipAddress }),
875
+ /* @__PURE__ */ jsx("span", { children: labels.ttl(session.ttlLabel) }),
876
+ session.workspaceCount > 0 && /* @__PURE__ */ jsx("span", { children: labels.workspaces(session.workspaceCount) })
877
+ ] })
878
+ ] })
879
+ ] });
880
+ }
881
+ function LogoutDialog({
882
+ open,
883
+ onClose,
884
+ onLogoutThis,
885
+ onLogoutAll,
886
+ canLogoutAll,
887
+ isOnline,
888
+ sessions,
889
+ renderSessionIcon,
890
+ labels,
891
+ testId,
892
+ testIds
893
+ }) {
894
+ const l = useMemo(() => ({ ...DEFAULT_LOGOUT_DIALOG_LABELS, ...labels }), [labels]);
895
+ const [sessionsOpen, setSessionsOpen] = useState(false);
896
+ const restoreFocus = useRestoreFocus();
897
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => !next && onClose(), children: /* @__PURE__ */ jsxs(
898
+ DialogContent,
899
+ {
900
+ ...restoreFocus,
901
+ className: "sm:max-w-md",
902
+ "data-testid": testIdOr(testId, { testId: "logout-modal" }),
903
+ children: [
904
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
905
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
906
+ /* @__PURE__ */ jsx(LogOut, { className: "h-6 w-6" }),
907
+ /* @__PURE__ */ jsx(DialogTitle, { children: l.title })
908
+ ] }),
909
+ /* @__PURE__ */ jsx(DialogDescription, { className: "text-base", children: canLogoutAll ? l.descriptionAll : l.descriptionThis })
910
+ ] }),
911
+ /* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2", children: [
912
+ /* @__PURE__ */ jsx(
913
+ Button,
914
+ {
915
+ variant: "outline",
916
+ onClick: onClose,
917
+ "data-testid": testIdOr(testIds?.cancel, { testId: "logout-modal-cancel-button" }),
918
+ children: l.cancel
919
+ }
920
+ ),
921
+ canLogoutAll && /* @__PURE__ */ jsx(
922
+ Button,
923
+ {
924
+ variant: "secondary",
925
+ onClick: onLogoutAll,
926
+ disabled: !isOnline,
927
+ title: isOnline ? void 0 : l.offlineTooltip,
928
+ "data-testid": testIdOr(testIds?.all, { testId: "logout-modal-all-button" }),
929
+ children: l.allSessions
930
+ }
931
+ ),
932
+ /* @__PURE__ */ jsx(
933
+ Button,
934
+ {
935
+ variant: "default",
936
+ onClick: onLogoutThis,
937
+ "data-testid": testIdOr(testIds?.this, { testId: "logout-modal-this-button" }),
938
+ children: l.thisSession
939
+ }
940
+ )
941
+ ] }),
942
+ canLogoutAll && !isOnline && /* @__PURE__ */ jsx(
943
+ "p",
944
+ {
945
+ className: "text-sm text-muted-foreground",
946
+ "data-testid": testIdOr(testIds?.offlineNote, { testId: "logout-offline-note" }),
947
+ children: l.offlineNote
948
+ }
949
+ ),
950
+ sessions.length > 0 && /* @__PURE__ */ jsxs(Collapsible, { open: sessionsOpen, onOpenChange: setSessionsOpen, children: [
951
+ /* @__PURE__ */ jsxs(CollapsibleTrigger, { className: "flex w-full items-center gap-2 py-1 text-left transition-opacity hover:opacity-80 pointer-coarse:py-3", children: [
952
+ sessionsOpen ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 flex-shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 flex-shrink-0" }),
953
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-sm font-medium text-muted-foreground", children: [
954
+ /* @__PURE__ */ jsx(Radio, { className: "h-3 w-3" }),
955
+ /* @__PURE__ */ jsx("span", { children: l.activeSessions(sessions.length) })
956
+ ] })
957
+ ] }),
958
+ /* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", { className: "max-h-48 space-y-1.5 overflow-auto pt-2", children: sessions.map((session) => /* @__PURE__ */ jsx(
959
+ SessionRow,
960
+ {
961
+ session,
962
+ icon: renderSessionIcon?.(session.status),
963
+ labels: l
964
+ },
965
+ session.id
966
+ )) }) })
967
+ ] })
968
+ ]
969
+ }
970
+ ) });
971
+ }
972
+ function SettingsSwitchRow({
973
+ id,
974
+ title,
975
+ icon,
976
+ description,
977
+ checked,
978
+ onCheckedChange,
979
+ testId,
980
+ disabled,
981
+ className
982
+ }) {
983
+ return /* @__PURE__ */ jsxs(
984
+ "div",
985
+ {
986
+ "data-slot": "settings-switch-row",
987
+ className: cn("flex items-center justify-between gap-4", className),
988
+ children: [
989
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
990
+ /* @__PURE__ */ jsxs("label", { htmlFor: id, className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [
991
+ icon,
992
+ title
993
+ ] }),
994
+ description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: description })
995
+ ] }),
996
+ /* @__PURE__ */ jsx(
997
+ Switch,
998
+ {
999
+ id,
1000
+ checked,
1001
+ onCheckedChange,
1002
+ disabled,
1003
+ "data-testid": testId
1004
+ }
1005
+ )
1006
+ ]
1007
+ }
1008
+ );
1009
+ }
1010
+ function SettingsSwitchGroup({
1011
+ className,
1012
+ children
1013
+ }) {
1014
+ return /* @__PURE__ */ jsx(
1015
+ "div",
1016
+ {
1017
+ "data-slot": "settings-switch-group",
1018
+ className: cn("ml-6 space-y-4 border-l border-border pl-4", className),
1019
+ children
1020
+ }
1021
+ );
1022
+ }
1023
+ function NotificationCategoryList({
1024
+ masterId,
1025
+ masterTitle,
1026
+ masterDescription,
1027
+ masterChecked,
1028
+ onMasterChange,
1029
+ masterTestId,
1030
+ categories,
1031
+ onCategoryChange,
1032
+ idPrefix = masterId,
1033
+ testIdPrefix
1034
+ }) {
1035
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "notification-category-list", children: [
1036
+ /* @__PURE__ */ jsx(
1037
+ SettingsSwitchRow,
1038
+ {
1039
+ id: masterId,
1040
+ title: masterTitle,
1041
+ description: masterDescription,
1042
+ checked: masterChecked,
1043
+ onCheckedChange: onMasterChange,
1044
+ testId: testIdOr(masterTestId, { testId: "toggle-email-notifications" })
1045
+ }
1046
+ ),
1047
+ /* @__PURE__ */ jsx("div", { className: "ml-1 mt-3 space-y-3 border-l border-border pl-4 pointer-coarse:mt-5 pointer-coarse:space-y-5", children: categories.map((c) => /* @__PURE__ */ jsxs(
1048
+ "label",
1049
+ {
1050
+ htmlFor: `${idPrefix}-${c.key}`,
1051
+ className: cn(
1052
+ "flex items-start gap-3 pointer-coarse:min-h-11",
1053
+ masterChecked ? "cursor-pointer" : "cursor-not-allowed opacity-50"
1054
+ ),
1055
+ children: [
1056
+ /* @__PURE__ */ jsx(
1057
+ Checkbox,
1058
+ {
1059
+ id: `${idPrefix}-${c.key}`,
1060
+ checked: c.checked,
1061
+ disabled: !masterChecked,
1062
+ onCheckedChange: (value) => onCategoryChange(c.key, value === true),
1063
+ "data-testid": prefixedTestId(testIdPrefix, c.key, { testId: `toggle-email-${c.key}` }),
1064
+ className: "mt-0.5 size-5 shrink-0"
1065
+ }
1066
+ ),
1067
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1068
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: c.label }),
1069
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: c.description })
1070
+ ] })
1071
+ ]
1072
+ },
1073
+ c.key
1074
+ )) })
1075
+ ] });
1076
+ }
1077
+
1078
+ // src/settings/account-views.ts
1079
+ function formatSessionTtl(totalSeconds) {
1080
+ if (totalSeconds <= 0) return "expired";
1081
+ const days = Math.floor(totalSeconds / 86400);
1082
+ const hours = Math.floor(totalSeconds % 86400 / 3600);
1083
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
1084
+ const parts = [];
1085
+ if (days > 0) parts.push(`${days}d`);
1086
+ if (hours > 0) parts.push(`${hours}h`);
1087
+ if (minutes > 0) parts.push(`${minutes}m`);
1088
+ return parts.length > 0 ? parts.join(" ") : "<1m";
1089
+ }
1090
+ function toActiveSessionViews(sessions, {
1091
+ currentSessionId,
1092
+ terminatingId,
1093
+ renderIcon,
1094
+ formatTtl = formatSessionTtl
1095
+ }) {
1096
+ return sessions.map((session) => {
1097
+ const status = session.status || "user";
1098
+ const count = session.workspaces.length;
1099
+ return {
1100
+ id: session.session_id,
1101
+ name: session.name || (status === "agent" ? "Agent session" : "Browser session"),
1102
+ isCurrent: session.session_id === currentSessionId,
1103
+ isAgent: status === "agent",
1104
+ detail: `${session.ip_address ?? "Unknown IP"} \xB7 expires in ${formatTtl(session.ttl)}${count > 0 ? ` \xB7 ${count} workspace${count > 1 ? "s" : ""}` : ""}`,
1105
+ isTerminating: terminatingId === session.session_id,
1106
+ icon: renderIcon?.(status)
1107
+ };
1108
+ }).sort((a, b) => Number(b.isCurrent) - Number(a.isCurrent));
1109
+ }
1110
+ function toLogoutSessionViews(sessions, formatTtl = formatSessionTtl) {
1111
+ return sessions.map((session) => ({
1112
+ id: session.session_id,
1113
+ status: session.status || "user",
1114
+ ipAddress: session.ip_address,
1115
+ ttlLabel: formatTtl(session.ttl),
1116
+ workspaceCount: session.workspaces.length
1117
+ }));
1118
+ }
1119
+ function toDeleteBlockerViews(blockers, renderSubscriptionLink) {
1120
+ return blockers.flatMap(
1121
+ (blocker) => blocker.type === "active_subscription" ? [
1122
+ {
1123
+ key: "active_subscription",
1124
+ content: renderSubscriptionLink ? renderSubscriptionLink() : "Active subscription: cancel it in your subscription settings first"
1125
+ }
1126
+ ] : blocker.workspaces.map((ws) => ({
1127
+ key: `workspace-${ws}`,
1128
+ content: `You are the sole admin of workspace "${ws}" \u2014 transfer admin rights or remove all other members first`
1129
+ }))
1130
+ );
1131
+ }
1132
+ var EMAIL_NOTIFICATION_CATEGORIES = [
1133
+ { key: "messages", label: "New messages", description: "A direct message while you\u2019re offline" },
1134
+ { key: "workspace_added", label: "Workspace access", description: "You\u2019re added to a workspace" },
1135
+ {
1136
+ key: "contact_accepted",
1137
+ label: "Invitation accepted",
1138
+ description: "Someone accepts your invitation"
1139
+ },
1140
+ { key: "referral_reward", label: "Rewards", description: "You earn a reward" },
1141
+ {
1142
+ key: "product_updates",
1143
+ label: "ARBI update",
1144
+ description: "Weekly digest of new features and highlights"
1145
+ }
1146
+ ];
1147
+ var EMAIL_NOTIFICATION_KEYS = EMAIL_NOTIFICATION_CATEGORIES.map(
1148
+ (c) => c.key
1149
+ );
1150
+ function toNotificationCategories(checked, defs = EMAIL_NOTIFICATION_CATEGORIES) {
1151
+ return defs.map((def) => ({ ...def, checked: checked[def.key] ?? true }));
1152
+ }
1153
+
1154
+ export { ActiveSessionsDialog, AvatarPicker, DEFAULT_ACTIVE_SESSIONS_DIALOG_LABELS, DEFAULT_AVATAR_PICKER_LABELS, DEFAULT_DELETE_ACCOUNT_DIALOG_LABELS, DEFAULT_LOGOUT_DIALOG_LABELS, DEFAULT_PASSWORD_CHANGE_DIALOG_LABELS, DEFAULT_PROFILE_CARD_LABELS, DEFAULT_SETTINGS_DANGER_ZONE_LABELS, DeleteAccountDialog, EMAIL_NOTIFICATION_CATEGORIES, EMAIL_NOTIFICATION_KEYS, LogoutDialog, NotificationCategoryList, PasswordChangeDialog, ProfileCard, SettingsActionRow, SettingsCard, SettingsDangerZone, SettingsPanel, SettingsRow, SettingsSection, SettingsSwitchGroup, SettingsSwitchRow, formatSessionTtl, toActiveSessionViews, toDeleteBlockerViews, toLogoutSessionViews, toNotificationCategories };
1155
+ //# sourceMappingURL=chunk-JLOYWXRB.js.map
1156
+ //# sourceMappingURL=chunk-JLOYWXRB.js.map