@arbidocs/blocks 0.5.43 → 0.5.44

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 (91) hide show
  1. package/README.md +14 -0
  2. package/dist/{ConnectedNativeDocxComparison-52KQKJGY.js → ConnectedNativeDocxComparison-4DYPHNY2.js} +6 -6
  3. package/dist/{ConnectedNativeDocxComparison-52KQKJGY.js.map → ConnectedNativeDocxComparison-4DYPHNY2.js.map} +1 -1
  4. package/dist/{ConnectedNativeDocxComparison-UVLZGS2V.cjs → ConnectedNativeDocxComparison-OZE2SPNU.cjs} +7 -7
  5. package/dist/{ConnectedNativeDocxComparison-UVLZGS2V.cjs.map → ConnectedNativeDocxComparison-OZE2SPNU.cjs.map} +1 -1
  6. package/dist/{ConnectedNativeDocxEditor-BRBL3MOV.js → ConnectedNativeDocxEditor-F3EHJKDI.js} +5 -5
  7. package/dist/{ConnectedNativeDocxEditor-BRBL3MOV.js.map → ConnectedNativeDocxEditor-F3EHJKDI.js.map} +1 -1
  8. package/dist/{ConnectedNativeDocxEditor-KHR5I7W6.cjs → ConnectedNativeDocxEditor-MUM6YRPY.cjs} +7 -7
  9. package/dist/{ConnectedNativeDocxEditor-KHR5I7W6.cjs.map → ConnectedNativeDocxEditor-MUM6YRPY.cjs.map} +1 -1
  10. package/dist/{ConnectedStreamedWordArtifact-DSVFI7BX.cjs → ConnectedStreamedWordArtifact-F6M766FG.cjs} +7 -7
  11. package/dist/ConnectedStreamedWordArtifact-F6M766FG.cjs.map +1 -0
  12. package/dist/{ConnectedStreamedWordArtifact-EQUE6WT5.js → ConnectedStreamedWordArtifact-XUWLRRG5.js} +6 -6
  13. package/dist/{ConnectedStreamedWordArtifact-EQUE6WT5.js.map → ConnectedStreamedWordArtifact-XUWLRRG5.js.map} +1 -1
  14. package/dist/WorkspaceTableView-2CGEO5KK.cjs +1 -1
  15. package/dist/WorkspaceTableView-3ARFQYNO.js +1 -1
  16. package/dist/agents/index.cjs +326 -326
  17. package/dist/agents/index.js +4 -4
  18. package/dist/calls/index.cjs +73 -696
  19. package/dist/calls/index.cjs.map +1 -1
  20. package/dist/calls/index.js +10 -666
  21. package/dist/calls/index.js.map +1 -1
  22. package/dist/{chunk-3YZ3RUSB.cjs → chunk-3GHFTAOV.cjs} +4 -4
  23. package/dist/{chunk-3YZ3RUSB.cjs.map → chunk-3GHFTAOV.cjs.map} +1 -1
  24. package/dist/{chunk-6AJJJ5HR.cjs → chunk-5R256EMF.cjs} +671 -3
  25. package/dist/chunk-5R256EMF.cjs.map +1 -0
  26. package/dist/{chunk-EFDZRAW6.js → chunk-CG7EYB3J.js} +3 -3
  27. package/dist/{chunk-EFDZRAW6.js.map → chunk-CG7EYB3J.js.map} +1 -1
  28. package/dist/{chunk-YAGSGBVM.js → chunk-EY4IEOW3.js} +3 -3
  29. package/dist/{chunk-YAGSGBVM.js.map → chunk-EY4IEOW3.js.map} +1 -1
  30. package/dist/{chunk-YD3RN2FY.cjs → chunk-F72ZD5Q2.cjs} +3 -3
  31. package/dist/{chunk-YD3RN2FY.cjs.map → chunk-F72ZD5Q2.cjs.map} +1 -1
  32. package/dist/{chunk-E3IEZMRK.cjs → chunk-FKFGP7MQ.cjs} +18 -18
  33. package/dist/{chunk-E3IEZMRK.cjs.map → chunk-FKFGP7MQ.cjs.map} +1 -1
  34. package/dist/{chunk-WAIHNFUH.js → chunk-G5JENSLN.js} +3 -3
  35. package/dist/{chunk-WAIHNFUH.js.map → chunk-G5JENSLN.js.map} +1 -1
  36. package/dist/{chunk-O3MRE2HL.cjs → chunk-GUV63FUC.cjs} +11 -11
  37. package/dist/{chunk-O3MRE2HL.cjs.map → chunk-GUV63FUC.cjs.map} +1 -1
  38. package/dist/{chunk-REHG7VRQ.js → chunk-H6UK6LGL.js} +4 -4
  39. package/dist/{chunk-REHG7VRQ.js.map → chunk-H6UK6LGL.js.map} +1 -1
  40. package/dist/{chunk-75Z5AUMM.js → chunk-JS7KJRKG.js} +3 -3
  41. package/dist/{chunk-75Z5AUMM.js.map → chunk-JS7KJRKG.js.map} +1 -1
  42. package/dist/{chunk-TPNLYQD2.cjs → chunk-PV5A5SAC.cjs} +5 -5
  43. package/dist/{chunk-TPNLYQD2.cjs.map → chunk-PV5A5SAC.cjs.map} +1 -1
  44. package/dist/{chunk-K53QRFPJ.cjs → chunk-QPDQYZIR.cjs} +4 -4
  45. package/dist/{chunk-K53QRFPJ.cjs.map → chunk-QPDQYZIR.cjs.map} +1 -1
  46. package/dist/{chunk-UZVXVTTB.cjs → chunk-QWSAJNQE.cjs} +9 -9
  47. package/dist/{chunk-UZVXVTTB.cjs.map → chunk-QWSAJNQE.cjs.map} +1 -1
  48. package/dist/{chunk-2QDNQM63.cjs → chunk-T5BCPKU3.cjs} +3 -3
  49. package/dist/{chunk-2QDNQM63.cjs.map → chunk-T5BCPKU3.cjs.map} +1 -1
  50. package/dist/{chunk-X7CXCEGO.js → chunk-T6KAZPOZ.js} +3 -3
  51. package/dist/{chunk-X7CXCEGO.js.map → chunk-T6KAZPOZ.js.map} +1 -1
  52. package/dist/{chunk-4U4NXFV5.js → chunk-TKTNXFAB.js} +666 -9
  53. package/dist/chunk-TKTNXFAB.js.map +1 -0
  54. package/dist/{chunk-FOIDBAZB.js → chunk-TOP5BMS7.js} +3 -3
  55. package/dist/{chunk-FOIDBAZB.js.map → chunk-TOP5BMS7.js.map} +1 -1
  56. package/dist/{chunk-7CHI36EP.js → chunk-VE6DHRXD.js} +3 -3
  57. package/dist/{chunk-7CHI36EP.js.map → chunk-VE6DHRXD.js.map} +1 -1
  58. package/dist/connect/docx.cjs +9 -9
  59. package/dist/connect/docx.js +5 -5
  60. package/dist/connect/index.cjs +1957 -774
  61. package/dist/connect/index.cjs.map +1 -1
  62. package/dist/connect/index.d.ts +1 -0
  63. package/dist/connect/index.js +1667 -487
  64. package/dist/connect/index.js.map +1 -1
  65. package/dist/connect/viewer.cjs +3 -3
  66. package/dist/connect/viewer.js +3 -3
  67. package/dist/connection/ConnectedFilterDropdown.d.ts +6 -0
  68. package/dist/connection/conversation/ConnectedConversation.d.ts +7 -9
  69. package/dist/connection/conversation/ConnectedConversationPage.d.ts +30 -0
  70. package/dist/connection/conversation/SemanticSearchButton.d.ts +12 -0
  71. package/dist/connection/files/imports/ConnectedAccountsImport.d.ts +16 -0
  72. package/dist/connection/files/imports/DriveImportPanel.d.ts +10 -0
  73. package/dist/connection/files/imports/EmailImportPanel.d.ts +21 -0
  74. package/dist/connection/files/imports/ImportHandoff.d.ts +24 -0
  75. package/dist/connection/files/imports/useDriveSyncTrigger.d.ts +11 -0
  76. package/dist/connection/files/imports/useEmailSyncTrigger.d.ts +11 -0
  77. package/dist/connection/files/imports/useImportHandoff.d.ts +20 -0
  78. package/dist/connection/files/index.d.ts +1 -0
  79. package/dist/facts/index.cjs +55 -55
  80. package/dist/facts/index.js +3 -3
  81. package/dist/index.cjs +384 -384
  82. package/dist/index.js +5 -5
  83. package/dist/settings/index.cjs +1 -1
  84. package/dist/settings/index.js +1 -1
  85. package/dist/workflow-canvas/index.cjs +17 -17
  86. package/dist/workflow-canvas/index.js +4 -4
  87. package/node_modules/@arbidocs/coedit/package.json +1 -1
  88. package/package.json +5 -5
  89. package/dist/ConnectedStreamedWordArtifact-DSVFI7BX.cjs.map +0 -1
  90. package/dist/chunk-4U4NXFV5.js.map +0 -1
  91. package/dist/chunk-6AJJJ5HR.cjs.map +0 -1
