@devicai/ui 0.25.0 → 0.27.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.
@@ -18,11 +18,12 @@ const FILE_TYPE_ACCEPT = {
18
18
  // Handoff (hands-free) loop timings.
19
19
  const HANDOFF_PENDING_MS = 1000; // default cancellable countdown before auto-send
20
20
  const HANDOFF_INACTIVITY_MS = 6000; // silence (no speech) that ends the loop
21
+ const HANDOFF_HOLD_MS = 3000; // press-and-hold duration on the mic to arm hands-free
21
22
  /**
22
23
  * Chat input component with file upload support
23
24
  */
24
25
  function ChatInput({ onSend, disabled = false, placeholder = 'Type a message...', enableFileUploads = false, allowedFileTypes = { images: true, documents: true }, maxFileSize = 10 * 1024 * 1024, // 10MB
25
- enableSpeechToText = false, speechLanguage, speechTenantId, speechAutoStop = true, speechAutoStopCountdownMs, speechAutoStopSilenceMs, speechAutoStopSilenceRatio, speechAutoStopSilenceLevel, speechAutoStopSpeechLevel, speechHandoff = false, speechHandoffSendDelayMs, apiKey, baseUrl, sendButtonContent, disabledMessage, isProcessing = false, onStop, stopButtonContent, pendingInputWidget, onSubmitWidget, onCancelWidget, references, onRemoveReference, usageBar, limitBanner, }) {
26
+ enableSpeechToText = false, speechLanguage, speechTenantId, speechAutoStop = true, speechAutoStopCountdownMs, speechAutoStopSilenceMs, speechAutoStopSilenceRatio, speechAutoStopSilenceLevel, speechAutoStopSpeechLevel, speechHandoff = false, speechHandoffSendDelayMs, speechHandoffHoldMs, apiKey, baseUrl, sendButtonContent, disabledMessage, isProcessing = false, onStop, stopButtonContent, pendingInputWidget, onSubmitWidget, onCancelWidget, references, onRemoveReference, usageBar, limitBanner, }) {
26
27
  // When a widget is pending as 'input', render it in place of the textarea
27
28
  if (pendingInputWidget) {
28
29
  const WidgetComponent = pendingInputWidget.widget.component;
@@ -71,6 +72,13 @@ enableSpeechToText = false, speechLanguage, speechTenantId, speechAutoStop = tru
71
72
  const prevProcessingRef = useRef(isProcessing);
72
73
  // Always-fresh send fn so the deferred auto-send uses the latest message.
73
74
  const handleSendRef = useRef(() => { });
75
+ // --- Press-and-hold to arm hands-free ---
76
+ // Holding the mic for `holdMs` fills a ring (0→1) and activates hands-free;
77
+ // releasing earlier falls back to a single one-shot recording.
78
+ const [holdProgress, setHoldProgress] = useState(0);
79
+ const [isHolding, setIsHolding] = useState(false);
80
+ const holdRafRef = useRef(null);
81
+ const holdFiredRef = useRef(false);
74
82
  // Client used only for the /whisper transcription call.
75
83
  const transcribeClient = useMemo(() => {
76
84
  if (!enableSpeechToText || !apiKey)
@@ -131,14 +139,81 @@ enableSpeechToText = false, speechLanguage, speechTenantId, speechAutoStop = tru
131
139
  }
132
140
  recording.cancel();
133
141
  }, [clearPending, recording]);
134
- const startRecording = useCallback(() => {
142
+ // One-shot recording: transcribe fill the textarea for manual review/send.
143
+ // No hands-free loop, so the textarea stays available afterwards.
144
+ const startOneShotRecording = useCallback(() => {
135
145
  setSpeechError(null);
136
- if (speechHandoff) {
137
- handoffActiveRef.current = true;
138
- setHandoffActive(true);
139
- }
140
146
  void recording.start();
141
- }, [recording, speechHandoff]);
147
+ }, [recording]);
148
+ // Arm the hands-free loop and start listening.
149
+ const startHandsfreeRecording = useCallback(() => {
150
+ setSpeechError(null);
151
+ handoffActiveRef.current = true;
152
+ setHandoffActive(true);
153
+ void recording.start();
154
+ }, [recording]);
155
+ // Stop and reset the press-and-hold progress loop.
156
+ const clearHold = useCallback(() => {
157
+ if (holdRafRef.current !== null) {
158
+ cancelAnimationFrame(holdRafRef.current);
159
+ holdRafRef.current = null;
160
+ }
161
+ setIsHolding(false);
162
+ setHoldProgress(0);
163
+ }, []);
164
+ // Mic pressed: when hands-free is available, run a hold timer whose ring fills
165
+ // (0→1) over `holdMs`. Completing it activates hands-free; releasing earlier
166
+ // (handleMicPointerUp) falls back to a one-shot recording. Pointer capture
167
+ // keeps the release event on the button even if the finger drifts off.
168
+ const handleMicPointerDown = useCallback((e) => {
169
+ if (disabled || isProcessing)
170
+ return;
171
+ try {
172
+ e.currentTarget.setPointerCapture(e.pointerId);
173
+ }
174
+ catch {
175
+ // ignore environments without pointer capture
176
+ }
177
+ const holdMs = speechHandoffHoldMs ?? HANDOFF_HOLD_MS;
178
+ holdFiredRef.current = false;
179
+ setIsHolding(true);
180
+ setHoldProgress(0);
181
+ const startedAt = Date.now();
182
+ const step = () => {
183
+ const progress = Math.min(1, (Date.now() - startedAt) / holdMs);
184
+ setHoldProgress(progress);
185
+ if (progress >= 1) {
186
+ holdRafRef.current = null;
187
+ holdFiredRef.current = true;
188
+ setIsHolding(false);
189
+ setHoldProgress(0);
190
+ startHandsfreeRecording();
191
+ return;
192
+ }
193
+ holdRafRef.current = requestAnimationFrame(step);
194
+ };
195
+ holdRafRef.current = requestAnimationFrame(step);
196
+ }, [disabled, isProcessing, speechHandoffHoldMs, startHandsfreeRecording]);
197
+ // Mic released: if the hold already armed hands-free, do nothing; otherwise
198
+ // treat it as a tap and start a one-shot recording.
199
+ const handleMicPointerUp = useCallback(() => {
200
+ if (holdFiredRef.current) {
201
+ holdFiredRef.current = false;
202
+ return;
203
+ }
204
+ if (holdRafRef.current === null && !isHolding)
205
+ return; // already aborted
206
+ clearHold();
207
+ startOneShotRecording();
208
+ }, [isHolding, clearHold, startOneShotRecording]);
209
+ // Pointer cancelled (e.g. interrupted touch): abort the hold without recording.
210
+ const handleMicPointerCancel = useCallback(() => {
211
+ if (holdFiredRef.current) {
212
+ holdFiredRef.current = false;
213
+ return;
214
+ }
215
+ clearHold();
216
+ }, [clearHold]);
142
217
  const cancelRecording = useCallback(() => {
143
218
  cancelHandoff();
144
219
  }, [cancelHandoff]);
@@ -285,6 +360,8 @@ enableSpeechToText = false, speechLanguage, speechTenantId, speechAutoStop = tru
285
360
  cancelAnimationFrame(pendingRafRef.current);
286
361
  if (inactivityTimerRef.current)
287
362
  clearTimeout(inactivityTimerRef.current);
363
+ if (holdRafRef.current !== null)
364
+ cancelAnimationFrame(holdRafRef.current);
288
365
  };
289
366
  }, []);
290
367
  // Handle key press
@@ -317,7 +394,9 @@ enableSpeechToText = false, speechLanguage, speechTenantId, speechAutoStop = tru
317
394
  }, []);
