@burdenoff/microfe-botmanor 2026.1120.27 → 2026.1123.1

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 (35) hide show
  1. package/dist/botlit/components/HandoffConfigPanel.js +133 -132
  2. package/dist/botlit/components/HandoffConfigPanel.js.map +1 -1
  3. package/dist/botlit/components/HandoffTargetPickers.d.ts +28 -0
  4. package/dist/botlit/components/HandoffTargetPickers.js +180 -0
  5. package/dist/botlit/components/HandoffTargetPickers.js.map +1 -0
  6. package/dist/botlit/hooks/index.js +2 -2
  7. package/dist/botlit/hooks/useHandoffInbox.d.ts +26 -0
  8. package/dist/botlit/hooks/useHandoffInbox.js +126 -0
  9. package/dist/botlit/hooks/useHandoffInbox.js.map +1 -0
  10. package/dist/botlit/hooks/useHandoffs.js +36 -63
  11. package/dist/botlit/hooks/useHandoffs.js.map +1 -1
  12. package/dist/botlit/hooks/useMyIntegrationConnections.d.ts +4 -0
  13. package/dist/botlit/hooks/useMyIntegrationConnections.js +26 -0
  14. package/dist/botlit/hooks/useMyIntegrationConnections.js.map +1 -0
  15. package/dist/botlit/hooks/useWorkspaceMemberDirectory.d.ts +26 -0
  16. package/dist/botlit/hooks/useWorkspaceMemberDirectory.js +84 -0
  17. package/dist/botlit/hooks/useWorkspaceMemberDirectory.js.map +1 -0
  18. package/dist/botlit/pages/AiOperationsPage.js +100 -95
  19. package/dist/botlit/pages/AiOperationsPage.js.map +1 -1
  20. package/dist/botlit/pages/BotChannelsTab.js +288 -250
  21. package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
  22. package/dist/botlit/pages/HandoffsPage.js +216 -171
  23. package/dist/botlit/pages/HandoffsPage.js.map +1 -1
  24. package/dist/botlit/permissions/botmanorPermissions.d.ts +1 -0
  25. package/dist/botlit/permissions/botmanorPermissions.js +1 -0
  26. package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
  27. package/dist/botlit/utils/handoffInbox.d.ts +64 -0
  28. package/dist/botlit/utils/handoffInbox.js +62 -0
  29. package/dist/botlit/utils/handoffInbox.js.map +1 -0
  30. package/dist/generated/wspace-operations.d.ts +160 -0
  31. package/dist/generated/wspace-operations.js +128 -87
  32. package/dist/generated/wspace-operations.js.map +1 -1
  33. package/dist/generated/wspace-types.js +8 -6
  34. package/dist/generated/wspace-types.js.map +1 -1
  35. package/package.json +1 -1
@@ -1,27 +1,34 @@
1
1
  import { useTr as e } from "../../shared/hooks/useTr.js";
2
2
  import { useAgents as t } from "../hooks/useAgents.js";
3
3
  import { PageLayout as n } from "../components/PageLayout.js";
4
- import { Card as r, CardContent as i, CardDescription as a, CardHeader as o, CardTitle as s } from "../components/Card.js";
5
- import { Button as c } from "../components/Button.js";
6
- import { Badge as l } from "../components/Badge.js";
7
- import { EmptyState as u } from "../components/EmptyState.js";
8
- import { ErrorState as d } from "../components/ErrorState.js";
9
- import { Input as f, Textarea as p } from "../components/Input.js";
4
+ import { BOTMANOR_PERMISSIONS as r } from "../permissions/botmanorPermissions.js";
5
+ import { useBotmanorPermission as i } from "../permissions/useBotmanorPermissions.js";
6
+ import { Card as a, CardContent as o, CardDescription as s, CardHeader as c, CardTitle as l } from "../components/Card.js";
7
+ import { Button as u } from "../components/Button.js";
8
+ import { Badge as d } from "../components/Badge.js";
9
+ import { EmptyState as f } from "../components/EmptyState.js";
10
+ import { ErrorState as p } from "../components/ErrorState.js";
11
+ import { Textarea as m } from "../components/Input.js";
10
12
  import "../hooks/index.js";
