@d-id/client-sdk 1.0.19-beta.141 → 1.0.19-beta.144

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,5 +1,5 @@
1
- var ie = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ie || {}), se = /* @__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))(se || {}), oe = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(oe || {}), ce = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(ce || {}), $ = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e))($ || {}), j = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Complete = "done", e))(j || {}), de = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(de || {}), le = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(le || {}), ge = /* @__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))(ge || {}), G = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e))(G || {});
2
- const me = (e) => {
1
+ var re = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(re || {}), ae = /* @__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))(ae || {}), ie = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ie || {}), se = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(se || {}), E = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e))(E || {}), N = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Complete = "done", e))(N || {}), oe = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(oe || {}), ce = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(ce || {}), de = /* @__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))(de || {}), O = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e))(O || {});
2
+ const le = (e) => {
3
3
  switch (e) {
4
4
  case "clip":
5
5
  return "clip";
@@ -9,439 +9,577 @@ const me = (e) => {
9
9
  throw new Error(`Unknown video type: ${e}`);
10
10
  }
11
11
  };
12
- var K = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(K || {}), q = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(q || {}), k = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(k || {}), ue = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ue || {}), he = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(he || {});
13
- const B = "https://api.d-id.com", we = "wss://notifications.d-id.com", fe = "79f81a83a67430be2bc0fd61042b8faa", H = () => Math.random().toString(16).slice(2);
14
- function Q() {
12
+ var x = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(x || {}), W = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(W || {}), S = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(S || {}), me = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(me || {}), ue = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(ue || {});
13
+ const H = "https://api.d-id.com", fe = "wss://notifications.d-id.com", ge = "79f81a83a67430be2bc0fd61042b8faa";
14
+ async function X(e, n) {
15
+ const s = {
16
+ limit: (n == null ? void 0 : n.limit) ?? 3,
17
+ delayMs: (n == null ? void 0 : n.delayMs) ?? 0,
18
+ timeout: (n == null ? void 0 : n.timeout) ?? 3e4,
19
+ timeoutErrorMessage: (n == null ? void 0 : n.timeoutErrorMessage) || "Timeout error",
20
+ shouldRetryFn: (n == null ? void 0 : n.shouldRetryFn) ?? function() {
21
+ return !0;
22
+ }
23
+ };
24
+ let i;
25
+ for (let t = 1; t <= s.limit; t++)
26
+ try {
27
+ if (!s.timeout)
28
+ return await e();
29
+ let a;
30
+ const r = new Promise((m, d) => {
31
+ a = setTimeout(() => d(new Error(s.timeoutErrorMessage)), s.timeout);
32
+ });
33
+ return await Promise.race([e().then((m) => (clearTimeout(a), m)), r]);
34
+ } catch (a) {
35
+ if (i = a, !s.shouldRetryFn(a) || t >= s.limit)
36
+ throw a;
37
+ s.delayMs > 0 && await new Promise((r) => setTimeout(r, s.delayMs));
38
+ }
39
+ throw i;
40
+ }
41
+ const K = () => Math.random().toString(16).slice(2);
42
+ function Y() {
15
43
  let e = window.localStorage.getItem("did_external_key_id");
16
44
  return e || (e = Math.random().toString(16).slice(2), window.localStorage.setItem("did_external_key_id", e)), e;
17
45
  }
18
- let pe = H();
19
- function ee(e) {
46
+ let he = K();
47
+ function Z(e) {
20
48
  if (e.type === "bearer")
21
49
  return `Bearer ${e.token}`;
22
50
  if (e.type === "basic")
23
51
  return `Basic ${btoa(`${e.username}:${e.password}`)}`;
24
52
  if (e.type === "key")
25
- return `Client-Key ${e.clientKey}.${Q()}_${pe}`;
53
+ return `Client-Key ${e.clientKey}.${Y()}_${he}`;
26
54
  throw new Error(`Unknown auth type: ${e}`);
27
55
  }
28
- function J(e, n = B, s) {
29
- const a = async (t, r) => {
30
- const i = await fetch(n + (t != null && t.startsWith("/") ? t : `/${t}`), {
31
- ...r,
56
+ const we = (e) => X(e, {
57
+ limit: 3,
58
+ delayMs: 1e3,
59
+ timeout: 0,
60
+ shouldRetryFn: (n) => n.status === 429
61
+ });
62
+ function B(e, n = H, s) {
63
+ const i = async (t, a) => {
64
+ const r = await we(() => fetch(n + (t != null && t.startsWith("/") ? t : `/${t}`), {
65
+ ...a,
32
66
  headers: {
33
- ...r == null ? void 0 : r.headers,
34
- Authorization: ee(e),
67
+ ...a == null ? void 0 : a.headers,
68
+ Authorization: Z(e),
35
69
  "Content-Type": "application/json"
36
70
  }
37
- });
38
- if (!i.ok) {
39
- let o = await i.text().catch(() => "Failed to fetch");
71
+ }));
72
+ if (!r.ok) {
73
+ let o = await r.text().catch(() => "Failed to fetch");
40
74
  throw s && s(new Error(o), {
41
75
  url: t,
42
- options: r,
43
- headers: i.headers
76
+ options: a,
77
+ headers: r.headers
44
78
  }), new Error(o);
45
79
  }
46
- return i.json();
80
+ return r.json();
47
81
  };
48
82
  return {
49
- get(t, r) {
50
- return a(t, {
51
- ...r,
83
+ get(t, a) {
84
+ return i(t, {
85
+ ...a,
52
86
  method: "GET"
53
87
  });
54
88
  },
55
- post(t, r, i) {
56
- return a(t, {
57
- ...i,
58
- body: JSON.stringify(r),
89
+ post(t, a, r) {
90
+ return i(t, {
91
+ ...r,
92
+ body: JSON.stringify(a),
59
93
  method: "POST"
60
94
  });
61
95
  },
62
- delete(t, r, i) {
63
- return a(t, {
64
- ...i,
65
- body: JSON.stringify(r),
96
+ delete(t, a, r) {
97
+ return i(t, {
98
+ ...r,
99
+ body: JSON.stringify(a),
66
100
  method: "DELETE"
67
101
  });
68
102
  },
69
- patch(t, r, i) {
70
- return a(t, {
71
- ...i,
72
- body: JSON.stringify(r),
103
+ patch(t, a, r) {
104
+ return i(t, {
105
+ ...r,
106
+ body: JSON.stringify(a),
73
107
  method: "PATCH"
74
108
  });
75
109
  }
76
110
  };
77
111
  }
78
- function te(e, n = B, s) {
79
- const a = J(e, `${n}/agents`, s);
112
+ function G(e, n = H, s) {
113
+ const i = B(e, `${n}/agents`, s);
80
114
  return {
81
- create(t, r) {
82
- return a.post("/", t, r);
115
+ create(t, a) {
116
+ return i.post("/", t, a);
83
117
  },
84
- getAgents(t, r) {
85
- return a.get(`/${t ? `?tag=${t}` : ""}`, r).then((i) => i ?? []);
118
+ getAgents(t, a) {
119
+ return i.get(`/${t ? `?tag=${t}` : ""}`, a).then((r) => r ?? []);
86
120
  },
87
- getById(t, r) {
88
- return a.get(`/${t}`, r);
121
+ getById(t, a) {
122
+ return i.get(`/${t}`, a);
89
123
  },
90
- delete(t, r) {
91
- return a.delete(`/${t}`, void 0, r);
124
+ delete(t, a) {
125
+ return i.delete(`/${t}`, void 0, a);
92
126
  },
93
- update(t, r, i) {
94
- return a.patch(`/${t}`, r, i);
127
+ update(t, a, r) {
128
+ return i.patch(`/${t}`, a, r);
95
129
  },
96
- newChat(t, r, i) {
97
- return a.post(`/${t}/chat`, r, i);
130
+ newChat(t, a, r) {
131
+ return i.post(`/${t}/chat`, a, r);
98
132
  },
99
- chat(t, r, i, o) {
100
- return a.post(`/${t}/chat/${r}`, i, o);
133
+ chat(t, a, r, o) {
134
+ return i.post(`/${t}/chat/${a}`, r, o);
101
135
  },
102
- createRating(t, r, i, o) {
103
- return a.post(`/${t}/chat/${r}/ratings`, i, o);
136
+ createRating(t, a, r, o) {
137
+ return i.post(`/${t}/chat/${a}/ratings`, r, o);
104
138
  },
105
- updateRating(t, r, i, o, l) {
106
- return a.patch(`/${t}/chat/${r}/ratings/${i}`, o, l);
139
+ updateRating(t, a, r, o, m) {
140
+ return i.patch(`/${t}/chat/${a}/ratings/${r}`, o, m);
107
141
  },
108
- deleteRating(t, r, i, o) {
109
- return a.delete(`/${t}/chat/${r}/ratings/${i}`, o);
142
+ deleteRating(t, a, r, o) {
143
+ return i.delete(`/${t}/chat/${a}/ratings/${r}`, o);
110
144
  },
111
- getSTTToken(t, r) {
112
- return a.get(`/${t}/stt-token`, r);
145
+ getSTTToken(t, a) {
146
+ return i.get(`/${t}/stt-token`, a);
113
147
  }
114
148
  };
115
149
  }
116
- const ye = (e) => new Promise((n) => setTimeout(n, e));
117
- function ve(e) {
150
+ const pe = (e) => new Promise((n) => setTimeout(n, e));
151
+ function ye(e) {
118
152
  return new Promise((n, s) => {
119
153
  const {
120
- callbacks: a,
154
+ callbacks: i,
121
155
  host: t,
122
- auth: r
156
+ auth: a
123
157
  } = e, {
124
- onMessage: i = null,
158
+ onMessage: r = null,
125
159
  onOpen: o = null,
126
- onClose: l = null,
127
- onError: g = null
128
- } = a || {}, u = new WebSocket(`${t}?authorization=${ee(r)}`);
129
- u.onmessage = i, u.onclose = l, u.onerror = (m) => {
130
- console.error(m), g == null || g("Websocket failed to connect", m), s(m);
131
- }, u.onopen = (m) => {
132
- o == null || o(m), n(u);
160
+ onClose: m = null,
161
+ onError: d = null
162
+ } = i || {}, f = new WebSocket(`${t}?authorization=${Z(a)}`);
163
+ f.onmessage = r, f.onclose = m, f.onerror = (u) => {
164
+ console.error(u), d == null || d("Websocket failed to connect", u), s(u);
165
+ }, f.onopen = (u) => {
166
+ o == null || o(u), n(f);
133
167
  };
134
168
  });
135
169
  }
136
- async function Ce(e) {
170
+ async function ve(e) {
137
171
  const {
138
172
  retries: n = 1
139
173
  } = e;
140
174
  let s = null;
141
- for (let a = 0; (s == null ? void 0 : s.readyState) !== WebSocket.OPEN; a++)
175
+ for (let i = 0; (s == null ? void 0 : s.readyState) !== WebSocket.OPEN; i++)
142
176
  try {
143
- s = await ve(e);
177
+ s = await ye(e);
144
178
  } catch (t) {
145
- if (a === n)
179
+ if (i === n)
146
180
  throw t;
147
- await ye(a * 500);
181
+ await pe(i * 500);
148
182
  }
149
183
  return s;
150
184
  }
151
- async function _e(e, n, s) {
152
- const a = s != null && s.onMessage ? [s.onMessage] : [], t = await Ce({
185
+ async function ke(e, n, s) {
186
+ const i = s != null && s.onMessage ? [s.onMessage] : [], t = await ve({
153
187
  auth: e,
154
188
  host: n,
155
189
  callbacks: {
156
190
  onError: s == null ? void 0 : s.onError,
157
- onMessage: (r) => {
158
- const i = JSON.parse(r.data);
159
- a.forEach((o) => o(i.event, i));
191
+ onMessage: (a) => {
192
+ const r = JSON.parse(a.data);
193
+ i.forEach((o) => o(r.event, r));
160
194
  }
161
195
  }
162
196
  });
163
197
  return {
164
198
  socket: t,
165
199
  disconnect: () => t.close(),
166
- subscribeToEvents: (r) => a.push(r)
200
+ subscribeToEvents: (a) => i.push(a)
167
201
  };
168
202
  }
169
- const Se = "X-Playground-Chat";
170
- function ke(e, n, s, a) {
171
- const t = J(e, `${n}/agents/${s}`, a);
203
+ const Ce = "X-Playground-Chat";
204
+ function Re(e, n, s, i) {
205
+ const t = B(e, `${n}/agents/${s}`, i);
172
206
  return {
173
- createStream(r) {
207
+ createStream(a) {
174
208
  return t.post("/streams", {
175
- output_resolution: r.output_resolution,
176
- compatibility_mode: r.compatibility_mode,
177
- stream_warmup: r.stream_warmup,
178
- session_timeout: r.session_timeout,
179
- stream_greeting: r.stream_greeting
209
+ output_resolution: a.output_resolution,
210
+ compatibility_mode: a.compatibility_mode,
211
+ stream_warmup: a.stream_warmup,
212
+ session_timeout: a.session_timeout,
213
+ stream_greeting: a.stream_greeting
180
214
  });
181
215
  },
182
- startConnection(r, i, o) {
183
- return t.post(`/streams/${r}/sdp`, {
216
+ startConnection(a, r, o) {
217
+ return t.post(`/streams/${a}/sdp`, {
184
218
  session_id: o,
185
- answer: i
219
+ answer: r
186
220
  });
187
221
  },
188
- addIceCandidate(r, i, o) {
189
- return t.post(`/streams/${r}/ice`, {
222
+ addIceCandidate(a, r, o) {
223
+ return t.post(`/streams/${a}/ice`, {
190
224
  session_id: o,
191
- ...i
225
+ ...r
192
226
  });
193
227
  },
194
- sendStreamRequest(r, i, o) {
195
- return t.post(`/streams/${r}`, {
196
- session_id: i,
228
+ sendStreamRequest(a, r, o) {
229
+ return t.post(`/streams/${a}`, {
230
+ session_id: r,
197
231
  ...o
198
232
  });
199
233
  },
200
- close(r, i) {
201
- return t.delete(`/streams/${r}`, {
202
- session_id: i
234
+ close(a, r) {
235
+ return t.delete(`/streams/${a}`, {
236
+ session_id: r
203
237
  });
204
238
  }
205
239
  };
206
240
  }
207
- function Me(e, n, s, a) {
208
- const t = J(e, `${n}/agents/${s}`, a);
241
+ function Se(e, n, s, i) {
242
+ const t = B(e, `${n}/agents/${s}`, i);
209
243
  return {
210
- createStream(r, i) {
244
+ createStream(a, r) {
211
245
  return t.post("/streams", {
212
- driver_url: r.driver_url,
213
- face: r.face,
214
- config: r.config,
215
- output_resolution: r.output_resolution,
216
- compatibility_mode: r.compatibility_mode,
217
- stream_warmup: r.stream_warmup,
218
- session_timeout: r.session_timeout,
219
- stream_greeting: r.stream_greeting
220
- }, i);
221
- },
222
- startConnection(r, i, o, l) {
223
- return t.post(`/streams/${r}/sdp`, {
246
+ driver_url: a.driver_url,
247
+ face: a.face,
248
+ config: a.config,
249
+ output_resolution: a.output_resolution,
250
+ compatibility_mode: a.compatibility_mode,
251
+ stream_warmup: a.stream_warmup,
252
+ session_timeout: a.session_timeout,
253
+ stream_greeting: a.stream_greeting
254
+ }, r);
255
+ },
256
+ startConnection(a, r, o, m) {
257
+ return t.post(`/streams/${a}/sdp`, {
224
258
  session_id: o,
225
- answer: i
226
- }, l);
259
+ answer: r
260
+ }, m);
227
261
  },
228
- addIceCandidate(r, i, o, l) {
229
- return t.post(`/streams/${r}/ice`, {
262
+ addIceCandidate(a, r, o, m) {
263
+ return t.post(`/streams/${a}/ice`, {
230
264
  session_id: o,
231
- ...i
232
- }, l);
265
+ ...r
266
+ }, m);
233
267
  },
234
- sendStreamRequest(r, i, o, l) {
235
- return t.post(`/streams/${r}`, {
236
- session_id: i,
268
+ sendStreamRequest(a, r, o, m) {
269
+ return t.post(`/streams/${a}`, {
270
+ session_id: r,
237
271
  ...o
238
- }, l);
272
+ }, m);
239
273
  },
240
- close(r, i, o) {
241
- return t.delete(`/streams/${r}`, {
242
- session_id: i
274
+ close(a, r, o) {
275
+ return t.delete(`/streams/${a}`, {
276
+ session_id: r
243
277
  }, o);
244
278
  }
245
279
  };
246
280
  }
247
- let ne = !1;
248
- const N = (e, n) => ne && console.log(e, n), Re = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
249
- function Y(e) {
281
+ function _e(e, n, s) {
282
+ return {
283
+ duration: (n.timestamp - e.timestamp) / 1e3,
284
+ bytesReceived: n.bytesReceived - e.bytesReceived,
285
+ bitrate: Math.round((n.bytesReceived - e.bytesReceived) * 8 / ((n.timestamp - e.timestamp) / 1e3)),
286
+ packetsReceived: n.packetsReceived - e.packetsReceived,
287
+ packetsLost: n.packetsLost - e.packetsLost,
288
+ framesDropped: n.framesDropped - e.framesDropped,
289
+ framesDecoded: n.framesDecoded - e.framesDecoded,
290
+ jitter: n.jitter,
291
+ framesPerSecond: n.framesPerSecond,
292
+ freezeCount: n.freezeCount - e.freezeCount,
293
+ freezeDuration: n.freezeDuration - e.freezeDuration,
294
+ lowFpsCount: s
295
+ };
296
+ }
297
+ function Me(e) {
298
+ return e.filter((n) => n.freezeCount > 0 || n.framesPerSecond < 21 || n.framesDropped > 0 || n.packetsLost > 0).map((n) => {
299
+ const {
300
+ timestamp: s,
301
+ ...i
302
+ } = n, t = [];
303
+ return n.freezeCount > 0 && t.push("freeze"), n.framesPerSecond < 21 && t.push("low fps"), n.framesDropped > 0 && t.push("frames dropped"), n.packetsLost > 0 && t.push("packet loss"), {
304
+ ...i,
305
+ causes: t
306
+ };
307
+ });
308
+ }
309
+ function De(e) {
310
+ let n = "";
311
+ for (const s of e.values())
312
+ if (s && s.type === "codec" && s.mimeType.startsWith("video") && (n = s.mimeType.split("/")[1]), s && s.type === "inbound-rtp" && s.kind === "video")
313
+ return {
314
+ codec: n,
315
+ timestamp: s.timestamp,
316
+ bytesReceived: s.bytesReceived,
317
+ packetsReceived: s.packetsReceived,
318
+ packetsLost: s.packetsLost,
319
+ framesDropped: s.framesDropped,
320
+ framesDecoded: s.framesDecoded,
321
+ jitter: s.jitter,
322
+ frameWidth: s.frameWidth,
323
+ frameHeight: s.frameHeight,
324
+ framesPerSecond: s.framesPerSecond,
325
+ freezeCount: s.freezeCount,
326
+ freezeDuration: s.totalFreezesDuration
327
+ };
328
+ return {};
329
+ }
330
+ function be(e, n, s) {
331
+ const i = e.map((r, o) => o === 0 ? s ? {
332
+ timestamp: r.timestamp,
333
+ duration: 0,
334
+ bytesReceived: r.bytesReceived - s.bytesReceived,
335
+ bitrate: (r.bytesReceived - s.bytesReceived) * 8 / (n / 1e3),
336
+ packetsReceived: r.packetsReceived - s.packetsReceived,
337
+ packetsLost: r.packetsLost - s.packetsLost,
338
+ framesDropped: r.framesDropped - s.framesDropped,
339
+ framesDecoded: r.framesDecoded - s.framesDecoded,
340
+ jitter: r.jitter,
341
+ framesPerSecond: r.framesPerSecond,
342
+ freezeCount: r.freezeCount - s.freezeCount,
343
+ freezeDuration: r.freezeDuration - s.freezeDuration
344
+ } : {
345
+ timestamp: r.timestamp,
346
+ duration: 0,
347
+ bytesReceived: r.bytesReceived,
348
+ bitrate: r.bytesReceived * 8 / (n / 1e3),
349
+ packetsReceived: r.packetsReceived,
350
+ packetsLost: r.packetsLost,
351
+ framesDropped: r.framesDropped,
352
+ framesDecoded: r.framesDecoded,
353
+ jitter: r.jitter,
354
+ framesPerSecond: r.framesPerSecond,
355
+ freezeCount: r.freezeCount,
356
+ freezeDuration: r.freezeDuration
357
+ } : {
358
+ timestamp: r.timestamp,
359
+ duration: n * o / 1e3,
360
+ bytesReceived: r.bytesReceived - e[o - 1].bytesReceived,
361
+ bitrate: (r.bytesReceived - e[o - 1].bytesReceived) * 8 / (n / 1e3),
362
+ packetsReceived: r.packetsReceived - e[o - 1].packetsReceived,
363
+ packetsLost: r.packetsLost - e[o - 1].packetsLost,
364
+ framesDropped: r.framesDropped - e[o - 1].framesDropped,
365
+ framesDecoded: r.framesDecoded - e[o - 1].framesDecoded,
366
+ jitter: r.jitter,
367
+ framesPerSecond: r.framesPerSecond,
368
+ freezeCount: r.freezeCount - e[o - 1].freezeCount,
369
+ freezeDuration: r.freezeDuration - e[o - 1].freezeDuration
370
+ }), t = Me(i), a = t.reduce((r, o) => r + (o.causes.includes("low fps") ? 1 : 0), 0);
371
+ return {
372
+ webRTCStats: {
373
+ anomalies: t,
374
+ aggregateReport: _e(e[0], e[e.length - 1], a)
375
+ },
376
+ codec: e[0].codec,
377
+ resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
378
+ };
379
+ }
380
+ let Q = !1;
381
+ const L = (e, n) => Q && console.log(e, n), Ee = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
382
+ function q(e) {
250
383
  switch (e) {
251
384
  case "connected":
252
- return k.Connected;
385
+ return S.Connected;
253
386
  case "checking":
254
- return k.Connecting;
387
+ return S.Connecting;
255
388
  case "failed":
256
- return k.Fail;
389
+ return S.Fail;
257
390
  case "new":
258
- return k.New;
391
+ return S.New;
259
392
  case "closed":
260
- return k.Closed;
393
+ return S.Closed;
261
394
  case "disconnected":
262
- return k.Disconnected;
395
+ return S.Disconnected;
263
396
  case "completed":
264
- return k.Completed;
397
+ return S.Completed;
265
398
  default:
266
- return k.New;
399
+ return S.New;
267
400
  }
268
401
  }
269
- function Ee() {
402
+ function Ie() {
270
403
  let e = 0;
271
404
  return (n) => {
272
405
  for (const s of n.values())
273
406
  if (s && s.type === "inbound-rtp" && s.kind === "video") {
274
- const a = s.bytesReceived, t = a - e > 0;
275
- return e = a, t;
407
+ const i = s.bytesReceived, t = i - e > 0;
408
+ return e = i, t;
276
409
  }
277
410
  return !1;
278
411
  };
279
412
  }
280
- function Ie(e, n, s = !1, a, t) {
281
- const i = Math.max(Math.ceil(10), 1);
282
- let o = 0, l = !1;
283
- const g = s ? 1 : 0;
284
- let u = 0;
285
- const m = Ee();
413
+ function Pe(e, n, s = !1, i, t) {
414
+ const r = Math.max(Math.ceil(10), 1);
415
+ let o = [], m, d = 0, f = !1;
416
+ const u = s ? 1 : 0;
417
+ let g = 0;
418
+ const C = Ie();
286
419
  return setInterval(async () => {
287
- const p = await e.getStats();
288
- m(p) ? (o = 0, l || (n == null || n(K.Start), u >= g && !a() && t(), u++, l = !0)) : l && (o++, o >= i && (n == null || n(K.Stop), l = !1));
420
+ const y = await e.getStats(), v = C(y), h = De(y);
421
+ if (v)
422
+ d = 0, f || (n == null || n(x.Start), g >= u && !i() && t(), m = o[o.length - 1], o = [], g++, f = !0), o.push(h);
423
+ else if (f && (d++, d >= r)) {
424
+ const b = be(o, 100, m);
425
+ n == null || n(x.Stop, b), f = !1;
426
+ }
289
427
  }, 100);
290
428
  }
291
429
  async function $e(e, n, {
292
430
  debug: s = !1,
293
- callbacks: a,
431
+ callbacks: i,
294
432
  auth: t,
295
- baseURL: r = B,
296
- warmup: i
433
+ baseURL: a = H,
434
+ warmup: r
297
435
  }) {
298
- ne = s;
436
+ Q = s;
299
437
  const {
300
438
  startConnection: o,
301
- sendStreamRequest: l,
302
- close: g,
303
- createStream: u,
304
- addIceCandidate: m
305
- } = n.videoType === G.Clip ? ke(t, r, e, a.onError) : Me(t, r, e, a.onError), {
306
- id: p,
307
- offer: w,
439
+ sendStreamRequest: m,
440
+ close: d,
441
+ createStream: f,
442
+ addIceCandidate: u
443
+ } = n.videoType === O.Clip ? Re(t, a, e, i.onError) : Se(t, a, e, i.onError), {
444
+ id: g,
445
+ offer: C,
308
446
  ice_servers: y,
309
- session_id: _
310
- } = await u(n), f = new Re({
447
+ session_id: v
448
+ } = await f(n), h = new Ee({
311
449
  iceServers: y
312
- }), R = f.createDataChannel("JanusDataChannel");
313
- if (!_)
450
+ }), b = h.createDataChannel("JanusDataChannel");
451
+ if (!v)
314
452
  throw new Error("Could not create session_id");
315
- let b = !1;
316
- const c = () => b, h = () => {
317
- var d;
318
- b = !0, (d = a.onConnectionStateChange) == null || d.call(a, k.Connected);
319
- }, v = Ie(f, a.onVideoStateChange, i, c, h);
320
- f.onicecandidate = (d) => {
321
- var C;
322
- N("peerConnection.onicecandidate", d);
453
+ let P = !1;
454
+ const c = () => P, w = () => {
455
+ var l;
456
+ P = !0, (l = i.onConnectionStateChange) == null || l.call(i, S.Connected);
457
+ }, k = Pe(h, i.onVideoStateChange, r, c, w);
458
+ h.onicecandidate = (l) => {
459
+ var p;
460
+ L("peerConnection.onicecandidate", l);
323
461
  try {
324
- d.candidate && d.candidate.sdpMid && d.candidate.sdpMLineIndex !== null ? m(p, {
325
- candidate: d.candidate.candidate,
326
- sdpMid: d.candidate.sdpMid,
327
- sdpMLineIndex: d.candidate.sdpMLineIndex
328
- }, _) : m(p, {
462
+ l.candidate && l.candidate.sdpMid && l.candidate.sdpMLineIndex !== null ? u(g, {
463
+ candidate: l.candidate.candidate,
464
+ sdpMid: l.candidate.sdpMid,
465
+ sdpMLineIndex: l.candidate.sdpMLineIndex
466
+ }, v) : u(g, {
329
467
  candidate: null
330
- }, _);
331
- } catch (E) {
332
- (C = a.onError) == null || C.call(a, E, {
333
- streamId: p
468
+ }, v);
469
+ } catch (R) {
470
+ (p = i.onError) == null || p.call(i, R, {
471
+ streamId: g
334
472
  });
335
473
  }
336
- }, R.onmessage = (d) => {
337
- if (R.readyState === "open") {
338
- const [C, E] = d.data.split(":");
339
- C === q.StreamReady && !b && h();
474
+ }, b.onmessage = (l) => {
475
+ if (b.readyState === "open") {
476
+ const [p, R] = l.data.split(":");
477
+ p === W.StreamReady && !P && w();
340
478
  }
341
- }, f.oniceconnectionstatechange = () => {
342
- var C;
343
- N("peerConnection.oniceconnectionstatechange => " + f.iceConnectionState);
344
- const d = Y(f.iceConnectionState);
345
- d !== k.Connected && ((C = a.onConnectionStateChange) == null || C.call(a, d));
346
- }, f.ontrack = (d) => {
347
- var C;
348
- N("peerConnection.ontrack", d), (C = a.onSrcObjectReady) == null || C.call(a, d.streams[0]);
349
- }, await f.setRemoteDescription(w), N("set remote description OK");
350
- const M = await f.createAnswer();
351
- return N("create answer OK"), await f.setLocalDescription(M), N("set local description OK"), await o(p, M, _), N("start connection OK"), {
479
+ }, h.oniceconnectionstatechange = () => {
480
+ var p;
481
+ L("peerConnection.oniceconnectionstatechange => " + h.iceConnectionState);
482
+ const l = q(h.iceConnectionState);
483
+ l !== S.Connected && ((p = i.onConnectionStateChange) == null || p.call(i, l));
484
+ }, h.ontrack = (l) => {
485
+ var p;
486
+ L("peerConnection.ontrack", l), (p = i.onSrcObjectReady) == null || p.call(i, l.streams[0]);
487
+ }, await h.setRemoteDescription(C), L("set remote description OK");
488
+ const _ = await h.createAnswer();
489
+ return L("create answer OK"), await h.setLocalDescription(_), L("set local description OK"), await o(g, _, v), L("start connection OK"), {
352
490
  /**
353
491
  * Method to send request to server to get clip or talk depend on you payload
354
492
  * @param payload
355
493
  */
