@poolse/react-ui 3.7.1 → 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/CHANGELOG.md +43 -0
- package/README.md +72 -1
- package/dist/index.cjs +1085 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +325 -8
- package/dist/index.d.ts +325 -8
- package/dist/index.js +1072 -85
- package/dist/index.js.map +1 -1
- package/dist/styles.css +595 -0
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var sdk = require('@poolse/sdk');
|
|
6
7
|
var react$1 = require('@poolse/react');
|
|
7
8
|
var ReactMarkdown = require('react-markdown');
|
|
8
9
|
var remarkGfm = require('remark-gfm');
|
|
@@ -1480,7 +1481,7 @@ function CallControlButton({
|
|
|
1480
1481
|
label,
|
|
1481
1482
|
onClick,
|
|
1482
1483
|
active = false,
|
|
1483
|
-
highlight = false,
|
|
1484
|
+
highlight: highlight2 = false,
|
|
1484
1485
|
tone = "neutral",
|
|
1485
1486
|
large = false,
|
|
1486
1487
|
disabled = false,
|
|
@@ -1491,7 +1492,7 @@ function CallControlButton({
|
|
|
1491
1492
|
"callbtn",
|
|
1492
1493
|
tone !== "neutral" ? `callbtn--${tone}` : "",
|
|
1493
1494
|
active ? "callbtn--active" : "",
|
|
1494
|
-
|
|
1495
|
+
highlight2 ? "callbtn--highlight" : "",
|
|
1495
1496
|
large ? "callbtn--large" : ""
|
|
1496
1497
|
].filter(Boolean).join(" ");
|
|
1497
1498
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callbtn__slot", children: [
|
|
@@ -1507,7 +1508,7 @@ function CallControlButton({
|
|
|
1507
1508
|
className: classes,
|
|
1508
1509
|
onClick,
|
|
1509
1510
|
disabled,
|
|
1510
|
-
"aria-pressed": tone === "neutral" ? active ||
|
|
1511
|
+
"aria-pressed": tone === "neutral" ? active || highlight2 : void 0,
|
|
1511
1512
|
"aria-label": label,
|
|
1512
1513
|
title: label,
|
|
1513
1514
|
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: large ? 26 : 22, label: null })
|
|
@@ -1645,47 +1646,133 @@ var localDraftStorage = {
|
|
|
1645
1646
|
}
|
|
1646
1647
|
}
|
|
1647
1648
|
};
|
|
1648
|
-
var memory = /* @__PURE__ */ new Map();
|
|
1649
1649
|
function draftKey(userId, conversationId) {
|
|
1650
1650
|
return `poolse:draft:${userId}:${conversationId}`;
|
|
1651
1651
|
}
|
|
1652
1652
|
var isEmpty = (d) => d.text.trim() === "" && !d.replyTo;
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
let raw;
|
|
1657
|
-
try {
|
|
1658
|
-
raw = storage.get(key);
|
|
1659
|
-
} catch {
|
|
1660
|
-
return null;
|
|
1653
|
+
var DraftScope = class {
|
|
1654
|
+
constructor(namespace) {
|
|
1655
|
+
this.namespace = namespace;
|
|
1661
1656
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1657
|
+
namespace;
|
|
1658
|
+
memory = /* @__PURE__ */ new Map();
|
|
1659
|
+
/** Storages written to, and the keys written to each. */
|
|
1660
|
+
written = /* @__PURE__ */ new Map();
|
|
1661
|
+
/** The storage key for a conversation's draft; null until the namespace is known. */
|
|
1662
|
+
key(conversationId) {
|
|
1663
|
+
const ns = this.namespace();
|
|
1664
|
+
return ns ? `${ns}:draft:${conversationId}` : null;
|
|
1665
|
+
}
|
|
1666
|
+
/** The draft for `key`: from memory, else from `storage` (else from `legacyKey`, moved over). */
|
|
1667
|
+
read(storage, key, legacyKey) {
|
|
1668
|
+
const held = this.memory.get(key);
|
|
1669
|
+
if (held) return held;
|
|
1670
|
+
const hold = (d) => {
|
|
1671
|
+
if (d && !this.memory.has(key)) this.memory.set(key, d);
|
|
1672
|
+
return this.memory.get(key) ?? d;
|
|
1673
|
+
};
|
|
1674
|
+
const fromLegacy = () => {
|
|
1675
|
+
if (!legacyKey) return null;
|
|
1676
|
+
const old = safeGet(storage, legacyKey);
|
|
1677
|
+
const move = (raw2) => {
|
|
1678
|
+
const d = parse(raw2);
|
|
1679
|
+
if (!d) return null;
|
|
1680
|
+
this.write(storage, key, d);
|
|
1681
|
+
swallow(() => storage.remove(legacyKey));
|
|
1682
|
+
return hold(d);
|
|
1683
|
+
};
|
|
1684
|
+
return old instanceof Promise ? old.then(move, () => null) : move(old);
|
|
1685
|
+
};
|
|
1686
|
+
const raw = safeGet(storage, key);
|
|
1687
|
+
const take = (r) => {
|
|
1688
|
+
const d = parse(r);
|
|
1689
|
+
return d ? hold(d) : fromLegacy();
|
|
1690
|
+
};
|
|
1691
|
+
return raw instanceof Promise ? raw.then(take, () => null) : take(raw);
|
|
1692
|
+
}
|
|
1693
|
+
/** Save (or, when empty, drop) the draft for `key`. */
|
|
1694
|
+
write(storage, key, draft) {
|
|
1695
|
+
if (isEmpty(draft)) {
|
|
1696
|
+
this.clear(storage, key);
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
this.memory.set(key, draft);
|
|
1700
|
+
this.track(storage, key);
|
|
1701
|
+
const value = JSON.stringify({ v: 1, text: draft.text, replyTo: draft.replyTo });
|
|
1702
|
+
swallow(() => storage.set(key, value));
|
|
1703
|
+
}
|
|
1704
|
+
clear(storage, key) {
|
|
1705
|
+
this.memory.delete(key);
|
|
1706
|
+
swallow(() => storage.remove(key));
|
|
1707
|
+
}
|
|
1708
|
+
/** Called by `chat.destroy()`. @internal */
|
|
1709
|
+
async destroy(opts) {
|
|
1710
|
+
this.memory.clear();
|
|
1711
|
+
if (!opts.clearStorage) return;
|
|
1712
|
+
const ns = this.namespace();
|
|
1713
|
+
const storages = /* @__PURE__ */ new Set([...this.written.keys(), localDraftStorage]);
|
|
1714
|
+
for (const storage of storages) {
|
|
1715
|
+
const keys = new Set(this.written.get(storage) ?? []);
|
|
1716
|
+
if (ns) {
|
|
1717
|
+
try {
|
|
1718
|
+
const raw = await storage.get(indexKey(ns));
|
|
1719
|
+
const listed = raw ? JSON.parse(raw) : [];
|
|
1720
|
+
if (Array.isArray(listed)) {
|
|
1721
|
+
for (const k of listed) if (typeof k === "string") keys.add(k);
|
|
1722
|
+
}
|
|
1723
|
+
} catch {
|
|
1724
|
+
}
|
|
1725
|
+
swallow(() => storage.remove(indexKey(ns)));
|
|
1726
|
+
}
|
|
1727
|
+
for (const k of keys) swallow(() => storage.remove(k));
|
|
1728
|
+
}
|
|
1729
|
+
this.written.clear();
|
|
1677
1730
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1731
|
+
// Remember the key in an index entry, so a sign-out finds drafts
|
|
1732
|
+
// written in earlier sessions too.
|
|
1733
|
+
track(storage, key) {
|
|
1734
|
+
let keys = this.written.get(storage);
|
|
1735
|
+
if (!keys) {
|
|
1736
|
+
keys = /* @__PURE__ */ new Set();
|
|
1737
|
+
this.written.set(storage, keys);
|
|
1738
|
+
}
|
|
1739
|
+
if (keys.has(key)) return;
|
|
1740
|
+
keys.add(key);
|
|
1741
|
+
const ns = this.namespace();
|
|
1742
|
+
if (!ns) return;
|
|
1743
|
+
const all = keys;
|
|
1744
|
+
const merge = (raw2) => {
|
|
1745
|
+
let listed = [];
|
|
1746
|
+
try {
|
|
1747
|
+
const v = raw2 ? JSON.parse(raw2) : [];
|
|
1748
|
+
if (Array.isArray(v)) listed = v.filter((k) => typeof k === "string");
|
|
1749
|
+
} catch {
|
|
1750
|
+
}
|
|
1751
|
+
const next = [.../* @__PURE__ */ new Set([...listed, ...all])];
|
|
1752
|
+
swallow(() => storage.set(indexKey(ns), JSON.stringify(next)));
|
|
1753
|
+
};
|
|
1754
|
+
const raw = safeGet(storage, indexKey(ns));
|
|
1755
|
+
if (raw instanceof Promise) void raw.then(merge, () => void 0);
|
|
1756
|
+
else merge(raw);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
function draftsOf(chat) {
|
|
1760
|
+
return chat.scoped("react-ui:drafts", (c) => new DraftScope(() => c.namespace));
|
|
1761
|
+
}
|
|
1762
|
+
var indexKey = (ns) => `${ns}:draft-index`;
|
|
1763
|
+
function safeGet(storage, key) {
|
|
1680
1764
|
try {
|
|
1681
|
-
|
|
1765
|
+
return storage.get(key);
|
|
1682
1766
|
} catch {
|
|
1767
|
+
return null;
|
|
1683
1768
|
}
|
|
1684
1769
|
}
|
|
1685
|
-
function
|
|
1686
|
-
memory.delete(key);
|
|
1770
|
+
function swallow(fn) {
|
|
1687
1771
|
try {
|
|
1688
|
-
|
|
1772
|
+
const r = fn();
|
|
1773
|
+
if (r && typeof r.catch === "function") {
|
|
1774
|
+
r.catch(() => void 0);
|
|
1775
|
+
}
|
|
1689
1776
|
} catch {
|
|
1690
1777
|
}
|
|
1691
1778
|
}
|
|
@@ -1701,6 +1788,93 @@ function parse(raw) {
|
|
|
1701
1788
|
return null;
|
|
1702
1789
|
}
|
|
1703
1790
|
}
|
|
1791
|
+
function EmptyState({ title, hint, action, className }) {
|
|
1792
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["poolse-empty-state", className].filter(Boolean).join(" "), role: "status", children: [
|
|
1793
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-empty-state__title", children: title }),
|
|
1794
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-empty-state__hint", children: hint }) : null,
|
|
1795
|
+
action ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-empty-state__action", children: action }) : null
|
|
1796
|
+
] });
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// src/keymap.ts
|
|
1800
|
+
var DEFAULT_KEYMAP = {
|
|
1801
|
+
composer: {
|
|
1802
|
+
send: ["Enter", "Mod+Enter"],
|
|
1803
|
+
newline: ["Shift+Enter"],
|
|
1804
|
+
editLast: ["ArrowUp"],
|
|
1805
|
+
cancel: ["Escape"]
|
|
1806
|
+
},
|
|
1807
|
+
messageList: {
|
|
1808
|
+
next: ["j", "ArrowDown"],
|
|
1809
|
+
prev: ["k", "ArrowUp"],
|
|
1810
|
+
last: ["End"],
|
|
1811
|
+
first: ["Home"],
|
|
1812
|
+
reply: ["r"],
|
|
1813
|
+
thread: ["t"],
|
|
1814
|
+
edit: ["e"],
|
|
1815
|
+
delete: ["Delete", "Backspace"],
|
|
1816
|
+
composer: ["Escape"]
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
var MOD_ENTER_COMPOSER = {
|
|
1820
|
+
send: ["Mod+Enter"],
|
|
1821
|
+
newline: ["Enter", "Shift+Enter"]
|
|
1822
|
+
};
|
|
1823
|
+
function resolveKeymap(overrides, sendOn = "enter") {
|
|
1824
|
+
return {
|
|
1825
|
+
composer: {
|
|
1826
|
+
...DEFAULT_KEYMAP.composer,
|
|
1827
|
+
...sendOn === "mod+enter" ? MOD_ENTER_COMPOSER : {},
|
|
1828
|
+
...overrides?.composer
|
|
1829
|
+
},
|
|
1830
|
+
messageList: { ...DEFAULT_KEYMAP.messageList, ...overrides?.messageList }
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function matchesKey(e, binding) {
|
|
1834
|
+
const parts = binding.split("+");
|
|
1835
|
+
const key = parts.pop() ?? "";
|
|
1836
|
+
const mods = new Set(parts.map((p) => p.toLowerCase()));
|
|
1837
|
+
const wantMod = mods.has("mod");
|
|
1838
|
+
const wantCtrl = mods.has("ctrl");
|
|
1839
|
+
const wantMeta = mods.has("meta") || mods.has("cmd");
|
|
1840
|
+
const wantAlt = mods.has("alt") || mods.has("option");
|
|
1841
|
+
const wantShift = mods.has("shift");
|
|
1842
|
+
if (wantMod ? !(e.metaKey || e.ctrlKey) : !wantCtrl && !wantMeta && (e.metaKey || e.ctrlKey)) {
|
|
1843
|
+
return false;
|
|
1844
|
+
}
|
|
1845
|
+
if (wantCtrl && !e.ctrlKey) return false;
|
|
1846
|
+
if (wantMeta && !e.metaKey) return false;
|
|
1847
|
+
if (wantAlt !== e.altKey) return false;
|
|
1848
|
+
const letter = key.length === 1;
|
|
1849
|
+
if (!letter && wantShift !== e.shiftKey) return false;
|
|
1850
|
+
if (letter && wantShift && !e.shiftKey) return false;
|
|
1851
|
+
return letter ? e.key.toLowerCase() === key.toLowerCase() : e.key === key;
|
|
1852
|
+
}
|
|
1853
|
+
function matchesAny(e, bindings) {
|
|
1854
|
+
return bindings.some((b) => matchesKey(e, b));
|
|
1855
|
+
}
|
|
1856
|
+
function isTypingTarget(target) {
|
|
1857
|
+
if (!target || typeof target.closest !== "function") return false;
|
|
1858
|
+
const el = target;
|
|
1859
|
+
if (el.isContentEditable) return true;
|
|
1860
|
+
return !!el.closest('input, textarea, select, [contenteditable="true"]');
|
|
1861
|
+
}
|
|
1862
|
+
function composerAction(e, keymap) {
|
|
1863
|
+
if (matchesAny(e, keymap.newline)) return "newline";
|
|
1864
|
+
if (matchesAny(e, keymap.send)) return "send";
|
|
1865
|
+
if (matchesAny(e, keymap.editLast)) return "editLast";
|
|
1866
|
+
if (matchesAny(e, keymap.cancel)) return "cancel";
|
|
1867
|
+
return null;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
// src/motion.ts
|
|
1871
|
+
function prefersReducedMotion() {
|
|
1872
|
+
try {
|
|
1873
|
+
return typeof globalThis.matchMedia === "function" && globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1874
|
+
} catch {
|
|
1875
|
+
return false;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1704
1878
|
|
|
1705
1879
|
// src/layout.ts
|
|
1706
1880
|
function gutterTime(time) {
|
|
@@ -2358,7 +2532,9 @@ var MentionInput = react.forwardRef(
|
|
|
2358
2532
|
emojiPicker = true,
|
|
2359
2533
|
maxFileSize,
|
|
2360
2534
|
acceptFileTypes,
|
|
2361
|
-
onValueChange
|
|
2535
|
+
onValueChange,
|
|
2536
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2537
|
+
onEditLast
|
|
2362
2538
|
}, ref) {
|
|
2363
2539
|
const chat = react$1.usePoolse();
|
|
2364
2540
|
const { members } = react$1.useMembers(conversationId);
|
|
@@ -2509,10 +2685,26 @@ var MentionInput = react.forwardRef(
|
|
|
2509
2685
|
return;
|
|
2510
2686
|
}
|
|
2511
2687
|
}
|
|
2512
|
-
|
|
2688
|
+
const action = composerAction(e, keymap);
|
|
2689
|
+
if (action === "editLast") {
|
|
2690
|
+
if (value === "" && onEditLast && onEditLast() !== false) e.preventDefault();
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
if (action === "newline" && e.key === "Enter" && !e.shiftKey) {
|
|
2694
|
+
const result = handleListEnter(value, e.currentTarget.selectionStart);
|
|
2695
|
+
if (result) {
|
|
2696
|
+
e.preventDefault();
|
|
2697
|
+
setValue(result.value);
|
|
2698
|
+
requestAnimationFrame(() => {
|
|
2699
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
2700
|
+
});
|
|
2701
|
+
}
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
if (action === "send") {
|
|
2513
2705
|
const ta = e.currentTarget;
|
|
2514
2706
|
const caret = ta.selectionStart;
|
|
2515
|
-
const result = handleListEnter(value, caret);
|
|
2707
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
2516
2708
|
if (result) {
|
|
2517
2709
|
e.preventDefault();
|
|
2518
2710
|
setValue(result.value);
|
|
@@ -2524,7 +2716,7 @@ var MentionInput = react.forwardRef(
|
|
|
2524
2716
|
e.preventDefault();
|
|
2525
2717
|
void submit();
|
|
2526
2718
|
}
|
|
2527
|
-
if (
|
|
2719
|
+
if (action === "cancel" && replyingTo && onCancelReply && !mention) {
|
|
2528
2720
|
e.preventDefault();
|
|
2529
2721
|
onCancelReply();
|
|
2530
2722
|
}
|
|
@@ -2580,6 +2772,8 @@ var MentionInput = react.forwardRef(
|
|
|
2580
2772
|
multiple: true,
|
|
2581
2773
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
2582
2774
|
className: "poolse-attach-input",
|
|
2775
|
+
"aria-label": "Attach files",
|
|
2776
|
+
tabIndex: -1,
|
|
2583
2777
|
onChange: (e) => {
|
|
2584
2778
|
const files = Array.from(e.target.files ?? []);
|
|
2585
2779
|
if (files.length > 0) addFiles(files);
|
|
@@ -2613,11 +2807,11 @@ var MentionInput = react.forwardRef(
|
|
|
2613
2807
|
placeholder,
|
|
2614
2808
|
disabled: disabled || sending,
|
|
2615
2809
|
"aria-label": placeholder,
|
|
2616
|
-
role: "combobox",
|
|
2617
|
-
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
2618
|
-
"aria-controls": menuId,
|
|
2619
2810
|
"aria-autocomplete": "list",
|
|
2620
|
-
...mention && filtered.length > 0 ? {
|
|
2811
|
+
...mention && filtered.length > 0 ? {
|
|
2812
|
+
"aria-controls": menuId,
|
|
2813
|
+
"aria-activedescendant": `${menuId}-opt-${activeIdx}`
|
|
2814
|
+
} : {}
|
|
2621
2815
|
}
|
|
2622
2816
|
),
|
|
2623
2817
|
emojiPicker && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2691,7 +2885,9 @@ var MessageComposer = react.forwardRef(
|
|
|
2691
2885
|
emojiPicker = true,
|
|
2692
2886
|
maxFileSize,
|
|
2693
2887
|
acceptFileTypes,
|
|
2694
|
-
onValueChange
|
|
2888
|
+
onValueChange,
|
|
2889
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2890
|
+
onEditLast
|
|
2695
2891
|
}, ref) {
|
|
2696
2892
|
const [value, setValue] = react.useState("");
|
|
2697
2893
|
const [sending, setSending] = react.useState(false);
|
|
@@ -2745,10 +2941,26 @@ var MessageComposer = react.forwardRef(
|
|
|
2745
2941
|
}
|
|
2746
2942
|
};
|
|
2747
2943
|
const onKeyDown = (e) => {
|
|
2748
|
-
|
|
2944
|
+
const action = composerAction(e, keymap);
|
|
2945
|
+
if (action === "editLast") {
|
|
2946
|
+
if (value === "" && onEditLast && onEditLast() !== false) e.preventDefault();
|
|
2947
|
+
return;
|
|
2948
|
+
}
|
|
2949
|
+
if (action === "newline" && e.key === "Enter" && !e.shiftKey) {
|
|
2950
|
+
const result = handleListEnter(value, e.currentTarget.selectionStart);
|
|
2951
|
+
if (result) {
|
|
2952
|
+
e.preventDefault();
|
|
2953
|
+
setValue(result.value);
|
|
2954
|
+
requestAnimationFrame(() => {
|
|
2955
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2960
|
+
if (action === "send") {
|
|
2749
2961
|
const ta = e.currentTarget;
|
|
2750
2962
|
const caret = ta.selectionStart;
|
|
2751
|
-
const result = handleListEnter(value, caret);
|
|
2963
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
2752
2964
|
if (result) {
|
|
2753
2965
|
e.preventDefault();
|
|
2754
2966
|
setValue(result.value);
|
|
@@ -2760,7 +2972,7 @@ var MessageComposer = react.forwardRef(
|
|
|
2760
2972
|
e.preventDefault();
|
|
2761
2973
|
void submit();
|
|
2762
2974
|
}
|
|
2763
|
-
if (
|
|
2975
|
+
if (action === "cancel" && replyingTo && onCancelReply) {
|
|
2764
2976
|
e.preventDefault();
|
|
2765
2977
|
onCancelReply();
|
|
2766
2978
|
}
|
|
@@ -2806,6 +3018,8 @@ var MessageComposer = react.forwardRef(
|
|
|
2806
3018
|
multiple: true,
|
|
2807
3019
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
2808
3020
|
className: "poolse-attach-input",
|
|
3021
|
+
"aria-label": "Attach files",
|
|
3022
|
+
tabIndex: -1,
|
|
2809
3023
|
onChange: (e) => {
|
|
2810
3024
|
const files = Array.from(e.target.files ?? []);
|
|
2811
3025
|
if (files.length > 0) addFiles(files);
|
|
@@ -2944,6 +3158,189 @@ function formatTime(iso) {
|
|
|
2944
3158
|
if (Number.isNaN(d.getTime())) return "";
|
|
2945
3159
|
return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
2946
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
|
+
}
|
|
2947
3344
|
function AttachmentPreview({ attachment, onClick }) {
|
|
2948
3345
|
const isFullRow = "content_type" in attachment;
|
|
2949
3346
|
const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
|
|
@@ -4019,6 +4416,35 @@ function InlineReactions({
|
|
|
4019
4416
|
);
|
|
4020
4417
|
}) });
|
|
4021
4418
|
}
|
|
4419
|
+
function SendStatus({ message, onRetry, onDiscard, align = "right" }) {
|
|
4420
|
+
const status = message.local_status;
|
|
4421
|
+
if (status !== "queued" && status !== "failed") return null;
|
|
4422
|
+
const failed = status === "failed";
|
|
4423
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4424
|
+
"div",
|
|
4425
|
+
{
|
|
4426
|
+
className: [
|
|
4427
|
+
"poolse-send-status",
|
|
4428
|
+
`poolse-send-status--${status}`,
|
|
4429
|
+
`poolse-send-status--${align}`
|
|
4430
|
+
].join(" "),
|
|
4431
|
+
role: "status",
|
|
4432
|
+
children: [
|
|
4433
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-send-status__text", children: failed ? message.local_error ? `Not sent: ${message.local_error}` : "Not sent" : "Waiting for network\u2026" }),
|
|
4434
|
+
onRetry && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-send-status__button", onClick: onRetry, children: failed ? "Retry" : "Send now" }),
|
|
4435
|
+
failed && onDiscard && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4436
|
+
"button",
|
|
4437
|
+
{
|
|
4438
|
+
type: "button",
|
|
4439
|
+
className: "poolse-send-status__button poolse-send-status__button--danger",
|
|
4440
|
+
onClick: onDiscard,
|
|
4441
|
+
children: "Delete"
|
|
4442
|
+
}
|
|
4443
|
+
)
|
|
4444
|
+
]
|
|
4445
|
+
}
|
|
4446
|
+
);
|
|
4447
|
+
}
|
|
4022
4448
|
function ThreadSummary({ message, onOpen, maxAvatars = 3, className }) {
|
|
4023
4449
|
const now = useNow();
|
|
4024
4450
|
const count = message.reply_count ?? 0;
|
|
@@ -4080,7 +4506,9 @@ function FlatMessageRow({
|
|
|
4080
4506
|
onAvatarPress,
|
|
4081
4507
|
timeFormat,
|
|
4082
4508
|
slots,
|
|
4083
|
-
mentionsMe = false
|
|
4509
|
+
mentionsMe = false,
|
|
4510
|
+
onRetrySend,
|
|
4511
|
+
onDiscardSend
|
|
4084
4512
|
}) {
|
|
4085
4513
|
const compact = layout === "compact";
|
|
4086
4514
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -4104,7 +4532,8 @@ function FlatMessageRow({
|
|
|
4104
4532
|
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
4105
4533
|
const replyCount = msg.reply_count ?? 0;
|
|
4106
4534
|
const showThreadLink = threads && !msg.thread_root_id && replyCount > 0;
|
|
4107
|
-
const
|
|
4535
|
+
const unsent = !!msg.local_status;
|
|
4536
|
+
const showActions = actions && !deleted && !editing && !unsent;
|
|
4108
4537
|
const timeEl = (className) => /* @__PURE__ */ jsxRuntime.jsx("time", { className, dateTime: msg.inserted_at, children: className === "poolse-row__gutter-time" ? gutterTime(time) : time });
|
|
4109
4538
|
const avatarSize = compact ? "sm" : "md";
|
|
4110
4539
|
const avatarEl = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4197,7 +4626,7 @@ function FlatMessageRow({
|
|
|
4197
4626
|
meta
|
|
4198
4627
|
}
|
|
4199
4628
|
);
|
|
4200
|
-
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4629
|
+
const reactionsEl = reactions && !deleted && !unsent ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4201
4630
|
InlineReactions,
|
|
4202
4631
|
{
|
|
4203
4632
|
reactions: reactionsHook.reactions,
|
|
@@ -4238,7 +4667,16 @@ function FlatMessageRow({
|
|
|
4238
4667
|
renderSlot(slots?.body, ctx, body),
|
|
4239
4668
|
linkPreviews && !editing && hasLinkPreviews(msg) ? /* @__PURE__ */ jsxRuntime.jsx(MessageLinkPreviews, { message: msg, canRemove: isSelf }) : null,
|
|
4240
4669
|
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
4241
|
-
renderSlot(slots?.thread, ctx, threadEl)
|
|
4670
|
+
renderSlot(slots?.thread, ctx, threadEl),
|
|
4671
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4672
|
+
SendStatus,
|
|
4673
|
+
{
|
|
4674
|
+
message: msg,
|
|
4675
|
+
align: "left",
|
|
4676
|
+
...onRetrySend ? { onRetry: onRetrySend } : {},
|
|
4677
|
+
...onDiscardSend ? { onDiscard: onDiscardSend } : {}
|
|
4678
|
+
}
|
|
4679
|
+
)
|
|
4242
4680
|
] });
|
|
4243
4681
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4244
4682
|
"div",
|
|
@@ -4250,9 +4688,13 @@ function FlatMessageRow({
|
|
|
4250
4688
|
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
4251
4689
|
isSelf ? "poolse-row--self" : "",
|
|
4252
4690
|
mentionsMe ? "poolse-row--mention" : "",
|
|
4253
|
-
editing ? "poolse-row--editing" : ""
|
|
4691
|
+
editing ? "poolse-row--editing" : "",
|
|
4692
|
+
unsent ? "poolse-row--unsent" : ""
|
|
4254
4693
|
].filter(Boolean).join(" "),
|
|
4255
4694
|
"data-message-id": msg.id,
|
|
4695
|
+
role: "article",
|
|
4696
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
4697
|
+
tabIndex: -1,
|
|
4256
4698
|
"data-actions-open": actionsOpen || void 0,
|
|
4257
4699
|
onClick: onRowClick,
|
|
4258
4700
|
children: [
|
|
@@ -4322,6 +4764,16 @@ function FlatBody({
|
|
|
4322
4764
|
);
|
|
4323
4765
|
}
|
|
4324
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
|
+
}
|
|
4325
4777
|
const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
|
|
4326
4778
|
if (callLog !== void 0) {
|
|
4327
4779
|
return callLog ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4367,7 +4819,9 @@ function BubbleMessageRow({
|
|
|
4367
4819
|
onSenderPress,
|
|
4368
4820
|
onAvatarPress,
|
|
4369
4821
|
timeFormat,
|
|
4370
|
-
slots
|
|
4822
|
+
slots,
|
|
4823
|
+
onRetrySend,
|
|
4824
|
+
onDiscardSend
|
|
4371
4825
|
}) {
|
|
4372
4826
|
const { profile: senderProfile } = react$1.useUser(msg.sender_external_id);
|
|
4373
4827
|
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
@@ -4384,8 +4838,9 @@ function BubbleMessageRow({
|
|
|
4384
4838
|
initialReactions: msg.reactions,
|
|
4385
4839
|
currentUserId: meId
|
|
4386
4840
|
});
|
|
4387
|
-
const
|
|
4388
|
-
const
|
|
4841
|
+
const unsent = !!msg.local_status;
|
|
4842
|
+
const showReactions = reactions && !msg.deleted_at && !unsent;
|
|
4843
|
+
const showActions = actions && !msg.deleted_at && !editing && !unsent;
|
|
4389
4844
|
const replyCount = msg.reply_count ?? 0;
|
|
4390
4845
|
const showThreadPill = threads && !msg.thread_root_id && replyCount > 0;
|
|
4391
4846
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
@@ -4409,9 +4864,13 @@ function BubbleMessageRow({
|
|
|
4409
4864
|
// tighten the inter-bubble gap inside a cluster (first/middle/
|
|
4410
4865
|
// last) and widen it between clusters (standalone or the
|
|
4411
4866
|
// first of a new run).
|
|
4412
|
-
`poolse-message-row--${groupPosition}
|
|
4867
|
+
`poolse-message-row--${groupPosition}`,
|
|
4868
|
+
unsent ? "poolse-message-row--unsent" : ""
|
|
4413
4869
|
].filter(Boolean).join(" "),
|
|
4414
4870
|
"data-message-id": msg.id,
|
|
4871
|
+
role: "article",
|
|
4872
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
4873
|
+
tabIndex: -1,
|
|
4415
4874
|
"data-actions-open": actionsOpen || void 0,
|
|
4416
4875
|
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
4417
4876
|
onClick: onRowClick,
|
|
@@ -4473,6 +4932,15 @@ function BubbleMessageRow({
|
|
|
4473
4932
|
)
|
|
4474
4933
|
}
|
|
4475
4934
|
),
|
|
4935
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4936
|
+
SendStatus,
|
|
4937
|
+
{
|
|
4938
|
+
message: msg,
|
|
4939
|
+
align: isSelf ? "right" : "left",
|
|
4940
|
+
...onRetrySend ? { onRetry: onRetrySend } : {},
|
|
4941
|
+
...onDiscardSend ? { onDiscard: onDiscardSend } : {}
|
|
4942
|
+
}
|
|
4943
|
+
),
|
|
4476
4944
|
renderSlot(
|
|
4477
4945
|
slots?.reactions,
|
|
4478
4946
|
slotContext,
|
|
@@ -4638,13 +5106,12 @@ function ThreadView({
|
|
|
4638
5106
|
}, [replies]);
|
|
4639
5107
|
react.useEffect(() => {
|
|
4640
5108
|
closeBtnRef.current?.focus();
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
}, [onClose]);
|
|
5109
|
+
}, []);
|
|
5110
|
+
const onPaneKeyDown = (e) => {
|
|
5111
|
+
if (e.key !== "Escape" || e.defaultPrevented || !onClose) return;
|
|
5112
|
+
e.preventDefault();
|
|
5113
|
+
onClose();
|
|
5114
|
+
};
|
|
4648
5115
|
const renderDefault = (msg) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4649
5116
|
MessageRow,
|
|
4650
5117
|
{
|
|
@@ -4677,6 +5144,7 @@ function ThreadView({
|
|
|
4677
5144
|
className: `poolse-thread${density ? ` poolse-conversation--density-${density}` : ""}${dragActive ? " is-drag-active" : ""}`,
|
|
4678
5145
|
role: "complementary",
|
|
4679
5146
|
"aria-label": "Message thread",
|
|
5147
|
+
onKeyDown: onPaneKeyDown,
|
|
4680
5148
|
onDragEnter,
|
|
4681
5149
|
onDragOver,
|
|
4682
5150
|
onDragLeave,
|
|
@@ -4697,9 +5165,9 @@ function ThreadView({
|
|
|
4697
5165
|
)
|
|
4698
5166
|
] }),
|
|
4699
5167
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
|
|
4700
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
|
|
5168
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-thread__messages", ref: listRef, role: "log", "aria-label": "Replies", children: [
|
|
4701
5169
|
hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
|
|
4702
|
-
loading && replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5170
|
+
loading && replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { title: "No replies yet", hint: "Write a reply below to start the thread." }) : (
|
|
4703
5171
|
// Same Fragment trick as ConversationView so MessageBubble
|
|
4704
5172
|
// remains the direct flex child for align-self to work.
|
|
4705
5173
|
replies.map((msg) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderOne(msg, me?.id ?? null) }, msg.id))
|
|
@@ -4836,7 +5304,11 @@ function ConversationView({
|
|
|
4836
5304
|
onJoinCall,
|
|
4837
5305
|
currentCallId = null,
|
|
4838
5306
|
persistDrafts = TRUE,
|
|
4839
|
-
draftStorage
|
|
5307
|
+
draftStorage,
|
|
5308
|
+
keymap: keymapOverrides,
|
|
5309
|
+
sendOn = "enter",
|
|
5310
|
+
keyboardShortcuts = TRUE,
|
|
5311
|
+
confirmDelete
|
|
4840
5312
|
}) {
|
|
4841
5313
|
usePoolseFonts(loadFonts);
|
|
4842
5314
|
const showComposer = composer && !readOnly;
|
|
@@ -4851,10 +5323,13 @@ function ConversationView({
|
|
|
4851
5323
|
loadMore,
|
|
4852
5324
|
loadUntil,
|
|
4853
5325
|
send,
|
|
5326
|
+
retry: retrySend,
|
|
5327
|
+
discard: discardSend,
|
|
4854
5328
|
edit,
|
|
4855
5329
|
delete: deleteMsg,
|
|
4856
5330
|
markReadUpTo
|
|
4857
5331
|
} = react$1.useMessages(conversationId);
|
|
5332
|
+
const keymap = react.useMemo(() => resolveKeymap(keymapOverrides, sendOn), [keymapOverrides, sendOn]);
|
|
4858
5333
|
const { typing: typingPeople, signalTyping } = react$1.useTyping(conversationId);
|
|
4859
5334
|
const streams = react$1.useMessageStreams(conversationId);
|
|
4860
5335
|
const typing = react.useMemo(() => {
|
|
@@ -4870,6 +5345,14 @@ function ConversationView({
|
|
|
4870
5345
|
const membersOn = mentions || readReceipts || wantsMemberCount;
|
|
4871
5346
|
const { members, loading: membersLoading } = react$1.useMembers(membersOn ? conversationId : "");
|
|
4872
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
|
+
);
|
|
4873
5356
|
const isGroupChat = members.length > 2;
|
|
4874
5357
|
const showSenderLabelsResolved = senderLabels === "always" || senderLabels === "auto" && isGroupChat;
|
|
4875
5358
|
const showAvatarsResolved = showAvatars ?? (layout === "list" ? true : layout === "compact" ? false : avatars === "always" || avatars === "auto" && isGroupChat);
|
|
@@ -5147,18 +5630,19 @@ function ConversationView({
|
|
|
5147
5630
|
const meIdForDrafts = me?.id ?? null;
|
|
5148
5631
|
const draftsOn = persistDrafts && showComposer;
|
|
5149
5632
|
const storage = draftStorage ?? localDraftStorage;
|
|
5633
|
+
const drafts = draftsOf(chat);
|
|
5150
5634
|
const draftRef = react.useRef({ text: "", replyTo: null });
|
|
5151
5635
|
const draftKeyFor = react.useCallback(
|
|
5152
|
-
() => draftsOn && meIdForDrafts ?
|
|
5153
|
-
[draftsOn, meIdForDrafts]
|
|
5636
|
+
() => draftsOn && meIdForDrafts ? drafts.key(conversationIdRef.current) : null,
|
|
5637
|
+
[draftsOn, meIdForDrafts, drafts]
|
|
5154
5638
|
);
|
|
5155
5639
|
const saveDraft = react.useCallback(
|
|
5156
5640
|
(patch) => {
|
|
5157
5641
|
draftRef.current = { ...draftRef.current, ...patch };
|
|
5158
5642
|
const key = draftKeyFor();
|
|
5159
|
-
if (key)
|
|
5643
|
+
if (key) drafts.write(storage, key, draftRef.current);
|
|
5160
5644
|
},
|
|
5161
|
-
[draftKeyFor, storage]
|
|
5645
|
+
[draftKeyFor, storage, drafts]
|
|
5162
5646
|
);
|
|
5163
5647
|
const setReplyingTo = react.useCallback(
|
|
5164
5648
|
(m) => {
|
|
@@ -5179,13 +5663,14 @@ function ConversationView({
|
|
|
5179
5663
|
draftRef.current = { text: composer2?.getText() || d.text, replyTo: d.replyTo };
|
|
5180
5664
|
if (d.replyTo && canQuote) setReplyingToState((cur) => cur ?? d.replyTo);
|
|
5181
5665
|
};
|
|
5182
|
-
const
|
|
5666
|
+
const legacy = meIdForDrafts ? draftKey(meIdForDrafts, conversationIdRef.current) : void 0;
|
|
5667
|
+
const found = drafts.read(storage, key, legacy);
|
|
5183
5668
|
if (found instanceof Promise) void found.then(apply);
|
|
5184
5669
|
else apply(found);
|
|
5185
5670
|
return () => {
|
|
5186
5671
|
live = false;
|
|
5187
5672
|
};
|
|
5188
|
-
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer]);
|
|
5673
|
+
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer, drafts, meIdForDrafts]);
|
|
5189
5674
|
const onComposerChange = react.useCallback((text) => saveDraft({ text }), [saveDraft]);
|
|
5190
5675
|
react.useEffect(() => {
|
|
5191
5676
|
if (!replyingTo) return;
|
|
@@ -5234,11 +5719,13 @@ function ConversationView({
|
|
|
5234
5719
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
5235
5720
|
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
5236
5721
|
};
|
|
5237
|
-
const sendRequest = async (
|
|
5722
|
+
const sendRequest = async (input) => {
|
|
5723
|
+
const req = { ...input, id: input.id ?? sdk.safeUuid() };
|
|
5238
5724
|
try {
|
|
5239
5725
|
await send(req);
|
|
5240
5726
|
} catch (err) {
|
|
5241
5727
|
if (err instanceof react$1.ApiError && err.code === "quoted_message_deleted") {
|
|
5728
|
+
discardSend(req.id);
|
|
5242
5729
|
setReplyingTo(null);
|
|
5243
5730
|
setSendNotice("The message you replied to was deleted.");
|
|
5244
5731
|
const body = req.body;
|
|
@@ -5250,13 +5737,91 @@ function ConversationView({
|
|
|
5250
5737
|
}
|
|
5251
5738
|
return;
|
|
5252
5739
|
}
|
|
5253
|
-
throw err;
|
|
5740
|
+
if (!(err instanceof sdk.MessageQueuedError) && !chat.outboxEnabled) throw err;
|
|
5254
5741
|
}
|
|
5255
5742
|
setReplyingToState(null);
|
|
5256
5743
|
setUnreadMarker(null);
|
|
5257
5744
|
draftRef.current = { text: "", replyTo: null };
|
|
5258
5745
|
const key = draftKeyFor();
|
|
5259
|
-
if (key)
|
|
5746
|
+
if (key) drafts.clear(storage, key);
|
|
5747
|
+
};
|
|
5748
|
+
const editLast = () => {
|
|
5749
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
5750
|
+
const m = messages[i];
|
|
5751
|
+
if (!me || m.sender_id !== me.id || m.deleted_at || m.local_status) continue;
|
|
5752
|
+
if (m.thread_root_id) continue;
|
|
5753
|
+
const isRead = maxReadByOthers !== null && maxReadByOthers >= m.sequence;
|
|
5754
|
+
const editable = react$1.canEditOwnMessage({
|
|
5755
|
+
isSelf: true,
|
|
5756
|
+
deleted: false,
|
|
5757
|
+
receiptsVisible,
|
|
5758
|
+
readState: showReadState && maxReadByOthers !== null ? isRead ? "read" : "sent" : void 0,
|
|
5759
|
+
insertedAt: m.inserted_at
|
|
5760
|
+
});
|
|
5761
|
+
if (!editable) return false;
|
|
5762
|
+
setEditingId(m.id);
|
|
5763
|
+
return true;
|
|
5764
|
+
}
|
|
5765
|
+
return false;
|
|
5766
|
+
};
|
|
5767
|
+
const rowsInList = () => Array.from(listRef.current?.querySelectorAll("[data-message-id]") ?? []).filter(
|
|
5768
|
+
(el) => el.closest(".poolse-conversation__messages") === listRef.current
|
|
5769
|
+
);
|
|
5770
|
+
const focusRow = (el) => {
|
|
5771
|
+
if (!el) return;
|
|
5772
|
+
el.focus();
|
|
5773
|
+
if (typeof el.scrollIntoView === "function") {
|
|
5774
|
+
el.scrollIntoView({ block: "nearest", behavior: prefersReducedMotion() ? "auto" : "smooth" });
|
|
5775
|
+
}
|
|
5776
|
+
};
|
|
5777
|
+
const onListKeyDown = (e) => {
|
|
5778
|
+
if (!keyboardShortcuts || isTypingTarget(e.target)) return;
|
|
5779
|
+
const km = keymap.messageList;
|
|
5780
|
+
const rows = rowsInList();
|
|
5781
|
+
if (rows.length === 0) return;
|
|
5782
|
+
const focused = e.target.closest?.("[data-message-id]");
|
|
5783
|
+
const idx = focused ? rows.indexOf(focused) : -1;
|
|
5784
|
+
const focusedMsg = focused ? messages.find((m) => m.id === focused.dataset["messageId"]) ?? null : null;
|
|
5785
|
+
const handled = () => {
|
|
5786
|
+
e.preventDefault();
|
|
5787
|
+
e.stopPropagation();
|
|
5788
|
+
};
|
|
5789
|
+
if (matchesAny(e, km.next)) {
|
|
5790
|
+
handled();
|
|
5791
|
+
focusRow(rows[idx === -1 ? rows.length - 1 : Math.min(rows.length - 1, idx + 1)]);
|
|
5792
|
+
} else if (matchesAny(e, km.prev)) {
|
|
5793
|
+
handled();
|
|
5794
|
+
focusRow(rows[idx === -1 ? rows.length - 1 : Math.max(0, idx - 1)]);
|
|
5795
|
+
} else if (matchesAny(e, km.last)) {
|
|
5796
|
+
handled();
|
|
5797
|
+
focusRow(rows[rows.length - 1]);
|
|
5798
|
+
} else if (matchesAny(e, km.first)) {
|
|
5799
|
+
handled();
|
|
5800
|
+
focusRow(rows[0]);
|
|
5801
|
+
} else if (matchesAny(e, km.composer)) {
|
|
5802
|
+
if (!showComposer) return;
|
|
5803
|
+
handled();
|
|
5804
|
+
composerRef.current?.focus();
|
|
5805
|
+
} else if (focusedMsg && !focusedMsg.deleted_at && !focusedMsg.local_status) {
|
|
5806
|
+
const isSelf = me !== null && focusedMsg.sender_id === me.id;
|
|
5807
|
+
if (matchesAny(e, km.reply) && canQuote) {
|
|
5808
|
+
handled();
|
|
5809
|
+
setReplyingTo(focusedMsg);
|
|
5810
|
+
composerRef.current?.focus();
|
|
5811
|
+
} else if (matchesAny(e, km.thread) && threads) {
|
|
5812
|
+
handled();
|
|
5813
|
+
setThreadRootId(focusedMsg.id);
|
|
5814
|
+
} else if (matchesAny(e, km.edit) && isSelf && showComposer) {
|
|
5815
|
+
handled();
|
|
5816
|
+
setEditingId(focusedMsg.id);
|
|
5817
|
+
} else if (matchesAny(e, km.delete) && isSelf && actions) {
|
|
5818
|
+
handled();
|
|
5819
|
+
const ask = confirmDelete ?? (() => typeof globalThis.confirm === "function" ? globalThis.confirm("Delete this message?") : false);
|
|
5820
|
+
void Promise.resolve(ask(focusedMsg)).then((ok) => {
|
|
5821
|
+
if (ok) void deleteMsg(focusedMsg.id).catch(() => void 0);
|
|
5822
|
+
});
|
|
5823
|
+
}
|
|
5824
|
+
}
|
|
5260
5825
|
};
|
|
5261
5826
|
const onSendBody = (body, opts) => sendRequest({
|
|
5262
5827
|
body,
|
|
@@ -5276,6 +5841,8 @@ function ConversationView({
|
|
|
5276
5841
|
conversationId,
|
|
5277
5842
|
onSend: onSendWithMentions,
|
|
5278
5843
|
onTyping: signalTyping,
|
|
5844
|
+
keymap: keymap.composer,
|
|
5845
|
+
onEditLast: editLast,
|
|
5279
5846
|
attachments,
|
|
5280
5847
|
emojiPicker,
|
|
5281
5848
|
...attachmentRules,
|
|
@@ -5290,6 +5857,8 @@ function ConversationView({
|
|
|
5290
5857
|
onValueChange: onComposerChange,
|
|
5291
5858
|
onSend: onSendBody,
|
|
5292
5859
|
onTyping: signalTyping,
|
|
5860
|
+
keymap: keymap.composer,
|
|
5861
|
+
onEditLast: editLast,
|
|
5293
5862
|
attachments,
|
|
5294
5863
|
emojiPicker,
|
|
5295
5864
|
...attachmentRules,
|
|
@@ -5354,6 +5923,8 @@ function ConversationView({
|
|
|
5354
5923
|
"aria-label": "Conversation messages",
|
|
5355
5924
|
"aria-live": "polite",
|
|
5356
5925
|
"aria-relevant": "additions",
|
|
5926
|
+
tabIndex: 0,
|
|
5927
|
+
onKeyDown: onListKeyDown,
|
|
5357
5928
|
children: [
|
|
5358
5929
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
5359
5930
|
showJump && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__jump-unread", children: [
|
|
@@ -5381,7 +5952,13 @@ function ConversationView({
|
|
|
5381
5952
|
}
|
|
5382
5953
|
)
|
|
5383
5954
|
] }),
|
|
5384
|
-
loading && messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: emptyState
|
|
5955
|
+
loading && messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 && !error ? typeof emptyState === "function" ? emptyState({ readOnly: !showComposer }) : emptyState !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: emptyState }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
5956
|
+
EmptyState,
|
|
5957
|
+
{
|
|
5958
|
+
title: "No messages yet",
|
|
5959
|
+
...showComposer ? { hint: "Write the first message below \u2014 everyone here will see it." } : {}
|
|
5960
|
+
}
|
|
5961
|
+
) : visibleMessages.map((msg, idx) => {
|
|
5385
5962
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
5386
5963
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
5387
5964
|
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
@@ -5440,7 +6017,12 @@ function ConversationView({
|
|
|
5440
6017
|
onQuote: () => setReplyingTo(msg),
|
|
5441
6018
|
...!isSelf && msg.sequence !== Number.MAX_SAFE_INTEGER ? { onMarkUnread: () => void markUnreadFrom(msg) } : {},
|
|
5442
6019
|
onQuotedClick: scrollToOriginal,
|
|
6020
|
+
...msg.local_status ? {
|
|
6021
|
+
onRetrySend: () => void retrySend(msg.id).catch(() => void 0),
|
|
6022
|
+
onDiscardSend: () => discardSend(msg.id)
|
|
6023
|
+
} : {},
|
|
5443
6024
|
...onCallBack ? { onCallBack } : {},
|
|
6025
|
+
nameForUserId,
|
|
5444
6026
|
...layoutProps,
|
|
5445
6027
|
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
5446
6028
|
}
|
|
@@ -5541,12 +6123,12 @@ function ConversationView({
|
|
|
5541
6123
|
var NO_MESSAGE = "00000000-0000-0000-0000-000000000000";
|
|
5542
6124
|
function scrollDividerIntoView(el) {
|
|
5543
6125
|
if (el && typeof el.scrollIntoView === "function") {
|
|
5544
|
-
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
6126
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "start" });
|
|
5545
6127
|
}
|
|
5546
6128
|
}
|
|
5547
6129
|
function highlightRow(el) {
|
|
5548
6130
|
if (typeof el.scrollIntoView === "function") {
|
|
5549
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
6131
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" });
|
|
5550
6132
|
}
|
|
5551
6133
|
el.classList.add("poolse-message-row--highlight");
|
|
5552
6134
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
@@ -5655,6 +6237,8 @@ function ConversationList({
|
|
|
5655
6237
|
onSelect,
|
|
5656
6238
|
renderItem,
|
|
5657
6239
|
emptyState,
|
|
6240
|
+
query = "",
|
|
6241
|
+
noResultsState,
|
|
5658
6242
|
conversations: controlledConversations,
|
|
5659
6243
|
loading: controlledLoading,
|
|
5660
6244
|
error: controlledError,
|
|
@@ -5675,7 +6259,15 @@ function ConversationList({
|
|
|
5675
6259
|
const meExternalId = me?.external_id ?? null;
|
|
5676
6260
|
const meId = me?.id ?? null;
|
|
5677
6261
|
const isControlled = controlledConversations !== void 0;
|
|
5678
|
-
const
|
|
6262
|
+
const allConversations = isControlled ? controlledConversations : auto.conversations;
|
|
6263
|
+
const needle = query.trim().toLowerCase();
|
|
6264
|
+
const conversations = react.useMemo(
|
|
6265
|
+
() => needle ? react$1.filterConversations(allConversations, needle, {
|
|
6266
|
+
meExternalId,
|
|
6267
|
+
...labelFor ? { labelFor } : {}
|
|
6268
|
+
}) : allConversations,
|
|
6269
|
+
[allConversations, needle, meExternalId, labelFor]
|
|
6270
|
+
);
|
|
5679
6271
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
5680
6272
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
5681
6273
|
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
@@ -5723,8 +6315,23 @@ function ConversationList({
|
|
|
5723
6315
|
if (error && conversations.length === 0) {
|
|
5724
6316
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: "Failed to load conversations." });
|
|
5725
6317
|
}
|
|
6318
|
+
if (conversations.length === 0 && needle && allConversations.length > 0) {
|
|
6319
|
+
return typeof noResultsState === "function" ? noResultsState(query.trim()) : noResultsState !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: noResultsState }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
6320
|
+
EmptyState,
|
|
6321
|
+
{
|
|
6322
|
+
title: `Nothing matches \u201C${query.trim()}\u201D`,
|
|
6323
|
+
hint: "Check the spelling, or search by a person's or channel's name."
|
|
6324
|
+
}
|
|
6325
|
+
);
|
|
6326
|
+
}
|
|
5726
6327
|
if (conversations.length === 0) {
|
|
5727
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState
|
|
6328
|
+
return emptyState !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
6329
|
+
EmptyState,
|
|
6330
|
+
{
|
|
6331
|
+
title: "No conversations yet",
|
|
6332
|
+
hint: "Start a chat with someone, or join a channel \u2014 it shows up here."
|
|
6333
|
+
}
|
|
6334
|
+
);
|
|
5728
6335
|
}
|
|
5729
6336
|
const row = (conv) => {
|
|
5730
6337
|
const selected = selectedId === conv.id;
|
|
@@ -5763,10 +6370,10 @@ function ConversationList({
|
|
|
5763
6370
|
);
|
|
5764
6371
|
};
|
|
5765
6372
|
return /* @__PURE__ */ jsxRuntime.jsxs("ul", { ref: listRef, className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: [
|
|
5766
|
-
groups === null ? conversations.map(row) : groups.map((g) => /* @__PURE__ */ jsxRuntime.
|
|
6373
|
+
groups === null ? conversations.map(row) : groups.map((g) => /* @__PURE__ */ jsxRuntime.jsx("li", { role: "presentation", className: "poolse-list__section", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", "aria-label": g.title, children: [
|
|
5767
6374
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__section-title", "aria-hidden": "true", children: g.title }),
|
|
5768
6375
|
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list__section-items", role: "presentation", children: g.conversations.map(row) })
|
|
5769
|
-
] }, g.title)),
|
|
6376
|
+
] }) }, g.title)),
|
|
5770
6377
|
loadingMore && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-list__loading-more", role: "presentation", children: "Loading\u2026" }),
|
|
5771
6378
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5772
6379
|
"li",
|
|
@@ -5815,7 +6422,7 @@ function DefaultRow({
|
|
|
5815
6422
|
const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? other?.avatarUrl ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
|
|
5816
6423
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
5817
6424
|
const hasUnread = unread > 0;
|
|
5818
|
-
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");
|
|
5819
6426
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5820
6427
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5821
6428
|
Avatar,
|
|
@@ -6084,7 +6691,7 @@ function UserPickerSheet({
|
|
|
6084
6691
|
}
|
|
6085
6692
|
)
|
|
6086
6693
|
] }),
|
|
6087
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-user-picker__empty", children: "No
|
|
6694
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-user-picker__empty", children: "No one matches that. Try part of a first or last name." }) : filtered.map((u) => {
|
|
6088
6695
|
const isSelected = selected.has(u.externalId);
|
|
6089
6696
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6090
6697
|
"li",
|
|
@@ -6381,8 +6988,24 @@ function RoomJoinBar({ room, allowStart = true }) {
|
|
|
6381
6988
|
] })
|
|
6382
6989
|
] });
|
|
6383
6990
|
}
|
|
6384
|
-
function RoomStage({
|
|
6991
|
+
function RoomStage({
|
|
6992
|
+
room,
|
|
6993
|
+
title,
|
|
6994
|
+
labelFor,
|
|
6995
|
+
className,
|
|
6996
|
+
capture = true,
|
|
6997
|
+
allowRecord = false
|
|
6998
|
+
}) {
|
|
6385
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;
|
|
6386
7009
|
const stage = react.useRef(null);
|
|
6387
7010
|
const fullscreen = useFullscreen(stage);
|
|
6388
7011
|
const [menu, setMenu] = react.useState(null);
|
|
@@ -6411,6 +7034,15 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
6411
7034
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-room__dot", "aria-hidden": "true" }),
|
|
6412
7035
|
elapsed
|
|
6413
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
|
+
),
|
|
6414
7046
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-room__chip", "aria-label": `${count} in the room`, children: [
|
|
6415
7047
|
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "users", size: 14, label: null }),
|
|
6416
7048
|
count
|
|
@@ -6435,6 +7067,19 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
6435
7067
|
}
|
|
6436
7068
|
)
|
|
6437
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
|
+
),
|
|
6438
7083
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-room__stage", children: count > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6439
7084
|
CallVideoGrid,
|
|
6440
7085
|
{
|
|
@@ -6449,6 +7094,20 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
6449
7094
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => void media.setScreenShareEnabled(false), children: "Stop sharing" })
|
|
6450
7095
|
] }),
|
|
6451
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
|
+
),
|
|
6452
7111
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-room__bar", children: [
|
|
6453
7112
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callsheet__control", children: [
|
|
6454
7113
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6526,6 +7185,16 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
6526
7185
|
}
|
|
6527
7186
|
)
|
|
6528
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
|
+
),
|
|
6529
7198
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6530
7199
|
CallControlButton,
|
|
6531
7200
|
{
|
|
@@ -6557,6 +7226,324 @@ function useElapsed(startedAt, running) {
|
|
|
6557
7226
|
const s = String(total % 60).padStart(2, "0");
|
|
6558
7227
|
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
|
6559
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
|
+
}
|
|
6560
7547
|
var ThemeContext = react.createContext(null);
|
|
6561
7548
|
var DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
6562
7549
|
function systemScheme() {
|
|
@@ -6751,14 +7738,20 @@ exports.CallDeviceMenu = CallDeviceMenu;
|
|
|
6751
7738
|
exports.CallLogRow = CallLogRow;
|
|
6752
7739
|
exports.CallVideoGrid = CallVideoGrid;
|
|
6753
7740
|
exports.ChatHeader = ChatHeader;
|
|
7741
|
+
exports.ConsentPrompt = ConsentPrompt;
|
|
6754
7742
|
exports.ConversationList = ConversationList;
|
|
6755
7743
|
exports.ConversationView = ConversationView;
|
|
7744
|
+
exports.DEFAULT_KEYMAP = DEFAULT_KEYMAP;
|
|
7745
|
+
exports.DraftScope = DraftScope;
|
|
6756
7746
|
exports.EditableMessageBubble = EditableMessageBubble;
|
|
6757
7747
|
exports.EditedLabel = EditedLabel;
|
|
6758
7748
|
exports.EmojiPicker = EmojiPicker;
|
|
7749
|
+
exports.EmptyState = EmptyState;
|
|
6759
7750
|
exports.GroupDetailsSheet = GroupDetailsSheet;
|
|
6760
7751
|
exports.LinkPreviewCard = LinkPreviewCard;
|
|
6761
7752
|
exports.LiveCallBanner = LiveCallBanner;
|
|
7753
|
+
exports.LiveTranscriptPanel = LiveTranscriptPanel;
|
|
7754
|
+
exports.MOD_ENTER_COMPOSER = MOD_ENTER_COMPOSER;
|
|
6762
7755
|
exports.MemberList = MemberList;
|
|
6763
7756
|
exports.MentionInput = MentionInput;
|
|
6764
7757
|
exports.MessageActions = MessageActions;
|
|
@@ -6772,19 +7765,28 @@ exports.PoolseTheme = PoolseTheme;
|
|
|
6772
7765
|
exports.PresenceBadge = PresenceBadge;
|
|
6773
7766
|
exports.ReactionPicker = ReactionPicker;
|
|
6774
7767
|
exports.ReactionStrip = ReactionStrip;
|
|
7768
|
+
exports.RecordingBanner = RecordingBanner;
|
|
7769
|
+
exports.RecordingIndicator = RecordingIndicator;
|
|
7770
|
+
exports.RecordingNoticeRow = RecordingNoticeRow;
|
|
6775
7771
|
exports.RoomJoinBar = RoomJoinBar;
|
|
6776
7772
|
exports.RoomStage = RoomStage;
|
|
7773
|
+
exports.SendStatus = SendStatus;
|
|
6777
7774
|
exports.ThreadSummary = ThreadSummary;
|
|
6778
7775
|
exports.ThreadView = ThreadView;
|
|
7776
|
+
exports.TranscriptViewer = TranscriptViewer;
|
|
6779
7777
|
exports.TypingIndicator = TypingIndicator;
|
|
6780
7778
|
exports.UploadQueueStrip = UploadQueueStrip;
|
|
6781
7779
|
exports.UserName = UserName;
|
|
6782
7780
|
exports.UserPickerSheet = UserPickerSheet;
|
|
7781
|
+
exports.draftsOf = draftsOf;
|
|
6783
7782
|
exports.formatRelativeTime = formatRelativeTime;
|
|
6784
7783
|
exports.loadEmojiData = loadEmojiData;
|
|
6785
7784
|
exports.localDraftStorage = localDraftStorage;
|
|
7785
|
+
exports.matchesAny = matchesAny;
|
|
7786
|
+
exports.matchesKey = matchesKey;
|
|
6786
7787
|
exports.presenceStateLabel = presenceStateLabel;
|
|
6787
7788
|
exports.presenceText = presenceText;
|
|
7789
|
+
exports.resolveKeymap = resolveKeymap;
|
|
6788
7790
|
exports.useDisplayName = useDisplayName;
|
|
6789
7791
|
exports.useEditHistory = useEditHistory;
|
|
6790
7792
|
exports.usePoolseFonts = usePoolseFonts;
|