11
- import { BotmanorHandoffMessageRole as m, BotmanorHandoffStatus as h } from "../../generated/wspace-types.js";
12
- import { isActiveHandoff as g, useAcceptHandoff as _, useAssignHandoff as v, useHandoffQueue as y, useHandoffTranscript as b, useRejectHandoff as ee, useReleaseHandoff as te, useReplyToHandoff as x, useResolveHandoff as S } from "../hooks/useHandoffs.js";
13
- import { formatRelativeTime as C } from "../utils/formatters.js";
14
- import { useEffect as w, useMemo as T, useRef as ne, useState as E } from "react";
15
- import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
16
- import { useSearchParams as A } from "react-router";
13
+ import { BotmanorHandoffMessageRole as h, BotmanorHandoffStatus as g } from "../../generated/wspace-types.js";
14
+ import { formatRelativeTime as _ } from "../utils/formatters.js";
15
+ import { useHandoffInbox as v } from "../hooks/useHandoffInbox.js";
16
+ import { isActiveHandoff as y, useAcceptHandoff as b, useAssignHandoff as x, useHandoffTranscript as S, useRejectHandoff as C, useReleaseHandoff as w, useReplyToHandoff as ee, useResolveHandoff as te } from "../hooks/useHandoffs.js";
17
+ import { shortUserLabel as ne, useWorkspaceMemberDirectory as T } from "../hooks/useWorkspaceMemberDirectory.js";
18
+ import { isHandoffConflict as E } from "../utils/handoffInbox.js";
19
+ import { LoadMore as D } from "../components/LoadMore.js";
20
+ import "../permissions/index.js";
21
+ import { useEffect as O, useMemo as k, useRef as re, useState as A } from "react";
22
+ import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
23
+ import { useSearchParams as P } from "react-router";
17
24
  // src/botlit/pages/HandoffsPage.tsx
