@arbidocs/react 0.4.166 → 0.4.168
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/artifacts/index.cjs +15 -12
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.js +6 -3
- package/dist/artifacts/index.js.map +1 -1
- package/dist/calls/livekit/index.cjs +977 -0
- package/dist/calls/livekit/index.cjs.map +1 -0
- package/dist/calls/livekit/index.d.cts +280 -0
- package/dist/calls/livekit/index.d.ts +280 -0
- package/dist/calls/livekit/index.js +961 -0
- package/dist/calls/livekit/index.js.map +1 -0
- package/dist/{chunk-ON4PL6DQ.cjs → chunk-2M4B4FFA.cjs} +48 -4
- package/dist/chunk-2M4B4FFA.cjs.map +1 -0
- package/dist/chunk-3J7MEBOW.cjs +2551 -0
- package/dist/chunk-3J7MEBOW.cjs.map +1 -0
- package/dist/chunk-3NVSUYUV.js +528 -0
- package/dist/chunk-3NVSUYUV.js.map +1 -0
- package/dist/{chunk-QJHCVQ6C.js → chunk-3WIBD44F.js} +4734 -4673
- package/dist/chunk-3WIBD44F.js.map +1 -0
- package/dist/chunk-5B4PPJNW.cjs +1035 -0
- package/dist/chunk-5B4PPJNW.cjs.map +1 -0
- package/dist/chunk-5HDC43MF.js +145 -0
- package/dist/chunk-5HDC43MF.js.map +1 -0
- package/dist/{chunk-D66JCVBB.cjs → chunk-7NHOKV7N.cjs} +4093 -4040
- package/dist/chunk-7NHOKV7N.cjs.map +1 -0
- package/dist/chunk-APZZQZ6P.js +147 -0
- package/dist/chunk-APZZQZ6P.js.map +1 -0
- package/dist/{chunk-I5ZBQ63Y.js → chunk-DGMK3EUN.js} +188 -181
- package/dist/chunk-DGMK3EUN.js.map +1 -0
- package/dist/chunk-DPYBZDJB.js +18 -0
- package/dist/chunk-DPYBZDJB.js.map +1 -0
- package/dist/chunk-EEIYXVM4.cjs +181 -0
- package/dist/chunk-EEIYXVM4.cjs.map +1 -0
- package/dist/chunk-H3LMKO3T.js +2362 -0
- package/dist/chunk-H3LMKO3T.js.map +1 -0
- package/dist/{chunk-JSSKEXRR.js → chunk-KGCGA452.js} +2 -2
- package/dist/chunk-KGCGA452.js.map +1 -0
- package/dist/chunk-MJNZLWJD.js +986 -0
- package/dist/chunk-MJNZLWJD.js.map +1 -0
- package/dist/chunk-N73IMVFF.cjs +21 -0
- package/dist/chunk-N73IMVFF.cjs.map +1 -0
- package/dist/chunk-NVAIVJID.js +298 -0
- package/dist/chunk-NVAIVJID.js.map +1 -0
- package/dist/{chunk-GTJ667CP.cjs → chunk-QQ7SCJRY.cjs} +2 -2
- package/dist/chunk-QQ7SCJRY.cjs.map +1 -0
- package/dist/chunk-S4PCA3ES.cjs +572 -0
- package/dist/chunk-S4PCA3ES.cjs.map +1 -0
- package/dist/chunk-VAMPYLQ4.cjs +157 -0
- package/dist/chunk-VAMPYLQ4.cjs.map +1 -0
- package/dist/chunk-VLK52VXC.cjs +307 -0
- package/dist/chunk-VLK52VXC.cjs.map +1 -0
- package/dist/{chunk-SVHGCX25.js → chunk-YWYCEEBF.js} +43 -4
- package/dist/chunk-YWYCEEBF.js.map +1 -0
- package/dist/{chunk-EUC2BTNS.cjs → chunk-ZI2VJOID.cjs} +206 -199
- package/dist/chunk-ZI2VJOID.cjs.map +1 -0
- package/dist/document-tools/index.cjs +85 -109
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +19 -5
- package/dist/document-tools/index.d.ts +19 -5
- package/dist/document-tools/index.js +28 -70
- package/dist/document-tools/index.js.map +1 -1
- package/dist/index.cjs +12692 -9494
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-DfCFKora.d.cts → index.d-Bvp6rKNo.d.cts} +139 -1
- package/dist/{index.d-DfCFKora.d.ts → index.d-Bvp6rKNo.d.ts} +139 -1
- package/dist/{index.d-DCjYj7YK.d.ts → index.d-Dx9sGkW2.d.cts} +20 -8
- package/dist/{index.d-DCjYj7YK.d.cts → index.d-Dx9sGkW2.d.ts} +20 -8
- package/dist/index.d.cts +5465 -2291
- package/dist/index.d.ts +5465 -2291
- package/dist/index.js +11047 -8858
- package/dist/index.js.map +1 -1
- package/dist/query-keys.d-Kw0JMoff.d.cts +308 -0
- package/dist/query-keys.d-Kw0JMoff.d.ts +308 -0
- package/dist/shell/index.cjs +78 -21
- package/dist/shell/index.d.cts +1 -1
- package/dist/shell/index.d.ts +1 -1
- package/dist/shell/index.js +6 -1
- package/dist/ui/index.cjs +200 -195
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +4 -3
- package/dist/useAudioRecorder.d-CWFDsb_S.d.cts +778 -0
- package/dist/useAudioRecorder.d-CWFDsb_S.d.ts +778 -0
- package/dist/viewers/index.cjs +2 -2
- package/dist/viewers/index.js +1 -1
- package/package.json +13 -3
- package/dist/chunk-6MTKKT2O.cjs +0 -999
- package/dist/chunk-6MTKKT2O.cjs.map +0 -1
- package/dist/chunk-CEZCFQ47.js +0 -932
- package/dist/chunk-CEZCFQ47.js.map +0 -1
- package/dist/chunk-D66JCVBB.cjs.map +0 -1
- package/dist/chunk-EUC2BTNS.cjs.map +0 -1
- package/dist/chunk-GTJ667CP.cjs.map +0 -1
- package/dist/chunk-I5ZBQ63Y.js.map +0 -1
- package/dist/chunk-JSSKEXRR.js.map +0 -1
- package/dist/chunk-ON4PL6DQ.cjs.map +0 -1
- package/dist/chunk-QJHCVQ6C.js.map +0 -1
- package/dist/chunk-SVHGCX25.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { cn } from './chunk-SN5YV6FF.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var Avatar = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
8
|
+
AvatarPrimitive.Root,
|
|
9
|
+
{
|
|
10
|
+
ref,
|
|
11
|
+
className: cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className),
|
|
12
|
+
...props
|
|
13
|
+
}
|
|
14
|
+
));
|
|
15
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
16
|
+
var AvatarImage = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17
|
+
AvatarPrimitive.Image,
|
|
18
|
+
{
|
|
19
|
+
ref,
|
|
20
|
+
className: cn("aspect-square h-full w-full object-cover", className),
|
|
21
|
+
...props
|
|
22
|
+
}
|
|
23
|
+
));
|
|
24
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
25
|
+
var AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
26
|
+
AvatarPrimitive.Fallback,
|
|
27
|
+
{
|
|
28
|
+
ref,
|
|
29
|
+
className: cn(
|
|
30
|
+
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
|
31
|
+
className
|
|
32
|
+
),
|
|
33
|
+
...props
|
|
34
|
+
}
|
|
35
|
+
));
|
|
36
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
37
|
+
function isAgent(user) {
|
|
38
|
+
return user.external_id.startsWith("agt-");
|
|
39
|
+
}
|
|
40
|
+
function getUserAvatarColor(userId) {
|
|
41
|
+
let fifthChar = "0";
|
|
42
|
+
if (userId && userId.length >= 5) {
|
|
43
|
+
fifthChar = userId.charAt(4);
|
|
44
|
+
}
|
|
45
|
+
const colorMap = {
|
|
46
|
+
"0": "bg-emerald-700",
|
|
47
|
+
"1": "bg-blue-700",
|
|
48
|
+
"2": "bg-violet-700",
|
|
49
|
+
"3": "bg-rose-700",
|
|
50
|
+
"4": "bg-amber-700",
|
|
51
|
+
"5": "bg-lime-700",
|
|
52
|
+
"6": "bg-purple-700",
|
|
53
|
+
"7": "bg-cyan-700",
|
|
54
|
+
"8": "bg-orange-700",
|
|
55
|
+
"9": "bg-teal-700",
|
|
56
|
+
a: "bg-red-700",
|
|
57
|
+
b: "bg-indigo-700",
|
|
58
|
+
c: "bg-pink-700",
|
|
59
|
+
d: "bg-green-700",
|
|
60
|
+
e: "bg-yellow-700",
|
|
61
|
+
f: "bg-sky-700"
|
|
62
|
+
};
|
|
63
|
+
return colorMap[fifthChar] || "bg-emerald-700";
|
|
64
|
+
}
|
|
65
|
+
function getUserInitials(user) {
|
|
66
|
+
const first = user.given_name[0] ?? "";
|
|
67
|
+
const last = user.family_name?.[0] ?? "";
|
|
68
|
+
return (first + last).toUpperCase();
|
|
69
|
+
}
|
|
70
|
+
function getUserDisplayName(user) {
|
|
71
|
+
return user.family_name ? `${user.given_name} ${user.family_name}` : user.given_name;
|
|
72
|
+
}
|
|
73
|
+
function createUserAvatarIcon(user) {
|
|
74
|
+
const initials = getUserInitials(user);
|
|
75
|
+
const colorClass = getUserAvatarColor(user.external_id);
|
|
76
|
+
return React__default.createElement(
|
|
77
|
+
Avatar,
|
|
78
|
+
{ className: "h-5 w-5 border border-white" },
|
|
79
|
+
user.picture && React__default.createElement(AvatarImage, { src: user.picture, alt: initials }),
|
|
80
|
+
React__default.createElement(
|
|
81
|
+
AvatarFallback,
|
|
82
|
+
{ className: `text-[9px] text-white font-semibold ${colorClass}` },
|
|
83
|
+
initials
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/documents/audio-segmenter.ts
|
|
89
|
+
var DEFAULT_SEGMENTER_CONFIG = {
|
|
90
|
+
voiceThreshold: 0.3,
|
|
91
|
+
silenceMs: 700,
|
|
92
|
+
maxMs: 1e4,
|
|
93
|
+
minVoiceMs: 600
|
|
94
|
+
};
|
|
95
|
+
var INITIAL_SEGMENTER_STATE = { phase: "idle" };
|
|
96
|
+
function levelFromRms(rms) {
|
|
97
|
+
return Math.sqrt(Math.min(1, rms * 8));
|
|
98
|
+
}
|
|
99
|
+
function end(state, at, reason, config) {
|
|
100
|
+
return {
|
|
101
|
+
type: "end",
|
|
102
|
+
at,
|
|
103
|
+
startedAt: state.startedAt,
|
|
104
|
+
voiceMs: state.voiceMs,
|
|
105
|
+
keep: state.voiceMs >= config.minVoiceMs,
|
|
106
|
+
reason
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function stepSegmenter(state, level, t, config = DEFAULT_SEGMENTER_CONFIG) {
|
|
110
|
+
const voice = level >= config.voiceThreshold;
|
|
111
|
+
if (state.phase === "idle") {
|
|
112
|
+
if (!voice) return { state, events: [] };
|
|
113
|
+
return {
|
|
114
|
+
state: { phase: "voice", startedAt: t, lastVoiceAt: t, lastSampleAt: t, voiceMs: 0 },
|
|
115
|
+
events: [{ type: "start", at: t }]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const dt = Math.max(0, t - state.lastSampleAt);
|
|
119
|
+
const next = {
|
|
120
|
+
...state,
|
|
121
|
+
lastSampleAt: t,
|
|
122
|
+
lastVoiceAt: voice ? t : state.lastVoiceAt,
|
|
123
|
+
voiceMs: state.voiceMs + (voice ? dt : 0)
|
|
124
|
+
};
|
|
125
|
+
if (t - next.startedAt >= config.maxMs) {
|
|
126
|
+
const events = [end(next, t, "max", config)];
|
|
127
|
+
if (!voice) return { state: { phase: "idle" }, events };
|
|
128
|
+
events.push({ type: "start", at: t });
|
|
129
|
+
return {
|
|
130
|
+
state: { phase: "voice", startedAt: t, lastVoiceAt: t, lastSampleAt: t, voiceMs: 0 },
|
|
131
|
+
events
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const silence = config.silenceMs + (next.voiceMs < config.minVoiceMs ? config.holdShortMs ?? 0 : 0);
|
|
135
|
+
if (!voice && t - next.lastVoiceAt >= silence) {
|
|
136
|
+
return { state: { phase: "idle" }, events: [end(next, t, "silence", config)] };
|
|
137
|
+
}
|
|
138
|
+
return { state: next, events: [] };
|
|
139
|
+
}
|
|
140
|
+
function flushSegmenter(state, t, config = DEFAULT_SEGMENTER_CONFIG) {
|
|
141
|
+
if (state.phase === "idle") return { state, events: [] };
|
|
142
|
+
return { state: { phase: "idle" }, events: [end(state, t, "flush", config)] };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export { Avatar, AvatarFallback, AvatarImage, DEFAULT_SEGMENTER_CONFIG, INITIAL_SEGMENTER_STATE, createUserAvatarIcon, flushSegmenter, getUserAvatarColor, getUserDisplayName, getUserInitials, isAgent, levelFromRms, stepSegmenter };
|
|
146
|
+
//# sourceMappingURL=chunk-APZZQZ6P.js.map
|
|
147
|
+
//# sourceMappingURL=chunk-APZZQZ6P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/avatar.tsx","../src/users/user-display.ts","../src/documents/audio-segmenter.ts"],"names":["React"],"mappings":";;;;;;AAKA,IAAM,MAAA,GAAe,iBAGnB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAA,qBAC1B,GAAA;AAAA,EAAiB,eAAA,CAAA,IAAA;AAAA,EAAhB;AAAA,IACC,GAAA;AAAA,IACA,SAAA,EAAW,EAAA,CAAG,+DAAA,EAAiE,SAAS,CAAA;AAAA,IACvF,GAAG;AAAA;AACN,CACD;AACD,MAAA,CAAO,cAA8B,eAAA,CAAA,IAAA,CAAK,WAAA;AAE1C,IAAM,WAAA,GAAoB,iBAGxB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAA,qBAC1B,GAAA;AAAA,EAAiB,eAAA,CAAA,KAAA;AAAA,EAAhB;AAAA,IACC,GAAA;AAAA,IACA,SAAA,EAAW,EAAA,CAAG,0CAAA,EAA4C,SAAS,CAAA;AAAA,IAClE,GAAG;AAAA;AACN,CACD;AACD,WAAA,CAAY,cAA8B,eAAA,CAAA,KAAA,CAAM,WAAA;AAEhD,IAAM,cAAA,GAAuB,iBAG3B,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAA,qBAC1B,GAAA;AAAA,EAAiB,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esContent":["import * as React from 'react'\nimport * as AvatarPrimitive from '@radix-ui/react-avatar'\n\nimport { cn } from '../lib/utils'\n\nconst Avatar = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Root\n ref={ref}\n className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}\n {...props}\n />\n))\nAvatar.displayName = AvatarPrimitive.Root.displayName\n\nconst AvatarImage = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Image>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Image\n ref={ref}\n className={cn('aspect-square h-full w-full object-cover', className)}\n {...props}\n />\n))\nAvatarImage.displayName = AvatarPrimitive.Image.displayName\n\nconst AvatarFallback = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Fallback>,\n React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Fallback\n ref={ref}\n className={cn(\n 'flex h-full w-full items-center justify-center rounded-full bg-muted',\n className\n )}\n {...props}\n />\n))\nAvatarFallback.displayName = AvatarPrimitive.Fallback.displayName\n\nexport { Avatar, AvatarImage, AvatarFallback }\n","/**\n * User Utilities\n *\n * A person's display name, avatar colour and initials, the same in every surface.\n * Uses deterministic color mapping based on user ID (5th character of ID).\n *\n * NOTE: given_name and family_name are required fields.\n */\n\nimport { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'\nimport React from 'react'\n\n/**\n * Check if a user is an agent (external_id starts with 'agt-')\n */\nexport function isAgent(user: { external_id: string }): boolean {\n return user.external_id.startsWith('agt-')\n}\n\n/**\n * Generate consistent avatar color based on user ID\n * Uses same pattern as workspace colors - extracts 5th character for deterministic mapping\n */\nexport function getUserAvatarColor(userId: string): string {\n // Extract 5th character (index 4) for color mapping\n let fifthChar = '0' // default fallback\n\n if (userId && userId.length >= 5) {\n fifthChar = userId.charAt(4)\n }\n\n // Map to solid, vibrant avatar colors (700 weight: white initials pass WCAG AA 4.5:1 on every colour)\n const colorMap: Record<string, string> = {\n '0': 'bg-emerald-700',\n '1': 'bg-blue-700',\n '2': 'bg-violet-700',\n '3': 'bg-rose-700',\n '4': 'bg-amber-700',\n '5': 'bg-lime-700',\n '6': 'bg-purple-700',\n '7': 'bg-cyan-700',\n '8': 'bg-orange-700',\n '9': 'bg-teal-700',\n a: 'bg-red-700',\n b: 'bg-indigo-700',\n c: 'bg-pink-700',\n d: 'bg-green-700',\n e: 'bg-yellow-700',\n f: 'bg-sky-700',\n }\n\n return colorMap[fifthChar] || 'bg-emerald-700'\n}\n\n/**\n * Get user initials from given_name and family_name (both required)\n * Returns first letter of each name, e.g. \"John Doe\" -> \"JD\"\n */\nexport function getUserInitials(user: { given_name: string; family_name?: string | null }): string {\n const first = user.given_name[0] ?? ''\n const last = user.family_name?.[0] ?? ''\n return (first + last).toUpperCase()\n}\n\n/**\n * Get user display name from given_name and family_name (both required)\n * Returns full name, e.g. \"John Doe\"\n */\nexport function getUserDisplayName(user: {\n given_name: string\n family_name?: string | null\n}): string {\n return user.family_name ? `${user.given_name} ${user.family_name}` : user.given_name\n}\n\n/**\n * Create a user avatar icon element for use in toast notifications.\n * This is a simple React element (not a component with hooks) so it can be\n * used outside of React component context (e.g., in WebSocket handlers).\n */\nexport function createUserAvatarIcon(user: {\n external_id: string\n given_name: string\n family_name?: string | null\n picture?: string | null\n}): React.ReactElement {\n const initials = getUserInitials(user)\n const colorClass = getUserAvatarColor(user.external_id)\n\n return React.createElement(\n Avatar,\n { className: 'h-5 w-5 border border-white' },\n user.picture && React.createElement(AvatarImage, { src: user.picture, alt: initials }),\n React.createElement(\n AvatarFallback,\n { className: `text-[9px] text-white font-semibold ${colorClass}` },\n initials\n )\n )\n}\n","/**\n * audio-segmenter — the voice-activity state machine behind `useAudioRecorder`'s\n * segmenting mode. Pure: fed one (level, time) sample per meter tick, it says\n * when a speech segment starts and when it ends, and whether the segment held\n * enough voice to be worth keeping. The hook owns the MediaRecorders; this\n * owns only the decisions, so it is unit-testable with synthetic levels.\n *\n * A segment starts on the first sample at or above `voiceThreshold`, ends after\n * `silenceMs` without voice or at `maxMs` (a cut while still speaking starts the\n * next segment on the same sample), and is dropped when it held less than\n * `minVoiceMs` of voice — a cough, a click, a door.\n */\n\nexport interface SegmenterConfig {\n /** Meter level (0-1, as `useAudioRecorder` reports it) that counts as voice. */\n voiceThreshold: number\n /** Silence that ends a segment. */\n silenceMs: number\n /** Longest segment; a longer utterance is cut into several. */\n maxMs: number\n /** Segments with less voice than this are dropped. */\n minVoiceMs: number\n /**\n * Extra silence a segment that is still too short waits for more voice before it ends (0 = none).\n * A short word and a short phrase a pause apart — \"Perfect.\" … \"Thank you both.\" — then make one\n * segment instead of two dropped ones.\n */\n holdShortMs?: number\n}\n\nexport const DEFAULT_SEGMENTER_CONFIG: SegmenterConfig = {\n voiceThreshold: 0.3,\n silenceMs: 700,\n maxMs: 10_000,\n minVoiceMs: 600,\n}\n\nexport type SegmenterState =\n | { phase: 'idle' }\n | {\n phase: 'voice'\n /** When the segment started (the clock of the samples). */\n startedAt: number\n /** The last sample that carried voice. */\n lastVoiceAt: number\n /** The previous sample, to integrate voice time between samples. */\n lastSampleAt: number\n /** Voice accumulated so far. */\n voiceMs: number\n }\n\nexport type SegmenterEvent =\n | { type: 'start'; at: number }\n | {\n type: 'end'\n at: number\n startedAt: number\n voiceMs: number\n /** False when the segment held too little voice: discard it. */\n keep: boolean\n reason: 'silence' | 'max' | 'flush'\n }\n\nexport const INITIAL_SEGMENTER_STATE: SegmenterState = { phase: 'idle' }\n\n/**\n * The meter level (0-1) of an RMS amplitude, as the segmenter's thresholds expect it. Normal\n * speech RMS is tiny (a laptop mic at conversational distance rarely exceeds ~0.1), so it is\n * boosted, then a sqrt (perceptual) curve makes quiet-to-moderate speech clearly visible.\n */\nexport function levelFromRms(rms: number): number {\n return Math.sqrt(Math.min(1, rms * 8))\n}\n\nfunction end(\n state: Extract<SegmenterState, { phase: 'voice' }>,\n at: number,\n reason: 'silence' | 'max' | 'flush',\n config: SegmenterConfig\n): SegmenterEvent {\n return {\n type: 'end',\n at,\n startedAt: state.startedAt,\n voiceMs: state.voiceMs,\n keep: state.voiceMs >= config.minVoiceMs,\n reason,\n }\n}\n\n/** Feed one meter sample. Returns the next state and what happened (0-2 events). */\nexport function stepSegmenter(\n state: SegmenterState,\n level: number,\n t: number,\n config: SegmenterConfig = DEFAULT_SEGMENTER_CONFIG\n): { state: SegmenterState; events: SegmenterEvent[] } {\n const voice = level >= config.voiceThreshold\n if (state.phase === 'idle') {\n if (!voice) return { state, events: [] }\n return {\n state: { phase: 'voice', startedAt: t, lastVoiceAt: t, lastSampleAt: t, voiceMs: 0 },\n events: [{ type: 'start', at: t }],\n }\n }\n const dt = Math.max(0, t - state.lastSampleAt)\n const next = {\n ...state,\n lastSampleAt: t,\n lastVoiceAt: voice ? t : state.lastVoiceAt,\n voiceMs: state.voiceMs + (voice ? dt : 0),\n }\n if (t - next.startedAt >= config.maxMs) {\n const events: SegmenterEvent[] = [end(next, t, 'max', config)]\n if (!voice) return { state: { phase: 'idle' }, events }\n events.push({ type: 'start', at: t })\n return {\n state: { phase: 'voice', startedAt: t, lastVoiceAt: t, lastSampleAt: t, voiceMs: 0 },\n events,\n }\n }\n const silence =\n config.silenceMs + (next.voiceMs < config.minVoiceMs ? (config.holdShortMs ?? 0) : 0)\n if (!voice && t - next.lastVoiceAt >= silence) {\n return { state: { phase: 'idle' }, events: [end(next, t, 'silence', config)] }\n }\n return { state: next, events: [] }\n}\n\n/** Close the open segment, if any (recording stopped). */\nexport function flushSegmenter(\n state: SegmenterState,\n t: number,\n config: SegmenterConfig = DEFAULT_SEGMENTER_CONFIG\n): { state: SegmenterState; events: SegmenterEvent[] } {\n if (state.phase === 'idle') return { state, events: [] }\n return { state: { phase: 'idle' }, events: [end(state, t, 'flush', config)] }\n}\n"]}
|
|
@@ -1,43 +1,16 @@
|
|
|
1
|
+
import { useNotify, selectUnread, DEFAULT_NOTIFY_TONE } from './chunk-5HDC43MF.js';
|
|
2
|
+
import { mergeHostConfig, OWN_SESSION_SLOT } from './chunk-DPYBZDJB.js';
|
|
3
|
+
import { parseVersionRef } from './chunk-NNWMHMEC.js';
|
|
1
4
|
import { ScrollArea } from './chunk-W4H6XAIU.js';
|
|
2
5
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from './chunk-47CCGUWR.js';
|
|
3
6
|
import { cn } from './chunk-SN5YV6FF.js';
|
|
4
7
|
import { ArbiHostContext } from './chunk-CPZ36AQS.js';
|
|
5
|
-
import { useContext, useState, useMemo } from 'react';
|
|
6
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
8
|
import { createStore } from 'zustand/vanilla';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { create } from 'zustand';
|
|
9
|
+
import { Toaster as Toaster$1 } from 'sonner';
|
|
10
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
11
|
+
import { useState, useContext, useMemo, useRef, useEffect, useSyncExternalStore } from 'react';
|
|
12
12
|
import { Bell, CheckCheck, BellOff, X, Info, AlertTriangle, XCircle, CheckCircle2 } from 'lucide-react';
|
|
13
13
|
|
|
14
|
-
// src/host/merge.ts
|
|
15
|
-
var MERGED = /* @__PURE__ */ new Set(["environment"]);
|
|
16
|
-
var OWN_SESSION_SLOT = "__ownSession";
|
|
17
|
-
function defined(record) {
|
|
18
|
-
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
|
|
19
|
-
}
|
|
20
|
-
function mergeHostConfig(parent, config2) {
|
|
21
|
-
const next = { ...parent };
|
|
22
|
-
for (const [key, value] of Object.entries(defined(config2))) {
|
|
23
|
-
if (key === "connection") continue;
|
|
24
|
-
next[key] = MERGED.has(key) && value && typeof value === "object" ? { ...parent[key], ...defined(value) } : value;
|
|
25
|
-
}
|
|
26
|
-
return next;
|
|
27
|
-
}
|
|
28
|
-
function ArbiHost({
|
|
29
|
-
config: config2,
|
|
30
|
-
children
|
|
31
|
-
}) {
|
|
32
|
-
const parent = useContext(ArbiHostContext);
|
|
33
|
-
const [ownSession] = useState(() => ({ current: null }));
|
|
34
|
-
const value = useMemo(() => {
|
|
35
|
-
const merged = mergeHostConfig(parent, config2);
|
|
36
|
-
return merged[OWN_SESSION_SLOT] ? merged : { ...merged, [OWN_SESSION_SLOT]: ownSession };
|
|
37
|
-
}, [parent, config2, ownSession]);
|
|
38
|
-
const Connection = config2.connection?.Provider;
|
|
39
|
-
return /* @__PURE__ */ jsx(ArbiHostContext.Provider, { value, children: Connection ? /* @__PURE__ */ jsx(Connection, { children }) : children });
|
|
40
|
-
}
|
|
41
14
|
var EMPTY = {
|
|
42
15
|
query: "",
|
|
43
16
|
results: [],
|
|
@@ -86,141 +59,24 @@ function persistSearchSession(key, storage = globalThis.localStorage, session =
|
|
|
86
59
|
}
|
|
87
60
|
});
|
|
88
61
|
}
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
var useNotify = create((set) => ({
|
|
97
|
-
notifications: [],
|
|
98
|
-
muted: false,
|
|
99
|
-
setMuted: (muted) => set({ muted }),
|
|
100
|
-
markRead: (id) => set((s) => ({
|
|
101
|
-
notifications: s.notifications.map((n) => n.id === id ? { ...n, read: true } : n)
|
|
102
|
-
})),
|
|
103
|
-
markAllRead: () => set((s) => ({ notifications: s.notifications.map((n) => ({ ...n, read: true })) })),
|
|
104
|
-
removeNotification: (id) => set((s) => ({ notifications: s.notifications.filter((n) => n.id !== id) })),
|
|
105
|
-
removeNotifications: (ids) => {
|
|
106
|
-
const drop = new Set(ids);
|
|
107
|
-
set((s) => ({ notifications: s.notifications.filter((n) => !drop.has(n.id)) }));
|
|
108
|
-
},
|
|
109
|
-
clearNotifications: () => set({ notifications: [] }),
|
|
110
|
-
seed: (items) => set({ notifications: items }),
|
|
111
|
-
record: (note) => set((s) => ({ notifications: capSession([note, ...s.notifications]) })),
|
|
112
|
-
syncSource: (source, items) => set((s) => ({
|
|
113
|
-
notifications: [
|
|
114
|
-
...items.map((n) => ({ ...n, source })),
|
|
115
|
-
...s.notifications.filter((n) => n.source !== source)
|
|
116
|
-
].sort((a, b) => b.ts - a.ts)
|
|
117
|
-
}))
|
|
118
|
-
}));
|
|
119
|
-
var config = {};
|
|
120
|
-
function configureNotify(next) {
|
|
121
|
-
config = { ...config, ...next };
|
|
122
|
-
}
|
|
123
|
-
function richMarkup(title) {
|
|
124
|
-
try {
|
|
125
|
-
return renderToStaticMarkup(title);
|
|
126
|
-
} catch {
|
|
127
|
-
return void 0;
|
|
62
|
+
var DEFAULT_TOAST_OPTIONS = {
|
|
63
|
+
classNames: {
|
|
64
|
+
toast: "group toast group-[.toaster]:bg-card group-[.toaster]:text-foreground group-[.toaster]:border group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:rounded-lg",
|
|
65
|
+
description: "group-[.toast]:text-muted-foreground",
|
|
66
|
+
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
|
67
|
+
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"
|
|
128
68
|
}
|
|
129
|
-
}
|
|
130
|
-
var textOf = (html) => (html ?? "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
131
|
-
function make(variant) {
|
|
132
|
-
return (title, opts = {}) => {
|
|
133
|
-
const { workspaceId } = opts;
|
|
134
|
-
const ambient = opts.ambient ?? config.ambient ?? false;
|
|
135
|
-
if (opts.toast !== false && !useNotify.getState().muted) {
|
|
136
|
-
toast[variant](title, {
|
|
137
|
-
description: opts.description,
|
|
138
|
-
duration: opts.duration,
|
|
139
|
-
action: opts.action,
|
|
140
|
-
icon: opts.icon ?? (workspaceId ? config.workspaceIcon?.(workspaceId) : void 0),
|
|
141
|
-
className: opts.className
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
const id = uid();
|
|
145
|
-
if (opts.record !== false) {
|
|
146
|
-
const html = opts.html ?? (typeof title === "string" || title == null ? void 0 : richMarkup(title));
|
|
147
|
-
useNotify.getState().record({
|
|
148
|
-
id,
|
|
149
|
-
// A rich toast still needs a READABLE title — "Passage copied: gamma-services p.1",
|
|
150
|
-
// not "Notification" — so it comes from the rendered markup, tags stripped.
|
|
151
|
-
title: opts.recordTitle ?? (typeof title === "string" ? title : textOf(html) || "Notification"),
|
|
152
|
-
description: typeof opts.description === "string" ? opts.description : void 0,
|
|
153
|
-
variant,
|
|
154
|
-
ts: Date.now(),
|
|
155
|
-
// Ambient activity is a log line, not a claim on attention: it never wears an unread dot.
|
|
156
|
-
read: ambient,
|
|
157
|
-
// Clicking the entry goes where the notification points: its action (when it has one),
|
|
158
|
-
// an explicit link, or the workspace it happened in.
|
|
159
|
-
href: opts.href ?? (workspaceId ? config.workspaceHref?.(workspaceId) : void 0),
|
|
160
|
-
onSelect: opts.action?.onClick,
|
|
161
|
-
actionLabel: opts.action ? String(opts.action.label) : void 0,
|
|
162
|
-
workspaceId,
|
|
163
|
-
html,
|
|
164
|
-
ambient
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
return id;
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
var notify = {
|
|
171
|
-
success: make("success"),
|
|
172
|
-
error: make("error"),
|
|
173
|
-
info: make("info"),
|
|
174
|
-
warning: make("warning")
|
|
175
69
|
};
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const saved2 = JSON.parse(storage.getItem(key) ?? "null");
|
|
184
|
-
if (saved2) {
|
|
185
|
-
const known = new Set(useNotify.getState().notifications.map((n) => n.id));
|
|
186
|
-
useNotify.setState((s) => ({
|
|
187
|
-
muted: saved2.muted ?? s.muted,
|
|
188
|
-
notifications: capSession(
|
|
189
|
-
[
|
|
190
|
-
...s.notifications,
|
|
191
|
-
...(saved2.notifications ?? []).filter((n) => !n.source && !known.has(n.id))
|
|
192
|
-
].sort((a, b) => b.ts - a.ts)
|
|
193
|
-
)
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
} catch {
|
|
197
|
-
}
|
|
198
|
-
let saved = [];
|
|
199
|
-
let savedMuted;
|
|
200
|
-
return useNotify.subscribe((s) => {
|
|
201
|
-
const session = s.notifications.filter((n) => !n.source);
|
|
202
|
-
if (s.muted === savedMuted && session.length === saved.length && session.every((n, i) => n === saved[i]))
|
|
203
|
-
return;
|
|
204
|
-
saved = session;
|
|
205
|
-
savedMuted = s.muted;
|
|
206
|
-
const notifications = session.map((n) => ({
|
|
207
|
-
...n,
|
|
208
|
-
onSelect: void 0,
|
|
209
|
-
actionLabel: void 0
|
|
210
|
-
}));
|
|
211
|
-
try {
|
|
212
|
-
storage.setItem(key, JSON.stringify({ muted: s.muted, notifications }));
|
|
213
|
-
} catch {
|
|
70
|
+
function Toaster({ toastOptions, ...props }) {
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
Toaster$1,
|
|
73
|
+
{
|
|
74
|
+
className: "toaster group",
|
|
75
|
+
toastOptions: toastOptions ?? DEFAULT_TOAST_OPTIONS,
|
|
76
|
+
...props
|
|
214
77
|
}
|
|
215
|
-
|
|
78
|
+
);
|
|
216
79
|
}
|
|
217
|
-
var selectUnread = (s) => s.notifications.filter((n) => !n.read && !n.ambient).length;
|
|
218
|
-
var DEFAULT_NOTIFY_TONE = {
|
|
219
|
-
success: "text-green-600",
|
|
220
|
-
error: "text-destructive",
|
|
221
|
-
warning: "text-amber-500",
|
|
222
|
-
info: "text-blue-500"
|
|
223
|
-
};
|
|
224
80
|
|
|
225
81
|
// src/lib/format-relative-time.ts
|
|
226
82
|
var FORMATTERS = /* @__PURE__ */ new Map();
|
|
@@ -423,25 +279,176 @@ function NotificationBell({
|
|
|
423
279
|
)
|
|
424
280
|
] });
|
|
425
281
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
282
|
+
function ArbiHost({
|
|
283
|
+
config,
|
|
284
|
+
children
|
|
285
|
+
}) {
|
|
286
|
+
const parent = useContext(ArbiHostContext);
|
|
287
|
+
const [ownSession] = useState(() => ({ current: null }));
|
|
288
|
+
const value = useMemo(() => {
|
|
289
|
+
const merged = mergeHostConfig(parent, config);
|
|
290
|
+
return merged[OWN_SESSION_SLOT] ? merged : { ...merged, [OWN_SESSION_SLOT]: ownSession };
|
|
291
|
+
}, [parent, config, ownSession]);
|
|
292
|
+
const Connection = config.connection?.Provider;
|
|
293
|
+
return /* @__PURE__ */ jsx(ArbiHostContext.Provider, { value, children: Connection ? /* @__PURE__ */ jsx(Connection, { children }) : children });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/chat/mentions.ts
|
|
297
|
+
var MAX_QUERY_LENGTH = 40;
|
|
298
|
+
function findMentionQuery(text, caret) {
|
|
299
|
+
const before = text.slice(0, caret);
|
|
300
|
+
const at = before.lastIndexOf("@");
|
|
301
|
+
if (at < 0) return null;
|
|
302
|
+
if (at > 0 && !/\s/.test(before[at - 1])) return null;
|
|
303
|
+
const query = before.slice(at + 1);
|
|
304
|
+
if (query.length > MAX_QUERY_LENGTH || query.includes("\n") || query.startsWith(" ")) return null;
|
|
305
|
+
return { start: at, query };
|
|
306
|
+
}
|
|
307
|
+
function filterMentionCandidates(candidates, query) {
|
|
308
|
+
const q = query.trim().toLowerCase();
|
|
309
|
+
if (!q) return candidates.slice();
|
|
310
|
+
const scored = [];
|
|
311
|
+
for (const c of candidates) {
|
|
312
|
+
const label = c.label.toLowerCase();
|
|
313
|
+
if (label.startsWith(q)) scored.push({ c, score: 0 });
|
|
314
|
+
else if (label.split(/\s+/).some((word) => word.startsWith(q))) scored.push({ c, score: 1 });
|
|
315
|
+
else if (c.description?.toLowerCase().startsWith(q)) scored.push({ c, score: 2 });
|
|
432
316
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
317
|
+
return scored.sort((a, b) => a.score - b.score).map((s) => s.c);
|
|
318
|
+
}
|
|
319
|
+
function insertMention(text, start, caret, label) {
|
|
320
|
+
const inserted = `@${label} `;
|
|
321
|
+
return {
|
|
322
|
+
text: text.slice(0, start) + inserted + text.slice(caret),
|
|
323
|
+
caret: start + inserted.length
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function tokenRanges(text, label) {
|
|
327
|
+
const needle = `@${label}`;
|
|
328
|
+
const ranges = [];
|
|
329
|
+
let from = 0;
|
|
330
|
+
for (; ; ) {
|
|
331
|
+
const i = text.indexOf(needle, from);
|
|
332
|
+
if (i < 0) break;
|
|
333
|
+
const end = i + needle.length;
|
|
334
|
+
const startsToken = i === 0 || /\s|\(|\[/.test(text[i - 1]);
|
|
335
|
+
const endsToken = end === text.length || !/[\p{L}\p{N}_]/u.test(text[end]);
|
|
336
|
+
if (startsToken && endsToken) ranges.push([i, end]);
|
|
337
|
+
from = end;
|
|
338
|
+
}
|
|
339
|
+
return ranges;
|
|
340
|
+
}
|
|
341
|
+
function extractMentions(text, candidates) {
|
|
342
|
+
const taken = [];
|
|
343
|
+
const found = [];
|
|
344
|
+
const byLength = [...candidates].sort((a, b) => b.label.length - a.label.length);
|
|
345
|
+
for (const c of byLength) {
|
|
346
|
+
if (!c.label) continue;
|
|
347
|
+
for (const [from, to] of tokenRanges(text, c.label)) {
|
|
348
|
+
if (taken.some(([a, b]) => from < b && to > a)) continue;
|
|
349
|
+
taken.push([from, to]);
|
|
350
|
+
if (!found.some((f) => f.c.id === c.id)) found.push({ c, at: from });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return found.sort((a, b) => a.at - b.at).map((f) => f.c);
|
|
354
|
+
}
|
|
355
|
+
function toMessageMentions(mentioned) {
|
|
356
|
+
return mentioned.map(
|
|
357
|
+
(c) => c.kind === "assistant" ? { type: "assistant" } : { type: "user", user_ext_id: c.id }
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
var MENTION_HREF_PREFIX = "#mention-";
|
|
361
|
+
function escapeLinkText(label) {
|
|
362
|
+
return label.replace(/[[\]\\]/g, (ch) => `\\${ch}`);
|
|
363
|
+
}
|
|
364
|
+
function linkMentions(content, mentions, assistantLabels = []) {
|
|
365
|
+
if (!mentions || mentions.length === 0 || !content) return content;
|
|
366
|
+
const targets = [];
|
|
367
|
+
for (const m of mentions) {
|
|
368
|
+
const id = m.type === "assistant" ? "assistant" : m.user_ext_id;
|
|
369
|
+
if (!id) continue;
|
|
370
|
+
const labels = m.type === "assistant" ? [m.label ?? "", ...assistantLabels] : [m.label ?? ""];
|
|
371
|
+
for (const label of labels) if (label) targets.push({ label, id });
|
|
372
|
+
}
|
|
373
|
+
targets.sort((a, b) => b.label.length - a.label.length);
|
|
374
|
+
const replacements = [];
|
|
375
|
+
for (const { label, id } of targets) {
|
|
376
|
+
for (const [from, to] of tokenRanges(content, label)) {
|
|
377
|
+
if (replacements.some((r) => from < r.to && to > r.from)) continue;
|
|
378
|
+
replacements.push({
|
|
379
|
+
from,
|
|
380
|
+
to,
|
|
381
|
+
text: `[@${escapeLinkText(label)}](${MENTION_HREF_PREFIX}${id})`
|
|
382
|
+
});
|
|
441
383
|
}
|
|
384
|
+
}
|
|
385
|
+
replacements.sort((a, b) => b.from - a.from);
|
|
386
|
+
let out = content;
|
|
387
|
+
for (const r of replacements) out = out.slice(0, r.from) + r.text + out.slice(r.to);
|
|
388
|
+
return out;
|
|
389
|
+
}
|
|
390
|
+
function mentionFromHref(href) {
|
|
391
|
+
if (!href?.startsWith(MENTION_HREF_PREFIX)) return null;
|
|
392
|
+
const id = href.slice(MENTION_HREF_PREFIX.length);
|
|
393
|
+
if (!id) return null;
|
|
394
|
+
return { kind: id === "assistant" ? "assistant" : "user", id };
|
|
395
|
+
}
|
|
396
|
+
function hasMessageBody(value, recipientLabel = "ARBI") {
|
|
397
|
+
const text = value.trim();
|
|
398
|
+
return !!text && text.toLowerCase() !== `@${recipientLabel}`.toLowerCase();
|
|
399
|
+
}
|
|
400
|
+
function savedDocumentIdFor(input) {
|
|
401
|
+
const { documentId, isDraft, isStreaming, isBlobArtifact, documentData } = input;
|
|
402
|
+
if (!documentId || isDraft || isStreaming || isBlobArtifact) return null;
|
|
403
|
+
if (documentData?.wp_type !== "artifact" && !documentData?.file_name?.toLowerCase().endsWith(".docx"))
|
|
404
|
+
return null;
|
|
405
|
+
if (documentData.external_id !== documentId) return null;
|
|
406
|
+
return documentId;
|
|
407
|
+
}
|
|
408
|
+
var entries = [];
|
|
409
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
410
|
+
function subscribe(listener) {
|
|
411
|
+
listeners.add(listener);
|
|
412
|
+
return () => listeners.delete(listener);
|
|
413
|
+
}
|
|
414
|
+
function emit() {
|
|
415
|
+
listeners.forEach((l) => l());
|
|
416
|
+
}
|
|
417
|
+
var top = () => entries[entries.length - 1];
|
|
418
|
+
function useRegisterOpenDocument(registration) {
|
|
419
|
+
const latest = useRef(registration);
|
|
420
|
+
useEffect(() => {
|
|
421
|
+
latest.current = registration;
|
|
422
|
+
});
|
|
423
|
+
const { documentId } = registration;
|
|
424
|
+
useEffect(() => {
|
|
425
|
+
if (!documentId) return;
|
|
426
|
+
const entry = { documentId, current: () => latest.current };
|
|
427
|
+
entries = [...entries, entry];
|
|
428
|
+
emit();
|
|
429
|
+
return () => {
|
|
430
|
+
entries = entries.filter((e) => e !== entry);
|
|
431
|
+
emit();
|
|
432
|
+
};
|
|
433
|
+
}, [documentId]);
|
|
434
|
+
}
|
|
435
|
+
function useOpenDocumentId() {
|
|
436
|
+
return useSyncExternalStore(
|
|
437
|
+
subscribe,
|
|
438
|
+
() => top()?.documentId ?? null,
|
|
439
|
+
() => null
|
|
442
440
|
);
|
|
443
441
|
}
|
|
442
|
+
function takeOpenDocumentForTurn(options) {
|
|
443
|
+
const entry = top();
|
|
444
|
+
if (!entry) return null;
|
|
445
|
+
const { shownId, showLive, workspaceId } = entry.current();
|
|
446
|
+
if (options?.workspaceId && workspaceId && options.workspaceId !== workspaceId) return null;
|
|
447
|
+
if (shownId && shownId !== entry.documentId && parseVersionRef(shownId).docId === entry.documentId)
|
|
448
|
+
showLive?.();
|
|
449
|
+
return entry.documentId;
|
|
450
|
+
}
|
|
444
451
|
|
|
445
|
-
export { ArbiHost,
|
|
446
|
-
//# sourceMappingURL=chunk-
|
|
447
|
-
//# sourceMappingURL=chunk-
|
|
452
|
+
export { ArbiHost, MENTION_HREF_PREFIX, NotificationBell, Toaster, clearSearchSession, createSearchSession, extractMentions, filterMentionCandidates, findMentionQuery, formatRelativeTime, hasMessageBody, insertMention, linkMentions, mentionFromHref, persistSearchSession, requestSearch, savedDocumentIdFor, sharedSearchSession, takeOpenDocumentForTurn, takePendingSearch, toMessageMentions, useOpenDocumentId, useRegisterOpenDocument };
|
|
453
|
+
//# sourceMappingURL=chunk-DGMK3EUN.js.map
|
|
454
|
+
//# sourceMappingURL=chunk-DGMK3EUN.js.map
|