@poolse/react-ui 3.8.0 → 3.9.0

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.
package/dist/index.cjs CHANGED
@@ -1481,7 +1481,7 @@ function CallControlButton({
1481
1481
  label,
1482
1482
  onClick,
1483
1483
  active = false,
1484
- highlight = false,
1484
+ highlight: highlight2 = false,
1485
1485
  tone = "neutral",
1486
1486
  large = false,
1487
1487
  disabled = false,
@@ -1492,7 +1492,7 @@ function CallControlButton({
1492
1492
  "callbtn",
1493
1493
  tone !== "neutral" ? `callbtn--${tone}` : "",
1494
1494
  active ? "callbtn--active" : "",
1495
- highlight ? "callbtn--highlight" : "",
1495
+ highlight2 ? "callbtn--highlight" : "",
1496
1496
  large ? "callbtn--large" : ""
1497
1497
  ].filter(Boolean).join(" ");
1498
1498
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callbtn__slot", children: [
@@ -1508,7 +1508,7 @@ function CallControlButton({
1508
1508
  className: classes,
1509
1509
  onClick,
1510
1510
  disabled,
1511
- "aria-pressed": tone === "neutral" ? active || highlight : void 0,
1511
+ "aria-pressed": tone === "neutral" ? active || highlight2 : void 0,
1512
1512
  "aria-label": label,
1513
1513
  title: label,
1514
1514
  children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: large ? 26 : 22, label: null })
@@ -3158,6 +3158,189 @@ function formatTime(iso) {
3158
3158
  if (Number.isNaN(d.getTime())) return "";
3159
3159
  return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
3160
3160
  }
3161
+ function RecordingBanner({
3162
+ recording,
3163
+ transcribing = false,
3164
+ mode,
3165
+ consentRequired = false,
3166
+ myConsent,
3167
+ onStop,
3168
+ onChangeConsent,
3169
+ pending = false,
3170
+ className
3171
+ }) {
3172
+ const label = react$1.captureLabel(recording, transcribing, mode);
3173
+ if (!label) return null;
3174
+ const listenOnly = consentRequired && myConsent === "declined";
3175
+ const meta = listenOnly ? "You declined \u2014 you are listen-only" : consentRequired ? "Only people who agreed are captured" : "Everyone in the call is told";
3176
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3177
+ "div",
3178
+ {
3179
+ className: ["poolse-rec-banner", className].filter(Boolean).join(" "),
3180
+ role: "status",
3181
+ "aria-label": `${label}. ${meta}`,
3182
+ children: [
3183
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
3184
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-rec-banner__text", children: [
3185
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-rec-banner__title", children: label }),
3186
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-rec-banner__meta", children: meta })
3187
+ ] }),
3188
+ listenOnly && onChangeConsent && /* @__PURE__ */ jsxRuntime.jsx(
3189
+ "button",
3190
+ {
3191
+ type: "button",
3192
+ className: "poolse-rec-banner__btn",
3193
+ onClick: onChangeConsent,
3194
+ disabled: pending,
3195
+ children: "Change"
3196
+ }
3197
+ ),
3198
+ recording && onStop && /* @__PURE__ */ jsxRuntime.jsx(
3199
+ "button",
3200
+ {
3201
+ type: "button",
3202
+ className: "poolse-rec-banner__btn",
3203
+ onClick: onStop,
3204
+ disabled: pending,
3205
+ children: "Stop"
3206
+ }
3207
+ )
3208
+ ]
3209
+ }
3210
+ );
3211
+ }
3212
+ function RecordingIndicator({
3213
+ recording,
3214
+ transcribing = false,
3215
+ mode,
3216
+ className
3217
+ }) {
3218
+ const label = react$1.captureLabel(recording, transcribing, mode);
3219
+ if (!label) return null;
3220
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3221
+ "span",
3222
+ {
3223
+ className: ["poolse-rec-indicator", className].filter(Boolean).join(" "),
3224
+ role: "img",
3225
+ "aria-label": label,
3226
+ title: label,
3227
+ children: [
3228
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
3229
+ recording ? "REC" : "Transcript"
3230
+ ]
3231
+ }
3232
+ );
3233
+ }
3234
+ function ConsentPrompt({
3235
+ recording,
3236
+ transcribing = false,
3237
+ mode,
3238
+ startedByName,
3239
+ onAnswer,
3240
+ onAccepted,
3241
+ onDeclined,
3242
+ pending = false,
3243
+ error,
3244
+ overlay = true,
3245
+ className
3246
+ }) {
3247
+ const [busy, setBusy] = react.useState(false);
3248
+ const [failed, setFailed] = react.useState(false);
3249
+ const agree = react.useRef(null);
3250
+ const id = react.useId();
3251
+ react.useEffect(() => agree.current?.focus(), []);
3252
+ const what = recording && transcribing ? "recorded and transcribed" : recording ? mode === "audio" ? "recorded (audio)" : "recorded" : "transcribed";
3253
+ const answer = async (decision) => {
3254
+ setBusy(true);
3255
+ setFailed(false);
3256
+ try {
3257
+ const ok = await onAnswer(decision);
3258
+ if (ok === false) {
3259
+ setFailed(true);
3260
+ return;
3261
+ }
3262
+ if (decision === "accepted") onAccepted?.();
3263
+ else onDeclined?.();
3264
+ } catch {
3265
+ setFailed(true);
3266
+ } finally {
3267
+ setBusy(false);
3268
+ }
3269
+ };
3270
+ const disabled = busy || pending;
3271
+ const shownError = error ?? (failed ? "That didn\u2019t go through. Try again." : null);
3272
+ const card = /* @__PURE__ */ jsxRuntime.jsxs(
3273
+ "div",
3274
+ {
3275
+ className: ["poolse-consent", className].filter(Boolean).join(" "),
3276
+ role: "alertdialog",
3277
+ "aria-modal": overlay ? true : void 0,
3278
+ "aria-labelledby": `${id}-title`,
3279
+ "aria-describedby": `${id}-body`,
3280
+ children: [
3281
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-consent__head", children: [
3282
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
3283
+ /* @__PURE__ */ jsxRuntime.jsxs("h2", { id: `${id}-title`, className: "poolse-consent__title", children: [
3284
+ "This call is being ",
3285
+ what
3286
+ ] })
3287
+ ] }),
3288
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { id: `${id}-body`, className: "poolse-consent__body", children: [
3289
+ startedByName ? `${startedByName} started it. ` : "",
3290
+ "Your microphone and camera stay off until you agree. You can still hear and see everyone."
3291
+ ] }),
3292
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-consent__actions", children: [
3293
+ /* @__PURE__ */ jsxRuntime.jsx(
3294
+ "button",
3295
+ {
3296
+ type: "button",
3297
+ className: "poolse-consent__btn",
3298
+ onClick: () => void answer("declined"),
3299
+ disabled,
3300
+ children: "Stay listen-only"
3301
+ }
3302
+ ),
3303
+ /* @__PURE__ */ jsxRuntime.jsx(
3304
+ "button",
3305
+ {
3306
+ ref: agree,
3307
+ type: "button",
3308
+ className: "poolse-consent__btn poolse-consent__btn--primary",
3309
+ onClick: () => void answer("accepted"),
3310
+ disabled,
3311
+ children: "Agree"
3312
+ }
3313
+ )
3314
+ ] }),
3315
+ shownError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-consent__error", role: "alert", children: shownError })
3316
+ ]
3317
+ }
3318
+ );
3319
+ return overlay ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-consent-scrim", children: card }) : card;
3320
+ }
3321
+ function RecordingNoticeRow({ msg, meId, nameFor }) {
3322
+ const display = react$1.recordingNoticeDisplayFor(msg, meId, nameFor);
3323
+ if (!display) return null;
3324
+ const time = formatTime2(msg.inserted_at);
3325
+ const label = [display.title, display.detail, time].filter(Boolean).join(", ");
3326
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-call-log poolse-rec-notice", role: "note", "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-call-log__chip", children: [
3327
+ /* @__PURE__ */ jsxRuntime.jsx(
3328
+ "span",
3329
+ {
3330
+ className: `poolse-rec-dot${display.event === "stopped" ? " poolse-rec-dot--off" : ""}`,
3331
+ "aria-hidden": "true"
3332
+ }
3333
+ ),
3334
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__title", children: display.title }),
3335
+ display.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
3336
+ time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__time", children: time })
3337
+ ] }) });
3338
+ }
3339
+ function formatTime2(iso) {
3340
+ const d = new Date(iso);
3341
+ if (Number.isNaN(d.getTime())) return "";
3342
+ return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
3343
+ }
3161
3344
  function AttachmentPreview({ attachment, onClick }) {
3162
3345
  const isFullRow = "content_type" in attachment;
3163
3346
  const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
@@ -4581,6 +4764,16 @@ function FlatBody({
4581
4764
  );
4582
4765
  }
4583
4766
  function MessageRow(props) {
4767
+ if (react$1.recordingNoticeDisplayFor(props.msg, props.meId)) {
4768
+ return /* @__PURE__ */ jsxRuntime.jsx(
4769
+ RecordingNoticeRow,
4770
+ {
4771
+ msg: props.msg,
4772
+ meId: props.meId,
4773
+ ...props.nameForUserId ? { nameFor: props.nameForUserId } : {}
4774
+ }
4775
+ );
4776
+ }
4584
4777
  const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
4585
4778
  if (callLog !== void 0) {
4586
4779
  return callLog ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -5152,6 +5345,14 @@ function ConversationView({
5152
5345
  const membersOn = mentions || readReceipts || wantsMemberCount;
5153
5346
  const { members, loading: membersLoading } = react$1.useMembers(membersOn ? conversationId : "");
5154
5347
  const chat = react$1.usePoolse();
5348
+ const nameForUserId = react.useCallback(
5349
+ (userId) => {
5350
+ const ext = members.find((m) => m.user_id === userId)?.external_id;
5351
+ if (!ext) return null;
5352
+ return chat.users.peek(ext)?.displayName ?? labelFor?.(ext) ?? null;
5353
+ },
5354
+ [members, chat, labelFor]
5355
+ );
5155
5356
  const isGroupChat = members.length > 2;
5156
5357
  const showSenderLabelsResolved = senderLabels === "always" || senderLabels === "auto" && isGroupChat;
5157
5358
  const showAvatarsResolved = showAvatars ?? (layout === "list" ? true : layout === "compact" ? false : avatars === "always" || avatars === "auto" && isGroupChat);
@@ -5821,6 +6022,7 @@ function ConversationView({
5821
6022
  onDiscardSend: () => discardSend(msg.id)
5822
6023
  } : {},
5823
6024
  ...onCallBack ? { onCallBack } : {},
6025
+ nameForUserId,
5824
6026
  ...layoutProps,
5825
6027
  mentionsMe: mentionsViewer(msg, me?.id ?? null)
5826
6028
  }
@@ -6220,7 +6422,7 @@ function DefaultRow({
6220
6422
  const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? other?.avatarUrl ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
6221
6423
  const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
6222
6424
  const hasUnread = unread > 0;
6223
- const preview = react$1.formatCallLogPreview(conv.last_message_preview, meId) ?? conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
6425
+ const preview = react$1.formatCallLogPreview(conv.last_message_preview, meId) ?? react$1.formatRecordingNoticePreview(conv.last_message_preview, meId) ?? conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
6224
6426
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6225
6427
  /* @__PURE__ */ jsxRuntime.jsx(
6226
6428
  Avatar,
@@ -6786,8 +6988,24 @@ function RoomJoinBar({ room, allowStart = true }) {
6786
6988
  ] })
6787
6989
  ] });
6788
6990
  }
6789
- function RoomStage({ room, title, labelFor, className }) {
6991
+ function RoomStage({
6992
+ room,
6993
+ title,
6994
+ labelFor,
6995
+ className,
6996
+ capture = true,
6997
+ allowRecord = false
6998
+ }) {
6790
6999
  const media = room.media;
7000
+ const live = room.live;
7001
+ const rec = react$1.useRecording(
7002
+ capture || allowRecord ? live?.id ?? null : null,
7003
+ live?.conversation_id ?? null,
7004
+ live
7005
+ );
7006
+ const [consentDismissed, setConsentDismissed] = react.useState(false);
7007
+ const transcribing = !!rec.transcription?.active;
7008
+ const starter = rec.recording?.started_by_user_id;
6791
7009
  const stage = react.useRef(null);
6792
7010
  const fullscreen = useFullscreen(stage);
6793
7011
  const [menu, setMenu] = react.useState(null);
@@ -6816,6 +7034,15 @@ function RoomStage({ room, title, labelFor, className }) {
6816
7034
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-room__dot", "aria-hidden": "true" }),
6817
7035
  elapsed
6818
7036
  ] }),
7037
+ capture && /* @__PURE__ */ jsxRuntime.jsx(
7038
+ RecordingIndicator,
7039
+ {
7040
+ recording: rec.active,
7041
+ transcribing,
7042
+ mode: rec.recording?.mode ?? null,
7043
+ className: "poolse-room__chip"
7044
+ }
7045
+ ),
6819
7046
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-room__chip", "aria-label": `${count} in the room`, children: [
6820
7047
  /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "users", size: 14, label: null }),