318
395
  return (jsxs("div", { className: "devic-input-area", children: [limitBanner, usageBar, disabledMessage && disabled && (jsxs("div", { className: "devic-input-disabled-notice", children: [jsx(WaitingIcon, {}), disabledMessage] })), speechError && (jsx("div", { className: "devic-speech-error", role: "alert", children: speechError })), handoffActive && (jsxs("div", { className: "devic-handoff-bar", "data-waiting": isProcessing ? 'true' : 'false', children: [jsx("span", { className: "devic-handoff-dot", "aria-hidden": "true" }), jsx("span", { className: "devic-handoff-label", children: isProcessing ? 'Hands-free · waiting for reply' : 'Hands-free on' }), jsx("button", { type: "button", className: "devic-handoff-stop", onClick: cancelHandoff, title: "Stop hands-free", "aria-label": "Stop hands-free", children: jsx(CloseIcon, {}) })] })), references && references.length > 0 && (jsx("div", { className: "devic-reference-chips", children: references.map((ref) => (jsxs("div", { className: "devic-reference-chip", title: ref.label, children: [jsx(ReferenceIcon, {}), jsxs("span", { className: "devic-reference-chip-label", children: ["\"", ref.label, "\""] }), jsx("button", { type: "button", className: "devic-reference-chip-remove", onClick: () => onRemoveReference?.(ref.id), "aria-label": "Quitar referencia", children: "\u00D7" })] }, ref.id))) })), files.length > 0 && (jsx("div", { className: "devic-file-preview", children: files.map((file, idx) => (jsxs("div", { className: "devic-file-preview-item", children: [jsx(FileIcon, {}), jsx("span", { children: file.name }), jsx("button", { className: "devic-file-remove", onClick: () => removeFile(idx), type: "button", children: "\u00D7" })] }, idx))) })), jsx("div", { className: "devic-input-wrapper", children: pendingSend ? (jsx("div", { className: "devic-speech-panel", "data-state": "pending", children: jsxs("div", { className: "devic-handoff-pending", children: [jsxs("div", { className: "devic-handoff-pending-icon", children: [jsx(SendCountdownRing, { progress: pendingProgress }), jsx(SendIcon, {})] }), jsxs("div", { className: "devic-handoff-pending-text", children: [jsx("span", { className: "devic-handoff-pending-title", children: "Sending\u2026 interact to cancel" }), message.trim() && (jsx("span", { className: "devic-handoff-pending-preview", children: message.trim() }))] })] }) })) : isTranscribing ? (jsxs("div", { className: "devic-speech-panel", "data-state": "processing", children: [jsx("span", { className: "devic-speech-spinner", "aria-hidden": "true" }), jsx("span", { className: "devic-speech-status", children: "Transcribing\u2026" })] })) : isRecordingActive ? (jsxs("div", { className: "devic-speech-panel", "data-state": "recording", children: [jsx("button", { className: "devic-input-btn devic-speech-cancel", onClick: cancelRecording, type: "button", title: "Cancel recording", children: jsx(CloseIcon, {}) }), jsxs("div", { className: "devic-speech-live", children: [jsx(Equalizer, { levels: recording.levels, paused: recording.isPaused }), jsx("span", { className: "devic-speech-timer", children: formatDuration(recording.durationMs) })] }), jsx("button", { className: "devic-input-btn", onClick: recording.isPaused ? recording.resume : recording.pause, type: "button", title: recording.isPaused ? 'Resume' : 'Pause', children: recording.isPaused ? jsx(PlayIcon, {}) : jsx(PauseIcon, {}) }), jsxs("div", { className: "devic-speech-confirm-wrap", "data-autostop": recording.isAutoStopping ? 'true' : 'false', children: [recording.isAutoStopping && (jsx(AutoStopRing, { progress: recording.autoStopProgress })), jsx("button", { className: "devic-input-btn devic-speech-confirm", onClick: () => void handleConfirm(), type: "button", title: recording.isAutoStopping
319
396
  ? 'Auto-sending… keep talking to cancel'
320
- : 'Confirm', children: jsx(CheckIcon, {}) })] })] })) : (jsxs(Fragment, { children: [enableFileUploads && (jsxs(Fragment, { children: [jsx("input", { ref: fileInputRef, type: "file", accept: acceptedTypes, multiple: true, onChange: handleFileSelect, style: { display: 'none' } }), jsx("button", { className: "devic-input-btn", onClick: () => fileInputRef.current?.click(), disabled: disabled, type: "button", title: "Attach file", children: jsx(AttachIcon, {}) })] })), speechEnabled && (jsx("button", { className: "devic-input-btn devic-speech-mic", onClick: startRecording, disabled: disabled || isProcessing, type: "button", title: "Record voice message", children: jsx(MicIcon, {}) })), jsx("textarea", { ref: textareaRef, className: "devic-input", value: message, onChange: (e) => {
397
+ : 'Confirm', children: jsx(CheckIcon, {}) })] })] })) : (jsxs(Fragment, { children: [enableFileUploads && (jsxs(Fragment, { children: [jsx("input", { ref: fileInputRef, type: "file", accept: acceptedTypes, multiple: true, onChange: handleFileSelect, style: { display: 'none' } }), jsx("button", { className: "devic-input-btn", onClick: () => fileInputRef.current?.click(), disabled: disabled, type: "button", title: "Attach file", children: jsx(AttachIcon, {}) })] })), speechEnabled && (jsxs("div", { className: "devic-speech-mic-wrap", "data-holding": isHolding ? 'true' : 'false', children: [isHolding && jsx(HoldRing, { progress: holdProgress }), jsx("button", { className: "devic-input-btn devic-speech-mic", onClick: speechHandoff ? undefined : startOneShotRecording, onPointerDown: speechHandoff ? handleMicPointerDown : undefined, onPointerUp: speechHandoff ? handleMicPointerUp : undefined, onPointerCancel: speechHandoff ? handleMicPointerCancel : undefined, disabled: disabled || isProcessing, type: "button", title: speechHandoff
398
+ ? 'Tap to dictate · hold to start hands-free'
399
+ : 'Record voice message', children: jsx(MicIcon, {}) })] })), jsx("textarea", { ref: textareaRef, className: "devic-input", value: message, onChange: (e) => {
321
400
  const value = e.target.value;
322
401
  setMessage(value);
323
402
  // If the user clears the field, drop the transcript link so a fresh
@@ -357,6 +436,17 @@ function SendCountdownRing({ progress }) {
357
436
  strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),
358
437
  } })] }));
359
438
  }
439
+ /**
440
+ * Filling ring drawn around the mic button while the user presses and holds to
441
+ * arm hands-free. Driven by `progress` (0 → 1): an empty ring that fills
442
+ * clockwise over the hold duration. Inverse of the draining auto-stop ring.
443
+ */
444
+ function HoldRing({ progress }) {
445
+ return (jsxs("svg", { className: "devic-mic-hold-ring", viewBox: "0 0 40 40", "aria-hidden": "true", children: [jsx("circle", { className: "devic-mic-hold-ring-track", cx: "20", cy: "20", r: AUTOSTOP_RING_R }), jsx("circle", { className: "devic-mic-hold-ring-progress", cx: "20", cy: "20", r: AUTOSTOP_RING_R, style: {
446
+ strokeDasharray: AUTOSTOP_RING_C,
447
+ strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),
448
+ } })] }));
449
+ }
360
450
  /** Formats milliseconds as m:ss. */
361
451
  function formatDuration(ms) {
362
452
  const totalSeconds = Math.floor(ms / 1000);
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInput.js","sources":["../../../../src/components/ChatDrawer/ChatInput.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useMemo, useEffect } from 'react';\nimport type { ChatInputProps } from './ChatDrawer.types';\nimport { useSpeechRecording } from '../../hooks/useSpeechRecording';\nimport { DevicApiClient } from '../../api/client';\n\nconst FILE_TYPE_ACCEPT: Record<string, string[]> = {\n images: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'],\n documents: [\n 'application/pdf',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'text/plain',\n 'text/csv',\n ],\n audio: ['audio/mpeg', 'audio/wav', 'audio/ogg'],\n video: ['video/mp4', 'video/webm', 'video/ogg'],\n};\n\n// Handoff (hands-free) loop timings.\nconst HANDOFF_PENDING_MS = 1000; // default cancellable countdown before auto-send\nconst HANDOFF_INACTIVITY_MS = 6000; // silence (no speech) that ends the loop\n\n/**\n * Chat input component with file upload support\n */\nexport function ChatInput({\n onSend,\n disabled = false,\n placeholder = 'Type a message...',\n enableFileUploads = false,\n allowedFileTypes = { images: true, documents: true },\n maxFileSize = 10 * 1024 * 1024, // 10MB\n enableSpeechToText = false,\n speechLanguage,\n speechTenantId,\n speechAutoStop = true,\n speechAutoStopCountdownMs,\n speechAutoStopSilenceMs,\n speechAutoStopSilenceRatio,\n speechAutoStopSilenceLevel,\n speechAutoStopSpeechLevel,\n speechHandoff = false,\n speechHandoffSendDelayMs,\n apiKey,\n baseUrl,\n sendButtonContent,\n disabledMessage,\n isProcessing = false,\n onStop,\n stopButtonContent,\n pendingInputWidget,\n onSubmitWidget,\n onCancelWidget,\n references,\n onRemoveReference,\n usageBar,\n limitBanner,\n}: ChatInputProps): JSX.Element {\n // When a widget is pending as 'input', render it in place of the textarea\n if (pendingInputWidget) {\n const WidgetComponent = pendingInputWidget.widget.component;\n return (\n <div className=\"devic-input-area\" data-widget-mode=\"input\">\n <div className=\"devic-input-widget\" data-tool-name={pendingInputWidget.toolName}>\n <WidgetComponent\n toolCall={pendingInputWidget.toolCall}\n params={pendingInputWidget.params}\n submit={(response) => onSubmitWidget?.(pendingInputWidget.toolCall.id, response)}\n cancel={(reason) => onCancelWidget?.(pendingInputWidget.toolCall.id, reason)}\n />\n </div>\n </div>\n );\n }\n const [message, setMessage] = useState('');\n const [files, setFiles] = useState<File[]>([]);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Speech-to-text state\n const [transcriptId, setTranscriptId] = useState<string | undefined>();\n const [isTranscribing, setIsTranscribing] = useState(false);\n const [speechError, setSpeechError] = useState<string | null>(null);\n // Holds the latest confirmRecording so the auto-stop callback (created before\n // confirmRecording is defined) always calls the current closure.\n const confirmRef = useRef<() => void>(() => {});\n const recording = useSpeechRecording({\n bars: 5,\n autoStop: speechAutoStop,\n ...(speechAutoStopCountdownMs != null && {\n autoStopCountdownMs: speechAutoStopCountdownMs,\n }),\n ...(speechAutoStopSilenceMs != null && {\n autoStopSilenceMs: speechAutoStopSilenceMs,\n }),\n ...(speechAutoStopSilenceRatio != null && {\n autoStopSilenceRatio: speechAutoStopSilenceRatio,\n }),\n ...(speechAutoStopSilenceLevel != null && {\n autoStopSilenceLevel: speechAutoStopSilenceLevel,\n }),\n ...(speechAutoStopSpeechLevel != null && {\n autoStopSpeechLevel: speechAutoStopSpeechLevel,\n }),\n onAutoStop: () => confirmRef.current(),\n });\n\n // --- Handoff (hands-free loop) state ---\n const [handoffActive, setHandoffActive] = useState(false);\n const [pendingSend, setPendingSend] = useState(false);\n const [pendingProgress, setPendingProgress] = useState(1);\n // Ref mirror so async callbacks (rAF, timers, document listeners) read the\n // live value without going stale.\n const handoffActiveRef = useRef(false);\n const pendingRafRef = useRef<number | null>(null);\n const inactivityTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const prevProcessingRef = useRef(isProcessing);\n // Always-fresh send fn so the deferred auto-send uses the latest message.\n const handleSendRef = useRef<() => void>(() => {});\n\n // Client used only for the /whisper transcription call.\n const transcribeClient = useMemo(() => {\n if (!enableSpeechToText || !apiKey) return null;\n return new DevicApiClient({\n apiKey,\n baseUrl: baseUrl || 'https://api.devic.ai',\n });\n }, [enableSpeechToText, apiKey, baseUrl]);\n\n const speechEnabled =\n enableSpeechToText && recording.isSupported && !!transcribeClient;\n const isRecordingActive = recording.isRecording || recording.isPaused;\n\n // Calculate accepted file types\n const acceptedTypes = Object.entries(allowedFileTypes)\n .filter(([, enabled]) => enabled)\n .flatMap(([type]) => FILE_TYPE_ACCEPT[type] || [])\n .join(',');\n\n // Auto-resize textarea\n const handleInput = useCallback(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px`;\n }\n }, []);\n\n // Handle send\n const handleSend = useCallback(() => {\n const trimmedMessage = message.trim();\n if (!trimmedMessage && files.length === 0) return;\n\n onSend(\n trimmedMessage,\n files.length > 0 ? files : undefined,\n transcriptId ? { transcriptId } : undefined,\n );\n setMessage('');\n setFiles([]);\n setTranscriptId(undefined);\n\n // Reset textarea height\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n }\n }, [message, files, onSend, transcriptId]);\n // Keep a fresh send fn for the deferred handoff auto-send.\n handleSendRef.current = handleSend;\n\n // --- Speech-to-text handlers ---\n\n const clearPending = useCallback(() => {\n if (pendingRafRef.current !== null) {\n cancelAnimationFrame(pendingRafRef.current);\n pendingRafRef.current = null;\n }\n setPendingSend(false);\n setPendingProgress(1);\n }, []);\n\n // Fully exit the hands-free loop and stop any recording in progress.\n const cancelHandoff = useCallback(() => {\n handoffActiveRef.current = false;\n setHandoffActive(false);\n clearPending();\n if (inactivityTimerRef.current) {\n clearTimeout(inactivityTimerRef.current);\n inactivityTimerRef.current = null;\n }\n recording.cancel();\n }, [clearPending, recording]);\n\n const startRecording = useCallback(() => {\n setSpeechError(null);\n if (speechHandoff) {\n handoffActiveRef.current = true;\n setHandoffActive(true);\n }\n void recording.start();\n }, [recording, speechHandoff]);\n\n const cancelRecording = useCallback(() => {\n cancelHandoff();\n }, [cancelHandoff]);\n\n // Stop recording, transcribe the audio and fill the input for review.\n // Returns the trimmed transcription (or null if nothing was transcribed) so\n // the handoff loop can decide whether to auto-send or end.\n const confirmRecording = useCallback(async (): Promise<string | null> => {\n if (!transcribeClient) return null;\n const blob = await recording.stop();\n if (!blob || blob.size === 0) return null;\n\n setIsTranscribing(true);\n setSpeechError(null);\n try {\n const result = await transcribeClient.transcribeAudio(blob, {\n language: speechLanguage,\n tenantId: speechTenantId,\n });\n const text = (result.text || '').trim();\n if (text) {\n setMessage((prev) => (prev ? `${prev} ${text}`.trim() : text));\n setTranscriptId(result.transcriptId);\n }\n // Resize textarea and focus for review/edit.\n requestAnimationFrame(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px`;\n textarea.focus();\n }\n });\n return text;\n } catch (e) {\n setSpeechError(\n `Could not transcribe the audio: ${(e as Error)?.message || 'unknown error'}`,\n );\n return null;\n } finally {\n setIsTranscribing(false);\n }\n }, [transcribeClient, recording, speechLanguage, speechTenantId]);\n\n // Cancellable countdown, then auto-send. Handoff stays active across the send\n // so the loop can continue after the assistant replies.\n const startPendingSend = useCallback(() => {\n const totalMs = speechHandoffSendDelayMs ?? HANDOFF_PENDING_MS;\n setPendingSend(true);\n setPendingProgress(1);\n const startedAt = Date.now();\n const step = () => {\n const elapsed = Date.now() - startedAt;\n setPendingProgress(Math.max(0, 1 - elapsed / totalMs));\n if (elapsed >= totalMs) {\n pendingRafRef.current = null;\n setPendingSend(false);\n setPendingProgress(1);\n handleSendRef.current(); // auto-send with the freshest message\n return;\n }\n pendingRafRef.current = requestAnimationFrame(step);\n };\n pendingRafRef.current = requestAnimationFrame(step);\n }, [speechHandoffSendDelayMs]);\n\n // Drives both the mic auto-stop and the manual confirm button, branching on\n // whether the hands-free loop is active.\n const handleConfirm = useCallback(async () => {\n const text = await confirmRecording();\n if (!handoffActiveRef.current) return; // normal mode: input already filled\n if (!text) {\n // Silent / empty turn → end the hands-free loop.\n cancelHandoff();\n setMessage('');\n setTranscriptId(undefined);\n return;\n }\n startPendingSend();\n }, [confirmRecording, cancelHandoff, startPendingSend]);\n\n // Auto-stop fires handleConfirm with the freshest closure.\n useEffect(() => {\n confirmRef.current = () => void handleConfirm();\n }, [handleConfirm]);\n\n // Any interaction during the pending countdown cancels the auto-send and\n // exits the loop (the user is taking manual control); text stays for editing.\n useEffect(() => {\n if (!pendingSend) return;\n const onInteract = () => {\n clearPending();\n handoffActiveRef.current = false;\n setHandoffActive(false);\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n document.addEventListener('mousedown', onInteract, true);\n document.addEventListener('keydown', onInteract, true);\n return () => {\n document.removeEventListener('mousedown', onInteract, true);\n document.removeEventListener('keydown', onInteract, true);\n };\n }, [pendingSend, clearPending]);\n\n // When the assistant finishes (isProcessing falls) while the loop is active,\n // re-activate listening for the next turn.\n useEffect(() => {\n const wasProcessing = prevProcessingRef.current;\n prevProcessingRef.current = isProcessing;\n if (\n handoffActive &&\n wasProcessing &&\n !isProcessing &&\n !disabled &&\n !pendingSend &&\n !isTranscribing &&\n !recording.isRecording &&\n !recording.isPaused\n ) {\n void recording.start();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isProcessing, handoffActive, disabled, pendingSend, isTranscribing]);\n\n // While listening in handoff with no speech yet, end the loop after a silence\n // window (an open mic with nothing said means the user is done).\n useEffect(() => {\n if (!(handoffActive && recording.isRecording && !recording.speechDetected)) {\n if (inactivityTimerRef.current) {\n clearTimeout(inactivityTimerRef.current);\n inactivityTimerRef.current = null;\n }\n return;\n }\n inactivityTimerRef.current = setTimeout(() => {\n if (handoffActiveRef.current && !recording.speechDetected) cancelHandoff();\n }, HANDOFF_INACTIVITY_MS);\n return () => {\n if (inactivityTimerRef.current) {\n clearTimeout(inactivityTimerRef.current);\n inactivityTimerRef.current = null;\n }\n };\n }, [handoffActive, recording.isRecording, recording.speechDetected, cancelHandoff]);\n\n // Cleanup deferred work on unmount.\n useEffect(() => {\n return () => {\n if (pendingRafRef.current !== null) cancelAnimationFrame(pendingRafRef.current);\n if (inactivityTimerRef.current) clearTimeout(inactivityTimerRef.current);\n };\n }, []);\n\n // Handle key press\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSend();\n }\n },\n [handleSend]\n );\n\n // Handle file selection\n const handleFileSelect = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const selectedFiles = Array.from(e.target.files || []);\n\n // Filter valid files\n const validFiles = selectedFiles.filter((file) => {\n if (file.size > maxFileSize) {\n console.warn(`File ${file.name} exceeds maximum size`);\n return false;\n }\n return true;\n });\n\n setFiles((prev) => [...prev, ...validFiles]);\n\n // Reset input\n if (fileInputRef.current) {\n fileInputRef.current.value = '';\n }\n },\n [maxFileSize]\n );\n\n // Remove file\n const removeFile = useCallback((index: number) => {\n setFiles((prev) => prev.filter((_, i) => i !== index));\n }, []);\n\n return (\n <div className=\"devic-input-area\">\n {limitBanner}\n {usageBar}\n {disabledMessage && disabled && (\n <div className=\"devic-input-disabled-notice\">\n <WaitingIcon />\n {disabledMessage}\n </div>\n )}\n {speechError && (\n <div className=\"devic-speech-error\" role=\"alert\">\n {speechError}\n </div>\n )}\n {handoffActive && (\n <div className=\"devic-handoff-bar\" data-waiting={isProcessing ? 'true' : 'false'}>\n <span className=\"devic-handoff-dot\" aria-hidden=\"true\" />\n <span className=\"devic-handoff-label\">\n {isProcessing ? 'Hands-free · waiting for reply' : 'Hands-free on'}\n </span>\n <button\n type=\"button\"\n className=\"devic-handoff-stop\"\n onClick={cancelHandoff}\n title=\"Stop hands-free\"\n aria-label=\"Stop hands-free\"\n >\n <CloseIcon />\n </button>\n </div>\n )}\n {references && references.length > 0 && (\n <div className=\"devic-reference-chips\">\n {references.map((ref) => (\n <div key={ref.id} className=\"devic-reference-chip\" title={ref.label}>\n <ReferenceIcon />\n <span className=\"devic-reference-chip-label\">\"{ref.label}\"</span>\n <button\n type=\"button\"\n className=\"devic-reference-chip-remove\"\n onClick={() => onRemoveReference?.(ref.id)}\n aria-label=\"Quitar referencia\"\n >\n &times;\n </button>\n </div>\n ))}\n </div>\n )}\n {files.length > 0 && (\n <div className=\"devic-file-preview\">\n {files.map((file, idx) => (\n <div key={idx} className=\"devic-file-preview-item\">\n <FileIcon />\n <span>{file.name}</span>\n <button\n className=\"devic-file-remove\"\n onClick={() => removeFile(idx)}\n type=\"button\"\n >\n &times;\n </button>\n </div>\n ))}\n </div>\n )}\n\n <div className=\"devic-input-wrapper\">\n {pendingSend ? (\n <div className=\"devic-speech-panel\" data-state=\"pending\">\n <div className=\"devic-handoff-pending\">\n <div className=\"devic-handoff-pending-icon\">\n <SendCountdownRing progress={pendingProgress} />\n <SendIcon />\n </div>\n <div className=\"devic-handoff-pending-text\">\n <span className=\"devic-handoff-pending-title\">\n Sending… interact to cancel\n </span>\n {message.trim() && (\n <span className=\"devic-handoff-pending-preview\">{message.trim()}</span>\n )}\n </div>\n </div>\n </div>\n ) : isTranscribing ? (\n <div className=\"devic-speech-panel\" data-state=\"processing\">\n <span className=\"devic-speech-spinner\" aria-hidden=\"true\" />\n <span className=\"devic-speech-status\">Transcribing…</span>\n </div>\n ) : isRecordingActive ? (\n <div className=\"devic-speech-panel\" data-state=\"recording\">\n <button\n className=\"devic-input-btn devic-speech-cancel\"\n onClick={cancelRecording}\n type=\"button\"\n title=\"Cancel recording\"\n >\n <CloseIcon />\n </button>\n <div className=\"devic-speech-live\">\n <Equalizer levels={recording.levels} paused={recording.isPaused} />\n <span className=\"devic-speech-timer\">\n {formatDuration(recording.durationMs)}\n </span>\n </div>\n <button\n className=\"devic-input-btn\"\n onClick={recording.isPaused ? recording.resume : recording.pause}\n type=\"button\"\n title={recording.isPaused ? 'Resume' : 'Pause'}\n >\n {recording.isPaused ? <PlayIcon /> : <PauseIcon />}\n </button>\n <div\n className=\"devic-speech-confirm-wrap\"\n data-autostop={recording.isAutoStopping ? 'true' : 'false'}\n >\n {recording.isAutoStopping && (\n <AutoStopRing progress={recording.autoStopProgress} />\n )}\n <button\n className=\"devic-input-btn devic-speech-confirm\"\n onClick={() => void handleConfirm()}\n type=\"button\"\n title={\n recording.isAutoStopping\n ? 'Auto-sending… keep talking to cancel'\n : 'Confirm'\n }\n >\n <CheckIcon />\n </button>\n </div>\n </div>\n ) : (\n <>\n {enableFileUploads && (\n <>\n <input\n ref={fileInputRef}\n type=\"file\"\n accept={acceptedTypes}\n multiple\n onChange={handleFileSelect}\n style={{ display: 'none' }}\n />\n <button\n className=\"devic-input-btn\"\n onClick={() => fileInputRef.current?.click()}\n disabled={disabled}\n type=\"button\"\n title=\"Attach file\"\n >\n <AttachIcon />\n </button>\n </>\n )}\n\n {speechEnabled && (\n <button\n className=\"devic-input-btn devic-speech-mic\"\n onClick={startRecording}\n disabled={disabled || isProcessing}\n type=\"button\"\n title=\"Record voice message\"\n >\n <MicIcon />\n </button>\n )}\n\n <textarea\n ref={textareaRef}\n className=\"devic-input\"\n value={message}\n onChange={(e) => {\n const value = e.target.value;\n setMessage(value);\n // If the user clears the field, drop the transcript link so a fresh\n // message isn't wrongly attributed to the previous transcription.\n if (transcriptId && value.trim() === '') setTranscriptId(undefined);\n handleInput();\n }}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n rows={1}\n />\n\n {isProcessing ? (\n stopButtonContent ? (\n <div className=\"devic-send-btn-wrapper\">\n <div className=\"devic-send-btn-custom\" aria-hidden=\"true\">\n {stopButtonContent}\n </div>\n <button\n className=\"devic-send-btn-overlay\"\n onClick={onStop}\n type=\"button\"\n title=\"Stop\"\n />\n </div>\n ) : (\n <button\n className=\"devic-input-btn devic-stop-btn\"\n onClick={onStop}\n type=\"button\"\n title=\"Stop\"\n >\n <StopIcon />\n </button>\n )\n ) : sendButtonContent ? (\n <div className=\"devic-send-btn-wrapper\">\n <div className=\"devic-send-btn-custom\" aria-hidden=\"true\">\n {sendButtonContent}\n </div>\n <button\n className=\"devic-send-btn-overlay\"\n onClick={handleSend}\n disabled={disabled || (!message.trim() && files.length === 0)}\n type=\"button\"\n title=\"Send message\"\n />\n </div>\n ) : (\n <button\n className=\"devic-input-btn devic-send-btn\"\n onClick={handleSend}\n disabled={disabled || (!message.trim() && files.length === 0)}\n type=\"button\"\n title=\"Send message\"\n >\n <SendIcon />\n </button>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Live equalizer rendered from the recording amplitude levels (0..1 per bar).\n * When paused, bars collapse to a flat baseline.\n */\nfunction Equalizer({\n levels,\n paused,\n}: {\n levels: number[];\n paused: boolean;\n}): JSX.Element {\n return (\n <div className=\"devic-equalizer\" aria-hidden=\"true\" data-paused={paused}>\n {levels.map((level, i) => (\n <span\n key={i}\n className=\"devic-equalizer-bar\"\n style={{ height: `${Math.max(10, Math.round((paused ? 0 : level) * 100))}%` }}\n />\n ))}\n </div>\n );\n}\n\n// Geometry for the auto-stop ring drawn around the confirm button.\nconst AUTOSTOP_RING_R = 18;\nconst AUTOSTOP_RING_C = 2 * Math.PI * AUTOSTOP_RING_R;\n\n/**\n * Inverted circular progress drawn around the confirm button. Driven by\n * `progress` (1 → 0): a full ring that drains to empty over the countdown.\n */\nfunction AutoStopRing({ progress }: { progress: number }): JSX.Element {\n return (\n <svg className=\"devic-autostop-ring\" viewBox=\"0 0 40 40\" aria-hidden=\"true\">\n <circle\n className=\"devic-autostop-ring-track\"\n cx=\"20\"\n cy=\"20\"\n r={AUTOSTOP_RING_R}\n />\n <circle\n className=\"devic-autostop-ring-progress\"\n cx=\"20\"\n cy=\"20\"\n r={AUTOSTOP_RING_R}\n style={{\n strokeDasharray: AUTOSTOP_RING_C,\n strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),\n }}\n />\n </svg>\n );\n}\n\n/**\n * Draining ring around the send icon during the handoff pending countdown.\n * Visually distinct from the auto-stop ring (slate→primary track, larger).\n */\nfunction SendCountdownRing({ progress }: { progress: number }): JSX.Element {\n return (\n <svg className=\"devic-handoff-ring\" viewBox=\"0 0 44 44\" aria-hidden=\"true\">\n <circle className=\"devic-handoff-ring-track\" cx=\"22\" cy=\"22\" r={AUTOSTOP_RING_R} />\n <circle\n className=\"devic-handoff-ring-progress\"\n cx=\"22\"\n cy=\"22\"\n r={AUTOSTOP_RING_R}\n style={{\n strokeDasharray: AUTOSTOP_RING_C,\n strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),\n }}\n />\n </svg>\n );\n}\n\n/** Formats milliseconds as m:ss. */\nfunction formatDuration(ms: number): string {\n const totalSeconds = Math.floor(ms / 1000);\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, '0')}`;\n}\n\n/**\n * Attach icon\n */\nfunction AttachIcon(): JSX.Element {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48\" />\n </svg>\n );\n}\n\n/**\n * Send icon\n */\nfunction SendIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" />\n </svg>\n );\n}\n\n/**\n * File icon\n */\nfunction FileIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14,2 14,8 20,8\" />\n </svg>\n );\n}\n\n/**\n * Microphone icon\n */\nfunction MicIcon(): JSX.Element {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\" />\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\" />\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\" />\n <line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\" />\n </svg>\n );\n}\n\n/**\n * Pause icon (two bars)\n */\nfunction PauseIcon(): JSX.Element {\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <rect x=\"6\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" />\n <rect x=\"14\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" />\n </svg>\n );\n}\n\n/**\n * Play icon (triangle)\n */\nfunction PlayIcon(): JSX.Element {\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M8 5v14l11-7z\" />\n </svg>\n );\n}\n\n/**\n * Check icon (confirm)\n */\nfunction CheckIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n );\n}\n\n/**\n * Close icon (cancel)\n */\nfunction CloseIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n/**\n * Stop icon (square)\n */\nfunction StopIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\" />\n </svg>\n );\n}\n\n/**\n * Reference icon (corner-down-right arrow)\n */\nfunction ReferenceIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"15 10 20 15 15 20\" />\n <path d=\"M4 4v7a4 4 0 0 0 4 4h12\" />\n </svg>\n );\n}\n\n/**\n * Waiting icon (clock)\n */\nfunction WaitingIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <polyline points=\"12,6 12,12 16,14\" />\n </svg>\n );\n}\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;AAKA,MAAM,gBAAgB,GAA6B;IACjD,MAAM,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,E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AAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,yBAAyB,EAAA,CAAG,CAAA,EAAA,CAChC;AAEV;AAEA;;AAEG;AACH,SAAS,WAAW,GAAA;IAClB,QACEC,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,QAAA,EAAA,CAEtBD,GAAA,CAAA,QAAA,EAAA,EAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,EAAA,CAAG,EACjCA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,kBAAkB,EAAA,CAAG,CAAA,EAAA,CAClC;AAEV;;;;"}
1
+ {"version":3,"file":"ChatInput.js","sources":["../../../../src/components/ChatDrawer/ChatInput.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useMemo, useEffect } from 'react';\nimport type { ChatInputProps } from './ChatDrawer.types';\nimport { useSpeechRecording } from '../../hooks/useSpeechRecording';\nimport { DevicApiClient } from '../../api/client';\n\nconst FILE_TYPE_ACCEPT: Record<string, string[]> = {\n images: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'],\n documents: [\n 'application/pdf',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'text/plain',\n 'text/csv',\n ],\n audio: ['audio/mpeg', 'audio/wav', 'audio/ogg'],\n video: ['video/mp4', 'video/webm', 'video/ogg'],\n};\n\n// Handoff (hands-free) loop timings.\nconst HANDOFF_PENDING_MS = 1000; // default cancellable countdown before auto-send\nconst HANDOFF_INACTIVITY_MS = 6000; // silence (no speech) that ends the loop\nconst HANDOFF_HOLD_MS = 3000; // press-and-hold duration on the mic to arm hands-free\n\n/**\n * Chat input component with file upload support\n */\nexport function ChatInput({\n onSend,\n disabled = false,\n placeholder = 'Type a message...',\n enableFileUploads = false,\n allowedFileTypes = { images: true, documents: true },\n maxFileSize = 10 * 1024 * 1024, // 10MB\n enableSpeechToText = false,\n speechLanguage,\n speechTenantId,\n speechAutoStop = true,\n speechAutoStopCountdownMs,\n speechAutoStopSilenceMs,\n speechAutoStopSilenceRatio,\n speechAutoStopSilenceLevel,\n speechAutoStopSpeechLevel,\n speechHandoff = false,\n speechHandoffSendDelayMs,\n speechHandoffHoldMs,\n apiKey,\n baseUrl,\n sendButtonContent,\n disabledMessage,\n isProcessing = false,\n onStop,\n stopButtonContent,\n pendingInputWidget,\n onSubmitWidget,\n onCancelWidget,\n references,\n onRemoveReference,\n usageBar,\n limitBanner,\n}: ChatInputProps): JSX.Element {\n // When a widget is pending as 'input', render it in place of the textarea\n if (pendingInputWidget) {\n const WidgetComponent = pendingInputWidget.widget.component;\n return (\n <div className=\"devic-input-area\" data-widget-mode=\"input\">\n <div className=\"devic-input-widget\" data-tool-name={pendingInputWidget.toolName}>\n <WidgetComponent\n toolCall={pendingInputWidget.toolCall}\n params={pendingInputWidget.params}\n submit={(response) => onSubmitWidget?.(pendingInputWidget.toolCall.id, response)}\n cancel={(reason) => onCancelWidget?.(pendingInputWidget.toolCall.id, reason)}\n />\n </div>\n </div>\n );\n }\n const [message, setMessage] = useState('');\n const [files, setFiles] = useState<File[]>([]);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Speech-to-text state\n const [transcriptId, setTranscriptId] = useState<string | undefined>();\n const [isTranscribing, setIsTranscribing] = useState(false);\n const [speechError, setSpeechError] = useState<string | null>(null);\n // Holds the latest confirmRecording so the auto-stop callback (created before\n // confirmRecording is defined) always calls the current closure.\n const confirmRef = useRef<() => void>(() => {});\n const recording = useSpeechRecording({\n bars: 5,\n autoStop: speechAutoStop,\n ...(speechAutoStopCountdownMs != null && {\n autoStopCountdownMs: speechAutoStopCountdownMs,\n }),\n ...(speechAutoStopSilenceMs != null && {\n autoStopSilenceMs: speechAutoStopSilenceMs,\n }),\n ...(speechAutoStopSilenceRatio != null && {\n autoStopSilenceRatio: speechAutoStopSilenceRatio,\n }),\n ...(speechAutoStopSilenceLevel != null && {\n autoStopSilenceLevel: speechAutoStopSilenceLevel,\n }),\n ...(speechAutoStopSpeechLevel != null && {\n autoStopSpeechLevel: speechAutoStopSpeechLevel,\n }),\n onAutoStop: () => confirmRef.current(),\n });\n\n // --- Handoff (hands-free loop) state ---\n const [handoffActive, setHandoffActive] = useState(false);\n const [pendingSend, setPendingSend] = useState(false);\n const [pendingProgress, setPendingProgress] = useState(1);\n // Ref mirror so async callbacks (rAF, timers, document listeners) read the\n // live value without going stale.\n const handoffActiveRef = useRef(false);\n const pendingRafRef = useRef<number | null>(null);\n const inactivityTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const prevProcessingRef = useRef(isProcessing);\n // Always-fresh send fn so the deferred auto-send uses the latest message.\n const handleSendRef = useRef<() => void>(() => {});\n\n // --- Press-and-hold to arm hands-free ---\n // Holding the mic for `holdMs` fills a ring (0→1) and activates hands-free;\n // releasing earlier falls back to a single one-shot recording.\n const [holdProgress, setHoldProgress] = useState(0);\n const [isHolding, setIsHolding] = useState(false);\n const holdRafRef = useRef<number | null>(null);\n const holdFiredRef = useRef(false);\n\n // Client used only for the /whisper transcription call.\n const transcribeClient = useMemo(() => {\n if (!enableSpeechToText || !apiKey) return null;\n return new DevicApiClient({\n apiKey,\n baseUrl: baseUrl || 'https://api.devic.ai',\n });\n }, [enableSpeechToText, apiKey, baseUrl]);\n\n const speechEnabled =\n enableSpeechToText && recording.isSupported && !!transcribeClient;\n const isRecordingActive = recording.isRecording || recording.isPaused;\n\n // Calculate accepted file types\n const acceptedTypes = Object.entries(allowedFileTypes)\n .filter(([, enabled]) => enabled)\n .flatMap(([type]) => FILE_TYPE_ACCEPT[type] || [])\n .join(',');\n\n // Auto-resize textarea\n const handleInput = useCallback(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px`;\n }\n }, []);\n\n // Handle send\n const handleSend = useCallback(() => {\n const trimmedMessage = message.trim();\n if (!trimmedMessage && files.length === 0) return;\n\n onSend(\n trimmedMessage,\n files.length > 0 ? files : undefined,\n transcriptId ? { transcriptId } : undefined,\n );\n setMessage('');\n setFiles([]);\n setTranscriptId(undefined);\n\n // Reset textarea height\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n }\n }, [message, files, onSend, transcriptId]);\n // Keep a fresh send fn for the deferred handoff auto-send.\n handleSendRef.current = handleSend;\n\n // --- Speech-to-text handlers ---\n\n const clearPending = useCallback(() => {\n if (pendingRafRef.current !== null) {\n cancelAnimationFrame(pendingRafRef.current);\n pendingRafRef.current = null;\n }\n setPendingSend(false);\n setPendingProgress(1);\n }, []);\n\n // Fully exit the hands-free loop and stop any recording in progress.\n const cancelHandoff = useCallback(() => {\n handoffActiveRef.current = false;\n setHandoffActive(false);\n clearPending();\n if (inactivityTimerRef.current) {\n clearTimeout(inactivityTimerRef.current);\n inactivityTimerRef.current = null;\n }\n recording.cancel();\n }, [clearPending, recording]);\n\n // One-shot recording: transcribe → fill the textarea for manual review/send.\n // No hands-free loop, so the textarea stays available afterwards.\n const startOneShotRecording = useCallback(() => {\n setSpeechError(null);\n void recording.start();\n }, [recording]);\n\n // Arm the hands-free loop and start listening.\n const startHandsfreeRecording = useCallback(() => {\n setSpeechError(null);\n handoffActiveRef.current = true;\n setHandoffActive(true);\n void recording.start();\n }, [recording]);\n\n // Stop and reset the press-and-hold progress loop.\n const clearHold = useCallback(() => {\n if (holdRafRef.current !== null) {\n cancelAnimationFrame(holdRafRef.current);\n holdRafRef.current = null;\n }\n setIsHolding(false);\n setHoldProgress(0);\n }, []);\n\n // Mic pressed: when hands-free is available, run a hold timer whose ring fills\n // (0→1) over `holdMs`. Completing it activates hands-free; releasing earlier\n // (handleMicPointerUp) falls back to a one-shot recording. Pointer capture\n // keeps the release event on the button even if the finger drifts off.\n const handleMicPointerDown = useCallback(\n (e: React.PointerEvent) => {\n if (disabled || isProcessing) return;\n try {\n e.currentTarget.setPointerCapture(e.pointerId);\n } catch {\n // ignore environments without pointer capture\n }\n const holdMs = speechHandoffHoldMs ?? HANDOFF_HOLD_MS;\n holdFiredRef.current = false;\n setIsHolding(true);\n setHoldProgress(0);\n const startedAt = Date.now();\n const step = () => {\n const progress = Math.min(1, (Date.now() - startedAt) / holdMs);\n setHoldProgress(progress);\n if (progress >= 1) {\n holdRafRef.current = null;\n holdFiredRef.current = true;\n setIsHolding(false);\n setHoldProgress(0);\n startHandsfreeRecording();\n return;\n }\n holdRafRef.current = requestAnimationFrame(step);\n };\n holdRafRef.current = requestAnimationFrame(step);\n },\n [disabled, isProcessing, speechHandoffHoldMs, startHandsfreeRecording],\n );\n\n // Mic released: if the hold already armed hands-free, do nothing; otherwise\n // treat it as a tap and start a one-shot recording.\n const handleMicPointerUp = useCallback(() => {\n if (holdFiredRef.current) {\n holdFiredRef.current = false;\n return;\n }\n if (holdRafRef.current === null && !isHolding) return; // already aborted\n clearHold();\n startOneShotRecording();\n }, [isHolding, clearHold, startOneShotRecording]);\n\n // Pointer cancelled (e.g. interrupted touch): abort the hold without recording.\n const handleMicPointerCancel = useCallback(() => {\n if (holdFiredRef.current) {\n holdFiredRef.current = false;\n return;\n }\n clearHold();\n }, [clearHold]);\n\n const cancelRecording = useCallback(() => {\n cancelHandoff();\n }, [cancelHandoff]);\n\n // Stop recording, transcribe the audio and fill the input for review.\n // Returns the trimmed transcription (or null if nothing was transcribed) so\n // the handoff loop can decide whether to auto-send or end.\n const confirmRecording = useCallback(async (): Promise<string | null> => {\n if (!transcribeClient) return null;\n const blob = await recording.stop();\n if (!blob || blob.size === 0) return null;\n\n setIsTranscribing(true);\n setSpeechError(null);\n try {\n const result = await transcribeClient.transcribeAudio(blob, {\n language: speechLanguage,\n tenantId: speechTenantId,\n });\n const text = (result.text || '').trim();\n if (text) {\n setMessage((prev) => (prev ? `${prev} ${text}`.trim() : text));\n setTranscriptId(result.transcriptId);\n }\n // Resize textarea and focus for review/edit.\n requestAnimationFrame(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px`;\n textarea.focus();\n }\n });\n return text;\n } catch (e) {\n setSpeechError(\n `Could not transcribe the audio: ${(e as Error)?.message || 'unknown error'}`,\n );\n return null;\n } finally {\n setIsTranscribing(false);\n }\n }, [transcribeClient, recording, speechLanguage, speechTenantId]);\n\n // Cancellable countdown, then auto-send. Handoff stays active across the send\n // so the loop can continue after the assistant replies.\n const startPendingSend = useCallback(() => {\n const totalMs = speechHandoffSendDelayMs ?? HANDOFF_PENDING_MS;\n setPendingSend(true);\n setPendingProgress(1);\n const startedAt = Date.now();\n const step = () => {\n const elapsed = Date.now() - startedAt;\n setPendingProgress(Math.max(0, 1 - elapsed / totalMs));\n if (elapsed >= totalMs) {\n pendingRafRef.current = null;\n setPendingSend(false);\n setPendingProgress(1);\n handleSendRef.current(); // auto-send with the freshest message\n return;\n }\n pendingRafRef.current = requestAnimationFrame(step);\n };\n pendingRafRef.current = requestAnimationFrame(step);\n }, [speechHandoffSendDelayMs]);\n\n // Drives both the mic auto-stop and the manual confirm button, branching on\n // whether the hands-free loop is active.\n const handleConfirm = useCallback(async () => {\n const text = await confirmRecording();\n if (!handoffActiveRef.current) return; // normal mode: input already filled\n if (!text) {\n // Silent / empty turn → end the hands-free loop.\n cancelHandoff();\n setMessage('');\n setTranscriptId(undefined);\n return;\n }\n startPendingSend();\n }, [confirmRecording, cancelHandoff, startPendingSend]);\n\n // Auto-stop fires handleConfirm with the freshest closure.\n useEffect(() => {\n confirmRef.current = () => void handleConfirm();\n }, [handleConfirm]);\n\n // Any interaction during the pending countdown cancels the auto-send and\n // exits the loop (the user is taking manual control); text stays for editing.\n useEffect(() => {\n if (!pendingSend) return;\n const onInteract = () => {\n clearPending();\n handoffActiveRef.current = false;\n setHandoffActive(false);\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n document.addEventListener('mousedown', onInteract, true);\n document.addEventListener('keydown', onInteract, true);\n return () => {\n document.removeEventListener('mousedown', onInteract, true);\n document.removeEventListener('keydown', onInteract, true);\n };\n }, [pendingSend, clearPending]);\n\n // When the assistant finishes (isProcessing falls) while the loop is active,\n // re-activate listening for the next turn.\n useEffect(() => {\n const wasProcessing = prevProcessingRef.current;\n prevProcessingRef.current = isProcessing;\n if (\n handoffActive &&\n wasProcessing &&\n !isProcessing &&\n !disabled &&\n !pendingSend &&\n !isTranscribing &&\n !recording.isRecording &&\n !recording.isPaused\n ) {\n void recording.start();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isProcessing, handoffActive, disabled, pendingSend, isTranscribing]);\n\n // While listening in handoff with no speech yet, end the loop after a silence\n // window (an open mic with nothing said means the user is done).\n useEffect(() => {\n if (!(handoffActive && recording.isRecording && !recording.speechDetected)) {\n if (inactivityTimerRef.current) {\n clearTimeout(inactivityTimerRef.current);\n inactivityTimerRef.current = null;\n }\n return;\n }\n inactivityTimerRef.current = setTimeout(() => {\n if (handoffActiveRef.current && !recording.speechDetected) cancelHandoff();\n }, HANDOFF_INACTIVITY_MS);\n return () => {\n if (inactivityTimerRef.current) {\n clearTimeout(inactivityTimerRef.current);\n inactivityTimerRef.current = null;\n }\n };\n }, [handoffActive, recording.isRecording, recording.speechDetected, cancelHandoff]);\n\n // Cleanup deferred work on unmount.\n useEffect(() => {\n return () => {\n if (pendingRafRef.current !== null) cancelAnimationFrame(pendingRafRef.current);\n if (inactivityTimerRef.current) clearTimeout(inactivityTimerRef.current);\n if (holdRafRef.current !== null) cancelAnimationFrame(holdRafRef.current);\n };\n }, []);\n\n // Handle key press\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSend();\n }\n },\n [handleSend]\n );\n\n // Handle file selection\n const handleFileSelect = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const selectedFiles = Array.from(e.target.files || []);\n\n // Filter valid files\n const validFiles = selectedFiles.filter((file) => {\n if (file.size > maxFileSize) {\n console.warn(`File ${file.name} exceeds maximum size`);\n return false;\n }\n return true;\n });\n\n setFiles((prev) => [...prev, ...validFiles]);\n\n // Reset input\n if (fileInputRef.current) {\n fileInputRef.current.value = '';\n }\n },\n [maxFileSize]\n );\n\n // Remove file\n const removeFile = useCallback((index: number) => {\n setFiles((prev) => prev.filter((_, i) => i !== index));\n }, []);\n\n return (\n <div className=\"devic-input-area\">\n {limitBanner}\n {usageBar}\n {disabledMessage && disabled && (\n <div className=\"devic-input-disabled-notice\">\n <WaitingIcon />\n {disabledMessage}\n </div>\n )}\n {speechError && (\n <div className=\"devic-speech-error\" role=\"alert\">\n {speechError}\n </div>\n )}\n {handoffActive && (\n <div className=\"devic-handoff-bar\" data-waiting={isProcessing ? 'true' : 'false'}>\n <span className=\"devic-handoff-dot\" aria-hidden=\"true\" />\n <span className=\"devic-handoff-label\">\n {isProcessing ? 'Hands-free · waiting for reply' : 'Hands-free on'}\n </span>\n <button\n type=\"button\"\n className=\"devic-handoff-stop\"\n onClick={cancelHandoff}\n title=\"Stop hands-free\"\n aria-label=\"Stop hands-free\"\n >\n <CloseIcon />\n </button>\n </div>\n )}\n {references && references.length > 0 && (\n <div className=\"devic-reference-chips\">\n {references.map((ref) => (\n <div key={ref.id} className=\"devic-reference-chip\" title={ref.label}>\n <ReferenceIcon />\n <span className=\"devic-reference-chip-label\">\"{ref.label}\"</span>\n <button\n type=\"button\"\n className=\"devic-reference-chip-remove\"\n onClick={() => onRemoveReference?.(ref.id)}\n aria-label=\"Quitar referencia\"\n >\n &times;\n </button>\n </div>\n ))}\n </div>\n )}\n {files.length > 0 && (\n <div className=\"devic-file-preview\">\n {files.map((file, idx) => (\n <div key={idx} className=\"devic-file-preview-item\">\n <FileIcon />\n <span>{file.name}</span>\n <button\n className=\"devic-file-remove\"\n onClick={() => removeFile(idx)}\n type=\"button\"\n >\n &times;\n </button>\n </div>\n ))}\n </div>\n )}\n\n <div className=\"devic-input-wrapper\">\n {pendingSend ? (\n <div className=\"devic-speech-panel\" data-state=\"pending\">\n <div className=\"devic-handoff-pending\">\n <div className=\"devic-handoff-pending-icon\">\n <SendCountdownRing progress={pendingProgress} />\n <SendIcon />\n </div>\n <div className=\"devic-handoff-pending-text\">\n <span className=\"devic-handoff-pending-title\">\n Sending… interact to cancel\n </span>\n {message.trim() && (\n <span className=\"devic-handoff-pending-preview\">{message.trim()}</span>\n )}\n </div>\n </div>\n </div>\n ) : isTranscribing ? (\n <div className=\"devic-speech-panel\" data-state=\"processing\">\n <span className=\"devic-speech-spinner\" aria-hidden=\"true\" />\n <span className=\"devic-speech-status\">Transcribing…</span>\n </div>\n ) : isRecordingActive ? (\n <div className=\"devic-speech-panel\" data-state=\"recording\">\n <button\n className=\"devic-input-btn devic-speech-cancel\"\n onClick={cancelRecording}\n type=\"button\"\n title=\"Cancel recording\"\n >\n <CloseIcon />\n </button>\n <div className=\"devic-speech-live\">\n <Equalizer levels={recording.levels} paused={recording.isPaused} />\n <span className=\"devic-speech-timer\">\n {formatDuration(recording.durationMs)}\n </span>\n </div>\n <button\n className=\"devic-input-btn\"\n onClick={recording.isPaused ? recording.resume : recording.pause}\n type=\"button\"\n title={recording.isPaused ? 'Resume' : 'Pause'}\n >\n {recording.isPaused ? <PlayIcon /> : <PauseIcon />}\n </button>\n <div\n className=\"devic-speech-confirm-wrap\"\n data-autostop={recording.isAutoStopping ? 'true' : 'false'}\n >\n {recording.isAutoStopping && (\n <AutoStopRing progress={recording.autoStopProgress} />\n )}\n <button\n className=\"devic-input-btn devic-speech-confirm\"\n onClick={() => void handleConfirm()}\n type=\"button\"\n title={\n recording.isAutoStopping\n ? 'Auto-sending… keep talking to cancel'\n : 'Confirm'\n }\n >\n <CheckIcon />\n </button>\n </div>\n </div>\n ) : (\n <>\n {enableFileUploads && (\n <>\n <input\n ref={fileInputRef}\n type=\"file\"\n accept={acceptedTypes}\n multiple\n onChange={handleFileSelect}\n style={{ display: 'none' }}\n />\n <button\n className=\"devic-input-btn\"\n onClick={() => fileInputRef.current?.click()}\n disabled={disabled}\n type=\"button\"\n title=\"Attach file\"\n >\n <AttachIcon />\n </button>\n </>\n )}\n\n {speechEnabled && (\n <div\n className=\"devic-speech-mic-wrap\"\n data-holding={isHolding ? 'true' : 'false'}\n >\n {isHolding && <HoldRing progress={holdProgress} />}\n <button\n className=\"devic-input-btn devic-speech-mic\"\n onClick={speechHandoff ? undefined : startOneShotRecording}\n onPointerDown={speechHandoff ? handleMicPointerDown : undefined}\n onPointerUp={speechHandoff ? handleMicPointerUp : undefined}\n onPointerCancel={speechHandoff ? handleMicPointerCancel : undefined}\n disabled={disabled || isProcessing}\n type=\"button\"\n title={\n speechHandoff\n ? 'Tap to dictate · hold to start hands-free'\n : 'Record voice message'\n }\n >\n <MicIcon />\n </button>\n </div>\n )}\n\n <textarea\n ref={textareaRef}\n className=\"devic-input\"\n value={message}\n onChange={(e) => {\n const value = e.target.value;\n setMessage(value);\n // If the user clears the field, drop the transcript link so a fresh\n // message isn't wrongly attributed to the previous transcription.\n if (transcriptId && value.trim() === '') setTranscriptId(undefined);\n handleInput();\n }}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n rows={1}\n />\n\n {isProcessing ? (\n stopButtonContent ? (\n <div className=\"devic-send-btn-wrapper\">\n <div className=\"devic-send-btn-custom\" aria-hidden=\"true\">\n {stopButtonContent}\n </div>\n <button\n className=\"devic-send-btn-overlay\"\n onClick={onStop}\n type=\"button\"\n title=\"Stop\"\n />\n </div>\n ) : (\n <button\n className=\"devic-input-btn devic-stop-btn\"\n onClick={onStop}\n type=\"button\"\n title=\"Stop\"\n >\n <StopIcon />\n </button>\n )\n ) : sendButtonContent ? (\n <div className=\"devic-send-btn-wrapper\">\n <div className=\"devic-send-btn-custom\" aria-hidden=\"true\">\n {sendButtonContent}\n </div>\n <button\n className=\"devic-send-btn-overlay\"\n onClick={handleSend}\n disabled={disabled || (!message.trim() && files.length === 0)}\n type=\"button\"\n title=\"Send message\"\n />\n </div>\n ) : (\n <button\n className=\"devic-input-btn devic-send-btn\"\n onClick={handleSend}\n disabled={disabled || (!message.trim() && files.length === 0)}\n type=\"button\"\n title=\"Send message\"\n >\n <SendIcon />\n </button>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Live equalizer rendered from the recording amplitude levels (0..1 per bar).\n * When paused, bars collapse to a flat baseline.\n */\nfunction Equalizer({\n levels,\n paused,\n}: {\n levels: number[];\n paused: boolean;\n}): JSX.Element {\n return (\n <div className=\"devic-equalizer\" aria-hidden=\"true\" data-paused={paused}>\n {levels.map((level, i) => (\n <span\n key={i}\n className=\"devic-equalizer-bar\"\n style={{ height: `${Math.max(10, Math.round((paused ? 0 : level) * 100))}%` }}\n />\n ))}\n </div>\n );\n}\n\n// Geometry for the auto-stop ring drawn around the confirm button.\nconst AUTOSTOP_RING_R = 18;\nconst AUTOSTOP_RING_C = 2 * Math.PI * AUTOSTOP_RING_R;\n\n/**\n * Inverted circular progress drawn around the confirm button. Driven by\n * `progress` (1 → 0): a full ring that drains to empty over the countdown.\n */\nfunction AutoStopRing({ progress }: { progress: number }): JSX.Element {\n return (\n <svg className=\"devic-autostop-ring\" viewBox=\"0 0 40 40\" aria-hidden=\"true\">\n <circle\n className=\"devic-autostop-ring-track\"\n cx=\"20\"\n cy=\"20\"\n r={AUTOSTOP_RING_R}\n />\n <circle\n className=\"devic-autostop-ring-progress\"\n cx=\"20\"\n cy=\"20\"\n r={AUTOSTOP_RING_R}\n style={{\n strokeDasharray: AUTOSTOP_RING_C,\n strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),\n }}\n />\n </svg>\n );\n}\n\n/**\n * Draining ring around the send icon during the handoff pending countdown.\n * Visually distinct from the auto-stop ring (slate→primary track, larger).\n */\nfunction SendCountdownRing({ progress }: { progress: number }): JSX.Element {\n return (\n <svg className=\"devic-handoff-ring\" viewBox=\"0 0 44 44\" aria-hidden=\"true\">\n <circle className=\"devic-handoff-ring-track\" cx=\"22\" cy=\"22\" r={AUTOSTOP_RING_R} />\n <circle\n className=\"devic-handoff-ring-progress\"\n cx=\"22\"\n cy=\"22\"\n r={AUTOSTOP_RING_R}\n style={{\n strokeDasharray: AUTOSTOP_RING_C,\n strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),\n }}\n />\n </svg>\n );\n}\n\n/**\n * Filling ring drawn around the mic button while the user presses and holds to\n * arm hands-free. Driven by `progress` (0 → 1): an empty ring that fills\n * clockwise over the hold duration. Inverse of the draining auto-stop ring.\n */\nfunction HoldRing({ progress }: { progress: number }): JSX.Element {\n return (\n <svg className=\"devic-mic-hold-ring\" viewBox=\"0 0 40 40\" aria-hidden=\"true\">\n <circle\n className=\"devic-mic-hold-ring-track\"\n cx=\"20\"\n cy=\"20\"\n r={AUTOSTOP_RING_R}\n />\n <circle\n className=\"devic-mic-hold-ring-progress\"\n cx=\"20\"\n cy=\"20\"\n r={AUTOSTOP_RING_R}\n style={{\n strokeDasharray: AUTOSTOP_RING_C,\n strokeDashoffset: AUTOSTOP_RING_C * (1 - progress),\n }}\n />\n </svg>\n );\n}\n\n/** Formats milliseconds as m:ss. */\nfunction formatDuration(ms: number): string {\n const totalSeconds = Math.floor(ms / 1000);\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, '0')}`;\n}\n\n/**\n * Attach icon\n */\nfunction AttachIcon(): JSX.Element {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48\" />\n </svg>\n );\n}\n\n/**\n * Send icon\n */\nfunction SendIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" />\n </svg>\n );\n}\n\n/**\n * File icon\n */\nfunction FileIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14,2 14,8 20,8\" />\n </svg>\n );\n}\n\n/**\n * Microphone icon\n */\nfunction MicIcon(): JSX.Element {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\" />\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\" />\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\" />\n <line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\" />\n </svg>\n );\n}\n\n/**\n * Pause icon (two bars)\n */\nfunction PauseIcon(): JSX.Element {\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <rect x=\"6\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" />\n <rect x=\"14\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" />\n </svg>\n );\n}\n\n/**\n * Play icon (triangle)\n */\nfunction PlayIcon(): JSX.Element {\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M8 5v14l11-7z\" />\n </svg>\n );\n}\n\n/**\n * Check icon (confirm)\n */\nfunction CheckIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n );\n}\n\n/**\n * Close icon (cancel)\n */\nfunction CloseIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n/**\n * Stop icon (square)\n */\nfunction StopIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\" />\n </svg>\n );\n}\n\n/**\n * Reference icon (corner-down-right arrow)\n */\nfunction ReferenceIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"15 10 20 15 15 20\" />\n <path d=\"M4 4v7a4 4 0 0 0 4 4h12\" />\n </svg>\n );\n}\n\n/**\n * Waiting icon (clock)\n */\nfunction WaitingIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <polyline points=\"12,6 12,12 16,14\" />\n </svg>\n );\n}\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;AAKA,MAAM,gBAAgB,GAA6B;IACjD,MAAM,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC;AAC9D,IAAA,SAAS,EAAE;QACT,iBAAiB;QACjB,oBAAoB;QACpB,yEAAyE;QACzE,YAAY;QACZ,UAAU;AACX,KAAA;AACD,IAAA,KAAK,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,CAAC;AAC/C,IAAA,KAAK,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,CAAC;CAChD;AAED;AACA,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B;;AAEG;SACa,SAAS,CAAC,EACxB,MAAM,EACN,QAAQ,GAAG,KAAK,EAChB,WAAW,GAAG,mBAAmB,EACjC,iBAAiB,GAAG,KAAK,EACzB,gBAAgB,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EACpD,WAAW,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI;AAC9B,kBAAkB,GAAG,KAAK,EAC1B,cAAc,EACd,cAAc,EACd,cAAc,GAAG,IAAI,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,aAAa,GAAG,KAAK,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,MAAM,EACN,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,YAAY,GAAG,KAAK,EACpB,MAAM,EACN,iBAAiB,EACjB,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AAmB,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,yBAAyB,EAAA,CAAG,CAAA,EAAA,CAChC;AAEV;AAEA;;AAEG;AACH,SAAS,WAAW,GAAA;IAClB,QACEC,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,QAAA,EAAA,CAEtBD,GAAA,CAAA,QAAA,EAAA,EAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,EAAA,CAAG,EACjCA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,kBAAkB,EAAA,CAAG,CAAA,EAAA,CAClC;AAEV;;;;"}
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+ import type { TenantUsageRule } from '../../api/types';
1
3
  /**
2
4
  * Controls what each usage row renders. All flags compose, so a developer can,
3
5
  * for example, show absolute values together with the percentage and the tier.
@@ -32,6 +34,25 @@ export interface UsageBarDisplay {
32
34
  */
33
35
  showAllRules?: boolean;
34
36
  }
