@streamoji/aitwin 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/aitwin.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { jsx as z, jsxs as De } from "react/jsx-runtime";
2
2
  import { useState as we, useEffect as Pe, forwardRef as On, useRef as U, useMemo as Wt, useCallback as _e, useImperativeHandle as Nn } from "react";
3
- import { PipecatClient as Yi } from "@pipecat-ai/client-js";
4
- import { WebSocketTransport as Qi, DailyMediaManager as Xi, ProtobufFrameSerializer as Ji } from "@pipecat-ai/websocket-transport";
5
- import { Filter as Zi, GlProgram as ea, Application as ta, RendererType as na, Sprite as zt, Texture as Re, VideoSource as ra, Rectangle as ia } from "pixi.js";
6
- const aa = "https://aitwin.bubu.social", Zr = {
7
- publicBase: aa
8
- }, sa = "0.6.3", oa = {
9
- version: sa
10
- }, ca = {}, gt = "https://ai.aitwin.me", Un = `${Zr.publicBase}/custom-faces`, la = `${Zr.publicBase}/aitwin-workers/v${oa.version}/visemeDiffPreview.worker.js`;
11
- function ua(e) {
3
+ import { PipecatClient as Qi } from "@pipecat-ai/client-js";
4
+ import { WebSocketTransport as Xi, DailyMediaManager as Ji, ProtobufFrameSerializer as Zi } from "@pipecat-ai/websocket-transport";
5
+ import { Filter as ea, GlProgram as ta, Application as na, RendererType as ra, Sprite as zt, Texture as Re, VideoSource as ia, Rectangle as aa } from "pixi.js";
6
+ const sa = "https://aitwin.bubu.social", Zr = {
7
+ publicBase: sa
8
+ }, oa = "0.6.5", ca = {
9
+ version: oa
10
+ }, la = {}, gt = "https://ai.aitwin.me", Un = `${Zr.publicBase}/custom-faces`, ua = `${Zr.publicBase}/aitwin-workers/v${ca.version}/visemeDiffPreview.worker.js`;
11
+ function da(e) {
12
12
  if (e) return e;
13
- const t = typeof import.meta < "u" ? ca?.VITE_AITWIN_WORKER_URL : void 0;
14
- return t?.trim() ? t.trim() : la;
13
+ const t = typeof import.meta < "u" ? la?.VITE_AITWIN_WORKER_URL : void 0;
14
+ return t?.trim() ? t.trim() : ua;
15
15
  }
16
- const da = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAiTwin", kn = 3e3, $t = 16, yr = 3e3, fa = 4e3, ma = 0.85, ha = 8, Vn = 400, ei = "eng_a7f2b9c1", Wn = "eng_d4e8f3a2", lt = "eng_c9b1e6d4", ut = "visemetts", Et = lt, zn = "eve", ti = /* @__PURE__ */ new Set([
16
+ const fa = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAiTwin", kn = 3e3, $t = 16, yr = 3e3, ma = 4e3, ha = 0.85, ga = 8, Vn = 400, ei = "eng_a7f2b9c1", Wn = "eng_d4e8f3a2", lt = "eng_c9b1e6d4", ut = "visemetts", Et = lt, zn = "eve", ti = /* @__PURE__ */ new Set([
17
17
  Wn,
18
18
  lt,
19
19
  ut
@@ -28,23 +28,23 @@ const da = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAiTwin", k
28
28
  cartesia: lt,
29
29
  visemetts: ut
30
30
  };