@@ -7,13 +7,569 @@ var chunkP6HVJP6Z_cjs = require('./chunk-P6HVJP6Z.cjs');
7
7
  var chunkZW6FPIFC_cjs = require('./chunk-ZW6FPIFC.cjs');
8
8
  var chunkNXHETIOB_cjs = require('./chunk-NXHETIOB.cjs');
9
9
  var chunkB3NYBMDR_cjs = require('./chunk-B3NYBMDR.cjs');
10
- var react = require('react');
11
10
  var react$1 = require('@arbidocs/react');
11
+ var react = require('react');
12
12
  var lucideReact = require('lucide-react');
13
13
  var ui = require('@arbidocs/react/ui');
14
14
  var jsxRuntime = require('react/jsx-runtime');
15
+ var browser = require('@arbidocs/sdk/browser');
15
16
  var documentTools = require('@arbidocs/react/document-tools');
16
17
 
18
+ function StartCallButton(props) {
19
+ const enabled = react$1.useCallsEnabled();
20
+ const canHost = react$1.useCanHostCalls();
21
+ return enabled && (canHost || props.isLive) ? /* @__PURE__ */ jsxRuntime.jsx(EnabledStartCallButton, { ...props }) : null;
22
+ }
23
+ function EnabledStartCallButton({
24
+ onStart,
25
+ isLive = false,
26
+ label = "Start call",
27
+ testId = "start-call-button"
28
+ }) {
29
+ const [isStarting, setIsStarting] = react.useState(false);
30
+ const inCall = react$1.useCallSession((s) => s.active !== null);
31
+ const text = inCall ? "Already in a call" : isLive ? "Join call" : label;
32
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Tooltip, { children: [
33
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
34
+ ui.Button,
35
+ {
36
+ type: "button",
37
+ variant: "ghost",
38
+ size: "icon",
39
+ "aria-label": isLive ? "Join call" : label,
40
+ "data-testid": testId,
41
+ "data-live": isLive || void 0,
42
+ disabled: isStarting || inCall,
43
+ onClick: () => {
44
+ setIsStarting(true);
45
+ void onStart().finally(() => setIsStarting(false));
46
+ },
47
+ className: ui.cn(
48
+ "text-muted-foreground hover:text-foreground",
49
+ isLive && "text-green-text hover:text-green-text"
50
+ ),
51
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Phone, { className: ui.cn("size-5", isLive && "animate-pulse") })
52
+ }
53
+ ) }),
54
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: text }) })
55
+ ] });
56
+ }
57
+ var INVITE_LINK_HINT = "will get an invitation to create an ARBI account and join";
58
+ var NO_KEY_REASON = "Cannot receive encrypted calls yet";
59
+ var NO_EMAIL_REASON = "No e-mail address to send a link to";
60
+ function contactName(contact) {
61
+ return contact.card?.name?.trim() || [contact.card?.given_name, contact.card?.family_name].filter(Boolean).join(" ") || (contact.user ? ui.getUserDisplayName(contact.user) : "") || contactEmail(contact) || "Contact";
62
+ }
63
+ function contactEmail(contact) {
64
+ return contact.email ?? contact.user?.email ?? contact.card?.emails?.[0]?.email ?? null;
65
+ }
66
+ function callContactOf(contact) {
67
+ if (!contact.external_id || contact.status === "failed") return null;
68
+ if (contact.user && ui.isAgent(contact.user)) return null;
69
+ return {
70
+ contactExtId: contact.external_id,
71
+ user: contact.user ?? null,
72
+ name: contactName(contact),
73
+ email: contactEmail(contact)
74
+ };
75
+ }
76
+ function userCandidate(user, section, status, contactExtId = null) {
77
+ const ringable = status !== "ring" || !!user.encryption_public_key;
78
+ return {
79
+ id: user.external_id,
80
+ name: ui.getUserDisplayName(user) || user.email,
81
+ email: user.email ?? null,
82
+ section,
83
+ status: ringable ? status : "unavailable",
84
+ reason: ringable ? void 0 : NO_KEY_REASON,
85
+ user,
86
+ contactExtId
87
+ };
88
+ }
89
+ function buildCallCandidates(opts) {
90
+ const seen = /* @__PURE__ */ new Set();
91
+ const out = [];
92
+ const add = (c) => {
93
+ if (seen.has(c.id)) return;
94
+ seen.add(c.id);
95
+ out.push(c);
96
+ };
97
+ const people = (users) => users.filter((u) => !ui.isAgent(u) && u.external_id !== opts.me);
98
+ if (opts.scope !== "contacts") {
99
+ for (const u of people(opts.members)) add(userCandidate(u, "members", "ring"));
100
+ return out;
101
+ }
102
+ const contacts = (opts.contacts ?? []).filter((c) => !(c.user && ui.isAgent(c.user)));
103
+ const contactOf = new Map(
104
+ contacts.filter((c) => c.user).map((c) => [c.user.external_id, c.contactExtId])
105
+ );
106
+ for (const u of people(opts.members)) {
107
+ const contactId = contactOf.get(u.external_id) ?? opts.contactIdOf?.(u) ?? null;
108
+ add(userCandidate(u, "members", contactId ? "ring" : "add-contact", contactId));
109
+ }
110
+ for (const c of contacts) {
111
+ if (c.user) {
112
+ if (c.user.external_id === opts.me) continue;
113
+ add(userCandidate(c.user, "contacts", "ring", c.contactExtId));
114
+ continue;
115
+ }
116
+ const status = c.email ? "invite" : "unavailable";
117
+ add({
118
+ id: c.contactExtId,
119
+ name: c.name,
120
+ email: c.email,
121
+ section: "contacts",
122
+ status,
123
+ reason: c.email ? INVITE_LINK_HINT : NO_EMAIL_REASON,
124
+ user: null,
125
+ contactExtId: c.contactExtId
126
+ });
127
+ }
128
+ return out;
129
+ }
130
+ function isPickable(c) {
131
+ return c.status === "ring" || c.status === "invite";
132
+ }
133
+ function matchesQuery(c, query) {
134
+ const q = query.trim().toLowerCase();
135
+ if (!q) return true;
136
+ return c.name.toLowerCase().includes(q) || (c.email ?? "").toLowerCase().includes(q);
137
+ }
138
+ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
139
+ var COPY = {
140
+ workspace: {
141
+ title: "Call thread members",
142
+ description: "Only members of this thread\u2019s workspace can join. Pick who to ring \u2014 or nobody, and share the call from the thread.",
143
+ action: "Start call"
144
+ },
145
+ chat: {
146
+ title: "Call the group",
147
+ description: "The people you pick are rung.",
148
+ action: "Start call"
149
+ },
150
+ contacts: {
151
+ title: "New call",
152
+ description: "Your contacts with an ARBI account are rung. Others get an invitation to create an account and join.",
153
+ action: "Start call"
154
+ }
155
+ };
156
+ function CandidateRow({
157
+ candidate,
158
+ checked,
159
+ onToggle,
160
+ onAddContact,
161
+ adding
162
+ }) {
163
+ const pickable = isPickable(candidate);
164
+ const hint = candidate.status === "invite" ? candidate.reason : candidate.status === "add-contact" ? "Not in your contacts" : void 0;
165
+ const row = /* @__PURE__ */ jsxRuntime.jsxs(
166
+ "li",
167
+ {
168
+ className: ui.cn(
169
+ "flex items-center gap-3 rounded-md px-2 py-1.5",
170
+ pickable ? "hover:bg-muted" : "opacity-60"
171
+ ),
172
+ "data-testid": `call-picker-row-${candidate.id}`,
173
+ "data-status": candidate.status,
174
+ "aria-disabled": !pickable || void 0,
175
+ children: [
176
+ /* @__PURE__ */ jsxRuntime.jsx(
177
+ ui.Checkbox,
178
+ {
179
+ checked,
180
+ disabled: !pickable,
181
+ onCheckedChange: onToggle,
182
+ "aria-label": `Invite ${candidate.name}`,
183
+ "data-testid": `call-picker-check-${candidate.id}`
184
+ }
185
+ ),
186
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
187
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate text-sm", children: candidate.name }),
188
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "block truncate text-xs text-muted-foreground", children: [
189
+ candidate.email,
190
+ hint && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 inline-flex items-center gap-1", children: [
191
+ candidate.status === "invite" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mail, { className: "size-3", "aria-hidden": true }),
192
+ candidate.email ? `\xB7 ${hint}` : hint
193
+ ] })
194
+ ] })
195
+ ] }),
196
+ candidate.status === "add-contact" && /* @__PURE__ */ jsxRuntime.jsxs(
197
+ ui.Button,
198
+ {
199
+ type: "button",
200
+ size: "sm",
201
+ variant: "outline",
202
+ disabled: adding,
203
+ onClick: onAddContact,
204
+ "data-testid": `call-picker-add-${candidate.id}`,
205
+ children: [
206
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserPlus, { className: "mr-1 size-3.5" }),
207
+ "Add contact"
208
+ ]
209
+ }
210
+ )
211
+ ]
212
+ }
213
+ );
214
+ if (candidate.status !== "unavailable" || !candidate.reason) return row;
215
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Tooltip, { children: [
216
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TooltipTrigger, { asChild: true, children: row }),
217
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: candidate.reason }) })
218
+ ] });
219
+ }
220
+ function InviteLinks({ callExtId }) {
221
+ const { notify } = chunkB3NYBMDR_cjs.useBlocksEnvironment();
222
+ const revokeLink = react$1.useRevokeCallInviteLink(callExtId);
223
+ const { data: invites = [] } = react$1.useCallInviteLinks(callExtId);
224
+ const live = invites.filter((i) => !i.revoked_at);
225
+ if (!live.length) return null;
226
+ const revoke = async (id) => {
227
+ try {
228
+ await revokeLink(id);
229
+ } catch (err) {
230
+ notify(err instanceof Error ? err.message : "Could not revoke the link", "error");
231
+ }
232
+ };
233
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col gap-1", "data-testid": "call-picker-invite-links", children: [
234
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-medium text-muted-foreground", children: "Invitations sent" }),
235
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-1", children: live.map((invite) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-center gap-2 text-sm", children: [
236
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mail, { className: "size-3.5 text-muted-foreground", "aria-hidden": true }),
237
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: invite.email }),
238
+ invite.used_at && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "joined" }),
239
+ /* @__PURE__ */ jsxRuntime.jsxs(
240
+ ui.Button,
241
+ {
242
+ type: "button",
243
+ size: "sm",
244
+ variant: "ghost",
245
+ onClick: () => void revoke(invite.external_id),
246
+ "data-testid": `call-picker-revoke-${invite.external_id}`,
247
+ children: [
248
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "mr-1 size-3.5" }),
249
+ "Revoke"
250
+ ]
251
+ }
252
+ )
253
+ ] }, invite.external_id)) })
254
+ ] });
255
+ }
256
+ function CallPeoplePicker({
257
+ open,
258
+ onOpenChange,
259
+ scope,
260
+ workspaceExtId,
261
+ members: chatMembers = [],
262
+ preselected = [],
263
+ title,
264
+ description,
265
+ actionLabel,
266
+ callExtId,
267
+ onSubmit
268
+ }) {
269
+ const { notify } = chunkB3NYBMDR_cjs.useBlocksEnvironment();
270
+ const createContact = react$1.useCreateContact();
271
+ const { userId: me, workspaceId: selectedWorkspaceId } = chunkP6HVJP6Z_cjs.useConnectedWorkspace();
272
+ const { data: workspaces = [] } = react$1.useWorkspaces({ enabled: scope !== "chat" });
273
+ const [picked, setPicked] = react.useState(() => new Set(preselected));
274
+ const [query, setQuery] = react.useState("");
275
+ const [newEmail, setNewEmail] = react.useState(null);
276
+ const [newName, setNewName] = react.useState("");
277
+ const [adding, setAdding] = react.useState(false);
278
+ const [busy, setBusy] = react.useState(false);
279
+ const [added, setAdded] = react.useState([]);
280
+ const { byEmail } = react$1.usePeople();
281
+ const { people: hits } = react$1.usePeopleSearch(open && scope === "contacts" ? query : "");
282
+ const preselectedKey = preselected.join(",");
283
+ react.useEffect(() => {
284
+ if (open) setPicked(new Set(preselectedKey ? preselectedKey.split(",") : []));
285
+ }, [open, preselectedKey]);
286
+ const workspaceId = workspaceExtId ?? (scope === "contacts" ? selectedWorkspaceId : null);
287
+ const workspaceMembers = react.useMemo(
288
+ () => (workspaces.find((w) => w.external_id === workspaceId)?.users ?? []).map((wu) => wu.user),
289
+ [workspaces, workspaceId]
290
+ );
291
+ const candidates = react.useMemo(() => {
292
+ const found = hits.flatMap(
293
+ (p) => p.contactId ? [{ contactExtId: p.contactId, user: p.user, name: p.name, email: p.email }] : []
294
+ );
295
+ return buildCallCandidates({
296
+ scope,
297
+ members: scope === "chat" ? chatMembers : workspaceMembers,
298
+ contacts: [...added, ...found],
299
+ contactIdOf: (u) => byEmail(u.email)?.contactId ?? null,
300
+ me
301
+ });
302
+ }, [scope, chatMembers, workspaceMembers, hits, added, byEmail, me]);
303
+ const shown = candidates.filter((c) => matchesQuery(c, query));
304
+ const copy = COPY[scope];
305
+ const toggle = (id) => setPicked((prev) => {
306
+ const next = new Set(prev);
307
+ if (next.has(id)) next.delete(id);
308
+ else next.add(id);
309
+ return next;
310
+ });
311
+ const addContact = async (email, name) => {
312
+ setAdding(true);
313
+ try {
314
+ const cardName = name?.trim();
315
+ const contact = await createContact.mutateAsync({
316
+ email,
317
+ invite: true,
318
+ ...cardName ? { card: { name: cardName, emails: [{ email }] } } : {}
319
+ });
320
+ if (contact.status === "failed") {
321
+ throw new Error(contact.outcome_detail || "Could not add the contact");
322
+ }
323
+ const added2 = callContactOf(contact);
324
+ if (added2) setAdded((prev) => [...prev, added2]);
325
+ const id = contact.user?.external_id ?? contact.external_id;
326
+ const pickable = contact.user ? !!contact.user.encryption_public_key : !!added2?.email;
327
+ if (id && pickable) setPicked((prev) => new Set(prev).add(id));
328
+ setNewEmail(null);
329
+ setNewName("");
330
+ } catch (err) {
331
+ notify(
332
+ err instanceof browser.ArbiApiError ? browser.refusalReason(err, "Could not add the contact") : err instanceof Error ? err.message : "Could not add the contact",
333
+ "error"
334
+ );
335
+ } finally {
336
+ setAdding(false);
337
+ }
338
+ };
339
+ const submit = async () => {
340
+ if (busy) return;
341
+ const chosen = candidates.filter((c) => picked.has(c.id) && isPickable(c));
342
+ setBusy(true);
343
+ try {
344
+ await onSubmit({
345
+ ring: chosen.filter((c) => c.status === "ring" && c.user).map((c) => c.user),
346
+ invites: chosen.filter((c) => c.status === "invite" && c.contactExtId).map((c) => ({ contactExtId: c.contactExtId, name: c.name }))
347
+ });
348
+ onOpenChange(false);
349
+ } catch (err) {
350
+ notify(err instanceof Error ? err.message : "Something went wrong", "error");
351
+ } finally {
352
+ setBusy(false);
353
+ }
354
+ };
355
+ const sections = scope === "contacts" ? [
356
+ { id: "members", label: "Workspace members" },
357
+ { id: "contacts", label: "Contacts" }
358
+ ] : [{ id: "members", label: scope === "chat" ? "Members" : "Workspace members" }];
359
+ const count = candidates.filter((c) => picked.has(c.id) && isPickable(c)).length;
360
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogContent, { className: "sm:max-w-md", "data-testid": "call-people-picker", children: [
361
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogHeader, { children: [
362
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DialogTitle, { children: title ?? copy.title }),
363
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DialogDescription, { children: description ?? copy.description })
364
+ ] }),
365
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-0 flex-col gap-3", children: [
366
+ /* @__PURE__ */ jsxRuntime.jsx(
367
+ ui.Input,
368
+ {
369
+ placeholder: "Search people",
370
+ value: query,
371
+ onChange: (e) => setQuery(e.target.value),
372
+ "aria-label": "Search people",
373
+ "data-testid": "call-picker-search"
374
+ }
375
+ ),
376
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-h-80 overflow-y-auto", children: [
377
+ sections.map((section) => {
378
+ const rows = shown.filter((c) => c.section === section.id);
379
+ if (!rows.length) return null;
380
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "mb-2", children: [
381
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "px-2 pb-1 text-xs font-medium text-muted-foreground", children: section.label }),
382
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { "data-testid": `call-picker-section-${section.id}`, children: rows.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
383
+ CandidateRow,
384
+ {
385
+ candidate: c,
386
+ checked: picked.has(c.id),
387
+ onToggle: () => toggle(c.id),
388
+ adding,
389
+ onAddContact: () => c.email && void addContact(c.email)
390
+ },
391
+ c.id
392
+ )) })
393
+ ] }, section.id);
394
+ }),
395
+ !shown.length && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: scope === "contacts" && !query.trim() ? "Search your contacts by name or e-mail." : candidates.length ? "Nobody matches." : "Nobody to call here yet." })
396
+ ] }),
397
+ scope === "contacts" && (newEmail === null ? /* @__PURE__ */ jsxRuntime.jsxs(
398
+ ui.Button,
399
+ {
400
+ type: "button",
401
+ variant: "ghost",
402
+ size: "sm",
403
+ className: "self-start",
404
+ onClick: () => setNewEmail(EMAIL_RE.test(query.trim()) ? query.trim() : ""),
405
+ "data-testid": "call-picker-add-contact",
406
+ children: [
407
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserPlus, { className: "mr-1 size-4" }),
408
+ "Add contact\u2026"
409
+ ]
410
+ }
411
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(
412
+ "form",
413
+ {
414
+ className: "flex flex-wrap items-center gap-2",
415
+ onSubmit: (e) => {
416
+ e.preventDefault();
417
+ if (EMAIL_RE.test(newEmail.trim())) void addContact(newEmail.trim(), newName);
418
+ },
419
+ children: [
420
+ /* @__PURE__ */ jsxRuntime.jsx(
421
+ ui.Input,
422
+ {
423
+ className: "min-w-[8rem] flex-1",
424
+ placeholder: "Name (optional)",
425
+ value: newName,
426
+ maxLength: 200,
427
+ onChange: (e) => setNewName(e.target.value),
428
+ "aria-label": "New contact's name",
429
+ autoComplete: "off",
430
+ "data-testid": "call-picker-new-name"
431
+ }
432
+ ),
433
+ /* @__PURE__ */ jsxRuntime.jsx(
434
+ ui.Input,
435
+ {
436
+ className: "min-w-[10rem] flex-1",
437
+ type: "email",
438
+ autoFocus: true,
439
+ placeholder: "name@example.com",
440
+ value: newEmail,
441
+ onChange: (e) => setNewEmail(e.target.value),
442
+ "aria-label": "New contact's e-mail",
443
+ "data-testid": "call-picker-new-email"
444
+ }
445
+ ),
446
+ /* @__PURE__ */ jsxRuntime.jsx(
447
+ ui.Button,
448
+ {
449
+ type: "submit",
450
+ size: "sm",
451
+ disabled: adding || !EMAIL_RE.test(newEmail.trim()),
452
+ "data-testid": "call-picker-new-submit",
453
+ children: "Add"
454
+ }
455
+ ),
456
+ /* @__PURE__ */ jsxRuntime.jsx(
457
+ ui.Button,
458
+ {
459
+ type: "button",
460
+ size: "sm",
461
+ variant: "ghost",
462
+ onClick: () => {
463
+ setNewEmail(null);
464
+ setNewName("");
465
+ },
466
+ children: "Cancel"
467
+ }
468
+ )
469
+ ]
470
+ }
471
+ )),
472
+ callExtId && scope === "contacts" && /* @__PURE__ */ jsxRuntime.jsx(InviteLinks, { callExtId }),
473
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Agents can\u2019t join calls." })
474
+ ] }),
475
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogFooter, { children: [
476
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "ghost", onClick: () => onOpenChange(false), disabled: busy, children: "Cancel" }),
477
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => void submit(), disabled: busy, "data-testid": "call-picker-submit", children: busy ? "Working\u2026" : `${actionLabel ?? copy.action}${count ? ` (${count})` : ""}` })
478
+ ] })
479
+ ] }) });
480
+ }
481
+ function ThreadCallButton({
482
+ conversationId
483
+ }) {
484
+ const arbi = react$1.useArbi();
485
+ const { data: conversations } = chunkHDEOORSV_cjs.useConnectedConversations();
486
+ const { workspaceId: workspaceExtId } = chunkP6HVJP6Z_cjs.useConnectedWorkspace();
487
+ const liveCallId = react$1.useCallSession((s) => react$1.threadLiveCallId(s, conversationId));
488
+ const isLive = liveCallId !== null;
489
+ const canHost = react$1.useCanHostCalls();
490
+ const [picking, setPicking] = react.useState(false);
491
+ const conversation = conversations.find((c) => c.external_id === conversationId);
492
+ if (!conversation?.is_shared) return null;
493
+ const title = conversation.title ?? null;
494
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
495
+ /* @__PURE__ */ jsxRuntime.jsx(
496
+ StartCallButton,
497
+ {
498
+ onStart: async () => {
499
+ if (liveCallId && !canHost) return react$1.openCall(arbi, { callExtId: liveCallId });
500
+ if (isLive) return react$1.startThreadCall(arbi, { threadExtId: conversationId, title, ring: [] });
501
+ setPicking(true);
502
+ return true;
503
+ },
504
+ isLive,
505
+ label: "Call thread members",
506
+ testId: "thread-call-button"
507
+ }
508
+ ),
509
+ picking && /* @__PURE__ */ jsxRuntime.jsx(
510
+ CallPeoplePicker,
511
+ {
512
+ open: true,
513
+ onOpenChange: setPicking,
514
+ scope: "workspace",
515
+ workspaceExtId,
516
+ onSubmit: async ({ ring }) => {
517
+ await react$1.startThreadCall(arbi, { threadExtId: conversationId, title, ring });
518
+ }
519
+ }
520
+ )
521
+ ] });
522
+ }
523
+ function ScheduleCallButton({
524
+ conversationId,
525
+ peer,
526
+ variant = "icon",
527
+ className
528
+ }) {
529
+ const callsEnabled = react$1.useCanHostCalls();
530
+ const { conversations } = react$1.useConversationItems();
531
+ const { data: workspaces = [] } = react$1.useWorkspaces();
532
+ const { workspaceId: selectedWorkspaceId, userId: me } = chunkP6HVJP6Z_cjs.useConnectedWorkspace();
533
+ const { openCalendar } = chunkB3NYBMDR_cjs.useBlocksEnvironment();
534
+ if (!callsEnabled) return null;
535
+ const open = () => {
536
+ const conversation = conversationId ? conversations?.find((c) => c.external_id === conversationId) : void 0;
537
+ let people = [];
538
+ if (peer) people = [peer];
539
+ else if (conversation?.is_shared) {
540
+ const workspace = workspaces.find((w) => w.external_id === selectedWorkspaceId);
541
+ people = (workspace?.users ?? []).map((wu) => wu.user);
542
+ }
543
+ chunkB3NYBMDR_cjs.requestCalendarComposer({
544
+ title: peer ? `Call with ${ui.getUserDisplayName(peer) || peer.email}` : conversation?.title ?? "",
545
+ conversationId: conversationId ?? null,
546
+ attendees: people.filter((u) => !ui.isAgent(u) && u.external_id !== me).map((u) => ({
547
+ email: u.email,
548
+ user_id: u.external_id,
549
+ name: ui.getUserDisplayName(u) || null
550
+ })),
551
+ addCall: true
552
+ });
553
+ openCalendar();
554
+ };
555
+ return /* @__PURE__ */ jsxRuntime.jsxs(
556
+ ui.Button,
557
+ {
558
+ type: "button",
559
+ variant: "ghost",
560
+ size: variant === "icon" ? "icon" : "sm",
561
+ className: ui.cn(variant === "icon" && "size-8", className),
562
+ onClick: open,
563
+ "aria-label": "Schedule call",
564
+ title: "Schedule call",
565
+ "data-testid": "schedule-call-button",
566
+ children: [
567
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarPlus, { className: "size-4" }),
568
+ variant === "label" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1.5", children: "Schedule call" })
569
+ ]
570
+ }
571
+ );
572
+ }
17
573
  function useMeetingThreadMessages(meetingCallExtId, messageHistory) {
18
574
  const hasRecTranscript = react.useMemo(
19
575
  () => !!meetingCallExtId && react$1.hasRecordingTranscript(messageHistory, react$1.threadTranscriptRef),
@@ -162,6 +718,32 @@ function PickThreadDialog({
162
718
  ] })
163
719
  ] }) });
