@nivaro/react 0.2.56 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/components/slots/TasksSlot.js +31 -29
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +414 -1
  5. package/dist/index.js +767 -716
  6. package/dist/shared/components/ClientChaosToolbar.js +410 -0
  7. package/dist/shared/components/ItemEditForm.js +666 -658
  8. package/dist/shared/components/LoadErrorNote.js +49 -0
  9. package/dist/shared/components/MyWorkView.js +47 -37
  10. package/dist/shared/components/PretendDown.js +258 -0
  11. package/dist/shared/components/ProfileView.js +208 -184
  12. package/dist/shared/components/QueryErrorState.js +16 -0
  13. package/dist/shared/components/ReportView.js +1351 -1338
  14. package/dist/shared/components/WidgetSlot.js +438 -418
  15. package/dist/shared/components/ai/AiPlanCard.js +427 -0
  16. package/dist/shared/components/ai/AiPlanChanges.js +117 -0
  17. package/dist/shared/components/ai/TaskDo.js +1022 -0
  18. package/dist/shared/components/chaos/DeclareIncidentButton.js +72 -0
  19. package/dist/shared/components/chaos/DrillBanner.js +119 -0
  20. package/dist/shared/components/chaos/DrillTag.js +62 -0
  21. package/dist/shared/components/chaos/GameDayStrip.js +61 -0
  22. package/dist/shared/components/chat/ChatAnalyticsView.js +19 -17
  23. package/dist/shared/components/chat/ChatPanel.js +1356 -1317
  24. package/dist/shared/components/chat/HuddleAnalyticsTab.js +198 -0
  25. package/dist/shared/components/chat/RoomHeaderMenu.js +78 -65
  26. package/dist/shared/components/chat/chat-core.js +273 -264
  27. package/dist/shared/components/chat/huddle/HuddleAudioUi.js +397 -0
  28. package/dist/shared/components/chat/huddle/HuddleCallBar.js +296 -0
  29. package/dist/shared/components/chat/huddle/HuddleCallLayer.js +180 -0
  30. package/dist/shared/components/chat/huddle/HuddleCamera.js +124 -0
  31. package/dist/shared/components/chat/huddle/HuddleCollab.js +320 -0
  32. package/dist/shared/components/chat/huddle/HuddleControls.js +82 -121
  33. package/dist/shared/components/chat/huddle/HuddleDraw.js +231 -0
  34. package/dist/shared/components/chat/huddle/HuddleLiveBadge.js +52 -0
  35. package/dist/shared/components/chat/huddle/HuddlePeoplePicker.js +143 -0
  36. package/dist/shared/components/chat/huddle/HuddleScheduleCard.js +190 -0
  37. package/dist/shared/components/chat/huddle/HuddleScheduleForm.js +188 -0
  38. package/dist/shared/components/chat/huddle/HuddleStage.js +184 -89
  39. package/dist/shared/components/chat/huddle/HuddleStageTools.js +197 -0
  40. package/dist/shared/components/chat/huddle/huddle-audio-logic.js +156 -0
  41. package/dist/shared/components/chat/huddle/huddle-audio.js +69 -0
  42. package/dist/shared/components/chat/huddle/huddle-calls.js +129 -0
  43. package/dist/shared/components/chat/huddle/huddle-camera.js +143 -0
  44. package/dist/shared/components/chat/huddle/huddle-collab-store.js +391 -0
  45. package/dist/shared/components/chat/huddle/huddle-device-prefs.js +55 -0
  46. package/dist/shared/components/chat/huddle/huddle-devices.js +99 -0
  47. package/dist/shared/components/chat/huddle/huddle-draw.js +226 -0
  48. package/dist/shared/components/chat/huddle/huddle-follow-bus.js +96 -0
  49. package/dist/shared/components/chat/huddle/huddle-hold.js +62 -0
  50. package/dist/shared/components/chat/huddle/huddle-link-quality.js +159 -0
  51. package/dist/shared/components/chat/huddle/huddle-live.js +82 -0
  52. package/dist/shared/components/chat/huddle/huddle-pip.js +343 -0
  53. package/dist/shared/components/chat/huddle/huddle-quality.js +22 -0
  54. package/dist/shared/components/chat/huddle/huddle-reactions.js +71 -0
  55. package/dist/shared/components/chat/huddle/huddle-ring-refused.js +34 -0
  56. package/dist/shared/components/chat/huddle/huddle-schedule.js +102 -0
  57. package/dist/shared/components/chat/huddle/huddle-sfu.js +176 -0
  58. package/dist/shared/components/chat/huddle/huddle-shortcuts.js +91 -0
  59. package/dist/shared/components/chat/huddle/huddle-speaking.js +100 -0
  60. package/dist/shared/components/chat/huddle/huddle-store.js +431 -157
  61. package/dist/shared/components/chat/huddle/useHuddle.js +46 -38
  62. package/dist/shared/components/chat/huddle/useHuddleAudio.js +35 -0
  63. package/dist/shared/components/client-chaos-gate.js +51 -0
  64. package/dist/shared/components/integrations/console/SignalCard.js +172 -167
  65. package/dist/shared/components/item-edit/GroupSection.js +1 -0
  66. package/dist/shared/components/item-edit/RecordChatActions.js +68 -59
  67. package/dist/shared/components/item-edit/UserChip.js +145 -142
  68. package/dist/shared/components/layout-editor/EditorTopBar.js +108 -105
  69. package/dist/shared/components/layout-editor/LayoutEditor.js +514 -508
  70. package/dist/shared/components/notifications/NotificationAnalyticsView.js +18 -10
  71. package/dist/shared/components/panels/TaskPanel.js +51 -49
  72. package/dist/shared/components/pipeline/PipelineEditorView.js +495 -479
  73. package/dist/shared/components/pipeline/TeamsView.js +184 -169
  74. package/dist/shared/components/support/TicketDetailSheet.js +57 -42
  75. package/dist/shared/lib/client-chaos.js +359 -0
  76. package/dist/shared/lib/load-error.js +26 -0
  77. package/dist/shared/lib/notification-sound.js +25 -16
  78. package/dist/shared/lib/socket-realtime.js +31 -30
  79. package/dist/shared/lib/worker-socket.js +108 -89
  80. package/package.json +2 -1
