@d-id/client-sdk 1.1.71 → 1.2.1-staging.341

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,90 @@
1
- var Xe = Object.defineProperty;
2
- var Ge = (e, t, r) => t in e ? Xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Z = (e, t, r) => Ge(e, typeof t != "symbol" ? t + "" : t, r);
4
- class de extends Error {
5
- constructor({ kind: r, description: a, error: c }) {
6
- super(JSON.stringify({ kind: r, description: a }));
7
- Z(this, "kind");
8
- Z(this, "description");
9
- Z(this, "error");
10
- this.kind = r, this.description = a, this.error = c;
1
+ var Ye = Object.defineProperty;
2
+ var Qe = (e, t, r) => t in e ? Ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var Z = (e, t, r) => Qe(e, typeof t != "symbol" ? t + "" : t, r);
4
+ class G extends Error {
5
+ constructor(t, r = "Error", a) {
6
+ super(t), this.kind = r, this.originalError = a, Object.setPrototypeOf(this, new.target.prototype);
7
+ }
8
+ toJson() {
9
+ const t = this.originalError instanceof Error ? this.originalError.message.slice(0, 256) : void 0;
10
+ return {
11
+ kind: this.kind,
12
+ message: this.message,
13
+ ...t && t !== this.message ? { cause: t } : {}
14
+ };
11
15
  }
12
16
  }
13
- class Ye extends de {
17
+ function gr(e) {
18
+ return e instanceof Error && typeof e.kind == "string";
19
+ }
20
+ class Ze extends G {
14
21
  constructor(t, r) {
15
- super({
16
- kind: "ChatCreationFailed",
17
- description: `Failed to create ${r ? "persistent" : ""} chat, mode: ${t}`
18
- });
22
+ super(`Failed to create ${r ? "persistent" : ""} chat, mode: ${t}`, "ChatCreationFailed");
19
23
  }
20
24
  }
21
- class Qe extends de {
25
+ class et extends G {
22
26
  constructor(t) {
23
- super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
27
+ super(`Chat mode downgraded to ${t}`, "ChatModeDowngraded");
28
+ }
29
+ }
30
+ function tt(e) {
31
+ try {
32
+ const t = JSON.parse(e);
33
+ if (t && typeof t == "object" && typeof t.kind == "string")
34
+ return t;
35
+ } catch {
24
36
  }
25
37
  }
26
- class Y extends de {
27
- constructor(r, a) {
28
- super({ kind: "ValidationError", description: r });
29
- Z(this, "key");
30
- this.key = a;
38
+ class ze extends G {
39
+ constructor(r, a, c = {}) {
40
+ const i = tt(a);
41
+ super(((i == null ? void 0 : i.description) ?? a).slice(0, 256), (i == null ? void 0 : i.kind) ?? "HttpError");
42
+ Z(this, "status");
43
+ Z(this, "url");
44
+ Z(this, "method");
45
+ this.status = r, this.url = c.url, this.method = c.method;
46
+ }
47
+ toJson() {
48
+ return {
49
+ ...super.toJson(),
50
+ httpStatus: this.status,
51
+ ...this.url ? { endpoint: this.url } : {},
52
+ ...this.method ? { method: this.method } : {}
53
+ };
54
+ }
55
+ }
56
+ class rt extends G {
57
+ constructor(r, a = {}) {
58
+ super("Network request failed", "NetworkError", r);
59
+ Z(this, "endpoint");
60
+ Z(this, "method");
61
+ this.endpoint = a.url, this.method = a.method;
62
+ }
63
+ toJson() {
64
+ return {
65
+ ...super.toJson(),
66
+ ...this.endpoint ? { endpoint: this.endpoint } : {},
67
+ ...this.method ? { method: this.method } : {}
68
+ };
31
69
  }
32
70
  }
33
- class Ze extends de {
71
+ class Ne extends G {
72
+ constructor(t, r) {
73
+ super(t, "StreamError", r);
74
+ }
75
+ }
76
+ class $ extends G {
77
+ constructor(t, r) {
78
+ super(t, "ValidationError"), this.key = r;
79
+ }
80
+ }
81
+ class nt extends G {
34
82
  constructor(t) {
35
- super({ kind: "WSError", description: t });
83
+ super(t, "WSError");
36
84
  }
37
85
  }
38
- var et = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(et || {}), tt = /* @__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))(tt || {}), rt = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(rt || {}), nt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(nt || {}), A = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(A || {}), B = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(B || {}), at = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(at || {}), it = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(it || {}), st = /* @__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))(st || {}), ze = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(ze || {});
39
- const lr = (e) => {
86
+ var at = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(at || {}), it = /* @__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))(it || {}), st = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(st || {}), ot = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(ot || {}), A = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(A || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), ct = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(dt || {}), lt = /* @__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))(lt || {}), Fe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Fe || {});
87
+ const hr = (e) => {
40
88
  switch (e) {
41
89
  case "clip":
42
90
  return "clip";
@@ -48,9 +96,9 @@ const lr = (e) => {
48
96
  throw new Error(`Unknown video type: ${e}`);
49
97
  }
50
98
  };
51
- var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), b = /* @__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))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), he = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(he || {}), ot = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ot || {}), ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(ct || {});
52
- const ur = (...e) => {
53
- }, Fe = (e) => new Promise((t) => setTimeout(t, e)), G = (e = 16) => {
99
+ var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}), ae = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ae || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), b = /* @__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))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), pe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(pe || {}), ut = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ut || {}), mt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(mt || {});
100
+ const pr = (...e) => {
101
+ }, Ve = (e) => new Promise((t) => setTimeout(t, e)), Q = (e = 16) => {
54
102
  const t = new Uint8Array(e);
55
103
  return window.crypto.getRandomValues(t), Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("").slice(0, 13);
56
104
  };
@@ -59,25 +107,25 @@ function me(e) {
59
107
  return window.localStorage.setItem("did_external_key_id", e), e;
60
108
  let t = window.localStorage.getItem("did_external_key_id");
61
109
  if (!t) {
62
- let r = G();
110
+ let r = Q();
63
111
  window.localStorage.setItem("did_external_key_id", r), t = r;
64
112
  }
65
113
  return t;
66
114
  }
67
- let Ne = G();
68
- function dt() {
69
- Ne = G();
115
+ let Je = Q();
116
+ function ft() {
117
+ Je = Q();
70
118
  }
71
- function Ve(e, t) {
119
+ function Ue(e, t) {
72
120
  if (e.type === "bearer")
73
121
  return `Bearer ${e.token}`;
74
122
  if (e.type === "basic")
75
123
  return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}`;
76
124
  if (e.type === "key")
77
- return `Client-Key ${e.clientKey}.${me(t)}_${Ne}`;
125
+ return `Client-Key ${e.clientKey}.${me(t)}_${Je}`;
78
126
  throw new Error(`Unknown auth type: ${e}`);
79
127
  }
80
- const lt = 45 * 1e3, ut = "X-Playground-Chat", ke = 2e3, le = "https://api.d-id.com", mt = "wss://notifications.d-id.com", ft = "79f81a83a67430be2bc0fd61042b8faa", Ke = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, gt = (e) => {
128
+ const gt = 45 * 1e3, ht = "X-Playground-Chat", ke = 2e3, le = "https://api.d-id.com", pt = "wss://notifications.d-id.com", wt = "79f81a83a67430be2bc0fd61042b8faa", Ke = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, vt = (e) => {
81
129
  switch (e.type) {
82
130
  case "expressive":
83
131
  return "v4";
@@ -86,13 +134,13 @@ const lt = 45 * 1e3, ut = "X-Playground-Chat", ke = 2e3, le = "https://api.d-id.
86
134
  case "talk":
87
135
  return "v2";
88
136
  }
89
- }, pt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, we = (e) => e === ze.Expressive, ht = (e) => [A.TextOnly, A.Playground, A.Maintenance].includes(e), Ue = (e) => e && [A.DirectPlayback, A.Off].includes(e), Re = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, Ie = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, wt = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
90
- function vt(e) {
137
+ }, yt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, we = (e) => e === Fe.Expressive, Ct = (e) => [A.TextOnly, A.Playground, A.Maintenance].includes(e), We = (e) => e && [A.DirectPlayback, A.Off].includes(e), Re = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, De = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, St = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
138
+ function kt(e) {
91
139
  const t = e.split("?")[0].split("#")[0].toLowerCase();
92
- return wt.some((r) => t.endsWith(r));
140
+ return St.some((r) => t.endsWith(r));
93
141
  }
94
- const De = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), Me = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
95
- function yt(e) {
142
+ const Ie = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), Me = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
143
+ function Rt(e) {
96
144
  if (e.length === 0)
97
145
  return [];
98
146
  const t = [];
@@ -103,13 +151,13 @@ function yt(e) {
103
151
  length: r[0].length,
104
152
  part: { type: "video", src: r[3], alt: r[1], thumbnail: r[2] }
105
153
  });
106
- for (Ie.lastIndex = 0; (r = Ie.exec(e)) !== null; )
154
+ for (De.lastIndex = 0; (r = De.exec(e)) !== null; )
107
155
  if (!t.some((o) => r.index >= o.index && r.index < o.index + o.length)) {
108
156
  const o = r[2], n = r[1];
109
- let i;
110
- vt(o) ? i = { type: "video", src: o, alt: n } : (i = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (i.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: i });
157
+ let s;
158
+ kt(o) ? s = { type: "video", src: o, alt: n } : (s = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (s.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: s });
111
159
  }
112
- for (De.lastIndex = 0; (r = De.exec(e)) !== null; )
160
+ for (Ie.lastIndex = 0; (r = Ie.exec(e)) !== null; )
113
161
  t.some((o) => r.index >= o.index && r.index < o.index + o.length) || t.push({
114
162
  index: r.index,
115
163
  length: r[0].length,
@@ -123,22 +171,22 @@ function yt(e) {
123
171
  });
124
172
  if (t.length === 0)
125
173
  return [{ type: "text", text: e }];
126
- t.sort((s, o) => s.index - o.index);
174
+ t.sort((i, o) => i.index - o.index);
127
175
  const a = [];
128
176
  let c = 0;
129
- for (const s of t)
130
- s.index > c && a.push({ type: "text", text: e.slice(c, s.index) }), a.push(s.part), c = s.index + s.length;
177
+ for (const i of t)
178
+ i.index > c && a.push({ type: "text", text: e.slice(c, i.index) }), a.push(i.part), c = i.index + i.length;
131
179
  return c < e.length && a.push({ type: "text", text: e.slice(c) }), a;
132
180
  }
133
181
  let Ee = "", ue = [];
134
- function re(e) {
135
- return e === Ee || (Ee = e, ue = yt(e)), ue;
182
+ function ne(e) {
183
+ return e === Ee || (Ee = e, ue = Rt(e)), ue;
136
184
  }
137
- function Ct(e, t) {
185
+ function Dt(e, t) {
138
186
  let r;
139
187
  return {
140
- promise: new Promise((c, s) => {
141
- r = setTimeout(() => s(new Error(t)), e);
188
+ promise: new Promise((c, i) => {
189
+ r = setTimeout(() => i(new Error(t)), e);
142
190
  }),
143
191
  clear: () => clearTimeout(r)
144
192
  };
@@ -158,104 +206,106 @@ async function fe(e, t) {
158
206
  try {
159
207
  if (!r.timeout)
160
208
  return await e();
161
- const { promise: s, clear: o } = Ct(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
162
- return await Promise.race([n, s]);
163
- } catch (s) {
164
- if (a = s, !r.shouldRetryFn(s) || c >= r.limit)
165
- throw s;
166
- await Fe(r.delayMs), r.onRetry(s);
209
+ const { promise: i, clear: o } = Dt(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
210
+ return await Promise.race([n, i]);
211
+ } catch (i) {
212
+ if (a = i, !r.shouldRetryFn(i) || c >= r.limit)
213
+ throw i;
214
+ await Ve(r.delayMs), r.onRetry(i);
167
215
  }
168
216
  throw a;
169
217
  }
170
- const St = (e) => fe(e, {
218
+ const It = (e) => fe(e, {
171
219
  limit: 3,
172
220
  delayMs: 1e3,
173
221
  timeout: 0,
174
222
  shouldRetryFn: (t) => t.status === 429
175
223
  });
176
- function We(e, t = le, r, a) {
177
- const c = async (s, o) => {
178
- const { skipErrorHandler: n, ...i } = o || {};
224
+ function He(e, t = le, r, a) {
225
+ const c = async (i, o) => {
226
+ const { skipErrorHandler: n, ...s } = o || {};
179
227
  let d;
180
228
  try {
181
- d = await St(
182
- () => fetch(t + (s != null && s.startsWith("/") ? s : `/${s}`), {
183
- ...i,
229
+ d = await It(
230
+ () => fetch(t + (i != null && i.startsWith("/") ? i : `/${i}`), {
231
+ ...s,
184
232
  headers: {
185
- ...i.headers,
186
- Authorization: Ve(e, a),
233
+ ...s.headers,
234
+ Authorization: Ue(e, a),
187
235
  "Content-Type": "application/json"
188
236
  }
189
237
  })
190
238
  );
191
239
  } catch (u) {
192
- throw !((u == null ? void 0 : u.name) === "AbortError") && r && !n && r(u, { url: s, options: i }), u;
240
+ if ((u == null ? void 0 : u.name) === "AbortError")
241
+ throw u;
242
+ const m = new rt(u, { url: i, method: s.method ?? "GET" });
243
+ throw n || r == null || r(m, { url: i, options: s }), m;
193
244
  }
194
245
  if (!d.ok) {
195
- let u = await d.text().catch(() => `Failed to fetch with status ${d.status}`);
196
- const m = new Error(u);
197
- throw r && !n && r(m, { url: s, options: i, headers: d.headers }), m;
246
+ const u = await d.text().catch(() => `Failed to fetch with status ${d.status}`), f = new ze(d.status, u, { url: i, method: s.method ?? "GET" });
247
+ throw n || r == null || r(f, { url: i, options: s, headers: d.headers }), f;
198
248
  }
199
249
  return d.json();
200
250
  };
201
251
  return {
202
- get(s, o) {
203
- return c(s, { ...o, method: "GET" });
252
+ get(i, o) {
253
+ return c(i, { ...o, method: "GET" });
204
254
  },
205
- post(s, o, n) {
206
- return c(s, { ...n, body: JSON.stringify(o), method: "POST" });
255
+ post(i, o, n) {
256
+ return c(i, { ...n, body: JSON.stringify(o), method: "POST" });
207
257
  },
208
- delete(s, o, n) {
209
- return c(s, { ...n, body: JSON.stringify(o), method: "DELETE" });
258
+ delete(i, o, n) {
259
+ return c(i, { ...n, body: JSON.stringify(o), method: "DELETE" });
210
260
  },
211
- patch(s, o, n) {
212
- return c(s, { ...n, body: JSON.stringify(o), method: "PATCH" });
261
+ patch(i, o, n) {
262
+ return c(i, { ...n, body: JSON.stringify(o), method: "PATCH" });
213
263
  }
214
264
  };
215
265
  }
216
- function kt(e, t = le, r, a) {
217
- const c = We(e, `${t}/agents`, r, a);
266
+ function Mt(e, t = le, r, a) {
267
+ const c = He(e, `${t}/agents`, r, a);
218
268
  return {
219
- create(s, o) {
220
- return c.post("/", s, o);
269
+ create(i, o) {
270
+ return c.post("/", i, o);
221
271
  },
222
- getAgents(s, o) {
223
- return c.get(`/${s ? `?tag=${s}` : ""}`, o).then((n) => n ?? []);
272
+ getAgents(i, o) {
273
+ return c.get(`/${i ? `?tag=${i}` : ""}`, o).then((n) => n ?? []);
224
274
  },
225
- getById(s, o) {
226
- return c.get(`/${s}`, o);
275
+ getById(i, o) {
276
+ return c.get(`/${i}`, o);
227
277
  },
228
- delete(s, o) {
229
- return c.delete(`/${s}`, void 0, o);
278
+ delete(i, o) {
279
+ return c.delete(`/${i}`, void 0, o);
230
280
  },
231
- update(s, o, n) {
232
- return c.patch(`/${s}`, o, n);
281
+ update(i, o, n) {
282
+ return c.patch(`/${i}`, o, n);
233
283
  },
234
- newChat(s, o, n) {
235
- return c.post(`/${s}/chat`, o, n);
284
+ newChat(i, o, n) {
285
+ return c.post(`/${i}/chat`, o, n);
236
286
  },
237
- chat(s, o, n, i) {
238
- return c.post(`/${s}/chat/${o}`, n, i);
287
+ chat(i, o, n, s) {
288
+ return c.post(`/${i}/chat/${o}`, n, s);
239
289
  },
240
- createRating(s, o, n, i) {
241
- return c.post(`/${s}/chat/${o}/ratings`, n, i);
290
+ createRating(i, o, n, s) {
291
+ return c.post(`/${i}/chat/${o}/ratings`, n, s);
242
292
  },
243
- updateRating(s, o, n, i, d) {
244
- return c.patch(`/${s}/chat/${o}/ratings/${n}`, i, d);
293
+ updateRating(i, o, n, s, d) {
294
+ return c.patch(`/${i}/chat/${o}/ratings/${n}`, s, d);
245
295
  },
246
- deleteRating(s, o, n, i) {
247
- return c.delete(`/${s}/chat/${o}/ratings/${n}`, i);
296
+ deleteRating(i, o, n, s) {
297
+ return c.delete(`/${i}/chat/${o}/ratings/${n}`, s);
248
298
  },
249
- getSTTToken(s, o) {
250
- return c.get(`/${s}/stt-token`, o);
299
+ getSTTToken(i, o) {
300
+ return c.get(`/${i}/stt-token`, o);
251
301
  }
252
302
  };
253
303
  }
254
- function Rt(e) {
255
- var c, s, o, n;
304
+ function Et(e) {
305
+ var c, i, o, n;
256
306
  const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", r = () => {
257
- const i = navigator.platform;
258
- return i.toLowerCase().includes("win") ? "Windows" : i.toLowerCase().includes("mac") ? "Mac OS X" : i.toLowerCase().includes("linux") ? "Linux" : "Unknown";
307
+ const s = navigator.platform;
308
+ return s.toLowerCase().includes("win") ? "Windows" : s.toLowerCase().includes("mac") ? "Mac OS X" : s.toLowerCase().includes("linux") ? "Linux" : "Unknown";
259
309
  }, a = e.presenter;
260
310
  return {
261
311
  $os: `${r()}`,
@@ -264,18 +314,18 @@ function Rt(e) {
264
314
  origin: window.location.origin,
265
315
  agentType: Ke(a),
266
316
  agentVoice: {
267
- voiceId: (s = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : s.voice_id,
317
+ voiceId: (i = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : i.voice_id,
268
318
  provider: (n = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : n.type
269
319
  }
270
320
  };
271
321
  }
272
- function It(e) {
273
- var r, a, c, s, o, n;
322
+ function Tt(e) {
323
+ var r, a, c, i, o, n;
274
324
  const t = (r = e.llm) == null ? void 0 : r.prompt_customization;
275
325
  return {
276
326
  agentType: Ke(e.presenter),
277
- presenterType: gt(e.presenter),
278
- presenter: pt(e.presenter),
327
+ presenterType: vt(e.presenter),
328
+ presenter: yt(e.presenter),
279
329
  owner_id: e.owner_id ?? "",
280
330
  promptVersion: (a = e.llm) == null ? void 0 : a.prompt_version,
281
331
  behavior: {
@@ -283,7 +333,7 @@ function It(e) {
283
333
  personality: t == null ? void 0 : t.personality,
284
334
  instructions: (c = e.llm) == null ? void 0 : c.instructions
285
335
  },
286
- temperature: (s = e.llm) == null ? void 0 : s.temperature,
336
+ temperature: (i = e.llm) == null ? void 0 : i.temperature,
287
337
  knowledgeSource: t == null ? void 0 : t.knowledge_source,
288
338
  starterQuestionsCount: (n = (o = e.knowledge) == null ? void 0 : o.starter_message) == null ? void 0 : n.length,
289
339
  topicsToAvoid: t == null ? void 0 : t.topics_to_avoid,
@@ -294,29 +344,32 @@ function It(e) {
294
344
  ...e.access === "public" ? { from: "agent-template" } : {}
295
345
  };
296
346
  }
297
- const _e = (e) => {
347
+ const _t = (e) => {
298
348
  try {
299
349
  return String((e == null ? void 0 : e.message) ?? e ?? "").slice(0, 256);
300
350
  } catch {
301
351
  return "Unknown error";
302
352
  }
303
- }, Dt = (e) => e.reduce((t, r) => t + r, 0), Te = (e) => Dt(e) / e.length;
304
- function Mt(e, t, r) {
305
- var i, d, u;
306
- const { event: a, ...c } = e, { template: s } = (t == null ? void 0 : t.llm) || {}, { language: o } = ((i = t == null ? void 0 : t.presenter) == null ? void 0 : i.voice) || {};
353
+ }, At = (e) => e.reduce((t, r) => t + r, 0), Te = (e) => At(e) / e.length;
354
+ function bt(e, t, r) {
355
+ var s, d, u;
356
+ const { event: a, ...c } = e, { template: i } = (t == null ? void 0 : t.llm) || {}, { language: o } = ((s = t == null ? void 0 : t.presenter) == null ? void 0 : s.voice) || {};
307
357
  return {
308
358
  ...c,
309
- llm: { ...c.llm, template: s },
359
+ llm: { ...c.llm, template: i },
310
360
  script: { ...c.script, provider: { ...(d = c == null ? void 0 : c.script) == null ? void 0 : d.provider, language: o } },
311
361
  stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (u = t == null ? void 0 : t.presenter) == null ? void 0 : u.stitch : void 0,
312
362
  ...r
313
363
  };
314
364
  }
315
- function Ae(e) {
365
+ function _e(e) {
316
366
  "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
317
367
  }
318
- const Et = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
319
- function _t(e) {
368
+ function Ae(e) {
369
+ return e instanceof G ? e.toJson() : { kind: "UnknownError", message: _t(e) || "UnknownError" };
370
+ }
371
+ const xt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
372
+ function Lt(e) {
320
373
  const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = {};
321
374
  return {
322
375
  token: e.token || "testKey",
@@ -327,14 +380,14 @@ function _t(e) {
327
380
  ...e.mixpanelAdditionalProperties || {}
328
381
  },
329
382
  isEnabled: e.isEnabled ?? !0,
330
- getRandom: G,
383
+ getRandom: Q,
331
384
  enrich(a) {
332
385
  this.additionalProperties = { ...this.additionalProperties, ...a };
333
386
  },
334
- async track(a, c, s) {
387
+ async track(a, c, i) {
335
388
  if (!this.isEnabled)
336
389
  return Promise.resolve();
337
- const { audioPath: o, ...n } = c || {}, i = s || Date.now(), d = {
390
+ const { audioPath: o, ...n } = c || {}, s = i || Date.now(), d = {
338
391
  method: "POST",
339
392
  headers: {
340
393
  "Content-Type": "application/x-www-form-urlencoded"
@@ -349,7 +402,7 @@ function _t(e) {
349
402
  agentId: this.agentId,
350
403
  source: t,
351
404
  token: this.token,
352
- time: i,
405
+ time: s,
353
406
  $insert_id: this.getRandom(),
354
407
  origin: window.location.href,
355
408
  "Screen Height": window.screen.height || window.innerWidth,
@@ -360,15 +413,15 @@ function _t(e) {
360
413
  ])
361
414
  })
362
415
  };
363
- return fetch(Et, d).catch((u) => console.error("Analytics tracking error:", u)), Promise.resolve();
416
+ return fetch(xt, d).catch((u) => console.error("Analytics tracking error:", u)), Promise.resolve();
364
417
  },
365
- linkTrack(a, c, s, o) {
366
- r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
418
+ linkTrack(a, c, i, o) {
419
+ r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(i) || o.push(i);
367
420
  const n = r[a];
368
- if (n.events[s] = { props: c }, n.resolvedDependencies.push(s), o.every(
421
+ if (n.events[i] = { props: c }, n.resolvedDependencies.push(i), o.every(
369
422
  (d) => n.resolvedDependencies.includes(d)
370
423
  )) {
371
- const d = o.reduce((u, m) => n.events[m] ? { ...u, ...n.events[m].props } : u, {});
424
+ const d = o.reduce((u, f) => n.events[f] ? { ...u, ...n.events[f].props } : u, {});
372
425
  this.track(a, d), n.resolvedDependencies = n.resolvedDependencies.filter(
373
426
  (u) => !o.includes(u)
374
427
  ), o.forEach((u) => {
@@ -386,74 +439,62 @@ function ve() {
386
439
  get: (t = !1) => t ? Date.now() - e : e
387
440
  };
388
441
  }
389
- const H = ve(), ge = ve(), be = ve();
390
- function Je(e) {
391
- return e === A.Playground ? { headers: { [ut]: "true" } } : {};
442
+ const q = ve(), ge = ve(), be = ve();
443
+ function Oe(e) {
444
+ return e === A.Playground ? { headers: { [ht]: "true" } } : {};
392
445
  }
393
- async function Oe(e, t, r, a, c = !1, s) {
394
- try {
395
- return !s && !Ue(a) && (s = await t.newChat(e.id, { persist: c }, Je(a)), r.track("agent-chat", {
396
- event: "created",
397
- chatId: s.id,
398
- mode: a
399
- })), { chat: s, chatMode: (s == null ? void 0 : s.chat_mode) ?? a };
400
- } catch (o) {
401
- throw Tt(o) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
402
- }
446
+ async function qe(e, t, r, a, c = !1, i) {
447
+ return !i && !We(a) && (i = await t.newChat(e.id, { persist: c }, Oe(a)), r.track("agent-chat", {
448
+ event: "created",
449
+ chatId: i.id,
450
+ mode: a
451
+ })), { chat: i, chatMode: (i == null ? void 0 : i.chat_mode) ?? a };
403
452
  }
404
- const Tt = (e) => {
405
- try {
406
- const t = JSON.parse(e.message);
407
- return t == null ? void 0 : t.kind;
408
- } catch {
409
- return "UnknownError";
410
- }
411
- };
412
- function At(e) {
453
+ function Pt(e) {
413
454
  return e && e.length > 0 ? e : [];
414
455
  }
415
- function bt(e) {
456
+ function jt(e) {
416
457
  return new Promise((t, r) => {
417
- const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: u = null } = a || {}, m = new WebSocket(`${c}?authorization=${encodeURIComponent(Ve(s, o))}`);
418
- m.onmessage = n, m.onclose = d, m.onerror = (f) => {
419
- console.error(f), u == null || u("Websocket failed to connect", f), r(f);
420
- }, m.onopen = (f) => {
421
- i == null || i(f), t(m);
458
+ const { callbacks: a, host: c, auth: i, externalId: o } = e, { onMessage: n = null, onOpen: s = null, onClose: d = null, onError: u = null } = a || {}, f = new WebSocket(`${c}?authorization=${encodeURIComponent(Ue(i, o))}`);
459
+ f.onmessage = n, f.onclose = d, f.onerror = (m) => {
460
+ console.error(m), u == null || u("Websocket failed to connect", m), r(m);
461
+ }, f.onopen = (m) => {
462
+ s == null || s(m), t(f);
422
463
  };
423
464
  });
424
465
  }
425
- async function xt(e) {
466
+ async function Bt(e) {
426
467
  const { retries: t = 1 } = e;
427
468
  let r = null;
428
469
  for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
429
470
  try {
430
- r = await bt(e);
471
+ r = await jt(e);
431
472
  } catch (c) {
432
473
  if (a === t)
433
474
  throw c;
434
- await Fe(a * 500);
475
+ await Ve(a * 500);
435
476
  }
436
477
  return r;
437
478
  }
438
- async function Lt(e, t, r, a) {
439
- const c = r != null && r.onMessage ? [r.onMessage] : [], s = await xt({
479
+ async function $t(e, t, r, a) {
480
+ const c = r != null && r.onMessage ? [r.onMessage] : [], i = await Bt({
440
481
  auth: e,
441
482
  host: t,
442
483
  externalId: a,
443
484
  callbacks: {
444
485
  onError: (o) => {
445
486
  var n;
446
- return (n = r.onError) == null ? void 0 : n.call(r, new Ze(o));
487
+ return (n = r.onError) == null ? void 0 : n.call(r, new nt(o));
447
488
  },
448
489
  onMessage(o) {
449
490
  const n = JSON.parse(o.data);
450
- c.forEach((i) => i(n.event, n));
491
+ c.forEach((s) => s(n.event, n));
451
492
  }
452
493
  }
453
494
  });
454
495
  return {
455
- socket: s,
456
- disconnect: () => s.close(),
496
+ socket: i,
497
+ disconnect: () => i.close(),
457
498
  subscribeToEvents: (o) => c.push(o)
458
499
  };
459
500
  }
@@ -465,35 +506,35 @@ function xe(e) {
465
506
  r += e[t++];
466
507
  return r;
467
508
  }
468
- function Pt(e, t, r) {
509
+ function zt(e, t, r) {
469
510
  if (!e.content)
470
511
  return;
471
512
  const a = {
472
513
  id: e.id || `user-${Date.now()}`,
473
514
  role: e.role,
474
515
  content: e.content,
475
- parts: re(e.content),
516
+ parts: ne(e.content),
476
517
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
477
518
  transcribed: !0
478
519
  };
479
520
  t.messages.push(a), r == null || r([...t.messages], "user");
480
521
  }
481
- function jt(e, t, r, a, c, s, o) {
482
- if (e === B.Transcribe && t.content) {
483
- Pt(t, a, c);
522
+ function Nt(e, t, r, a, c, i, o) {
523
+ if (e === z.Transcribe && t.content) {
524
+ zt(t, a, c);
484
525
  return;
485
526
  }
486
- if (!(e === B.Partial || e === B.Answer))
527
+ if (!(e === z.Partial || e === z.Answer))
487
528
  return;
488
529
  const n = a.messages[a.messages.length - 1];
489
- if (e === B.Answer && (n == null ? void 0 : n.role) === "user" && o === "partial")
530
+ if (e === z.Answer && (n == null ? void 0 : n.role) === "user" && o === "partial")
490
531
  return;
491
532
  const d = o === "answer";
492
533
  let u;
493
534
  if ((n == null ? void 0 : n.role) === "assistant" && !d)
494
535
  u = n;
495
536
  else if (!n || n.role === "user" || d)
496
- d && s(), u = {
537
+ d && i(), u = {
497
538
  id: t.id || `assistant-${Date.now()}`,
498
539
  role: t.role || "assistant",
499
540
  content: t.content || "",
@@ -502,102 +543,102 @@ function jt(e, t, r, a, c, s, o) {
502
543
  }, a.messages.push(u);
503
544
  else
504
545
  return;
505
- const { content: m, sequence: f } = t;
506
- if (e === B.Partial)
507
- r[f] = m;
546
+ const { content: f, sequence: m } = t;
547
+ if (e === z.Partial)
548
+ r[m] = f;
508
549
  else {
509
550
  const y = xe(r);
510
- !!(m && m.length < y.length) && (u.interrupted = !0), r.answer = m;
551
+ !!(f && f.length < y.length) && (u.interrupted = !0), r.answer = f;
511
552
  }
512
553
  const w = xe(r);
513
- (u.content !== w || e === B.Answer) && (u.content = w, u.parts = re(w), c == null || c([...a.messages], e));
554
+ (u.content !== w || e === z.Answer) && (u.content = w, u.parts = ne(w), c == null || c([...a.messages], e));
514
555
  }
515
- function $t(e, t, r, a, c) {
516
- const s = {}, o = () => {
517
- for (const d of Object.keys(s))
518
- delete s[d];
556
+ function Ft(e, t, r, a, c) {
557
+ const i = {}, o = () => {
558
+ for (const d of Object.keys(i))
559
+ delete i[d];
519
560
  };
520
561
  let n = null;
521
- const i = (d, u) => {
522
- var m, f;
523
- u === "user" && o(), (f = (m = r.callbacks).onNewMessage) == null || f.call(m, d, u);
562
+ const s = (d, u) => {
563
+ var f, m;
564
+ u === "user" && o(), (m = (f = r.callbacks).onNewMessage) == null || m.call(f, d, u);
524
565
  };
525
566
  return {
526
567
  clearQueue: o,
527
568
  onMessage: (d, u) => {
528
- var m, f;
569
+ var f, m;
529
570
  if ("content" in u) {
530
- const w = d === x.ChatAnswer ? B.Answer : d === x.ChatAudioTranscribed ? B.Transcribe : d;
531
- jt(
571
+ const w = d === x.ChatAnswer ? z.Answer : d === x.ChatAudioTranscribed ? z.Transcribe : d;
572
+ Nt(
532
573
  w,
533
574
  u,
534
- s,
535
- t,
536
575
  i,
576
+ t,
577
+ s,
537
578
  o,
538
579
  n
539
- ), w === B.Partial ? n = "partial" : w === B.Answer && (n = "answer", o()), w === B.Answer && e.track("agent-message-received", {
580
+ ), w === z.Partial ? n = "partial" : w === z.Answer && (n = "answer", o()), w === z.Answer && e.track("agent-message-received", {
540
581
  content: u.content,
541
582
  messages: t.messages.length,
542
583
  mode: t.chatMode
543
584
  });
544
585
  } else {
545
- const w = x, y = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], j = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], M = Mt(u, a, { mode: t.chatMode });
586
+ const w = x, y = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], j = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], M = bt(u, a, { mode: t.chatMode });
546
587
  if (d = d, d === w.StreamVideoCreated && (e.linkTrack("agent-video", M, w.StreamVideoCreated, ["start"]), u.sentiment)) {
547
- const _ = t.messages[t.messages.length - 1];
548
- if ((_ == null ? void 0 : _.role) === "assistant") {
549
- const L = { ..._, sentiment: u.sentiment };
550
- t.messages[t.messages.length - 1] = L, i == null || i([...t.messages], n ?? "answer");
588
+ const T = t.messages[t.messages.length - 1];
589
+ if ((T == null ? void 0 : T.role) === "assistant") {
590
+ const L = { ...T, sentiment: u.sentiment };
591
+ t.messages[t.messages.length - 1] = L, s == null || s([...t.messages], n ?? "answer");
551
592
  }
552
593
  }
553
594
  if (y.includes(d)) {
554
- const _ = d.split("/")[1];
555
- j.includes(d) ? e.track("agent-video", { ...M, event: _ }) : e.linkTrack("agent-video", { ...M, event: _ }, d, ["done"]);
595
+ const T = d.split("/")[1];
596
+ j.includes(d) ? e.track("agent-video", { ...M, event: T }) : e.linkTrack("agent-video", { ...M, event: T }, d, ["done"]);
556
597
  }
557
- j.includes(d) && ((f = (m = r.callbacks).onError) == null || f.call(m, new Error(`Stream failed with event ${d}`), { data: u })), u.event === w.StreamDone && c();
598
+ j.includes(d) && ((m = (f = r.callbacks).onError) == null || m.call(f, new Ne(`Stream failed with event ${d}`), { data: u })), u.event === w.StreamDone && c();
558
599
  }
559
600
  }
560
601
  };
561
602
  }
562
- function Bt(e, t, r, a) {
563
- const c = We(e, `${t}/agents/${r}`, a);
603
+ function Vt(e, t, r, a) {
604
+ const c = He(e, `${t}/agents/${r}`, a);
564
605
  return {
565
- createStream(s, o) {
566
- return c.post("/streams", s, { signal: o });
606
+ createStream(i, o) {
607
+ return c.post("/streams", i, { signal: o });
567
608
  },
568
- startConnection(s, o, n, i) {
609
+ startConnection(i, o, n, s) {
569
610
  return c.post(
570
- `/streams/${s}/sdp`,
611
+ `/streams/${i}/sdp`,
571
612
  {
572
613
  session_id: n,
573
614
  answer: o
574
615
  },
575
- { signal: i }
616
+ { signal: s }
576
617
  );
577
618
  },
578
- addIceCandidate(s, o, n, i) {
619
+ addIceCandidate(i, o, n, s) {
579
620
  return c.post(
580
- `/streams/${s}/ice`,
621
+ `/streams/${i}/ice`,
581
622
  {
582
623
  session_id: n,
583
624
  ...o
584
625
  },
585
- { signal: i }
626
+ { signal: s }
586
627
  );
587
628
  },
588
- sendStreamRequest(s, o, n) {
589
- return c.post(`/streams/${s}`, {
629
+ sendStreamRequest(i, o, n) {
630
+ return c.post(`/streams/${i}`, {
590
631
  session_id: o,
591
632
  ...n
592
633
  });
593
634
  },
594
- close(s, o) {
595
- return c.delete(`/streams/${s}`, { session_id: o });
635
+ close(i, o) {
636
+ return c.delete(`/streams/${i}`, { session_id: o });
596
637
  }
597
638
  };
598
639
  }
599
- const zt = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? "");
600
- function Ft(e, t, r) {
640
+ const Jt = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? "");
641
+ function Ut(e, t, r) {
601
642
  const a = (t.timestamp - e.timestamp) / 1e3;
602
643
  return {
603
644
  duration: a,
@@ -617,7 +658,7 @@ function Ft(e, t, r) {
617
658
  lowFpsCount: r
618
659
  };
619
660
  }
620
- function Nt(e) {
661
+ function Kt(e) {
621
662
  return e.filter(
622
663
  (t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
623
664
  ).map((t) => {
@@ -628,7 +669,7 @@ function Nt(e) {
628
669
  };
629
670
  });
630
671
  }
631
- function Vt(e) {
672
+ function Wt(e) {
632
673
  var o;
633
674
  let t = "", r = 0, a = null;
634
675
  const c = /* @__PURE__ */ new Map();
@@ -637,56 +678,17 @@ function Vt(e) {
637
678
  if (n.type === "codec" && ((o = n.mimeType) != null && o.startsWith("video")))
638
679
  c.set(n.id, n.mimeType.split("/")[1]);
639
680
  else if (n.type === "candidate-pair") {
640
- const i = n, d = i.currentRoundTripTime ?? 0;
641
- d > 0 && (i.nominated === !0 || r === 0) && (r = d);
681
+ const s = n, d = s.currentRoundTripTime ?? 0;
682
+ d > 0 && (s.nominated === !0 || r === 0) && (r = d);
642
683
  } else n.type === "inbound-rtp" && n.kind === "video" && (a = n);
643
684
  if (!a)
644
685
  return {};
645
- const s = a;
646
- return s.codecId && c.has(s.codecId) ? t = c.get(s.codecId) : c.size > 0 && (t = c.values().next().value ?? ""), {
686
+ const i = a;
687
+ return i.codecId && c.has(i.codecId) ? t = c.get(i.codecId) : c.size > 0 && (t = c.values().next().value ?? ""), {
647
688
  codec: t,
648
689
  rtt: r,
649
- timestamp: s.timestamp,
650
- bytesReceived: s.bytesReceived,
651
- packetsReceived: s.packetsReceived,
652
- packetsLost: s.packetsLost,
653
- framesDropped: s.framesDropped,
654
- framesDecoded: s.framesDecoded,
655
- jitter: s.jitter,
656
- jitterBufferDelay: s.jitterBufferDelay,
657
- jitterBufferEmittedCount: s.jitterBufferEmittedCount,
658
- avgJitterDelayInInterval: s.jitterBufferDelay / s.jitterBufferEmittedCount,
659
- frameWidth: s.frameWidth,
660
- frameHeight: s.frameHeight,
661
- framesPerSecond: s.framesPerSecond,
662
- freezeCount: s.freezeCount,
663
- freezeDuration: s.totalFreezesDuration
664
- };
665
- }
666
- function Le(e, t, r) {
667
- const a = e.map((i, d) => d === 0 ? r ? {
668
690
  timestamp: i.timestamp,
669
- duration: 0,
670
- rtt: i.rtt,
671
- bytesReceived: i.bytesReceived - r.bytesReceived,
672
- bitrate: (i.bytesReceived - r.bytesReceived) * 8 / (t / 1e3),
673
- packetsReceived: i.packetsReceived - r.packetsReceived,
674
- packetsLost: i.packetsLost - r.packetsLost,
675
- framesDropped: i.framesDropped - r.framesDropped,
676
- framesDecoded: i.framesDecoded - r.framesDecoded,
677
- jitter: i.jitter,
678
- jitterBufferDelay: i.jitterBufferDelay - r.jitterBufferDelay,
679
- jitterBufferEmittedCount: i.jitterBufferEmittedCount - r.jitterBufferEmittedCount,
680
- avgJitterDelayInInterval: (i.jitterBufferDelay - r.jitterBufferDelay) / (i.jitterBufferEmittedCount - r.jitterBufferEmittedCount),
681
- framesPerSecond: i.framesPerSecond,
682
- freezeCount: i.freezeCount - r.freezeCount,
683
- freezeDuration: i.freezeDuration - r.freezeDuration
684
- } : {
685
- timestamp: i.timestamp,
686
- rtt: i.rtt,
687
- duration: 0,
688
691
  bytesReceived: i.bytesReceived,
689
- bitrate: i.bytesReceived * 8 / (t / 1e3),
690
692
  packetsReceived: i.packetsReceived,
691
693
  packetsLost: i.packetsLost,
692
694
  framesDropped: i.framesDropped,
@@ -695,34 +697,73 @@ function Le(e, t, r) {
695
697
  jitterBufferDelay: i.jitterBufferDelay,
696
698
  jitterBufferEmittedCount: i.jitterBufferEmittedCount,
697
699
  avgJitterDelayInInterval: i.jitterBufferDelay / i.jitterBufferEmittedCount,
700
+ frameWidth: i.frameWidth,
701
+ frameHeight: i.frameHeight,
698
702
  framesPerSecond: i.framesPerSecond,
699
703
  freezeCount: i.freezeCount,
700
- freezeDuration: i.freezeDuration
704
+ freezeDuration: i.totalFreezesDuration
705
+ };
706
+ }
707
+ function Le(e, t, r) {
708
+ const a = e.map((s, d) => d === 0 ? r ? {
709
+ timestamp: s.timestamp,
710
+ duration: 0,
711
+ rtt: s.rtt,
712
+ bytesReceived: s.bytesReceived - r.bytesReceived,
713
+ bitrate: (s.bytesReceived - r.bytesReceived) * 8 / (t / 1e3),
714
+ packetsReceived: s.packetsReceived - r.packetsReceived,
715
+ packetsLost: s.packetsLost - r.packetsLost,
716
+ framesDropped: s.framesDropped - r.framesDropped,
717
+ framesDecoded: s.framesDecoded - r.framesDecoded,
718
+ jitter: s.jitter,
719
+ jitterBufferDelay: s.jitterBufferDelay - r.jitterBufferDelay,
720
+ jitterBufferEmittedCount: s.jitterBufferEmittedCount - r.jitterBufferEmittedCount,
721
+ avgJitterDelayInInterval: (s.jitterBufferDelay - r.jitterBufferDelay) / (s.jitterBufferEmittedCount - r.jitterBufferEmittedCount),
722
+ framesPerSecond: s.framesPerSecond,
723
+ freezeCount: s.freezeCount - r.freezeCount,
724
+ freezeDuration: s.freezeDuration - r.freezeDuration
701
725
  } : {
702
- timestamp: i.timestamp,
726
+ timestamp: s.timestamp,
727
+ rtt: s.rtt,
728
+ duration: 0,
729
+ bytesReceived: s.bytesReceived,
730
+ bitrate: s.bytesReceived * 8 / (t / 1e3),
731
+ packetsReceived: s.packetsReceived,
732
+ packetsLost: s.packetsLost,
733
+ framesDropped: s.framesDropped,
734
+ framesDecoded: s.framesDecoded,
735
+ jitter: s.jitter,
736
+ jitterBufferDelay: s.jitterBufferDelay,
737
+ jitterBufferEmittedCount: s.jitterBufferEmittedCount,
738
+ avgJitterDelayInInterval: s.jitterBufferDelay / s.jitterBufferEmittedCount,
739
+ framesPerSecond: s.framesPerSecond,
740
+ freezeCount: s.freezeCount,
741
+ freezeDuration: s.freezeDuration
742
+ } : {
743
+ timestamp: s.timestamp,
703
744
  duration: t * d / 1e3,
704
- rtt: i.rtt,
705
- bytesReceived: i.bytesReceived - e[d - 1].bytesReceived,
706
- bitrate: (i.bytesReceived - e[d - 1].bytesReceived) * 8 / (t / 1e3),
707
- packetsReceived: i.packetsReceived - e[d - 1].packetsReceived,
708
- packetsLost: i.packetsLost - e[d - 1].packetsLost,
709
- framesDropped: i.framesDropped - e[d - 1].framesDropped,
710
- framesDecoded: i.framesDecoded - e[d - 1].framesDecoded,
711
- jitter: i.jitter,
712
- jitterBufferDelay: i.jitterBufferDelay - e[d - 1].jitterBufferDelay,
713
- jitterBufferEmittedCount: i.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount,
714
- avgJitterDelayInInterval: (i.jitterBufferDelay - e[d - 1].jitterBufferDelay) / (i.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount),
715
- framesPerSecond: i.framesPerSecond,
716
- freezeCount: i.freezeCount - e[d - 1].freezeCount,
717
- freezeDuration: i.freezeDuration - e[d - 1].freezeDuration
718
- }), c = Nt(a), s = c.reduce((i, d) => i + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((i) => !!i.avgJitterDelayInInterval).map((i) => i.avgJitterDelayInInterval), n = a.filter((i) => !!i.rtt).map((i) => i.rtt);
745
+ rtt: s.rtt,
746
+ bytesReceived: s.bytesReceived - e[d - 1].bytesReceived,
747
+ bitrate: (s.bytesReceived - e[d - 1].bytesReceived) * 8 / (t / 1e3),
748
+ packetsReceived: s.packetsReceived - e[d - 1].packetsReceived,
749
+ packetsLost: s.packetsLost - e[d - 1].packetsLost,
750
+ framesDropped: s.framesDropped - e[d - 1].framesDropped,
751
+ framesDecoded: s.framesDecoded - e[d - 1].framesDecoded,
752
+ jitter: s.jitter,
753
+ jitterBufferDelay: s.jitterBufferDelay - e[d - 1].jitterBufferDelay,
754
+ jitterBufferEmittedCount: s.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount,
755
+ avgJitterDelayInInterval: (s.jitterBufferDelay - e[d - 1].jitterBufferDelay) / (s.jitterBufferEmittedCount - e[d - 1].jitterBufferEmittedCount),
756
+ framesPerSecond: s.framesPerSecond,
757
+ freezeCount: s.freezeCount - e[d - 1].freezeCount,
758
+ freezeDuration: s.freezeDuration - e[d - 1].freezeDuration
759
+ }), c = Kt(a), i = c.reduce((s, d) => s + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((s) => !!s.avgJitterDelayInInterval).map((s) => s.avgJitterDelayInInterval), n = a.filter((s) => !!s.rtt).map((s) => s.rtt);
719
760
  return {
720
761
  webRTCStats: {
721
762
  anomalies: c,
722
763
  minRtt: Math.min(...n),
723
764
  avgRtt: Te(n),
724
765
  maxRtt: Math.max(...n),
725
- aggregateReport: Ft(e[0], e[e.length - 1], s),
766
+ aggregateReport: Ut(e[0], e[e.length - 1], i),
726
767
  minJitterDelayInInterval: Math.min(...o),
727
768
  maxJitterDelayInInterval: Math.max(...o),
728
769
  avgJitterDelayInInterval: Te(o)
@@ -731,95 +772,95 @@ function Le(e, t, r) {
731
772
  resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
732
773
  };
733
774
  }
734
- function He(e, t) {
775
+ function Ge(e, t) {
735
776
  for (const r of e.values())
736
777
  if ((r == null ? void 0 : r.type) === "inbound-rtp" && r.kind === t)
737
778
  return r;
738
779
  return null;
739
780
  }
740
- const ee = 10;
741
- function mr(e, t) {
742
- let r = !1, a = !1, c = null, s = 0, o = 0, n = {};
743
- async function i() {
781
+ const te = 10;
782
+ function wr(e, t) {
783
+ let r = !1, a = !1, c = null, i = 0, o = 0, n = {};
784
+ async function s() {
744
785
  if (r) {
745
786
  try {
746
787
  const d = await e();
747
788
  if (!d) {
748
- c = setTimeout(i, ee);
789
+ c = setTimeout(s, te);
749
790
  return;
750
791
  }
751
- const u = He(d, "audio");
792
+ const u = Ge(d, "audio");
752
793
  if (!u) {
753
- c = setTimeout(i, ee);
794
+ c = setTimeout(s, te);
754
795
  return;
755
796
  }
756
- const m = u.totalAudioEnergy ?? 0, f = u.totalSamplesReceived ?? 0;
797
+ const f = u.totalAudioEnergy ?? 0, m = u.totalSamplesReceived ?? 0;
757
798
  if (!a) {
758
- s = m, o = f, a = !0, c = setTimeout(i, ee);
799
+ i = f, o = m, a = !0, c = setTimeout(s, te);
759
800
  return;
760
801
  }
761
- const w = m - s, y = f - o;
762
- if (s = m, o = f, y > 0 && w > 0) {
802
+ const w = f - i, y = m - o;
803
+ if (i = f, o = m, y > 0 && w > 0) {
763
804
  r = !1, t(n);
764
805
  return;
765
806
  }
766
807
  } catch {
767
808
  }
768
- r && (c = setTimeout(i, ee));
809
+ r && (c = setTimeout(s, te));
769
810
  }
770
811
  }
771
812
  return {
772
813
  arm(d = {}) {
773
- n = d, r = !0, a = !1, performance.now(), c !== null && clearTimeout(c), c = setTimeout(i, ee);
814
+ n = d, r = !0, a = !1, performance.now(), c !== null && clearTimeout(c), c = setTimeout(s, te);
774
815
  },
775
816
  destroy() {
776
817
  r = !1, c !== null && (clearTimeout(c), c = null);
777
818
  }
778
819
  };
779
820
  }
780
- const ce = 100, Kt = Math.max(Math.ceil(400 / ce), 1), Ut = 0.25, Wt = 0.28;
781
- function Jt() {
821
+ const de = 100, Ht = Math.max(Math.ceil(400 / de), 1), Ot = 0.25, qt = 0.28;
822
+ function Gt() {
782
823
  let e = 0, t, r, a = 0;
783
824
  return (c) => {
784
- const s = He(c, "video");
785
- if (!s)
825
+ const i = Ge(c, "video");
826
+ if (!i)
786
827
  return { isReceiving: !1, avgJitterDelayInInterval: a };
787
- const o = s.jitterBufferDelay, n = s.jitterBufferEmittedCount;
828
+ const o = i.jitterBufferDelay, n = i.jitterBufferEmittedCount;
788
829
  if (r && n > r) {
789
- const u = o - t, m = n - r;
790
- a = u / m;
830
+ const u = o - t, f = n - r;
831
+ a = u / f;
791
832
  }
792
833
  t = o, r = n;
793
- const i = s.framesDecoded, d = i - e > 0;
794
- return e = i, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: s.freezeCount };
834
+ const s = i.framesDecoded, d = s - e > 0;
835
+ return e = s, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: i.freezeCount };
795
836
  };
796
837
  }
797
- function Ot(e, t, r, a, c) {
798
- let s = null, o = [], n, i = 0, d = !1, u = te.Unknown, m = te.Unknown, f = 0, w = 0;
799
- const y = Jt();
838
+ function Xt(e, t, r, a, c) {
839
+ let i = null, o = [], n, s = 0, d = !1, u = re.Unknown, f = re.Unknown, m = 0, w = 0;
840
+ const y = Gt();
800
841
  async function j() {
801
842
  const M = await e();
802
843
  if (!M)
803
844
  return;
804
- const { isReceiving: _, avgJitterDelayInInterval: L, freezeCount: E } = y(M), q = Vt(M);
805
- if (_)
806
- i = 0, f = E - w, m = L < Ut ? te.Strong : L > Wt && f > 1 ? te.Weak : u, m !== u && (c == null || c(m), u = m, w += f, f = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
807
- else if (d && (i++, i >= Kt)) {
808
- const J = Le(o, ce, n);
809
- a == null || a(S.Stop, J), t() || r(), w = E, d = !1;
845
+ const { isReceiving: T, avgJitterDelayInInterval: L, freezeCount: E } = y(M), X = Wt(M);
846
+ if (T)
847
+ s = 0, m = E - w, f = L < Ot ? re.Strong : L > qt && m > 1 ? re.Weak : u, f !== u && (c == null || c(f), u = f, w += m, m = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(X);
848
+ else if (d && (s++, s >= Ht)) {
849
+ const H = Le(o, de, n);
850
+ a == null || a(S.Stop, H), t() || r(), w = E, d = !1;
810
851
  }
811
852
  }
812
853
  return {
813
854
  start: () => {
814
- s || (s = setInterval(j, ce));
855
+ i || (i = setInterval(j, de));
815
856
  },
816
857
  stop: () => {
817
- s && (clearInterval(s), s = null);
858
+ i && (clearInterval(i), i = null);
818
859
  },
819
- getReport: () => Le(o, ce, n)
860
+ getReport: () => Le(o, de, n)
820
861
  };
821
862
  }
822
- const Ht = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
863
+ const Yt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
823
864
  function Pe(e) {
824
865
  switch (e) {
825
866
  case "connected":
@@ -840,7 +881,7 @@ function Pe(e) {
840
881
  return b.New;
841
882
  }
842
883
  }
843
- const qt = (e) => (t) => {
884
+ const Qt = (e) => (t) => {
844
885
  const [r, a = ""] = t.split(/:(.+)/);
845
886
  try {
846
887
  const c = JSON.parse(a);
@@ -849,7 +890,7 @@ const qt = (e) => (t) => {
849
890
  return e("Failed to parse data channel message, returning data as string", { subject: r, rawData: a, error: c }), { subject: r, data: a };
850
891
  }
851
892
  };
852
- function Xt({
893
+ function Zt({
853
894
  statsSignal: e,
854
895
  dataChannelSignal: t,
855
896
  onVideoStateChange: r,
@@ -858,15 +899,15 @@ function Xt({
858
899
  }) {
859
900
  e === S.Start && t === S.Start ? (c("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && t === S.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, a));
860
901
  }
861
- function Gt({
902
+ function er({
862
903
  statsSignal: e,
863
904
  dataChannelSignal: t,
864
905
  onVideoStateChange: r,
865
906
  onAgentActivityStateChange: a,
866
907
  report: c,
867
- log: s
908
+ log: i
868
909
  }) {
869
- e === S.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ne.Talking) : t === S.Stop && (a == null || a(ne.Idle));
910
+ e === S.Start ? (i("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (i("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ae.Talking) : t === S.Stop && (a == null || a(ae.Idle));
870
911
  }
871
912
  function je({
872
913
  statsSignal: e,
@@ -874,67 +915,67 @@ function je({
874
915
  onVideoStateChange: r,
875
916
  onAgentActivityStateChange: a,
876
917
  streamType: c,
877
- report: s,
918
+ report: i,
878
919
  log: o
879
920
  }) {
880
- c === W.Legacy ? Xt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: s, log: o }) : c === W.Fluent && Gt({
921
+ c === W.Legacy ? Zt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: i, log: o }) : c === W.Fluent && er({
881
922
  statsSignal: e,
882
923
  dataChannelSignal: t,
883
924
  onVideoStateChange: r,
884
925
  onAgentActivityStateChange: a,
885
- report: s,
926
+ report: i,
886
927
  log: o
887
928
  });
888
929
  }
889
- async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le, analytics: o }, n) {
930
+ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: i = le, analytics: o }, n) {
890
931
  var F;
891
- const i = zt(r, "WebRTCStreamingManager"), d = qt(i);
892
- let u = !1, m = !1, f = S.Stop, w = S.Stop;
893
- const { startConnection: y, sendStreamRequest: j, close: M, createStream: _, addIceCandidate: L } = Bt(
932
+ const s = Jt(r, "WebRTCStreamingManager"), d = Qt(s);
933
+ let u = !1, f = !1, m = S.Stop, w = S.Stop;
934
+ const { startConnection: y, sendStreamRequest: j, close: M, createStream: T, addIceCandidate: L } = Vt(
894
935
  c,
895
- s,
936
+ i,
896
937
  e,
897
938
  a.onError
898
939
  ), {
899
940
  id: E,
900
- offer: q,
901
- ice_servers: J,
902
- session_id: N,
903
- fluent: ae,
904
- interrupt_enabled: X
905
- } = await _(t, n);
906
- (F = a.onStreamCreated) == null || F.call(a, { stream_id: E, session_id: N, agent_id: e });
907
- const I = new Ht({ iceServers: J }), O = I.createDataChannel("JanusDataChannel");
908
- if (!N)
941
+ offer: X,
942
+ ice_servers: H,
943
+ session_id: V,
944
+ fluent: ie,
945
+ interrupt_enabled: Y
946
+ } = await T(t, n);
947
+ (F = a.onStreamCreated) == null || F.call(a, { stream_id: E, session_id: V, agent_id: e });
948
+ const D = new Yt({ iceServers: H }), O = D.createDataChannel("JanusDataChannel");
949
+ if (!V)
909
950
  throw new Error("Could not create session_id");
910
- const V = ae ? W.Fluent : W.Legacy;
951
+ const J = ie ? W.Fluent : W.Legacy;
911
952
  o.enrich({
912
- "stream-type": V
953
+ "stream-type": J
913
954
  });
914
- const ie = t.stream_warmup && !ae, se = () => u, Q = () => {
955
+ const se = t.stream_warmup && !ie, oe = () => u, ee = () => {
915
956
  var g;
916
- u = !0, m && (i("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a, b.Connected));
917
- }, l = Ot(
918
- () => I.getStats(),
919
- se,
920
- Q,
921
- (g, p) => je({
957
+ u = !0, f && (s("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a, b.Connected));
958
+ }, l = Xt(
959
+ () => D.getStats(),
960
+ oe,
961
+ ee,
962
+ (g, h) => je({
922
963
  statsSignal: w = g,
923
- dataChannelSignal: V === W.Legacy ? f : void 0,
964
+ dataChannelSignal: J === W.Legacy ? m : void 0,
924
965
  onVideoStateChange: a.onVideoStateChange,
925
966
  onAgentActivityStateChange: a.onAgentActivityStateChange,
926
- report: p,
927
- streamType: V,
928
- log: i
967
+ report: h,
968
+ streamType: J,
969
+ log: s
929
970
  }),
930
971
  (g) => {
931
- var p;
932
- return (p = a.onConnectivityStateChange) == null ? void 0 : p.call(a, g);
972
+ var h;
973
+ return (h = a.onConnectivityStateChange) == null ? void 0 : h.call(a, g);
933
974
  }
934
975
  );
935
- l.start(), I.onicecandidate = (g) => {
936
- var p;
937
- i("peerConnection.onicecandidate", g);
976
+ l.start(), D.onicecandidate = (g) => {
977
+ var h;
978
+ s("peerConnection.onicecandidate", g);
938
979
  try {
939
980
  g.candidate && g.candidate.sdpMid && g.candidate.sdpMLineIndex !== null ? L(
940
981
  E,
@@ -943,38 +984,38 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
943
984
  sdpMid: g.candidate.sdpMid,
944
985
  sdpMLineIndex: g.candidate.sdpMLineIndex
945
986
  },
946
- N,
987
+ V,
947
988
  n
948
- ) : L(E, { candidate: null }, N, n);
949
- } catch (D) {
950
- (p = a.onError) == null || p.call(a, D, { streamId: E });
989
+ ) : L(E, { candidate: null }, V, n);
990
+ } catch (I) {
991
+ (h = a.onError) == null || h.call(a, I, { streamId: E });
951
992
  }
952
993
  }, O.onopen = () => {
953
- m = !0, (!ie || u) && Q();
994
+ f = !0, (!se || u) && ee();
954
995
  };
955
- let h = null;
996
+ let p = null;
956
997
  const v = (g) => {
957
- var p;
958
- h = g, (p = a.onVideoIdChange) == null || p.call(a, g);
998
+ var h;
999
+ p = g, (h = a.onVideoIdChange) == null || h.call(a, g);
959
1000
  };
960
- function C(g, p) {
961
- if (g === x.StreamStarted && typeof p == "object" && "metadata" in p) {
962
- const D = p.metadata;
963
- v(D.videoId);
1001
+ function C(g, h) {
1002
+ if (g === x.StreamStarted && typeof h == "object" && "metadata" in h) {
1003
+ const I = h.metadata;
1004
+ v(I.videoId);
964
1005
  }
965
- g === x.StreamDone && v(null), f = g === x.StreamStarted ? S.Start : S.Stop, je({
966
- statsSignal: V === W.Legacy ? w : void 0,
967
- dataChannelSignal: f,
1006
+ g === x.StreamDone && v(null), m = g === x.StreamStarted ? S.Start : S.Stop, je({
1007
+ statsSignal: J === W.Legacy ? w : void 0,
1008
+ dataChannelSignal: m,
968
1009
  onVideoStateChange: a.onVideoStateChange,
969
1010
  onAgentActivityStateChange: a.onAgentActivityStateChange,
970
- streamType: V,
971
- log: i
1011
+ streamType: J,
1012
+ log: s
972
1013
  });
973
1014
  }
974
- function k(g, p) {
975
- var $;
976
- const D = typeof p == "string" ? p : p == null ? void 0 : p.metadata;
977
- D && o.enrich({ streamMetadata: D }), ($ = a.onStreamReady) == null || $.call(a);
1015
+ function k(g, h) {
1016
+ var B;
1017
+ const I = typeof h == "string" ? h : h == null ? void 0 : h.metadata;
1018
+ I && o.enrich({ streamMetadata: I }), (B = a.onStreamReady) == null || B.call(a);
978
1019
  }
979
1020
  const R = {
980
1021
  [x.StreamStarted]: C,
@@ -982,32 +1023,32 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
982
1023
  [x.StreamReady]: k
983
1024
  };
984
1025
  O.onmessage = (g) => {
985
- var $;
986
- const { subject: p, data: D } = d(g.data);
987
- ($ = R[p]) == null || $.call(R, p, D);
988
- }, I.oniceconnectionstatechange = () => {
989
- var p;
990
- i("peerConnection.oniceconnectionstatechange => " + I.iceConnectionState);
991
- const g = Pe(I.iceConnectionState);
992
- g !== b.Connected && ((p = a.onConnectionStateChange) == null || p.call(a, g));
993
- }, I.ontrack = (g) => {
994
- var p;
995
- i("peerConnection.ontrack", g), i("CALLBACK: onSrcObjectReady"), (p = a.onSrcObjectReady) == null || p.call(a, g.streams[0]);
996
- }, await I.setRemoteDescription(q), i("set remote description OK");
997
- const P = await I.createAnswer();
998
- i("create answer OK"), await I.setLocalDescription(P), i("set local description OK"), await y(E, P, N, n), i("start connection OK");
999
- function z(g) {
1000
- var p, D;
1026
+ var B;
1027
+ const { subject: h, data: I } = d(g.data);
1028
+ (B = R[h]) == null || B.call(R, h, I);
1029
+ }, D.oniceconnectionstatechange = () => {
1030
+ var h;
1031
+ s("peerConnection.oniceconnectionstatechange => " + D.iceConnectionState);
1032
+ const g = Pe(D.iceConnectionState);
1033
+ g !== b.Connected && ((h = a.onConnectionStateChange) == null || h.call(a, g));
1034
+ }, D.ontrack = (g) => {
1035
+ var h;
1036
+ s("peerConnection.ontrack", g), s("CALLBACK: onSrcObjectReady"), (h = a.onSrcObjectReady) == null || h.call(a, g.streams[0]);
1037
+ }, await D.setRemoteDescription(X), s("set remote description OK");
1038
+ const P = await D.createAnswer();
1039
+ s("create answer OK"), await D.setLocalDescription(P), s("set local description OK"), await y(E, P, V, n), s("start connection OK");
1040
+ function N(g) {
1041
+ var h, I;
1001
1042
  if (!u || O.readyState !== "open") {
1002
- i("Data channel is not ready for sending messages"), (p = a.onError) == null || p.call(a, new Error("Data channel is not ready for sending messages"), {
1043
+ s("Data channel is not ready for sending messages"), (h = a.onError) == null || h.call(a, new Ne("Data channel is not ready for sending messages"), {
1003
1044
  streamId: E
1004
1045
  });
1005
1046
  return;
1006
1047
  }
1007
1048
  try {
1008
1049
  O.send(g);
1009
- } catch ($) {
1010
- i("Error sending data channel message", $), (D = a.onError) == null || D.call(a, $, { streamId: E });
1050
+ } catch (B) {
1051
+ s("Error sending data channel message", B), (I = a.onError) == null || I.call(a, B, { streamId: E });
1011
1052
  }
1012
1053
  }
1013
1054
  return {
@@ -1016,7 +1057,7 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1016
1057
  * @param payload
1017
1058
  */
1018
1059
  speak(g) {
1019
- return j(E, N, g);
1060
+ return j(E, V, g);
1020
1061
  },
1021
1062
  /**
1022
1063
  * Method to close RTC connection
@@ -1024,64 +1065,64 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1024
1065
  async disconnect() {
1025
1066
  var g;
1026
1067
  if (E) {
1027
- const p = Pe(I.iceConnectionState);
1028
- if (I) {
1029
- if (p === b.New) {
1068
+ const h = Pe(D.iceConnectionState);
1069
+ if (D) {
1070
+ if (h === b.New) {
1030
1071
  l.stop();
1031
1072
  return;
1032
1073
  }
1033
- I.close(), I.oniceconnectionstatechange = null, I.onnegotiationneeded = null, I.onicecandidate = null, I.ontrack = null;
1074
+ D.close(), D.oniceconnectionstatechange = null, D.onnegotiationneeded = null, D.onicecandidate = null, D.ontrack = null;
1034
1075
  }
1035
1076
  try {
1036
- p === b.Connected && await M(E, N).catch((D) => {
1077
+ h === b.Connected && await M(E, V).catch((I) => {
1037
1078
  });
1038
- } catch (D) {
1039
- i("Error on close stream connection", D);
1079
+ } catch (I) {
1080
+ s("Error on close stream connection", I);
1040
1081
  }
1041
- (g = a.onAgentActivityStateChange) == null || g.call(a, ne.Idle), l.stop();
1082
+ (g = a.onAgentActivityStateChange) == null || g.call(a, ae.Idle), l.stop();
1042
1083
  }
1043
1084
  },
1044
- sendDataChannelMessage: z,
1085
+ sendDataChannelMessage: N,
1045
1086
  /**
1046
1087
  * Session identifier information, should be returned in the body of all streaming requests
1047
1088
  */
1048
- sessionId: N,
1089
+ sessionId: V,
1049
1090
  /**
1050
1091
  * Id of current RTC stream
1051
1092
  */
1052
1093
  streamId: E,
1053
- streamType: V,
1054
- interruptAvailable: X ?? !1,
1094
+ streamType: J,
1095
+ interruptAvailable: Y ?? !1,
1055
1096
  isInterruptible: !0,
1056
1097
  interrupt(g) {
1057
- if (!X)
1098
+ if (!Y)
1058
1099
  throw new Error("Interrupt is not enabled for this stream");
1059
- if (V !== W.Fluent)
1100
+ if (J !== W.Fluent)
1060
1101
  throw new Error("Interrupt only available for Fluent streams");
1061
- if (!h)
1102
+ if (!p)
1062
1103
  throw new Error("No active video to interrupt");
1063
- const p = {
1104
+ const h = {
1064
1105
  type: x.StreamInterrupt,
1065
- videoId: h,
1106
+ videoId: p,
1066
1107
  timestamp: Date.now()
1067
1108
  };
1068
- z(JSON.stringify(p));
1109
+ N(JSON.stringify(h));
1069
1110
  }
1070
1111
  };
1071
1112
  }
1072
- var pe = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(pe || {});
1073
- async function Qt(e, t, r, a) {
1113
+ var he = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(he || {});
1114
+ async function rr(e, t, r, a) {
1074
1115
  const c = e.id;
1075
1116
  switch (t.version) {
1076
1117
  case "v1": {
1077
- const { version: s, ...o } = t;
1078
- return Yt(c, o, r, a);
1118
+ const { version: i, ...o } = t;
1119
+ return tr(c, o, r, a);
1079
1120
  }
1080
1121
  case "v2": {
1081
- const { version: s, ...o } = t;
1122
+ const { version: i, ...o } = t;
1082
1123
  switch (o.transport.provider) {
1083
- case he.Livekit:
1084
- const { createLiveKitStreamingManager: n } = await import("./livekit-manager-B01_ssBG.js");
1124
+ case pe.Livekit:
1125
+ const { createLiveKitStreamingManager: n } = await import("./livekit-manager-CFuAnjAa.js");
1085
1126
  return n(c, o, r);
1086
1127
  default:
1087
1128
  throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
@@ -1091,18 +1132,18 @@ async function Qt(e, t, r, a) {
1091
1132
  throw new Error(`Invalid stream version: ${t.version}`);
1092
1133
  }
1093
1134
  }
1094
- const Zt = "cht";
1095
- function er() {
1135
+ const nr = "cht";
1136
+ function ar() {
1096
1137
  return {
1097
1138
  transport: {
1098
- provider: he.Livekit
1139
+ provider: pe.Livekit
1099
1140
  }
1100
1141
  };
1101
1142
  }
1102
- function tr(e) {
1103
- var c, s;
1143
+ function ir(e) {
1144
+ var c, i;
1104
1145
  const { streamOptions: t } = e ?? {}, r = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
1105
- plan: (s = e.mixpanelAdditionalProperties) == null ? void 0 : s.plan
1146
+ plan: (i = e.mixpanelAdditionalProperties) == null ? void 0 : i.plan
1106
1147
  } : void 0;
1107
1148
  return { ...{
1108
1149
  output_resolution: t == null ? void 0 : t.outputResolution,
@@ -1112,16 +1153,16 @@ function tr(e) {
1112
1153
  fluent: t == null ? void 0 : t.fluent
1113
1154
  }, ...r && { end_user_data: r } };
1114
1155
  }
1115
- function rr(e, t) {
1116
- return we(e.presenter.type) ? { version: pe.V2, ...er() } : { version: pe.V1, ...tr(t) };
1156
+ function sr(e, t) {
1157
+ return we(e.presenter.type) ? { version: he.V2, ...ar() } : { version: he.V1, ...ir(t) };
1117
1158
  }
1118
- function nr(e, t, r) {
1159
+ function or(e, t, r) {
1119
1160
  r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
1120
1161
  }
1121
- function ar(e, t, r, a, c) {
1122
- c === W.Fluent ? ir(e, t, r, a, c) : sr(e, t, r, a, c);
1162
+ function cr(e, t, r, a, c) {
1163
+ c === W.Fluent ? dr(e, t, r, a, c) : lr(e, t, r, a, c);
1123
1164
  }
1124
- function ir(e, t, r, a, c) {
1165
+ function dr(e, t, r, a, c) {
1125
1166
  e === S.Start ? a.track("stream-session", { event: "start", "stream-type": c }) : e === S.Stop && a.track("stream-session", {
1126
1167
  event: "stop",
1127
1168
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
@@ -1130,7 +1171,7 @@ function ir(e, t, r, a, c) {
1130
1171
  ...r
1131
1172
  });
1132
1173
  }
1133
- function $e(e, t, r, a, c) {
1174
+ function Be(e, t, r, a, c) {
1134
1175
  e === S.Start ? r.linkTrack("agent-video", { event: "start", ...c, "stream-type": a }, "start", [
1135
1176
  x.StreamVideoCreated
1136
1177
  ]) : e === S.Stop && r.linkTrack(
@@ -1145,10 +1186,10 @@ function $e(e, t, r, a, c) {
1145
1186
  [x.StreamVideoDone]
1146
1187
  );
1147
1188
  }
1148
- function sr(e, t, r, a, c) {
1189
+ function lr(e, t, r, a, c) {
1149
1190
  e === S.Start ? a.linkTrack(
1150
1191
  "agent-video",
1151
- { event: "start", latency: H.get(!0), "stream-type": c },
1192
+ { event: "start", latency: q.get(!0), "stream-type": c },
1152
1193
  "start",
1153
1194
  [x.StreamVideoCreated]
1154
1195
  ) : e === S.Stop && a.linkTrack(
@@ -1164,7 +1205,7 @@ function sr(e, t, r, a, c) {
1164
1205
  [x.StreamVideoDone]
1165
1206
  );
1166
1207
  }
1167
- function or(e, t, r) {
1208
+ function ur(e, t, r) {
1168
1209
  const a = {
1169
1210
  call_id: t.call_id,
1170
1211
  name: t.name
@@ -1181,80 +1222,80 @@ function or(e, t, r) {
1181
1222
  extra_keys: c.extra ? Object.keys(c.extra).length : 0
1182
1223
  });
1183
1224
  }
1184
- function Be(e, t, r, a) {
1185
- return H.reset(), be.update(), new Promise(async (c, s) => {
1225
+ function $e(e, t, r, a) {
1226
+ return q.reset(), be.update(), new Promise(async (c, i) => {
1186
1227
  try {
1187
1228
  let o, n = !1;
1188
- const i = rr(e, t);
1229
+ const s = sr(e, t);
1189
1230
  r.enrich({
1190
- "stream-version": i.version.toString()
1231
+ "stream-version": s.version.toString()
1191
1232
  });
1192
1233
  let d = null;
1193
1234
  const u = e.presenter.type === "expressive";
1194
- o = await Qt(
1235
+ o = await rr(
1195
1236
  e,
1196
- i,
1237
+ s,
1197
1238
  {
1198
1239
  ...t,
1199
1240
  analytics: r,
1200
1241
  callbacks: {
1201
1242
  ...t.callbacks,
1202
- onConnectionStateChange: (m, f) => {
1243
+ onConnectionStateChange: (f, m) => {
1203
1244
  var w, y;
1204
- (y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, m), nr(m, f, r), m === b.Connected && (o ? c(o) : n = !0);
1245
+ (y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, f), or(f, m, r), f === b.Connected && (o ? c(o) : n = !0);
1205
1246
  },
1206
- onVideoStateChange: (m, f) => {
1247
+ onVideoStateChange: (f, m) => {
1207
1248
  var w, y;
1208
- (y = (w = t.callbacks).onVideoStateChange) == null || y.call(w, m), ar(
1209
- m,
1210
- e,
1249
+ (y = (w = t.callbacks).onVideoStateChange) == null || y.call(w, f), cr(
1211
1250
  f,
1251
+ e,
1252
+ m,
1212
1253
  r,
1213
1254
  o.streamType
1214
1255
  );
1215
1256
  },
1216
- onAgentActivityStateChange: (m) => {
1217
- var f, w;
1218
- (w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, m), m === ne.Talking ? (ge.update(), d = (y) => {
1219
- $e(
1257
+ onAgentActivityStateChange: (f) => {
1258
+ var m, w;
1259
+ (w = (m = t.callbacks).onAgentActivityStateChange) == null || w.call(m, f), f === ae.Talking ? (ge.update(), d = (y) => {
1260
+ Be(
1220
1261
  S.Start,
1221
1262
  e,
1222
1263
  r,
1223
1264
  o.streamType,
1224
1265
  y
1225
1266
  ), d = null;
1226
- }, u || d({ latency: H.get(!0) })) : (ge.reset(), d = null, $e(
1267
+ }, u || d({ latency: q.get(!0) })) : (ge.reset(), d = null, Be(
1227
1268
  S.Stop,
1228
1269
  e,
1229
1270
  r,
1230
1271
  o.streamType
1231
1272
  ));
1232
1273
  },
1233
- onFirstAudioDetected: (m) => {
1234
- d == null || d(m);
1274
+ onFirstAudioDetected: (f) => {
1275
+ d == null || d(f);
1235
1276
  },
1236
1277
  onStreamReady: () => {
1237
- const m = be.get(!0);
1238
- r.track("agent-chat", { event: "ready", latency: m });
1278
+ const f = be.get(!0);
1279
+ r.track("agent-chat", { event: "ready", latency: f });
1239
1280
  },
1240
- onToolEvent: ((m, f) => {
1281
+ onToolEvent: ((f, m) => {
1241
1282
  var w, y;
1242
- (y = (w = t.callbacks).onToolEvent) == null || y.call(w, m, f), or(m, f, r);
1283
+ (y = (w = t.callbacks).onToolEvent) == null || y.call(w, f, m), ur(f, m, r);
1243
1284
  })
1244
1285
  }
1245
1286
  },
1246
1287
  a
1247
1288
  ), n && c(o);
1248
1289
  } catch (o) {
1249
- s(o);
1290
+ i(o);
1250
1291
  }
1251
1292
  });
1252
1293
  }
1253
- async function cr(e, t, r, a, c) {
1254
- var u, m, f, w;
1255
- const s = async () => {
1294
+ async function mr(e, t, r, a, c) {
1295
+ var u, f, m, w;
1296
+ const i = async () => {
1256
1297
  if (we(e.presenter.type)) {
1257
- const y = await Be(e, t, a), j = `${Zt}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1298
+ const y = await $e(e, t, a), j = `${nr}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1258
1299
  return { chatResult: {
1259
1300
  chatMode: A.Functional,
1260
1301
  chat: {
@@ -1273,105 +1314,105 @@ async function cr(e, t, r, a, c) {
1273
1314
  const y = new AbortController(), j = y.signal;
1274
1315
  let M;
1275
1316
  try {
1276
- const _ = Oe(
1317
+ const T = qe(
1277
1318
  e,
1278
1319
  r,
1279
1320
  a,
1280
1321
  t.mode,
1281
1322
  t.persistentChat,
1282
1323
  c
1283
- ), L = Be(e, t, a, j).then((J) => (M = J, J)), [E, q] = await Promise.all([_, L]);
1284
- return { chatResult: E, streamingManager: q };
1285
- } catch (_) {
1324
+ ), L = $e(e, t, a, j).then((H) => (M = H, H)), [E, X] = await Promise.all([T, L]);
1325
+ return { chatResult: E, streamingManager: X };
1326
+ } catch (T) {
1286
1327
  throw y.abort(), M && await M.disconnect().catch(() => {
1287
- }), _;
1328
+ }), T;
1288
1329
  }
1289
1330
  }
1290
- }, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
1291
- return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (m = (u = t.callbacks).onModeChange) == null || m.call(u, d), d !== A.Functional) ? ((w = (f = t.callbacks).onError) == null || w.call(f, new Qe(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
1331
+ }, { chatResult: o, streamingManager: n } = await i(), { chat: s, chatMode: d } = o;
1332
+ return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (f = (u = t.callbacks).onModeChange) == null || f.call(u, d), d !== A.Functional) ? ((w = (m = t.callbacks).onError) == null || w.call(m, new et(d)), n == null || n.disconnect(), { chat: s }) : { chat: s, streamingManager: n };
1292
1333
  }
1293
- async function fr(e, t) {
1294
- var V, ie, se, Q;
1334
+ async function vr(e, t) {
1335
+ var J, se, oe, ee;
1295
1336
  let r = !0;
1296
- const a = t.mixpanelKey || ft, c = t.wsURL || mt, s = t.baseURL || le, o = t.mode || A.Functional, n = {
1337
+ const a = t.mixpanelKey || wt, c = t.wsURL || pt, i = t.baseURL || le, o = t.mode || A.Functional, n = {
1297
1338
  messages: [],
1298
1339
  chatMode: o
1299
- }, i = _t({
1340
+ }, s = Lt({
1300
1341
  token: a,
1301
1342
  agentId: e,
1302
1343
  isEnabled: t.enableAnalitics,
1303
1344
  externalId: t.externalId,
1304
1345
  mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
1305
1346
  }), d = Date.now();
1306
- Ae(() => {
1307
- i.track("agent-sdk", { event: "init" }, d);
1347
+ _e(() => {
1348
+ s.track("agent-sdk", { event: "init" }, d);
1308
1349
  });
1309
1350
  const u = t.callbacks.onError;
1310
- t.callbacks.onError = (l, h) => {
1311
- i.track("agent-error", { error: _e(l) }), u == null || u(l, h);
1351
+ t.callbacks.onError = (l, p) => {
1352
+ s.track("agent-error", { error: Ae(l) }), u == null || u(l, p);
1312
1353
  };
1313
- const m = kt(t.auth, s, t.callbacks.onError, t.externalId), f = await m.getById(e);
1314
- t.debug = t.debug || ((V = f == null ? void 0 : f.advanced_settings) == null ? void 0 : V.ui_debug_mode);
1315
- const w = we(f.presenter.type);
1316
- i.enrich(It(f));
1317
- const { onMessage: y, clearQueue: j } = $t(i, n, t, f, () => {
1318
- var l, h, v;
1319
- (l = n.socketManager) == null || l.disconnect(), (v = (h = t.callbacks).onConnectionStateChange) == null || v.call(h, b.Disconnected);
1354
+ const f = Mt(t.auth, i, t.callbacks.onError, t.externalId), m = await f.getById(e);
1355
+ t.debug = t.debug || ((J = m == null ? void 0 : m.advanced_settings) == null ? void 0 : J.ui_debug_mode);
1356
+ const w = we(m.presenter.type);
1357
+ s.enrich(Tt(m));
1358
+ const { onMessage: y, clearQueue: j } = Ft(s, n, t, m, () => {
1359
+ var l, p, v;
1360
+ (l = n.socketManager) == null || l.disconnect(), (v = (p = t.callbacks).onConnectionStateChange) == null || v.call(p, b.Disconnected);
1320
1361
  });
1321
- n.messages = At(t.initialMessages), (se = (ie = t.callbacks).onNewMessage) == null || se.call(ie, [...n.messages], "answer");
1362
+ n.messages = Pt(t.initialMessages), (oe = (se = t.callbacks).onNewMessage) == null || oe.call(se, [...n.messages], "answer");
1322
1363
  const M = (l) => {
1323
- }, _ = ({ type: l }) => {
1364
+ }, T = ({ type: l }) => {
1324
1365
  var v, C, k, R;
1325
1366
  if (!((v = n.streamingManager) != null && v.interruptAvailable) || !((C = n.streamingManager) != null && C.isInterruptible)) return;
1326
- const h = n.messages[n.messages.length - 1];
1327
- i.track("agent-video-interrupt", {
1367
+ const p = n.messages[n.messages.length - 1];
1368
+ s.track("agent-video-interrupt", {
1328
1369
  type: l || "click",
1329
1370
  video_duration_to_interrupt: ge.get(!0),
1330
- message_duration_to_interrupt: H.get(!0)
1331
- }), h.interrupted = !0, (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer"), n.streamingManager.interrupt(l);
1371
+ message_duration_to_interrupt: q.get(!0)
1372
+ }), p.interrupted = !0, (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer"), n.streamingManager.interrupt(l);
1332
1373
  }, L = /* @__PURE__ */ new Map();
1333
1374
  function E(l) {
1334
- return async (h) => {
1375
+ return async (p) => {
1335
1376
  const v = L.get(l);
1336
1377
  if (!v)
1337
1378
  throw new Error(`No handler registered for client tool: ${l}`);
1338
1379
  try {
1339
- const C = JSON.parse(h.payload);
1380
+ const C = JSON.parse(p.payload);
1340
1381
  return await v(C);
1341
1382
  } catch (C) {
1342
1383
  throw new Error(`Client tool "${l}" failed: ${C.message}`);
1343
1384
  }
1344
1385
  };
1345
1386
  }
1346
- function q() {
1347
- var l, h, v, C;
1387
+ function X() {
1388
+ var l, p, v, C;
1348
1389
  for (const [k] of L)
1349
- (h = (l = n.streamingManager) == null ? void 0 : l.unregisterRpcMethod) == null || h.call(l, k), (C = (v = n.streamingManager) == null ? void 0 : v.registerRpcMethod) == null || C.call(v, k, E(k));
1390
+ (p = (l = n.streamingManager) == null ? void 0 : l.unregisterRpcMethod) == null || p.call(l, k), (C = (v = n.streamingManager) == null ? void 0 : v.registerRpcMethod) == null || C.call(v, k, E(k));
1350
1391
  }
1351
- function J(l, h) {
1392
+ function H(l, p) {
1352
1393
  var C, k;
1353
1394
  const v = !L.has(l);
1354
- L.set(l, h), v && ((k = (C = n.streamingManager) == null ? void 0 : C.registerRpcMethod) == null || k.call(C, l, E(l)));
1395
+ L.set(l, p), v && ((k = (C = n.streamingManager) == null ? void 0 : C.registerRpcMethod) == null || k.call(C, l, E(l)));
1355
1396
  }
1356
- function N(l) {
1357
- var h, v;
1358
- L.delete(l), (v = (h = n.streamingManager) == null ? void 0 : h.unregisterRpcMethod) == null || v.call(h, l);
1397
+ function V(l) {
1398
+ var p, v;
1399
+ L.delete(l), (v = (p = n.streamingManager) == null ? void 0 : p.unregisterRpcMethod) == null || v.call(p, l);
1359
1400
  }
1360
- const ae = Date.now();
1361
- Ae(() => {
1362
- i.track("agent-sdk", { event: "loaded", ...Rt(f) }, ae);
1401
+ const ie = Date.now();
1402
+ _e(() => {
1403
+ s.track("agent-sdk", { event: "loaded", ...Et(m) }, ie);
1363
1404
  });
1364
- async function X(l) {
1365
- var P, z, F, g, p, D, $;
1366
- dt(), (z = (P = t.callbacks).onConnectionStateChange) == null || z.call(P, b.Connecting), H.reset(), l && !r && (delete n.chat, (g = (F = t.callbacks).onNewMessage) == null || g.call(F, [...n.messages], "answer"));
1367
- const h = o === A.DirectPlayback || w ? Promise.resolve(void 0) : Lt(
1405
+ async function Y(l) {
1406
+ var P, N, F, g, h, I, B;
1407
+ ft(), (N = (P = t.callbacks).onConnectionStateChange) == null || N.call(P, b.Connecting), q.reset(), l && !r && (delete n.chat, (g = (F = t.callbacks).onNewMessage) == null || g.call(F, [...n.messages], "answer"));
1408
+ const p = o === A.DirectPlayback || w ? Promise.resolve(void 0) : $t(
1368
1409
  t.auth,
1369
1410
  c,
1370
1411
  { onMessage: y, onError: t.callbacks.onError },
1371
1412
  t.externalId
1372
1413
  ), v = fe(
1373
- () => cr(
1374
- f,
1414
+ () => mr(
1415
+ m,
1375
1416
  {
1376
1417
  ...t,
1377
1418
  mode: o,
@@ -1381,37 +1422,37 @@ async function fr(e, t) {
1381
1422
  onMessage: y
1382
1423
  }
1383
1424
  },
1384
- m,
1385
- i,
1425
+ f,
1426
+ s,
1386
1427
  n.chat
1387
1428
  ),
1388
1429
  {
1389
1430
  limit: 3,
1390
- timeout: lt,
1431
+ timeout: gt,
1391
1432
  timeoutErrorMessage: "Timeout initializing the stream",
1392
- shouldRetryFn: (K) => (K == null ? void 0 : K.message) !== "Could not connect" && K.status !== 429 && (K == null ? void 0 : K.message) !== "InsufficientCreditsError",
1433
+ shouldRetryFn: (K) => (K == null ? void 0 : K.message) !== "Could not connect" && !(K instanceof ze && (K.status === 429 || K.kind === "InsufficientCreditsError")),
1393
1434
  delayMs: 1e3
1394
1435
  }
1395
1436
  ).catch((K) => {
1396
- var T, U;
1397
- throw O(A.Maintenance), (U = (T = t.callbacks).onConnectionStateChange) == null || U.call(T, b.Fail), K;
1398
- }), [C, { streamingManager: k, chat: R }] = await Promise.all([h, v]);
1399
- R && R.id !== ((p = n.chat) == null ? void 0 : p.id) && (($ = (D = t.callbacks).onNewChat) == null || $.call(D, R.id)), n.streamingManager = k, n.socketManager = C, n.chat = R, q(), r = !1, i.enrich({
1437
+ var _, U;
1438
+ throw O(A.Maintenance), (U = (_ = t.callbacks).onConnectionStateChange) == null || U.call(_, b.Fail), K;
1439
+ }), [C, { streamingManager: k, chat: R }] = await Promise.all([p, v]);
1440
+ R && R.id !== ((h = n.chat) == null ? void 0 : h.id) && ((B = (I = t.callbacks).onNewChat) == null || B.call(I, R.id)), n.streamingManager = k, n.socketManager = C, n.chat = R, X(), r = !1, s.enrich({
1400
1441
  chatId: R == null ? void 0 : R.id,
1401
1442
  streamId: k == null ? void 0 : k.streamId,
1402
1443
  mode: n.chatMode
1403
1444
  }), O((R == null ? void 0 : R.chat_mode) ?? o);
1404
1445
  }
1405
- async function I() {
1406
- var l, h, v, C;
1407
- (l = n.socketManager) == null || l.disconnect(), await ((h = n.streamingManager) == null ? void 0 : h.disconnect()), delete n.streamingManager, delete n.socketManager, (C = (v = t.callbacks).onConnectionStateChange) == null || C.call(v, b.Disconnected);
1446
+ async function D() {
1447
+ var l, p, v, C;
1448
+ (l = n.socketManager) == null || l.disconnect(), await ((p = n.streamingManager) == null ? void 0 : p.disconnect()), delete n.streamingManager, delete n.socketManager, (C = (v = t.callbacks).onConnectionStateChange) == null || C.call(v, b.Disconnected);
1408
1449
  }
1409
1450
  async function O(l) {
1410
- var h, v;
1411
- l !== n.chatMode && (i.track("agent-mode-change", { mode: l }), n.chatMode = l, n.chatMode !== A.Functional && await I(), (v = (h = t.callbacks).onModeChange) == null || v.call(h, l));
1451
+ var p, v;
1452
+ l !== n.chatMode && (s.track("agent-mode-change", { mode: l }), n.chatMode = l, n.chatMode !== A.Functional && await D(), (v = (p = t.callbacks).onModeChange) == null || v.call(p, l));
1412
1453
  }
1413
1454
  return {
1414
- agent: f,
1455
+ agent: m,
1415
1456
  getStreamType: () => {
1416
1457
  var l;
1417
1458
  return (l = n.streamingManager) == null ? void 0 : l.streamType;
@@ -1420,12 +1461,12 @@ async function fr(e, t) {
1420
1461
  var l;
1421
1462
  return ((l = n.streamingManager) == null ? void 0 : l.interruptAvailable) ?? !1;
1422
1463
  },
1423
- starterMessages: ((Q = f.knowledge) == null ? void 0 : Q.starter_message) || [],
1424
- getSTTToken: () => m.getSTTToken(f.id),
1464
+ starterMessages: ((ee = m.knowledge) == null ? void 0 : ee.starter_message) || [],
1465
+ getSTTToken: () => f.getSTTToken(m.id),
1425
1466
  changeMode: O,
1426
- enrichAnalytics: i.enrich,
1467
+ enrichAnalytics: s.enrich,
1427
1468
  async connect() {
1428
- await X(!0), i.track("agent-chat", {
1469
+ await Y(!0), s.track("agent-chat", {
1429
1470
  event: "connect",
1430
1471
  mode: n.chatMode
1431
1472
  });
@@ -1434,256 +1475,262 @@ async function fr(e, t) {
1434
1475
  const l = n.streamingManager;
1435
1476
  if (w && (l != null && l.reconnect)) {
1436
1477
  try {
1437
- await l.reconnect(), i.track("agent-chat", {
1478
+ await l.reconnect(), s.track("agent-chat", {
1438
1479
  event: "reconnect",
1439
1480
  mode: n.chatMode
1440
1481
  });
1441
1482
  } catch {
1442
- await I(), await X(!1);
1483
+ await D(), await Y(!1);
1443
1484
  }
1444
1485
  return;
1445
1486
  }
1446
- await I(), await X(!1), i.track("agent-chat", {
1487
+ await D(), await Y(!1), s.track("agent-chat", {
1447
1488
  event: "reconnect",
1448
1489
  mode: n.chatMode
1449
1490
  });
1450
1491
  },
1451
1492
  async disconnect() {
1452
- await I(), i.track("agent-chat", {
1493
+ await D(), s.track("agent-chat", {
1453
1494
  event: "disconnect",
1454
1495
  mode: n.chatMode
1455
1496
  });
1456
1497
  },
1457
1498
  publishMicrophoneStream(l) {
1458
- var h;
1459
- return (h = n.streamingManager) != null && h.publishMicrophoneStream ? n.streamingManager.publishMicrophoneStream(l) : Promise.reject(new Error("publishMicrophoneStream is not available for this streaming manager"));
1499
+ var p;
1500
+ return (p = n.streamingManager) != null && p.publishMicrophoneStream ? n.streamingManager.publishMicrophoneStream(l) : Promise.reject(new Error("publishMicrophoneStream is not available for this streaming manager"));
1460
1501
  },
1461
1502
  unpublishMicrophoneStream() {
1462
1503
  var l;
1463
1504
  return (l = n.streamingManager) != null && l.unpublishMicrophoneStream ? n.streamingManager.unpublishMicrophoneStream() : Promise.resolve();
1464
1505
  },
1465
1506
  replaceMicrophoneTrack(l) {
1466
- var h;
1467
- return (h = n.streamingManager) != null && h.replaceMicrophoneTrack ? n.streamingManager.replaceMicrophoneTrack(l) : Promise.reject(new Error("replaceMicrophoneTrack is not available for this streaming manager"));
1507
+ var p;
1508
+ return (p = n.streamingManager) != null && p.replaceMicrophoneTrack ? n.streamingManager.replaceMicrophoneTrack(l) : Promise.reject(new Error("replaceMicrophoneTrack is not available for this streaming manager"));
1468
1509
  },
1469
1510
  publishCameraStream(l) {
1470
- var h;
1471
- return (h = n.streamingManager) != null && h.publishCameraStream ? n.streamingManager.publishCameraStream(l) : Promise.reject(new Error("publishCameraStream is not available for this streaming manager"));
1511
+ var p;
1512
+ return (p = n.streamingManager) != null && p.publishCameraStream ? n.streamingManager.publishCameraStream(l) : Promise.reject(new Error("publishCameraStream is not available for this streaming manager"));
1472
1513
  },
1473
1514
  unpublishCameraStream() {
1474
1515
  var l;
1475
1516
  return (l = n.streamingManager) != null && l.unpublishCameraStream ? n.streamingManager.unpublishCameraStream() : Promise.resolve();
1476
1517
  },
1477
1518
  async chat(l) {
1478
- var k, R, P, z, F;
1479
- const h = () => {
1480
- if (Ue(o))
1481
- throw new Y(`${o} is enabled, chat is disabled`);
1519
+ var k, R, P, N, F;
1520
+ const p = () => {
1521
+ if (We(o))
1522
+ throw new $(`${o} is enabled, chat is disabled`);
1482
1523
  if (l.length >= ke)
1483
- throw new Y(`Message cannot be more than ${ke} characters`);
1524
+ throw new $(`Message cannot be more than ${ke} characters`);
1484
1525
  if (l.length === 0)
1485
- throw new Y("Message cannot be empty");
1526
+ throw new $("Message cannot be empty");
1486
1527
  if (n.chatMode === A.Maintenance)
1487
- throw new Y("Chat is in maintenance mode");
1528
+ throw new $("Chat is in maintenance mode");
1488
1529
  if (![A.TextOnly, A.Playground].includes(n.chatMode)) {
1489
1530
  if (!n.streamingManager)
1490
- throw new Y("Streaming manager is not initialized");
1531
+ throw new $("Streaming manager is not initialized");
1491
1532
  if (!n.chat)
1492
- throw new Y("Chat is not initialized");
1533
+ throw new $("Chat is not initialized");
1493
1534
  }
1494
1535
  }, v = async () => {
1495
- var g, p;
1536
+ var g, h;
1496
1537
  if (!n.chat) {
1497
- const D = await Oe(
1498
- f,
1538
+ const I = await qe(
1499
1539
  m,
1500
- i,
1540
+ f,
1541
+ s,
1501
1542
  n.chatMode,
1502
1543
  t.persistentChat
1503
1544
  );
1504
- if (!D.chat)
1505
- throw new Ye(n.chatMode, !!t.persistentChat);
1506
- n.chat = D.chat, (p = (g = t.callbacks).onNewChat) == null || p.call(g, n.chat.id);
1545
+ if (!I.chat)
1546
+ throw new Ze(n.chatMode, !!t.persistentChat);
1547
+ n.chat = I.chat, (h = (g = t.callbacks).onNewChat) == null || h.call(g, n.chat.id);
1507
1548
  }
1508
1549
  return n.chat.id;
1509
- }, C = async (g, p) => {
1510
- const D = n.chatMode === A.Playground;
1511
- return fe(w && !D ? async () => {
1512
- var T, U;
1513
- return await ((U = (T = n.streamingManager) == null ? void 0 : T.sendTextMessage) == null ? void 0 : U.call(T, l)), Promise.resolve({});
1550
+ }, C = async (g, h) => {
1551
+ const I = n.chatMode === A.Playground;
1552
+ return fe(w && !I ? async () => {
1553
+ var _, U;
1554
+ return await ((U = (_ = n.streamingManager) == null ? void 0 : _.sendTextMessage) == null ? void 0 : U.call(_, l)), Promise.resolve({});
1514
1555
  } : async () => {
1515
- var T, U;
1516
- return m.chat(
1517
- f.id,
1518
- p,
1556
+ var _, U;
1557
+ return f.chat(
1558
+ m.id,
1559
+ h,
1519
1560
  {
1520
1561
  chatMode: n.chatMode,
1521
- streamId: (T = n.streamingManager) == null ? void 0 : T.streamId,
1562
+ streamId: (_ = n.streamingManager) == null ? void 0 : _.streamId,
1522
1563
  sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
1523
- messages: g.map(({ matches: qe, ...oe }) => oe)
1564
+ messages: g.map(({ matches: Xe, ...ce }) => ce)
1524
1565
  },
1525
1566
  {
1526
- ...Je(n.chatMode),
1567
+ ...Oe(n.chatMode),
1527
1568
  skipErrorHandler: !0
1528
1569
  }
1529
1570
  );
1530
1571
  }, {
1531
1572
  limit: 2,
1532
- shouldRetryFn: (T) => {
1533
- var oe, ye, Ce, Se;
1534
- const U = (oe = T == null ? void 0 : T.message) == null ? void 0 : oe.includes("missing or invalid session_id");
1535
- return !((ye = T == null ? void 0 : T.message) == null ? void 0 : ye.includes("Stream Error")) && !U ? ((Se = (Ce = t.callbacks).onError) == null || Se.call(Ce, T), !1) : !0;
1573
+ shouldRetryFn: (_) => {
1574
+ var ce, ye, Ce, Se;
1575
+ const U = (ce = _ == null ? void 0 : _.message) == null ? void 0 : ce.includes("missing or invalid session_id");
1576
+ return !((ye = _ == null ? void 0 : _.message) == null ? void 0 : ye.includes("Stream Error")) && !U ? ((Se = (Ce = t.callbacks).onError) == null || Se.call(Ce, _), !1) : !0;
1536
1577
  },
1537
1578
  onRetry: async () => {
1538
- await I(), await X(!1);
1579
+ await D(), await Y(!1);
1539
1580
  }
1540
1581
  });
1541
1582
  };
1542
1583
  try {
1543
- j(), h(), n.messages.push({
1544
- id: G(),
1584
+ j(), p(), n.messages.push({
1585
+ id: Q(),
1545
1586
  role: "user",
1546
1587
  content: l,
1547
- parts: re(l),
1548
- created_at: new Date(H.update()).toISOString()
1588
+ parts: ne(l),
1589
+ created_at: new Date(q.update()).toISOString()
1549
1590
  }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "user");
1550
- const g = await v(), p = await C([...n.messages], g);
1551
- return p.result && n.messages.push({
1552
- id: G(),
1591
+ const g = await v(), h = await C([...n.messages], g);
1592
+ return h.result && n.messages.push({
1593
+ id: Q(),
1553
1594
  role: "assistant",
1554
- content: p.result,
1555
- parts: re(p.result),
1595
+ content: h.result,
1596
+ parts: ne(h.result),
1556
1597
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1557
- context: p.context,
1558
- matches: p.matches
1559
- }), i.track("agent-message-send", {
1598
+ context: h.context,
1599
+ matches: h.matches
1600
+ }), s.track("agent-message-send", {
1560
1601
  event: "success",
1561
1602
  messages: n.messages.length + 1
1562
- }), p.result && ((z = (P = t.callbacks).onNewMessage) == null || z.call(P, [...n.messages], "answer"), i.track("agent-message-received", {
1563
- latency: H.get(!0),
1603
+ }), h.result && ((N = (P = t.callbacks).onNewMessage) == null || N.call(P, [...n.messages], "answer"), s.track("agent-message-received", {
1604
+ latency: q.get(!0),
1564
1605
  messages: n.messages.length
1565
- })), p;
1606
+ })), h;
1566
1607
  } catch (g) {
1567
- throw ((F = n.messages[n.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && n.messages.pop(), i.track("agent-message-send", {
1608
+ throw ((F = n.messages[n.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && n.messages.pop(), s.track("agent-message-send", {
1568
1609
  event: "error",
1569
1610
  messages: n.messages.length,
1570
- error: _e(g)
1611
+ error: Ae(g)
1571
1612
  }), g;
1572
1613
  }
1573
1614
  },
1574
- rate(l, h, v) {
1575
- var R, P, z, F;
1615
+ rate(l, p, v) {
1616
+ var R, P, N, F;
1576
1617
  const C = n.messages.find((g) => g.id === l);
1577
1618
  if (n.chat) {
1578
1619
  if (!C)
1579
- throw new Error("Message not found");
1580
- } else throw new Error("Chat is not initialized");
1620
+ throw new $("Message not found");
1621
+ } else throw new $("Chat is not initialized");
1581
1622
  const k = ((R = C.matches) == null ? void 0 : R.map((g) => [g.document_id, g.id])) ?? [];
1582
- return i.track("agent-rate", {
1623
+ return s.track("agent-rate", {
1583
1624
  event: v ? "update" : "create",
1584
- thumb: h === 1 ? "up" : "down",
1585
- knowledge_id: ((P = f.knowledge) == null ? void 0 : P.id) ?? "",
1625
+ thumb: p === 1 ? "up" : "down",
1626
+ knowledge_id: ((P = m.knowledge) == null ? void 0 : P.id) ?? "",
1586
1627
  matches: k,
1587
- score: h
1588
- }), v ? m.updateRating(f.id, n.chat.id, v, {
1589
- knowledge_id: ((z = f.knowledge) == null ? void 0 : z.id) ?? "",
1628
+ score: p
1629
+ }), v ? f.updateRating(m.id, n.chat.id, v, {
1630
+ knowledge_id: ((N = m.knowledge) == null ? void 0 : N.id) ?? "",
1590
1631
  message_id: l,
1591
1632
  matches: k,
1592
- score: h
1593
- }) : m.createRating(f.id, n.chat.id, {
1594
- knowledge_id: ((F = f.knowledge) == null ? void 0 : F.id) ?? "",
1633
+ score: p
1634
+ }) : f.createRating(m.id, n.chat.id, {
1635
+ knowledge_id: ((F = m.knowledge) == null ? void 0 : F.id) ?? "",
1595
1636
  message_id: l,
1596
1637
  matches: k,
1597
- score: h
1638
+ score: p
1598
1639
  });
1599
1640
  },
1600
1641
  deleteRate(l) {
1601
1642
  if (!n.chat)
1602
- throw new Error("Chat is not initialized");
1603
- return i.track("agent-rate-delete", { type: "text" }), m.deleteRating(f.id, n.chat.id, l);
1643
+ throw new $("Chat is not initialized");
1644
+ return s.track("agent-rate-delete", { type: "text" }), f.deleteRating(m.id, n.chat.id, l);
1604
1645
  },
1605
1646
  async speak(l) {
1606
1647
  var k, R, P;
1607
- function h() {
1648
+ function p() {
1608
1649
  if (typeof l == "string") {
1609
- if (!f.presenter.voice)
1610
- throw new Error("Presenter voice is not initialized");
1650
+ if (!m.presenter.voice)
1651
+ throw new $("Presenter voice is not initialized");
1611
1652
  return {
1612
1653
  type: "text",
1613
- provider: f.presenter.voice,
1654
+ provider: m.presenter.voice,
1614
1655
  input: l,
1615
1656
  ssml: !1
1616
1657
  };
1617
1658
  }
1618
1659
  if (l.type === "text" && !l.provider) {
1619
- if (!f.presenter.voice)
1620
- throw new Error("Presenter voice is not initialized");
1660
+ if (!m.presenter.voice)
1661
+ throw new $("Presenter voice is not initialized");
1621
1662
  return {
1622
1663
  type: "text",
1623
- provider: f.presenter.voice,
1664
+ provider: m.presenter.voice,
1624
1665
  input: l.input,
1625
1666
  ssml: l.ssml
1626
1667
  };
1627
1668
  }
1628
1669
  return l;
1629
1670
  }
1630
- const v = h();
1631
- if (i.track("agent-speak", v), H.update(), n.messages && v.type === "text" && (n.messages.push({
1632
- id: G(),
1671
+ const v = p();
1672
+ if (s.track("agent-speak", v), q.update(), n.messages && v.type === "text" && (n.messages.push({
1673
+ id: Q(),
1633
1674
  role: "assistant",
1634
1675
  content: v.input,
1635
- parts: re(v.input),
1676
+ parts: ne(v.input),
1636
1677
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1637
- }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer")), ht(n.chatMode))
1678
+ }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer")), Ct(n.chatMode))
1638
1679
  return {
1639
1680
  duration: 0,
1640
1681
  video_id: "",
1641
1682
  status: "success"
1642
1683
  };
1643
1684
  if (!n.streamingManager)
1644
- throw new Error("Please connect to the agent first");
1685
+ throw new $("Please connect to the agent first");
1645
1686
  return n.streamingManager.speak({
1646
1687
  script: v,
1647
- metadata: { chat_id: (P = n.chat) == null ? void 0 : P.id, agent_id: f.id }
1688
+ metadata: { chat_id: (P = n.chat) == null ? void 0 : P.id, agent_id: m.id }
1648
1689
  });
1649
1690
  },
1650
- interrupt: _,
1651
- registerClientTool: J,
1652
- unregisterClientTool: N
1691
+ interrupt: T,
1692
+ registerClientTool: H,
1693
+ unregisterClientTool: V
1653
1694
  };
1654
1695
  }
1655
1696
  export {
1656
- ne as A,
1657
- B as C,
1658
- st as D,
1659
- it as K,
1660
- tt as P,
1661
- nt as R,
1697
+ ae as A,
1698
+ G as B,
1699
+ z as C,
1700
+ lt as D,
1701
+ ze as H,
1702
+ dt as K,
1703
+ rt as N,
1704
+ it as P,
1705
+ ot as R,
1662
1706
  x as S,
1663
- he as T,
1664
- et as U,
1665
- Y as V,
1666
- Ze as W,
1667
- zt as a,
1707
+ pe as T,
1708
+ at as U,
1709
+ $ as V,
1710
+ nt as W,
1711
+ Jt as a,
1668
1712
  W as b,
1669
- We as c,
1713
+ He as c,
1670
1714
  le as d,
1671
- b as e,
1672
- te as f,
1673
- Ot as g,
1674
- mr as h,
1675
- S as i,
1676
- rt as j,
1677
- Ye as k,
1678
- H as l,
1679
- A as m,
1680
- ur as n,
1681
- Qe as o,
1682
- ot as p,
1683
- at as q,
1684
- ze as r,
1685
- ct as s,
1686
- fr as t,
1687
- lr as u,
1688
- yt as v
1715
+ Ne as e,
1716
+ b as f,
1717
+ re as g,
1718
+ Xt as h,
1719
+ wr as i,
1720
+ S as j,
1721
+ st as k,
1722
+ q as l,
1723
+ Ze as m,
1724
+ pr as n,
1725
+ A as o,
1726
+ et as p,
1727
+ ut as q,
1728
+ ct as r,
1729
+ Fe as s,
1730
+ Ae as t,
1731
+ mt as u,
1732
+ vr as v,
1733
+ gr as w,
1734
+ hr as x,
1735
+ Rt as y
1689
1736
  };