164
720
  }
721
+ function MeetingThreadTranscriptAction({
722
+ conversationExtId,
723
+ meetingCallExtId,
724
+ title,
725
+ messages
726
+ }) {
727
+ const { data: call } = react$1.useCall(meetingCallExtId);
728
+ const { data: workspaceUsers = [] } = react$1.useWorkspaceUsers();
729
+ const lines = react.useMemo(
730
+ () => react$1.threadTranscriptLines(messages, (id) => {
731
+ const user = workspaceUsers.find((wu) => wu.user.external_id === id)?.user;
732
+ return user ? ui.getUserDisplayName(user) : null;
733
+ }),
734
+ [messages, workspaceUsers]
735
+ );
736
+ if (!meetingCallExtId || !call?.is_creator) return null;
737
+ return /* @__PURE__ */ jsxRuntime.jsx(
738
+ SaveTranscriptToThread,
739
+ {
740
+ title,
741
+ lines,
742
+ excludeConversationExtId: conversationExtId,
743
+ iconOnly: true
744
+ }
745
+ );
746
+ }
165
747
  function RecordingCard({
166
748
  callExtId,
167
749
  recordingExtId,
@@ -764,6 +1346,81 @@ function MixPlayer({
764
1346
  ] })
765
1347
  ] });
766
1348
  }