6821
7048
  count
@@ -6840,6 +7067,19 @@ function RoomStage({ room, title, labelFor, className }) {
6840
7067
  }
6841
7068
  )
6842
7069
  ] }),
7070
+ capture && /* @__PURE__ */ jsxRuntime.jsx(
7071
+ RecordingBanner,
7072
+ {
7073
+ className: "poolse-room__rec",
7074
+ recording: rec.active,
7075
+ transcribing,
7076
+ mode: rec.recording?.mode ?? null,
7077
+ consentRequired: rec.consentRequired,
7078
+ myConsent: rec.myConsent,
7079
+ onChangeConsent: () => setConsentDismissed(false),
7080
+ pending: rec.pending
7081
+ }
7082
+ ),
6843
7083
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-room__stage", children: count > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
6844
7084
  CallVideoGrid,
6845
7085
  {
@@ -6854,6 +7094,20 @@ function RoomStage({ room, title, labelFor, className }) {
6854
7094
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => void media.setScreenShareEnabled(false), children: "Stop sharing" })
6855
7095
  ] }),
6856
7096
  room.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-room__error", children: room.error.message }),
7097
+ rec.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-room__error", children: react$1.captureErrorMessage(rec.error) }),
7098
+ capture && rec.needsConsent && !(consentDismissed && rec.myConsent === "declined") && /* @__PURE__ */ jsxRuntime.jsx(
7099
+ ConsentPrompt,
7100
+ {
7101
+ recording: rec.active,
7102
+ transcribing,
7103
+ mode: rec.recording?.mode ?? null,
7104
+ startedByName: starter ? labelFor?.(starter) ?? null : null,
7105
+ onAnswer: rec.consent,
7106
+ onAccepted: () => void media.republish(),
7107
+ onDeclined: () => setConsentDismissed(true),
7108
+ pending: rec.pending
7109
+ }
7110
+ ),
6857
7111
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-room__bar", children: [
6858
7112
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callsheet__control", children: [
6859
7113
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -6931,6 +7185,16 @@ function RoomStage({ room, title, labelFor, className }) {
6931
7185
  }
