@glydeunity/voice-sdk 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
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";
2
+ import { jsxs as l, jsx as i, Fragment as K } from "react/jsx-runtime";
3
+ import { createRoot as $ } from "react-dom/client";
4
4
  const J = `
5
5
  class AudioCaptureProcessor extends AudioWorkletProcessor {
6
6
  constructor() {
@@ -154,6 +154,8 @@ class Y {
154
154
  // Agent state
155
155
  isAgentSpeaking = !1;
156
156
  agentAudioDoneReceived = !1;
157
+ // Conversation history
158
+ conversationHistory = [];
157
159
  // Session context for function calls (passed to backend for data controls)
158
160
  sessionContext = {};
159
161
  /**
@@ -161,7 +163,7 @@ class Y {
161
163
  * @param config - Configuration options
162
164
  */
163
165
  constructor(e) {
164
- this.config = e, this.unityUrl = e.unityBaseUrl || "https://api.glydeunity.com", !e.publishableKey && !e.apiKey && !e.authToken && console.warn("[GlydeVoice] No authentication method provided. One of publishableKey, apiKey, or authToken is required.");
166
+ this.config = e, this.unityUrl = e.unityBaseUrl || "https://api.glydeunity.com", e.conversationHistory && (this.conversationHistory = e.conversationHistory), !e.publishableKey && !e.apiKey && !e.authToken && console.warn("[GlydeVoice] No authentication method provided. One of publishableKey, apiKey, or authToken is required.");
165
167
  }
166
168
  /**
167
169
  * Get authentication headers based on configured auth method
@@ -219,20 +221,26 @@ class Y {
219
221
  contextType: this.config.contextType,
220
222
  currentJobUuid: s?.job_uuid
221
223
  });
222
- const g = this.config.systemPrompt || s.instructions || this.serverConfig?.system_prompt || "You are a helpful AI assistant.";
223
- await this.initializeAudio();
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
+ let y = this.config.systemPrompt || s.instructions || this.serverConfig?.system_prompt || "You are a helpful AI assistant.";
225
+ this.conversationHistory && this.conversationHistory.length > 0 && (y = `Previous conversation context:
226
+ ${this.conversationHistory.map((p) => `${p.role === "agent" ? "Assistant" : "User"}: ${p.content}`).join(`
227
+ `)}
228
+
229
+ IMPORTANT: This is a continuation of a previous conversation. When the user starts speaking, you must first greet them warmly and acknowledge that you're continuing the conversation. Say something like "Welcome back! I'm glad you're continuing our conversation. How can I help you today?" or similar, then continue naturally based on the previous context.
230
+
231
+ ${y}`), await this.initializeAudio();
232
+ let h = "wss://agent.deepgram.com/v1/agent/converse";
233
+ const u = this.config.deepgramConfig || c || this.serverConfig?.deepgram_config;
234
+ if (u?.tags && u.tags.length > 0) {
227
235
  const a = new URLSearchParams();
228
- p.tags.forEach((h) => a.append("tag", h)), y += `?${a.toString()}`;
236
+ u.tags.forEach((p) => a.append("tag", p)), h += `?${a.toString()}`;
229
237
  }
230
- this.ws = new WebSocket(y, ["bearer", n]), this.ws.onopen = () => {
231
- const a = p || {
238
+ this.ws = new WebSocket(h, ["bearer", n]), this.ws.onopen = () => {
239
+ const a = u || {
232
240
  think: { provider: { type: "open_ai", model: "gpt-4.1-nano" } },
233
241
  speak: { provider: { type: "deepgram", model: "aura-2-thalia-en" } },
234
242
  listen: { provider: { type: "deepgram", version: "v2", model: "flux-general-en" } }
235
- }, h = {
243
+ }, p = {
236
244
  type: "Settings",
237
245
  audio: {
238
246
  input: {
@@ -258,22 +266,32 @@ class Y {
258
266
  // Functions come from server config - no client-side defaults
259
267
  ...a.think?.functions && { functions: a.think.functions }
260
268
  },
261
- greeting: "Hi! I'm excited you chose to speak with me. Are you ready to start?"
269
+ // Only show greeting if there's no previous conversation history
270
+ // When resuming a conversation, skip the greeting to continue naturally
271
+ ...!this.conversationHistory || this.conversationHistory.length === 0 ? { greeting: "Hi! I'm excited you chose to speak with me. Are you ready to start?" } : {}
262
272
  }
263
273
  };
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 } });
274
+ a.tags && a.tags.length > 0 && (p.tags = a.tags), this.ws.send(JSON.stringify(p)), this.emit({ type: "open", payload: { config: s, serverConfig: this.serverConfig } });
265
275
  };
266
- const f = g;
276
+ const f = y;
267
277
  this.ws.onmessage = (a) => {
268
278
  if (typeof a.data == "string") {
269
279
  try {
270
- if (JSON.parse(a.data).type === "SettingsApplied") {
271
- const b = {
280
+ const p = JSON.parse(a.data);
281
+ if (p.type === "SettingsApplied") {
282
+ const m = {
272
283
  type: "UpdatePrompt",
273
284
  prompt: f
274
285
  };
275
- this.ws.send(JSON.stringify(b)), this.startMicrophone();
286
+ this.ws.send(JSON.stringify(m)), setTimeout(() => {
287
+ this.mediaStream || this.startMicrophone().catch((v) => {
288
+ console.error("[GlydeVoice] Failed to start microphone:", v);
289
+ });
290
+ }, 500);
276
291
  }
292
+ p.type === "PromptUpdated" && (this.mediaStream || this.startMicrophone().catch((m) => {
293
+ console.error("[GlydeVoice] Failed to start microphone:", m);
294
+ }));
277
295
  } catch {
278
296
  }
279
297
  this.handleTextMessage(a.data);
@@ -330,6 +348,8 @@ class Y {
330
348
  break;
331
349
  case "SettingsApplied":
332
350
  break;
351
+ case "PromptUpdated":
352
+ break;
333
353
  case "UserStartedSpeaking":
334
354
  this.emit({ type: "user_speaking", payload: !0 }), this.clearPlaybackBuffer(), this.isAgentSpeaking = !1, this.agentAudioDoneReceived = !1;
335
355
  break;
@@ -378,15 +398,15 @@ class Y {
378
398
  const o = t - t % 2;
379
399
  if (o === 0) return;
380
400
  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);
401
+ for (let u = 0; u < s.length; u++)
402
+ c[u] = s[u] / 32768;
403
+ const y = this.resample24kTo48k(c);
384
404
  !this.isAgentSpeaking && !this.agentAudioDoneReceived && (this.isAgentSpeaking = !0, this.emit({ type: "agent_speaking", payload: !0 }));
385
- const y = new Float32Array(g);
405
+ const h = new Float32Array(y);
386
406
  this.playbackWorkletNode.port.postMessage({
387
407
  type: "audio",
388
- data: y
389
- }, [y.buffer]);
408
+ data: h
409
+ }, [h.buffer]);
390
410
  }
391
411
  /**
392
412
  * Resample audio from 24kHz to 48kHz using linear interpolation
@@ -394,8 +414,8 @@ class Y {
394
414
  resample24kTo48k(e) {
395
415
  const t = e.length * 2, o = new Float32Array(t);
396
416
  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;
417
+ const c = e[s], y = e[s + 1];
418
+ o[s * 2] = c, o[s * 2 + 1] = (c + y) / 2;
399
419
  }
400
420
  const n = e.length - 1;
401
421
  return o[n * 2] = e[n], o[n * 2 + 1] = e[n], o;
@@ -705,12 +725,12 @@ class X {
705
725
  })
706
726
  });
707
727
  if (!o.ok) {
708
- const g = await o.json().catch(() => ({}));
709
- throw new Error(g.error?.message || g.message || "Failed to send message");
728
+ const y = await o.json().catch(() => ({}));
729
+ throw new Error(y.error?.message || y.message || "Failed to send message");
710
730
  }
711
731
  const n = await o.json();
712
732
  n.history?.messages && (this.history = n.history.messages);
713
- const s = [...this.history].reverse().find((g) => g.role === "assistant");
733
+ const s = [...this.history].reverse().find((y) => y.role === "assistant");
714
734
  return s ? (this.config.onMessage && this.config.onMessage(s), this.emit({ type: "message", payload: s }), s) : {
715
735
  role: "assistant",
716
736
  content: n.response || "I received your message.",
@@ -750,122 +770,122 @@ class X {
750
770
  }
751
771
  }
752
772
  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) {
773
+ const [e, t] = k("idle"), [o, n] = k([]), [s, c] = k(!1), [y, h] = k(!1), [u, f] = k(!1), [a, p] = k(null), m = E(null), v = A((d) => {
774
+ switch (d.type) {
755
775
  case "ready":
756
776
  t("active");
757
777
  break;
758
778
  case "close":
759
- t("idle"), c(!1), y(!1);
779
+ t("idle"), c(!1), h(!1);
760
780
  break;
761
781
  case "error":
762
- t("error"), h(
763
- typeof l.payload == "object" && l.payload !== null && "message" in l.payload ? String(l.payload.message) : "Connection error"
782
+ t("error"), p(
783
+ typeof d.payload == "object" && d.payload !== null && "message" in d.payload ? String(d.payload.message) : "Connection error"
764
784
  );
765
785
  break;
766
786
  case "user_speaking":
767
- c(!!l.payload);
787
+ c(!!d.payload);
768
788
  break;
769
789
  case "agent_speaking":
770
- y(!!l.payload);
790
+ h(!!d.payload);
771
791
  break;
772
792
  }
773
- }, []), x = A((l, B) => {
774
- n((L) => [...L, {
793
+ }, []), b = A((d, B) => {
794
+ n((W) => [...W, {
775
795
  role: B,
776
- content: l,
796
+ content: d,
777
797
  timestamp: /* @__PURE__ */ new Date()
778
798
  }]);
779
- }, []), u = A(async () => {
780
- t("connecting"), h(null);
799
+ }, []), g = A(async () => {
800
+ t("connecting"), p(null);
781
801
  try {
782
- const l = new Y({
802
+ const d = new Y({
783
803
  ...r,
784
804
  onEvent: v,
785
- onTranscript: x
805
+ onTranscript: b
786
806
  });
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");
807
+ m.current = d, await d.start();
808
+ } catch (d) {
809
+ console.error("[useVoiceAgent] Failed to start:", d), t("error"), p(d instanceof Error ? d.message : "Failed to connect");
790
810
  }
791
- }, [r, v, x]), w = A(() => {
792
- b.current?.stop(), b.current = null, t("idle"), c(!1), y(!1);
811
+ }, [r, v, b]), w = A(() => {
812
+ m.current?.stop(), m.current = null, t("idle"), c(!1), h(!1);
793
813
  }, []), 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);
814
+ const d = !u;
815
+ f(d), m.current?.setMuted(d);
816
+ }, [u]), T = A((d) => {
817
+ f(d), m.current?.setMuted(d);
798
818
  }, []), R = A(() => {
799
819
  n([]);
800
820
  }, []);
801
821
  return I(() => () => {
802
- b.current?.stop();
822
+ m.current?.stop();
803
823
  }, []), I(() => {
804
- r.autoStart && e === "idle" && u();
805
- }, [r.autoStart, e, u]), {
824
+ r.autoStart && e === "idle" && g();
825
+ }, [r.autoStart, e, g]), {
806
826
  status: e,
807
827
  transcripts: o,
808
828
  isUserSpeaking: s,
809
- isAgentSpeaking: g,
810
- isMuted: p,
829
+ isAgentSpeaking: y,
830
+ isMuted: u,
811
831
  errorMessage: a,
812
- start: u,
832
+ start: g,
813
833
  stop: w,
814
834
  toggleMute: C,
815
835
  setMuted: T,
816
836
  clearTranscripts: R,
817
- voiceAgent: b.current
837
+ voiceAgent: m.current
818
838
  };
819
839
  }
820
840
  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({
841
+ const [e, t] = k("idle"), [o, n] = k([]), [s, c] = k(!1), [y, h] = k(null), u = E(null), f = E(!1), a = A(() => (u.current || (u.current = new X({
822
842
  ...r,
823
843
  onTyping: c
824
- })), p.current), [r]), h = A(async () => {
844
+ })), u.current), [r]), p = A(async () => {
825
845
  if (!f.current) {
826
- t("loading"), y(null);
846
+ t("loading"), h(null);
827
847
  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");
848
+ const g = await a().initialize();
849
+ n(g), t("ready"), f.current = !0;
850
+ } catch (b) {
851
+ console.error("[useTextChat] Initialization error:", b), t("error"), h(b instanceof Error ? b.message : "Failed to initialize chat");
832
852
  }
833
853
  }
834
- }, [a]), b = A(async (x) => {
835
- if (x.trim()) {
836
- y(null);
854
+ }, [a]), m = A(async (b) => {
855
+ if (b.trim()) {
856
+ h(null);
837
857
  try {
838
- const u = a(), w = {
858
+ const g = a(), w = {
839
859
  role: "user",
840
- content: x.trim(),
860
+ content: b.trim(),
841
861
  created: (/* @__PURE__ */ new Date()).toISOString()
842
862
  };
843
- n((T) => [...T, w]), await u.sendMessage(x);
844
- const C = u.getHistory();
863
+ n((T) => [...T, w]), await g.sendMessage(b);
864
+ const C = g.getHistory();
845
865
  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");
866
+ } catch (g) {
867
+ console.error("[useTextChat] Send message error:", g), h(g instanceof Error ? g.message : "Failed to send message");
848
868
  }
849
869
  }
850
870
  }, [a, e]), v = A(() => {
851
- p.current?.clearHistory(), n([]), f.current = !1, t("idle");
871
+ u.current?.clearHistory(), n([]), f.current = !1, t("idle");
852
872
  }, []);
853
873
  return I(() => {
854
- r.autoInit && !f.current && r.contextId && h();
855
- }, [r.autoInit, r.contextId, h]), I(() => () => {
856
- p.current = null;
874
+ r.autoInit && !f.current && r.contextId && p();
875
+ }, [r.autoInit, r.contextId, p]), I(() => () => {
876
+ u.current = null;
857
877
  }, []), {
858
878
  status: e,
859
879
  messages: o,
860
880
  isLoading: s,
861
- errorMessage: g,
862
- initialize: h,
863
- sendMessage: b,
881
+ errorMessage: y,
882
+ initialize: p,
883
+ sendMessage: m,
864
884
  clearHistory: v,
865
- textChat: p.current
885
+ textChat: u.current
866
886
  };
867
887
  }
868
- const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
888
+ const P = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
869
889
  "svg",
870
890
  {
871
891
  xmlns: "http://www.w3.org/2000/svg",
@@ -884,7 +904,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
884
904
  /* @__PURE__ */ i("line", { x1: "12", x2: "12", y1: "19", y2: "22" })
885
905
  ]
886
906
  }
887
- ), be = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
907
+ ), be = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
888
908
  "svg",
889
909
  {
890
910
  xmlns: "http://www.w3.org/2000/svg",
@@ -921,7 +941,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
921
941
  className: t,
922
942
  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
943
  }
924
- ), ee = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
944
+ ), ee = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
925
945
  "svg",
926
946
  {
927
947
  xmlns: "http://www.w3.org/2000/svg",
@@ -954,7 +974,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
954
974
  className: t,
955
975
  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
976
  }
957
- ), te = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
977
+ ), te = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
958
978
  "svg",
959
979
  {
960
980
  xmlns: "http://www.w3.org/2000/svg",
@@ -972,7 +992,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
972
992
  /* @__PURE__ */ i("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
973
993
  ]
974
994
  }
975
- ), re = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
995
+ ), re = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
976
996
  "svg",
977
997
  {
978
998
  xmlns: "http://www.w3.org/2000/svg",
@@ -990,7 +1010,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
990
1010
  /* @__PURE__ */ i("circle", { cx: "12", cy: "7", r: "4" })
991
1011
  ]
992
1012
  }
993
- ), ie = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
1013
+ ), ie = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
994
1014
  "svg",
995
1015
  {
996
1016
  xmlns: "http://www.w3.org/2000/svg",
@@ -1027,7 +1047,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
1027
1047
  className: t,
1028
1048
  children: /* @__PURE__ */ i("polyline", { points: "22 12 18 12 15 21 9 3 6 12 2 12" })
1029
1049
  }
1030
- ), ne = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
1050
+ ), ne = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
1031
1051
  "svg",
1032
1052
  {
1033
1053
  xmlns: "http://www.w3.org/2000/svg",
@@ -1046,7 +1066,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
1046
1066
  /* @__PURE__ */ i("line", { x1: "16", x2: "22", y1: "9", y2: "15" })
1047
1067
  ]
1048
1068
  }
1049
- ), se = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
1069
+ ), se = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
1050
1070
  "svg",
1051
1071
  {
1052
1072
  xmlns: "http://www.w3.org/2000/svg",
@@ -1064,7 +1084,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
1064
1084
  /* @__PURE__ */ i("line", { x1: "6", x2: "18", y1: "6", y2: "18" })
1065
1085
  ]
1066
1086
  }
1067
- ), ae = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ d(
1087
+ ), ae = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__PURE__ */ l(
1068
1088
  "svg",
1069
1089
  {
1070
1090
  xmlns: "http://www.w3.org/2000/svg",
@@ -1100,7 +1120,7 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
1100
1120
  style: { animation: "spin 1s linear infinite" },
1101
1121
  children: /* @__PURE__ */ i("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
1102
1122
  }
1103
- ), de = {
1123
+ ), le = {
1104
1124
  light: {
1105
1125
  // Primary colors (purple/magenta)
1106
1126
  primary: "#c026d3",
@@ -1160,8 +1180,8 @@ const j = ({ size: r = 24, color: e = "currentColor", className: t }) => /* @__P
1160
1180
  textMuted: "#9ca3af"
1161
1181
  }
1162
1182
  };
1163
- function $(r) {
1164
- const e = de[r];
1183
+ function D(r) {
1184
+ const e = le[r];
1165
1185
  return `