1349
+ function MeetingThreadRecordingsAction({
1350
+ meetingCallExtId,
1351
+ title,
1352
+ iconOnly = false
1353
+ }) {
1354
+ const [open, setOpen] = react.useState(false);
1355
+ const pending = chunkEGSSLWNZ_cjs.usePendingRecording();
1356
+ react.useEffect(() => {
1357
+ if (pending) setOpen(true);
1358
+ }, [pending]);
1359
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1360
+ /* @__PURE__ */ jsxRuntime.jsx(
1361
+ chunkEGSSLWNZ_cjs.HeaderAction,
1362
+ {
1363
+ label: "Recordings",
1364
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Disc, { className: "size-3.5", "aria-hidden": true }),
1365
+ iconOnly,
1366
+ onClick: () => setOpen(true),
1367
+ testId: "meeting-recordings"
1368
+ }
1369
+ ),
1370
+ open && /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open: true, onOpenChange: (o) => !o && setOpen(false), children: /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogContent, { className: "sm:max-w-2xl", "data-testid": "meeting-recordings-dialog", children: [
1371
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogHeader, { children: [
1372
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DialogTitle, { children: "Recordings" }),
1373
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DialogDescription, { children: "Recordings of this meeting, encrypted under the workspace key. Playing or downloading one decrypts it in this browser." })
1374
+ ] }),
1375
+ /* @__PURE__ */ jsxRuntime.jsx(
1376
+ RecordingsList,
1377
+ {
1378
+ callExtId: meetingCallExtId,
1379
+ title,
1380
+ className: "max-h-[60vh] overflow-y-auto"
1381
+ }
1382
+ )
1383
+ ] }) })
1384
+ ] });
1385
+ }
1386
+ function ConnectedConversationCallActions() {
1387
+ const conversationId = react$1.useArbiSessionState((state) => state.conversationId);
1388
+ const { conversations } = react$1.useConversationItems();
1389
+ const conversation = conversationId ? conversations.find((c) => c.external_id === conversationId) : void 0;
1390
+ const meetingCallExtId = conversation?.meeting_call_ext_id ?? null;
1391
+ const { messageHistory } = react$1.useConversationData();
1392
+ const threadMessages = useMeetingThreadMessages(meetingCallExtId, messageHistory);
1393
+ const meetingMessages = react.useMemo(
1394
+ () => meetingCallExtId ? threadMessages.map((m) => ({
1395
+ content: m.content,
1396
+ created_at: m.created_at,
1397
+ tools: m.tools ?? m.meta?.tools
1398
+ })) : [],
1399
+ [meetingCallExtId, threadMessages]
1400
+ );
1401
+ if (!conversationId) return null;
1402
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1403
+ /* @__PURE__ */ jsxRuntime.jsx(ThreadCallButton, { conversationId }),
1404
+ /* @__PURE__ */ jsxRuntime.jsx(ScheduleCallButton, { conversationId }),
1405
+ meetingCallExtId && /* @__PURE__ */ jsxRuntime.jsx(
1406
+ MeetingThreadTranscriptAction,
1407
+ {
1408
+ conversationExtId: conversationId,
1409
+ meetingCallExtId,
1410
+ title: conversation?.title,
1411
+ messages: meetingMessages
1412
+ }
1413
+ ),
1414
+ meetingCallExtId && /* @__PURE__ */ jsxRuntime.jsx(
1415
+ MeetingThreadRecordingsAction,
1416
+ {
1417
+ meetingCallExtId,
1418
+ title: conversation?.title,
1419
+ iconOnly: true
1420
+ }
1421
+ )
1422
+ ] });
1423
+ }
767
1424
  function joinNames(people, name) {
768
1425
  const names = people.map(name);
769
1426
  return names.length > 4 ? `${names.slice(0, 4).join(", ")} +${names.length - 4}` : names.join(", ");
@@ -984,18 +1641,29 @@ function threadTranscriptRuns(messages) {
984
1641
  }
985
1642
 
986
1643
  exports.CallConversationEmpty = CallConversationEmpty;
1644
+ exports.CallPeoplePicker = CallPeoplePicker;
1645
+ exports.ConnectedConversationCallActions = ConnectedConversationCallActions;
1646
+ exports.MeetingThreadRecordingsAction = MeetingThreadRecordingsAction;
1647
+ exports.MeetingThreadTranscriptAction = MeetingThreadTranscriptAction;
987
1648
  exports.PickThreadDialog = PickThreadDialog;
988
1649
  exports.ProvisionalSpeakers = ProvisionalSpeakers;
989
1650
  exports.RecordingCard = RecordingCard;
990
1651
  exports.RecordingsList = RecordingsList;
991
1652
  exports.SaveTranscriptToThread = SaveTranscriptToThread;
1653
+ exports.ScheduleCallButton = ScheduleCallButton;
1654
+ exports.StartCallButton = StartCallButton;
1655
+ exports.ThreadCallButton = ThreadCallButton;
992
1656
  exports.ThreadCallLogCard = ThreadCallLogCard;
993
1657
  exports.TranscriptEntry = TranscriptEntry;
994
1658
  exports.TranscriptRunsContext = TranscriptRunsContext;
1659
+ exports.buildCallCandidates = buildCallCandidates;
1660
+ exports.callContactOf = callContactOf;
1661
+ exports.isPickable = isPickable;
1662
+ exports.matchesQuery = matchesQuery;
995
1663
  exports.threadTranscriptRuns = threadTranscriptRuns;
996
1664
  exports.useCallPersonName = useCallPersonName;
997
1665
  exports.useMeetingThreadMessages = useMeetingThreadMessages;
998
1666
  exports.useProvisionalSpeakers = useProvisionalSpeakers;
999
1667
  exports.useTranscriptRuns = useTranscriptRuns;
1000
- //# sourceMappingURL=chunk-6AJJJ5HR.cjs.map
1001
- //# sourceMappingURL=chunk-6AJJJ5HR.cjs.map
1668
+ //# sourceMappingURL=chunk-5R256EMF.cjs.map
1669
+ //# sourceMappingURL=chunk-5R256EMF.cjs.map