@spatialwalk/avatarkit 1.0.0-beta.16 → 1.0.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- var tn = Object.defineProperty;
2
- var rn = (r, e, t) => e in r ? tn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var d = (r, e, t) => rn(r, typeof e != "symbol" ? e + "" : e, t);
4
- class nn {
1
+ var nn = Object.defineProperty;
2
+ var an = (r, e, t) => e in r ? nn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var d = (r, e, t) => an(r, typeof e != "symbol" ? e + "" : e, t);
4
+ class sn {
5
5
  /**
6
6
  * 构造函数(内部使用)
7
7
  * @param id 数字人 ID
@@ -29,48 +29,48 @@ class nn {
29
29
  return this.resources;
30
30
  }
31
31
  }
32
- var an = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.ANIMATION_MONO = "frameMono", r.AUDIO_MONO = "audioMono", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(an || {});
33
- function Oa(r) {
34
- var e, t, n, a, i, s, l, o, p, c, u, m, w, v, y, b, P;
32
+ var on = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.ANIMATION_MONO = "frameMono", r.AUDIO_MONO = "audioMono", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(on || {});
33
+ function Na(r) {
34
+ var e, t, n, a, i, s, o, l, p, c, u, m, y, w, A, S, E;
35
35
  return {
36
36
  camera: ((t = (e = r.camera) == null ? void 0 : e.resource) == null ? void 0 : t.remote) || null,
37
37
  frameIdle: ((i = (a = (n = r.animations) == null ? void 0 : n.frameIdle) == null ? void 0 : a.resource) == null ? void 0 : i.remote) || null,
38
- frameMono: ((o = (l = (s = r.animations) == null ? void 0 : s.frameMono) == null ? void 0 : l.resource) == null ? void 0 : o.remote) || null,
38
+ frameMono: ((l = (o = (s = r.animations) == null ? void 0 : s.frameMono) == null ? void 0 : o.resource) == null ? void 0 : l.remote) || null,
39
39
  audioMono: ((u = (c = (p = r.animations) == null ? void 0 : p.audioMono) == null ? void 0 : c.resource) == null ? void 0 : u.remote) || null,
40
- shape: ((v = (w = (m = r.models) == null ? void 0 : m.shape) == null ? void 0 : w.resource) == null ? void 0 : v.remote) || null,
41
- gsStandard: ((P = (b = (y = r.models) == null ? void 0 : y.gsStandard) == null ? void 0 : b.resource) == null ? void 0 : P.remote) || null
40
+ shape: ((w = (y = (m = r.models) == null ? void 0 : m.shape) == null ? void 0 : y.resource) == null ? void 0 : w.remote) || null,
41
+ gsStandard: ((E = (S = (A = r.models) == null ? void 0 : A.gsStandard) == null ? void 0 : S.resource) == null ? void 0 : E.remote) || null
42
42
  };
43
43
  }
44
- function Na(r) {
44
+ function Ua(r) {
45
45
  var e, t, n, a, i, s;
46
46
  return !!((n = (t = (e = r.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((s = (i = (a = r.animations) == null ? void 0 : a.audioMono) == null ? void 0 : i.resource) != null && s.remote));
47
47
  }
48
- function Ua(r) {
48
+ function za(r) {
49
49
  var e, t, n, a, i, s;
50
50
  try {
51
- const l = JSON.parse(r);
52
- return !!((n = (t = (e = l == null ? void 0 : l.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((s = (i = (a = l == null ? void 0 : l.animations) == null ? void 0 : a.audioMono) == null ? void 0 : i.resource) != null && s.remote));
51
+ const o = JSON.parse(r);
52
+ return !!((n = (t = (e = o == null ? void 0 : o.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((s = (i = (a = o == null ? void 0 : o.animations) == null ? void 0 : a.audioMono) == null ? void 0 : i.resource) != null && s.remote));
53
53
  } catch {
54
54
  return !1;
55
55
  }
56
56
  }
57
- var le = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(le || {}), he = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(he || {}), be = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(be || {}), T = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(T || {});
58
- class oe extends Error {
57
+ var ce = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(ce || {}), We = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(We || {}), fe = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(fe || {}), _e = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(_e || {}), F = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(F || {});
58
+ class ee extends Error {
59
59
  constructor(e, t) {
60
60
  super(e), this.code = t, this.name = "SPAvatarError";
61
61
  }
62
62
  }
63
- var Me = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(Me || {});
64
- function sn() {
63
+ var we = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(we || {});
64
+ function ln() {
65
65
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
66
66
  }
67
- function on() {
68
- return sn();
67
+ function cn() {
68
+ return ln();
69
69
  }
70
- const x = {
70
+ const I = {
71
71
  // Dynamic debug mode check (includes URL parameter)
72
72
  get debug() {
73
- return on();
73
+ return cn();
74
74
  },
75
75
  camera: {
76
76
  position: [-0.02, -0.013, 1.5],
@@ -99,7 +99,7 @@ const x = {
99
99
  }
100
100
  }
101
101
  };
102
- function zt(r) {
102
+ function $t(r) {
103
103
  var e;
104
104
  return {
105
105
  translation: r.translation || [0, 0, 0],
@@ -114,7 +114,7 @@ function zt(r) {
114
114
  has_eyelid: (((e = r.eyeLid) == null ? void 0 : e.length) || 0) > 0
115
115
  };
116
116
  }
117
- function ht(r) {
117
+ function ft(r) {
118
118
  return {
119
119
  translation: r.translation || [0, 0, 0],
120
120
  rotation: r.rotation || [0, 0, 0],
@@ -125,97 +125,97 @@ function ht(r) {
125
125
  expression: r.expr_params || []
126
126
  };
127
127
  }
128
- var $t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
129
- function ln(r) {
128
+ var qt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
129
+ function dn(r) {
130
130
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
131
131
  }
132
- var qt = { exports: {} }, Ne = { exports: {} }, ft;
133
- function cn() {
134
- return ft || (ft = 1, function(r, e) {
132
+ var Gt = { exports: {} }, Ne = { exports: {} }, mt;
133
+ function un() {
134
+ return mt || (mt = 1, function(r, e) {
135
135
  (function(t, n) {
136
136
  r.exports = n();
137
- })($t, function() {
138
- function t(y) {
139
- return !isNaN(parseFloat(y)) && isFinite(y);
137
+ })(qt, function() {
138
+ function t(A) {
139
+ return !isNaN(parseFloat(A)) && isFinite(A);
140
140
  }
141
- function n(y) {
142
- return y.charAt(0).toUpperCase() + y.substring(1);
141
+ function n(A) {
142
+ return A.charAt(0).toUpperCase() + A.substring(1);
143
143
  }
144
- function a(y) {
144
+ function a(A) {
145
145
  return function() {
146
- return this[y];
146
+ return this[A];
147
147
  };
148
148
  }
149
- var i = ["isConstructor", "isEval", "isNative", "isToplevel"], s = ["columnNumber", "lineNumber"], l = ["fileName", "functionName", "source"], o = ["args"], p = ["evalOrigin"], c = i.concat(s, l, o, p);
150
- function u(y) {
151
- if (y)
152
- for (var b = 0; b < c.length; b++)
153
- y[c[b]] !== void 0 && this["set" + n(c[b])](y[c[b]]);
149
+ var i = ["isConstructor", "isEval", "isNative", "isToplevel"], s = ["columnNumber", "lineNumber"], o = ["fileName", "functionName", "source"], l = ["args"], p = ["evalOrigin"], c = i.concat(s, o, l, p);
150
+ function u(A) {
151
+ if (A)
152
+ for (var S = 0; S < c.length; S++)
153
+ A[c[S]] !== void 0 && this["set" + n(c[S])](A[c[S]]);
154
154
  }
155
155
  u.prototype = {
156
156
  getArgs: function() {
157
157
  return this.args;
158
158
  },
159
- setArgs: function(y) {
160
- if (Object.prototype.toString.call(y) !== "[object Array]")
159
+ setArgs: function(A) {
160
+ if (Object.prototype.toString.call(A) !== "[object Array]")
161
161
  throw new TypeError("Args must be an Array");
162
- this.args = y;
162
+ this.args = A;
163
163
  },
164
164
  getEvalOrigin: function() {
165
165
  return this.evalOrigin;
166
166
  },
167
- setEvalOrigin: function(y) {
168
- if (y instanceof u)
169
- this.evalOrigin = y;
170
- else if (y instanceof Object)
171
- this.evalOrigin = new u(y);
167
+ setEvalOrigin: function(A) {
168
+ if (A instanceof u)
169
+ this.evalOrigin = A;
170
+ else if (A instanceof Object)
171
+ this.evalOrigin = new u(A);
172
172
  else
173
173
  throw new TypeError("Eval Origin must be an Object or StackFrame");
174
174
  },
175
175
  toString: function() {
176
- var y = this.getFileName() || "", b = this.getLineNumber() || "", P = this.getColumnNumber() || "", L = this.getFunctionName() || "";
177
- return this.getIsEval() ? y ? "[eval] (" + y + ":" + b + ":" + P + ")" : "[eval]:" + b + ":" + P : L ? L + " (" + y + ":" + b + ":" + P + ")" : y + ":" + b + ":" + P;
176
+ var A = this.getFileName() || "", S = this.getLineNumber() || "", E = this.getColumnNumber() || "", T = this.getFunctionName() || "";
177
+ return this.getIsEval() ? A ? "[eval] (" + A + ":" + S + ":" + E + ")" : "[eval]:" + S + ":" + E : T ? T + " (" + A + ":" + S + ":" + E + ")" : A + ":" + S + ":" + E;
178
178
  }
179
- }, u.fromString = function(b) {
180
- var P = b.indexOf("("), L = b.lastIndexOf(")"), _ = b.substring(0, P), Y = b.substring(P + 1, L).split(","), G = b.substring(L + 1);
179
+ }, u.fromString = function(S) {
180
+ var E = S.indexOf("("), T = S.lastIndexOf(")"), _ = S.substring(0, E), J = S.substring(E + 1, T).split(","), G = S.substring(T + 1);
181
181
  if (G.indexOf("@") === 0)
182
182
  var U = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), W = U[1], Z = U[2], X = U[3];
183
183
  return new u({
184
184
  functionName: _,
185
- args: Y || void 0,
185
+ args: J || void 0,
186
186
  fileName: W,
187
187
  lineNumber: Z || void 0,
188
188
  columnNumber: X || void 0
189
189
  });
190
190
  };
191
191
  for (var m = 0; m < i.length; m++)
192
- u.prototype["get" + n(i[m])] = a(i[m]), u.prototype["set" + n(i[m])] = /* @__PURE__ */ function(y) {
193
- return function(b) {
194
- this[y] = !!b;
192
+ u.prototype["get" + n(i[m])] = a(i[m]), u.prototype["set" + n(i[m])] = /* @__PURE__ */ function(A) {
193
+ return function(S) {
194
+ this[A] = !!S;
195
195
  };
196
196
  }(i[m]);
197
- for (var w = 0; w < s.length; w++)
198
- u.prototype["get" + n(s[w])] = a(s[w]), u.prototype["set" + n(s[w])] = /* @__PURE__ */ function(y) {
199
- return function(b) {
200
- if (!t(b))
201
- throw new TypeError(y + " must be a Number");
202
- this[y] = Number(b);
197
+ for (var y = 0; y < s.length; y++)
198
+ u.prototype["get" + n(s[y])] = a(s[y]), u.prototype["set" + n(s[y])] = /* @__PURE__ */ function(A) {
199
+ return function(S) {
200
+ if (!t(S))
201
+ throw new TypeError(A + " must be a Number");
202
+ this[A] = Number(S);
203
203
  };
204
- }(s[w]);
205
- for (var v = 0; v < l.length; v++)
206
- u.prototype["get" + n(l[v])] = a(l[v]), u.prototype["set" + n(l[v])] = /* @__PURE__ */ function(y) {
207
- return function(b) {
208
- this[y] = String(b);
204
+ }(s[y]);
205
+ for (var w = 0; w < o.length; w++)
206
+ u.prototype["get" + n(o[w])] = a(o[w]), u.prototype["set" + n(o[w])] = /* @__PURE__ */ function(A) {
207
+ return function(S) {
208
+ this[A] = String(S);
209
209
  };
210
- }(l[v]);
210
+ }(o[w]);
211
211
  return u;
212
212
  });
213
213
  }(Ne)), Ne.exports;
214
214
  }
215
215
  (function(r, e) {
216
216
  (function(t, n) {
217
- r.exports = n(cn());
218
- })($t, function(n) {
217
+ r.exports = n(un());
218
+ })(qt, function(n) {
219
219
  var a = /(^|@)\S+:\d+/, i = /^\s*at .*(\S+:\d+|\(native\))/m, s = /^(eval@)?(\[native code])?$/;
220
220
  return {
221
221
  /**
@@ -224,24 +224,24 @@ function cn() {
224
224
  * @param {Error} error object
225
225
  * @return {Array} of StackFrames
226
226
  */
227
- parse: function(o) {
228
- if (typeof o.stacktrace < "u" || typeof o["opera#sourceloc"] < "u")
229
- return this.parseOpera(o);
230
- if (o.stack && o.stack.match(i))
231
- return this.parseV8OrIE(o);
232
- if (o.stack)
233
- return this.parseFFOrSafari(o);
227
+ parse: function(l) {
228
+ if (typeof l.stacktrace < "u" || typeof l["opera#sourceloc"] < "u")
229
+ return this.parseOpera(l);
230
+ if (l.stack && l.stack.match(i))
231
+ return this.parseV8OrIE(l);
232
+ if (l.stack)
233
+ return this.parseFFOrSafari(l);
234
234
  throw new Error("Cannot parse given Error object");
235
235
  },
236
236
  // Separate line and column numbers from a string of the form: (URI:Line:Column)
237
- extractLocation: function(o) {
238
- if (o.indexOf(":") === -1)
239
- return [o];
240
- var p = /(.+?)(?::(\d+))?(?::(\d+))?$/, c = p.exec(o.replace(/[()]/g, ""));
237
+ extractLocation: function(l) {
238
+ if (l.indexOf(":") === -1)
239
+ return [l];
240
+ var p = /(.+?)(?::(\d+))?(?::(\d+))?$/, c = p.exec(l.replace(/[()]/g, ""));
241
241
  return [c[1], c[2] || void 0, c[3] || void 0];
242
242
  },
243
- parseV8OrIE: function(o) {
244
- var p = o.stack.split(`
243
+ parseV8OrIE: function(l) {
244
+ var p = l.stack.split(`
245
245
  `).filter(function(c) {
246
246
  return !!c.match(i);
247
247
  }, this);
@@ -249,18 +249,18 @@ function cn() {
249
249
  c.indexOf("(eval ") > -1 && (c = c.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
250
250
  var u = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = u.match(/ (\(.+\)$)/);
251
251
  u = m ? u.replace(m[0], "") : u;
252
- var w = this.extractLocation(m ? m[1] : u), v = m && u || void 0, y = ["eval", "<anonymous>"].indexOf(w[0]) > -1 ? void 0 : w[0];
252
+ var y = this.extractLocation(m ? m[1] : u), w = m && u || void 0, A = ["eval", "<anonymous>"].indexOf(y[0]) > -1 ? void 0 : y[0];
253
253
  return new n({
254
- functionName: v,
255
- fileName: y,
256
- lineNumber: w[1],
257
- columnNumber: w[2],
254
+ functionName: w,
255
+ fileName: A,
256
+ lineNumber: y[1],
257
+ columnNumber: y[2],
258
258
  source: c
259
259
  });
260
260
  }, this);
261
261
  },
262
- parseFFOrSafari: function(o) {
263
- var p = o.stack.split(`
262
+ parseFFOrSafari: function(l) {
263
+ var p = l.stack.split(`
264
264
  `).filter(function(c) {
265
265
  return !c.match(s);
266
266
  }, this);
@@ -269,43 +269,43 @@ function cn() {
269
269
  return new n({
270
270
  functionName: c
271
271
  });
272
- var u = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(u), w = m && m[1] ? m[1] : void 0, v = this.extractLocation(c.replace(u, ""));
272
+ var u = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(u), y = m && m[1] ? m[1] : void 0, w = this.extractLocation(c.replace(u, ""));
273
273
  return new n({
274
- functionName: w,
275
- fileName: v[0],
276
- lineNumber: v[1],
277
- columnNumber: v[2],
274
+ functionName: y,
275
+ fileName: w[0],
276
+ lineNumber: w[1],
277
+ columnNumber: w[2],
278
278
  source: c
279
279
  });
280
280
  }, this);
281
281
  },
282
- parseOpera: function(o) {
283
- return !o.stacktrace || o.message.indexOf(`
284
- `) > -1 && o.message.split(`
285
- `).length > o.stacktrace.split(`
286
- `).length ? this.parseOpera9(o) : o.stack ? this.parseOpera11(o) : this.parseOpera10(o);
282
+ parseOpera: function(l) {
283
+ return !l.stacktrace || l.message.indexOf(`
284
+ `) > -1 && l.message.split(`
285
+ `).length > l.stacktrace.split(`
286
+ `).length ? this.parseOpera9(l) : l.stack ? this.parseOpera11(l) : this.parseOpera10(l);
287
287
  },
288
- parseOpera9: function(o) {
289
- for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = o.message.split(`
290
- `), u = [], m = 2, w = c.length; m < w; m += 2) {
291
- var v = p.exec(c[m]);
292
- v && u.push(new n({
293
- fileName: v[2],
294
- lineNumber: v[1],
288
+ parseOpera9: function(l) {
289
+ for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
290
+ `), u = [], m = 2, y = c.length; m < y; m += 2) {
291
+ var w = p.exec(c[m]);
292
+ w && u.push(new n({
293
+ fileName: w[2],
294
+ lineNumber: w[1],
295
295
  source: c[m]
296
296
  }));
297
297
  }
298
298
  return u;
299
299
  },
300
- parseOpera10: function(o) {
301
- for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = o.stacktrace.split(`
302
- `), u = [], m = 0, w = c.length; m < w; m += 2) {
303
- var v = p.exec(c[m]);
304
- v && u.push(
300
+ parseOpera10: function(l) {
301
+ for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = l.stacktrace.split(`
302
+ `), u = [], m = 0, y = c.length; m < y; m += 2) {
303
+ var w = p.exec(c[m]);
304
+ w && u.push(
305
305
  new n({
306
- functionName: v[3] || void 0,
307
- fileName: v[2],
308
- lineNumber: v[1],
306
+ functionName: w[3] || void 0,
307
+ fileName: w[2],
308
+ lineNumber: w[1],
309
309
  source: c[m]
310
310
  })
311
311
  );
@@ -313,18 +313,18 @@ function cn() {
313
313
  return u;
314
314
  },
315
315
  // Opera 10.65+ Error.stack very similar to FF/Safari
316
- parseOpera11: function(o) {
317
- var p = o.stack.split(`
316
+ parseOpera11: function(l) {
317
+ var p = l.stack.split(`
318
318
  `).filter(function(c) {
319
319
  return !!c.match(a) && !c.match(/^Error created at/);
320
320
  }, this);
321
321
  return p.map(function(c) {
322
- var u = c.split("@"), m = this.extractLocation(u.pop()), w = u.shift() || "", v = w.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, y;
323
- w.match(/\(([^)]*)\)/) && (y = w.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
324
- var b = y === void 0 || y === "[arguments not available]" ? void 0 : y.split(",");
322
+ var u = c.split("@"), m = this.extractLocation(u.pop()), y = u.shift() || "", w = y.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, A;
323
+ y.match(/\(([^)]*)\)/) && (A = y.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
324
+ var S = A === void 0 || A === "[arguments not available]" ? void 0 : A.split(",");
325
325
  return new n({
326
- functionName: v,
327
- args: b,
326
+ functionName: w,
327
+ args: S,
328
328
  fileName: m[0],
329
329
  lineNumber: m[1],
330
330
  columnNumber: m[2],
@@ -334,175 +334,175 @@ function cn() {
334
334
  }
335
335
  };
336
336
  });
337
- })(qt);
338
- var dn = qt.exports;
339
- const un = /* @__PURE__ */ ln(dn);
340
- let mt = () => {
337
+ })(Gt);
338
+ var hn = Gt.exports;
339
+ const fn = /* @__PURE__ */ dn(hn);
340
+ let pt = () => {
341
341
  var r = (() => {
342
342
  var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, i = (f, g) => {
343
- for (var A in g) e(f, A, { get: g[A], enumerable: !0 });
344
- }, s = (f, g, A, C) => {
345
- if (g && typeof g == "object" || typeof g == "function") for (let E of n(g)) !a.call(f, E) && E !== A && e(f, E, { get: () => g[E], enumerable: !(C = t(g, E)) || C.enumerable });
343
+ for (var b in g) e(f, b, { get: g[b], enumerable: !0 });
344
+ }, s = (f, g, b, C) => {
345
+ if (g && typeof g == "object" || typeof g == "function") for (let P of n(g)) !a.call(f, P) && P !== b && e(f, P, { get: () => g[P], enumerable: !(C = t(g, P)) || C.enumerable });
346
346
  return f;
347
- }, l = (f) => s(e({}, "__esModule", { value: !0 }), f), o = {};
348
- i(o, { default: () => Qr });
349
- var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number", w = (f) => typeof f == "object" && f !== null, v = (f) => f instanceof RegExp, y = (f) => typeof f == "string", b = (f) => f === void 0, P = (f) => {
347
+ }, o = (f) => s(e({}, "__esModule", { value: !0 }), f), l = {};
348
+ i(l, { default: () => tn });
349
+ var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number", y = (f) => typeof f == "object" && f !== null, w = (f) => f instanceof RegExp, A = (f) => typeof f == "string", S = (f) => f === void 0, E = (f) => {
350
350
  const g = /* @__PURE__ */ new Map();
351
- return (A) => {
352
- const C = g.get(A);
351
+ return (b) => {
352
+ const C = g.get(b);
353
353
  if (C) return C;
354
- const E = f(A);
355
- return g.set(A, E), E;
354
+ const P = f(b);
355
+ return g.set(b, P), P;
356
356
  };
357
- }, L = (f, g, A = {}) => {
358
- const C = { cache: {}, input: f, index: 0, indexMax: 0, options: A, output: [] };
359
- if (z(g)(C) && C.index === f.length) return C.output;
357
+ }, T = (f, g, b = {}) => {
358
+ const C = { cache: {}, input: f, index: 0, indexMax: 0, options: b, output: [] };
359
+ if (V(g)(C) && C.index === f.length) return C.output;
360
360
  throw new Error(`Failed to parse at index ${C.indexMax}`);
361
- }, _ = (f, g) => p(f) ? Y(f, g) : y(f) ? U(f, g) : G(f, g), Y = (f, g) => {
362
- const A = {};
361
+ }, _ = (f, g) => p(f) ? J(f, g) : A(f) ? U(f, g) : G(f, g), J = (f, g) => {
362
+ const b = {};
363
363
  for (const C of f) {
364
364
  if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
365
- const E = C.charCodeAt(0);
366
- A[E] = !0;
365
+ const P = C.charCodeAt(0);
366
+ b[P] = !0;
367
367
  }
368
368
  return (C) => {
369
- const E = C.index, I = C.input;
370
- for (; C.index < I.length && I.charCodeAt(C.index) in A; ) C.index += 1;
371
- const R = C.index;
372
- if (R > E) {
373
- if (!b(g) && !C.options.silent) {
374
- const q = C.input.slice(E, R), j = c(g) ? g(q, I, String(E)) : g;
375
- b(j) || C.output.push(j);
369
+ const P = C.index, k = C.input;
370
+ for (; C.index < k.length && k.charCodeAt(C.index) in b; ) C.index += 1;
371
+ const L = C.index;
372
+ if (L > P) {
373
+ if (!S(g) && !C.options.silent) {
374
+ const q = C.input.slice(P, L), j = c(g) ? g(q, k, String(P)) : g;
375
+ S(j) || C.output.push(j);
376
376
  }
377
377
  C.indexMax = Math.max(C.indexMax, C.index);
378
378
  }
379
379
  return !0;
380
380
  };
381
381
  }, G = (f, g) => {
382
- const A = f.source, C = f.flags.replace(/y|$/, "y"), E = new RegExp(A, C);
383
- return ne((I) => {
384
- E.lastIndex = I.index;
385
- const R = E.exec(I.input);
386
- if (R) {
387
- if (!b(g) && !I.options.silent) {
388
- const q = c(g) ? g(...R, I.input, String(I.index)) : g;
389
- b(q) || I.output.push(q);
382
+ const b = f.source, C = f.flags.replace(/y|$/, "y"), P = new RegExp(b, C);
383
+ return ae((k) => {
384
+ P.lastIndex = k.index;
385
+ const L = P.exec(k.input);
386
+ if (L) {
387
+ if (!S(g) && !k.options.silent) {
388
+ const q = c(g) ? g(...L, k.input, String(k.index)) : g;
389
+ S(q) || k.output.push(q);
390
390
  }
391
- return I.index += R[0].length, I.indexMax = Math.max(I.indexMax, I.index), !0;
391
+ return k.index += L[0].length, k.indexMax = Math.max(k.indexMax, k.index), !0;
392
392
  } else return !1;
393
393
  });
394
- }, U = (f, g) => (A) => {
395
- if (A.input.startsWith(f, A.index)) {
396
- if (!b(g) && !A.options.silent) {
397
- const C = c(g) ? g(f, A.input, String(A.index)) : g;
398
- b(C) || A.output.push(C);
394
+ }, U = (f, g) => (b) => {
395
+ if (b.input.startsWith(f, b.index)) {
396
+ if (!S(g) && !b.options.silent) {
397
+ const C = c(g) ? g(f, b.input, String(b.index)) : g;
398
+ S(C) || b.output.push(C);
399
399
  }
400
- return A.index += f.length, A.indexMax = Math.max(A.indexMax, A.index), !0;
400
+ return b.index += f.length, b.indexMax = Math.max(b.indexMax, b.index), !0;
401
401
  } else return !1;
402
- }, W = (f, g, A, C) => {
403
- const E = z(f);
404
- return ne(ue(ye((I) => {
405
- let R = 0;
406
- for (; R < A; ) {
407
- const q = I.index;
408
- if (!E(I) || (R += 1, I.index === q)) break;
402
+ }, W = (f, g, b, C) => {
403
+ const P = V(f);
404
+ return ae(he(be((k) => {
405
+ let L = 0;
406
+ for (; L < b; ) {
407
+ const q = k.index;
408
+ if (!P(k) || (L += 1, k.index === q)) break;
409
409
  }
410
- return R >= g;
410
+ return L >= g;
411
411
  })));
412
- }, Z = (f, g) => W(f, 0, 1), X = (f, g) => W(f, 0, 1 / 0), re = (f, g) => {
413
- const A = f.map(z);
414
- return ne(ue(ye((C) => {
415
- for (let E = 0, I = A.length; E < I; E++) if (!A[E](C)) return !1;
412
+ }, Z = (f, g) => W(f, 0, 1), X = (f, g) => W(f, 0, 1 / 0), ne = (f, g) => {
413
+ const b = f.map(V);
414
+ return ae(he(be((C) => {
415
+ for (let P = 0, k = b.length; P < k; P++) if (!b[P](C)) return !1;
416
416
  return !0;
417
417
  })));
418
- }, V = (f, g) => {
419
- const A = f.map(z);
420
- return ne(ue((C) => {
421
- for (let E = 0, I = A.length; E < I; E++) if (A[E](C)) return !0;
418
+ }, z = (f, g) => {
419
+ const b = f.map(V);
420
+ return ae(he((C) => {
421
+ for (let P = 0, k = b.length; P < k; P++) if (b[P](C)) return !0;
422
422
  return !1;
423
423
  }));
424
- }, ye = (f, g = !1) => {
425
- const A = z(f);
424
+ }, be = (f, g = !1) => {
425
+ const b = V(f);
426
426
  return (C) => {
427
- const E = C.index, I = C.output.length, R = A(C);
428
- return (!R || g) && (C.index = E, C.output.length !== I && (C.output.length = I)), R;
427
+ const P = C.index, k = C.output.length, L = b(C);
428
+ return (!L || g) && (C.index = P, C.output.length !== k && (C.output.length = k)), L;
429
429
  };
430
- }, ue = (f, g) => z(f), ne = /* @__PURE__ */ (() => {
430
+ }, he = (f, g) => V(f), ae = /* @__PURE__ */ (() => {
431
431
  let f = 0;
432
432
  return (g) => {
433
- const A = z(g), C = f += 1;
434
- return (E) => {
435
- var lt;
436
- var I;
437
- if (E.options.memoization === !1) return A(E);
438
- const R = E.index, q = (I = E.cache)[C] || (I[C] = /* @__PURE__ */ new Map()), j = q.get(R);
433
+ const b = V(g), C = f += 1;
434
+ return (P) => {
435
+ var ct;
436
+ var k;
437
+ if (P.options.memoization === !1) return b(P);
438
+ const L = P.index, q = (k = P.cache)[C] || (k[C] = /* @__PURE__ */ new Map()), j = q.get(L);
439
439
  if (j === !1) return !1;
440
- if (m(j)) return E.index = j, !0;
441
- if (j) return E.index = j.index, (lt = j.output) != null && lt.length && E.output.push(...j.output), !0;
440
+ if (m(j)) return P.index = j, !0;
441
+ if (j) return P.index = j.index, (ct = j.output) != null && ct.length && P.output.push(...j.output), !0;
442
442
  {
443
- const ct = E.output.length;
444
- if (A(E)) {
445
- const dt = E.index, ut = E.output.length;
446
- if (ut > ct) {
447
- const en = E.output.slice(ct, ut);
448
- q.set(R, { index: dt, output: en });
449
- } else q.set(R, dt);
443
+ const dt = P.output.length;
444
+ if (b(P)) {
445
+ const ut = P.index, ht = P.output.length;
446
+ if (ht > dt) {
447
+ const rn = P.output.slice(dt, ht);
448
+ q.set(L, { index: ut, output: rn });
449
+ } else q.set(L, ut);
450
450
  return !0;
451
- } else return q.set(R, !1), !1;
451
+ } else return q.set(L, !1), !1;
452
452
  }
453
453
  };
454
454
  };
455
455
  })(), B = (f) => {
456
456
  let g;
457
- return (A) => (g || (g = z(f())), g(A));
458
- }, z = P((f) => {
457
+ return (b) => (g || (g = V(f())), g(b));
458
+ }, V = E((f) => {
459
459
  if (c(f)) return u(f) ? B(f) : f;
460
- if (y(f) || v(f)) return _(f);
461
- if (p(f)) return re(f);
462
- if (w(f)) return V(Object.values(f));
460
+ if (A(f) || w(f)) return _(f);
461
+ if (p(f)) return ne(f);
462
+ if (y(f)) return z(Object.values(f));
463
463
  throw new Error("Invalid rule");
464
- }), ae = "abcdefghijklmnopqrstuvwxyz", Te = (f) => {
464
+ }), ie = "abcdefghijklmnopqrstuvwxyz", Te = (f) => {
465
465
  let g = "";
466
466
  for (; f > 0; ) {
467
- const A = (f - 1) % 26;
468
- g = ae[A] + g, f = Math.floor((f - 1) / 26);
467
+ const b = (f - 1) % 26;
468
+ g = ie[b] + g, f = Math.floor((f - 1) / 26);
469
469
  }
470
470
  return g;
471
471
  }, H = (f) => {
472
472
  let g = 0;
473
- for (let A = 0, C = f.length; A < C; A++) g = g * 26 + ae.indexOf(f[A]) + 1;
473
+ for (let b = 0, C = f.length; b < C; b++) g = g * 26 + ie.indexOf(f[b]) + 1;
474
474
  return g;
475
475
  }, Be = (f, g) => {
476
476
  if (g < f) return Be(g, f);
477
- const A = [];
478
- for (; f <= g; ) A.push(f++);
479
- return A;
480
- }, ir = (f, g, A) => Be(f, g).map((C) => String(C).padStart(A, "0")), Qe = (f, g) => Be(H(f), H(g)).map(Te), J = (f) => f, et = (f) => sr((g) => L(g, f, { memoization: !1 }).join("")), sr = (f) => {
477
+ const b = [];
478
+ for (; f <= g; ) b.push(f++);
479
+ return b;
480
+ }, or = (f, g, b) => Be(f, g).map((C) => String(C).padStart(b, "0")), et = (f, g) => Be(H(f), H(g)).map(Te), Y = (f) => f, tt = (f) => lr((g) => T(g, f, { memoization: !1 }).join("")), lr = (f) => {
481
481
  const g = {};
482
- return (A) => g[A] ?? (g[A] = f(A));
483
- }, or = _(/^\*\*\/\*$/, ".*"), lr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, A) => `.*${g ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}`), cr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, A, C) => `.*${g ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), De = _(/\\./, J), dr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), ur = _(/./, J), hr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${ot(g)}$).*?`), fr = _(/^(!!)+/, ""), mr = V([hr, fr]), pr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = _(/^(\*\*\/)+/, "(?:^|.*/)"), wr = _(/\/(\*\*)$/, "(?:/.*|$)"), vr = _(/\*\*/, ".*"), tt = V([pr, gr, wr, vr]), yr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), Ar = _(/\*/, "[^/]*"), rt = V([yr, Ar]), nt = _("?", "[^/]"), Sr = _("[", J), br = _("]", J), Cr = _(/[!^]/, "^/"), _r = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, J), Er = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Pr = _(/[^\]]/, J), Ir = V([De, Er, _r, Pr]), at = re([Sr, Z(Cr), X(Ir), br]), xr = _("{", "(?:"), kr = _("}", ")"), Mr = _(/(\d+)\.\.(\d+)/, (f, g, A) => ir(+g, +A, Math.min(g.length, A.length)).join("|")), Fr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, A) => Qe(g, A).join("|")), Rr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, A) => Qe(g.toLowerCase(), A.toLowerCase()).join("|").toUpperCase()), Lr = V([Mr, Fr, Rr]), it = re([xr, Lr, kr]), Tr = _("{", "(?:"), Br = _("}", ")"), Dr = _(",", "|"), Or = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Nr = _(/[^}]/, J), Ur = B(() => st), Vr = V([tt, rt, nt, at, it, Ur, De, Or, Dr, Nr]), st = re([Tr, X(Vr), Br]), zr = X(V([or, lr, cr, mr, tt, rt, nt, at, it, st, De, dr, ur])), $r = zr, qr = et($r), ot = qr, Gr = _(/\\./, J), Wr = _(/./, J), Hr = _(/\*\*\*+/, "*"), jr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Kr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Xr = X(V([Gr, Hr, jr, Kr, Wr])), Jr = Xr, Yr = et(Jr), Zr = Yr, Oe = (f, g) => {
484
- const A = Array.isArray(f) ? f : [f];
485
- if (!A.length) return !1;
486
- const C = A.map(Oe.compile), E = A.every((R) => /(\/(?:\*\*)?|\[\/\])$/.test(R)), I = g.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
487
- return C.some((R) => R.test(I));
482
+ return (b) => g[b] ?? (g[b] = f(b));
483
+ }, cr = _(/^\*\*\/\*$/, ".*"), dr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, b) => `.*${g ? "" : "(?:^|/)"}${b.replaceAll(".", "\\.")}`), ur = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, b, C) => `.*${g ? "" : "(?:^|/)"}${b.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), De = _(/\\./, Y), hr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), fr = _(/./, Y), mr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${lt(g)}$).*?`), pr = _(/^(!!)+/, ""), gr = z([mr, pr]), yr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), vr = _(/^(\*\*\/)+/, "(?:^|.*/)"), wr = _(/\/(\*\*)$/, "(?:/.*|$)"), Ar = _(/\*\*/, ".*"), rt = z([yr, vr, wr, Ar]), br = _(/\*\/(?!\*\*\/)/, "[^/]*/"), Sr = _(/\*/, "[^/]*"), nt = z([br, Sr]), at = _("?", "[^/]"), Cr = _("[", Y), _r = _("]", Y), Pr = _(/[!^]/, "^/"), Er = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, Y), Ir = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), kr = _(/[^\]]/, Y), xr = z([De, Ir, Er, kr]), it = ne([Cr, Z(Pr), X(xr), _r]), Mr = _("{", "(?:"), Fr = _("}", ")"), Rr = _(/(\d+)\.\.(\d+)/, (f, g, b) => or(+g, +b, Math.min(g.length, b.length)).join("|")), Lr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, b) => et(g, b).join("|")), Tr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, b) => et(g.toLowerCase(), b.toLowerCase()).join("|").toUpperCase()), Br = z([Rr, Lr, Tr]), st = ne([Mr, Br, Fr]), Dr = _("{", "(?:"), Or = _("}", ")"), Nr = _(",", "|"), Ur = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), zr = _(/[^}]/, Y), Vr = B(() => ot), $r = z([rt, nt, at, it, st, Vr, De, Ur, Nr, zr]), ot = ne([Dr, X($r), Or]), qr = X(z([cr, dr, ur, gr, rt, nt, at, it, st, ot, De, hr, fr])), Gr = qr, Wr = tt(Gr), lt = Wr, Hr = _(/\\./, Y), jr = _(/./, Y), Kr = _(/\*\*\*+/, "*"), Xr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Yr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Jr = X(z([Hr, Kr, Xr, Yr, jr])), Zr = Jr, Qr = tt(Zr), en = Qr, Oe = (f, g) => {
484
+ const b = Array.isArray(f) ? f : [f];
485
+ if (!b.length) return !1;
486
+ const C = b.map(Oe.compile), P = b.every((L) => /(\/(?:\*\*)?|\[\/\])$/.test(L)), k = g.replace(/[\\\/]+/g, "/").replace(/\/$/, P ? "/" : "");
487
+ return C.some((L) => L.test(k));
488
488
  };
489
- Oe.compile = (f) => new RegExp(`^${ot(Zr(f))}$`, "s");
490
- var Qr = Oe;
491
- return l(o);
489
+ Oe.compile = (f) => new RegExp(`^${lt(en(f))}$`, "s");
490
+ var tn = Oe;
491
+ return o(l);
492
492
  })();
493
493
  return r.default || r;
494
494
  }, Ue;
495
- const hn = (r, e) => (Ue || (Ue = mt(), mt = null), Ue(r, e)), fn = /^[A-Za-z]:\//;
496
- function ce(r = "") {
497
- return r && r.replace(/\\/g, "/").replace(fn, (e) => e.toUpperCase());
495
+ const mn = (r, e) => (Ue || (Ue = pt(), pt = null), Ue(r, e)), pn = /^[A-Za-z]:\//;
496
+ function de(r = "") {
497
+ return r && r.replace(/\\/g, "/").replace(pn, (e) => e.toUpperCase());
498
498
  }
499
- const mn = /^[/\\]{2}/, pn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Gt = /^[A-Za-z]:$/, pt = /^\/([A-Za-z]:)?$/, gn = /.(\.[^./]+|\.)$/, wn = /^[/\\]|^[a-zA-Z]:[/\\]/, vn = "/", Xe = function(r) {
499
+ const gn = /^[/\\]{2}/, yn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/, gt = /^\/([A-Za-z]:)?$/, vn = /.(\.[^./]+|\.)$/, wn = /^[/\\]|^[a-zA-Z]:[/\\]/, An = "/", Ye = function(r) {
500
500
  if (r.length === 0)
501
501
  return ".";
502
- r = ce(r);
503
- const e = r.match(mn), t = ve(r), n = r[r.length - 1] === "/";
504
- return r = Je(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Gt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !ve(r) ? `/${r}` : r);
505
- }, yn = function(...r) {
502
+ r = de(r);
503
+ const e = r.match(gn), t = Ae(r), n = r[r.length - 1] === "/";
504
+ return r = Je(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Wt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !Ae(r) ? `/${r}` : r);
505
+ }, bn = function(...r) {
506
506
  let e = "";
507
507
  for (const t of r)
508
508
  if (t)
@@ -511,60 +511,60 @@ const mn = /^[/\\]{2}/, pn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
511
511
  n && a ? e += t.slice(1) : e += n || a ? t : `/${t}`;
512
512
  } else
513
513
  e += t;
514
- return Xe(e);
514
+ return Ye(e);
515
515
  };
516
- function An() {
516
+ function Sn() {
517
517
  return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
518
518
  }
519
519
  const Fe = function(...r) {
520
- r = r.map((n) => ce(n));
520
+ r = r.map((n) => de(n));
521
521
  let e = "", t = !1;
522
522
  for (let n = r.length - 1; n >= -1 && !t; n--) {
523
- const a = n >= 0 ? r[n] : An();
524
- !a || a.length === 0 || (e = `${a}/${e}`, t = ve(a));
523
+ const a = n >= 0 ? r[n] : Sn();
524
+ !a || a.length === 0 || (e = `${a}/${e}`, t = Ae(a));
525
525
  }
526
- return e = Je(e, !t), t && !ve(e) ? `/${e}` : e.length > 0 ? e : ".";
526
+ return e = Je(e, !t), t && !Ae(e) ? `/${e}` : e.length > 0 ? e : ".";
527
527
  };
528
528
  function Je(r, e) {
529
529
  let t = "", n = 0, a = -1, i = 0, s = null;
530
- for (let l = 0; l <= r.length; ++l) {
531
- if (l < r.length)
532
- s = r[l];
530
+ for (let o = 0; o <= r.length; ++o) {
531
+ if (o < r.length)
532
+ s = r[o];
533
533
  else {
534
534
  if (s === "/")
535
535
  break;
536
536
  s = "/";
537
537
  }
538
538
  if (s === "/") {
539
- if (!(a === l - 1 || i === 1)) if (i === 2) {
539
+ if (!(a === o - 1 || i === 1)) if (i === 2) {
540
540
  if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
541
541
  if (t.length > 2) {
542
- const o = t.lastIndexOf("/");
543
- o === -1 ? (t = "", n = 0) : (t = t.slice(0, o), n = t.length - 1 - t.lastIndexOf("/")), a = l, i = 0;
542
+ const l = t.lastIndexOf("/");
543
+ l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), a = o, i = 0;
544
544
  continue;
545
545
  } else if (t.length > 0) {
546
- t = "", n = 0, a = l, i = 0;
546
+ t = "", n = 0, a = o, i = 0;
547
547
  continue;
548
548
  }
549
549
  }
550
550
  e && (t += t.length > 0 ? "/.." : "..", n = 2);
551
551
  } else
552
- t.length > 0 ? t += `/${r.slice(a + 1, l)}` : t = r.slice(a + 1, l), n = l - a - 1;
553
- a = l, i = 0;
552
+ t.length > 0 ? t += `/${r.slice(a + 1, o)}` : t = r.slice(a + 1, o), n = o - a - 1;
553
+ a = o, i = 0;
554
554
  } else s === "." && i !== -1 ? ++i : i = -1;
555
555
  }
556
556
  return t;
557
557
  }
558
- const ve = function(r) {
559
- return pn.test(r);
560
- }, Sn = function(r) {
561
- return ce(r);
562
- }, Wt = function(r) {
558
+ const Ae = function(r) {
559
+ return yn.test(r);
560
+ }, Cn = function(r) {
561
+ return de(r);
562
+ }, Ht = function(r) {
563
563
  if (r === "..") return "";
564
- const e = gn.exec(ce(r));
564
+ const e = vn.exec(de(r));
565
565
  return e && e[1] || "";
566
- }, bn = function(r, e) {
567
- const t = Fe(r).replace(pt, "$1").split("/"), n = Fe(e).replace(pt, "$1").split("/");
566
+ }, _n = function(r, e) {
567
+ const t = Fe(r).replace(gt, "$1").split("/"), n = Fe(e).replace(gt, "$1").split("/");
568
568
  if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
569
569
  return n.join("/");
570
570
  const a = [...t];
@@ -574,18 +574,18 @@ const ve = function(r) {
574
574
  t.shift(), n.shift();
575
575
  }
576
576
  return [...t.map(() => ".."), ...n].join("/");
577
- }, Ht = function(r) {
578
- const e = ce(r).replace(/\/$/, "").split("/").slice(0, -1);
579
- return e.length === 1 && Gt.test(e[0]) && (e[0] += "/"), e.join("/") || (ve(r) ? "/" : ".");
580
- }, Cn = function(r) {
577
+ }, jt = function(r) {
578
+ const e = de(r).replace(/\/$/, "").split("/").slice(0, -1);
579
+ return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (Ae(r) ? "/" : ".");
580
+ }, Pn = function(r) {
581
581
  const e = r.ext ? r.ext.startsWith(".") ? r.ext : `.${r.ext}` : "", t = [r.root, r.dir, r.base ?? (r.name ?? "") + e].filter(
582
582
  Boolean
583
583
  );
584
- return ce(
584
+ return de(
585
585
  r.root ? Fe(...t) : t.join("/")
586
586
  );
587
- }, jt = function(r, e) {
588
- const t = ce(r).split("/");
587
+ }, Kt = function(r, e) {
588
+ const t = de(r).split("/");
589
589
  let n = "";
590
590
  for (let a = t.length - 1; a >= 0; a--) {
591
591
  const i = t[a];
@@ -595,101 +595,101 @@ const ve = function(r) {
595
595
  }
596
596
  }
597
597
  return e && n.endsWith(e) ? n.slice(0, -e.length) : n;
598
- }, _n = function(r) {
598
+ }, En = function(r) {
599
599
  var a, i;
600
- const e = ((i = (a = wn.exec(r)) == null ? void 0 : a[0]) == null ? void 0 : i.replace(/\\/g, "/")) || "", t = jt(r), n = Wt(t);
600
+ const e = ((i = (a = wn.exec(r)) == null ? void 0 : a[0]) == null ? void 0 : i.replace(/\\/g, "/")) || "", t = Kt(r), n = Ht(t);
601
601
  return {
602
602
  root: e,
603
- dir: Ht(r),
603
+ dir: jt(r),
604
604
  base: t,
605
605
  ext: n,
606
606
  name: t.slice(0, t.length - n.length)
607
607
  };
608
- }, En = (r, e) => hn(e, Xe(r)), gt = {
608
+ }, In = (r, e) => mn(e, Ye(r)), yt = {
609
609
  __proto__: null,
610
- basename: jt,
611
- dirname: Ht,
612
- extname: Wt,
613
- format: Cn,
614
- isAbsolute: ve,
615
- join: yn,
616
- matchesGlob: En,
617
- normalize: Xe,
610
+ basename: Kt,
611
+ dirname: jt,
612
+ extname: Ht,
613
+ format: Pn,
614
+ isAbsolute: Ae,
615
+ join: bn,
616
+ matchesGlob: In,
617
+ normalize: Ye,
618
618
  normalizeString: Je,
619
- parse: _n,
620
- relative: bn,
619
+ parse: En,
620
+ relative: _n,
621
621
  resolve: Fe,
622
- sep: vn,
623
- toNamespacedPath: Sn
624
- }, Pn = /* @__PURE__ */ (() => {
622
+ sep: An,
623
+ toNamespacedPath: Cn
624
+ }, kn = /* @__PURE__ */ (() => {
625
625
  var r;
626
626
  return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
627
- })(), In = { posix: void 0, win32: void 0 }, Kt = (r = Pn) => new Proxy(gt, {
627
+ })(), xn = { posix: void 0, win32: void 0 }, Xt = (r = kn) => new Proxy(yt, {
628
628
  get(e, t) {
629
- return t === "delimiter" ? r : t === "posix" ? We : t === "win32" ? xn : In[t] || gt[t];
629
+ return t === "delimiter" ? r : t === "posix" ? He : t === "win32" ? Mn : xn[t] || yt[t];
630
630
  }
631
- }), We = /* @__PURE__ */ Kt(":"), xn = /* @__PURE__ */ Kt(";");
632
- var M = /* @__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))(M || {}), k = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(k || {}), te = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(te || {});
633
- const kn = !0;
634
- function F(r, e, t = r) {
631
+ }), He = /* @__PURE__ */ Xt(":"), Mn = /* @__PURE__ */ Xt(";");
632
+ var M = /* @__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))(M || {}), 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 || {});
633
+ const Fn = !0;
634
+ function R(r, e, t = r) {
635
635
  return (n) => {
636
636
  const a = `${n}`, i = a.indexOf(e, r.length);
637
- return ~i ? r + Xt(a, e, t, i) + e : r + a + e;
637
+ return ~i ? r + Yt(a, e, t, i) + e : r + a + e;
638
638
  };
639
639
  }
640
- function Xt(r, e, t, n) {
640
+ function Yt(r, e, t, n) {
641
641
  const a = r.substring(0, n) + t, i = r.substring(n + e.length), s = i.indexOf(e);
642
- return ~s ? a + Xt(i, e, t, s) : a + i;
642
+ return ~s ? a + Yt(i, e, t, s) : a + i;
643
643
  }
644
- function Mn(r = kn) {
644
+ function Rn(r = Fn) {
645
645
  return {
646
646
  isColorSupported: r,
647
647
  reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
648
- bold: r ? F("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
649
- dim: r ? F("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
650
- italic: r ? F("\x1B[3m", "\x1B[23m") : String,
651
- underline: r ? F("\x1B[4m", "\x1B[24m") : String,
652
- inverse: r ? F("\x1B[7m", "\x1B[27m") : String,
653
- hidden: r ? F("\x1B[8m", "\x1B[28m") : String,
654
- strikethrough: r ? F("\x1B[9m", "\x1B[29m") : String,
655
- black: r ? F("\x1B[30m", "\x1B[39m") : String,
656
- red: r ? F("\x1B[31m", "\x1B[39m") : String,
657
- green: r ? F("\x1B[32m", "\x1B[39m") : String,
658
- yellow: r ? F("\x1B[33m", "\x1B[39m") : String,
659
- blue: r ? F("\x1B[34m", "\x1B[39m") : String,
660
- magenta: r ? F("\x1B[35m", "\x1B[39m") : String,
661
- cyan: r ? F("\x1B[36m", "\x1B[39m") : String,
662
- white: r ? F("\x1B[37m", "\x1B[39m") : String,
663
- gray: r ? F("\x1B[90m", "\x1B[39m") : String,
664
- bgBlack: r ? F("\x1B[40m", "\x1B[49m") : String,
665
- bgRed: r ? F("\x1B[41m", "\x1B[49m") : String,
666
- bgGreen: r ? F("\x1B[42m", "\x1B[49m") : String,
667
- bgYellow: r ? F("\x1B[43m", "\x1B[49m") : String,
668
- bgBlue: r ? F("\x1B[44m", "\x1B[49m") : String,
669
- bgMagenta: r ? F("\x1B[45m", "\x1B[49m") : String,
670
- bgCyan: r ? F("\x1B[46m", "\x1B[49m") : String,
671
- bgWhite: r ? F("\x1B[47m", "\x1B[49m") : String
648
+ bold: r ? R("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
649
+ dim: r ? R("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
650
+ italic: r ? R("\x1B[3m", "\x1B[23m") : String,
651
+ underline: r ? R("\x1B[4m", "\x1B[24m") : String,
652
+ inverse: r ? R("\x1B[7m", "\x1B[27m") : String,
653
+ hidden: r ? R("\x1B[8m", "\x1B[28m") : String,
654
+ strikethrough: r ? R("\x1B[9m", "\x1B[29m") : String,
655
+ black: r ? R("\x1B[30m", "\x1B[39m") : String,
656
+ red: r ? R("\x1B[31m", "\x1B[39m") : String,
657
+ green: r ? R("\x1B[32m", "\x1B[39m") : String,
658
+ yellow: r ? R("\x1B[33m", "\x1B[39m") : String,
659
+ blue: r ? R("\x1B[34m", "\x1B[39m") : String,
660
+ magenta: r ? R("\x1B[35m", "\x1B[39m") : String,
661
+ cyan: r ? R("\x1B[36m", "\x1B[39m") : String,
662
+ white: r ? R("\x1B[37m", "\x1B[39m") : String,
663
+ gray: r ? R("\x1B[90m", "\x1B[39m") : String,
664
+ bgBlack: r ? R("\x1B[40m", "\x1B[49m") : String,
665
+ bgRed: r ? R("\x1B[41m", "\x1B[49m") : String,
666
+ bgGreen: r ? R("\x1B[42m", "\x1B[49m") : String,
667
+ bgYellow: r ? R("\x1B[43m", "\x1B[49m") : String,
668
+ bgBlue: r ? R("\x1B[44m", "\x1B[49m") : String,
669
+ bgMagenta: r ? R("\x1B[45m", "\x1B[49m") : String,
670
+ bgCyan: r ? R("\x1B[46m", "\x1B[49m") : String,
671
+ bgWhite: r ? R("\x1B[47m", "\x1B[49m") : String
672
672
  };
673
673
  }
674
- const D = Mn(), He = {
675
- [k.Error]: M.Error,
676
- [k.Warning]: M.Warning,
677
- [k.Log]: M.Log,
678
- [k.Verbose]: M.Verbose,
679
- [k.Debug]: M.Debug
680
- }, Fn = {
681
- [M.Error]: k.Error,
682
- [M.Warning]: k.Warning,
683
- [M.Log]: k.Log,
684
- [M.Verbose]: k.Verbose,
685
- [M.Debug]: k.Debug
686
- }, wt = [
687
- k.Error,
688
- k.Warning,
689
- k.Log,
690
- k.Verbose,
691
- k.Debug
692
- ], Rn = {
674
+ const D = Rn(), je = {
675
+ [x.Error]: M.Error,
676
+ [x.Warning]: M.Warning,
677
+ [x.Log]: M.Log,
678
+ [x.Verbose]: M.Verbose,
679
+ [x.Debug]: M.Debug
680
+ }, Ln = {
681
+ [M.Error]: x.Error,
682
+ [M.Warning]: x.Warning,
683
+ [M.Log]: x.Log,
684
+ [M.Verbose]: x.Verbose,
685
+ [M.Debug]: x.Debug
686
+ }, vt = [
687
+ x.Error,
688
+ x.Warning,
689
+ x.Log,
690
+ x.Verbose,
691
+ x.Debug
692
+ ], Tn = {
693
693
  [M.Error]: D.red,
694
694
  [M.Warning]: D.yellow,
695
695
  [M.Log]: D.blue,
@@ -701,8 +701,8 @@ const D = Mn(), He = {
701
701
  M.Log,
702
702
  M.Verbose,
703
703
  M.Debug
704
- ], vt = [te.JSON, te.Pretty];
705
- function Ln(r) {
704
+ ], wt = [re.JSON, re.Pretty];
705
+ function Bn(r) {
706
706
  return r.stack == null ? [] : r.stack.split(`
707
707
  `).map((e) => e.trim()).slice(1).filter((e) => !!/^at (.*)( \(.*:(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e)).map((e) => {
708
708
  const t = /at (.*)( \((.*):(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e);
@@ -728,7 +728,7 @@ function Ln(r) {
728
728
  function Jt(r) {
729
729
  return r == null ? !1 : r instanceof Error;
730
730
  }
731
- function Yt(r, e, t, n, a) {
731
+ function Zt(r, e, t, n, a) {
732
732
  let i = { context: "" };
733
733
  typeof t < "u" && t !== null && (i = { ...t }), typeof e < "u" && e !== null && (i.context = e);
734
734
  const s = /* @__PURE__ */ new Date();
@@ -740,11 +740,11 @@ function Yt(r, e, t, n, a) {
740
740
  message: n
741
741
  };
742
742
  }
743
- function Tn(r, e, t, n, a, i) {
744
- const s = Yt(r, e, t, n, i);
743
+ function Dn(r, e, t, n, a, i) {
744
+ const s = Zt(r, e, t, n, i);
745
745
  return typeof a < "u" && a !== null && (s.errored = !0, s.error = { stack: a }), s;
746
746
  }
747
- function yt(r) {
747
+ function At(r) {
748
748
  let e = "";
749
749
  switch (typeof r) {
750
750
  case "number":
@@ -765,10 +765,10 @@ function yt(r) {
765
765
  }
766
766
  return e;
767
767
  }
768
- function Ie(r) {
768
+ function ke(r) {
769
769
  const e = [];
770
770
  e.push(r["@localetime"]), e.push(
771
- Rn[He[r.level]](
771
+ Tn[je[r.level]](
772
772
  `[${r.level}]`
773
773
  )
774
774
  );
@@ -777,57 +777,57 @@ function Ie(r) {
777
777
  const n = Object.entries(r.fields);
778
778
  n.length > 0 && e.push(" {");
779
779
  for (const [i, s] of n) {
780
- let l = s;
780
+ let o = s;
781
781
  if (Jt(s)) {
782
- if (s.message && (l = yt(s.message)), l || (l = ""), s.cause != null)
782
+ if (s.message && (o = At(s.message)), o || (o = ""), s.cause != null)
783
783
  try {
784
- l += JSON.stringify(s.cause);
784
+ o += JSON.stringify(s.cause);
785
785
  } catch {
786
- l += String(s.cause);
786
+ o += String(s.cause);
787
787
  }
788
788
  } else
789
- l = yt(s);
790
- e.push(`${D.gray(i)}${D.gray("=")}${l}`);
789
+ o = At(s);
790
+ e.push(`${D.gray(i)}${D.gray("=")}${o}`);
791
791
  }
792
792
  n.length > 0 && e.push("}");
793
793
  let a = e.join(" ");
794
794
  return r.errored != null && r.errored && r.error && r.error.stack != null && r.error.stack && (a += `
795
795
  ${r.error.stack}`), a;
796
796
  }
797
- function Bn(r) {
797
+ function On(r) {
798
798
  return r >= M.Debug;
799
799
  }
800
- function Dn(r) {
800
+ function Nn(r) {
801
801
  return r >= M.Verbose;
802
802
  }
803
- function On(r) {
803
+ function Un(r) {
804
804
  return r >= M.Log;
805
805
  }
806
- function Nn(r) {
806
+ function zn(r) {
807
807
  return r >= M.Warning;
808
808
  }
809
- function Un(r) {
809
+ function Vn(r) {
810
810
  return r >= M.Error;
811
811
  }
812
- function Zt() {
812
+ function Qt() {
813
813
  return typeof window < "u";
814
814
  }
815
- function Vn() {
816
- return !Zt() && je() === te.Pretty;
815
+ function $n() {
816
+ return !Qt() && Ke() === re.Pretty;
817
817
  }
818
- function zn(r, e) {
819
- return Vn() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
818
+ function qn(r, e) {
819
+ return $n() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
820
820
  }
821
821
  const Ee = {
822
822
  configured: !1,
823
823
  logLevel: M.Debug,
824
- format: te.JSON,
824
+ format: re.JSON,
825
825
  timeFormatter: (r) => r.toISOString()
826
826
  };
827
- function At() {
827
+ function bt() {
828
828
  return Ee.logLevel;
829
829
  }
830
- function $n(r) {
830
+ function Gn(r) {
831
831
  if (Re.includes(r))
832
832
  Ee.logLevel = r;
833
833
  else
@@ -838,24 +838,24 @@ function $n(r) {
838
838
  );
839
839
  Ee.configured = !0;
840
840
  }
841
- function je() {
841
+ function Ke() {
842
842
  return Ee.format;
843
843
  }
844
- function qn() {
844
+ function Wn() {
845
845
  return Ee.timeFormatter;
846
846
  }
847
- function Qt(r) {
847
+ function er(r) {
848
848
  const e = {
849
849
  fields: {},
850
850
  context: r,
851
851
  logLevel: M.Debug,
852
- format: te.JSON,
852
+ format: re.JSON,
853
853
  shouldUseGlobalConfig: !1,
854
854
  errorProcessor: (c) => c,
855
855
  timeFormatter: (c) => c.toISOString(),
856
- useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format = je(), e.logLevel = At(), e.child()),
856
+ useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format = Ke(), e.logLevel = bt(), e.child()),
857
857
  child: (c) => {
858
- const u = Qt(e.context);
858
+ const u = er(e.context);
859
859
  return c != null ? u.fields = { ...e.fields, ...c } : u.fields = e.fields, u.fields != null && "context" in u.fields ? u.context = u.fields.context : u.context = e.context, u.logLevel = e.logLevel, u.format = e.format, u.shouldUseGlobalConfig = e.shouldUseGlobalConfig, u;
860
860
  },
861
861
  withContext: (c) => {
@@ -866,7 +866,7 @@ function Qt(r) {
866
866
  const u = e.child();
867
867
  if (Re.includes(c))
868
868
  u.logLevel = c, u.shouldUseGlobalConfig = !1, u.debug(
869
- `setting log level to ${Fn[c]} (${c})`
869
+ `setting log level to ${Ln[c]} (${c})`
870
870
  );
871
871
  else
872
872
  throw new Error(
@@ -878,13 +878,13 @@ function Qt(r) {
878
878
  },
879
879
  withLogLevelString: (c) => {
880
880
  const u = e.child();
881
- if (wt.includes(c))
882
- u.logLevel = He[c], u.shouldUseGlobalConfig = !1, u.debug(
883
- `setting log level to ${c} (${He[c]})`
881
+ if (vt.includes(c))
882
+ u.logLevel = je[c], u.shouldUseGlobalConfig = !1, u.debug(
883
+ `setting log level to ${c} (${je[c]})`
884
884
  );
885
885
  else
886
886
  throw new Error(
887
- `log level ${c} is not available. available log levels are: ${wt.join(
887
+ `log level ${c} is not available. available log levels are: ${vt.join(
888
888
  ", "
889
889
  )}`
890
890
  );
@@ -892,11 +892,11 @@ function Qt(r) {
892
892
  },
893
893
  withFormat: (c) => {
894
894
  const u = e.child();
895
- if (vt.includes(c))
895
+ if (wt.includes(c))
896
896
  u.format = c, u.shouldUseGlobalConfig = !1, u.debug(`setting format to ${c}`);
897
897
  else
898
898
  throw new Error(
899
- `format ${c} is not available. available formats are: ${vt.join(
899
+ `format ${c} is not available. available formats are: ${wt.join(
900
900
  ", "
901
901
  )}`
902
902
  );
@@ -921,7 +921,7 @@ function Qt(r) {
921
921
  return u;
922
922
  },
923
923
  withCallStack(c) {
924
- const u = Ln(c).slice(2).filter((m) => !m.invalid);
924
+ const u = Bn(c).slice(2).filter((m) => !m.invalid);
925
925
  return u.length === 0 ? e : e.child({
926
926
  function: u[0].function,
927
927
  file: `${u[0].file}:${u[0].line}:${u[0].column}`,
@@ -952,97 +952,97 @@ function Qt(r) {
952
952
  const u = e.child();
953
953
  return u.errorProcessor = c, u;
954
954
  }
955
- }, t = () => e.shouldUseGlobalConfig ? At() : e.logLevel, n = () => e.shouldUseGlobalConfig ? je() : 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, s = (c, u, m) => {
956
- const w = n();
957
- if (Zt() && w === te.Pretty) {
955
+ }, t = () => e.shouldUseGlobalConfig ? bt() : e.logLevel, n = () => e.shouldUseGlobalConfig ? Ke() : e.format, a = () => e.shouldUseGlobalConfig ? Wn() : e.timeFormatter ?? ((c) => c.toISOString()), i = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields, s = (c, u, m) => {
956
+ const y = n();
957
+ if (Qt() && y === re.Pretty) {
958
958
  c.fields = Object.fromEntries(
959
- Object.entries(c.fields).filter(([b, P]) => {
960
- if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
961
- return [b, P];
959
+ Object.entries(c.fields).filter(([S, E]) => {
960
+ if (S === "isNestSystemModule" || S === "nestSystemModule" || S === "context")
961
+ return [S, E];
962
962
  })
963
963
  );
964
- const y = m ?? e.fields;
965
- Array.isArray(y) && y.length > 0 ? console[u](Ie(c), ...y) : Object.keys(y).length > 0 ? console[u](Ie(c), y) : console[u](Ie(c));
964
+ const A = m ?? e.fields;
965
+ Array.isArray(A) && A.length > 0 ? console[u](ke(c), ...A) : Object.keys(A).length > 0 ? console[u](ke(c), A) : console[u](ke(c));
966
966
  return;
967
967
  }
968
- const v = w === te.Pretty ? Ie(c) : JSON.stringify(c);
969
- console[u](v);
970
- }, l = {
971
- [k.Debug]: Bn,
972
- [k.Verbose]: Dn,
973
- [k.Log]: On,
974
- [k.Warning]: Nn
968
+ const w = y === re.Pretty ? ke(c) : JSON.stringify(c);
969
+ console[u](w);
975
970
  }, o = {
976
- [k.Debug]: "debug",
977
- [k.Verbose]: "log",
978
- [k.Log]: "log",
979
- [k.Warning]: "warn"
971
+ [x.Debug]: On,
972
+ [x.Verbose]: Nn,
973
+ [x.Log]: Un,
974
+ [x.Warning]: zn
975
+ }, l = {
976
+ [x.Debug]: "debug",
977
+ [x.Verbose]: "log",
978
+ [x.Log]: "log",
979
+ [x.Warning]: "warn"
980
980
  }, p = (c, u, m) => {
981
- const w = t(), v = l[c];
982
- if (!v(w))
981
+ const y = t(), w = o[c];
982
+ if (!w(y))
983
983
  return;
984
- const y = i(m), b = Yt(
984
+ const A = i(m), S = Zt(
985
985
  c,
986
986
  e.context,
987
- y,
987
+ A,
988
988
  u,
989
989
  a()
990
990
  );
991
- s(b, o[c], y);
991
+ s(S, l[c], A);
992
992
  };
993
993
  return e.debug = (c, ...u) => {
994
- p(k.Debug, c, u);
994
+ p(x.Debug, c, u);
995
995
  }, e.verbose = (c, ...u) => {
996
- p(k.Verbose, c, u);
996
+ p(x.Verbose, c, u);
997
997
  }, e.log = (c, ...u) => {
998
- p(k.Log, c, u);
998
+ p(x.Log, c, u);
999
999
  }, e.warn = (c, ...u) => {
1000
- p(k.Warning, c, u);
1000
+ p(x.Warning, c, u);
1001
1001
  }, e.error = (c, u, ...m) => {
1002
- const w = t();
1003
- if (!Un(w))
1002
+ const y = t();
1003
+ if (!Vn(y))
1004
1004
  return;
1005
- const v = i(m), y = Tn(
1006
- k.Error,
1005
+ const w = i(m), A = Dn(
1006
+ x.Error,
1007
1007
  e.context,
1008
- v,
1008
+ w,
1009
1009
  c,
1010
1010
  u,
1011
1011
  a()
1012
1012
  );
1013
- s(y, "error", v);
1013
+ s(A, "error", w);
1014
1014
  }, e.errorWithError = (c, u, ...m) => e.withError(u).error(c, void 0, ...m), e;
1015
1015
  }
1016
- function Gn(r) {
1016
+ function Hn(r) {
1017
1017
  var i;
1018
- const t = un.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a = We.join(...n.split(We.sep).slice(-2));
1019
- return r = r ?? `${a}:${t.lineNumber}`, Qt(zn(n, r));
1018
+ const t = fn.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a = He.join(...n.split(He.sep).slice(-2));
1019
+ return r = r ?? `${a}:${t.lineNumber}`, er(qn(n, r));
1020
1020
  }
1021
- const Wn = (r) => Gn(r).useGlobalConfig();
1021
+ const jn = (r) => Hn(r).useGlobalConfig();
1022
1022
  let Q = [];
1023
1023
  const St = 100;
1024
- async function Hn() {
1024
+ async function Kn() {
1025
1025
  if (Q.length === 0)
1026
1026
  return;
1027
1027
  const r = [...Q];
1028
1028
  Q = [];
1029
1029
  try {
1030
- await jn();
1030
+ await Xn();
1031
1031
  } catch (e) {
1032
1032
  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));
1033
1033
  }
1034
1034
  }
1035
- async function jn(r) {
1035
+ async function Xn(r) {
1036
1036
  }
1037
- function Kn() {
1038
- Q.length > 0 && Hn(), h.log("[CLS] Cleaned up");
1037
+ function Yn() {
1038
+ Q.length > 0 && Kn(), h.log("[CLS] Cleaned up");
1039
1039
  }
1040
- $n(M.Warning);
1041
- const h = Wn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
1040
+ Gn(M.Warning);
1041
+ const h = jn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
1042
1042
  config: null,
1043
1043
  promise: null
1044
1044
  };
1045
- async function Xn(r) {
1045
+ async function Jn(r) {
1046
1046
  return O.promise ? (await O.promise, O.config || {}) : O.config ? O.config : (O.promise = (async () => {
1047
1047
  try {
1048
1048
  const t = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") ? `/api/config/sdk?version=${r}` : `https://config.spatialwalk.top/sdk?version=${r}`;
@@ -1059,7 +1059,7 @@ async function Xn(r) {
1059
1059
  if (!a.endpoints)
1060
1060
  throw new Error("Invalid config response: missing endpoints");
1061
1061
  const i = {};
1062
- a.endpoints.cn && (i[le.cn] = `https://${a.endpoints.cn}`), a.endpoints.us && (i[le.us] = `https://${a.endpoints.us}`), a.endpoints.test && (i[le.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
1062
+ a.endpoints.cn && (i[ce.cn] = `https://${a.endpoints.cn}`), a.endpoints.us && (i[ce.us] = `https://${a.endpoints.us}`), a.endpoints.test && (i[ce.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
1063
1063
  } catch {
1064
1064
  O.config = {};
1065
1065
  } finally {
@@ -1067,10 +1067,10 @@ async function Xn(r) {
1067
1067
  }
1068
1068
  })(), await O.promise, O.config || {});
1069
1069
  }
1070
- function Jn() {
1070
+ function Zn() {
1071
1071
  O.config = null, O.promise = null;
1072
1072
  }
1073
- class Yn {
1073
+ class Qn {
1074
1074
  constructor(e) {
1075
1075
  d(this, "module");
1076
1076
  d(this, "allocatedPointers");
@@ -1102,9 +1102,9 @@ class Yn {
1102
1102
  throw new Error("teethPb is missing or empty!");
1103
1103
  if (!e.teethNpz || e.teethNpz.byteLength === 0)
1104
1104
  throw new Error("teethNpz is missing or empty!");
1105
- const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate), s = this.allocateAndCopy(e.teethPb), l = this.allocateAndCopy(e.teethNpz);
1106
- let o = 0;
1107
- return this.module.setValue(n + o, a.ptr, "i32"), o += 4, this.module.setValue(n + o, a.size, "i32"), o += 4, this.module.setValue(n + o, i.ptr, "i32"), o += 4, this.module.setValue(n + o, i.size, "i32"), o += 4, this.module.setValue(n + o, s.ptr, "i32"), o += 4, this.module.setValue(n + o, s.size, "i32"), o += 4, this.module.setValue(n + o, l.ptr, "i32"), o += 4, this.module.setValue(n + o, l.size, "i32"), o += 4, this.module.setValue(n + o, 0, "i32"), o += 4, this.module.setValue(n + o, 0, "i32"), o += 4, this.structPointers.set("template_config", n), n;
1105
+ const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate), s = this.allocateAndCopy(e.teethPb), o = this.allocateAndCopy(e.teethNpz);
1106
+ let l = 0;
1107
+ return this.module.setValue(n + l, a.ptr, "i32"), l += 4, this.module.setValue(n + l, a.size, "i32"), l += 4, this.module.setValue(n + l, i.ptr, "i32"), l += 4, this.module.setValue(n + l, i.size, "i32"), l += 4, this.module.setValue(n + l, s.ptr, "i32"), l += 4, this.module.setValue(n + l, s.size, "i32"), l += 4, this.module.setValue(n + l, o.ptr, "i32"), l += 4, this.module.setValue(n + l, o.size, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.structPointers.set("template_config", n), n;
1108
1108
  }
1109
1109
  /**
1110
1110
  * 创建 AvatarCharacterData 结构体 - 新版 Emscripten 方式
@@ -1113,11 +1113,11 @@ class Yn {
1113
1113
  const i = this.module._malloc(16);
1114
1114
  if (!i)
1115
1115
  throw new Error("Failed to allocate AvatarCharacterData structure");
1116
- const s = this.allocateAndCopy(e), l = this.allocateAndCopy(t);
1117
- let o = 0;
1118
- this.module.setValue(i + o, s.ptr, "i32"), o += 4, this.module.setValue(i + o, s.size, "i32"), o += 4, this.module.setValue(i + o, l.ptr, "i32"), o += 4, this.module.setValue(i + o, l.size, "i32"), o += 4;
1116
+ const s = this.allocateAndCopy(e), o = this.allocateAndCopy(t);
1117
+ let l = 0;
1118
+ this.module.setValue(i + l, s.ptr, "i32"), l += 4, this.module.setValue(i + l, s.size, "i32"), l += 4, this.module.setValue(i + l, o.ptr, "i32"), l += 4, this.module.setValue(i + l, o.size, "i32"), l += 4;
1119
1119
  const p = n ? `character_data_${n}` : "character_data";
1120
- return this.structPointers.set(p, i), { dataPtr: i, shapePtr: s.ptr, plyPtr: l.ptr };
1120
+ return this.structPointers.set(p, i), { dataPtr: i, shapePtr: s.ptr, plyPtr: o.ptr };
1121
1121
  }
1122
1122
  /**
1123
1123
  * 读取 AvatarFlameParams 结构体数据
@@ -1137,12 +1137,12 @@ class Yn {
1137
1137
  const s = [];
1138
1138
  for (let m = 0; m < 3; m++)
1139
1139
  s.push(this.module.getValue(e + t, "float")), t += 4;
1140
- const l = [];
1141
- for (let m = 0; m < 3; m++)
1142
- l.push(this.module.getValue(e + t, "float")), t += 4;
1143
1140
  const o = [];
1144
1141
  for (let m = 0; m < 3; m++)
1145
1142
  o.push(this.module.getValue(e + t, "float")), t += 4;
1143
+ const l = [];
1144
+ for (let m = 0; m < 3; m++)
1145
+ l.push(this.module.getValue(e + t, "float")), t += 4;
1146
1146
  const p = [];
1147
1147
  for (let m = 0; m < 6; m++)
1148
1148
  p.push(this.module.getValue(e + t, "float")), t += 4;
@@ -1155,8 +1155,8 @@ class Yn {
1155
1155
  expr_params: a,
1156
1156
  rotation: i,
1157
1157
  translation: s,
1158
- neck_pose: l,
1159
- jaw_pose: o,
1158
+ neck_pose: o,
1159
+ jaw_pose: l,
1160
1160
  eyes_pose: p,
1161
1161
  eyelid: c,
1162
1162
  has_eyelid: u
@@ -1166,42 +1166,42 @@ class Yn {
1166
1166
  * 创建 AvatarFlameParams 结构体 - 新版 Emscripten 方式
1167
1167
  */
1168
1168
  createFlameParams(e) {
1169
- var i, s, l, o, p, c, u, m;
1169
+ var i, s, o, l, p, c, u, m;
1170
1170
  const n = this.module._malloc(1684);
1171
1171
  if (!n)
1172
1172
  throw new Error("Failed to allocate AvatarFlameParams structure");
1173
1173
  let a = 0;
1174
- for (let w = 0; w < 300; w++) {
1175
- const v = ((i = e.shape_params) == null ? void 0 : i[w]) || 0;
1176
- this.module.setValue(n + a, v, "float"), a += 4;
1174
+ for (let y = 0; y < 300; y++) {
1175
+ const w = ((i = e.shape_params) == null ? void 0 : i[y]) || 0;
1176
+ this.module.setValue(n + a, w, "float"), a += 4;
1177
1177
  }
1178
- for (let w = 0; w < 100; w++) {
1179
- const v = ((s = e.expr_params) == null ? void 0 : s[w]) || 0;
1180
- this.module.setValue(n + a, v, "float"), a += 4;
1178
+ for (let y = 0; y < 100; y++) {
1179
+ const w = ((s = e.expr_params) == null ? void 0 : s[y]) || 0;
1180
+ this.module.setValue(n + a, w, "float"), a += 4;
1181
1181
  }
1182
- for (let w = 0; w < 3; w++) {
1183
- const v = ((l = e.rotation) == null ? void 0 : l[w]) || 0;
1184
- this.module.setValue(n + a, v, "float"), a += 4;
1182
+ for (let y = 0; y < 3; y++) {
1183
+ const w = ((o = e.rotation) == null ? void 0 : o[y]) || 0;
1184
+ this.module.setValue(n + a, w, "float"), a += 4;
1185
1185
  }
1186
- for (let w = 0; w < 3; w++) {
1187
- const v = ((o = e.translation) == null ? void 0 : o[w]) || 0;
1188
- this.module.setValue(n + a, v, "float"), a += 4;
1186
+ for (let y = 0; y < 3; y++) {
1187
+ const w = ((l = e.translation) == null ? void 0 : l[y]) || 0;
1188
+ this.module.setValue(n + a, w, "float"), a += 4;
1189
1189
  }
1190
- for (let w = 0; w < 3; w++) {
1191
- const v = ((p = e.neck_pose) == null ? void 0 : p[w]) || 0;
1192
- this.module.setValue(n + a, v, "float"), a += 4;
1190
+ for (let y = 0; y < 3; y++) {
1191
+ const w = ((p = e.neck_pose) == null ? void 0 : p[y]) || 0;
1192
+ this.module.setValue(n + a, w, "float"), a += 4;
1193
1193
  }
1194
- for (let w = 0; w < 3; w++) {
1195
- const v = ((c = e.jaw_pose) == null ? void 0 : c[w]) || 0;
1196
- this.module.setValue(n + a, v, "float"), a += 4;
1194
+ for (let y = 0; y < 3; y++) {
1195
+ const w = ((c = e.jaw_pose) == null ? void 0 : c[y]) || 0;
1196
+ this.module.setValue(n + a, w, "float"), a += 4;
1197
1197
  }
1198
- for (let w = 0; w < 6; w++) {
1199
- const v = ((u = e.eyes_pose) == null ? void 0 : u[w]) || 0;
1200
- this.module.setValue(n + a, v, "float"), a += 4;
1198
+ for (let y = 0; y < 6; y++) {
1199
+ const w = ((u = e.eyes_pose) == null ? void 0 : u[y]) || 0;
1200
+ this.module.setValue(n + a, w, "float"), a += 4;
1201
1201
  }
1202
- for (let w = 0; w < 2; w++) {
1203
- const v = ((m = e.eyelid) == null ? void 0 : m[w]) || 0;
1204
- this.module.setValue(n + a, v, "float"), a += 4;
1202
+ for (let y = 0; y < 2; y++) {
1203
+ const w = ((m = e.eyelid) == null ? void 0 : m[y]) || 0;
1204
+ this.module.setValue(n + a, w, "float"), a += 4;
1205
1205
  }
1206
1206
  return this.module.setValue(n + a, e.has_eyelid ? 1 : 0, "i32"), a += 4, n;
1207
1207
  }
@@ -1226,14 +1226,14 @@ class Yn {
1226
1226
  const t = this.module.getValue(e, "i32"), n = this.module.getValue(e + 4, "i32");
1227
1227
  if (n === 0 || !t)
1228
1228
  return null;
1229
- const i = n * 13, s = t / 4, l = new Float32Array(i);
1230
- return l.set(this.module.HEAPF32.subarray(s, s + i)), l;
1229
+ const i = n * 13, s = t / 4, o = new Float32Array(i);
1230
+ return o.set(this.module.HEAPF32.subarray(s, s + i)), o;
1231
1231
  }
1232
1232
  /**
1233
1233
  * 读取AvatarMeshData结构体数据
1234
1234
  */
1235
1235
  readMeshData(e) {
1236
- const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), a = this.module.getValue(e + 8, "*"), i = this.module.getValue(e + 12, "i32"), s = this.module.getValue(e + 16, "float"), l = this.module.getValue(e + 20, "*"), o = this.module.getValue(e + 24, "i32"), p = new Float32Array(n * 3);
1236
+ const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), a = this.module.getValue(e + 8, "*"), i = this.module.getValue(e + 12, "i32"), s = this.module.getValue(e + 16, "float"), o = this.module.getValue(e + 20, "*"), l = this.module.getValue(e + 24, "i32"), p = new Float32Array(n * 3);
1237
1237
  if (t && n > 0)
1238
1238
  for (let m = 0; m < n * 3; m++)
1239
1239
  p[m] = this.module.getValue(t + m * 4, "float");
@@ -1242,10 +1242,10 @@ class Yn {
1242
1242
  for (let m = 0; m < i * 3; m++)
1243
1243
  c[m] = this.module.getValue(a + m * 4, "i32");
1244
1244
  let u = null;
1245
- if (l && o > 0) {
1246
- u = new Float32Array(o * 3);
1247
- for (let m = 0; m < o * 3; m++)
1248
- u[m] = this.module.getValue(l + m * 4, "float");
1245
+ if (o && l > 0) {
1246
+ u = new Float32Array(l * 3);
1247
+ for (let m = 0; m < l * 3; m++)
1248
+ u[m] = this.module.getValue(o + m * 4, "float");
1249
1249
  }
1250
1250
  return {
1251
1251
  vertices: p,
@@ -1253,7 +1253,7 @@ class Yn {
1253
1253
  faces: c,
1254
1254
  faceCount: i,
1255
1255
  landmarks: u,
1256
- landmarkCount: o,
1256
+ landmarkCount: l,
1257
1257
  computeTime: s
1258
1258
  };
1259
1259
  }
@@ -1292,7 +1292,7 @@ class Yn {
1292
1292
  };
1293
1293
  }
1294
1294
  }
1295
- class Zn {
1295
+ class ea {
1296
1296
  constructor(e = {}) {
1297
1297
  // 配置
1298
1298
  d(this, "options");
@@ -1367,7 +1367,7 @@ class Zn {
1367
1367
  async loadWASMModule() {
1368
1368
  try {
1369
1369
  const { default: e } = await import("./avatar_core_wasm-BPIbbUx_.js");
1370
- this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new Yn(this.wasmModule), this.setupCAPIFunctions(), h.log("✅ Created new WASM instance with clean C++ memory");
1370
+ this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new Qn(this.wasmModule), this.setupCAPIFunctions(), h.log("✅ Created new WASM instance with clean C++ memory");
1371
1371
  } catch (e) {
1372
1372
  const t = e instanceof Error ? e.message : String(e);
1373
1373
  throw new Error(`Failed to load WASM module: ${t}`);
@@ -1510,21 +1510,21 @@ class Zn {
1510
1510
  throw new Error("Avatar Core not initialized");
1511
1511
  const a = performance.now();
1512
1512
  try {
1513
- const { dataPtr: i, shapePtr: s, plyPtr: l } = this.memoryManager.createCharacterData(
1513
+ const { dataPtr: i, shapePtr: s, plyPtr: o } = this.memoryManager.createCharacterData(
1514
1514
  e,
1515
1515
  t,
1516
1516
  n
1517
- ), o = this.api.loadCharacter(this.coreHandle, i);
1518
- if (!o) {
1519
- this.memoryManager.free(s), this.memoryManager.free(l);
1517
+ ), l = this.api.loadCharacter(this.coreHandle, i);
1518
+ if (!l) {
1519
+ this.memoryManager.free(s), this.memoryManager.free(o);
1520
1520
  const u = n ? `character_data_${n}` : "character_data";
1521
1521
  throw this.memoryManager.freeStruct(u), new Error("avatar_core_load_character returned NULL - character loading failed");
1522
1522
  }
1523
- this.memoryManager.free(s), this.memoryManager.free(l);
1523
+ this.memoryManager.free(s), this.memoryManager.free(o);
1524
1524
  const p = n ? `character_data_${n}` : "character_data";
1525
1525
  this.memoryManager.freeStruct(p);
1526
1526
  const c = n || "default";
1527
- return this.characterHandles.set(c, o), !n || c === "default" ? (this.characterHandle = o, this.isCharacterLoaded = !0, await this.queryCharacterInfo()) : this.characterHandle || (this.characterHandle = o, this.isCharacterLoaded = !0), this.performanceMetrics.loadTime = performance.now() - a, o;
1527
+ return this.characterHandles.set(c, l), !n || c === "default" ? (this.characterHandle = l, this.isCharacterLoaded = !0, await this.queryCharacterInfo()) : this.characterHandle || (this.characterHandle = l, this.isCharacterLoaded = !0), this.performanceMetrics.loadTime = performance.now() - a, l;
1528
1528
  } catch (i) {
1529
1529
  h.errorWithError("❌ Character loading failed:", i);
1530
1530
  const s = i instanceof Error ? i.message : String(i);
@@ -1607,22 +1607,22 @@ class Zn {
1607
1607
  const s = (a == null ? void 0 : a.totalFrames) ?? this.totalFrames;
1608
1608
  s !== null && s > 0 && (e = e % s, e < 0 && (e += s));
1609
1609
  try {
1610
- const o = this.wasmModule._malloc(1684), p = this.api.getFrameFromAnimation(i, e, o);
1610
+ const l = this.wasmModule._malloc(1684), p = this.api.getFrameFromAnimation(i, e, l);
1611
1611
  if (p !== 0) {
1612
- this.wasmModule._free(o);
1612
+ this.wasmModule._free(l);
1613
1613
  const u = this.api.getErrorString(p);
1614
1614
  throw new Error(`Failed to get frame ${e}: ${u}`);
1615
1615
  }
1616
1616
  const c = this.characterHandles.get(n) || this.characterHandle;
1617
1617
  if (c) {
1618
- const u = this.api.getCharacterShapeParams(c, o);
1618
+ const u = this.api.getCharacterShapeParams(c, l);
1619
1619
  u !== 0 && h.warn(`Failed to get character shape params: ${this.api.getErrorString(u)}`);
1620
1620
  }
1621
- return o;
1622
- } catch (l) {
1623
- h.errorWithError(`❌ Failed to get animation frame ${e}:`, l);
1624
- const o = l instanceof Error ? l.message : String(l);
1625
- throw new Error(`Failed to get animation frame ${e}: ${o}`);
1621
+ return l;
1622
+ } catch (o) {
1623
+ h.errorWithError(`❌ Failed to get animation frame ${e}:`, o);
1624
+ const l = o instanceof Error ? o.message : String(o);
1625
+ throw new Error(`Failed to get animation frame ${e}: ${l}`);
1626
1626
  }
1627
1627
  }
1628
1628
  /**
@@ -1684,8 +1684,8 @@ class Zn {
1684
1684
  n
1685
1685
  );
1686
1686
  this.checkError(a, "avatar_core_get_flame_info");
1687
- const i = this.wasmModule.getValue(e, "i32"), s = this.wasmModule.getValue(t, "i32"), l = this.wasmModule.getValue(n, "i32");
1688
- this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount: s, jointCount: l };
1687
+ const i = this.wasmModule.getValue(e, "i32"), s = this.wasmModule.getValue(t, "i32"), o = this.wasmModule.getValue(n, "i32");
1688
+ this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount: s, jointCount: o };
1689
1689
  } catch (e) {
1690
1690
  const t = e instanceof Error ? e.message : String(e);
1691
1691
  h.errorWithError("❌ Failed to query FLAME info:", t);
@@ -1803,21 +1803,21 @@ class Zn {
1803
1803
  const n = performance.now();
1804
1804
  let a = null, i = null;
1805
1805
  try {
1806
- const s = (e == null ? void 0 : e.frameIndex) ?? 0, l = t || this.characterHandle;
1807
- let o;
1808
- if (l) {
1809
- for (const [m, w] of this.characterHandles.entries())
1810
- if (w === l) {
1811
- o = m;
1806
+ const s = (e == null ? void 0 : e.frameIndex) ?? 0, o = t || this.characterHandle;
1807
+ let l;
1808
+ if (o) {
1809
+ for (const [m, y] of this.characterHandles.entries())
1810
+ if (y === o) {
1811
+ l = m;
1812
1812
  break;
1813
1813
  }
1814
- !o && l === this.characterHandle && (o = "default");
1814
+ !l && o === this.characterHandle && (l = "default");
1815
1815
  }
1816
- if (i = await this.getAnimationFrameParams(s, o), a = this.wasmModule._malloc(16), !l)
1816
+ if (i = await this.getAnimationFrameParams(s, l), a = this.wasmModule._malloc(16), !o)
1817
1817
  throw new Error("No character loaded");
1818
1818
  const p = this.api.computeFrameFlat(
1819
1819
  this.coreHandle,
1820
- l,
1820
+ o,
1821
1821
  i,
1822
1822
  a
1823
1823
  );
@@ -1826,8 +1826,8 @@ class Zn {
1826
1826
  return this.wasmTime = u, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += u, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, c;
1827
1827
  } catch (s) {
1828
1828
  h.errorWithError("❌ computeCompleteFrameFlat failed:", s);
1829
- const l = s instanceof Error ? s.message : String(s);
1830
- throw new Error(`computeCompleteFrameFlat failed: ${l}`);
1829
+ const o = s instanceof Error ? s.message : String(s);
1830
+ throw new Error(`computeCompleteFrameFlat failed: ${o}`);
1831
1831
  } finally {
1832
1832
  a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
1833
1833
  }
@@ -1851,19 +1851,19 @@ class Zn {
1851
1851
  const s = t || this.characterHandle;
1852
1852
  if (!s)
1853
1853
  throw new Error("No character loaded");
1854
- const l = this.api.computeFrameFlat(
1854
+ const o = this.api.computeFrameFlat(
1855
1855
  this.coreHandle,
1856
1856
  s,
1857
1857
  i,
1858
1858
  a
1859
1859
  );
1860
- this.checkError(l, "avatar_core_compute_frame_as_splat_points_flat");
1861
- const o = this.memoryManager.readSplatPointFlatArray(a), p = performance.now() - n;
1862
- return this.wasmTime = p, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += p, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, o;
1860
+ this.checkError(o, "avatar_core_compute_frame_as_splat_points_flat");
1861
+ const l = this.memoryManager.readSplatPointFlatArray(a), p = performance.now() - n;
1862
+ return this.wasmTime = p, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += p, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, l;
1863
1863
  } catch (s) {
1864
1864
  h.errorWithError("❌ computeFrameFlatFromParams failed:", s);
1865
- const l = s instanceof Error ? s.message : String(s);
1866
- throw new Error(`computeFrameFlatFromParams failed: ${l}`);
1865
+ const o = s instanceof Error ? s.message : String(s);
1866
+ throw new Error(`computeFrameFlatFromParams failed: ${o}`);
1867
1867
  } finally {
1868
1868
  a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
1869
1869
  }
@@ -1886,7 +1886,7 @@ class Zn {
1886
1886
  return null;
1887
1887
  }
1888
1888
  }
1889
- class S {
1889
+ class v {
1890
1890
  /**
1891
1891
  * SDK 初始化
1892
1892
  * @param appId 前端需要在 HTTP Headers 和 WebSocket Headers 中都带上
@@ -1916,7 +1916,7 @@ class S {
1916
1916
  */
1917
1917
  static async initializeWASMModule() {
1918
1918
  try {
1919
- h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new Zn({
1919
+ h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new ea({
1920
1920
  logLevel: "basic",
1921
1921
  enableValidation: !0,
1922
1922
  enablePerformanceMetrics: !0,
@@ -2005,7 +2005,7 @@ class S {
2005
2005
  static cleanup() {
2006
2006
  if (this._isInitialized)
2007
2007
  try {
2008
- this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._appId = null, this._configuration = null, this._sessionToken = null, this._userId = null, this._dynamicSdkConfig = null, this._isInitialized = !1, Jn(), Kn(), h.log("[AvatarKit] Cleanup completed");
2008
+ this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._appId = null, this._configuration = null, this._sessionToken = null, this._userId = null, this._dynamicSdkConfig = null, this._isInitialized = !1, Zn(), Yn(), h.log("[AvatarKit] Cleanup completed");
2009
2009
  } catch (e) {
2010
2010
  h.error("Failed to cleanup AvatarKit:", e instanceof Error ? e.message : String(e));
2011
2011
  }
@@ -2015,7 +2015,7 @@ class S {
2015
2015
  */
2016
2016
  static async _fetchSdkConfig() {
2017
2017
  try {
2018
- this._dynamicSdkConfig = await Xn(this._version);
2018
+ this._dynamicSdkConfig = await Jn(this._version);
2019
2019
  } catch (e) {
2020
2020
  const t = e instanceof Error ? e.message : String(e);
2021
2021
  h.warn("Failed to fetch SDK config from remote, using defaults:", t), this.logEvent("sdk_config", "warning", {
@@ -2032,15 +2032,15 @@ class S {
2032
2032
  if (!this._configuration)
2033
2033
  throw new Error("AvatarKit not initialized");
2034
2034
  const t = {
2035
- [le.cn]: {
2035
+ [ce.cn]: {
2036
2036
  sdkApiBaseUrl: "https://api.spatialwalk.top",
2037
2037
  driveningressWsUrl: "wss://api.spatialwalk.top/v1/driveningress/websocket"
2038
2038
  },
2039
- [le.us]: {
2039
+ [ce.us]: {
2040
2040
  sdkApiBaseUrl: "https://api.spatialwalk.cloud",
2041
2041
  driveningressWsUrl: "wss://api.spatialwalk.cloud/v1/driveningress/websocket"
2042
2042
  },
2043
- [le.test]: {
2043
+ [ce.test]: {
2044
2044
  sdkApiBaseUrl: "https://api-test.spatialwalk.top",
2045
2045
  driveningressWsUrl: "wss://api-test.spatialwalk.top/v1/driveningress/websocket"
2046
2046
  }
@@ -2069,18 +2069,18 @@ class S {
2069
2069
  h[i](`[Telemetry] ${e}`, a);
2070
2070
  }
2071
2071
  }
2072
- d(S, "_isInitialized", !1), d(S, "_appId", null), d(S, "_configuration", null), d(S, "_sessionToken", null), d(S, "_userId", null), d(S, "_version", "1.0.0-beta.16"), d(S, "_avatarCore", null), d(S, "_dynamicSdkConfig", null), d(S, "_logLevels", {
2072
+ d(v, "_isInitialized", !1), d(v, "_appId", null), d(v, "_configuration", null), d(v, "_sessionToken", null), d(v, "_userId", null), d(v, "_version", "1.0.0-beta.17"), d(v, "_avatarCore", null), d(v, "_dynamicSdkConfig", null), d(v, "_logLevels", {
2073
2073
  debug: "log",
2074
2074
  info: "log",
2075
2075
  warning: "warn",
2076
2076
  error: "error"
2077
2077
  });
2078
- const _e = class _e {
2078
+ const Pe = class Pe {
2079
2079
  constructor() {
2080
2080
  d(this, "audio", null);
2081
2081
  d(this, "streamingPlayer", null);
2082
2082
  d(this, "_isPlaying", !1);
2083
- d(this, "fps", x.animation.fps);
2083
+ d(this, "fps", I.animation.fps);
2084
2084
  d(this, "onEndedCallback");
2085
2085
  d(this, "useStreaming", !1);
2086
2086
  }
@@ -2089,10 +2089,10 @@ const _e = class _e {
2089
2089
  * 必须在用户交互事件(如 click)中调用
2090
2090
  */
2091
2091
  static async unlockAudioContext() {
2092
- if (!_e.audioUnlocked)
2092
+ if (!Pe.audioUnlocked)
2093
2093
  try {
2094
2094
  const e = new Audio();
2095
- e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0, _e.audioUnlocked = !0, h.log("✅ Audio context unlocked for Safari");
2095
+ e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0, Pe.audioUnlocked = !0, h.log("✅ Audio context unlocked for Safari");
2096
2096
  } catch (e) {
2097
2097
  h.warn("⚠️ Failed to unlock audio context:", e);
2098
2098
  }
@@ -2138,9 +2138,9 @@ const _e = class _e {
2138
2138
  async createAndInitializeStreamingPlayer() {
2139
2139
  if (this.streamingPlayer)
2140
2140
  return;
2141
- const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-COgQTrz3.js");
2141
+ const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-a8MwHQ3Q.js");
2142
2142
  this.streamingPlayer = new e({
2143
- sampleRate: x.audio.sampleRate,
2143
+ sampleRate: I.audio.sampleRate,
2144
2144
  channelCount: 1,
2145
2145
  debug: !1
2146
2146
  });
@@ -2148,7 +2148,7 @@ const _e = class _e {
2148
2148
  await this.streamingPlayer.initialize();
2149
2149
  } catch (t) {
2150
2150
  const n = t instanceof Error ? t.message : String(t);
2151
- throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n), S.logEvent("character_player", "error", {
2151
+ throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n), v.logEvent("character_player", "error", {
2152
2152
  event: "streaming_player_initialize_failed",
2153
2153
  reason: n
2154
2154
  }), t;
@@ -2227,9 +2227,24 @@ const _e = class _e {
2227
2227
  this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
2228
2228
  }
2229
2229
  };
2230
- d(_e, "audioUnlocked", !1);
2231
- let Ce = _e;
2232
- function Qn() {
2230
+ d(Pe, "audioUnlocked", !1);
2231
+ let le = Pe, ta = (r) => crypto.getRandomValues(new Uint8Array(r)), ra = (r, e, t) => {
2232
+ let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
2233
+ return (i = e) => {
2234
+ let s = "";
2235
+ for (; ; ) {
2236
+ let o = t(a), l = a | 0;
2237
+ for (; l--; )
2238
+ if (s += r[o[l] & n] || "", s.length >= i) return s;
2239
+ }
2240
+ };
2241
+ }, na = (r, e = 21) => ra(r, e | 0, ta);
2242
+ const aa = na("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
2243
+ function tr() {
2244
+ const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), a = String(r.getUTCHours()).padStart(2, "0"), i = String(r.getUTCMinutes()).padStart(2, "0"), s = String(r.getUTCSeconds()).padStart(2, "0"), o = `${e}${t}${n}${a}${i}${s}`, l = aa();
2245
+ return `${o}_${l}`;
2246
+ }
2247
+ function ia() {
2233
2248
  let r = 0, e = 0;
2234
2249
  for (let n = 0; n < 28; n += 7) {
2235
2250
  let a = this.buf[this.pos++];
@@ -2246,63 +2261,63 @@ function Qn() {
2246
2261
  }
2247
2262
  throw new Error("invalid varint");
2248
2263
  }
2249
- function Ve(r, e, t) {
2264
+ function ze(r, e, t) {
2250
2265
  for (let i = 0; i < 28; i = i + 7) {
2251
- const s = r >>> i, l = !(!(s >>> 7) && e == 0), o = (l ? s | 128 : s) & 255;
2252
- if (t.push(o), !l)
2266
+ const s = r >>> i, o = !(!(s >>> 7) && e == 0), l = (o ? s | 128 : s) & 255;
2267
+ if (t.push(l), !o)
2253
2268
  return;
2254
2269
  }
2255
2270
  const n = r >>> 28 & 15 | (e & 7) << 4, a = !!(e >> 3);
2256
2271
  if (t.push((a ? n | 128 : n) & 255), !!a) {
2257
2272
  for (let i = 3; i < 31; i = i + 7) {
2258
- const s = e >>> i, l = !!(s >>> 7), o = (l ? s | 128 : s) & 255;
2259
- if (t.push(o), !l)
2273
+ const s = e >>> i, o = !!(s >>> 7), l = (o ? s | 128 : s) & 255;
2274
+ if (t.push(l), !o)
2260
2275
  return;
2261
2276
  }
2262
2277
  t.push(e >>> 31 & 1);
2263
2278
  }
2264
2279
  }
2265
- const ke = 4294967296;
2266
- function bt(r) {
2280
+ const Me = 4294967296;
2281
+ function Ct(r) {
2267
2282
  const e = r[0] === "-";
2268
2283
  e && (r = r.slice(1));
2269
2284
  const t = 1e6;
2270
2285
  let n = 0, a = 0;
2271
- function i(s, l) {
2272
- const o = Number(r.slice(s, l));
2273
- a *= t, n = n * t + o, n >= ke && (a = a + (n / ke | 0), n = n % ke);
2286
+ function i(s, o) {
2287
+ const l = Number(r.slice(s, o));
2288
+ a *= t, n = n * t + l, n >= Me && (a = a + (n / Me | 0), n = n % Me);
2274
2289
  }
2275
- return i(-24, -18), i(-18, -12), i(-12, -6), i(-6), e ? tr(n, a) : Ye(n, a);
2290
+ return i(-24, -18), i(-18, -12), i(-12, -6), i(-6), e ? nr(n, a) : Ze(n, a);
2276
2291
  }
2277
- function ea(r, e) {
2278
- let t = Ye(r, e);
2292
+ function sa(r, e) {
2293
+ let t = Ze(r, e);
2279
2294
  const n = t.hi & 2147483648;
2280
- n && (t = tr(t.lo, t.hi));
2281
- const a = er(t.lo, t.hi);
2295
+ n && (t = nr(t.lo, t.hi));
2296
+ const a = rr(t.lo, t.hi);
2282
2297
  return n ? "-" + a : a;
2283
2298
  }
2284
- function er(r, e) {
2285
- if ({ lo: r, hi: e } = ta(r, e), e <= 2097151)
2286
- return String(ke * e + r);
2299
+ function rr(r, e) {
2300
+ if ({ lo: r, hi: e } = oa(r, e), e <= 2097151)
2301
+ return String(Me * e + r);
2287
2302
  const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, a = e >> 16 & 65535;
2288
- let i = t + n * 6777216 + a * 6710656, s = n + a * 8147497, l = a * 2;
2289
- const o = 1e7;
2290
- return i >= o && (s += Math.floor(i / o), i %= o), s >= o && (l += Math.floor(s / o), s %= o), l.toString() + Ct(s) + Ct(i);
2303
+ let i = t + n * 6777216 + a * 6710656, s = n + a * 8147497, o = a * 2;
2304
+ const l = 1e7;
2305
+ return i >= l && (s += Math.floor(i / l), i %= l), s >= l && (o += Math.floor(s / l), s %= l), o.toString() + _t(s) + _t(i);
2291
2306
  }
2292
- function ta(r, e) {
2307
+ function oa(r, e) {
2293
2308
  return { lo: r >>> 0, hi: e >>> 0 };
2294
2309
  }
2295
- function Ye(r, e) {
2310
+ function Ze(r, e) {
2296
2311
  return { lo: r | 0, hi: e | 0 };
2297
2312
  }
2298
- function tr(r, e) {
2299
- return e = ~e, r ? r = ~r + 1 : e += 1, Ye(r, e);
2313
+ function nr(r, e) {
2314
+ return e = ~e, r ? r = ~r + 1 : e += 1, Ze(r, e);
2300
2315
  }
2301
- const Ct = (r) => {
2316
+ const _t = (r) => {
2302
2317
  const e = String(r);
2303
2318
  return "0000000".slice(e.length) + e;
2304
2319
  };
2305
- function _t(r, e) {
2320
+ function Pt(r, e) {
2306
2321
  if (r >= 0) {
2307
2322
  for (; r > 127; )
2308
2323
  e.push(r & 127 | 128), r = r >>> 7;
@@ -2313,7 +2328,7 @@ function _t(r, e) {
2313
2328
  e.push(1);
2314
2329
  }
2315
2330
  }
2316
- function ra() {
2331
+ function la() {
2317
2332
  let r = this.buf[this.pos++], e = r & 127;
2318
2333
  if (!(r & 128))
2319
2334
  return this.assertBounds(), e;
@@ -2330,8 +2345,8 @@ function ra() {
2330
2345
  throw new Error("invalid varint");
2331
2346
  return this.assertBounds(), e >>> 0;
2332
2347
  }
2333
- const K = /* @__PURE__ */ na();
2334
- function na() {
2348
+ const K = /* @__PURE__ */ ca();
2349
+ function ca() {
2335
2350
  const r = new DataView(new ArrayBuffer(8));
2336
2351
  if (typeof BigInt == "function" && typeof r.getBigInt64 == "function" && typeof r.getBigUint64 == "function" && typeof r.setBigInt64 == "function" && typeof r.setBigUint64 == "function" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
2337
2352
  const t = BigInt("-9223372036854775808"), n = BigInt("9223372036854775807"), a = BigInt("0"), i = BigInt("18446744073709551615");
@@ -2339,16 +2354,16 @@ function na() {
2339
2354
  zero: BigInt(0),
2340
2355
  supported: !0,
2341
2356
  parse(s) {
2342
- const l = typeof s == "bigint" ? s : BigInt(s);
2343
- if (l > n || l < t)
2357
+ const o = typeof s == "bigint" ? s : BigInt(s);
2358
+ if (o > n || o < t)
2344
2359
  throw new Error(`invalid int64: ${s}`);
2345
- return l;
2360
+ return o;
2346
2361
  },
2347
2362
  uParse(s) {
2348
- const l = typeof s == "bigint" ? s : BigInt(s);
2349
- if (l > i || l < a)
2363
+ const o = typeof s == "bigint" ? s : BigInt(s);
2364
+ if (o > i || o < a)
2350
2365
  throw new Error(`invalid uint64: ${s}`);
2351
- return l;
2366
+ return o;
2352
2367
  },
2353
2368
  enc(s) {
2354
2369
  return r.setBigInt64(0, this.parse(s), !0), {
@@ -2362,11 +2377,11 @@ function na() {
2362
2377
  hi: r.getInt32(4, !0)
2363
2378
  };
2364
2379
  },
2365
- dec(s, l) {
2366
- return r.setInt32(0, s, !0), r.setInt32(4, l, !0), r.getBigInt64(0, !0);
2380
+ dec(s, o) {
2381
+ return r.setInt32(0, s, !0), r.setInt32(4, o, !0), r.getBigInt64(0, !0);
2367
2382
  },
2368
- uDec(s, l) {
2369
- return r.setInt32(0, s, !0), r.setInt32(4, l, !0), r.getBigUint64(0, !0);
2383
+ uDec(s, o) {
2384
+ return r.setInt32(0, s, !0), r.setInt32(4, o, !0), r.getBigUint64(0, !0);
2370
2385
  }
2371
2386
  };
2372
2387
  }
@@ -2377,19 +2392,19 @@ function na() {
2377
2392
  return typeof t != "string" && (t = t.toString()), Et(t), t;
2378
2393
  },
2379
2394
  uParse(t) {
2380
- return typeof t != "string" && (t = t.toString()), Pt(t), t;
2395
+ return typeof t != "string" && (t = t.toString()), It(t), t;
2381
2396
  },
2382
2397
  enc(t) {
2383
- return typeof t != "string" && (t = t.toString()), Et(t), bt(t);
2398
+ return typeof t != "string" && (t = t.toString()), Et(t), Ct(t);
2384
2399
  },
2385
2400
  uEnc(t) {
2386
- return typeof t != "string" && (t = t.toString()), Pt(t), bt(t);
2401
+ return typeof t != "string" && (t = t.toString()), It(t), Ct(t);
2387
2402
  },
2388
2403
  dec(t, n) {
2389
- return ea(t, n);
2404
+ return sa(t, n);
2390
2405
  },
2391
2406
  uDec(t, n) {
2392
- return er(t, n);
2407
+ return rr(t, n);
2393
2408
  }
2394
2409
  };
2395
2410
  }
@@ -2397,15 +2412,15 @@ function Et(r) {
2397
2412
  if (!/^-?[0-9]+$/.test(r))
2398
2413
  throw new Error("invalid int64: " + r);
2399
2414
  }
2400
- function Pt(r) {
2415
+ function It(r) {
2401
2416
  if (!/^[0-9]+$/.test(r))
2402
2417
  throw new Error("invalid uint64: " + r);
2403
2418
  }
2404
- const ze = Symbol.for("@bufbuild/protobuf/text-encoding");
2405
- function rr() {
2406
- if (globalThis[ze] == null) {
2419
+ const Ve = Symbol.for("@bufbuild/protobuf/text-encoding");
2420
+ function ar() {
2421
+ if (globalThis[Ve] == null) {
2407
2422
  const r = new globalThis.TextEncoder(), e = new globalThis.TextDecoder();
2408
- globalThis[ze] = {
2423
+ globalThis[Ve] = {
2409
2424
  encodeUtf8(t) {
2410
2425
  return r.encode(t);
2411
2426
  },
@@ -2421,15 +2436,15 @@ function rr() {
2421
2436
  }
2422
2437
  };
2423
2438
  }
2424
- return globalThis[ze];
2439
+ return globalThis[Ve];
2425
2440
  }
2426
- var ee;
2441
+ var te;
2427
2442
  (function(r) {
2428
2443
  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
- })(ee || (ee = {}));
2430
- const aa = 34028234663852886e22, ia = -34028234663852886e22, sa = 4294967295, oa = 2147483647, la = -2147483648;
2431
- class de {
2432
- constructor(e = rr().encodeUtf8) {
2444
+ })(te || (te = {}));
2445
+ const da = 34028234663852886e22, ua = -34028234663852886e22, ha = 4294967295, fa = 2147483647, ma = -2147483648;
2446
+ class ue {
2447
+ constructor(e = ar().encodeUtf8) {
2433
2448
  this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
2434
2449
  }
2435
2450
  /**
@@ -2484,7 +2499,7 @@ class de {
2484
2499
  * Write a `uint32` value, an unsigned 32 bit varint.
2485
2500
  */
2486
2501
  uint32(e) {
2487
- for (It(e); e > 127; )
2502
+ for (kt(e); e > 127; )
2488
2503
  this.buf.push(e & 127 | 128), e = e >>> 7;
2489
2504
  return this.buf.push(e), this;
2490
2505
  }
@@ -2492,7 +2507,7 @@ class de {
2492
2507
  * Write a `int32` value, a signed 32 bit varint.
2493
2508
  */
2494
2509
  int32(e) {
2495
- return $e(e), _t(e, this.buf), this;
2510
+ return $e(e), Pt(e, this.buf), this;
2496
2511
  }
2497
2512
  /**
2498
2513
  * Write a `bool` value, a variant.
@@ -2517,7 +2532,7 @@ class de {
2517
2532
  * Write a `float` value, 32-bit floating point number.
2518
2533
  */
2519
2534
  float(e) {
2520
- ca(e);
2535
+ pa(e);
2521
2536
  let t = new Uint8Array(4);
2522
2537
  return new DataView(t.buffer).setFloat32(0, e, !0), this.raw(t);
2523
2538
  }
@@ -2532,7 +2547,7 @@ class de {
2532
2547
  * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
2533
2548
  */
2534
2549
  fixed32(e) {
2535
- It(e);
2550
+ kt(e);
2536
2551
  let t = new Uint8Array(4);
2537
2552
  return new DataView(t.buffer).setUint32(0, e, !0), this.raw(t);
2538
2553
  }
@@ -2548,7 +2563,7 @@ class de {
2548
2563
  * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
2549
2564
  */
2550
2565
  sint32(e) {
2551
- return $e(e), e = (e << 1 ^ e >> 31) >>> 0, _t(e, this.buf), this;
2566
+ return $e(e), e = (e << 1 ^ e >> 31) >>> 0, Pt(e, this.buf), this;
2552
2567
  }
2553
2568
  /**
2554
2569
  * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
@@ -2569,26 +2584,26 @@ class de {
2569
2584
  */
2570
2585
  int64(e) {
2571
2586
  let t = K.enc(e);
2572
- return Ve(t.lo, t.hi, this.buf), this;
2587
+ return ze(t.lo, t.hi, this.buf), this;
2573
2588
  }
2574
2589
  /**
2575
2590
  * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
2576
2591
  */
2577
2592
  sint64(e) {
2578
2593
  const t = K.enc(e), n = t.hi >> 31, a = t.lo << 1 ^ n, i = (t.hi << 1 | t.lo >>> 31) ^ n;
2579
- return Ve(a, i, this.buf), this;
2594
+ return ze(a, i, this.buf), this;
2580
2595
  }
2581
2596
  /**
2582
2597
  * Write a `uint64` value, an unsigned 64-bit varint.
2583
2598
  */
2584
2599
  uint64(e) {
2585
2600
  const t = K.uEnc(e);
2586
- return Ve(t.lo, t.hi, this.buf), this;
2601
+ return ze(t.lo, t.hi, this.buf), this;
2587
2602
  }
2588
2603
  }
2589
2604
  class N {
2590
- constructor(e, t = rr().decodeUtf8) {
2591
- this.decodeUtf8 = t, this.varint64 = Qn, this.uint32 = ra, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength);
2605
+ constructor(e, t = ar().decodeUtf8) {
2606
+ this.decodeUtf8 = t, this.varint64 = ia, this.uint32 = la, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength);
2592
2607
  }
2593
2608
  /**
2594
2609
  * Reads a tag - field number and wire type.
@@ -2608,23 +2623,23 @@ class N {
2608
2623
  skip(e, t) {
2609
2624
  let n = this.pos;
2610
2625
  switch (e) {
2611
- case ee.Varint:
2626
+ case te.Varint:
2612
2627
  for (; this.buf[this.pos++] & 128; )
2613
2628
  ;
2614
2629
  break;
2615
- case ee.Bit64:
2630
+ case te.Bit64:
2616
2631
  this.pos += 4;
2617
- case ee.Bit32:
2632
+ case te.Bit32:
2618
2633
  this.pos += 4;
2619
2634
  break;
2620
- case ee.LengthDelimited:
2635
+ case te.LengthDelimited:
2621
2636
  let a = this.uint32();
2622
2637
  this.pos += a;
2623
2638
  break;
2624
- case ee.StartGroup:
2639
+ case te.StartGroup:
2625
2640
  for (; ; ) {
2626
2641
  const [i, s] = this.tag();
2627
- if (s === ee.EndGroup) {
2642
+ if (s === te.EndGroup) {
2628
2643
  if (t !== void 0 && i !== t)
2629
2644
  throw new Error("invalid end group tag");
2630
2645
  break;
@@ -2738,29 +2753,29 @@ function $e(r) {
2738
2753
  r = Number(r);
2739
2754
  else if (typeof r != "number")
2740
2755
  throw new Error("invalid int32: " + typeof r);
2741
- if (!Number.isInteger(r) || r > oa || r < la)
2756
+ if (!Number.isInteger(r) || r > fa || r < ma)
2742
2757
  throw new Error("invalid int32: " + r);
2743
2758
  }
2744
- function It(r) {
2759
+ function kt(r) {
2745
2760
  if (typeof r == "string")
2746
2761
  r = Number(r);
2747
2762
  else if (typeof r != "number")
2748
2763
  throw new Error("invalid uint32: " + typeof r);
2749
- if (!Number.isInteger(r) || r > sa || r < 0)
2764
+ if (!Number.isInteger(r) || r > ha || r < 0)
2750
2765
  throw new Error("invalid uint32: " + r);
2751
2766
  }
2752
- function ca(r) {
2767
+ function pa(r) {
2753
2768
  if (typeof r == "string") {
2754
2769
  const e = r;
2755
2770
  if (r = Number(r), Number.isNaN(r) && e !== "NaN")
2756
2771
  throw new Error("invalid float32: " + e);
2757
2772
  } else if (typeof r != "number")
2758
2773
  throw new Error("invalid float32: " + typeof r);
2759
- if (Number.isFinite(r) && (r > aa || r < ia))
2774
+ if (Number.isFinite(r) && (r > da || r < ua))
2760
2775
  throw new Error("invalid float32: " + r);
2761
2776
  }
2762
- var Pe = /* @__PURE__ */ ((r) => (r[r.MESSAGE_UNSPECIFIED = 0] = "MESSAGE_UNSPECIFIED", r[r.MESSAGE_ERROR = 2] = "MESSAGE_ERROR", r[r.MESSAGE_SERVER_RESPONSE_ANIMATION = 1004] = "MESSAGE_SERVER_RESPONSE_ANIMATION", r[r.MESSAGE_CLIENT_AUDIO_INPUT = 2003] = "MESSAGE_CLIENT_AUDIO_INPUT", r[r.UNRECOGNIZED = -1] = "UNRECOGNIZED", r))(Pe || {});
2763
- function da(r) {
2777
+ var Ie = /* @__PURE__ */ ((r) => (r[r.MESSAGE_UNSPECIFIED = 0] = "MESSAGE_UNSPECIFIED", r[r.MESSAGE_ERROR = 2] = "MESSAGE_ERROR", r[r.MESSAGE_SERVER_RESPONSE_ANIMATION = 1004] = "MESSAGE_SERVER_RESPONSE_ANIMATION", r[r.MESSAGE_CLIENT_AUDIO_INPUT = 2003] = "MESSAGE_CLIENT_AUDIO_INPUT", r[r.UNRECOGNIZED = -1] = "UNRECOGNIZED", r))(Ie || {});
2778
+ function ga(r) {
2764
2779
  switch (r) {
2765
2780
  case 0:
2766
2781
  case "MESSAGE_UNSPECIFIED":
@@ -2780,7 +2795,7 @@ function da(r) {
2780
2795
  return -1;
2781
2796
  }
2782
2797
  }
2783
- function ua(r) {
2798
+ function ya(r) {
2784
2799
  switch (r) {
2785
2800
  case 0:
2786
2801
  return "MESSAGE_UNSPECIFIED";
@@ -2798,8 +2813,8 @@ function ua(r) {
2798
2813
  function xt() {
2799
2814
  return { reqId: "", audio: new Uint8Array(0), end: !1 };
2800
2815
  }
2801
- const fe = {
2802
- encode(r, e = new de()) {
2816
+ const me = {
2817
+ encode(r, e = new ue()) {
2803
2818
  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
2819
  },
2805
2820
  decode(r, e) {
@@ -2837,27 +2852,27 @@ const fe = {
2837
2852
  fromJSON(r) {
2838
2853
  return {
2839
2854
  reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
2840
- audio: $(r.audio) ? ha(r.audio) : new Uint8Array(0),
2855
+ audio: $(r.audio) ? va(r.audio) : new Uint8Array(0),
2841
2856
  end: $(r.end) ? globalThis.Boolean(r.end) : !1
2842
2857
  };
2843
2858
  },
2844
2859
  toJSON(r) {
2845
2860
  const e = {};
2846
- return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio = fa(r.audio)), r.end !== !1 && (e.end = r.end), e;
2861
+ 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
2862
  },
2848
2863
  create(r) {
2849
- return fe.fromPartial(r ?? {});
2864
+ return me.fromPartial(r ?? {});
2850
2865
  },
2851
2866
  fromPartial(r) {
2852
2867
  const e = xt();
2853
2868
  return e.reqId = r.reqId ?? "", e.audio = r.audio ?? new Uint8Array(0), e.end = r.end ?? !1, e;
2854
2869
  }
2855
2870
  };
2856
- function kt() {
2871
+ function Mt() {
2857
2872
  return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
2858
2873
  }
2859
- const me = {
2860
- encode(r, e = new de()) {
2874
+ const pe = {
2875
+ encode(r, e = new ue()) {
2861
2876
  e.uint32(18).fork();
2862
2877
  for (const t of r.translation)
2863
2878
  e.float(t);
@@ -2884,7 +2899,7 @@ const me = {
2884
2899
  decode(r, e) {
2885
2900
  const t = r instanceof N ? r : new N(r);
2886
2901
  let n = e === void 0 ? t.len : t.pos + e;
2887
- const a = kt();
2902
+ const a = Mt();
2888
2903
  for (; t.pos < n; ) {
2889
2904
  const i = t.uint32();
2890
2905
  switch (i >>> 3) {
@@ -2998,39 +3013,39 @@ const me = {
2998
3013
  };
2999
3014
  },
3000
3015
  toJSON(r) {
3001
- var t, n, a, i, s, l, o;
3016
+ var t, n, a, i, s, o, l;
3002
3017
  const e = {};
3003
- 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), (s = r.eyePose) != null && s.length && (e.eyePose = r.eyePose), (l = r.eyeLid) != null && l.length && (e.eyeLid = r.eyeLid), (o = r.expression) != null && o.length && (e.expression = r.expression), e;
3018
+ 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), (s = r.eyePose) != null && s.length && (e.eyePose = r.eyePose), (o = r.eyeLid) != null && o.length && (e.eyeLid = r.eyeLid), (l = r.expression) != null && l.length && (e.expression = r.expression), e;
3004
3019
  },
3005
3020
  create(r) {
3006
- return me.fromPartial(r ?? {});
3021
+ return pe.fromPartial(r ?? {});
3007
3022
  },
3008
3023
  fromPartial(r) {
3009
- var t, n, a, i, s, l, o;
3010
- const e = kt();
3011
- 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 = ((s = r.eyePose) == null ? void 0 : s.map((p) => p)) || [], e.eyeLid = ((l = r.eyeLid) == null ? void 0 : l.map((p) => p)) || [], e.expression = ((o = r.expression) == null ? void 0 : o.map((p) => p)) || [], e;
3024
+ var t, n, a, i, s, o, l;
3025
+ const e = Mt();
3026
+ 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 = ((s = r.eyePose) == null ? void 0 : s.map((p) => p)) || [], e.eyeLid = ((o = r.eyeLid) == null ? void 0 : o.map((p) => p)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((p) => p)) || [], e;
3012
3027
  }
3013
3028
  };
3014
- function Mt() {
3029
+ function Ft() {
3015
3030
  return { keyframes: [] };
3016
3031
  }
3017
- const pe = {
3018
- encode(r, e = new de()) {
3032
+ const ge = {
3033
+ encode(r, e = new ue()) {
3019
3034
  for (const t of r.keyframes)
3020
- me.encode(t, e.uint32(10).fork()).join();
3035
+ pe.encode(t, e.uint32(10).fork()).join();
3021
3036
  return e;
3022
3037
  },
3023
3038
  decode(r, e) {
3024
3039
  const t = r instanceof N ? r : new N(r);
3025
3040
  let n = e === void 0 ? t.len : t.pos + e;
3026
- const a = Mt();
3041
+ const a = Ft();
3027
3042
  for (; t.pos < n; ) {
3028
3043
  const i = t.uint32();
3029
3044
  switch (i >>> 3) {
3030
3045
  case 1: {
3031
3046
  if (i !== 10)
3032
3047
  break;
3033
- a.keyframes.push(me.decode(t, t.uint32()));
3048
+ a.keyframes.push(pe.decode(t, t.uint32()));
3034
3049
  continue;
3035
3050
  }
3036
3051
  }
@@ -3042,34 +3057,34 @@ const pe = {
3042
3057
  },
3043
3058
  fromJSON(r) {
3044
3059
  return {
3045
- keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => me.fromJSON(e)) : []
3060
+ keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => pe.fromJSON(e)) : []
3046
3061
  };
3047
3062
  },
3048
3063
  toJSON(r) {
3049
3064
  var t;
3050
3065
  const e = {};
3051
- return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => me.toJSON(n))), e;
3066
+ return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => pe.toJSON(n))), e;
3052
3067
  },
3053
3068
  create(r) {
3054
- return pe.fromPartial(r ?? {});
3069
+ return ge.fromPartial(r ?? {});
3055
3070
  },
3056
3071
  fromPartial(r) {
3057
3072
  var t;
3058
- const e = Mt();
3059
- return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => me.fromPartial(n))) || [], e;
3073
+ const e = Ft();
3074
+ return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => pe.fromPartial(n))) || [], e;
3060
3075
  }
3061
3076
  };
3062
- function Ft() {
3077
+ function Rt() {
3063
3078
  return { reqId: "", animation: void 0 };
3064
3079
  }
3065
- const ge = {
3066
- encode(r, e = new de()) {
3067
- return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && pe.encode(r.animation, e.uint32(18).fork()).join(), e;
3080
+ const ye = {
3081
+ encode(r, e = new ue()) {
3082
+ return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && ge.encode(r.animation, e.uint32(18).fork()).join(), e;
3068
3083
  },
3069
3084
  decode(r, e) {
3070
3085
  const t = r instanceof N ? r : new N(r);
3071
3086
  let n = e === void 0 ? t.len : t.pos + e;
3072
- const a = Ft();
3087
+ const a = Rt();
3073
3088
  for (; t.pos < n; ) {
3074
3089
  const i = t.uint32();
3075
3090
  switch (i >>> 3) {
@@ -3082,7 +3097,7 @@ const ge = {
3082
3097
  case 2: {
3083
3098
  if (i !== 18)
3084
3099
  break;
3085
- a.animation = pe.decode(t, t.uint32());
3100
+ a.animation = ge.decode(t, t.uint32());
3086
3101
  continue;
3087
3102
  }
3088
3103
  }
@@ -3095,32 +3110,32 @@ const ge = {
3095
3110
  fromJSON(r) {
3096
3111
  return {
3097
3112
  reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
3098
- animation: $(r.animation) ? pe.fromJSON(r.animation) : void 0
3113
+ animation: $(r.animation) ? ge.fromJSON(r.animation) : void 0
3099
3114
  };
3100
3115
  },
3101
3116
  toJSON(r) {
3102
3117
  const e = {};
3103
- return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = pe.toJSON(r.animation)), e;
3118
+ return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = ge.toJSON(r.animation)), e;
3104
3119
  },
3105
3120
  create(r) {
3106
- return ge.fromPartial(r ?? {});
3121
+ return ye.fromPartial(r ?? {});
3107
3122
  },
3108
3123
  fromPartial(r) {
3109
- const e = Ft();
3110
- return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? pe.fromPartial(r.animation) : void 0, e;
3124
+ const e = Rt();
3125
+ return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? ge.fromPartial(r.animation) : void 0, e;
3111
3126
  }
3112
3127
  };
3113
- function Rt() {
3128
+ function Lt() {
3114
3129
  return { reqId: "", code: 0, reason: "" };
3115
3130
  }
3116
- const we = {
3117
- encode(r, e = new de()) {
3131
+ const ve = {
3132
+ encode(r, e = new ue()) {
3118
3133
  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
3134
  },
3120
3135
  decode(r, e) {
3121
3136
  const t = r instanceof N ? r : new N(r);
3122
3137
  let n = e === void 0 ? t.len : t.pos + e;
3123
- const a = Rt();
3138
+ const a = Lt();
3124
3139
  for (; t.pos < n; ) {
3125
3140
  const i = t.uint32();
3126
3141
  switch (i >>> 3) {
@@ -3161,24 +3176,24 @@ const we = {
3161
3176
  return r.reqId !== "" && (e.reqId = r.reqId), r.code !== 0 && (e.code = Math.round(r.code)), r.reason !== "" && (e.reason = r.reason), e;
3162
3177
  },
3163
3178
  create(r) {
3164
- return we.fromPartial(r ?? {});
3179
+ return ve.fromPartial(r ?? {});
3165
3180
  },
3166
3181
  fromPartial(r) {
3167
- const e = Rt();
3182
+ const e = Lt();
3168
3183
  return e.reqId = r.reqId ?? "", e.code = r.code ?? 0, e.reason = r.reason ?? "", e;
3169
3184
  }
3170
3185
  };
3171
- function Lt() {
3186
+ function Tt() {
3172
3187
  return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
3173
3188
  }
3174
- const Ke = {
3175
- encode(r, e = new de()) {
3176
- return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && we.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && ge.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && fe.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
3189
+ const Xe = {
3190
+ encode(r, e = new ue()) {
3191
+ return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && ve.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && ye.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && me.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
3177
3192
  },
3178
3193
  decode(r, e) {
3179
3194
  const t = r instanceof N ? r : new N(r);
3180
3195
  let n = e === void 0 ? t.len : t.pos + e;
3181
- const a = Lt();
3196
+ const a = Tt();
3182
3197
  for (; t.pos < n; ) {
3183
3198
  const i = t.uint32();
3184
3199
  switch (i >>> 3) {
@@ -3191,19 +3206,19 @@ const Ke = {
3191
3206
  case 2: {
3192
3207
  if (i !== 18)
3193
3208
  break;
3194
- a.error = we.decode(t, t.uint32());
3209
+ a.error = ve.decode(t, t.uint32());
3195
3210
  continue;
3196
3211
  }
3197
3212
  case 3: {
3198
3213
  if (i !== 26)
3199
3214
  break;
3200
- a.serverResponseAnimation = ge.decode(t, t.uint32());
3215
+ a.serverResponseAnimation = ye.decode(t, t.uint32());
3201
3216
  continue;
3202
3217
  }
3203
3218
  case 4: {
3204
3219
  if (i !== 34)
3205
3220
  break;
3206
- a.clientAudioInput = fe.decode(t, t.uint32());
3221
+ a.clientAudioInput = me.decode(t, t.uint32());
3207
3222
  continue;
3208
3223
  }
3209
3224
  }
@@ -3215,31 +3230,31 @@ const Ke = {
3215
3230
  },
3216
3231
  fromJSON(r) {
3217
3232
  return {
3218
- type: $(r.type) ? da(r.type) : 0,
3219
- error: $(r.error) ? we.fromJSON(r.error) : void 0,
3220
- serverResponseAnimation: $(r.serverResponseAnimation) ? ge.fromJSON(r.serverResponseAnimation) : void 0,
3221
- clientAudioInput: $(r.clientAudioInput) ? fe.fromJSON(r.clientAudioInput) : void 0
3233
+ type: $(r.type) ? ga(r.type) : 0,
3234
+ error: $(r.error) ? ve.fromJSON(r.error) : void 0,
3235
+ serverResponseAnimation: $(r.serverResponseAnimation) ? ye.fromJSON(r.serverResponseAnimation) : void 0,
3236
+ clientAudioInput: $(r.clientAudioInput) ? me.fromJSON(r.clientAudioInput) : void 0
3222
3237
  };
3223
3238
  },
3224
3239
  toJSON(r) {
3225
3240
  const e = {};
3226
- return r.type !== 0 && (e.type = ua(r.type)), r.error !== void 0 && (e.error = we.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = ge.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = fe.toJSON(r.clientAudioInput)), e;
3241
+ return r.type !== 0 && (e.type = ya(r.type)), r.error !== void 0 && (e.error = ve.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = ye.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = me.toJSON(r.clientAudioInput)), e;
3227
3242
  },
3228
3243
  create(r) {
3229
- return Ke.fromPartial(r ?? {});
3244
+ return Xe.fromPartial(r ?? {});
3230
3245
  },
3231
3246
  fromPartial(r) {
3232
- const e = Lt();
3233
- return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? we.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? ge.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? fe.fromPartial(r.clientAudioInput) : void 0, e;
3247
+ const e = Tt();
3248
+ return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? ve.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? ye.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? me.fromPartial(r.clientAudioInput) : void 0, e;
3234
3249
  }
3235
3250
  };
3236
- function ha(r) {
3251
+ function va(r) {
3237
3252
  const e = globalThis.atob(r), t = new Uint8Array(e.length);
3238
3253
  for (let n = 0; n < e.length; ++n)
3239
3254
  t[n] = e.charCodeAt(n);
3240
3255
  return t;
3241
3256
  }
3242
- function fa(r) {
3257
+ function wa(r) {
3243
3258
  const e = [];
3244
3259
  return r.forEach((t) => {
3245
3260
  e.push(globalThis.String.fromCharCode(t));
@@ -3248,23 +3263,7 @@ function fa(r) {
3248
3263
  function $(r) {
3249
3264
  return r != null;
3250
3265
  }
3251
- let ma = (r) => crypto.getRandomValues(new Uint8Array(r)), pa = (r, e, t) => {
3252
- let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
3253
- return (i = e) => {
3254
- let s = "";
3255
- for (; ; ) {
3256
- let l = t(a), o = a | 0;
3257
- for (; o--; )
3258
- if (s += r[l[o] & n] || "", s.length >= i) return s;
3259
- }
3260
- };
3261
- }, ga = (r, e = 21) => pa(r, e | 0, ma);
3262
- const wa = ga("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
3263
- function va() {
3264
- const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), a = String(r.getUTCHours()).padStart(2, "0"), i = String(r.getUTCMinutes()).padStart(2, "0"), s = String(r.getUTCSeconds()).padStart(2, "0"), l = `${e}${t}${n}${a}${i}${s}`, o = wa();
3265
- return `${l}_${o}`;
3266
- }
3267
- class ya {
3266
+ class Aa {
3268
3267
  constructor() {
3269
3268
  d(this, "events", /* @__PURE__ */ new Map());
3270
3269
  }
@@ -3284,7 +3283,7 @@ class ya {
3284
3283
  e ? this.events.delete(e) : this.events.clear();
3285
3284
  }
3286
3285
  }
3287
- class Aa extends ya {
3286
+ class ba extends Aa {
3288
3287
  constructor(t) {
3289
3288
  super();
3290
3289
  d(this, "wsUrl");
@@ -3315,7 +3314,7 @@ class Aa extends ya {
3315
3314
  try {
3316
3315
  this.isConnecting = !0, this.currentCharacterId = t;
3317
3316
  const n = this.buildWebSocketUrl(t);
3318
- h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"), S.logEvent("character_animation_service", "info", {
3317
+ h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"), v.logEvent("character_animation_service", "info", {
3319
3318
  characterId: t,
3320
3319
  event: "connect_success",
3321
3320
  url: n
@@ -3323,7 +3322,7 @@ class Aa extends ya {
3323
3322
  } catch (n) {
3324
3323
  this.isConnecting = !1;
3325
3324
  const a = n instanceof Error ? n.message : String(n);
3326
- throw h.error("[AnimationWebSocketClient] Connection failed:", a), S.logEvent("character_animation_service", "error", {
3325
+ throw h.error("[AnimationWebSocketClient] Connection failed:", a), v.logEvent("character_animation_service", "error", {
3327
3326
  characterId: t,
3328
3327
  event: "connect_failed",
3329
3328
  reason: a
@@ -3344,19 +3343,19 @@ class Aa extends ya {
3344
3343
  return h.error("[AnimationWebSocketClient] WebSocket not connected"), !1;
3345
3344
  try {
3346
3345
  const i = {
3347
- type: Pe.MESSAGE_CLIENT_AUDIO_INPUT,
3346
+ type: Ie.MESSAGE_CLIENT_AUDIO_INPUT,
3348
3347
  clientAudioInput: {
3349
3348
  reqId: t,
3350
3349
  audio: new Uint8Array(n),
3351
3350
  end: a
3352
3351
  }
3353
- }, s = new de();
3354
- Ke.encode(i, s);
3355
- const l = s.finish();
3356
- return this.ws.send(l), !0;
3352
+ }, s = new ue();
3353
+ Xe.encode(i, s);
3354
+ const o = s.finish();
3355
+ return this.ws.send(o), !0;
3357
3356
  } catch (i) {
3358
3357
  const s = i instanceof Error ? i.message : String(i);
3359
- return h.error("[AnimationWebSocketClient] Failed to send audio data:", s), S.logEvent("character_animation_service", "warning", {
3358
+ return h.error("[AnimationWebSocketClient] Failed to send audio data:", s), v.logEvent("character_animation_service", "warning", {
3360
3359
  characterId: this.currentCharacterId,
3361
3360
  event: "send_audio_failed",
3362
3361
  reqId: t,
@@ -3369,7 +3368,7 @@ class Aa extends ya {
3369
3368
  * 使用统一的 ReqID 生成规则:YYYYMMDDHHmmss_nanoid
3370
3369
  */
3371
3370
  generateReqId() {
3372
- return va();
3371
+ return tr();
3373
3372
  }
3374
3373
  /**
3375
3374
  * 获取连接状态
@@ -3395,19 +3394,19 @@ class Aa extends ya {
3395
3394
  this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
3396
3395
  }, this.ws.onmessage = (i) => {
3397
3396
  i.data instanceof ArrayBuffer ? this.handleMessage(i.data) : i.data instanceof Blob ? i.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((s) => {
3398
- h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", s), S.logEvent("character_animation_service", "error", {
3397
+ h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", s), v.logEvent("character_animation_service", "error", {
3399
3398
  characterId: this.currentCharacterId,
3400
3399
  event: "decode_blob_failed",
3401
3400
  reason: s instanceof Error ? s.message : String(s)
3402
3401
  }), this.emit("error", s);
3403
3402
  }) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof i.data);
3404
3403
  }, this.ws.onerror = (i) => {
3405
- h.errorWithError("[AnimationWebSocketClient] WebSocket error:", i), S.logEvent("character_animation_service", "error", {
3404
+ h.errorWithError("[AnimationWebSocketClient] WebSocket error:", i), v.logEvent("character_animation_service", "error", {
3406
3405
  characterId: this.currentCharacterId,
3407
3406
  event: "websocket_error"
3408
3407
  }), this.emit("error", new Error("WebSocket error")), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
3409
3408
  }, this.ws.onclose = (i) => {
3410
- h.log("[AnimationWebSocketClient] WebSocket closed:", i.code, i.reason), this.emit("disconnected", i.reason || "Connection closed"), i.code === 1012 && S.logEvent("character_animation_service", "error", {
3409
+ h.log("[AnimationWebSocketClient] WebSocket closed:", i.code, i.reason), this.emit("disconnected", i.reason || "Connection closed"), i.code === 1012 && v.logEvent("character_animation_service", "error", {
3411
3410
  characterId: this.currentCharacterId,
3412
3411
  event: "service_restart",
3413
3412
  reason: i.reason || "service restart"
@@ -3420,9 +3419,9 @@ class Aa extends ya {
3420
3419
  }
3421
3420
  handleMessage(t) {
3422
3421
  try {
3423
- const n = new N(new Uint8Array(t)), a = Ke.decode(n);
3422
+ const n = new N(new Uint8Array(t)), a = Xe.decode(n);
3424
3423
  if (a.error) {
3425
- h.error(`[AnimationWebSocketClient] Server error: reqId=${a.error.reqId}, code=${a.error.code}, reason=${a.error.reason}`), S.logEvent("character_animation_service", "error", {
3424
+ h.error(`[AnimationWebSocketClient] Server error: reqId=${a.error.reqId}, code=${a.error.code}, reason=${a.error.reason}`), v.logEvent("character_animation_service", "error", {
3426
3425
  characterId: this.currentCharacterId,
3427
3426
  event: "server_error",
3428
3427
  reqId: a.error.reqId,
@@ -3431,8 +3430,8 @@ class Aa extends ya {
3431
3430
  }), this.emit("error", new Error(a.error.reason || "Server error"));
3432
3431
  return;
3433
3432
  }
3434
- if (a.type === Pe.MESSAGE_ERROR) {
3435
- h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), S.logEvent("character_animation_service", "warning", {
3433
+ if (a.type === Ie.MESSAGE_ERROR) {
3434
+ h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), v.logEvent("character_animation_service", "warning", {
3436
3435
  characterId: this.currentCharacterId,
3437
3436
  event: "message_error_without_payload"
3438
3437
  }), this.emit("error", new Error("Server returned error message without error details"));
@@ -3441,7 +3440,7 @@ class Aa extends ya {
3441
3440
  this.emit("message", a);
3442
3441
  } catch (n) {
3443
3442
  const a = n instanceof Error ? n.message : String(n);
3444
- h.error("[AnimationWebSocketClient] Failed to decode message:", a), S.logEvent("character_animation_service", "error", {
3443
+ h.error("[AnimationWebSocketClient] Failed to decode message:", a), v.logEvent("character_animation_service", "error", {
3445
3444
  characterId: this.currentCharacterId,
3446
3445
  event: "decode_failed",
3447
3446
  reason: a
@@ -3464,17 +3463,16 @@ class Sa {
3464
3463
  d(this, "dataController");
3465
3464
  // 组合播放层
3466
3465
  d(this, "currentReqId", null);
3467
- d(this, "hasSentEnd", !1);
3468
- d(this, "audioBytesPerSecond", x.audio.sampleRate * 2);
3466
+ d(this, "audioBytesPerSecond", I.audio.sampleRate * 2);
3469
3467
  d(this, "audioMetrics", this.createAudioMetrics());
3470
3468
  this.dataController = e;
3471
- const t = S.getEnvironmentConfig();
3472
- this.wsClient = new Aa({
3469
+ const t = v.getEnvironmentConfig();
3470
+ this.wsClient = new ba({
3473
3471
  wsUrl: t.driveningressWsUrl,
3474
3472
  reconnectAttempts: 5,
3475
3473
  debug: !1,
3476
- jwtToken: S.sessionToken || void 0,
3477
- appId: S.appId || void 0
3474
+ jwtToken: v.sessionToken || void 0,
3475
+ appId: v.appId || void 0
3478
3476
  }), this.setupWebSocketListeners();
3479
3477
  }
3480
3478
  /**
@@ -3485,20 +3483,21 @@ class Sa {
3485
3483
  }
3486
3484
  /**
3487
3485
  * 发送音频数据到服务器
3486
+ * 注意:打断逻辑由 AvatarController.send() 统一处理,这里只负责网络通信
3488
3487
  */
3489
3488
  sendAudioData(e, t) {
3490
- var l, o;
3491
- this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(), S.logEvent("character_manager", "info", {
3489
+ var o, l;
3490
+ this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.resetAudioMetrics(), v.logEvent("character_manager", "info", {
3492
3491
  characterId: this.dataController.getAvatarId(),
3493
3492
  event: "conversation_started",
3494
3493
  reqId: this.currentReqId
3495
- })), t && (this.hasSentEnd = !0);
3494
+ }));
3496
3495
  const n = this.audioMetrics;
3497
3496
  let a = !1;
3498
3497
  n.startTimestamp === 0 && (n.startTimestamp = Date.now(), a = !0), n.accumulatedBytes += e.byteLength;
3499
3498
  const i = n.accumulatedBytes / this.audioBytesPerSecond;
3500
3499
  if (i >= 2 && n.tap2Timestamp === 0 && (n.tap2Timestamp = Date.now(), a = !0), i >= 4 && n.tap4Timestamp === 0 && (n.tap4Timestamp = Date.now(), a = !0), t && n.endTimestamp === 0 && (n.endTimestamp = Date.now(), a = !0), e.byteLength === 0 && !t && h.warn("[NetworkLayer] Warning: sending empty audio data (size=0, end=false)"), !this.wsClient.sendAudioData(this.currentReqId, e, t)) {
3501
- h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (o = (l = this.dataController).onError) == null || o.call(l, new oe("Failed to send audio data to WebSocket", "SEND_FAILED")), S.logEvent("character_animation_service", "error", {
3500
+ h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (l = (o = this.dataController).onError) == null || l.call(o, new ee("Failed to send audio data to WebSocket", "SEND_FAILED")), v.logEvent("character_animation_service", "error", {
3502
3501
  characterId: this.dataController.getAvatarId(),
3503
3502
  event: "send_audio_failed",
3504
3503
  reqId: this.currentReqId
@@ -3511,7 +3510,7 @@ class Sa {
3511
3510
  * 断开连接
3512
3511
  */
3513
3512
  disconnect() {
3514
- this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentReqId = null, this.hasSentEnd = !1;
3513
+ this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentReqId = null;
3515
3514
  }
3516
3515
  /**
3517
3516
  * 获取当前请求ID
@@ -3523,7 +3522,7 @@ class Sa {
3523
3522
  * 重置请求ID(用于打断后清理)
3524
3523
  */
3525
3524
  resetReqId() {
3526
- this.currentReqId = null, this.hasSentEnd = !1, this.resetAudioMetrics();
3525
+ this.currentReqId = null, this.resetAudioMetrics();
3527
3526
  }
3528
3527
  /**
3529
3528
  * 设置 WebSocket 事件监听器
@@ -3532,29 +3531,29 @@ class Sa {
3532
3531
  setupWebSocketListeners() {
3533
3532
  this.wsClient.removeAllListeners(), this.wsClient.on("connected", () => {
3534
3533
  var e, t;
3535
- this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, be.connected), S.logEvent("character_animation_service", "info", {
3534
+ this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, _e.connected), v.logEvent("character_animation_service", "info", {
3536
3535
  characterId: this.dataController.getAvatarId(),
3537
3536
  event: "connected"
3538
3537
  });
3539
3538
  }), this.wsClient.on("disconnected", () => {
3540
3539
  var e, t;
3541
- this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, be.disconnected), S.logEvent("character_animation_service", "warning", {
3540
+ this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, _e.disconnected), v.logEvent("character_animation_service", "warning", {
3542
3541
  characterId: this.dataController.getAvatarId(),
3543
3542
  event: "disconnected"
3544
3543
  });
3545
3544
  }), this.wsClient.on("reconnecting", () => {
3546
- S.logEvent("character_animation_service", "info", {
3545
+ v.logEvent("character_animation_service", "info", {
3547
3546
  characterId: this.dataController.getAvatarId(),
3548
3547
  event: "reconnecting"
3549
3548
  });
3550
3549
  }), this.wsClient.on("error", (e) => {
3551
3550
  var n, a, i, s;
3552
3551
  const t = e instanceof Error ? e.message : String(e);
3553
- h.error("[NetworkLayer] WebSocket error:", t), S.logEvent("character_animation_service", "error", {
3552
+ h.error("[NetworkLayer] WebSocket error:", t), v.logEvent("character_animation_service", "error", {
3554
3553
  characterId: this.dataController.getAvatarId(),
3555
3554
  event: "websocket_error",
3556
3555
  reason: t
3557
- }), (a = (n = this.dataController).onConnectionState) == null || a.call(n, be.failed), (s = (i = this.dataController).onError) == null || s.call(i, e);
3556
+ }), (a = (n = this.dataController).onConnectionState) == null || a.call(n, _e.failed), (s = (i = this.dataController).onError) == null || s.call(i, e);
3558
3557
  }), this.wsClient.on("message", (e) => {
3559
3558
  this.handleMessage(e);
3560
3559
  });
@@ -3565,16 +3564,16 @@ class Sa {
3565
3564
  handleMessage(e) {
3566
3565
  try {
3567
3566
  switch (e.type) {
3568
- case Pe.MESSAGE_SERVER_RESPONSE_ANIMATION:
3567
+ case Ie.MESSAGE_SERVER_RESPONSE_ANIMATION:
3569
3568
  this.handleAnimationMessage(e);
3570
3569
  break;
3571
- case Pe.MESSAGE_ERROR:
3570
+ case Ie.MESSAGE_ERROR:
3572
3571
  this.handleErrorMessage(e);
3573
3572
  break;
3574
3573
  }
3575
3574
  } catch (t) {
3576
3575
  const n = t instanceof Error ? t.message : String(t);
3577
- h.error("[NetworkLayer] Failed to handle message:", n), S.logEvent("character_manager", "error", {
3576
+ h.error("[NetworkLayer] Failed to handle message:", n), v.logEvent("character_manager", "error", {
3578
3577
  characterId: this.dataController.getAvatarId(),
3579
3578
  event: "handle_message_failed",
3580
3579
  reason: n
@@ -3591,7 +3590,7 @@ class Sa {
3591
3590
  }
3592
3591
  const { reqId: t, animation: n } = e.serverResponseAnimation;
3593
3592
  if (!this.currentReqId || t !== this.currentReqId) {
3594
- h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`), S.logEvent("character_manager", "warning", {
3593
+ h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`), v.logEvent("character_manager", "warning", {
3595
3594
  characterId: this.dataController.getAvatarId(),
3596
3595
  event: "animation_reqid_mismatch",
3597
3596
  expectedReqId: this.currentReqId,
@@ -3601,9 +3600,9 @@ class Sa {
3601
3600
  }
3602
3601
  if (n != null && n.keyframes && n.keyframes.length > 0) {
3603
3602
  const a = n.keyframes;
3604
- this.dataController.sendKeyframes(a), this.dataController.getIsPlaying() || this.dataController.startStreamingPlayback(), this.audioMetrics.didRecvFirstFlame || (this.audioMetrics.didRecvFirstFlame = !0, this.audioMetrics.recvFirstFlameTimestamp = Date.now(), this.currentReqId && this.reportAudioMetrics(this.currentReqId));
3603
+ this.dataController.yieldFramesData(a, t), this.dataController.getIsPlaying() || this.dataController.startStreamingPlayback(), this.audioMetrics.didRecvFirstFlame || (this.audioMetrics.didRecvFirstFlame = !0, this.audioMetrics.recvFirstFlameTimestamp = Date.now(), this.currentReqId && this.reportAudioMetrics(this.currentReqId));
3605
3604
  } else
3606
- h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`), S.logEvent("character_manager", "warning", {
3605
+ h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`), v.logEvent("character_manager", "warning", {
3607
3606
  characterId: this.dataController.getAvatarId(),
3608
3607
  event: "animation_empty_keyframes",
3609
3608
  reqId: t
@@ -3615,13 +3614,13 @@ class Sa {
3615
3614
  handleErrorMessage(e) {
3616
3615
  var n, a, i, s;
3617
3616
  if (!e.error) {
3618
- h.warn("[NetworkLayer] MESSAGE_ERROR received but message.error is empty"), e.serverResponseAnimation && (h.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message"), S.logEvent("character_manager", "warning", {
3617
+ h.warn("[NetworkLayer] MESSAGE_ERROR received but message.error is empty"), e.serverResponseAnimation && (h.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message"), v.logEvent("character_manager", "warning", {
3619
3618
  characterId: this.dataController.getAvatarId(),
3620
3619
  event: "message_error_with_payload"
3621
3620
  }), this.handleAnimationMessage(e));
3622
3621
  return;
3623
3622
  }
3624
- h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`), S.logEvent("character_manager", "error", {
3623
+ h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`), v.logEvent("character_manager", "error", {
3625
3624
  characterId: this.dataController.getAvatarId(),
3626
3625
  event: "server_error",
3627
3626
  reqId: e.error.reqId,
@@ -3629,14 +3628,14 @@ class Sa {
3629
3628
  reason: e.error.reason
3630
3629
  });
3631
3630
  const t = ((n = e.error.code) == null ? void 0 : n.toString().toLowerCase()) ?? "";
3632
- (t.includes("unauth") || t === "401") && S.logEvent("sdk_verify", "error", {
3631
+ (t.includes("unauth") || t === "401") && v.logEvent("sdk_verify", "error", {
3633
3632
  characterId: this.dataController.getAvatarId(),
3634
3633
  reqId: e.error.reqId,
3635
3634
  reason: e.error.reason
3636
- }), (s = (i = this.dataController).onError) == null || s.call(i, new oe(
3635
+ }), (s = (i = this.dataController).onError) == null || s.call(i, new ee(
3637
3636
  e.error.reason || "Server error occurred",
3638
3637
  ((a = e.error.code) == null ? void 0 : a.toString()) || "SERVER_ERROR"
3639
- )), this.currentReqId && e.error.reqId === this.currentReqId && this.dataController.interrupt();
3638
+ )), this.currentReqId && e.error.reqId === this.currentReqId && (h.warn("[NetworkLayer] Server error for current request - triggering audio-only mode via empty keyframes"), this.dataController.yieldFramesData([], e.error.reqId));
3640
3639
  }
3641
3640
  /**
3642
3641
  * 创建音频指标
@@ -3662,7 +3661,7 @@ class Sa {
3662
3661
  * 上报音频指标
3663
3662
  */
3664
3663
  reportAudioMetrics(e) {
3665
- !e || this.audioMetrics.startTimestamp === 0 || S.logEvent("send_audio_measure", "info", {
3664
+ !e || this.audioMetrics.startTimestamp === 0 || v.logEvent("send_audio_measure", "info", {
3666
3665
  reqId: e,
3667
3666
  start: this.audioMetrics.startTimestamp,
3668
3667
  tap2: this.audioMetrics.tap2Timestamp,
@@ -3672,8 +3671,8 @@ class Sa {
3672
3671
  });
3673
3672
  }
3674
3673
  }
3675
- class ba {
3676
- // Maximum pending audio chunks to prevent memory leak
3674
+ class Ca {
3675
+ // 音频独立播放模式标志
3677
3676
  constructor(e, t) {
3678
3677
  // ========== Configuration and Composition ==========
3679
3678
  d(this, "networkLayer");
@@ -3686,7 +3685,10 @@ class ba {
3686
3685
  d(this, "isPlaying", !1);
3687
3686
  // ========== State Management ==========
3688
3687
  d(this, "isConnected", !1);
3689
- d(this, "currentState", T.idle);
3688
+ d(this, "currentState", F.idle);
3689
+ // ========== ReqId Management (for external data mode) ==========
3690
+ d(this, "currentReqId", null);
3691
+ d(this, "reqEnd", !1);
3690
3692
  // ========== Event System ==========
3691
3693
  d(this, "onConnectionState", null);
3692
3694
  d(this, "onAvatarState", null);
@@ -3707,7 +3709,10 @@ class ba {
3707
3709
  d(this, "KEYFRAMES_CLEANUP_THRESHOLD", 3e3);
3708
3710
  // Cleanup threshold (keep some buffer)
3709
3711
  d(this, "MAX_PENDING_AUDIO_CHUNKS", 100);
3710
- this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? Me.network, this.playbackMode === Me.network && (this.networkLayer = new Sa(this));
3712
+ // Maximum pending audio chunks to prevent memory leak
3713
+ // ========== Audio Only Mode ==========
3714
+ d(this, "isAudioOnlyMode", !1);
3715
+ this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? we.network, this.playbackMode === we.network && (this.networkLayer = new Sa(this));
3711
3716
  }
3712
3717
  // ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
3713
3718
  /**
@@ -3752,23 +3757,31 @@ class ba {
3752
3757
  getAnimationPlayer() {
3753
3758
  return this.animationPlayer;
3754
3759
  }
3760
+ /**
3761
+ * Get current request ID
3762
+ * Returns the current reqId for the active audio session
3763
+ * @returns Current reqId, or null if no active session
3764
+ */
3765
+ getCurrentReqId() {
3766
+ return this.getEffectiveReqId();
3767
+ }
3755
3768
  // ========== Network Mode Interface ==========
3756
3769
  /**
3757
3770
  * Start service (network mode only)
3758
3771
  */
3759
3772
  async start() {
3760
3773
  if (!this.networkLayer)
3761
- throw new oe(
3774
+ throw new ee(
3762
3775
  "Network layer not available. Use network playback mode.",
3763
3776
  "NETWORK_LAYER_NOT_AVAILABLE"
3764
3777
  );
3765
3778
  if (!this.animationPlayer) {
3766
- this.animationPlayer = new Ce();
3779
+ this.animationPlayer = new le();
3767
3780
  try {
3768
3781
  await this.animationPlayer.createAndInitializeStreamingPlayer();
3769
3782
  } catch (e) {
3770
3783
  const t = e instanceof Error ? e.message : String(e);
3771
- throw h.error("[AvatarController] Failed to create streaming player:", t), S.logEvent("character_player", "error", {
3784
+ throw h.error("[AvatarController] Failed to create streaming player:", t), v.logEvent("character_player", "error", {
3772
3785
  characterId: this.avatar.id,
3773
3786
  event: "streaming_player_init_failed",
3774
3787
  reason: t
@@ -3780,61 +3793,109 @@ class ba {
3780
3793
  /**
3781
3794
  * Send audio to server (network mode only)
3782
3795
  * Also cache to data layer for playback
3796
+ * @returns reqId - Request ID for this audio session
3783
3797
  */
3784
3798
  send(e, t = !1) {
3785
- var n, a;
3786
- if (!this.networkLayer || !this.isConnected) {
3787
- (n = this.onError) == null || n.call(this, new oe("Service not connected", "NOT_CONNECTED")), S.logEvent("character_manager", "warning", {
3799
+ var a, i;
3800
+ if (!this.networkLayer || !this.isConnected)
3801
+ return (a = this.onError) == null || a.call(this, new ee("Service not connected", "NOT_CONNECTED")), v.logEvent("character_manager", "warning", {
3788
3802
  characterId: this.avatar.id,
3789
3803
  event: "send_not_connected"
3790
- });
3791
- return;
3792
- }
3793
- this.networkLayer.sendAudioData(e, t), this.addAudioChunkToBuffer(new Uint8Array(e), t), (a = this.onAvatarState) == null || a.call(this, T.active);
3804
+ }), null;
3805
+ const n = this.networkLayer.getCurrentReqId();
3806
+ return this.reqEnd && this.isPlaying && n && this.interrupt(), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0), this.addAudioChunkToBuffer(new Uint8Array(e), t), (i = this.onAvatarState) == null || i.call(this, F.active), this.networkLayer.getCurrentReqId();
3794
3807
  }
3795
3808
  /**
3796
3809
  * Close service (network mode only)
3797
3810
  */
3798
3811
  close() {
3799
- var e, t;
3800
- (this.isPlaying || this.currentState === T.paused) && this.stopPlayback(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.keyframesOffset = 0, (e = this.networkLayer) == null || e.disconnect(), this.isConnected = !1, (t = this.onConnectionState) == null || t.call(this, be.disconnected);
3812
+ var e;
3813
+ (this.isPlaying || this.currentState === F.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentReqId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this, _e.disconnected);
3801
3814
  }
3802
3815
  // ========== External Data Mode Interface ==========
3803
3816
  /**
3804
- * Start playback (external data mode)
3805
- * Must call this method first with initial data to start playback
3817
+ * Playback existing audio and animation data (external data mode)
3818
+ * Starts a new conversation by generating a new reqId and interrupting any existing conversation
3819
+ * @param initialAudioChunks - Existing audio chunks to playback
3820
+ * @param initialKeyframes - Existing animation keyframes to playback
3821
+ * @returns reqId - New request ID for this conversation session
3806
3822
  */
3807
- async play(e, t) {
3808
- if (!this.isPlaying) {
3809
- if (this.animationPlayer || (this.animationPlayer = new Ce()), this.animationPlayer.isStreamingReady() || await this.animationPlayer.createAndInitializeStreamingPlayer(), e && e.length > 0 && this.pendingAudioChunks.push(...e), t && t.length > 0 && (this.currentKeyframes.length === 0 ? this.currentKeyframes = t : this.currentKeyframes.push(...t), this.emit("keyframesUpdate", this.currentKeyframes)), this.currentKeyframes.length === 0)
3810
- throw new oe("No animation keyframes to play", "NO_ANIMATION");
3811
- if (this.pendingAudioChunks.length === 0)
3812
- throw new oe("No audio chunks to play", "NO_AUDIO");
3813
- await this.startStreamingPlayback();
3814
- }
3823
+ async playback(e, t) {
3824
+ if ((this.isPlaying || this.currentReqId) && this.interrupt(), this.currentReqId = this.generateAndLogNewReqId(), this.reqEnd = !1, this.clearPlaybackData(), this.animationPlayer || (this.animationPlayer = new le()), 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"), v.logEvent("character_manager", "info", {
3825
+ characterId: this.avatar.id,
3826
+ event: "empty_animation_data_audio_only_fallback",
3827
+ reqId: this.currentReqId
3828
+ }), this.isAudioOnlyMode = !0), this.pendingAudioChunks.length === 0)
3829
+ throw new ee("No audio chunks to play", "NO_AUDIO");
3830
+ return this.isAudioOnlyMode ? await this.startAudioOnlyPlayback() : await this.startStreamingPlayback(), this.currentReqId;
3815
3831
  }
3816
3832
  /**
3817
3833
  * Send audio data (external data mode)
3818
- * Stream additional audio data after play()
3834
+ * Stream additional audio data after playback()
3835
+ * @returns reqId - Request ID for this audio session
3819
3836
  */
3820
- sendAudioChunk(e, t = !1) {
3837
+ yieldAudioData(e, t = !1) {
3821
3838
  var n, a;
3822
- if (this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()))
3839
+ if (this.reqEnd && this.isPlaying && this.currentReqId && (this.interrupt(), this.currentReqId = this.generateAndLogNewReqId(), this.reqEnd = !1), this.currentReqId || (this.isPlaying && this.interrupt(), this.currentReqId = this.generateAndLogNewReqId(), this.reqEnd = !1, this.clearPlaybackData()), t && (this.reqEnd = !0), this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()))
3823
3840
  this.animationPlayer.addAudioChunk(e, t);
3824
3841
  else if (e.length > 0 || t) {
3825
3842
  if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
3826
3843
  const i = this.pendingAudioChunks.findIndex((s) => s.isLast);
3827
3844
  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`);
3828
3845
  }
3829
- this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onAvatarState) == null || a.call(this, T.active);
3846
+ this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onAvatarState) == null || a.call(this, F.active);
3830
3847
  }
3848
+ return this.currentReqId;
3831
3849
  }
3832
3850
  /**
3833
3851
  * Send animation keyframes (external data mode or network mode)
3834
- * Stream additional animation data after play()
3835
- */
3836
- sendKeyframes(e) {
3837
- this.currentKeyframes.length === 0 ? this.currentKeyframes = e : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes);
3852
+ * Stream additional animation data after playback()
3853
+ * @param keyframes - Animation keyframes to send
3854
+ * @param reqId - Request ID (required). If reqId doesn't match current reqId, keyframes will be discarded.
3855
+ * Use getCurrentReqId() to get the current reqId.
3856
+ */
3857
+ yieldFramesData(e, t) {
3858
+ if (!t || typeof t != "string") {
3859
+ h.error("[AvatarController] yieldFramesData requires a valid reqId. Use getCurrentReqId() to get the current reqId."), v.logEvent("character_manager", "error", {
3860
+ characterId: this.avatar.id,
3861
+ event: "keyframes_missing_reqid",
3862
+ receivedReqId: t
3863
+ });
3864
+ return;
3865
+ }
3866
+ const n = this.getEffectiveReqId();
3867
+ if (!n || t !== n) {
3868
+ h.warn(`[AvatarController] Ignoring mismatched keyframes - expected reqId: ${n}, received reqId: ${t}`), v.logEvent("character_manager", "warning", {
3869
+ characterId: this.avatar.id,
3870
+ event: "keyframes_reqid_mismatch",
3871
+ expectedReqId: n,
3872
+ receivedReqId: t
3873
+ });
3874
+ return;
3875
+ }
3876
+ if (this.isAudioOnlyMode) {
3877
+ h.warn("[AvatarController] Ignoring animation data in audio-only mode"), v.logEvent("character_manager", "info", {
3878
+ characterId: this.avatar.id,
3879
+ event: "animation_data_ignored_audio_only",
3880
+ reqId: t
3881
+ });
3882
+ return;
3883
+ }
3884
+ if (!e || e.length === 0) {
3885
+ h.warn("[AvatarController] Empty animation data received - enabling audio-only mode"), v.logEvent("character_manager", "info", {
3886
+ characterId: this.avatar.id,
3887
+ event: "empty_animation_data_audio_only_fallback",
3888
+ reqId: t
3889
+ }), this.enableAudioOnlyMode();
3890
+ return;
3891
+ }
3892
+ if (this.currentKeyframes.length === 0 ? this.currentKeyframes = e : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes), !this.isPlaying && this.pendingAudioChunks.length > 0 && this.currentKeyframes.length > 0) {
3893
+ const a = I.audio.sampleRate * 2;
3894
+ this.pendingAudioChunks.reduce((s, o) => s + o.data.length, 0) >= a && this.startStreamingPlayback().catch((s) => {
3895
+ var o;
3896
+ h.error("[AvatarController] Failed to auto-start playback:", s), (o = this.onError) == null || o.call(this, new ee("Failed to start playback", "PLAYBACK_START_FAILED"));
3897
+ });
3898
+ }
3838
3899
  }
3839
3900
  // ========== Common Interface ==========
3840
3901
  /**
@@ -3843,7 +3904,7 @@ class ba {
3843
3904
  */
3844
3905
  pause() {
3845
3906
  var e, t, n;
3846
- !this.isPlaying || this.currentState === T.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = T.paused, (t = this.onAvatarState) == null || t.call(this, T.paused), h.log("[AvatarController] Playback paused"), S.logEvent("character_player", "info", {
3907
+ !this.isPlaying || this.currentState === F.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = F.paused, (t = this.onAvatarState) == null || t.call(this, F.paused), h.log("[AvatarController] Playback paused"), v.logEvent("character_player", "info", {
3847
3908
  characterId: this.avatar.id,
3848
3909
  event: "playback_paused",
3849
3910
  reqId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentReqId()) || void 0
@@ -3856,7 +3917,7 @@ class ba {
3856
3917
  */
3857
3918
  async resume() {
3858
3919
  var e, t, n;
3859
- !this.isPlaying || this.currentState !== T.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = T.playing, (t = this.onAvatarState) == null || t.call(this, T.playing), h.log("[AvatarController] Playback resumed"), S.logEvent("character_player", "info", {
3920
+ !this.isPlaying || this.currentState !== F.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = F.playing, (t = this.onAvatarState) == null || t.call(this, F.playing), h.log("[AvatarController] Playback resumed"), v.logEvent("character_player", "info", {
3860
3921
  characterId: this.avatar.id,
3861
3922
  event: "playback_resumed",
3862
3923
  reqId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentReqId()) || void 0
@@ -3867,15 +3928,15 @@ class ba {
3867
3928
  */
3868
3929
  interrupt() {
3869
3930
  var e;
3870
- this.currentState === T.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
3871
- })), this.stopPlayback(), this.emit("interrupt"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.keyframesOffset = 0, this.networkLayer && this.networkLayer.resetReqId();
3931
+ this.currentState === F.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
3932
+ })), this.stopPlayback(), this.emit("interrupt"), this.clearPlaybackData(), this.resetReqIdState(), this.isAudioOnlyMode = !1;
3872
3933
  }
3873
3934
  /**
3874
3935
  * Clear all data and resources
3875
3936
  */
3876
3937
  clear() {
3877
3938
  var e, t;
3878
- this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.isConnected = !1, this.currentState = T.idle, (t = this.onAvatarState) == null || t.call(this, T.idle);
3939
+ this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.clearPlaybackData(), this.isConnected = !1, this.currentState = F.idle, (t = this.onAvatarState) == null || t.call(this, F.idle), this.networkLayer || (this.currentReqId = null), this.reqEnd = !1;
3879
3940
  }
3880
3941
  /**
3881
3942
  * Dispose controller, clean up all callbacks to avoid memory leaks
@@ -3885,9 +3946,44 @@ class ba {
3885
3946
  dispose() {
3886
3947
  this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
3887
3948
  }
3949
+ // ========== Internal Helper Methods ==========
3950
+ /**
3951
+ * Generate new reqId and log conversation started event
3952
+ * @private
3953
+ */
3954
+ generateAndLogNewReqId() {
3955
+ const e = tr();
3956
+ return v.logEvent("character_manager", "info", {
3957
+ characterId: this.avatar.id,
3958
+ event: "conversation_started",
3959
+ reqId: e
3960
+ }), e;
3961
+ }
3962
+ /**
3963
+ * Clear playback data (keyframes, audio chunks, and playback state)
3964
+ * @private
3965
+ */
3966
+ clearPlaybackData() {
3967
+ this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.keyframesOffset = 0, this.isAudioOnlyMode = !1;
3968
+ }
3969
+ /**
3970
+ * Reset reqId state (for both network and external modes)
3971
+ * @private
3972
+ */
3973
+ resetReqIdState() {
3974
+ this.networkLayer ? this.networkLayer.resetReqId() : this.currentReqId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1;
3975
+ }
3976
+ /**
3977
+ * Get effective reqId (handles both network and external modes)
3978
+ * @private
3979
+ */
3980
+ getEffectiveReqId() {
3981
+ var e;
3982
+ return this.playbackMode === we.network ? ((e = this.networkLayer) == null ? void 0 : e.getCurrentReqId()) || null : this.currentReqId;
3983
+ }
3888
3984
  // ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
3889
3985
  /**
3890
- * Start streaming playback (internal method, called by NetworkLayer or play())
3986
+ * Start streaming playback (internal method, called by NetworkLayer or playback())
3891
3987
  * @internal
3892
3988
  */
3893
3989
  startStreamingPlayback() {
@@ -3929,10 +4025,17 @@ class ba {
3929
4025
  */
3930
4026
  async startStreamingPlaybackInternal() {
3931
4027
  var e, t, n;
3932
- if (!this.animationPlayer) {
3933
- h.error("[AvatarController] AnimationPlayer not initialized");
3934
- return;
3935
- }
4028
+ if (this.animationPlayer || (this.animationPlayer = new le()), !this.animationPlayer.isStreamingReady())
4029
+ try {
4030
+ await this.animationPlayer.createAndInitializeStreamingPlayer();
4031
+ } catch (a) {
4032
+ const i = a instanceof Error ? a.message : String(a);
4033
+ throw h.error("[AvatarController] Failed to create streaming player:", i), v.logEvent("character_player", "error", {
4034
+ characterId: this.avatar.id,
4035
+ event: "streaming_player_init_failed",
4036
+ reason: i
4037
+ }), a;
4038
+ }
3936
4039
  if (!this.currentKeyframes || this.currentKeyframes.length === 0) {
3937
4040
  h.warn("[AvatarController] No animation keyframes to play");
3938
4041
  return;
@@ -3940,21 +4043,21 @@ class ba {
3940
4043
  try {
3941
4044
  await this.animationPlayer.prepareStreamingPlayer(() => {
3942
4045
  var i, s;
3943
- this.isPlaying = !1, this.currentState = T.idle, (i = this.onAvatarState) == null || i.call(this, T.idle), this.emit("stopRendering"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId(), S.logEvent("character_player", "info", {
4046
+ this.isPlaying = !1, this.currentState = F.idle, (i = this.onAvatarState) == null || i.call(this, F.idle), this.emit("stopRendering"), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.resetReqId() : this.currentReqId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1, v.logEvent("character_player", "info", {
3944
4047
  characterId: this.avatar.id,
3945
4048
  event: "playback_ended",
3946
4049
  reqId: ((s = this.networkLayer) == null ? void 0 : s.getCurrentReqId()) || void 0
3947
4050
  });
3948
4051
  }), this.emit("startRendering");
3949
4052
  const a = this.animationPlayer.getStreamingPlayer();
3950
- a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = T.playing, (e = this.onAvatarState) == null || e.call(this, T.playing), this.startPlaybackLoop(), S.logEvent("character_player", "info", {
4053
+ a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = F.playing, (e = this.onAvatarState) == null || e.call(this, F.playing), this.startPlaybackLoop(), v.logEvent("character_player", "info", {
3951
4054
  characterId: this.avatar.id,
3952
4055
  event: "playback_started",
3953
4056
  reqId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentReqId()) || void 0
3954
4057
  });
3955
4058
  } catch (a) {
3956
4059
  const i = a instanceof Error ? a.message : String(a);
3957
- h.error("[AvatarController] Failed to start streaming playback:", i), (n = this.onError) == null || n.call(this, new oe("Failed to start streaming playback", "INIT_FAILED")), this.isPlaying = !1;
4060
+ h.error("[AvatarController] Failed to start streaming playback:", i), (n = this.onError) == null || n.call(this, new ee("Failed to start streaming playback", "INIT_FAILED")), this.isPlaying = !1;
3958
4061
  }
3959
4062
  }
3960
4063
  /**
@@ -3963,8 +4066,8 @@ class ba {
3963
4066
  startPlaybackLoop() {
3964
4067
  if (this.playbackLoopId)
3965
4068
  return;
3966
- const e = x.animation.fps, t = async () => {
3967
- if (!this.isPlaying || this.currentState === T.paused || !this.animationPlayer) {
4069
+ const e = I.animation.fps, t = async () => {
4070
+ if (!this.isPlaying || this.currentState === F.paused || !this.animationPlayer) {
3968
4071
  this.playbackLoopId = null;
3969
4072
  return;
3970
4073
  }
@@ -3982,13 +4085,13 @@ class ba {
3982
4085
  return;
3983
4086
  }
3984
4087
  if (this.lastRenderedFrameIndex = a, this.currentKeyframes.length > this.MAX_KEYFRAMES) {
3985
- const s = this.KEYFRAMES_CLEANUP_THRESHOLD, l = a - s;
3986
- l > 0 && l < a && (this.currentKeyframes.splice(0, l), this.keyframesOffset += l, i = a - this.keyframesOffset, i < 0 && (i = 0), i >= this.currentKeyframes.length && (i = this.currentKeyframes.length - 1), h.log(`[AvatarController] Cleaned up ${l} old keyframes (kept ${this.currentKeyframes.length} frames, offset: ${this.keyframesOffset})`));
4088
+ const s = this.KEYFRAMES_CLEANUP_THRESHOLD, o = a - s;
4089
+ o > 0 && o < a && (this.currentKeyframes.splice(0, o), this.keyframesOffset += o, i = a - this.keyframesOffset, i < 0 && (i = 0), i >= this.currentKeyframes.length && (i = this.currentKeyframes.length - 1), h.log(`[AvatarController] Cleaned up ${o} old keyframes (kept ${this.currentKeyframes.length} frames, offset: ${this.keyframesOffset})`));
3987
4090
  }
3988
4091
  if (i >= 0 && i < this.currentKeyframes.length) {
3989
- const s = this.currentKeyframes[i], l = zt(s), o = S.getAvatarCore();
3990
- if (o) {
3991
- const p = await o.computeFrameFlatFromParams(l, this.characterHandle ?? void 0);
4092
+ const s = this.currentKeyframes[i], o = $t(s), l = v.getAvatarCore();
4093
+ if (l) {
4094
+ const p = await l.computeFrameFlatFromParams(o, this.characterHandle ?? void 0);
3992
4095
  p && this.renderCallback && this.renderCallback(p, a);
3993
4096
  }
3994
4097
  }
@@ -4006,6 +4109,73 @@ class ba {
4006
4109
  stopPlaybackLoop() {
4007
4110
  this.playbackLoopId && (cancelAnimationFrame(this.playbackLoopId), this.playbackLoopId = null);
4008
4111
  }
4112
+ // ========== Audio Only Mode ==========
4113
+ /**
4114
+ * 启用音频独立播放模式(当服务器错误或超时时调用)
4115
+ * 此模式下,音频会独立播放,不依赖动画数据
4116
+ * 一旦启用,本次会话后续的动画数据将被忽略
4117
+ * @private
4118
+ */
4119
+ enableAudioOnlyMode() {
4120
+ this.isAudioOnlyMode || (h.warn("[AvatarController] Enabling audio-only playback mode"), this.isAudioOnlyMode = !0, !this.isPlaying && this.pendingAudioChunks.length > 0 && this.startAudioOnlyPlayback().catch((e) => {
4121
+ h.error("[AvatarController] Failed to start audio-only playback:", e), this.isAudioOnlyMode = !1;
4122
+ }));
4123
+ }
4124
+ /**
4125
+ * 音频独立播放(完全独立的逻辑,不影响正常播放流程)
4126
+ * @private
4127
+ */
4128
+ async startAudioOnlyPlayback() {
4129
+ var e, t;
4130
+ if (this.animationPlayer || (this.animationPlayer = new le()), !this.animationPlayer.isStreamingReady())
4131
+ try {
4132
+ await this.animationPlayer.createAndInitializeStreamingPlayer();
4133
+ } catch (n) {
4134
+ const a = n instanceof Error ? n.message : String(n);
4135
+ throw h.error("[AvatarController] Failed to create streaming player for audio-only mode:", a), v.logEvent("character_player", "error", {
4136
+ characterId: this.avatar.id,
4137
+ event: "audio_only_streaming_player_init_failed",
4138
+ reason: a
4139
+ }), n;
4140
+ }
4141
+ try {
4142
+ await this.animationPlayer.prepareStreamingPlayer(() => {
4143
+ var a;
4144
+ this.isPlaying = !1, this.currentState = F.idle, (a = this.onAvatarState) == null || a.call(this, F.idle), this.isAudioOnlyMode = !1, this.clearPlaybackData(), this.resetReqIdState(), v.logEvent("character_player", "info", {
4145
+ characterId: this.avatar.id,
4146
+ event: "audio_only_playback_ended",
4147
+ reqId: this.getEffectiveReqId() || void 0
4148
+ });
4149
+ });
4150
+ const n = this.animationPlayer.getStreamingPlayer();
4151
+ n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = F.playing, (e = this.onAvatarState) == null || e.call(this, F.playing), this.startAudioMonitoringLoop(), v.logEvent("character_player", "info", {
4152
+ characterId: this.avatar.id,
4153
+ event: "audio_only_playback_started",
4154
+ reqId: this.getEffectiveReqId() || void 0
4155
+ });
4156
+ } catch (n) {
4157
+ const a = n instanceof Error ? n.message : String(n);
4158
+ throw h.error("[AvatarController] Failed to start audio-only playback:", a), (t = this.onError) == null || t.call(this, new ee("Failed to start audio-only playback", "AUDIO_ONLY_INIT_FAILED")), this.isPlaying = !1, this.isAudioOnlyMode = !1, n;
4159
+ }
4160
+ }
4161
+ /**
4162
+ * 音频监控循环(仅用于音频独立模式)
4163
+ * 只检测音频是否结束,不进行动画渲染
4164
+ * @private
4165
+ */
4166
+ startAudioMonitoringLoop() {
4167
+ if (this.playbackLoopId)
4168
+ return;
4169
+ const e = () => {
4170
+ var t;
4171
+ if (!this.isAudioOnlyMode || !this.isPlaying) {
4172
+ this.playbackLoopId = null;
4173
+ return;
4174
+ }
4175
+ (t = this.animationPlayer) != null && t.isPlaying() ? this.playbackLoopId = requestAnimationFrame(e) : this.playbackLoopId = null;
4176
+ };
4177
+ this.playbackLoopId = requestAnimationFrame(e);
4178
+ }
4009
4179
  /**
4010
4180
  * Stop playback
4011
4181
  */
@@ -4016,7 +4186,7 @@ class ba {
4016
4186
  const t = this.animationPlayer.getStreamingPlayer();
4017
4187
  t == null || t.stop();
4018
4188
  }
4019
- this.emit("stopRendering"), this.isPlaying = !1, this.currentState = T.idle, (e = this.onAvatarState) == null || e.call(this, T.idle);
4189
+ this.emit("stopRendering"), this.isPlaying = !1, this.currentState = F.idle, (e = this.onAvatarState) == null || e.call(this, F.idle);
4020
4190
  }
4021
4191
  /**
4022
4192
  * Clean up players
@@ -4028,7 +4198,7 @@ class ba {
4028
4198
  * Add audio chunk to buffer
4029
4199
  */
4030
4200
  addAudioChunkToBuffer(e, t) {
4031
- if (this.animationPlayer || (this.animationPlayer = new Ce()), this.isPlaying && this.animationPlayer.isStreamingReady())
4201
+ if (this.animationPlayer || (this.animationPlayer = new le()), this.isPlaying && this.animationPlayer.isStreamingReady())
4032
4202
  this.animationPlayer.addAudioChunk(e, t);
4033
4203
  else {
4034
4204
  if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
@@ -4052,7 +4222,7 @@ class ba {
4052
4222
  n && n.forEach((a) => a(t));
4053
4223
  }
4054
4224
  }
4055
- function nr(r) {
4225
+ function ir(r) {
4056
4226
  if (r instanceof Error)
4057
4227
  return r.message;
4058
4228
  if (typeof r == "string")
@@ -4068,9 +4238,9 @@ function nr(r) {
4068
4238
  }
4069
4239
  return String(r);
4070
4240
  }
4071
- async function Ca(r) {
4241
+ async function _a(r) {
4072
4242
  try {
4073
- const e = {}, t = S.appId, n = S.sessionToken;
4243
+ const e = {}, t = v.appId, n = v.sessionToken;
4074
4244
  t && (e["X-App-Id"] = t), n && (e.Authorization = `Bearer ${n}`);
4075
4245
  const a = await fetch(r, {
4076
4246
  headers: Object.keys(e).length > 0 ? e : void 0
@@ -4079,23 +4249,23 @@ async function Ca(r) {
4079
4249
  throw new Error(`HTTP ${a.status} ${a.statusText}`);
4080
4250
  return await a.arrayBuffer();
4081
4251
  } catch (e) {
4082
- const t = nr(e);
4252
+ const t = ir(e);
4083
4253
  throw new Error(`[downloadResource] ${r} → ${t}`);
4084
4254
  }
4085
4255
  }
4086
- const _a = 50, ie = /* @__PURE__ */ new Map();
4256
+ const Pa = 50, se = /* @__PURE__ */ new Map();
4087
4257
  async function qe(r) {
4088
- const e = ie.get(r);
4258
+ const e = se.get(r);
4089
4259
  if (e)
4090
- return ie.delete(r), ie.set(r, e), e;
4091
- const t = await Ca(r);
4092
- if (ie.size >= _a) {
4093
- const n = ie.keys().next().value;
4094
- n && ie.delete(n);
4260
+ return se.delete(r), se.set(r, e), e;
4261
+ const t = await _a(r);
4262
+ if (se.size >= Pa) {
4263
+ const n = se.keys().next().value;
4264
+ n && se.delete(n);
4095
4265
  }
4096
- return ie.set(r, t), t;
4266
+ return se.set(r, t), t;
4097
4267
  }
4098
- class ar {
4268
+ class sr {
4099
4269
  constructor(e = "/") {
4100
4270
  d(this, "baseAssetsPath");
4101
4271
  this.baseAssetsPath = e;
@@ -4105,7 +4275,7 @@ class ar {
4105
4275
  * Falls back to global CDN config if not provided by API
4106
4276
  */
4107
4277
  async loadTemplateResources(e, t = null) {
4108
- var c, u, m, w;
4278
+ var c, u, m, y;
4109
4279
  if (!(e && Object.keys(e).length > 0))
4110
4280
  return h.log("⚠️ FLAME resources not provided in CharacterMeta, using global CDN config"), this.loadGlobalFlameResources(t);
4111
4281
  h.log("✅ Using FLAME resources from CharacterMeta API");
@@ -4123,27 +4293,27 @@ class ar {
4123
4293
  resourceName: "teeth.pb"
4124
4294
  },
4125
4295
  teethNpz: {
4126
- url: (w = e.teethNpz) == null ? void 0 : w.remote,
4296
+ url: (y = e.teethNpz) == null ? void 0 : y.remote,
4127
4297
  resourceName: "teeth.npz"
4128
4298
  }
4129
4299
  }, i = Object.keys(a).length;
4130
4300
  let s = 0;
4131
- const l = (v, y) => {
4132
- t && (y && s++, t({
4301
+ const o = (w, A) => {
4302
+ t && (A && s++, t({
4133
4303
  stage: "template",
4134
- filename: v,
4304
+ filename: w,
4135
4305
  loaded: s,
4136
4306
  total: i,
4137
4307
  progress: Math.round(s / i * 100)
4138
4308
  }));
4139
- }, o = {}, p = Object.entries(a).map(async ([v, { url: y, resourceName: b }]) => {
4140
- if (!y)
4141
- throw new Error(`[loadTemplateResources] Missing CDN URL for ${v} (${b})`);
4142
- l(b, !1), h.log(`📥 Loading ${v} from API CDN: ${y}`);
4143
- const P = await qe(y);
4144
- h.log(`✅ ${v} loaded: ${P.byteLength} bytes`), o[v] = P, l(b, !0);
4309
+ }, l = {}, p = Object.entries(a).map(async ([w, { url: A, resourceName: S }]) => {
4310
+ if (!A)
4311
+ throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${S})`);
4312
+ o(S, !1), h.log(`📥 Loading ${w} from API CDN: ${A}`);
4313
+ const E = await qe(A);
4314
+ h.log(`✅ ${w} loaded: ${E.byteLength} bytes`), l[w] = E, o(S, !0);
4145
4315
  });
4146
- return await Promise.all(p), o;
4316
+ return await Promise.all(p), l;
4147
4317
  }
4148
4318
  /**
4149
4319
  * Load global FLAME template resources from CDN
@@ -4151,7 +4321,7 @@ class ar {
4151
4321
  * @internal 供 AvatarKit 使用
4152
4322
  */
4153
4323
  async loadGlobalFlameResources(e = null) {
4154
- const { cdnBaseUrl: t, resources: n } = x.flame, a = {
4324
+ const { cdnBaseUrl: t, resources: n } = I.flame, a = {
4155
4325
  flameModel: {
4156
4326
  url: `${t}/${n.flameModel}`,
4157
4327
  resourceName: n.flameModel
@@ -4170,7 +4340,7 @@ class ar {
4170
4340
  }
4171
4341
  }, i = Object.keys(a).length;
4172
4342
  let s = 0;
4173
- const l = (c, u) => {
4343
+ const o = (c, u) => {
4174
4344
  e && (u && s++, e({
4175
4345
  stage: "template",
4176
4346
  filename: c,
@@ -4178,12 +4348,12 @@ class ar {
4178
4348
  total: i,
4179
4349
  progress: Math.round(s / i * 100)
4180
4350
  }));
4181
- }, o = {}, p = Object.entries(a).map(async ([c, { url: u, resourceName: m }]) => {
4182
- l(m, !1), h.log(`📥 Loading ${c} from global CDN: ${u}`);
4183
- const w = await qe(u);
4184
- h.log(`✅ ${c} loaded: ${w.byteLength} bytes`), o[c] = w, l(m, !0);
4351
+ }, l = {}, p = Object.entries(a).map(async ([c, { url: u, resourceName: m }]) => {
4352
+ o(m, !1), h.log(`📥 Loading ${c} from global CDN: ${u}`);
4353
+ const y = await qe(u);
4354
+ h.log(`✅ ${c} loaded: ${y.byteLength} bytes`), l[c] = y, o(m, !0);
4185
4355
  });
4186
- return await Promise.all(p), o;
4356
+ return await Promise.all(p), l;
4187
4357
  }
4188
4358
  /**
4189
4359
  * Load camera settings from CharacterMeta (optional)
@@ -4197,14 +4367,14 @@ class ar {
4197
4367
  }
4198
4368
  try {
4199
4369
  h.log(`📥 Loading camera info from: ${t}`);
4200
- const i = {}, s = S.appId, l = S.sessionToken;
4201
- s && (i["X-App-Id"] = s), l && (i.Authorization = `Bearer ${l}`);
4202
- const o = await fetch(t, {
4370
+ const i = {}, s = v.appId, o = v.sessionToken;
4371
+ s && (i["X-App-Id"] = s), o && (i.Authorization = `Bearer ${o}`);
4372
+ const l = await fetch(t, {
4203
4373
  headers: Object.keys(i).length > 0 ? i : void 0
4204
4374
  });
4205
- if (!o.ok)
4206
- throw new Error(`Failed to fetch camera info: ${o.statusText}`);
4207
- const p = await o.json();
4375
+ if (!l.ok)
4376
+ throw new Error(`Failed to fetch camera info: ${l.statusText}`);
4377
+ const p = await l.json();
4208
4378
  return h.log("✅ Camera info loaded:", p), p;
4209
4379
  } catch (i) {
4210
4380
  h.warn("⚠️ Failed to load camera info, using default:", i);
@@ -4215,11 +4385,11 @@ class ar {
4215
4385
  * Load character data from CharacterMeta (iOS compatible)
4216
4386
  */
4217
4387
  async loadCharacterData(e, t) {
4218
- var b, P, L, _, Y, G, U, W, Z, X, re, V, ye, ue, ne;
4219
- const { loadMonologue: n = !1, progressCallback: a = null } = t || {}, i = (L = (P = (b = e.models) == null ? void 0 : b.shape) == null ? void 0 : P.resource) == null ? void 0 : L.remote, s = (G = (Y = (_ = e.models) == null ? void 0 : _.gsStandard) == null ? void 0 : Y.resource) == null ? void 0 : G.remote, l = (Z = (W = (U = e.animations) == null ? void 0 : U.frameIdle) == null ? void 0 : W.resource) == null ? void 0 : Z.remote, o = (V = (re = (X = e.animations) == null ? void 0 : X.frameMono) == null ? void 0 : re.resource) == null ? void 0 : V.remote, p = (ne = (ue = (ye = e.animations) == null ? void 0 : ye.audioMono) == null ? void 0 : ue.resource) == null ? void 0 : ne.remote;
4388
+ var S, E, T, _, J, G, U, W, Z, X, ne, z, be, he, ae;
4389
+ const { loadMonologue: n = !1, progressCallback: a = null } = t || {}, i = (T = (E = (S = e.models) == null ? void 0 : S.shape) == null ? void 0 : E.resource) == null ? void 0 : T.remote, s = (G = (J = (_ = e.models) == null ? void 0 : _.gsStandard) == null ? void 0 : J.resource) == null ? void 0 : G.remote, o = (Z = (W = (U = e.animations) == null ? void 0 : U.frameIdle) == null ? void 0 : W.resource) == null ? void 0 : Z.remote, l = (z = (ne = (X = e.animations) == null ? void 0 : X.frameMono) == null ? void 0 : ne.resource) == null ? void 0 : z.remote, p = (ae = (he = (be = e.animations) == null ? void 0 : be.audioMono) == null ? void 0 : he.resource) == null ? void 0 : ae.remote;
4220
4390
  if (!i || !s) {
4221
4391
  const B = "Missing required resources: shape or gsStandard (point cloud)";
4222
- throw S.logEvent("character_load", "error", {
4392
+ throw v.logEvent("character_load", "error", {
4223
4393
  characterId: e.characterId ?? "unknown",
4224
4394
  stage: "resource_validation",
4225
4395
  reason: B
@@ -4229,54 +4399,54 @@ class ar {
4229
4399
  { key: "shape", url: i, filename: "shape.pb" },
4230
4400
  { key: "pointCloud", url: s, filename: "point_cloud.ply" }
4231
4401
  ];
4232
- l && c.push({ key: "idleAnimation", url: l, filename: "idle.pb", optional: !0 }), n && o ? (h.log("📥 Loading monologue animation (enabled by option)"), c.push({ key: "monoAnimation", url: o, filename: "mono.pb", optional: !0 })) : !n && o && h.log("⏭️ Skipping monologue animation (disabled by option)");
4402
+ o && c.push({ key: "idleAnimation", url: o, filename: "idle.pb", optional: !0 }), n && l ? (h.log("📥 Loading monologue animation (enabled by option)"), c.push({ key: "monoAnimation", url: l, filename: "mono.pb", optional: !0 })) : !n && l && h.log("⏭️ Skipping monologue animation (disabled by option)");
4233
4403
  let u = 0;
4234
- const m = c.length, w = (B, z) => {
4235
- a && (z && u++, a({
4404
+ const m = c.length, y = (B, V) => {
4405
+ a && (V && u++, a({
4236
4406
  stage: "character",
4237
4407
  filename: B,
4238
4408
  loaded: u,
4239
4409
  total: m,
4240
4410
  progress: Math.round(u / m * 100)
4241
4411
  }));
4242
- }, v = {}, y = c.map(async ({ key: B, url: z, filename: ae, optional: Te }) => {
4243
- w(ae, !1);
4412
+ }, w = {}, A = c.map(async ({ key: B, url: V, filename: ie, optional: Te }) => {
4413
+ y(ie, !1);
4244
4414
  try {
4245
- const H = await qe(z);
4246
- return B === "shape" ? v.shape = H : B === "pointCloud" ? v.pointCloud = H : B === "idleAnimation" ? v.idleAnimation = H : B === "monoAnimation" && (v.monoAnimation = H), w(ae, !0), { key: B, success: !0 };
4415
+ const H = await qe(V);
4416
+ return B === "shape" ? w.shape = H : B === "pointCloud" ? w.pointCloud = H : B === "idleAnimation" ? w.idleAnimation = H : B === "monoAnimation" && (w.monoAnimation = H), y(ie, !0), { key: B, success: !0 };
4247
4417
  } catch (H) {
4248
4418
  if (!Te)
4249
4419
  throw H;
4250
- return h.warn(`⚠️ Optional resource ${ae} failed to load:`, H), w(ae, !0), { key: B, success: !1 };
4420
+ return h.warn(`⚠️ Optional resource ${ie} failed to load:`, H), y(ie, !0), { key: B, success: !1 };
4251
4421
  }
4252
4422
  });
4253
- if (await Promise.all(y), n && p && (v.monoAudioUrl = p), !v.shape || !v.pointCloud) {
4423
+ if (await Promise.all(A), n && p && (w.monoAudioUrl = p), !w.shape || !w.pointCloud) {
4254
4424
  const B = "Failed to load character data";
4255
- throw S.logEvent("character_load", "error", {
4425
+ throw v.logEvent("character_load", "error", {
4256
4426
  characterId: e.characterId ?? "unknown",
4257
4427
  stage: "download",
4258
4428
  reason: B
4259
4429
  }), new Error(B);
4260
4430
  }
4261
- return v;
4431
+ return w;
4262
4432
  }
4263
4433
  /**
4264
4434
  * Preload all resources (template + character data + camera info + settings)
4265
4435
  */
4266
4436
  async preloadResources(e, t) {
4267
- const { loadMonologue: n = !1, progressCallback: a = null } = t || {}, [i, s, l] = await Promise.all([
4268
- this.loadTemplateResources(e.flame, (o) => {
4437
+ const { loadMonologue: n = !1, progressCallback: a = null } = t || {}, [i, s, o] = await Promise.all([
4438
+ this.loadTemplateResources(e.flame, (l) => {
4269
4439
  a && a({
4270
- ...o,
4271
- stage: `template-${o.stage}`
4440
+ ...l,
4441
+ stage: `template-${l.stage}`
4272
4442
  });
4273
4443
  }),
4274
4444
  this.loadCharacterData(e, {
4275
4445
  loadMonologue: n,
4276
- progressCallback: (o) => {
4446
+ progressCallback: (l) => {
4277
4447
  a && a({
4278
- ...o,
4279
- stage: `character-${o.stage}`
4448
+ ...l,
4449
+ stage: `character-${l.stage}`
4280
4450
  });
4281
4451
  }
4282
4452
  }),
@@ -4285,7 +4455,7 @@ class ar {
4285
4455
  return {
4286
4456
  templateResources: i,
4287
4457
  characterData: s,
4288
- preloadCameraSettings: l,
4458
+ preloadCameraSettings: o,
4289
4459
  characterSettings: e.characterSettings
4290
4460
  };
4291
4461
  }
@@ -4302,10 +4472,10 @@ class ar {
4302
4472
  getSdkApiClient() {
4303
4473
  return {
4304
4474
  async request(e, t = {}) {
4305
- const i = S.getEnvironmentConfig().sdkApiBaseUrl + e, s = {
4475
+ const i = v.getEnvironmentConfig().sdkApiBaseUrl + e, s = {
4306
4476
  "Content-Type": "application/json"
4307
- }, l = S.appId, o = S.sessionToken;
4308
- l && (s["X-App-Id"] = l), o && (s.Authorization = `Bearer ${o}`);
4477
+ }, o = v.appId, l = v.sessionToken;
4478
+ o && (s["X-App-Id"] = o), l && (s.Authorization = `Bearer ${l}`);
4309
4479
  try {
4310
4480
  const p = await fetch(i, {
4311
4481
  method: t.method || "GET",
@@ -4319,7 +4489,7 @@ class ar {
4319
4489
  throw new Error(`HTTP ${p.status} ${p.statusText}`);
4320
4490
  return p.json();
4321
4491
  } catch (p) {
4322
- const c = nr(p);
4492
+ const c = ir(p);
4323
4493
  throw new Error(`[SdkApiClient] ${i} → ${c}`);
4324
4494
  }
4325
4495
  }
@@ -4340,7 +4510,7 @@ class ar {
4340
4510
  } catch (n) {
4341
4511
  h.errorWithError("Failed to fetch character:", n);
4342
4512
  const a = n && typeof n == "object" && "message" in n ? String(n.message) : "Failed to fetch character", i = n && typeof n == "object" && "data" in n && typeof n.data == "object" && ((t = n.data) != null && t.message) ? String(n.data.message) : null;
4343
- throw S.logEvent("character_load", "error", {
4513
+ throw v.logEvent("character_load", "error", {
4344
4514
  characterId: e ?? "unknown",
4345
4515
  stage: "fetch",
4346
4516
  reason: i || a
@@ -4350,7 +4520,7 @@ class ar {
4350
4520
  }
4351
4521
  const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4352
4522
  __proto__: null,
4353
- AvatarDownloader: ar
4523
+ AvatarDownloader: sr
4354
4524
  }, Symbol.toStringTag, { value: "Module" })), Le = class Le {
4355
4525
  constructor() {
4356
4526
  d(this, "avatarDownloader", null);
@@ -4371,33 +4541,33 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4371
4541
  async load(e, t, n) {
4372
4542
  h.log(`[AvatarManager] Loading avatar with id: ${e}`);
4373
4543
  try {
4374
- if (!S.isInitialized)
4544
+ if (!v.isInitialized)
4375
4545
  throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
4376
- this.avatarDownloader || (this.avatarDownloader = new ar()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: he.downloading, progress: 10 });
4546
+ this.avatarDownloader || (this.avatarDownloader = new sr()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: fe.downloading, progress: 10 });
4377
4547
  const a = await this.avatarDownloader.getCharacterById(e);
4378
- h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: he.downloading, progress: 30 });
4548
+ h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: fe.downloading, progress: 30 });
4379
4549
  const i = await this.avatarDownloader.preloadResources(a, {
4380
4550
  loadMonologue: (n == null ? void 0 : n.enableMonologue) ?? !1,
4381
- progressCallback: (l) => {
4382
- const o = 30 + l.progress / 100 * 70;
4551
+ progressCallback: (o) => {
4552
+ const l = 30 + o.progress / 100 * 70;
4383
4553
  t == null || t({
4384
- type: he.downloading,
4385
- progress: Math.round(o)
4554
+ type: fe.downloading,
4555
+ progress: Math.round(l)
4386
4556
  });
4387
4557
  }
4388
4558
  });
4389
4559
  h.log("[AvatarManager] Step 3: Creating Avatar instance...");
4390
- const s = new nn(e, a, i);
4391
- return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: he.completed }), S.logEvent("character_load", "info", {
4560
+ const s = new sn(e, a, i);
4561
+ return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: fe.completed }), v.logEvent("character_load", "info", {
4392
4562
  characterId: e,
4393
4563
  event: "load_success"
4394
4564
  }), s;
4395
4565
  } catch (a) {
4396
4566
  const i = a instanceof Error ? a.message : String(a);
4397
- throw h.error("Failed to load avatar:", i), S.logEvent("character_load", "error", {
4567
+ throw h.error("Failed to load avatar:", i), v.logEvent("character_load", "error", {
4398
4568
  characterId: e,
4399
4569
  reason: i
4400
- }), t == null || t({ type: he.failed, error: a }), a;
4570
+ }), t == null || t({ type: fe.failed, error: a }), a;
4401
4571
  }
4402
4572
  }
4403
4573
  /**
@@ -4408,54 +4578,54 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4408
4578
  }
4409
4579
  };
4410
4580
  d(Le, "_instance", null);
4411
- let Tt = Le, Ae = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
4412
- const Ze = 2048, Vt = Ze - 1;
4413
- function Pa(r, e, t) {
4581
+ let Bt = Le, Se = null, Dt = null, Ot = null, Nt = null, Ut = null, zt = null;
4582
+ const Qe = 2048, Vt = Qe - 1;
4583
+ function Ia(r, e, t) {
4414
4584
  const a = r.length / 13;
4415
- (!Ae || Ae.length !== a) && (Ae = new Float32Array(a), Bt = new Uint32Array(Ae.buffer), Dt = new Uint32Array(a), Ot = new Uint32Array(a), Nt = new Uint32Array(a), Ut = new Uint32Array(Ze));
4416
- const i = Ae, s = Bt, l = Dt, o = Ot, p = Nt, c = Ut, u = e[0], m = e[1], w = e[2], v = t[0], y = t[1], b = t[2];
4417
- for (let P = 0; P < a; P++) {
4418
- const L = P * 13;
4419
- i[P] = (r[L] - u) * v + (r[L + 1] - m) * y + (r[L + 2] - w) * b, l[P] = P;
4420
- }
4421
- for (let P = 0; P < a; P++) {
4422
- const L = s[P];
4423
- s[P] = L ^ (-(L >> 31) | 2147483648);
4424
- }
4425
- Ge(s, l, o, c, 0, a), Ge(s, o, l, c, 11, a), Ge(s, l, o, c, 22, a);
4426
- for (let P = 0; P < a; P++)
4427
- p[P] = o[a - 1 - P];
4585
+ (!Se || Se.length !== a) && (Se = new Float32Array(a), Dt = new Uint32Array(Se.buffer), Ot = new Uint32Array(a), Nt = new Uint32Array(a), Ut = new Uint32Array(a), zt = new Uint32Array(Qe));
4586
+ const i = Se, s = Dt, o = Ot, l = Nt, p = Ut, c = zt, u = e[0], m = e[1], y = e[2], w = t[0], A = t[1], S = t[2];
4587
+ for (let E = 0; E < a; E++) {
4588
+ const T = E * 13;
4589
+ i[E] = (r[T] - u) * w + (r[T + 1] - m) * A + (r[T + 2] - y) * S, o[E] = E;
4590
+ }
4591
+ for (let E = 0; E < a; E++) {
4592
+ const T = s[E];
4593
+ s[E] = T ^ (-(T >> 31) | 2147483648);
4594
+ }
4595
+ Ge(s, o, l, c, 0, a), Ge(s, l, o, c, 11, a), Ge(s, o, l, c, 22, a);
4596
+ for (let E = 0; E < a; E++)
4597
+ p[E] = l[a - 1 - E];
4428
4598
  return p;
4429
4599
  }
4430
4600
  function Ge(r, e, t, n, a, i) {
4431
4601
  n.fill(0);
4432
- for (let l = 0; l < i; l++) {
4433
- const o = r[e[l]] >> a & Vt;
4434
- n[o]++;
4602
+ for (let o = 0; o < i; o++) {
4603
+ const l = r[e[o]] >> a & Vt;
4604
+ n[l]++;
4435
4605
  }
4436
4606
  let s = 0;
4437
- for (let l = 0; l < Ze; l++) {
4438
- const o = n[l];
4439
- n[l] = s, s += o;
4607
+ for (let o = 0; o < Qe; o++) {
4608
+ const l = n[o];
4609
+ n[o] = s, s += l;
4440
4610
  }
4441
- for (let l = 0; l < i; l++) {
4442
- const o = e[l], p = r[o] >> a & Vt;
4443
- t[n[p]++] = o;
4611
+ for (let o = 0; o < i; o++) {
4612
+ const l = e[o], p = r[l] >> a & Vt;
4613
+ t[n[p]++] = l;
4444
4614
  }
4445
4615
  }
4446
4616
  const xe = 13;
4447
- let Se = null;
4448
- function Ia(r, e) {
4617
+ let Ce = null;
4618
+ function ka(r, e) {
4449
4619
  const t = e.length, n = t * xe;
4450
- (!Se || Se.length !== n) && (Se = new Float32Array(n));
4620
+ (!Ce || Ce.length !== n) && (Ce = new Float32Array(n));
4451
4621
  for (let a = 0; a < t; a++) {
4452
- const s = e[a] * xe, l = a * xe;
4453
- Se.set(
4622
+ const s = e[a] * xe, o = a * xe;
4623
+ Ce.set(
4454
4624
  r.subarray(s, s + xe),
4455
- l
4625
+ o
4456
4626
  );
4457
4627
  }
4458
- return Se;
4628
+ return Ce;
4459
4629
  }
4460
4630
  const xa = `#version 300 es
4461
4631
  precision highp float;
@@ -4487,7 +4657,7 @@ void main() {
4487
4657
  // 预乘 alpha 输出(匹配 premultipliedAlpha: true)
4488
4658
  // 颜色值需要乘以 alpha,这样 WebGL 才能正确混合
4489
4659
  fragColor = vec4(v_color.rgb * alpha, alpha);
4490
- }`, ka = `#version 300 es
4660
+ }`, Ma = `#version 300 es
4491
4661
  precision highp float;
4492
4662
 
4493
4663
  // 基础四边形顶点属性(共享4个顶点)
@@ -4655,7 +4825,7 @@ void main() {
4655
4825
  v_relativePosition = relativeCoord * BOUNDS_RADIUS;
4656
4826
  v_color = a_color;
4657
4827
  }`;
4658
- class Ma {
4828
+ class Fa {
4659
4829
  // 跟踪当前 buffer 大小
4660
4830
  constructor(e, t) {
4661
4831
  d(this, "canvas");
@@ -4847,7 +5017,7 @@ class Ma {
4847
5017
  const t = e.createShader(e.VERTEX_SHADER);
4848
5018
  if (!t)
4849
5019
  throw new Error("Failed to create vertex shader");
4850
- if (e.shaderSource(t, ka), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
5020
+ if (e.shaderSource(t, Ma), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
4851
5021
  const i = e.getShaderInfoLog(t);
4852
5022
  throw e.deleteShader(t), new Error(`Vertex shader compilation failed: ${i}`);
4853
5023
  }
@@ -4883,7 +5053,7 @@ class Ma {
4883
5053
  this.gl = null, this.isInitialized = !1;
4884
5054
  }
4885
5055
  }
4886
- const Fa = `/**
5056
+ const Ra = `/**
4887
5057
  * WebGPU 3DGS 渲染着色器
4888
5058
  *
4889
5059
  * 实例化渲染:每个 splat 绘制一个四边形
@@ -5146,7 +5316,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
5146
5316
  return vec4f(input.color.rgb * alpha, alpha);
5147
5317
  }
5148
5318
  `;
5149
- class Ra {
5319
+ class La {
5150
5320
  constructor(e, t) {
5151
5321
  d(this, "canvas");
5152
5322
  d(this, "backgroundColor");
@@ -5233,7 +5403,7 @@ class Ra {
5233
5403
  return;
5234
5404
  const e = this.device.createShaderModule({
5235
5405
  label: "3DGS Render Shader",
5236
- code: Fa
5406
+ code: Ra
5237
5407
  }), t = this.device.createBindGroupLayout({
5238
5408
  label: "Uniform Bind Group Layout",
5239
5409
  entries: [
@@ -5414,7 +5584,7 @@ class Ra {
5414
5584
  (e = this.sortIndexBuffer) == null || e.destroy(), (t = this.splatDataBuffer) == null || t.destroy(), (n = this.quadVertexBuffer) == null || n.destroy(), (a = this.uniformBuffer) == null || a.destroy(), (i = this.device) == null || i.destroy(), this.sortIndexBuffer = null, this.splatDataBuffer = null, this.quadVertexBuffer = null, this.uniformBuffer = null, this.uniformBindGroup = null, this.storageBindGroup = null, this.device = null, this.context = null, this.renderPipeline = null;
5415
5585
  }
5416
5586
  }
5417
- class La {
5587
+ class Ta {
5418
5588
  // 排序耗时
5419
5589
  constructor(e) {
5420
5590
  d(this, "renderer", null);
@@ -5463,12 +5633,12 @@ class La {
5463
5633
  const { preferBackend: e, backgroundColor: t = [0, 0, 0, 0] } = this.options;
5464
5634
  if (e !== "webgl" && await this.checkWebGPUSupport())
5465
5635
  try {
5466
- this.renderer = new Ra(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", h.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
5636
+ this.renderer = new La(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", h.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
5467
5637
  return;
5468
5638
  } catch (a) {
5469
5639
  h.warn("⚠️ WebGPU init failed, fallback to WebGL:", a);
5470
5640
  }
5471
- this.renderer = new Ma(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
5641
+ this.renderer = new Fa(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
5472
5642
  }
5473
5643
  /**
5474
5644
  * Load packed Splat data (zero-copy, GPU format)
@@ -5488,7 +5658,7 @@ class La {
5488
5658
  if (!this.renderer || !this.originalPackedData)
5489
5659
  return;
5490
5660
  this.updateCameraMatrices();
5491
- const e = Math.floor(this.originalPackedData.length / 13), t = performance.now(), n = Pa(
5661
+ const e = Math.floor(this.originalPackedData.length / 13), t = performance.now(), n = Ia(
5492
5662
  this.originalPackedData,
5493
5663
  this.camera.position,
5494
5664
  this.getCameraForward()
@@ -5496,8 +5666,8 @@ class La {
5496
5666
  if (this.sortTime = a, this.backend === "webgpu")
5497
5667
  this.renderer.loadSplatsFromPackedData(this.originalPackedData, e, n);
5498
5668
  else {
5499
- const l = Ia(this.originalPackedData, n);
5500
- this.renderer.loadSplatsFromPackedData(l, e);
5669
+ const o = ka(this.originalPackedData, n);
5670
+ this.renderer.loadSplatsFromPackedData(o, e);
5501
5671
  }
5502
5672
  const i = performance.now();
5503
5673
  this.renderer.render(
@@ -5556,16 +5726,16 @@ class La {
5556
5726
  * Update camera matrices (with caching to avoid unnecessary updates)
5557
5727
  */
5558
5728
  updateCameraMatrices() {
5559
- const { position: e, target: t, up: n, fov: a, aspect: i, near: s, far: l } = this.camera;
5560
- !(!this.cachedCameraParams || this.cachedCameraParams.position[0] !== e[0] || this.cachedCameraParams.position[1] !== e[1] || this.cachedCameraParams.position[2] !== e[2] || this.cachedCameraParams.target[0] !== t[0] || this.cachedCameraParams.target[1] !== t[1] || this.cachedCameraParams.target[2] !== t[2] || this.cachedCameraParams.up[0] !== n[0] || this.cachedCameraParams.up[1] !== n[1] || this.cachedCameraParams.up[2] !== n[2] || this.cachedCameraParams.fov !== a || this.cachedCameraParams.aspect !== i || this.cachedCameraParams.near !== s || this.cachedCameraParams.far !== l) && this.matricesCacheValid || (this.cachedCameraParams ? (this.cachedCameraParams.position[0] = e[0], this.cachedCameraParams.position[1] = e[1], this.cachedCameraParams.position[2] = e[2], this.cachedCameraParams.target[0] = t[0], this.cachedCameraParams.target[1] = t[1], this.cachedCameraParams.target[2] = t[2], this.cachedCameraParams.up[0] = n[0], this.cachedCameraParams.up[1] = n[1], this.cachedCameraParams.up[2] = n[2], this.cachedCameraParams.fov = a, this.cachedCameraParams.aspect = i, this.cachedCameraParams.near = s, this.cachedCameraParams.far = l) : this.cachedCameraParams = {
5729
+ const { position: e, target: t, up: n, fov: a, aspect: i, near: s, far: o } = this.camera;
5730
+ !(!this.cachedCameraParams || this.cachedCameraParams.position[0] !== e[0] || this.cachedCameraParams.position[1] !== e[1] || this.cachedCameraParams.position[2] !== e[2] || this.cachedCameraParams.target[0] !== t[0] || this.cachedCameraParams.target[1] !== t[1] || this.cachedCameraParams.target[2] !== t[2] || this.cachedCameraParams.up[0] !== n[0] || this.cachedCameraParams.up[1] !== n[1] || this.cachedCameraParams.up[2] !== n[2] || this.cachedCameraParams.fov !== a || this.cachedCameraParams.aspect !== i || this.cachedCameraParams.near !== s || this.cachedCameraParams.far !== o) && this.matricesCacheValid || (this.cachedCameraParams ? (this.cachedCameraParams.position[0] = e[0], this.cachedCameraParams.position[1] = e[1], this.cachedCameraParams.position[2] = e[2], this.cachedCameraParams.target[0] = t[0], this.cachedCameraParams.target[1] = t[1], this.cachedCameraParams.target[2] = t[2], this.cachedCameraParams.up[0] = n[0], this.cachedCameraParams.up[1] = n[1], this.cachedCameraParams.up[2] = n[2], this.cachedCameraParams.fov = a, this.cachedCameraParams.aspect = i, this.cachedCameraParams.near = s, this.cachedCameraParams.far = o) : this.cachedCameraParams = {
5561
5731
  position: [e[0], e[1], e[2]],
5562
5732
  target: [t[0], t[1], t[2]],
5563
5733
  up: [n[0], n[1], n[2]],
5564
5734
  fov: a,
5565
5735
  aspect: i,
5566
5736
  near: s,
5567
- far: l
5568
- }, this.updatePerspectiveMatrix(a, i, s, l), this.forwardCacheValid = !1, this.updateViewMatrix(e, t, n), this.matricesCacheValid = !0);
5737
+ far: o
5738
+ }, this.updatePerspectiveMatrix(a, i, s, o), this.forwardCacheValid = !1, this.updateViewMatrix(e, t, n), this.matricesCacheValid = !0);
5569
5739
  }
5570
5740
  /**
5571
5741
  * Get camera forward vector (cached version)
@@ -5585,8 +5755,8 @@ class La {
5585
5755
  * Update perspective projection matrix (reuse buffer)
5586
5756
  */
5587
5757
  updatePerspectiveMatrix(e, t, n, a) {
5588
- const i = e * Math.PI / 180, s = 1 / Math.tan(i / 2), l = a / (n - a), o = this.projectionMatrix;
5589
- o[0] = s / t, o[1] = 0, o[2] = 0, o[3] = 0, o[4] = 0, o[5] = s, o[6] = 0, o[7] = 0, o[8] = 0, o[9] = 0, o[10] = l, o[11] = -1, o[12] = 0, o[13] = 0, o[14] = l * n, o[15] = 0;
5758
+ const i = e * Math.PI / 180, s = 1 / Math.tan(i / 2), o = a / (n - a), l = this.projectionMatrix;
5759
+ l[0] = s / t, l[1] = 0, l[2] = 0, l[3] = 0, l[4] = 0, l[5] = s, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = o, l[11] = -1, l[12] = 0, l[13] = 0, l[14] = o * n, l[15] = 0;
5590
5760
  }
5591
5761
  /**
5592
5762
  * Update view matrix (directly update pre-allocated buffer to avoid per-frame allocation)
@@ -5600,36 +5770,36 @@ class La {
5600
5770
  this.tempForward[0] /= a, this.tempForward[1] /= a, this.tempForward[2] /= a, this.tempRight[0] = this.tempForward[1] * n[2] - this.tempForward[2] * n[1], this.tempRight[1] = this.tempForward[2] * n[0] - this.tempForward[0] * n[2], this.tempRight[2] = this.tempForward[0] * n[1] - this.tempForward[1] * n[0];
5601
5771
  const i = Math.hypot(this.tempRight[0], this.tempRight[1], this.tempRight[2]) || 1;
5602
5772
  this.tempRight[0] /= i, this.tempRight[1] /= i, this.tempRight[2] /= i, this.tempUp[0] = this.tempRight[1] * this.tempForward[2] - this.tempRight[2] * this.tempForward[1], this.tempUp[1] = this.tempRight[2] * this.tempForward[0] - this.tempRight[0] * this.tempForward[2], this.tempUp[2] = this.tempRight[0] * this.tempForward[1] - this.tempRight[1] * this.tempForward[0];
5603
- const s = this.viewMatrix, l = -e[0], o = -e[1], p = -e[2];
5604
- s[0] = this.tempRight[0], s[1] = this.tempUp[0], s[2] = -this.tempForward[0], s[3] = 0, s[4] = this.tempRight[1], s[5] = this.tempUp[1], s[6] = -this.tempForward[1], s[7] = 0, s[8] = this.tempRight[2], s[9] = this.tempUp[2], s[10] = -this.tempForward[2], s[11] = 0, s[12] = l, s[13] = o, s[14] = p, s[15] = 1;
5773
+ const s = this.viewMatrix, o = -e[0], l = -e[1], p = -e[2];
5774
+ s[0] = this.tempRight[0], s[1] = this.tempUp[0], s[2] = -this.tempForward[0], s[3] = 0, s[4] = this.tempRight[1], s[5] = this.tempUp[1], s[6] = -this.tempForward[1], s[7] = 0, s[8] = this.tempRight[2], s[9] = this.tempUp[2], s[10] = -this.tempForward[2], s[11] = 0, s[12] = o, s[13] = l, s[14] = p, s[15] = 1;
5605
5775
  }
5606
5776
  }
5607
- function se(r, e, t) {
5777
+ function oe(r, e, t) {
5608
5778
  const n = Math.min(r.length, e.length), a = Array.from({ length: n });
5609
5779
  for (let i = 0; i < n; i++)
5610
5780
  a[i] = r[i] + (e[i] - r[i]) * t;
5611
5781
  return a;
5612
5782
  }
5613
- function Ta(r, e, t) {
5783
+ function Ba(r, e, t) {
5614
5784
  const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
5615
5785
  return {
5616
- translation: se(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
5617
- rotation: se(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
5618
- neckPose: se(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
5619
- jawPose: se(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
5620
- eyePose: se(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
5786
+ translation: oe(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
5787
+ rotation: oe(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
5788
+ neckPose: oe(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
5789
+ jawPose: oe(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
5790
+ eyePose: oe(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
5621
5791
  eyeLid: (() => {
5622
5792
  const a = r.eyeLid, i = e.eyeLid;
5623
- return a && a.length > 0 && i && i.length > 0 ? se(a, i, n) : a || i || [];
5793
+ return a && a.length > 0 && i && i.length > 0 ? oe(a, i, n) : a || i || [];
5624
5794
  })(),
5625
- expression: se(r.expression || [], e.expression || [], n)
5795
+ expression: oe(r.expression || [], e.expression || [], n)
5626
5796
  };
5627
5797
  }
5628
- function Ba(r, e, t, n = 25) {
5798
+ function Da(r, e, t, n = 25) {
5629
5799
  const a = Math.max(1, Math.floor(t / 1e3 * n)), i = Array.from({ length: a });
5630
5800
  for (let s = 0; s < a; s++) {
5631
- const l = s / (a - 1);
5632
- i[s] = Ta(r, e, l);
5801
+ const o = s / (a - 1);
5802
+ i[s] = Ba(r, e, o);
5633
5803
  }
5634
5804
  return i;
5635
5805
  }
@@ -5638,10 +5808,18 @@ class Va {
5638
5808
  * 构造函数
5639
5809
  * 创建统一的 AvatarController,内部根据配置自动组合网络层
5640
5810
  */
5811
+ /**
5812
+ * 构造函数
5813
+ * 创建统一的 AvatarController,内部根据配置自动组合网络层
5814
+ * @param avatar - Avatar 实例
5815
+ * @param container - Canvas 容器元素(必选)
5816
+ */
5641
5817
  constructor(e, t) {
5642
5818
  d(this, "avatarController");
5643
5819
  d(this, "playbackMode");
5644
5820
  d(this, "avatar");
5821
+ // Initialization state
5822
+ d(this, "ready");
5645
5823
  // Canvas and rendering
5646
5824
  d(this, "canvas");
5647
5825
  d(this, "renderSystem", null);
@@ -5665,30 +5843,33 @@ class Va {
5665
5843
  // Transition animation data
5666
5844
  d(this, "transitionKeyframes", []);
5667
5845
  d(this, "transitionStartTime", 0);
5668
- d(this, "transitionDurationMs", 200);
5846
+ d(this, "transitionDurationMs", 400);
5669
5847
  d(this, "cachedIdleFirstFrame", null);
5670
5848
  d(this, "idleCurrentFrameIndex", 0);
5671
5849
  // Character handle for multi-character support
5672
5850
  d(this, "characterHandle", null);
5673
5851
  d(this, "characterId");
5674
5852
  this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
5675
- const n = (t == null ? void 0 : t.playbackMode) ?? Me.network;
5676
- this.playbackMode = n, this.avatarController = new ba(e, {
5677
- playbackMode: n
5678
- }), this.avatarController.setRenderCallback((a, i) => {
5679
- this.renderRealtimeFrame(a, i);
5853
+ const n = v.configuration;
5854
+ if (!n)
5855
+ throw new Error("AvatarKit must be initialized before creating AvatarView. Call AvatarKit.initialize() first.");
5856
+ const i = (n.drivingServiceMode ?? We.sdk) === We.sdk ? we.network : we.external;
5857
+ this.playbackMode = i, this.avatarController = new Ca(e, {
5858
+ playbackMode: i
5859
+ }), this.avatarController.setRenderCallback((s, o) => {
5860
+ this.renderRealtimeFrame(s, o);
5680
5861
  }), this.avatarController.setTransitionCompleteCallback(() => {
5681
5862
  this.onTransitionComplete();
5682
- }), this.canvas = this.createCanvas(t == null ? void 0 : t.container), this.initializeView(e), this.setupControllerEventListeners();
5863
+ }), this.canvas = this.createCanvas(t), this.ready = this.initializeView(e), this.setupControllerEventListeners();
5683
5864
  }
5684
5865
  // Unique ID for this character instance
5685
5866
  /**
5686
5867
  * 对齐两端 Flame 维度:标量统一长度,expression 取最大长度并零填充
5687
5868
  */
5688
5869
  alignFlamePair(e, t) {
5689
- const n = (l, o) => {
5690
- const p = Array.isArray(l) ? l.slice(0, o) : [];
5691
- return p.length < o ? Array.from({ length: o }, (c, u) => p[u] ?? 0) : p;
5870
+ const n = (o, l) => {
5871
+ const p = Array.isArray(o) ? o.slice(0, l) : [];
5872
+ return p.length < l ? Array.from({ length: l }, (c, u) => p[u] ?? 0) : p;
5692
5873
  }, a = {
5693
5874
  translation: n(e == null ? void 0 : e.translation, 3),
5694
5875
  rotation: n(e == null ? void 0 : e.rotation, 3),
@@ -5713,11 +5894,11 @@ class Va {
5713
5894
  */
5714
5895
  generateAndAlignTransitionFrames(e, t) {
5715
5896
  const n = this.alignFlamePair(e, t);
5716
- let a = Ba(
5897
+ let a = Da(
5717
5898
  n.from,
5718
5899
  n.to,
5719
5900
  this.transitionDurationMs,
5720
- x.animation.fps
5901
+ I.animation.fps
5721
5902
  );
5722
5903
  return a.length < 2 && (a = [n.from, n.to]), a[0] = n.from, a[a.length - 1] = n.to, a;
5723
5904
  }
@@ -5726,11 +5907,11 @@ class Va {
5726
5907
  */
5727
5908
  async getCachedIdleFirstFrame() {
5728
5909
  if (!this.cachedIdleFirstFrame) {
5729
- const e = S.getAvatarCore();
5910
+ const e = v.getAvatarCore();
5730
5911
  if (e)
5731
5912
  try {
5732
5913
  const t = await e.getCurrentFrameParams(0, this.characterId);
5733
- this.cachedIdleFirstFrame = ht(t);
5914
+ this.cachedIdleFirstFrame = ft(t);
5734
5915
  } catch (t) {
5735
5916
  h.warn("[AvatarView] Failed to get idle first frame:", t instanceof Error ? t.message : String(t));
5736
5917
  }
@@ -5747,14 +5928,11 @@ class Va {
5747
5928
  * 创建canvas元素
5748
5929
  */
5749
5930
  createCanvas(e) {
5750
- const t = document.createElement("canvas");
5751
- let n = 800, a = 600;
5752
- e && e instanceof HTMLElement && (n = e.offsetWidth || 800, a = e.offsetHeight || 600);
5753
- const i = window.devicePixelRatio || 1;
5754
- return t.width = Math.floor(n * i), t.height = Math.floor(a * i), t.style.width = `${n}px`, t.style.height = `${a}px`, t.style.display = "block", t.style.margin = "0 auto", t.style.position = "", t.style.top = "", t.style.left = "", t.style.zIndex = "", t.style.background = "none", t.style.border = "none", e && e instanceof HTMLElement ? (e.appendChild(t), e.style.display = "flex", e.style.justifyContent = "center", e.style.alignItems = "center", e.style.position = "relative", this.resizeObserver = new ResizeObserver(() => {
5755
- const s = window.devicePixelRatio || 1, l = Math.floor(e.offsetWidth || 0), o = Math.floor(e.offsetHeight || 0);
5756
- t.width = Math.floor(l * s), t.height = Math.floor(o * s), t.style.width = `${l}px`, t.style.height = `${o}px`, this.handleResize();
5757
- }), this.resizeObserver.observe(e)) : document.body.appendChild(t), window.addEventListener("resize", this.onWindowResize), t;
5931
+ const t = document.createElement("canvas"), n = e.offsetWidth || 800, a = e.offsetHeight || 600, i = window.devicePixelRatio || 1;
5932
+ return t.width = Math.floor(n * i), t.height = Math.floor(a * i), t.style.width = `${n}px`, t.style.height = `${a}px`, t.style.display = "block", t.style.margin = "0 auto", t.style.position = "", t.style.top = "", t.style.left = "", t.style.zIndex = "", t.style.background = "none", t.style.border = "none", e.appendChild(t), e.style.display = "flex", e.style.justifyContent = "center", e.style.alignItems = "center", e.style.position = "relative", this.resizeObserver = new ResizeObserver(() => {
5933
+ const s = window.devicePixelRatio || 1, o = Math.floor(e.offsetWidth || 0), l = Math.floor(e.offsetHeight || 0);
5934
+ t.width = Math.floor(o * s), t.height = Math.floor(l * s), t.style.width = `${o}px`, t.style.height = `${l}px`, this.handleResize();
5935
+ }), this.resizeObserver.observe(e), window.addEventListener("resize", this.onWindowResize), t;
5758
5936
  }
5759
5937
  /**
5760
5938
  * 获取canvas元素(供外部访问)
@@ -5768,23 +5946,23 @@ class Va {
5768
5946
  */
5769
5947
  async initializeView(e) {
5770
5948
  try {
5771
- x.debug && h.log("[AvatarView] Initializing avatar view...");
5772
- const t = S.getAvatarCore();
5949
+ I.debug && h.log("[AvatarView] Initializing avatar view...");
5950
+ const t = v.getAvatarCore();
5773
5951
  if (!t)
5774
5952
  throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
5775
5953
  const n = e.getResources();
5776
- x.debug && h.log("[AvatarView] Loading character data..."), this.characterHandle = await t.loadCharacterFromBuffers(
5954
+ I.debug && h.log("[AvatarView] Loading character data..."), this.characterHandle = await t.loadCharacterFromBuffers(
5777
5955
  n.characterData.shape,
5778
5956
  n.characterData.pointCloud,
5779
5957
  this.characterId
5780
- ), n.characterData.idleAnimation && (x.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation, this.characterId)), n.characterData.shape = new ArrayBuffer(0), n.characterData.pointCloud = new ArrayBuffer(0), n.characterData.idleAnimation && (n.characterData.idleAnimation = new ArrayBuffer(0)), n.characterData.monoAnimation && (n.characterData.monoAnimation = new ArrayBuffer(0)), this.avatarController.setRenderCallback(
5958
+ ), n.characterData.idleAnimation && (I.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation, this.characterId)), n.characterData.shape = new ArrayBuffer(0), n.characterData.pointCloud = new ArrayBuffer(0), n.characterData.idleAnimation && (n.characterData.idleAnimation = new ArrayBuffer(0)), n.characterData.monoAnimation && (n.characterData.monoAnimation = new ArrayBuffer(0)), this.avatarController.setRenderCallback(
5781
5959
  (i, s) => {
5782
5960
  this.renderRealtimeFrame(i, s);
5783
5961
  },
5784
5962
  this.characterHandle
5785
- ), x.debug && h.log("[AvatarView] Initializing render system...");
5963
+ ), I.debug && h.log("[AvatarView] Initializing render system...");
5786
5964
  const a = this.resolveCameraConfig(n);
5787
- await this.initializeRenderSystem(a), x.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, x.debug && h.log("[AvatarView] Avatar view initialized successfully");
5965
+ await this.initializeRenderSystem(a), I.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, I.debug && h.log("[AvatarView] Avatar view initialized successfully");
5788
5966
  } catch (t) {
5789
5967
  throw h.error("[AvatarView] Failed to initialize avatar view:", t instanceof Error ? t.message : String(t)), t;
5790
5968
  }
@@ -5793,25 +5971,25 @@ class Va {
5793
5971
  * 初始化渲染系统
5794
5972
  */
5795
5973
  async initializeRenderSystem(e) {
5796
- this.cameraConfig = e || this.getDefaultCameraConfig(), e ? h.log("[AvatarView] Using resolved camera config:", e) : h.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new La({
5974
+ this.cameraConfig = e || this.getDefaultCameraConfig(), e ? h.log("[AvatarView] Using resolved camera config:", e) : h.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new Ta({
5797
5975
  canvas: this.canvas,
5798
5976
  camera: this.cameraConfig,
5799
5977
  backgroundColor: [0, 0, 0, 0]
5800
5978
  // 透明背景,让 CSS 背景透出
5801
- }), await this.renderSystem.initialize(), x.debug && h.log("[AvatarView] Render system initialized successfully");
5979
+ }), await this.renderSystem.initialize(), I.debug && h.log("[AvatarView] Render system initialized successfully");
5802
5980
  }
5803
5981
  /**
5804
5982
  * 获取默认相机配置
5805
5983
  */
5806
5984
  getDefaultCameraConfig() {
5807
- return { ...x.camera };
5985
+ return { ...I.camera };
5808
5986
  }
5809
5987
  /**
5810
5988
  * 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
5811
5989
  */
5812
5990
  resolveCameraConfig(e) {
5813
- var l, o;
5814
- const t = this.getDefaultCameraConfig(), n = ((l = e.characterSettings) == null ? void 0 : l.camera) ?? null, a = ((o = e.preloadCameraSettings) == null ? void 0 : o.camera) ?? null, i = n ?? a;
5991
+ var o, l;
5992
+ const t = this.getDefaultCameraConfig(), n = ((o = e.characterSettings) == null ? void 0 : o.camera) ?? null, a = ((l = e.preloadCameraSettings) == null ? void 0 : l.camera) ?? null, i = n ?? a;
5815
5993
  if (!i)
5816
5994
  return h.warn("[AvatarView] Camera settings not found in resources, falling back to default camera config"), t;
5817
5995
  const s = n ? "characterSettings" : "camera.json";
@@ -5821,35 +5999,35 @@ class Va {
5821
5999
  * 从角色设置中推导相机配置
5822
6000
  */
5823
6001
  deriveCameraConfigFromSettings(e, t, n) {
5824
- const a = (W, Z) => Number.isFinite(W) ? W : Z, i = a(e.translationX, t.position[0]), s = a(e.translationY, t.position[1]), l = a(e.translationZ, t.position[2]), o = a(e.rotation, 0), p = a(e.fovYRadians, 0), c = Math.hypot(i, s, l) > 1e-4, u = p > 0, m = Math.abs(o) > 1e-4;
6002
+ const a = (W, Z) => Number.isFinite(W) ? W : Z, i = a(e.translationX, t.position[0]), s = a(e.translationY, t.position[1]), o = a(e.translationZ, t.position[2]), l = a(e.rotation, 0), p = a(e.fovYRadians, 0), c = Math.hypot(i, s, o) > 1e-4, u = p > 0, m = Math.abs(l) > 1e-4;
5825
6003
  if (!c && !u && !m)
5826
6004
  return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
5827
- const w = Math.sin(o), v = Math.cos(o), y = c ? [i, s, l] : [...t.position], b = [
5828
- -w,
6005
+ const y = Math.sin(l), w = Math.cos(l), A = c ? [i, s, o] : [...t.position], S = [
6006
+ -y,
5829
6007
  0,
5830
- -v
5831
- ], P = Math.hypot(b[0], b[1], b[2]) || 1, L = [
5832
- b[0] / P,
5833
- b[1] / P,
5834
- b[2] / P
6008
+ -w
6009
+ ], E = Math.hypot(S[0], S[1], S[2]) || 1, T = [
6010
+ S[0] / E,
6011
+ S[1] / E,
6012
+ S[2] / E
5835
6013
  ], _ = [
5836
- y[0] + L[0],
5837
- y[1] + L[1],
5838
- y[2] + L[2]
5839
- ], Y = [0, 1, 0], G = u ? p * 180 / Math.PI : t.fov, U = {
6014
+ A[0] + T[0],
6015
+ A[1] + T[1],
6016
+ A[2] + T[2]
6017
+ ], J = [0, 1, 0], G = u ? p * 180 / Math.PI : t.fov, U = {
5840
6018
  ...t,
5841
6019
  // 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
5842
- position: y,
6020
+ position: A,
5843
6021
  target: _,
5844
- up: Y,
6022
+ up: J,
5845
6023
  fov: G
5846
6024
  // near/far 从 fallback 继承,无需硬编码
5847
6025
  };
5848
6026
  return h.log("[AvatarView] Applied camera settings from resources", {
5849
6027
  source: n,
5850
- translation: [i, s, l],
5851
- yawRadians: o,
5852
- position: y,
6028
+ translation: [i, s, o],
6029
+ yawRadians: l,
6030
+ position: A,
5853
6031
  target: _,
5854
6032
  fov: G,
5855
6033
  near: U.near,
@@ -5862,7 +6040,7 @@ class Va {
5862
6040
  async renderFirstFrame() {
5863
6041
  if (!this.renderSystem)
5864
6042
  throw new Error("Render system not initialized");
5865
- const e = S.getAvatarCore();
6043
+ const e = v.getAvatarCore();
5866
6044
  if (!e)
5867
6045
  throw new Error("AvatarCore not available");
5868
6046
  const t = {
@@ -5875,7 +6053,7 @@ class Va {
5875
6053
  eyes_pose: [0, 0, 0, 0, 0, 0]
5876
6054
  }, n = await e.computeFrameFlatFromParams(t, this.characterHandle ?? void 0);
5877
6055
  if (n)
5878
- this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), x.debug && h.log("[AvatarView] First frame rendered successfully");
6056
+ this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), I.debug && h.log("[AvatarView] First frame rendered successfully");
5879
6057
  else
5880
6058
  throw new Error("Failed to compute first frame splat data");
5881
6059
  }
@@ -5898,12 +6076,12 @@ class Va {
5898
6076
  */
5899
6077
  startIdleAnimationLoop() {
5900
6078
  if (this.idleAnimationLoopId && this.stopIdleAnimationLoop(), this.renderingState !== "idle") {
5901
- x.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
6079
+ I.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
5902
6080
  return;
5903
6081
  }
5904
6082
  this.idleCurrentFrameIndex = 0;
5905
6083
  let e = 0;
5906
- const n = 1e3 / x.animation.fps;
6084
+ const n = 1e3 / I.animation.fps;
5907
6085
  this.initFPS();
5908
6086
  const a = async (i) => {
5909
6087
  try {
@@ -5918,21 +6096,21 @@ class Va {
5918
6096
  return;
5919
6097
  }
5920
6098
  e = i;
5921
- const s = S.getAvatarCore();
6099
+ const s = v.getAvatarCore();
5922
6100
  if (!s)
5923
6101
  return;
5924
- const l = await s.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex }, this.characterHandle ?? void 0);
5925
- if (this.idleCurrentFrameIndex++, l) {
6102
+ const o = await s.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex }, this.characterHandle ?? void 0);
6103
+ if (this.idleCurrentFrameIndex++, o) {
5926
6104
  if (this.renderingState !== "idle")
5927
6105
  return;
5928
- this.renderSystem.loadSplatsFromPackedData(l), this.renderSystem.renderFrame();
6106
+ this.renderSystem.loadSplatsFromPackedData(o), this.renderSystem.renderFrame();
5929
6107
  }
5930
6108
  this.idleAnimationLoopId = requestAnimationFrame(a);
5931
6109
  } catch (s) {
5932
6110
  h.error("[AvatarView] Idle animation loop error:", s instanceof Error ? s.message : String(s)), this.stopIdleAnimationLoop();
5933
6111
  }
5934
6112
  };
5935
- this.idleAnimationLoopId = requestAnimationFrame(a), x.debug && h.log("[AvatarView] Idle animation loop started");
6113
+ this.idleAnimationLoopId = requestAnimationFrame(a), I.debug && h.log("[AvatarView] Idle animation loop started");
5936
6114
  }
5937
6115
  /**
5938
6116
  * 开始实时对话动画循环
@@ -5940,7 +6118,7 @@ class Va {
5940
6118
  startRealtimeAnimationLoop() {
5941
6119
  this.realtimeAnimationLoopId && this.stopRealtimeAnimationLoop();
5942
6120
  let e = 0;
5943
- const n = 1e3 / x.animation.fps;
6121
+ const n = 1e3 / I.animation.fps;
5944
6122
  this.initFPS();
5945
6123
  const a = async (i) => {
5946
6124
  try {
@@ -5958,12 +6136,12 @@ class Va {
5958
6136
  this.realtimeAnimationLoopId = requestAnimationFrame(a);
5959
6137
  return;
5960
6138
  }
5961
- const l = performance.now() - this.transitionStartTime, o = Math.min(1, Math.max(0, l / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(o * (p - 1))), u = this.transitionKeyframes[c], m = zt(u), w = S.getAvatarCore();
5962
- if (w) {
5963
- const v = await w.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
5964
- v && (this.renderSystem.loadSplatsFromPackedData(v), this.renderSystem.renderFrame());
6139
+ const o = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, o / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(l * (p - 1))), u = this.transitionKeyframes[c], m = $t(u), y = v.getAvatarCore();
6140
+ if (y) {
6141
+ const w = await y.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
6142
+ w && (this.renderSystem.loadSplatsFromPackedData(w), this.renderSystem.renderFrame());
5965
6143
  }
5966
- if (o >= 1) {
6144
+ if (l >= 1) {
5967
6145
  if (s === "transitioningToSpeaking")
5968
6146
  this.setState(
5969
6147
  "speaking"
@@ -5988,19 +6166,19 @@ class Va {
5988
6166
  h.error("[AvatarView] Realtime animation loop error:", s instanceof Error ? s.message : String(s)), this.stopRealtimeAnimationLoop();
5989
6167
  }
5990
6168
  };
5991
- this.realtimeAnimationLoopId = requestAnimationFrame(a), x.debug && h.log("[AvatarView] Realtime animation loop started");
6169
+ this.realtimeAnimationLoopId = requestAnimationFrame(a), I.debug && h.log("[AvatarView] Realtime animation loop started");
5992
6170
  }
5993
6171
  /**
5994
6172
  * 停止idle动画循环
5995
6173
  */
5996
6174
  stopIdleAnimationLoop() {
5997
- this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, x.debug && h.log("[AvatarView] Idle animation loop stopped"));
6175
+ this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, I.debug && h.log("[AvatarView] Idle animation loop stopped"));
5998
6176
  }
5999
6177
  /**
6000
6178
  * 停止实时对话动画循环
6001
6179
  */
6002
6180
  stopRealtimeAnimationLoop() {
6003
- this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, x.debug && h.log("[AvatarView] Realtime animation loop stopped"));
6181
+ this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, I.debug && h.log("[AvatarView] Realtime animation loop stopped"));
6004
6182
  }
6005
6183
  /**
6006
6184
  * 停止所有动画循环
@@ -6089,17 +6267,17 @@ class Va {
6089
6267
  /* TransitioningToSpeaking */
6090
6268
  );
6091
6269
  try {
6092
- const n = S.getAvatarCore();
6270
+ const n = v.getAvatarCore();
6093
6271
  if (n && e.length > 0) {
6094
6272
  if (this.renderingState !== "transitioningToSpeaking")
6095
6273
  return;
6096
- const a = await n.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), i = ht(a);
6274
+ const a = await n.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), i = ft(a);
6097
6275
  await this.getCachedIdleFirstFrame();
6098
6276
  const s = e[0];
6099
6277
  this.transitionKeyframes = this.generateAndAlignTransitionFrames(i, s), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
6100
6278
  "speaking"
6101
6279
  /* Speaking */
6102
- ), this.avatarController.onTransitionComplete()) : x.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
6280
+ ), this.avatarController.onTransitionComplete()) : I.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
6103
6281
  }
6104
6282
  } catch (n) {
6105
6283
  h.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
@@ -6113,7 +6291,7 @@ class Va {
6113
6291
  * 开始实时渲染循环
6114
6292
  */
6115
6293
  startRealtimeRendering() {
6116
- x.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), S.logEvent("character_view", "info", {
6294
+ I.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), v.logEvent("character_view", "info", {
6117
6295
  characterId: this.avatar.id,
6118
6296
  event: "rendering_started",
6119
6297
  keyframesCount: this.currentKeyframes.length
@@ -6139,10 +6317,10 @@ class Va {
6139
6317
  try {
6140
6318
  if (this.renderingState !== "transitioningToIdle")
6141
6319
  return;
6142
- if (S.getAvatarCore() && this.currentKeyframes.length > 0) {
6320
+ if (v.getAvatarCore() && this.currentKeyframes.length > 0) {
6143
6321
  const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], a = await this.getCachedIdleFirstFrame();
6144
6322
  if (a && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, a), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
6145
- x.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
6323
+ I.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
6146
6324
  return;
6147
6325
  }
6148
6326
  }
@@ -6161,21 +6339,21 @@ class Va {
6161
6339
  * 关闭 avatarController 并清理所有相关资源
6162
6340
  */
6163
6341
  dispose() {
6164
- x.debug && h.log("[AvatarView] Disposing avatar view..."), S.logEvent("character_view", "info", {
6342
+ I.debug && h.log("[AvatarView] Disposing avatar view..."), v.logEvent("character_view", "info", {
6165
6343
  characterId: this.avatar.id,
6166
6344
  event: "disposed"
6167
6345
  }), this.avatarController && (this.avatarController.clear(), this.avatarController.dispose()), this.stopAllAnimationLoops(), this.setState(
6168
6346
  "idle"
6169
6347
  /* Idle */
6170
6348
  ), this.cachedIdleFirstFrame = null, this.idleCurrentFrameIndex = 0;
6171
- const e = S.getAvatarCore();
6349
+ const e = v.getAvatarCore();
6172
6350
  if (e && this.characterHandle)
6173
6351
  try {
6174
- e.removeCharacter(this.characterHandle, this.characterId), x.debug && h.log("[AvatarView] AvatarCore character resources released"), this.characterHandle = null;
6352
+ e.removeCharacter(this.characterHandle, this.characterId), I.debug && h.log("[AvatarView] AvatarCore character resources released"), this.characterHandle = null;
6175
6353
  } catch (t) {
6176
6354
  h.error("[AvatarView] Failed to release AvatarCore resources:", t instanceof Error ? t.message : String(t));
6177
6355
  }
6178
- this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1, x.debug && h.log("[AvatarView] Avatar view disposed successfully");
6356
+ this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1, I.debug && h.log("[AvatarView] Avatar view disposed successfully");
6179
6357
  }
6180
6358
  /**
6181
6359
  * 获取相机配置
@@ -6189,7 +6367,7 @@ class Va {
6189
6367
  * @internal
6190
6368
  */
6191
6369
  updateCameraConfig(e) {
6192
- this.cameraConfig = e, x.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), x.debug && h.log("[AvatarView] Applied new camera config to render system"));
6370
+ this.cameraConfig = e, I.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), I.debug && h.log("[AvatarView] Applied new camera config to render system"));
6193
6371
  }
6194
6372
  /**
6195
6373
  * 处理尺寸变化:通知渲染系统更新视口与投影
@@ -6213,23 +6391,24 @@ class Va {
6213
6391
  }
6214
6392
  }
6215
6393
  export {
6216
- x as A,
6217
- be as C,
6218
- le as E,
6219
- he as L,
6220
- an as R,
6221
- oe as S,
6222
- S as a,
6223
- nn as b,
6224
- ba as c,
6225
- Tt as d,
6226
- nr as e,
6394
+ I as A,
6395
+ _e as C,
6396
+ We as D,
6397
+ ce as E,
6398
+ fe as L,
6399
+ on as R,
6400
+ ee as S,
6401
+ v as a,
6402
+ sn as b,
6403
+ Ca as c,
6404
+ Bt as d,
6405
+ ir as e,
6227
6406
  Va as f,
6228
- T as g,
6229
- Me as h,
6230
- Oa as i,
6231
- Na as j,
6232
- Ua as k,
6407
+ F as g,
6408
+ we as h,
6409
+ Na as i,
6410
+ Ua as j,
6411
+ za as k,
6233
6412
  h as l
6234
6413
  };
6235
- //# sourceMappingURL=index-Dsokgngg.js.map
6414
+ //# sourceMappingURL=index-suaZGA5u.js.map