6932
7186
  )
6933
7187
  ] }),
7188
+ allowRecord && rec.available && /* @__PURE__ */ jsxRuntime.jsx(
7189
+ CallControlButton,
7190
+ {
7191
+ icon: "presence",
7192
+ highlight: rec.active,
7193
+ label: rec.active ? "Stop recording" : "Record",
7194
+ onClick: () => void (rec.active ? rec.stop() : rec.start()),
7195
+ disabled: rec.pending || media.status !== "connected"
7196
+ }
7197
+ ),
6934
7198
  /* @__PURE__ */ jsxRuntime.jsx(
6935
7199
  CallControlButton,
6936
7200
  {
@@ -6962,6 +7226,324 @@ function useElapsed(startedAt, running) {
6962
7226
  const s = String(total % 60).padStart(2, "0");
6963
7227
  return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
6964
7228
  }
7229
+ function LiveTranscriptPanel({
7230
+ callId,
7231
+ enabled = true,
7232
+ showControls = true,
7233
+ onClose,
7234
+ title = "Live transcript",
7235
+ className
7236
+ }) {
7237
+ const live = react$1.useLiveTranscript(callId, { enabled });
7238
+ const blocks = react.useMemo(() => react$1.groupTranscript(live.segments), [live.segments]);
7239
+ const scroller = react.useRef(null);
7240
+ const pinned = react.useRef(true);
7241
+ react.useEffect(() => {
7242
+ const el = scroller.current;
7243
+ if (el && pinned.current) el.scrollTop = el.scrollHeight;
7244
+ }, [live.segments]);
7245
+ const error = live.error ? transcriptError(live.error) : null;
7246
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7247
+ "section",
7248
+ {
7249
+ className: ["poolse-transcript", "poolse-transcript--live", className].filter(Boolean).join(" "),
7250
+ "aria-label": title,
7251
+ children: [
7252
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-transcript__head", children: [
7253
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-transcript__title", children: [
7254
+ live.live && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
7255
+ title
7256
+ ] }),
7257
+ showControls && callId && /* @__PURE__ */ jsxRuntime.jsx(
7258
+ "button",
7259
+ {
7260
+ type: "button",
7261
+ className: "poolse-transcript__btn",
7262
+ onClick: () => void (live.live ? live.stop() : live.start()),
7263
+ disabled: live.pending,
7264
+ children: live.live ? "Stop" : live.transcript ? "Resume" : "Start"
7265
+ }
7266
+ ),
7267
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(
7268
+ "button",
7269
+ {
7270
+ type: "button",
7271
+ className: "poolse-transcript__icon-btn",
7272
+ onClick: onClose,
7273
+ "aria-label": "Close transcript",
7274
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 16, label: null })
7275
+ }
7276
+ )
7277
+ ] }),
7278
+ /* @__PURE__ */ jsxRuntime.jsx(
7279
+ "div",
7280
+ {
7281
+ ref: scroller,
7282
+ className: "poolse-transcript__body",
7283
+ role: "log",
7284
+ "aria-live": "polite",
7285
+ "aria-relevant": "additions",
7286
+ onScroll: (e) => {
7287
+ const el = e.currentTarget;
7288
+ pinned.current = el.scrollHeight - el.scrollTop - el.clientHeight < 24;
7289
+ },
7290
+ children: blocks.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__empty", children: error ?? (live.live ? "Listening\u2026" : live.joined ? "Transcription is off. Start it to see what is said." : "Opening the transcript\u2026") }) : blocks.map((b, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-transcript__block", children: [
7291
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-transcript__who", children: [
7292
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__name", children: b.name }),
7293
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__time", children: react$1.formatCallDuration(b.startMs) })
7294
+ ] }),
7295
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__text", children: b.segments.map((s, k) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: s.final ? void 0 : "poolse-transcript__interim", children: [
7296
+ k > 0 ? " " : "",
7297
+ s.text
7298
+ ] }, k)) })
7299
+ ] }, `${b.speaker}-${b.startMs}-${i}`))
7300
+ }
7301
+ ),
7302
+ error && blocks.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__error", role: "alert", children: error })
7303
+ ]
7304
+ }
7305
+ );
7306
+ }
7307
+ function TranscriptViewer({
7308
+ callId,
7309
+ canRename = true,
7310
+ onSeek,
7311
+ title = "Transcript",
7312
+ className
7313
+ }) {
7314
+ const { transcript, loading, missing, error, renameSpeakers } = react$1.useTranscript(callId);
7315
+ const [query, setQuery] = react.useState("");
7316
+ const [hit, setHit] = react.useState(0);
7317
+ const blocks = react.useMemo(() => react$1.groupTranscript(transcript?.segments ?? []), [transcript]);
7318
+ const hits = react.useMemo(() => {
7319
+ const out = [];
7320
+ if (!query.trim()) return out;
7321
+ blocks.forEach(
7322
+ (block, b) => block.segments.forEach((seg, s) => {
7323
+ for (const r of react$1.findInText(seg.text, query)) out.push({ b, s, r });
7324
+ })
7325
+ );
7326
+ return out;
7327
+ }, [blocks, query]);
7328
+ react.useEffect(() => setHit(0), [query]);
7329
+ const body = react.useRef(null);
7330
+ react.useEffect(() => {
7331
+ body.current?.querySelector(".poolse-transcript__hit--current")?.scrollIntoView({ block: "center" });
7332
+ }, [hit, hits]);
7333
+ const step = (d) => setHit((h) => hits.length ? (h + d + hits.length) % hits.length : 0);
7334
+ if (!callId) return null;
7335
+ const meta = transcript ? [
7336
+ transcript.started_at ? formatDate(transcript.started_at) : null,
7337
+ duration(transcript),
7338
+ transcript.speakers.length === 1 ? "1 speaker" : `${transcript.speakers.length} speakers`
7339
+ ].filter(Boolean).join(" \xB7 ") : null;
7340
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7341
+ "section",
7342
+ {
7343
+ className: ["poolse-transcript", "poolse-transcript--viewer", className].filter(Boolean).join(" "),
7344
+ "aria-label": title,
7345
+ children: [
7346
+ /* @__PURE__ */ jsxRuntime.jsx("header", { className: "poolse-transcript__head", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-transcript__heading", children: [
7347
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__title", children: title }),
7348
+ meta && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__meta", children: meta })
7349
+ ] }) }),
7350
+ transcript && transcript.segments.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-transcript__search", role: "search", children: [
7351
+ /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "search", size: 15, label: null }),
7352
+ /* @__PURE__ */ jsxRuntime.jsx(
7353
+ "input",
7354
+ {
7355
+ type: "search",
7356
+ value: query,
7357
+ onChange: (e) => setQuery(e.target.value),
7358
+ onKeyDown: (e) => {
7359
+ if (e.key === "Enter") {
7360
+ e.preventDefault();
7361
+ step(e.shiftKey ? -1 : 1);
7362
+ }
7363
+ },
7364
+ placeholder: "Search the transcript",
7365
+ "aria-label": "Search the transcript"
7366
+ }
7367
+ ),
7368
+ query.trim() && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7369
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__count", "aria-live": "polite", children: hits.length ? `${hit + 1} of ${hits.length}` : "No matches" }),
7370
+ /* @__PURE__ */ jsxRuntime.jsx(
7371
+ "button",
7372
+ {
7373
+ type: "button",
7374
+ className: "poolse-transcript__icon-btn",
7375
+ onClick: () => step(-1),
7376
+ disabled: !hits.length,
7377
+ "aria-label": "Previous match",
7378
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "chevron-up", size: 15, label: null })
7379
+ }
7380
+ ),
7381
+ /* @__PURE__ */ jsxRuntime.jsx(
7382
+ "button",
7383
+ {
7384
+ type: "button",
7385
+ className: "poolse-transcript__icon-btn",
7386
+ onClick: () => step(1),
7387
+ disabled: !hits.length,
7388
+ "aria-label": "Next match",
7389
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "chevron-down", size: 15, label: null })
7390
+ }
7391
+ )
7392
+ ] })
7393
+ ] }),
7394
+ transcript && transcript.speakers.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
7395
+ SpeakerList,
7396
+ {
7397
+ speakers: transcript.speakers,
7398
+ canRename,
7399
+ onRename: renameSpeakers
7400
+ }
7401
+ ),
7402
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: body, className: "poolse-transcript__body", children: loading && !transcript ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__empty", children: "Loading the transcript\u2026" }) : missing ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__empty", children: "This call has no transcript." }) : error && !transcript ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__empty", children: transcriptError(error) }) : transcript && transcript.segments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__empty", children: "Nothing was said in this call." }) : blocks.map((block, b) => /* @__PURE__ */ jsxRuntime.jsxs(
7403
+ "div",
7404
+ {
7405
+ className: "poolse-transcript__block",
7406
+ children: [
7407
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-transcript__who", children: [
7408
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__name", children: block.name }),
7409
+ onSeek ? /* @__PURE__ */ jsxRuntime.jsx(
7410
+ "button",
7411
+ {
7412
+ type: "button",
7413
+ className: "poolse-transcript__time poolse-transcript__time--link",
7414
+ onClick: () => onSeek(block.startMs),
7415
+ "aria-label": `Play from ${react$1.formatCallDuration(block.startMs)}`,
7416
+ children: react$1.formatCallDuration(block.startMs)
7417
+ }
7418
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__time", children: react$1.formatCallDuration(block.startMs) })
7419
+ ] }),
7420
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__text", children: block.segments.map((seg, s) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
7421
+ s > 0 ? " " : "",
7422
+ highlight(seg, hits, b, s, hit)
7423
+ ] }, s)) })
7424
+ ]
7425
+ },
7426
+ `${block.speaker}-${block.startMs}-${b}`
7427
+ )) })
7428
+ ]
7429
+ }
7430
+ );
7431
+ }
7432
+ function SpeakerList({
7433
+ speakers,
7434
+ canRename,
7435
+ onRename
7436
+ }) {
7437
+ const [editing, setEditing] = react.useState(null);
7438
+ const [draft, setDraft] = react.useState("");
7439
+ const [busy, setBusy] = react.useState(false);
7440
+ const [error, setError] = react.useState(null);
7441
+ const save = async (key, name) => {
7442
+ setBusy(true);
7443
+ setError(null);
7444
+ try {
7445
+ await onRename({ [key]: name });
7446
+ setEditing(null);
7447
+ } catch (err) {
7448
+ setError(
7449
+ err instanceof react$1.ApiError && err.status === 403 ? "Only people who were in the call can rename speakers." : err instanceof react$1.ApiError && err.code === "validation_failed" ? "Names can be up to 100 characters." : "The name could not be saved. Try again."
7450
+ );
7451
+ } finally {
7452
+ setBusy(false);
7453
+ }
7454
+ };
7455
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-transcript__speakers", children: [
7456
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": "Speakers", children: speakers.map((sp) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-transcript__speaker", children: editing === sp.key ? /* @__PURE__ */ jsxRuntime.jsxs(
7457
+ "form",
7458
+ {
7459
+ className: "poolse-transcript__rename",
7460
+ onSubmit: (e) => {
7461
+ e.preventDefault();
7462
+ const name = draft.trim();
7463
+ if (name) void save(sp.key, name);
7464
+ },
7465
+ children: [
7466
+ /* @__PURE__ */ jsxRuntime.jsx(
7467
+ "input",
7468
+ {
7469
+ value: draft,
7470
+ onChange: (e) => setDraft(e.target.value),
7471
+ maxLength: 100,
7472
+ "aria-label": "Speaker name",
7473
+ autoFocus: true,
7474
+ onKeyDown: (e) => {
7475
+ if (e.key === "Escape") setEditing(null);
7476
+ }
7477
+ }
7478
+ ),
7479
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: busy || !draft.trim(), children: "Save" }),
7480
+ sp.corrected && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", disabled: busy, onClick: () => void save(sp.key, null), children: "Use their own name" }),
7481
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", disabled: busy, onClick: () => setEditing(null), children: "Cancel" })
7482
+ ]
7483
+ }
7484
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7485
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-transcript__speaker-name", title: sp.name ?? void 0, children: sp.name?.trim() || "Speaker" }),
7486
+ canRename && /* @__PURE__ */ jsxRuntime.jsx(
7487
+ "button",
7488
+ {
7489
+ type: "button",
7490
+ className: "poolse-transcript__icon-btn",
7491
+ onClick: () => {
7492
+ setDraft(sp.name ?? "");
7493
+ setError(null);
7494
+ setEditing(sp.key);
7495
+ },
7496
+ "aria-label": `Rename ${sp.name?.trim() || "speaker"}`,
7497
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "edit", size: 13, label: null })
7498
+ }
7499
+ )
7500
+ ] }) }, sp.key)) }),
7501
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-transcript__error", role: "alert", children: error })
7502
+ ] });
7503
+ }
7504
+ function highlight(seg, hits, b, s, current) {
7505
+ const mine = hits.map((h, i) => ({ ...h, i })).filter((h) => h.b === b && h.s === s);
7506
+ if (!mine.length) return seg.text;
7507
+ const out = [];
7508
+ let at = 0;
7509
+ for (const h of mine) {
7510
+ if (h.r[0] > at) out.push(seg.text.slice(at, h.r[0]));
7511
+ out.push(
7512
+ /* @__PURE__ */ jsxRuntime.jsx(
7513
+ "mark",
7514
+ {
7515
+ className: `poolse-transcript__hit${h.i === current ? " poolse-transcript__hit--current" : ""}`,
7516
+ children: seg.text.slice(h.r[0], h.r[1])
7517
+ },
7518
+ h.i
7519
+ )
7520
+ );
7521
+ at = h.r[1];
7522
+ }
7523
+ if (at < seg.text.length) out.push(seg.text.slice(at));
7524
+ return out;
7525
+ }
7526
+ function duration(t) {
7527
+ if (!t.started_at || !t.ended_at) return null;
7528
+ const ms = Date.parse(t.ended_at) - Date.parse(t.started_at);
7529
+ return Number.isFinite(ms) && ms > 0 ? react$1.formatCallDuration(ms) : null;
7530
+ }
7531
+ function formatDate(iso) {
7532
+ const d = new Date(iso);
7533
+ if (Number.isNaN(d.getTime())) return null;
7534
+ return d.toLocaleString(void 0, {
7535
+ month: "short",
7536
+ day: "numeric",
7537
+ hour: "2-digit",
7538
+ minute: "2-digit"
7539
+ });
7540
+ }
7541
+ function transcriptError(err) {
7542
+ const code = err instanceof react$1.ApiError ? err.code : err.message;
7543
+ if (code === "forbidden") return "You can\u2019t open this transcript.";
7544
+ if (code === "not_found") return "There is no transcript for this call.";
7545
+ return react$1.captureErrorMessage(err instanceof react$1.ApiError ? err : { code });
7546
+ }
6965
7547
  var ThemeContext = react.createContext(null);
