@spatialwalk/avatarkit 1.0.0-beta.21 → 1.0.0-beta.23

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.
@@ -39,13 +39,12 @@ function Na(r) {
39
39
  gsStandard: ((d = (c = (p = r.models) == null ? void 0 : p.gsStandard) == null ? void 0 : c.resource) == null ? void 0 : d.remote) || null
40
40
  };
41
41
  }
42
- var oe = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(oe || {}), ze = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(ze || {}), ce = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(ce || {}), ee = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(ee || {}), M = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(M || {});
42
+ var se = /* @__PURE__ */ ((r) => (r.cn = "cn", r.intl = "intl", r.test = "test", r))(se || {}), we = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(we || {}), de = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(de || {}), ee = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(ee || {}), re = /* @__PURE__ */ ((r) => (r.idle = "idle", r.playing = "playing", r))(re || {}), x = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(x || {});
43
43
  class H extends Error {
44
44
  constructor(e, t) {
45
45
  super(e), this.code = t, this.name = "SPAvatarError";
46
46
  }
47
47
  }
48
- var pe = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(pe || {});
49
48
  function ln() {
50
49
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
51
50
  }
@@ -84,7 +83,7 @@ const k = {
84
83
  }
85
84
  }
86
85
  };
87
- function Vt(r) {
86
+ function zt(r) {
88
87
  var e;
89
88
  return {
90
89
  translation: r.translation || [0, 0, 0],
@@ -114,7 +113,7 @@ var $t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
114
113
  function dn(r) {
115
114
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
116
115
  }
117
- var Gt = { exports: {} }, Re = { exports: {} }, ft;
116
+ var Gt = { exports: {} }, Te = { exports: {} }, ft;
118
117
  function un() {
119
118
  return ft || (ft = 1, function(r, e) {
120
119
  (function(t, n) {
@@ -134,8 +133,8 @@ function un() {
134
133
  var i = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"], s = ["fileName", "functionName", "source"], l = ["args"], p = ["evalOrigin"], c = i.concat(o, s, l, p);
135
134
  function d(A) {
136
135
  if (A)
137
- for (var S = 0; S < c.length; S++)
138
- A[c[S]] !== void 0 && this["set" + n(c[S])](A[c[S]]);
136
+ for (var b = 0; b < c.length; b++)
137
+ A[c[b]] !== void 0 && this["set" + n(c[b])](A[c[b]]);
139
138
  }
140
139
  d.prototype = {
141
140
  getArgs: function() {
@@ -158,44 +157,44 @@ function un() {
158
157
  throw new TypeError("Eval Origin must be an Object or StackFrame");
159
158
  },
160
159
  toString: function() {
161
- var A = this.getFileName() || "", S = this.getLineNumber() || "", P = this.getColumnNumber() || "", B = this.getFunctionName() || "";
162
- return this.getIsEval() ? A ? "[eval] (" + A + ":" + S + ":" + P + ")" : "[eval]:" + S + ":" + P : B ? B + " (" + A + ":" + S + ":" + P + ")" : A + ":" + S + ":" + P;
160
+ var A = this.getFileName() || "", b = this.getLineNumber() || "", E = this.getColumnNumber() || "", B = this.getFunctionName() || "";
161
+ return this.getIsEval() ? A ? "[eval] (" + A + ":" + b + ":" + E + ")" : "[eval]:" + b + ":" + E : B ? B + " (" + A + ":" + b + ":" + E + ")" : A + ":" + b + ":" + E;
163
162
  }
164
- }, d.fromString = function(S) {
165
- var P = S.indexOf("("), B = S.lastIndexOf(")"), _ = S.substring(0, P), Y = S.substring(P + 1, B).split(","), G = S.substring(B + 1);
163
+ }, d.fromString = function(b) {
164
+ var E = b.indexOf("("), B = b.lastIndexOf(")"), _ = b.substring(0, E), Y = b.substring(E + 1, B).split(","), G = b.substring(B + 1);
166
165
  if (G.indexOf("@") === 0)
167
- var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), z = R[1], W = R[2], Z = R[3];
166
+ var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), V = R[1], W = R[2], Z = R[3];
168
167
  return new d({
169
168
  functionName: _,
170
169
  args: Y || void 0,
171
- fileName: z,
170
+ fileName: V,
172
171
  lineNumber: W || void 0,
173
172
  columnNumber: Z || void 0
174
173
  });
175
174
  };
176
175
  for (var m = 0; m < i.length; m++)
177
176
  d.prototype["get" + n(i[m])] = a(i[m]), d.prototype["set" + n(i[m])] = /* @__PURE__ */ function(A) {
178
- return function(S) {
179
- this[A] = !!S;
177
+ return function(b) {
178
+ this[A] = !!b;
180
179
  };
181
180
  }(i[m]);
182
181
  for (var v = 0; v < o.length; v++)
183
182
  d.prototype["get" + n(o[v])] = a(o[v]), d.prototype["set" + n(o[v])] = /* @__PURE__ */ function(A) {
184
- return function(S) {
185
- if (!t(S))
183
+ return function(b) {
184
+ if (!t(b))
186
185
  throw new TypeError(A + " must be a Number");
187
- this[A] = Number(S);
186
+ this[A] = Number(b);
188
187
  };
189
188
  }(o[v]);
190
- for (var b = 0; b < s.length; b++)
191
- d.prototype["get" + n(s[b])] = a(s[b]), d.prototype["set" + n(s[b])] = /* @__PURE__ */ function(A) {
192
- return function(S) {
193
- this[A] = String(S);
189
+ for (var S = 0; S < s.length; S++)
190
+ d.prototype["get" + n(s[S])] = a(s[S]), d.prototype["set" + n(s[S])] = /* @__PURE__ */ function(A) {
191
+ return function(b) {
192
+ this[A] = String(b);
194
193
  };
195
- }(s[b]);
194
+ }(s[S]);
196
195
  return d;
197
196
  });
198
- }(Re)), Re.exports;
197
+ }(Te)), Te.exports;
199
198
  }
200
199
  (function(r, e) {
201
200
  (function(t, n) {
@@ -234,9 +233,9 @@ function un() {
234
233
  c.indexOf("(eval ") > -1 && (c = c.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
235
234
  var d = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = d.match(/ (\(.+\)$)/);
236
235
  d = m ? d.replace(m[0], "") : d;
237
- var v = this.extractLocation(m ? m[1] : d), b = m && d || void 0, A = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
236
+ var v = this.extractLocation(m ? m[1] : d), S = m && d || void 0, A = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
238
237
  return new n({
239
- functionName: b,
238
+ functionName: S,
240
239
  fileName: A,
241
240
  lineNumber: v[1],
242
241
  columnNumber: v[2],
@@ -254,12 +253,12 @@ function un() {
254
253
  return new n({
255
254
  functionName: c
256
255
  });
257
- var d = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(d), v = m && m[1] ? m[1] : void 0, b = this.extractLocation(c.replace(d, ""));
256
+ var d = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(d), v = m && m[1] ? m[1] : void 0, S = this.extractLocation(c.replace(d, ""));
258
257
  return new n({
259
258
  functionName: v,
260
- fileName: b[0],
261
- lineNumber: b[1],
262
- columnNumber: b[2],
259
+ fileName: S[0],
260
+ lineNumber: S[1],
261
+ columnNumber: S[2],
263
262
  source: c
264
263
  });
265
264
  }, this);
@@ -273,10 +272,10 @@ function un() {
273
272
  parseOpera9: function(l) {
274
273
  for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
275
274
  `), d = [], m = 2, v = c.length; m < v; m += 2) {
276
- var b = p.exec(c[m]);
277
- b && d.push(new n({
278
- fileName: b[2],
279
- lineNumber: b[1],
275
+ var S = p.exec(c[m]);
276
+ S && d.push(new n({
277
+ fileName: S[2],
278
+ lineNumber: S[1],
280
279
  source: c[m]
281
280
  }));
282
281
  }
@@ -285,12 +284,12 @@ function un() {
285
284
  parseOpera10: function(l) {
286
285
  for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = l.stacktrace.split(`
287
286
  `), d = [], m = 0, v = c.length; m < v; m += 2) {
288
- var b = p.exec(c[m]);
289
- b && d.push(
287
+ var S = p.exec(c[m]);
288
+ S && d.push(
290
289
  new n({
291
- functionName: b[3] || void 0,
292
- fileName: b[2],
293
- lineNumber: b[1],
290
+ functionName: S[3] || void 0,
291
+ fileName: S[2],
292
+ lineNumber: S[1],
294
293
  source: c[m]
295
294
  })
296
295
  );
@@ -304,12 +303,12 @@ function un() {
304
303
  return !!c.match(a) && !c.match(/^Error created at/);
305
304
  }, this);
306
305
  return p.map(function(c) {
307
- var d = c.split("@"), m = this.extractLocation(d.pop()), v = d.shift() || "", b = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, A;
306
+ var d = c.split("@"), m = this.extractLocation(d.pop()), v = d.shift() || "", S = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, A;
308
307
  v.match(/\(([^)]*)\)/) && (A = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
309
- var S = A === void 0 || A === "[arguments not available]" ? void 0 : A.split(",");
308
+ var b = A === void 0 || A === "[arguments not available]" ? void 0 : A.split(",");
310
309
  return new n({
311
- functionName: b,
312
- args: S,
310
+ functionName: S,
311
+ args: b,
313
312
  fileName: m[0],
314
313
  lineNumber: m[1],
315
314
  columnNumber: m[2],
@@ -327,17 +326,17 @@ let mt = () => {
327
326
  var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, i = (f, g) => {
328
327
  for (var w in g) e(f, w, { get: g[w], enumerable: !0 });
329
328
  }, o = (f, g, w, C) => {
330
- if (g && typeof g == "object" || typeof g == "function") for (let E of n(g)) !a.call(f, E) && E !== w && e(f, E, { get: () => g[E], enumerable: !(C = t(g, E)) || C.enumerable });
329
+ if (g && typeof g == "object" || typeof g == "function") for (let P of n(g)) !a.call(f, P) && P !== w && e(f, P, { get: () => g[P], enumerable: !(C = t(g, P)) || C.enumerable });
331
330
  return f;
332
331
  }, s = (f) => o(e({}, "__esModule", { value: !0 }), f), l = {};
333
332
  i(l, { default: () => tn });
334
- var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", d = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, b = (f) => f instanceof RegExp, A = (f) => typeof f == "string", S = (f) => f === void 0, P = (f) => {
333
+ var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", d = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, S = (f) => f instanceof RegExp, A = (f) => typeof f == "string", b = (f) => f === void 0, E = (f) => {
335
334
  const g = /* @__PURE__ */ new Map();
336
335
  return (w) => {
337
336
  const C = g.get(w);
338
337
  if (C) return C;
339
- const E = f(w);
340
- return g.set(w, E), E;
338
+ const P = f(w);
339
+ return g.set(w, P), P;
341
340
  };
342
341
  }, B = (f, g, w = {}) => {
343
342
  const C = { cache: {}, input: f, index: 0, indexMax: 0, options: w, output: [] };
@@ -347,89 +346,89 @@ let mt = () => {
347
346
  const w = {};
348
347
  for (const C of f) {
349
348
  if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
350
- const E = C.charCodeAt(0);
351
- w[E] = !0;
349
+ const P = C.charCodeAt(0);
350
+ w[P] = !0;
352
351
  }
353
352
  return (C) => {
354
- const E = C.index, I = C.input;
353
+ const P = C.index, I = C.input;
355
354
  for (; C.index < I.length && I.charCodeAt(C.index) in w; ) C.index += 1;
356
355
  const T = C.index;
357
- if (T > E) {
358
- if (!S(g) && !C.options.silent) {
359
- const $ = C.input.slice(E, T), q = c(g) ? g($, I, String(E)) : g;
360
- S(q) || C.output.push(q);
356
+ if (T > P) {
357
+ if (!b(g) && !C.options.silent) {
358
+ const $ = C.input.slice(P, T), q = c(g) ? g($, I, String(P)) : g;
359
+ b(q) || C.output.push(q);
361
360
  }
362
361
  C.indexMax = Math.max(C.indexMax, C.index);
363
362
  }
364
363
  return !0;
365
364
  };
366
365
  }, G = (f, g) => {
367
- const w = f.source, C = f.flags.replace(/y|$/, "y"), E = new RegExp(w, C);
368
- return Se((I) => {
369
- E.lastIndex = I.index;
370
- const T = E.exec(I.input);
366
+ const w = f.source, C = f.flags.replace(/y|$/, "y"), P = new RegExp(w, C);
367
+ return Ce((I) => {
368
+ P.lastIndex = I.index;
369
+ const T = P.exec(I.input);
371
370
  if (T) {
372
- if (!S(g) && !I.options.silent) {
371
+ if (!b(g) && !I.options.silent) {
373
372
  const $ = c(g) ? g(...T, I.input, String(I.index)) : g;
374
- S($) || I.output.push($);
373
+ b($) || I.output.push($);
375
374
  }
376
375
  return I.index += T[0].length, I.indexMax = Math.max(I.indexMax, I.index), !0;
377
376
  } else return !1;
378
377
  });
379
378
  }, R = (f, g) => (w) => {
380
379
  if (w.input.startsWith(f, w.index)) {
381
- if (!S(g) && !w.options.silent) {
380
+ if (!b(g) && !w.options.silent) {
382
381
  const C = c(g) ? g(f, w.input, String(w.index)) : g;
383
- S(C) || w.output.push(C);
382
+ b(C) || w.output.push(C);
384
383
  }
385
384
  return w.index += f.length, w.indexMax = Math.max(w.indexMax, w.index), !0;
386
385
  } else return !1;
387
- }, z = (f, g, w, C) => {
388
- const E = J(f);
389
- return Se(xe(Xe((I) => {
386
+ }, V = (f, g, w, C) => {
387
+ const P = J(f);
388
+ return Ce(Me(Xe((I) => {
390
389
  let T = 0;
391
390
  for (; T < w; ) {
392
391
  const $ = I.index;
393
- if (!E(I) || (T += 1, I.index === $)) break;
392
+ if (!P(I) || (T += 1, I.index === $)) break;
394
393
  }
395
394
  return T >= g;
396
395
  })));
397
- }, W = (f, g) => z(f, 0, 1), Z = (f, g) => z(f, 0, 1 / 0), V = (f, g) => {
396
+ }, W = (f, g) => V(f, 0, 1), Z = (f, g) => V(f, 0, 1 / 0), z = (f, g) => {
398
397
  const w = f.map(J);
399
- return Se(xe(Xe((C) => {
400
- for (let E = 0, I = w.length; E < I; E++) if (!w[E](C)) return !1;
398
+ return Ce(Me(Xe((C) => {
399
+ for (let P = 0, I = w.length; P < I; P++) if (!w[P](C)) return !1;
401
400
  return !0;
402
401
  })));
403
402
  }, K = (f, g) => {
404
403
  const w = f.map(J);
405
- return Se(xe((C) => {
406
- for (let E = 0, I = w.length; E < I; E++) if (w[E](C)) return !0;
404
+ return Ce(Me((C) => {
405
+ for (let P = 0, I = w.length; P < I; P++) if (w[P](C)) return !0;
407
406
  return !1;
408
407
  }));
409
408
  }, Xe = (f, g = !1) => {
410
409
  const w = J(f);
411
410
  return (C) => {
412
- const E = C.index, I = C.output.length, T = w(C);
413
- return (!T || g) && (C.index = E, C.output.length !== I && (C.output.length = I)), T;
411
+ const P = C.index, I = C.output.length, T = w(C);
412
+ return (!T || g) && (C.index = P, C.output.length !== I && (C.output.length = I)), T;
414
413
  };
415
- }, xe = (f, g) => J(f), Se = /* @__PURE__ */ (() => {
414
+ }, Me = (f, g) => J(f), Ce = /* @__PURE__ */ (() => {
416
415
  let f = 0;
417
416
  return (g) => {
418
417
  const w = J(g), C = f += 1;
419
- return (E) => {
418
+ return (P) => {
420
419
  var lt;
421
420
  var I;
422
- if (E.options.memoization === !1) return w(E);
423
- const T = E.index, $ = (I = E.cache)[C] || (I[C] = /* @__PURE__ */ new Map()), q = $.get(T);
421
+ if (P.options.memoization === !1) return w(P);
422
+ const T = P.index, $ = (I = P.cache)[C] || (I[C] = /* @__PURE__ */ new Map()), q = $.get(T);
424
423
  if (q === !1) return !1;
425
- if (m(q)) return E.index = q, !0;
426
- if (q) return E.index = q.index, (lt = q.output) != null && lt.length && E.output.push(...q.output), !0;
424
+ if (m(q)) return P.index = q, !0;
425
+ if (q) return P.index = q.index, (lt = q.output) != null && lt.length && P.output.push(...q.output), !0;
427
426
  {
428
- const ct = E.output.length;
429
- if (w(E)) {
430
- const dt = E.index, ut = E.output.length;
427
+ const ct = P.output.length;
428
+ if (w(P)) {
429
+ const dt = P.index, ut = P.output.length;
431
430
  if (ut > ct) {
432
- const rn = E.output.slice(ct, ut);
431
+ const rn = P.output.slice(ct, ut);
433
432
  $.set(T, { index: dt, output: rn });
434
433
  } else $.set(T, dt);
435
434
  return !0;
@@ -440,10 +439,10 @@ let mt = () => {
440
439
  })(), Ye = (f) => {
441
440
  let g;
442
441
  return (w) => (g || (g = J(f())), g(w));
443
- }, J = P((f) => {
442
+ }, J = E((f) => {
444
443
  if (c(f)) return d(f) ? Ye(f) : f;
445
- if (A(f) || b(f)) return _(f);
446
- if (p(f)) return V(f);
444
+ if (A(f) || S(f)) return _(f);
445
+ if (p(f)) return z(f);
447
446
  if (v(f)) return K(Object.values(f));
448
447
  throw new Error("Invalid rule");
449
448
  }), Ze = "abcdefghijklmnopqrstuvwxyz", or = (f) => {
@@ -465,29 +464,29 @@ let mt = () => {
465
464
  }, sr = (f, g, w) => Fe(f, g).map((C) => String(C).padStart(w, "0")), Qe = (f, g) => Fe(Je(f), Je(g)).map(or), X = (f) => f, et = (f) => lr((g) => B(g, f, { memoization: !1 }).join("")), lr = (f) => {
466
465
  const g = {};
467
466
  return (w) => g[w] ?? (g[w] = f(w));
468
- }, cr = _(/^\*\*\/\*$/, ".*"), dr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, w) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}`), ur = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, w, C) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Me = _(/\\./, X), hr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), fr = _(/./, X), mr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${st(g)}$).*?`), pr = _(/^(!!)+/, ""), gr = K([mr, pr]), vr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), yr = _(/^(\*\*\/)+/, "(?:^|.*/)"), wr = _(/\/(\*\*)$/, "(?:/.*|$)"), Ar = _(/\*\*/, ".*"), tt = K([vr, yr, wr, Ar]), br = _(/\*\/(?!\*\*\/)/, "[^/]*/"), Sr = _(/\*/, "[^/]*"), rt = K([br, Sr]), nt = _("?", "[^/]"), Cr = _("[", X), _r = _("]", X), Er = _(/[!^]/, "^/"), Pr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, X), Ir = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), kr = _(/[^\]]/, X), xr = K([Me, Ir, Pr, kr]), at = V([Cr, W(Er), Z(xr), _r]), Fr = _("{", "(?:"), Mr = _("}", ")"), Lr = _(/(\d+)\.\.(\d+)/, (f, g, w) => sr(+g, +w, Math.min(g.length, w.length)).join("|")), Rr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, w) => Qe(g, w).join("|")), Tr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, w) => Qe(g.toLowerCase(), w.toLowerCase()).join("|").toUpperCase()), Br = K([Lr, Rr, Tr]), it = V([Fr, Br, Mr]), Dr = _("{", "(?:"), Or = _("}", ")"), Nr = _(",", "|"), Ur = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), zr = _(/[^}]/, X), Vr = Ye(() => ot), $r = K([tt, rt, nt, at, it, Vr, Me, Ur, Nr, zr]), ot = V([Dr, Z($r), Or]), Gr = Z(K([cr, dr, ur, gr, tt, rt, nt, at, it, ot, Me, hr, fr])), Wr = Gr, qr = et(Wr), st = qr, Hr = _(/\\./, X), jr = _(/./, X), Kr = _(/\*\*\*+/, "*"), Xr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Yr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Zr = Z(K([Hr, Kr, Xr, Yr, jr])), Jr = Zr, Qr = et(Jr), en = Qr, Le = (f, g) => {
467
+ }, cr = _(/^\*\*\/\*$/, ".*"), dr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, w) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}`), ur = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, w, C) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Le = _(/\\./, X), hr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), fr = _(/./, X), mr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${st(g)}$).*?`), pr = _(/^(!!)+/, ""), gr = K([mr, pr]), vr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), yr = _(/^(\*\*\/)+/, "(?:^|.*/)"), wr = _(/\/(\*\*)$/, "(?:/.*|$)"), Ar = _(/\*\*/, ".*"), tt = K([vr, yr, wr, Ar]), Sr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), br = _(/\*/, "[^/]*"), rt = K([Sr, br]), nt = _("?", "[^/]"), Cr = _("[", X), _r = _("]", X), Pr = _(/[!^]/, "^/"), Er = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, X), Ir = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), kr = _(/[^\]]/, X), xr = K([Le, Ir, Er, kr]), at = z([Cr, W(Pr), Z(xr), _r]), Mr = _("{", "(?:"), Fr = _("}", ")"), Lr = _(/(\d+)\.\.(\d+)/, (f, g, w) => sr(+g, +w, Math.min(g.length, w.length)).join("|")), Rr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, w) => Qe(g, w).join("|")), Tr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, w) => Qe(g.toLowerCase(), w.toLowerCase()).join("|").toUpperCase()), Br = K([Lr, Rr, Tr]), it = z([Mr, Br, Fr]), Dr = _("{", "(?:"), Or = _("}", ")"), Nr = _(",", "|"), Ur = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Vr = _(/[^}]/, X), zr = Ye(() => ot), $r = K([tt, rt, nt, at, it, zr, Le, Ur, Nr, Vr]), ot = z([Dr, Z($r), Or]), Gr = Z(K([cr, dr, ur, gr, tt, rt, nt, at, it, ot, Le, hr, fr])), Wr = Gr, qr = et(Wr), st = qr, Hr = _(/\\./, X), jr = _(/./, X), Kr = _(/\*\*\*+/, "*"), Xr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Yr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Zr = Z(K([Hr, Kr, Xr, Yr, jr])), Jr = Zr, Qr = et(Jr), en = Qr, Re = (f, g) => {
469
468
  const w = Array.isArray(f) ? f : [f];
470
469
  if (!w.length) return !1;
471
- const C = w.map(Le.compile), E = w.every((T) => /(\/(?:\*\*)?|\[\/\])$/.test(T)), I = g.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
470
+ const C = w.map(Re.compile), P = w.every((T) => /(\/(?:\*\*)?|\[\/\])$/.test(T)), I = g.replace(/[\\\/]+/g, "/").replace(/\/$/, P ? "/" : "");
472
471
  return C.some((T) => T.test(I));
473
472
  };
474
- Le.compile = (f) => new RegExp(`^${st(en(f))}$`, "s");
475
- var tn = Le;
473
+ Re.compile = (f) => new RegExp(`^${st(en(f))}$`, "s");
474
+ var tn = Re;
476
475
  return s(l);
477
476
  })();
478
477
  return r.default || r;
479
- }, Te;
480
- const mn = (r, e) => (Te || (Te = mt(), mt = null), Te(r, e)), pn = /^[A-Za-z]:\//;
481
- function se(r = "") {
478
+ }, Be;
479
+ const mn = (r, e) => (Be || (Be = mt(), mt = null), Be(r, e)), pn = /^[A-Za-z]:\//;
480
+ function le(r = "") {
482
481
  return r && r.replace(/\\/g, "/").replace(pn, (e) => e.toUpperCase());
483
482
  }
484
483
  const gn = /^[/\\]{2}/, vn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/, pt = /^\/([A-Za-z]:)?$/, yn = /.(\.[^./]+|\.)$/, wn = /^[/\\]|^[a-zA-Z]:[/\\]/, An = "/", qe = function(r) {
485
484
  if (r.length === 0)
486
485
  return ".";
487
- r = se(r);
486
+ r = le(r);
488
487
  const e = r.match(gn), t = ge(r), n = r[r.length - 1] === "/";
489
488
  return r = He(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Wt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !ge(r) ? `/${r}` : r);
490
- }, bn = function(...r) {
489
+ }, Sn = function(...r) {
491
490
  let e = "";
492
491
  for (const t of r)
493
492
  if (t)
@@ -498,14 +497,14 @@ const gn = /^[/\\]{2}/, vn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
498
497
  e += t;
499
498
  return qe(e);
500
499
  };
501
- function Sn() {
500
+ function bn() {
502
501
  return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
503
502
  }
504
- const Pe = function(...r) {
505
- r = r.map((n) => se(n));
503
+ const Ie = function(...r) {
504
+ r = r.map((n) => le(n));
506
505
  let e = "", t = !1;
507
506
  for (let n = r.length - 1; n >= -1 && !t; n--) {
508
- const a = n >= 0 ? r[n] : Sn();
507
+ const a = n >= 0 ? r[n] : bn();
509
508
  !a || a.length === 0 || (e = `${a}/${e}`, t = ge(a));
510
509
  }
511
510
  return e = He(e, !t), t && !ge(e) ? `/${e}` : e.length > 0 ? e : ".";
@@ -543,13 +542,13 @@ function He(r, e) {
543
542
  const ge = function(r) {
544
543
  return vn.test(r);
545
544
  }, Cn = function(r) {
546
- return se(r);
545
+ return le(r);
547
546
  }, qt = function(r) {
548
547
  if (r === "..") return "";
549
- const e = yn.exec(se(r));
548
+ const e = yn.exec(le(r));
550
549
  return e && e[1] || "";
551
550
  }, _n = function(r, e) {
552
- const t = Pe(r).replace(pt, "$1").split("/"), n = Pe(e).replace(pt, "$1").split("/");
551
+ const t = Ie(r).replace(pt, "$1").split("/"), n = Ie(e).replace(pt, "$1").split("/");
553
552
  if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
554
553
  return n.join("/");
555
554
  const a = [...t];
@@ -560,17 +559,17 @@ const ge = function(r) {
560
559
  }
561
560
  return [...t.map(() => ".."), ...n].join("/");
562
561
  }, Ht = function(r) {
563
- const e = se(r).replace(/\/$/, "").split("/").slice(0, -1);
562
+ const e = le(r).replace(/\/$/, "").split("/").slice(0, -1);
564
563
  return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (ge(r) ? "/" : ".");
565
- }, En = function(r) {
564
+ }, Pn = function(r) {
566
565
  const e = r.ext ? r.ext.startsWith(".") ? r.ext : `.${r.ext}` : "", t = [r.root, r.dir, r.base ?? (r.name ?? "") + e].filter(
567
566
  Boolean
568
567
  );
569
- return se(
570
- r.root ? Pe(...t) : t.join("/")
568
+ return le(
569
+ r.root ? Ie(...t) : t.join("/")
571
570
  );
572
571
  }, jt = function(r, e) {
573
- const t = se(r).split("/");
572
+ const t = le(r).split("/");
574
573
  let n = "";
575
574
  for (let a = t.length - 1; a >= 0; a--) {
576
575
  const i = t[a];
@@ -580,7 +579,7 @@ const ge = function(r) {
580
579
  }
581
580
  }
582
581
  return e && n.endsWith(e) ? n.slice(0, -e.length) : n;
583
- }, Pn = function(r) {
582
+ }, En = function(r) {
584
583
  var a, i;
585
584
  const e = ((i = (a = wn.exec(r)) == null ? void 0 : a[0]) == null ? void 0 : i.replace(/\\/g, "/")) || "", t = jt(r), n = qt(t);
586
585
  return {
@@ -595,15 +594,15 @@ const ge = function(r) {
595
594
  basename: jt,
596
595
  dirname: Ht,
597
596
  extname: qt,
598
- format: En,
597
+ format: Pn,
599
598
  isAbsolute: ge,
600
- join: bn,
599
+ join: Sn,
601
600
  matchesGlob: In,
602
601
  normalize: qe,
603
602
  normalizeString: He,
604
- parse: Pn,
603
+ parse: En,
605
604
  relative: _n,
606
- resolve: Pe,
605
+ resolve: Ie,
607
606
  sep: An,
608
607
  toNamespacedPath: Cn
609
608
  }, kn = /* @__PURE__ */ (() => {
@@ -611,11 +610,11 @@ const ge = function(r) {
611
610
  return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
612
611
  })(), xn = { posix: void 0, win32: void 0 }, Kt = (r = kn) => new Proxy(gt, {
613
612
  get(e, t) {
614
- return t === "delimiter" ? r : t === "posix" ? Ve : t === "win32" ? Fn : xn[t] || gt[t];
613
+ return t === "delimiter" ? r : t === "posix" ? ze : t === "win32" ? Mn : xn[t] || gt[t];
615
614
  }
616
- }), Ve = /* @__PURE__ */ Kt(":"), Fn = /* @__PURE__ */ Kt(";");
617
- var F = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(F || {}), x = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(x || {}), re = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(re || {});
618
- const Mn = !0;
615
+ }), ze = /* @__PURE__ */ Kt(":"), Mn = /* @__PURE__ */ Kt(";");
616
+ var F = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(F || {}), M = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(M || {}), ne = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(ne || {});
617
+ const Fn = !0;
619
618
  function L(r, e, t = r) {
620
619
  return (n) => {
621
620
  const a = `${n}`, i = a.indexOf(e, r.length);
@@ -626,7 +625,7 @@ function Xt(r, e, t, n) {
626
625
  const a = r.substring(0, n) + t, i = r.substring(n + e.length), o = i.indexOf(e);
627
626
  return ~o ? a + Xt(i, e, t, o) : a + i;
628
627
  }
629
- function Ln(r = Mn) {
628
+ function Ln(r = Fn) {
630
629
  return {
631
630
  isColorSupported: r,
632
631
  reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
@@ -657,36 +656,36 @@ function Ln(r = Mn) {
657
656
  };
658
657
  }
659
658
  const D = Ln(), $e = {
660
- [x.Error]: F.Error,
661
- [x.Warning]: F.Warning,
662
- [x.Log]: F.Log,
663
- [x.Verbose]: F.Verbose,
664
- [x.Debug]: F.Debug
659
+ [M.Error]: F.Error,
660
+ [M.Warning]: F.Warning,
661
+ [M.Log]: F.Log,
662
+ [M.Verbose]: F.Verbose,
663
+ [M.Debug]: F.Debug
665
664
  }, Rn = {
666
- [F.Error]: x.Error,
667
- [F.Warning]: x.Warning,
668
- [F.Log]: x.Log,
669
- [F.Verbose]: x.Verbose,
670
- [F.Debug]: x.Debug
665
+ [F.Error]: M.Error,
666
+ [F.Warning]: M.Warning,
667
+ [F.Log]: M.Log,
668
+ [F.Verbose]: M.Verbose,
669
+ [F.Debug]: M.Debug
671
670
  }, vt = [
672
- x.Error,
673
- x.Warning,
674
- x.Log,
675
- x.Verbose,
676
- x.Debug
671
+ M.Error,
672
+ M.Warning,
673
+ M.Log,
674
+ M.Verbose,
675
+ M.Debug
677
676
  ], Tn = {
678
677
  [F.Error]: D.red,
679
678
  [F.Warning]: D.yellow,
680
679
  [F.Log]: D.blue,
681
680
  [F.Verbose]: D.cyan,
682
681
  [F.Debug]: D.green
683
- }, Ie = [
682
+ }, ke = [
684
683
  F.Error,
685
684
  F.Warning,
686
685
  F.Log,
687
686
  F.Verbose,
688
687
  F.Debug
689
- ], yt = [re.JSON, re.Pretty];
688
+ ], yt = [ne.JSON, ne.Pretty];
690
689
  function Bn(r) {
691
690
  return r.stack == null ? [] : r.stack.split(`
692
691
  `).map((e) => e.trim()).slice(1).filter((e) => !!/^at (.*)( \(.*:(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e)).map((e) => {
@@ -750,7 +749,7 @@ function wt(r) {
750
749
  }
751
750
  return e;
752
751
  }
753
- function Ce(r) {
752
+ function _e(r) {
754
753
  const e = [];
755
754
  e.push(r["@localetime"]), e.push(
756
755
  Tn[$e[r.level]](
@@ -788,53 +787,53 @@ function Nn(r) {
788
787
  function Un(r) {
789
788
  return r >= F.Log;
790
789
  }
791
- function zn(r) {
790
+ function Vn(r) {
792
791
  return r >= F.Warning;
793
792
  }
794
- function Vn(r) {
793
+ function zn(r) {
795
794
  return r >= F.Error;
796
795
  }
797
796
  function Jt() {
798
797
  return typeof window < "u";
799
798
  }
800
799
  function $n() {
801
- return !Jt() && Ge() === re.Pretty;
800
+ return !Jt() && Ge() === ne.Pretty;
802
801
  }
803
802
  function Gn(r, e) {
804
803
  return $n() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
805
804
  }
806
- const Ae = {
805
+ const Se = {
807
806
  configured: !1,
808
807
  logLevel: F.Debug,
809
- format: re.JSON,
808
+ format: ne.JSON,
810
809
  timeFormatter: (r) => r.toISOString()
811
810
  };
812
811
  function At() {
813
- return Ae.logLevel;
812
+ return Se.logLevel;
814
813
  }
815
814
  function Wn(r) {
816
- if (Ie.includes(r))
817
- Ae.logLevel = r;
815
+ if (ke.includes(r))
816
+ Se.logLevel = r;
818
817
  else
819
818
  throw new Error(
820
- `log level ${r} is not available. available log levels are: ${Ie.join(
819
+ `log level ${r} is not available. available log levels are: ${ke.join(
821
820
  ", "
822
821
  )}`
823
822
  );
824
- Ae.configured = !0;
823
+ Se.configured = !0;
825
824
  }
826
825
  function Ge() {
827
- return Ae.format;
826
+ return Se.format;
828
827
  }
829
828
  function qn() {
830
- return Ae.timeFormatter;
829
+ return Se.timeFormatter;
831
830
  }
832
831
  function Qt(r) {
833
832
  const e = {
834
833
  fields: {},
835
834
  context: r,
836
835
  logLevel: F.Debug,
837
- format: re.JSON,
836
+ format: ne.JSON,
838
837
  shouldUseGlobalConfig: !1,
839
838
  errorProcessor: (c) => c,
840
839
  timeFormatter: (c) => c.toISOString(),
@@ -849,13 +848,13 @@ function Qt(r) {
849
848
  },
850
849
  withLogLevel: (c) => {
851
850
  const d = e.child();
852
- if (Ie.includes(c))
851
+ if (ke.includes(c))
853
852
  d.logLevel = c, d.shouldUseGlobalConfig = !1, d.debug(
854
853
  `setting log level to ${Rn[c]} (${c})`
855
854
  );
856
855
  else
857
856
  throw new Error(
858
- `log level ${c} is not available. available log levels are: ${Ie.join(
857
+ `log level ${c} is not available. available log levels are: ${ke.join(
859
858
  ", "
860
859
  )}`
861
860
  );
@@ -939,73 +938,73 @@ function Qt(r) {
939
938
  }
940
939
  }, t = () => e.shouldUseGlobalConfig ? At() : e.logLevel, n = () => e.shouldUseGlobalConfig ? Ge() : e.format, a = () => e.shouldUseGlobalConfig ? qn() : e.timeFormatter ?? ((c) => c.toISOString()), i = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields, o = (c, d, m) => {
941
940
  const v = n();
942
- if (Jt() && v === re.Pretty) {
941
+ if (Jt() && v === ne.Pretty) {
943
942
  c.fields = Object.fromEntries(
944
- Object.entries(c.fields).filter(([S, P]) => {
945
- if (S === "isNestSystemModule" || S === "nestSystemModule" || S === "context")
946
- return [S, P];
943
+ Object.entries(c.fields).filter(([b, E]) => {
944
+ if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
945
+ return [b, E];
947
946
  })
948
947
  );
949
948
  const A = m ?? e.fields;
950
- Array.isArray(A) && A.length > 0 ? console[d](Ce(c), ...A) : Object.keys(A).length > 0 ? console[d](Ce(c), A) : console[d](Ce(c));
949
+ Array.isArray(A) && A.length > 0 ? console[d](_e(c), ...A) : Object.keys(A).length > 0 ? console[d](_e(c), A) : console[d](_e(c));
951
950
  return;
952
951
  }
953
- const b = v === re.Pretty ? Ce(c) : JSON.stringify(c);
954
- console[d](b);
952
+ const S = v === ne.Pretty ? _e(c) : JSON.stringify(c);
953
+ console[d](S);
955
954
  }, s = {
956
- [x.Debug]: On,
957
- [x.Verbose]: Nn,
958
- [x.Log]: Un,
959
- [x.Warning]: zn
955
+ [M.Debug]: On,
956
+ [M.Verbose]: Nn,
957
+ [M.Log]: Un,
958
+ [M.Warning]: Vn
960
959
  }, l = {
961
- [x.Debug]: "debug",
962
- [x.Verbose]: "log",
963
- [x.Log]: "log",
964
- [x.Warning]: "warn"
960
+ [M.Debug]: "debug",
961
+ [M.Verbose]: "log",
962
+ [M.Log]: "log",
963
+ [M.Warning]: "warn"
965
964
  }, p = (c, d, m) => {
966
- const v = t(), b = s[c];
967
- if (!b(v))
965
+ const v = t(), S = s[c];
966
+ if (!S(v))
968
967
  return;
969
- const A = i(m), S = Zt(
968
+ const A = i(m), b = Zt(
970
969
  c,
971
970
  e.context,
972
971
  A,
973
972
  d,
974
973
  a()
975
974
  );
976
- o(S, l[c], A);
975
+ o(b, l[c], A);
977
976
  };
978
977
  return e.debug = (c, ...d) => {
979
- p(x.Debug, c, d);
978
+ p(M.Debug, c, d);
980
979
  }, e.verbose = (c, ...d) => {
981
- p(x.Verbose, c, d);
980
+ p(M.Verbose, c, d);
982
981
  }, e.log = (c, ...d) => {
983
- p(x.Log, c, d);
982
+ p(M.Log, c, d);
984
983
  }, e.warn = (c, ...d) => {
985
- p(x.Warning, c, d);
984
+ p(M.Warning, c, d);
986
985
  }, e.error = (c, d, ...m) => {
987
986
  const v = t();
988
- if (!Vn(v))
987
+ if (!zn(v))
989
988
  return;
990
- const b = i(m), A = Dn(
991
- x.Error,
989
+ const S = i(m), A = Dn(
990
+ M.Error,
992
991
  e.context,
993
- b,
992
+ S,
994
993
  c,
995
994
  d,
996
995
  a()
997
996
  );
998
- o(A, "error", b);
997
+ o(A, "error", S);
999
998
  }, e.errorWithError = (c, d, ...m) => e.withError(d).error(c, void 0, ...m), e;
1000
999
  }
1001
1000
  function Hn(r) {
1002
1001
  var i;
1003
- const t = fn.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a = Ve.join(...n.split(Ve.sep).slice(-2));
1002
+ const t = fn.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a = ze.join(...n.split(ze.sep).slice(-2));
1004
1003
  return r = r ?? `${a}:${t.lineNumber}`, Qt(Gn(n, r));
1005
1004
  }
1006
1005
  const jn = (r) => Hn(r).useGlobalConfig();
1007
1006
  let Q = [];
1008
- const bt = 100;
1007
+ const St = 100;
1009
1008
  async function Kn() {
1010
1009
  if (Q.length === 0)
1011
1010
  return;
@@ -1014,7 +1013,7 @@ async function Kn() {
1014
1013
  try {
1015
1014
  await Xn();
1016
1015
  } catch (e) {
1017
- h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length > bt && (Q = Q.slice(0, bt));
1016
+ h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length > St && (Q = Q.slice(0, St));
1018
1017
  }
1019
1018
  }
1020
1019
  async function Xn(r) {
@@ -1044,7 +1043,7 @@ async function Zn(r) {
1044
1043
  if (!a.endpoints)
1045
1044
  throw new Error("Invalid config response: missing endpoints");
1046
1045
  const i = {};
1047
- a.endpoints.cn && (i[oe.cn] = `https://${a.endpoints.cn}`), a.endpoints.us && (i[oe.us] = `https://${a.endpoints.us}`), a.endpoints.test && (i[oe.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
1046
+ a.endpoints.cn && (i[se.cn] = `https://${a.endpoints.cn}`), a.endpoints.intl && (i[se.intl] = `https://${a.endpoints.intl}`), a.endpoints.test && (i[se.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
1048
1047
  } catch {
1049
1048
  O.config = {};
1050
1049
  } finally {
@@ -1157,36 +1156,36 @@ class Qn {
1157
1156
  throw new Error("Failed to allocate AvatarFlameParams structure");
1158
1157
  let a = 0;
1159
1158
  for (let v = 0; v < 300; v++) {
1160
- const b = ((i = e.shape_params) == null ? void 0 : i[v]) || 0;
1161
- this.module.setValue(n + a, b, "float"), a += 4;
1159
+ const S = ((i = e.shape_params) == null ? void 0 : i[v]) || 0;
1160
+ this.module.setValue(n + a, S, "float"), a += 4;
1162
1161
  }
1163
1162
  for (let v = 0; v < 100; v++) {
1164
- const b = ((o = e.expr_params) == null ? void 0 : o[v]) || 0;
1165
- this.module.setValue(n + a, b, "float"), a += 4;
1163
+ const S = ((o = e.expr_params) == null ? void 0 : o[v]) || 0;
1164
+ this.module.setValue(n + a, S, "float"), a += 4;
1166
1165
  }
1167
1166
  for (let v = 0; v < 3; v++) {
1168
- const b = ((s = e.rotation) == null ? void 0 : s[v]) || 0;
1169
- this.module.setValue(n + a, b, "float"), a += 4;
1167
+ const S = ((s = e.rotation) == null ? void 0 : s[v]) || 0;
1168
+ this.module.setValue(n + a, S, "float"), a += 4;
1170
1169
  }
1171
1170
  for (let v = 0; v < 3; v++) {
1172
- const b = ((l = e.translation) == null ? void 0 : l[v]) || 0;
1173
- this.module.setValue(n + a, b, "float"), a += 4;
1171
+ const S = ((l = e.translation) == null ? void 0 : l[v]) || 0;
1172
+ this.module.setValue(n + a, S, "float"), a += 4;
1174
1173
  }
1175
1174
  for (let v = 0; v < 3; v++) {
1176
- const b = ((p = e.neck_pose) == null ? void 0 : p[v]) || 0;
1177
- this.module.setValue(n + a, b, "float"), a += 4;
1175
+ const S = ((p = e.neck_pose) == null ? void 0 : p[v]) || 0;
1176
+ this.module.setValue(n + a, S, "float"), a += 4;
1178
1177
  }
1179
1178
  for (let v = 0; v < 3; v++) {
1180
- const b = ((c = e.jaw_pose) == null ? void 0 : c[v]) || 0;
1181
- this.module.setValue(n + a, b, "float"), a += 4;
1179
+ const S = ((c = e.jaw_pose) == null ? void 0 : c[v]) || 0;
1180
+ this.module.setValue(n + a, S, "float"), a += 4;
1182
1181
  }
1183
1182
  for (let v = 0; v < 6; v++) {
1184
- const b = ((d = e.eyes_pose) == null ? void 0 : d[v]) || 0;
1185
- this.module.setValue(n + a, b, "float"), a += 4;
1183
+ const S = ((d = e.eyes_pose) == null ? void 0 : d[v]) || 0;
1184
+ this.module.setValue(n + a, S, "float"), a += 4;
1186
1185
  }
1187
1186
  for (let v = 0; v < 2; v++) {
1188
- const b = ((m = e.eyelid) == null ? void 0 : m[v]) || 0;
1189
- this.module.setValue(n + a, b, "float"), a += 4;
1187
+ const S = ((m = e.eyelid) == null ? void 0 : m[v]) || 0;
1188
+ this.module.setValue(n + a, S, "float"), a += 4;
1190
1189
  }
1191
1190
  return this.module.setValue(n + a, e.has_eyelid ? 1 : 0, "i32"), a += 4, n;
1192
1191
  }
@@ -1933,7 +1932,7 @@ class y {
1933
1932
  throw new Error("AvatarCore not available");
1934
1933
  h.log("[AvatarKit] Loading template resources...");
1935
1934
  try {
1936
- const { AvatarDownloader: e } = await Promise.resolve().then(() => Pa), n = await new e().loadGlobalFlameResources();
1935
+ const { AvatarDownloader: e } = await Promise.resolve().then(() => Ea), n = await new e().loadGlobalFlameResources();
1937
1936
  await this._avatarCore.loadTemplateResourcesFromBuffers(n) ? h.log("[AvatarKit] Template resources initialized successfully") : h.log("[AvatarKit] Template resources already initialized, skipping...");
1938
1937
  } catch (e) {
1939
1938
  const t = e instanceof Error ? e.message : String(e);
@@ -1977,6 +1976,14 @@ class y {
1977
1976
  static get version() {
1978
1977
  return this._version;
1979
1978
  }
1979
+ /**
1980
+ * 获取播放模式(根据 drivingServiceMode)
1981
+ * @internal
1982
+ */
1983
+ static getPlaybackMode() {
1984
+ var e;
1985
+ return ((e = this._configuration) == null ? void 0 : e.drivingServiceMode) ?? we.sdk;
1986
+ }
1980
1987
  /**
1981
1988
  * 获取AvatarCore实例(仅供 SDK 内部使用)
1982
1989
  * @internal
@@ -2017,15 +2024,15 @@ class y {
2017
2024
  if (!this._configuration)
2018
2025
  throw new Error("AvatarKit not initialized");
2019
2026
  const t = {
2020
- [oe.cn]: {
2027
+ [se.cn]: {
2021
2028
  sdkApiBaseUrl: "https://api.spatialwalk.top",
2022
2029
  driveningressWsUrl: "wss://api.spatialwalk.top/v1/driveningress/websocket"
2023
2030
  },
2024
- [oe.us]: {
2031
+ [se.intl]: {
2025
2032
  sdkApiBaseUrl: "https://api.spatialwalk.cloud",
2026
2033
  driveningressWsUrl: "wss://api.spatialwalk.cloud/v1/driveningress/websocket"
2027
2034
  },
2028
- [oe.test]: {
2035
+ [se.test]: {
2029
2036
  sdkApiBaseUrl: "https://api-test.spatialwalk.top",
2030
2037
  driveningressWsUrl: "wss://api-test.spatialwalk.top/v1/driveningress/websocket"
2031
2038
  }
@@ -2054,13 +2061,13 @@ class y {
2054
2061
  h[i](`[Telemetry] ${e}`, a);
2055
2062
  }
2056
2063
  }
2057
- u(y, "_isInitialized", !1), u(y, "_appId", null), u(y, "_configuration", null), u(y, "_sessionToken", null), u(y, "_userId", null), u(y, "_version", "1.0.0-beta.20"), u(y, "_avatarCore", null), u(y, "_dynamicSdkConfig", null), u(y, "_logLevels", {
2064
+ u(y, "_isInitialized", !1), u(y, "_appId", null), u(y, "_configuration", null), u(y, "_sessionToken", null), u(y, "_userId", null), u(y, "_version", "1.0.0-beta.23"), u(y, "_avatarCore", null), u(y, "_dynamicSdkConfig", null), u(y, "_logLevels", {
2058
2065
  debug: "log",
2059
2066
  info: "log",
2060
2067
  warning: "warn",
2061
2068
  error: "error"
2062
2069
  });
2063
- const we = class we {
2070
+ const Ae = class Ae {
2064
2071
  constructor() {
2065
2072
  u(this, "audio", null);
2066
2073
  u(this, "streamingPlayer", null);
@@ -2074,10 +2081,10 @@ const we = class we {
2074
2081
  * 必须在用户交互事件(如 click)中调用
2075
2082
  */
2076
2083
  static async unlockAudioContext() {
2077
- if (!we.audioUnlocked)
2084
+ if (!Ae.audioUnlocked)
2078
2085
  try {
2079
2086
  const e = new Audio();
2080
- e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0, we.audioUnlocked = !0, h.log("✅ Audio context unlocked for Safari");
2087
+ e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0, Ae.audioUnlocked = !0, h.log("✅ Audio context unlocked for Safari");
2081
2088
  } catch (e) {
2082
2089
  h.warn("⚠️ Failed to unlock audio context:", e);
2083
2090
  }
@@ -2123,7 +2130,7 @@ const we = class we {
2123
2130
  async createAndInitializeStreamingPlayer() {
2124
2131
  if (this.streamingPlayer)
2125
2132
  return;
2126
- const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-DEXcuhRW.js");
2133
+ const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-PkzxBP93.js");
2127
2134
  this.streamingPlayer = new e({
2128
2135
  sampleRate: k.audio.sampleRate,
2129
2136
  channelCount: 1,
@@ -2208,12 +2215,28 @@ const we = class we {
2208
2215
  var e;
2209
2216
  this.useStreaming ? await ((e = this.streamingPlayer) == null ? void 0 : e.resume()) : this.audio && await this.audio.play();
2210
2217
  }
2218
+ /**
2219
+ * 设置音量 (0.0 - 1.0)
2220
+ * 注意:这仅控制数字人音频播放器的音量,不影响系统音量
2221
+ * @param volume 音量值,范围 0.0 到 1.0(0.0 为静音,1.0 为最大音量)
2222
+ */
2223
+ setVolume(e) {
2224
+ this.useStreaming && this.streamingPlayer ? this.streamingPlayer.setVolume(e) : this.audio && (this.audio.volume = Math.max(0, Math.min(1, e)));
2225
+ }
2226
+ /**
2227
+ * 获取当前音量
2228
+ * @returns 当前音量值 (0.0 - 1.0)
2229
+ */
2230
+ getVolume() {
2231
+ var e;
2232
+ return this.useStreaming && this.streamingPlayer ? this.streamingPlayer.getVolume() : ((e = this.audio) == null ? void 0 : e.volume) ?? 1;
2233
+ }
2211
2234
  dispose() {
2212
2235
  this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
2213
2236
  }
2214
2237
  };
2215
- u(we, "audioUnlocked", !1);
2216
- let ie = we, ta = (r) => crypto.getRandomValues(new Uint8Array(r)), ra = (r, e, t) => {
2238
+ u(Ae, "audioUnlocked", !1);
2239
+ let oe = Ae, ta = (r) => crypto.getRandomValues(new Uint8Array(r)), ra = (r, e, t) => {
2217
2240
  let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
2218
2241
  return (i = e) => {
2219
2242
  let o = "";
@@ -2246,7 +2269,7 @@ function ia() {
2246
2269
  }
2247
2270
  throw new Error("invalid varint");
2248
2271
  }
2249
- function Be(r, e, t) {
2272
+ function De(r, e, t) {
2250
2273
  for (let i = 0; i < 28; i = i + 7) {
2251
2274
  const o = r >>> i, s = !(!(o >>> 7) && e == 0), l = (s ? o | 128 : o) & 255;
2252
2275
  if (t.push(l), !s)
@@ -2263,7 +2286,7 @@ function Be(r, e, t) {
2263
2286
  }
2264
2287
  }
2265
2288
  const Ee = 4294967296;
2266
- function St(r) {
2289
+ function bt(r) {
2267
2290
  const e = r[0] === "-";
2268
2291
  e && (r = r.slice(1));
2269
2292
  const t = 1e6;
@@ -2374,16 +2397,16 @@ function ca() {
2374
2397
  zero: "0",
2375
2398
  supported: !1,
2376
2399
  parse(t) {
2377
- return typeof t != "string" && (t = t.toString()), Et(t), t;
2400
+ return typeof t != "string" && (t = t.toString()), Pt(t), t;
2378
2401
  },
2379
2402
  uParse(t) {
2380
- return typeof t != "string" && (t = t.toString()), Pt(t), t;
2403
+ return typeof t != "string" && (t = t.toString()), Et(t), t;
2381
2404
  },
2382
2405
  enc(t) {
2383
- return typeof t != "string" && (t = t.toString()), Et(t), St(t);
2406
+ return typeof t != "string" && (t = t.toString()), Pt(t), bt(t);
2384
2407
  },
2385
2408
  uEnc(t) {
2386
- return typeof t != "string" && (t = t.toString()), Pt(t), St(t);
2409
+ return typeof t != "string" && (t = t.toString()), Et(t), bt(t);
2387
2410
  },
2388
2411
  dec(t, n) {
2389
2412
  return oa(t, n);
@@ -2393,19 +2416,19 @@ function ca() {
2393
2416
  }
2394
2417
  };
2395
2418
  }
2396
- function Et(r) {
2419
+ function Pt(r) {
2397
2420
  if (!/^-?[0-9]+$/.test(r))
2398
2421
  throw new Error("invalid int64: " + r);
2399
2422
  }
2400
- function Pt(r) {
2423
+ function Et(r) {
2401
2424
  if (!/^[0-9]+$/.test(r))
2402
2425
  throw new Error("invalid uint64: " + r);
2403
2426
  }
2404
- const De = Symbol.for("@bufbuild/protobuf/text-encoding");
2427
+ const Oe = Symbol.for("@bufbuild/protobuf/text-encoding");
2405
2428
  function nr() {
2406
- if (globalThis[De] == null) {
2429
+ if (globalThis[Oe] == null) {
2407
2430
  const r = new globalThis.TextEncoder(), e = new globalThis.TextDecoder();
2408
- globalThis[De] = {
2431
+ globalThis[Oe] = {
2409
2432
  encodeUtf8(t) {
2410
2433
  return r.encode(t);
2411
2434
  },
@@ -2421,14 +2444,14 @@ function nr() {
2421
2444
  }
2422
2445
  };
2423
2446
  }
2424
- return globalThis[De];
2447
+ return globalThis[Oe];
2425
2448
  }
2426
2449
  var te;
2427
2450
  (function(r) {
2428
2451
  r[r.Varint = 0] = "Varint", r[r.Bit64 = 1] = "Bit64", r[r.LengthDelimited = 2] = "LengthDelimited", r[r.StartGroup = 3] = "StartGroup", r[r.EndGroup = 4] = "EndGroup", r[r.Bit32 = 5] = "Bit32";
2429
2452
  })(te || (te = {}));
2430
2453
  const da = 34028234663852886e22, ua = -34028234663852886e22, ha = 4294967295, fa = 2147483647, ma = -2147483648;
2431
- class le {
2454
+ class ce {
2432
2455
  constructor(e = nr().encodeUtf8) {
2433
2456
  this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
2434
2457
  }
@@ -2492,7 +2515,7 @@ class le {
2492
2515
  * Write a `int32` value, a signed 32 bit varint.
2493
2516
  */
2494
2517
  int32(e) {
2495
- return Oe(e), _t(e, this.buf), this;
2518
+ return Ne(e), _t(e, this.buf), this;
2496
2519
  }
2497
2520
  /**
2498
2521
  * Write a `bool` value, a variant.
@@ -2540,7 +2563,7 @@ class le {
2540
2563
  * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
2541
2564
  */
2542
2565
  sfixed32(e) {
2543
- Oe(e);
2566
+ Ne(e);
2544
2567
  let t = new Uint8Array(4);
2545
2568
  return new DataView(t.buffer).setInt32(0, e, !0), this.raw(t);
2546
2569
  }
@@ -2548,7 +2571,7 @@ class le {
2548
2571
  * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
2549
2572
  */
2550
2573
  sint32(e) {
2551
- return Oe(e), e = (e << 1 ^ e >> 31) >>> 0, _t(e, this.buf), this;
2574
+ return Ne(e), e = (e << 1 ^ e >> 31) >>> 0, _t(e, this.buf), this;
2552
2575
  }
2553
2576
  /**
2554
2577
  * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
@@ -2569,21 +2592,21 @@ class le {
2569
2592
  */
2570
2593
  int64(e) {
2571
2594
  let t = j.enc(e);
2572
- return Be(t.lo, t.hi, this.buf), this;
2595
+ return De(t.lo, t.hi, this.buf), this;
2573
2596
  }
2574
2597
  /**
2575
2598
  * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
2576
2599
  */
2577
2600
  sint64(e) {
2578
2601
  const t = j.enc(e), n = t.hi >> 31, a = t.lo << 1 ^ n, i = (t.hi << 1 | t.lo >>> 31) ^ n;
2579
- return Be(a, i, this.buf), this;
2602
+ return De(a, i, this.buf), this;
2580
2603
  }
2581
2604
  /**
2582
2605
  * Write a `uint64` value, an unsigned 64-bit varint.
2583
2606
  */
2584
2607
  uint64(e) {
2585
2608
  const t = j.uEnc(e);
2586
- return Be(t.lo, t.hi, this.buf), this;
2609
+ return De(t.lo, t.hi, this.buf), this;
2587
2610
  }
2588
2611
  }
2589
2612
  class N {
@@ -2733,7 +2756,7 @@ class N {
2733
2756
  return this.decodeUtf8(this.bytes());
2734
2757
  }
2735
2758
  }
2736
- function Oe(r) {
2759
+ function Ne(r) {
2737
2760
  if (typeof r == "string")
2738
2761
  r = Number(r);
2739
2762
  else if (typeof r != "number")
@@ -2798,8 +2821,8 @@ function va(r) {
2798
2821
  function kt() {
2799
2822
  return { reqId: "", audio: new Uint8Array(0), end: !1 };
2800
2823
  }
2801
- const de = {
2802
- encode(r, e = new le()) {
2824
+ const ue = {
2825
+ encode(r, e = new ce()) {
2803
2826
  return r.reqId !== "" && e.uint32(10).string(r.reqId), r.audio.length !== 0 && e.uint32(18).bytes(r.audio), r.end !== !1 && e.uint32(24).bool(r.end), e;
2804
2827
  },
2805
2828
  decode(r, e) {
@@ -2846,7 +2869,7 @@ const de = {
2846
2869
  return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio = wa(r.audio)), r.end !== !1 && (e.end = r.end), e;
2847
2870
  },
2848
2871
  create(r) {
2849
- return de.fromPartial(r ?? {});
2872
+ return ue.fromPartial(r ?? {});
2850
2873
  },
2851
2874
  fromPartial(r) {
2852
2875
  const e = kt();
@@ -2856,8 +2879,8 @@ const de = {
2856
2879
  function xt() {
2857
2880
  return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
2858
2881
  }
2859
- const ue = {
2860
- encode(r, e = new le()) {
2882
+ const he = {
2883
+ encode(r, e = new ce()) {
2861
2884
  e.uint32(18).fork();
2862
2885
  for (const t of r.translation)
2863
2886
  e.float(t);
@@ -3003,7 +3026,7 @@ const ue = {
3003
3026
  return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (a = r.neckPose) != null && a.length && (e.neckPose = r.neckPose), (i = r.jawPose) != null && i.length && (e.jawPose = r.jawPose), (o = r.eyePose) != null && o.length && (e.eyePose = r.eyePose), (s = r.eyeLid) != null && s.length && (e.eyeLid = r.eyeLid), (l = r.expression) != null && l.length && (e.expression = r.expression), e;
3004
3027
  },
3005
3028
  create(r) {
3006
- return ue.fromPartial(r ?? {});
3029
+ return he.fromPartial(r ?? {});
3007
3030
  },
3008
3031
  fromPartial(r) {
3009
3032
  var t, n, a, i, o, s, l;
@@ -3011,26 +3034,26 @@ const ue = {
3011
3034
  return e.translation = ((t = r.translation) == null ? void 0 : t.map((p) => p)) || [], e.rotation = ((n = r.rotation) == null ? void 0 : n.map((p) => p)) || [], e.neckPose = ((a = r.neckPose) == null ? void 0 : a.map((p) => p)) || [], e.jawPose = ((i = r.jawPose) == null ? void 0 : i.map((p) => p)) || [], e.eyePose = ((o = r.eyePose) == null ? void 0 : o.map((p) => p)) || [], e.eyeLid = ((s = r.eyeLid) == null ? void 0 : s.map((p) => p)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((p) => p)) || [], e;
3012
3035
  }
3013
3036
  };
3014
- function Ft() {
3037
+ function Mt() {
3015
3038
  return { keyframes: [] };
3016
3039
  }
3017
- const he = {
3018
- encode(r, e = new le()) {
3040
+ const fe = {
3041
+ encode(r, e = new ce()) {
3019
3042
  for (const t of r.keyframes)
3020
- ue.encode(t, e.uint32(10).fork()).join();
3043
+ he.encode(t, e.uint32(10).fork()).join();
3021
3044
  return e;
3022
3045
  },
3023
3046
  decode(r, e) {
3024
3047
  const t = r instanceof N ? r : new N(r);
3025
3048
  let n = e === void 0 ? t.len : t.pos + e;
3026
- const a = Ft();
3049
+ const a = Mt();
3027
3050
  for (; t.pos < n; ) {
3028
3051
  const i = t.uint32();
3029
3052
  switch (i >>> 3) {
3030
3053
  case 1: {
3031
3054
  if (i !== 10)
3032
3055
  break;
3033
- a.keyframes.push(ue.decode(t, t.uint32()));
3056
+ a.keyframes.push(he.decode(t, t.uint32()));
3034
3057
  continue;
3035
3058
  }
3036
3059
  }
@@ -3042,34 +3065,34 @@ const he = {
3042
3065
  },
3043
3066
  fromJSON(r) {
3044
3067
  return {
3045
- keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => ue.fromJSON(e)) : []
3068
+ keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => he.fromJSON(e)) : []
3046
3069
  };
3047
3070
  },
3048
3071
  toJSON(r) {
3049
3072
  var t;
3050
3073
  const e = {};
3051
- return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => ue.toJSON(n))), e;
3074
+ return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => he.toJSON(n))), e;
3052
3075
  },
3053
3076
  create(r) {
3054
- return he.fromPartial(r ?? {});
3077
+ return fe.fromPartial(r ?? {});
3055
3078
  },
3056
3079
  fromPartial(r) {
3057
3080
  var t;
3058
- const e = Ft();
3059
- return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => ue.fromPartial(n))) || [], e;
3081
+ const e = Mt();
3082
+ return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => he.fromPartial(n))) || [], e;
3060
3083
  }
3061
3084
  };
3062
- function Mt() {
3085
+ function Ft() {
3063
3086
  return { reqId: "", animation: void 0 };
3064
3087
  }
3065
- const fe = {
3066
- encode(r, e = new le()) {
3067
- return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && he.encode(r.animation, e.uint32(18).fork()).join(), e;
3088
+ const me = {
3089
+ encode(r, e = new ce()) {
3090
+ return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && fe.encode(r.animation, e.uint32(18).fork()).join(), e;
3068
3091
  },
3069
3092
  decode(r, e) {
3070
3093
  const t = r instanceof N ? r : new N(r);
3071
3094
  let n = e === void 0 ? t.len : t.pos + e;
3072
- const a = Mt();
3095
+ const a = Ft();
3073
3096
  for (; t.pos < n; ) {
3074
3097
  const i = t.uint32();
3075
3098
  switch (i >>> 3) {
@@ -3082,7 +3105,7 @@ const fe = {
3082
3105
  case 2: {
3083
3106
  if (i !== 18)
3084
3107
  break;
3085
- a.animation = he.decode(t, t.uint32());
3108
+ a.animation = fe.decode(t, t.uint32());
3086
3109
  continue;
3087
3110
  }
3088
3111
  }
@@ -3095,26 +3118,26 @@ const fe = {
3095
3118
  fromJSON(r) {
3096
3119
  return {
3097
3120
  reqId: U(r.reqId) ? globalThis.String(r.reqId) : "",
3098
- animation: U(r.animation) ? he.fromJSON(r.animation) : void 0
3121
+ animation: U(r.animation) ? fe.fromJSON(r.animation) : void 0
3099
3122
  };
3100
3123
  },
3101
3124
  toJSON(r) {
3102
3125
  const e = {};
3103
- return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = he.toJSON(r.animation)), e;
3126
+ return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = fe.toJSON(r.animation)), e;
3104
3127
  },
3105
3128
  create(r) {
3106
- return fe.fromPartial(r ?? {});
3129
+ return me.fromPartial(r ?? {});
3107
3130
  },
3108
3131
  fromPartial(r) {
3109
- const e = Mt();
3110
- return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? he.fromPartial(r.animation) : void 0, e;
3132
+ const e = Ft();
3133
+ return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? fe.fromPartial(r.animation) : void 0, e;
3111
3134
  }
3112
3135
  };
3113
3136
  function Lt() {
3114
3137
  return { reqId: "", code: 0, reason: "" };
3115
3138
  }
3116
- const me = {
3117
- encode(r, e = new le()) {
3139
+ const pe = {
3140
+ encode(r, e = new ce()) {
3118
3141
  return r.reqId !== "" && e.uint32(10).string(r.reqId), r.code !== 0 && e.uint32(16).int32(r.code), r.reason !== "" && e.uint32(26).string(r.reason), e;
3119
3142
  },
3120
3143
  decode(r, e) {
@@ -3161,7 +3184,7 @@ const me = {
3161
3184
  return r.reqId !== "" && (e.reqId = r.reqId), r.code !== 0 && (e.code = Math.round(r.code)), r.reason !== "" && (e.reason = r.reason), e;
3162
3185
  },
3163
3186
  create(r) {
3164
- return me.fromPartial(r ?? {});
3187
+ return pe.fromPartial(r ?? {});
3165
3188
  },
3166
3189
  fromPartial(r) {
3167
3190
  const e = Lt();
@@ -3172,8 +3195,8 @@ function Rt() {
3172
3195
  return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
3173
3196
  }
3174
3197
  const We = {
3175
- encode(r, e = new le()) {
3176
- return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && me.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && fe.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && de.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
3198
+ encode(r, e = new ce()) {
3199
+ return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && pe.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && me.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && ue.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
3177
3200
  },
3178
3201
  decode(r, e) {
3179
3202
  const t = r instanceof N ? r : new N(r);
@@ -3191,19 +3214,19 @@ const We = {
3191
3214
  case 2: {
3192
3215
  if (i !== 18)
3193
3216
  break;
3194
- a.error = me.decode(t, t.uint32());
3217
+ a.error = pe.decode(t, t.uint32());
3195
3218
  continue;
3196
3219
  }
3197
3220
  case 3: {
3198
3221
  if (i !== 26)
3199
3222
  break;
3200
- a.serverResponseAnimation = fe.decode(t, t.uint32());
3223
+ a.serverResponseAnimation = me.decode(t, t.uint32());
3201
3224
  continue;
3202
3225
  }
3203
3226
  case 4: {
3204
3227
  if (i !== 34)
3205
3228
  break;
3206
- a.clientAudioInput = de.decode(t, t.uint32());
3229
+ a.clientAudioInput = ue.decode(t, t.uint32());
3207
3230
  continue;
3208
3231
  }
3209
3232
  }
@@ -3216,21 +3239,21 @@ const We = {
3216
3239
  fromJSON(r) {
3217
3240
  return {
3218
3241
  type: U(r.type) ? ga(r.type) : 0,
3219
- error: U(r.error) ? me.fromJSON(r.error) : void 0,
3220
- serverResponseAnimation: U(r.serverResponseAnimation) ? fe.fromJSON(r.serverResponseAnimation) : void 0,
3221
- clientAudioInput: U(r.clientAudioInput) ? de.fromJSON(r.clientAudioInput) : void 0
3242
+ error: U(r.error) ? pe.fromJSON(r.error) : void 0,
3243
+ serverResponseAnimation: U(r.serverResponseAnimation) ? me.fromJSON(r.serverResponseAnimation) : void 0,
3244
+ clientAudioInput: U(r.clientAudioInput) ? ue.fromJSON(r.clientAudioInput) : void 0
3222
3245
  };
3223
3246
  },
3224
3247
  toJSON(r) {
3225
3248
  const e = {};
3226
- return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error = me.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = fe.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = de.toJSON(r.clientAudioInput)), e;
3249
+ return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error = pe.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = me.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = ue.toJSON(r.clientAudioInput)), e;
3227
3250
  },
3228
3251
  create(r) {
3229
3252
  return We.fromPartial(r ?? {});
3230
3253
  },
3231
3254
  fromPartial(r) {
3232
3255
  const e = Rt();
3233
- return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? me.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? fe.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? de.fromPartial(r.clientAudioInput) : void 0, e;
3256
+ return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? pe.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? me.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? ue.fromPartial(r.clientAudioInput) : void 0, e;
3234
3257
  }
3235
3258
  };
3236
3259
  function ya(r) {
@@ -3268,7 +3291,7 @@ class Aa {
3268
3291
  e ? this.events.delete(e) : this.events.clear();
3269
3292
  }
3270
3293
  }
3271
- class ba extends Aa {
3294
+ class Sa extends Aa {
3272
3295
  constructor(t) {
3273
3296
  super();
3274
3297
  u(this, "wsUrl");
@@ -3336,7 +3359,7 @@ class ba extends Aa {
3336
3359
  audio: new Uint8Array(n),
3337
3360
  end: a
3338
3361
  }
3339
- }, o = new le();
3362
+ }, o = new ce();
3340
3363
  We.encode(i, o);
3341
3364
  const s = o.finish();
3342
3365
  return this.ws.send(s), !0;
@@ -3444,7 +3467,7 @@ class ba extends Aa {
3444
3467
  }, t);
3445
3468
  }
3446
3469
  }
3447
- class Sa {
3470
+ class ba {
3448
3471
  // 避免并发连接
3449
3472
  constructor(e) {
3450
3473
  u(this, "wsClient");
@@ -3458,7 +3481,7 @@ class Sa {
3458
3481
  u(this, "isConnecting", !1);
3459
3482
  this.dataController = e;
3460
3483
  const t = y.getEnvironmentConfig();
3461
- this.wsClient = new ba({
3484
+ this.wsClient = new Sa({
3462
3485
  wsUrl: t.driveningressWsUrl,
3463
3486
  reconnectAttempts: 5,
3464
3487
  debug: !1,
@@ -3713,18 +3736,17 @@ class Ca {
3713
3736
  u(this, "isPlaying", !1);
3714
3737
  // ========== State Management ==========
3715
3738
  u(this, "isConnected", !1);
3716
- u(this, "currentState", M.idle);
3717
- // ========== Conversation ID Management (for external data mode) ==========
3739
+ u(this, "currentState", x.idle);
3740
+ // ========== Conversation ID Management (for host mode) ==========
3718
3741
  u(this, "currentConversationId", null);
3719
3742
  u(this, "reqEnd", !1);
3720
3743
  // ========== Event System ==========
3721
3744
  u(this, "onConnectionState", null);
3722
- u(this, "onAvatarState", null);
3745
+ u(this, "onConversationState", null);
3723
3746
  u(this, "onError", null);
3724
3747
  u(this, "eventListeners", /* @__PURE__ */ new Map());
3725
3748
  // ========== Callbacks ==========
3726
3749
  u(this, "renderCallback");
3727
- u(this, "transitionCompleteCallback");
3728
3750
  u(this, "characterHandle", null);
3729
3751
  // Character handle for multi-character support
3730
3752
  // ========== Playback Loop ==========
@@ -3740,7 +3762,7 @@ class Ca {
3740
3762
  // Maximum pending audio chunks to prevent memory leak
3741
3763
  // ========== Audio Only Mode ==========
3742
3764
  u(this, "isAudioOnlyMode", !1);
3743
- this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? pe.network, this.playbackMode === pe.network && (this.networkLayer = new Sa(this));
3765
+ this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? we.sdk, this.playbackMode === we.sdk && (this.networkLayer = new ba(this));
3744
3766
  }
3745
3767
  // ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
3746
3768
  /**
@@ -3778,6 +3800,23 @@ class Ca {
3778
3800
  get state() {
3779
3801
  return this.currentState;
3780
3802
  }
3803
+ /**
3804
+ * 将内部 AvatarState 映射到外部 ConversationState
3805
+ * @internal
3806
+ */
3807
+ mapToConversationState(e) {
3808
+ switch (e) {
3809
+ case x.idle:
3810
+ return re.idle;
3811
+ case x.active:
3812
+ return this.isPlaying ? re.playing : re.idle;
3813
+ case x.playing:
3814
+ case x.paused:
3815
+ return re.playing;
3816
+ default:
3817
+ return re.idle;
3818
+ }
3819
+ }
3781
3820
  /**
3782
3821
  * Get animation player instance
3783
3822
  * @internal
@@ -3793,18 +3832,18 @@ class Ca {
3793
3832
  getCurrentConversationId() {
3794
3833
  return this.getEffectiveConversationId();
3795
3834
  }
3796
- // ========== Network Mode Interface ==========
3835
+ // ========== SDK Mode Interface ==========
3797
3836
  /**
3798
- * Start service (network mode only)
3837
+ * Start service (SDK mode only)
3799
3838
  */
3800
3839
  async start() {
3801
3840
  if (!this.networkLayer)
3802
3841
  throw new H(
3803
- "Network layer not available. Use network playback mode.",
3842
+ "Network layer not available. Use SDK mode.",
3804
3843
  "NETWORK_LAYER_NOT_AVAILABLE"
3805
3844
  );
3806
3845
  if (!this.animationPlayer) {
3807
- this.animationPlayer = new ie();
3846
+ this.animationPlayer = new oe();
3808
3847
  try {
3809
3848
  await this.animationPlayer.createAndInitializeStreamingPlayer();
3810
3849
  } catch (e) {
@@ -3819,7 +3858,7 @@ class Ca {
3819
3858
  await this.networkLayer.connect(this.avatar.id);
3820
3859
  }
3821
3860
  /**
3822
- * Send audio to server (network mode only)
3861
+ * Send audio to server (SDK mode only)
3823
3862
  * Also cache to data layer for playback
3824
3863
  * @returns conversationId - Conversation ID for this audio session
3825
3864
  */
@@ -3833,25 +3872,26 @@ class Ca {
3833
3872
  event: "send_not_connected"
3834
3873
  }), null;
3835
3874
  const n = this.networkLayer.getCurrentConversationId();
3836
- return this.reqEnd && this.isPlaying && n && this.interrupt(), this.addAudioChunkToBuffer(new Uint8Array(e), t), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0), (o = this.onAvatarState) == null || o.call(this, M.active), this.networkLayer.getCurrentConversationId();
3875
+ return this.reqEnd && this.isPlaying && n && this.interrupt(), this.addAudioChunkToBuffer(new Uint8Array(e), t), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0), (o = this.onConversationState) == null || o.call(this, this.mapToConversationState(x.active)), this.networkLayer.getCurrentConversationId();
3837
3876
  }
3838
3877
  /**
3839
- * Close service (network mode only)
3878
+ * Close service (SDK mode only)
3840
3879
  */
3841
3880
  close() {
3842
3881
  var e;
3843
- (this.isPlaying || this.currentState === M.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this, ee.disconnected);
3882
+ (this.isPlaying || this.currentState === x.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this, ee.disconnected);
3844
3883
  }
3845
- // ========== External Data Mode Interface ==========
3884
+ // ========== Host Mode Interface ==========
3846
3885
  /**
3847
- * Playback existing audio and animation data (external data mode)
3886
+ * Playback existing audio and animation data (host mode)
3848
3887
  * Starts a new conversation by generating a new conversation ID and interrupting any existing conversation
3849
3888
  * @param initialAudioChunks - Existing audio chunks to playback
3850
3889
  * @param initialKeyframes - Existing animation keyframes to playback
3851
3890
  * @returns conversationId - New conversation ID for this conversation session
3891
+ * @internal
3852
3892
  */
3853
3893
  async playback(e, t) {
3854
- if ((this.isPlaying || this.currentConversationId) && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData(), this.animationPlayer || (this.animationPlayer = new ie()), this.animationPlayer.isStreamingReady() || await this.animationPlayer.createAndInitializeStreamingPlayer(), e && e.length > 0 && this.pendingAudioChunks.push(...e), t && t.length > 0 ? (this.currentKeyframes = t, this.emit("keyframesUpdate", this.currentKeyframes)) : (h.warn("[AvatarController] Empty animation data in playback - enabling audio-only mode"), y.logEvent("character_manager", "info", {
3894
+ if ((this.isPlaying || this.currentConversationId) && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData(), this.animationPlayer || (this.animationPlayer = new oe()), this.animationPlayer.isStreamingReady() || await this.animationPlayer.createAndInitializeStreamingPlayer(), e && e.length > 0 && this.pendingAudioChunks.push(...e), t && t.length > 0 ? (this.currentKeyframes = t, this.emit("keyframesUpdate", this.currentKeyframes)) : (h.warn("[AvatarController] Empty animation data in playback - enabling audio-only mode"), y.logEvent("character_manager", "info", {
3855
3895
  characterId: this.avatar.id,
3856
3896
  event: "empty_animation_data_audio_only_fallback",
3857
3897
  conversationId: this.currentConversationId
@@ -3860,7 +3900,7 @@ class Ca {
3860
3900
  return this.isAudioOnlyMode ? await this.startAudioOnlyPlayback() : await this.startStreamingPlayback(), this.currentConversationId;
3861
3901
  }
3862
3902
  /**
3863
- * Send audio data (external data mode)
3903
+ * Send audio data (host mode)
3864
3904
  * Stream additional audio data after playback()
3865
3905
  * @returns conversationId - Conversation ID for this audio session
3866
3906
  */
@@ -3873,12 +3913,12 @@ class Ca {
3873
3913
  const i = this.pendingAudioChunks.findIndex((o) => o.isLast);
3874
3914
  i >= 0 && i < this.pendingAudioChunks.length - 1 ? this.pendingAudioChunks.splice(0, i) : this.pendingAudioChunks.shift(), h.warn(`[AvatarController] Pending audio chunks limit reached (${this.MAX_PENDING_AUDIO_CHUNKS}), removed oldest chunk`);
3875
3915
  }
3876
- this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onAvatarState) == null || a.call(this, M.active);
3916
+ this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onConversationState) == null || a.call(this, this.mapToConversationState(x.active));
3877
3917
  }
3878
3918
  return this.currentConversationId;
3879
3919
  }
3880
3920
  /**
3881
- * Send animation keyframes (external data mode or network mode)
3921
+ * Send animation keyframes (host mode or SDK mode)
3882
3922
  * Stream additional animation data after playback()
3883
3923
  * @param keyframes - Animation keyframes to send
3884
3924
  * @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
@@ -3931,7 +3971,7 @@ class Ca {
3931
3971
  */
3932
3972
  pause() {
3933
3973
  var e, t, n;
3934
- !this.isPlaying || this.currentState === M.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = M.paused, (t = this.onAvatarState) == null || t.call(this, M.paused), h.log("[AvatarController] Playback paused"), y.logEvent("character_player", "info", {
3974
+ !this.isPlaying || this.currentState === x.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = x.paused, (t = this.onConversationState) == null || t.call(this, this.mapToConversationState(x.paused)), h.log("[AvatarController] Playback paused"), y.logEvent("character_player", "info", {
3935
3975
  characterId: this.avatar.id,
3936
3976
  event: "playback_paused",
3937
3977
  conversationId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentConversationId()) || void 0
@@ -3944,7 +3984,7 @@ class Ca {
3944
3984
  */
3945
3985
  async resume() {
3946
3986
  var e, t, n;
3947
- !this.isPlaying || this.currentState !== M.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = M.playing, (t = this.onAvatarState) == null || t.call(this, M.playing), h.log("[AvatarController] Playback resumed"), y.logEvent("character_player", "info", {
3987
+ !this.isPlaying || this.currentState !== x.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = x.playing, (t = this.onConversationState) == null || t.call(this, this.mapToConversationState(x.playing)), h.log("[AvatarController] Playback resumed"), y.logEvent("character_player", "info", {
3948
3988
  characterId: this.avatar.id,
3949
3989
  event: "playback_resumed",
3950
3990
  conversationId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentConversationId()) || void 0
@@ -3955,7 +3995,7 @@ class Ca {
3955
3995
  */
3956
3996
  interrupt() {
3957
3997
  var e;
3958
- this.currentState === M.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
3998
+ this.currentState === x.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
3959
3999
  })), this.stopPlayback(), this.emit("interrupt"), this.clearPlaybackData(), this.resetConversationIdState(), this.isAudioOnlyMode = !1;
3960
4000
  }
3961
4001
  /**
@@ -3963,7 +4003,7 @@ class Ca {
3963
4003
  */
3964
4004
  clear() {
3965
4005
  var e, t;
3966
- this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.clearPlaybackData(), this.isConnected = !1, this.currentState = M.idle, (t = this.onAvatarState) == null || t.call(this, M.idle), this.networkLayer || (this.currentConversationId = null), this.reqEnd = !1;
4006
+ this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.clearPlaybackData(), this.isConnected = !1, this.currentState = x.idle, (t = this.onConversationState) == null || t.call(this, this.mapToConversationState(x.idle)), this.networkLayer || (this.currentConversationId = null), this.reqEnd = !1;
3967
4007
  }
3968
4008
  /**
3969
4009
  * Dispose controller, clean up all callbacks to avoid memory leaks
@@ -3971,7 +4011,7 @@ class Ca {
3971
4011
  * @internal
3972
4012
  */
3973
4013
  dispose() {
3974
- this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
4014
+ this.onConnectionState = null, this.onConversationState = null, this.onError = null, this.renderCallback = void 0, this.eventListeners.clear();
3975
4015
  }
3976
4016
  // ========== Internal Helper Methods ==========
3977
4017
  /**
@@ -4001,12 +4041,12 @@ class Ca {
4001
4041
  this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1;
4002
4042
  }
4003
4043
  /**
4004
- * Get effective conversation ID (handles both network and external modes)
4044
+ * Get effective conversation ID (handles both SDK and host modes)
4005
4045
  * @private
4006
4046
  */
4007
4047
  getEffectiveConversationId() {
4008
4048
  var e;
4009
- return this.playbackMode === pe.network ? ((e = this.networkLayer) == null ? void 0 : e.getCurrentConversationId()) || null : this.currentConversationId;
4049
+ return this.playbackMode === we.sdk ? ((e = this.networkLayer) == null ? void 0 : e.getCurrentConversationId()) || null : this.currentConversationId;
4010
4050
  }
4011
4051
  // ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
4012
4052
  /**
@@ -4023,13 +4063,6 @@ class Ca {
4023
4063
  setRenderCallback(e, t) {
4024
4064
  this.renderCallback = e, t !== void 0 && (this.characterHandle = t);
4025
4065
  }
4026
- /**
4027
- * Set transition complete callback (called by AvatarView)
4028
- * @internal
4029
- */
4030
- setTransitionCompleteCallback(e) {
4031
- this.transitionCompleteCallback = e;
4032
- }
4033
4066
  /**
4034
4067
  * Transition complete notification (called by AvatarView)
4035
4068
  * @internal
@@ -4039,6 +4072,27 @@ class Ca {
4039
4072
  const e = (t = this.animationPlayer) == null ? void 0 : t.getStreamingPlayer();
4040
4073
  e && e.play();
4041
4074
  }
4075
+ /**
4076
+ * 设置音频播放音量
4077
+ * 注意:这仅控制数字人音频播放器的音量,不影响系统音量
4078
+ * @param volume 音量值,范围 0.0 到 1.0(0.0 为静音,1.0 为最大音量)
4079
+ */
4080
+ setVolume(e) {
4081
+ var t;
4082
+ (e < 0 || e > 1) && (h.warn(`[AvatarController] Volume out of range: ${e}, clamping to [0, 1]`), e = Math.max(0, Math.min(1, e))), (t = this.animationPlayer) == null || t.setVolume(e), y.logEvent("character_player", "info", {
4083
+ characterId: this.avatar.id,
4084
+ event: "volume_changed",
4085
+ volume: e
4086
+ });
4087
+ }
4088
+ /**
4089
+ * 获取当前音频播放音量
4090
+ * @returns 当前音量值 (0.0 - 1.0)
4091
+ */
4092
+ getVolume() {
4093
+ var e;
4094
+ return ((e = this.animationPlayer) == null ? void 0 : e.getVolume()) ?? 1;
4095
+ }
4042
4096
  /**
4043
4097
  * Provide interface for AvatarView to register internal events
4044
4098
  * @internal
@@ -4052,7 +4106,7 @@ class Ca {
4052
4106
  */
4053
4107
  async startStreamingPlaybackInternal() {
4054
4108
  var e, t, n;
4055
- if (this.animationPlayer || (this.animationPlayer = new ie()), !this.animationPlayer.isStreamingReady())
4109
+ if (this.animationPlayer || (this.animationPlayer = new oe()), !this.animationPlayer.isStreamingReady())
4056
4110
  try {
4057
4111
  await this.animationPlayer.createAndInitializeStreamingPlayer();
4058
4112
  } catch (a) {
@@ -4070,14 +4124,14 @@ class Ca {
4070
4124
  try {
4071
4125
  await this.animationPlayer.prepareStreamingPlayer(() => {
4072
4126
  var i, o;
4073
- this.isPlaying = !1, this.currentState = M.idle, (i = this.onAvatarState) == null || i.call(this, M.idle), this.emit("stopRendering"), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1, y.logEvent("character_player", "info", {
4127
+ this.isPlaying = !1, this.currentState = x.idle, (i = this.onConversationState) == null || i.call(this, this.mapToConversationState(x.idle)), this.emit("stopRendering"), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1, y.logEvent("character_player", "info", {
4074
4128
  characterId: this.avatar.id,
4075
4129
  event: "playback_ended",
4076
4130
  conversationId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentConversationId()) || void 0
4077
4131
  });
4078
4132
  }), this.emit("startRendering");
4079
4133
  const a = this.animationPlayer.getStreamingPlayer();
4080
- a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = M.playing, (e = this.onAvatarState) == null || e.call(this, M.playing), this.startPlaybackLoop(), y.logEvent("character_player", "info", {
4134
+ a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = x.playing, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.playing)), this.startPlaybackLoop(), y.logEvent("character_player", "info", {
4081
4135
  characterId: this.avatar.id,
4082
4136
  event: "playback_started",
4083
4137
  conversationId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentConversationId()) || void 0
@@ -4094,7 +4148,7 @@ class Ca {
4094
4148
  if (this.playbackLoopId)
4095
4149
  return;
4096
4150
  const e = k.animation.fps, t = async () => {
4097
- if (!this.isPlaying || this.currentState === M.paused || !this.animationPlayer) {
4151
+ if (!this.isPlaying || this.currentState === x.paused || !this.animationPlayer) {
4098
4152
  this.playbackLoopId = null;
4099
4153
  return;
4100
4154
  }
@@ -4116,7 +4170,7 @@ class Ca {
4116
4170
  s > 0 && s < a && (this.currentKeyframes.splice(0, s), this.keyframesOffset += s, i = a - this.keyframesOffset, i < 0 && (i = 0), i >= this.currentKeyframes.length && (i = this.currentKeyframes.length - 1), h.log(`[AvatarController] Cleaned up ${s} old keyframes (kept ${this.currentKeyframes.length} frames, offset: ${this.keyframesOffset})`));
4117
4171
  }
4118
4172
  if (i >= 0 && i < this.currentKeyframes.length) {
4119
- const o = this.currentKeyframes[i], s = Vt(o), l = y.getAvatarCore();
4173
+ const o = this.currentKeyframes[i], s = zt(o), l = y.getAvatarCore();
4120
4174
  if (l) {
4121
4175
  const p = await l.computeFrameFlatFromParams(s, this.characterHandle ?? void 0);
4122
4176
  p && this.renderCallback && this.renderCallback(p, a);
@@ -4154,7 +4208,7 @@ class Ca {
4154
4208
  */
4155
4209
  async startAudioOnlyPlayback() {
4156
4210
  var e, t;
4157
- if (this.animationPlayer || (this.animationPlayer = new ie()), !this.animationPlayer.isStreamingReady())
4211
+ if (this.animationPlayer || (this.animationPlayer = new oe()), !this.animationPlayer.isStreamingReady())
4158
4212
  try {
4159
4213
  await this.animationPlayer.createAndInitializeStreamingPlayer();
4160
4214
  } catch (n) {
@@ -4168,14 +4222,14 @@ class Ca {
4168
4222
  try {
4169
4223
  await this.animationPlayer.prepareStreamingPlayer(() => {
4170
4224
  var a;
4171
- this.isPlaying = !1, this.currentState = M.idle, (a = this.onAvatarState) == null || a.call(this, M.idle), this.isAudioOnlyMode = !1, this.clearPlaybackData(), this.resetConversationIdState(), y.logEvent("character_player", "info", {
4225
+ this.isPlaying = !1, this.currentState = x.idle, (a = this.onConversationState) == null || a.call(this, this.mapToConversationState(x.idle)), this.isAudioOnlyMode = !1, this.clearPlaybackData(), this.resetConversationIdState(), y.logEvent("character_player", "info", {
4172
4226
  characterId: this.avatar.id,
4173
4227
  event: "audio_only_playback_ended",
4174
4228
  conversationId: this.getEffectiveConversationId() || void 0
4175
4229
  });
4176
4230
  });
4177
4231
  const n = this.animationPlayer.getStreamingPlayer();
4178
- n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = M.playing, (e = this.onAvatarState) == null || e.call(this, M.playing), this.startAudioMonitoringLoop(), y.logEvent("character_player", "info", {
4232
+ n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = x.playing, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.playing)), this.startAudioMonitoringLoop(), y.logEvent("character_player", "info", {
4179
4233
  characterId: this.avatar.id,
4180
4234
  event: "audio_only_playback_started",
4181
4235
  conversationId: this.getEffectiveConversationId() || void 0
@@ -4213,7 +4267,7 @@ class Ca {
4213
4267
  const t = this.animationPlayer.getStreamingPlayer();
4214
4268
  t == null || t.stop();
4215
4269
  }
4216
- this.emit("stopRendering"), this.isPlaying = !1, this.currentState = M.idle, (e = this.onAvatarState) == null || e.call(this, M.idle);
4270
+ this.emit("stopRendering"), this.isPlaying = !1, this.currentState = x.idle, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.idle));
4217
4271
  }
4218
4272
  /**
4219
4273
  * Clean up players
@@ -4225,7 +4279,7 @@ class Ca {
4225
4279
  * Add audio chunk to buffer
4226
4280
  */
4227
4281
  addAudioChunkToBuffer(e, t) {
4228
- if (this.animationPlayer || (this.animationPlayer = new ie()), this.isPlaying && this.animationPlayer.isStreamingReady())
4282
+ if (this.animationPlayer || (this.animationPlayer = new oe()), this.isPlaying && this.animationPlayer.isStreamingReady())
4229
4283
  this.animationPlayer.addAudioChunk(e, t);
4230
4284
  else {
4231
4285
  if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
@@ -4280,17 +4334,17 @@ async function _a(r) {
4280
4334
  throw new Error(`[downloadResource] ${r} → ${t}`);
4281
4335
  }
4282
4336
  }
4283
- const Ea = 50, ne = /* @__PURE__ */ new Map();
4284
- async function Ne(r) {
4285
- const e = ne.get(r);
4337
+ const Pa = 50, ae = /* @__PURE__ */ new Map();
4338
+ async function Ue(r) {
4339
+ const e = ae.get(r);
4286
4340
  if (e)
4287
- return ne.delete(r), ne.set(r, e), e;
4341
+ return ae.delete(r), ae.set(r, e), e;
4288
4342
  const t = await _a(r);
4289
- if (ne.size >= Ea) {
4290
- const n = ne.keys().next().value;
4291
- n && ne.delete(n);
4343
+ if (ae.size >= Pa) {
4344
+ const n = ae.keys().next().value;
4345
+ n && ae.delete(n);
4292
4346
  }
4293
- return ne.set(r, t), t;
4347
+ return ae.set(r, t), t;
4294
4348
  }
4295
4349
  class ir {
4296
4350
  constructor(e = "/") {
@@ -4325,20 +4379,20 @@ class ir {
4325
4379
  }
4326
4380
  }, i = Object.keys(a).length;
4327
4381
  let o = 0;
4328
- const s = (b, A) => {
4382
+ const s = (S, A) => {
4329
4383
  t && (A && o++, t({
4330
4384
  stage: "template",
4331
- filename: b,
4385
+ filename: S,
4332
4386
  loaded: o,
4333
4387
  total: i,
4334
4388
  progress: Math.round(o / i * 100)
4335
4389
  }));
4336
- }, l = {}, p = Object.entries(a).map(async ([b, { url: A, resourceName: S }]) => {
4390
+ }, l = {}, p = Object.entries(a).map(async ([S, { url: A, resourceName: b }]) => {
4337
4391
  if (!A)
4338
- throw new Error(`[loadTemplateResources] Missing CDN URL for ${b} (${S})`);
4339
- s(S, !1), h.log(`📥 Loading ${b} from API CDN: ${A}`);
4340
- const P = await Ne(A);
4341
- h.log(`✅ ${b} loaded: ${P.byteLength} bytes`), l[b] = P, s(S, !0);
4392
+ throw new Error(`[loadTemplateResources] Missing CDN URL for ${S} (${b})`);
4393
+ s(b, !1), h.log(`📥 Loading ${S} from API CDN: ${A}`);
4394
+ const E = await Ue(A);
4395
+ h.log(`✅ ${S} loaded: ${E.byteLength} bytes`), l[S] = E, s(b, !0);
4342
4396
  });
4343
4397
  return await Promise.all(p), l;
4344
4398
  }
@@ -4377,7 +4431,7 @@ class ir {
4377
4431
  }));
4378
4432
  }, l = {}, p = Object.entries(a).map(async ([c, { url: d, resourceName: m }]) => {
4379
4433
  s(m, !1), h.log(`📥 Loading ${c} from global CDN: ${d}`);
4380
- const v = await Ne(d);
4434
+ const v = await Ue(d);
4381
4435
  h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, s(m, !0);
4382
4436
  });
4383
4437
  return await Promise.all(p), l;
@@ -4412,8 +4466,8 @@ class ir {
4412
4466
  * Load character data from CharacterMeta (iOS compatible)
4413
4467
  */
4414
4468
  async loadCharacterData(e, t) {
4415
- var v, b, A, S, P, B, _, Y, G;
4416
- const { progressCallback: n = null } = t || {}, a = (A = (b = (v = e.models) == null ? void 0 : v.shape) == null ? void 0 : b.resource) == null ? void 0 : A.remote, i = (B = (P = (S = e.models) == null ? void 0 : S.gsStandard) == null ? void 0 : P.resource) == null ? void 0 : B.remote, o = (G = (Y = (_ = e.animations) == null ? void 0 : _.frameIdle) == null ? void 0 : Y.resource) == null ? void 0 : G.remote;
4469
+ var v, S, A, b, E, B, _, Y, G;
4470
+ const { progressCallback: n = null } = t || {}, a = (A = (S = (v = e.models) == null ? void 0 : v.shape) == null ? void 0 : S.resource) == null ? void 0 : A.remote, i = (B = (E = (b = e.models) == null ? void 0 : b.gsStandard) == null ? void 0 : E.resource) == null ? void 0 : B.remote, o = (G = (Y = (_ = e.animations) == null ? void 0 : _.frameIdle) == null ? void 0 : Y.resource) == null ? void 0 : G.remote;
4417
4471
  if (!a || !i) {
4418
4472
  const R = "Missing required resources: shape or gsStandard (point cloud)";
4419
4473
  throw y.logEvent("character_load", "error", {
@@ -4428,23 +4482,23 @@ class ir {
4428
4482
  ];
4429
4483
  o && s.push({ key: "idleAnimation", url: o, filename: "idle.pb", optional: !0 });
4430
4484
  let l = 0;
4431
- const p = s.length, c = (R, z) => {
4432
- n && (z && l++, n({
4485
+ const p = s.length, c = (R, V) => {
4486
+ n && (V && l++, n({
4433
4487
  stage: "character",
4434
4488
  filename: R,
4435
4489
  loaded: l,
4436
4490
  total: p,
4437
4491
  progress: Math.round(l / p * 100)
4438
4492
  }));
4439
- }, d = {}, m = s.map(async ({ key: R, url: z, filename: W, optional: Z }) => {
4493
+ }, d = {}, m = s.map(async ({ key: R, url: V, filename: W, optional: Z }) => {
4440
4494
  c(W, !1);
4441
4495
  try {
4442
- const V = await Ne(z);
4443
- return R === "shape" ? d.shape = V : R === "pointCloud" ? d.pointCloud = V : R === "idleAnimation" && (d.idleAnimation = V), c(W, !0), { key: R, success: !0 };
4444
- } catch (V) {
4496
+ const z = await Ue(V);
4497
+ return R === "shape" ? d.shape = z : R === "pointCloud" ? d.pointCloud = z : R === "idleAnimation" && (d.idleAnimation = z), c(W, !0), { key: R, success: !0 };
4498
+ } catch (z) {
4445
4499
  if (!Z)
4446
- throw V;
4447
- return h.warn(`⚠️ Optional resource ${W} failed to load:`, V), c(W, !0), { key: R, success: !1 };
4500
+ throw z;
4501
+ return h.warn(`⚠️ Optional resource ${W} failed to load:`, z), c(W, !0), { key: R, success: !1 };
4448
4502
  }
4449
4503
  });
4450
4504
  if (await Promise.all(m), !d.shape || !d.pointCloud) {
@@ -4544,10 +4598,10 @@ class ir {
4544
4598
  }
4545
4599
  }
4546
4600
  }
4547
- const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4601
+ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4548
4602
  __proto__: null,
4549
4603
  AvatarDownloader: ir
4550
- }, Symbol.toStringTag, { value: "Module" })), ke = class ke {
4604
+ }, Symbol.toStringTag, { value: "Module" })), xe = class xe {
4551
4605
  constructor() {
4552
4606
  u(this, "avatarDownloader", null);
4553
4607
  }
@@ -4555,7 +4609,7 @@ const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4555
4609
  * 通过全局单例来访问
4556
4610
  */
4557
4611
  static get shared() {
4558
- return this._instance || (this._instance = new ke()), this._instance;
4612
+ return this._instance || (this._instance = new xe()), this._instance;
4559
4613
  }
4560
4614
  /**
4561
4615
  * 加载数字人
@@ -4569,21 +4623,21 @@ const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4569
4623
  try {
4570
4624
  if (!y.isInitialized)
4571
4625
  throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
4572
- this.avatarDownloader || (this.avatarDownloader = new ir()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: ce.downloading, progress: 10 });
4626
+ this.avatarDownloader || (this.avatarDownloader = new ir()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: de.downloading, progress: 10 });
4573
4627
  const n = await this.avatarDownloader.getCharacterById(e);
4574
- h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: ce.downloading, progress: 30 });
4628
+ h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: de.downloading, progress: 30 });
4575
4629
  const a = await this.avatarDownloader.preloadResources(n, {
4576
4630
  progressCallback: (o) => {
4577
4631
  const s = 30 + o.progress / 100 * 70;
4578
4632
  t == null || t({
4579
- type: ce.downloading,
4633
+ type: de.downloading,
4580
4634
  progress: Math.round(s)
4581
4635
  });
4582
4636
  }
4583
4637
  });
4584
4638
  h.log("[AvatarManager] Step 3: Creating Avatar instance...");
4585
4639
  const i = new on(e, n, a);
4586
- return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: ce.completed }), y.logEvent("character_load", "info", {
4640
+ return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: de.completed }), y.logEvent("character_load", "info", {
4587
4641
  characterId: e,
4588
4642
  event: "load_success"
4589
4643
  }), i;
@@ -4592,7 +4646,7 @@ const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4592
4646
  throw h.error("Failed to load avatar:", a), y.logEvent("character_load", "error", {
4593
4647
  characterId: e,
4594
4648
  reason: a
4595
- }), t == null || t({ type: ce.failed, error: n }), n;
4649
+ }), t == null || t({ type: de.failed, error: n }), n;
4596
4650
  }
4597
4651
  }
4598
4652
  /**
@@ -4602,30 +4656,30 @@ const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4602
4656
  this.avatarDownloader && this.avatarDownloader.clear();
4603
4657
  }
4604
4658
  };
4605
- u(ke, "_instance", null);
4606
- let Tt = ke, ve = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
4607
- const Ke = 2048, zt = Ke - 1;
4659
+ u(xe, "_instance", null);
4660
+ let Tt = xe, ve = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
4661
+ const Ke = 2048, Vt = Ke - 1;
4608
4662
  function Ia(r, e, t) {
4609
4663
  const a = r.length / 13;
4610
4664
  (!ve || ve.length !== a) && (ve = new Float32Array(a), Bt = new Uint32Array(ve.buffer), Dt = new Uint32Array(a), Ot = new Uint32Array(a), Nt = new Uint32Array(a), Ut = new Uint32Array(Ke));
4611
- const i = ve, o = Bt, s = Dt, l = Ot, p = Nt, c = Ut, d = e[0], m = e[1], v = e[2], b = t[0], A = t[1], S = t[2];
4612
- for (let P = 0; P < a; P++) {
4613
- const B = P * 13;
4614
- i[P] = (r[B] - d) * b + (r[B + 1] - m) * A + (r[B + 2] - v) * S, s[P] = P;
4615
- }
4616
- for (let P = 0; P < a; P++) {
4617
- const B = o[P];
4618
- o[P] = B ^ (-(B >> 31) | 2147483648);
4619
- }
4620
- Ue(o, s, l, c, 0, a), Ue(o, l, s, c, 11, a), Ue(o, s, l, c, 22, a);
4621
- for (let P = 0; P < a; P++)
4622
- p[P] = l[a - 1 - P];
4665
+ const i = ve, o = Bt, s = Dt, l = Ot, p = Nt, c = Ut, d = e[0], m = e[1], v = e[2], S = t[0], A = t[1], b = t[2];
4666
+ for (let E = 0; E < a; E++) {
4667
+ const B = E * 13;
4668
+ i[E] = (r[B] - d) * S + (r[B + 1] - m) * A + (r[B + 2] - v) * b, s[E] = E;
4669
+ }
4670
+ for (let E = 0; E < a; E++) {
4671
+ const B = o[E];
4672
+ o[E] = B ^ (-(B >> 31) | 2147483648);
4673
+ }
4674
+ Ve(o, s, l, c, 0, a), Ve(o, l, s, c, 11, a), Ve(o, s, l, c, 22, a);
4675
+ for (let E = 0; E < a; E++)
4676
+ p[E] = l[a - 1 - E];
4623
4677
  return p;
4624
4678
  }
4625
- function Ue(r, e, t, n, a, i) {
4679
+ function Ve(r, e, t, n, a, i) {
4626
4680
  n.fill(0);
4627
4681
  for (let s = 0; s < i; s++) {
4628
- const l = r[e[s]] >> a & zt;
4682
+ const l = r[e[s]] >> a & Vt;
4629
4683
  n[l]++;
4630
4684
  }
4631
4685
  let o = 0;
@@ -4634,19 +4688,19 @@ function Ue(r, e, t, n, a, i) {
4634
4688
  n[s] = o, o += l;
4635
4689
  }
4636
4690
  for (let s = 0; s < i; s++) {
4637
- const l = e[s], p = r[l] >> a & zt;
4691
+ const l = e[s], p = r[l] >> a & Vt;
4638
4692
  t[n[p]++] = l;
4639
4693
  }
4640
4694
  }
4641
- const _e = 13;
4695
+ const Pe = 13;
4642
4696
  let ye = null;
4643
4697
  function ka(r, e) {
4644
- const t = e.length, n = t * _e;
4698
+ const t = e.length, n = t * Pe;
4645
4699
  (!ye || ye.length !== n) && (ye = new Float32Array(n));
4646
4700
  for (let a = 0; a < t; a++) {
4647
- const o = e[a] * _e, s = a * _e;
4701
+ const o = e[a] * Pe, s = a * Pe;
4648
4702
  ye.set(
4649
- r.subarray(o, o + _e),
4703
+ r.subarray(o, o + Pe),
4650
4704
  s
4651
4705
  );
4652
4706
  }
@@ -4682,7 +4736,7 @@ void main() {
4682
4736
  // 预乘 alpha 输出(匹配 premultipliedAlpha: true)
4683
4737
  // 颜色值需要乘以 alpha,这样 WebGL 才能正确混合
4684
4738
  fragColor = vec4(v_color.rgb * alpha, alpha);
4685
- }`, Fa = `#version 300 es
4739
+ }`, Ma = `#version 300 es
4686
4740
  precision highp float;
4687
4741
 
4688
4742
  // 基础四边形顶点属性(共享4个顶点)
@@ -4850,7 +4904,7 @@ void main() {
4850
4904
  v_relativePosition = relativeCoord * BOUNDS_RADIUS;
4851
4905
  v_color = a_color;
4852
4906
  }`;
4853
- class Ma {
4907
+ class Fa {
4854
4908
  // 跟踪当前 buffer 大小
4855
4909
  constructor(e, t) {
4856
4910
  u(this, "canvas");
@@ -5042,7 +5096,7 @@ class Ma {
5042
5096
  const t = e.createShader(e.VERTEX_SHADER);
5043
5097
  if (!t)
5044
5098
  throw new Error("Failed to create vertex shader");
5045
- if (e.shaderSource(t, Fa), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
5099
+ if (e.shaderSource(t, Ma), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
5046
5100
  const i = e.getShaderInfoLog(t);
5047
5101
  throw e.deleteShader(t), new Error(`Vertex shader compilation failed: ${i}`);
5048
5102
  }
@@ -5663,7 +5717,7 @@ class Ta {
5663
5717
  } catch (a) {
5664
5718
  h.warn("⚠️ WebGPU init failed, fallback to WebGL:", a);
5665
5719
  }
5666
- this.renderer = new Ma(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
5720
+ this.renderer = new Fa(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
5667
5721
  }
5668
5722
  /**
5669
5723
  * Load packed Splat data (zero-copy, GPU format)
@@ -5799,7 +5853,7 @@ class Ta {
5799
5853
  o[0] = this.tempRight[0], o[1] = this.tempUp[0], o[2] = -this.tempForward[0], o[3] = 0, o[4] = this.tempRight[1], o[5] = this.tempUp[1], o[6] = -this.tempForward[1], o[7] = 0, o[8] = this.tempRight[2], o[9] = this.tempUp[2], o[10] = -this.tempForward[2], o[11] = 0, o[12] = s, o[13] = l, o[14] = p, o[15] = 1;
5800
5854
  }
5801
5855
  }
5802
- function ae(r, e, t) {
5856
+ function ie(r, e, t) {
5803
5857
  const n = Math.min(r.length, e.length), a = Array.from({ length: n });
5804
5858
  for (let i = 0; i < n; i++)
5805
5859
  a[i] = r[i] + (e[i] - r[i]) * t;
@@ -5808,16 +5862,16 @@ function ae(r, e, t) {
5808
5862
  function Ba(r, e, t) {
5809
5863
  const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
5810
5864
  return {
5811
- translation: ae(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
5812
- rotation: ae(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
5813
- neckPose: ae(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
5814
- jawPose: ae(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
5815
- eyePose: ae(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
5865
+ translation: ie(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
5866
+ rotation: ie(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
5867
+ neckPose: ie(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
5868
+ jawPose: ie(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
5869
+ eyePose: ie(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
5816
5870
  eyeLid: (() => {
5817
5871
  const a = r.eyeLid, i = e.eyeLid;
5818
- return a && a.length > 0 && i && i.length > 0 ? ae(a, i, n) : a || i || [];
5872
+ return a && a.length > 0 && i && i.length > 0 ? ie(a, i, n) : a || i || [];
5819
5873
  })(),
5820
- expression: ae(r.expression || [], e.expression || [], n)
5874
+ expression: ie(r.expression || [], e.expression || [], n)
5821
5875
  };
5822
5876
  }
5823
5877
  function Da(r, e, t, n = 25) {
@@ -5841,7 +5895,6 @@ class Ua {
5841
5895
  */
5842
5896
  constructor(e, t) {
5843
5897
  u(this, "avatarController");
5844
- u(this, "playbackMode");
5845
5898
  u(this, "avatar");
5846
5899
  // Initialization state
5847
5900
  u(this, "ready");
@@ -5874,17 +5927,13 @@ class Ua {
5874
5927
  // Character handle for multi-character support
5875
5928
  u(this, "characterHandle", null);
5876
5929
  u(this, "characterId");
5877
- this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
5878
- const n = y.configuration;
5879
- if (!n)
5930
+ if (this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, !y.configuration)
5880
5931
  throw new Error("AvatarKit must be initialized before creating AvatarView. Call AvatarKit.initialize() first.");
5881
- const i = (n.drivingServiceMode ?? ze.sdk) === ze.sdk ? pe.network : pe.external;
5882
- this.playbackMode = i, this.avatarController = new Ca(e, {
5883
- playbackMode: i
5884
- }), this.avatarController.setRenderCallback((o, s) => {
5885
- this.renderRealtimeFrame(o, s);
5886
- }), this.avatarController.setTransitionCompleteCallback(() => {
5887
- this.onTransitionComplete();
5932
+ const n = y.getPlaybackMode();
5933
+ this.avatarController = new Ca(e, {
5934
+ playbackMode: n
5935
+ }), this.avatarController.setRenderCallback((a, i) => {
5936
+ this.renderRealtimeFrame(a, i);
5888
5937
  }), this.canvas = this.createCanvas(t), this.ready = this.initializeView(e), this.setupControllerEventListeners();
5889
5938
  }
5890
5939
  // Unique ID for this character instance
@@ -6024,17 +6073,17 @@ class Ua {
6024
6073
  * 从角色设置中推导相机配置
6025
6074
  */
6026
6075
  deriveCameraConfigFromSettings(e, t, n) {
6027
- const a = (z, W) => Number.isFinite(z) ? z : W, i = a(e.translationX, t.position[0]), o = a(e.translationY, t.position[1]), s = a(e.translationZ, t.position[2]), l = a(e.rotation, 0), p = a(e.fovYRadians, 0), c = Math.hypot(i, o, s) > 1e-4, d = p > 0, m = Math.abs(l) > 1e-4;
6076
+ const a = (V, W) => Number.isFinite(V) ? V : W, i = a(e.translationX, t.position[0]), o = a(e.translationY, t.position[1]), s = a(e.translationZ, t.position[2]), l = a(e.rotation, 0), p = a(e.fovYRadians, 0), c = Math.hypot(i, o, s) > 1e-4, d = p > 0, m = Math.abs(l) > 1e-4;
6028
6077
  if (!c && !d && !m)
6029
6078
  return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
6030
- const v = Math.sin(l), b = Math.cos(l), A = c ? [i, o, s] : [...t.position], S = [
6079
+ const v = Math.sin(l), S = Math.cos(l), A = c ? [i, o, s] : [...t.position], b = [
6031
6080
  -v,
6032
6081
  0,
6033
- -b
6034
- ], P = Math.hypot(S[0], S[1], S[2]) || 1, B = [
6035
- S[0] / P,
6036
- S[1] / P,
6037
- S[2] / P
6082
+ -S
6083
+ ], E = Math.hypot(b[0], b[1], b[2]) || 1, B = [
6084
+ b[0] / E,
6085
+ b[1] / E,
6086
+ b[2] / E
6038
6087
  ], _ = [
6039
6088
  A[0] + B[0],
6040
6089
  A[1] + B[1],
@@ -6161,10 +6210,10 @@ class Ua {
6161
6210
  this.realtimeAnimationLoopId = requestAnimationFrame(a);
6162
6211
  return;
6163
6212
  }
6164
- const s = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, s / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(l * (p - 1))), d = this.transitionKeyframes[c], m = Vt(d), v = y.getAvatarCore();
6213
+ const s = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, s / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(l * (p - 1))), d = this.transitionKeyframes[c], m = zt(d), v = y.getAvatarCore();
6165
6214
  if (v) {
6166
- const b = await v.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
6167
- b && (this.renderSystem.loadSplatsFromPackedData(b), this.renderSystem.renderFrame());
6215
+ const S = await v.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
6216
+ S && (this.renderSystem.loadSplatsFromPackedData(S), this.renderSystem.renderFrame());
6168
6217
  }
6169
6218
  if (l >= 1) {
6170
6219
  if (o === "transitioningToSpeaking")
@@ -6217,11 +6266,6 @@ class Ua {
6217
6266
  renderRealtimeFrame(e, t) {
6218
6267
  !this.renderSystem || this.renderingState !== "speaking" || (this.renderSystem.loadSplatsFromPackedData(e), this.renderSystem.renderFrame(), this.lastRenderedFrameIndex = t, t >= 0 && t < this.currentKeyframes.length && (this.lastRealtimeProtoFrame = this.currentKeyframes[t]));
6219
6268
  }
6220
- /**
6221
- * 过渡完成回调(通知播放层启动音频)
6222
- */
6223
- onTransitionComplete() {
6224
- }
6225
6269
  /**
6226
6270
  * 状态转换方法
6227
6271
  * 统一管理状态转换,确保状态一致性
@@ -6282,6 +6326,7 @@ class Ua {
6282
6326
  * 准备实时渲染(生成 Idle -> Speaking 过渡)
6283
6327
  */
6284
6328
  async prepareRealtimeRendering(e) {
6329
+ var n, a;
6285
6330
  const t = this.renderingState;
6286
6331
  if ((t === "speaking" || t === "transitioningToSpeaking") && this.currentKeyframes.length > 0) {
6287
6332
  this.currentKeyframes = e;
@@ -6290,22 +6335,22 @@ class Ua {
6290
6335
  this.stopIdleAnimationLoop(), this.currentKeyframes = e, this.setState(
6291
6336
  "transitioningToSpeaking"
6292
6337
  /* TransitioningToSpeaking */
6293
- );
6338
+ ), (a = (n = this.avatarController).onConversationState) == null || a.call(n, re.playing);
6294
6339
  try {
6295
- const n = y.getAvatarCore();
6296
- if (n && e.length > 0) {
6340
+ const i = y.getAvatarCore();
6341
+ if (i && e.length > 0) {
6297
6342
  if (this.renderingState !== "transitioningToSpeaking")
6298
6343
  return;
6299
- const a = await n.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), i = ht(a);
6344
+ const o = await i.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), s = ht(o);
6300
6345
  await this.getCachedIdleFirstFrame();
6301
- const o = e[0];
6302
- this.transitionKeyframes = this.generateAndAlignTransitionFrames(i, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
6346
+ const l = e[0];
6347
+ this.transitionKeyframes = this.generateAndAlignTransitionFrames(s, l), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
6303
6348
  "speaking"
6304
6349
  /* Speaking */
6305
6350
  ), this.avatarController.onTransitionComplete()) : k.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
6306
6351
  }
6307
- } catch (n) {
6308
- h.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
6352
+ } catch (i) {
6353
+ h.warn("[AvatarView] Transition generation failed:", i instanceof Error ? i.message : String(i)), this.renderingState === "transitioningToSpeaking" && (this.setState(
6309
6354
  "speaking"
6310
6355
  /* Speaking */
6311
6356
  ), this.avatarController.onTransitionComplete());
@@ -6326,6 +6371,7 @@ class Ua {
6326
6371
  * 停止实时对话渲染
6327
6372
  */
6328
6373
  stopRealtimeRendering() {
6374
+ var t, n;
6329
6375
  const e = this.renderingState;
6330
6376
  if (!(e === "idle" || e === "transitioningToIdle")) {
6331
6377
  if (e !== "speaking") {
@@ -6338,19 +6384,19 @@ class Ua {
6338
6384
  this.setState(
6339
6385
  "transitioningToIdle"
6340
6386
  /* TransitioningToIdle */
6341
- ), (async () => {
6387
+ ), (n = (t = this.avatarController).onConversationState) == null || n.call(t, re.idle), (async () => {
6342
6388
  try {
6343
6389
  if (this.renderingState !== "transitioningToIdle")
6344
6390
  return;
6345
6391
  if (y.getAvatarCore() && this.currentKeyframes.length > 0) {
6346
- const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], a = await this.getCachedIdleFirstFrame();
6347
- if (a && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, a), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
6392
+ const i = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], o = await this.getCachedIdleFirstFrame();
6393
+ if (o && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(i, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
6348
6394
  k.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
6349
6395
  return;
6350
6396
  }
6351
6397
  }
6352
- } catch (t) {
6353
- h.warn("[AvatarView] Return transition generation failed:", t instanceof Error ? t.message : String(t));
6398
+ } catch (a) {
6399
+ h.warn("[AvatarView] Return transition generation failed:", a instanceof Error ? a.message : String(a));
6354
6400
  }
6355
6401
  this.renderingState === "transitioningToIdle" && (this.setState(
6356
6402
  "idle"
@@ -6418,9 +6464,9 @@ class Ua {
6418
6464
  export {
6419
6465
  k as A,
6420
6466
  ee as C,
6421
- ze as D,
6422
- oe as E,
6423
- ce as L,
6467
+ we as D,
6468
+ se as E,
6469
+ de as L,
6424
6470
  sn as R,
6425
6471
  H as S,
6426
6472
  y as a,
@@ -6429,9 +6475,9 @@ export {
6429
6475
  Tt as d,
6430
6476
  ar as e,
6431
6477
  Ua as f,
6432
- M as g,
6433
- pe as h,
6478
+ re as g,
6479
+ x as h,
6434
6480
  Na as i,
6435
6481
  h as l
6436
6482
  };
6437
- //# sourceMappingURL=index-ChKhyUK4.js.map
6483
+ //# sourceMappingURL=index-DYf1u8L7.js.map