356
- speak(d) {
357
- return l(p, _, d);
494
+ speak(l) {
495
+ return m(g, v, l);
358
496
  },
359
497
  /**
360
498
  * Method to close RTC connection
361
499
  */
362
500
  async disconnect() {
363
- var d, C;
364
- if (p) {
365
- const E = Y(f.iceConnectionState);
366
- if (f) {
367
- if (E === k.New) {
368
- (d = a.onVideoStateChange) == null || d.call(a, K.Stop), clearInterval(v);
501
+ var l, p;
502
+ if (g) {
503
+ const R = q(h.iceConnectionState);
504
+ if (h) {
505
+ if (R === S.New) {
506
+ (l = i.onVideoStateChange) == null || l.call(i, x.Stop), clearInterval(k);
369
507
  return;
370
508
  }
371
- f.close(), f.oniceconnectionstatechange = null, f.onnegotiationneeded = null, f.onicecandidate = null, f.ontrack = null;
509
+ h.close(), h.oniceconnectionstatechange = null, h.onnegotiationneeded = null, h.onicecandidate = null, h.ontrack = null;
372
510
  }
373
511
  try {
374
- E === k.Connected && await g(p, _).catch((S) => {
512
+ R === S.Connected && await d(g, v).catch((M) => {
375
513
  });
376
- } catch (S) {
377
- N("Error on close stream connection", S);
514
+ } catch (M) {
515
+ L("Error on close stream connection", M);
378
516
  }
379
- (C = a.onVideoStateChange) == null || C.call(a, K.Stop), clearInterval(v);
517
+ (p = i.onVideoStateChange) == null || p.call(i, x.Stop), clearInterval(k);
380
518
  }
381
519
  },
382
520
  /**
383
521
  * Session identifier information, should be returned in the body of all streaming requests
384
522
  */
385
- sessionId: _,
523
+ sessionId: v,
386
524
  /**
387
525
  * Id of current RTC stream
388
526
  */
389
- streamId: p
527
+ streamId: g
390
528
  };
391
529
  }
392
- let z = {};
530
+ let U = {};
393
531
  function Ae(e) {
394
- var r, i, o, l, g;
395
- const n = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", s = e.agent.presenter, a = (r = e.agent.llm) == null ? void 0 : r.prompt_customization, t = {
532
+ var a, r, o, m, d;
533
+ const n = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", s = e.agent.presenter, i = (a = e.agent.llm) == null ? void 0 : a.prompt_customization, t = {
396
534
  token: e.token || "testKey",
397
- distinct_id: e.distinctId || Q(),
535
+ distinct_id: e.distinctId || Y(),
398
536
  agentId: e.agent.id,
399
537
  agentType: s.type === "clip" && s.presenter_id.startsWith("v2_") ? "clip_v2" : s.type,
400
538
  owner_id: e.agent.owner_id ?? "",
401
539
  behavior: {
402
- role: a == null ? void 0 : a.role,
403
- personality: a == null ? void 0 : a.personality,
404
- instructions: (i = e.agent.llm) == null ? void 0 : i.instructions
540
+ role: i == null ? void 0 : i.role,
541
+ personality: i == null ? void 0 : i.personality,
542
+ instructions: (r = e.agent.llm) == null ? void 0 : r.instructions
405
543
  },
406
544
  temperature: (o = e.agent.llm) == null ? void 0 : o.temperature,
407
- knowledgeSource: a == null ? void 0 : a.knowledge_source,
408
- starterQuestionsCount: (g = (l = e.agent.knowledge) == null ? void 0 : l.starter_message) == null ? void 0 : g.length,
409
- topicsToAvoid: a == null ? void 0 : a.topics_to_avoid,
410
- maxResponseLength: a == null ? void 0 : a.max_response_length
545
+ knowledgeSource: i == null ? void 0 : i.knowledge_source,
546
+ starterQuestionsCount: (d = (m = e.agent.knowledge) == null ? void 0 : m.starter_message) == null ? void 0 : d.length,
547
+ topicsToAvoid: i == null ? void 0 : i.topics_to_avoid,
548
+ maxResponseLength: i == null ? void 0 : i.max_response_length
411
549
  };
412
550
  return {
413
551
  ...t,
414
552
  additionalProperties: {},
415
553
  isEnabled: e.isEnabled ?? !0,
416
554
  getRandom: () => Math.random().toString(16).slice(2),
417
- enrich(u) {
418
- const m = {};
419
- if (u && typeof u != "object")
555
+ enrich(f) {
556
+ const u = {};
557
+ if (f && typeof f != "object")
420
558
  throw new Error("properties must be a flat json object");
421
- for (let p in u)
422
- (typeof u[p] == "string" || typeof u[p] == "number") && (m[p] = u[p]);
559
+ for (let g in f)
560
+ (typeof f[g] == "string" || typeof f[g] == "number") && (u[g] = f[g]);
423
561
  this.additionalProperties = {
424
562
  ...this.additionalProperties,
425
- ...m
563
+ ...u
426
564
  };
427
565
  },
428
- track(u, m) {
566
+ track(f, u) {
429
567
  if (!this.isEnabled)
430
568
  return Promise.resolve();
431
569
  const {
432
- audioPath: p,
433
- ...w
434
- } = m || {}, y = {
570
+ audioPath: g,
571
+ ...C
572
+ } = u || {}, y = {
435
573
  method: "POST",
436
574
  headers: {
437
575
  "Content-Type": "application/x-www-form-urlencoded"
438
576
  },
439
577
  body: new URLSearchParams({
440
578
  data: JSON.stringify([{
441
- event: u,
579
+ event: f,
442
580
  properties: {
443
581
  ...this.additionalProperties,
444
- ...w,
582
+ ...C,
445
583
  ...t,
446
584
  source: n,
447
585
  time: Date.now(),
@@ -454,175 +592,180 @@ function Ae(e) {
454
592
  }])
455
593
  })
456
594
  };
457
- return fetch("https://api-js.mixpanel.com/track/?verbose=1&ip=1", y).then((_) => _.json()).catch((_) => console.error(_));
595
+ return fetch("https://api-js.mixpanel.com/track/?verbose=1&ip=1", y).then((v) => v.json()).catch((v) => console.error(v));
458
596
  },
459
- linkTrack(u, m, p, w) {
460
- z[u] || (z[u] = {
597
+ linkTrack(f, u, g, C) {
598
+ U[f] || (U[f] = {
461
599
  events: {},
462
600
  resolvedDependencies: []
463
- }), w.includes(p) || w.push(p);
464
- const y = z[u];
465
- if (y.events[p] = {
466
- props: m
467
- }, y.resolvedDependencies.push(p), w.every((f) => y.resolvedDependencies.includes(f))) {
468
- const f = w.reduce((R, b) => y.events[b] ? {
469
- ...R,
470
- ...y.events[b].props
471
- } : R, {});
472
- this.track(u, f), y.resolvedDependencies = y.resolvedDependencies.filter((R) => !w.includes(R)), w.forEach((R) => {
473
- delete y.events[R];
601
+ }), C.includes(g) || C.push(g);
602
+ const y = U[f];
603
+ if (y.events[g] = {
604
+ props: u
605
+ }, y.resolvedDependencies.push(g), C.every((h) => y.resolvedDependencies.includes(h))) {
606
+ const h = C.reduce((b, P) => y.events[P] ? {
607
+ ...b,
608
+ ...y.events[P].props
609
+ } : b, {});
610
+ this.track(f, h), y.resolvedDependencies = y.resolvedDependencies.filter((b) => !C.includes(b)), C.forEach((b) => {
611
+ delete y.events[b];
474
612
  });
475
613
  }
476
614
  }
477
615
  };
478
616
  }
479
- function be(e) {
480
- var t, r, i, o;
617
+ function Te(e) {
618
+ var t, a, r, o;
481
619
  const n = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", s = () => {
482
- const l = navigator.platform;
483
- return l.toLowerCase().includes("win") ? "Windows" : l.toLowerCase().includes("mac") ? "Mac OS X" : l.toLowerCase().includes("linux") ? "Linux" : "Unknown";
484
- }, a = e.presenter;
620
+ const m = navigator.platform;
621
+ return m.toLowerCase().includes("win") ? "Windows" : m.toLowerCase().includes("mac") ? "Mac OS X" : m.toLowerCase().includes("linux") ? "Linux" : "Unknown";
622
+ }, i = e.presenter;
485
623
  return {
486
624
  $os: `${s()}`,
487
625
  isMobile: `${n() == "Mobile"}`,
488
626
  browser: navigator.userAgent,
489
627
  origin: window.location.origin,
490
- agentType: a.type === "clip" && a.presenter_id.startsWith("v2_") ? "clip_v2" : a.type,
628
+ agentType: i.type === "clip" && i.presenter_id.startsWith("v2_") ? "clip_v2" : i.type,
491
629
  agentVoice: {
492
- voiceId: (r = (t = e.presenter) == null ? void 0 : t.voice) == null ? void 0 : r.voice_id,
493
- provider: (o = (i = e.presenter) == null ? void 0 : i.voice) == null ? void 0 : o.type
630
+ voiceId: (a = (t = e.presenter) == null ? void 0 : t.voice) == null ? void 0 : a.voice_id,
631
+ provider: (o = (r = e.presenter) == null ? void 0 : r.voice) == null ? void 0 : o.type
494
632
  }
495
633
  };
496
634
  }
497
- function Pe(e, n, s) {
498
- var g, u;
635
+ function Le(e, n, s) {
636
+ var d, f;
499
637
  const {
500
- event: a,
638
+ event: i,
501
639
  ...t
502
640
  } = e, {
503
- template: r
641
+ template: a
504
642
  } = (n == null ? void 0 : n.llm) || {}, {
505
- language: i
506
- } = ((g = n == null ? void 0 : n.presenter) == null ? void 0 : g.voice) || {}, {
643
+ language: r
644
+ } = ((d = n == null ? void 0 : n.presenter) == null ? void 0 : d.voice) || {}, {
507
645
  stitch: o
508
646
  } = (n == null ? void 0 : n.presenter) || {};
509
647
  return {
510
648
  ...t,
511
649
  llm: {
512
650
  ...t.llm,
513
- template: r
651
+ template: a
514
652
  },
515
653
  script: {
516
654
  ...t.script,
517
655
  provider: {
518
- ...(u = t == null ? void 0 : t.script) == null ? void 0 : u.provider,
519
- language: i
656
+ ...(f = t == null ? void 0 : t.script) == null ? void 0 : f.provider,
657
+ language: r
520
658
  }
521
659
  },
522
660
  stitch: o,
523
661
  ...s
524
662
  };
525
663
  }
526
- let L = 0;
527
- const Te = 20 * 1e3;
528
- function De(e, n, s) {
529
- var a, t, r, i, o;
664
+ let z = 0;
665
+ const ze = 20 * 1e3;
666
+ function xe(e, n, s) {
667
+ var i, t, a, r, o;
530
668
  return {
531
- videoType: me(e.presenter.type),
532
- output_resolution: (a = n == null ? void 0 : n.streamOptions) == null ? void 0 : a.outputResolution,
669
+ videoType: le(e.presenter.type),
670
+ output_resolution: (i = n == null ? void 0 : n.streamOptions) == null ? void 0 : i.outputResolution,
533
671
  session_timeout: (t = n == null ? void 0 : n.streamOptions) == null ? void 0 : t.sessionTimeout,
534
- stream_warmup: (r = n == null ? void 0 : n.streamOptions) == null ? void 0 : r.streamWarmup,
535
- compatibility_mode: (i = n == null ? void 0 : n.streamOptions) == null ? void 0 : i.compatibilityMode,
672
+ stream_warmup: (a = n == null ? void 0 : n.streamOptions) == null ? void 0 : a.streamWarmup,
673
+ compatibility_mode: (r = n == null ? void 0 : n.streamOptions) == null ? void 0 : r.compatibilityMode,
536
674
  stream_greeting: (o = n == null ? void 0 : n.streamOptions) != null && o.streamGreeting ? s : void 0
537
675
  };
538
676
  }
539
- function re(e) {
540
- return e === $.Playground ? {
677
+ function ee(e) {
678
+ return e === E.Playground ? {
541
679
  headers: {
542
- [Se]: "true"
680
+ [Ce]: "true"
543
681
  }
544
682
  } : {};
545
683
  }
546
- async function ae(e, n, s, a, t) {
684
+ async function te(e, n, s, i, t) {
547
685
  try {
548
- const r = await n.newChat(e, {
686
+ const a = await n.newChat(e, {
549
687
  persist: t ?? !1
550
- }, re(a));
688
+ }, ee(i));
551
689
  return s.track("agent-chat", {
552
690
  event: "created",
553
- chat_id: r.id,
691
+ chat_id: a.id,
554
692
  agent_id: e,
555
- mode: a
556
- }), r;
557
- } catch (r) {
558
- let i;
693
+ mode: i
694
+ }), a;
695
+ } catch (a) {
696
+ let r;
559
697
  try {
560
- i = JSON.parse(r.message);
698
+ r = JSON.parse(a.message);
561
699
  } catch (o) {
562
700
  console.error("Error parsing the error message:", o);
563
701
  }
564
- throw (i == null ? void 0 : i.kind) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
702
+ throw (r == null ? void 0 : r.kind) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
565
703
  }
566
704
  }
567
- function xe(e, n, s, a, t, r) {
568
- return new Promise(async (i, o) => {
569
- var p;
570
- L = 0;
571
- const l = setTimeout(() => {
572
- u(new Error("Could not connect"));
573
- }, Te), g = (w) => {
574
- clearTimeout(l), i(w);
575
- }, u = (w) => {
576
- clearTimeout(l), o(w);
577
- };
578
- if (!t && n.mode !== $.DirectPlayback)
705
+ function Ne(e, n, s, i, t, a) {
706
+ return new Promise(async (r, o) => {
707
+ var d, f, u;
708
+ if (z = 0, !t && n.mode !== E.DirectPlayback)
579
709
  try {
580
- t = await ae(e.id, s, a, n.mode, n.persistentChat);
581
- } catch (w) {
582
- return u(w);
710
+ t = await te(e.id, s, i, n.mode, n.persistentChat);
711
+ } catch (g) {
712
+ return o(g);
583
713
  }
584
- const m = await $e(e.id, De(e, n, r), {
714
+ if ((t == null ? void 0 : t.chat_mode) === E.TextOnly)
715
+ return (f = (d = n.callbacks) == null ? void 0 : d.onError) == null || f.call(d, new Error(JSON.stringify({
716
+ kind: "InsufficientCreditsError"
717
+ })), {
718
+ fromSdk: !0
719
+ }), r({
720
+ chat: t
721
+ });
722
+ const m = await $e(e.id, xe(e, n, a), {
585
723
  ...n,
586
- analytics: a,
587
- warmup: (p = n.streamOptions) == null ? void 0 : p.streamWarmup,
724
+ analytics: i,
725
+ warmup: (u = n.streamOptions) == null ? void 0 : u.streamWarmup,
588
726
  callbacks: {
589
727
  ...n.callbacks,
590
- onConnectionStateChange: async (w) => {
591
- var y, _, f, R;
592
- w === k.Connected ? m ? ((_ = (y = n.callbacks).onConnectionStateChange) == null || _.call(y, w), g({
728
+ onConnectionStateChange: async (g) => {
729
+ var C, y, v, h;
730
+ g === S.Connected ? m ? ((y = (C = n.callbacks).onConnectionStateChange) == null || y.call(C, g), r({
593
731
  chat: t,
594
732
  streamingManager: m
595
- })) : t && u(new Error("Something went wrong while initializing the manager")) : (R = (f = n.callbacks).onConnectionStateChange) == null || R.call(f, w);
733
+ })) : t && o(new Error("Something went wrong while initializing the manager")) : (h = (v = n.callbacks).onConnectionStateChange) == null || h.call(v, g);
596
734
  },
597
- onVideoStateChange(w) {
598
- var y, _;
599
- (_ = (y = n.callbacks).onVideoStateChange) == null || _.call(y, w), L > 0 && w === K.Start && a.linkTrack("agent-video", {
735
+ onVideoStateChange(g, C) {
736
+ var y, v;
737
+ (v = (y = n.callbacks).onVideoStateChange) == null || v.call(y, g), z > 0 && (g === x.Start ? i.linkTrack("agent-video", {
600
738
  event: "start",
601
- latency: Date.now() - L
602
- }, "start", [q.StreamVideoCreated]);
739
+ latency: Date.now() - z
740
+ }, "start", [W.StreamVideoCreated]) : g === x.Stop && i.linkTrack("agent-video", {
741
+ event: "stop",
742
+ is_greenscreen: e.presenter.type === "clip" && e.presenter.is_greenscreen,
743
+ background: e.presenter.type === "clip" && e.presenter.background,
744
+ ...C
745
+ }, "done", [W.StreamVideoDone]));
603
746
  }
604
747
  }
605
- }).catch(u);
748
+ }).catch(o);
606
749
  });
607
750
  }
608
- function Ne(e) {
751
+ function je(e) {
609
752
  var s;
610
- const n = (s = e.greetings) == null ? void 0 : s.filter((a) => a.length > 0);
753
+ const n = (s = e.greetings) == null ? void 0 : s.filter((i) => i.length > 0);
611
754
  if (n && n.length > 0) {
612
- const a = Math.floor(Math.random() * n.length);
613
- return n[a];
755
+ const i = Math.floor(Math.random() * n.length);
756
+ return n[i];
614
757
  } else
615
758
  return `Hi! I'm ${e.preview_name || "My Agent"}. How can I help you?`;
616
759
  }
617
- function Z(e, n) {
760
+ function J(e, n) {
618
761
  return n && n.length > 0 ? n : [{
619
762
  content: e,
620
- id: H(),
763
+ id: K(),
621
764
  role: "assistant",
622
765
  created_at: (/* @__PURE__ */ new Date()).toISOString()
623
766
  }];
624
767
  }
625
- function Oe(e) {
768
+ function Fe(e) {
626
769
  if (e.answer !== void 0)
627
770
  return e.answer;
628
771
  let n = 0, s = "";
@@ -630,297 +773,292 @@ function Oe(e) {
630
773
  s += e[n], n++;
631
774
  return s;
632
775
  }
633
- function Le(e, n, s, a, t) {
634
- if (!(e === j.Partial || e === j.Answer))
776
+ function We(e, n, s, i, t) {
777
+ if (!(e === N.Partial || e === N.Answer))
635
778
  return;
636
- const r = a.messages[a.messages.length - 1];
637
- if ((r == null ? void 0 : r.role) !== "assistant")
779
+ const a = i.messages[i.messages.length - 1];
780
+ if ((a == null ? void 0 : a.role) !== "assistant")
638
781
  return;
639
782
  const {
640
- content: i,
783
+ content: r,
641
784
  sequence: o
642
785
  } = n;
643
- e === j.Partial ? s[o] = i : s.answer = i;
644
- const l = Oe(s);
645
- (r.content !== l || e === j.Answer) && (r.content = l, t == null || t([...a.messages], e));
786
+ e === N.Partial ? s[o] = r : s.answer = r;
787
+ const m = Fe(s);
788
+ (a.content !== m || e === N.Answer) && (a.content = m, t == null || t([...i.messages], e));
646
789
  }
647
- async function je(e, n) {
648
- var f, R, b;
649
- let s = {}, a = !0;
790
+ async function He(e, n) {
791
+ var h, b, P;
792
+ let s = {}, i = !0;
650
793
  const t = {
651
794
  messages: [],
652
- chatMode: n.mode || $.Functional
653
- }, r = n.baseURL || B, i = n.wsURL || we, o = n.mixpanelKey || fe, l = te(n.auth, r, n.callbacks.onError), g = await l.getById(e), u = Ne(g);
654
- t.messages = Z(u, n.initialMessages), (R = (f = n.callbacks).onNewMessage) == null || R.call(f, [...t.messages], "answer");
655
- const m = Ae({
795
+ chatMode: n.mode || E.Functional
796
+ }, a = n.baseURL || H, r = n.wsURL || fe, o = n.mixpanelKey || ge, m = G(n.auth, a, n.callbacks.onError), d = await m.getById(e), f = je(d);
797
+ t.messages = J(f, n.initialMessages), (b = (h = n.callbacks).onNewMessage) == null || b.call(h, [...t.messages], "answer");
798
+ const u = Ae({
656
799
  token: o,
657
- agent: g,
800
+ agent: d,
658
801
  isEnabled: n.enableAnalitics,
659
802
  distinctId: n.distinctId
660
803
  });
661
- m.track("agent-sdk", {
804
+ u.track("agent-sdk", {
662
805
  event: "loaded",
663
- ...be(g)
806
+ ...Te(d)
664
807
  });
665
- const p = {
666
- onMessage: (c, h) => {
667
- var v, M;
668
- if ("content" in h)
669
- Le(c, h, s, t, n.callbacks.onNewMessage), c === j.Answer && m.track("agent-message-received", {
808
+ const g = {
809
+ onMessage: (c, w) => {
810
+ var k, _;
811
+ if ("content" in w)
812
+ We(c, w, s, t, n.callbacks.onNewMessage), c === N.Answer && u.track("agent-message-received", {
670
813
  messages: t.messages.length,
671
814
  mode: t.chatMode
672
815
  });
673
816
  else {
674
- const d = q, C = [d.StreamVideoDone, d.StreamVideoError, d.StreamVideoRejected], E = [d.StreamFailed, d.StreamVideoError, d.StreamVideoRejected], S = Pe(h, g, {
817
+ const l = W, p = [l.StreamVideoDone, l.StreamVideoError, l.StreamVideoRejected], R = [l.StreamFailed, l.StreamVideoError, l.StreamVideoRejected], M = Le(w, d, {
675
818
  mode: t.chatMode
676
819
  });
677
- if (c = c, c === d.StreamVideoCreated)
678
- m.linkTrack("agent-video", S, d.StreamVideoCreated, ["start"]);
679
- else if (C.includes(c)) {
680
- const I = c.split("/")[1];
681
- m.track("agent-video", {
682
- ...S,
683
- event: I
684
- });
820
+ if (c = c, c === l.StreamVideoCreated)
821
+ u.linkTrack("agent-video", M, l.StreamVideoCreated, ["start"]);
822
+ else if (p.includes(c)) {
823
+ const D = c.split("/")[1];
824
+ R.includes(c) ? u.track("agent-video", {
825
+ ...M,
826
+ event: D
827
+ }) : u.linkTrack("agent-video", {
828
+ ...M,
829
+ event: D
830
+ }, c, ["done"]);
685
831
  }
686
- E.includes(c) && ((M = (v = n.callbacks).onError) == null || M.call(v, new Error(`Stream failed with event ${c}`), {
687
- data: h
688
- })), h.event === d.StreamDone && y();
832
+ R.includes(c) && ((_ = (k = n.callbacks).onError) == null || _.call(k, new Error(`Stream failed with event ${c}`), {
833
+ data: w
834
+ })), w.event === l.StreamDone && y();
689
835
  }
690
836
  }
691
837
  };
692
- async function w(c) {
693
- var I, P, W, D, T, x, F;
694
- (P = (I = n.callbacks).onConnectionStateChange) == null || P.call(I, k.Connecting), L = 0;
695
- const h = 3;
696
- c && !a && (delete t.chat, t.messages = Z(u), (D = (W = n.callbacks).onNewMessage) == null || D.call(W, [...t.messages], "answer"));
697
- const v = n.mode === $.DirectPlayback ? Promise.resolve(void 0) : _e(n.auth, i, p);
698
- async function M() {
699
- var U, O, V;
700
- for (let X = 1; X <= h; X++)
701
- try {
702
- const A = await xe(g, n, l, m, t.chat, c ? u : void 0);
703
- return A.chat && A.chat.id !== ((U = t.chat) == null ? void 0 : U.id) && (t.chat = A.chat, (V = (O = n.callbacks).onNewChat) == null || V.call(O, A.chat.id)), A;
704
- } catch (A) {
705
- if ((A == null ? void 0 : A.message) !== "Could not connect")
706
- throw A;
707
- }
708
- throw new Error("Could not connect");
709
- }
710
- const d = M().catch((U) => {
711
- var O, V;
712
- throw _($.Maintenance), (V = (O = n.callbacks).onConnectionStateChange) == null || V.call(O, k.Fail), U;
713
- }), [C, {
714
- streamingManager: E,
715
- chat: S
716
- }] = await Promise.all([v, d]);
717
- S && S.id !== ((T = t.chat) == null ? void 0 : T.id) && ((F = (x = n.callbacks).onNewChat) == null || F.call(x, S.id)), t.streamingManager = E, t.socketManager = C, t.chat = S, a = !1, _((S == null ? void 0 : S.chat_mode) ?? n.mode ?? $.Functional);
838
+ async function C(c) {
839
+ var R, M, D, $, j, T, A;
840
+ (M = (R = n.callbacks).onConnectionStateChange) == null || M.call(R, S.Connecting), z = 0, c && !i && (delete t.chat, t.messages = J(f), ($ = (D = n.callbacks).onNewMessage) == null || $.call(D, [...t.messages], "answer"));
841
+ const w = n.mode === E.DirectPlayback ? Promise.resolve(void 0) : ke(n.auth, r, g), k = X(() => Ne(d, n, m, u, t.chat, c ? f : void 0), {
842
+ limit: 3,
843
+ timeout: ze,
844
+ timeoutErrorMessage: "Could not connect",
845
+ // Retry on all errors except for connection errors and rate limit errors, these are already handled in client level.
846
+ shouldRetryFn: (I) => (I == null ? void 0 : I.message) !== "Could not connect" && I.status !== 429,
847
+ delayMs: 1e3
848
+ }).catch((I) => {
849
+ var F, V;
850
+ throw v(E.Maintenance), (V = (F = n.callbacks).onConnectionStateChange) == null || V.call(F, S.Fail), I;
851
+ }), [_, {
852
+ streamingManager: l,
853
+ chat: p
854
+ }] = await Promise.all([w, k]);
855
+ p && p.id !== ((j = t.chat) == null ? void 0 : j.id) && ((A = (T = n.callbacks).onNewChat) == null || A.call(T, p.id)), t.streamingManager = l, t.socketManager = _, t.chat = p, i = !1, v((p == null ? void 0 : p.chat_mode) ?? n.mode ?? E.Functional);
718
856
  }
719
857
  async function y() {
720
- var c, h, v, M;
721
- (c = t.socketManager) == null || c.disconnect(), await ((h = t.streamingManager) == null ? void 0 : h.disconnect()), delete t.streamingManager, delete t.socketManager, (M = (v = n.callbacks).onConnectionStateChange) == null || M.call(v, k.Disconnected);
858
+ var c, w, k, _;
859
+ (c = t.socketManager) == null || c.disconnect(), await ((w = t.streamingManager) == null ? void 0 : w.disconnect()), delete t.streamingManager, delete t.socketManager, (_ = (k = n.callbacks).onConnectionStateChange) == null || _.call(k, S.Disconnected);
722
860
  }
723
- async function _(c) {
724
- var h, v;
725
- c !== t.chatMode && (m.track("agent-mode-change", {
861
+ async function v(c) {
862
+ var w, k;
863
+ c !== t.chatMode && (u.track("agent-mode-change", {
726
864
  mode: c
727
- }), t.chatMode = c, t.chatMode !== $.Functional && await y(), (v = (h = n.callbacks).onModeChange) == null || v.call(h, c));
865
+ }), t.chatMode = c, t.chatMode !== E.Functional && await y(), (k = (w = n.callbacks).onModeChange) == null || k.call(w, c));
728
866
  }
729
867
  return {
730
- agent: g,
731
- starterMessages: ((b = g.knowledge) == null ? void 0 : b.starter_message) || [],
732
- getSTTToken: () => l.getSTTToken(g.id),
733
- changeMode: _,
734
- enrichAnalytics: m.enrich,
868
+ agent: d,
869
+ starterMessages: ((P = d.knowledge) == null ? void 0 : P.starter_message) || [],
870
+ getSTTToken: () => m.getSTTToken(d.id),
871
+ changeMode: v,
872
+ enrichAnalytics: u.enrich,
735
873
  async connect() {
736
874
  var c;
737
- await w(!0), m.track("agent-chat", {
875
+ await C(!0), u.track("agent-chat", {
738
876
  event: "connect",
739
877
  chatId: (c = t.chat) == null ? void 0 : c.id,
740
- agentId: g.id,
878
+ agentId: d.id,
741
879
  mode: t.chatMode
742
880
  });
743
881
  },
744
882
  async reconnect() {
745
883
  var c;
746
- await y(), await w(!1), m.track("agent-chat", {
884
+ await y(), await C(!1), u.track("agent-chat", {
747
885
  event: "reconnect",
748
886
  chatId: (c = t.chat) == null ? void 0 : c.id,
749
- agentId: g.id,
887
+ agentId: d.id,
750
888
  mode: t.chatMode
751
889
  });
752
890
  },
753
891
  async disconnect() {
754
892
  var c;
755
- await y(), m.track("agent-chat", {
893
+ await y(), u.track("agent-chat", {
756
894
  event: "disconnect",
757
895
  chatId: (c = t.chat) == null ? void 0 : c.id,
758
- agentId: g.id,
896
+ agentId: d.id,
759
897
  mode: t.chatMode
760
898
  });
761
899
  },
762
900
  async chat(c) {
763
- var v, M, d, C, E, S;
764
- const h = H();
901
+ var k, _, l, p, R, M;
902
+ const w = K();
765
903
  s = {};
766
904
  try {
767
- if (L = Date.now(), n.mode === $.DirectPlayback)
905
+ if (z = Date.now(), n.mode === E.DirectPlayback)
768
906
  throw new Error("Direct playback is enabled, chat is disabled");
769
907
  if (c.length >= 800)
770
908
  throw new Error("Message cannot be more than 800 characters");
771
909
  if (c.length === 0)
772
910
  throw new Error("Message cannot be empty");
773
- if (t.chatMode === $.Maintenance)
911
+ if (t.chatMode === E.Maintenance)
774
912
  throw new Error("Chat is in maintenance mode");
775
- if (![$.TextOnly, $.Playground].includes(t.chatMode))
913
+ if (![E.TextOnly, E.Playground].includes(t.chatMode))
776
914
  if (t.streamingManager) {
777
915
  if (!t.chat)
778
916
  throw new Error("Chat is not initialized");
779
917
  } else
780
918
  throw new Error("Streaming manager is not initialized");
781
919
  t.messages.push({
782
- id: H(),
920
+ id: K(),
783
921
  role: "user",
784
922
  content: c,
785
- created_at: new Date(L).toISOString()
786
- }), (M = (v = n.callbacks).onNewMessage) == null || M.call(v, [...t.messages], "user"), t.chat || (t.chat = await ae(g.id, l, m, t.chatMode, n.persistentChat), (C = (d = n.callbacks).onNewChat) == null || C.call(d, t.chat.id));
787
- const I = {
788
- id: h,
923
+ created_at: new Date(z).toISOString()
924
+ }), (_ = (k = n.callbacks).onNewMessage) == null || _.call(k, [...t.messages], "user"), t.chat || (t.chat = await te(d.id, m, u, t.chatMode, n.persistentChat), (p = (l = n.callbacks).onNewChat) == null || p.call(l, t.chat.id));
925
+ const D = {
926
+ id: w,
789
927
  role: "assistant",
790
928
  content: "",
791
929
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
792
930
  matches: []
793
- }, P = [...t.messages];
794
- t.messages.push(I);
795
- const W = (T) => {
796
- var x, F;
797
- return l.chat(g.id, T, {
798
- sessionId: (x = t.streamingManager) == null ? void 0 : x.sessionId,
931
+ }, $ = [...t.messages];
932
+ t.messages.push(D);
933
+ const j = (A) => {
934
+ var I, F;
935
+ return m.chat(d.id, A, {
936
+ sessionId: (I = t.streamingManager) == null ? void 0 : I.sessionId,
799
937
  streamId: (F = t.streamingManager) == null ? void 0 : F.streamId,
800
938
  chatMode: t.chatMode,
801
- messages: P.map(({
802
- matches: U,
803
- ...O
804
- }) => O)
805
- }, re(t.chatMode));
806
- }, D = await W(t.chat.id).catch(async (T) => {
807
- var x;
808
- if (!((x = T == null ? void 0 : T.message) != null && x.includes("missing or invalid session_id")))
809
- throw T;
810
- return await y(), await w(!1), W(t.chat.id);
939
+ messages: $.map(({
940
+ matches: V,
941
+ ...ne
942
+ }) => ne)
943
+ }, ee(t.chatMode));
944
+ }, T = await j(t.chat.id).catch(async (A) => {
945
+ var I;
946
+ if (!((I = A == null ? void 0 : A.message) != null && I.includes("missing or invalid session_id")))
947
+ throw A;
948
+ return await y(), await C(!1), j(t.chat.id);
811
949
  });
812
- return m.track("agent-message-send", {
950
+ return u.track("agent-message-send", {
813
951
  event: "success",
814
952
  mode: t.chatMode,
815
953
  messages: t.messages.length + 1
816
- }), I.context = D.context, I.matches = D.matches, D.result && (I.content = D.result, m.track("agent-message-received", {
817
- latency: Date.now() - L,
954
+ }), D.context = T.context, D.matches = T.matches, T.result && (D.content = T.result, u.track("agent-message-received", {
955
+ latency: Date.now() - z,
818
956
  mode: t.chatMode,
819
957
  messages: t.messages.length
820
- }), (S = (E = n.callbacks).onNewMessage) == null || S.call(E, [...t.messages], "answer")), D;
821
- } catch (I) {
822
- throw t.messages[t.messages.length - 1].id === h && t.messages.pop(), m.track("agent-message-send", {
958
+ }), (M = (R = n.callbacks).onNewMessage) == null || M.call(R, [...t.messages], "answer")), T;
959
+ } catch (D) {
960
+ throw t.messages[t.messages.length - 1].id === w && t.messages.pop(), u.track("agent-message-send", {
823
961
  event: "error",
824
962
  mode: t.chatMode,
825
963
  messages: t.messages.length
826
- }), I;
964
+ }), D;
827
965
  }
828
966
  },
829
- rate(c, h, v) {
830
- var C, E, S, I;
831
- const M = t.messages.find((P) => P.id === c);
967
+ rate(c, w, k) {
968
+ var p, R, M, D;
969
+ const _ = t.messages.find(($) => $.id === c);
832
970
  if (t.chat) {
833
- if (!M)
971
+ if (!_)
834
972
  throw new Error("Message not found");
835
973
  } else
836
974
  throw new Error("Chat is not initialized");
837
- const d = ((C = M.matches) == null ? void 0 : C.map((P) => [P.document_id, P.id])) ?? [];
838
- return m.track("agent-rate", {
839
- event: v ? "update" : "create",
840
- thumb: h === 1 ? "up" : "down",
841
- knowledge_id: ((E = g.knowledge) == null ? void 0 : E.id) ?? "",
975
+ const l = ((p = _.matches) == null ? void 0 : p.map(($) => [$.document_id, $.id])) ?? [];
976
+ return u.track("agent-rate", {
977
+ event: k ? "update" : "create",
978
+ thumb: w === 1 ? "up" : "down",
979
+ knowledge_id: ((R = d.knowledge) == null ? void 0 : R.id) ?? "",
842
980
  mode: t.chatMode,
843
- matches: d,
844
- score: h
845
- }), v ? l.updateRating(g.id, t.chat.id, v, {
846
- knowledge_id: ((S = g.knowledge) == null ? void 0 : S.id) ?? "",
981
+ matches: l,
982
+ score: w
983
+ }), k ? m.updateRating(d.id, t.chat.id, k, {
984
+ knowledge_id: ((M = d.knowledge) == null ? void 0 : M.id) ?? "",
847
985
  message_id: c,
848
- matches: d,
849
- score: h
850
- }) : l.createRating(g.id, t.chat.id, {
851
- knowledge_id: ((I = g.knowledge) == null ? void 0 : I.id) ?? "",
986
+ matches: l,
987
+ score: w
988
+ }) : m.createRating(d.id, t.chat.id, {
989
+ knowledge_id: ((D = d.knowledge) == null ? void 0 : D.id) ?? "",
852
990
  message_id: c,
853
- matches: d,
854
- score: h
991
+ matches: l,
992
+ score: w
855
993
  });
856
994
  },
857
995
  deleteRate(c) {
858
- var h;
996
+ var w;
859
997
  if (!t.chat)
860
998
  throw new Error("Chat is not initialized");
861
- return m.track("agent-rate-delete", {
999
+ return u.track("agent-rate-delete", {
862
1000
  type: "text",
863
- chat_id: (h = t.chat) == null ? void 0 : h.id,
1001
+ chat_id: (w = t.chat) == null ? void 0 : w.id,
864
1002
  id: c,
865
1003
  mode: t.chatMode
866
- }), l.deleteRating(g.id, t.chat.id, c);
1004
+ }), m.deleteRating(d.id, t.chat.id, c);
867
1005
  },
868
1006
  speak(c) {
869
1007
  if (!t.streamingManager)
870
1008
  throw new Error("Please connect to the agent first");
871
- function h() {
1009
+ function w() {
872
1010
  if (typeof c == "string") {
873
- if (!g.presenter.voice)
1011
+ if (!d.presenter.voice)
874
1012
  throw new Error("Presenter voice is not initialized");
875
1013
  return {
876
1014
  type: "text",
877
- provider: g.presenter.voice,
1015
+ provider: d.presenter.voice,
878
1016
  input: c,
879
1017
  ssml: !1
880
1018
  };
881
1019
  }
882
1020
  if (c.type === "text" && !c.provider) {
883
- if (!g.presenter.voice)
1021
+ if (!d.presenter.voice)
884
1022
  throw new Error("Presenter voice is not initialized");
885
1023
  return {
886
1024
  type: "text",
887
- provider: g.presenter.voice,
1025
+ provider: d.presenter.voice,
888
1026
  input: c.input,
889
1027
  ssml: c.ssml
890
1028
  };
891
1029
  }
892
1030
  return c;
893
1031
  }
894
- const v = h();
895
- return m.track("agent-speak", v), t.streamingManager.speak({
896
- script: v
1032
+ const k = w();
1033
+ return u.track("agent-speak", k), t.streamingManager.speak({
1034
+ script: k
897
1035
  });
898
1036
  }
899
1037
  };
900
1038
  }
901
1039
  function Ke(e, n, s) {
902
1040
  const {
903
- getById: a
904
- } = te(n, s || B);
905
- return a(e);
1041
+ getById: i
1042
+ } = G(n, s || H);
1043
+ return i(e);
906
1044
  }
907
1045
  export {
908
- oe as AgentStatus,
909
- $ as ChatMode,
910
- j as ChatProgress,
911
- k as ConnectionState,
912
- ge as DocumentType,
913
- le as KnowledgeType,
914
- se as PlanGroup,
915
- ue as Providers,
916
- ce as RateState,
917
- q as StreamEvents,
918
- K as StreamingState,
919
- de as Subject,
920
- ie as UserPlan,
921
- G as VideoType,
922
- he as VoiceAccess,
923
- je as createAgentManager,
1046
+ ie as AgentStatus,
1047
+ E as ChatMode,
1048
+ N as ChatProgress,
1049
+ S as ConnectionState,
1050
+ de as DocumentType,
1051
+ ce as KnowledgeType,
1052
+ ae as PlanGroup,
1053
+ me as Providers,
1054
+ se as RateState,
1055
+ W as StreamEvents,
1056
+ x as StreamingState,
1057
+ oe as Subject,
1058
+ re as UserPlan,
1059
+ O as VideoType,
1060
+ ue as VoiceAccess,
1061
+ He as createAgentManager,
924
1062
  Ke as getAgent,
925
- me as mapVideoType
1063
+ le as mapVideoType
926
1064
  };