6966
7548
  var DARK_QUERY = "(prefers-color-scheme: dark)";
6967
7549
  function systemScheme() {
@@ -7156,6 +7738,7 @@ exports.CallDeviceMenu = CallDeviceMenu;
7156
7738
  exports.CallLogRow = CallLogRow;
7157
7739
  exports.CallVideoGrid = CallVideoGrid;
7158
7740
  exports.ChatHeader = ChatHeader;
7741
+ exports.ConsentPrompt = ConsentPrompt;
7159
7742
  exports.ConversationList = ConversationList;
7160
7743
  exports.ConversationView = ConversationView;
7161
7744
  exports.DEFAULT_KEYMAP = DEFAULT_KEYMAP;
@@ -7167,6 +7750,7 @@ exports.EmptyState = EmptyState;
7167
7750
  exports.GroupDetailsSheet = GroupDetailsSheet;
7168
7751
  exports.LinkPreviewCard = LinkPreviewCard;
7169
7752
  exports.LiveCallBanner = LiveCallBanner;
7753
+ exports.LiveTranscriptPanel = LiveTranscriptPanel;
7170
7754
  exports.MOD_ENTER_COMPOSER = MOD_ENTER_COMPOSER;
7171
7755
  exports.MemberList = MemberList;
7172
7756
  exports.MentionInput = MentionInput;
@@ -7181,11 +7765,15 @@ exports.PoolseTheme = PoolseTheme;
7181
7765
  exports.PresenceBadge = PresenceBadge;
7182
7766
  exports.ReactionPicker = ReactionPicker;
7183
7767
  exports.ReactionStrip = ReactionStrip;
7768
+ exports.RecordingBanner = RecordingBanner;
7769
+ exports.RecordingIndicator = RecordingIndicator;
7770
+ exports.RecordingNoticeRow = RecordingNoticeRow;
7184
7771
  exports.RoomJoinBar = RoomJoinBar;
7185
7772
  exports.RoomStage = RoomStage;
7186
7773
  exports.SendStatus = SendStatus;
7187
7774
  exports.ThreadSummary = ThreadSummary;
7188
7775
  exports.ThreadView = ThreadView;
7776
+ exports.TranscriptViewer = TranscriptViewer;
7189
7777
  exports.TypingIndicator = TypingIndicator;
7190
7778
  exports.UploadQueueStrip = UploadQueueStrip;
7191
7779
  exports.UserName = UserName;