37
+ /**
38
+ * Usage data handed to a `customUsageBar` renderer so a developer can build
39
+ * their own component with the live consumption / limits.
40
+ */
41
+ export interface UsageBarData {
42
+ /** Tenant the usage belongs to. */
43
+ tenantId?: string;
44
+ /** Subtenant the usage is scoped to, if any. */
45
+ subtenantId?: string;
46
+ /** Tier (plan) the limits come from, if any. */
47
+ tierId?: string;
48
+ /**
49
+ * Applicable usage rules (filtered by `metric` when set), sorted by
50
+ * utilization descending — the most restrictive first.
51
+ */
52
+ rules: TenantUsageRule[];
53
+ /** `true` until the first fetch resolves. */
54
+ loading: boolean;
55
+ }
35
56
  /**
36
57
  * Props for the UsageBar component.
37
58
  */
@@ -57,6 +78,13 @@ export interface UsageBarProps {
57
78
  * to render all applicable rules or only the most restrictive one.
58
79
  */
59
80
  display?: UsageBarDisplay;
81
+ /**
82
+ * Render your own component instead of the built-in bar(s). Receives the live
83
+ * usage data (rules + tier + loading) and renders in the same slot, replacing
84
+ * the default UI entirely. When set, fetching/polling is still handled here;
85
+ * `mode`/`display` only affect the default UI and are ignored.
86
+ */
87
+ customUsageBar?: (data: UsageBarData) => React.ReactNode;
60
88
  /** Primary color for the bar fill (below the warning threshold). */
61
89
  color?: string;
62
90
  /**
@@ -72,4 +100,4 @@ export interface UsageBarProps {
72
100
  * Rendered above the chat input. Antd-free — styled via `.devic-usage-*` classes.
73
101
  * Renders nothing when there are no usage limits configured for the tenant.
74
102
  */
75
- export declare function UsageBar({ apiKey, baseUrl, tenantId, subtenantId, mode, metric, display, color, refreshKey, debug, }: UsageBarProps): JSX.Element | null;
103
+ export declare function UsageBar({ apiKey, baseUrl, tenantId, subtenantId, mode, metric, display, customUsageBar, color, refreshKey, debug, }: UsageBarProps): JSX.Element | null;