@d-id/client-sdk 1.2.7-staging.362 → 1.2.7

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.
@@ -14,7 +14,7 @@ class G extends Error {
14
14
  };
15
15
  }
16
16
  }
17
- function _n(e) {
17
+ function bn(e) {
18
18
  return e instanceof Error && typeof e.kind == "string";
19
19
  }
20
20
  class ot extends G {
@@ -79,7 +79,7 @@ class We extends G {
79
79
  super(t, "StreamError", n);
80
80
  }
81
81
  }
82
- class $ extends G {
82
+ class B extends G {
83
83
  constructor(t, n) {
84
84
  super(t, "ValidationError"), this.key = n;
85
85
  }
@@ -89,7 +89,7 @@ class ut extends G {
89
89
  super(t, "WSError");
90
90
  }
91
91
  }
92
- var ft = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ft || {}), mt = /* @__PURE__ */ ((e) => (e.TRIAL = "deid-trial", e.PRO = "deid-pro", e.ENTERPRISE = "deid-enterprise", e.LITE = "deid-lite", e.ADVANCED = "deid-advanced", e.BUILD = "deid-api-build", e.LAUNCH = "deid-api-launch", e.SCALE = "deid-api-scale", e))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ht || {}), gt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(gt || {}), _ = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(_ || {}), F = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(F || {}), pt = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(pt || {}), wt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(wt || {}), yt = /* @__PURE__ */ ((e) => (e.Pdf = "pdf", e.Text = "text", e.Html = "html", e.Word = "word", e.Json = "json", e.Markdown = "markdown", e.Csv = "csv", e.Excel = "excel", e.Powerpoint = "powerpoint", e.Archive = "archive", e.Image = "image", e.Audio = "audio", e.Video = "video", e))(yt || {}), He = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(He || {});
92
+ var ft = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ft || {}), mt = /* @__PURE__ */ ((e) => (e.TRIAL = "deid-trial", e.PRO = "deid-pro", e.ENTERPRISE = "deid-enterprise", e.LITE = "deid-lite", e.ADVANCED = "deid-advanced", e.BUILD = "deid-api-build", e.LAUNCH = "deid-api-launch", e.SCALE = "deid-api-scale", e))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ht || {}), gt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(gt || {}), b = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(b || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), pt = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(pt || {}), wt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(wt || {}), yt = /* @__PURE__ */ ((e) => (e.Pdf = "pdf", e.Text = "text", e.Html = "html", e.Word = "word", e.Json = "json", e.Markdown = "markdown", e.Csv = "csv", e.Excel = "excel", e.Powerpoint = "powerpoint", e.Archive = "archive", e.Image = "image", e.Audio = "audio", e.Video = "video", e))(yt || {}), He = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(He || {});
93
93
  const An = (e) => {
94
94
  switch (e) {
95
95
  case "clip":
@@ -102,7 +102,7 @@ const An = (e) => {
102
102
  throw new Error(`Unknown video type: ${e}`);
103
103
  }
104
104
  };
105
- var k = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(k || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}), ie = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ie || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), A = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(A || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), Se = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(Se || {}), vt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(vt || {}), Ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(Ct || {});
105
+ var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}), ie = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ie || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), A = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(A || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), ke = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ke || {}), vt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(vt || {}), Ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(Ct || {});
106
106
  const xn = (...e) => {
107
107
  }, qe = (e) => new Promise((t) => setTimeout(t, e)), ee = (e = 16) => {
108
108
  const t = new Uint8Array(e);
@@ -119,7 +119,7 @@ function we(e) {
119
119
  return t;
120
120
  }
121
121
  let ue = ee();
122
- function kt() {
122
+ function St() {
123
123
  ue = ee();
124
124
  }
125
125
  function Xe(e, t) {
@@ -131,7 +131,7 @@ function Xe(e, t) {
131
131
  return `Client-Key ${e.clientKey}.${we(t)}_${ue}`;
132
132
  throw new Error(`Unknown auth type: ${e}`);
133
133
  }
134
- const St = 45 * 1e3, Mt = "X-Playground-Chat", be = 2e3, me = "https://api.d-id.com", Rt = "wss://notifications.d-id.com", Dt = "79f81a83a67430be2bc0fd61042b8faa", Ge = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, It = (e) => {
134
+ const kt = 45 * 1e3, Mt = "X-Playground-Chat", Te = 2e3, me = "https://api.d-id.com", Rt = "wss://notifications.d-id.com", Dt = "79f81a83a67430be2bc0fd61042b8faa", Ge = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, It = (e) => {
135
135
  switch (e.type) {
136
136
  case "expressive":
137
137
  return "v4";
@@ -140,10 +140,10 @@ const St = 45 * 1e3, Mt = "X-Playground-Chat", be = 2e3, me = "https://api.d-id.
140
140
  case "talk":
141
141
  return "v2";
142
142
  }
143
- }, Et = (e) => e.type === "talk" ? e.source_url : e.presenter_id, Me = (e) => e === He.Expressive, bt = (e) => [_.TextOnly, _.Playground, _.Maintenance].includes(e), Qe = (e) => e && [_.DirectPlayback, _.Off].includes(e), Te = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, _e = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, Tt = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
144
- function _t(e) {
143
+ }, Et = (e) => e.type === "talk" ? e.source_url : e.presenter_id, Me = (e) => e === He.Expressive, Tt = (e) => [b.TextOnly, b.Playground, b.Maintenance].includes(e), Qe = (e) => e && [b.DirectPlayback, b.Off].includes(e), _e = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, be = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, _t = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
144
+ function bt(e) {
145
145
  const t = e.split("?")[0].split("#")[0].toLowerCase();
146
- return Tt.some((n) => t.endsWith(n));
146
+ return _t.some((n) => t.endsWith(n));
147
147
  }
148
148
  const Ae = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), xe = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
149
149
  function At(e) {
@@ -151,17 +151,17 @@ function At(e) {
151
151
  return [];
152
152
  const t = [];
153
153
  let n;
154
- for (Te.lastIndex = 0; (n = Te.exec(e)) !== null; )
154
+ for (_e.lastIndex = 0; (n = _e.exec(e)) !== null; )
155
155
  t.push({
156
156
  index: n.index,
157
157
  length: n[0].length,
158
158
  part: { type: "video", src: n[3], alt: n[1], thumbnail: n[2] }
159
159
  });
160
- for (_e.lastIndex = 0; (n = _e.exec(e)) !== null; )
160
+ for (be.lastIndex = 0; (n = be.exec(e)) !== null; )
161
161
  if (!t.some((s) => n.index >= s.index && n.index < s.index + s.length)) {
162
162
  const s = n[2], r = n[1];
163
163
  let a;
164
- _t(s) ? a = { type: "video", src: s, alt: r } : (a = { type: "image", src: s, alt: r }, s.toLowerCase().endsWith(".gif") && (a.mimeType = "image/gif")), t.push({ index: n.index, length: n[0].length, part: a });
164
+ bt(s) ? a = { type: "video", src: s, alt: r } : (a = { type: "image", src: s, alt: r }, s.toLowerCase().endsWith(".gif") && (a.mimeType = "image/gif")), t.push({ index: n.index, length: n[0].length, part: a });
165
165
  }
166
166
  for (Ae.lastIndex = 0; (n = Ae.exec(e)) !== null; )
167
167
  t.some((s) => n.index >= s.index && n.index < s.index + s.length) || t.push({
@@ -308,9 +308,6 @@ function Lt(e, t = me, n, i) {
308
308
  deleteRating(o, s, r, a) {
309
309
  return c.delete(`/${o}/chat/${s}/ratings/${r}`, a);
310
310
  },
311
- submitFeedback(o, s, r, a) {
312
- return c.post(`/${o}/chat/${s}/feedback`, r, a);
313
- },
314
311
  getSTTToken(o, s) {
315
312
  return c.get(`/${o}/stt-token`, s);
316
313
  }
@@ -365,13 +362,13 @@ const Bt = (e) => {
365
362
  } catch {
366
363
  return "Unknown error";
367
364
  }
368
- }, Ft = (e) => e.reduce((t, n) => t + n, 0), Le = (e) => Ft(e) / e.length, je = (e) => Math.min(...e), $e = (e) => Math.max(...e), le = (e, t = 0) => {
365
+ }, zt = (e) => e.reduce((t, n) => t + n, 0), Le = (e) => zt(e) / e.length, je = (e) => Math.min(...e), $e = (e) => Math.max(...e), le = (e, t = 0) => {
369
366
  const n = 10 ** t;
370
367
  return Math.round(e * n) / n;
371
- }, zt = (e, t) => {
368
+ }, Nt = (e, t) => {
372
369
  const n = [...e].sort((i, c) => i - c);
373
370
  return n[Math.min(n.length - 1, Math.floor(t * (n.length - 1)))];
374
- }, Nt = (e) => zt(e, 0.5), Vt = (e, t) => {
371
+ }, Ft = (e) => Nt(e, 0.5), Vt = (e, t) => {
375
372
  try {
376
373
  return e();
377
374
  } catch {
@@ -395,7 +392,7 @@ function Be(e) {
395
392
  function ge(e) {
396
393
  return e instanceof G ? e.toJson() : { kind: "UnknownError", message: Bt(e) || "UnknownError" };
397
394
  }
398
- const Jt = "1.2.7-staging.362", Ot = "https://api-js.mixpanel.com/track/?verbose=1&ip=1", Ze = 50, Z = [];
395
+ const Jt = "1.2.7", Ot = "https://api-js.mixpanel.com/track/?verbose=1&ip=1", Ze = 50, Z = [];
399
396
  let pe = !1;
400
397
  async function et(e) {
401
398
  const t = await fetch(Ot, {
@@ -485,9 +482,9 @@ function Re() {
485
482
  get: (t = !1) => t ? Date.now() - e : e
486
483
  };
487
484
  }
488
- const X = Re(), Ce = Re(), Fe = Re();
485
+ const X = Re(), Ce = Re(), ze = Re();
489
486
  function tt(e) {
490
- return e === _.Playground ? { headers: { [Mt]: "true" } } : {};
487
+ return e === b.Playground ? { headers: { [Mt]: "true" } } : {};
491
488
  }
492
489
  async function nt(e, t, n, i, c = !1, o) {
493
490
  return !o && !Qe(i) && (o = await t.newChat(e.id, { persist: c }, tt(i)), n.track("agent-chat", {
@@ -544,7 +541,7 @@ async function Gt(e, t, n, i) {
544
541
  subscribeToEvents: (s) => c.push(s)
545
542
  };
546
543
  }
547
- function ze(e) {
544
+ function Ne(e) {
548
545
  if (e.answer !== void 0)
549
546
  return e.answer;
550
547
  let t = 0, n = "";
@@ -566,14 +563,14 @@ function Qt(e, t, n) {
566
563
  t.messages.push(i), n == null || n([...t.messages], "user");
567
564
  }
568
565
  function Yt(e, t, n, i, c, o, s) {
569
- if (e === F.Transcribe && t.content) {
566
+ if (e === z.Transcribe && t.content) {
570
567
  Qt(t, i, c);
571
568
  return;
572
569
  }
573
- if (!(e === F.Partial || e === F.Answer))
570
+ if (!(e === z.Partial || e === z.Answer))
574
571
  return;
575
572
  const r = i.messages[i.messages.length - 1];
576
- if (e === F.Answer && (r == null ? void 0 : r.role) === "user" && s === "partial")
573
+ if (e === z.Answer && (r == null ? void 0 : r.role) === "user" && s === "partial")
577
574
  return;
578
575
  const d = s === "answer";
579
576
  let m;
@@ -590,14 +587,14 @@ function Yt(e, t, n, i, c, o, s) {
590
587
  else
591
588
  return;
592
589
  const { content: u, sequence: f } = t;
593
- if (e === F.Partial)
590
+ if (e === z.Partial)
594
591
  n[f] = u;
595
592
  else {
596
- const v = ze(n);
593
+ const v = Ne(n);
597
594
  !!(u && u.length < v.length) && (m.interrupted = !0), n.answer = u;
598
595
  }
599
- const w = ze(n);
600
- (m.content !== w || e === F.Answer) && (m.content = w, m.parts = ae(w), c == null || c([...i.messages], e));
596
+ const w = Ne(n);
597
+ (m.content !== w || e === z.Answer) && (m.content = w, m.parts = ae(w), c == null || c([...i.messages], e));
601
598
  }
602
599
  function Zt(e, t, n, i, c) {
603
600
  const o = {}, s = () => {
@@ -614,7 +611,7 @@ function Zt(e, t, n, i, c) {
614
611
  onMessage: (d, m) => {
615
612
  var u, f;
616
613
  if ("content" in m) {
617
- const w = d === x.ChatAnswer ? F.Answer : d === x.ChatAudioTranscribed ? F.Transcribe : d;
614
+ const w = d === x.ChatAnswer ? z.Answer : d === x.ChatAudioTranscribed ? z.Transcribe : d;
618
615
  Yt(
619
616
  w,
620
617
  m,
@@ -623,7 +620,7 @@ function Zt(e, t, n, i, c) {
623
620
  a,
624
621
  s,
625
622
  r
626
- ), w === F.Partial ? r = "partial" : w === F.Answer && (r = "answer", s()), w === F.Answer && e.track("agent-message-received", {
623
+ ), w === z.Partial ? r = "partial" : w === z.Answer && (r = "answer", s()), w === z.Answer && e.track("agent-message-received", {
627
624
  content: m.content,
628
625
  messages: t.messages.length,
629
626
  mode: t.chatMode
@@ -631,15 +628,15 @@ function Zt(e, t, n, i, c) {
631
628
  } else {
632
629
  const w = x, v = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], j = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], I = Ut(m, i, { mode: t.chatMode });
633
630
  if (d = d, d === w.StreamVideoCreated && (e.linkTrack("agent-video", I, w.StreamVideoCreated, ["start"]), m.sentiment)) {
634
- const b = t.messages[t.messages.length - 1];
635
- if ((b == null ? void 0 : b.role) === "assistant") {
636
- const P = { ...b, sentiment: m.sentiment };
631
+ const T = t.messages[t.messages.length - 1];
632
+ if ((T == null ? void 0 : T.role) === "assistant") {
633
+ const P = { ...T, sentiment: m.sentiment };
637
634
  t.messages[t.messages.length - 1] = P, a == null || a([...t.messages], r ?? "answer");
638
635
  }
639
636
  }
640
637
  if (v.includes(d)) {
641
- const b = d.split("/")[1];
642
- j.includes(d) ? e.track("agent-video", { ...I, event: b }) : e.linkTrack("agent-video", { ...I, event: b }, d, ["done"]);
638
+ const T = d.split("/")[1];
639
+ j.includes(d) ? e.track("agent-video", { ...I, event: T }) : e.linkTrack("agent-video", { ...I, event: T }, d, ["done"]);
643
640
  }
644
641
  j.includes(d) && ((f = (u = n.callbacks).onError) == null || f.call(u, new We(`Stream failed with event ${d}`), { data: m })), m.event === w.StreamDone && c();
645
642
  }
@@ -696,7 +693,7 @@ function rn(e) {
696
693
  durationMs: le(i),
697
694
  desyncDurationMs: le(i * (o.length / c.length)),
698
695
  maxOffsetMs: le(c.reduce((a, d) => Math.abs(d) > Math.abs(a) ? d : a)),
699
- residualOffsetMs: le(Nt(r))
696
+ residualOffsetMs: le(Ft(r))
700
697
  };
701
698
  }
702
699
  function an(e, t, n) {
@@ -771,7 +768,7 @@ function on(e) {
771
768
  localTs: s.timestamp
772
769
  }), r;
773
770
  }
774
- function Ne(e, t, n) {
771
+ function Fe(e, t, n) {
775
772
  const i = e.map((a, d) => d === 0 ? n ? {
776
773
  timestamp: a.timestamp,
777
774
  duration: 0,
@@ -910,12 +907,12 @@ function fn(e, t, n, i, c) {
910
907
  const I = await e();
911
908
  if (!I)
912
909
  return;
913
- const { isReceiving: b, avgJitterDelayInInterval: P, freezeCount: E } = v(I), Q = on(I);
914
- if (b)
915
- a = 0, f = E - w, u = P < dn ? re.Strong : P > ln && f > 1 ? re.Weak : m, u !== m && (c == null || c(u), m = u, w += f, f = 0), d || (i == null || i(k.Start), r = s[s.length - 1], s = [], d = !0), s.push(Q);
910
+ const { isReceiving: T, avgJitterDelayInInterval: P, freezeCount: E } = v(I), Q = on(I);
911
+ if (T)
912
+ a = 0, f = E - w, u = P < dn ? re.Strong : P > ln && f > 1 ? re.Weak : m, u !== m && (c == null || c(u), m = u, w += f, f = 0), d || (i == null || i(S.Start), r = s[s.length - 1], s = [], d = !0), s.push(Q);
916
913
  else if (d && (a++, a >= cn)) {
917
- const H = Ne(s, fe, r);
918
- i == null || i(k.Stop, H), t() || n(), w = E, d = !1;
914
+ const H = Fe(s, fe, r);
915
+ i == null || i(S.Stop, H), t() || n(), w = E, d = !1;
919
916
  }
920
917
  }
921
918
  return {
@@ -925,7 +922,7 @@ function fn(e, t, n, i, c) {
925
922
  stop: () => {
926
923
  o && (clearInterval(o), o = null);
927
924
  },
928
- getReport: () => Ne(s, fe, r)
925
+ getReport: () => Fe(s, fe, r)
929
926
  };
930
927
  }
931
928
  const mn = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
@@ -965,7 +962,7 @@ function gn({
965
962
  report: i,
966
963
  log: c
967
964
  }) {
968
- e === k.Start && t === k.Start ? (c("CALLBACK: onVideoStateChange(Start)"), n == null || n(k.Start)) : e === k.Stop && t === k.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), n == null || n(k.Stop, i));
965
+ e === S.Start && t === S.Start ? (c("CALLBACK: onVideoStateChange(Start)"), n == null || n(S.Start)) : e === S.Stop && t === S.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), n == null || n(S.Stop, i));
969
966
  }
970
967
  function pn({
971
968
  statsSignal: e,
@@ -975,7 +972,7 @@ function pn({
975
972
  report: c,
976
973
  log: o
977
974
  }) {
978
- e === k.Start ? (o("CALLBACK: onVideoStateChange(Start)"), n == null || n(k.Start)) : e === k.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), n == null || n(k.Stop, c)), t === k.Start ? i == null || i(ie.Talking) : t === k.Stop && (i == null || i(ie.Idle));
975
+ e === S.Start ? (o("CALLBACK: onVideoStateChange(Start)"), n == null || n(S.Start)) : e === S.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), n == null || n(S.Stop, c)), t === S.Start ? i == null || i(ie.Talking) : t === S.Stop && (i == null || i(ie.Idle));
979
976
  }
980
977
  function Ue({
981
978
  statsSignal: e,
@@ -996,10 +993,10 @@ function Ue({
996
993
  });
997
994
  }
998
995
  async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me, analytics: s }, r) {
999
- var N;
996
+ var F;
1000
997
  const a = tn(n, "WebRTCStreamingManager"), d = hn(a);
1001
- let m = !1, u = !1, f = k.Stop, w = k.Stop;
1002
- const { startConnection: v, sendStreamRequest: j, close: I, createStream: b, addIceCandidate: P } = en(
998
+ let m = !1, u = !1, f = S.Stop, w = S.Stop;
999
+ const { startConnection: v, sendStreamRequest: j, close: I, createStream: T, addIceCandidate: P } = en(
1003
1000
  c,
1004
1001
  o,
1005
1002
  e,
@@ -1011,8 +1008,8 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1011
1008
  session_id: V,
1012
1009
  fluent: se,
1013
1010
  interrupt_enabled: Y
1014
- } = await b(t, r);
1015
- (N = i.onStreamCreated) == null || N.call(i, { stream_id: E, session_id: V, agent_id: e });
1011
+ } = await T(t, r);
1012
+ (F = i.onStreamCreated) == null || F.call(i, { stream_id: E, session_id: V, agent_id: e });
1016
1013
  const R = new mn({ iceServers: H }), q = R.createDataChannel("JanusDataChannel");
1017
1014
  if (!V)
1018
1015
  throw new Error("Could not create session_id");
@@ -1027,22 +1024,22 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1027
1024
  () => R.getStats(),
1028
1025
  ce,
1029
1026
  te,
1030
- (h, p) => Ue({
1027
+ (h, g) => Ue({
1031
1028
  statsSignal: w = h,
1032
1029
  dataChannelSignal: U === W.Legacy ? f : void 0,
1033
1030
  onVideoStateChange: i.onVideoStateChange,
1034
1031
  onAgentActivityStateChange: i.onAgentActivityStateChange,
1035
- report: p,
1032
+ report: g,
1036
1033
  streamType: U,
1037
1034
  log: a
1038
1035
  }),
1039
1036
  (h) => {
1040
- var p;
1041
- return (p = i.onConnectivityStateChange) == null ? void 0 : p.call(i, h);
1037
+ var g;
1038
+ return (g = i.onConnectivityStateChange) == null ? void 0 : g.call(i, h);
1042
1039
  }
1043
1040
  );
1044
1041
  l.start(), R.onicecandidate = (h) => {
1045
- var p;
1042
+ var g;
1046
1043
  a("peerConnection.onicecandidate", h);
1047
1044
  try {
1048
1045
  h.candidate && h.candidate.sdpMid && h.candidate.sdpMLineIndex !== null ? P(
@@ -1056,22 +1053,22 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1056
1053
  r
1057
1054
  ) : P(E, { candidate: null }, V, r);
1058
1055
  } catch (D) {
1059
- (p = i.onError) == null || p.call(i, D, { streamId: E });
1056
+ (g = i.onError) == null || g.call(i, D, { streamId: E });
1060
1057
  }
1061
1058
  }, q.onopen = () => {
1062
1059
  u = !0, (!oe || m) && te();
1063
1060
  };
1064
- let g = null;
1061
+ let p = null;
1065
1062
  const y = (h) => {
1066
- var p;
1067
- g = h, (p = i.onVideoIdChange) == null || p.call(i, h);
1063
+ var g;
1064
+ p = h, (g = i.onVideoIdChange) == null || g.call(i, h);
1068
1065
  };
1069
- function C(h, p) {
1070
- if (h === x.StreamStarted && typeof p == "object" && "metadata" in p) {
1071
- const D = p.metadata;
1066
+ function C(h, g) {
1067
+ if (h === x.StreamStarted && typeof g == "object" && "metadata" in g) {
1068
+ const D = g.metadata;
1072
1069
  y(D.videoId);
1073
1070
  }
1074
- h === x.StreamDone && y(null), f = h === x.StreamStarted ? k.Start : k.Stop, Ue({
1071
+ h === x.StreamDone && y(null), f = h === x.StreamStarted ? S.Start : S.Stop, Ue({
1075
1072
  statsSignal: U === W.Legacy ? w : void 0,
1076
1073
  dataChannelSignal: f,
1077
1074
  onVideoStateChange: i.onVideoStateChange,
@@ -1080,43 +1077,43 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1080
1077
  log: a
1081
1078
  });
1082
1079
  }
1083
- function S(h, p) {
1084
- var B;
1085
- const D = typeof p == "string" ? p : p == null ? void 0 : p.metadata;
1086
- D && s.enrich({ streamMetadata: D }), (B = i.onStreamReady) == null || B.call(i);
1080
+ function k(h, g) {
1081
+ var $;
1082
+ const D = typeof g == "string" ? g : g == null ? void 0 : g.metadata;
1083
+ D && s.enrich({ streamMetadata: D }), ($ = i.onStreamReady) == null || $.call(i);
1087
1084
  }
1088
1085
  const M = {
1089
1086
  [x.StreamStarted]: C,
1090
1087
  [x.StreamDone]: C,
1091
- [x.StreamReady]: S
1088
+ [x.StreamReady]: k
1092
1089
  };
1093
1090
  q.onmessage = (h) => {
1094
- var B;
1095
- const { subject: p, data: D } = d(h.data);
1096
- (B = M[p]) == null || B.call(M, p, D);
1091
+ var $;
1092
+ const { subject: g, data: D } = d(h.data);
1093
+ ($ = M[g]) == null || $.call(M, g, D);
1097
1094
  }, R.oniceconnectionstatechange = () => {
1098
- var p;
1095
+ var g;
1099
1096
  a("peerConnection.oniceconnectionstatechange => " + R.iceConnectionState);
1100
1097
  const h = Ve(R.iceConnectionState);
1101
- h !== A.Connected && ((p = i.onConnectionStateChange) == null || p.call(i, h, `webrtc:ice-${R.iceConnectionState}`));
1098
+ h !== A.Connected && ((g = i.onConnectionStateChange) == null || g.call(i, h, `webrtc:ice-${R.iceConnectionState}`));
1102
1099
  }, R.ontrack = (h) => {
1103
- var p;
1104
- a("peerConnection.ontrack", h), a("CALLBACK: onSrcObjectReady"), (p = i.onSrcObjectReady) == null || p.call(i, h.streams[0]);
1100
+ var g;
1101
+ a("peerConnection.ontrack", h), a("CALLBACK: onSrcObjectReady"), (g = i.onSrcObjectReady) == null || g.call(i, h.streams[0]);
1105
1102
  }, await R.setRemoteDescription(Q), a("set remote description OK");
1106
1103
  const L = await R.createAnswer();
1107
1104
  a("create answer OK"), await R.setLocalDescription(L), a("set local description OK"), await v(E, L, V, r), a("start connection OK");
1108
- function z(h) {
1109
- var p, D;
1105
+ function N(h) {
1106
+ var g, D;
1110
1107
  if (!m || q.readyState !== "open") {
1111
- a("Data channel is not ready for sending messages"), (p = i.onError) == null || p.call(i, new We("Data channel is not ready for sending messages"), {
1108
+ a("Data channel is not ready for sending messages"), (g = i.onError) == null || g.call(i, new We("Data channel is not ready for sending messages"), {
1112
1109
  streamId: E
1113
1110
  });
1114
1111
  return;
1115
1112
  }
1116
1113
  try {
1117
1114
  q.send(h);
1118
- } catch (B) {
1119
- a("Error sending data channel message", B), (D = i.onError) == null || D.call(i, B, { streamId: E });
1115
+ } catch ($) {
1116
+ a("Error sending data channel message", $), (D = i.onError) == null || D.call(i, $, { streamId: E });
1120
1117
  }
1121
1118
  }
1122
1119
  return {
@@ -1133,16 +1130,16 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1133
1130
  async disconnect() {
1134
1131
  var h;
1135
1132
  if (E) {
1136
- const p = Ve(R.iceConnectionState);
1133
+ const g = Ve(R.iceConnectionState);
1137
1134
  if (R) {
1138
- if (p === A.New) {
1135
+ if (g === A.New) {
1139
1136
  l.stop();
1140
1137
  return;
1141
1138
  }
1142
1139
  R.close(), R.oniceconnectionstatechange = null, R.onnegotiationneeded = null, R.onicecandidate = null, R.ontrack = null;
1143
1140
  }
1144
1141
  try {
1145
- p === A.Connected && await I(E, V).catch((D) => {
1142
+ g === A.Connected && await I(E, V).catch((D) => {
1146
1143
  });
1147
1144
  } catch (D) {
1148
1145
  a("Error on close stream connection", D);
@@ -1150,7 +1147,7 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1150
1147
  (h = i.onAgentActivityStateChange) == null || h.call(i, ie.Idle), l.stop();
1151
1148
  }
1152
1149
  },
1153
- sendDataChannelMessage: z,
1150
+ sendDataChannelMessage: N,
1154
1151
  /**
1155
1152
  * Session identifier information, should be returned in the body of all streaming requests
1156
1153
  */
@@ -1167,18 +1164,18 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
1167
1164
  throw new Error("Interrupt is not enabled for this stream");
1168
1165
  if (U !== W.Fluent)
1169
1166
  throw new Error("Interrupt only available for Fluent streams");
1170
- if (!g)
1167
+ if (!p)
1171
1168
  throw new Error("No active video to interrupt");
1172
- const p = {
1169
+ const g = {
1173
1170
  type: x.StreamInterrupt,
1174
- videoId: g,
1171
+ videoId: p,
1175
1172
  timestamp: Date.now()
1176
1173
  };
1177
- z(JSON.stringify(p));
1174
+ N(JSON.stringify(g));
1178
1175
  }
1179
1176
  };
1180
1177
  }
1181
- var ke = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(ke || {});
1178
+ var Se = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Se || {});
1182
1179
  async function yn(e, t, n, i) {
1183
1180
  const c = e.id;
1184
1181
  switch (t.version) {
@@ -1189,8 +1186,8 @@ async function yn(e, t, n, i) {
1189
1186
  case "v2": {
1190
1187
  const { version: o, ...s } = t;
1191
1188
  switch (s.transport.provider) {
1192
- case Se.Livekit:
1193
- const { createLiveKitStreamingManager: r } = await import("./livekit-manager-B-KgHWF7.js");
1189
+ case ke.Livekit:
1190
+ const { createLiveKitStreamingManager: r } = await import("./livekit-manager-D2P6tClx.js");
1194
1191
  return r(c, s, n);
1195
1192
  default:
1196
1193
  throw new Error(`Unsupported transport provider: ${s.transport.provider}`);
@@ -1204,11 +1201,11 @@ const vn = "cht";
1204
1201
  function Cn() {
1205
1202
  return {
1206
1203
  transport: {
1207
- provider: Se.Livekit
1204
+ provider: ke.Livekit
1208
1205
  }
1209
1206
  };
1210
1207
  }
1211
- function kn(e) {
1208
+ function Sn(e) {
1212
1209
  var c, o;
1213
1210
  const { streamOptions: t } = e ?? {}, n = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
1214
1211
  plan: (o = e.mixpanelAdditionalProperties) == null ? void 0 : o.plan
@@ -1221,8 +1218,8 @@ function kn(e) {
1221
1218
  fluent: t == null ? void 0 : t.fluent
1222
1219
  }, ...n && { end_user_data: n } };
1223
1220
  }
1224
- function Sn(e, t) {
1225
- return Me(e.presenter.type) ? { version: ke.V2, ...Cn() } : { version: ke.V1, ...kn(t) };
1221
+ function kn(e, t) {
1222
+ return Me(e.presenter.type) ? { version: Se.V2, ...Cn() } : { version: Se.V1, ...Sn(t) };
1226
1223
  }
1227
1224
  function Mn(e, t, n) {
1228
1225
  n.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
@@ -1231,7 +1228,7 @@ function Rn(e, t, n, i, c) {
1231
1228
  c === W.Fluent ? Dn(e, t, n, i, c) : In(e, t, n, i, c);
1232
1229
  }
1233
1230
  function Dn(e, t, n, i, c) {
1234
- e === k.Start ? i.track("stream-session", { event: "start", "stream-type": c }) : e === k.Stop && i.track("stream-session", {
1231
+ e === S.Start ? i.track("stream-session", { event: "start", "stream-type": c }) : e === S.Stop && i.track("stream-session", {
1235
1232
  event: "stop",
1236
1233
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
1237
1234
  background: t.presenter.type === "clip" && t.presenter.background,
@@ -1240,9 +1237,9 @@ function Dn(e, t, n, i, c) {
1240
1237
  });
1241
1238
  }
1242
1239
  function Je(e, t, n, i, c) {
1243
- e === k.Start ? n.linkTrack("agent-video", { event: "start", ...c, "stream-type": i }, "start", [
1240
+ e === S.Start ? n.linkTrack("agent-video", { event: "start", ...c, "stream-type": i }, "start", [
1244
1241
  x.StreamVideoCreated
1245
- ]) : e === k.Stop && n.linkTrack(
1242
+ ]) : e === S.Stop && n.linkTrack(
1246
1243
  "agent-video",
1247
1244
  {
1248
1245
  event: "stop",
@@ -1255,12 +1252,12 @@ function Je(e, t, n, i, c) {
1255
1252
  );
1256
1253
  }
1257
1254
  function In(e, t, n, i, c) {
1258
- e === k.Start ? i.linkTrack(
1255
+ e === S.Start ? i.linkTrack(
1259
1256
  "agent-video",
1260
1257
  { event: "start", latency: X.get(!0), "stream-type": c },
1261
1258
  "start",
1262
1259
  [x.StreamVideoCreated]
1263
- ) : e === k.Stop && i.linkTrack(
1260
+ ) : e === S.Stop && i.linkTrack(
1264
1261
  "agent-video",
1265
1262
  {
1266
1263
  event: "stop",
@@ -1291,10 +1288,10 @@ function En(e, t, n) {
1291
1288
  });
1292
1289
  }
1293
1290
  function Oe(e, t, n, i) {
1294
- return X.reset(), Fe.update(), new Promise(async (c, o) => {
1291
+ return X.reset(), ze.update(), new Promise(async (c, o) => {
1295
1292
  try {
1296
1293
  let s, r = !1;
1297
- const a = Sn(e, t);
1294
+ const a = kn(e, t);
1298
1295
  n.enrich({
1299
1296
  "stream-version": a.version.toString()
1300
1297
  });
@@ -1326,14 +1323,14 @@ function Oe(e, t, n, i) {
1326
1323
  var f, w;
1327
1324
  (w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, u), u === ie.Talking ? (Ce.update(), d = (v) => {
1328
1325
  Je(
1329
- k.Start,
1326
+ S.Start,
1330
1327
  e,
1331
1328
  n,
1332
1329
  s.streamType,
1333
1330
  v
1334
1331
  ), d = null;
1335
1332
  }, m || d({ latency: X.get(!0) })) : (Ce.reset(), d = null, Je(
1336
- k.Stop,
1333
+ S.Stop,
1337
1334
  e,
1338
1335
  n,
1339
1336
  s.streamType
@@ -1343,7 +1340,7 @@ function Oe(e, t, n, i) {
1343
1340
  d == null || d(u);
1344
1341
  },
1345
1342
  onStreamReady: () => {
1346
- const u = Fe.get(!0);
1343
+ const u = ze.get(!0);
1347
1344
  n.track("agent-chat", { event: "ready", latency: u });
1348
1345
  },
1349
1346
  onToolEvent: ((u, f) => {
@@ -1359,13 +1356,13 @@ function Oe(e, t, n, i) {
1359
1356
  }
1360
1357
  });
1361
1358
  }
1362
- async function bn(e, t, n, i, c) {
1359
+ async function Tn(e, t, n, i, c) {
1363
1360
  var m, u, f, w;
1364
1361
  const o = async () => {
1365
1362
  if (Me(e.presenter.type)) {
1366
1363
  const v = await Oe(e, t, i), j = `${vn}_${v.sessionId}`, I = (/* @__PURE__ */ new Date()).toISOString();
1367
1364
  return { chatResult: {
1368
- chatMode: _.Functional,
1365
+ chatMode: b.Functional,
1369
1366
  chat: {
1370
1367
  id: j,
1371
1368
  agent_id: e.id,
@@ -1374,7 +1371,7 @@ async function bn(e, t, n, i, c) {
1374
1371
  modified: I,
1375
1372
  agent_id__created_at: I,
1376
1373
  agent_id__modified_at: I,
1377
- chat_mode: _.Functional,
1374
+ chat_mode: b.Functional,
1378
1375
  messages: []
1379
1376
  }
1380
1377
  }, streamingManager: v };
@@ -1382,27 +1379,27 @@ async function bn(e, t, n, i, c) {
1382
1379
  const v = new AbortController(), j = v.signal;
1383
1380
  let I;
1384
1381
  try {
1385
- const b = nt(
1382
+ const T = nt(
1386
1383
  e,
1387
1384
  n,
1388
1385
  i,
1389
1386
  t.mode,
1390
1387
  t.persistentChat,
1391
1388
  c
1392
- ), P = Oe(e, t, i, j).then((H) => (I = H, H)), [E, Q] = await Promise.all([b, P]);
1389
+ ), P = Oe(e, t, i, j).then((H) => (I = H, H)), [E, Q] = await Promise.all([T, P]);
1393
1390
  return { chatResult: E, streamingManager: Q };
1394
- } catch (b) {
1391
+ } catch (T) {
1395
1392
  throw v.abort(), I && await I.disconnect().catch(() => {
1396
- }), b;
1393
+ }), T;
1397
1394
  }
1398
1395
  }
1399
1396
  }, { chatResult: s, streamingManager: r } = await o(), { chat: a, chatMode: d } = s;
1400
- return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (u = (m = t.callbacks).onModeChange) == null || u.call(m, d), d !== _.Functional) ? ((w = (f = t.callbacks).onError) == null || w.call(f, new ct(d)), r == null || r.disconnect(), { chat: a }) : { chat: a, streamingManager: r };
1397
+ return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (u = (m = t.callbacks).onModeChange) == null || u.call(m, d), d !== b.Functional) ? ((w = (f = t.callbacks).onError) == null || w.call(f, new ct(d)), r == null || r.disconnect(), { chat: a }) : { chat: a, streamingManager: r };
1401
1398
  }
1402
1399
  async function Ln(e, t) {
1403
1400
  var U, oe, ce, te;
1404
1401
  let n = !0;
1405
- const i = t.mixpanelKey || Dt, c = t.wsURL || Rt, o = t.baseURL || me, s = t.mode || _.Functional, r = {
1402
+ const i = t.mixpanelKey || Dt, c = t.wsURL || Rt, o = t.baseURL || me, s = t.mode || b.Functional, r = {
1406
1403
  messages: [],
1407
1404
  chatMode: s
1408
1405
  }, a = Wt({
@@ -1416,37 +1413,37 @@ async function Ln(e, t) {
1416
1413
  a.track("agent-sdk", { event: "init" }, d);
1417
1414
  });
1418
1415
  const m = t.callbacks.onError;
1419
- t.callbacks.onError = (l, g) => {
1420
- a.track("agent-error", { error: ge(l) }), m == null || m(l, g);
1416
+ t.callbacks.onError = (l, p) => {
1417
+ a.track("agent-error", { error: ge(l) }), m == null || m(l, p);
1421
1418
  };
1422
1419
  const u = Lt(t.auth, o, t.callbacks.onError, t.externalId), f = await u.getById(e);
1423
1420
  t.debug = t.debug || ((U = f == null ? void 0 : f.advanced_settings) == null ? void 0 : U.ui_debug_mode);
1424
1421
  const w = Me(f.presenter.type);
1425
1422
  a.enrich($t(f));
1426
1423
  const { onMessage: v, clearQueue: j } = Zt(a, r, t, f, () => {
1427
- var l, g, y;
1428
- (l = r.socketManager) == null || l.disconnect(), (y = (g = t.callbacks).onConnectionStateChange) == null || y.call(g, A.Disconnected);
1424
+ var l, p, y;
1425
+ (l = r.socketManager) == null || l.disconnect(), (y = (p = t.callbacks).onConnectionStateChange) == null || y.call(p, A.Disconnected);
1429
1426
  });
1430
1427
  r.messages = Ht(t.initialMessages), (ce = (oe = t.callbacks).onNewMessage) == null || ce.call(oe, [...r.messages], "answer");
1431
1428
  const I = (l) => {
1432
1429
  a.enrich({ videoId: l });
1433
- }, b = ({ type: l }) => {
1434
- var y, C, S, M;
1430
+ }, T = ({ type: l }) => {
1431
+ var y, C, k, M;
1435
1432
  if (!((y = r.streamingManager) != null && y.interruptAvailable) || !((C = r.streamingManager) != null && C.isInterruptible)) return;
1436
- const g = r.messages[r.messages.length - 1];
1433
+ const p = r.messages[r.messages.length - 1];
1437
1434
  a.track("agent-video-interrupt", {
1438
1435
  type: l || "click",
1439
1436
  video_duration_to_interrupt: Ce.get(!0),
1440
1437
  message_duration_to_interrupt: X.get(!0)
1441
- }), g.interrupted = !0, (M = (S = t.callbacks).onNewMessage) == null || M.call(S, [...r.messages], "answer"), r.streamingManager.interrupt(l);
1438
+ }), p.interrupted = !0, (M = (k = t.callbacks).onNewMessage) == null || M.call(k, [...r.messages], "answer"), r.streamingManager.interrupt(l);
1442
1439
  }, P = /* @__PURE__ */ new Map();
1443
1440
  function E(l) {
1444
- return async (g) => {
1441
+ return async (p) => {
1445
1442
  const y = P.get(l);
1446
1443
  if (!y)
1447
1444
  throw new Error(`No handler registered for client tool: ${l}`);
1448
1445
  try {
1449
- const C = JSON.parse(g.payload);
1446
+ const C = JSON.parse(p.payload);
1450
1447
  return await y(C);
1451
1448
  } catch (C) {
1452
1449
  throw new Error(`Client tool "${l}" failed: ${C.message}`);
@@ -1454,33 +1451,33 @@ async function Ln(e, t) {
1454
1451
  };
1455
1452
  }
1456
1453
  function Q() {
1457
- var l, g, y, C;
1458
- for (const [S] of P)
1459
- (g = (l = r.streamingManager) == null ? void 0 : l.unregisterRpcMethod) == null || g.call(l, S), (C = (y = r.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || C.call(y, S, E(S));
1454
+ var l, p, y, C;
1455
+ for (const [k] of P)
1456
+ (p = (l = r.streamingManager) == null ? void 0 : l.unregisterRpcMethod) == null || p.call(l, k), (C = (y = r.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || C.call(y, k, E(k));
1460
1457
  }
1461
- function H(l, g) {
1462
- var C, S;
1458
+ function H(l, p) {
1459
+ var C, k;
1463
1460
  const y = !P.has(l);
1464
- P.set(l, g), y && ((S = (C = r.streamingManager) == null ? void 0 : C.registerRpcMethod) == null || S.call(C, l, E(l)));
1461
+ P.set(l, p), y && ((k = (C = r.streamingManager) == null ? void 0 : C.registerRpcMethod) == null || k.call(C, l, E(l)));
1465
1462
  }
1466
1463
  function V(l) {
1467
- var g, y;
1468
- P.delete(l), (y = (g = r.streamingManager) == null ? void 0 : g.unregisterRpcMethod) == null || y.call(g, l);
1464
+ var p, y;
1465
+ P.delete(l), (y = (p = r.streamingManager) == null ? void 0 : p.unregisterRpcMethod) == null || y.call(p, l);
1469
1466
  }
1470
1467
  const se = Date.now();
1471
1468
  Be(() => {
1472
1469
  a.track("agent-sdk", { event: "loaded", ...jt(f) }, se);
1473
1470
  });
1474
1471
  async function Y(l) {
1475
- var L, z, N, h, p, D, B;
1476
- kt(), (z = (L = t.callbacks).onConnectionStateChange) == null || z.call(L, A.Connecting), X.reset(), l && !n && (delete r.chat, (h = (N = t.callbacks).onNewMessage) == null || h.call(N, [...r.messages], "answer"));
1477
- const g = s === _.DirectPlayback || w ? Promise.resolve(void 0) : Gt(
1472
+ var L, N, F, h, g, D, $;
1473
+ St(), (N = (L = t.callbacks).onConnectionStateChange) == null || N.call(L, A.Connecting), X.reset(), l && !n && (delete r.chat, (h = (F = t.callbacks).onNewMessage) == null || h.call(F, [...r.messages], "answer"));
1474
+ const p = s === b.DirectPlayback || w ? Promise.resolve(void 0) : Gt(
1478
1475
  t.auth,
1479
1476
  c,
1480
1477
  { onMessage: v, onError: t.callbacks.onError },
1481
1478
  t.externalId
1482
1479
  ), y = ye(
1483
- () => bn(
1480
+ () => Tn(
1484
1481
  f,
1485
1482
  {
1486
1483
  ...t,
@@ -1497,28 +1494,28 @@ async function Ln(e, t) {
1497
1494
  ),
1498
1495
  {
1499
1496
  limit: 3,
1500
- timeout: St,
1497
+ timeout: kt,
1501
1498
  timeoutErrorMessage: "Timeout initializing the stream",
1502
1499
  shouldRetryFn: (O) => (O == null ? void 0 : O.message) !== "Could not connect" && !(O instanceof Ke && (O.status === 429 || O.kind === "InsufficientCreditsError")),
1503
1500
  delayMs: 1e3
1504
1501
  }
1505
1502
  ).catch((O) => {
1506
- var T, J;
1507
- throw q(_.Maintenance), (J = (T = t.callbacks).onConnectionStateChange) == null || J.call(T, A.Fail), O;
1508
- }), [C, { streamingManager: S, chat: M }] = await Promise.all([g, y]);
1509
- M && M.id !== ((p = r.chat) == null ? void 0 : p.id) && ((B = (D = t.callbacks).onNewChat) == null || B.call(D, M.id)), r.streamingManager = S, r.socketManager = C, r.chat = M, Q(), n = !1, a.enrich({
1503
+ var _, J;
1504
+ throw q(b.Maintenance), (J = (_ = t.callbacks).onConnectionStateChange) == null || J.call(_, A.Fail), O;
1505
+ }), [C, { streamingManager: k, chat: M }] = await Promise.all([p, y]);
1506
+ M && M.id !== ((g = r.chat) == null ? void 0 : g.id) && (($ = (D = t.callbacks).onNewChat) == null || $.call(D, M.id)), r.streamingManager = k, r.socketManager = C, r.chat = M, Q(), n = !1, a.enrich({
1510
1507
  chatId: M == null ? void 0 : M.id,
1511
- streamId: S == null ? void 0 : S.streamId,
1508
+ streamId: k == null ? void 0 : k.streamId,
1512
1509
  mode: r.chatMode
1513
1510
  }), q((M == null ? void 0 : M.chat_mode) ?? s);
1514
1511
  }
1515
1512
  async function R() {
1516
- var l, g, y, C;
1517
- (l = r.socketManager) == null || l.disconnect(), await ((g = r.streamingManager) == null ? void 0 : g.disconnect()), delete r.streamingManager, delete r.socketManager, (C = (y = t.callbacks).onConnectionStateChange) == null || C.call(y, A.Disconnected);
1513
+ var l, p, y, C;
1514
+ (l = r.socketManager) == null || l.disconnect(), await ((p = r.streamingManager) == null ? void 0 : p.disconnect()), delete r.streamingManager, delete r.socketManager, (C = (y = t.callbacks).onConnectionStateChange) == null || C.call(y, A.Disconnected);
1518
1515
  }
1519
1516
  async function q(l) {
1520
- var g, y;
1521
- l !== r.chatMode && (a.track("agent-mode-change", { mode: l }), r.chatMode = l, r.chatMode !== _.Functional && await R(), (y = (g = t.callbacks).onModeChange) == null || y.call(g, l));
1517
+ var p, y;
1518
+ l !== r.chatMode && (a.track("agent-mode-change", { mode: l }), r.chatMode = l, r.chatMode !== b.Functional && await R(), (y = (p = t.callbacks).onModeChange) == null || y.call(p, l));
1522
1519
  }
1523
1520
  return {
1524
1521
  agent: f,
@@ -1542,12 +1539,12 @@ async function Ln(e, t) {
1542
1539
  },
1543
1540
  async reconnect() {
1544
1541
  const l = r.streamingManager;
1545
- let g;
1542
+ let p;
1546
1543
  if (w && (l != null && l.reconnect))
1547
1544
  try {
1548
1545
  await l.reconnect();
1549
1546
  } catch (y) {
1550
- g = ge(y).kind, await R(), await Y(!1);
1547
+ p = ge(y).kind, await R(), await Y(!1);
1551
1548
  }
1552
1549
  else
1553
1550
  await R(), await Y(!1);
@@ -1555,7 +1552,7 @@ async function Ln(e, t) {
1555
1552
  event: "reconnect",
1556
1553
  mode: r.chatMode,
1557
1554
  success: !0,
1558
- ...g && { fallbackReason: g }
1555
+ ...p && { fallbackReason: p }
1559
1556
  });
1560
1557
  },
1561
1558
  async disconnect() {
@@ -1565,44 +1562,44 @@ async function Ln(e, t) {
1565
1562
  });
1566
1563
  },
1567
1564
  publishMicrophoneStream(l) {
1568
- var g;
1569
- return (g = r.streamingManager) != null && g.publishMicrophoneStream ? r.streamingManager.publishMicrophoneStream(l) : Promise.reject(new Error("publishMicrophoneStream is not available for this streaming manager"));
1565
+ var p;
1566
+ return (p = r.streamingManager) != null && p.publishMicrophoneStream ? r.streamingManager.publishMicrophoneStream(l) : Promise.reject(new Error("publishMicrophoneStream is not available for this streaming manager"));
1570
1567
  },
1571
1568
  unpublishMicrophoneStream() {
1572
1569
  var l;
1573
1570
  return (l = r.streamingManager) != null && l.unpublishMicrophoneStream ? r.streamingManager.unpublishMicrophoneStream() : Promise.resolve();
1574
1571
  },
1575
1572
  replaceMicrophoneTrack(l) {
1576
- var g;
1577
- return (g = r.streamingManager) != null && g.replaceMicrophoneTrack ? r.streamingManager.replaceMicrophoneTrack(l) : Promise.reject(new Error("replaceMicrophoneTrack is not available for this streaming manager"));
1573
+ var p;
1574
+ return (p = r.streamingManager) != null && p.replaceMicrophoneTrack ? r.streamingManager.replaceMicrophoneTrack(l) : Promise.reject(new Error("replaceMicrophoneTrack is not available for this streaming manager"));
1578
1575
  },
1579
1576
  publishCameraStream(l) {
1580
- var g;
1581
- return (g = r.streamingManager) != null && g.publishCameraStream ? r.streamingManager.publishCameraStream(l) : Promise.reject(new Error("publishCameraStream is not available for this streaming manager"));
1577
+ var p;
1578
+ return (p = r.streamingManager) != null && p.publishCameraStream ? r.streamingManager.publishCameraStream(l) : Promise.reject(new Error("publishCameraStream is not available for this streaming manager"));
1582
1579
  },
1583
1580
  unpublishCameraStream() {
1584
1581
  var l;
1585
1582
  return (l = r.streamingManager) != null && l.unpublishCameraStream ? r.streamingManager.unpublishCameraStream() : Promise.resolve();
1586
1583
  },
1587
1584
  async chat(l) {
1588
- var S, M, L, z, N;
1589
- const g = () => {
1585
+ var k, M, L, N, F;
1586
+ const p = () => {
1590
1587
  if (Qe(s))
1591
- throw new $(`${s} is enabled, chat is disabled`);
1592
- if (l.length >= be)
1593
- throw new $(`Message cannot be more than ${be} characters`);
1588
+ throw new B(`${s} is enabled, chat is disabled`);
1589
+ if (l.length >= Te)
1590
+ throw new B(`Message cannot be more than ${Te} characters`);
1594
1591
  if (l.length === 0)
1595
- throw new $("Message cannot be empty");
1596
- if (r.chatMode === _.Maintenance)
1597
- throw new $("Chat is in maintenance mode");
1598
- if (![_.TextOnly, _.Playground].includes(r.chatMode)) {
1592
+ throw new B("Message cannot be empty");
1593
+ if (r.chatMode === b.Maintenance)
1594
+ throw new B("Chat is in maintenance mode");
1595
+ if (![b.TextOnly, b.Playground].includes(r.chatMode)) {
1599
1596
  if (!r.streamingManager)
1600
- throw new $("Streaming manager is not initialized");
1597
+ throw new B("Streaming manager is not initialized");
1601
1598
  if (!r.chat)
1602
- throw new $("Chat is not initialized");
1599
+ throw new B("Chat is not initialized");
1603
1600
  }
1604
1601
  }, y = async () => {
1605
- var h, p;
1602
+ var h, g;
1606
1603
  if (!r.chat) {
1607
1604
  const D = await nt(
1608
1605
  f,
@@ -1613,22 +1610,22 @@ async function Ln(e, t) {
1613
1610
  );
1614
1611
  if (!D.chat)
1615
1612
  throw new ot(r.chatMode, !!t.persistentChat);
1616
- r.chat = D.chat, (p = (h = t.callbacks).onNewChat) == null || p.call(h, r.chat.id);
1613
+ r.chat = D.chat, (g = (h = t.callbacks).onNewChat) == null || g.call(h, r.chat.id);
1617
1614
  }
1618
1615
  return r.chat.id;
1619
- }, C = async (h, p) => {
1620
- const D = r.chatMode === _.Playground;
1616
+ }, C = async (h, g) => {
1617
+ const D = r.chatMode === b.Playground;
1621
1618
  return ye(w && !D ? async () => {
1622
- var T, J;
1623
- return await ((J = (T = r.streamingManager) == null ? void 0 : T.sendTextMessage) == null ? void 0 : J.call(T, l)), Promise.resolve({});
1619
+ var _, J;
1620
+ return await ((J = (_ = r.streamingManager) == null ? void 0 : _.sendTextMessage) == null ? void 0 : J.call(_, l)), Promise.resolve({});
1624
1621
  } : async () => {
1625
- var T, J;
1622
+ var _, J;
1626
1623
  return u.chat(
1627
1624
  f.id,
1628
- p,
1625
+ g,
1629
1626
  {
1630
1627
  chatMode: r.chatMode,
1631
- streamId: (T = r.streamingManager) == null ? void 0 : T.streamId,
1628
+ streamId: (_ = r.streamingManager) == null ? void 0 : _.streamId,
1632
1629
  sessionId: (J = r.streamingManager) == null ? void 0 : J.sessionId,
1633
1630
  messages: h.map(({ matches: at, ...de }) => de)
1634
1631
  },
@@ -1639,10 +1636,10 @@ async function Ln(e, t) {
1639
1636
  );
1640
1637
  }, {
1641
1638
  limit: 2,
1642
- shouldRetryFn: (T) => {
1639
+ shouldRetryFn: (_) => {
1643
1640
  var de, De, Ie, Ee;
1644
- const J = (de = T == null ? void 0 : T.message) == null ? void 0 : de.includes("missing or invalid session_id");
1645
- return !((De = T == null ? void 0 : T.message) == null ? void 0 : De.includes("Stream Error")) && !J ? ((Ee = (Ie = t.callbacks).onError) == null || Ee.call(Ie, T), !1) : !0;
1641
+ const J = (de = _ == null ? void 0 : _.message) == null ? void 0 : de.includes("missing or invalid session_id");
1642
+ return !((De = _ == null ? void 0 : _.message) == null ? void 0 : De.includes("Stream Error")) && !J ? ((Ee = (Ie = t.callbacks).onError) == null || Ee.call(Ie, _), !1) : !0;
1646
1643
  },
1647
1644
  onRetry: async () => {
1648
1645
  await R(), await Y(!1);
@@ -1650,79 +1647,74 @@ async function Ln(e, t) {
1650
1647
  });
1651
1648
  };
1652
1649
  try {
1653
- j(), g(), r.messages.push({
1650
+ j(), p(), r.messages.push({
1654
1651
  id: ee(),
1655
1652
  role: "user",
1656
1653
  content: l,
1657
1654
  parts: ae(l),
1658
1655
  created_at: new Date(X.update()).toISOString()
1659
- }), (M = (S = t.callbacks).onNewMessage) == null || M.call(S, [...r.messages], "user");
1660
- const h = await y(), p = await C([...r.messages], h);
1661
- return p.result && r.messages.push({
1656
+ }), (M = (k = t.callbacks).onNewMessage) == null || M.call(k, [...r.messages], "user");
1657
+ const h = await y(), g = await C([...r.messages], h);
1658
+ return g.result && r.messages.push({
1662
1659
  id: ee(),
1663
1660
  role: "assistant",
1664
- content: p.result,
1665
- parts: ae(p.result),
1661
+ content: g.result,
1662
+ parts: ae(g.result),
1666
1663
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1667
- context: p.context,
1668
- matches: p.matches
1664
+ context: g.context,
1665
+ matches: g.matches
1669
1666
  }), a.track("agent-message-send", {
1670
1667
  event: "success",
1671
1668
  messages: r.messages.length + 1
1672
- }), p.result && ((z = (L = t.callbacks).onNewMessage) == null || z.call(L, [...r.messages], "answer"), a.track("agent-message-received", {
1669
+ }), g.result && ((N = (L = t.callbacks).onNewMessage) == null || N.call(L, [...r.messages], "answer"), a.track("agent-message-received", {
1673
1670
  latency: X.get(!0),
1674
1671
  messages: r.messages.length
1675
- })), p;
1672
+ })), g;
1676
1673
  } catch (h) {
1677
- throw ((N = r.messages[r.messages.length - 1]) == null ? void 0 : N.role) === "assistant" && r.messages.pop(), a.track("agent-message-send", {
1674
+ throw ((F = r.messages[r.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && r.messages.pop(), a.track("agent-message-send", {
1678
1675
  event: "error",
1679
1676
  messages: r.messages.length,
1680
1677
  error: ge(h)
1681
1678
  }), h;
1682
1679
  }
1683
1680
  },
1684
- rate(l, g, y) {
1685
- var M, L, z, N;
1681
+ rate(l, p, y) {
1682
+ var M, L, N, F;
1686
1683
  const C = r.messages.find((h) => h.id === l);
1687
1684
  if (r.chat) {
1688
1685
  if (!C)
1689
- throw new $("Message not found");
1690
- } else throw new $("Chat is not initialized");
1691
- const S = ((M = C.matches) == null ? void 0 : M.map((h) => [h.document_id, h.id])) ?? [];
1686
+ throw new B("Message not found");
1687
+ } else throw new B("Chat is not initialized");
1688
+ const k = ((M = C.matches) == null ? void 0 : M.map((h) => [h.document_id, h.id])) ?? [];
1692
1689
  return a.track("agent-rate", {
1693
1690
  event: y ? "update" : "create",
1694
- thumb: g === 1 ? "up" : "down",
1691
+ thumb: p === 1 ? "up" : "down",
1695
1692
  knowledge_id: ((L = f.knowledge) == null ? void 0 : L.id) ?? "",
1696
- matches: S,
1697
- score: g
1693
+ matches: k,
1694
+ score: p
1698
1695
  }), y ? u.updateRating(f.id, r.chat.id, y, {
1699
- knowledge_id: ((z = f.knowledge) == null ? void 0 : z.id) ?? "",
1696
+ knowledge_id: ((N = f.knowledge) == null ? void 0 : N.id) ?? "",
1700
1697
  message_id: l,
1701
- matches: S,
1702
- score: g
1698
+ matches: k,
1699
+ score: p
1703
1700
  }) : u.createRating(f.id, r.chat.id, {
1704
- knowledge_id: ((N = f.knowledge) == null ? void 0 : N.id) ?? "",
1701
+ knowledge_id: ((F = f.knowledge) == null ? void 0 : F.id) ?? "",
1705
1702
  message_id: l,
1706
- matches: S,
1707
- score: g
1703
+ matches: k,
1704
+ score: p
1708
1705
  });
1709
1706
  },
1710
1707
  deleteRate(l) {
1711
1708
  if (!r.chat)
1712
- throw new $("Chat is not initialized");
1709
+ throw new B("Chat is not initialized");
1713
1710
  return a.track("agent-rate-delete", { type: "text" }), u.deleteRating(f.id, r.chat.id, l);
1714
1711
  },
1715
- submitFeedback(l, g) {
1716
- if (!r.chat)
1717
- throw new $("Chat is not initialized");
1718
- return a.track("agent-feedback", { rating: l, hasAnswer: !!g }), u.submitFeedback(f.id, r.chat.id, { rating: l, answer: g });
1719
- },
1720
1712
  async speak(l) {
1721
- var S, M, L;
1722
- function g() {
1713
+ var k, M, L;
1714
+ function p() {
1723
1715
  if (typeof l == "string") {
1724
1716
  if (!f.presenter.voice)
1725
- throw new $("Presenter voice is not initialized");
1717
+ throw new B("Presenter voice is not initialized");
1726
1718
  return {
1727
1719
  type: "text",
1728
1720
  provider: f.presenter.voice,
@@ -1732,7 +1724,7 @@ async function Ln(e, t) {
1732
1724
  }
1733
1725
  if (l.type === "text" && !l.provider) {
1734
1726
  if (!f.presenter.voice)
1735
- throw new $("Presenter voice is not initialized");
1727
+ throw new B("Presenter voice is not initialized");
1736
1728
  return {
1737
1729
  type: "text",
1738
1730
  provider: f.presenter.voice,
@@ -1742,27 +1734,27 @@ async function Ln(e, t) {
1742
1734
  }
1743
1735
  return l;
1744
1736
  }
1745
- const y = g();
1737
+ const y = p();
1746
1738
  if (a.track("agent-speak", y), X.update(), r.messages && y.type === "text" && (r.messages.push({
1747
1739
  id: ee(),
1748
1740
  role: "assistant",
1749
1741
  content: y.input,
1750
1742
  parts: ae(y.input),
1751
1743
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1752
- }), (M = (S = t.callbacks).onNewMessage) == null || M.call(S, [...r.messages], "answer")), bt(r.chatMode))
1744
+ }), (M = (k = t.callbacks).onNewMessage) == null || M.call(k, [...r.messages], "answer")), Tt(r.chatMode))
1753
1745
  return {
1754
1746
  duration: 0,
1755
1747
  video_id: "",
1756
1748
  status: "success"
1757
1749
  };
1758
1750
  if (!r.streamingManager)
1759
- throw new $("Please connect to the agent first");
1751
+ throw new B("Please connect to the agent first");
1760
1752
  return r.streamingManager.speak({
1761
1753
  script: y,
1762
1754
  metadata: { chat_id: (L = r.chat) == null ? void 0 : L.id, agent_id: f.id }
1763
1755
  });
1764
1756
  },
1765
- interrupt: b,
1757
+ interrupt: T,
1766
1758
  registerClientTool: H,
1767
1759
  unregisterClientTool: V
1768
1760
  };
@@ -1770,7 +1762,7 @@ async function Ln(e, t) {
1770
1762
  export {
1771
1763
  ie as A,
1772
1764
  G as B,
1773
- F as C,
1765
+ z as C,
1774
1766
  yt as D,
1775
1767
  Ke as H,
1776
1768
  wt as K,
@@ -1778,9 +1770,9 @@ export {
1778
1770
  mt as P,
1779
1771
  gt as R,
1780
1772
  x as S,
1781
- Se as T,
1773
+ ke as T,
1782
1774
  ft as U,
1783
- $ as V,
1775
+ B as V,
1784
1776
  ut as W,
1785
1777
  tn as a,
1786
1778
  W as b,
@@ -1791,12 +1783,12 @@ export {
1791
1783
  re as g,
1792
1784
  fn as h,
1793
1785
  Pn as i,
1794
- k as j,
1786
+ S as j,
1795
1787
  ht as k,
1796
1788
  X as l,
1797
1789
  ot as m,
1798
1790
  xn as n,
1799
- _ as o,
1791
+ b as o,
1800
1792
  ct as p,
1801
1793
  vt as q,
1802
1794
  Jt as r,
@@ -1805,7 +1797,7 @@ export {
1805
1797
  He as u,
1806
1798
  Ct as v,
1807
1799
  Ln as w,
1808
- _n as x,
1800
+ bn as x,
1809
1801
  An as y,
1810
1802
  At as z
1811
1803
  };