@@ -0,0 +1,343 @@
1
+ var I = Object.defineProperty;
2
+ var W = (t, e, n) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var m = (t, e, n) => W(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsxs as u, jsx as o } from "react/jsx-runtime";
5
+ import { PictureInPicture2 as L, Headphones as M, MicOff as P, Mic as R, PhoneOff as T } from "lucide-react";
6
+ import { useSyncExternalStore as w, useState as x, useRef as O, useEffect as v } from "react";
7
+ import { createRoot as $ } from "react-dom/client";
8
+ import { cn as k } from "../../../lib/utils.js";
9
+ import { chatInitials as q, chatAvatarColor as D } from "../chat-core.js";
10
+ import { huddleSpeaking as N } from "./huddle-speaking.js";
11
+ import { huddleStore as p, formatElapsed as F } from "./huddle-store.js";
12
+ function E() {
13
+ if (typeof window > "u") return null;
14
+ const t = window.documentPictureInPicture;
15
+ return t && typeof t.requestWindow == "function" ? t : null;
16
+ }
17
+ function A() {
18
+ return !!E();
19
+ }
20
+ function K(t, e) {
21
+ for (const n of Array.from(t.styleSheets))
22
+ try {
23
+ const r = Array.from(n.cssRules).map((a) => a.cssText).join(`
24
+ `), i = e.createElement("style");
25
+ i.textContent = r, e.head.appendChild(i);
26
+ } catch {
27
+ if (!n.href) continue;
28
+ const r = e.createElement("link");
29
+ r.rel = "stylesheet", r.href = n.href, e.head.appendChild(r);
30
+ }
31
+ C(t, e), e.title = "Huddle";
32
+ }
33
+ function C(t, e) {
34
+ const n = t.documentElement, r = e.documentElement;
35
+ r.className = n.className;
36
+ const i = n.getAttribute("style");
37
+ i ? r.setAttribute("style", i) : r.removeAttribute("style");
38
+ for (const a of ["data-theme", "lang", "dir"]) {
39
+ const l = n.getAttribute(a);
40
+ l == null ? r.removeAttribute(a) : r.setAttribute(a, l);
41
+ }
42
+ }
43
+ class V {
44
+ constructor() {
45
+ m(this, "win", null);
46
+ m(this, "root", null);
47
+ m(this, "offs", []);
48
+ m(this, "listeners", /* @__PURE__ */ new Set());
49
+ m(this, "opening", !1);
50
+ m(this, "subscribe", (e) => (this.listeners.add(e), () => {
51
+ this.listeners.delete(e);
52
+ }));
53
+ m(this, "getSnapshot", () => !!this.win);
54
+ }
55
+ emit() {
56
+ for (const e of this.listeners) e();
57
+ }
58
+ isOpen() {
59
+ return !!this.win;
60
+ }
61
+ /** Must run inside a click (or the browser's auto-PiP action): PiP needs user activation. */
62
+ async open(e) {
63
+ const n = E(), r = p.getSnapshot();
64
+ if (!n || this.opening || r.status !== "live" && r.status !== "joining") return !1;
65
+ if (this.win)
66
+ return this.win.focus(), !0;
67
+ this.opening = !0;
68
+ let i;
69
+ try {
70
+ i = await n.requestWindow({ width: 320, height: 240 });
71
+ } catch {
72
+ return !1;
73
+ } finally {
74
+ this.opening = !1;
75
+ }
76
+ K(document, i.document), i.document.body.className = "m-0 bg-slate-50 font-sans text-slate-900 antialiased dark:bg-background dark:text-slate-100";
77
+ const a = i.document.createElement("div");
78
+ a.className = "h-screen", i.document.body.appendChild(a), this.win = i, this.root = $(a), this.root.render(/* @__PURE__ */ o(_, { me: e, win: i }));
79
+ const l = new MutationObserver(() => C(document, i.document));
80
+ l.observe(document.documentElement, {
81
+ attributes: !0,
82
+ attributeFilter: ["class", "style", "data-theme"]
83
+ });
84
+ const c = () => this.closed();
85
+ return i.addEventListener("pagehide", c), this.offs = [
86
+ () => l.disconnect(),
87
+ () => i.removeEventListener("pagehide", c),
88
+ p.subscribe(() => {
89
+ const d = p.getSnapshot().status;
90
+ d !== "live" && d !== "joining" && this.close();
91
+ })
92
+ ], this.emit(), !0;
93
+ }
94
+ close() {
95
+ const e = this.win;
96
+ this.closed(), e == null || e.close();
97
+ }
98
+ closed() {
99
+ if (!this.win) return;
100
+ for (const n of this.offs) n();
101
+ this.offs = [];
102
+ const e = this.root;
103
+ this.root = null, this.win = null, queueMicrotask(() => e == null ? void 0 : e.unmount()), this.emit();
104
+ }
105
+ }
106
+ const f = new V();
107
+ function Y({
108
+ id: t,
109
+ name: e,
110
+ speaking: n,
111
+ muted: r
112
+ }) {
113
+ return /* @__PURE__ */ u("span", { className: "relative inline-flex shrink-0", "data-tip": e ?? "Someone", children: [
114
+ /* @__PURE__ */ o(
115
+ "span",
116
+ {
117
+ className: k(
118
+ "flex h-8 w-8 items-center justify-center rounded-full text-[11px] font-semibold text-[#04263b] ring-2 ring-offset-2 ring-offset-slate-50 transition-[box-shadow] duration-200 dark:ring-offset-background",
119
+ n ? "ring-emerald-500 dark:ring-emerald-400" : "ring-transparent"
120
+ ),
121
+ style: { backgroundColor: D(t) },
122
+ role: "img",
123
+ "aria-label": `${e ?? "Someone"}${n ? ", speaking" : ""}${r ? ", muted" : ""}`,
124
+ children: q(e)
125
+ }
126
+ ),
127
+ r && /* @__PURE__ */ o("span", { className: "absolute -bottom-0.5 -right-0.5 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white ring-1 ring-slate-200 dark:bg-card dark:ring-border", children: /* @__PURE__ */ o(P, { className: "h-2.5 w-2.5 text-red-600 dark:text-red-300", strokeWidth: 2.25 }) })
128
+ ] });
129
+ }
130
+ function U({ stream: t, label: e }) {
131
+ const n = O(null);
132
+ return v(() => {
133
+ const r = n.current;
134
+ if (r)
135
+ return r.srcObject = t, r.play().catch(() => null), () => {
136
+ r.srcObject = null;
137
+ };
138
+ }, [t]), /* @__PURE__ */ u("div", { className: "relative min-h-0 flex-1 overflow-hidden rounded-md bg-[#0f172a]", children: [
139
+ /* @__PURE__ */ o("video", { ref: n, muted: !0, playsInline: !0, className: "h-full w-full object-contain" }),
140
+ /* @__PURE__ */ o("span", { className: "absolute bottom-1 left-1.5 max-w-[calc(100%-0.75rem)] truncate rounded bg-black/55 px-1.5 py-0.5 text-[10px] font-medium text-white", children: e })
141
+ ] });
142
+ }
143
+ function _({ me: t, win: e }) {
144
+ const n = w(p.subscribe, p.getSnapshot), r = w(N.subscribe, N.getSnapshot), [, i] = x(0);
145
+ v(() => {
146
+ const s = e.setInterval(() => i((b) => b + 1), 1e3);
147
+ return () => e.clearInterval(s);
148
+ }, [e]);
149
+ const a = n.peers.find((s) => s.video), l = n.peers.find((s) => s.camera), c = a != null && a.video ? { stream: a.video, label: `${a.name ?? "Someone"}'s screen` } : n.localScreen ? { stream: n.localScreen, label: "Your screen" } : l != null && l.camera ? { stream: l.camera, label: l.name ?? "Someone" } : null, d = [
150
+ ...t ? [
151
+ {
152
+ socket: "me",
153
+ user: t.id,
154
+ name: t.name,
155
+ muted: n.muted,
156
+ speaking: r.selfSpeaking
157
+ }
158
+ ] : [],
159
+ ...n.peers.map((s) => ({ ...s, speaking: !!r.speaking[s.socket] }))
160
+ ], g = n.status === "live";
161
+ return /* @__PURE__ */ u("div", { className: "flex h-full flex-col gap-2 p-2.5 text-[12px]", "data-huddle-pip": !0, children: [
162
+ /* @__PURE__ */ u("div", { className: "flex items-center gap-1.5", children: [
163
+ /* @__PURE__ */ o(M, { className: "h-3.5 w-3.5 text-nvr-cyan", strokeWidth: 2 }),
164
+ /* @__PURE__ */ o("span", { className: "font-medium", children: g ? "Huddle" : "Connecting…" }),
165
+ g && n.startedAt && /* @__PURE__ */ o("span", { className: "tabular-nums text-slate-500 dark:text-slate-400", children: F(Date.now() - n.startedAt) }),
166
+ /* @__PURE__ */ u("span", { className: "ml-auto text-[11px] text-slate-500 dark:text-slate-400", children: [
167
+ d.length,
168
+ " ",
169
+ d.length === 1 ? "person" : "people"
170
+ ] })
171
+ ] }),
172
+ c ? /* @__PURE__ */ o(U, { stream: c.stream, label: c.label }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 items-center", children: d.length <= 1 && /* @__PURE__ */ o("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: "Only you so far." }) }),
173
+ /* @__PURE__ */ u("div", { className: "flex items-center gap-2", children: [
174
+ /* @__PURE__ */ u("div", { className: "flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden py-1 pl-1", children: [
175
+ d.slice(0, 5).map((s) => /* @__PURE__ */ o(Y, { id: s.user, name: s.name, speaking: s.speaking, muted: s.muted }, s.socket)),
176
+ d.length > 5 && /* @__PURE__ */ u("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
177
+ "+",
178
+ d.length - 5
179
+ ] })
180
+ ] }),
181
+ /* @__PURE__ */ o(
182
+ "button",
183
+ {
184
+ type: "button",
185
+ onClick: () => p.setMuted(!n.muted),
186
+ disabled: !g,
187
+ className: k(
188
+ "flex h-8 w-8 items-center justify-center rounded-md border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-40",
189
+ n.muted ? "border-red-200 bg-red-50 text-red-600 dark:border-red-500/30 dark:bg-red-500/15 dark:text-red-300" : "border-slate-200 bg-white text-slate-700 hover:bg-slate-100 dark:border-border dark:bg-card dark:text-slate-200 dark:hover:bg-white/10"
190
+ ),
191
+ "aria-pressed": n.muted,
192
+ "aria-label": n.muted ? "Unmute microphone" : "Mute microphone",
193
+ children: n.muted ? /* @__PURE__ */ o(P, { className: "h-4 w-4", strokeWidth: 2 }) : /* @__PURE__ */ o(R, { className: "h-4 w-4", strokeWidth: 2 })
194
+ }
195
+ ),
196
+ /* @__PURE__ */ u(
197
+ "button",
198
+ {
199
+ type: "button",
200
+ onClick: () => p.leave(),
201
+ className: "flex h-8 items-center gap-1 rounded-md bg-red-600 px-2.5 text-[12px] font-medium text-white transition-colors hover:bg-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1",
202
+ "aria-label": "Leave the huddle",
203
+ children: [
204
+ /* @__PURE__ */ o(T, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
205
+ "Leave"
206
+ ]
207
+ }
208
+ )
209
+ ] })
210
+ ] });
211
+ }
212
+ const j = "nvr-huddle-pip";
213
+ function y() {
214
+ try {
215
+ const t = window.localStorage.getItem(j);
216
+ return t === "asked" || t === "auto" ? t : null;
217
+ } catch {
218
+ return null;
219
+ }
220
+ }
221
+ function S(t) {
222
+ try {
223
+ window.localStorage.setItem(j, t);
224
+ } catch {
225
+ }
226
+ }
227
+ function H() {
228
+ return typeof navigator > "u" ? null : navigator.mediaSession ?? null;
229
+ }
230
+ let h = null;
231
+ function z() {
232
+ if (h != null) return h;
233
+ const t = H();
234
+ if (!t || !A())
235
+ return h = !1, h;
236
+ try {
237
+ t.setActionHandler("enterpictureinpicture", null), h = !0;
238
+ } catch {
239
+ h = !1;
240
+ }
241
+ return h;
242
+ }
243
+ function re(t, e) {
244
+ const n = w(f.subscribe, f.getSnapshot, () => !1), [r] = x(A), [i] = x(z), [a, l] = x(!1), c = O(e);
245
+ c.current = e, v(() => {
246
+ if (!t || !r || y()) return;
247
+ let s = !1;
248
+ const b = () => {
249
+ document.hidden ? f.isOpen() || (s = !0) : s && (s = !1, !y() && !f.isOpen() && l(!0));
250
+ };
251
+ return document.addEventListener("visibilitychange", b), () => document.removeEventListener("visibilitychange", b);
252
+ }, [t, r]);
253
+ const [d, g] = x(0);
254
+ return v(() => {
255
+ const s = H();
256
+ if (!(!t || !i || !s || y() !== "auto")) {
257
+ try {
258
+ s.setActionHandler("enterpictureinpicture", () => void f.open(c.current));
259
+ } catch {
260
+ return;
261
+ }
262
+ return () => {
263
+ try {
264
+ s.setActionHandler("enterpictureinpicture", null);
265
+ } catch {
266
+ }
267
+ };
268
+ }
269
+ }, [t, i, d]), v(() => {
270
+ t || l(!1);
271
+ }, [t]), {
272
+ supported: r,
273
+ open: n,
274
+ toggle: () => f.isOpen() ? f.close() : void f.open(c.current),
275
+ offer: a,
276
+ autoSupported: i,
277
+ acceptOffer: (s) => {
278
+ S(s && i ? "auto" : "asked"), g((b) => b + 1), l(!1), f.open(c.current);
279
+ },
280
+ dismissOffer: () => {
281
+ S("asked"), l(!1);
282
+ }
283
+ };
284
+ }
285
+ function se({ pip: t }) {
286
+ if (!t.offer || t.open) return null;
287
+ const e = "rounded px-1.5 py-0.5 font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan";
288
+ return /* @__PURE__ */ u(
289
+ "div",
290
+ {
291
+ className: "mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-slate-200 bg-white px-2 py-1 text-[11.5px] text-slate-700 dark:border-border dark:bg-card dark:text-slate-200",
292
+ role: "status",
293
+ "data-huddle-pip-offer": !0,
294
+ children: [
295
+ /* @__PURE__ */ o(L, { className: "h-3.5 w-3.5 shrink-0 text-nvr-cyan", strokeWidth: 2 }),
296
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1", children: "Keep the huddle on top when you switch to another tab or app?" }),
297
+ /* @__PURE__ */ u("span", { className: "flex items-center gap-1", children: [
298
+ /* @__PURE__ */ o(
299
+ "button",
300
+ {
301
+ type: "button",
302
+ onClick: () => t.acceptOffer(!1),
303
+ className: k(e, "bg-nvr-cyan text-white hover:bg-nvr-cyan/90"),
304
+ children: "Pop out"
305
+ }
306
+ ),
307
+ t.autoSupported && /* @__PURE__ */ o(
308
+ "button",
309
+ {
310
+ type: "button",
311
+ onClick: () => t.acceptOffer(!0),
312
+ className: k(
313
+ e,
314
+ "text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-white/10"
315
+ ),
316
+ "data-tip": "Pop out by itself whenever you leave this tab during a huddle",
317
+ children: "Every time"
318
+ }
319
+ ),
320
+ /* @__PURE__ */ o(
321
+ "button",
322
+ {
323
+ type: "button",
324
+ onClick: t.dismissOffer,
325
+ className: k(
326
+ e,
327
+ "text-slate-500 hover:bg-slate-100 dark:text-slate-400 dark:hover:bg-white/10"
328
+ ),
329
+ children: "No thanks"
330
+ }
331
+ )
332
+ ] })
333
+ ]
334
+ }
335
+ );
336
+ }
337
+ export {
338
+ se as HuddlePipOffer,
339
+ z as autoPipSupported,
340
+ f as huddlePip,
341
+ A as pipSupported,
342
+ re as useHuddlePip
343
+ };
@@ -0,0 +1,22 @@
1
+ function c(e, l) {
2
+ return {
3
+ relay: e.path == null ? null : e.path === "relay",
4
+ lost: l.lost,
5
+ received: l.received,
6
+ rttMs: e.rtt == null ? null : e.rtt
7
+ };
8
+ }
9
+ function g(e, l) {
10
+ if (!e.length && !l) return null;
11
+ const n = e.filter((t) => t.relay != null), u = e.reduce((t, r) => t + r.lost, 0), o = e.reduce((t, r) => t + r.received, 0), a = e.map((t) => t.rttMs).filter((t) => t != null);
12
+ return {
13
+ relay_share: n.length ? n.filter((t) => t.relay).length / n.length : 0,
14
+ ice_failed: l,
15
+ avg_loss: u + o > 0 ? u / (u + o) : null,
16
+ avg_rtt: a.length ? Math.round(a.reduce((t, r) => t + r, 0) / a.length) : null
17
+ };
18
+ }
19
+ export {
20
+ g as aggregateQuality,
21
+ c as linkSummaryOf
22
+ };
@@ -0,0 +1,71 @@
1
+ var u = Object.defineProperty;
2
+ var l = (e, t, s) => t in e ? u(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var n = (e, t, s) => l(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { huddleStore as i } from "./huddle-store.js";
5
+ const c = ["👍", "👏", "😂", "🎉", "❤️", "🤔"], f = 1e3, m = 2600;
6
+ function S(e) {
7
+ return typeof e == "string" && c.includes(e);
8
+ }
9
+ function H(e) {
10
+ return e.filter((t) => typeof t.hand_at == "number" && t.hand_at > 0).sort((t, s) => t.hand_at - s.hand_at || (t.socket < s.socket ? -1 : 1));
11
+ }
12
+ class _ {
13
+ constructor() {
14
+ n(this, "items", []);
15
+ n(this, "listeners", /* @__PURE__ */ new Set());
16
+ n(this, "seq", 0);
17
+ n(this, "lastSent", 0);
18
+ n(this, "subscribe", (t) => (this.listeners.add(t), () => {
19
+ this.listeners.delete(t);
20
+ }));
21
+ n(this, "getSnapshot", () => this.items);
22
+ }
23
+ emit() {
24
+ for (const t of this.listeners) t();
25
+ }
26
+ push(t, s, r = Date.now()) {
27
+ const o = ++this.seq, d = 0.12 + o * 0.618 % 1 * 0.76;
28
+ this.items = [...this.items.slice(-23), { id: o, user: t, emoji: s, at: r, lane: d }], this.emit(), setTimeout(() => {
29
+ this.items = this.items.filter((h) => h.id !== o), this.emit();
30
+ }, m);
31
+ }
32
+ clear() {
33
+ this.items.length && (this.items = [], this.emit());
34
+ }
35
+ /** Send one (and show it at once); false when throttled or not in a huddle. */
36
+ send(t, s, r = Date.now()) {
37
+ return r - this.lastSent < f || !i.send("huddle:react", { emoji: t }) ? !1 : (this.lastSent = r, this.push(s, t, r), !0);
38
+ }
39
+ }
40
+ const a = new _();
41
+ function g(e) {
42
+ return i.send("huddle:state", { hand: e });
43
+ }
44
+ function R() {
45
+ return i.send("huddle:hands_down");
46
+ }
47
+ const w = {
48
+ attach: (e) => [
49
+ e.on("huddle:react", (t) => {
50
+ const s = i.getSnapshot();
51
+ !t || t.room !== s.room || s.status !== "live" || t.from === s.self || !S(t.emoji) || typeof t.user != "string" || a.push(t.user, t.emoji);
52
+ })
53
+ ],
54
+ joined: () => {
55
+ i.getSnapshot().handAt && g(!0);
56
+ },
57
+ teardown: () => a.clear()
58
+ };
59
+ function p() {
60
+ i.use(w);
61
+ }
62
+ export {
63
+ c as HUDDLE_REACTIONS,
64
+ m as REACTION_LIFE_MS,
65
+ H as handQueue,
66
+ p as installHuddleReactions,
67
+ S as isHuddleReaction,
68
+ R as lowerAllHands,
69
+ g as raiseHand,
70
+ a as reactionFeed
71
+ };
@@ -0,0 +1,34 @@
1
+ import { toast as s } from "sonner";
2
+ function i(e) {
3
+ const t = Math.max(1, Math.ceil(Number(e) || 0));
4
+ return t < 60 ? `${t} s` : `${Math.ceil(t / 60)} min`;
5
+ }
6
+ function u(e) {
7
+ return e.length <= 1 ? e[0] ?? "them" : e.length === 2 ? `${e[0]} and ${e[1]}` : `${e.slice(0, -1).join(", ")} and ${e.at(-1)}`;
8
+ }
9
+ function c(e) {
10
+ if (e.reason === "rate")
11
+ return {
12
+ title: `You can start another call in ${i(e.retry_in ?? 60)}`,
13
+ description: "Too many calls in a short time."
14
+ };
15
+ const t = (e.users ?? []).filter((n) => n && typeof n.id == "string");
16
+ if (!t.length) return null;
17
+ const r = Math.max(...t.map((n) => Number(n.retry_in) || 0)), o = `You can call ${u(t.map((n) => n.name || "Someone"))} again in ${i(r)}`, a = t.some((n) => n.reason === "limit");
18
+ return {
19
+ title: o,
20
+ description: a ? "You have rung them several times in the last few minutes." : "They just declined or missed a call from you."
21
+ };
22
+ }
23
+ function l(e) {
24
+ return e.on("huddle:ring-refused", (t) => {
25
+ if (typeof (t == null ? void 0 : t.room) != "string") return;
26
+ const r = c(t);
27
+ r && s(r.title, { id: `huddle-ring-refused-${t.room}`, description: r.description });
28
+ });
29
+ }
30
+ export {
31
+ c as ringRefusedText,
32
+ i as waitWords,
33
+ l as watchRingRefused
34
+ };
@@ -0,0 +1,102 @@
1
+ const d = /\[huddle:(\d+)\]/;
2
+ function l(e) {
3
+ const t = e ? d.exec(e) : null;
4
+ return t ? Number(t[1]) : null;
5
+ }
6
+ function m(e) {
7
+ return e.replace(d, "").replace(/\s+$/, "");
8
+ }
9
+ function f(e, t = Date.now()) {
10
+ if (e.status === "cancelled") return "cancelled";
11
+ const n = new Date(e.starts_at).getTime(), o = new Date(e.ends_at).getTime();
12
+ return t >= o ? "ended" : t >= n ? "live" : n - t <= 15 * 6e4 ? "soon" : "upcoming";
13
+ }
14
+ function $(e, t) {
15
+ const n = new Date(e), o = new Date(t);
16
+ if (Number.isNaN(n.getTime())) return "";
17
+ const r = n.toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }), a = (i) => i.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
18
+ return `${r} · ${a(n)}–${a(o)}`;
19
+ }
20
+ function h(e, t = Date.now()) {
21
+ const n = new Date(e).getTime() - t;
22
+ if (n <= 3e4) return "now";
23
+ const o = Math.round(n / 6e4);
24
+ if (o < 60) return `in ${o} min`;
25
+ const r = Math.floor(o / 60), a = o % 60;
26
+ if (r < 24) return a ? `in ${r} h ${a} min` : `in ${r} h`;
27
+ const i = Math.round(r / 24);
28
+ return `in ${i} day${i === 1 ? "" : "s"}`;
29
+ }
30
+ function u(e) {
31
+ return new Date(e).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
32
+ }
33
+ function c(e) {
34
+ return e.replace(/\\/g, "\\\\").replace(/;/g, "\\;").replace(/,/g, "\\,").replace(/\n/g, "\\n");
35
+ }
36
+ function s(e, t, n = /* @__PURE__ */ new Date()) {
37
+ const o = [
38
+ "BEGIN:VCALENDAR",
39
+ "VERSION:2.0",
40
+ "PRODID:-//Nivaro//Huddles//EN",
41
+ "CALSCALE:GREGORIAN",
42
+ "METHOD:PUBLISH",
43
+ "BEGIN:VEVENT",
44
+ `UID:nivaro-huddle-${e.id}@${e.room.replace(/[^A-Za-z0-9.-]/g, "-")}`,
45
+ `DTSTAMP:${u(n.toISOString())}`,
46
+ `DTSTART:${u(e.starts_at)}`,
47
+ `DTEND:${u(e.ends_at)}`,
48
+ `SUMMARY:${c(`Huddle: ${e.title}`)}`,
49
+ `DESCRIPTION:${c(
50
+ `${e.organizer.name ?? "Someone"} scheduled a huddle in Nivaro.${t ? ` Join: ${t}` : ""}`
51
+ )}`
52
+ ];
53
+ return t && o.push(`URL:${t}`), o.push(
54
+ "BEGIN:VALARM",
55
+ "TRIGGER:-PT5M",
56
+ "ACTION:DISPLAY",
57
+ `DESCRIPTION:${c(`Huddle in 5 minutes: ${e.title}`)}`,
58
+ "END:VALARM",
59
+ "END:VEVENT",
60
+ "END:VCALENDAR"
61
+ ), `${o.join(`\r
62
+ `)}\r
63
+ `;
64
+ }
65
+ function D(e, t) {
66
+ return `https://outlook.office.com/calendar/0/deeplink/compose?${new URLSearchParams({
67
+ path: "/calendar/action/compose",
68
+ rru: "addevent",
69
+ subject: `Huddle: ${e.title}`,
70
+ startdt: new Date(e.starts_at).toISOString(),
71
+ enddt: new Date(e.ends_at).toISOString(),
72
+ body: `${e.organizer.name ?? "Someone"} scheduled a huddle in Nivaro.${t ? ` Join: ${t}` : ""}`
73
+ }).toString()}`;
74
+ }
75
+ function p(e, t) {
76
+ if (!(typeof document > "u" || typeof URL > "u"))
77
+ try {
78
+ const n = new Blob([s(e, t)], { type: "text/calendar;charset=utf-8" }), o = URL.createObjectURL(n), r = document.createElement("a");
79
+ r.href = o, r.download = `huddle-${e.id}.ics`, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(o), 1e3);
80
+ } catch {
81
+ }
82
+ }
83
+ function S(e) {
84
+ const t = (n) => String(n).padStart(2, "0");
85
+ return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`;
86
+ }
87
+ function g(e = /* @__PURE__ */ new Date()) {
88
+ const t = new Date(e.getTime() + 9e5);
89
+ return t.setSeconds(0, 0), t.setMinutes(Math.ceil(t.getMinutes() / 15) * 15), t;
90
+ }
91
+ export {
92
+ s as buildIcs,
93
+ g as defaultStart,
94
+ p as downloadIcs,
95
+ $ as formatScheduleWhen,
96
+ h as formatStartsIn,
97
+ l as huddleRefOf,
98
+ D as outlookComposeUrl,
99
+ f as schedulePhase,
100
+ m as stripHuddleRef,
101
+ S as toLocalInput
102
+ };