18
- var j = "handoff", M = [
25
+ var F = "handoff", I = [
19
26
  {
20
27
  id: "active",
21
28
  statuses: [
22
- h.Requested,
23
- h.Assigned,
24
- h.Accepted
29
+ g.Requested,
30
+ g.Assigned,
31
+ g.Accepted
25
32
  ],
26
33
  labelKey: "botlit.handoffs.filter.active",
27
34
  label: "Active"
@@ -29,9 +36,9 @@ var j = "handoff", M = [
29
36
  {
30
37
  id: "resolved",
31
38
  statuses: [
32
- h.Resolved,
33
- h.Released,
34
- h.Rejected
39
+ g.Resolved,
40
+ g.Released,
41
+ g.Rejected
35
42
  ],
36
43
  labelKey: "botlit.handoffs.filter.resolved",
37
44
  label: "Closed"
@@ -42,7 +49,7 @@ var j = "handoff", M = [
42
49
  labelKey: "botlit.handoffs.filter.all",
43
50
  label: "All"
44
51
  }
45
- ], N = ({ handoff: t }) => {
52
+ ], ie = ({ handoff: t }) => {
46
53
  let n = e(), r = {
47
54
  EXPLICIT_REQUEST: n("botlit.handoffs.trigger.explicitRequest", "Explicit request"),
48
55
  CUSTOM_INTENT: n("botlit.handoffs.trigger.customIntent", "Custom intent"),
@@ -51,37 +58,37 @@ var j = "handoff", M = [
51
58
  POLICY_REFUSAL: n("botlit.handoffs.trigger.policyRefusal", "Policy refusal"),
52
59
  MANUAL: n("botlit.handoffs.trigger.manual", "Manual")
53
60
  };
54
- return /* @__PURE__ */ O(l, {
61
+ return /* @__PURE__ */ M(d, {
55
62
  variant: "outline",
56
63
  children: r[t.trigger] ?? t.trigger
57
64
  });
58
- }, P = ({ status: t }) => {
65
+ }, ae = ({ status: t }) => {
59
66
  let n = e(), r = {
60
- [h.Requested]: {
67
+ [g.Requested]: {
61
68
  text: n("botlit.handoffs.status.requested", "Requested"),
62
69
  variant: "warning"
63
70
  },
64
- [h.Assigned]: {
71
+ [g.Assigned]: {
65
72
  text: n("botlit.handoffs.status.assigned", "Assigned"),
66
73
  variant: "warning"
67
74
  },
68
- [h.Accepted]: {
75
+ [g.Accepted]: {
69
76
  text: n("botlit.handoffs.status.accepted", "Accepted"),
70
77
  variant: "success"
71
78
  },
72
- [h.Resolved]: {
79
+ [g.Resolved]: {
73
80
  text: n("botlit.handoffs.status.resolved", "Resolved"),
74
81
  variant: "outline"
75
82
  },
76
- [h.Released]: {
83
+ [g.Released]: {
77
84
  text: n("botlit.handoffs.status.released", "Released to bot"),
78
85
  variant: "outline"
79
86
  },
80
- [h.Rejected]: {
87
+ [g.Rejected]: {
81
88
  text: n("botlit.handoffs.status.rejected", "Rejected"),
82
89
  variant: "destructive"
83
90
  },
84
- [h.Expired]: {
91
+ [g.Expired]: {
85
92
  text: n("botlit.handoffs.status.expired", "Expired"),
86
93
  variant: "outline"
87
94
  }
@@ -89,341 +96,379 @@ var j = "handoff", M = [
89
96
  text: String(t),
90
97
  variant: "outline"
91
98
  };
92
- return /* @__PURE__ */ O(l, {
99
+ return /* @__PURE__ */ M(d, {
93
100
  variant: r.variant,
94
101
  children: r.text
95
102
  });
96
- }, F = 1e4;
97
- function I(e, t) {
103
+ }, L = 1e4;
104
+ function R(e, t) {
98
105
  return Math.round((new Date(e).getTime() - t) / 6e4);
99
106
  }
100
- var L = ({ handoff: t }) => {
101
- let n = e(), [r, i] = E(() => Date.now()), a = g(t.status) && !t.firstResponseAt;
102
- if (w(() => {
107
+ var oe = ({ handoff: t }) => {
108
+ let n = e(), [r, i] = A(() => Date.now()), a = y(t.status) && !t.firstResponseAt;
109
+ if (O(() => {
103
110
  if (!a) return;
104
111
  let e = window.setInterval(() => i(Date.now()), 3e4);
105
112
  return () => window.clearInterval(e);
106
113
  }, [a]), !t.slaDueAt) return null;
107
- if (t.slaBreached || a && new Date(t.slaDueAt).getTime() <= r) return /* @__PURE__ */ O(l, {
114
+ if (t.slaBreached || a && new Date(t.slaDueAt).getTime() <= r) return /* @__PURE__ */ M(d, {
108
115
  variant: "destructive",
109
116
  "data-testid": "handoff-sla",
110
117
  children: n("botlit.handoffs.sla.breached", "SLA breached")
111
118
  });
112
- if (t.firstResponseAt) return /* @__PURE__ */ O(l, {
119
+ if (t.firstResponseAt) return /* @__PURE__ */ M(d, {
113
120
  variant: "success",
114
121
  "data-testid": "handoff-sla",
115
122
  children: n("botlit.handoffs.sla.met", "SLA met")
116
123
  });
117
124
  if (!a) return null;
118
- let o = Math.max(I(t.slaDueAt, r), 0);
119
- return /* @__PURE__ */ O(l, {
125
+ let o = Math.max(R(t.slaDueAt, r), 0);
126
+ return /* @__PURE__ */ M(d, {
120
127
  variant: "warning",
121
128
  "data-testid": "handoff-sla",
122
129
  children: n("botlit.handoffs.sla.due", "Reply due in {{minutes}} min", { minutes: o })
123
130
  });
124
- }, R = {
125
- [m.Customer]: {
131
+ }, z = {
132
+ [h.Customer]: {
126
133
  key: "botlit.handoffs.thread.customer",
127
134
  label: "Customer"
128
135
  },
129
- [m.Bot]: {
136
+ [h.Bot]: {
130
137
  key: "botlit.handoffs.thread.bot",
131
138
  label: "Bot"
132
139
  },
133
- [m.Operator]: {
140
+ [h.Operator]: {
134
141
  key: "botlit.handoffs.thread.operator",
135
142
  label: "Operator"
136
143
  }
137
- }, re = ({ handoffId: t, messages: n }) => {
144
+ }, se = ({ handoffId: t, messages: n }) => {
138
145
  let r = e();
139
- return n.length === 0 ? /* @__PURE__ */ O("p", {
146
+ return n.length === 0 ? /* @__PURE__ */ M("p", {
140
147
  className: "text-sm text-text-secondary",
141
148
  children: r("botlit.handoffs.thread.empty", "No messages on this handoff yet.")
142
- }) : /* @__PURE__ */ O("ol", {
149
+ }) : /* @__PURE__ */ M("ol", {
143
150
  className: "grid gap-2 rounded-card border border-border-seam p-3",
144
151
  "aria-label": r("botlit.handoffs.thread.label", "Conversation"),
145
152
  "data-testid": `handoff-thread-${t}`,
146
153
  children: n.map((e) => {
147
- let t = R[e.role] ?? {
154
+ let t = z[e.role] ?? {
148
155
  key: "",
149
156
  label: String(e.role)
150
157
  };
151
- return /* @__PURE__ */ k("li", {
158
+ return /* @__PURE__ */ N("li", {
152
159
  className: "grid gap-0.5",
153
- children: [/* @__PURE__ */ k("span", {
160
+ children: [/* @__PURE__ */ N("span", {
154
161
  className: "text-xs font-medium text-text-secondary",
155
162
  children: [
156
163
  t.key ? r(t.key, t.label) : t.label,
157
164
  " ·",
158
165
  " ",
159
- C(e.createdAt)
166
+ _(e.createdAt)
160
167
  ]
161
- }), /* @__PURE__ */ O("span", {
168
+ }), /* @__PURE__ */ M("span", {
162
169
  className: "text-sm whitespace-pre-wrap text-text-primary",
163
170
  children: e.text
164
171
  })]
165
172
  }, e.id);
166
173
  })
167
174
  });
168
- }, z = ({ handoff: t, agents: n, onChanged: r, linked: i = !1 }) => {
169
- let a = e(), [o, s] = _(), [u, d] = te(), [m, y] = S(), [T, A] = ee(), [j, M] = v(), [I, R] = x(), z = g(t.status), B = t.status === h.Accepted, [V, H] = E(null), U = V && V.linked === i ? V.open : i, W = ne(null);
170
- w(() => {
171
- i && W.current?.scrollIntoView?.({
175
+ }, B = ({ handoff: t, agents: n, members: r, isNew: i, canManage: a, onChanged: o, linked: s = !1 }) => {
176
+ let c = e(), [l, f] = b(), [p, h] = w(), [v, T] = te(), [D, k] = C(), [P, F] = x(), [I, R] = ee(), z = y(t.status), B = t.status === g.Accepted, [V, H] = A(null), U = V && V.linked === s ? V.open : s, W = re(null);
177
+ O(() => {
178
+ s && W.current?.scrollIntoView?.({
172
179
  block: "center",
173
180
  behavior: "smooth"
174
181
  });
175
- }, [i]);
176
- let G = b(U ? t.id : void 0), K = G.refetch;
177
- w(() => {
182
+ }, [s]);
183
+ let G = S(U ? t.id : void 0), K = G.refetch;
184
+ O(() => {
178
185
  if (!U || !z) return;
179
186
  let e = window.setInterval(() => {
180
187
  K();
181
- }, F);
188
+ }, L);
182
189
  return () => window.clearInterval(e);
183
190
  }, [
184
191
  U,
185
192
  z,
186
193
  K
187
194
  ]);
188
- let [q, J] = E(""), [Y, X] = E(""), Z = s.loading || d.loading || y.loading || A.loading || M.loading || R.loading, Q = s.error ?? d.error ?? y.error ?? A.error ?? M.error ?? R.error, ie = async (e) => {
195
+ let [q, J] = A(""), [Y, X] = A(""), Z = f.loading || h.loading || T.loading || k.loading || F.loading || R.loading, Q = f.error ?? h.error ?? T.error ?? k.error ?? F.error ?? R.error, ce = Q ? E(Q) : !1, le = (e) => r.find((t) => t.userId === e)?.displayName ?? ne(e), ue = async (e) => {
189
196
  e.preventDefault();
190
197
  let n = q.trim();
191
198
  if (n) try {
192
199
  await I({
193
200
  id: t.id,
194
201
  message: n
195
- }), J(""), await G.refetch(), r();
202
+ }), J(""), await G.refetch(), o();
196
203
  } catch {}
197
- }, ae = async (e) => {
204
+ }, de = async (e) => {
198
205
  e.preventDefault();
199
206
  let n = Y.trim();
200
207
  if (n) try {
201
- await j({
208
+ await P({
202
209
  id: t.id,
203
210
  assigneeId: n
204
- }), X(""), r();
211
+ }), X(""), o();
205
212
  } catch {}
206
213
  }, $ = async (e) => {
207
214
  try {
208
- await e(t.id), r();
209
- } catch {}
215
+ await e(t.id), o();
216
+ } catch (e) {
217
+ E(e) && o();
218
+ }
210
219
  };
211
- return /* @__PURE__ */ k("li", {
220
+ return /* @__PURE__ */ N("li", {
212
221
  ref: W,
213
222
  "data-testid": `handoff-row-${t.id}`,
214
- "aria-current": i ? "true" : void 0,
215
- className: `grid gap-3 rounded-card border bg-bg-surface p-4 ${i ? "border-primary ring-2 ring-primary" : "border-border-seam"}`,
223
+ "aria-current": s ? "true" : void 0,
224
+ className: `grid gap-3 rounded-card border bg-bg-surface p-4 ${s ? "border-primary ring-2 ring-primary" : "border-border-seam"}`,
216
225
  children: [
217
- /* @__PURE__ */ k("div", {
226
+ /* @__PURE__ */ N("div", {
218
227
  className: "flex flex-wrap items-center gap-2",
219
228
  children: [
220
- /* @__PURE__ */ O(P, { status: t.status }),
221
- /* @__PURE__ */ O(N, { handoff: t }),
222
- /* @__PURE__ */ O(L, { handoff: t }),
223
- t.replyChannel ? /* @__PURE__ */ O(l, {
229
+ i ? /* @__PURE__ */ M(d, {
230
+ variant: "default",
231
+ children: c("botlit.handoffs.new", "New")
232
+ }) : null,
233
+ /* @__PURE__ */ M(ae, { status: t.status }),
234
+ /* @__PURE__ */ M(ie, { handoff: t }),
235
+ /* @__PURE__ */ M(oe, { handoff: t }),
236
+ t.replyChannel ? /* @__PURE__ */ M(d, {
224
237
  variant: "outline",
225
238
  children: t.replyChannel
226
239
  }) : null,
227
- /* @__PURE__ */ O("span", {
240
+ /* @__PURE__ */ M("span", {
228
241
  className: "text-xs text-text-secondary",
229
- children: a("botlit.handoffs.opened", "Opened {{time}}", { time: C(t.createdAt) })
242
+ children: c("botlit.handoffs.opened", "Opened {{time}}", { time: _(t.createdAt) })
230
243
  })
231
244
  ]
232
245
  }),
233
- /* @__PURE__ */ O("p", {
246
+ /* @__PURE__ */ M("p", {
234
247
  className: "text-sm text-text-primary",
235
248
  children: t.reason
236
249
  }),
237
- t.userMessage ? /* @__PURE__ */ O("blockquote", {
250
+ t.userMessage ? /* @__PURE__ */ M("blockquote", {
238
251
  className: "border-l-2 border-border-seam pl-3 text-sm text-text-secondary italic",
239
252
  children: t.userMessage
240
253
  }) : null,
241
- /* @__PURE__ */ k("div", {
254
+ /* @__PURE__ */ N("div", {
242
255
  className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
243
- children: [/* @__PURE__ */ O("span", { children: n.get(t.agentId) ? a("botlit.handoffs.agent", "Agent {{name}}", { name: n.get(t.agentId) }) : a("botlit.handoffs.conversation", "Conversation {{key}}", { key: t.conversationKey }) }), t.assignedToId ? /* @__PURE__ */ O("span", { children: a("botlit.handoffs.assignedTo", "· with {{who}}", { who: t.assignedToId }) }) : null]
256
+ children: [/* @__PURE__ */ M("span", { children: n.get(t.agentId) ? c("botlit.handoffs.agent", "Agent {{name}}", { name: n.get(t.agentId) }) : c("botlit.handoffs.conversation", "Conversation {{key}}", { key: t.conversationKey }) }), t.assignedToId ? /* @__PURE__ */ M("span", { children: c("botlit.handoffs.assignedTo", "· with {{who}}", { who: le(t.assignedToId) }) }) : null]
244
257
  }),
245
- /* @__PURE__ */ O("div", { children: /* @__PURE__ */ O(c, {
258
+ /* @__PURE__ */ M("div", { children: /* @__PURE__ */ M(u, {
246
259
  size: "sm",
247
260
  variant: "ghost",
248
261
  "aria-expanded": U,
249
262
  onClick: () => H({
250
- linked: i,
263
+ linked: s,
251
264
  open: !U
252
265
  }),
253
- children: U ? a("botlit.handoffs.thread.hide", "Hide conversation") : a("botlit.handoffs.thread.show", "Show conversation")
266
+ children: U ? c("botlit.handoffs.thread.hide", "Hide conversation") : c("botlit.handoffs.thread.show", "Show conversation")
254
267
  }) }),
255
- U ? G.loading && G.data.length === 0 ? /* @__PURE__ */ O("p", {
268
+ U ? G.loading && G.data.length === 0 ? /* @__PURE__ */ M("p", {
256
269
  role: "status",
257
270
  className: "text-sm text-text-secondary",
258
- children: a("botlit.handoffs.thread.loading", "Loading conversation…")
259
- }) : G.error ? /* @__PURE__ */ O("p", {
271
+ children: c("botlit.handoffs.thread.loading", "Loading conversation…")
272
+ }) : G.error ? /* @__PURE__ */ M("p", {
260
273
  role: "alert",
261
274
  className: "text-sm text-status-danger-text",
262
275
  children: G.error.message
263
- }) : /* @__PURE__ */ O(re, {
276
+ }) : /* @__PURE__ */ M(se, {
264
277
  handoffId: t.id,
265
278
  messages: G.data
266
279
  }) : null,
267
- B && t.replyChannel ? /* @__PURE__ */ k("form", {
280
+ a && B && t.replyChannel ? /* @__PURE__ */ N("form", {
268
281
  className: "grid gap-2",
269
- onSubmit: (e) => void ie(e),
282
+ onSubmit: (e) => void ue(e),
270
283
  children: [
271
- /* @__PURE__ */ O("label", {
284
+ /* @__PURE__ */ M("label", {
272
285
  className: "text-sm font-medium text-text-primary",
273
286
  htmlFor: `reply-${t.id}`,
274
- children: a("botlit.handoffs.reply.label", "Reply to the customer")
287
+ children: c("botlit.handoffs.reply.label", "Reply to the customer")
275
288
  }),
276
- /* @__PURE__ */ O(p, {
289
+ /* @__PURE__ */ M(m, {
277
290
  id: `reply-${t.id}`,
278
291
  value: q,
279
292
  maxLength: 4e3,
280
293
  rows: 3,
281
294
  onChange: (e) => J(e.target.value),
282
- placeholder: a("botlit.handoffs.reply.placeholder", "Sent in the same thread as the bot — the bot stays quiet until you hand back.")
295
+ placeholder: c("botlit.handoffs.reply.placeholder", "Sent in the same thread as the bot — the bot stays quiet until you hand back.")
283
296
  }),
284
- /* @__PURE__ */ O("div", { children: /* @__PURE__ */ O(c, {
297
+ /* @__PURE__ */ M("div", { children: /* @__PURE__ */ M(u, {
285
298
  size: "sm",
286
299
  type: "submit",
287
300
  disabled: Z || !q.trim(),
288
- children: a("botlit.handoffs.reply.send", "Send reply")
301
+ children: c("botlit.handoffs.reply.send", "Send reply")
289
302
  }) })
290
303
  ]
291
304
  }) : null,
292
- B && !t.replyChannel ? /* @__PURE__ */ O("p", {
305
+ B && !t.replyChannel ? /* @__PURE__ */ M("p", {
293
306
  className: "text-sm text-text-secondary",
294
- children: a("botlit.handoffs.reply.webChat", "This conversation came from web chat, which has no channel to reply on.")
307
+ children: c("botlit.handoffs.reply.webChat", "This conversation came from web chat, which has no channel to reply on.")
295
308
  }) : null,
296
- z ? /* @__PURE__ */ k("form", {
309
+ a && z ? /* @__PURE__ */ N("form", {
297
310
  className: "flex flex-wrap items-center gap-2",
298
- onSubmit: (e) => void ae(e),
311
+ onSubmit: (e) => void de(e),
299
312
  children: [
300
- /* @__PURE__ */ O("label", {
313
+ /* @__PURE__ */ M("label", {
301
314
  className: "sr-only",
302
315
  htmlFor: `assign-${t.id}`,
303
- children: a("botlit.handoffs.assign.label", "Assign to (user id)")
316
+ children: c("botlit.handoffs.assign.label", "Assign to a teammate")
304
317
  }),
305
- /* @__PURE__ */ O(f, {
318
+ /* @__PURE__ */ N("select", {
306
319
  id: `assign-${t.id}`,
307
- className: "max-w-xs",
320
+ className: "h-9 max-w-xs rounded-md border border-border-default bg-bg-surface px-3 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
308
321
  value: Y,
309
322
  onChange: (e) => X(e.target.value),
310
- placeholder: a("botlit.handoffs.assign.placeholder", "Teammate user id")
323
+ children: [/* @__PURE__ */ M("option", {
324
+ value: "",
325
+ children: c("botlit.handoffs.assign.placeholder", "Choose a teammate")
326
+ }), r.filter((e) => e.userId !== t.assignedToId).map((e) => /* @__PURE__ */ M("option", {
327
+ value: e.userId,
328
+ children: e.email ? `${e.displayName} (${e.email})` : e.displayName
329
+ }, e.userId))]
311
330
  }),
312
- /* @__PURE__ */ O(c, {
331
+ /* @__PURE__ */ M(u, {
313
332
  size: "sm",
314
333
  variant: "outline",
315
334
  type: "submit",
316
335
  disabled: Z || !Y.trim(),
317
- children: a("botlit.handoffs.assign.submit", "Assign")
336
+ children: c("botlit.handoffs.assign.submit", "Assign")
318
337
  })
319
338
  ]
320
339
  }) : null,
321
- Q ? /* @__PURE__ */ O("p", {
340
+ Q ? /* @__PURE__ */ M("div", {
322
341
  role: "alert",
323
- className: "text-sm text-status-danger-text",
324
- children: Q.message
342
+ className: "flex flex-wrap items-center gap-2 text-sm text-status-danger-text",
343
+ children: /* @__PURE__ */ M("span", { children: ce ? c("botlit.handoffs.conflict", "A teammate changed this handoff first (for example, took it over). The inbox has been refreshed.") : Q.message })
325
344
  }) : null,
326
- /* @__PURE__ */ k("div", {
345
+ a ? /* @__PURE__ */ N("div", {
327
346
  className: "flex flex-wrap gap-2",
328
- children: [t.status === h.Requested || t.status === h.Assigned ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(c, {
347
+ children: [t.status === g.Requested || t.status === g.Assigned ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(u, {
329
348
  size: "sm",
330
349
  disabled: Z,
331
- onClick: () => void $(o),
332
- children: a("botlit.handoffs.actions.takeOver", "Take over")
333
- }), /* @__PURE__ */ O(c, {
350
+ onClick: () => void $(l),
351
+ children: c("botlit.handoffs.actions.takeOver", "Take over")
352
+ }), /* @__PURE__ */ M(u, {
334
353
  size: "sm",
335
354
  variant: "outline",
336
355
  disabled: Z,
337
- onClick: () => void $(T),
338
- children: a("botlit.handoffs.actions.reject", "Reject")
339
- })] }) : null, t.status === h.Accepted ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(c, {
356
+ onClick: () => void $(D),
357
+ children: c("botlit.handoffs.actions.reject", "Reject")
358
+ })] }) : null, t.status === g.Accepted ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(u, {
340
359
  size: "sm",
341
360
  variant: "outline",
342
361
  disabled: Z,
343
- onClick: () => void $(u),
344
- children: a("botlit.handoffs.actions.handBack", "Hand back to bot")
345
- }), /* @__PURE__ */ O(c, {
362
+ onClick: () => void $(p),
363
+ children: c("botlit.handoffs.actions.handBack", "Hand back to bot")
364
+ }), /* @__PURE__ */ M(u, {
346
365
  size: "sm",
347
366
  disabled: Z,
348
- onClick: () => void $(m),
349
- children: a("botlit.handoffs.actions.resolve", "Resolve")
367
+ onClick: () => void $(v),
368
+ children: c("botlit.handoffs.actions.resolve", "Resolve")
350
369
  })] }) : null]
351
- })
370
+ }) : null
352
371
  ]
353
372
  });
354
- }, B = ({ linkedId: t, filter: n, items: r }) => {
373
+ }, V = ({ linkedId: t, filter: n, items: r }) => {
355
374
  let i = e();
356
- return !t || !r || r.some((e) => e.id === t) ? null : /* @__PURE__ */ O("p", {
375
+ return !t || !r || r.some((e) => e.id === t) ? null : /* @__PURE__ */ M("p", {
357
376
  role: "status",
358
377
  className: "text-sm text-text-secondary",
359
378
  "data-testid": "handoff-link-missing",
360
379
  children: n === "all" ? i("botlit.handoffs.linkMissing", "The handoff from your notification could not be found. It may have been removed.") : i("botlit.handoffs.linkMissingFiltered", "The handoff from your notification is not in this list. Switch to All to see every status.")
361
380
  });
362
381
  };
363
- function V(e) {
364
- let [t, n] = E(null), r = e ? "all" : "active";
382
+ function H(e) {
383
+ let [t, n] = A(null), r = e ? "all" : "active";
365
384
  return [t && t.linkedId === e ? t.filter : r, (t) => n({
366
385
  linkedId: e,
367
386
  filter: t
368
387
  })];
369
388
  }
370
- var H = () => {
371
- let l = e(), [f] = A(), p = f.get("handoff")?.trim() || null, [m, h] = V(p), g = M.find((e) => e.id === m) ?? M[0], _ = y({ statuses: g.statuses ?? void 0 }), v = t(), b = T(() => new Map((v.data ?? []).map((e) => [e.id, e.name])), [v.data]);
372
- return /* @__PURE__ */ O(n, {
373
- title: l("botlit.handoffs.title", "Human Handoffs"),
374
- description: l("botlit.handoffs.description", "Conversations the runtime handed to your team. Taking one over stops the bot from replying until you hand it back."),
375
- children: /* @__PURE__ */ k("div", {
389
+ var U = () => {
390
+ let d = e(), m = i(r.AGENT_UPDATE), [h] = P(), g = h.get("handoff")?.trim() || null, [_, y] = H(g), b = I.find((e) => e.id === _) ?? I[0], x = v({ statuses: b.statuses ?? void 0 }), S = T(), C = t(), w = k(() => new Map((C.data ?? []).map((e) => [e.id, e.name])), [C.data]);
391
+ return /* @__PURE__ */ M(n, {
392
+ title: d("botlit.handoffs.title", "Human Handoffs"),
393
+ description: d("botlit.handoffs.description", "Conversations the runtime handed to your team. Taking one over stops the bot from replying until you hand it back."),
394
+ children: /* @__PURE__ */ N("div", {
376
395
  className: "mx-auto flex w-full max-w-4xl flex-col gap-4 p-4",
377
396
  children: [
378
- /* @__PURE__ */ k("div", {
397
+ /* @__PURE__ */ N("div", {
379
398
  className: "flex flex-wrap items-center gap-2",
380
- children: [M.map((e) => /* @__PURE__ */ O(c, {
381
- size: "sm",
382
- variant: m === e.id ? "primary" : "outline",
383
- onClick: () => h(e.id),
384
- children: l(e.labelKey, e.label)
385
- }, e.id)), /* @__PURE__ */ O(c, {
386
- size: "sm",
387
- variant: "outline",
388
- onClick: () => void _.refetch(),
389
- children: l("botlit.handoffs.refresh", "Refresh")
390
- })]
399
+ children: [
400
+ I.map((e) => /* @__PURE__ */ M(u, {
401
+ size: "sm",
402
+ variant: _ === e.id ? "primary" : "outline",
403
+ onClick: () => y(e.id),
404
+ children: d(e.labelKey, e.label)
405
+ }, e.id)),
406
+ /* @__PURE__ */ M(u, {
407
+ size: "sm",
408
+ variant: "outline",
409
+ isLoading: x.refreshing,
410
+ onClick: () => void x.refresh(),
411
+ children: d("botlit.handoffs.refresh", "Refresh")
412
+ }),
413
+ /* @__PURE__ */ M("span", {
414
+ className: "text-xs text-text-secondary",
415
+ children: d("botlit.handoffs.autoRefresh", "Updates automatically while this page is open.")
416
+ })
417
+ ]
391
418
  }),
392
- /* @__PURE__ */ O(B, {
393
- linkedId: p,
394
- filter: m,
395
- items: _.loading || _.error ? null : _.data?.items ?? null
419
+ /* @__PURE__ */ M(V, {
420
+ linkedId: g,
421
+ filter: _,
422
+ items: x.loading || x.error ? null : x.items
396
423
  }),
397
- _.loading ? /* @__PURE__ */ O("p", {
424
+ /* @__PURE__ */ M("div", {
425
+ "aria-live": "polite",
426
+ children: x.newIds.size > 0 ? /* @__PURE__ */ N("div", {
427
+ className: "flex flex-wrap items-center gap-2 rounded-card border border-status-info-border bg-status-info-bg-subtle p-3 text-sm text-text-primary",
428
+ children: [/* @__PURE__ */ M("span", { children: d("botlit.handoffs.newArrived", "{{count}} new handoff(s) arrived.", { count: x.newIds.size }) }), /* @__PURE__ */ M(u, {
429
+ size: "sm",
430
+ variant: "ghost",
431
+ onClick: x.acknowledgeNew,
432
+ children: d("botlit.handoffs.markSeen", "Mark as seen")
433
+ })]
434
+ }) : null
435
+ }),
436
+ x.loading && x.items.length === 0 ? /* @__PURE__ */ M("p", {
398
437
  role: "status",
399
- children: l("botlit.handoffs.loading", "Loading handoffs…")
400
- }) : _.error ? /* @__PURE__ */ O(d, {
401
- resource: l("botlit.handoffs.errorResource", "handoffs"),
402
- error: _.error,
403
- onRetry: () => void _.refetch()
404
- }) : _.data && _.data.items.length > 0 ? /* @__PURE__ */ k(r, { children: [/* @__PURE__ */ k(o, { children: [/* @__PURE__ */ O(s, { children: l("botlit.handoffs.queue", "Team inbox") }), /* @__PURE__ */ O(a, { children: l("botlit.handoffs.queueDescription", "Newest first — accept a conversation to take it over.") })] }), /* @__PURE__ */ O(i, { children: /* @__PURE__ */ O("ul", {
438
+ children: d("botlit.handoffs.loading", "Loading handoffs…")
439
+ }) : x.error && x.items.length === 0 ? /* @__PURE__ */ M(p, {
440
+ resource: d("botlit.handoffs.errorResource", "handoffs"),
441
+ error: x.error,
442
+ onRetry: () => void x.refresh()
443
+ }) : x.items.length > 0 ? /* @__PURE__ */ N(a, { children: [/* @__PURE__ */ N(c, { children: [/* @__PURE__ */ M(l, { children: d("botlit.handoffs.queue", "Team inbox") }), /* @__PURE__ */ M(s, { children: d("botlit.handoffs.queueDescription", "Newest first — accept a conversation to take it over.") })] }), /* @__PURE__ */ N(o, { children: [x.error ? /* @__PURE__ */ M("p", {
444
+ role: "alert",
445
+ className: "mb-3 text-sm text-status-danger-text",
446
+ children: d("botlit.handoffs.refreshFailed", "Could not refresh the inbox: {{message}}", { message: x.error.message })
447
+ }) : null, /* @__PURE__ */ M("ul", {
405
448
  className: "grid gap-3",
406
- children: _.data.items.map((e) => /* @__PURE__ */ O(z, {
449
+ children: x.items.map((e) => /* @__PURE__ */ M(B, {
407
450
  handoff: e,
408
- agents: b,
409
- onChanged: () => void _.refetch(),
410
- linked: e.id === p
451
+ agents: w,
452
+ members: S.members,
453
+ isNew: x.newIds.has(e.id),
454
+ canManage: m,
455
+ onChanged: () => void x.refresh(),
456
+ linked: e.id === g
411
457
  }, e.id))
412
- }) })] }) : /* @__PURE__ */ O(u, {
413
- title: l("botlit.handoffs.empty", "No handoffs"),
414
- description: l("botlit.handoffs.emptyDescription", "Nothing needs a human right now. Triggered handoffs from your agents land here.")
458
+ })] })] }) : /* @__PURE__ */ M(f, {
459
+ title: d("botlit.handoffs.empty", "No handoffs"),
460
+ description: d("botlit.handoffs.emptyDescription", "Nothing needs a human right now. Triggered handoffs from your agents land here.")
415
461
  }),
416
- _.data && _.data.hasMore ? /* @__PURE__ */ O("p", {
417
- className: "text-sm text-text-secondary",
418
- children: l("botlit.handoffs.truncated", "Showing the {{shown}} most recent of {{total}} handoffs — narrow the filter to see the rest.", {
419
- shown: _.data.items.length,
420
- total: _.data.total
421
- })
422
- }) : null
462
+ /* @__PURE__ */ M(D, {
463
+ hasMore: x.hasMore,
464
+ loadingMore: x.loadingMore,
465
+ onLoadMore: () => void x.loadMore(),
466
+ loadedCount: x.items.length
467
+ })
423
468
  ]
424
469
  })
425
470
  });
426
471
  };
427
- export { j as HANDOFF_QUERY_PARAM, H as HandoffsPage };
472
+ export { F as HANDOFF_QUERY_PARAM, U as HandoffsPage };
428
473
 
429
474
  //# sourceMappingURL=HandoffsPage.js.map