1166
1186
  --glyde-primary: ${e.primary};
1167
1187
  --glyde-primary-hover: ${e.primaryHover};
@@ -1244,7 +1264,7 @@ const V = `
1244
1264
  .glyde-slide-up {
1245
1265
  animation: glyde-slide-up 0.3s ease-out;
1246
1266
  }
1247
- `, m = {
1267
+ `, x = {
1248
1268
  // Floating widget button
1249
1269
  floatingButton: {
1250
1270
  position: "fixed",
@@ -1438,7 +1458,7 @@ const V = `
1438
1458
  color: "var(--glyde-primary)"
1439
1459
  }
1440
1460
  };
1441
- function le(r, e = 20) {
1461
+ function de(r, e = 20) {
1442
1462
  return {
1443
1463
  "bottom-right": {
1444
1464
  button: { bottom: e, right: e },
@@ -1458,14 +1478,14 @@ function le(r, e = 20) {
1458
1478
  }
1459
1479
  }[r];
1460
1480
  }
1461
- function N(r = "light") {
1481
+ function j(r = "light") {
1462
1482
  const e = "glyde-widget-styles";
1463
1483
  if (document.getElementById(e))
1464
1484
  return;
1465
1485
  const t = document.createElement("style");
1466
1486
  t.id = e, t.textContent = `
1467
1487
  :root {
1468
- ${$(r)}
1488
+ ${D(r)}
1469
1489
  }
1470
1490
 
1471
1491
  ${V}
@@ -1475,13 +1495,13 @@ function ke(r) {
1475
1495
  const t = document.getElementById("glyde-widget-styles");
1476
1496
  t ? t.textContent = `
1477
1497
  :root {
1478
- ${$(r)}
1498
+ ${D(r)}
1479
1499
  }
1480
1500
 
1481
1501
  ${V}
1482
- ` : N(r);
1502
+ ` : j(r);
1483
1503
  }
1484
- const F = ({
1504
+ const H = ({
1485
1505
  contextId: r,
1486
1506
  publishableKey: e,
1487
1507
  apiKey: t,
@@ -1489,17 +1509,17 @@ const F = ({
1489
1509
  unityApiUrl: n = "https://api.glydeunity.com",
1490
1510
  contextType: s = "screening",
1491
1511
  height: c = "600px",
1492
- onTranscript: g,
1493
- onCallEnd: y,
1494
- onError: p
1512
+ onTranscript: y,
1513
+ onCallEnd: h,
1514
+ onError: u
1495
1515
  }) => {
1496
1516
  const f = E(null), {
1497
1517
  status: a,
1498
- transcripts: h,
1499
- isUserSpeaking: b,
1518
+ transcripts: p,
1519
+ isUserSpeaking: m,
1500
1520
  isAgentSpeaking: v,
1501
- isMuted: x,
1502
- errorMessage: u,
1521
+ isMuted: b,
1522
+ errorMessage: g,
1503
1523
  start: w,
1504
1524
  stop: C,
1505
1525
  toggleMute: T,
@@ -1514,15 +1534,15 @@ const F = ({
1514
1534
  });
1515
1535
  I(() => {
1516
1536
  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);
1537
+ }, [p]), I(() => {
1538
+ if (y && p.length > 0) {
1539
+ const S = p[p.length - 1];
1540
+ y(S.content, S.role);
1521
1541
  }
1522
- }, [h, g]), I(() => {
1523
- a === "error" && u && p && p(new Error(u));
1524
- }, [a, u, p]);
1525
- const l = () => {
1542
+ }, [p, y]), I(() => {
1543
+ a === "error" && g && u && u(new Error(g));
1544
+ }, [a, g, u]);
1545
+ const d = () => {
1526
1546
  switch (s) {
1527
1547
  case "screening":
1528
1548
  return "Screening Interview";
@@ -1537,10 +1557,10 @@ const F = ({
1537
1557
  }
1538
1558
  }, B = async () => {
1539
1559
  R(), await w();
1540
- }, L = () => {
1541
- C(), y?.();
1560
+ }, W = () => {
1561
+ C(), h?.();
1542
1562
  };
1543
- return /* @__PURE__ */ d("div", { style: {
1563
+ return /* @__PURE__ */ l("div", { style: {
1544
1564
  background: "var(--glyde-background, white)",
1545
1565
  borderRadius: "12px",
1546
1566
  boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
@@ -1549,20 +1569,20 @@ const F = ({
1549
1569
  flexDirection: "column",
1550
1570
  overflow: "hidden"
1551
1571
  }, children: [
1552
- /* @__PURE__ */ d("div", { style: {
1572
+ /* @__PURE__ */ l("div", { style: {
1553
1573
  padding: "16px 20px",
1554
1574
  borderBottom: "1px solid var(--glyde-border, #e5e7eb)",
1555
1575
  display: "flex",
1556
1576
  justifyContent: "space-between",
1557
1577
  alignItems: "center"
1558
1578
  }, 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() }),
1579
+ /* @__PURE__ */ l("div", { children: [
1580
+ /* @__PURE__ */ i("h2", { style: { margin: 0, fontSize: "1.1rem", fontWeight: 600, color: "var(--glyde-text, #1f2937)" }, children: d() }),
1561
1581
  /* @__PURE__ */ i("small", { style: { color: "var(--glyde-text-secondary, #6b7280)", fontSize: "0.8rem" }, children: o ? "JWT Auth" : e ? "Publishable Key" : "API Key" })
1562
1582
  ] }),
1563
- a === "active" && /* @__PURE__ */ d("div", { style: {
1564
- ...m.statusBadge,
1565
- ...m.statusBadgeLive
1583
+ a === "active" && /* @__PURE__ */ l("div", { style: {
1584
+ ...x.statusBadge,
1585
+ ...x.statusBadgeLive
1566
1586
  }, children: [
1567
1587
  /* @__PURE__ */ i(oe, { size: 14 }),
1568
1588
  " Live"
@@ -1570,7 +1590,7 @@ const F = ({
1570
1590
  ] }),
1571
1591
  /* @__PURE__ */ i("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: a === "idle" || a === "error" ? (
1572
1592
  /* Idle State */
1573
- /* @__PURE__ */ d("div", { style: {
1593
+ /* @__PURE__ */ l("div", { style: {
1574
1594
  flex: 1,
1575
1595
  display: "flex",
1576
1596
  flexDirection: "column",
@@ -1587,10 +1607,10 @@ const F = ({
1587
1607
  alignItems: "center",
1588
1608
  justifyContent: "center",
1589
1609
  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: [
1610
+ }, children: /* @__PURE__ */ i(P, { size: 48, color: "var(--glyde-primary, #c026d3)" }) }),
1611
+ /* @__PURE__ */ l("h3", { style: { marginBottom: "8px", color: "var(--glyde-text, #1f2937)" }, children: [
1592
1612
  "Ready for ",
1593
- l(),
1613
+ d(),
1594
1614
  "?"
1595
1615
  ] }),
1596
1616
  /* @__PURE__ */ i("p", { style: {
@@ -1599,12 +1619,12 @@ const F = ({
1599
1619
  textAlign: "center",
1600
1620
  maxWidth: "280px"
1601
1621
  }, 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(
1622
+ /* @__PURE__ */ l(
1603
1623
  "button",
1604
1624
  {
1605
1625
  onClick: B,
1606
1626
  style: {
1607
- ...m.primaryButton,
1627
+ ...x.primaryButton,
1608
1628
  padding: "14px 36px",
1609
1629
  borderRadius: "30px",
1610
1630
  boxShadow: "0 4px 12px rgba(192, 38, 211, 0.3)"
@@ -1615,58 +1635,58 @@ const F = ({
1615
1635
  ]
1616
1636
  }
1617
1637
  ),
1618
- u && /* @__PURE__ */ i("p", { style: { color: "var(--glyde-error, #ef4444)", marginTop: "16px", fontSize: "0.9rem" }, children: u })
1638
+ g && /* @__PURE__ */ i("p", { style: { color: "var(--glyde-error, #ef4444)", marginTop: "16px", fontSize: "0.9rem" }, children: g })
1619
1639
  ] })
1620
1640
  ) : (
1621
1641
  /* Active/Connecting State */
1622
- /* @__PURE__ */ d(K, { children: [
1623
- /* @__PURE__ */ d("div", { style: {
1642
+ /* @__PURE__ */ l(K, { children: [
1643
+ /* @__PURE__ */ l("div", { style: {
1624
1644
  flex: 1,
1625
1645
  overflowY: "auto",
1626
1646
  padding: "16px",
1627
1647
  background: "var(--glyde-surface, #f9fafb)"
1628
1648
  }, children: [
1629
- a === "connecting" && /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "var(--glyde-text-secondary, #6b7280)", padding: "40px" }, children: [
1649
+ a === "connecting" && /* @__PURE__ */ l("div", { style: { textAlign: "center", color: "var(--glyde-text-secondary, #6b7280)", padding: "40px" }, children: [
1630
1650
  /* @__PURE__ */ i("div", { className: "glyde-spinner", style: { margin: "0 auto 12px" } }),
1631
1651
  "Connecting to AI Agent..."
1632
1652
  ] }),
1633
- h.length === 0 && a === "active" && /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "var(--glyde-text-muted, #9ca3af)", padding: "40px" }, children: [
1653
+ p.length === 0 && a === "active" && /* @__PURE__ */ l("div", { style: { textAlign: "center", color: "var(--glyde-text-muted, #9ca3af)", padding: "40px" }, children: [
1634
1654
  /* @__PURE__ */ i(O, { size: 32, color: "var(--glyde-text-muted, #9ca3af)" }),
1635
1655
  /* @__PURE__ */ i("p", { style: { marginTop: "8px" }, children: "Start speaking - the AI will respond" })
1636
1656
  ] }),
1637
- h.map((S, P) => /* @__PURE__ */ i(ce, { transcript: S, contextType: s }, P)),
1657
+ p.map((S, N) => /* @__PURE__ */ i(ce, { transcript: S, contextType: s }, N)),
1638
1658
  /* @__PURE__ */ i("div", { ref: f })
1639
1659
  ] }),
1640
- /* @__PURE__ */ d("div", { style: {
1660
+ /* @__PURE__ */ l("div", { style: {
1641
1661
  padding: "16px",
1642
1662
  borderTop: "1px solid var(--glyde-border, #e5e7eb)",
1643
1663
  background: "var(--glyde-background, white)"
1644
1664
  }, children: [
1645
1665
  /* @__PURE__ */ i(
1646
- pe,
1666
+ he,
1647
1667
  {
1648
- isUserSpeaking: b,
1668
+ isUserSpeaking: m,
1649
1669
  isAgentSpeaking: v
1650
1670
  }
1651
1671
  ),
1652
- /* @__PURE__ */ d("div", { style: { display: "flex", justifyContent: "center", gap: "12px", marginTop: "16px" }, children: [
1672
+ /* @__PURE__ */ l("div", { style: { display: "flex", justifyContent: "center", gap: "12px", marginTop: "16px" }, children: [
1653
1673
  /* @__PURE__ */ i(
1654
1674
  "button",
1655
1675
  {
1656
1676
  onClick: T,
1657
1677
  style: {
1658
- ...m.iconButton,
1659
- background: x ? "var(--glyde-error-light, #fecaca)" : "var(--glyde-secondary-light, #e0f2fe)"
1678
+ ...x.iconButton,
1679
+ background: b ? "var(--glyde-error-light, #fecaca)" : "var(--glyde-secondary-light, #e0f2fe)"
1660
1680
  },
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)" })
1681
+ title: b ? "Unmute" : "Mute",
1682
+ children: b ? /* @__PURE__ */ i(ne, { size: 20, color: "var(--glyde-error, #dc2626)" }) : /* @__PURE__ */ i(P, { size: 20, color: "var(--glyde-secondary, #0ea5e9)" })
1663
1683
  }
1664
1684
  ),
1665
- /* @__PURE__ */ d(
1685
+ /* @__PURE__ */ l(
1666
1686
  "button",
1667
1687
  {
1668
- onClick: L,
1669
- style: m.dangerButton,
1688
+ onClick: W,
1689
+ style: x.dangerButton,
1670
1690
  children: [
1671
1691
  /* @__PURE__ */ i(ee, { size: 18, color: "white" }),
1672
1692
  " End Call"
@@ -1704,44 +1724,44 @@ const F = ({
1704
1724
  marginBottom: "12px",
1705
1725
  display: "flex",
1706
1726
  justifyContent: t ? "flex-end" : "flex-start"
1707
- }, children: /* @__PURE__ */ d("div", { style: {
1708
- ...m.messageBubble,
1709
- ...t ? m.messageBubbleUser : m.messageBubbleAgent
1727
+ }, children: /* @__PURE__ */ l("div", { style: {
1728
+ ...x.messageBubble,
1729
+ ...t ? x.messageBubbleUser : x.messageBubbleAgent
1710
1730
  }, children: [
1711
1731
  /* @__PURE__ */ i("div", { style: { fontSize: "0.75rem", opacity: 0.7, marginBottom: "4px" }, children: t ? "You" : e === "recruiter" ? "AI Copilot" : "AI Recruiter" }),
1712
1732
  r.content
1713
1733
  ] }) });
1714
- }, pe = ({
1734
+ }, he = ({
1715
1735
  isUserSpeaking: r,
1716
1736
  isAgentSpeaking: e
1717
- }) => /* @__PURE__ */ d("div", { style: {
1737
+ }) => /* @__PURE__ */ l("div", { style: {
1718
1738
  display: "flex",
1719
1739
  justifyContent: "center",
1720
1740
  gap: "20px"
1721
1741
  }, children: [
1722
- /* @__PURE__ */ d("div", { style: {
1723
- ...m.speakingIndicator,
1742
+ /* @__PURE__ */ l("div", { style: {
1743
+ ...x.speakingIndicator,
1724
1744
  color: r ? "var(--glyde-primary, #c026d3)" : "var(--glyde-text-muted, #9ca3af)"
1725
1745
  }, children: [
1726
1746
  /* @__PURE__ */ i("div", { style: {
1727
- ...m.speakingDot,
1747
+ ...x.speakingDot,
1728
1748
  background: r ? "var(--glyde-primary, #c026d3)" : "var(--glyde-border, #d1d5db)",
1729
1749
  animation: r ? "glyde-pulse 1s infinite" : "none"
1730
1750
  } }),
1731
1751
  "You"
1732
1752
  ] }),
1733
- /* @__PURE__ */ d("div", { style: {
1734
- ...m.speakingIndicator,
1753
+ /* @__PURE__ */ l("div", { style: {
1754
+ ...x.speakingIndicator,
1735
1755
  color: e ? "var(--glyde-success, #059669)" : "var(--glyde-text-muted, #9ca3af)"
1736
1756
  }, children: [
1737
1757
  /* @__PURE__ */ i("div", { style: {
1738
- ...m.speakingDot,
1758
+ ...x.speakingDot,
1739
1759
  background: e ? "var(--glyde-success, #059669)" : "var(--glyde-border, #d1d5db)",
1740
1760
  animation: e ? "glyde-pulse 1s infinite" : "none"
1741
1761
  } }),
1742
1762
  "AI Agent"
1743
1763
  ] })
1744
- ] }), G = ({
1764
+ ] }), F = ({
1745
1765
  contextId: r,
1746
1766
  publishableKey: e,
1747
1767
  apiKey: t,
@@ -1749,15 +1769,15 @@ const F = ({
1749
1769
  unityApiUrl: n = "https://api.glydeunity.com",
1750
1770
  height: s = "600px",
1751
1771
  title: c = "AI Chat",
1752
- placeholder: g = "Type your message...",
1753
- autoInit: y = !0,
1754
- onMessage: p,
1772
+ placeholder: y = "Type your message...",
1773
+ autoInit: h = !0,
1774
+ onMessage: u,
1755
1775
  onError: f
1756
1776
  }) => {
1757
- const [a, h] = k(""), b = E(null), {
1777
+ const [a, p] = k(""), m = E(null), {
1758
1778
  status: v,
1759
- messages: x,
1760
- isLoading: u,
1779
+ messages: b,
1780
+ isLoading: g,
1761
1781
  errorMessage: w,
1762
1782
  sendMessage: C
1763
1783
  } = Q({
@@ -1766,21 +1786,21 @@ const F = ({
1766
1786
  authToken: o,
1767
1787
  contextId: r,
1768
1788
  unityBaseUrl: n,
1769
- autoInit: y
1789
+ autoInit: h
1770
1790
  });
1771
1791
  I(() => {
1772
- b.current?.scrollIntoView({ behavior: "smooth" });
1773
- }, [x]), I(() => {
1792
+ m.current?.scrollIntoView({ behavior: "smooth" });
1793
+ }, [b]), I(() => {
1774
1794
  v === "error" && w && f && f(new Error(w));
1775
1795
  }, [v, w, f]);
1776
1796
  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());
1797
+ if (!a.trim() || g) return;
1798
+ const d = a.trim();
1799
+ p(""), await C(d), u && u({ role: "user", content: d });
1800
+ }, R = (d) => {
1801
+ d.key === "Enter" && !d.shiftKey && (d.preventDefault(), T());
1782
1802
  };
1783
- return /* @__PURE__ */ d("div", { style: {
1803
+ return /* @__PURE__ */ l("div", { style: {
1784
1804
  background: "var(--glyde-background, white)",
1785
1805
  borderRadius: "12px",
1786
1806
  boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
@@ -1797,7 +1817,7 @@ const F = ({
1797
1817
  borderTopLeftRadius: "12px",
1798
1818
  borderTopRightRadius: "12px"
1799
1819
  }, children: /* @__PURE__ */ i("h2", { style: { margin: 0, fontSize: "1.1rem", fontWeight: 600 }, children: c }) }),
1800
- /* @__PURE__ */ d("div", { style: {
1820
+ /* @__PURE__ */ l("div", { style: {
1801
1821
  flex: 1,
1802
1822
  overflowY: "auto",
1803
1823
  padding: "20px",
@@ -1806,48 +1826,48 @@ const F = ({
1806
1826
  gap: "15px",
1807
1827
  background: "var(--glyde-background, white)"
1808
1828
  }, children: [
1809
- v === "loading" && x.length === 0 && /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "var(--glyde-text-muted, #94a3b8)", padding: "20px" }, children: [
1829
+ v === "loading" && b.length === 0 && /* @__PURE__ */ l("div", { style: { textAlign: "center", color: "var(--glyde-text-muted, #94a3b8)", padding: "20px" }, children: [
1810
1830
  /* @__PURE__ */ i("div", { className: "glyde-spinner", style: { margin: "0 auto 12px" } }),
1811
1831
  "Loading conversation..."
1812
1832
  ] }),
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 })
1833
+ b.map((d, B) => /* @__PURE__ */ i(pe, { message: d }, B)),
1834
+ g && /* @__PURE__ */ i("div", { style: { color: "var(--glyde-text-muted, #94a3b8)", fontSize: "0.9rem", marginLeft: "42px" }, children: /* @__PURE__ */ i(ue, {}) }),
1835
+ /* @__PURE__ */ i("div", { ref: m })
1816
1836
  ] }),
1817
- /* @__PURE__ */ d("div", { style: { padding: "16px 20px", borderTop: "1px solid var(--glyde-border, #eee)" }, children: [
1837
+ /* @__PURE__ */ l("div", { style: { padding: "16px 20px", borderTop: "1px solid var(--glyde-border, #eee)" }, children: [
1818
1838
  w && /* @__PURE__ */ i("p", { style: {
1819
1839
  color: "var(--glyde-error, #ef4444)",
1820
1840
  fontSize: "0.85rem",
1821
1841
  marginBottom: "10px"
1822
1842
  }, children: w }),
1823
- /* @__PURE__ */ d("div", { style: { display: "flex", gap: "10px" }, children: [
1843
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: "10px" }, children: [
1824
1844
  /* @__PURE__ */ i(
1825
1845
  "input",
1826
1846
  {
1827
1847
  type: "text",
1828
1848
  value: a,
1829
- onChange: (l) => h(l.target.value),
1849
+ onChange: (d) => p(d.target.value),
1830
1850
  onKeyDown: R,
1831
- placeholder: g,
1851
+ placeholder: y,
1832
1852
  style: {
1833
- ...m.inputField,
1853
+ ...x.inputField,
1834
1854
  flex: 1
1835
1855
  },
1836
- disabled: u
1856
+ disabled: g
1837
1857
  }
1838
1858
  ),
1839
1859
  /* @__PURE__ */ i(
1840
1860
  "button",
1841
1861
  {
1842
1862
  onClick: T,
1843
- disabled: u || !a.trim(),
1863
+ disabled: g || !a.trim(),
1844
1864
  style: {
1845
- ...m.iconButton,
1865
+ ...x.iconButton,
1846
1866
  background: "var(--glyde-secondary, #0284c7)",
1847
1867
  width: "48px",
1848
1868
  height: "48px",
1849
- opacity: u || !a.trim() ? 0.5 : 1,
1850
- cursor: u || !a.trim() ? "not-allowed" : "pointer"
1869
+ opacity: g || !a.trim() ? 0.5 : 1,
1870
+ cursor: g || !a.trim() ? "not-allowed" : "pointer"
1851
1871
  },
1852
1872
  children: /* @__PURE__ */ i(te, { size: 20, color: "white" })
1853
1873
  }
@@ -1872,9 +1892,9 @@ const F = ({
1872
1892
  }
1873
1893
  ` })
1874
1894
  ] });
1875
- }, he = ({ message: r }) => {
1895
+ }, pe = ({ message: r }) => {
1876
1896
  const e = r.role === "user";
1877
- return /* @__PURE__ */ d("div", { style: {
1897
+ return /* @__PURE__ */ l("div", { style: {
1878
1898
  display: "flex",
1879
1899
  gap: "10px",
1880
1900
  flexDirection: e ? "row-reverse" : "row",
@@ -1901,7 +1921,7 @@ const F = ({
1901
1921
  lineHeight: 1.5
1902
1922
  }, children: r.content })
1903
1923
  ] });
1904
- }, ue = () => /* @__PURE__ */ d("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
1924
+ }, ue = () => /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
1905
1925
  /* @__PURE__ */ i("span", { children: "Typing" }),
1906
1926
  /* @__PURE__ */ i("span", { style: { display: "flex", gap: "2px" }, children: [0, 1, 2].map((r) => /* @__PURE__ */ i(
1907
1927
  "span",
@@ -1925,28 +1945,28 @@ const F = ({
1925
1945
  unityBaseUrl: n = "https://api.glydeunity.com",
1926
1946
  contextType: s = "screening",
1927
1947
  defaultMode: c = "voice",
1928
- position: g = "bottom-right",
1929
- theme: y = "light",
1930
- allowModeSwitch: p = !0,
1948
+ position: y = "bottom-right",
1949
+ theme: h = "light",
1950
+ allowModeSwitch: u = !0,
1931
1951
  container: f,
1932
1952
  onReady: a,
1933
- onModeChange: h,
1934
- onTranscript: b,
1953
+ onModeChange: p,
1954
+ onTranscript: m,
1935
1955
  onError: v,
1936
- initialExpanded: x = !1
1956
+ initialExpanded: b = !1
1937
1957
  }) => {
1938
- const [u, w] = k(x), [C, T] = k(c);
1958
+ const [g, w] = k(b), [C, T] = k(c);
1939
1959
  I(() => {
1940
- const S = y === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : y;
1941
- N(S);
1942
- }, [y]), I(() => {
1960
+ const S = h === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : h;
1961
+ j(S);
1962
+ }, [h]), I(() => {
1943
1963
  a?.();
1944
1964
  }, [a]);
1945
- const R = le(g), l = (S) => {
1946
- T(S), h?.(S);
1947
- }, B = (S, P) => {
1948
- b?.(S, P);
1949
- }, L = (S) => {
1965
+ const R = de(y), d = (S) => {
1966
+ T(S), p?.(S);
1967
+ }, B = (S, N) => {
1968
+ m?.(S, N);
1969
+ }, W = (S) => {
1950
1970
  v?.(S);
1951
1971
  };
1952
1972
  return f ? /* @__PURE__ */ i(
@@ -1959,53 +1979,53 @@ const F = ({
1959
1979
  unityBaseUrl: n,
1960
1980
  contextType: s,
1961
1981
  mode: C,
1962
- allowModeSwitch: p,
1963
- onModeChange: l,
1982
+ allowModeSwitch: u,
1983
+ onModeChange: d,
1964
1984
  onTranscript: B,
1965
- onError: L
1985
+ onError: W
1966
1986
  }
1967
- ) : /* @__PURE__ */ d("div", { className: "glyde-widget-root", children: [
1968
- !u && /* @__PURE__ */ i(
1987
+ ) : /* @__PURE__ */ l("div", { className: "glyde-widget-root", children: [
1988
+ !g && /* @__PURE__ */ i(
1969
1989
  "button",
1970
1990
  {
1971
1991
  onClick: () => w(!0),
1972
1992
  style: {
1973
- ...m.floatingButton,
1993
+ ...x.floatingButton,
1974
1994
  ...R.button,
1975
1995
  background: "linear-gradient(135deg, var(--glyde-primary, #c026d3) 0%, var(--glyde-secondary, #7c3aed) 100%)"
1976
1996
  },
1977
1997
  "aria-label": "Open chat",
1978
- children: /* @__PURE__ */ i(j, { size: 28, color: "white" })
1998
+ children: /* @__PURE__ */ i(P, { size: 28, color: "white" })
1979
1999
  }
1980
2000
  ),
1981
- u && /* @__PURE__ */ d(
2001
+ g && /* @__PURE__ */ l(
1982
2002
  "div",
1983
2003
  {
1984
2004
  style: {
1985
- ...m.widgetPanel,
2005
+ ...x.widgetPanel,
1986
2006
  ...R.panel,
1987
2007
  background: "var(--glyde-background, white)"
1988
2008
  },
1989
2009
  className: "glyde-slide-up",
1990
2010
  children: [
1991
- /* @__PURE__ */ d("div", { style: {
1992
- ...m.header,
2011
+ /* @__PURE__ */ l("div", { style: {
2012
+ ...x.header,
1993
2013
  background: "linear-gradient(135deg, var(--glyde-primary, #c026d3) 0%, var(--glyde-secondary, #7c3aed) 100%)",
1994
2014
  color: "white",
1995
2015
  borderTopLeftRadius: "16px",
1996
2016
  borderTopRightRadius: "16px"
1997
2017
  }, children: [
1998
- /* @__PURE__ */ d("div", { children: [
2018
+ /* @__PURE__ */ l("div", { children: [
1999
2019
  /* @__PURE__ */ i("h3", { style: { margin: 0, fontSize: "1rem", fontWeight: 600 }, children: "GLYDE Assistant" }),
2000
2020
  /* @__PURE__ */ i("small", { style: { opacity: 0.8, fontSize: "0.75rem" }, children: s === "screening" ? "Candidate Screening" : "AI Assistant" })
2001
2021
  ] }),
2002
- /* @__PURE__ */ d("div", { style: { display: "flex", gap: "8px" }, children: [
2022
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: "8px" }, children: [
2003
2023
  /* @__PURE__ */ i(
2004
2024
  "button",
2005
2025
  {
2006
2026
  onClick: () => w(!1),
2007
2027
  style: {
2008
- ...m.iconButton,
2028
+ ...x.iconButton,
2009
2029
  background: "rgba(255,255,255,0.2)",
2010
2030
  width: "32px",
2011
2031
  height: "32px"
@@ -2019,7 +2039,7 @@ const F = ({
2019
2039
  {
2020
2040
  onClick: () => w(!1),
2021
2041
  style: {
2022
- ...m.iconButton,
2042
+ ...x.iconButton,
2023
2043
  background: "rgba(255,255,255,0.2)",
2024
2044
  width: "32px",
2025
2045
  height: "32px"
@@ -2030,12 +2050,12 @@ const F = ({
2030
2050
  )
2031
2051
  ] })
2032
2052
  ] }),
2033
- p && /* @__PURE__ */ i("div", { style: {
2053
+ u && /* @__PURE__ */ i("div", { style: {
2034
2054
  padding: "12px 16px",
2035
2055
  borderBottom: "1px solid var(--glyde-border, #e5e7eb)"
2036
- }, children: /* @__PURE__ */ i(H, { mode: C, onModeChange: l }) }),
2056
+ }, children: /* @__PURE__ */ i(G, { mode: C, onModeChange: d }) }),
2037
2057
  /* @__PURE__ */ i("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: C === "voice" ? /* @__PURE__ */ i(
2038
- F,
2058
+ H,
2039
2059
  {
2040
2060
  publishableKey: r,
2041
2061
  apiKey: e,
@@ -2045,10 +2065,10 @@ const F = ({
2045
2065
  contextType: s,
2046
2066
  height: "100%",
2047
2067
  onTranscript: B,
2048
- onError: L
2068
+ onError: W
2049
2069
  }
2050
2070
  ) : /* @__PURE__ */ i(
2051
- G,
2071
+ F,
2052
2072
  {
2053
2073
  publishableKey: r,
2054
2074
  apiKey: e,
@@ -2057,35 +2077,35 @@ const F = ({
2057
2077
  unityApiUrl: n,
2058
2078
  height: "100%",
2059
2079
  title: "Text Chat",
2060
- onError: L
2080
+ onError: W
2061
2081
  }
2062
2082
  ) })
2063
2083
  ]
2064
2084
  }
2065
2085
  )
2066
2086
  ] });
2067
- }, H = ({ mode: r, onModeChange: e }) => /* @__PURE__ */ d("div", { style: m.modeSelector, children: [
2068
- /* @__PURE__ */ d(
2087
+ }, G = ({ mode: r, onModeChange: e }) => /* @__PURE__ */ l("div", { style: x.modeSelector, children: [
2088
+ /* @__PURE__ */ l(
2069
2089
  "button",
2070
2090
  {
2071
2091
  onClick: () => e("voice"),
2072
2092
  style: {
2073
- ...m.modeSelectorButton,
2093
+ ...x.modeSelectorButton,
2074
2094
  background: r === "voice" ? "var(--glyde-primary, #c026d3)" : "transparent",
2075
2095
  color: r === "voice" ? "white" : "var(--glyde-text, #1f2937)"
2076
2096
  },
2077
2097
  children: [
2078
- /* @__PURE__ */ i(j, { size: 16 }),
2098
+ /* @__PURE__ */ i(P, { size: 16 }),
2079
2099
  " Voice"
2080
2100
  ]
2081
2101
  }
2082
2102
  ),
2083
- /* @__PURE__ */ d(
2103
+ /* @__PURE__ */ l(
2084
2104
  "button",
2085
2105
  {
2086
2106
  onClick: () => e("text"),
2087
2107
  style: {
2088
- ...m.modeSelectorButton,
2108
+ ...x.modeSelectorButton,
2089
2109
  background: r === "text" ? "var(--glyde-secondary, #0284c7)" : "transparent",
2090
2110
  color: r === "text" ? "white" : "var(--glyde-text, #1f2937)"
2091
2111
  },
@@ -2103,22 +2123,22 @@ const F = ({
2103
2123
  unityBaseUrl: n,
2104
2124
  contextType: s,
2105
2125
  mode: c,
2106
- allowModeSwitch: g,
2107
- onModeChange: y,
2108
- onTranscript: p,
2126
+ allowModeSwitch: y,
2127
+ onModeChange: h,
2128
+ onTranscript: u,
2109
2129
  onError: f
2110
2130
  }) => {
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: {
2131
+ const [a, p] = k(c);
2132
+ return /* @__PURE__ */ l("div", { className: "glyde-widget-root", style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
2133
+ y && /* @__PURE__ */ i("div", { style: {
2114
2134
  padding: "12px 16px",
2115
2135
  borderBottom: "1px solid var(--glyde-border, #e5e7eb)",
2116
2136
  background: "var(--glyde-background, white)"
2117
- }, children: /* @__PURE__ */ i(H, { mode: a, onModeChange: (v) => {
2118
- h(v), y(v);
2137
+ }, children: /* @__PURE__ */ i(G, { mode: a, onModeChange: (v) => {
2138
+ p(v), h(v);
2119
2139
  } }) }),
2120
2140
  /* @__PURE__ */ i("div", { style: { flex: 1, overflow: "hidden" }, children: a === "voice" ? /* @__PURE__ */ i(
2121
- F,
2141
+ H,
2122
2142
  {
2123
2143
  publishableKey: r,
2124
2144
  apiKey: e,
@@ -2127,11 +2147,11 @@ const F = ({
2127
2147
  unityApiUrl: n,
2128
2148
  contextType: s,
2129
2149
  height: "100%",
2130
- onTranscript: p,
2150
+ onTranscript: u,
2131
2151
  onError: f
2132
2152
  }
2133
2153
  ) : /* @__PURE__ */ i(
2134
- G,
2154
+ F,
2135
2155
  {
2136
2156
  publishableKey: r,
2137
2157
  apiKey: e,
@@ -2145,7 +2165,7 @@ const F = ({
2145
2165
  ) })
2146
2166
  ] });
2147
2167
  };
2148
- let M = null, W = null;
2168
+ let M = null, L = null;
2149
2169
  const _ = {
2150
2170
  /**
2151
2171
  * Initialize the chat widget
@@ -2157,10 +2177,10 @@ const _ = {
2157
2177
  if (!r.publishableKey && !r.apiKey && !r.authToken)
2158
2178
  return console.error("[GlydeChat] Authentication required: provide publishableKey, apiKey, or authToken"), null;
2159
2179
  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);
2180
+ j(e), M && L && (M.unmount(), L.remove(), M = null, L = null);
2161
2181
  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);
2182
+ t.id = "glyde-chat-widget", t.className = "glyde-widget-root", document.body.appendChild(t), L = t;
2183
+ const o = $(t);
2164
2184
  return M = o, o.render(
2165
2185
  z.createElement(U, {
2166
2186
  ...r,
@@ -2171,7 +2191,7 @@ const _ = {
2171
2191
  * Destroy the widget
2172
2192
  */
2173
2193
  destroy() {
2174
- M && W && (M.unmount(), W.remove(), M = null, W = null, console.log("[GlydeChat] Widget destroyed"));
2194
+ M && L && (M.unmount(), L.remove(), M = null, L = null, console.log("[GlydeChat] Widget destroyed"));
2175
2195
  },
2176
2196
  /**
2177
2197
  * Update widget configuration
@@ -2197,8 +2217,8 @@ const _ = {
2197
2217
  if (!t)
2198
2218
  return console.error("[GlydeChat] Container not found:", r), null;
2199
2219
  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);
2220
+ j(o);
2221
+ const n = $(t);
2202
2222
  return n.render(
2203
2223
  z.createElement(U, {
2204
2224
  ...e,
@@ -2234,11 +2254,28 @@ const _ = {
2234
2254
  };
2235
2255
  function ye() {
2236
2256
  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,
2257
+ if (!e) {
2258
+ console.log("[GlydeChat] No script tag found for auto-init");
2259
+ return;
2260
+ }
2261
+ const t = e.getAttribute("data-auto-init");
2262
+ if (t === "false") {
2263
+ console.log('[GlydeChat] Auto-init disabled via data-auto-init="false"');
2264
+ return;
2265
+ }
2266
+ const o = e.getAttribute("data-publishable-key") || void 0, n = e.getAttribute("data-api-key") || void 0, s = e.getAttribute("data-auth-token") || void 0, c = o || n || s;
2267
+ if (!c && !(t === "true")) {
2268
+ console.log("[GlydeChat] Auto-init skipped: no authentication data attributes found. Call GlydeChat.init() manually.");
2269
+ return;
2270
+ }
2271
+ if (!c) {
2272
+ console.warn("[GlydeChat] Auto-init skipped: no authentication provided (publishableKey, apiKey, or authToken required)");
2273
+ return;
2274
+ }
2275
+ const h = {
2276
+ publishableKey: o,
2277
+ apiKey: n,
2278
+ authToken: s,
2242
2279
  contextId: e.getAttribute("data-context-id") || void 0,
2243
2280
  unityBaseUrl: e.getAttribute("data-unity-url") || "https://api.glydeunity.com",
2244
2281
  contextType: e.getAttribute("data-context-type") || "screening",
@@ -2247,11 +2284,15 @@ function ye() {
2247
2284
  theme: e.getAttribute("data-theme") || "light",
2248
2285
  allowModeSwitch: e.getAttribute("data-allow-mode-switch") !== "false"
2249
2286
  };
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);
2287
+ console.log("[GlydeChat] Auto-initializing with config:", {
2288
+ hasPublishableKey: !!h.publishableKey,
2289
+ hasApiKey: !!h.apiKey,
2290
+ hasAuthToken: !!h.authToken,
2291
+ contextId: h.contextId,
2292
+ defaultMode: h.defaultMode,
2293
+ position: h.position,
2294
+ theme: h.theme
2295
+ }), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => _.init(h)) : _.init(h);
2255
2296
  }
2256
2297
  typeof window < "u" && (window.GlydeChat = _, ye());
2257
2298
  export {
@@ -2263,23 +2304,23 @@ export {
2263
2304
  Y as GlydeVoice,
2264
2305
  we as LoaderIcon,
2265
2306
  O as MessageIcon,
2266
- j as MicIcon,
2307
+ P as MicIcon,
2267
2308
  be as MicOffIcon,
2268
2309
  ae as MinimizeIcon,
2269
2310
  ve as PhoneIcon,
2270
2311
  ee as PhoneOffIcon,
2271
2312
  te as SendIcon,
2272
- G as TextChat,
2313
+ F as TextChat,
2273
2314
  re as UserIcon,
2274
- F as VoiceChat,
2315
+ H as VoiceChat,
2275
2316
  ne as VolumeXIcon,
2276
2317
  se as XIcon,
2277
- m as componentStyles,
2278
- le as getPositionStyles,
2279
- $ as getThemeCSSVariables,
2318
+ x as componentStyles,
2319
+ de as getPositionStyles,
2320
+ D as getThemeCSSVariables,
2280
2321
  V as globalStyles,
2281
- N as injectGlobalStyles,
2282
- de as themeColors,
2322
+ j as injectGlobalStyles,
2323
+ le as themeColors,
2283
2324
  ke as updateTheme,
2284
2325
  Q as useTextChat,
2285
2326
  Z as useVoiceAgent