@epicbagel/saas-kit 1.21.0 → 1.23.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.
@@ -0,0 +1,148 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
+
3
+
4
+ var _chunkNKWHDI4Ccjs = require('./chunk-NKWHDI4C.cjs');
5
+
6
+
7
+ var _chunkJDEXZGIYcjs = require('./chunk-JDEXZGIY.cjs');
8
+
9
+
10
+ var _chunkKWLSBTB2cjs = require('./chunk-KWLSBTB2.cjs');
11
+
12
+ // src/primitives/voice-session-controls.tsx
13
+ var _react = require('react');
14
+ var _lucidereact = require('lucide-react');
15
+ var _jsxruntime = require('react/jsx-runtime');
16
+ var SILENCE = [];
17
+ var silence = () => SILENCE;
18
+ var noSubscription = () => () => {
19
+ };
20
+ var DEFAULT_LABELS = {
21
+ disconnected: "Voice chat",
22
+ connecting: "Connecting\u2026",
23
+ listening: "Listening\u2026",
24
+ thinking: "Thinking\u2026",
25
+ speaking: "Speaking",
26
+ reconnecting: "Reconnecting\u2026",
27
+ error: "Voice chat unavailable",
28
+ start: "Start voice chat",
29
+ end: "End voice chat",
30
+ mute: "Mute microphone",
31
+ unmute: "Unmute microphone",
32
+ muted: "Microphone muted",
33
+ retry: "Retry voice chat",
34
+ endShort: "End voice",
35
+ muteShort: "Mute",
36
+ unmuteShort: "Unmute"
37
+ };
38
+ function VoiceSessionControls({
39
+ state,
40
+ onStart,
41
+ onEnd,
42
+ muted = false,
43
+ onMutedChange,
44
+ disabled = false,
45
+ error,
46
+ volumeBands,
47
+ audioLevels,
48
+ labels,
49
+ onWarm,
50
+ size = "icon",
51
+ className
52
+ }) {
53
+ const liveBands = _react.useSyncExternalStore.call(void 0, _nullishCoalesce(_optionalChain([audioLevels, 'optionalAccess', _ => _.subscribe]), () => ( noSubscription)), _nullishCoalesce(_optionalChain([audioLevels, 'optionalAccess', _2 => _2.getSnapshot]), () => ( silence)), silence);
54
+ const copy = { ...DEFAULT_LABELS, ...labels };
55
+ const active = state !== "disconnected" && state !== "error";
56
+ const waiting = state === "connecting" || state === "reconnecting";
57
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
58
+ "div",
59
+ {
60
+ "data-slot": "voice-session-controls",
61
+ "data-state": state,
62
+ className: _chunkKWLSBTB2cjs.cn.call(void 0, "min-w-0", active ? "@container/voice w-full" : "flex flex-wrap items-center gap-2", className),
63
+ children: [
64
+ active ? (
65
+ // One row at every width: on a narrow strip the actions show only their
66
+ // icons (each keeps its full name), rather than wrapping onto a second row.
67
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "voice-session-strip", className: "flex w-full flex-nowrap items-center gap-3 bg-primary/5 p-3 @sm/voice:gap-4 @sm/voice:p-4 @2xl/voice:px-5", children: [
68
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-w-0 flex-1 items-center gap-3 @2xl/voice:gap-4", children: [
69
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "aria-hidden": "true", className: _chunkKWLSBTB2cjs.cn.call(void 0,
70
+ "flex size-10 shrink-0 items-center justify-center rounded-full ring-8 ring-primary/5 @sm/voice:size-12 @md/voice:size-14",
71
+ muted ? "bg-muted text-muted-foreground" : "bg-primary text-primary-foreground"
72
+ ), children: muted ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MicOff, { className: "size-5" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Mic, { className: "size-5" }) }),
73
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
74
+ _chunkNKWHDI4Ccjs.AgentAudioVisualizerBar,
75
+ {
76
+ "aria-hidden": "true",
77
+ size: "sm",
78
+ barCount: 5,
79
+ className: "shrink-0 text-primary [&>div]:w-1",
80
+ state: muted && state === "listening" ? "disconnected" : state === "reconnecting" ? "connecting" : state,
81
+ volumeBands: muted && state === "listening" ? SILENCE : _nullishCoalesce(volumeBands, () => ( liveBands))
82
+ }
83
+ ),
84
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { role: "status", className: "min-w-0 flex-1 truncate text-sm font-medium text-primary", children: muted && state === "listening" ? copy.muted : copy[state] })
85
+ ] }),
86
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
87
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
88
+ _chunkJDEXZGIYcjs.Button,
89
+ {
90
+ type: "button",
91
+ variant: "outline",
92
+ size: "sm",
93
+ className: "min-h-[44px] min-w-[44px] shrink-0 rounded-xl bg-background px-0 text-foreground @md/voice:px-3",
94
+ "aria-label": muted ? copy.unmute : copy.mute,
95
+ title: muted ? copy.unmute : copy.mute,
96
+ "aria-pressed": muted,
97
+ disabled: waiting,
98
+ onClick: () => onMutedChange(!muted),
99
+ children: [
100
+ muted ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Mic, { "aria-hidden": "true" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MicOff, { "aria-hidden": "true" }),
101
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-slot": "voice-session-action-label", className: "hidden @md/voice:inline", children: muted ? copy.unmuteShort : copy.muteShort })
102
+ ]
103
+ }
104
+ ),
105
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
106
+ _chunkJDEXZGIYcjs.Button,
107
+ {
108
+ type: "button",
109
+ variant: "outline",
110
+ size: "sm",
111
+ className: "min-h-[44px] min-w-[44px] shrink-0 rounded-xl bg-background px-0 text-foreground @md/voice:px-3",
112
+ "aria-label": copy.end,
113
+ title: copy.end,
114
+ onClick: onEnd,
115
+ children: [
116
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Square, { "aria-hidden": "true", className: "fill-current" }),
117
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-slot": "voice-session-action-label", className: "hidden @md/voice:inline", children: copy.endShort })
118
+ ]
119
+ }
120
+ )
121
+ ] })
122
+ ] })
123
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
124
+ _chunkJDEXZGIYcjs.Button,
125
+ {
126
+ type: "button",
127
+ size: "icon",
128
+ shape: "circle",
129
+ disabled,
130
+ onClick: onStart,
131
+ onPointerEnter: onWarm,
132
+ onPointerDown: onWarm,
133
+ onFocus: onWarm,
134
+ "aria-label": state === "error" ? copy.retry : copy.start,
135
+ title: state === "error" ? copy.retry : copy.start,
136
+ className: _chunkKWLSBTB2cjs.cn.call(void 0, "min-h-[44px] min-w-[44px] shrink-0 rounded-full", size === "hero" && "size-24 [&_svg]:size-7"),
137
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AudioLines, { "aria-hidden": "true" })
138
+ }
139
+ ),
140
+ state === "error" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { role: "alert", className: "basis-full text-xs text-destructive", children: error || copy.error })
141
+ ]
142
+ }
143
+ );
144
+ }
145
+
146
+
147
+
148
+ exports.VoiceSessionControls = VoiceSessionControls;
@@ -0,0 +1,148 @@
1
+ "use client";
2
+ import {
3
+ AgentAudioVisualizerBar
4
+ } from "./chunk-5OF6D3GH.js";
5
+ import {
6
+ Button
7
+ } from "./chunk-W326GKML.js";
8
+ import {
9
+ cn
10
+ } from "./chunk-G6SRSWXB.js";
11
+
12
+ // src/primitives/voice-session-controls.tsx
13
+ import { useSyncExternalStore } from "react";
14
+ import { Mic, MicOff, Square, AudioLines } from "lucide-react";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ var SILENCE = [];
17
+ var silence = () => SILENCE;
18
+ var noSubscription = () => () => {
19
+ };
20
+ var DEFAULT_LABELS = {
21
+ disconnected: "Voice chat",
22
+ connecting: "Connecting\u2026",
23
+ listening: "Listening\u2026",
24
+ thinking: "Thinking\u2026",
25
+ speaking: "Speaking",
26
+ reconnecting: "Reconnecting\u2026",
27
+ error: "Voice chat unavailable",
28
+ start: "Start voice chat",
29
+ end: "End voice chat",
30
+ mute: "Mute microphone",
31
+ unmute: "Unmute microphone",
32
+ muted: "Microphone muted",
33
+ retry: "Retry voice chat",
34
+ endShort: "End voice",
35
+ muteShort: "Mute",
36
+ unmuteShort: "Unmute"
37
+ };
38
+ function VoiceSessionControls({
39
+ state,
40
+ onStart,
41
+ onEnd,
42
+ muted = false,
43
+ onMutedChange,
44
+ disabled = false,
45
+ error,
46
+ volumeBands,
47
+ audioLevels,
48
+ labels,
49
+ onWarm,
50
+ size = "icon",
51
+ className
52
+ }) {
53
+ const liveBands = useSyncExternalStore(audioLevels?.subscribe ?? noSubscription, audioLevels?.getSnapshot ?? silence, silence);
54
+ const copy = { ...DEFAULT_LABELS, ...labels };
55
+ const active = state !== "disconnected" && state !== "error";
56
+ const waiting = state === "connecting" || state === "reconnecting";
57
+ return /* @__PURE__ */ jsxs(
58
+ "div",
59
+ {
60
+ "data-slot": "voice-session-controls",
61
+ "data-state": state,
62
+ className: cn("min-w-0", active ? "@container/voice w-full" : "flex flex-wrap items-center gap-2", className),
63
+ children: [
64
+ active ? (
65
+ // One row at every width: on a narrow strip the actions show only their
66
+ // icons (each keeps its full name), rather than wrapping onto a second row.
67
+ /* @__PURE__ */ jsxs("div", { "data-slot": "voice-session-strip", className: "flex w-full flex-nowrap items-center gap-3 bg-primary/5 p-3 @sm/voice:gap-4 @sm/voice:p-4 @2xl/voice:px-5", children: [
68
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3 @2xl/voice:gap-4", children: [
69
+ /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: cn(
70
+ "flex size-10 shrink-0 items-center justify-center rounded-full ring-8 ring-primary/5 @sm/voice:size-12 @md/voice:size-14",
71
+ muted ? "bg-muted text-muted-foreground" : "bg-primary text-primary-foreground"
72
+ ), children: muted ? /* @__PURE__ */ jsx(MicOff, { className: "size-5" }) : /* @__PURE__ */ jsx(Mic, { className: "size-5" }) }),
73
+ /* @__PURE__ */ jsx(
74
+ AgentAudioVisualizerBar,
75
+ {
76
+ "aria-hidden": "true",
77
+ size: "sm",
78
+ barCount: 5,
79
+ className: "shrink-0 text-primary [&>div]:w-1",
80
+ state: muted && state === "listening" ? "disconnected" : state === "reconnecting" ? "connecting" : state,
81
+ volumeBands: muted && state === "listening" ? SILENCE : volumeBands ?? liveBands
82
+ }
83
+ ),
84
+ /* @__PURE__ */ jsx("span", { role: "status", className: "min-w-0 flex-1 truncate text-sm font-medium text-primary", children: muted && state === "listening" ? copy.muted : copy[state] })
85
+ ] }),
86
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
87
+ /* @__PURE__ */ jsxs(
88
+ Button,
89
+ {
90
+ type: "button",
91
+ variant: "outline",
92
+ size: "sm",
93
+ className: "min-h-[44px] min-w-[44px] shrink-0 rounded-xl bg-background px-0 text-foreground @md/voice:px-3",
94
+ "aria-label": muted ? copy.unmute : copy.mute,
95
+ title: muted ? copy.unmute : copy.mute,
96
+ "aria-pressed": muted,
97
+ disabled: waiting,
98
+ onClick: () => onMutedChange(!muted),
99
+ children: [
100
+ muted ? /* @__PURE__ */ jsx(Mic, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(MicOff, { "aria-hidden": "true" }),
101
+ /* @__PURE__ */ jsx("span", { "data-slot": "voice-session-action-label", className: "hidden @md/voice:inline", children: muted ? copy.unmuteShort : copy.muteShort })
102
+ ]
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsxs(
106
+ Button,
107
+ {
108
+ type: "button",
109
+ variant: "outline",
110
+ size: "sm",
111
+ className: "min-h-[44px] min-w-[44px] shrink-0 rounded-xl bg-background px-0 text-foreground @md/voice:px-3",
112
+ "aria-label": copy.end,
113
+ title: copy.end,
114
+ onClick: onEnd,
115
+ children: [
116
+ /* @__PURE__ */ jsx(Square, { "aria-hidden": "true", className: "fill-current" }),
117
+ /* @__PURE__ */ jsx("span", { "data-slot": "voice-session-action-label", className: "hidden @md/voice:inline", children: copy.endShort })
118
+ ]
119
+ }
120
+ )
121
+ ] })
122
+ ] })
123
+ ) : /* @__PURE__ */ jsx(
124
+ Button,
125
+ {
126
+ type: "button",
127
+ size: "icon",
128
+ shape: "circle",
129
+ disabled,
130
+ onClick: onStart,
131
+ onPointerEnter: onWarm,
132
+ onPointerDown: onWarm,
133
+ onFocus: onWarm,
134
+ "aria-label": state === "error" ? copy.retry : copy.start,
135
+ title: state === "error" ? copy.retry : copy.start,
136
+ className: cn("min-h-[44px] min-w-[44px] shrink-0 rounded-full", size === "hero" && "size-24 [&_svg]:size-7"),
137
+ children: /* @__PURE__ */ jsx(AudioLines, { "aria-hidden": "true" })
138
+ }
139
+ ),
140
+ state === "error" && /* @__PURE__ */ jsx("span", { role: "alert", className: "basis-full text-xs text-destructive", children: error || copy.error })
141
+ ]
142
+ }
143
+ );
144
+ }
145
+
146
+ export {
147
+ VoiceSessionControls
148
+ };