@glydeunity/voice-sdk 1.3.6 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/glyde-chat.umd.js +265 -0
- package/dist/glyde-chat.umd.js.map +1 -0
- package/dist/index.d.ts +851 -16
- package/dist/voice-sdk.es.js +1738 -70
- package/dist/voice-sdk.es.js.map +1 -0
- package/package.json +29 -9
- package/dist/voice-sdk.umd.js +0 -140
package/dist/voice-sdk.es.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import z, { useState as k, useRef as E, useCallback as A, useEffect as I } from "react";
|
|
2
|
+
import { jsxs as d, jsx as i, Fragment as K } from "react/jsx-runtime";
|
|
3
|
+
import { createRoot as D } from "react-dom/client";
|
|
4
|
+
const J = `
|
|
2
5
|
class AudioCaptureProcessor extends AudioWorkletProcessor {
|
|
3
6
|
constructor() {
|
|
4
7
|
super();
|
|
@@ -33,7 +36,7 @@ class AudioCaptureProcessor extends AudioWorkletProcessor {
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
registerProcessor('audio-capture-processor', AudioCaptureProcessor);
|
|
36
|
-
`,
|
|
39
|
+
`, q = `
|
|
37
40
|
class AudioPlaybackProcessor extends AudioWorkletProcessor {
|
|
38
41
|
constructor() {
|
|
39
42
|
super();
|
|
@@ -131,7 +134,7 @@ class AudioPlaybackProcessor extends AudioWorkletProcessor {
|
|
|
131
134
|
|
|
132
135
|
registerProcessor('audio-playback-processor', AudioPlaybackProcessor);
|
|
133
136
|
`;
|
|
134
|
-
class
|
|
137
|
+
class Y {
|
|
135
138
|
config;
|
|
136
139
|
unityUrl;
|
|
137
140
|
active = !1;
|
|
@@ -176,16 +179,16 @@ class y {
|
|
|
176
179
|
* @returns Voice configuration including system prompt, tools, and Deepgram settings
|
|
177
180
|
*/
|
|
178
181
|
async fetchConfig() {
|
|
179
|
-
const e = `${this.unityUrl}/api/unity/voice/config/${this.config.contextType}`, t = this.config.contextId ? `${e}/${this.config.contextId}` : e,
|
|
182
|
+
const e = `${this.unityUrl}/api/unity/voice/config/${this.config.contextType}`, t = this.config.contextId ? `${e}/${this.config.contextId}` : e, o = await fetch(t, {
|
|
180
183
|
method: "GET",
|
|
181
184
|
headers: this.getAuthHeaders()
|
|
182
185
|
});
|
|
183
|
-
if (!
|
|
184
|
-
const
|
|
185
|
-
throw new Error(
|
|
186
|
+
if (!o.ok) {
|
|
187
|
+
const s = await o.json();
|
|
188
|
+
throw new Error(s.error?.message || s.message || "Failed to fetch voice config");
|
|
186
189
|
}
|
|
187
|
-
const { data:
|
|
188
|
-
return
|
|
190
|
+
const { data: n } = await o.json();
|
|
191
|
+
return n;
|
|
189
192
|
}
|
|
190
193
|
/**
|
|
191
194
|
* Initialize and start the voice session
|
|
@@ -209,23 +212,23 @@ class y {
|
|
|
209
212
|
const a = await t.json();
|
|
210
213
|
throw new Error(a.error?.message || a.message || "Failed to authenticate voice session");
|
|
211
214
|
}
|
|
212
|
-
const { data:
|
|
215
|
+
const { data: o } = await t.json(), { token: n, agent_config: s, deepgram_config: c } = o;
|
|
213
216
|
this.setSessionContext({
|
|
214
|
-
clientUuid:
|
|
217
|
+
clientUuid: s?.client_uuid,
|
|
215
218
|
contextId: this.config.contextId,
|
|
216
219
|
contextType: this.config.contextType,
|
|
217
|
-
currentJobUuid:
|
|
220
|
+
currentJobUuid: s?.job_uuid
|
|
218
221
|
});
|
|
219
|
-
const
|
|
222
|
+
const g = this.config.systemPrompt || s.instructions || this.serverConfig?.system_prompt || "You are a helpful AI assistant.";
|
|
220
223
|
await this.initializeAudio();
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
+
let y = "wss://agent.deepgram.com/v1/agent/converse";
|
|
225
|
+
const p = this.config.deepgramConfig || c || this.serverConfig?.deepgram_config;
|
|
226
|
+
if (p?.tags && p.tags.length > 0) {
|
|
224
227
|
const a = new URLSearchParams();
|
|
225
|
-
|
|
228
|
+
p.tags.forEach((h) => a.append("tag", h)), y += `?${a.toString()}`;
|
|
226
229
|
}
|
|
227
|
-
this.ws = new WebSocket(
|
|
228
|
-
const a =
|
|
230
|
+
this.ws = new WebSocket(y, ["bearer", n]), this.ws.onopen = () => {
|
|
231
|
+
const a = p || {
|
|
229
232
|
think: { provider: { type: "open_ai", model: "gpt-4.1-nano" } },
|
|
230
233
|
speak: { provider: { type: "deepgram", model: "aura-2-thalia-en" } },
|
|
231
234
|
listen: { provider: { type: "deepgram", version: "v2", model: "flux-general-en" } }
|
|
@@ -258,18 +261,18 @@ class y {
|
|
|
258
261
|
greeting: "Hi! I'm excited you chose to speak with me. Are you ready to start?"
|
|
259
262
|
}
|
|
260
263
|
};
|
|
261
|
-
a.tags && a.tags.length > 0 && (h.tags = a.tags), this.ws.send(JSON.stringify(h)), this.emit({ type: "open", payload: { config:
|
|
264
|
+
a.tags && a.tags.length > 0 && (h.tags = a.tags), this.ws.send(JSON.stringify(h)), this.emit({ type: "open", payload: { config: s, serverConfig: this.serverConfig } });
|
|
262
265
|
};
|
|
263
|
-
const
|
|
266
|
+
const f = g;
|
|
264
267
|
this.ws.onmessage = (a) => {
|
|
265
268
|
if (typeof a.data == "string") {
|
|
266
269
|
try {
|
|
267
270
|
if (JSON.parse(a.data).type === "SettingsApplied") {
|
|
268
|
-
const
|
|
271
|
+
const b = {
|
|
269
272
|
type: "UpdatePrompt",
|
|
270
|
-
prompt:
|
|
273
|
+
prompt: f
|
|
271
274
|
};
|
|
272
|
-
this.ws.send(JSON.stringify(
|
|
275
|
+
this.ws.send(JSON.stringify(b)), this.startMicrophone();
|
|
273
276
|
}
|
|
274
277
|
} catch {
|
|
275
278
|
}
|
|
@@ -301,7 +304,7 @@ class y {
|
|
|
301
304
|
*/
|
|
302
305
|
async initializeAudio() {
|
|
303
306
|
this.audioContext = new AudioContext({ sampleRate: this.inputSampleRate });
|
|
304
|
-
const e = this.createWorkletBlobUrl(
|
|
307
|
+
const e = this.createWorkletBlobUrl(J), t = this.createWorkletBlobUrl(q);
|
|
305
308
|
try {
|
|
306
309
|
await Promise.all([
|
|
307
310
|
this.audioContext.audioWorklet.addModule(e),
|
|
@@ -310,9 +313,9 @@ class y {
|
|
|
310
313
|
} finally {
|
|
311
314
|
URL.revokeObjectURL(e), URL.revokeObjectURL(t);
|
|
312
315
|
}
|
|
313
|
-
this.playbackWorkletNode = new AudioWorkletNode(this.audioContext, "audio-playback-processor"), this.playbackWorkletNode.connect(this.audioContext.destination), this.playbackWorkletNode.port.onmessage = (
|
|
314
|
-
const { type:
|
|
315
|
-
(
|
|
316
|
+
this.playbackWorkletNode = new AudioWorkletNode(this.audioContext, "audio-playback-processor"), this.playbackWorkletNode.connect(this.audioContext.destination), this.playbackWorkletNode.port.onmessage = (o) => {
|
|
317
|
+
const { type: n } = o.data;
|
|
318
|
+
(n === "cleared" || n === "bufferEmpty") && (this.isAgentSpeaking = !1, this.agentAudioDoneReceived = !1, this.emit({ type: "agent_speaking", payload: !1 }));
|
|
316
319
|
};
|
|
317
320
|
}
|
|
318
321
|
/**
|
|
@@ -335,8 +338,8 @@ class y {
|
|
|
335
338
|
break;
|
|
336
339
|
case "ConversationText":
|
|
337
340
|
if (t.content && t.content.trim()) {
|
|
338
|
-
const
|
|
339
|
-
this.config.onTranscript && this.config.onTranscript(t.content,
|
|
341
|
+
const o = t.role === "assistant" ? "agent" : "user";
|
|
342
|
+
this.config.onTranscript && this.config.onTranscript(t.content, o), this.emit({ type: "transcript", payload: { text: t.content, role: o } }), this.saveTranscript(t.content, t.role);
|
|
340
343
|
}
|
|
341
344
|
break;
|
|
342
345
|
case "AgentStartedSpeaking":
|
|
@@ -372,30 +375,30 @@ class y {
|
|
|
372
375
|
this.audioContext.state === "suspended" && this.audioContext.resume();
|
|
373
376
|
const t = e.byteLength;
|
|
374
377
|
if (t === 0) return;
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
377
|
-
const
|
|
378
|
-
for (let
|
|
379
|
-
|
|
380
|
-
const
|
|
378
|
+
const o = t - t % 2;
|
|
379
|
+
if (o === 0) return;
|
|
380
|
+
const n = o === t ? e : e.slice(0, o), s = new Int16Array(n), c = new Float32Array(s.length);
|
|
381
|
+
for (let p = 0; p < s.length; p++)
|
|
382
|
+
c[p] = s[p] / 32768;
|
|
383
|
+
const g = this.resample24kTo48k(c);
|
|
381
384
|
!this.isAgentSpeaking && !this.agentAudioDoneReceived && (this.isAgentSpeaking = !0, this.emit({ type: "agent_speaking", payload: !0 }));
|
|
382
|
-
const
|
|
385
|
+
const y = new Float32Array(g);
|
|
383
386
|
this.playbackWorkletNode.port.postMessage({
|
|
384
387
|
type: "audio",
|
|
385
|
-
data:
|
|
386
|
-
}, [
|
|
388
|
+
data: y
|
|
389
|
+
}, [y.buffer]);
|
|
387
390
|
}
|
|
388
391
|
/**
|
|
389
392
|
* Resample audio from 24kHz to 48kHz using linear interpolation
|
|
390
393
|
*/
|
|
391
394
|
resample24kTo48k(e) {
|
|
392
|
-
const t = e.length * 2,
|
|
393
|
-
for (let
|
|
394
|
-
const
|
|
395
|
-
s
|
|
395
|
+
const t = e.length * 2, o = new Float32Array(t);
|
|
396
|
+
for (let s = 0; s < e.length - 1; s++) {
|
|
397
|
+
const c = e[s], g = e[s + 1];
|
|
398
|
+
o[s * 2] = c, o[s * 2 + 1] = (c + g) / 2;
|
|
396
399
|
}
|
|
397
|
-
const
|
|
398
|
-
return
|
|
400
|
+
const n = e.length - 1;
|
|
401
|
+
return o[n * 2] = e[n], o[n * 2 + 1] = e[n], o;
|
|
399
402
|
}
|
|
400
403
|
/**
|
|
401
404
|
* Clear the playback buffer (for interruption handling)
|
|
@@ -515,28 +518,28 @@ class y {
|
|
|
515
518
|
async handleFunctionCallRequest(e) {
|
|
516
519
|
for (const t of e.functions) {
|
|
517
520
|
console.log("[GlydeVoice] Function call request:", t.name, t.arguments);
|
|
518
|
-
let
|
|
521
|
+
let o = {};
|
|
519
522
|
try {
|
|
520
|
-
|
|
521
|
-
} catch (
|
|
522
|
-
console.warn("[GlydeVoice] Failed to parse function arguments:",
|
|
523
|
+
o = t.arguments ? JSON.parse(t.arguments) : {};
|
|
524
|
+
} catch (c) {
|
|
525
|
+
console.warn("[GlydeVoice] Failed to parse function arguments:", c);
|
|
523
526
|
}
|
|
524
|
-
let
|
|
527
|
+
let n;
|
|
525
528
|
try {
|
|
526
|
-
t.name === "end_conversation" ?
|
|
527
|
-
} catch (
|
|
528
|
-
console.error("[GlydeVoice] Function call error:",
|
|
529
|
+
t.name === "end_conversation" ? n = await this.handleEndConversation(o) : n = await this.executeVoiceFunction(t.name, t.id, o);
|
|
530
|
+
} catch (c) {
|
|
531
|
+
console.error("[GlydeVoice] Function call error:", c), n = JSON.stringify({
|
|
529
532
|
error: "Function execution failed",
|
|
530
|
-
details:
|
|
533
|
+
details: c instanceof Error ? c.message : String(c)
|
|
531
534
|
});
|
|
532
535
|
}
|
|
533
|
-
const
|
|
536
|
+
const s = {
|
|
534
537
|
type: "FunctionCallResponse",
|
|
535
538
|
id: t.id,
|
|
536
539
|
name: t.name,
|
|
537
|
-
content:
|
|
540
|
+
content: n
|
|
538
541
|
};
|
|
539
|
-
this.ws && this.ws.readyState === WebSocket.OPEN ? (this.ws.send(JSON.stringify(
|
|
542
|
+
this.ws && this.ws.readyState === WebSocket.OPEN ? (this.ws.send(JSON.stringify(s)), console.log("[GlydeVoice] Function response sent:", t.name)) : console.error("[GlydeVoice] Cannot send function response - WebSocket not open");
|
|
540
543
|
}
|
|
541
544
|
}
|
|
542
545
|
/**
|
|
@@ -549,16 +552,16 @@ class y {
|
|
|
549
552
|
* @param input - Function input parameters
|
|
550
553
|
* @returns JSON string with function result
|
|
551
554
|
*/
|
|
552
|
-
async executeVoiceFunction(e, t,
|
|
555
|
+
async executeVoiceFunction(e, t, o) {
|
|
553
556
|
console.log("[GlydeVoice] Executing voice function via Unity API:", e);
|
|
554
557
|
try {
|
|
555
|
-
const
|
|
558
|
+
const n = await fetch(`${this.unityUrl}/api/unity/voice/function`, {
|
|
556
559
|
method: "POST",
|
|
557
560
|
headers: this.getAuthHeaders(),
|
|
558
561
|
body: JSON.stringify({
|
|
559
562
|
function_name: e,
|
|
560
563
|
function_call_id: t,
|
|
561
|
-
input:
|
|
564
|
+
input: o,
|
|
562
565
|
context: {
|
|
563
566
|
context_id: this.sessionContext.contextId,
|
|
564
567
|
context_type: this.sessionContext.contextType,
|
|
@@ -566,18 +569,18 @@ class y {
|
|
|
566
569
|
}
|
|
567
570
|
})
|
|
568
571
|
});
|
|
569
|
-
if (!
|
|
570
|
-
const
|
|
571
|
-
throw new Error(
|
|
572
|
+
if (!n.ok) {
|
|
573
|
+
const c = await n.json().catch(() => ({}));
|
|
574
|
+
throw new Error(c.error?.message || `Function call failed: ${n.status}`);
|
|
572
575
|
}
|
|
573
|
-
const
|
|
574
|
-
if (
|
|
575
|
-
return typeof
|
|
576
|
+
const s = await n.json();
|
|
577
|
+
if (s.success && s.data?.output)
|
|
578
|
+
return typeof s.data.output == "string" ? s.data.output : JSON.stringify(s.data.output);
|
|
576
579
|
throw new Error("Invalid response from voice function endpoint");
|
|
577
|
-
} catch (
|
|
578
|
-
return console.error("[GlydeVoice] Voice function error:",
|
|
580
|
+
} catch (n) {
|
|
581
|
+
return console.error("[GlydeVoice] Voice function error:", n), JSON.stringify({
|
|
579
582
|
success: !1,
|
|
580
|
-
error:
|
|
583
|
+
error: n instanceof Error ? n.message : "Function execution failed",
|
|
581
584
|
fallback_message: "I apologize, but I'm having trouble with that request right now. Is there something else I can help you with?"
|
|
582
585
|
});
|
|
583
586
|
}
|
|
@@ -614,6 +617,1671 @@ class y {
|
|
|
614
617
|
});
|
|
615
618
|
}
|
|
616
619
|
}
|
|
620
|
+
class X {
|
|
621
|
+
config;
|
|
622
|
+
unityUrl;
|
|
623
|
+
history = [];
|
|
624
|
+
isTyping = !1;
|
|
625
|
+
initialized = !1;
|
|
626
|
+
/**
|
|
627
|
+
* Create a new GlydeText instance
|
|
628
|
+
* @param config - Configuration options
|
|
629
|
+
*/
|
|
630
|
+
constructor(e) {
|
|
631
|
+
this.config = e, this.unityUrl = e.unityBaseUrl || "https://api.glydeunity.com", !e.publishableKey && !e.apiKey && !e.authToken && console.warn("[GlydeText] No authentication method provided. One of publishableKey, apiKey, or authToken is required.");
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Get authentication headers based on configured auth method
|
|
635
|
+
* @returns Headers object with appropriate authentication
|
|
636
|
+
*/
|
|
637
|
+
getAuthHeaders() {
|
|
638
|
+
const e = {
|
|
639
|
+
"Content-Type": "application/json"
|
|
640
|
+
};
|
|
641
|
+
return this.config.publishableKey && (e["x-publishable-key"] = this.config.publishableKey), this.config.apiKey && (e["x-api-key"] = this.config.apiKey), this.config.authToken && (e.Authorization = `Bearer ${this.config.authToken}`), e;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Emit event to callback
|
|
645
|
+
*/
|
|
646
|
+
emit(e) {
|
|
647
|
+
this.config.onEvent && this.config.onEvent(e);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Set typing state and notify callback
|
|
651
|
+
*/
|
|
652
|
+
setTyping(e) {
|
|
653
|
+
this.isTyping = e, this.config.onTyping && this.config.onTyping(e);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Initialize the chat session and load existing history
|
|
657
|
+
* @returns The loaded message history
|
|
658
|
+
*/
|
|
659
|
+
async initialize() {
|
|
660
|
+
if (!this.config.contextId)
|
|
661
|
+
throw new Error("contextId is required for text chat initialization");
|
|
662
|
+
this.setTyping(!0);
|
|
663
|
+
try {
|
|
664
|
+
const e = await fetch(`${this.unityUrl}/api/unity/screening/start`, {
|
|
665
|
+
method: "POST",
|
|
666
|
+
headers: this.getAuthHeaders(),
|
|
667
|
+
body: JSON.stringify({ application_uuid: this.config.contextId })
|
|
668
|
+
});
|
|
669
|
+
if (!e.ok) {
|
|
670
|
+
const o = await e.json().catch(() => ({}));
|
|
671
|
+
throw new Error(o.error?.message || o.message || "Failed to initialize chat");
|
|
672
|
+
}
|
|
673
|
+
const t = await e.json();
|
|
674
|
+
return t.messages && (this.history = t.messages), this.initialized = !0, this.emit({ type: "ready" }), this.emit({ type: "history_loaded", payload: this.history }), this.history;
|
|
675
|
+
} catch (e) {
|
|
676
|
+
throw console.error("[GlydeText] Initialization error:", e), this.emit({ type: "error", payload: e }), e;
|
|
677
|
+
} finally {
|
|
678
|
+
this.setTyping(!1);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Send a message and get the agent's response
|
|
683
|
+
* @param message - The message content to send
|
|
684
|
+
* @returns The agent's response message
|
|
685
|
+
*/
|
|
686
|
+
async sendMessage(e) {
|
|
687
|
+
if (!this.config.contextId)
|
|
688
|
+
throw new Error("contextId is required for sending messages");
|
|
689
|
+
if (!e.trim())
|
|
690
|
+
throw new Error("Message cannot be empty");
|
|
691
|
+
this.initialized || await this.initialize();
|
|
692
|
+
const t = {
|
|
693
|
+
role: "user",
|
|
694
|
+
content: e.trim(),
|
|
695
|
+
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
696
|
+
};
|
|
697
|
+
this.history.push(t), this.config.onMessage && this.config.onMessage(t), this.emit({ type: "message", payload: t }), this.setTyping(!0);
|
|
698
|
+
try {
|
|
699
|
+
const o = await fetch(`${this.unityUrl}/api/unity/screening/chat`, {
|
|
700
|
+
method: "POST",
|
|
701
|
+
headers: this.getAuthHeaders(),
|
|
702
|
+
body: JSON.stringify({
|
|
703
|
+
application_uuid: this.config.contextId,
|
|
704
|
+
message: e.trim()
|
|
705
|
+
})
|
|
706
|
+
});
|
|
707
|
+
if (!o.ok) {
|
|
708
|
+
const g = await o.json().catch(() => ({}));
|
|
709
|
+
throw new Error(g.error?.message || g.message || "Failed to send message");
|
|
710
|
+
}
|
|
711
|
+
const n = await o.json();
|
|
712
|
+
n.history?.messages && (this.history = n.history.messages);
|
|
713
|
+
const s = [...this.history].reverse().find((g) => g.role === "assistant");
|
|
714
|
+
return s ? (this.config.onMessage && this.config.onMessage(s), this.emit({ type: "message", payload: s }), s) : {
|
|
715
|
+
role: "assistant",
|
|
716
|
+
content: n.response || "I received your message.",
|
|
717
|
+
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
718
|
+
};
|
|
719
|
+
} catch (o) {
|
|
720
|
+
throw console.error("[GlydeText] Send message error:", o), this.emit({ type: "error", payload: o }), o;
|
|
721
|
+
} finally {
|
|
722
|
+
this.setTyping(!1);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Get the current conversation history
|
|
727
|
+
* @returns Array of chat messages
|
|
728
|
+
*/
|
|
729
|
+
getHistory() {
|
|
730
|
+
return [...this.history];
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Clear the local conversation history
|
|
734
|
+
* Note: This does not clear server-side history
|
|
735
|
+
*/
|
|
736
|
+
clearHistory() {
|
|
737
|
+
this.history = [], this.initialized = !1;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Check if the chat is currently waiting for a response
|
|
741
|
+
*/
|
|
742
|
+
getIsTyping() {
|
|
743
|
+
return this.isTyping;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Check if the chat has been initialized
|
|
747
|
+
*/
|
|
748
|
+
getIsInitialized() {
|
|
749
|
+
return this.initialized;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function Z(r) {
|
|
753
|
+
const [e, t] = k("idle"), [o, n] = k([]), [s, c] = k(!1), [g, y] = k(!1), [p, f] = k(!1), [a, h] = k(null), b = E(null), v = A((l) => {
|
|
754
|
+
switch (l.type) {
|
|
755
|
+
case "ready":
|
|
756
|
+
t("active");
|
|
757
|
+
break;
|
|
758
|
+
case "close":
|
|
759
|
+
t("idle"), c(!1), y(!1);
|
|
760
|
+
break;
|
|
761
|
+
case "error":
|
|
762
|
+
t("error"), h(
|
|
763
|
+
typeof l.payload == "object" && l.payload !== null && "message" in l.payload ? String(l.payload.message) : "Connection error"
|
|
764
|
+
);
|
|
765
|
+
break;
|
|
766
|
+
case "user_speaking":
|
|
767
|
+
c(!!l.payload);
|
|
768
|
+
break;
|
|
769
|
+
case "agent_speaking":
|
|
770
|
+
y(!!l.payload);
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
}, []), x = A((l, B) => {
|
|
774
|
+
n((L) => [...L, {
|
|
775
|
+
role: B,
|
|
776
|
+
content: l,
|
|
777
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
778
|
+
}]);
|
|
779
|
+
}, []), u = A(async () => {
|
|
780
|
+
t("connecting"), h(null);
|
|
781
|
+
try {
|
|
782
|
+
const l = new Y({
|
|
783
|
+
...r,
|
|
784
|
+
onEvent: v,
|
|
785
|
+
onTranscript: x
|
|
786
|
+
});
|
|
787
|
+
b.current = l, await l.start();
|
|
788
|
+
} catch (l) {
|
|
789
|
+
console.error("[useVoiceAgent] Failed to start:", l), t("error"), h(l instanceof Error ? l.message : "Failed to connect");
|
|
790
|
+
}
|
|
791
|
+
}, [r, v, x]), w = A(() => {
|
|
792
|
+
b.current?.stop(), b.current = null, t("idle"), c(!1), y(!1);
|
|
793
|
+
}, []), C = A(() => {
|
|
794
|
+
const l = !p;
|
|
795
|
+
f(l), b.current?.setMuted(l);
|
|
796
|
+
}, [p]), T = A((l) => {
|
|
797
|
+
f(l), b.current?.setMuted(l);
|
|
798
|
+
}, []), R = A(() => {
|
|
799
|
+
n([]);
|
|
800
|
+
}, []);
|
|
801
|
+
return I(() => () => {
|
|
802
|
+
b.current?.stop();
|
|
803
|
+
}, []), I(() => {
|
|
804
|
+
r.autoStart && e === "idle" && u();
|
|
805
|
+
}, [r.autoStart, e, u]), {
|
|
806
|
+
status: e,
|
|
807
|
+
transcripts: o,
|
|
808
|
+
isUserSpeaking: s,
|
|
809
|
+
isAgentSpeaking: g,
|
|
810
|
+
isMuted: p,
|
|
811
|
+
errorMessage: a,
|
|
812
|
+
start: u,
|
|
813
|
+
stop: w,
|
|
814
|
+
toggleMute: C,
|
|
815
|
+
setMuted: T,
|
|
816
|
+
clearTranscripts: R,
|
|
817
|
+
voiceAgent: b.current
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function Q(r) {
|
|
821
|
+
const [e, t] = k("idle"), [o, n] = k([]), [s, c] = k(!1), [g, y] = k(null), p = E(null), f = E(!1), a = A(() => (p.current || (p.current = new X({
|
|
822
|
+
...r,
|
|
823
|
+
onTyping: c
|
|
824
|
+
})), p.current), [r]), h = A(async () => {
|
|
825
|
+
if (!f.current) {
|
|
826
|
+
t("loading"), y(null);
|
|
827
|
+
try {
|
|
828
|
+
const u = await a().initialize();
|
|
829
|
+
n(u), t("ready"), f.current = !0;
|
|
830
|
+
} catch (x) {
|
|
831
|
+
console.error("[useTextChat] Initialization error:", x), t("error"), y(x instanceof Error ? x.message : "Failed to initialize chat");
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}, [a]), b = A(async (x) => {
|
|
835
|
+
if (x.trim()) {
|
|
836
|
+
y(null);
|
|
837
|
+
try {
|
|
838
|
+
const u = a(), w = {
|
|
839
|
+
role: "user",
|
|
840
|
+
content: x.trim(),
|
|
841
|
+
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
842
|
+
};
|
|
843
|
+
n((T) => [...T, w]), await u.sendMessage(x);
|
|
844
|
+
const C = u.getHistory();
|
|
845
|
+
n(C), e !== "ready" && (t("ready"), f.current = !0);
|
|
846
|
+
} catch (u) {
|
|
847
|
+
console.error("[useTextChat] Send message error:", u), y(u instanceof Error ? u.message : "Failed to send message");
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}, [a, e]), v = A(() => {
|
|
851
|
+
p.current?.clearHistory(), n([]), f.current = !1, t("idle");
|
|
852
|
+
}, []);
|
|
853
|
+
return I(() => {
|
|
854
|
+
r.autoInit && !f.current && r.contextId && h();
|
|
855
|
+
}, [r.autoInit, r.contextId, h]), I(() => () => {
|
|
856
|
+
p.current = null;
|
|
857
|
+
}, []), {
|
|
858
|
+
status: e,
|
|
859
|
+
messages: o,
|
|
860
|
+
isLoading: s,
|
|
861
|
+
errorMessage: g,
|
|
862
|
+
initialize: h,
|
|
863
|
+
sendMessage: b,
|
|
864
|
+
clearHistory: v,
|
|
865
|
+
textChat: p.current
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
869
|
+
"svg",
|
|
870
|
+
{
|
|
871
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
872
|
+
width: r,
|
|
873
|
+
height: r,
|
|
874
|
+
viewBox: "0 0 24 24",
|
|
875
|
+
fill: "none",
|
|
876
|
+
stroke: e,
|
|
877
|
+
strokeWidth: "2",
|
|
878
|
+
strokeLinecap: "round",
|
|
879
|
+
strokeLinejoin: "round",
|
|
880
|
+
className: t,
|
|
881
|
+
children: [
|
|
882
|
+
/* @__PURE__ */ i("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }),
|
|
883
|
+
/* @__PURE__ */ i("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
|
|
884
|
+
/* @__PURE__ */ i("line", { x1: "12", x2: "12", y1: "19", y2: "22" })
|
|
885
|
+
]
|
|
886
|
+
}
|
|
887
|
+
), be = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
888
|
+
"svg",
|
|
889
|
+
{
|
|
890
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
891
|
+
width: r,
|
|
892
|
+
height: r,
|
|
893
|
+
viewBox: "0 0 24 24",
|
|
894
|
+
fill: "none",
|
|
895
|
+
stroke: e,
|
|
896
|
+
strokeWidth: "2",
|
|
897
|
+
strokeLinecap: "round",
|
|
898
|
+
strokeLinejoin: "round",
|
|
899
|
+
className: t,
|
|
900
|
+
children: [
|
|
901
|
+
/* @__PURE__ */ i("line", { x1: "2", x2: "22", y1: "2", y2: "22" }),
|
|
902
|
+
/* @__PURE__ */ i("path", { d: "M18.89 13.23A7.12 7.12 0 0 0 19 12v-2" }),
|
|
903
|
+
/* @__PURE__ */ i("path", { d: "M5 10v2a7 7 0 0 0 12 5" }),
|
|
904
|
+
/* @__PURE__ */ i("path", { d: "M15 9.34V5a3 3 0 0 0-5.68-1.33" }),
|
|
905
|
+
/* @__PURE__ */ i("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" }),
|
|
906
|
+
/* @__PURE__ */ i("line", { x1: "12", x2: "12", y1: "19", y2: "22" })
|
|
907
|
+
]
|
|
908
|
+
}
|
|
909
|
+
), ve = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ i(
|
|
910
|
+
"svg",
|
|
911
|
+
{
|
|
912
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
913
|
+
width: r,
|
|
914
|
+
height: r,
|
|
915
|
+
viewBox: "0 0 24 24",
|
|
916
|
+
fill: "none",
|
|
917
|
+
stroke: e,
|
|
918
|
+
strokeWidth: "2",
|
|
919
|
+
strokeLinecap: "round",
|
|
920
|
+
strokeLinejoin: "round",
|
|
921
|
+
className: t,
|
|
922
|
+
children: /* @__PURE__ */ i("path", { d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" })
|
|
923
|
+
}
|
|
924
|
+
), ee = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
925
|
+
"svg",
|
|
926
|
+
{
|
|
927
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
928
|
+
width: r,
|
|
929
|
+
height: r,
|
|
930
|
+
viewBox: "0 0 24 24",
|
|
931
|
+
fill: "none",
|
|
932
|
+
stroke: e,
|
|
933
|
+
strokeWidth: "2",
|
|
934
|
+
strokeLinecap: "round",
|
|
935
|
+
strokeLinejoin: "round",
|
|
936
|
+
className: t,
|
|
937
|
+
children: [
|
|
938
|
+
/* @__PURE__ */ i("path", { d: "M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91" }),
|
|
939
|
+
/* @__PURE__ */ i("line", { x1: "22", x2: "2", y1: "2", y2: "22" })
|
|
940
|
+
]
|
|
941
|
+
}
|
|
942
|
+
), O = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ i(
|
|
943
|
+
"svg",
|
|
944
|
+
{
|
|
945
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
946
|
+
width: r,
|
|
947
|
+
height: r,
|
|
948
|
+
viewBox: "0 0 24 24",
|
|
949
|
+
fill: "none",
|
|
950
|
+
stroke: e,
|
|
951
|
+
strokeWidth: "2",
|
|
952
|
+
strokeLinecap: "round",
|
|
953
|
+
strokeLinejoin: "round",
|
|
954
|
+
className: t,
|
|
955
|
+
children: /* @__PURE__ */ i("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
|
|
956
|
+
}
|
|
957
|
+
), te = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
958
|
+
"svg",
|
|
959
|
+
{
|
|
960
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
961
|
+
width: r,
|
|
962
|
+
height: r,
|
|
963
|
+
viewBox: "0 0 24 24",
|
|
964
|
+
fill: "none",
|
|
965
|
+
stroke: e,
|
|
966
|
+
strokeWidth: "2",
|
|
967
|
+
strokeLinecap: "round",
|
|
968
|
+
strokeLinejoin: "round",
|
|
969
|
+
className: t,
|
|
970
|
+
children: [
|
|
971
|
+
/* @__PURE__ */ i("line", { x1: "22", x2: "11", y1: "2", y2: "13" }),
|
|
972
|
+
/* @__PURE__ */ i("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
973
|
+
]
|
|
974
|
+
}
|
|
975
|
+
), re = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
976
|
+
"svg",
|
|
977
|
+
{
|
|
978
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
979
|
+
width: r,
|
|
980
|
+
height: r,
|
|
981
|
+
viewBox: "0 0 24 24",
|
|
982
|
+
fill: "none",
|
|
983
|
+
stroke: e,
|
|
984
|
+
strokeWidth: "2",
|
|
985
|
+
strokeLinecap: "round",
|
|
986
|
+
strokeLinejoin: "round",
|
|
987
|
+
className: t,
|
|
988
|
+
children: [
|
|
989
|
+
/* @__PURE__ */ i("path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }),
|
|
990
|
+
/* @__PURE__ */ i("circle", { cx: "12", cy: "7", r: "4" })
|
|
991
|
+
]
|
|
992
|
+
}
|
|
993
|
+
), ie = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
994
|
+
"svg",
|
|
995
|
+
{
|
|
996
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
997
|
+
width: r,
|
|
998
|
+
height: r,
|
|
999
|
+
viewBox: "0 0 24 24",
|
|
1000
|
+
fill: "none",
|
|
1001
|
+
stroke: e,
|
|
1002
|
+
strokeWidth: "2",
|
|
1003
|
+
strokeLinecap: "round",
|
|
1004
|
+
strokeLinejoin: "round",
|
|
1005
|
+
className: t,
|
|
1006
|
+
children: [
|
|
1007
|
+
/* @__PURE__ */ i("path", { d: "M12 8V4H8" }),
|
|
1008
|
+
/* @__PURE__ */ i("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
1009
|
+
/* @__PURE__ */ i("path", { d: "M2 14h2" }),
|
|
1010
|
+
/* @__PURE__ */ i("path", { d: "M20 14h2" }),
|
|
1011
|
+
/* @__PURE__ */ i("path", { d: "M15 13v2" }),
|
|
1012
|
+
/* @__PURE__ */ i("path", { d: "M9 13v2" })
|
|
1013
|
+
]
|
|
1014
|
+
}
|
|
1015
|
+
), oe = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ i(
|
|
1016
|
+
"svg",
|
|
1017
|
+
{
|
|
1018
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1019
|
+
width: r,
|
|
1020
|
+
height: r,
|
|
1021
|
+
viewBox: "0 0 24 24",
|
|
1022
|
+
fill: "none",
|
|
1023
|
+
stroke: e,
|
|
1024
|
+
strokeWidth: "2",
|
|
1025
|
+
strokeLinecap: "round",
|
|
1026
|
+
strokeLinejoin: "round",
|
|
1027
|
+
className: t,
|
|
1028
|
+
children: /* @__PURE__ */ i("polyline", { points: "22 12 18 12 15 21 9 3 6 12 2 12" })
|
|
1029
|
+
}
|
|
1030
|
+
), ne = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
1031
|
+
"svg",
|
|
1032
|
+
{
|
|
1033
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1034
|
+
width: r,
|
|
1035
|
+
height: r,
|
|
1036
|
+
viewBox: "0 0 24 24",
|
|
1037
|
+
fill: "none",
|
|
1038
|
+
stroke: e,
|
|
1039
|
+
strokeWidth: "2",
|
|
1040
|
+
strokeLinecap: "round",
|
|
1041
|
+
strokeLinejoin: "round",
|
|
1042
|
+
className: t,
|
|
1043
|
+
children: [
|
|
1044
|
+
/* @__PURE__ */ i("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
|
|
1045
|
+
/* @__PURE__ */ i("line", { x1: "22", x2: "16", y1: "9", y2: "15" }),
|
|
1046
|
+
/* @__PURE__ */ i("line", { x1: "16", x2: "22", y1: "9", y2: "15" })
|
|
1047
|
+
]
|
|
1048
|
+
}
|
|
1049
|
+
), se = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
1050
|
+
"svg",
|
|
1051
|
+
{
|
|
1052
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1053
|
+
width: r,
|
|
1054
|
+
height: r,
|
|
1055
|
+
viewBox: "0 0 24 24",
|
|
1056
|
+
fill: "none",
|
|
1057
|
+
stroke: e,
|
|
1058
|
+
strokeWidth: "2",
|
|
1059
|
+
strokeLinecap: "round",
|
|
1060
|
+
strokeLinejoin: "round",
|
|
1061
|
+
className: t,
|
|
1062
|
+
children: [
|
|
1063
|
+
/* @__PURE__ */ i("line", { x1: "18", x2: "6", y1: "6", y2: "18" }),
|
|
1064
|
+
/* @__PURE__ */ i("line", { x1: "6", x2: "18", y1: "6", y2: "18" })
|
|
1065
|
+
]
|
|
1066
|
+
}
|
|
1067
|
+
), ae = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
|
|
1068
|
+
"svg",
|
|
1069
|
+
{
|
|
1070
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1071
|
+
width: r,
|
|
1072
|
+
height: r,
|
|
1073
|
+
viewBox: "0 0 24 24",
|
|
1074
|
+
fill: "none",
|
|
1075
|
+
stroke: e,
|
|
1076
|
+
strokeWidth: "2",
|
|
1077
|
+
strokeLinecap: "round",
|
|
1078
|
+
strokeLinejoin: "round",
|
|
1079
|
+
className: t,
|
|
1080
|
+
children: [
|
|
1081
|
+
/* @__PURE__ */ i("path", { d: "M8 3v3a2 2 0 0 1-2 2H3" }),
|
|
1082
|
+
/* @__PURE__ */ i("path", { d: "M21 8h-3a2 2 0 0 1-2-2V3" }),
|
|
1083
|
+
/* @__PURE__ */ i("path", { d: "M3 16h3a2 2 0 0 1 2 2v3" }),
|
|
1084
|
+
/* @__PURE__ */ i("path", { d: "M16 21v-3a2 2 0 0 1 2-2h3" })
|
|
1085
|
+
]
|
|
1086
|
+
}
|
|
1087
|
+
), we = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ i(
|
|
1088
|
+
"svg",
|
|
1089
|
+
{
|
|
1090
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1091
|
+
width: r,
|
|
1092
|
+
height: r,
|
|
1093
|
+
viewBox: "0 0 24 24",
|
|
1094
|
+
fill: "none",
|
|
1095
|
+
stroke: e,
|
|
1096
|
+
strokeWidth: "2",
|
|
1097
|
+
strokeLinecap: "round",
|
|
1098
|
+
strokeLinejoin: "round",
|
|
1099
|
+
className: t,
|
|
1100
|
+
style: { animation: "spin 1s linear infinite" },
|
|
1101
|
+
children: /* @__PURE__ */ i("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
1102
|
+
}
|
|
1103
|
+
), de = {
|
|
1104
|
+
light: {
|
|
1105
|
+
// Primary colors (purple/magenta)
|
|
1106
|
+
primary: "#c026d3",
|
|
1107
|
+
primaryHover: "#a21caf",
|
|
1108
|
+
primaryLight: "#fdf4ff",
|
|
1109
|
+
primaryText: "#ffffff",
|
|
1110
|
+
// Secondary colors (blue/cyan for text chat)
|
|
1111
|
+
secondary: "#0284c7",
|
|
1112
|
+
secondaryHover: "#0369a1",
|
|
1113
|
+
secondaryLight: "#f0f9ff",
|
|
1114
|
+
secondaryText: "#ffffff",
|
|
1115
|
+
// Success/active colors (green)
|
|
1116
|
+
success: "#059669",
|
|
1117
|
+
successLight: "#dcfce7",
|
|
1118
|
+
successText: "#166534",
|
|
1119
|
+
// Error colors (red)
|
|
1120
|
+
error: "#ef4444",
|
|
1121
|
+
errorHover: "#dc2626",
|
|
1122
|
+
errorLight: "#fef2f2",
|
|
1123
|
+
errorText: "#b91c1c",
|
|
1124
|
+
// Neutral colors
|
|
1125
|
+
background: "#ffffff",
|
|
1126
|
+
surface: "#f9fafb",
|
|
1127
|
+
border: "#e5e7eb",
|
|
1128
|
+
borderLight: "#f3f4f6",
|
|
1129
|
+
text: "#1f2937",
|
|
1130
|
+
textSecondary: "#6b7280",
|
|
1131
|
+
textMuted: "#9ca3af"
|
|
1132
|
+
},
|
|
1133
|
+
dark: {
|
|
1134
|
+
// Primary colors
|
|
1135
|
+
primary: "#d946ef",
|
|
1136
|
+
primaryHover: "#c026d3",
|
|
1137
|
+
primaryLight: "#3b0764",
|
|
1138
|
+
primaryText: "#ffffff",
|
|
1139
|
+
// Secondary colors
|
|
1140
|
+
secondary: "#38bdf8",
|
|
1141
|
+
secondaryHover: "#0ea5e9",
|
|
1142
|
+
secondaryLight: "#0c4a6e",
|
|
1143
|
+
secondaryText: "#ffffff",
|
|
1144
|
+
// Success colors
|
|
1145
|
+
success: "#34d399",
|
|
1146
|
+
successLight: "#064e3b",
|
|
1147
|
+
successText: "#a7f3d0",
|
|
1148
|
+
// Error colors
|
|
1149
|
+
error: "#f87171",
|
|
1150
|
+
errorHover: "#ef4444",
|
|
1151
|
+
errorLight: "#450a0a",
|
|
1152
|
+
errorText: "#fecaca",
|
|
1153
|
+
// Neutral colors
|
|
1154
|
+
background: "#111827",
|
|
1155
|
+
surface: "#1f2937",
|
|
1156
|
+
border: "#374151",
|
|
1157
|
+
borderLight: "#4b5563",
|
|
1158
|
+
text: "#f9fafb",
|
|
1159
|
+
textSecondary: "#d1d5db",
|
|
1160
|
+
textMuted: "#9ca3af"
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
function $(r) {
|
|
1164
|
+
const e = de[r];
|
|
1165
|
+
return `
|
|
1166
|
+
--glyde-primary: ${e.primary};
|
|
1167
|
+
--glyde-primary-hover: ${e.primaryHover};
|
|
1168
|
+
--glyde-primary-light: ${e.primaryLight};
|
|
1169
|
+
--glyde-primary-text: ${e.primaryText};
|
|
1170
|
+
--glyde-secondary: ${e.secondary};
|
|
1171
|
+
--glyde-secondary-hover: ${e.secondaryHover};
|
|
1172
|
+
--glyde-secondary-light: ${e.secondaryLight};
|
|
1173
|
+
--glyde-secondary-text: ${e.secondaryText};
|
|
1174
|
+
--glyde-success: ${e.success};
|
|
1175
|
+
--glyde-success-light: ${e.successLight};
|
|
1176
|
+
--glyde-success-text: ${e.successText};
|
|
1177
|
+
--glyde-error: ${e.error};
|
|
1178
|
+
--glyde-error-hover: ${e.errorHover};
|
|
1179
|
+
--glyde-error-light: ${e.errorLight};
|
|
1180
|
+
--glyde-error-text: ${e.errorText};
|
|
1181
|
+
--glyde-background: ${e.background};
|
|
1182
|
+
--glyde-surface: ${e.surface};
|
|
1183
|
+
--glyde-border: ${e.border};
|
|
1184
|
+
--glyde-border-light: ${e.borderLight};
|
|
1185
|
+
--glyde-text: ${e.text};
|
|
1186
|
+
--glyde-text-secondary: ${e.textSecondary};
|
|
1187
|
+
--glyde-text-muted: ${e.textMuted};
|
|
1188
|
+
`;
|
|
1189
|
+
}
|
|
1190
|
+
const V = `
|
|
1191
|
+
@keyframes glyde-pulse {
|
|
1192
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
1193
|
+
50% { opacity: 0.5; transform: scale(1.2); }
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
@keyframes glyde-spin {
|
|
1197
|
+
to { transform: rotate(360deg); }
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
@keyframes glyde-fade-in {
|
|
1201
|
+
from { opacity: 0; transform: translateY(10px); }
|
|
1202
|
+
to { opacity: 1; transform: translateY(0); }
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
@keyframes glyde-slide-up {
|
|
1206
|
+
from { opacity: 0; transform: translateY(20px); }
|
|
1207
|
+
to { opacity: 1; transform: translateY(0); }
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
@keyframes glyde-bounce {
|
|
1211
|
+
0%, 100% { transform: translateY(0); }
|
|
1212
|
+
50% { transform: translateY(-5px); }
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
.glyde-widget-root {
|
|
1216
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
1217
|
+
font-size: 14px;
|
|
1218
|
+
line-height: 1.5;
|
|
1219
|
+
color: var(--glyde-text);
|
|
1220
|
+
box-sizing: border-box;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
.glyde-widget-root *, .glyde-widget-root *::before, .glyde-widget-root *::after {
|
|
1224
|
+
box-sizing: border-box;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
.glyde-spinner {
|
|
1228
|
+
width: 32px;
|
|
1229
|
+
height: 32px;
|
|
1230
|
+
border: 3px solid var(--glyde-border);
|
|
1231
|
+
border-top-color: var(--glyde-primary);
|
|
1232
|
+
border-radius: 50%;
|
|
1233
|
+
animation: glyde-spin 1s linear infinite;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
.glyde-pulse-dot {
|
|
1237
|
+
animation: glyde-pulse 1.5s infinite;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
.glyde-fade-in {
|
|
1241
|
+
animation: glyde-fade-in 0.3s ease-out;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
.glyde-slide-up {
|
|
1245
|
+
animation: glyde-slide-up 0.3s ease-out;
|
|
1246
|
+
}
|
|
1247
|
+
`, m = {
|
|
1248
|
+
// Floating widget button
|
|
1249
|
+
floatingButton: {
|
|
1250
|
+
position: "fixed",
|
|
1251
|
+
width: "60px",
|
|
1252
|
+
height: "60px",
|
|
1253
|
+
borderRadius: "50%",
|
|
1254
|
+
border: "none",
|
|
1255
|
+
cursor: "pointer",
|
|
1256
|
+
display: "flex",
|
|
1257
|
+
alignItems: "center",
|
|
1258
|
+
justifyContent: "center",
|
|
1259
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
1260
|
+
transition: "transform 0.2s, box-shadow 0.2s",
|
|
1261
|
+
zIndex: 9999
|
|
1262
|
+
},
|
|
1263
|
+
// Widget panel
|
|
1264
|
+
widgetPanel: {
|
|
1265
|
+
position: "fixed",
|
|
1266
|
+
width: "380px",
|
|
1267
|
+
height: "600px",
|
|
1268
|
+
borderRadius: "16px",
|
|
1269
|
+
boxShadow: "0 10px 40px rgba(0, 0, 0, 0.2)",
|
|
1270
|
+
display: "flex",
|
|
1271
|
+
flexDirection: "column",
|
|
1272
|
+
overflow: "hidden",
|
|
1273
|
+
zIndex: 9998
|
|
1274
|
+
},
|
|
1275
|
+
// Card container
|
|
1276
|
+
card: {
|
|
1277
|
+
background: "var(--glyde-background)",
|
|
1278
|
+
borderRadius: "12px",
|
|
1279
|
+
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
|
|
1280
|
+
overflow: "hidden"
|
|
1281
|
+
},
|
|
1282
|
+
// Header
|
|
1283
|
+
header: {
|
|
1284
|
+
padding: "16px 20px",
|
|
1285
|
+
borderBottom: "1px solid var(--glyde-border)",
|
|
1286
|
+
display: "flex",
|
|
1287
|
+
justifyContent: "space-between",
|
|
1288
|
+
alignItems: "center"
|
|
1289
|
+
},
|
|
1290
|
+
// Mode selector
|
|
1291
|
+
modeSelector: {
|
|
1292
|
+
display: "flex",
|
|
1293
|
+
gap: "8px",
|
|
1294
|
+
padding: "4px",
|
|
1295
|
+
background: "var(--glyde-surface)",
|
|
1296
|
+
borderRadius: "8px"
|
|
1297
|
+
},
|
|
1298
|
+
modeSelectorButton: {
|
|
1299
|
+
padding: "8px 16px",
|
|
1300
|
+
border: "none",
|
|
1301
|
+
borderRadius: "6px",
|
|
1302
|
+
cursor: "pointer",
|
|
1303
|
+
display: "flex",
|
|
1304
|
+
alignItems: "center",
|
|
1305
|
+
gap: "6px",
|
|
1306
|
+
fontSize: "14px",
|
|
1307
|
+
fontWeight: 500,
|
|
1308
|
+
transition: "all 0.2s"
|
|
1309
|
+
},
|
|
1310
|
+
// Transcript area
|
|
1311
|
+
transcriptArea: {
|
|
1312
|
+
flex: 1,
|
|
1313
|
+
overflowY: "auto",
|
|
1314
|
+
padding: "16px",
|
|
1315
|
+
background: "var(--glyde-surface)"
|
|
1316
|
+
},
|
|
1317
|
+
// Message bubble
|
|
1318
|
+
messageBubble: {
|
|
1319
|
+
maxWidth: "80%",
|
|
1320
|
+
padding: "10px 14px",
|
|
1321
|
+
borderRadius: "12px",
|
|
1322
|
+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)"
|
|
1323
|
+
},
|
|
1324
|
+
messageBubbleUser: {
|
|
1325
|
+
background: "var(--glyde-primary)",
|
|
1326
|
+
color: "var(--glyde-primary-text)",
|
|
1327
|
+
borderTopRightRadius: "4px"
|
|
1328
|
+
},
|
|
1329
|
+
messageBubbleAgent: {
|
|
1330
|
+
background: "var(--glyde-background)",
|
|
1331
|
+
color: "var(--glyde-text)",
|
|
1332
|
+
borderTopLeftRadius: "4px"
|
|
1333
|
+
},
|
|
1334
|
+
// Controls area
|
|
1335
|
+
controlsArea: {
|
|
1336
|
+
padding: "16px",
|
|
1337
|
+
borderTop: "1px solid var(--glyde-border)",
|
|
1338
|
+
background: "var(--glyde-background)"
|
|
1339
|
+
},
|
|
1340
|
+
// Speaking indicators
|
|
1341
|
+
speakingIndicator: {
|
|
1342
|
+
display: "flex",
|
|
1343
|
+
alignItems: "center",
|
|
1344
|
+
gap: "6px",
|
|
1345
|
+
fontSize: "13px"
|
|
1346
|
+
},
|
|
1347
|
+
speakingDot: {
|
|
1348
|
+
width: "8px",
|
|
1349
|
+
height: "8px",
|
|
1350
|
+
borderRadius: "50%",
|
|
1351
|
+
transition: "background-color 0.2s"
|
|
1352
|
+
},
|
|
1353
|
+
// Buttons
|
|
1354
|
+
primaryButton: {
|
|
1355
|
+
padding: "12px 24px",
|
|
1356
|
+
background: "var(--glyde-primary)",
|
|
1357
|
+
color: "var(--glyde-primary-text)",
|
|
1358
|
+
border: "none",
|
|
1359
|
+
borderRadius: "8px",
|
|
1360
|
+
fontSize: "15px",
|
|
1361
|
+
fontWeight: 600,
|
|
1362
|
+
cursor: "pointer",
|
|
1363
|
+
display: "flex",
|
|
1364
|
+
alignItems: "center",
|
|
1365
|
+
justifyContent: "center",
|
|
1366
|
+
gap: "8px",
|
|
1367
|
+
transition: "background-color 0.2s, transform 0.1s"
|
|
1368
|
+
},
|
|
1369
|
+
secondaryButton: {
|
|
1370
|
+
padding: "10px 20px",
|
|
1371
|
+
background: "var(--glyde-surface)",
|
|
1372
|
+
color: "var(--glyde-text)",
|
|
1373
|
+
border: "1px solid var(--glyde-border)",
|
|
1374
|
+
borderRadius: "8px",
|
|
1375
|
+
fontSize: "14px",
|
|
1376
|
+
fontWeight: 500,
|
|
1377
|
+
cursor: "pointer",
|
|
1378
|
+
display: "flex",
|
|
1379
|
+
alignItems: "center",
|
|
1380
|
+
justifyContent: "center",
|
|
1381
|
+
gap: "6px",
|
|
1382
|
+
transition: "background-color 0.2s"
|
|
1383
|
+
},
|
|
1384
|
+
dangerButton: {
|
|
1385
|
+
padding: "12px 24px",
|
|
1386
|
+
background: "var(--glyde-error)",
|
|
1387
|
+
color: "white",
|
|
1388
|
+
border: "none",
|
|
1389
|
+
borderRadius: "24px",
|
|
1390
|
+
fontSize: "15px",
|
|
1391
|
+
fontWeight: 600,
|
|
1392
|
+
cursor: "pointer",
|
|
1393
|
+
display: "flex",
|
|
1394
|
+
alignItems: "center",
|
|
1395
|
+
gap: "8px",
|
|
1396
|
+
transition: "background-color 0.2s"
|
|
1397
|
+
},
|
|
1398
|
+
iconButton: {
|
|
1399
|
+
width: "44px",
|
|
1400
|
+
height: "44px",
|
|
1401
|
+
padding: "0",
|
|
1402
|
+
border: "none",
|
|
1403
|
+
borderRadius: "50%",
|
|
1404
|
+
cursor: "pointer",
|
|
1405
|
+
display: "flex",
|
|
1406
|
+
alignItems: "center",
|
|
1407
|
+
justifyContent: "center",
|
|
1408
|
+
transition: "background-color 0.2s"
|
|
1409
|
+
},
|
|
1410
|
+
// Input field
|
|
1411
|
+
inputField: {
|
|
1412
|
+
flex: 1,
|
|
1413
|
+
padding: "12px 16px",
|
|
1414
|
+
borderRadius: "8px",
|
|
1415
|
+
border: "1px solid var(--glyde-border)",
|
|
1416
|
+
background: "var(--glyde-background)",
|
|
1417
|
+
color: "var(--glyde-text)",
|
|
1418
|
+
fontSize: "14px",
|
|
1419
|
+
outline: "none",
|
|
1420
|
+
transition: "border-color 0.2s"
|
|
1421
|
+
},
|
|
1422
|
+
// Status badge
|
|
1423
|
+
statusBadge: {
|
|
1424
|
+
padding: "4px 10px",
|
|
1425
|
+
borderRadius: "20px",
|
|
1426
|
+
fontSize: "12px",
|
|
1427
|
+
fontWeight: 500,
|
|
1428
|
+
display: "flex",
|
|
1429
|
+
alignItems: "center",
|
|
1430
|
+
gap: "4px"
|
|
1431
|
+
},
|
|
1432
|
+
statusBadgeLive: {
|
|
1433
|
+
background: "var(--glyde-success-light)",
|
|
1434
|
+
color: "var(--glyde-success-text)"
|
|
1435
|
+
},
|
|
1436
|
+
statusBadgeConnecting: {
|
|
1437
|
+
background: "var(--glyde-primary-light)",
|
|
1438
|
+
color: "var(--glyde-primary)"
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
function le(r, e = 20) {
|
|
1442
|
+
return {
|
|
1443
|
+
"bottom-right": {
|
|
1444
|
+
button: { bottom: e, right: e },
|
|
1445
|
+
panel: { bottom: e + 70, right: e }
|
|
1446
|
+
},
|
|
1447
|
+
"bottom-left": {
|
|
1448
|
+
button: { bottom: e, left: e },
|
|
1449
|
+
panel: { bottom: e + 70, left: e }
|
|
1450
|
+
},
|
|
1451
|
+
"top-right": {
|
|
1452
|
+
button: { top: e, right: e },
|
|
1453
|
+
panel: { top: e + 70, right: e }
|
|
1454
|
+
},
|
|
1455
|
+
"top-left": {
|
|
1456
|
+
button: { top: e, left: e },
|
|
1457
|
+
panel: { top: e + 70, left: e }
|
|
1458
|
+
}
|
|
1459
|
+
}[r];
|
|
1460
|
+
}
|
|
1461
|
+
function N(r = "light") {
|
|
1462
|
+
const e = "glyde-widget-styles";
|
|
1463
|
+
if (document.getElementById(e))
|
|
1464
|
+
return;
|
|
1465
|
+
const t = document.createElement("style");
|
|
1466
|
+
t.id = e, t.textContent = `
|
|
1467
|
+
:root {
|
|
1468
|
+
${$(r)}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
${V}
|
|
1472
|
+
`, document.head.appendChild(t);
|
|
1473
|
+
}
|
|
1474
|
+
function ke(r) {
|
|
1475
|
+
const t = document.getElementById("glyde-widget-styles");
|
|
1476
|
+
t ? t.textContent = `
|
|
1477
|
+
:root {
|
|
1478
|
+
${$(r)}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
${V}
|
|
1482
|
+
` : N(r);
|
|
1483
|
+
}
|
|
1484
|
+
const F = ({
|
|
1485
|
+
contextId: r,
|
|
1486
|
+
publishableKey: e,
|
|
1487
|
+
apiKey: t,
|
|
1488
|
+
authToken: o,
|
|
1489
|
+
unityApiUrl: n = "https://api.glydeunity.com",
|
|
1490
|
+
contextType: s = "screening",
|
|
1491
|
+
height: c = "600px",
|
|
1492
|
+
onTranscript: g,
|
|
1493
|
+
onCallEnd: y,
|
|
1494
|
+
onError: p
|
|
1495
|
+
}) => {
|
|
1496
|
+
const f = E(null), {
|
|
1497
|
+
status: a,
|
|
1498
|
+
transcripts: h,
|
|
1499
|
+
isUserSpeaking: b,
|
|
1500
|
+
isAgentSpeaking: v,
|
|
1501
|
+
isMuted: x,
|
|
1502
|
+
errorMessage: u,
|
|
1503
|
+
start: w,
|
|
1504
|
+
stop: C,
|
|
1505
|
+
toggleMute: T,
|
|
1506
|
+
clearTranscripts: R
|
|
1507
|
+
} = Z({
|
|
1508
|
+
publishableKey: e,
|
|
1509
|
+
apiKey: t,
|
|
1510
|
+
authToken: o,
|
|
1511
|
+
contextType: s,
|
|
1512
|
+
contextId: r,
|
|
1513
|
+
unityBaseUrl: n
|
|
1514
|
+
});
|
|
1515
|
+
I(() => {
|
|
1516
|
+
f.current?.scrollIntoView({ behavior: "smooth" });
|
|
1517
|
+
}, [h]), I(() => {
|
|
1518
|
+
if (g && h.length > 0) {
|
|
1519
|
+
const S = h[h.length - 1];
|
|
1520
|
+
g(S.content, S.role);
|
|
1521
|
+
}
|
|
1522
|
+
}, [h, g]), I(() => {
|
|
1523
|
+
a === "error" && u && p && p(new Error(u));
|
|
1524
|
+
}, [a, u, p]);
|
|
1525
|
+
const l = () => {
|
|
1526
|
+
switch (s) {
|
|
1527
|
+
case "screening":
|
|
1528
|
+
return "Screening Interview";
|
|
1529
|
+
case "recruiter":
|
|
1530
|
+
return "Recruiter Copilot";
|
|
1531
|
+
case "custom":
|
|
1532
|
+
return "Custom Agent";
|
|
1533
|
+
case "phone":
|
|
1534
|
+
return "Phone Agent";
|
|
1535
|
+
default:
|
|
1536
|
+
return "Voice Interview";
|
|
1537
|
+
}
|
|
1538
|
+
}, B = async () => {
|
|
1539
|
+
R(), await w();
|
|
1540
|
+
}, L = () => {
|
|
1541
|
+
C(), y?.();
|
|
1542
|
+
};
|
|
1543
|
+
return /* @__PURE__ */ d("div", { style: {
|
|
1544
|
+
background: "var(--glyde-background, white)",
|
|
1545
|
+
borderRadius: "12px",
|
|
1546
|
+
boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
|
|
1547
|
+
height: typeof c == "number" ? `${c}px` : c,
|
|
1548
|
+
display: "flex",
|
|
1549
|
+
flexDirection: "column",
|
|
1550
|
+
overflow: "hidden"
|
|
1551
|
+
}, children: [
|
|
1552
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1553
|
+
padding: "16px 20px",
|
|
1554
|
+
borderBottom: "1px solid var(--glyde-border, #e5e7eb)",
|
|
1555
|
+
display: "flex",
|
|
1556
|
+
justifyContent: "space-between",
|
|
1557
|
+
alignItems: "center"
|
|
1558
|
+
}, children: [
|
|
1559
|
+
/* @__PURE__ */ d("div", { children: [
|
|
1560
|
+
/* @__PURE__ */ i("h2", { style: { margin: 0, fontSize: "1.1rem", fontWeight: 600, color: "var(--glyde-text, #1f2937)" }, children: l() }),
|
|
1561
|
+
/* @__PURE__ */ i("small", { style: { color: "var(--glyde-text-secondary, #6b7280)", fontSize: "0.8rem" }, children: o ? "JWT Auth" : e ? "Publishable Key" : "API Key" })
|
|
1562
|
+
] }),
|
|
1563
|
+
a === "active" && /* @__PURE__ */ d("div", { style: {
|
|
1564
|
+
...m.statusBadge,
|
|
1565
|
+
...m.statusBadgeLive
|
|
1566
|
+
}, children: [
|
|
1567
|
+
/* @__PURE__ */ i(oe, { size: 14 }),
|
|
1568
|
+
" Live"
|
|
1569
|
+
] })
|
|
1570
|
+
] }),
|
|
1571
|
+
/* @__PURE__ */ i("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: a === "idle" || a === "error" ? (
|
|
1572
|
+
/* Idle State */
|
|
1573
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1574
|
+
flex: 1,
|
|
1575
|
+
display: "flex",
|
|
1576
|
+
flexDirection: "column",
|
|
1577
|
+
alignItems: "center",
|
|
1578
|
+
justifyContent: "center",
|
|
1579
|
+
padding: "40px"
|
|
1580
|
+
}, children: [
|
|
1581
|
+
/* @__PURE__ */ i("div", { style: {
|
|
1582
|
+
width: "100px",
|
|
1583
|
+
height: "100px",
|
|
1584
|
+
borderRadius: "50%",
|
|
1585
|
+
background: "var(--glyde-primary-light, #fdf4ff)",
|
|
1586
|
+
display: "flex",
|
|
1587
|
+
alignItems: "center",
|
|
1588
|
+
justifyContent: "center",
|
|
1589
|
+
marginBottom: "24px"
|
|
1590
|
+
}, children: /* @__PURE__ */ i(j, { size: 48, color: "var(--glyde-primary, #c026d3)" }) }),
|
|
1591
|
+
/* @__PURE__ */ d("h3", { style: { marginBottom: "8px", color: "var(--glyde-text, #1f2937)" }, children: [
|
|
1592
|
+
"Ready for ",
|
|
1593
|
+
l(),
|
|
1594
|
+
"?"
|
|
1595
|
+
] }),
|
|
1596
|
+
/* @__PURE__ */ i("p", { style: {
|
|
1597
|
+
color: "var(--glyde-text-secondary, #666)",
|
|
1598
|
+
marginBottom: "24px",
|
|
1599
|
+
textAlign: "center",
|
|
1600
|
+
maxWidth: "280px"
|
|
1601
|
+
}, children: s === "screening" ? "The AI recruiter will speak with you. Make sure your microphone is ready." : s === "recruiter" ? "The AI copilot will assist you with recruiting tasks." : "The AI agent will speak with you. Make sure your microphone is ready." }),
|
|
1602
|
+
/* @__PURE__ */ d(
|
|
1603
|
+
"button",
|
|
1604
|
+
{
|
|
1605
|
+
onClick: B,
|
|
1606
|
+
style: {
|
|
1607
|
+
...m.primaryButton,
|
|
1608
|
+
padding: "14px 36px",
|
|
1609
|
+
borderRadius: "30px",
|
|
1610
|
+
boxShadow: "0 4px 12px rgba(192, 38, 211, 0.3)"
|
|
1611
|
+
},
|
|
1612
|
+
children: [
|
|
1613
|
+
"Start ",
|
|
1614
|
+
s === "screening" ? "Interview" : "Call"
|
|
1615
|
+
]
|
|
1616
|
+
}
|
|
1617
|
+
),
|
|
1618
|
+
u && /* @__PURE__ */ i("p", { style: { color: "var(--glyde-error, #ef4444)", marginTop: "16px", fontSize: "0.9rem" }, children: u })
|
|
1619
|
+
] })
|
|
1620
|
+
) : (
|
|
1621
|
+
/* Active/Connecting State */
|
|
1622
|
+
/* @__PURE__ */ d(K, { children: [
|
|
1623
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1624
|
+
flex: 1,
|
|
1625
|
+
overflowY: "auto",
|
|
1626
|
+
padding: "16px",
|
|
1627
|
+
background: "var(--glyde-surface, #f9fafb)"
|
|
1628
|
+
}, children: [
|
|
1629
|
+
a === "connecting" && /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "var(--glyde-text-secondary, #6b7280)", padding: "40px" }, children: [
|
|
1630
|
+
/* @__PURE__ */ i("div", { className: "glyde-spinner", style: { margin: "0 auto 12px" } }),
|
|
1631
|
+
"Connecting to AI Agent..."
|
|
1632
|
+
] }),
|
|
1633
|
+
h.length === 0 && a === "active" && /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "var(--glyde-text-muted, #9ca3af)", padding: "40px" }, children: [
|
|
1634
|
+
/* @__PURE__ */ i(O, { size: 32, color: "var(--glyde-text-muted, #9ca3af)" }),
|
|
1635
|
+
/* @__PURE__ */ i("p", { style: { marginTop: "8px" }, children: "Start speaking - the AI will respond" })
|
|
1636
|
+
] }),
|
|
1637
|
+
h.map((S, P) => /* @__PURE__ */ i(ce, { transcript: S, contextType: s }, P)),
|
|
1638
|
+
/* @__PURE__ */ i("div", { ref: f })
|
|
1639
|
+
] }),
|
|
1640
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1641
|
+
padding: "16px",
|
|
1642
|
+
borderTop: "1px solid var(--glyde-border, #e5e7eb)",
|
|
1643
|
+
background: "var(--glyde-background, white)"
|
|
1644
|
+
}, children: [
|
|
1645
|
+
/* @__PURE__ */ i(
|
|
1646
|
+
pe,
|
|
1647
|
+
{
|
|
1648
|
+
isUserSpeaking: b,
|
|
1649
|
+
isAgentSpeaking: v
|
|
1650
|
+
}
|
|
1651
|
+
),
|
|
1652
|
+
/* @__PURE__ */ d("div", { style: { display: "flex", justifyContent: "center", gap: "12px", marginTop: "16px" }, children: [
|
|
1653
|
+
/* @__PURE__ */ i(
|
|
1654
|
+
"button",
|
|
1655
|
+
{
|
|
1656
|
+
onClick: T,
|
|
1657
|
+
style: {
|
|
1658
|
+
...m.iconButton,
|
|
1659
|
+
background: x ? "var(--glyde-error-light, #fecaca)" : "var(--glyde-secondary-light, #e0f2fe)"
|
|
1660
|
+
},
|
|
1661
|
+
title: x ? "Unmute" : "Mute",
|
|
1662
|
+
children: x ? /* @__PURE__ */ i(ne, { size: 20, color: "var(--glyde-error, #dc2626)" }) : /* @__PURE__ */ i(j, { size: 20, color: "var(--glyde-secondary, #0ea5e9)" })
|
|
1663
|
+
}
|
|
1664
|
+
),
|
|
1665
|
+
/* @__PURE__ */ d(
|
|
1666
|
+
"button",
|
|
1667
|
+
{
|
|
1668
|
+
onClick: L,
|
|
1669
|
+
style: m.dangerButton,
|
|
1670
|
+
children: [
|
|
1671
|
+
/* @__PURE__ */ i(ee, { size: 18, color: "white" }),
|
|
1672
|
+
" End Call"
|
|
1673
|
+
]
|
|
1674
|
+
}
|
|
1675
|
+
)
|
|
1676
|
+
] })
|
|
1677
|
+
] })
|
|
1678
|
+
] })
|
|
1679
|
+
) }),
|
|
1680
|
+
/* @__PURE__ */ i("style", { children: `
|
|
1681
|
+
@keyframes glyde-pulse {
|
|
1682
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
1683
|
+
50% { opacity: 0.5; transform: scale(1.2); }
|
|
1684
|
+
}
|
|
1685
|
+
.glyde-spinner {
|
|
1686
|
+
width: 32px;
|
|
1687
|
+
height: 32px;
|
|
1688
|
+
border: 3px solid var(--glyde-border, #e5e7eb);
|
|
1689
|
+
border-top-color: var(--glyde-primary, #c026d3);
|
|
1690
|
+
border-radius: 50%;
|
|
1691
|
+
animation: spin 1s linear infinite;
|
|
1692
|
+
}
|
|
1693
|
+
@keyframes spin {
|
|
1694
|
+
to { transform: rotate(360deg); }
|
|
1695
|
+
}
|
|
1696
|
+
` })
|
|
1697
|
+
] });
|
|
1698
|
+
}, ce = ({
|
|
1699
|
+
transcript: r,
|
|
1700
|
+
contextType: e
|
|
1701
|
+
}) => {
|
|
1702
|
+
const t = r.role === "user";
|
|
1703
|
+
return /* @__PURE__ */ i("div", { style: {
|
|
1704
|
+
marginBottom: "12px",
|
|
1705
|
+
display: "flex",
|
|
1706
|
+
justifyContent: t ? "flex-end" : "flex-start"
|
|
1707
|
+
}, children: /* @__PURE__ */ d("div", { style: {
|
|
1708
|
+
...m.messageBubble,
|
|
1709
|
+
...t ? m.messageBubbleUser : m.messageBubbleAgent
|
|
1710
|
+
}, children: [
|
|
1711
|
+
/* @__PURE__ */ i("div", { style: { fontSize: "0.75rem", opacity: 0.7, marginBottom: "4px" }, children: t ? "You" : e === "recruiter" ? "AI Copilot" : "AI Recruiter" }),
|
|
1712
|
+
r.content
|
|
1713
|
+
] }) });
|
|
1714
|
+
}, pe = ({
|
|
1715
|
+
isUserSpeaking: r,
|
|
1716
|
+
isAgentSpeaking: e
|
|
1717
|
+
}) => /* @__PURE__ */ d("div", { style: {
|
|
1718
|
+
display: "flex",
|
|
1719
|
+
justifyContent: "center",
|
|
1720
|
+
gap: "20px"
|
|
1721
|
+
}, children: [
|
|
1722
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1723
|
+
...m.speakingIndicator,
|
|
1724
|
+
color: r ? "var(--glyde-primary, #c026d3)" : "var(--glyde-text-muted, #9ca3af)"
|
|
1725
|
+
}, children: [
|
|
1726
|
+
/* @__PURE__ */ i("div", { style: {
|
|
1727
|
+
...m.speakingDot,
|
|
1728
|
+
background: r ? "var(--glyde-primary, #c026d3)" : "var(--glyde-border, #d1d5db)",
|
|
1729
|
+
animation: r ? "glyde-pulse 1s infinite" : "none"
|
|
1730
|
+
} }),
|
|
1731
|
+
"You"
|
|
1732
|
+
] }),
|
|
1733
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1734
|
+
...m.speakingIndicator,
|
|
1735
|
+
color: e ? "var(--glyde-success, #059669)" : "var(--glyde-text-muted, #9ca3af)"
|
|
1736
|
+
}, children: [
|
|
1737
|
+
/* @__PURE__ */ i("div", { style: {
|
|
1738
|
+
...m.speakingDot,
|
|
1739
|
+
background: e ? "var(--glyde-success, #059669)" : "var(--glyde-border, #d1d5db)",
|
|
1740
|
+
animation: e ? "glyde-pulse 1s infinite" : "none"
|
|
1741
|
+
} }),
|
|
1742
|
+
"AI Agent"
|
|
1743
|
+
] })
|
|
1744
|
+
] }), G = ({
|
|
1745
|
+
contextId: r,
|
|
1746
|
+
publishableKey: e,
|
|
1747
|
+
apiKey: t,
|
|
1748
|
+
authToken: o,
|
|
1749
|
+
unityApiUrl: n = "https://api.glydeunity.com",
|
|
1750
|
+
height: s = "600px",
|
|
1751
|
+
title: c = "AI Chat",
|
|
1752
|
+
placeholder: g = "Type your message...",
|
|
1753
|
+
autoInit: y = !0,
|
|
1754
|
+
onMessage: p,
|
|
1755
|
+
onError: f
|
|
1756
|
+
}) => {
|
|
1757
|
+
const [a, h] = k(""), b = E(null), {
|
|
1758
|
+
status: v,
|
|
1759
|
+
messages: x,
|
|
1760
|
+
isLoading: u,
|
|
1761
|
+
errorMessage: w,
|
|
1762
|
+
sendMessage: C
|
|
1763
|
+
} = Q({
|
|
1764
|
+
publishableKey: e,
|
|
1765
|
+
apiKey: t,
|
|
1766
|
+
authToken: o,
|
|
1767
|
+
contextId: r,
|
|
1768
|
+
unityBaseUrl: n,
|
|
1769
|
+
autoInit: y
|
|
1770
|
+
});
|
|
1771
|
+
I(() => {
|
|
1772
|
+
b.current?.scrollIntoView({ behavior: "smooth" });
|
|
1773
|
+
}, [x]), I(() => {
|
|
1774
|
+
v === "error" && w && f && f(new Error(w));
|
|
1775
|
+
}, [v, w, f]);
|
|
1776
|
+
const T = async () => {
|
|
1777
|
+
if (!a.trim() || u) return;
|
|
1778
|
+
const l = a.trim();
|
|
1779
|
+
h(""), await C(l), p && p({ role: "user", content: l });
|
|
1780
|
+
}, R = (l) => {
|
|
1781
|
+
l.key === "Enter" && !l.shiftKey && (l.preventDefault(), T());
|
|
1782
|
+
};
|
|
1783
|
+
return /* @__PURE__ */ d("div", { style: {
|
|
1784
|
+
background: "var(--glyde-background, white)",
|
|
1785
|
+
borderRadius: "12px",
|
|
1786
|
+
boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
|
|
1787
|
+
height: typeof s == "number" ? `${s}px` : s,
|
|
1788
|
+
display: "flex",
|
|
1789
|
+
flexDirection: "column",
|
|
1790
|
+
overflow: "hidden"
|
|
1791
|
+
}, children: [
|
|
1792
|
+
/* @__PURE__ */ i("div", { style: {
|
|
1793
|
+
padding: "16px 20px",
|
|
1794
|
+
borderBottom: "1px solid var(--glyde-border, #eee)",
|
|
1795
|
+
background: "var(--glyde-secondary, #0284c7)",
|
|
1796
|
+
color: "white",
|
|
1797
|
+
borderTopLeftRadius: "12px",
|
|
1798
|
+
borderTopRightRadius: "12px"
|
|
1799
|
+
}, children: /* @__PURE__ */ i("h2", { style: { margin: 0, fontSize: "1.1rem", fontWeight: 600 }, children: c }) }),
|
|
1800
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1801
|
+
flex: 1,
|
|
1802
|
+
overflowY: "auto",
|
|
1803
|
+
padding: "20px",
|
|
1804
|
+
display: "flex",
|
|
1805
|
+
flexDirection: "column",
|
|
1806
|
+
gap: "15px",
|
|
1807
|
+
background: "var(--glyde-background, white)"
|
|
1808
|
+
}, children: [
|
|
1809
|
+
v === "loading" && x.length === 0 && /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "var(--glyde-text-muted, #94a3b8)", padding: "20px" }, children: [
|
|
1810
|
+
/* @__PURE__ */ i("div", { className: "glyde-spinner", style: { margin: "0 auto 12px" } }),
|
|
1811
|
+
"Loading conversation..."
|
|
1812
|
+
] }),
|
|
1813
|
+
x.map((l, B) => /* @__PURE__ */ i(he, { message: l }, B)),
|
|
1814
|
+
u && /* @__PURE__ */ i("div", { style: { color: "var(--glyde-text-muted, #94a3b8)", fontSize: "0.9rem", marginLeft: "42px" }, children: /* @__PURE__ */ i(ue, {}) }),
|
|
1815
|
+
/* @__PURE__ */ i("div", { ref: b })
|
|
1816
|
+
] }),
|
|
1817
|
+
/* @__PURE__ */ d("div", { style: { padding: "16px 20px", borderTop: "1px solid var(--glyde-border, #eee)" }, children: [
|
|
1818
|
+
w && /* @__PURE__ */ i("p", { style: {
|
|
1819
|
+
color: "var(--glyde-error, #ef4444)",
|
|
1820
|
+
fontSize: "0.85rem",
|
|
1821
|
+
marginBottom: "10px"
|
|
1822
|
+
}, children: w }),
|
|
1823
|
+
/* @__PURE__ */ d("div", { style: { display: "flex", gap: "10px" }, children: [
|
|
1824
|
+
/* @__PURE__ */ i(
|
|
1825
|
+
"input",
|
|
1826
|
+
{
|
|
1827
|
+
type: "text",
|
|
1828
|
+
value: a,
|
|
1829
|
+
onChange: (l) => h(l.target.value),
|
|
1830
|
+
onKeyDown: R,
|
|
1831
|
+
placeholder: g,
|
|
1832
|
+
style: {
|
|
1833
|
+
...m.inputField,
|
|
1834
|
+
flex: 1
|
|
1835
|
+
},
|
|
1836
|
+
disabled: u
|
|
1837
|
+
}
|
|
1838
|
+
),
|
|
1839
|
+
/* @__PURE__ */ i(
|
|
1840
|
+
"button",
|
|
1841
|
+
{
|
|
1842
|
+
onClick: T,
|
|
1843
|
+
disabled: u || !a.trim(),
|
|
1844
|
+
style: {
|
|
1845
|
+
...m.iconButton,
|
|
1846
|
+
background: "var(--glyde-secondary, #0284c7)",
|
|
1847
|
+
width: "48px",
|
|
1848
|
+
height: "48px",
|
|
1849
|
+
opacity: u || !a.trim() ? 0.5 : 1,
|
|
1850
|
+
cursor: u || !a.trim() ? "not-allowed" : "pointer"
|
|
1851
|
+
},
|
|
1852
|
+
children: /* @__PURE__ */ i(te, { size: 20, color: "white" })
|
|
1853
|
+
}
|
|
1854
|
+
)
|
|
1855
|
+
] })
|
|
1856
|
+
] }),
|
|
1857
|
+
/* @__PURE__ */ i("style", { children: `
|
|
1858
|
+
.glyde-spinner {
|
|
1859
|
+
width: 24px;
|
|
1860
|
+
height: 24px;
|
|
1861
|
+
border: 2px solid var(--glyde-border, #e5e7eb);
|
|
1862
|
+
border-top-color: var(--glyde-secondary, #0284c7);
|
|
1863
|
+
border-radius: 50%;
|
|
1864
|
+
animation: spin 1s linear infinite;
|
|
1865
|
+
}
|
|
1866
|
+
@keyframes spin {
|
|
1867
|
+
to { transform: rotate(360deg); }
|
|
1868
|
+
}
|
|
1869
|
+
@keyframes typing-dot {
|
|
1870
|
+
0%, 60%, 100% { opacity: 0.3; }
|
|
1871
|
+
30% { opacity: 1; }
|
|
1872
|
+
}
|
|
1873
|
+
` })
|
|
1874
|
+
] });
|
|
1875
|
+
}, he = ({ message: r }) => {
|
|
1876
|
+
const e = r.role === "user";
|
|
1877
|
+
return /* @__PURE__ */ d("div", { style: {
|
|
1878
|
+
display: "flex",
|
|
1879
|
+
gap: "10px",
|
|
1880
|
+
flexDirection: e ? "row-reverse" : "row",
|
|
1881
|
+
alignItems: "flex-start"
|
|
1882
|
+
}, children: [
|
|
1883
|
+
/* @__PURE__ */ i("div", { style: {
|
|
1884
|
+
width: "32px",
|
|
1885
|
+
height: "32px",
|
|
1886
|
+
borderRadius: "50%",
|
|
1887
|
+
background: e ? "var(--glyde-primary-light, #e0e7ff)" : "var(--glyde-secondary-light, #f0f9ff)",
|
|
1888
|
+
display: "flex",
|
|
1889
|
+
alignItems: "center",
|
|
1890
|
+
justifyContent: "center",
|
|
1891
|
+
flexShrink: 0
|
|
1892
|
+
}, children: e ? /* @__PURE__ */ i(re, { size: 18, color: "var(--glyde-primary, #4338ca)" }) : /* @__PURE__ */ i(ie, { size: 18, color: "var(--glyde-secondary, #0284c7)" }) }),
|
|
1893
|
+
/* @__PURE__ */ i("div", { style: {
|
|
1894
|
+
padding: "12px 16px",
|
|
1895
|
+
borderRadius: "12px",
|
|
1896
|
+
background: e ? "var(--glyde-primary, #4338ca)" : "var(--glyde-surface, #f1f5f9)",
|
|
1897
|
+
color: e ? "white" : "var(--glyde-text, #1e293b)",
|
|
1898
|
+
maxWidth: "70%",
|
|
1899
|
+
borderTopRightRadius: e ? "4px" : "12px",
|
|
1900
|
+
borderTopLeftRadius: e ? "12px" : "4px",
|
|
1901
|
+
lineHeight: 1.5
|
|
1902
|
+
}, children: r.content })
|
|
1903
|
+
] });
|
|
1904
|
+
}, ue = () => /* @__PURE__ */ d("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
1905
|
+
/* @__PURE__ */ i("span", { children: "Typing" }),
|
|
1906
|
+
/* @__PURE__ */ i("span", { style: { display: "flex", gap: "2px" }, children: [0, 1, 2].map((r) => /* @__PURE__ */ i(
|
|
1907
|
+
"span",
|
|
1908
|
+
{
|
|
1909
|
+
style: {
|
|
1910
|
+
width: "4px",
|
|
1911
|
+
height: "4px",
|
|
1912
|
+
borderRadius: "50%",
|
|
1913
|
+
background: "var(--glyde-text-muted, #94a3b8)",
|
|
1914
|
+
animation: "typing-dot 1.4s infinite",
|
|
1915
|
+
animationDelay: `${r * 0.2}s`
|
|
1916
|
+
}
|
|
1917
|
+
},
|
|
1918
|
+
r
|
|
1919
|
+
)) })
|
|
1920
|
+
] }), U = ({
|
|
1921
|
+
publishableKey: r,
|
|
1922
|
+
apiKey: e,
|
|
1923
|
+
authToken: t,
|
|
1924
|
+
contextId: o,
|
|
1925
|
+
unityBaseUrl: n = "https://api.glydeunity.com",
|
|
1926
|
+
contextType: s = "screening",
|
|
1927
|
+
defaultMode: c = "voice",
|
|
1928
|
+
position: g = "bottom-right",
|
|
1929
|
+
theme: y = "light",
|
|
1930
|
+
allowModeSwitch: p = !0,
|
|
1931
|
+
container: f,
|
|
1932
|
+
onReady: a,
|
|
1933
|
+
onModeChange: h,
|
|
1934
|
+
onTranscript: b,
|
|
1935
|
+
onError: v,
|
|
1936
|
+
initialExpanded: x = !1
|
|
1937
|
+
}) => {
|
|
1938
|
+
const [u, w] = k(x), [C, T] = k(c);
|
|
1939
|
+
I(() => {
|
|
1940
|
+
const S = y === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : y;
|
|
1941
|
+
N(S);
|
|
1942
|
+
}, [y]), I(() => {
|
|
1943
|
+
a?.();
|
|
1944
|
+
}, [a]);
|
|
1945
|
+
const R = le(g), l = (S) => {
|
|
1946
|
+
T(S), h?.(S);
|
|
1947
|
+
}, B = (S, P) => {
|
|
1948
|
+
b?.(S, P);
|
|
1949
|
+
}, L = (S) => {
|
|
1950
|
+
v?.(S);
|
|
1951
|
+
};
|
|
1952
|
+
return f ? /* @__PURE__ */ i(
|
|
1953
|
+
ge,
|
|
1954
|
+
{
|
|
1955
|
+
publishableKey: r,
|
|
1956
|
+
apiKey: e,
|
|
1957
|
+
authToken: t,
|
|
1958
|
+
contextId: o,
|
|
1959
|
+
unityBaseUrl: n,
|
|
1960
|
+
contextType: s,
|
|
1961
|
+
mode: C,
|
|
1962
|
+
allowModeSwitch: p,
|
|
1963
|
+
onModeChange: l,
|
|
1964
|
+
onTranscript: B,
|
|
1965
|
+
onError: L
|
|
1966
|
+
}
|
|
1967
|
+
) : /* @__PURE__ */ d("div", { className: "glyde-widget-root", children: [
|
|
1968
|
+
!u && /* @__PURE__ */ i(
|
|
1969
|
+
"button",
|
|
1970
|
+
{
|
|
1971
|
+
onClick: () => w(!0),
|
|
1972
|
+
style: {
|
|
1973
|
+
...m.floatingButton,
|
|
1974
|
+
...R.button,
|
|
1975
|
+
background: "linear-gradient(135deg, var(--glyde-primary, #c026d3) 0%, var(--glyde-secondary, #7c3aed) 100%)"
|
|
1976
|
+
},
|
|
1977
|
+
"aria-label": "Open chat",
|
|
1978
|
+
children: /* @__PURE__ */ i(j, { size: 28, color: "white" })
|
|
1979
|
+
}
|
|
1980
|
+
),
|
|
1981
|
+
u && /* @__PURE__ */ d(
|
|
1982
|
+
"div",
|
|
1983
|
+
{
|
|
1984
|
+
style: {
|
|
1985
|
+
...m.widgetPanel,
|
|
1986
|
+
...R.panel,
|
|
1987
|
+
background: "var(--glyde-background, white)"
|
|
1988
|
+
},
|
|
1989
|
+
className: "glyde-slide-up",
|
|
1990
|
+
children: [
|
|
1991
|
+
/* @__PURE__ */ d("div", { style: {
|
|
1992
|
+
...m.header,
|
|
1993
|
+
background: "linear-gradient(135deg, var(--glyde-primary, #c026d3) 0%, var(--glyde-secondary, #7c3aed) 100%)",
|
|
1994
|
+
color: "white",
|
|
1995
|
+
borderTopLeftRadius: "16px",
|
|
1996
|
+
borderTopRightRadius: "16px"
|
|
1997
|
+
}, children: [
|
|
1998
|
+
/* @__PURE__ */ d("div", { children: [
|
|
1999
|
+
/* @__PURE__ */ i("h3", { style: { margin: 0, fontSize: "1rem", fontWeight: 600 }, children: "GLYDE Assistant" }),
|
|
2000
|
+
/* @__PURE__ */ i("small", { style: { opacity: 0.8, fontSize: "0.75rem" }, children: s === "screening" ? "Candidate Screening" : "AI Assistant" })
|
|
2001
|
+
] }),
|
|
2002
|
+
/* @__PURE__ */ d("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2003
|
+
/* @__PURE__ */ i(
|
|
2004
|
+
"button",
|
|
2005
|
+
{
|
|
2006
|
+
onClick: () => w(!1),
|
|
2007
|
+
style: {
|
|
2008
|
+
...m.iconButton,
|
|
2009
|
+
background: "rgba(255,255,255,0.2)",
|
|
2010
|
+
width: "32px",
|
|
2011
|
+
height: "32px"
|
|
2012
|
+
},
|
|
2013
|
+
"aria-label": "Minimize",
|
|
2014
|
+
children: /* @__PURE__ */ i(ae, { size: 16, color: "white" })
|
|
2015
|
+
}
|
|
2016
|
+
),
|
|
2017
|
+
/* @__PURE__ */ i(
|
|
2018
|
+
"button",
|
|
2019
|
+
{
|
|
2020
|
+
onClick: () => w(!1),
|
|
2021
|
+
style: {
|
|
2022
|
+
...m.iconButton,
|
|
2023
|
+
background: "rgba(255,255,255,0.2)",
|
|
2024
|
+
width: "32px",
|
|
2025
|
+
height: "32px"
|
|
2026
|
+
},
|
|
2027
|
+
"aria-label": "Close",
|
|
2028
|
+
children: /* @__PURE__ */ i(se, { size: 16, color: "white" })
|
|
2029
|
+
}
|
|
2030
|
+
)
|
|
2031
|
+
] })
|
|
2032
|
+
] }),
|
|
2033
|
+
p && /* @__PURE__ */ i("div", { style: {
|
|
2034
|
+
padding: "12px 16px",
|
|
2035
|
+
borderBottom: "1px solid var(--glyde-border, #e5e7eb)"
|
|
2036
|
+
}, children: /* @__PURE__ */ i(H, { mode: C, onModeChange: l }) }),
|
|
2037
|
+
/* @__PURE__ */ i("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: C === "voice" ? /* @__PURE__ */ i(
|
|
2038
|
+
F,
|
|
2039
|
+
{
|
|
2040
|
+
publishableKey: r,
|
|
2041
|
+
apiKey: e,
|
|
2042
|
+
authToken: t,
|
|
2043
|
+
contextId: o || "",
|
|
2044
|
+
unityApiUrl: n,
|
|
2045
|
+
contextType: s,
|
|
2046
|
+
height: "100%",
|
|
2047
|
+
onTranscript: B,
|
|
2048
|
+
onError: L
|
|
2049
|
+
}
|
|
2050
|
+
) : /* @__PURE__ */ i(
|
|
2051
|
+
G,
|
|
2052
|
+
{
|
|
2053
|
+
publishableKey: r,
|
|
2054
|
+
apiKey: e,
|
|
2055
|
+
authToken: t,
|
|
2056
|
+
contextId: o || "",
|
|
2057
|
+
unityApiUrl: n,
|
|
2058
|
+
height: "100%",
|
|
2059
|
+
title: "Text Chat",
|
|
2060
|
+
onError: L
|
|
2061
|
+
}
|
|
2062
|
+
) })
|
|
2063
|
+
]
|
|
2064
|
+
}
|
|
2065
|
+
)
|
|
2066
|
+
] });
|
|
2067
|
+
}, H = ({ mode: r, onModeChange: e }) => /* @__PURE__ */ d("div", { style: m.modeSelector, children: [
|
|
2068
|
+
/* @__PURE__ */ d(
|
|
2069
|
+
"button",
|
|
2070
|
+
{
|
|
2071
|
+
onClick: () => e("voice"),
|
|
2072
|
+
style: {
|
|
2073
|
+
...m.modeSelectorButton,
|
|
2074
|
+
background: r === "voice" ? "var(--glyde-primary, #c026d3)" : "transparent",
|
|
2075
|
+
color: r === "voice" ? "white" : "var(--glyde-text, #1f2937)"
|
|
2076
|
+
},
|
|
2077
|
+
children: [
|
|
2078
|
+
/* @__PURE__ */ i(j, { size: 16 }),
|
|
2079
|
+
" Voice"
|
|
2080
|
+
]
|
|
2081
|
+
}
|
|
2082
|
+
),
|
|
2083
|
+
/* @__PURE__ */ d(
|
|
2084
|
+
"button",
|
|
2085
|
+
{
|
|
2086
|
+
onClick: () => e("text"),
|
|
2087
|
+
style: {
|
|
2088
|
+
...m.modeSelectorButton,
|
|
2089
|
+
background: r === "text" ? "var(--glyde-secondary, #0284c7)" : "transparent",
|
|
2090
|
+
color: r === "text" ? "white" : "var(--glyde-text, #1f2937)"
|
|
2091
|
+
},
|
|
2092
|
+
children: [
|
|
2093
|
+
/* @__PURE__ */ i(O, { size: 16 }),
|
|
2094
|
+
" Text"
|
|
2095
|
+
]
|
|
2096
|
+
}
|
|
2097
|
+
)
|
|
2098
|
+
] }), ge = ({
|
|
2099
|
+
publishableKey: r,
|
|
2100
|
+
apiKey: e,
|
|
2101
|
+
authToken: t,
|
|
2102
|
+
contextId: o,
|
|
2103
|
+
unityBaseUrl: n,
|
|
2104
|
+
contextType: s,
|
|
2105
|
+
mode: c,
|
|
2106
|
+
allowModeSwitch: g,
|
|
2107
|
+
onModeChange: y,
|
|
2108
|
+
onTranscript: p,
|
|
2109
|
+
onError: f
|
|
2110
|
+
}) => {
|
|
2111
|
+
const [a, h] = k(c);
|
|
2112
|
+
return /* @__PURE__ */ d("div", { className: "glyde-widget-root", style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
|
|
2113
|
+
g && /* @__PURE__ */ i("div", { style: {
|
|
2114
|
+
padding: "12px 16px",
|
|
2115
|
+
borderBottom: "1px solid var(--glyde-border, #e5e7eb)",
|
|
2116
|
+
background: "var(--glyde-background, white)"
|
|
2117
|
+
}, children: /* @__PURE__ */ i(H, { mode: a, onModeChange: (v) => {
|
|
2118
|
+
h(v), y(v);
|
|
2119
|
+
} }) }),
|
|
2120
|
+
/* @__PURE__ */ i("div", { style: { flex: 1, overflow: "hidden" }, children: a === "voice" ? /* @__PURE__ */ i(
|
|
2121
|
+
F,
|
|
2122
|
+
{
|
|
2123
|
+
publishableKey: r,
|
|
2124
|
+
apiKey: e,
|
|
2125
|
+
authToken: t,
|
|
2126
|
+
contextId: o || "",
|
|
2127
|
+
unityApiUrl: n,
|
|
2128
|
+
contextType: s,
|
|
2129
|
+
height: "100%",
|
|
2130
|
+
onTranscript: p,
|
|
2131
|
+
onError: f
|
|
2132
|
+
}
|
|
2133
|
+
) : /* @__PURE__ */ i(
|
|
2134
|
+
G,
|
|
2135
|
+
{
|
|
2136
|
+
publishableKey: r,
|
|
2137
|
+
apiKey: e,
|
|
2138
|
+
authToken: t,
|
|
2139
|
+
contextId: o || "",
|
|
2140
|
+
unityApiUrl: n,
|
|
2141
|
+
height: "100%",
|
|
2142
|
+
title: "Text Chat",
|
|
2143
|
+
onError: f
|
|
2144
|
+
}
|
|
2145
|
+
) })
|
|
2146
|
+
] });
|
|
2147
|
+
};
|
|
2148
|
+
let M = null, W = null;
|
|
2149
|
+
const _ = {
|
|
2150
|
+
/**
|
|
2151
|
+
* Initialize the chat widget
|
|
2152
|
+
*
|
|
2153
|
+
* @param config - Widget configuration
|
|
2154
|
+
* @returns Control object for the widget
|
|
2155
|
+
*/
|
|
2156
|
+
init(r) {
|
|
2157
|
+
if (!r.publishableKey && !r.apiKey && !r.authToken)
|
|
2158
|
+
return console.error("[GlydeChat] Authentication required: provide publishableKey, apiKey, or authToken"), null;
|
|
2159
|
+
const e = r.theme === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : r.theme || "light";
|
|
2160
|
+
N(e), M && W && (M.unmount(), W.remove(), M = null, W = null);
|
|
2161
|
+
const t = document.createElement("div");
|
|
2162
|
+
t.id = "glyde-chat-widget", t.className = "glyde-widget-root", document.body.appendChild(t), W = t;
|
|
2163
|
+
const o = D(t);
|
|
2164
|
+
return M = o, o.render(
|
|
2165
|
+
z.createElement(U, {
|
|
2166
|
+
...r,
|
|
2167
|
+
initialExpanded: !1
|
|
2168
|
+
})
|
|
2169
|
+
), console.log("[GlydeChat] Widget initialized"), {
|
|
2170
|
+
/**
|
|
2171
|
+
* Destroy the widget
|
|
2172
|
+
*/
|
|
2173
|
+
destroy() {
|
|
2174
|
+
M && W && (M.unmount(), W.remove(), M = null, W = null, console.log("[GlydeChat] Widget destroyed"));
|
|
2175
|
+
},
|
|
2176
|
+
/**
|
|
2177
|
+
* Update widget configuration
|
|
2178
|
+
*/
|
|
2179
|
+
update(n) {
|
|
2180
|
+
M && M.render(
|
|
2181
|
+
z.createElement(U, {
|
|
2182
|
+
...r,
|
|
2183
|
+
...n
|
|
2184
|
+
})
|
|
2185
|
+
);
|
|
2186
|
+
}
|
|
2187
|
+
};
|
|
2188
|
+
},
|
|
2189
|
+
/**
|
|
2190
|
+
* Render widget into a specific container (non-floating)
|
|
2191
|
+
*
|
|
2192
|
+
* @param container - DOM element or selector
|
|
2193
|
+
* @param config - Widget configuration
|
|
2194
|
+
*/
|
|
2195
|
+
render(r, e) {
|
|
2196
|
+
const t = typeof r == "string" ? document.querySelector(r) : r;
|
|
2197
|
+
if (!t)
|
|
2198
|
+
return console.error("[GlydeChat] Container not found:", r), null;
|
|
2199
|
+
const o = e.theme === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : e.theme || "light";
|
|
2200
|
+
N(o);
|
|
2201
|
+
const n = D(t);
|
|
2202
|
+
return n.render(
|
|
2203
|
+
z.createElement(U, {
|
|
2204
|
+
...e,
|
|
2205
|
+
container: t
|
|
2206
|
+
})
|
|
2207
|
+
), {
|
|
2208
|
+
destroy() {
|
|
2209
|
+
n.unmount();
|
|
2210
|
+
},
|
|
2211
|
+
update(s) {
|
|
2212
|
+
n.render(
|
|
2213
|
+
z.createElement(U, {
|
|
2214
|
+
...e,
|
|
2215
|
+
...s,
|
|
2216
|
+
container: t
|
|
2217
|
+
})
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
2220
|
+
};
|
|
2221
|
+
},
|
|
2222
|
+
/**
|
|
2223
|
+
* Check if the SDK is loaded and ready
|
|
2224
|
+
*/
|
|
2225
|
+
isReady() {
|
|
2226
|
+
return !0;
|
|
2227
|
+
},
|
|
2228
|
+
/**
|
|
2229
|
+
* Get SDK version
|
|
2230
|
+
*/
|
|
2231
|
+
get version() {
|
|
2232
|
+
return "__SDK_VERSION__";
|
|
2233
|
+
}
|
|
2234
|
+
};
|
|
2235
|
+
function ye() {
|
|
2236
|
+
const r = document.querySelectorAll('script[src*="glyde-chat"]'), e = r[r.length - 1];
|
|
2237
|
+
if (!e || e.getAttribute("data-auto-init") !== "true") return;
|
|
2238
|
+
const o = {
|
|
2239
|
+
publishableKey: e.getAttribute("data-publishable-key") || void 0,
|
|
2240
|
+
apiKey: e.getAttribute("data-api-key") || void 0,
|
|
2241
|
+
authToken: e.getAttribute("data-auth-token") || void 0,
|
|
2242
|
+
contextId: e.getAttribute("data-context-id") || void 0,
|
|
2243
|
+
unityBaseUrl: e.getAttribute("data-unity-url") || "https://api.glydeunity.com",
|
|
2244
|
+
contextType: e.getAttribute("data-context-type") || "screening",
|
|
2245
|
+
defaultMode: e.getAttribute("data-default-mode") || "voice",
|
|
2246
|
+
position: e.getAttribute("data-position") || "bottom-right",
|
|
2247
|
+
theme: e.getAttribute("data-theme") || "light",
|
|
2248
|
+
allowModeSwitch: e.getAttribute("data-allow-mode-switch") !== "false"
|
|
2249
|
+
};
|
|
2250
|
+
if (!o.publishableKey && !o.apiKey && !o.authToken) {
|
|
2251
|
+
console.warn("[GlydeChat] Auto-init skipped: no authentication provided");
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => _.init(o)) : _.init(o);
|
|
2255
|
+
}
|
|
2256
|
+
typeof window < "u" && (window.GlydeChat = _, ye());
|
|
617
2257
|
export {
|
|
618
|
-
|
|
2258
|
+
oe as ActivityIcon,
|
|
2259
|
+
ie as BotIcon,
|
|
2260
|
+
U as ChatWidget,
|
|
2261
|
+
_ as GlydeChat,
|
|
2262
|
+
X as GlydeText,
|
|
2263
|
+
Y as GlydeVoice,
|
|
2264
|
+
we as LoaderIcon,
|
|
2265
|
+
O as MessageIcon,
|
|
2266
|
+
j as MicIcon,
|
|
2267
|
+
be as MicOffIcon,
|
|
2268
|
+
ae as MinimizeIcon,
|
|
2269
|
+
ve as PhoneIcon,
|
|
2270
|
+
ee as PhoneOffIcon,
|
|
2271
|
+
te as SendIcon,
|
|
2272
|
+
G as TextChat,
|
|
2273
|
+
re as UserIcon,
|
|
2274
|
+
F as VoiceChat,
|
|
2275
|
+
ne as VolumeXIcon,
|
|
2276
|
+
se as XIcon,
|
|
2277
|
+
m as componentStyles,
|
|
2278
|
+
le as getPositionStyles,
|
|
2279
|
+
$ as getThemeCSSVariables,
|
|
2280
|
+
V as globalStyles,
|
|
2281
|
+
N as injectGlobalStyles,
|
|
2282
|
+
de as themeColors,
|
|
2283
|
+
ke as updateTheme,
|
|
2284
|
+
Q as useTextChat,
|
|
2285
|
+
Z as useVoiceAgent
|
|
619
2286
|
};
|
|
2287
|
+
//# sourceMappingURL=voice-sdk.es.js.map
|