@d-id/client-sdk 1.1.47 → 1.1.48-staging.213

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- var nt = Object.defineProperty;
2
- var rt = (e, t, i) => t in e ? nt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
- var fe = (e, t, i) => rt(e, typeof t != "symbol" ? t + "" : t, i);
1
+ var rt = Object.defineProperty;
2
+ var it = (e, t, i) => t in e ? rt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
+ var ge = (e, t, i) => it(e, typeof t != "symbol" ? t + "" : t, i);
4
4
  class Se extends Error {
5
5
  constructor({ kind: i, description: r, error: o }) {
6
6
  super(JSON.stringify({ kind: i, description: r }));
7
- fe(this, "kind");
8
- fe(this, "description");
9
- fe(this, "error");
7
+ ge(this, "kind");
8
+ ge(this, "description");
9
+ ge(this, "error");
10
10
  this.kind = i, this.description = r, this.error = o;
11
11
  }
12
12
  }
13
- class it extends Se {
13
+ class at extends Se {
14
14
  constructor(t, i) {
15
15
  super({
16
16
  kind: "ChatCreationFailed",
@@ -18,25 +18,25 @@ class it extends Se {
18
18
  });
19
19
  }
20
20
  }
21
- class at extends Se {
21
+ class ot extends Se {
22
22
  constructor(t) {
23
23
  super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
24
24
  }
25
25
  }
26
- class ue extends Se {
26
+ class fe extends Se {
27
27
  constructor(i, r) {
28
28
  super({ kind: "ValidationError", description: i });
29
- fe(this, "key");
29
+ ge(this, "key");
30
30
  this.key = r;
31
31
  }
32
32
  }
33
- class ot extends Se {
33
+ class st extends Se {
34
34
  constructor(t) {
35
35
  super({ kind: "WSError", description: t });
36
36
  }
37
37
  }
38
- var st = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(st || {}), ct = /* @__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))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(dt || {}), ut = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(ut || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), Q = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(Q || {}), lt = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(lt || {}), mt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(mt || {}), ft = /* @__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))(ft || {}), Ue = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Ue || {});
39
- const Sn = (e) => {
38
+ var ct = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ct || {}), dt = /* @__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))(dt || {}), ut = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ut || {}), lt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(lt || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), X = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(X || {}), ft = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(ft || {}), mt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(mt || {}), gt = /* @__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))(gt || {}), Oe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Oe || {});
39
+ const kn = (e) => {
40
40
  switch (e) {
41
41
  case "clip":
42
42
  return "clip";
@@ -48,13 +48,13 @@ const Sn = (e) => {
48
48
  throw new Error(`Unknown video type: ${e}`);
49
49
  }
50
50
  };
51
- var M = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(M || {}), ne = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(ne || {}), W = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e))(W || {}), A = /* @__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))(A || {}), T = /* @__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))(T || {}), re = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(re || {}), ke = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ke || {}), gt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(gt || {}), ht = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(ht || {});
52
- const pt = 45 * 1e3, wt = "X-Playground-Chat", he = "https://api.d-id.com", yt = "wss://notifications.d-id.com", vt = "79f81a83a67430be2bc0fd61042b8faa", Ct = (...e) => {
53
- }, We = (e) => new Promise((t) => setTimeout(t, e)), le = (e = 16) => {
51
+ var C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), ne = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(ne || {}), O = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e))(O || {}), L = /* @__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))(L || {}), T = /* @__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))(T || {}), re = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(re || {}), ke = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ke || {}), ht = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ht || {}), pt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(pt || {});
52
+ const wt = 45 * 1e3, yt = "X-Playground-Chat", pe = "https://api.d-id.com", vt = "wss://notifications.d-id.com", Ct = "79f81a83a67430be2bc0fd61042b8faa", St = (...e) => {
53
+ }, He = (e) => new Promise((t) => setTimeout(t, e)), me = (e = 16) => {
54
54
  const t = new Uint8Array(e);
55
55
  return window.crypto.getRandomValues(t), Array.from(t, (i) => i.toString(16).padStart(2, "0")).join("").slice(0, 13);
56
- }, Oe = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, Ae = (e) => e === Ue.Expressive, St = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), He = (e) => e && [x.DirectPlayback, x.Off].includes(e);
57
- function kt(e, t) {
56
+ }, qe = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, _e = (e) => e === Oe.Expressive, kt = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), Qe = (e) => e && [x.DirectPlayback, x.Off].includes(e);
57
+ function Rt(e, t) {
58
58
  let i;
59
59
  return {
60
60
  promise: new Promise((o, a) => {
@@ -63,7 +63,7 @@ function kt(e, t) {
63
63
  clear: () => clearTimeout(i)
64
64
  };
65
65
  }
66
- async function Me(e, t) {
66
+ async function De(e, t) {
67
67
  const i = {
68
68
  limit: (t == null ? void 0 : t.limit) ?? 3,
69
69
  delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
@@ -78,12 +78,12 @@ async function Me(e, t) {
78
78
  try {
79
79
  if (!i.timeout)
80
80
  return await e();
81
- const { promise: a, clear: s } = kt(i.timeout, i.timeoutErrorMessage), d = e().finally(s);
81
+ const { promise: a, clear: s } = Rt(i.timeout, i.timeoutErrorMessage), d = e().finally(s);
82
82
  return await Promise.race([d, a]);
83
83
  } catch (a) {
84
84
  if (r = a, !i.shouldRetryFn(a) || o >= i.limit)
85
85
  throw a;
86
- await We(i.delayMs), i.onRetry(a);
86
+ await He(i.delayMs), i.onRetry(a);
87
87
  }
88
88
  throw r;
89
89
  }
@@ -92,43 +92,43 @@ function Ee(e) {
92
92
  return window.localStorage.setItem("did_external_key_id", e), e;
93
93
  let t = window.localStorage.getItem("did_external_key_id");
94
94
  if (!t) {
95
- let i = le();
95
+ let i = me();
96
96
  window.localStorage.setItem("did_external_key_id", i), t = i;
97
97
  }
98
98
  return t;
99
99
  }
100
- let Rt = le();
101
- function qe(e, t) {
100
+ let Dt = me();
101
+ function Xe(e, t) {
102
102
  if (e.type === "bearer")
103
103
  return `Bearer ${e.token}`;
104
104
  if (e.type === "basic")
105
105
  return `Basic ${btoa(`${e.username}:${e.password}`)}`;
106
106
  if (e.type === "key")
107
- return `Client-Key ${e.clientKey}.${Ee(t)}_${Rt}`;
107
+ return `Client-Key ${e.clientKey}.${Ee(t)}_${Dt}`;
108
108
  throw new Error(`Unknown auth type: ${e}`);
109
109
  }
110
- const Dt = (e) => Me(e, {
110
+ const Et = (e) => De(e, {
111
111
  limit: 3,
112
112
  delayMs: 1e3,
113
113
  timeout: 0,
114
114
  shouldRetryFn: (t) => t.status === 429
115
115
  });
116
- function Pe(e, t = he, i, r) {
116
+ function Ae(e, t = pe, i, r) {
117
117
  const o = async (a, s) => {
118
- const { skipErrorHandler: d, ...n } = s || {}, c = await Dt(
118
+ const { skipErrorHandler: d, ...n } = s || {}, c = await Et(
119
119
  () => fetch(t + (a != null && a.startsWith("/") ? a : `/${a}`), {
120
120
  ...n,
121
121
  headers: {
122
122
  ...n.headers,
123
- Authorization: qe(e, r),
123
+ Authorization: Xe(e, r),
124
124
  "Content-Type": "application/json"
125
125
  }
126
126
  })
127
127
  );
128
128
  if (!c.ok) {
129
- let w = await c.text().catch(() => `Failed to fetch with status ${c.status}`);
130
- const y = new Error(w);
131
- throw i && !d && i(y, { url: a, options: n, headers: c.headers }), y;
129
+ let g = await c.text().catch(() => `Failed to fetch with status ${c.status}`);
130
+ const w = new Error(g);
131
+ throw i && !d && i(w, { url: a, options: n, headers: c.headers }), w;
132
132
  }
133
133
  return c.json();
134
134
  };
@@ -147,8 +147,8 @@ function Pe(e, t = he, i, r) {
147
147
  }
148
148
  };
149
149
  }
150
- function Mt(e, t = he, i, r) {
151
- const o = Pe(e, `${t}/agents`, i, r);
150
+ function Mt(e, t = pe, i, r) {
151
+ const o = Ae(e, `${t}/agents`, i, r);
152
152
  return {
153
153
  create(a, s) {
154
154
  return o.post("/", a, s);
@@ -185,7 +185,7 @@ function Mt(e, t = he, i, r) {
185
185
  }
186
186
  };
187
187
  }
188
- function Et(e) {
188
+ function It(e) {
189
189
  var o, a, s, d;
190
190
  const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", i = () => {
191
191
  const n = navigator.platform;
@@ -196,18 +196,18 @@ function Et(e) {
196
196
  isMobile: `${t() == "Mobile"}`,
197
197
  browser: navigator.userAgent,
198
198
  origin: window.location.origin,
199
- agentType: Oe(r),
199
+ agentType: qe(r),
200
200
  agentVoice: {
201
201
  voiceId: (a = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : a.voice_id,
202
202
  provider: (d = (s = e.presenter) == null ? void 0 : s.voice) == null ? void 0 : d.type
203
203
  }
204
204
  };
205
205
  }
206
- function It(e) {
206
+ function Tt(e) {
207
207
  var i, r, o, a, s, d;
208
208
  const t = (i = e.llm) == null ? void 0 : i.prompt_customization;
209
209
  return {
210
- agentType: Oe(e.presenter),
210
+ agentType: qe(e.presenter),
211
211
  owner_id: e.owner_id ?? "",
212
212
  promptVersion: (r = e.llm) == null ? void 0 : r.prompt_version,
213
213
  behavior: {
@@ -226,25 +226,24 @@ function It(e) {
226
226
  ...e.access === "public" ? { from: "agent-template" } : {}
227
227
  };
228
228
  }
229
- const Tt = (e) => e.reduce((t, i) => t + i, 0), xe = (e) => Tt(e) / e.length;
230
- function _t(e, t, i) {
231
- var n, c, w;
229
+ const _t = (e) => e.reduce((t, i) => t + i, 0), ze = (e) => _t(e) / e.length;
230
+ function At(e, t, i) {
231
+ var n, c, g;
232
232
  const { event: r, ...o } = e, { template: a } = (t == null ? void 0 : t.llm) || {}, { language: s } = ((n = t == null ? void 0 : t.presenter) == null ? void 0 : n.voice) || {};
233
233
  return {
234
234
  ...o,
235
235
  llm: { ...o.llm, template: a },
236
236
  script: { ...o.script, provider: { ...(c = o == null ? void 0 : o.script) == null ? void 0 : c.provider, language: s } },
237
- stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (w = t == null ? void 0 : t.presenter) == null ? void 0 : w.stitch : void 0,
237
+ stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (g = t == null ? void 0 : t.presenter) == null ? void 0 : g.stitch : void 0,
238
238
  ...i
239
239
  };
240
240
  }
241
- function Fe(e) {
241
+ function Ke(e) {
242
242
  "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
243
243
  }
244
- let De = {};
245
- const At = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
244
+ const Lt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
246
245
  function Pt(e) {
247
- const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk";
246
+ const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", i = {};
248
247
  return {
249
248
  token: e.token || "testKey",
250
249
  distinct_id: Ee(e.externalId),
@@ -254,14 +253,14 @@ function Pt(e) {
254
253
  ...e.mixpanelAdditionalProperties || {}
255
254
  },
256
255
  isEnabled: e.isEnabled ?? !0,
257
- getRandom: le,
258
- enrich(i) {
259
- this.additionalProperties = { ...this.additionalProperties, ...i };
256
+ getRandom: me,
257
+ enrich(r) {
258
+ this.additionalProperties = { ...this.additionalProperties, ...r };
260
259
  },
261
- async track(i, r, o) {
260
+ async track(r, o, a) {
262
261
  if (!this.isEnabled)
263
262
  return Promise.resolve();
264
- const { audioPath: a, ...s } = r || {}, d = o || Date.now(), n = {
263
+ const { audioPath: s, ...d } = o || {}, n = a || Date.now(), c = {
265
264
  method: "POST",
266
265
  headers: {
267
266
  "Content-Type": "application/x-www-form-urlencoded"
@@ -269,14 +268,14 @@ function Pt(e) {
269
268
  body: new URLSearchParams({
270
269
  data: JSON.stringify([
271
270
  {
272
- event: i,
271
+ event: r,
273
272
  properties: {
274
273
  ...this.additionalProperties,
275
- ...s,
274
+ ...d,
276
275
  agentId: this.agentId,
277
276
  source: t,
278
277
  token: this.token,
279
- time: d,
278
+ time: n,
280
279
  $insert_id: this.getRandom(),
281
280
  origin: window.location.href,
282
281
  "Screen Height": window.screen.height || window.innerWidth,
@@ -287,22 +286,19 @@ function Pt(e) {
287
286
  ])
288
287
  })
289
288
  };
290
- return fetch(At, {
291
- ...n,
292
- keepalive: !0
293
- }).catch((c) => console.error("Analytics tracking error:", c)), Promise.resolve();
289
+ return fetch(Lt, c).catch((g) => console.error("Analytics tracking error:", g)), Promise.resolve();
294
290
  },
295
- linkTrack(i, r, o, a) {
296
- De[i] || (De[i] = { events: {}, resolvedDependencies: [] }), a.includes(o) || a.push(o);
297
- const s = De[i];
298
- if (s.events[o] = { props: r }, s.resolvedDependencies.push(o), a.every(
299
- (n) => s.resolvedDependencies.includes(n)
291
+ linkTrack(r, o, a, s) {
292
+ i[r] || (i[r] = { events: {}, resolvedDependencies: [] }), s.includes(a) || s.push(a);
293
+ const d = i[r];
294
+ if (d.events[a] = { props: o }, d.resolvedDependencies.push(a), s.every(
295
+ (c) => d.resolvedDependencies.includes(c)
300
296
  )) {
301
- const n = a.reduce((c, w) => s.events[w] ? { ...c, ...s.events[w].props } : c, {});
302
- this.track(i, n), s.resolvedDependencies = s.resolvedDependencies.filter(
303
- (c) => !a.includes(c)
304
- ), a.forEach((c) => {
305
- delete s.events[c];
297
+ const c = s.reduce((g, w) => d.events[w] ? { ...g, ...d.events[w].props } : g, {});
298
+ this.track(r, c), d.resolvedDependencies = d.resolvedDependencies.filter(
299
+ (g) => !s.includes(g)
300
+ ), s.forEach((g) => {
301
+ delete d.events[g];
306
302
  });
307
303
  }
308
304
  }
@@ -316,22 +312,22 @@ function Le() {
316
312
  get: (t = !1) => t ? Date.now() - e : e
317
313
  };
318
314
  }
319
- const ee = Le(), Ie = Le(), ze = Le();
320
- function Qe(e) {
321
- return e === x.Playground ? { headers: { [wt]: "true" } } : {};
315
+ const te = Le(), Me = Le(), Ne = Le();
316
+ function Ye(e) {
317
+ return e === x.Playground ? { headers: { [yt]: "true" } } : {};
322
318
  }
323
- async function Xe(e, t, i, r, o = !1, a) {
319
+ async function Ge(e, t, i, r, o = !1, a) {
324
320
  try {
325
- return !a && !He(r) && (a = await t.newChat(e.id, { persist: o }, Qe(r)), i.track("agent-chat", {
321
+ return !a && !Qe(r) && (a = await t.newChat(e.id, { persist: o }, Ye(r)), i.track("agent-chat", {
326
322
  event: "created",
327
323
  chatId: a.id,
328
324
  mode: r
329
325
  })), { chat: a, chatMode: (a == null ? void 0 : a.chat_mode) ?? r };
330
326
  } catch (s) {
331
- throw Lt(s) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
327
+ throw bt(s) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
332
328
  }
333
329
  }
334
- const Lt = (e) => {
330
+ const bt = (e) => {
335
331
  try {
336
332
  const t = JSON.parse(e.message);
337
333
  return t == null ? void 0 : t.kind;
@@ -339,19 +335,19 @@ const Lt = (e) => {
339
335
  return "UnknownError";
340
336
  }
341
337
  };
342
- function bt(e) {
338
+ function jt(e) {
343
339
  return e && e.length > 0 ? e : [];
344
340
  }
345
- function jt(e, t, i, r) {
346
- const o = Pe(e, `${t}/v2/agents/${i}`, r);
341
+ function $t(e, t, i, r) {
342
+ const o = Ae(e, `${t}/v2/agents/${i}`, r);
347
343
  return {
348
344
  async createStream(a) {
349
345
  return o.post("/sessions", a);
350
346
  }
351
347
  };
352
348
  }
353
- const Ye = (e, t) => (i, r) => e && console.log(`[${t}] ${i}`, r ?? "");
354
- function $t(e, t, i) {
349
+ const Ze = (e, t) => (i, r) => e && console.log(`[${t}] ${i}`, r ?? "");
350
+ function Bt(e, t, i) {
355
351
  const r = (t.timestamp - e.timestamp) / 1e3;
356
352
  return {
357
353
  duration: r,
@@ -371,7 +367,7 @@ function $t(e, t, i) {
371
367
  lowFpsCount: i
372
368
  };
373
369
  }
374
- function Bt(e) {
370
+ function xt(e) {
375
371
  return e.filter(
376
372
  (t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
377
373
  ).map((t) => {
@@ -382,7 +378,7 @@ function Bt(e) {
382
378
  };
383
379
  });
384
380
  }
385
- function xt(e) {
381
+ function Ft(e) {
386
382
  let t = "", i = 0;
387
383
  for (const r of e.values()) {
388
384
  if (r && r.type === "codec" && r.mimeType.startsWith("video") && (t = r.mimeType.split("/")[1]), r && r.type === "candidate-pair") {
@@ -412,7 +408,7 @@ function xt(e) {
412
408
  }
413
409
  return {};
414
410
  }
415
- function Ke(e, t, i) {
411
+ function Ve(e, t, i) {
416
412
  const r = e.map((n, c) => c === 0 ? i ? {
417
413
  timestamp: n.timestamp,
418
414
  duration: 0,
@@ -464,32 +460,32 @@ function Ke(e, t, i) {
464
460
  framesPerSecond: n.framesPerSecond,
465
461
  freezeCount: n.freezeCount - e[c - 1].freezeCount,
466
462
  freezeDuration: n.freezeDuration - e[c - 1].freezeDuration
467
- }), o = Bt(r), a = o.reduce((n, c) => n + (c.causes.includes("low fps") ? 1 : 0), 0), s = r.filter((n) => !!n.avgJitterDelayInInterval).map((n) => n.avgJitterDelayInInterval), d = r.filter((n) => !!n.rtt).map((n) => n.rtt);
463
+ }), o = xt(r), a = o.reduce((n, c) => n + (c.causes.includes("low fps") ? 1 : 0), 0), s = r.filter((n) => !!n.avgJitterDelayInInterval).map((n) => n.avgJitterDelayInInterval), d = r.filter((n) => !!n.rtt).map((n) => n.rtt);
468
464
  return {
469
465
  webRTCStats: {
470
466
  anomalies: o,
471
467
  minRtt: Math.min(...d),
472
- avgRtt: xe(d),
468
+ avgRtt: ze(d),
473
469
  maxRtt: Math.max(...d),
474
- aggregateReport: $t(e[0], e[e.length - 1], a),
470
+ aggregateReport: Bt(e[0], e[e.length - 1], a),
475
471
  minJitterDelayInInterval: Math.min(...s),
476
472
  maxJitterDelayInInterval: Math.max(...s),
477
- avgJitterDelayInInterval: xe(s)
473
+ avgJitterDelayInInterval: ze(s)
478
474
  },
479
475
  codec: e[0].codec,
480
476
  resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
481
477
  };
482
478
  }
483
- const Ce = 100, Ft = Math.max(Math.ceil(400 / Ce), 1), zt = 0.25, Kt = 0.28;
484
- function Nt() {
479
+ const Ce = 100, zt = Math.max(Math.ceil(400 / Ce), 1), Kt = 0.25, Nt = 0.28;
480
+ function Vt() {
485
481
  let e = 0, t, i, r = 0;
486
482
  return (o) => {
487
483
  for (const a of o.values())
488
484
  if (a && a.type === "inbound-rtp" && a.kind === "video") {
489
485
  const s = a.jitterBufferDelay, d = a.jitterBufferEmittedCount;
490
486
  if (i && d > i) {
491
- const w = s - t, y = d - i;
492
- r = w / y;
487
+ const g = s - t, w = d - i;
488
+ r = g / w;
493
489
  }
494
490
  t = s, i = d;
495
491
  const n = a.framesDecoded, c = n - e > 0;
@@ -498,32 +494,32 @@ function Nt() {
498
494
  return { isReceiving: !1, avgJitterDelayInInterval: r };
499
495
  };
500
496
  }
501
- function Ge(e, t, i, r, o) {
502
- let a = null, s = [], d, n = 0, c = !1, w = ne.Unknown, y = ne.Unknown, g = 0, m = 0;
503
- const P = Nt();
504
- async function U() {
505
- const E = await e();
506
- if (!E)
497
+ function et(e, t, i, r, o) {
498
+ let a = null, s = [], d, n = 0, c = !1, g = ne.Unknown, w = ne.Unknown, h = 0, f = 0;
499
+ const P = Vt();
500
+ async function J() {
501
+ const D = await e();
502
+ if (!D)
507
503
  return;
508
- const { isReceiving: C, avgJitterDelayInInterval: L, freezeCount: I } = P(E), j = xt(E);
509
- if (C)
510
- n = 0, g = I - m, y = L < zt ? ne.Strong : L > Kt && g > 1 ? ne.Weak : w, y !== w && (o == null || o(y), w = y, m += g, g = 0), c || (r == null || r(M.Start), d = s[s.length - 1], s = [], c = !0), s.push(j);
511
- else if (c && (n++, n >= Ft)) {
512
- const X = Ke(s, Ce, d);
513
- r == null || r(M.Stop, X), t() || i(), m = I, c = !1;
504
+ const { isReceiving: k, avgJitterDelayInInterval: _, freezeCount: I } = P(D), F = Ft(D);
505
+ if (k)
506
+ n = 0, h = I - f, w = _ < Kt ? ne.Strong : _ > Nt && h > 1 ? ne.Weak : g, w !== g && (o == null || o(w), g = w, f += h, h = 0), c || (r == null || r(C.Start), d = s[s.length - 1], s = [], c = !0), s.push(F);
507
+ else if (c && (n++, n >= zt)) {
508
+ const $ = Ve(s, Ce, d);
509
+ r == null || r(C.Stop, $), t() || i(), f = I, c = !1;
514
510
  }
515
511
  }
516
512
  return {
517
513
  start: () => {
518
- a || (a = setInterval(U, Ce));
514
+ a || (a = setInterval(J, Ce));
519
515
  },
520
516
  stop: () => {
521
517
  a && (clearInterval(a), a = null);
522
518
  },
523
- getReport: () => Ke(s, Ce, d)
519
+ getReport: () => Ve(s, Ce, d)
524
520
  };
525
521
  }
526
- async function Vt() {
522
+ async function Jt() {
527
523
  try {
528
524
  return await import("./livekit-client.esm-C1GRQdZY.js");
529
525
  } catch {
@@ -532,321 +528,325 @@ async function Vt() {
532
528
  );
533
529
  }
534
530
  }
535
- const Jt = {
531
+ const Ut = {
536
532
  excellent: ne.Strong,
537
533
  good: ne.Strong,
538
534
  poor: ne.Weak,
539
535
  lost: ne.Unknown,
540
536
  unknown: ne.Unknown
541
- }, ge = JSON.stringify({
537
+ }, he = JSON.stringify({
542
538
  kind: "InternalServerError",
543
539
  description: "Stream Error"
544
540
  });
545
- var be = /* @__PURE__ */ ((e) => (e.Chat = "lk.chat", e.Speak = "did.speak", e.Interrupt = "did.interrupt", e))(be || {});
546
- function Te(e, t, i) {
541
+ var Pe = /* @__PURE__ */ ((e) => (e.Chat = "lk.chat", e.Speak = "did.speak", e.Interrupt = "did.interrupt", e))(Pe || {});
542
+ function Ie(e, t, i) {
547
543
  var r, o;
548
544
  throw t("Failed to connect to LiveKit room:", e), (r = i.onConnectionStateChange) == null || r.call(i, T.Fail, "internal:init-error"), (o = i.onError) == null || o.call(i, e, { sessionId: "" }), e;
549
545
  }
550
- async function Ut(e, t, i) {
551
- var je;
552
- const r = Ye(i.debug || !1, "LiveKitStreamingManager"), { Room: o, RoomEvent: a, ConnectionState: s, Track: d } = await Vt(), { callbacks: n, auth: c, baseURL: w, analytics: y, microphoneStream: g } = i;
553
- let m = null, P = !1;
554
- const U = re.Fluent;
555
- let E = null, C = null, L = null, I = !1;
556
- m = new o({
546
+ async function Wt(e, t, i) {
547
+ var be;
548
+ const r = Ze(i.debug || !1, "LiveKitStreamingManager"), { Room: o, RoomEvent: a, ConnectionState: s, Track: d } = await Jt(), { callbacks: n, auth: c, baseURL: g, analytics: w, microphoneStream: h } = i;
549
+ let f = null, P = !1;
550
+ const J = re.Fluent;
551
+ let D = null, k = null, _ = null, I = null, F = !1;
552
+ f = new o({
557
553
  adaptiveStream: !1,
558
554
  // Must be false to use mediaStreamTrack directly
559
555
  dynacast: !0
560
556
  });
561
- let j = null;
562
- const X = 2e4;
563
- let F = W.Idle;
564
- const ce = jt(c, w || he, e, n.onError);
565
- let V, Z, u;
557
+ let $ = null;
558
+ const H = 2e4;
559
+ let Z = O.Idle;
560
+ const se = $t(c, g || pe, e, n.onError);
561
+ let N, u, S;
566
562
  try {
567
- const l = await ce.createStream({
563
+ const l = await se.createStream({
568
564
  transport_provider: ke.Livekit,
569
565
  chat_persist: t.chat_persist ?? !0
570
- }), { id: h, session_token: v, session_url: k } = l;
571
- (je = n.onStreamCreated) == null || je.call(n, { session_id: h, stream_id: h, agent_id: e }), V = h, Z = v, u = k, await m.prepareConnection(u, Z);
566
+ }), { id: p, session_token: v, session_url: M } = l;
567
+ (be = n.onStreamCreated) == null || be.call(n, { session_id: p, stream_id: p, agent_id: e }), N = p, u = v, S = M, await f.prepareConnection(S, u);
572
568
  } catch (l) {
573
- Te(l, r, n);
569
+ Ie(l, r, n);
574
570
  }
575
- if (!u || !Z || !V)
571
+ if (!S || !u || !N)
576
572
  return Promise.reject(new Error("Failed to initialize LiveKit stream"));
577
- m.on(a.ConnectionStateChanged, S).on(a.ConnectionQualityChanged, z).on(a.ParticipantConnected, b).on(a.ParticipantDisconnected, _).on(a.TrackSubscribed, K).on(a.TrackUnsubscribed, O).on(a.DataReceived, H).on(a.MediaDevicesError, $).on(a.TranscriptionReceived, R).on(a.EncryptionError, B).on(a.TrackSubscriptionFailed, Y);
578
- function R(l, h) {
573
+ f.on(a.ConnectionStateChanged, z).on(a.ConnectionQualityChanged, b).on(a.ParticipantConnected, A).on(a.ParticipantDisconnected, K).on(a.TrackSubscribed, j).on(a.TrackUnsubscribed, B).on(a.DataReceived, Y).on(a.MediaDevicesError, ie).on(a.TranscriptionReceived, R).on(a.EncryptionError, y).on(a.TrackSubscriptionFailed, m);
574
+ function R(l, p) {
579
575
  var v;
580
- h != null && h.isLocal && (ee.update(), F === W.Talking && ((v = n.onInterruptDetected) == null || v.call(n, { type: "audio" }), F = W.Idle));
576
+ p != null && p.isLocal && (te.update(), Z === O.Talking && ((v = n.onInterruptDetected) == null || v.call(n, { type: "audio" }), Z = O.Idle));
581
577
  }
582
578
  try {
583
- await m.connect(u, Z), r("LiveKit room joined successfully"), j = setTimeout(() => {
579
+ await f.connect(S, u), r("LiveKit room joined successfully"), $ = setTimeout(() => {
584
580
  var l;
585
- r("Track subscription timeout - no track subscribed within 30 seconds after connect"), j = null, y.track("connectivity-error", {
581
+ r("Track subscription timeout - no track subscribed within 30 seconds after connect"), $ = null, w.track("connectivity-error", {
586
582
  error: "Track subscription timeout",
587
- sessionId: V
588
- }), (l = n.onError) == null || l.call(n, new Error("Track subscription timeout"), { sessionId: V }), de("internal:track-subscription-timeout");
589
- }, X);
583
+ sessionId: N
584
+ }), (l = n.onError) == null || l.call(n, new Error("Track subscription timeout"), { sessionId: N }), Re("internal:track-subscription-timeout");
585
+ }, H);
590
586
  } catch (l) {
591
- Te(l, r, n);
587
+ Ie(l, r, n);
592
588
  }
593
- y.enrich({
594
- "stream-type": U
589
+ w.enrich({
590
+ "stream-type": J
595
591
  });
596
- function S(l) {
597
- var h, v, k, N;
592
+ function z(l) {
593
+ var p, v, M, U;
598
594
  switch (r("Connection state changed:", l), l) {
599
595
  case s.Connecting:
600
- r("CALLBACK: onConnectionStateChange(Connecting)"), (h = n.onConnectionStateChange) == null || h.call(n, T.Connecting, "livekit:connecting");
596
+ r("CALLBACK: onConnectionStateChange(Connecting)"), (p = n.onConnectionStateChange) == null || p.call(n, T.Connecting, "livekit:connecting");
601
597
  break;
602
598
  case s.Connected:
603
599
  r("LiveKit room connected successfully"), P = !0;
604
600
  break;
605
601
  case s.Disconnected:
606
- r("LiveKit room disconnected"), P = !1, I = !1, (v = n.onConnectionStateChange) == null || v.call(n, T.Disconnected, "livekit:disconnected");
602
+ r("LiveKit room disconnected"), P = !1, F = !1, (v = n.onConnectionStateChange) == null || v.call(n, T.Disconnected, "livekit:disconnected");
607
603
  break;
608
604
  case s.Reconnecting:
609
- r("LiveKit room reconnecting..."), (k = n.onConnectionStateChange) == null || k.call(n, T.Connecting, "livekit:reconnecting");
605
+ r("LiveKit room reconnecting..."), (M = n.onConnectionStateChange) == null || M.call(n, T.Connecting, "livekit:reconnecting");
610
606
  break;
611
607
  case s.SignalReconnecting:
612
- r("LiveKit room signal reconnecting..."), (N = n.onConnectionStateChange) == null || N.call(n, T.Connecting, "livekit:signal-reconnecting");
608
+ r("LiveKit room signal reconnecting..."), (U = n.onConnectionStateChange) == null || U.call(n, T.Connecting, "livekit:signal-reconnecting");
613
609
  break;
614
610
  }
615
611
  }
616
- function z(l, h) {
612
+ function b(l, p) {
617
613
  var v;
618
- r("Connection quality:", l), h != null && h.isLocal && ((v = n.onConnectivityStateChange) == null || v.call(n, Jt[l]));
614
+ r("Connection quality:", l), p != null && p.isLocal && ((v = n.onConnectivityStateChange) == null || v.call(n, Ut[l]));
619
615
  }
620
- function b(l) {
616
+ function A(l) {
621
617
  r("Participant connected:", l.identity);
622
618
  }
623
- function _(l) {
624
- r("Participant disconnected:", l.identity), de("livekit:participant-disconnected");
619
+ function K(l) {
620
+ r("Participant disconnected:", l.identity), Re("livekit:participant-disconnected");
625
621
  }
626
- function K(l, h, v) {
627
- var N, J, oe, me;
628
- r(`Track subscribed: ${l.kind} from ${v.identity}`), j && (clearTimeout(j), j = null, r("Track subscription timeout cleared"));
629
- const k = l.mediaStreamTrack;
630
- if (!k) {
622
+ function q() {
623
+ var l;
624
+ I !== C.Start && (r("CALLBACK: onVideoStateChange(Start)"), I = C.Start, (l = n.onVideoStateChange) == null || l.call(n, C.Start));
625
+ }
626
+ function W(l) {
627
+ var p;
628
+ I !== C.Stop && (r("CALLBACK: onVideoStateChange(Stop)"), I = C.Stop, (p = n.onVideoStateChange) == null || p.call(n, C.Stop, l));
629
+ }
630
+ function j(l, p, v) {
631
+ var U, V, ae;
632
+ r(`Track subscribed: ${l.kind} from ${v.identity}`), $ && (clearTimeout($), $ = null, r("Track subscription timeout cleared"));
633
+ const M = l.mediaStreamTrack;
634
+ if (!M) {
631
635
  r(`No mediaStreamTrack available for ${l.kind}`);
632
636
  return;
633
637
  }
634
- E ? (E.addTrack(k), r(`Added ${l.kind} track to shared MediaStream`)) : (E = new MediaStream([k]), r(`Created shared MediaStream with ${l.kind} track`)), l.kind === "video" && ((N = n.onStreamReady) == null || N.call(n), r("CALLBACK: onSrcObjectReady"), (J = n.onSrcObjectReady) == null || J.call(n, E), I || (I = !0, r("CALLBACK: onConnectionStateChange(Connected)"), (oe = n.onConnectionStateChange) == null || oe.call(n, T.Connected, "livekit:track-subscribed")), r("CALLBACK: onVideoStateChange(Start)"), (me = n.onVideoStateChange) == null || me.call(n, M.Start), L = Ge(
638
+ D ? (D.addTrack(M), r(`Added ${l.kind} track to shared MediaStream`)) : (D = new MediaStream([M]), r(`Created shared MediaStream with ${l.kind} track`)), l.kind === "video" && ((U = n.onStreamReady) == null || U.call(n), r("CALLBACK: onSrcObjectReady"), (V = n.onSrcObjectReady) == null || V.call(n, D), F || (F = !0, r("CALLBACK: onConnectionStateChange(Connected)"), (ae = n.onConnectionStateChange) == null || ae.call(n, T.Connected, "livekit:track-subscribed")), _ = et(
635
639
  () => l.getRTCStatsReport(),
636
640
  () => P,
637
- Ct,
638
- (ye, Re) => {
639
- r(`Video state change: ${ye}`);
641
+ St,
642
+ (le, ye) => {
643
+ r(`Video state change: ${le}`), le === C.Start ? q() : le === C.Stop && W(ye);
640
644
  }
641
- ), L.start());
645
+ ), _.start());
642
646
  }
643
- function O(l, h, v) {
644
- var k;
645
- if (r(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video") {
646
- const N = L == null ? void 0 : L.getReport();
647
- L == null || L.stop(), L = null, (k = n.onVideoStateChange) == null || k.call(n, M.Stop, N);
648
- }
647
+ function B(l, p, v) {
648
+ r(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video" && (W(_ == null ? void 0 : _.getReport()), _ == null || _.stop(), _ = null);
649
649
  }
650
- function H(l, h, v, k) {
651
- var J, oe, me, ye, Re, $e;
652
- const N = new TextDecoder().decode(l);
650
+ function Y(l, p, v, M) {
651
+ var V, ae, le, ye, je, $e, Be, xe;
652
+ const U = new TextDecoder().decode(l);
653
653
  try {
654
- const q = JSON.parse(N), se = k || q.subject;
655
- if (r("Data received:", { subject: se, data: q }), se === A.ChatAnswer) {
656
- const te = Q.Answer;
657
- (J = n.onMessage) == null || J.call(n, te, {
658
- event: te,
659
- ...q
654
+ const Q = JSON.parse(U), oe = M || Q.subject;
655
+ if (r("Data received:", { subject: oe, data: Q }), oe === L.ChatAnswer) {
656
+ const ee = X.Answer;
657
+ (V = n.onMessage) == null || V.call(n, ee, {
658
+ event: ee,
659
+ ...Q
660
660
  });
661
- } else if (se === A.ChatPartial) {
662
- const te = Q.Partial;
663
- (oe = n.onMessage) == null || oe.call(n, te, {
664
- event: te,
665
- ...q
661
+ } else if (oe === L.ChatPartial) {
662
+ const ee = X.Partial;
663
+ (ae = n.onMessage) == null || ae.call(n, ee, {
664
+ event: ee,
665
+ ...Q
666
666
  });
667
667
  } else if ([
668
- A.StreamVideoCreated,
669
- A.StreamVideoDone,
670
- A.StreamVideoError,
671
- A.StreamVideoRejected
672
- ].includes(se)) {
673
- F = se === A.StreamVideoCreated ? W.Talking : W.Idle, (me = n.onAgentActivityStateChange) == null || me.call(n, F);
674
- const { role: te, status: ve, ...Ze } = q, et = te ?? (h == null ? void 0 : h.identity) ?? "datachannel", tt = ve ?? se.split("/").pop() ?? "unknown", Be = { [et]: { ...Ze, status: tt } };
675
- i.debug && ((ye = q == null ? void 0 : q.metadata) != null && ye.sentiment) && (Be.sentiment = {
676
- id: q.metadata.sentiment.id,
677
- name: q.metadata.sentiment.sentiment
678
- }), (Re = n.onMessage) == null || Re.call(n, se, Be);
679
- } else if (se === A.ChatAudioTranscribed) {
680
- const te = Q.Transcribe;
681
- ($e = n.onMessage) == null || $e.call(n, te, {
682
- event: te,
683
- ...q
668
+ L.StreamVideoCreated,
669
+ L.StreamVideoDone,
670
+ L.StreamVideoError,
671
+ L.StreamVideoRejected
672
+ ].includes(oe)) {
673
+ Z = oe === L.StreamVideoCreated ? O.Talking : O.Idle, (le = n.onAgentActivityStateChange) == null || le.call(n, Z);
674
+ const ee = ((je = (ye = _ == null ? void 0 : _.getReport()) == null ? void 0 : ye.webRTCStats) == null ? void 0 : je.avgRtt) ?? 0, ve = ee > 0 ? Math.round(ee / 2 * 1e3) : 0, Fe = { ...Q, downstreamNetworkLatency: ve };
675
+ i.debug && (($e = Q == null ? void 0 : Q.metadata) != null && $e.sentiment) && (Fe.sentiment = {
676
+ id: Q.metadata.sentiment.id,
677
+ name: Q.metadata.sentiment.sentiment
678
+ }), (Be = n.onMessage) == null || Be.call(n, oe, Fe);
679
+ } else if (oe === L.ChatAudioTranscribed) {
680
+ const ee = X.Transcribe;
681
+ (xe = n.onMessage) == null || xe.call(n, ee, {
682
+ event: ee,
683
+ ...Q
684
684
  }), queueMicrotask(() => {
685
685
  var ve;
686
- (ve = n.onAgentActivityStateChange) == null || ve.call(n, W.Loading);
686
+ (ve = n.onAgentActivityStateChange) == null || ve.call(n, O.Loading);
687
687
  });
688
688
  }
689
- } catch (q) {
690
- r("Failed to parse data channel message:", q);
689
+ } catch (Q) {
690
+ r("Failed to parse data channel message:", Q);
691
691
  }
692
692
  }
693
- function $(l) {
694
- var h;
695
- r("Media devices error:", l), (h = n.onError) == null || h.call(n, new Error(ge), { sessionId: V });
693
+ function ie(l) {
694
+ var p;
695
+ r("Media devices error:", l), (p = n.onError) == null || p.call(n, new Error(he), { sessionId: N });
696
696
  }
697
- function B(l) {
698
- var h;
699
- r("Encryption error:", l), (h = n.onError) == null || h.call(n, new Error(ge), { sessionId: V });
697
+ function y(l) {
698
+ var p;
699
+ r("Encryption error:", l), (p = n.onError) == null || p.call(n, new Error(he), { sessionId: N });
700
700
  }
701
- function Y(l, h, v) {
702
- r("Track subscription failed:", { trackSid: l, participant: h, reason: v });
701
+ function m(l, p, v) {
702
+ r("Track subscription failed:", { trackSid: l, participant: p, reason: v });
703
703
  }
704
- function ie(l) {
705
- if (!m) return null;
706
- const h = m.localParticipant.audioTrackPublications;
707
- if (h) {
708
- for (const [v, k] of h)
709
- if (k.source === d.Source.Microphone && k.track) {
710
- const J = k.track.mediaStreamTrack;
711
- if (J === l || J && J.id === l.id)
712
- return k;
704
+ function E(l) {
705
+ if (!f) return null;
706
+ const p = f.localParticipant.audioTrackPublications;
707
+ if (p) {
708
+ for (const [v, M] of p)
709
+ if (M.source === d.Source.Microphone && M.track) {
710
+ const V = M.track.mediaStreamTrack;
711
+ if (V === l || V && V.id === l.id)
712
+ return M;
713
713
  }
714
714
  }
715
715
  return null;
716
716
  }
717
- function p(l) {
718
- if (!C || !C.track)
717
+ function G(l) {
718
+ if (!k || !k.track)
719
719
  return !1;
720
- const h = C.track.mediaStreamTrack;
721
- return h !== l && (h == null ? void 0 : h.id) !== l.id;
720
+ const p = k.track.mediaStreamTrack;
721
+ return p !== l && (p == null ? void 0 : p.id) !== l.id;
722
722
  }
723
- async function f(l) {
724
- var N, J;
725
- if (!P || !m)
723
+ async function ce(l) {
724
+ var U, V;
725
+ if (!P || !f)
726
726
  throw r("Room is not connected, cannot publish microphone stream"), new Error("Room is not connected");
727
- const h = l.getAudioTracks();
728
- if (h.length === 0) {
727
+ const p = l.getAudioTracks();
728
+ if (p.length === 0) {
729
729
  r("No audio track found in the provided MediaStream");
730
730
  return;
731
731
  }
732
- const v = h[0], k = ie(v);
733
- if (k) {
732
+ const v = p[0], M = E(v);
733
+ if (M) {
734
734
  r("Microphone track is already published, skipping", {
735
735
  trackId: v.id,
736
- publishedTrackId: (J = (N = k.track) == null ? void 0 : N.mediaStreamTrack) == null ? void 0 : J.id
737
- }), C = k;
736
+ publishedTrackId: (V = (U = M.track) == null ? void 0 : U.mediaStreamTrack) == null ? void 0 : V.id
737
+ }), k = M;
738
738
  return;
739
739
  }
740
- p(v) && (r("Unpublishing existing microphone track before publishing new one"), await D()), r("Publishing microphone track from provided MediaStream", { trackId: v.id });
740
+ G(v) && (r("Unpublishing existing microphone track before publishing new one"), await de()), r("Publishing microphone track from provided MediaStream", { trackId: v.id });
741
741
  try {
742
- C = await m.localParticipant.publishTrack(v, {
742
+ k = await f.localParticipant.publishTrack(v, {
743
743
  source: d.Source.Microphone
744
- }), r("Microphone track published successfully", { trackSid: C.trackSid });
745
- } catch (oe) {
746
- throw r("Failed to publish microphone track:", oe), oe;
744
+ }), r("Microphone track published successfully", { trackSid: k.trackSid });
745
+ } catch (ae) {
746
+ throw r("Failed to publish microphone track:", ae), ae;
747
747
  }
748
748
  }
749
- async function D() {
750
- if (!(!C || !C.track))
749
+ async function de() {
750
+ if (!(!k || !k.track))
751
751
  try {
752
- m && (await m.localParticipant.unpublishTrack(C.track), r("Microphone track unpublished"));
752
+ f && (await f.localParticipant.unpublishTrack(k.track), r("Microphone track unpublished"));
753
753
  } catch (l) {
754
754
  r("Error unpublishing microphone track:", l);
755
755
  } finally {
756
- C = null;
756
+ k = null;
757
757
  }
758
758
  }
759
- function G() {
760
- E && (E.getTracks().forEach((l) => l.stop()), E = null);
759
+ function we() {
760
+ D && (D.getTracks().forEach((l) => l.stop()), D = null);
761
761
  }
762
- async function ae(l, h) {
763
- var v, k;
764
- if (!P || !m) {
765
- r("Room is not connected for sending messages"), (v = n.onError) == null || v.call(n, new Error(ge), {
766
- sessionId: V
762
+ async function ue(l, p) {
763
+ var v, M;
764
+ if (!P || !f) {
765
+ r("Room is not connected for sending messages"), (v = n.onError) == null || v.call(n, new Error(he), {
766
+ sessionId: N
767
767
  });
768
768
  return;
769
769
  }
770
770
  try {
771
- await m.localParticipant.sendText(l, { topic: h }), r("Message sent successfully:", l);
772
- } catch (N) {
773
- r("Failed to send message:", N), (k = n.onError) == null || k.call(n, new Error(ge), { sessionId: V });
771
+ await f.localParticipant.sendText(l, { topic: p }), r("Message sent successfully:", l);
772
+ } catch (U) {
773
+ r("Failed to send message:", U), (M = n.onError) == null || M.call(n, new Error(he), { sessionId: N });
774
774
  }
775
775
  }
776
- async function pe(l) {
777
- var h;
776
+ async function tt(l) {
777
+ var p;
778
778
  try {
779
- const k = JSON.parse(l).topic;
780
- return ae("", k);
779
+ const M = JSON.parse(l).topic;
780
+ return ue("", M);
781
781
  } catch (v) {
782
- r("Failed to send data channel message:", v), (h = n.onError) == null || h.call(n, new Error(ge), { sessionId: V });
782
+ r("Failed to send data channel message:", v), (p = n.onError) == null || p.call(n, new Error(he), { sessionId: N });
783
783
  }
784
784
  }
785
- function we(l) {
786
- return ae(
785
+ function nt(l) {
786
+ return ue(
787
787
  l,
788
788
  "lk.chat"
789
789
  /* Chat */
790
790
  );
791
791
  }
792
- async function de(l) {
793
- var h, v;
794
- j && (clearTimeout(j), j = null), m && (await D(), (h = n.onConnectionStateChange) == null || h.call(n, T.Disconnecting, l), await m.disconnect()), G(), P = !1, I = !1, (v = n.onAgentActivityStateChange) == null || v.call(n, W.Idle), F = W.Idle;
792
+ async function Re(l) {
793
+ var p, v;
794
+ $ && (clearTimeout($), $ = null), f && (await de(), (p = n.onConnectionStateChange) == null || p.call(n, T.Disconnecting, l), await f.disconnect()), we(), P = !1, F = !1, (v = n.onAgentActivityStateChange) == null || v.call(n, O.Idle), Z = O.Idle;
795
795
  }
796
796
  return {
797
797
  speak(l) {
798
- const h = typeof l == "string" ? l : JSON.stringify(l);
799
- return ae(
800
- h,
798
+ const p = typeof l == "string" ? l : JSON.stringify(l);
799
+ return ue(
800
+ p,
801
801
  "did.speak"
802
802
  /* Speak */
803
803
  );
804
804
  },
805
- disconnect: () => de("user:disconnect"),
805
+ disconnect: () => Re("user:disconnect"),
806
806
  async reconnect() {
807
- var l, h;
808
- if ((m == null ? void 0 : m.state) === s.Connected) {
807
+ var l, p;
808
+ if ((f == null ? void 0 : f.state) === s.Connected) {
809
809
  r("Room is already connected");
810
810
  return;
811
811
  }
812
- if (!m || !u || !Z)
812
+ if (!f || !S || !u)
813
813
  throw r("Cannot reconnect: missing room, URL or token"), new Error("Cannot reconnect: session not available");
814
- r("Reconnecting to LiveKit room, state:", m.state), I = !1, (l = n.onConnectionStateChange) == null || l.call(n, T.Connecting, "user:reconnect");
814
+ r("Reconnecting to LiveKit room, state:", f.state), F = !1, (l = n.onConnectionStateChange) == null || l.call(n, T.Connecting, "user:reconnect");
815
815
  try {
816
- if (await m.connect(u, Z), r("Room reconnected"), P = !0, m.remoteParticipants.size === 0) {
817
- if (r("Waiting for agent to join..."), !await new Promise((k) => {
818
- const N = setTimeout(() => {
819
- m == null || m.off(a.ParticipantConnected, J), k(!1);
820
- }, 5e3), J = () => {
821
- clearTimeout(N), m == null || m.off(a.ParticipantConnected, J), k(!0);
816
+ if (await f.connect(S, u), r("Room reconnected"), P = !0, f.remoteParticipants.size === 0) {
817
+ if (r("Waiting for agent to join..."), !await new Promise((M) => {
818
+ const U = setTimeout(() => {
819
+ f == null || f.off(a.ParticipantConnected, V), M(!1);
820
+ }, 5e3), V = () => {
821
+ clearTimeout(U), f == null || f.off(a.ParticipantConnected, V), M(!0);
822
822
  };
823
- m == null || m.on(a.ParticipantConnected, J);
823
+ f == null || f.on(a.ParticipantConnected, V);
824
824
  }))
825
- throw r("Agent did not join within timeout"), await m.disconnect(), new Error("Agent did not rejoin the room");
825
+ throw r("Agent did not join within timeout"), await f.disconnect(), new Error("Agent did not rejoin the room");
826
826
  r("Agent joined, reconnection successful");
827
827
  }
828
828
  } catch (v) {
829
- throw r("Failed to reconnect:", v), (h = n.onConnectionStateChange) == null || h.call(n, T.Fail, "user:reconnect-failed"), v;
829
+ throw r("Failed to reconnect:", v), (p = n.onConnectionStateChange) == null || p.call(n, T.Fail, "user:reconnect-failed"), v;
830
830
  }
831
831
  },
832
- sendDataChannelMessage: pe,
833
- sendTextMessage: we,
834
- publishMicrophoneStream: f,
835
- unpublishMicrophoneStream: D,
836
- sessionId: V,
837
- streamId: V,
838
- streamType: U,
832
+ sendDataChannelMessage: tt,
833
+ sendTextMessage: nt,
834
+ publishMicrophoneStream: ce,
835
+ unpublishMicrophoneStream: de,
836
+ sessionId: N,
837
+ streamId: N,
838
+ streamType: J,
839
839
  interruptAvailable: !0,
840
840
  triggersAvailable: !1
841
841
  };
842
842
  }
843
- const Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
843
+ const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
844
844
  __proto__: null,
845
- DataChannelTopic: be,
846
- createLiveKitStreamingManager: Ut,
847
- handleInitError: Te
845
+ DataChannelTopic: Pe,
846
+ createLiveKitStreamingManager: Wt,
847
+ handleInitError: Ie
848
848
  }, Symbol.toStringTag, { value: "Module" }));
849
- function Ot(e, t, i) {
849
+ function Ht(e, t, i) {
850
850
  if (!e)
851
851
  throw new Error("Please connect to the agent first");
852
852
  if (!e.interruptAvailable)
@@ -856,52 +856,52 @@ function Ot(e, t, i) {
856
856
  if (!i)
857
857
  throw new Error("No active video to interrupt");
858
858
  }
859
- async function Ht(e, t) {
859
+ async function qt(e, t) {
860
860
  const i = {
861
- type: A.StreamInterrupt,
861
+ type: L.StreamInterrupt,
862
862
  videoId: t,
863
863
  timestamp: Date.now()
864
864
  };
865
865
  e.sendDataChannelMessage(JSON.stringify(i));
866
866
  }
867
- async function qt(e) {
867
+ async function Qt(e) {
868
868
  const t = {
869
- topic: be.Interrupt
869
+ topic: Pe.Interrupt
870
870
  };
871
871
  e.sendDataChannelMessage(JSON.stringify(t));
872
872
  }
873
- function Qt(e) {
873
+ function Xt(e) {
874
874
  return new Promise((t, i) => {
875
- const { callbacks: r, host: o, auth: a, externalId: s } = e, { onMessage: d = null, onOpen: n = null, onClose: c = null, onError: w = null } = r || {}, y = new WebSocket(`${o}?authorization=${encodeURIComponent(qe(a, s))}`);
876
- y.onmessage = d, y.onclose = c, y.onerror = (g) => {
877
- console.error(g), w == null || w("Websocket failed to connect", g), i(g);
878
- }, y.onopen = (g) => {
879
- n == null || n(g), t(y);
875
+ const { callbacks: r, host: o, auth: a, externalId: s } = e, { onMessage: d = null, onOpen: n = null, onClose: c = null, onError: g = null } = r || {}, w = new WebSocket(`${o}?authorization=${encodeURIComponent(Xe(a, s))}`);
876
+ w.onmessage = d, w.onclose = c, w.onerror = (h) => {
877
+ console.error(h), g == null || g("Websocket failed to connect", h), i(h);
878
+ }, w.onopen = (h) => {
879
+ n == null || n(h), t(w);
880
880
  };
881
881
  });
882
882
  }
883
- async function Xt(e) {
883
+ async function Yt(e) {
884
884
  const { retries: t = 1 } = e;
885
885
  let i = null;
886
886
  for (let r = 0; (i == null ? void 0 : i.readyState) !== WebSocket.OPEN; r++)
887
887
  try {
888
- i = await Qt(e);
888
+ i = await Xt(e);
889
889
  } catch (o) {
890
890
  if (r === t)
891
891
  throw o;
892
- await We(r * 500);
892
+ await He(r * 500);
893
893
  }
894
894
  return i;
895
895
  }
896
- async function Yt(e, t, i, r) {
897
- const o = i != null && i.onMessage ? [i.onMessage] : [], a = await Xt({
896
+ async function Gt(e, t, i, r) {
897
+ const o = i != null && i.onMessage ? [i.onMessage] : [], a = await Yt({
898
898
  auth: e,
899
899
  host: t,
900
900
  externalId: r,
901
901
  callbacks: {
902
902
  onError: (s) => {
903
903
  var d;
904
- return (d = i.onError) == null ? void 0 : d.call(i, new ot(s));
904
+ return (d = i.onError) == null ? void 0 : d.call(i, new st(s));
905
905
  },
906
906
  onMessage(s) {
907
907
  const d = JSON.parse(s.data);
@@ -915,7 +915,7 @@ async function Yt(e, t, i, r) {
915
915
  subscribeToEvents: (s) => o.push(s)
916
916
  };
917
917
  }
918
- function Gt(e) {
918
+ function Zt(e) {
919
919
  if (e.answer !== void 0)
920
920
  return e.answer;
921
921
  let t = 0, i = "";
@@ -923,7 +923,7 @@ function Gt(e) {
923
923
  i += e[t++];
924
924
  return i;
925
925
  }
926
- function Zt(e, t, i) {
926
+ function en(e, t, i) {
927
927
  if (!e.content)
928
928
  return;
929
929
  const r = t.messages[t.messages.length - 1];
@@ -937,17 +937,17 @@ function Zt(e, t, i) {
937
937
  };
938
938
  t.messages.push(o), i == null || i([...t.messages], "user");
939
939
  }
940
- function en(e, t, i, r, o) {
941
- if (e === Q.Transcribe && t.content) {
942
- Zt(t, r, o);
940
+ function tn(e, t, i, r, o) {
941
+ if (e === X.Transcribe && t.content) {
942
+ en(t, r, o);
943
943
  return;
944
944
  }
945
- if (!(e === Q.Partial || e === Q.Answer))
945
+ if (!(e === X.Partial || e === X.Answer))
946
946
  return;
947
947
  const a = r.messages[r.messages.length - 1];
948
948
  let s;
949
949
  if (a != null && a.transcribed && a.role === "user")
950
- e === Q.Answer && t.content, s = {
950
+ e === X.Answer && t.content, s = {
951
951
  id: t.id || `assistant-${Date.now()}`,
952
952
  role: t.role || "assistant",
953
953
  content: t.content || "",
@@ -958,48 +958,49 @@ function en(e, t, i, r, o) {
958
958
  else
959
959
  return;
960
960
  const { content: d, sequence: n } = t;
961
- e === Q.Partial ? i[n] = d : i.answer = d;
962
- const c = Gt(i);
963
- (s.content !== c || e === Q.Answer) && (s.content = c, o == null || o([...r.messages], e));
961
+ e === X.Partial ? i[n] = d : i.answer = d;
962
+ const c = Zt(i);
963
+ (s.content !== c || e === X.Answer) && (s.content = c, o == null || o([...r.messages], e));
964
964
  }
965
- function tn(e, t, i, r, o) {
965
+ function nn(e, t, i, r, o) {
966
966
  let a = {};
967
967
  const s = () => a = {};
968
968
  let d = "answer";
969
- const n = (c, w) => {
970
- var y, g;
971
- w === "user" && s(), d = w, (g = (y = i.callbacks).onNewMessage) == null || g.call(y, c, w);
969
+ const n = (c, g) => {
970
+ var w, h;
971
+ g === "user" && s(), d = g, (h = (w = i.callbacks).onNewMessage) == null || h.call(w, c, g);
972
972
  };
973
973
  return {
974
974
  clearQueue: s,
975
- onMessage: (c, w) => {
976
- var y, g;
977
- if ("content" in w) {
978
- const m = c === A.ChatAnswer ? Q.Answer : c === A.ChatAudioTranscribed ? Q.Transcribe : c;
979
- en(m, w, a, t, n), m === Q.Answer && e.track("agent-message-received", {
975
+ onMessage: (c, g) => {
976
+ var w, h;
977
+ if ("content" in g) {
978
+ const f = c === L.ChatAnswer ? X.Answer : c === L.ChatAudioTranscribed ? X.Transcribe : c;
979
+ tn(f, g, a, t, n), f === X.Answer && e.track("agent-message-received", {
980
+ content: g.content,
980
981
  messages: t.messages.length,
981
982
  mode: t.chatMode
982
983
  });
983
984
  } else {
984
- const m = A, P = [m.StreamVideoDone, m.StreamVideoError, m.StreamVideoRejected], U = [m.StreamFailed, m.StreamVideoError, m.StreamVideoRejected], E = _t(w, r, { mode: t.chatMode });
985
- if (c = c, c === m.StreamVideoCreated && (e.linkTrack("agent-video", E, m.StreamVideoCreated, ["start"]), w.sentiment)) {
986
- const C = t.messages[t.messages.length - 1];
987
- if ((C == null ? void 0 : C.role) === "assistant") {
988
- const L = { ...C, sentiment: w.sentiment };
989
- t.messages[t.messages.length - 1] = L, n == null || n([...t.messages], d);
985
+ const f = L, P = [f.StreamVideoDone, f.StreamVideoError, f.StreamVideoRejected], J = [f.StreamFailed, f.StreamVideoError, f.StreamVideoRejected], D = At(g, r, { mode: t.chatMode });
986
+ if (c = c, c === f.StreamVideoCreated && (e.linkTrack("agent-video", D, f.StreamVideoCreated, ["start"]), g.sentiment)) {
987
+ const k = t.messages[t.messages.length - 1];
988
+ if ((k == null ? void 0 : k.role) === "assistant") {
989
+ const _ = { ...k, sentiment: g.sentiment };
990
+ t.messages[t.messages.length - 1] = _, n == null || n([...t.messages], d);
990
991
  }
991
992
  }
992
993
  if (P.includes(c)) {
993
- const C = c.split("/")[1];
994
- U.includes(c) ? e.track("agent-video", { ...E, event: C }) : e.linkTrack("agent-video", { ...E, event: C }, c, ["done"]);
994
+ const k = c.split("/")[1];
995
+ J.includes(c) ? e.track("agent-video", { ...D, event: k }) : e.linkTrack("agent-video", { ...D, event: k }, c, ["done"]);
995
996
  }
996
- U.includes(c) && ((g = (y = i.callbacks).onError) == null || g.call(y, new Error(`Stream failed with event ${c}`), { data: w })), w.event === m.StreamDone && o();
997
+ J.includes(c) && ((h = (w = i.callbacks).onError) == null || h.call(w, new Error(`Stream failed with event ${c}`), { data: g })), g.event === f.StreamDone && o();
997
998
  }
998
999
  }
999
1000
  };
1000
1001
  }
1001
- function nn(e, t, i, r) {
1002
- const o = Pe(e, `${t}/agents/${i}`, r);
1002
+ function rn(e, t, i, r) {
1003
+ const o = Ae(e, `${t}/agents/${i}`, r);
1003
1004
  return {
1004
1005
  createStream(a, s) {
1005
1006
  return o.post("/streams", a, { signal: s });
@@ -1035,8 +1036,8 @@ function nn(e, t, i, r) {
1035
1036
  }
1036
1037
  };
1037
1038
  }
1038
- const rn = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
1039
- function Ne(e) {
1039
+ const an = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
1040
+ function Je(e) {
1040
1041
  switch (e) {
1041
1042
  case "connected":
1042
1043
  return T.Connected;
@@ -1056,7 +1057,7 @@ function Ne(e) {
1056
1057
  return T.New;
1057
1058
  }
1058
1059
  }
1059
- const an = (e) => (t) => {
1060
+ const on = (e) => (t) => {
1060
1061
  const [i, r = ""] = t.split(/:(.+)/);
1061
1062
  try {
1062
1063
  const o = JSON.parse(r);
@@ -1065,16 +1066,16 @@ const an = (e) => (t) => {
1065
1066
  return e("Failed to parse data channel message, returning data as string", { subject: i, rawData: r, error: o }), { subject: i, data: r };
1066
1067
  }
1067
1068
  };
1068
- function on({
1069
+ function sn({
1069
1070
  statsSignal: e,
1070
1071
  dataChannelSignal: t,
1071
1072
  onVideoStateChange: i,
1072
1073
  report: r,
1073
1074
  log: o
1074
1075
  }) {
1075
- e === M.Start && t === M.Start ? (o("CALLBACK: onVideoStateChange(Start)"), i == null || i(M.Start)) : e === M.Stop && t === M.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), i == null || i(M.Stop, r));
1076
+ e === C.Start && t === C.Start ? (o("CALLBACK: onVideoStateChange(Start)"), i == null || i(C.Start)) : e === C.Stop && t === C.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), i == null || i(C.Stop, r));
1076
1077
  }
1077
- function sn({
1078
+ function cn({
1078
1079
  statsSignal: e,
1079
1080
  dataChannelSignal: t,
1080
1081
  onVideoStateChange: i,
@@ -1082,9 +1083,9 @@ function sn({
1082
1083
  report: o,
1083
1084
  log: a
1084
1085
  }) {
1085
- e === M.Start ? (a("CALLBACK: onVideoStateChange(Start)"), i == null || i(M.Start)) : e === M.Stop && (a("CALLBACK: onVideoStateChange(Stop)"), i == null || i(M.Stop, o)), t === M.Start ? r == null || r(W.Talking) : t === M.Stop && (r == null || r(W.Idle));
1086
+ e === C.Start ? (a("CALLBACK: onVideoStateChange(Start)"), i == null || i(C.Start)) : e === C.Stop && (a("CALLBACK: onVideoStateChange(Stop)"), i == null || i(C.Stop, o)), t === C.Start ? r == null || r(O.Talking) : t === C.Stop && (r == null || r(O.Idle));
1086
1087
  }
1087
- function Ve({
1088
+ function Ue({
1088
1089
  statsSignal: e,
1089
1090
  dataChannelSignal: t,
1090
1091
  onVideoStateChange: i,
@@ -1093,7 +1094,7 @@ function Ve({
1093
1094
  report: a,
1094
1095
  log: s
1095
1096
  }) {
1096
- o === re.Legacy ? on({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: i, report: a, log: s }) : o === re.Fluent && sn({
1097
+ o === re.Legacy ? sn({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: i, report: a, log: s }) : o === re.Fluent && cn({
1097
1098
  statsSignal: e,
1098
1099
  dataChannelSignal: t,
1099
1100
  onVideoStateChange: i,
@@ -1102,189 +1103,189 @@ function Ve({
1102
1103
  log: s
1103
1104
  });
1104
1105
  }
1105
- async function cn(e, t, { debug: i = !1, callbacks: r, auth: o, baseURL: a = he, analytics: s }, d) {
1106
+ async function dn(e, t, { debug: i = !1, callbacks: r, auth: o, baseURL: a = pe, analytics: s }, d) {
1106
1107
  var ie;
1107
- const n = Ye(i, "WebRTCStreamingManager"), c = an(n);
1108
- let w = !1, y = !1, g = M.Stop, m = M.Stop;
1109
- const { startConnection: P, sendStreamRequest: U, close: E, createStream: C, addIceCandidate: L } = nn(
1108
+ const n = Ze(i, "WebRTCStreamingManager"), c = on(n);
1109
+ let g = !1, w = !1, h = C.Stop, f = C.Stop;
1110
+ const { startConnection: P, sendStreamRequest: J, close: D, createStream: k, addIceCandidate: _ } = rn(
1110
1111
  o,
1111
1112
  a,
1112
1113
  e,
1113
1114
  r.onError
1114
1115
  ), {
1115
1116
  id: I,
1116
- offer: j,
1117
- ice_servers: X,
1118
- session_id: F,
1119
- fluent: ce,
1120
- interrupt_enabled: V,
1121
- triggers_enabled: Z
1122
- } = await C(t, d);
1123
- (ie = r.onStreamCreated) == null || ie.call(r, { stream_id: I, session_id: F, agent_id: e });
1124
- const u = new rn({ iceServers: X }), R = u.createDataChannel("JanusDataChannel");
1125
- if (!F)
1117
+ offer: F,
1118
+ ice_servers: $,
1119
+ session_id: H,
1120
+ fluent: Z,
1121
+ interrupt_enabled: se,
1122
+ triggers_enabled: N
1123
+ } = await k(t, d);
1124
+ (ie = r.onStreamCreated) == null || ie.call(r, { stream_id: I, session_id: H, agent_id: e });
1125
+ const u = new an({ iceServers: $ }), S = u.createDataChannel("JanusDataChannel");
1126
+ if (!H)
1126
1127
  throw new Error("Could not create session_id");
1127
- const S = ce ? re.Fluent : re.Legacy;
1128
+ const R = Z ? re.Fluent : re.Legacy;
1128
1129
  s.enrich({
1129
- "stream-type": S
1130
+ "stream-type": R
1130
1131
  });
1131
- const z = t.stream_warmup && !ce, b = () => w, _ = () => {
1132
- var p;
1133
- w = !0, y && (n("CALLBACK: onConnectionStateChange(Connected)"), (p = r.onConnectionStateChange) == null || p.call(r, T.Connected));
1134
- }, K = Ge(
1132
+ const z = t.stream_warmup && !Z, b = () => g, A = () => {
1133
+ var y;
1134
+ g = !0, w && (n("CALLBACK: onConnectionStateChange(Connected)"), (y = r.onConnectionStateChange) == null || y.call(r, T.Connected));
1135
+ }, K = et(
1135
1136
  () => u.getStats(),
1136
1137
  b,
1137
- _,
1138
- (p, f) => Ve({
1139
- statsSignal: m = p,
1140
- dataChannelSignal: S === re.Legacy ? g : void 0,
1138
+ A,
1139
+ (y, m) => Ue({
1140
+ statsSignal: f = y,
1141
+ dataChannelSignal: R === re.Legacy ? h : void 0,
1141
1142
  onVideoStateChange: r.onVideoStateChange,
1142
1143
  onAgentActivityStateChange: r.onAgentActivityStateChange,
1143
- report: f,
1144
- streamType: S,
1144
+ report: m,
1145
+ streamType: R,
1145
1146
  log: n
1146
1147
  }),
1147
- (p) => {
1148
- var f;
1149
- return (f = r.onConnectivityStateChange) == null ? void 0 : f.call(r, p);
1148
+ (y) => {
1149
+ var m;
1150
+ return (m = r.onConnectivityStateChange) == null ? void 0 : m.call(r, y);
1150
1151
  }
1151
1152
  );
1152
- K.start(), u.onicecandidate = (p) => {
1153
- var f;
1154
- n("peerConnection.onicecandidate", p);
1153
+ K.start(), u.onicecandidate = (y) => {
1154
+ var m;
1155
+ n("peerConnection.onicecandidate", y);
1155
1156
  try {
1156
- p.candidate && p.candidate.sdpMid && p.candidate.sdpMLineIndex !== null ? L(
1157
+ y.candidate && y.candidate.sdpMid && y.candidate.sdpMLineIndex !== null ? _(
1157
1158
  I,
1158
1159
  {
1159
- candidate: p.candidate.candidate,
1160
- sdpMid: p.candidate.sdpMid,
1161
- sdpMLineIndex: p.candidate.sdpMLineIndex
1160
+ candidate: y.candidate.candidate,
1161
+ sdpMid: y.candidate.sdpMid,
1162
+ sdpMLineIndex: y.candidate.sdpMLineIndex
1162
1163
  },
1163
- F,
1164
+ H,
1164
1165
  d
1165
- ) : L(I, { candidate: null }, F, d);
1166
- } catch (D) {
1167
- (f = r.onError) == null || f.call(r, D, { streamId: I });
1166
+ ) : _(I, { candidate: null }, H, d);
1167
+ } catch (E) {
1168
+ (m = r.onError) == null || m.call(r, E, { streamId: I });
1168
1169
  }
1169
- }, R.onopen = () => {
1170
- y = !0, (!z || w) && _();
1170
+ }, S.onopen = () => {
1171
+ w = !0, (!z || g) && A();
1171
1172
  };
1172
- const O = (p) => {
1173
- var f;
1174
- (f = r.onVideoIdChange) == null || f.call(r, p);
1173
+ const q = (y) => {
1174
+ var m;
1175
+ (m = r.onVideoIdChange) == null || m.call(r, y);
1175
1176
  };
1176
- function H(p, f) {
1177
- if (p === A.StreamStarted && typeof f == "object" && "metadata" in f) {
1178
- const D = f.metadata;
1179
- O(D.videoId);
1177
+ function W(y, m) {
1178
+ if (y === L.StreamStarted && typeof m == "object" && "metadata" in m) {
1179
+ const E = m.metadata;
1180
+ q(E.videoId);
1180
1181
  }
1181
- p === A.StreamDone && O(null), g = p === A.StreamStarted ? M.Start : M.Stop, Ve({
1182
- statsSignal: S === re.Legacy ? m : void 0,
1183
- dataChannelSignal: g,
1182
+ y === L.StreamDone && q(null), h = y === L.StreamStarted ? C.Start : C.Stop, Ue({
1183
+ statsSignal: R === re.Legacy ? f : void 0,
1184
+ dataChannelSignal: h,
1184
1185
  onVideoStateChange: r.onVideoStateChange,
1185
1186
  onAgentActivityStateChange: r.onAgentActivityStateChange,
1186
- streamType: S,
1187
+ streamType: R,
1187
1188
  log: n
1188
1189
  });
1189
1190
  }
1190
- function $(p, f) {
1191
+ function j(y, m) {
1191
1192
  var G;
1192
- const D = typeof f == "string" ? f : f == null ? void 0 : f.metadata;
1193
- D && s.enrich({ streamMetadata: D }), (G = r.onStreamReady) == null || G.call(r);
1193
+ const E = typeof m == "string" ? m : m == null ? void 0 : m.metadata;
1194
+ E && s.enrich({ streamMetadata: E }), (G = r.onStreamReady) == null || G.call(r);
1194
1195
  }
1195
1196
  const B = {
1196
- [A.StreamStarted]: H,
1197
- [A.StreamDone]: H,
1198
- [A.StreamReady]: $
1197
+ [L.StreamStarted]: W,
1198
+ [L.StreamDone]: W,
1199
+ [L.StreamReady]: j
1199
1200
  };
1200
- R.onmessage = (p) => {
1201
+ S.onmessage = (y) => {
1201
1202
  var G;
1202
- const { subject: f, data: D } = c(p.data);
1203
- (G = B[f]) == null || G.call(B, f, D);
1203
+ const { subject: m, data: E } = c(y.data);
1204
+ (G = B[m]) == null || G.call(B, m, E);
1204
1205
  }, u.oniceconnectionstatechange = () => {
1205
- var f;
1206
+ var m;
1206
1207
  n("peerConnection.oniceconnectionstatechange => " + u.iceConnectionState);
1207
- const p = Ne(u.iceConnectionState);
1208
- p !== T.Connected && ((f = r.onConnectionStateChange) == null || f.call(r, p));
1209
- }, u.ontrack = (p) => {
1210
- var f;
1211
- n("peerConnection.ontrack", p), n("CALLBACK: onSrcObjectReady"), (f = r.onSrcObjectReady) == null || f.call(r, p.streams[0]);
1212
- }, await u.setRemoteDescription(j), n("set remote description OK");
1208
+ const y = Je(u.iceConnectionState);
1209
+ y !== T.Connected && ((m = r.onConnectionStateChange) == null || m.call(r, y));
1210
+ }, u.ontrack = (y) => {
1211
+ var m;
1212
+ n("peerConnection.ontrack", y), n("CALLBACK: onSrcObjectReady"), (m = r.onSrcObjectReady) == null || m.call(r, y.streams[0]);
1213
+ }, await u.setRemoteDescription(F), n("set remote description OK");
1213
1214
  const Y = await u.createAnswer();
1214
- return n("create answer OK"), await u.setLocalDescription(Y), n("set local description OK"), await P(I, Y, F, d), n("start connection OK"), {
1215
+ return n("create answer OK"), await u.setLocalDescription(Y), n("set local description OK"), await P(I, Y, H, d), n("start connection OK"), {
1215
1216
  /**
1216
1217
  * Method to send request to server to get clip or talk depend on you payload
1217
1218
  * @param payload
1218
1219
  */
1219
- speak(p) {
1220
- return U(I, F, p);
1220
+ speak(y) {
1221
+ return J(I, H, y);
1221
1222
  },
1222
1223
  /**
1223
1224
  * Method to close RTC connection
1224
1225
  */
1225
1226
  async disconnect() {
1226
- var p;
1227
+ var y;
1227
1228
  if (I) {
1228
- const f = Ne(u.iceConnectionState);
1229
+ const m = Je(u.iceConnectionState);
1229
1230
  if (u) {
1230
- if (f === T.New) {
1231
+ if (m === T.New) {
1231
1232
  K.stop();
1232
1233
  return;
1233
1234
  }
1234
1235
  u.close(), u.oniceconnectionstatechange = null, u.onnegotiationneeded = null, u.onicecandidate = null, u.ontrack = null;
1235
1236
  }
1236
1237
  try {
1237
- f === T.Connected && await E(I, F).catch((D) => {
1238
+ m === T.Connected && await D(I, H).catch((E) => {
1238
1239
  });
1239
- } catch (D) {
1240
- n("Error on close stream connection", D);
1240
+ } catch (E) {
1241
+ n("Error on close stream connection", E);
1241
1242
  }
1242
- (p = r.onAgentActivityStateChange) == null || p.call(r, W.Idle), K.stop();
1243
+ (y = r.onAgentActivityStateChange) == null || y.call(r, O.Idle), K.stop();
1243
1244
  }
1244
1245
  },
1245
1246
  /**
1246
1247
  * Method to send data channel messages to the server
1247
1248
  */
1248
- sendDataChannelMessage(p) {
1249
- var f, D;
1250
- if (!w || R.readyState !== "open") {
1251
- n("Data channel is not ready for sending messages"), (f = r.onError) == null || f.call(r, new Error("Data channel is not ready for sending messages"), {
1249
+ sendDataChannelMessage(y) {
1250
+ var m, E;
1251
+ if (!g || S.readyState !== "open") {
1252
+ n("Data channel is not ready for sending messages"), (m = r.onError) == null || m.call(r, new Error("Data channel is not ready for sending messages"), {
1252
1253
  streamId: I
1253
1254
  });
1254
1255
  return;
1255
1256
  }
1256
1257
  try {
1257
- R.send(p);
1258
+ S.send(y);
1258
1259
  } catch (G) {
1259
- n("Error sending data channel message", G), (D = r.onError) == null || D.call(r, G, { streamId: I });
1260
+ n("Error sending data channel message", G), (E = r.onError) == null || E.call(r, G, { streamId: I });
1260
1261
  }
1261
1262
  },
1262
1263
  /**
1263
1264
  * Session identifier information, should be returned in the body of all streaming requests
1264
1265
  */
1265
- sessionId: F,
1266
+ sessionId: H,
1266
1267
  /**
1267
1268
  * Id of current RTC stream
1268
1269
  */
1269
1270
  streamId: I,
1270
- streamType: S,
1271
- interruptAvailable: V ?? !1,
1272
- triggersAvailable: Z ?? !1
1271
+ streamType: R,
1272
+ interruptAvailable: se ?? !1,
1273
+ triggersAvailable: N ?? !1
1273
1274
  };
1274
1275
  }
1275
- var _e = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(_e || {});
1276
- async function dn(e, t, i, r) {
1276
+ var Te = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Te || {});
1277
+ async function un(e, t, i, r) {
1277
1278
  const o = e.id;
1278
1279
  switch (t.version) {
1279
1280
  case "v1": {
1280
1281
  const { version: a, ...s } = t;
1281
- return cn(o, s, i, r);
1282
+ return dn(o, s, i, r);
1282
1283
  }
1283
1284
  case "v2": {
1284
1285
  const { version: a, ...s } = t;
1285
1286
  switch (s.transport_provider) {
1286
1287
  case ke.Livekit:
1287
- const { createLiveKitStreamingManager: d } = await Promise.resolve().then(() => Wt);
1288
+ const { createLiveKitStreamingManager: d } = await Promise.resolve().then(() => Ot);
1288
1289
  return d(o, s, i);
1289
1290
  default:
1290
1291
  throw new Error(`Unsupported transport provider: ${s.transport_provider}`);
@@ -1294,8 +1295,8 @@ async function dn(e, t, i, r) {
1294
1295
  throw new Error(`Invalid stream version: ${t.version}`);
1295
1296
  }
1296
1297
  }
1297
- const un = "cht";
1298
- function ln() {
1298
+ const ln = "cht";
1299
+ function fn() {
1299
1300
  return {
1300
1301
  transport_provider: ke.Livekit
1301
1302
  };
@@ -1313,17 +1314,17 @@ function mn(e) {
1313
1314
  fluent: t == null ? void 0 : t.fluent
1314
1315
  }, ...i && { end_user_data: i } };
1315
1316
  }
1316
- function fn(e, t) {
1317
- return Ae(e.presenter.type) ? { version: _e.V2, ...ln() } : { version: _e.V1, ...mn(t) };
1317
+ function gn(e, t) {
1318
+ return _e(e.presenter.type) ? { version: Te.V2, ...fn() } : { version: Te.V1, ...mn(t) };
1318
1319
  }
1319
- function gn(e, t, i) {
1320
+ function hn(e, t, i) {
1320
1321
  i.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
1321
1322
  }
1322
- function hn(e, t, i, r, o) {
1323
- o === re.Fluent ? pn(e, t, i, r, o) : yn(e, t, i, r, o);
1324
- }
1325
1323
  function pn(e, t, i, r, o) {
1326
- e === M.Start ? r.track("stream-session", { event: "start", "stream-type": o }) : e === M.Stop && r.track("stream-session", {
1324
+ o === re.Fluent ? wn(e, t, i, r, o) : vn(e, t, i, r, o);
1325
+ }
1326
+ function wn(e, t, i, r, o) {
1327
+ e === C.Start ? r.track("stream-session", { event: "start", "stream-type": o }) : e === C.Stop && r.track("stream-session", {
1327
1328
  event: "stop",
1328
1329
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
1329
1330
  background: t.presenter.type === "clip" && t.presenter.background,
@@ -1331,13 +1332,13 @@ function pn(e, t, i, r, o) {
1331
1332
  ...i
1332
1333
  });
1333
1334
  }
1334
- function wn(e, t, i, r) {
1335
- ee.get() <= 0 || (e === M.Start ? i.linkTrack(
1335
+ function yn(e, t, i, r) {
1336
+ te.get() <= 0 || (e === C.Start ? i.linkTrack(
1336
1337
  "agent-video",
1337
- { event: "start", latency: ee.get(!0), "stream-type": r },
1338
+ { event: "start", latency: te.get(!0), "stream-type": r },
1338
1339
  "start",
1339
- [A.StreamVideoCreated]
1340
- ) : e === M.Stop && i.linkTrack(
1340
+ [L.StreamVideoCreated]
1341
+ ) : e === C.Stop && i.linkTrack(
1341
1342
  "agent-video",
1342
1343
  {
1343
1344
  event: "stop",
@@ -1346,16 +1347,16 @@ function wn(e, t, i, r) {
1346
1347
  "stream-type": r
1347
1348
  },
1348
1349
  "done",
1349
- [A.StreamVideoDone]
1350
+ [L.StreamVideoDone]
1350
1351
  ));
1351
1352
  }
1352
- function yn(e, t, i, r, o) {
1353
- ee.get() <= 0 || (e === M.Start ? r.linkTrack(
1353
+ function vn(e, t, i, r, o) {
1354
+ te.get() <= 0 || (e === C.Start ? r.linkTrack(
1354
1355
  "agent-video",
1355
- { event: "start", latency: ee.get(!0), "stream-type": o },
1356
+ { event: "start", latency: te.get(!0), "stream-type": o },
1356
1357
  "start",
1357
- [A.StreamVideoCreated]
1358
- ) : e === M.Stop && r.linkTrack(
1358
+ [L.StreamVideoCreated]
1359
+ ) : e === C.Stop && r.linkTrack(
1359
1360
  "agent-video",
1360
1361
  {
1361
1362
  event: "stop",
@@ -1365,17 +1366,17 @@ function yn(e, t, i, r, o) {
1365
1366
  ...i
1366
1367
  },
1367
1368
  "done",
1368
- [A.StreamVideoDone]
1369
+ [L.StreamVideoDone]
1369
1370
  ));
1370
1371
  }
1371
- function Je(e, t, i, r) {
1372
- return ee.reset(), ze.update(), new Promise(async (o, a) => {
1372
+ function We(e, t, i, r) {
1373
+ return te.reset(), Ne.update(), new Promise(async (o, a) => {
1373
1374
  try {
1374
1375
  let s, d = !1;
1375
- const n = fn(e, t);
1376
+ const n = gn(e, t);
1376
1377
  i.enrich({
1377
1378
  "stream-version": n.version.toString()
1378
- }), s = await dn(
1379
+ }), s = await un(
1379
1380
  e,
1380
1381
  n,
1381
1382
  {
@@ -1383,31 +1384,31 @@ function Je(e, t, i, r) {
1383
1384
  analytics: i,
1384
1385
  callbacks: {
1385
1386
  ...t.callbacks,
1386
- onConnectionStateChange: (c, w) => {
1387
- var y, g;
1388
- (g = (y = t.callbacks).onConnectionStateChange) == null || g.call(y, c), gn(c, w, i), c === T.Connected && (s ? o(s) : d = !0);
1387
+ onConnectionStateChange: (c, g) => {
1388
+ var w, h;
1389
+ (h = (w = t.callbacks).onConnectionStateChange) == null || h.call(w, c), hn(c, g, i), c === T.Connected && (s ? o(s) : d = !0);
1389
1390
  },
1390
- onVideoStateChange: (c, w) => {
1391
- var y, g;
1392
- (g = (y = t.callbacks).onVideoStateChange) == null || g.call(y, c), hn(
1391
+ onVideoStateChange: (c, g) => {
1392
+ var w, h;
1393
+ (h = (w = t.callbacks).onVideoStateChange) == null || h.call(w, c), pn(
1393
1394
  c,
1394
1395
  e,
1395
- w,
1396
+ g,
1396
1397
  i,
1397
1398
  s.streamType
1398
1399
  );
1399
1400
  },
1400
1401
  onAgentActivityStateChange: (c) => {
1401
- var w, y;
1402
- (y = (w = t.callbacks).onAgentActivityStateChange) == null || y.call(w, c), c === W.Talking ? Ie.update() : Ie.reset(), wn(
1403
- c === W.Talking ? M.Start : M.Stop,
1402
+ var g, w;
1403
+ (w = (g = t.callbacks).onAgentActivityStateChange) == null || w.call(g, c), c === O.Talking ? Me.update() : Me.reset(), yn(
1404
+ c === O.Talking ? C.Start : C.Stop,
1404
1405
  e,
1405
1406
  i,
1406
1407
  s.streamType
1407
1408
  );
1408
1409
  },
1409
1410
  onStreamReady: () => {
1410
- const c = ze.get(!0);
1411
+ const c = Ne.get(!0);
1411
1412
  i.track("agent-chat", { event: "ready", latency: c });
1412
1413
  }
1413
1414
  }
@@ -1419,50 +1420,50 @@ function Je(e, t, i, r) {
1419
1420
  }
1420
1421
  });
1421
1422
  }
1422
- async function vn(e, t, i, r, o) {
1423
- var w, y, g, m;
1423
+ async function Cn(e, t, i, r, o) {
1424
+ var g, w, h, f;
1424
1425
  const a = async () => {
1425
- if (Ae(e.presenter.type)) {
1426
- const P = await Je(e, t, r), U = `${un}_${P.sessionId}`, E = (/* @__PURE__ */ new Date()).toISOString();
1426
+ if (_e(e.presenter.type)) {
1427
+ const P = await We(e, t, r), J = `${ln}_${P.sessionId}`, D = (/* @__PURE__ */ new Date()).toISOString();
1427
1428
  return { chatResult: {
1428
1429
  chatMode: x.Functional,
1429
1430
  chat: {
1430
- id: U,
1431
+ id: J,
1431
1432
  agent_id: e.id,
1432
1433
  owner_id: e.owner_id ?? "",
1433
- created: E,
1434
- modified: E,
1435
- agent_id__created_at: E,
1436
- agent_id__modified_at: E,
1434
+ created: D,
1435
+ modified: D,
1436
+ agent_id__created_at: D,
1437
+ agent_id__modified_at: D,
1437
1438
  chat_mode: x.Functional,
1438
1439
  messages: []
1439
1440
  }
1440
1441
  }, streamingManager: P };
1441
1442
  } else {
1442
- const P = new AbortController(), U = P.signal;
1443
- let E;
1443
+ const P = new AbortController(), J = P.signal;
1444
+ let D;
1444
1445
  try {
1445
- const C = Xe(
1446
+ const k = Ge(
1446
1447
  e,
1447
1448
  i,
1448
1449
  r,
1449
1450
  t.mode,
1450
1451
  t.persistentChat,
1451
1452
  o
1452
- ), L = Je(e, t, r, U).then((X) => (E = X, X)), [I, j] = await Promise.all([C, L]);
1453
- return { chatResult: I, streamingManager: j };
1454
- } catch (C) {
1455
- throw P.abort(), E && await E.disconnect().catch(() => {
1456
- }), C;
1453
+ ), _ = We(e, t, r, J).then(($) => (D = $, $)), [I, F] = await Promise.all([k, _]);
1454
+ return { chatResult: I, streamingManager: F };
1455
+ } catch (k) {
1456
+ throw P.abort(), D && await D.disconnect().catch(() => {
1457
+ }), k;
1457
1458
  }
1458
1459
  }
1459
1460
  }, { chatResult: s, streamingManager: d } = await a(), { chat: n, chatMode: c } = s;
1460
- return c && t.mode !== void 0 && c !== t.mode && (t.mode = c, (y = (w = t.callbacks).onModeChange) == null || y.call(w, c), c !== x.Functional) ? ((m = (g = t.callbacks).onError) == null || m.call(g, new at(c)), d == null || d.disconnect(), { chat: n }) : { chat: n, streamingManager: d };
1461
+ return c && t.mode !== void 0 && c !== t.mode && (t.mode = c, (w = (g = t.callbacks).onModeChange) == null || w.call(g, c), c !== x.Functional) ? ((f = (h = t.callbacks).onError) == null || f.call(h, new ot(c)), d == null || d.disconnect(), { chat: n }) : { chat: n, streamingManager: d };
1461
1462
  }
1462
- async function kn(e, t) {
1463
- var F, ce, V, Z;
1463
+ async function Rn(e, t) {
1464
+ var H, Z, se, N;
1464
1465
  let i = !0, r = null;
1465
- const o = t.mixpanelKey || vt, a = t.wsURL || yt, s = t.baseURL || he, d = t.mode || x.Functional, n = {
1466
+ const o = t.mixpanelKey || Ct, a = t.wsURL || vt, s = t.baseURL || pe, d = t.mode || x.Functional, n = {
1466
1467
  messages: [],
1467
1468
  chatMode: d
1468
1469
  }, c = Pt({
@@ -1471,91 +1472,91 @@ async function kn(e, t) {
1471
1472
  isEnabled: t.enableAnalitics,
1472
1473
  externalId: t.externalId,
1473
1474
  mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
1474
- }), w = Date.now();
1475
- Fe(() => {
1476
- c.track("agent-sdk", { event: "init" }, w);
1475
+ }), g = Date.now();
1476
+ Ke(() => {
1477
+ c.track("agent-sdk", { event: "init" }, g);
1477
1478
  });
1478
- const y = Mt(t.auth, s, t.callbacks.onError, t.externalId), g = await y.getById(e);
1479
- t.debug = t.debug || ((F = g == null ? void 0 : g.advanced_settings) == null ? void 0 : F.ui_debug_mode);
1480
- const m = Ae(g.presenter.type);
1481
- c.enrich(It(g));
1482
- const { onMessage: P, clearQueue: U } = tn(
1479
+ const w = Mt(t.auth, s, t.callbacks.onError, t.externalId), h = await w.getById(e);
1480
+ t.debug = t.debug || ((H = h == null ? void 0 : h.advanced_settings) == null ? void 0 : H.ui_debug_mode);
1481
+ const f = _e(h.presenter.type);
1482
+ c.enrich(Tt(h));
1483
+ const { onMessage: P, clearQueue: J } = nn(
1483
1484
  c,
1484
1485
  n,
1485
1486
  t,
1486
- g,
1487
+ h,
1487
1488
  () => {
1488
1489
  var u;
1489
1490
  return (u = n.socketManager) == null ? void 0 : u.disconnect();
1490
1491
  }
1491
1492
  );
1492
- n.messages = bt(t.initialMessages), (V = (ce = t.callbacks).onNewMessage) == null || V.call(ce, [...n.messages], "answer");
1493
- const E = (u) => {
1493
+ n.messages = jt(t.initialMessages), (se = (Z = t.callbacks).onNewMessage) == null || se.call(Z, [...n.messages], "answer");
1494
+ const D = (u) => {
1494
1495
  r = u;
1495
- }, C = ({ type: u }) => {
1496
- var S, z, b;
1497
- const R = n.messages[n.messages.length - 1];
1496
+ }, k = ({ type: u }) => {
1497
+ var R, z, b;
1498
+ const S = n.messages[n.messages.length - 1];
1498
1499
  c.track("agent-video-interrupt", {
1499
1500
  type: u || "click",
1500
- video_duration_to_interrupt: Ie.get(!0),
1501
- message_duration_to_interrupt: ee.get(!0)
1502
- }), R.interrupted = !0, (z = (S = t.callbacks).onNewMessage) == null || z.call(S, [...n.messages], "answer"), m ? qt(n.streamingManager) : (Ot(n.streamingManager, (b = n.streamingManager) == null ? void 0 : b.streamType, r), Ht(n.streamingManager, r));
1503
- }, L = Date.now();
1504
- Fe(() => {
1505
- c.track("agent-sdk", { event: "loaded", ...Et(g) }, L);
1501
+ video_duration_to_interrupt: Me.get(!0),
1502
+ message_duration_to_interrupt: te.get(!0)
1503
+ }), S.interrupted = !0, (z = (R = t.callbacks).onNewMessage) == null || z.call(R, [...n.messages], "answer"), f ? Qt(n.streamingManager) : (Ht(n.streamingManager, (b = n.streamingManager) == null ? void 0 : b.streamType, r), qt(n.streamingManager, r));
1504
+ }, _ = Date.now();
1505
+ Ke(() => {
1506
+ c.track("agent-sdk", { event: "loaded", ...It(h) }, _);
1506
1507
  });
1507
1508
  async function I(u) {
1508
- var K, O, H, $, B, Y, ie;
1509
- (O = (K = t.callbacks).onConnectionStateChange) == null || O.call(K, T.Connecting), ee.reset(), u && !i && (delete n.chat, ($ = (H = t.callbacks).onNewMessage) == null || $.call(H, [...n.messages], "answer"));
1510
- const R = d === x.DirectPlayback || m ? Promise.resolve(void 0) : Yt(
1509
+ var K, q, W, j, B, Y, ie;
1510
+ (q = (K = t.callbacks).onConnectionStateChange) == null || q.call(K, T.Connecting), te.reset(), u && !i && (delete n.chat, (j = (W = t.callbacks).onNewMessage) == null || j.call(W, [...n.messages], "answer"));
1511
+ const S = d === x.DirectPlayback || f ? Promise.resolve(void 0) : Gt(
1511
1512
  t.auth,
1512
1513
  a,
1513
1514
  { onMessage: P, onError: t.callbacks.onError },
1514
1515
  t.externalId
1515
- ), S = Me(
1516
- () => vn(
1517
- g,
1516
+ ), R = De(
1517
+ () => Cn(
1518
+ h,
1518
1519
  {
1519
1520
  ...t,
1520
1521
  mode: d,
1521
1522
  callbacks: {
1522
1523
  ...t.callbacks,
1523
- onVideoIdChange: E,
1524
+ onVideoIdChange: D,
1524
1525
  onMessage: P,
1525
- onInterruptDetected: C
1526
+ onInterruptDetected: k
1526
1527
  }
1527
1528
  },
1528
- y,
1529
+ w,
1529
1530
  c,
1530
1531
  n.chat
1531
1532
  ),
1532
1533
  {
1533
1534
  limit: 3,
1534
- timeout: pt,
1535
+ timeout: wt,
1535
1536
  timeoutErrorMessage: "Timeout initializing the stream",
1536
- shouldRetryFn: (p) => (p == null ? void 0 : p.message) !== "Could not connect" && p.status !== 429 && (p == null ? void 0 : p.message) !== "InsufficientCreditsError",
1537
+ shouldRetryFn: (y) => (y == null ? void 0 : y.message) !== "Could not connect" && y.status !== 429 && (y == null ? void 0 : y.message) !== "InsufficientCreditsError",
1537
1538
  delayMs: 1e3
1538
1539
  }
1539
- ).catch((p) => {
1540
- var f, D;
1541
- throw X(x.Maintenance), (D = (f = t.callbacks).onConnectionStateChange) == null || D.call(f, T.Fail), p;
1542
- }), [z, { streamingManager: b, chat: _ }] = await Promise.all([R, S]);
1543
- _ && _.id !== ((B = n.chat) == null ? void 0 : B.id) && ((ie = (Y = t.callbacks).onNewChat) == null || ie.call(Y, _.id)), n.streamingManager = b, n.socketManager = z, n.chat = _, i = !1, c.enrich({
1544
- chatId: _ == null ? void 0 : _.id,
1540
+ ).catch((y) => {
1541
+ var m, E;
1542
+ throw $(x.Maintenance), (E = (m = t.callbacks).onConnectionStateChange) == null || E.call(m, T.Fail), y;
1543
+ }), [z, { streamingManager: b, chat: A }] = await Promise.all([S, R]);
1544
+ A && A.id !== ((B = n.chat) == null ? void 0 : B.id) && ((ie = (Y = t.callbacks).onNewChat) == null || ie.call(Y, A.id)), n.streamingManager = b, n.socketManager = z, n.chat = A, i = !1, c.enrich({
1545
+ chatId: A == null ? void 0 : A.id,
1545
1546
  streamId: b == null ? void 0 : b.streamId,
1546
1547
  mode: n.chatMode
1547
- }), X((_ == null ? void 0 : _.chat_mode) ?? d);
1548
+ }), $((A == null ? void 0 : A.chat_mode) ?? d);
1548
1549
  }
1549
- async function j() {
1550
- var u, R, S, z;
1551
- (u = n.socketManager) == null || u.disconnect(), await ((R = n.streamingManager) == null ? void 0 : R.disconnect()), delete n.streamingManager, delete n.socketManager, (z = (S = t.callbacks).onConnectionStateChange) == null || z.call(S, T.Disconnected);
1550
+ async function F() {
1551
+ var u, S, R, z;
1552
+ (u = n.socketManager) == null || u.disconnect(), await ((S = n.streamingManager) == null ? void 0 : S.disconnect()), delete n.streamingManager, delete n.socketManager, (z = (R = t.callbacks).onConnectionStateChange) == null || z.call(R, T.Disconnected);
1552
1553
  }
1553
- async function X(u) {
1554
- var R, S;
1555
- u !== n.chatMode && (c.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await j(), (S = (R = t.callbacks).onModeChange) == null || S.call(R, u));
1554
+ async function $(u) {
1555
+ var S, R;
1556
+ u !== n.chatMode && (c.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await F(), (R = (S = t.callbacks).onModeChange) == null || R.call(S, u));
1556
1557
  }
1557
1558
  return {
1558
- agent: g,
1559
+ agent: h,
1559
1560
  getStreamType: () => {
1560
1561
  var u;
1561
1562
  return (u = n.streamingManager) == null ? void 0 : u.streamType;
@@ -1568,9 +1569,9 @@ async function kn(e, t) {
1568
1569
  var u;
1569
1570
  return ((u = n.streamingManager) == null ? void 0 : u.triggersAvailable) ?? !1;
1570
1571
  },
1571
- starterMessages: ((Z = g.knowledge) == null ? void 0 : Z.starter_message) || [],
1572
- getSTTToken: () => y.getSTTToken(g.id),
1573
- changeMode: X,
1572
+ starterMessages: ((N = h.knowledge) == null ? void 0 : N.starter_message) || [],
1573
+ getSTTToken: () => w.getSTTToken(h.id),
1574
+ changeMode: $,
1574
1575
  enrichAnalytics: c.enrich,
1575
1576
  async connect() {
1576
1577
  await I(!0), c.track("agent-chat", {
@@ -1580,31 +1581,31 @@ async function kn(e, t) {
1580
1581
  },
1581
1582
  async reconnect() {
1582
1583
  const u = n.streamingManager;
1583
- if (m && (u != null && u.reconnect)) {
1584
+ if (f && (u != null && u.reconnect)) {
1584
1585
  try {
1585
1586
  await u.reconnect(), c.track("agent-chat", {
1586
1587
  event: "reconnect",
1587
1588
  mode: n.chatMode
1588
1589
  });
1589
1590
  } catch {
1590
- await j(), await I(!1);
1591
+ await F(), await I(!1);
1591
1592
  }
1592
1593
  return;
1593
1594
  }
1594
- await j(), await I(!1), c.track("agent-chat", {
1595
+ await F(), await I(!1), c.track("agent-chat", {
1595
1596
  event: "reconnect",
1596
1597
  mode: n.chatMode
1597
1598
  });
1598
1599
  },
1599
1600
  async disconnect() {
1600
- await j(), c.track("agent-chat", {
1601
+ await F(), c.track("agent-chat", {
1601
1602
  event: "disconnect",
1602
1603
  mode: n.chatMode
1603
1604
  });
1604
1605
  },
1605
1606
  async publishMicrophoneStream(u) {
1606
- var R;
1607
- if (!((R = n.streamingManager) != null && R.publishMicrophoneStream))
1607
+ var S;
1608
+ if (!((S = n.streamingManager) != null && S.publishMicrophoneStream))
1608
1609
  throw new Error("publishMicrophoneStream is not available for this streaming manager");
1609
1610
  return n.streamingManager.publishMicrophoneStream(u);
1610
1611
  },
@@ -1615,80 +1616,80 @@ async function kn(e, t) {
1615
1616
  return n.streamingManager.unpublishMicrophoneStream();
1616
1617
  },
1617
1618
  async chat(u) {
1618
- var b, _, K, O, H;
1619
- const R = () => {
1620
- if (He(d))
1621
- throw new ue(`${d} is enabled, chat is disabled`);
1619
+ var b, A, K, q, W;
1620
+ const S = () => {
1621
+ if (Qe(d))
1622
+ throw new fe(`${d} is enabled, chat is disabled`);
1622
1623
  if (u.length >= 800)
1623
- throw new ue("Message cannot be more than 800 characters");
1624
+ throw new fe("Message cannot be more than 800 characters");
1624
1625
  if (u.length === 0)
1625
- throw new ue("Message cannot be empty");
1626
+ throw new fe("Message cannot be empty");
1626
1627
  if (n.chatMode === x.Maintenance)
1627
- throw new ue("Chat is in maintenance mode");
1628
+ throw new fe("Chat is in maintenance mode");
1628
1629
  if (![x.TextOnly, x.Playground].includes(n.chatMode)) {
1629
1630
  if (!n.streamingManager)
1630
- throw new ue("Streaming manager is not initialized");
1631
+ throw new fe("Streaming manager is not initialized");
1631
1632
  if (!n.chat)
1632
- throw new ue("Chat is not initialized");
1633
+ throw new fe("Chat is not initialized");
1633
1634
  }
1634
- }, S = async () => {
1635
- var $, B;
1635
+ }, R = async () => {
1636
+ var j, B;
1636
1637
  if (!n.chat) {
1637
- const Y = await Xe(
1638
- g,
1639
- y,
1638
+ const Y = await Ge(
1639
+ h,
1640
+ w,
1640
1641
  c,
1641
1642
  n.chatMode,
1642
1643
  t.persistentChat
1643
1644
  );
1644
1645
  if (!Y.chat)
1645
- throw new it(n.chatMode, !!t.persistentChat);
1646
- n.chat = Y.chat, (B = ($ = t.callbacks).onNewChat) == null || B.call($, n.chat.id);
1646
+ throw new at(n.chatMode, !!t.persistentChat);
1647
+ n.chat = Y.chat, (B = (j = t.callbacks).onNewChat) == null || B.call(j, n.chat.id);
1647
1648
  }
1648
1649
  return n.chat.id;
1649
- }, z = async ($, B) => {
1650
+ }, z = async (j, B) => {
1650
1651
  const Y = n.chatMode === x.Playground;
1651
- return Me(m && !Y ? async () => {
1652
- var f, D;
1653
- return await ((D = (f = n.streamingManager) == null ? void 0 : f.sendTextMessage) == null ? void 0 : D.call(f, u)), Promise.resolve({});
1652
+ return De(f && !Y ? async () => {
1653
+ var m, E;
1654
+ return await ((E = (m = n.streamingManager) == null ? void 0 : m.sendTextMessage) == null ? void 0 : E.call(m, u)), Promise.resolve({});
1654
1655
  } : async () => {
1655
- var f, D;
1656
- return y.chat(
1657
- g.id,
1656
+ var m, E;
1657
+ return w.chat(
1658
+ h.id,
1658
1659
  B,
1659
1660
  {
1660
1661
  chatMode: n.chatMode,
1661
- streamId: (f = n.streamingManager) == null ? void 0 : f.streamId,
1662
- sessionId: (D = n.streamingManager) == null ? void 0 : D.sessionId,
1663
- messages: $.map(({ matches: G, ...ae }) => ae)
1662
+ streamId: (m = n.streamingManager) == null ? void 0 : m.streamId,
1663
+ sessionId: (E = n.streamingManager) == null ? void 0 : E.sessionId,
1664
+ messages: j.map(({ matches: G, ...ce }) => ce)
1664
1665
  },
1665
1666
  {
1666
- ...Qe(n.chatMode),
1667
+ ...Ye(n.chatMode),
1667
1668
  skipErrorHandler: !0
1668
1669
  }
1669
1670
  );
1670
1671
  }, {
1671
1672
  limit: 2,
1672
- shouldRetryFn: (f) => {
1673
- var ae, pe, we, de;
1674
- const D = (ae = f == null ? void 0 : f.message) == null ? void 0 : ae.includes("missing or invalid session_id");
1675
- return !((pe = f == null ? void 0 : f.message) == null ? void 0 : pe.includes("Stream Error")) && !D ? ((de = (we = t.callbacks).onError) == null || de.call(we, f), !1) : !0;
1673
+ shouldRetryFn: (m) => {
1674
+ var ce, de, we, ue;
1675
+ const E = (ce = m == null ? void 0 : m.message) == null ? void 0 : ce.includes("missing or invalid session_id");
1676
+ return !((de = m == null ? void 0 : m.message) == null ? void 0 : de.includes("Stream Error")) && !E ? ((ue = (we = t.callbacks).onError) == null || ue.call(we, m), !1) : !0;
1676
1677
  },
1677
1678
  onRetry: async () => {
1678
- await j(), await I(!1);
1679
+ await F(), await I(!1);
1679
1680
  }
1680
1681
  });
1681
1682
  };
1682
1683
  try {
1683
- U(), R(), n.messages.push({
1684
- id: le(),
1684
+ J(), S(), n.messages.push({
1685
+ id: me(),
1685
1686
  role: "user",
1686
1687
  content: u,
1687
- created_at: new Date(ee.update()).toISOString()
1688
- }), (_ = (b = t.callbacks).onNewMessage) == null || _.call(b, [...n.messages], "user");
1689
- const $ = await S(), B = await z([...n.messages], $);
1688
+ created_at: new Date(te.update()).toISOString()
1689
+ }), (A = (b = t.callbacks).onNewMessage) == null || A.call(b, [...n.messages], "user");
1690
+ const j = await R(), B = await z([...n.messages], j);
1690
1691
  return n.messages.push({
1691
- id: le(),
1692
+ id: me(),
1692
1693
  role: "assistant",
1693
1694
  content: B.result || "",
1694
1695
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1697,80 +1698,80 @@ async function kn(e, t) {
1697
1698
  }), c.track("agent-message-send", {
1698
1699
  event: "success",
1699
1700
  messages: n.messages.length + 1
1700
- }), B.result && ((O = (K = t.callbacks).onNewMessage) == null || O.call(K, [...n.messages], "answer"), c.track("agent-message-received", {
1701
- latency: ee.get(!0),
1701
+ }), B.result && ((q = (K = t.callbacks).onNewMessage) == null || q.call(K, [...n.messages], "answer"), c.track("agent-message-received", {
1702
+ latency: te.get(!0),
1702
1703
  messages: n.messages.length
1703
1704
  })), B;
1704
- } catch ($) {
1705
- throw ((H = n.messages[n.messages.length - 1]) == null ? void 0 : H.role) === "assistant" && n.messages.pop(), c.track("agent-message-send", {
1705
+ } catch (j) {
1706
+ throw ((W = n.messages[n.messages.length - 1]) == null ? void 0 : W.role) === "assistant" && n.messages.pop(), c.track("agent-message-send", {
1706
1707
  event: "error",
1707
1708
  messages: n.messages.length
1708
- }), $;
1709
+ }), j;
1709
1710
  }
1710
1711
  },
1711
- rate(u, R, S) {
1712
- var _, K, O, H;
1713
- const z = n.messages.find(($) => $.id === u);
1712
+ rate(u, S, R) {
1713
+ var A, K, q, W;
1714
+ const z = n.messages.find((j) => j.id === u);
1714
1715
  if (n.chat) {
1715
1716
  if (!z)
1716
1717
  throw new Error("Message not found");
1717
1718
  } else throw new Error("Chat is not initialized");
1718
- const b = ((_ = z.matches) == null ? void 0 : _.map(($) => [$.document_id, $.id])) ?? [];
1719
+ const b = ((A = z.matches) == null ? void 0 : A.map((j) => [j.document_id, j.id])) ?? [];
1719
1720
  return c.track("agent-rate", {
1720
- event: S ? "update" : "create",
1721
- thumb: R === 1 ? "up" : "down",
1722
- knowledge_id: ((K = g.knowledge) == null ? void 0 : K.id) ?? "",
1721
+ event: R ? "update" : "create",
1722
+ thumb: S === 1 ? "up" : "down",
1723
+ knowledge_id: ((K = h.knowledge) == null ? void 0 : K.id) ?? "",
1723
1724
  matches: b,
1724
- score: R
1725
- }), S ? y.updateRating(g.id, n.chat.id, S, {
1726
- knowledge_id: ((O = g.knowledge) == null ? void 0 : O.id) ?? "",
1725
+ score: S
1726
+ }), R ? w.updateRating(h.id, n.chat.id, R, {
1727
+ knowledge_id: ((q = h.knowledge) == null ? void 0 : q.id) ?? "",
1727
1728
  message_id: u,
1728
1729
  matches: b,
1729
- score: R
1730
- }) : y.createRating(g.id, n.chat.id, {
1731
- knowledge_id: ((H = g.knowledge) == null ? void 0 : H.id) ?? "",
1730
+ score: S
1731
+ }) : w.createRating(h.id, n.chat.id, {
1732
+ knowledge_id: ((W = h.knowledge) == null ? void 0 : W.id) ?? "",
1732
1733
  message_id: u,
1733
1734
  matches: b,
1734
- score: R
1735
+ score: S
1735
1736
  });
1736
1737
  },
1737
1738
  deleteRate(u) {
1738
1739
  if (!n.chat)
1739
1740
  throw new Error("Chat is not initialized");
1740
- return c.track("agent-rate-delete", { type: "text" }), y.deleteRating(g.id, n.chat.id, u);
1741
+ return c.track("agent-rate-delete", { type: "text" }), w.deleteRating(h.id, n.chat.id, u);
1741
1742
  },
1742
1743
  async speak(u) {
1743
- var b, _, K;
1744
- function R() {
1744
+ var b, A, K;
1745
+ function S() {
1745
1746
  if (typeof u == "string") {
1746
- if (!g.presenter.voice)
1747
+ if (!h.presenter.voice)
1747
1748
  throw new Error("Presenter voice is not initialized");
1748
1749
  return {
1749
1750
  type: "text",
1750
- provider: g.presenter.voice,
1751
+ provider: h.presenter.voice,
1751
1752
  input: u,
1752
1753
  ssml: !1
1753
1754
  };
1754
1755
  }
1755
1756
  if (u.type === "text" && !u.provider) {
1756
- if (!g.presenter.voice)
1757
+ if (!h.presenter.voice)
1757
1758
  throw new Error("Presenter voice is not initialized");
1758
1759
  return {
1759
1760
  type: "text",
1760
- provider: g.presenter.voice,
1761
+ provider: h.presenter.voice,
1761
1762
  input: u.input,
1762
1763
  ssml: u.ssml
1763
1764
  };
1764
1765
  }
1765
1766
  return u;
1766
1767
  }
1767
- const S = R();
1768
- if (c.track("agent-speak", S), ee.update(), n.messages && S.type === "text" && (n.messages.push({
1769
- id: le(),
1768
+ const R = S();
1769
+ if (c.track("agent-speak", R), te.update(), n.messages && R.type === "text" && (n.messages.push({
1770
+ id: me(),
1770
1771
  role: "assistant",
1771
- content: S.input,
1772
+ content: R.input,
1772
1773
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1773
- }), (_ = (b = t.callbacks).onNewMessage) == null || _.call(b, [...n.messages], "answer")), St(n.chatMode))
1774
+ }), (A = (b = t.callbacks).onNewMessage) == null || A.call(b, [...n.messages], "answer")), kt(n.chatMode))
1774
1775
  return {
1775
1776
  duration: 0,
1776
1777
  video_id: "",
@@ -1779,37 +1780,37 @@ async function kn(e, t) {
1779
1780
  if (!n.streamingManager)
1780
1781
  throw new Error("Please connect to the agent first");
1781
1782
  return n.streamingManager.speak({
1782
- script: S,
1783
- metadata: { chat_id: (K = n.chat) == null ? void 0 : K.id, agent_id: g.id }
1783
+ script: R,
1784
+ metadata: { chat_id: (K = n.chat) == null ? void 0 : K.id, agent_id: h.id }
1784
1785
  });
1785
1786
  },
1786
- interrupt: C
1787
+ interrupt: k
1787
1788
  };
1788
1789
  }
1789
1790
  export {
1790
- W as AgentActivityState,
1791
- dt as AgentStatus,
1792
- it as ChatCreationFailed,
1791
+ O as AgentActivityState,
1792
+ ut as AgentStatus,
1793
+ at as ChatCreationFailed,
1793
1794
  x as ChatMode,
1794
- at as ChatModeDowngraded,
1795
- Q as ChatProgress,
1795
+ ot as ChatModeDowngraded,
1796
+ X as ChatProgress,
1796
1797
  T as ConnectionState,
1797
1798
  ne as ConnectivityState,
1798
- ft as DocumentType,
1799
+ gt as DocumentType,
1799
1800
  mt as KnowledgeType,
1800
- ct as PlanGroup,
1801
- gt as Providers,
1802
- ut as RateState,
1803
- A as StreamEvents,
1801
+ dt as PlanGroup,
1802
+ ht as Providers,
1803
+ lt as RateState,
1804
+ L as StreamEvents,
1804
1805
  re as StreamType,
1805
- M as StreamingState,
1806
- lt as Subject,
1806
+ C as StreamingState,
1807
+ ft as Subject,
1807
1808
  ke as TransportProvider,
1808
- st as UserPlan,
1809
- ue as ValidationError,
1810
- Ue as VideoType,
1811
- ht as VoiceAccess,
1812
- ot as WsError,
1813
- kn as createAgentManager,
1814
- Sn as mapVideoType
1809
+ ct as UserPlan,
1810
+ fe as ValidationError,
1811
+ Oe as VideoType,
1812
+ pt as VoiceAccess,
1813
+ st as WsError,
1814
+ Rn as createAgentManager,
1815
+ kn as mapVideoType
1815
1816
  };