31
- function ga(e) {
31
+ function wa(e) {
32
32
  const t = e.trim();
33
33
  if (t)
34
34
  return t in $n ? t : Mn[t.toLowerCase()];
35
35
  }
36
- function wa(e) {
36
+ function pa(e) {
37
37
  const t = e?.trim();
38
38
  if (!t) return {};
39
39
  const n = t.indexOf(":");
40
40
  if (n <= 0) return { voiceId: t };
41
- const r = ga(t.slice(0, n));
41
+ const r = wa(t.slice(0, n));
42
42
  if (!r) return { voiceId: t };
43
43
  const i = t.slice(n + 1).trim();
44
44
  return { ttsEngineId: r, voiceId: i || void 0 };
45
45
  }
46
46
  function ot(e, t) {
47
- const n = wa(t);
47
+ const n = pa(t);
48
48
  return {
49
49
  ttsEngineId: e ?? n.ttsEngineId,
50
50
  voiceId: n.voiceId
@@ -53,13 +53,13 @@ function ot(e, t) {
53
53
  function ni(e) {
54
54
  return $n[e];
55
55
  }
56
- function pa(e) {
56
+ function ya(e) {
57
57
  return e === lt;
58
58
  }
59
59
  function ri(e) {
60
60
  return e === ut;
61
61
  }
62
- function ya(e) {
62
+ function va(e) {
63
63
  if (e.ttsEngineId && e.ttsEngineId in $n)
64
64
  return e.ttsEngineId;
65
65
  const t = e.tts?.toLowerCase();
@@ -70,7 +70,14 @@ class Pn extends Error {
70
70
  super(t), this.name = "AiTwinNotFoundError";
71
71
  }
72
72
  }
73
- async function va(e, t = da) {
73
+ function ii(e, ...t) {
74
+ const n = typeof e == "string" ? e : e?.brainId?.trim() || e?.knowledgeContextId?.trim();
75
+ for (const r of [n, ...t]) {
76
+ const i = r?.trim();
77
+ if (i) return i;
78
+ }
79
+ }
80
+ async function _a(e, t = fa) {
74
81
  const n = new URL(t);
75
82
  n.searchParams.set("id", e);
76
83
  const r = await fetch(n.toString());
@@ -81,46 +88,48 @@ async function va(e, t = da) {
81
88
  const i = await r.json();
82
89
  if (!i.success)
83
90
  throw new Pn(i.error ?? "AI twin not found");
84
- const { tts: a, token: o, ...s } = i.data, u = String(s.authToken ?? o ?? "").trim() || void 0;
91
+ const { tts: a, token: o, ...s } = i.data, u = String(s.authToken ?? o ?? "").trim() || void 0, d = ii(s);
85
92
  return {
86
93
  ...s,
87
- ttsEngineId: ya(i.data),
88
- authToken: u
94
+ ttsEngineId: va(i.data),
95
+ authToken: u,
96
+ brainId: d,
97
+ knowledgeContextId: d
89
98
  };
90
99
  }
91
- const ii = "thumbnail.webp";
92
- function _a(e, t = Un) {
100
+ const ai = "thumbnail.webp";
101
+ function ba(e, t = Un) {
93
102
  const n = e.trim();
94
103
  if (!n)
95
104
  throw new Error("faceId is required");
96
- return `${t.replace(/\/$/, "")}/${n}/${ii}`;
105
+ return `${t.replace(/\/$/, "")}/${n}/${ai}`;
97
106
  }
98
107
  function vr(e) {
99
108
  const t = e?.trim();
100
109
  if (!t) return null;
101
110
  try {
102
- return _a(t);
111
+ return ba(t);
103
112
  } catch {
104
113
  return null;
105
114
  }
106
115
  }
107
- function ba(e) {
116
+ function Sa(e) {
108
117
  if (!e) return null;
109
118
  const t = (e.binBase || e.twinBase).trim().replace(/\/$/, "");
110
- return t ? `${t}/${ii}` : null;
119
+ return t ? `${t}/${ai}` : null;
111
120
  }
112
- const Sa = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAuthToken", ka = "client_6TNvp3SCs4Og0a1ijm9TommXLql1", Ta = "kk8Fq8EmexzP10jMIEwY3R44M5RKUEm1", Ea = "6TNvp3SCs4Og0a1ijm9TommXLql1", xa = "Swaraj Mali";
121
+ const ka = "https://us-central1-streamoji-265f4.cloudfunctions.net/getAuthToken", Ta = "client_6TNvp3SCs4Og0a1ijm9TommXLql1", Ea = "kk8Fq8EmexzP10jMIEwY3R44M5RKUEm1", xa = "6TNvp3SCs4Og0a1ijm9TommXLql1", Ia = "Swaraj Mali";
113
122
  async function sn() {
114
- const e = await fetch(Sa, {
123
+ const e = await fetch(ka, {
115
124
  method: "POST",
116
125
  headers: {
117
126
  "Content-Type": "application/json",
118
- "Client-Id": ka,
119
- "Client-Secret": Ta
127
+ "Client-Id": Ta,
128
+ "Client-Secret": Ea
120
129
  },
121
130
  body: JSON.stringify({
122
- userId: Ea,
123
- userName: xa
131
+ userId: xa,
132
+ userName: Ia
124
133
  })
125
134
  });
126
135
  if (!e.ok)
@@ -130,7 +139,7 @@ async function sn() {
130
139
  throw new Error("getAuthToken returned no token");
131
140
  return n;
132
141
  }
133
- async function Ia(e, t = gt) {
142
+ async function Aa(e, t = gt) {
134
143
  const n = await fetch(`${t.replace(/\/$/, "")}/api/session-value`, {
135
144
  headers: { Authorization: `Bearer ${e}` }
136
145
  });
@@ -140,7 +149,7 @@ async function Ia(e, t = gt) {
140
149
  if (!r.value) throw new Error("Session value response missing value");
141
150
  return r;
142
151
  }
143
- function Aa(e) {
152
+ function Ma(e) {
144
153
  const t = e.trim();
145
154
  if (t.length % 2 !== 0) throw new Error("Invalid hex key");
146
155
  const n = new Uint8Array(t.length / 2);
@@ -151,17 +160,17 @@ function Aa(e) {
151
160
  function en(e) {
152
161
  return Uint8Array.from(e);
153
162
  }
154
- function Ma(e, t) {
163
+ function Pa(e, t) {
155
164
  const n = new Uint8Array(e.length + t.length);
156
165
  return n.set(e, 0), n.set(t, e.length), n;
157
166
  }
158
- async function Pa(e, t) {
167
+ async function Ca(e, t) {
159
168
  if (!t) throw new Error("Asset key is required for encrypted assets");
160
169
  if (e.byteLength < 28)
161
170
  throw new Error("Encrypted payload too small");
162
- const n = new Uint8Array(e), r = en(n.subarray(0, 12)), i = en(n.subarray(12, 28)), a = en(n.subarray(28)), o = en(Ma(a, i)), s = await crypto.subtle.importKey(
171
+ const n = new Uint8Array(e), r = en(n.subarray(0, 12)), i = en(n.subarray(12, 28)), a = en(n.subarray(28)), o = en(Pa(a, i)), s = await crypto.subtle.importKey(
163
172
  "raw",
164
- Aa(t),
173
+ Ma(t),
165
174
  { name: "AES-GCM" },
166
175
  !1,
167
176
  ["decrypt"]
@@ -191,14 +200,14 @@ function _r(e, t = Un) {
191
200
  const n = `${t.replace(/\/$/, "")}/${e}`;
192
201
  return { twinBase: n, binBase: n, encrypted: !0 };
193
202
  }
194
- function Ca(e, t) {
203
+ function Ra(e, t) {
195
204
  return (e ?? t)?.trim() || void 0;
196
205
  }
197
- function Ra(e) {
206
+ function Da(e) {
198
207
  Cn = on(e);
199
208
  for (const t of Rn) t();
200
209
  }
201
- function Da(e, t) {
210
+ function Ba(e, t) {
202
211
  const n = typeof globalThis.location < "u" ? globalThis.location.href : void 0;
203
212
  if (!n) return on(e);
204
213
  const r = (i) => {
@@ -219,29 +228,29 @@ function pt() {
219
228
  throw new Error("Twin assets not configured; call setActiveTwinAssets first");
220
229
  return Cn;
221
230
  }
222
- function ai(e) {
231
+ function si(e) {
223
232
  return Rn.add(e), () => Rn.delete(e);
224
233
  }
225
234
  function cn() {
226
235
  const e = pt();
227
236
  return wt(e) ? `${e.binBase}/sil.bin` : `${e.twinBase}/sil.png`;
228
237
  }
229
- function Ba() {
238
+ function Fa() {
230
239
  const e = pt();
231
240
  return wt(e) ? `${e.binBase}/idle.bin` : `${e.twinBase}/idle.mp4`;
232
241
  }
233
- function si() {
242
+ function oi() {
234
243
  const e = pt();
235
244
  return wt(e) ? e.binBase : e.twinBase;
236
245
  }
237
246
  function qt() {
238
247
  return wt(pt());
239
248
  }
240
- function oi() {
249
+ function ci() {
241
250
  const e = pt();
242
251
  return wt(e) ? `${e.binBase}/atlas.bin` : `${e.twinBase}/atlas.json`;
243
252
  }
244
- function ci() {
253
+ function li() {
245
254
  const e = pt();
246
255
  return wt(e) ? `${e.binBase}/expression_atlas.bin` : `${e.twinBase}/expression_atlas.json`;
247
256
  }
@@ -295,22 +304,22 @@ const xt = [
295
304
  { code: "ml", label: "Malayalam", visemetts: !1, cartesia: !0 },
296
305
  { code: "mr", label: "Marathi", visemetts: !1, cartesia: !0 },
297
306
  { code: "pa", label: "Punjabi", visemetts: !1, cartesia: !0 }
298
- ], Fa = xt.map(
307
+ ], La = xt.map(
299
308
  (e) => e.code
300
- ), La = new Set(Fa), Oa = new Set(
309
+ ), Oa = new Set(La), Na = new Set(
301
310
  xt.filter((e) => e.visemetts).map((e) => e.code)
302
- ), Na = new Set(
311
+ ), Ua = new Set(
303
312
  xt.filter((e) => e.cartesia).map((e) => e.code)
304
- ), _c = "en";
305
- function Ua(e) {
306
- return La.has(e);
313
+ ), bc = "en";
314
+ function Va(e) {
315
+ return Oa.has(e);
307
316
  }
308
317
  function Hn(e) {
309
318
  const t = e?.trim();
310
319
  if (t)
311
320
  return t;
312
321
  }
313
- function bc(e) {
322
+ function Sc(e) {
314
323
  return e === ut ? xt.filter((t) => t.visemetts).map(
315
324
  (t) => t.code
316
325
  ) : e === lt ? xt.filter((t) => t.cartesia).map(
@@ -319,11 +328,11 @@ function bc(e) {
319
328
  (t) => t.code
320
329
  );
321
330
  }
322
- function Sc(e, t) {
331
+ function kc(e, t) {
323
332
  const n = t.trim();
324
- return n ? e === ut ? Oa.has(n) : e === lt ? Na.has(n) : Ua(n) : !1;
333
+ return n ? e === ut ? Na.has(n) : e === lt ? Ua.has(n) : Va(n) : !1;
325
334
  }
326
- function li(e) {
335
+ function ui(e) {
327
336
  const t = e.split(/\r?\n/);
328
337
  let n = "", r = "";
329
338
  for (const a of t)
@@ -338,7 +347,7 @@ function li(e) {
338
347
  }
339
348
  return { event: n, data: i };
340
349
  }
341
- const Va = [
350
+ const Wa = [
342
351
  "aa",
343
352
  "CH",
344
353
  "DD",
@@ -354,14 +363,14 @@ const Va = [
354
363
  "kk",
355
364
  "nn",
356
365
  "sil"
357
- ], Wa = new Map(
358
- Va.map((e) => [e.toLowerCase(), e])
366
+ ], za = new Map(
367
+ Wa.map((e) => [e.toLowerCase(), e])
359
368
  );
360
369
  function Kn(e) {
361
370
  const t = (e ?? "").trim();
362
- return t ? Wa.get(t.toLowerCase()) ?? "sil" : "sil";
371
+ return t ? za.get(t.toLowerCase()) ?? "sil" : "sil";
363
372
  }
364
- const za = {
373
+ const $a = {
365
374
  aei: ["aa", "E", "I"],
366
375
  o: ["O", "U"],
367
376
  ee: ["I"],
@@ -373,12 +382,12 @@ const za = {
373
382
  qw: ["U", "O"],
374
383
  cdgknstxyz: ["DD", "SS", "kk", "CH"]
375
384
  };
376
- function $a(e) {
385
+ function Ha(e) {
377
386
  if (!e) return ["sil"];
378
387
  const t = e.toLowerCase();
379
- return za[t] ?? ["sil"];
388
+ return $a[t] ?? ["sil"];
380
389
  }
381
- function ui(e, t) {
390
+ function di(e, t) {
382
391
  const n = e.word.length;
383
392
  if (n <= 0) return 0;
384
393
  const r = e.wduration;
@@ -394,11 +403,11 @@ function mn(e, t) {
394
403
  const n = e.toLowerCase().replace(/[^a-z']/g, "");
395
404
  return !n || At(n, t) !== "w" || t > 0 && At(n, t - 1) === "q" ? !1 : t === 0 && /^w[aeiouy]/.test(n);
396
405
  }
397
- function Ha(e, t) {
406
+ function Ka(e, t) {
398
407
  const n = e.toLowerCase(), r = At(n, t), i = n.slice(Math.max(0, t - 1), t + 2);
399
408
  return r === "i" || r === "y" ? "I" : i.includes("ee") || r === "e" || n.includes("ea") ? "E" : "aa";
400
409
  }
401
- function Ka(e, t) {
410
+ function qa(e, t) {
402
411
  const n = e.toLowerCase(), r = n.slice(
403
412
  Math.max(0, t - 1),
404
413
  Math.min(n.length, t + 3)
@@ -408,7 +417,7 @@ function Ka(e, t) {
408
417
  const i = At(n, t);
409
418
  return i === "u" || i === "w" ? "U" : "O";
410
419
  }
411
- function qa(e, t) {
420
+ function Ga(e, t) {
412
421
  const n = e.toLowerCase();
413
422
  if (mn(n, t)) return "FF";
414
423
  const r = n.slice(Math.max(0, t - 2), t + 1);
@@ -431,7 +440,7 @@ const nn = {
431
440
  x: "CH",
432
441
  j: "CH"
433
442
  };
434
- function Ga(e, t) {
443
+ function ja(e, t) {
435
444
  const n = e.toLowerCase(), r = At(n, t);
436
445
  if (nn[r]) return nn[r];
437
446
  for (let i = 0; i < n.length; i++) {
@@ -440,55 +449,55 @@ function Ga(e, t) {
440
449
  }
441
450
  return "DD";
442
451
  }
443
- function di(e, t, n) {
444
- const r = $a(e);
452
+ function fi(e, t, n) {
453
+ const r = Ha(e);
445
454
  if (r.length === 1) return r[0];
446
455
  const i = t.trim();
447
456
  if (!i) return r[0];
448
457
  const a = (e ?? "").toLowerCase(), o = Math.max(0, n);
449
458
  switch (a) {
450
459
  case "aei":
451
- return Ha(i, o);
452
- case "o":
453
460
  return Ka(i, o);
454
- case "qw":
461
+ case "o":
455
462
  return qa(i, o);
456
- case "cdgknstxyz":
463
+ case "qw":
457
464
  return Ga(i, o);
465
+ case "cdgknstxyz":
466
+ return ja(i, o);
458
467
  default:
459
468
  return r[0];
460
469
  }
461
470
  }
462
- const fi = 16, br = 47, ja = /* @__PURE__ */ new Set(["aa", "E", "I"]), Ya = /* @__PURE__ */ new Set(["DD", "SS", "kk", "CH"]), Qa = [ja, Ya];
463
- function Xa(e) {
464
- for (const t of Qa)
471
+ const mi = 16, br = 47, Ya = /* @__PURE__ */ new Set(["aa", "E", "I"]), Qa = /* @__PURE__ */ new Set(["DD", "SS", "kk", "CH"]), Xa = [Ya, Qa];
472
+ function Ja(e) {
473
+ for (const t of Xa)
465
474
  if (t.has(e)) return t;
466
475
  return null;
467
476
  }
468
- function Ja(e) {
469
- return Xa(e) != null;
477
+ function Za(e) {
478
+ return Ja(e) != null;
470
479
  }
471
- function Za(e, t = fi) {
480
+ function es(e, t = mi) {
472
481
  return t <= 0 ? e : Math.round(e / t) * t;
473
482
  }
474
- function mi(e, t = fi) {
483
+ function hi(e, t = mi) {
475
484
  return e.map((n) => ({
476
485
  ...n,
477
- vtime: Za(n.vtime, t)
486
+ vtime: es(n.vtime, t)
478
487
  }));
479
488
  }
480
- function hi(e) {
489
+ function gi(e) {
481
490
  const t = /* @__PURE__ */ new Map();
482
491
  for (const n of e)
483
492
  t.has(n.vtime) || t.set(n.vtime, n);
484
493
  return [...t.values()].sort((n, r) => n.vtime - r.vtime);
485
494
  }
486
- function gi(e) {
495
+ function wi(e) {
487
496
  if (e.length <= 2) return [...e];
488
497
  const t = [e[0]];
489
498
  for (let n = 1; n < e.length - 1; n++) {
490
499
  const r = e[n], i = e[n + 1], a = t[t.length - 1];
491
- if (!Ja(r.viseme)) {
500
+ if (!Za(r.viseme)) {
492
501
  t.push(r);
493
502
  continue;
494
503
  }
@@ -498,9 +507,9 @@ function gi(e) {
498
507
  return t.push(e[e.length - 1]), t;
499
508
  }
500
509
  function qn(e) {
501
- return gi(hi(mi(e)));
510
+ return wi(gi(hi(e)));
502
511
  }
503
- function es(e, t) {
512
+ function ts(e, t) {
504
513
  let n = "sil";
505
514
  for (const r of e) {
506
515
  if (r.vtime > t) break;
@@ -509,22 +518,22 @@ function es(e, t) {
509
518
  return n;
510
519
  }
511
520
  function Gn(e) {
512
- const t = hi(mi(e)), n = gi(t), r = new Set(n.map((a) => a.vtime)), i = [];
521
+ const t = gi(hi(e)), n = wi(t), r = new Set(n.map((a) => a.vtime)), i = [];
513
522
  for (const a of t)
514
523
  r.has(a.vtime) || i.push({ viseme: a.viseme, vtime: a.vtime });
515
524
  return i;
516
525
  }
517
- function kc(e) {
526
+ function Tc(e) {
518
527
  return Gn(e).map((t) => t.viseme);
519
528
  }
520
- const ts = 32, Sr = 48;
521
- function wi(e) {
529
+ const ns = 32, Sr = 48;
530
+ function pi(e) {
522
531
  let t = 0;
523
532
  for (const n of e)
524
533
  t = Math.max(t, n.vtime + n.vduration);
525
534
  return t;
526
535
  }
527
- function pi(e) {
536
+ function yi(e) {
528
537
  let t = null, n = -1;
529
538
  for (const r of e) {
530
539
  if (r.viseme === "sil") continue;
@@ -533,22 +542,22 @@ function pi(e) {
533
542
  }
534
543
  return t;
535
544
  }
536
- function ns(e) {
545
+ function rs(e) {
537
546
  return qn(e).find((n) => n.viseme !== "sil") ?? null;
538
547
  }
539
548
  function mt(e) {
540
- const t = wi(e);
541
- return pi(e) ? t + Vn : t;
549
+ const t = pi(e);
550
+ return yi(e) ? t + Vn : t;
542
551
  }
543
- function rs(e) {
544
- const t = [], n = ns(e);
552
+ function is(e) {
553
+ const t = [], n = rs(e);
545
554
  n && n.vtime > 0 && t.push({
546
555
  from: "sil",
547
556
  to: n.viseme,
548
557
  fromVtime: 0,
549
558
  toVtime: n.vtime
550
559
  });
551
- const r = pi(e), i = wi(e);
560
+ const r = yi(e), i = pi(e);
552
561
  return r && t.push({
553
562
  from: r.viseme,
554
563
  to: "sil",
@@ -556,7 +565,7 @@ function rs(e) {
556
565
  toVtime: i + Vn
557
566
  }), t;
558
567
  }
559
- function is(e) {
568
+ function as(e) {
560
569
  const t = qn(e), n = [];
561
570
  for (let r = 0; r < t.length - 1; r++) {
562
571
  const i = t[r].viseme, a = t[r + 1].viseme, o = t[r].vtime, s = t[r + 1].vtime;
@@ -564,16 +573,16 @@ function is(e) {
564
573
  }
565
574
  return n;
566
575
  }
567
- function as(e) {
576
+ function ss(e) {
568
577
  return e.length === 0 ? [] : [
569
- ...rs(e),
570
- ...is(e)
578
+ ...is(e),
579
+ ...as(e)
571
580
  ];
572
581
  }
573
- function ss(e, t) {
582
+ function os(e, t) {
574
583
  let n = null;
575
584
  for (const r of e) {
576
- const { transStart: i, transEnd: a } = yi(
585
+ const { transStart: i, transEnd: a } = vi(
577
586
  r.fromVtime,
578
587
  r.toVtime,
579
588
  r.from,
@@ -583,7 +592,7 @@ function ss(e, t) {
583
592
  }
584
593
  return n;
585
594
  }
586
- function yi(e, t, n, r) {
595
+ function vi(e, t, n, r) {
587
596
  const i = Math.max(0, t - e);
588
597
  if ((n === "PP" || r === "PP") && i > Sr) {
589
598
  const d = Sr, l = t, c = l - d;
@@ -595,10 +604,10 @@ function yi(e, t, n, r) {
595
604
  transEnd: l
596
605
  };
597
606
  }
598
- const o = i > 0 ? Math.max(i, ts) : 0, s = e, u = e + o;
607
+ const o = i > 0 ? Math.max(i, ns) : 0, s = e, u = e + o;
599
608
  return { gapMs: i, effectiveGapMs: o, holdEnd: e, transStart: s, transEnd: u };
600
609
  }
601
- function vi(e, t, n, r, i, a) {
610
+ function _i(e, t, n, r, i, a) {
602
611
  r.forEach((o) => {
603
612
  const u = String(o.word ?? "").trim();
604
613
  if (!u) return;
@@ -614,9 +623,9 @@ function vi(e, t, n, r, i, a) {
614
623
  }), n.forEach((o) => {
615
624
  const s = String(o.symbol ?? o.viseme ?? "").trim();
616
625
  if (!s) return;
617
- const u = Math.round((o.start ?? 0) * 1e3), d = Math.max(1, Math.round((o.duration ?? 0) * 1e3)), l = i + u, c = Si(t, l), m = c ? ui(c, l) : 0;
626
+ const u = Math.round((o.start ?? 0) * 1e3), d = Math.max(1, Math.round((o.duration ?? 0) * 1e3)), l = i + u, c = ki(t, l), m = c ? di(c, l) : 0;
618
627
  let g;
619
- ni(a) === "oculus_direct" ? (g = Kn(s), g === "U" && c && mn(c.word, m) && (g = "FF")) : g = di(
628
+ ni(a) === "oculus_direct" ? (g = Kn(s), g === "U" && c && mn(c.word, m) && (g = "FF")) : g = fi(
620
629
  s,
621
630
  c?.word ?? "",
622
631
  m
@@ -628,7 +637,7 @@ function vi(e, t, n, r, i, a) {
628
637
  });
629
638
  });
630
639
  }
631
- function _i(e, t) {
640
+ function bi(e, t) {
632
641
  let n = t;
633
642
  for (const r of e) {
634
643
  const i = Math.round((r.start ?? 0) * 1e3), a = Math.max(1, Math.round((r.duration ?? 0) * 1e3));
@@ -637,18 +646,18 @@ function _i(e, t) {
637
646
  return n;
638
647
  }
639
648
  const jn = 16e3;
640
- function bi(e) {
649
+ function Si(e) {
641
650
  const t = Number(e);
642
651
  return Number.isFinite(t) && t > 0 ? t : jn;
643
652
  }
644
- function os(e) {
653
+ function cs(e) {
645
654
  let t = e.trim();
646
655
  const n = t.indexOf(",");
647
656
  t.startsWith("data:") && n >= 0 && (t = t.slice(n + 1)), t = t.replace(/\s+/g, "").replace(/-/g, "+").replace(/_/g, "/");
648
657
  const r = t.length % 4;
649
658
  return r !== 0 && (t += "=".repeat(4 - r)), t;
650
659
  }
651
- function cs(e) {
660
+ function ls(e) {
652
661
  return e.length >= 4 && e[0] === 82 && e[1] === 73 && e[2] === 70 && e[3] === 70;
653
662
  }
654
663
  function kr(e, t, n = jn) {
@@ -662,15 +671,15 @@ function kr(e, t, n = jn) {
662
671
  const o = e.createBuffer(1, a.length, n);
663
672
  return o.copyToChannel(a, 0), o;
664
673
  }
665
- function ls(e) {
666
- const t = os(e), n = window.atob(t), r = new Uint8Array(n.length);
674
+ function us(e) {
675
+ const t = cs(e), n = window.atob(t), r = new Uint8Array(n.length);
667
676
  for (let i = 0; i < n.length; i++)
668
677
  r[i] = n.charCodeAt(i);
669
678
  return r;
670
679
  }
671
680
  async function Tr(e, t, n = jn) {
672
- const r = ls(t), i = bi(n);
673
- if (cs(r)) {
681
+ const r = us(t), i = Si(n);
682
+ if (ls(r)) {
674
683
  const a = r.buffer.slice(
675
684
  r.byteOffset,
676
685
  r.byteOffset + r.byteLength
@@ -689,13 +698,13 @@ async function Tr(e, t, n = jn) {
689
698
  return kr(e, r, i);
690
699
  }
691
700
  }
692
- function Si(e, t) {
701
+ function ki(e, t) {
693
702
  for (const n of e)
694
703
  if (t >= n.wtime && t < n.wtime + n.wduration)
695
704
  return n;
696
705
  return null;
697
706
  }
698
- function ki(e, t) {
707
+ function Ti(e, t) {
699
708
  const n = [], r = [];
700
709
  let i = null, a = !1, o = !1, s = !1, u = !1, d = 0, l = 0, c = 0, m = null, g = 1, S = t, f = !1, T = null, C = 0, R = !1, y = !1, k = 0, B = null, I = null, ie = null;
701
710
  const de = () => ({
@@ -765,9 +774,9 @@ function ki(e, t) {
765
774
  $.length !== 0 && (c = le, $.forEach((w) => {
766
775
  const b = String(w.symbol ?? w.viseme ?? "").trim();
767
776
  if (!b) return;
768
- const E = Math.round((w.start ?? 0) * 1e3), v = Math.max(1, Math.round((w.duration ?? 0) * 1e3)), N = c + E, Z = Si(M, N), te = Z ? ui(Z, N) : 0;
777
+ const E = Math.round((w.start ?? 0) * 1e3), v = Math.max(1, Math.round((w.duration ?? 0) * 1e3)), N = c + E, Z = ki(M, N), te = Z ? di(Z, N) : 0;
769
778
  let W;
770
- ni(j) === "oculus_direct" ? (W = Kn(b), W === "U" && Z && mn(Z.word, te) && (W = "FF")) : W = di(
779
+ ni(j) === "oculus_direct" ? (W = Kn(b), W === "U" && Z && mn(Z.word, te) && (W = "FF")) : W = fi(
771
780
  b,
772
781
  Z?.word ?? "",
773
782
  te
@@ -927,7 +936,7 @@ function ki(e, t) {
927
936
  playAudioChunk: async (_, M, $, le, K, j, w) => {
928
937
  if (f) return;
929
938
  B = _, I = M;
930
- const b = bi(w?.sampleRate), E = w?.newStream === !0, v = de();
939
+ const b = Si(w?.sampleRate), E = w?.newStream === !0, v = de();
931
940
  if (!$?.trim()) {
932
941
  if (le.length === 0 && K.length === 0) return;
933
942
  he(v, _, M), E && w?.onNewStream?.(), V(
@@ -989,7 +998,7 @@ function hn(e, t) {
989
998
  t < r.vtime || t >= r.vtime + r.vduration || (!n || r.vtime >= n.vtime) && (n = r);
990
999
  return n ? n.viseme : "sil";
991
1000
  }
992
- function Ti(e, t, n = 120) {
1001
+ function Ei(e, t, n = 120) {
993
1002
  const r = hn(e, t);
994
1003
  if (r !== "sil") return r;
995
1004
  let i = null;
@@ -1000,7 +1009,7 @@ function Ti(e, t, n = 120) {
1000
1009
  }
1001
1010
  return i?.viseme ?? "sil";
1002
1011
  }
1003
- function us(e, t, n = 400) {
1012
+ function ds(e, t, n = 400) {
1004
1013
  const r = t - n;
1005
1014
  let i = 0;
1006
1015
  for (const a of e)
@@ -1008,7 +1017,7 @@ function us(e, t, n = 400) {
1008
1017
  else break;
1009
1018
  i > 0 && e.splice(0, i);
1010
1019
  }
1011
- function Tc(e, t) {
1020
+ function Ec(e, t) {
1012
1021
  for (const n of e)
1013
1022
  if (t >= n.wtime && t < n.wtime + n.wduration)
1014
1023
  return n;
@@ -1024,7 +1033,7 @@ function Er(e, t) {
1024
1033
  return null;
1025
1034
  }
1026
1035
  }
1027
- const Yn = 0.5, Qn = 1.5, Ei = "Olivia", xi = "f786b574-daa5-4673-aa0c-cbe3e8534c02", gn = 0.85;
1036
+ const Yn = 0.5, Qn = 1.5, xi = "Olivia", Ii = "f786b574-daa5-4673-aa0c-cbe3e8534c02", gn = 0.85;
1028
1037
  function xr(e, t = gt, n = {}) {
1029
1038
  const r = `${t.replace(/\/$/, "")}/avatar_ttsWithPoses`, i = [], a = [], o = [], s = [];
1030
1039
  let u = 0;
@@ -1034,7 +1043,7 @@ function xr(e, t = gt, n = {}) {
1034
1043
  let T = 0, C = null, R = 0, y = null;
1035
1044
  const k = () => f.forEach((F) => F());
1036
1045
  let B = () => !1;
1037
- const I = ki(
1046
+ const I = Ti(
1038
1047
  {
1039
1048
  onSpeakingStart: () => e("speaking"),
1040
1049
  onSpeakingDone: () => e("done"),
@@ -1098,7 +1107,7 @@ function xr(e, t = gt, n = {}) {
1098
1107
  o.length = 0, s.length = 0, u = 0;
1099
1108
  }, se = (F, J, V, he, q) => {
1100
1109
  if (F.length === 0 && J.length === 0) return;
1101
- vi(
1110
+ _i(
1102
1111
  o,
1103
1112
  s,
1104
1113
  F,
@@ -1106,7 +1115,7 @@ function xr(e, t = gt, n = {}) {
1106
1115
  u,
1107
1116
  q
1108
1117
  );
1109
- const ee = _i(F, u), H = V ? Er(V, he) : null;
1118
+ const ee = bi(F, u), H = V ? Er(V, he) : null;
1110
1119
  u = Math.max(
1111
1120
  ee,
1112
1121
  H != null ? u + H : u
@@ -1131,7 +1140,7 @@ function xr(e, t = gt, n = {}) {
1131
1140
  throw new Error("Developer token required for avatar_ttsWithPoses");
1132
1141
  const q = ot(J?.ttsEngineId, J?.voiceId), ee = q.ttsEngineId ?? S ?? Et;
1133
1142
  I.resetForNewStream(ee), I.setStreamTtsEngineId(ee);
1134
- const H = q.voiceId ?? (ee === ut ? zn : Ei), X = J?.speakingRate ?? gn, be = Math.max(
1143
+ const H = q.voiceId ?? (ee === ut ? zn : xi), X = J?.speakingRate ?? gn, be = Math.max(
1135
1144
  Yn,
1136
1145
  Math.min(Qn, X)
1137
1146
  ), oe = {
@@ -1161,7 +1170,7 @@ function xr(e, t = gt, n = {}) {
1161
1170
  let j = "", w = !0;
1162
1171
  const b = async (E) => {
1163
1172
  if (V !== R) return;
1164
- const v = li(E);
1173
+ const v = ui(E);
1165
1174
  if (v) {
1166
1175
  if (v.event === "audio") {
1167
1176
  const N = v.data.chunk, Z = v.data.visemes ?? [], te = v.data.words ?? [], W = v.data.is_new_segment ?? !1, Se = v.data.sample_rate, tt = Number(v.data.audio_offset_ms ?? 0), Bt = i.length;
@@ -1268,8 +1277,8 @@ function xr(e, t = gt, n = {}) {
1268
1277
  subscribe: (F) => (f.add(F), () => f.delete(F))
1269
1278
  };
1270
1279
  }
1271
- const Ii = 16e3, Ai = 16e3;
1272
- class ds extends Ji {
1280
+ const Ai = 16e3, Mi = 16e3;
1281
+ class fs extends Zi {
1273
1282
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1274
1283
  async deserialize(t) {
1275
1284
  try {
@@ -1281,7 +1290,7 @@ class ds extends Ji {
1281
1290
  }
1282
1291
  }
1283
1292
  }
1284
- class fs extends Xi {
1293
+ class ms extends Ji {
1285
1294
  constructor() {
1286
1295
  super(
1287
1296
  !0,
@@ -1289,30 +1298,30 @@ class fs extends Xi {
1289
1298
  void 0,
1290
1299
  void 0,
1291
1300
  512,
1292
- Ii,
1293
- Ai
1301
+ Ai,
1302
+ Mi
1294
1303
  );
1295
1304
  }
1296
1305
  /** Pipecat protobuf bot audio is unused — playback comes from avatar_audio_chunk. */
1297
1306
  bufferBotAudio(t, n) {
1298
1307
  }
1299
1308
  }
1300
- const ms = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1309
+ const hs = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1301
1310
  function Ir(e) {
1302
- return ms.test(e.trim());
1311
+ return hs.test(e.trim());
1303
1312
  }
1304
- function hs(e) {
1313
+ function gs(e) {
1305
1314
  const t = e.replace(/\/$/, "");
1306
1315
  return t.startsWith("https://") ? `wss://${t.slice(8)}` : t.startsWith("http://") ? `ws://${t.slice(7)}` : t;
1307
1316
  }
1308
- function gs(e) {
1317
+ function ws(e) {
1309
1318
  if (e.wsUrl?.trim()) return e.wsUrl.trim();
1310
1319
  const t = e.authToken?.trim();
1311
1320
  if (!t)
1312
1321
  throw new Error(
1313
1322
  "Voice connect requires authToken (same JWT as SSE Authorization Bearer)."
1314
1323
  );
1315
- const n = e.apiBase ?? gt, r = new URL(`${hs(n)}/ws/voice`);
1324
+ const n = e.apiBase ?? gt, r = new URL(`${gs(n)}/ws/voice`);
1316
1325
  r.searchParams.set("authToken", t), r.searchParams.set("tenant", "aiTwin");
1317
1326
  const i = ot(e.ttsEngineId, e.voiceId), a = i.ttsEngineId;
1318
1327
  a && r.searchParams.set("ttsEngineId", a);
@@ -1320,8 +1329,8 @@ function gs(e) {
1320
1329
  o && (a && ri(a) ? Ir(o) || r.searchParams.set("voiceId", o) : Ir(o) && r.searchParams.set("voiceId", o));
1321
1330
  const s = Hn(e.language);
1322
1331
  s && r.searchParams.set("language", s);
1323
- const u = e.personaId?.trim();
1324
- u && r.searchParams.set("personaId", u);
1332
+ const u = e.brainId?.trim() || e.personaId?.trim();
1333
+ u && r.searchParams.set("brainId", u);
1325
1334
  const d = e.speakingRate ?? gn;
1326
1335
  r.searchParams.set(
1327
1336
  "speaking_rate",
@@ -1344,7 +1353,7 @@ function Tn(e, t) {
1344
1353
  });
1345
1354
  return n;
1346
1355
  }
1347
- function ws(e) {
1356
+ function ps(e) {
1348
1357
  if (!e || typeof e != "object") return null;
1349
1358
  const t = e, r = (t.data && typeof t.data == "object" && !Array.isArray(t.data) ? t.data : null) || t;
1350
1359
  return {
@@ -1355,10 +1364,10 @@ function ws(e) {
1355
1364
  function Ar(e) {
1356
1365
  return e.is_new_segment === !0 || Number(e.audio_offset_ms ?? -1) === 0 ? !0 : Number(e.chunk_index ?? -1) === 0;
1357
1366
  }
1358
- function ps(e) {
1367
+ function ys(e) {
1359
1368
  return e?.transport?._mediaManager?._wavStreamPlayer ?? null;
1360
1369
  }
1361
- function ys(e, t = {}) {
1370
+ function vs(e, t = {}) {
1362
1371
  const n = [], r = [], i = [], a = [];
1363
1372
  let o = 0;
1364
1373
  const s = [], u = [];
@@ -1375,7 +1384,7 @@ function ys(e, t = {}) {
1375
1384
  }, 450);
1376
1385
  }, V = () => R.forEach((h) => h());
1377
1386
  let he = () => !1;
1378
- const q = ki(
1387
+ const q = Ti(
1379
1388
  {
1380
1389
  onSpeakingStart: () => e("speaking"),
1381
1390
  onSpeakingDone: () => {
@@ -1426,7 +1435,7 @@ function ys(e, t = {}) {
1426
1435
  }, _ = () => {
1427
1436
  I = !0, de.clear(), q.clearAborted();
1428
1437
  }, M = () => {
1429
- const h = ps(g);
1438
+ const h = ys(g);
1430
1439
  if (h) {
1431
1440
  ie = `bot-${Date.now()}`, h.interruptedTrackIds = { [ie]: !0 };
1432
1441
  try {
@@ -1491,7 +1500,7 @@ function ys(e, t = {}) {
1491
1500
  });
1492
1501
  }, N = (h, P, ne, ue) => {
1493
1502
  if (h.length === 0 && P.length === 0) return;
1494
- vi(
1503
+ _i(
1495
1504
  i,
1496
1505
  a,
1497
1506
  h,
@@ -1499,7 +1508,7 @@ function ys(e, t = {}) {
1499
1508
  o,
1500
1509
  c
1501
1510
  );
1502
- const Te = _i(h, o);
1511
+ const Te = bi(h, o);
1503
1512
  let ve = null;
1504
1513
  const Ee = ne.trim();
1505
1514
  if (Ee)
@@ -1581,7 +1590,7 @@ function ys(e, t = {}) {
1581
1590
  _(), q.resetForNewStream(c), d = P;
1582
1591
  const Ee = `${(f.apiBase ?? gt).replace(/\/$/, "")}/avatar_ttsWithPoses`, Ke = ot(c, f.voiceId);
1583
1592
  Ke.ttsEngineId && (c = Ke.ttsEngineId, q.setStreamTtsEngineId(c));
1584
- const Ue = Ke.voiceId?.trim() || (c === ut ? zn : xi), Gt = f.speakingRate ?? gn, yn = Math.max(
1593
+ const Ue = Ke.voiceId?.trim() || (c === ut ? zn : Ii), Gt = f.speakingRate ?? gn, yn = Math.max(
1585
1594
  Yn,
1586
1595
  Math.min(Qn, Gt)
1587
1596
  ), Lt = {
@@ -1607,12 +1616,12 @@ function ys(e, t = {}) {
1607
1616
  throw new Error(`avatar_ttsWithPoses failed (${Fe.status})`);
1608
1617
  const Ge = Fe.body;
1609
1618
  if (!Ge) throw new Error("No response body");
1610
- const _t = Ge.getReader(), Me = new TextDecoder();
1619
+ const _t = Ge.getReader(), Ae = new TextDecoder();
1611
1620
  let Ie = "", je = !0;
1612
1621
  const Ye = async (rt) => {
1613
1622
  if (Te !== O || ue.signal.aborted || !I)
1614
1623
  return;
1615
- const pe = li(rt);
1624
+ const pe = ui(rt);
1616
1625
  if (pe) {
1617
1626
  if (pe.event === "audio") {
1618
1627
  const Ve = pe.data.chunk, Be = pe.data.visemes ?? [], We = pe.data.words ?? [], ze = pe.data.is_new_segment ?? !1, Ot = pe.data.sample_rate, ft = Number(pe.data.audio_offset_ms ?? 0);
@@ -1650,7 +1659,7 @@ function ys(e, t = {}) {
1650
1659
  };
1651
1660
  for (; !(Te !== O || ue.signal.aborted || !I); ) {
1652
1661
  const { done: rt, value: pe } = await _t.read();
1653
- pe && (Ie += Me.decode(pe, { stream: !0 }));
1662
+ pe && (Ie += Ae.decode(pe, { stream: !0 }));
1654
1663
  const Ve = Ie.split(`
1655
1664
 
1656
1665
  `);
@@ -1668,7 +1677,7 @@ function ys(e, t = {}) {
1668
1677
  x === ue && (x = null);
1669
1678
  }
1670
1679
  }, Se = (h) => {
1671
- const P = ws(h);
1680
+ const P = ps(h);
1672
1681
  if (!P) {
1673
1682
  console.warn("[realtimeVoice] server message with no payload", h);
1674
1683
  return;
@@ -1696,12 +1705,12 @@ function ys(e, t = {}) {
1696
1705
  W(P);
1697
1706
  break;
1698
1707
  }
1699
- }, tt = () => g || (S = new fs(), g = new Yi({
1700
- transport: new Qi({
1708
+ }, tt = () => g || (S = new ms(), g = new Qi({
1709
+ transport: new Xi({
1701
1710
  mediaManager: S,
1702
- serializer: new ds(),
1703
- recorderSampleRate: Ii,
1704
- playerSampleRate: Ai
1711
+ serializer: new fs(),
1712
+ recorderSampleRate: Ai,
1713
+ playerSampleRate: Mi
1705
1714
  }),
1706
1715
  enableCam: !1,
1707
1716
  enableMic: !0,
@@ -1772,7 +1781,7 @@ function ys(e, t = {}) {
1772
1781
  e("loading");
1773
1782
  const ne = tt();
1774
1783
  await ne.initDevices();
1775
- const ue = gs({ ...f, ttsEngineId: c });
1784
+ const ue = ws({ ...f, ttsEngineId: c });
1776
1785
  console.info("[realtimeVoice] connecting (avatar_audio_chunk RTVI):", ue);
1777
1786
  try {
1778
1787
  await ne.connect({ wsUrl: ue });
@@ -1817,13 +1826,13 @@ function ys(e, t = {}) {
1817
1826
  subscribe: (h) => (R.add(h), () => R.delete(h))
1818
1827
  };
1819
1828
  }
1820
- function Mi(e, t, n) {
1829
+ function Pi(e, t, n) {
1821
1830
  return {
1822
1831
  width: e.crop?.source_width ?? t,
1823
1832
  height: e.crop?.source_height ?? n
1824
1833
  };
1825
1834
  }
1826
- function Pi(e, t) {
1835
+ function Ci(e, t) {
1827
1836
  const n = e.crop;
1828
1837
  return {
1829
1838
  x: t?.source_x ?? n?.x ?? 0,
@@ -1832,25 +1841,25 @@ function Pi(e, t) {
1832
1841
  height: t?.source_h ?? n?.height ?? e.frame_height ?? 0
1833
1842
  };
1834
1843
  }
1835
- function Ci(e) {
1844
+ function Ri(e) {
1836
1845
  return e ? (e.w ?? 0) > 0 && (e.h ?? 0) > 0 : !1;
1837
1846
  }
1838
1847
  async function Dt(e, t) {
1839
1848
  const n = await fetch(e);
1840
1849
  if (!n.ok) throw new Error(`Failed to load encrypted asset: ${e}`);
1841
1850
  const r = await n.arrayBuffer();
1842
- return Pa(r, t);
1851
+ return Ca(r, t);
1843
1852
  }
1844
- async function Ri(e, t) {
1853
+ async function Di(e, t) {
1845
1854
  if (!t) throw new Error("Missing asset key for encrypted JSON");
1846
1855
  const n = await Dt(e, t), r = new TextDecoder().decode(n);
1847
1856
  return JSON.parse(r);
1848
1857
  }
1849
- async function vs(e) {
1858
+ async function _s(e) {
1850
1859
  const t = new Blob([e], { type: "image/webp" });
1851
1860
  return createImageBitmap(t);
1852
1861
  }
1853
- async function _s(e) {
1862
+ async function bs(e) {
1854
1863
  const t = new Blob([e], { type: "image/webp" }), n = URL.createObjectURL(t);
1855
1864
  return new Promise((r, i) => {
1856
1865
  const a = new Image();
@@ -1861,11 +1870,11 @@ async function _s(e) {
1861
1870
  }, a.src = n;
1862
1871
  });
1863
1872
  }
1864
- async function bs(e) {
1873
+ async function Ss(e) {
1865
1874
  const t = new Blob([e], { type: "image/png" });
1866
1875
  return createImageBitmap(t);
1867
1876
  }
1868
- async function Ss(e) {
1877
+ async function ks(e) {
1869
1878
  const t = new Blob([e], { type: "image/png" }), n = URL.createObjectURL(t);
1870
1879
  return new Promise((r, i) => {
1871
1880
  const a = new Image();
@@ -1876,28 +1885,28 @@ async function Ss(e) {
1876
1885
  }, a.src = n;
1877
1886
  });
1878
1887
  }
1879
- function ks(e) {
1888
+ function Ts(e) {
1880
1889
  const t = new Blob([e], { type: "video/mp4" });
1881
1890
  return URL.createObjectURL(t);
1882
1891
  }
1883
- async function Ts(e) {
1884
- const t = Ba();
1892
+ async function Es(e) {
1893
+ const t = Fa();
1885
1894
  if (!qt()) return t;
1886
1895
  if (!e) throw new Error("Missing asset key for encrypted idle video");
1887
1896
  const n = await Dt(t, e);
1888
- return ks(n);
1897
+ return Ts(n);
1889
1898
  }
1890
1899
  function It(e, t) {
1891
1900
  return `${e}/${t}_minus_sil.png`;
1892
1901
  }
1893
- const Di = 5;
1902
+ const Bi = 5;
1894
1903
  function wn(e) {
1895
1904
  const t = e?.composite_threshold;
1896
1905
  if (typeof t == "number" && t > 0) return t;
1897
1906
  const n = e?.crop?.content_threshold;
1898
- return typeof n == "number" && n > 0 ? n : Di;
1907
+ return typeof n == "number" && n > 0 ? n : Bi;
1899
1908
  }
1900
- const Ec = [
1909
+ const xc = [
1901
1910
  "aa",
1902
1911
  "E",
1903
1912
  "I",
@@ -1916,7 +1925,7 @@ const Ec = [
1916
1925
  "t01_0.25",
1917
1926
  "t02_0.50",
1918
1927
  "t03_0.75"
1919
- ], Es = Dn.length, Mr = /* @__PURE__ */ new Set([
1928
+ ], xs = Dn.length, Mr = /* @__PURE__ */ new Set([
1920
1929
  "aa__kk",
1921
1930
  "aa__nn",
1922
1931
  "aa__sil",
@@ -2041,12 +2050,12 @@ function Xn(e, t) {
2041
2050
  const i = Mt(r);
2042
2051
  return t.has(i) ? i : null;
2043
2052
  }
2044
- function Bi(e, t) {
2053
+ function Fi(e, t) {
2045
2054
  return e.filter((n) => t.has(n));
2046
2055
  }
2047
- function xs(e, t, n) {
2056
+ function Is(e, t, n) {
2048
2057
  const r = Jn(e, t);
2049
- return Bi(r, n).length > 0;
2058
+ return Fi(r, n).length > 0;
2050
2059
  }
2051
2060
  function Jn(e, t) {
2052
2061
  if (e === t) return [];
@@ -2058,40 +2067,40 @@ function Jn(e, t) {
2058
2067
  }
2059
2068
  const i = Pr(t, e);
2060
2069
  if (Mr.has(i)) {
2061
- for (let a = Es - 1; a >= 0; a--)
2070
+ for (let a = xs - 1; a >= 0; a--)
2062
2071
  n.push(Cr(i, Dn[a]));
2063
2072
  return n;
2064
2073
  }
2065
2074
  return [];
2066
2075
  }
2067
- function Is(e) {
2076
+ function As(e) {
2068
2077
  return e < 16 ? [1] : e < 24 ? [1] : e < 35 ? [0, 1, 2] : [0, 1, 2];
2069
2078
  }
2070
- function As(e, t) {
2071
- return Is(t).map((r) => e[r]).filter((r) => r != null);
2079
+ function Ms(e, t) {
2080
+ return As(t).map((r) => e[r]).filter((r) => r != null);
2072
2081
  }
2073
- function Ms(e, t, n, r) {
2082
+ function Ps(e, t, n, r) {
2074
2083
  if (r <= 0) return 0;
2075
2084
  const a = Math.max(1, n - t) / r, o = e - t, s = Math.floor(o / a);
2076
2085
  return Math.min(r - 1, Math.max(0, s));
2077
2086
  }
2078
- function Fi(e, t, n) {
2087
+ function Li(e, t, n) {
2079
2088
  if (!n) return `${e}/${t}`;
2080
2089
  const r = t.split("/").pop() ?? t, i = r.includes(".") ? r.slice(0, r.lastIndexOf(".")) : r;
2081
2090
  return `${e}/${i}.bin`;
2082
2091
  }
2083
- const Ps = [0.32, 0.24, 0.16, 0.08, 0], Cs = Ps.map(
2092
+ const Cs = [0.32, 0.24, 0.16, 0.08, 0], Rs = Cs.map(
2084
2093
  (e) => `eyes_${e.toFixed(2)}`
2085
- ), Rs = [
2094
+ ), Ds = [
2086
2095
  "eyes_0.32",
2087
2096
  "eyes_0.16",
2088
2097
  "eyes_0.00"
2089
- ], Ds = [
2098
+ ], Bs = [
2090
2099
  "eyes_0.32",
2091
2100
  "eyes_0.16",
2092
2101
  "eyes_0.08",
2093
2102
  "eyes_0.00"
2094
- ], qe = 2, Bs = -20, ln = 16, Fs = {
2103
+ ], qe = 2, Fs = -20, ln = 16, Ls = {
2095
2104
  fear: -20,
2096
2105
  anger: -20,
2097
2106
  sad: -10,
@@ -2104,12 +2113,12 @@ function Ht(e) {
2104
2113
  return `brow_${e}`;
2105
2114
  }
2106
2115
  function Pt(e) {
2107
- return Fs[e];
2116
+ return Ls[e];
2108
2117
  }
2109
2118
  function et(e) {
2110
- return Math.max(Bs, Math.min(ln, e));
2119
+ return Math.max(Fs, Math.min(ln, e));
2111
2120
  }
2112
- function Ls(e, t) {
2121
+ function Os(e, t) {
2113
2122
  if (e === t) return [];
2114
2123
  const n = e < t, r = n ? qe : -qe, i = [];
2115
2124
  let a = e;
@@ -2135,7 +2144,7 @@ function Rr(e) {
2135
2144
  const n = Math.floor(t / qe) * qe, r = Math.min(ln, n + qe), i = et(n);
2136
2145
  return t - i <= r - t ? i === r ? [i] : [i, r] : i === r ? [r] : [r, i];
2137
2146
  }
2138
- const xc = [
2147
+ const Ic = [
2139
2148
  "fear",
2140
2149
  "anger",
2141
2150
  "sad",
@@ -2143,7 +2152,7 @@ const xc = [
2143
2152
  "love",
2144
2153
  "happy",
2145
2154
  "disgust"
2146
- ], Os = {
2155
+ ], Ns = {
2147
2156
  fear: "fear",
2148
2157
  afraid: "fear",
2149
2158
  anxiety: "fear",
@@ -2168,15 +2177,15 @@ const xc = [
2168
2177
  };
2169
2178
  function st(e, t = "neutral") {
2170
2179
  const n = String(e ?? "").trim().toLowerCase();
2171
- return n ? Os[n] ?? t : t;
2180
+ return n ? Ns[n] ?? t : t;
2172
2181
  }
2173
- function Li(e) {
2182
+ function Oi(e) {
2174
2183
  return e === 0 ? null : It(Ht(e), "eyes_standard");
2175
2184
  }
2176
- function Oi(e) {
2177
- return Li(Pt(e));
2185
+ function Ni(e) {
2186
+ return Oi(Pt(e));
2178
2187
  }
2179
- const Ns = {
2188
+ const Us = {
2180
2189
  [-20]: "anger",
2181
2190
  [-10]: "sad",
2182
2191
  0: "neutral",
@@ -2195,7 +2204,7 @@ function Zn(e, t) {
2195
2204
  const u = It(Ht(s), a);
2196
2205
  if (t(u)) return u;
2197
2206
  }
2198
- const o = Ns[i];
2207
+ const o = Us[i];
2199
2208
  if (o) {
2200
2209
  const s = It(o, a);
2201
2210
  if (t(s)) return s;
@@ -2216,36 +2225,36 @@ function Zn(e, t) {
2216
2225
  }
2217
2226
  function Dr(e, t) {
2218
2227
  const n = Ht(Pt(e));
2219
- return !t || t === "eyes_standard" ? Oi(e) : e === "neutral" && t === "eyes_standard" ? null : It(n, t);
2228
+ return !t || t === "eyes_standard" ? Ni(e) : e === "neutral" && t === "eyes_standard" ? null : It(n, t);
2220
2229
  }
2221
- function Us(e, t) {
2230
+ function Vs(e, t) {
2222
2231
  const n = [];
2223
2232
  for (const r of t)
2224
2233
  n.push(Dr(e, r));
2225
2234
  for (let r = t.length - 2; r >= 0; r--)
2226
2235
  n.push(Dr(e, t[r]));
2227
- return n.push(Oi(e)), n;
2236
+ return n.push(Ni(e)), n;
2228
2237
  }
2229
- function Vs(e) {
2238
+ function Ws(e) {
2230
2239
  return It(Ht(e), "eyes_standard");
2231
2240
  }
2232
- function Ws(e, t) {
2233
- return Ls(e, t).map(Vs);
2241
+ function zs(e, t) {
2242
+ return Os(e, t).map(Ws);
2234
2243
  }
2235
- const zs = 6;
2236
- function $s(e, t) {
2244
+ const $s = 6;
2245
+ function Hs(e, t) {
2237
2246
  for (const n of e)
2238
2247
  if (t >= n.wtime && t < n.wtime + n.wduration)
2239
2248
  return n;
2240
2249
  return null;
2241
2250
  }
2242
- function Hs(e) {
2251
+ function Ks(e) {
2243
2252
  const t = et(e);
2244
- return t >= ln ? ln : et(t + zs);
2253
+ return t >= ln ? ln : et(t + $s);
2245
2254
  }
2246
- function Ks(e, t, n) {
2255
+ function qs(e, t, n) {
2247
2256
  const r = et(n);
2248
- return $s(t, e)?.emphasis ? Hs(r) : r;
2257
+ return Hs(t, e)?.emphasis ? Ks(r) : r;
2249
2258
  }
2250
2259
  function Br(e) {
2251
2260
  if (!e) return 0;
@@ -2260,7 +2269,7 @@ function Ze(e, t) {
2260
2269
  function Fr() {
2261
2270
  return Ze(14, 32);
2262
2271
  }
2263
- function qs(e) {
2272
+ function Gs(e) {
2264
2273
  if (e)
2265
2274
  return { holdMinMs: 10, holdMaxMs: 18, closedExtraMs: 0 };
2266
2275
  const t = Math.random();
@@ -2282,7 +2291,7 @@ function Lr(e, t) {
2282
2291
  const n = Ze(e.holdMinMs, e.holdMaxMs);
2283
2292
  return t ? n + e.closedExtraMs : n;
2284
2293
  }
2285
- function Gs(e = {}) {
2294
+ function js(e = {}) {
2286
2295
  const {
2287
2296
  initialDelayMs: t = 800 + Math.random() * 1200,
2288
2297
  intervalMinMs: n = 2200,
@@ -2307,7 +2316,7 @@ function Gs(e = {}) {
2307
2316
  G != null ? g = G : x == null && (g = 0), R(O);
2308
2317
  }
2309
2318
  function k(x) {
2310
- return Li(x);
2319
+ return Oi(x);
2311
2320
  }
2312
2321
  function B(x, O, G) {
2313
2322
  const se = et(O), ae = et(G);
@@ -2316,7 +2325,7 @@ function Gs(e = {}) {
2316
2325
  return;
2317
2326
  }
2318
2327
  const re = [
2319
- ...Ws(se, ae),
2328
+ ...zs(se, ae),
2320
2329
  k(ae)
2321
2330
  ];
2322
2331
  f = {
@@ -2334,10 +2343,10 @@ function Gs(e = {}) {
2334
2343
  }, c = O, y(k(m), O);
2335
2344
  }
2336
2345
  function ie(x, O, G) {
2337
- const se = G ? Rs : Math.random() < s ? Cs : Ds, ae = qs(G), re = se.length - 1;
2346
+ const se = G ? Ds : Math.random() < s ? Rs : Bs, ae = Gs(G), re = se.length - 1;
2338
2347
  f = {
2339
2348
  kind: "playing",
2340
- paths: Us(O, se),
2349
+ paths: Vs(O, se),
2341
2350
  index: 0,
2342
2351
  holdUntil: x + Lr(ae, re === 0),
2343
2352
  after: "idle",
@@ -2426,7 +2435,7 @@ function Gs(e = {}) {
2426
2435
  }
2427
2436
  };
2428
2437
  }
2429
- function js() {
2438
+ function Ys() {
2430
2439
  const e = document.createElement("video");
2431
2440
  e.muted = !0, e.playsInline = !0, e.preload = "auto", e.setAttribute("playsinline", ""), e.loop = !0;
2432
2441
  let t = !1, n = null, r = "";
@@ -2469,17 +2478,17 @@ function js() {
2469
2478
  }
2470
2479
  };
2471
2480
  }
2472
- const Ys = 50, Ni = 400;
2473
- function Qs(e, t, n) {
2481
+ const Qs = 50, Ui = 400;
2482
+ function Xs(e, t, n) {
2474
2483
  return e.filter((r) => {
2475
2484
  const i = r.queueIndex ?? -1;
2476
2485
  return i >= t && i <= n;
2477
2486
  });
2478
2487
  }
2479
- function Xs(e, t) {
2488
+ function Js(e, t) {
2480
2489
  const n = [];
2481
2490
  for (const r of e) {
2482
- const i = Qs(
2491
+ const i = Xs(
2483
2492
  t,
2484
2493
  r.start_word,
2485
2494
  r.end_word
@@ -2488,30 +2497,30 @@ function Xs(e, t) {
2488
2497
  const a = i[0], o = i[i.length - 1];
2489
2498
  n.push({
2490
2499
  sentence: r,
2491
- startMs: Math.max(0, a.wtime - Ys),
2492
- endMs: o.wtime + o.wduration + Ni
2500
+ startMs: Math.max(0, a.wtime - Qs),
2501
+ endMs: o.wtime + o.wduration + Ui
2493
2502
  });
2494
2503
  }
2495
2504
  return n.sort((r, i) => r.startMs - i.startMs);
2496
2505
  }
2497
- function Js(e, t, n, r = "neutral") {
2506
+ function Zs(e, t, n, r = "neutral") {
2498
2507
  const i = st(r);
2499
2508
  if (t.length === 0) return i;
2500
2509
  if (n.length === 0 || e < n[0].wtime)
2501
2510
  return st(t[0]?.emotion, i);
2502
- const a = Xs(t, n);
2511
+ const a = Js(t, n);
2503
2512
  let o = null;
2504
2513
  for (const d of a)
2505
2514
  e >= d.startMs && e <= d.endMs && (o = d);
2506
2515
  if (o)
2507
2516
  return st(o.sentence.emotion, i);
2508
2517
  const s = n[n.length - 1], u = s.wtime + s.wduration;
2509
- return e > u + Ni ? st(
2518
+ return e > u + Ui ? st(
2510
2519
  t[t.length - 1]?.emotion,
2511
2520
  i
2512
2521
  ) : i;
2513
2522
  }
2514
- function er(e, t, n, r, i = Di) {
2523
+ function er(e, t, n, r, i = Bi) {
2515
2524
  const a = new OffscreenCanvas(n, r), o = a.getContext("2d", { willReadFrequently: !0 });
2516
2525
  o.drawImage(e, 0, 0, n, r);
2517
2526
  const s = o.getImageData(0, 0, n, r), u = o.createImageData(n, r);
@@ -2529,11 +2538,11 @@ function er(e, t, n, r, i = Di) {
2529
2538
  }
2530
2539
  let ht = null, Ct = null;
2531
2540
  const un = /* @__PURE__ */ new Map();
2532
- function Zs() {
2541
+ function eo() {
2533
2542
  ht = null, Ct = null, un.clear();
2534
2543
  }
2535
- ai(Zs);
2536
- function eo(e) {
2544
+ si(eo);
2545
+ function to(e) {
2537
2546
  return e ?? Ct ?? void 0;
2538
2547
  }
2539
2548
  function tr(e) {
@@ -2542,20 +2551,20 @@ function tr(e) {
2542
2551
  r.decoding = "async", r.onload = () => t(r), r.onerror = () => n(new Error(`Failed to load image: ${e}`)), r.src = e;
2543
2552
  });
2544
2553
  }
2545
- async function to(e) {
2546
- return qt() ? Ss(
2554
+ async function no(e) {
2555
+ return qt() ? ks(
2547
2556
  await Dt(cn(), e ?? "")
2548
2557
  ) : tr(cn());
2549
2558
  }
2550
2559
  async function Or(e, t, n, r) {
2551
- const i = n ? await Ri(e, r) : await fetch(e).then((d) => {
2560
+ const i = n ? await Di(e, r) : await fetch(e).then((d) => {
2552
2561
  if (!d.ok) throw new Error(`Failed to load ${e}`);
2553
2562
  return d.json();
2554
2563
  }), a = i.sheets?.[0];
2555
2564
  if (!a?.path) throw new Error(`${e} has no sheets[0].path`);
2556
- const o = n ? await _s(
2565
+ const o = n ? await bs(
2557
2566
  await Dt(
2558
- Fi(t, a.path, n),
2567
+ Li(t, a.path, n),
2559
2568
  r ?? ""
2560
2569
  )
2561
2570
  ) : await tr(`${t}/${a.path}`), s = /* @__PURE__ */ new Map();
@@ -2567,7 +2576,7 @@ async function Or(e, t, n, r) {
2567
2576
  return { atlas: o, atlasMeta: i, cellByPath: s, sheetByIndex: u, diffBase: t };
2568
2577
  }
2569
2578
  async function Bn(e) {
2570
- const t = eo(e), n = qt();
2579
+ const t = to(e), n = qt();
2571
2580
  if (n && !t)
2572
2581
  throw new Error("Encrypted assets enabled but no key provided");
2573
2582
  if (ht && (!n || Ct === (t ?? null))) {
@@ -2578,10 +2587,10 @@ async function Bn(e) {
2578
2587
  };
2579
2588
  }
2580
2589
  Ct = t ?? null, un.clear();
2581
- const r = si();
2590
+ const r = oi();
2582
2591
  ht = (async () => {
2583
- const a = await to(t), o = await Or(
2584
- oi(),
2592
+ const a = await no(t), o = await Or(
2593
+ ci(),
2585
2594
  r,
2586
2595
  n,
2587
2596
  t
@@ -2589,7 +2598,7 @@ async function Bn(e) {
2589
2598
  let s = null;
2590
2599
  try {
2591
2600
  s = await Or(
2592
- ci(),
2601
+ li(),
2593
2602
  r,
2594
2603
  n,
2595
2604
  t
@@ -2607,13 +2616,13 @@ async function nr(e) {
2607
2616
  return ht;
2608
2617
  }
2609
2618
  function Rt(e) {
2610
- return Mi(
2619
+ return Pi(
2611
2620
  e.viseme.atlasMeta,
2612
2621
  e.sil.naturalWidth,
2613
2622
  e.sil.naturalHeight
2614
2623
  );
2615
2624
  }
2616
- function no(e, t) {
2625
+ function ro(e, t) {
2617
2626
  const n = document.createElement("canvas");
2618
2627
  return n.width = t.w, n.height = t.h, n.getContext("2d", { willReadFrequently: !0 }).drawImage(e.atlas, t.x, t.y, t.w, t.h, 0, 0, t.w, t.h), n;
2619
2628
  }
@@ -2623,9 +2632,9 @@ async function dn(e, t, n) {
2623
2632
  const a = (async () => {
2624
2633
  const o = t.cellByPath.get(n);
2625
2634
  if (!o) throw new Error(`No atlas cell for path: ${n}`);
2626
- const s = Pi(t.atlasMeta, o), u = Rt(e);
2627
- if (Ci(o)) {
2628
- const c = no(t, o), m = document.createElement("canvas");
2635
+ const s = Ci(t.atlasMeta, o), u = Rt(e);
2636
+ if (Ri(o)) {
2637
+ const c = ro(t, o), m = document.createElement("canvas");
2629
2638
  m.width = u.width, m.height = u.height;
2630
2639
  const g = m.getContext("2d");
2631
2640
  return g.fillStyle = "#000", g.fillRect(0, 0, u.width, u.height), g.drawImage(c, s.x, s.y), m;
@@ -2697,7 +2706,7 @@ async function Fn(e, t, n) {
2697
2706
  );
2698
2707
  u.drawImage(d, 0, 0);
2699
2708
  }
2700
- async function ro(e, t) {
2709
+ async function io(e, t) {
2701
2710
  const n = await nr(Ct ?? void 0), r = wn(n.viseme.atlasMeta), { width: i, height: a } = Rt(n), o = [];
2702
2711
  if (e.mouthPath) {
2703
2712
  const l = new Set(n.viseme.cellByPath.keys()), c = Xn(e.mouthPath, l) ?? (l.has(e.mouthPath) ? e.mouthPath : null);
@@ -2724,7 +2733,7 @@ async function ro(e, t) {
2724
2733
  );
2725
2734
  return u.drawImage(d, 0, 0), s.transferToImageBitmap();
2726
2735
  }
2727
- async function io(e) {
2736
+ async function ao(e) {
2728
2737
  await Fn(e, { mouthPath: null, expressionPath: null });
2729
2738
  }
2730
2739
  const rn = {
@@ -2732,10 +2741,10 @@ const rn = {
2732
2741
  fontSize: "clamp(0.875rem, 2.5vw, 1.125rem)",
2733
2742
  color: "rgba(255,255,255,0.85)"
2734
2743
  };
2735
- function ao(e) {
2744
+ function so(e) {
2736
2745
  return e.length === 0 ? "" : e.map((t) => t.word).join(" ");
2737
2746
  }
2738
- function so(e) {
2747
+ function oo(e) {
2739
2748
  if (!e)
2740
2749
  return { enabled: !1, style: rn };
2741
2750
  const t = e === !0 ? {} : e;
@@ -2748,7 +2757,7 @@ function so(e) {
2748
2757
  }
2749
2758
  };
2750
2759
  }
2751
- const oo = {
2760
+ const co = {
2752
2761
  position: "absolute",
2753
2762
  bottom: 0,
2754
2763
  left: 0,
@@ -2757,7 +2766,7 @@ const oo = {
2757
2766
  justifyContent: "center",
2758
2767
  padding: "0.75rem 1rem",
2759
2768
  pointerEvents: "none"
2760
- }, co = {
2769
+ }, lo = {
2761
2770
  display: "inline-block",
2762
2771
  maxWidth: "100%",
2763
2772
  padding: "0.45rem 0.85rem",
@@ -2765,7 +2774,7 @@ const oo = {
2765
2774
  background: "rgba(0,0,0,0.55)",
2766
2775
  lineHeight: 1.4,
2767
2776
  textAlign: "center"
2768
- }, lo = {
2777
+ }, uo = {
2769
2778
  display: "-webkit-box",
2770
2779
  WebkitLineClamp: 2,
2771
2780
  WebkitBoxOrient: "vertical",
@@ -2773,30 +2782,30 @@ const oo = {
2773
2782
  maxWidth: "100%",
2774
2783
  margin: 0
2775
2784
  };
2776
- function uo({
2785
+ function fo({
2777
2786
  text: e,
2778
2787
  style: t
2779
2788
  }) {
2780
- return /* @__PURE__ */ z("div", { style: oo, "aria-live": "polite", "aria-atomic": "true", children: /* @__PURE__ */ z(
2789
+ return /* @__PURE__ */ z("div", { style: co, "aria-live": "polite", "aria-atomic": "true", children: /* @__PURE__ */ z(
2781
2790
  "div",
2782
2791
  {
2783
2792
  style: {
2784
- ...co,
2793
+ ...lo,
2785
2794
  fontFamily: t.fontFamily,
2786
2795
  fontSize: t.fontSize,
2787
2796
  color: t.color
2788
2797
  },
2789
- children: /* @__PURE__ */ z("p", { style: lo, children: e })
2798
+ children: /* @__PURE__ */ z("p", { style: uo, children: e })
2790
2799
  }
2791
2800
  ) });
2792
2801
  }
2793
- const fo = {
2802
+ const mo = {
2794
2803
  inset: 0,
2795
2804
  overflow: "hidden",
2796
2805
  pointerEvents: "none",
2797
2806
  position: "absolute",
2798
2807
  zIndex: 3
2799
- }, mo = {
2808
+ }, ho = {
2800
2809
  filter: "blur(22px)",
2801
2810
  height: "100%",
2802
2811
  inset: 0,
@@ -2805,26 +2814,26 @@ const fo = {
2805
2814
  position: "absolute",
2806
2815
  transform: "scale(1.08)",
2807
2816
  width: "100%"
2808
- }, ho = {
2817
+ }, go = {
2809
2818
  backdropFilter: "blur(10px)",
2810
2819
  WebkitBackdropFilter: "blur(10px)",
2811
2820
  inset: 0,
2812
2821
  position: "absolute"
2813
2822
  };
2814
- function go({ thumbnailUrl: e }) {
2823
+ function wo({ thumbnailUrl: e }) {
2815
2824
  const [t, n] = we(!1);
2816
2825
  Pe(() => {
2817
2826
  n(!1);
2818
2827
  }, [e]);
2819
2828
  const r = !!e && t;
2820
- return /* @__PURE__ */ De("div", { style: fo, "aria-hidden": !0, children: [
2829
+ return /* @__PURE__ */ De("div", { style: mo, "aria-hidden": !0, children: [
2821
2830
  e ? /* @__PURE__ */ z(
2822
2831
  "img",
2823
2832
  {
2824
2833
  src: e,
2825
2834
  alt: "",
2826
2835
  style: {
2827
- ...mo,
2836
+ ...ho,
2828
2837
  opacity: r ? 1 : 0,
2829
2838
  transition: "opacity 0.45s ease"
2830
2839
  },
@@ -2836,21 +2845,21 @@ function go({ thumbnailUrl: e }) {
2836
2845
  "div",
2837
2846
  {
2838
2847
  style: {
2839
- ...ho,
2848
+ ...go,
2840
2849
  background: r ? "rgba(0, 0, 0, 0.28)" : "rgba(10, 10, 11, 0.92)"
2841
2850
  }
2842
2851
  }
2843
2852
  )
2844
2853
  ] });
2845
2854
  }
2846
- let Ui = null;
2855
+ let Vi = null;
2847
2856
  function Nr(e) {
2848
- Ui = e;
2857
+ Vi = e;
2849
2858
  }
2850
2859
  function ct() {
2851
- return Ui;
2860
+ return Vi;
2852
2861
  }
2853
- function wo(e) {
2862
+ function po(e) {
2854
2863
  return `${e.from}→${e.to}@${e.fromVtime}`;
2855
2864
  }
2856
2865
  function Ur() {
@@ -2871,7 +2880,7 @@ function Ur() {
2871
2880
  bufferPrefetched: 0
2872
2881
  };
2873
2882
  }
2874
- function po() {
2883
+ function yo() {
2875
2884
  let e = Ur();
2876
2885
  const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
2877
2886
  let i = "", a = -1, o = "";
@@ -2900,7 +2909,7 @@ function po() {
2900
2909
  e.workerStale += 1;
2901
2910
  },
2902
2911
  onTransitionSample(l, c) {
2903
- const m = wo(l);
2912
+ const m = po(l);
2904
2913
  e.transitionFramesSampled += 1, m !== i && (i = m, a = -1, o !== m && (o = m, e.rifeFramesOmittedByGap += l.omittedByGap)), c && n.add(c), a >= 0 && l.frameIdx > a + 1 && (e.transitionFramesMissed += l.frameIdx - a - 1), a = l.frameIdx;
2905
2914
  },
2906
2915
  onBufferTick() {
@@ -2963,9 +2972,9 @@ function po() {
2963
2972
  }
2964
2973
  };
2965
2974
  }
2966
- const Vi = Vn, yo = 200, Vr = 300, vo = 100, _o = 600, Wi = "__sil__";
2975
+ const Wi = Vn, vo = 200, Vr = 300, _o = 100, bo = 600, zi = "__sil__";
2967
2976
  function Wr(e) {
2968
- return e.lastDrawnKey ? e.lastDrawnKey.split("|")[0] === Wi : !1;
2977
+ return e.lastDrawnKey ? e.lastDrawnKey.split("|")[0] === zi : !1;
2969
2978
  }
2970
2979
  function rr() {
2971
2980
  return { lastDrawnKey: "" };
@@ -2973,41 +2982,41 @@ function rr() {
2973
2982
  function Ne(e) {
2974
2983
  e.lastDrawnKey = "", e.transitionCache = void 0;
2975
2984
  }
2976
- function bo(e, t) {
2985
+ function So(e, t) {
2977
2986
  if (t?.transitionCache && t.transitionCache.queueLength === e.length)
2978
2987
  return t.transitionCache.transitions;
2979
- const n = as(e);
2988
+ const n = ss(e);
2980
2989
  return t && (t.transitionCache = { queueLength: e.length, transitions: n }), n;
2981
2990
  }
2982
- function So(e, t) {
2991
+ function ko(e, t) {
2983
2992
  let n = "sil";
2984
2993
  for (const r of e)
2985
2994
  r.viseme !== "sil" && (t != null && r.vtime > t || (n = r.viseme));
2986
2995
  return n;
2987
2996
  }
2988
- function ko(e, t, n, r = 120) {
2997
+ function To(e, t, n, r = 120) {
2989
2998
  if (n !== "sil")
2990
2999
  return n;
2991
- const i = Ti(e, t, r);
2992
- return i !== "sil" ? i : So(e, t);
3000
+ const i = Ei(e, t, r);
3001
+ return i !== "sil" ? i : ko(e, t);
2993
3002
  }
2994
- function To(e, t) {
2995
- return e === "sil" ? !1 : t ? xs(e, "sil", t) : Jn(e, "sil").length > 0;
3003
+ function Eo(e, t) {
3004
+ return e === "sil" ? !1 : t ? Is(e, "sil", t) : Jn(e, "sil").length > 0;
2996
3005
  }
2997
- function Eo() {
2998
- return Vi + _o;
3006
+ function xo() {
3007
+ return Wi + bo;
2999
3008
  }
3000
3009
  function fn(e) {
3001
- return e ?? Wi;
3010
+ return e ?? zi;
3002
3011
  }
3003
- function ir(e, t, n, r, i = vo) {
3012
+ function ir(e, t, n, r, i = _o) {
3004
3013
  if (e.length === 0)
3005
3014
  return { diffPath: null, label: "sil" };
3006
3015
  if (t >= mt(e))
3007
3016
  return { diffPath: null, label: "sil" };
3008
- const a = bo(e, r), o = ss(a, t);
3017
+ const a = So(e, r), o = os(a, t);
3009
3018
  if (o) {
3010
- const d = yi(
3019
+ const d = vi(
3011
3020
  o.fromVtime,
3012
3021
  o.toVtime,
3013
3022
  o.from,
@@ -3015,10 +3024,10 @@ function ir(e, t, n, r, i = vo) {
3015
3024
  );
3016
3025
  if (t >= d.transStart && t < d.transEnd) {
3017
3026
  let l = Jn(o.from, o.to);
3018
- n && (l = Bi(l, n));
3019
- const c = As(l, d.effectiveGapMs);
3027
+ n && (l = Fi(l, n));
3028
+ const c = Ms(l, d.effectiveGapMs);
3020
3029
  if (c.length > 0) {
3021
- const m = Ms(
3030
+ const m = Ps(
3022
3031
  t,
3023
3032
  d.transStart,
3024
3033
  d.transEnd,
@@ -3043,8 +3052,8 @@ function ir(e, t, n, r, i = vo) {
3043
3052
  }
3044
3053
  }
3045
3054
  const s = qn(e);
3046
- let u = es(s, t);
3047
- return u === "sil" && (u = Ti(e, t, i)), u === "sil" ? { diffPath: null, label: "sil" } : { diffPath: Mt(u), label: u };
3055
+ let u = ts(s, t);
3056
+ return u === "sil" && (u = Ei(e, t, i)), u === "sil" ? { diffPath: null, label: "sil" } : { diffPath: Mt(u), label: u };
3048
3057
  }
3049
3058
  function Kt(e, t) {
3050
3059
  const n = t ?? fn(e.expressionPath);
@@ -3071,7 +3080,7 @@ function xn(e, t, n, r, i, a, o = null, s = null) {
3071
3080
  m === l && (r.lastDrawnKey = l);
3072
3081
  }));
3073
3082
  }
3074
- function zi(e, t, n, r, i = $t, a) {
3083
+ function $i(e, t, n, r, i = $t, a) {
3075
3084
  if (n <= t || e.length === 0) return [];
3076
3085
  const o = a ?? rr(), s = [];
3077
3086
  let u = "";
@@ -3091,7 +3100,7 @@ function zi(e, t, n, r, i = $t, a) {
3091
3100
  }
3092
3101
  return s;
3093
3102
  }
3094
- const xo = 3;
3103
+ const Io = 3;
3095
3104
  function ar(e) {
3096
3105
  let t = 0;
3097
3106
  const n = [];
@@ -3116,7 +3125,7 @@ function ar(e) {
3116
3125
  return {
3117
3126
  enqueue(s, u, d) {
3118
3127
  const l = n.findIndex((c) => c.drawKey === u);
3119
- l >= 0 ? n[l] = { diffs: s, drawKey: u, onDisplayed: d } : (n.length >= xo && (n.shift(), ct()?.onQueueSuperseded()), n.push({ diffs: s, drawKey: u, onDisplayed: d })), o();
3128
+ l >= 0 ? n[l] = { diffs: s, drawKey: u, onDisplayed: d } : (n.length >= Io && (n.shift(), ct()?.onQueueSuperseded()), n.push({ diffs: s, drawKey: u, onDisplayed: d })), o();
3120
3129
  },
3121
3130
  reset() {
3122
3131
  t += 1, n.length = 0;
@@ -3129,7 +3138,7 @@ function ar(e) {
3129
3138
  }
3130
3139
  };
3131
3140
  }
3132
- function Io(e, t = 2) {
3141
+ function Ao(e, t = 2) {
3133
3142
  const n = [], r = /* @__PURE__ */ new Set();
3134
3143
  let i = 0, a = !1, o = 0;
3135
3144
  const s = (d, l) => `${d}|${l}`, u = async () => {
@@ -3171,7 +3180,7 @@ function Io(e, t = 2) {
3171
3180
  }
3172
3181
  };
3173
3182
  }
3174
- function Ao() {
3183
+ function Mo() {
3175
3184
  const e = /* @__PURE__ */ new Map(), t = (n) => {
3176
3185
  n.bitmap.close();
3177
3186
  };
@@ -3206,8 +3215,8 @@ function Ao() {
3206
3215
  }
3207
3216
  };
3208
3217
  }
3209
- function Mo(e, t, n, r, i, a) {
3210
- const o = zi(
3218
+ function Po(e, t, n, r, i, a) {
3219
+ const o = $i(
3211
3220
  t,
3212
3221
  n,
3213
3222
  r,
@@ -3221,10 +3230,10 @@ function Mo(e, t, n, r, i, a) {
3221
3230
  e.has(u.displayAtMs, u.mouthKey) && (s += 1);
3222
3231
  return { ready: s, total: o.length };
3223
3232
  }
3224
- function Po(e) {
3225
- const t = Ao(), n = rr(), r = /* @__PURE__ */ new Set();
3233
+ function Co(e) {
3234
+ const t = Mo(), n = rr(), r = /* @__PURE__ */ new Set();
3226
3235
  let i = "", a = null;
3227
- const o = Io(
3236
+ const o = Ao(
3228
3237
  async (c) => {
3229
3238
  try {
3230
3239
  if (!e.supportsBufferedPlayback) return;
@@ -3244,7 +3253,7 @@ function Po(e) {
3244
3253
  r.delete(c.mouthKey);
3245
3254
  }
3246
3255
  },
3247
- ha
3256
+ ga
3248
3257
  ), s = (c) => {
3249
3258
  for (const m of c)
3250
3259
  t.has(m.displayAtMs, m.mouthKey) || r.has(m.mouthKey) || o.isQueuedOrInflight(0, m.mouthKey) || (r.add(m.mouthKey), o.enqueue({
@@ -3258,7 +3267,7 @@ function Po(e) {
3258
3267
  }));
3259
3268
  }, u = (c, m, g, S = kn) => {
3260
3269
  if (!e.supportsBufferedPlayback) return;
3261
- const f = Math.max(0, m - $t * 4), T = zi(
3270
+ const f = Math.max(0, m - $t * 4), T = $i(
3262
3271
  c,
3263
3272
  f,
3264
3273
  m + S,
@@ -3287,7 +3296,7 @@ function Po(e) {
3287
3296
  },
3288
3297
  isWarmupReady(c, m = yr) {
3289
3298
  if (!e.supportsBufferedPlayback) return !0;
3290
- const { ready: g, total: S } = Mo(
3299
+ const { ready: g, total: S } = Po(
3291
3300
  t,
3292
3301
  c.queue,
3293
3302
  0,
@@ -3295,7 +3304,7 @@ function Po(e) {
3295
3304
  c.availablePaths,
3296
3305
  n
3297
3306
  );
3298
- return S === 0 ? !1 : g / S >= ma;
3307
+ return S === 0 ? !1 : g / S >= ha;
3299
3308
  },
3300
3309
  getBufferedFrameCount: () => t.size(),
3301
3310
  tick(c) {
@@ -3328,7 +3337,7 @@ function Po(e) {
3328
3337
  }
3329
3338
  };
3330
3339
  }
3331
- const Co = `
3340
+ const Ro = `
3332
3341
  in vec2 aPosition;
3333
3342
  out vec2 vTextureCoord;
3334
3343
 
@@ -3356,7 +3365,7 @@ void main(void)
3356
3365
  gl_Position = filterVertexPosition();
3357
3366
  vTextureCoord = filterTextureCoord();
3358
3367
  }
3359
- `, Ro = `
3368
+ `, Do = `
3360
3369
  in vec2 vTextureCoord;
3361
3370
  out vec4 finalColor;
3362
3371
 
@@ -3372,10 +3381,10 @@ void main(void)
3372
3381
  }
3373
3382
  `;
3374
3383
  function $r(e = 5) {
3375
- const t = new Zi({
3376
- glProgram: ea.from({
3377
- vertex: Co,
3378
- fragment: Ro,
3384
+ const t = new ea({
3385
+ glProgram: ta.from({
3386
+ vertex: Ro,
3387
+ fragment: Do,
3379
3388
  name: "threshold-key-filter"
3380
3389
  }),
3381
3390
  resources: {
@@ -3390,16 +3399,16 @@ function $r(e = 5) {
3390
3399
  t.resources.thresholdUniforms.uniforms.uThreshold * 255
3391
3400
  ), t;
3392
3401
  }
3393
- function Do(e, t, n) {
3402
+ function Bo(e, t, n) {
3394
3403
  return e > n || t > n;
3395
3404
  }
3396
- function Bo(e) {
3405
+ function Fo(e) {
3397
3406
  return e ? e.getParameter(e.MAX_TEXTURE_SIZE) : 4096;
3398
3407
  }
3399
- function Fo(e, t) {
3400
- return t != null && t > 0 ? Math.floor(t) : Bo(e);
3401
- }
3402
3408
  function Lo(e, t) {
3409
+ return t != null && t > 0 ? Math.floor(t) : Fo(e);
3410
+ }
3411
+ function Oo(e, t) {
3403
3412
  const n = document.createElement("canvas");
3404
3413
  n.width = t.w, n.height = t.h;
3405
3414
  const r = n.getContext("2d");
@@ -3407,23 +3416,23 @@ function Lo(e, t) {
3407
3416
  throw new Error("Failed to acquire 2d context for atlas cell crop");
3408
3417
  return r.drawImage(e, t.x, t.y, t.w, t.h, 0, 0, t.w, t.h), n;
3409
3418
  }
3410
- function $i(e) {
3419
+ function Hi(e) {
3411
3420
  return fetch(e).then((t) => {
3412
3421
  if (!t.ok) throw new Error(`Failed to load image: ${e}`);
3413
3422
  return t.blob();
3414
3423
  }).then((t) => createImageBitmap(t));
3415
3424
  }
3416
3425
  async function Hr(e, t, n, r, i) {
3417
- const a = n ? await Ri(e, i) : await fetch(e).then((c) => {
3426
+ const a = n ? await Di(e, i) : await fetch(e).then((c) => {
3418
3427
  if (!c.ok) throw new Error(`Failed to load ${e}`);
3419
3428
  return c.json();
3420
3429
  }), o = a.sheets?.[0];
3421
3430
  if (!o?.path) throw new Error(`${e} has no sheets[0].path`);
3422
3431
  const s = /* @__PURE__ */ new Map(), u = async (c, m) => {
3423
- const g = Fi(t, m, n), S = n ? await vs(
3432
+ const g = Li(t, m, n), S = n ? await _s(
3424
3433
  await Dt(g, i ?? "")
3425
- ) : await $i(g);
3426
- if (Do(S.width, S.height, r))
3434
+ ) : await Hi(g);
3435
+ if (Bo(S.width, S.height, r))
3427
3436
  return console.info(
3428
3437
  `[PixiVisemeCompositor] Sheet ${m} (${S.width}x${S.height}) exceeds MAX_TEXTURE_SIZE=${r}; using per-cell crops.`
3429
3438
  ), { mode: "cells", bitmap: S };
@@ -3447,8 +3456,8 @@ async function Hr(e, t, n, r, i) {
3447
3456
  sheets: s
3448
3457
  };
3449
3458
  }
3450
- async function Oo(e, t = {}) {
3451
- const n = new ta();
3459
+ async function No(e, t = {}) {
3460
+ const n = new na();
3452
3461
  try {
3453
3462
  await n.init({
3454
3463
  canvas: e,
@@ -3466,9 +3475,9 @@ async function Oo(e, t = {}) {
3466
3475
  } catch (w) {
3467
3476
  throw n.destroy({ removeView: !1 }), w;
3468
3477
  }
3469
- if (n.renderer.type !== na.WEBGL)
3478
+ if (n.renderer.type !== ra.WEBGL)
3470
3479
  throw n.destroy({ removeView: !1 }), new Error("Pixi did not initialize a WebGL renderer");
3471
- const r = Fo(
3480
+ const r = Lo(
3472
3481
  n.renderer.gl,
3473
3482
  t.maxTextureSize
3474
3483
  );
@@ -3486,7 +3495,7 @@ async function Oo(e, t = {}) {
3486
3495
  let T = null, C = null, R = null, y = null, k = null, B = null, I = null, ie = 842, de = 1264, x = null, O = 5;
3487
3496
  const G = /* @__PURE__ */ new Map();
3488
3497
  let se = null, ae = null, re = null;
3489
- const F = ai(() => {
3498
+ const F = si(() => {
3490
3499
  G.clear(), B = null, I = null, T = null, x = null;
3491
3500
  }), J = (w, b) => {
3492
3501
  ie = w, de = b, n.renderer.resize(w, b), (e.width !== w || e.height !== b) && (e.width = w, e.height = b);
@@ -3536,7 +3545,7 @@ async function Oo(e, t = {}) {
3536
3545
  C && (C.destroy(!1), C = null), y = null;
3537
3546
  }, M = (w, b) => {
3538
3547
  const E = w.cellByPath.get(b);
3539
- if (!E || !Ci(E)) return null;
3548
+ if (!E || !Ri(E)) return null;
3540
3549
  const v = `${w.diffBase}::${b}`;
3541
3550
  let N = G.get(v);
3542
3551
  if (!N) {
@@ -3546,10 +3555,10 @@ async function Oo(e, t = {}) {
3546
3555
  if (te.mode === "full")
3547
3556
  W = new Re({
3548
3557
  source: te.texture.source,
3549
- frame: new ia(E.x, E.y, E.w, E.h)
3558
+ frame: new aa(E.x, E.y, E.w, E.h)
3550
3559
  });
3551
3560
  else {
3552
- const tt = Lo(te.bitmap, E);
3561
+ const tt = Oo(te.bitmap, E);
3553
3562
  W = Re.from(tt), W.source.scaleMode = "nearest", Se = !0;
3554
3563
  }
3555
3564
  N = { texture: W, ownsSource: Se }, G.set(v, N);
@@ -3561,7 +3570,7 @@ async function Oo(e, t = {}) {
3561
3570
  const N = M(E, v);
3562
3571
  if (!N)
3563
3572
  return w.visible = !1, w.texture = Re.EMPTY, !1;
3564
- const Z = Pi(E.atlasMeta, N.cell);
3573
+ const Z = Ci(E.atlasMeta, N.cell);
3565
3574
  return b.setThreshold(O), w.texture = N.texture, w.x = Z.x, w.y = Z.y, w.width = N.cell.w, w.height = N.cell.h, w.visible = !0, !0;
3566
3575
  }, le = (w) => {
3567
3576
  if (!w || !B) return null;
@@ -3592,13 +3601,13 @@ async function Oo(e, t = {}) {
3592
3601
  const b = qt();
3593
3602
  if (b && !w)
3594
3603
  throw new Error("Encrypted assets enabled but no key provided");
3595
- const E = b ? await bs(
3604
+ const E = b ? await Ss(
3596
3605
  await Dt(cn(), w ?? "")
3597
- ) : await $i(cn());
3606
+ ) : await Hi(cn());
3598
3607
  T && T.destroy(!0), T = Re.from(E), T.source.scaleMode = "linear";
3599
- const v = si();
3608
+ const v = oi();
3600
3609
  B = await Hr(
3601
- oi(),
3610
+ ci(),
3602
3611
  v,
3603
3612
  b,
3604
3613
  r,
@@ -3606,7 +3615,7 @@ async function Oo(e, t = {}) {
3606
3615
  );
3607
3616
  try {
3608
3617
  I = await Hr(
3609
- ci(),
3618
+ li(),
3610
3619
  v,
3611
3620
  b,
3612
3621
  r,
@@ -3618,7 +3627,7 @@ async function Oo(e, t = {}) {
3618
3627
  Z
3619
3628
  ), I = null;
3620
3629
  }
3621
- const N = Mi(
3630
+ const N = Pi(
3622
3631
  B.atlasMeta,
3623
3632
  E.width,
3624
3633
  E.height
@@ -3636,7 +3645,7 @@ async function Oo(e, t = {}) {
3636
3645
  o || i || !T || (X(), K(w), j());
3637
3646
  },
3638
3647
  drawIdleVideo(w, b) {
3639
- o || i || document.hidden || b && !b() || w.readyState < HTMLMediaElement.HAVE_CURRENT_DATA || (he(), V(), g.visible = !1, !C || y !== w ? (_(), R = new ra({
3648
+ o || i || document.hidden || b && !b() || w.readyState < HTMLMediaElement.HAVE_CURRENT_DATA || (he(), V(), g.visible = !1, !C || y !== w ? (_(), R = new ia({
3640
3649
  resource: w,
3641
3650
  autoPlay: !1,
3642
3651
  updateFPS: 0
@@ -3684,7 +3693,7 @@ async function Oo(e, t = {}) {
3684
3693
  };
3685
3694
  }
3686
3695
  const Kr = -1, an = 1e5, qr = /* @__PURE__ */ new Map();
3687
- async function No(e) {
3696
+ async function Uo(e) {
3688
3697
  let t = qr.get(e);
3689
3698
  if (!t) {
3690
3699
  const n = await fetch(e);
@@ -3697,7 +3706,7 @@ async function No(e) {
3697
3706
  }
3698
3707
  return new Worker(t, { name: "visemeDiffPreview" });
3699
3708
  }
3700
- function Uo() {
3709
+ function Vo() {
3701
3710
  return typeof Worker < "u" && typeof OffscreenCanvas < "u";
3702
3711
  }
3703
3712
  function Ln(e, t) {
@@ -3719,14 +3728,14 @@ function Gr(e, t) {
3719
3728
  return r;
3720
3729
  },
3721
3730
  async renderSilOnly() {
3722
- n += 1, i.reset(), await io(e);
3731
+ n += 1, i.reset(), await ao(e);
3723
3732
  },
3724
3733
  drawLiveFrame(a, o, s, u) {
3725
3734
  i.enqueue(o, s, u);
3726
3735
  },
3727
3736
  async compositePrefetchFrame(a, o) {
3728
3737
  try {
3729
- return await ro(a);
3738
+ return await io(a);
3730
3739
  } catch {
3731
3740
  return null;
3732
3741
  }
@@ -3760,7 +3769,7 @@ function Gr(e, t) {
3760
3769
  }
3761
3770
  };
3762
3771
  }
3763
- function Vo(e, t, n) {
3772
+ function Wo(e, t, n) {
3764
3773
  let r = null, i = 1, a = 0, o = !1, s = !1, u = null;
3765
3774
  const d = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
3766
3775
  let c = an;
@@ -3800,7 +3809,7 @@ function Vo(e, t, n) {
3800
3809
  }), f({ ...R, requestId: B });
3801
3810
  });
3802
3811
  }, C = (async () => {
3803
- r = await No(n), r.onmessage = (R) => {
3812
+ r = await Uo(n), r.onmessage = (R) => {
3804
3813
  if (s) return;
3805
3814
  const y = R.data;
3806
3815
  if (y.type === "status") {
@@ -3872,7 +3881,7 @@ function Vo(e, t, n) {
3872
3881
  return await T({
3873
3882
  type: "loadAssets",
3874
3883
  keyHex: R,
3875
- urls: Da(pt())
3884
+ urls: Ba(pt())
3876
3885
  }) ?? { width: 842, height: 1264 };
3877
3886
  },
3878
3887
  getVisemeAtlasPaths() {
@@ -3962,8 +3971,8 @@ function Vo(e, t, n) {
3962
3971
  }
3963
3972
  };
3964
3973
  }
3965
- async function Wo(e, t) {
3966
- const n = await Oo(e, {
3974
+ async function zo(e, t) {
3975
+ const n = await No(e, {
3967
3976
  onWebGlContextLost: t.onWebGlContextLost,
3968
3977
  maxTextureSize: t.pixiMaxTextureSize
3969
3978
  });
@@ -4030,22 +4039,22 @@ async function Wo(e, t) {
4030
4039
  };
4031
4040
  }
4032
4041
  function jr(e, t) {
4033
- if (!Uo())
4042
+ if (!Vo())
4034
4043
  return Gr(e, t);
4035
- const n = ua(t.workerScriptUrl);
4044
+ const n = da(t.workerScriptUrl);
4036
4045
  try {
4037
- return Vo(e, t, n);
4046
+ return Wo(e, t, n);
4038
4047
  } catch {
4039
4048
  return Gr(e, t);
4040
4049
  }
4041
4050
  }
4042
- function zo(e, t = {}) {
4051
+ function $o(e, t = {}) {
4043
4052
  if (t.preferLegacyRenderer)
4044
4053
  return jr(e, t);
4045
4054
  let n = null, r = !1, i = null, a = !1;
4046
4055
  const o = () => n ? Promise.resolve(n) : (i || (i = (async () => {
4047
4056
  try {
4048
- const s = await Wo(e, t);
4057
+ const s = await zo(e, t);
4049
4058
  if (a)
4050
4059
  throw s.dispose(), new Error("Renderer disposed during Pixi init");
4051
4060
  return r = !0, n = s, s;
@@ -4111,7 +4120,7 @@ function zo(e, t = {}) {
4111
4120
  }
4112
4121
  };
4113
4122
  }
4114
- class $o extends Error {
4123
+ class Ho extends Error {
4115
4124
  constructor(t, n) {
4116
4125
  super(`${t} timed out after ${Math.round(n / 1e3)}s`), this.name = "LoadTimeoutError";
4117
4126
  }
@@ -4119,7 +4128,7 @@ class $o extends Error {
4119
4128
  function In(e, t, n) {
4120
4129
  return new Promise((r, i) => {
4121
4130
  const a = globalThis.setTimeout(() => {
4122
- i(new $o(n, t));
4131
+ i(new Ho(n, t));
4123
4132
  }, t);
4124
4133
  e.then(
4125
4134
  (o) => {
@@ -4131,16 +4140,16 @@ function In(e, t, n) {
4131
4140
  );
4132
4141
  });
4133
4142
  }
4134
- const Ho = {
4143
+ const Ko = {
4135
4144
  overflow: "hidden",
4136
4145
  position: "relative",
4137
4146
  display: "inline-block",
4138
4147
  lineHeight: 0
4139
- }, Ko = {
4148
+ }, qo = {
4140
4149
  display: "block",
4141
4150
  maxWidth: "100%",
4142
4151
  height: "auto"
4143
- }, qo = {
4152
+ }, Go = {
4144
4153
  position: "absolute",
4145
4154
  inset: 0,
4146
4155
  display: "flex",
@@ -4153,12 +4162,12 @@ const Ho = {
4153
4162
  textAlign: "center"
4154
4163
  };
4155
4164
  function An(e) {
4156
- return pa(e) ? xi : ri(e) ? zn : Ei;
4165
+ return ya(e) ? Ii : ri(e) ? zn : xi;
4157
4166
  }
4158
4167
  function nt(e, t) {
4159
4168
  return t?.isSpeaking() || t?.isWarmingUp() ? t : e.isSpeaking() || e.isWarmingUp() ? e : t?.isConnected() ? t : e;
4160
4169
  }
4161
- const Go = On(function({
4170
+ const jo = On(function({
4162
4171
  id: t,
4163
4172
  avatarId: n,
4164
4173
  faceId: r,
@@ -4184,7 +4193,7 @@ const Go = On(function({
4184
4193
  onFrameRenderStats: ie,
4185
4194
  lipsyncBufferedPlayback: de = !0,
4186
4195
  lipsyncPlaybackWarmupMs: x = 1500,
4187
- idleHandoffHoldMs: O = yo,
4196
+ idleHandoffHoldMs: O = vo,
4188
4197
  pixiMaxTextureSize: G,
4189
4198
  captions: se
4190
4199
  }, ae) {
@@ -4194,16 +4203,16 @@ const Go = On(function({
4194
4203
  he.current = x;
4195
4204
  const q = U(O);
4196
4205
  q.current = O;
4197
- const ee = U(0), H = U(rr()), X = U(Gs()), be = U(!1), oe = U(null), _ = U(null), M = U(0), $ = U(0), le = U(0), K = U(null), j = U(null), w = U(!1), b = U(!1), E = U(!1), v = U(!1), N = U("sil"), Z = U(0), te = U(!1), W = U(
4206
+ const ee = U(0), H = U(rr()), X = U(js()), be = U(!1), oe = U(null), _ = U(null), M = U(0), $ = U(0), le = U(0), K = U(null), j = U(null), w = U(!1), b = U(!1), E = U(!1), v = U(!1), N = U("sil"), Z = U(0), te = U(!1), W = U(
4198
4207
  null
4199
- ), Se = U(!1), [tt, Bt] = we("idle"), [yt, Ft] = we(null), [dt, pn] = we(!1), [h, P] = we(!1), [ne, ue] = we(!1), [Te, ve] = we(), [Ee, Ke] = we({ width: 842, height: 1264 }), [Ue, Gt] = we(null), [yn, Lt] = we(0), vt = U(!1), Fe = U(a ?? null), Ge = o?.trim() || gt, _t = U(null), Me = U(null), { ttsEngineId: Ie, voiceId: je } = Wt(() => {
4208
+ ), Se = U(!1), [tt, Bt] = we("idle"), [yt, Ft] = we(null), [dt, pn] = we(!1), [h, P] = we(!1), [ne, ue] = we(!1), [Te, ve] = we(), [Ee, Ke] = we({ width: 842, height: 1264 }), [Ue, Gt] = we(null), [yn, Lt] = we(0), vt = U(!1), Fe = U(a ?? null), Ge = o?.trim() || gt, _t = U(null), Ae = U(null), { ttsEngineId: Ie, voiceId: je } = Wt(() => {
4200
4209
  const p = ot(s, u), A = p.ttsEngineId ?? Et;
4201
4210
  return {
4202
4211
  ttsEngineId: A,
4203
4212
  voiceId: p.voiceId ?? An(A)
4204
4213
  };
4205
4214
  }, [s, u]), Ye = U(!1), rt = U({ width: 842, height: 1264 }), pe = U(null), Ve = U("sil"), Be = U(""), We = Wt(
4206
- () => so(se),
4215
+ () => oo(se),
4207
4216
  [se]
4208
4217
  ), ze = _e(() => {
4209
4218
  Be.current = "", Gt(null);
@@ -4219,7 +4228,7 @@ const Go = On(function({
4219
4228
  Be.current && ze();
4220
4229
  return;
4221
4230
  }
4222
- const D = ao(p.getWordQueue());
4231
+ const D = so(p.getWordQueue());
4223
4232
  if (!D) {
4224
4233
  Be.current && ze();
4225
4234
  return;
@@ -4227,7 +4236,7 @@ const Go = On(function({
4227
4236
  D !== Be.current && (Be.current = D, Gt(D));
4228
4237
  },
4229
4238
  [We.enabled, ze]
4230
- ), ft = U(void 0), Nt = U(/* @__PURE__ */ new Map()), sr = U(C), or = U(S), ye = U(f), cr = U(T), lr = U(k), ur = U(B), jt = U(I), dr = U(ie), bt = U(po());
4239
+ ), ft = U(void 0), Nt = U(/* @__PURE__ */ new Map()), sr = U(C), or = U(S), ye = U(f), cr = U(T), lr = U(k), ur = U(B), jt = U(I), dr = U(ie), bt = U(yo());
4231
4240
  sr.current = C, or.current = S, ye.current = f, cr.current = T, lr.current = k, ur.current = B, jt.current = I, dr.current = ie, Pe(() => {
4232
4241
  const p = bt.current;
4233
4242
  return Nr(p), () => Nr(null);
@@ -4237,7 +4246,7 @@ const Go = On(function({
4237
4246
  const A = ot(
4238
4247
  p?.ttsEngineId ?? s,
4239
4248
  p?.voiceId ?? u
4240
- ), L = A.ttsEngineId ?? Me.current?.ttsEngineId ?? Et, D = A.voiceId ?? Me.current?.voiceId ?? An(L);
4249
+ ), L = A.ttsEngineId ?? Ae.current?.ttsEngineId ?? Et, D = A.voiceId ?? Ae.current?.voiceId ?? An(L);
4241
4250
  return { ttsEngineId: L, voiceId: D };
4242
4251
  },
4243
4252
  [s, u]
@@ -4264,7 +4273,7 @@ const Go = On(function({
4264
4273
  const p = me.current;
4265
4274
  p && (p.disconnect(), me.current = null);
4266
4275
  }), [Ut, Ge]);
4267
- const hr = _e(() => (me.current || (me.current = ys(
4276
+ const hr = _e(() => (me.current || (me.current = vs(
4268
4277
  Ut,
4269
4278
  {
4270
4279
  speakingRate: l,
@@ -4379,14 +4388,14 @@ const Go = On(function({
4379
4388
  St();
4380
4389
  return;
4381
4390
  }
4382
- const xe = ko(
4391
+ const xe = To(
4383
4392
  nt(
4384
4393
  fe.current,
4385
4394
  me.current
4386
4395
  ).getVisemeQueue(),
4387
4396
  Z.current,
4388
4397
  N.current
4389
- ), $e = To(
4398
+ ), $e = Eo(
4390
4399
  xe,
4391
4400
  pe.current
4392
4401
  );
@@ -4402,7 +4411,7 @@ const Go = On(function({
4402
4411
  try {
4403
4412
  await L.renderViseme(D, "sil", {
4404
4413
  from: xe,
4405
- transitionDurationMs: Vi
4414
+ transitionDurationMs: Wi
4406
4415
  });
4407
4416
  } catch (Ce) {
4408
4417
  if (Ce?.name !== "AbortError")
@@ -4430,14 +4439,14 @@ const Go = On(function({
4430
4439
  b.current = !1;
4431
4440
  }), K.current = setTimeout(() => {
4432
4441
  K.current = null, p === $.current && vn({ fallbackOnly: !0 });
4433
- }, Eo());
4442
+ }, xo());
4434
4443
  }, [Le, vn]), wr = _e(async () => {
4435
4444
  const p = Math.floor(Date.now() / 1e3);
4436
4445
  if (_t.current && p < _t.current.expiresAt - 60)
4437
4446
  return _t.current.key;
4438
4447
  const A = Fe.current ?? await sn();
4439
4448
  Fe.current = A, fe.current.setDeveloperToken(A);
4440
- const L = await Ia(A, Ge);
4449
+ const L = await Aa(A, Ge);
4441
4450
  return _t.current = {
4442
4451
  key: L.value,
4443
4452
  expiresAt: L.expiresAt
@@ -4446,16 +4455,16 @@ const Go = On(function({
4446
4455
  Pe(() => {
4447
4456
  a && (Fe.current = a, fe.current.setDeveloperToken(a));
4448
4457
  }, [a]), Pe(() => {
4449
- fe.current.setTtsEngineId(Ie), me.current?.setTtsEngineId(Ie), Me.current && (Me.current.ttsEngineId = Ie);
4458
+ fe.current.setTtsEngineId(Ie), me.current?.setTtsEngineId(Ie), Ae.current && (Ae.current.ttsEngineId = Ie);
4450
4459
  }, [Ie]), Pe(() => {
4451
- Me.current && (Me.current.voiceId = je);
4460
+ Ae.current && (Ae.current.voiceId = je);
4452
4461
  }, [je]);
4453
4462
  const Qe = Wt(
4454
- () => Ca(n, r),
4463
+ () => Ra(n, r),
4455
4464
  [n, r]
4456
- ), qi = Wt(() => i ? JSON.stringify(i) : Qe ? `face:${Qe}` : `id:${t ?? ""}`, [i, Qe, t]), Gi = Wt(() => {
4465
+ ), Gi = Wt(() => i ? JSON.stringify(i) : Qe ? `face:${Qe}` : `id:${t ?? ""}`, [i, Qe, t]), ji = Wt(() => {
4457
4466
  const p = y?.trim();
4458
- return p || (vr(Qe) ?? vr(Te) ?? ba(i));
4467
+ return p || (vr(Qe) ?? vr(Te) ?? Sa(i));
4459
4468
  }, [y, Qe, Te, i]);
4460
4469
  return Pe(() => {
4461
4470
  if (!t && !i && !Qe) {
@@ -4463,7 +4472,7 @@ const Go = On(function({
4463
4472
  return;
4464
4473
  }
4465
4474
  let p = !1;
4466
- Ye.current = !1, pn(!1), P(!1), ue(!1), ve(Qe), Ft(null), Me.current = null, W.current = null, Se.current = !1;
4475
+ Ye.current = !1, pn(!1), P(!1), ue(!1), ve(Qe), Ft(null), Ae.current = null, W.current = null, Se.current = !1;
4467
4476
  const A = re.current;
4468
4477
  if (!A) return;
4469
4478
  let L = null;
@@ -4477,7 +4486,7 @@ const Go = On(function({
4477
4486
  else {
4478
4487
  ye.current?.("getAiTwin");
4479
4488
  const Y = await In(
4480
- va(t),
4489
+ _a(t),
4481
4490
  3e4,
4482
4491
  "getAiTwin"
4483
4492
  );
@@ -4486,11 +4495,11 @@ const Go = On(function({
4486
4495
  throw new Error("getAiTwin returned no faceId");
4487
4496
  ve(Y.faceId.trim());
4488
4497
  const ce = ot(s, u);
4489
- Q = ce.ttsEngineId ?? Y.ttsEngineId, ke = ce.voiceId ?? Y.voiceId ?? An(Q), xe = Y.knowledgeContextId?.trim() || void 0, D = _r(Y.faceId);
4498
+ Q = ce.ttsEngineId ?? Y.ttsEngineId, ke = ce.voiceId ?? Y.voiceId ?? An(Q), xe = ii(Y), D = _r(Y.faceId);
4490
4499
  }
4491
- Me.current = { ttsEngineId: Q, voiceId: ke, personaId: xe }, Ra(D), W.current = js();
4500
+ Ae.current = { ttsEngineId: Q, voiceId: ke, brainId: xe }, Da(D), W.current = Ys();
4492
4501
  const $e = !!(i && !wt(i));
4493
- L = zo(A, {
4502
+ L = $o(A, {
4494
4503
  preferLegacyRenderer: $e,
4495
4504
  pixiMaxTextureSize: G,
4496
4505
  onStatus: (Y) => {
@@ -4513,13 +4522,13 @@ const Go = On(function({
4513
4522
  p || Lt((Y) => Y + 1);
4514
4523
  }));
4515
4524
  }
4516
- }), F.current = L, J.current = Po(L), vt.current = !1;
4525
+ }), F.current = L, J.current = Co(L), vt.current = !1;
4517
4526
  const Ce = (Y) => {
4518
4527
  const ce = () => {
4519
4528
  if (!Y || he.current <= 0)
4520
4529
  return !1;
4521
- const Ae = F.current;
4522
- return Ae ? V.current && Ae.supportsBufferedPlayback ? !0 : Ae.usesPixi : !1;
4530
+ const Me = F.current;
4531
+ return Me ? V.current && Me.supportsBufferedPlayback ? !0 : Me.usesPixi : !1;
4523
4532
  };
4524
4533
  fe.current.setLipsyncWarmupHold(Y, ce), me.current?.setLipsyncWarmupHold(Y, ce);
4525
4534
  };
@@ -4540,7 +4549,7 @@ const Go = On(function({
4540
4549
  p || ye.current?.("sil");
4541
4550
  }), (async () => {
4542
4551
  try {
4543
- const Y = await Ts(Qt);
4552
+ const Y = await Es(Qt);
4544
4553
  if (await W.current.load(Y), p) return;
4545
4554
  Se.current = !0, P(!0), Ne(H.current), W.current.setActive(!0);
4546
4555
  const ce = W.current.getVideo();
@@ -4569,7 +4578,7 @@ const Go = On(function({
4569
4578
  })(), () => {
4570
4579
  p = !0, W.current?.dispose(), L?.dispose(), F.current = null;
4571
4580
  };
4572
- }, [qi, i, Qe, t, Ie, je, s, u, a, G, wr, it, yn]), Pe(() => {
4581
+ }, [Gi, i, Qe, t, Ie, je, s, u, a, G, wr, it, yn]), Pe(() => {
4573
4582
  const p = { current: !1 }, A = () => {
4574
4583
  const L = re.current, D = F.current, Q = nt(
4575
4584
  fe.current,
@@ -4593,7 +4602,7 @@ const Go = On(function({
4593
4602
  }
4594
4603
  const ge = Q.getVisemeQueue();
4595
4604
  ge.length > 0 && ee.current === 0 && (ee.current = performance.now()), X.current.advance(performance.now());
4596
- const Y = X.current.getExpressionPath(), ce = X.current.getDrawKey(), Ae = {
4605
+ const Y = X.current.getExpressionPath(), ce = X.current.getDrawKey(), Me = {
4597
4606
  queue: ge,
4598
4607
  elapsedMs: 0,
4599
4608
  expressionPath: Y,
@@ -4601,8 +4610,8 @@ const Go = On(function({
4601
4610
  availablePaths: pe.current
4602
4611
  };
4603
4612
  let He = !1;
4604
- Qt && J.current ? (J.current.warmupTick(Ae), He = J.current.isWarmupReady(
4605
- Ae,
4613
+ Qt && J.current ? (J.current.warmupTick(Me), He = J.current.isWarmupReady(
4614
+ Me,
4606
4615
  he.current
4607
4616
  )) : D.usesPixi && zr(
4608
4617
  L,
@@ -4621,7 +4630,7 @@ const Go = On(function({
4621
4630
  },
4622
4631
  pe.current
4623
4632
  );
4624
- const at = ee.current > 0 && performance.now() - ee.current > fa;
4633
+ const at = ee.current > 0 && performance.now() - ee.current > ma;
4625
4634
  ye.current?.(
4626
4635
  He ? "buffer ready" : "buffering lipsync…"
4627
4636
  ), (He || at) && (ee.current = 0, Q.releaseWarmupHold()), Ot(Q), te.current = Q.isSpeaking(), M.current = requestAnimationFrame(A);
@@ -4630,20 +4639,20 @@ const Go = On(function({
4630
4639
  if (ke) {
4631
4640
  Yt(), Se.current && W.current?.setActive(!1), D.usesPixi && D.isIdleToSilCrossfading() && D.finishIdleToSilCrossfade();
4632
4641
  const ge = Q.getVisemeQueue(), Y = Q.getPlaybackElapsedMs();
4633
- us(ge, Y), Z.current = Y;
4642
+ ds(ge, Y), Z.current = Y;
4634
4643
  const ce = ge.length > 0 ? hn(ge, Y) : "sil";
4635
4644
  ce !== "sil" && (N.current = ce);
4636
- const Ae = Js(
4645
+ const Me = Zs(
4637
4646
  Y,
4638
4647
  Q.getSentenceEmotions(),
4639
4648
  Q.getWordQueue(),
4640
4649
  Q.getStreamMood()
4641
4650
  );
4642
- X.current.setTargetEmotion(Ae), X.current.setTargetEyebrow(
4643
- Ks(
4651
+ X.current.setTargetEmotion(Me), X.current.setTargetEyebrow(
4652
+ qs(
4644
4653
  Y,
4645
4654
  Q.getWordQueue(),
4646
- Pt(Ae)
4655
+ Pt(Me)
4647
4656
  )
4648
4657
  ), X.current.advance(performance.now());
4649
4658
  const He = X.current.getExpressionPath(), at = X.current.getDrawKey(), Tt = (Je, bn, Vt, Sn) => {
@@ -4657,9 +4666,9 @@ const Go = On(function({
4657
4666
  Vt,
4658
4667
  He
4659
4668
  ), D.drawLiveFrame(Je, bn, Vt, (Zt) => {
4660
- const ji = Nt.current.get(Zt) ?? pr;
4669
+ const Yi = Nt.current.get(Zt) ?? pr;
4661
4670
  Nt.current.delete(Zt), bt.current.onDrawDisplayed(
4662
- ji,
4671
+ Yi,
4663
4672
  ge
4664
4673
  ), J.current?.markExternallyDisplayed(
4665
4674
  Zt,
@@ -4711,15 +4720,15 @@ const Go = On(function({
4711
4720
  ge,
4712
4721
  Y,
4713
4722
  H.current,
4714
- (ce, Ae, He, at) => D.drawLiveFrame(ce, Ae, He, at),
4723
+ (ce, Me, He, at) => D.drawLiveFrame(ce, Me, He, at),
4715
4724
  (ce) => {
4716
4725
  if (_.current) {
4717
4726
  ye.current?.(_.current);
4718
4727
  return;
4719
4728
  }
4720
- const Ae = X.current.getTargetEmotion();
4729
+ const Me = X.current.getTargetEmotion();
4721
4730
  ye.current?.(
4722
- ce === "sil" || ce === "blink" ? `${Ae}${ce === "blink" ? " · blink" : ""}` : ce
4731
+ ce === "sil" || ce === "blink" ? `${Me}${ce === "blink" ? " · blink" : ""}` : ce
4723
4732
  );
4724
4733
  },
4725
4734
  null,
@@ -4746,7 +4755,7 @@ const Go = On(function({
4746
4755
  null,
4747
4756
  "__sil__",
4748
4757
  H.current,
4749
- (ce, Ae, He, at) => D.drawLiveFrame(ce, Ae, He, at),
4758
+ (ce, Me, He, at) => D.drawLiveFrame(ce, Me, He, at),
4750
4759
  (ce) => ye.current?.(ce)
4751
4760
  );
4752
4761
  } else Xe || xn(
@@ -4754,7 +4763,7 @@ const Go = On(function({
4754
4763
  null,
4755
4764
  "__sil__",
4756
4765
  H.current,
4757
- (ge, Y, ce, Ae) => D.drawLiveFrame(ge, Y, ce, Ae),
4766
+ (ge, Y, ce, Me) => D.drawLiveFrame(ge, Y, ce, Me),
4758
4767
  (ge) => ye.current?.(ge)
4759
4768
  );
4760
4769
  We.enabled && Ot(Q), te.current = ke, M.current = requestAnimationFrame(A);
@@ -4798,7 +4807,7 @@ const Go = On(function({
4798
4807
  $.current += 1, Le(), Oe(), w.current = !1, b.current = !1, v.current = !1, F.current?.finishIdleToSilCrossfade(), fe.current.stop(), me.current?.stop(), Ne(H.current), J.current?.reset(), ee.current = 0, te.current = !1, ze(), kt();
4799
4808
  },
4800
4809
  setTtsEngineId: (p) => {
4801
- fe.current.setTtsEngineId(p), me.current?.setTtsEngineId(p), Me.current && (Me.current.ttsEngineId = p);
4810
+ fe.current.setTtsEngineId(p), me.current?.setTtsEngineId(p), Ae.current && (Ae.current.ttsEngineId = p);
4802
4811
  },
4803
4812
  renderViseme: async (p, A) => {
4804
4813
  const L = F.current, D = re.current;
@@ -4858,13 +4867,13 @@ const Go = On(function({
4858
4867
  const L = ot(
4859
4868
  p.ttsEngineId ?? s,
4860
4869
  p.voiceId ?? u
4861
- ), D = L.voiceId ?? Me.current?.voiceId, Q = p.personaId?.trim() ?? Me.current?.personaId, ke = L.ttsEngineId ?? Me.current?.ttsEngineId ?? Ie, xe = hr();
4870
+ ), D = L.voiceId ?? Ae.current?.voiceId, Q = p.brainId?.trim() || p.personaId?.trim() || Ae.current?.brainId, ke = L.ttsEngineId ?? Ae.current?.ttsEngineId ?? Ie, xe = hr();
4862
4871
  ke && xe.setTtsEngineId(ke), await xe.unlockAudio(), await xe.connect({
4863
4872
  ...p,
4864
4873
  apiBase: p.apiBase?.trim() || Ge,
4865
4874
  authToken: A,
4866
4875
  voiceId: D,
4867
- personaId: Q,
4876
+ brainId: Q,
4868
4877
  ttsEngineId: ke,
4869
4878
  speakingRate: p.speakingRate ?? l,
4870
4879
  language: p.language ?? d
@@ -4889,7 +4898,8 @@ const Go = On(function({
4889
4898
  const p = me.current, A = fe.current;
4890
4899
  return p?.isMuted?.() ?? A?.isMuted?.() ?? !1;
4891
4900
  },
4892
- getPersonaId: () => Me.current?.personaId?.trim() || null
4901
+ getBrainId: () => Ae.current?.brainId?.trim() || null,
4902
+ getPersonaId: () => Ae.current?.brainId?.trim() || null
4893
4903
  }),
4894
4904
  [
4895
4905
  dt,
@@ -4907,21 +4917,21 @@ const Go = On(function({
4907
4917
  tt,
4908
4918
  Ge
4909
4919
  ]
4910
- ), /* @__PURE__ */ De("div", { className: c, style: { ...Ho, ...m }, children: [
4920
+ ), /* @__PURE__ */ De("div", { className: c, style: { ...Ko, ...m }, children: [
4911
4921
  /* @__PURE__ */ z(
4912
4922
  "canvas",
4913
4923
  {
4914
4924
  ref: re,
4915
4925
  width: Ee.width,
4916
4926
  height: Ee.height,
4917
- style: { ...Ko, ...g },
4927
+ style: { ...qo, ...g },
4918
4928
  "aria-label": t ? `AI twin ${t}` : "AI twin face"
4919
4929
  }
4920
4930
  ),
4921
- !ne && !yt ? /* @__PURE__ */ z(go, { thumbnailUrl: Gi }) : null,
4922
- R && yt ? /* @__PURE__ */ z("div", { style: qo, children: yt }) : null,
4931
+ !ne && !yt ? /* @__PURE__ */ z(wo, { thumbnailUrl: ji }) : null,
4932
+ R && yt ? /* @__PURE__ */ z("div", { style: Go, children: yt }) : null,
4923
4933
  We.enabled && Ue ? /* @__PURE__ */ z(
4924
- uo,
4934
+ fo,
4925
4935
  {
4926
4936
  text: Ue,
4927
4937
  style: We.style
@@ -4930,7 +4940,7 @@ const Go = On(function({
4930
4940
  ) : null
4931
4941
  ] });
4932
4942
  });
4933
- async function jo(e) {
4943
+ async function Yo(e) {
4934
4944
  try {
4935
4945
  const t = await e.json();
4936
4946
  if (typeof t.detail == "string" && t.detail.trim())
@@ -4941,7 +4951,7 @@ async function jo(e) {
4941
4951
  }
4942
4952
  return `avatarReply failed (${e.status})`;
4943
4953
  }
4944
- async function Yo(e) {
4954
+ async function Qo(e) {
4945
4955
  const t = e.message.trim();
4946
4956
  if (!t)
4947
4957
  throw new Error("Message is required");
@@ -4961,11 +4971,12 @@ async function Yo(e) {
4961
4971
  body: JSON.stringify({
4962
4972
  message: t,
4963
4973
  history: e.history ?? [],
4964
- persona_id: e.personaId?.trim() || ""
4974
+ brainId: e.brainId?.trim() || e.personaId?.trim() || "",
4975
+ tenant: "aiTwin"
4965
4976
  })
4966
4977
  });
4967
4978
  if (!i.ok)
4968
- throw new Error(await jo(i));
4979
+ throw new Error(await Yo(i));
4969
4980
  if (!i.body)
4970
4981
  throw new Error("avatarReply response body is empty");
4971
4982
  const a = i.body.getReader(), o = new TextDecoder();
@@ -5006,7 +5017,7 @@ async function Yo(e) {
5006
5017
  spokenText: u.trim()
5007
5018
  };
5008
5019
  }
5009
- function Qo({ muted: e }) {
5020
+ function Xo({ muted: e }) {
5010
5021
  return e ? /* @__PURE__ */ De("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", "aria-hidden": !0, children: [
5011
5022
  /* @__PURE__ */ z(
5012
5023
  "path",
@@ -5037,13 +5048,13 @@ function Qo({ muted: e }) {
5037
5048
  )
5038
5049
  ] });
5039
5050
  }
5040
- function Xo() {
5051
+ function Jo() {
5041
5052
  return /* @__PURE__ */ z("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ z("path", { d: "M8 5.5v13l11-6.5L8 5.5Z" }) });
5042
5053
  }
5043
- function Jo() {
5054
+ function Zo() {
5044
5055
  return /* @__PURE__ */ z("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ z("rect", { x: "6", y: "6", width: "12", height: "12", rx: "1.5" }) });
5045
5056
  }
5046
- function Zo() {
5057
+ function ec() {
5047
5058
  return /* @__PURE__ */ z("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", "aria-hidden": !0, children: /* @__PURE__ */ z(
5048
5059
  "path",
5049
5060
  {
@@ -5054,7 +5065,7 @@ function Zo() {
5054
5065
  }
5055
5066
  ) });
5056
5067
  }
5057
- function Hi({ className: e }) {
5068
+ function Ki({ className: e }) {
5058
5069
  return /* @__PURE__ */ z("span", { className: e ?? "aitwin-widget__spinner", "aria-hidden": !0, children: /* @__PURE__ */ z("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ z(
5059
5070
  "circle",
5060
5071
  {
@@ -5068,7 +5079,7 @@ function Hi({ className: e }) {
5068
5079
  }
5069
5080
  ) }) });
5070
5081
  }
5071
- function ec({
5082
+ function tc({
5072
5083
  muted: e,
5073
5084
  onToggle: t
5074
5085
  }) {
@@ -5080,17 +5091,17 @@ function ec({
5080
5091
  onClick: t,
5081
5092
  "aria-label": e ? "Unmute" : "Mute",
5082
5093
  "aria-pressed": e,
5083
- children: /* @__PURE__ */ z(Qo, { muted: e })
5094
+ children: /* @__PURE__ */ z(Xo, { muted: e })
5084
5095
  }
5085
5096
  );
5086
5097
  }
5087
- function tc() {
5098
+ function nc() {
5088
5099
  return /* @__PURE__ */ De("div", { className: "aitwin-widget__connecting", role: "status", "aria-live": "polite", children: [
5089
- /* @__PURE__ */ z(Hi, { className: "aitwin-widget__spinner aitwin-widget__spinner--accent" }),
5100
+ /* @__PURE__ */ z(Ki, { className: "aitwin-widget__spinner aitwin-widget__spinner--accent" }),
5090
5101
  /* @__PURE__ */ z("span", { children: "Connecting..." })
5091
5102
  ] });
5092
5103
  }
5093
- function nc(e) {
5104
+ function rc(e) {
5094
5105
  const t = e.connecting || e.textSending || e.status === "loading" || e.status === "speaking", n = e.connecting ? "Connecting..." : e.connected ? "End Talk" : "Talk", r = [
5095
5106
  "aitwin-widget__action",
5096
5107
  e.textMode && !e.connecting ? "" : "aitwin-widget__action--primary",
@@ -5107,7 +5118,7 @@ function nc(e) {
5107
5118
  disabled: !e.ready || e.connecting || e.textSending,
5108
5119
  "aria-busy": e.connecting,
5109
5120
  children: [
5110
- e.connecting ? /* @__PURE__ */ z(Hi, { className: "aitwin-widget__spinner aitwin-widget__spinner--on-accent" }) : e.connected ? /* @__PURE__ */ z(Jo, {}) : /* @__PURE__ */ z(Xo, {}),
5121
+ e.connecting ? /* @__PURE__ */ z(Ki, { className: "aitwin-widget__spinner aitwin-widget__spinner--on-accent" }) : e.connected ? /* @__PURE__ */ z(Zo, {}) : /* @__PURE__ */ z(Jo, {}),
5111
5122
  /* @__PURE__ */ z("span", { children: n })
5112
5123
  ]
5113
5124
  }
@@ -5121,7 +5132,7 @@ function nc(e) {
5121
5132
  disabled: !e.ready || e.connecting || e.textSending,
5122
5133
  "aria-pressed": e.textMode,
5123
5134
  children: [
5124
- /* @__PURE__ */ z(Zo, {}),
5135
+ /* @__PURE__ */ z(ec, {}),
5125
5136
  /* @__PURE__ */ z("span", { children: "Text" })
5126
5137
  ]
5127
5138
  }
@@ -5163,15 +5174,15 @@ function nc(e) {
5163
5174
  e.error ? /* @__PURE__ */ z("p", { className: "aitwin-widget__controls-error", role: "alert", children: e.error }) : null
5164
5175
  ] });
5165
5176
  }
5166
- const Yr = 97, rc = 3500;
5167
- function ic(e, t) {
5168
- const n = Math.max(0, e), r = 1 - Math.exp(-n / rc);
5177
+ const Yr = 97, ic = 3500;
5178
+ function ac(e, t) {
5179
+ const n = Math.max(0, e), r = 1 - Math.exp(-n / ic);
5169
5180
  return Math.min(
5170
5181
  Yr,
5171
5182
  Math.round(r * Yr)
5172
5183
  );
5173
5184
  }
5174
- function ac(e) {
5185
+ function sc(e) {
5175
5186
  const [t, n] = we(null), [r, i] = we(() => Date.now());
5176
5187
  return Pe(() => {
5177
5188
  if (!e) {
@@ -5187,10 +5198,10 @@ function ac(e) {
5187
5198
  return o = window.requestAnimationFrame(s), () => {
5188
5199
  window.cancelAnimationFrame(o);
5189
5200
  };
5190
- }, [e]), e ? t == null ? 0 : ic(r - t) : 100;
5201
+ }, [e]), e ? t == null ? 0 : ac(r - t) : 100;
5191
5202
  }
5192
- const sc = "M259.01,593.87v-101.49c.33-6.31,4.94-11.26,10.21-11.88,6.42-.75,13.18,4.99,13.13,12.92-.42,45.09-.83,90.17-1.25,135.26.03,1.56.56,15.43,11.95,23.2,6.18,4.21,12.57,4.6,15.42,4.58-.42-112.77-.83-225.54-1.25-338.31-.08-2.55-1.03-46.36,21.17-55.34,2.05-.83,4.42-1.41,7.17-1.56v453.42c.07,12.06,1.98,37.84,19.03,62.73,7.01,10.23,14.79,17.71,21.4,22.99V222.42c-.01-3.72.48-11.67,5.35-19.87,7-11.77,18.13-15.82,21.4-16.95,10.42-3.61,19.49-2.06,23.48-1.11v684.96c.59,4.03,1.78,9.72,4.45,16.12,1.93,4.63,8.84,20.57,26.47,31.26,13.48,8.18,26.56,9.23,32.86,9.31-1.3-256.11-2.59-512.22-3.89-768.33.76-16.43,14.57-28.94,29.73-28.34,13.53.53,25.39,11.39,27.23,25.84-1.1,264.68-2.2,529.35-3.3,794.03,4.33.92,22.38,4.25,38.94-6.53,10.26-6.68,15.24-15.72,17.09-19.17,5.55-10.36,6.42-19.98,6.53-25.01-.72-246.99-1.43-493.97-2.15-740.96,2.27-.06,34.75-.44,48.29,22.68,3.41,5.83,4.87,11.86,5.34,17.19v674.68c5.92-2.16,39.19-14.94,50.16-47.79,3.12-9.34,3.68-18.03,3.33-25.01.03-193.22.06-386.43.09-579.65,4.12,1.18,28.28,8.48,36.17,30.08,1.64,4.49,2.32,8.88,2.43,12.92.02,146.42.05,292.84.07,439.25,3.82-1.71,19.51-9.22,25.56-26.47,2.15-6.12,2.48-11.73,2.29-15.89.01-114.91.03-229.81.04-344.72,2.36-.1,7.51.02,12.74,3.13,9.1,5.4,10.87,15.35,11.12,16.88.35,11.49.69,22.97,1.04,34.46.46,37.05.93,74.1,1.39,111.15v152.69c3.39-.72,9.77-2.67,14.31-8.34,3.62-4.52,4.51-9.46,5.56-15.28.91-5.04.95-9.31.83-12.23.02-38.81.03-77.62.05-116.43";
5193
- function oc({
5203
+ const oc = "M259.01,593.87v-101.49c.33-6.31,4.94-11.26,10.21-11.88,6.42-.75,13.18,4.99,13.13,12.92-.42,45.09-.83,90.17-1.25,135.26.03,1.56.56,15.43,11.95,23.2,6.18,4.21,12.57,4.6,15.42,4.58-.42-112.77-.83-225.54-1.25-338.31-.08-2.55-1.03-46.36,21.17-55.34,2.05-.83,4.42-1.41,7.17-1.56v453.42c.07,12.06,1.98,37.84,19.03,62.73,7.01,10.23,14.79,17.71,21.4,22.99V222.42c-.01-3.72.48-11.67,5.35-19.87,7-11.77,18.13-15.82,21.4-16.95,10.42-3.61,19.49-2.06,23.48-1.11v684.96c.59,4.03,1.78,9.72,4.45,16.12,1.93,4.63,8.84,20.57,26.47,31.26,13.48,8.18,26.56,9.23,32.86,9.31-1.3-256.11-2.59-512.22-3.89-768.33.76-16.43,14.57-28.94,29.73-28.34,13.53.53,25.39,11.39,27.23,25.84-1.1,264.68-2.2,529.35-3.3,794.03,4.33.92,22.38,4.25,38.94-6.53,10.26-6.68,15.24-15.72,17.09-19.17,5.55-10.36,6.42-19.98,6.53-25.01-.72-246.99-1.43-493.97-2.15-740.96,2.27-.06,34.75-.44,48.29,22.68,3.41,5.83,4.87,11.86,5.34,17.19v674.68c5.92-2.16,39.19-14.94,50.16-47.79,3.12-9.34,3.68-18.03,3.33-25.01.03-193.22.06-386.43.09-579.65,4.12,1.18,28.28,8.48,36.17,30.08,1.64,4.49,2.32,8.88,2.43,12.92.02,146.42.05,292.84.07,439.25,3.82-1.71,19.51-9.22,25.56-26.47,2.15-6.12,2.48-11.73,2.29-15.89.01-114.91.03-229.81.04-344.72,2.36-.1,7.51.02,12.74,3.13,9.1,5.4,10.87,15.35,11.12,16.88.35,11.49.69,22.97,1.04,34.46.46,37.05.93,74.1,1.39,111.15v152.69c3.39-.72,9.77-2.67,14.31-8.34,3.62-4.52,4.51-9.46,5.56-15.28.91-5.04.95-9.31.83-12.23.02-38.81.03-77.62.05-116.43";
5204
+ function cc({
5194
5205
  className: e = "aitwin-widget__logo",
5195
5206
  strokeWidth: t = 15,
5196
5207
  durationMs: n = 2600,
@@ -5208,7 +5219,7 @@ function oc({
5208
5219
  "path",
5209
5220
  {
5210
5221
  className: i ? "aitwin-widget__logo-draw aitwin-widget__logo-draw--loop" : "aitwin-widget__logo-draw",
5211
- d: sc,
5222
+ d: oc,
5212
5223
  fill: "none",
5213
5224
  stroke: "currentColor",
5214
5225
  strokeWidth: t,
@@ -5223,7 +5234,7 @@ function oc({
5223
5234
  }
5224
5235
  );
5225
5236
  }
5226
- function cc({
5237
+ function lc({
5227
5238
  progress: e
5228
5239
  }) {
5229
5240
  const t = Math.max(0, Math.min(100, Math.round(e)));
@@ -5235,7 +5246,7 @@ function cc({
5235
5246
  "aria-label": `Loading ${t} percent`,
5236
5247
  children: /* @__PURE__ */ De("div", { className: "aitwin-widget__face-loading-content", children: [
5237
5248
  /* @__PURE__ */ z(
5238
- oc,
5249
+ cc,
5239
5250
  {
5240
5251
  className: "aitwin-widget__logo",
5241
5252
  loop: !0,
@@ -5281,7 +5292,7 @@ function Qr(e) {
5281
5292
  language: e.language
5282
5293
  };
5283
5294
  }
5284
- function lc(e) {
5295
+ function uc(e) {
5285
5296
  return [
5286
5297
  e.id ?? "",
5287
5298
  e.faceId ?? "",
@@ -5298,13 +5309,13 @@ const Xr = {
5298
5309
  width: "100%",
5299
5310
  height: "100%",
5300
5311
  lineHeight: 0
5301
- }, uc = {
5312
+ }, dc = {
5302
5313
  display: "block",
5303
5314
  height: "100%",
5304
5315
  width: "100%",
5305
5316
  objectFit: "cover",
5306
5317
  objectPosition: "top"
5307
- }, dc = On(
5318
+ }, fc = On(
5308
5319
  function({ options: t }, n) {
5309
5320
  const r = U(null), i = U(t);
5310
5321
  i.current = {
@@ -5320,9 +5331,11 @@ const Xr = {
5320
5331
  ), [s, u] = we(
5321
5332
  () => Qr(t)
5322
5333
  ), [d, l] = we(!1), [c, m] = we(!1), [g, S] = we(!1), [f, T] = we(!1), [C, R] = we("idle"), [y, k] = we(null), [B, I] = we(!1), [ie, de] = we(!1), [x, O] = we(""), [G, se] = we(!1), [ae, re] = we([]), [F, J] = we(
5323
- t.personaId?.trim() || void 0
5334
+ t.brainId?.trim() || t.personaId?.trim() || void 0
5324
5335
  ), V = _e((v) => {
5325
- i.current = { ...i.current, ...v }, v.showControls !== void 0 && o(!!v.showControls), v.personaId !== void 0 && J(v.personaId.trim() || void 0), u(
5336
+ i.current = { ...i.current, ...v }, v.showControls !== void 0 && o(!!v.showControls), (v.brainId !== void 0 || v.personaId !== void 0) && J(
5337
+ (v.brainId ?? v.personaId)?.trim() || void 0
5338
+ ), u(
5326
5339
  (N) => Qr({
5327
5340
  id: v.id ?? N.id,
5328
5341
  faceId: v.faceId ?? v.avatarId ?? N.faceId,
@@ -5353,6 +5366,7 @@ const Xr = {
5353
5366
  t.voiceId,
5354
5367
  t.speakingRate,
5355
5368
  t.showControls,
5369
+ t.brainId,
5356
5370
  t.personaId
5357
5371
  ]);
5358
5372
  const he = _e(() => {
@@ -5375,7 +5389,7 @@ const Xr = {
5375
5389
  }, 400);
5376
5390
  return () => window.clearInterval(v);
5377
5391
  }, [a, s]);
5378
- const oe = lc(s), _ = !!(s.id || s.faceId), M = d && c, $ = _ && !M && !y, le = ac($), K = U(oe);
5392
+ const oe = uc(s), _ = !!(s.id || s.faceId), M = d && c, $ = _ && !M && !y, le = sc($), K = U(oe);
5379
5393
  Pe(() => {
5380
5394
  M && i.current.onReady?.();
5381
5395
  }, [M]), Pe(() => {
@@ -5416,11 +5430,11 @@ const Xr = {
5416
5430
  const v = x.trim(), N = r.current;
5417
5431
  !v || !N?.isReady() || G || (k(null), O(""), se(!0), i.current.onUserTranscript?.(v, !0), (async () => {
5418
5432
  try {
5419
- const Z = s.authToken?.trim() || await sn(), te = F || N.getPersonaId()?.trim() || void 0, W = await Yo({
5433
+ const Z = s.authToken?.trim() || await sn(), te = F || N.getBrainId()?.trim() || void 0, W = await Qo({
5420
5434
  message: v,
5421
5435
  authToken: Z,
5422
5436
  apiBase: s.apiBase || gt,
5423
- personaId: te,
5437
+ brainId: te,
5424
5438
  history: ae
5425
5439
  });
5426
5440
  re((Se) => [
@@ -5446,7 +5460,7 @@ const Xr = {
5446
5460
  return /* @__PURE__ */ De("div", { className: "aitwin-widget__layout", children: [
5447
5461
  /* @__PURE__ */ De("div", { className: "aitwin-widget__stage", children: [
5448
5462
  _ ? /* @__PURE__ */ z("div", { style: Xr, children: /* @__PURE__ */ z(
5449
- Go,
5463
+ jo,
5450
5464
  {
5451
5465
  ref: r,
5452
5466
  id: s.id,
@@ -5457,7 +5471,7 @@ const Xr = {
5457
5471
  speakingRate: s.speakingRate,
5458
5472
  language: s.language,
5459
5473
  style: Xr,
5460
- canvasStyle: uc,
5474
+ canvasStyle: dc,
5461
5475
  onReady: he,
5462
5476
  onDisplayStatus: q,
5463
5477
  onStatusChange: ee,
@@ -5469,16 +5483,16 @@ const Xr = {
5469
5483
  oe
5470
5484
  ) }) : /* @__PURE__ */ z("p", { className: "aitwin-widget__hint", style: { padding: 16 }, children: "Pass id or faceId to load a twin." }),
5471
5485
  $ ? /* @__PURE__ */ z(
5472
- cc,
5486
+ lc,
5473
5487
  {
5474
5488
  progress: le
5475
5489
  }
5476
5490
  ) : null,
5477
- a ? /* @__PURE__ */ z(ec, { muted: B, onToggle: E }) : null,
5478
- a && f ? /* @__PURE__ */ z(tc, {}) : null
5491
+ a ? /* @__PURE__ */ z(tc, { muted: B, onToggle: E }) : null,
5492
+ a && f ? /* @__PURE__ */ z(nc, {}) : null
5479
5493
  ] }),
5480
5494
  a ? /* @__PURE__ */ z(
5481
- nc,
5495
+ rc,
5482
5496
  {
5483
5497
  ready: M,
5484
5498
  connected: g,
@@ -5496,10 +5510,10 @@ const Xr = {
5496
5510
  ) : null
5497
5511
  ] });
5498
5512
  }
5499
- ), fc = ".aitwin-widget{--aitwin-border: rgba(255, 255, 255, .12);--aitwin-text: #f4f4f5;--aitwin-muted: #a1a1aa;--aitwin-accent: #f97316;--aitwin-accent-hover: #fb923c;--aitwin-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;--aitwin-size: 1;--aitwin-stage-width: calc(200px * var(--aitwin-size));--aitwin-stage-height: calc(267px * var(--aitwin-size));--aitwin-action-height: calc(40px * var(--aitwin-size));--aitwin-action-font: calc(13px * var(--aitwin-size));--aitwin-action-radius: calc(10px * var(--aitwin-size));--aitwin-action-gap: calc(6px * var(--aitwin-size));--aitwin-mute-size: calc(28px * var(--aitwin-size));--aitwin-layout-gap: calc(8px * var(--aitwin-size));box-sizing:border-box;color:var(--aitwin-text);font-family:var(--aitwin-font);font-size:calc(12px * var(--aitwin-size));line-height:1.45;width:fit-content;max-width:100%}.aitwin-widget *,.aitwin-widget *:before,.aitwin-widget *:after{box-sizing:border-box}.aitwin-widget__layout{display:flex;flex-direction:column;gap:var(--aitwin-layout-gap);width:fit-content;max-width:100%}.aitwin-widget__stage{align-items:center;background:#0a0a0b;border:1px solid var(--aitwin-border);border-radius:calc(10px * var(--aitwin-size));display:flex;flex-shrink:0;height:var(--aitwin-stage-height);justify-content:center;line-height:0;overflow:hidden;position:relative;width:var(--aitwin-stage-width)}.aitwin-widget__stage .aitwin-root,.aitwin-widget__stage canvas{display:block;height:100%;object-fit:cover;object-position:top;width:100%}.aitwin-widget__hint{color:var(--aitwin-muted);font-size:calc(11px * var(--aitwin-size));margin:0}.aitwin-widget__mute{align-items:center;background:#28282cb8;border:none;border-radius:999px;color:#fff;cursor:pointer;display:inline-flex;height:var(--aitwin-mute-size);justify-content:center;padding:0;position:absolute;right:calc(8px * var(--aitwin-size));top:calc(8px * var(--aitwin-size));width:var(--aitwin-mute-size);z-index:2}.aitwin-widget__mute:hover{background:#37373cd9}.aitwin-widget__mute svg{height:calc(15px * var(--aitwin-size));width:calc(15px * var(--aitwin-size))}.aitwin-widget__controls{display:flex;flex-direction:column;gap:var(--aitwin-action-gap);width:var(--aitwin-stage-width)}.aitwin-widget__actions{display:grid;gap:var(--aitwin-action-gap);grid-template-columns:1fr 1fr;width:100%}.aitwin-widget__action{align-items:center;background:transparent;border:1.5px solid var(--aitwin-accent);border-radius:999px;color:var(--aitwin-accent);cursor:pointer;display:inline-flex;font-family:inherit;font-size:var(--aitwin-action-font);font-weight:600;gap:calc(6px * var(--aitwin-size));height:var(--aitwin-action-height);justify-content:center;padding:0 calc(10px * var(--aitwin-size))}.aitwin-widget__action svg{flex-shrink:0;height:calc(12px * var(--aitwin-size));width:calc(12px * var(--aitwin-size))}.aitwin-widget__action:hover:not(:disabled){background:#f973161a}.aitwin-widget__action:disabled{cursor:not-allowed;opacity:.45}.aitwin-widget__action--primary{background:var(--aitwin-accent);border-color:transparent;color:#fff}.aitwin-widget__action--primary:hover:not(:disabled){background:var(--aitwin-accent-hover)}.aitwin-widget__action--connecting:disabled{cursor:progress;opacity:1}.aitwin-widget__spinner{display:inline-flex;flex-shrink:0;height:calc(14px * var(--aitwin-size));width:calc(14px * var(--aitwin-size))}.aitwin-widget__spinner svg{animation:aitwin-widget-spin .8s linear infinite;display:block;height:100%;width:100%}.aitwin-widget__spinner--accent{color:var(--aitwin-accent);height:calc(16px * var(--aitwin-size));width:calc(16px * var(--aitwin-size))}.aitwin-widget__spinner--on-accent{color:#fff}@keyframes aitwin-widget-spin{to{transform:rotate(360deg)}}.aitwin-widget__connecting{align-items:center;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);background:#ffffffe0;border-radius:999px;bottom:calc(14px * var(--aitwin-size));box-shadow:0 4px 16px #0000001f;color:#3f3f46;display:inline-flex;font-size:calc(12px * var(--aitwin-size));font-weight:600;gap:calc(8px * var(--aitwin-size));left:50%;line-height:1;padding:calc(8px * var(--aitwin-size)) calc(14px * var(--aitwin-size));pointer-events:none;position:absolute;transform:translate(-50%);z-index:3}.aitwin-widget__face-loading{background:transparent;inset:0;overflow:hidden;pointer-events:none;position:absolute;z-index:4}.aitwin-widget__face-loading-content{align-items:center;display:flex;flex-direction:column;gap:calc(12px * var(--aitwin-size));inset:0;justify-content:center;padding:calc(24px * var(--aitwin-size));position:absolute;z-index:1}.aitwin-widget__logo{color:#fff;display:block;flex-shrink:0;height:calc(64px * var(--aitwin-size));margin-bottom:calc(4px * var(--aitwin-size));width:calc(64px * var(--aitwin-size))}.aitwin-widget__logo-draw{stroke-dasharray:1;stroke-dashoffset:1;animation:aitwin-widget-logo-draw 2.6s ease-in-out forwards}.aitwin-widget__logo-draw--loop{animation:aitwin-widget-logo-draw-loop 2.6s ease-in-out infinite}@keyframes aitwin-widget-logo-draw{to{stroke-dashoffset:0}}@keyframes aitwin-widget-logo-draw-loop{0%{stroke-dashoffset:1}45%{stroke-dashoffset:0}55%{stroke-dashoffset:0}to{stroke-dashoffset:-1}}@media(prefers-reduced-motion:reduce){.aitwin-widget__logo-draw,.aitwin-widget__logo-draw--loop{animation:none;stroke-dashoffset:0}}.aitwin-widget__face-loading-bar-wrap{max-width:calc(220px * var(--aitwin-size));width:100%}.aitwin-widget__face-loading-track{background:#fff3;border-radius:999px;height:calc(4px * var(--aitwin-size));overflow:hidden;width:100%}.aitwin-widget__face-loading-fill{background:var(--aitwin-accent);border-radius:999px;height:100%;transition:width .3s ease-out}.aitwin-widget__face-loading-pct{color:#ffffffbf;font-size:calc(12px * var(--aitwin-size));margin:calc(8px * var(--aitwin-size)) 0 0;text-align:center}.aitwin-widget__composer{display:grid;gap:var(--aitwin-action-gap);grid-template-columns:1fr auto;width:100%}.aitwin-widget__composer-input{background:#ffffff0a;border:1px solid var(--aitwin-border);border-radius:var(--aitwin-action-radius);color:var(--aitwin-text);font-family:inherit;font-size:calc(12px * var(--aitwin-size));min-width:0;outline:none;padding:calc(8px * var(--aitwin-size)) calc(10px * var(--aitwin-size))}.aitwin-widget__composer-input:focus{border-color:#f973168c}.aitwin-widget__composer-send{background:var(--aitwin-accent);border:none;border-radius:var(--aitwin-action-radius);color:#fff;cursor:pointer;font-family:inherit;font-size:calc(12px * var(--aitwin-size));font-weight:600;padding:0 calc(12px * var(--aitwin-size))}.aitwin-widget__composer-send:disabled{cursor:not-allowed;opacity:.45}.aitwin-widget__controls-error{color:#fecaca;font-size:calc(11px * var(--aitwin-size));margin:0}.aitwin-widget--float{bottom:20px;filter:drop-shadow(0 12px 32px rgba(0,0,0,.45));height:fit-content;margin:0;max-width:calc(100vw - 40px);position:fixed;right:20px;width:fit-content;z-index:2147483000}", Jr = "data-aitwin-widget-style";
5500
- function Ki() {
5513
+ ), mc = ".aitwin-widget{--aitwin-border: rgba(255, 255, 255, .12);--aitwin-text: #f4f4f5;--aitwin-muted: #a1a1aa;--aitwin-accent: #f97316;--aitwin-accent-hover: #fb923c;--aitwin-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;--aitwin-size: 1;--aitwin-stage-width: calc(200px * var(--aitwin-size));--aitwin-stage-height: calc(267px * var(--aitwin-size));--aitwin-action-height: calc(40px * var(--aitwin-size));--aitwin-action-font: calc(13px * var(--aitwin-size));--aitwin-action-radius: calc(10px * var(--aitwin-size));--aitwin-action-gap: calc(6px * var(--aitwin-size));--aitwin-mute-size: calc(28px * var(--aitwin-size));--aitwin-layout-gap: calc(8px * var(--aitwin-size));box-sizing:border-box;color:var(--aitwin-text);font-family:var(--aitwin-font);font-size:calc(12px * var(--aitwin-size));line-height:1.45;width:fit-content;max-width:100%}.aitwin-widget *,.aitwin-widget *:before,.aitwin-widget *:after{box-sizing:border-box}.aitwin-widget__layout{display:flex;flex-direction:column;gap:var(--aitwin-layout-gap);width:fit-content;max-width:100%}.aitwin-widget__stage{align-items:center;background:#0a0a0b;border:1px solid var(--aitwin-border);border-radius:calc(10px * var(--aitwin-size));display:flex;flex-shrink:0;height:var(--aitwin-stage-height);justify-content:center;line-height:0;overflow:hidden;position:relative;width:var(--aitwin-stage-width)}.aitwin-widget__stage .aitwin-root,.aitwin-widget__stage canvas{display:block;height:100%;object-fit:cover;object-position:top;width:100%}.aitwin-widget__hint{color:var(--aitwin-muted);font-size:calc(11px * var(--aitwin-size));margin:0}.aitwin-widget__mute{align-items:center;background:#28282cb8;border:none;border-radius:999px;color:#fff;cursor:pointer;display:inline-flex;height:var(--aitwin-mute-size);justify-content:center;padding:0;position:absolute;right:calc(8px * var(--aitwin-size));top:calc(8px * var(--aitwin-size));width:var(--aitwin-mute-size);z-index:2}.aitwin-widget__mute:hover{background:#37373cd9}.aitwin-widget__mute svg{height:calc(15px * var(--aitwin-size));width:calc(15px * var(--aitwin-size))}.aitwin-widget__controls{display:flex;flex-direction:column;gap:var(--aitwin-action-gap);width:var(--aitwin-stage-width)}.aitwin-widget__actions{display:grid;gap:var(--aitwin-action-gap);grid-template-columns:1fr 1fr;width:100%}.aitwin-widget__action{align-items:center;background:transparent;border:1.5px solid var(--aitwin-accent);border-radius:999px;color:var(--aitwin-accent);cursor:pointer;display:inline-flex;font-family:inherit;font-size:var(--aitwin-action-font);font-weight:600;gap:calc(6px * var(--aitwin-size));height:var(--aitwin-action-height);justify-content:center;padding:0 calc(10px * var(--aitwin-size))}.aitwin-widget__action svg{flex-shrink:0;height:calc(12px * var(--aitwin-size));width:calc(12px * var(--aitwin-size))}.aitwin-widget__action:hover:not(:disabled){background:#f973161a}.aitwin-widget__action:disabled{cursor:not-allowed;opacity:.45}.aitwin-widget__action--primary{background:var(--aitwin-accent);border-color:transparent;color:#fff}.aitwin-widget__action--primary:hover:not(:disabled){background:var(--aitwin-accent-hover)}.aitwin-widget__action--connecting:disabled{cursor:progress;opacity:1}.aitwin-widget__spinner{display:inline-flex;flex-shrink:0;height:calc(14px * var(--aitwin-size));width:calc(14px * var(--aitwin-size))}.aitwin-widget__spinner svg{animation:aitwin-widget-spin .8s linear infinite;display:block;height:100%;width:100%}.aitwin-widget__spinner--accent{color:var(--aitwin-accent);height:calc(16px * var(--aitwin-size));width:calc(16px * var(--aitwin-size))}.aitwin-widget__spinner--on-accent{color:#fff}@keyframes aitwin-widget-spin{to{transform:rotate(360deg)}}.aitwin-widget__connecting{align-items:center;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);background:#ffffffe0;border-radius:999px;bottom:calc(14px * var(--aitwin-size));box-shadow:0 4px 16px #0000001f;color:#3f3f46;display:inline-flex;font-size:calc(12px * var(--aitwin-size));font-weight:600;gap:calc(8px * var(--aitwin-size));left:50%;line-height:1;padding:calc(8px * var(--aitwin-size)) calc(14px * var(--aitwin-size));pointer-events:none;position:absolute;transform:translate(-50%);z-index:3}.aitwin-widget__face-loading{background:transparent;inset:0;overflow:hidden;pointer-events:none;position:absolute;z-index:4}.aitwin-widget__face-loading-content{align-items:center;display:flex;flex-direction:column;gap:calc(12px * var(--aitwin-size));inset:0;justify-content:center;padding:calc(24px * var(--aitwin-size));position:absolute;z-index:1}.aitwin-widget__logo{color:#fff;display:block;flex-shrink:0;height:calc(64px * var(--aitwin-size));margin-bottom:calc(4px * var(--aitwin-size));width:calc(64px * var(--aitwin-size))}.aitwin-widget__logo-draw{stroke-dasharray:1;stroke-dashoffset:1;animation:aitwin-widget-logo-draw 2.6s ease-in-out forwards}.aitwin-widget__logo-draw--loop{animation:aitwin-widget-logo-draw-loop 2.6s ease-in-out infinite}@keyframes aitwin-widget-logo-draw{to{stroke-dashoffset:0}}@keyframes aitwin-widget-logo-draw-loop{0%{stroke-dashoffset:1}45%{stroke-dashoffset:0}55%{stroke-dashoffset:0}to{stroke-dashoffset:-1}}@media(prefers-reduced-motion:reduce){.aitwin-widget__logo-draw,.aitwin-widget__logo-draw--loop{animation:none;stroke-dashoffset:0}}.aitwin-widget__face-loading-bar-wrap{max-width:calc(220px * var(--aitwin-size));width:100%}.aitwin-widget__face-loading-track{background:#fff3;border-radius:999px;height:calc(4px * var(--aitwin-size));overflow:hidden;width:100%}.aitwin-widget__face-loading-fill{background:var(--aitwin-accent);border-radius:999px;height:100%;transition:width .3s ease-out}.aitwin-widget__face-loading-pct{color:#ffffffbf;font-size:calc(12px * var(--aitwin-size));margin:calc(8px * var(--aitwin-size)) 0 0;text-align:center}.aitwin-widget__composer{display:grid;gap:var(--aitwin-action-gap);grid-template-columns:1fr auto;width:100%}.aitwin-widget__composer-input{background:#ffffff0a;border:1px solid var(--aitwin-border);border-radius:var(--aitwin-action-radius);color:var(--aitwin-text);font-family:inherit;font-size:calc(12px * var(--aitwin-size));min-width:0;outline:none;padding:calc(8px * var(--aitwin-size)) calc(10px * var(--aitwin-size))}.aitwin-widget__composer-input:focus{border-color:#f973168c}.aitwin-widget__composer-send{background:var(--aitwin-accent);border:none;border-radius:var(--aitwin-action-radius);color:#fff;cursor:pointer;font-family:inherit;font-size:calc(12px * var(--aitwin-size));font-weight:600;padding:0 calc(12px * var(--aitwin-size))}.aitwin-widget__composer-send:disabled{cursor:not-allowed;opacity:.45}.aitwin-widget__controls-error{color:#fecaca;font-size:calc(11px * var(--aitwin-size));margin:0}.aitwin-widget--float{bottom:20px;filter:drop-shadow(0 12px 32px rgba(0,0,0,.45));height:fit-content;margin:0;max-width:calc(100vw - 40px);position:fixed;right:20px;width:fit-content;z-index:2147483000}", Jr = "data-aitwin-widget-style";
5514
+ function qi() {
5501
5515
  if (typeof document > "u") return;
5502
- const e = fc.trim();
5516
+ const e = mc.trim();
5503
5517
  if (!e) {
5504
5518
  console.warn(
5505
5519
  "[AiTwinWidget] styles.css?inline resolved empty — chrome will be unstyled"
@@ -5515,10 +5529,10 @@ function Ki() {
5515
5529
  const n = document.createElement("style");
5516
5530
  n.setAttribute(Jr, "1"), n.textContent = e, (document.head ?? document.documentElement).appendChild(n);
5517
5531
  }
5518
- typeof document < "u" && Ki();
5519
- const Ic = On(
5532
+ typeof document < "u" && qi();
5533
+ const Ac = On(
5520
5534
  function(t, n) {
5521
- Ki();
5535
+ qi();
5522
5536
  const r = U(null);
5523
5537
  Nn(
5524
5538
  n,
@@ -5552,34 +5566,34 @@ const Ic = On(
5552
5566
  "div",
5553
5567
  {
5554
5568
  className: i ? "aitwin-widget aitwin-widget--float" : "aitwin-widget",
5555
- children: /* @__PURE__ */ z(dc, { ref: r, options: t })
5569
+ children: /* @__PURE__ */ z(fc, { ref: r, options: t })
5556
5570
  }
5557
5571
  );
5558
5572
  }
5559
- ), mc = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".webp"]);
5560
- function hc(e = ".png") {
5573
+ ), hc = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".webp"]);
5574
+ function gc(e = ".png") {
5561
5575
  const t = e.toLowerCase();
5562
- return mc.has(t) ? `source${t}` : "source.png";
5576
+ return hc.has(t) ? `source${t}` : "source.png";
5563
5577
  }
5564
- function Ac(e, t = Un, n = ".png") {
5578
+ function Mc(e, t = Un, n = ".png") {
5565
5579
  const r = e.trim();
5566
5580
  if (!r)
5567
5581
  throw new Error("faceId is required");
5568
- return `${t.replace(/\/$/, "")}/${r}/${hc(n)}`;
5582
+ return `${t.replace(/\/$/, "")}/${r}/${gc(n)}`;
5569
5583
  }
5570
5584
  export {
5571
- ii as AI_TWIN_THUMBNAIL_FILENAME,
5572
- Go as AiTwin,
5585
+ ai as AI_TWIN_THUMBNAIL_FILENAME,
5586
+ jo as AiTwin,
5573
5587
  Pn as AiTwinNotFoundError,
5574
- Ic as AiTwinWidget,
5575
- Ya as CONSONANT_SKIP_GROUP,
5588
+ Ac as AiTwinWidget,
5589
+ Qa as CONSONANT_SKIP_GROUP,
5576
5590
  Et as DEFAULT_TTS_ENGINE_ID,
5577
- _c as DEFAULT_TTS_LANGUAGE,
5578
- Fs as EMOTION_TO_EYEBROW,
5579
- xc as EXPRESSION_ATLAS_EMOTIONS,
5580
- Ii as MIC_SAMPLE_RATE,
5581
- Va as OCULUS_VISEME_IDS,
5582
- Ai as PLAYBACK_SAMPLE_RATE,
5591
+ bc as DEFAULT_TTS_LANGUAGE,
5592
+ Ls as EMOTION_TO_EYEBROW,
5593
+ Ic as EXPRESSION_ATLAS_EMOTIONS,
5594
+ Ai as MIC_SAMPLE_RATE,
5595
+ Wa as OCULUS_VISEME_IDS,
5596
+ Mi as PLAYBACK_SAMPLE_RATE,
5583
5597
  Qn as SPEAKING_RATE_MAX,
5584
5598
  Yn as SPEAKING_RATE_MIN,
5585
5599
  lt as TTS_ENGINE_CARTESIA,
@@ -5587,45 +5601,46 @@ export {
5587
5601
  Wn as TTS_ENGINE_INWORLD,
5588
5602
  ut as TTS_ENGINE_VISEMETTS,
5589
5603
  xt as TTS_LANGUAGE_CATALOG,
5590
- Fa as TTS_LANGUAGE_CODES,
5591
- Ec as VISEME_IDS,
5604
+ La as TTS_LANGUAGE_CODES,
5605
+ xc as VISEME_IDS,
5592
5606
  br as VISEME_SKIP_GAP_MS,
5593
- xi as VISEME_TEST_CARTESIA_VOICE_ID,
5607
+ Ii as VISEME_TEST_CARTESIA_VOICE_ID,
5594
5608
  gn as VISEME_TEST_SPEAKING_RATE,
5595
5609
  zn as VISEME_TEST_VISEMETTS_VOICE_ID,
5596
- Ei as VISEME_TEST_VOICE_ID,
5597
- fi as VISEME_VTIME_GRID_MS,
5598
- ja as VOWEL_SKIP_GROUP,
5599
- hc as aiTwinSourceFilename,
5600
- as as buildPlaybackTransitions,
5610
+ xi as VISEME_TEST_VOICE_ID,
5611
+ mi as VISEME_VTIME_GRID_MS,
5612
+ Ya as VOWEL_SKIP_GROUP,
5613
+ gc as aiTwinSourceFilename,
5614
+ ss as buildPlaybackTransitions,
5601
5615
  qn as buildPlaybackVisemeSeries,
5602
- is as buildRawVisemeTransitions,
5603
- gs as buildVoiceWebSocketUrl,
5604
- gi as compactSkippableVisemes,
5616
+ as as buildRawVisemeTransitions,
5617
+ ws as buildVoiceWebSocketUrl,
5618
+ wi as compactSkippableVisemes,
5605
5619
  xr as createAvatarTtsLipsyncController,
5606
- ys as createRealtimeVoiceLipsyncController,
5620
+ vs as createRealtimeVoiceLipsyncController,
5607
5621
  Pt as emotionToEyebrow,
5608
5622
  _r as faceAssetUrls,
5609
- va as fetchAiTwin,
5610
- Yo as fetchAvatarReply,
5623
+ _a as fetchAiTwin,
5624
+ Qo as fetchAvatarReply,
5611
5625
  sn as fetchDevAuthToken,
5612
- Ac as getAiTwinSourceUrl,
5613
- _a as getAiTwinThumbnailUrl,
5614
- Ua as isTtsLanguageCode,
5615
- Sc as isTtsLanguageSupported,
5626
+ Mc as getAiTwinSourceUrl,
5627
+ ba as getAiTwinThumbnailUrl,
5628
+ Va as isTtsLanguageCode,
5629
+ kc as isTtsLanguageSupported,
5616
5630
  Gn as listSkippedVisemeEntries,
5617
- kc as listSkippedVisemes,
5631
+ Tc as listSkippedVisemes,
5618
5632
  Kn as normalizeOculusViseme,
5619
5633
  st as normalizeStreamEmotion,
5620
5634
  Hn as normalizeTtsLanguage,
5621
- wa as parsePackedVoiceId,
5622
- Ca as resolveDirectFaceId,
5635
+ pa as parsePackedVoiceId,
5636
+ Ra as resolveDirectFaceId,
5637
+ ii as resolveTwinBrainId,
5623
5638
  hn as resolveVisemeAtTime,
5624
- es as resolveVisemeFromPlaybackSeries,
5625
- Tc as resolveWordAtTime,
5626
- Ra as setActiveTwinAssets,
5627
- mi as snapVisemeQueueToGrid,
5628
- Za as snapVisemeVtimeToGrid,
5639
+ ts as resolveVisemeFromPlaybackSeries,
5640
+ Ec as resolveWordAtTime,
5641
+ Da as setActiveTwinAssets,
5642
+ hi as snapVisemeQueueToGrid,
5643
+ es as snapVisemeVtimeToGrid,
5629
5644
  ot as splitVoiceIdSpec,
5630
- bc as ttsLanguagesForEngine
5645
+ Sc as ttsLanguagesForEngine
5631
5646
  };