@vkontakte/calls-sdk 2.8.13-dev.47735529.0 → 2.8.13-dev.49da331a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.13-dev.47735529.0
3
- * Fri, 23 Oct 2026 13:53:00 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.49da331a.0
3
+ * Mon, 26 Oct 2026 16:23:11 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -2220,7 +2220,7 @@ var wn = Cn.getInstance(), N = class e {
2220
2220
  return 1.1;
2221
2221
  }
2222
2222
  static get sdkVersion() {
2223
- return "2.8.13-dev.47735529.0";
2223
+ return "2.8.13-dev.49da331a.0";
2224
2224
  }
2225
2225
  static get debug() {
2226
2226
  return e._params.debug;
@@ -9067,7 +9067,7 @@ function fs(e) {
9067
9067
  }
9068
9068
  //#endregion
9069
9069
  //#region src/classes/stat/StatQueue.ts
9070
- var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys = 10080 * 60 * 1e3, bs = 5e3, xs = 6e4, Q = class e {
9070
+ var ps, ms = "ok-calls-sdk-stats", hs = 2, gs = "events", _s = "tails", vs = 100, ys = 5e3, bs = 10080 * 60 * 1e3, xs = 5e3, Ss = 6e4, Q = class e {
9071
9071
  static isSupported() {
9072
9072
  return e._supported;
9073
9073
  }
@@ -9082,14 +9082,32 @@ var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys
9082
9082
  }).catch((e) => (z.error("[StatQueue] failed to append event", e), null));
9083
9083
  return r === null ? null : (await e._countAppend(), r);
9084
9084
  }
9085
- static async appendFinishOnce(t) {
9085
+ static async putTail(t) {
9086
+ let n = await e._open();
9087
+ return n ? e._runTransaction(n, "readwrite", (e) => (e.put(t), !0), [_s]).catch((e) => (z.error("[StatQueue] failed to put tail", e), !1)) : !1;
9088
+ }
9089
+ static async updateTail(t) {
9090
+ let n = await e._open();
9091
+ return n ? e._runTransaction(n, "readwrite", async (n) => await e._request(n.count(t.key)) === 0 ? "missing" : (n.put(t), "updated"), [_s]).catch((e) => (z.error("[StatQueue] failed to update tail", e), "failed")) : "failed";
9092
+ }
9093
+ static async removeTail(t) {
9094
+ let n = await e._open();
9095
+ return n ? e._runTransaction(n, "readwrite", async (n) => await e._request(n.count(t)) === 0 ? "missing" : (n.delete(t), "removed"), [_s]).catch((e) => (z.error("[StatQueue] failed to remove tail", e), "failed")) : "failed";
9096
+ }
9097
+ static async listTailKeys() {
9098
+ let t = await e._open();
9099
+ return t ? e._runTransaction(t, "readonly", (t) => e._request(t.getAllKeys()), [_s]).catch((e) => (z.error("[StatQueue] failed to list tails", e), [])) : [];
9100
+ }
9101
+ static async adoptTail(t) {
9086
9102
  let n = await e._open();
9087
9103
  if (!n) return "failed";
9088
- let r = await e._runTransaction(n, "readwrite", async (e) => (await new Promise((n) => {
9089
- let r = e.index("by_vcid").getAll(IDBKeyRange.only(t.vcid));
9090
- r.onsuccess = () => n(r.result);
9091
- })).some((e) => e.uid === t.uid && e.ev.name === U.CALL_FINISH) ? "exists" : (e.add(t), "added")).catch((e) => (z.error("[StatQueue] failed to append finish", e), "failed"));
9092
- return r === "added" && await e._countAppend(), r;
9104
+ let r = 0, i = await e._runTransaction(n, "readwrite", async (n, i) => {
9105
+ let a = i.objectStore(_s), o = await e._request(a.get(t));
9106
+ if (!o) return "missing";
9107
+ let s = await e._request(n.index("by_vcid").getAll(IDBKeyRange.only(o.vcid)));
9108
+ return a.delete(t), s.some((e) => e.uid === o.uid && e.ev.name === U.CALL_FINISH) ? "exists" : (o.entries.forEach((e) => n.add(e)), r = o.entries.length, "added");
9109
+ }, [gs, _s]).catch((e) => (z.error("[StatQueue] failed to adopt tail", e), "failed"));
9110
+ return i === "added" && await e._countAppend(r), i;
9093
9111
  }
9094
9112
  static async fillDelta(t, n) {
9095
9113
  if (t.length === 0) return;
@@ -9192,9 +9210,9 @@ var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys
9192
9210
  static async __resetForTests() {
9193
9211
  if (e._appendsSinceEvictCheck = 0, e._lastOpenFailureAt = null, e._supported = e._checkSupport(), e._dbName === ms && (e._dbName = `${ms}-test-${Math.random().toString(36).slice(2)}`, e._close()), e._supported) {
9194
9212
  let t = await e._open();
9195
- t && await e._runTransaction(t, "readwrite", (e) => {
9196
- e.clear();
9197
- }).catch((e) => {
9213
+ t && await e._runTransaction(t, "readwrite", (e, t) => {
9214
+ e.clear(), t.objectStore(_s).clear();
9215
+ }, [gs, _s]).catch((e) => {
9198
9216
  z.error("[StatQueue] failed to reset storage", e);
9199
9217
  });
9200
9218
  }
@@ -9205,7 +9223,7 @@ var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys
9205
9223
  static _open() {
9206
9224
  if (!e._checkSupport()) return e._supported = !1, Promise.resolve(null);
9207
9225
  if (e._dbPromise) return e._dbPromise;
9208
- if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < xs) return Promise.resolve(null);
9226
+ if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < Ss) return Promise.resolve(null);
9209
9227
  let t = !1, n = new Promise((n) => {
9210
9228
  let r = (r, i) => {
9211
9229
  t || (t = !0, z.error(r, i), e._supported = !1, e._dbPromise = null, e._lastOpenFailureAt = Date.now(), n(null));
@@ -9216,7 +9234,7 @@ var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys
9216
9234
  r("[StatQueue] storage is not accessible", e);
9217
9235
  return;
9218
9236
  }
9219
- let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), bs);
9237
+ let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), xs);
9220
9238
  i.onupgradeneeded = () => {
9221
9239
  e._createSchema(i.result);
9222
9240
  }, i.onsuccess = () => {
@@ -9233,33 +9251,40 @@ var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys
9233
9251
  });
9234
9252
  return t || (e._dbPromise = n), n;
9235
9253
  }
9236
- static async _countAppend() {
9237
- e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= _s && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(vs));
9254
+ static async _countAppend(t = 1) {
9255
+ e._appendsSinceEvictCheck += t, e._appendsSinceEvictCheck >= vs && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(ys));
9238
9256
  }
9239
9257
  static _close() {
9240
9258
  e._db && (e._db.close(), e._db = null), e._dbPromise = null;
9241
9259
  }
9242
9260
  static _createSchema(e) {
9243
- if (e.objectStoreNames.contains(gs)) return;
9244
- let t = e.createObjectStore(gs, {
9245
- keyPath: "id",
9246
- autoIncrement: !0
9247
- });
9248
- t.createIndex("by_uid", "uid", { unique: !1 }), t.createIndex("by_vcid", "vcid", { unique: !1 });
9261
+ if (!e.objectStoreNames.contains(gs)) {
9262
+ let t = e.createObjectStore(gs, {
9263
+ keyPath: "id",
9264
+ autoIncrement: !0
9265
+ });
9266
+ t.createIndex("by_uid", "uid", { unique: !1 }), t.createIndex("by_vcid", "vcid", { unique: !1 });
9267
+ }
9268
+ e.objectStoreNames.contains(_s) || e.createObjectStore(_s, { keyPath: "key" });
9249
9269
  }
9250
- static _runTransaction(e, t, n) {
9251
- return new Promise((r, i) => {
9252
- let a = e.transaction(gs, t), o;
9253
- a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(gs))).then((e) => {
9254
- o = e;
9270
+ static _runTransaction(e, t, n, r = [gs]) {
9271
+ return new Promise((i, a) => {
9272
+ let o = e.transaction(r, t), s;
9273
+ o.oncomplete = () => i(s), o.onerror = () => a(o.error), o.onabort = () => a(o.error), Promise.resolve(n(o.objectStore(r[0]), o)).then((e) => {
9274
+ s = e;
9255
9275
  }).catch((e) => {
9256
9276
  try {
9257
- a.abort();
9277
+ o.abort();
9258
9278
  } catch {}
9259
- i(e);
9279
+ a(e);
9260
9280
  });
9261
9281
  });
9262
9282
  }
9283
+ static _request(e) {
9284
+ return new Promise((t) => {
9285
+ e.onsuccess = () => t(e.result);
9286
+ });
9287
+ }
9263
9288
  static _readOldestRecord(e) {
9264
9289
  let t = e.openCursor();
9265
9290
  return new Promise((e) => {
@@ -9278,15 +9303,15 @@ var ps, ms = "ok-calls-sdk-stats", hs = 1, gs = "events", _s = 100, vs = 5e3, ys
9278
9303
  ps = Q, h(Q, "_db", null), h(Q, "_dbPromise", null), h(Q, "_dbName", ms), h(Q, "_supported", ps._checkSupport()), h(Q, "_appendsSinceEvictCheck", 0), h(Q, "_lastOpenFailureAt", null);
9279
9304
  //#endregion
9280
9305
  //#region src/static/ApiTransport.ts
9281
- var Ss = null, Cs = null, ws = 64 * 1024;
9282
- function Ts() {
9283
- Ss = null, Cs = null;
9306
+ var Cs = null, ws = null, Ts = 64 * 1024;
9307
+ function Es() {
9308
+ Cs = null, ws = null;
9284
9309
  }
9285
- function Es(e) {
9310
+ function Ds(e) {
9286
9311
  return e?.endsWith("/") ? e.slice(0, -1) : e;
9287
9312
  }
9288
- async function Ds(e = null, t) {
9289
- let n = Es(e ?? N.apiBaseUrl);
9313
+ async function Os(e = null, t) {
9314
+ let n = Ds(e ?? N.apiBaseUrl);
9290
9315
  if (n) return n;
9291
9316
  if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
9292
9317
  try {
@@ -9301,25 +9326,25 @@ async function Ds(e = null, t) {
9301
9326
  return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
9302
9327
  }
9303
9328
  }
9304
- async function Os() {
9305
- return Ss || Cs || (Cs = Ds(), Ss = await Cs, Cs = null, Ss);
9329
+ async function ks() {
9330
+ return Cs || ws || (ws = Os(), Cs = await ws, ws = null, Cs);
9306
9331
  }
9307
- async function ks(e, t = {}, n = !1) {
9332
+ async function As(e, t = {}, n = !1) {
9308
9333
  if (!window.Blob || !window.navigator.sendBeacon) return;
9309
- await Os();
9310
- let r = Fs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9311
- window.navigator.sendBeacon(`${Ss}/fb.do`, i);
9334
+ await ks();
9335
+ let r = Is(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9336
+ window.navigator.sendBeacon(`${Cs}/fb.do`, i);
9312
9337
  }
9313
- async function As(e, t = {}, n = !1, r) {
9314
- return await Os(), Ms(Fs(e, t, n), r);
9338
+ async function js(e, t = {}, n = !1, r) {
9339
+ return await ks(), Ns(Is(e, t, n), r);
9315
9340
  }
9316
- async function js(e, t = {}, n = !1) {
9317
- await Os();
9318
- let r = Fs(e, t, n);
9319
- return Ms(r, void 0, new Blob([r]).size <= ws);
9341
+ async function Ms(e, t = {}, n = !1) {
9342
+ await ks();
9343
+ let r = Is(e, t, n);
9344
+ return Ns(r, void 0, new Blob([r]).size <= Ts);
9320
9345
  }
9321
- async function Ms(e, t, n = !1) {
9322
- let r = `${t ?? Ss}/fb.do`, i = new AbortController(), a = new k(b.NETWORK, { callError: {
9346
+ async function Ns(e, t, n = !1) {
9347
+ let r = `${t ?? Cs}/fb.do`, i = new AbortController(), a = new k(b.NETWORK, { callError: {
9323
9348
  scope: "network",
9324
9349
  source: "api",
9325
9350
  code: "timeout",
@@ -9338,16 +9363,16 @@ async function Ms(e, t, n = !1) {
9338
9363
  } catch {
9339
9364
  o = { result: a };
9340
9365
  }
9341
- if (!t.ok && !Ns(o)) throw new k(b.API, { callError: {
9366
+ if (!t.ok && !Ps(o)) throw new k(b.API, { callError: {
9342
9367
  scope: "server",
9343
9368
  source: "api",
9344
9369
  code: `http-${t.status}`,
9345
9370
  description: "http-error"
9346
9371
  } });
9347
- if (Ns(o)) throw o;
9372
+ if (Ps(o)) throw o;
9348
9373
  return o;
9349
9374
  } catch (e) {
9350
- throw e instanceof k ? e : i.signal.aborted ? a : Ns(e) ? e : new k(b.NETWORK, { callError: {
9375
+ throw e instanceof k ? e : i.signal.aborted ? a : Ps(e) ? e : new k(b.NETWORK, { callError: {
9351
9376
  scope: "network",
9352
9377
  source: "api",
9353
9378
  code: "fetch-failed",
@@ -9357,12 +9382,12 @@ async function Ms(e, t, n = !1) {
9357
9382
  clearTimeout(o);
9358
9383
  }
9359
9384
  }
9360
- function Ns(e) {
9385
+ function Ps(e) {
9361
9386
  if (typeof e != "object" || !e) return !1;
9362
9387
  let t = e;
9363
9388
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
9364
9389
  }
9365
- async function Ps(e, t) {
9390
+ async function Fs(e, t) {
9366
9391
  try {
9367
9392
  let n = await fetch(e, {
9368
9393
  method: "POST",
@@ -9375,7 +9400,7 @@ async function Ps(e, t) {
9375
9400
  throw z.warn("Failed to send form data", e), e;
9376
9401
  }
9377
9402
  }
9378
- function Fs(e, t = {}, n = !1) {
9403
+ function Is(e, t = {}, n = !1) {
9379
9404
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = N.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
9380
9405
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
9381
9406
  let r = "";
@@ -9384,7 +9409,7 @@ function Fs(e, t = {}, n = !1) {
9384
9409
  }
9385
9410
  //#endregion
9386
9411
  //#region src/static/SessionStore.ts
9387
- var Is = "sessions", Ls = 5, Rs = class e {
9412
+ var Ls = "sessions", Rs = 5, zs = class e {
9388
9413
  static remember(t, n) {
9389
9414
  let r = e._read();
9390
9415
  r[String(t)] = {
@@ -9392,7 +9417,7 @@ var Is = "sessions", Ls = 5, Rs = class e {
9392
9417
  savedAt: Date.now()
9393
9418
  };
9394
9419
  let i = Object.keys(r);
9395
- i.length > Ls && i.sort((e, t) => r[e].savedAt - r[t].savedAt).slice(0, i.length - Ls).forEach((e) => delete r[e]), e._write(r);
9420
+ i.length > Rs && i.sort((e, t) => r[e].savedAt - r[t].savedAt).slice(0, i.length - Rs).forEach((e) => delete r[e]), e._write(r);
9396
9421
  }
9397
9422
  static get(t) {
9398
9423
  return e._read()[String(t)] ?? null;
@@ -9408,10 +9433,10 @@ var Is = "sessions", Ls = 5, Rs = class e {
9408
9433
  }), r && e._write(n);
9409
9434
  }
9410
9435
  static currentEndpoint() {
9411
- return String(Es(N.apiBaseUrl) || N.apiEndpoint());
9436
+ return String(Ds(N.apiBaseUrl) || N.apiEndpoint());
9412
9437
  }
9413
9438
  static _read() {
9414
- let t = ht.get(Is);
9439
+ let t = ht.get(Ls);
9415
9440
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
9416
9441
  let n = {};
9417
9442
  return Object.entries(t).forEach(([t, r]) => {
@@ -9420,291 +9445,155 @@ var Is = "sessions", Ls = 5, Rs = class e {
9420
9445
  }
9421
9446
  static _write(e) {
9422
9447
  if (Object.keys(e).length === 0) {
9423
- ht.remove(Is);
9448
+ ht.remove(Ls);
9424
9449
  return;
9425
9450
  }
9426
- ht.set(Is, e);
9451
+ ht.set(Ls, e);
9427
9452
  }
9428
9453
  static _isValid(e) {
9429
9454
  let t = e;
9430
9455
  return typeof t == "object" && !!t && typeof t.sessionKey == "string" && t.sessionKey.length > 0 && typeof t.endpoint == "string" && typeof t.savedAt == "number";
9431
9456
  }
9432
- }, zs = "okcls-stat-unload.", Bs = class e {
9433
- static beginTabSession() {
9434
- e._tabKey = null, e._entries = [];
9435
- }
9436
- static writeSync(t) {
9437
- let n = e._storage();
9438
- if (!n) return !1;
9439
- try {
9440
- return e._tabKey || (e._tabKey = zs + M.uuid()), e._entries.length > 0 && n.getItem(e._tabKey) === null && (e._entries = []), e._entries.push(t), n.setItem(e._tabKey, JSON.stringify(e._entries)), !0;
9441
- } catch (e) {
9442
- return z.error("[StatUnloadJournal] failed to write", e), !1;
9443
- }
9444
- }
9445
- static async drainToQueue() {
9446
- let t = e._storage();
9447
- if (!t) return 0;
9448
- let n = [];
9449
- try {
9450
- for (let e = 0; e < t.length; e += 1) {
9451
- let r = t.key(e);
9452
- r && r.startsWith(zs) && n.push(r);
9453
- }
9454
- } catch (e) {
9455
- return z.error("[StatUnloadJournal] failed to scan journals", e), 0;
9456
- }
9457
- let r = 0;
9458
- e.beginTabSession();
9459
- for (let i of n) {
9460
- let n = e._take(t, i);
9461
- if (n === null) continue;
9462
- let a = null;
9463
- try {
9464
- a = JSON.parse(n);
9465
- } catch {
9466
- z.error("[StatUnloadJournal] dropping corrupted journal", i);
9467
- }
9468
- if (Array.isArray(a)) for (let t of a) e._isValidEntry(t) && await Q.append(t) && (r += 1);
9469
- }
9470
- return r;
9471
- }
9472
- static __resetForTests() {
9473
- e._tabKey = null, e._entries = [];
9474
- }
9475
- static _take(e, t) {
9476
- try {
9477
- let n = e.getItem(t);
9478
- return n === null ? null : (e.removeItem(t), n);
9479
- } catch (e) {
9480
- return z.error("[StatUnloadJournal] failed to take journal", e), null;
9481
- }
9457
+ }, Bs = 1e3, Vs = 5, Hs = "okcls-stat-call.", Us = 3, Ws = { wallNow: () => Date.now() }, Gs = class e {
9458
+ static get tabId() {
9459
+ return e._tabId === null && (e._tabId = M.uuid()), e._tabId;
9482
9460
  }
9483
- static _storage() {
9484
- try {
9485
- return window.localStorage;
9486
- } catch {
9487
- return null;
9488
- }
9461
+ static lockName(e) {
9462
+ return Hs + e;
9489
9463
  }
9490
- static _isValidEntry(e) {
9491
- let t = e;
9492
- return typeof t == "object" && !!t && typeof t.uid == "number" && (t.vcid === null || typeof t.vcid == "string") && typeof t.ts == "number" && (t.delta === void 0 || t.delta === null || typeof t.delta == "number") && typeof t.ev == "object" && t.ev !== null;
9493
- }
9494
- };
9495
- h(Bs, "_tabKey", null), h(Bs, "_entries", []);
9496
- //#endregion
9497
- //#region src/classes/stat/ProvisionalFinishStore.ts
9498
- var Vs = "okcls-stat-provisional.", Hs = "okcls-stat-tab.", Us = ys - 360 * 60 * 1e3, Ws = new class {
9499
- constructor({ keyPrefix: e = Vs, lockPrefix: t = Hs } = {}) {
9500
- h(this, "_keyPrefix", void 0), h(this, "_lockPrefix", void 0), h(this, "_tabId", null), h(this, "_holders", 0), h(this, "_lockState", "none"), h(this, "_generation", 0), h(this, "_releaseLock", null), h(this, "_waiting", /* @__PURE__ */ new Map()), h(this, "_written", /* @__PURE__ */ new Set()), h(this, "_adopted", /* @__PURE__ */ new Set()), h(this, "_whenOwned", []), this._keyPrefix = e, this._lockPrefix = t;
9501
- }
9502
- get tabId() {
9503
- return this._tabId === null && (this._tabId = M.uuid()), this._tabId;
9464
+ static isSupported() {
9465
+ return typeof navigator < "u" && !!navigator.locks && Q.isSupported();
9504
9466
  }
9505
- isSupported() {
9506
- return this._locks() !== null && this._storage() !== null;
9467
+ constructor(e, t, n = Ws) {
9468
+ h(this, "_logger", void 0), h(this, "_summaries", void 0), h(this, "_clock", void 0), h(this, "_status", "idle"), h(this, "_vcid", null), h(this, "_key", null), h(this, "_creation", null), h(this, "_summaryCache", []), h(this, "_touches", 0), h(this, "_timer", null), h(this, "_releaseLock", null), h(this, "_lockFailures", 0), h(this, "_onAdopted", null), this._logger = e, this._summaries = t, this._clock = n;
9507
9469
  }
9508
- hold() {
9509
- this._holders += 1, this._lockState === "none" && this._requestLock();
9470
+ start(t, n) {
9471
+ this._status === "idle" && (this._status = "starting", this._vcid = t, this._key = `${e.tabId}.${t}`, this._onAdopted = n, this._requestLock());
9510
9472
  }
9511
- unhold() {
9512
- this._holders = Math.max(0, this._holders - 1), this._holders === 0 && this._lockState === "held" && (this._lockState = "none", this._release());
9473
+ touch() {
9474
+ this._status === "active" && this._write();
9513
9475
  }
9514
- save(e) {
9515
- if (!this._adopted.has(e.vcid)) {
9516
- if (this._lockState === "held") {
9517
- this._write(e);
9518
- return;
9519
- }
9520
- (this._lockState === "requesting" || this._lockState === "regaining") && this._waiting.set(e.vcid, e);
9476
+ complete(e) {
9477
+ let t = this._status, n = this._key;
9478
+ if (t === "adopted" || t === "done") return;
9479
+ let r = this._creation;
9480
+ if (this._finish(), t !== "active" || r === null || n === null) {
9481
+ this._release(), e();
9482
+ return;
9521
9483
  }
9484
+ r.then((e) => e ? Q.removeTail(n) : "failed").then((t) => {
9485
+ this._release(), t !== "missing" && e();
9486
+ });
9522
9487
  }
9523
- remove(e) {
9524
- this._waiting.delete(e), this._adopted.delete(e), this._written.delete(e) && (this._lockState === "held" || this._lockState === "failed") && this._removeKey(this._key(e));
9525
- }
9526
- isAdopted(e) {
9527
- return this._lockState === "held" && this._detectAdopted(e), this._adopted.has(e);
9528
- }
9529
- whenOwned(e) {
9530
- if (this._lockState === "regaining") {
9531
- this._whenOwned.push(e);
9488
+ stop() {
9489
+ if (this._status !== "active" && this._status !== "starting") return;
9490
+ let e = this._creation === null ? null : this._key;
9491
+ if (this._finish(), e === null) {
9492
+ this._release();
9532
9493
  return;
9533
9494
  }
9534
- this._run(e);
9495
+ Q.removeTail(e).then(() => this._release());
9535
9496
  }
9536
- async adoptOrphans(e = Date.now()) {
9537
- let t = this._locks(), n = this._storage();
9538
- if (!t || !n) return 0;
9539
- let r = 0;
9540
- try {
9541
- let i = this._findOrphans(n, e);
9542
- if (i.size === 0) return 0;
9543
- await Bs.drainToQueue();
9544
- for (let [e, a] of i) try {
9545
- await t.request(this._lockPrefix + e, { ifAvailable: !0 }, async (e) => {
9546
- if (e !== null) for (let e of a) await this._adoptOne(n, e) && (r += 1);
9547
- });
9548
- } catch (t) {
9549
- z.error("[ProvisionalFinishStore] failed to adopt records of tab", e, t);
9550
- }
9551
- } catch (e) {
9552
- z.error("[ProvisionalFinishStore] failed to adopt records", e);
9553
- }
9554
- return r > 0 && z.debug("[ProvisionalFinishStore] adopted", r, "provisional finishes"), r;
9497
+ abandon() {
9498
+ this._status !== "active" && this._status !== "starting" || (this._clearTimer(), this._status = "abandoned", this._release());
9555
9499
  }
9556
9500
  _requestLock() {
9557
- this._generation += 1;
9558
- let e = this._generation;
9559
- this._lockState = this._lockState === "held" ? "regaining" : "requesting";
9560
- let t = this._locks();
9561
- if (!t) {
9562
- this._fail(/* @__PURE__ */ Error("Web Locks are not available"));
9563
- return;
9564
- }
9565
- try {
9566
- t.request(this._lockPrefix + this.tabId, () => this._onGranted(e)).then(() => this._onLockGone(e), (t) => this._onLockGone(e, t));
9501
+ let t = this._key, n = !1;
9502
+ if (t !== null) try {
9503
+ navigator.locks.request(e.lockName(t), () => (n = !0, this._onLockGranted())).then(() => this._onLockGone(n), (e) => this._onLockGone(n, e));
9567
9504
  } catch (e) {
9568
- this._fail(e);
9505
+ this._onLockGone(!1, e);
9569
9506
  }
9570
9507
  }
9571
- _onGranted(e) {
9572
- if (e !== this._generation) return;
9573
- if (this._holders === 0) {
9574
- this._lockState = "none";
9575
- return;
9576
- }
9577
- this._lockState === "regaining" && this._markAdopted();
9578
- let t = new Promise((e) => {
9508
+ _onLockGranted() {
9509
+ if (this._status !== "starting" && this._status !== "active") return;
9510
+ this._lockFailures = 0;
9511
+ let e = new Promise((e) => {
9579
9512
  this._releaseLock = e;
9580
9513
  });
9581
- return this._lockState = "held", this._writeWaiting(), this._flushWhenOwned(), t;
9514
+ return this._status === "starting" && (this._status = "active", this._summaryCache = this._collectSummaries(), this._write(), this._timer = window.setInterval(() => this._onTimer(), Bs)), e;
9582
9515
  }
9583
9516
  _onLockGone(e, t) {
9584
- if (e === this._generation) {
9585
- if (this._lockState === "held") {
9586
- this._releaseLock = null, this._holders > 0 ? this._requestLock() : this._lockState = "none";
9587
- return;
9588
- }
9589
- (this._lockState === "requesting" || this._lockState === "regaining") && this._fail(t);
9590
- }
9591
- }
9592
- _fail(e) {
9593
- z.error("[ProvisionalFinishStore] tab lock is not available", e), this._lockState = "failed", this._releaseLock = null, this._waiting.clear(), this._written.forEach((e) => this._removeKey(this._key(e))), this._written.clear(), this._flushWhenOwned();
9594
- }
9595
- _release() {
9596
- let e = this._releaseLock;
9597
- this._releaseLock = null, e?.();
9598
- }
9599
- _markAdopted() {
9600
- [...this._written].forEach((e) => this._detectAdopted(e));
9601
- }
9602
- _detectAdopted(e) {
9603
- let t = this._storage();
9604
- if (!t || !this._written.has(e)) return !1;
9605
- try {
9606
- if (t.getItem(this._key(e)) !== null) return !1;
9607
- } catch (e) {
9608
- return z.error("[ProvisionalFinishStore] failed to check record", e), !1;
9517
+ if (this._releaseLock = null, this._status !== "starting" && this._status !== "active") return;
9518
+ if (e || (this._lockFailures += 1), this._lockFailures < Us) {
9519
+ this._requestLock();
9520
+ return;
9609
9521
  }
9610
- return this._written.delete(e), this._adopted.add(e), !0;
9522
+ z.error("[CallStatTail] call lock is not available", t);
9523
+ let n = this._creation === null ? null : this._key;
9524
+ this._clearTimer(), this._status = "off", n !== null && Q.removeTail(n);
9611
9525
  }
9612
- _writeWaiting() {
9613
- let e = this._waiting;
9614
- this._waiting = /* @__PURE__ */ new Map();
9615
- for (let t of e.values()) this._adopted.has(t.vcid) || this._write(t);
9526
+ _onTimer() {
9527
+ this._touches += 1, this._touches % Vs === 0 && (this._summaryCache = this._collectSummaries()), this.touch();
9616
9528
  }
9617
- _flushWhenOwned() {
9618
- let e = this._whenOwned;
9619
- this._whenOwned = [], e.forEach((e) => this._run(e));
9620
- }
9621
- _run(e) {
9622
- try {
9623
- e();
9624
- } catch (e) {
9625
- z.error("[ProvisionalFinishStore] callback failed", e);
9626
- }
9627
- }
9628
- _write(e) {
9629
- let t = this._storage();
9630
- if (!(!t || this._detectAdopted(e.vcid))) try {
9631
- t.setItem(this._key(e.vcid), JSON.stringify(e)), this._written.add(e.vcid);
9632
- } catch (e) {
9633
- z.error("[ProvisionalFinishStore] failed to write record", e);
9529
+ _write() {
9530
+ let e = this._buildTail();
9531
+ if (e !== null) {
9532
+ if (this._creation === null) {
9533
+ let t = Q.putTail(e);
9534
+ this._creation = t, t.then((e) => {
9535
+ !e && this._creation === t && this._status === "active" && (this._creation = null);
9536
+ });
9537
+ return;
9538
+ }
9539
+ Q.updateTail(e).then((e) => {
9540
+ e === "missing" && this._status === "active" && this._adopt();
9541
+ });
9634
9542
  }
9635
9543
  }
9636
- _findOrphans(e, t) {
9637
- let n = /* @__PURE__ */ new Map(), r = [];
9544
+ _buildTail() {
9638
9545
  try {
9639
- for (let t = 0; t < e.length; t += 1) {
9640
- let n = e.key(t);
9641
- n !== null && n.startsWith(this._keyPrefix) && r.push(n);
9546
+ let e = this._vcid, t = this._key;
9547
+ if (e === null || t === null) return null;
9548
+ let n = {
9549
+ conversationId: e,
9550
+ occurredAt: this._clock.wallNow()
9551
+ }, r = this._logger.buildEntry({
9552
+ name: U.CALL_FINISH,
9553
+ reason: "terminated"
9554
+ }, n);
9555
+ if (r === null) return null;
9556
+ let i = [r];
9557
+ for (let e of this._summaryCache) {
9558
+ let t = this._logger.buildEntry(e, n);
9559
+ t !== null && i.push(t);
9642
9560
  }
9561
+ return {
9562
+ key: t,
9563
+ uid: r.uid,
9564
+ vcid: e,
9565
+ ts: n.occurredAt,
9566
+ entries: i
9567
+ };
9643
9568
  } catch (e) {
9644
- return z.error("[ProvisionalFinishStore] failed to scan records", e), n;
9645
- }
9646
- for (let i of r) {
9647
- let r = this._getItem(e, i);
9648
- if (r === null) continue;
9649
- let a = this._parse(r);
9650
- if (a === null) {
9651
- this._removeKey(i);
9652
- continue;
9653
- }
9654
- if (a.tab === this.tabId) continue;
9655
- if (t - a.ts > Us) {
9656
- this._removeKey(i);
9657
- continue;
9658
- }
9659
- let o = n.get(a.tab) ?? [];
9660
- o.push(i), n.set(a.tab, o);
9661
- }
9662
- return n;
9663
- }
9664
- async _adoptOne(e, t) {
9665
- let n = this._getItem(e, t), r = n === null ? null : this._parse(n);
9666
- if (r === null) return !1;
9667
- let { tab: i, ...a } = r, o = await Q.appendFinishOnce(a);
9668
- return o === "failed" ? !1 : (this._removeKey(t), o === "added");
9669
- }
9670
- _parse(e) {
9671
- let t;
9672
- try {
9673
- t = JSON.parse(e);
9674
- } catch {
9675
- return null;
9569
+ return z.error("[CallStatTail] failed to build tail", e), null;
9676
9570
  }
9677
- let n = t;
9678
- return typeof n == "object" && n && typeof n.tab == "string" && typeof n.vcid == "string" && Number.isFinite(n.uid) && Number.isFinite(n.ts) && (n.delta === void 0 || n.delta === null || typeof n.delta == "number") && typeof n.ev == "object" && n.ev !== null && n.ev.name === U.CALL_FINISH ? n : null;
9679
- }
9680
- _key(e) {
9681
- return `${this._keyPrefix}${this.tabId}.${e}`;
9682
9571
  }
9683
- _getItem(e, t) {
9572
+ _collectSummaries() {
9684
9573
  try {
9685
- return e.getItem(t);
9574
+ return this._summaries();
9686
9575
  } catch (e) {
9687
- return z.error("[ProvisionalFinishStore] failed to read record", e), null;
9576
+ return z.error("[CallStatTail] failed to collect call summaries", e), [];
9688
9577
  }
9689
9578
  }
9690
- _removeKey(e) {
9691
- try {
9692
- this._storage()?.removeItem(e);
9693
- } catch (e) {
9694
- z.error("[ProvisionalFinishStore] failed to remove record", e);
9695
- }
9579
+ _adopt() {
9580
+ this._clearTimer(), this._status = "adopted", this._release(), this._onAdopted?.();
9696
9581
  }
9697
- _storage() {
9698
- try {
9699
- return typeof window < "u" && window.localStorage ? window.localStorage : null;
9700
- } catch {
9701
- return null;
9702
- }
9582
+ _finish() {
9583
+ this._clearTimer(), this._status = "done";
9584
+ }
9585
+ _release() {
9586
+ let e = this._releaseLock;
9587
+ this._releaseLock = null, e?.();
9703
9588
  }
9704
- _locks() {
9705
- return typeof navigator < "u" && navigator.locks ? navigator.locks : null;
9589
+ _clearTimer() {
9590
+ this._timer !== null && (window.clearInterval(this._timer), this._timer = null);
9706
9591
  }
9707
- }(), Gs = 15e3, Ks = class e {
9592
+ };
9593
+ h(Gs, "_tabId", null);
9594
+ //#endregion
9595
+ //#region src/classes/stat/StatClock.ts
9596
+ var Ks = 15e3, qs = class e {
9708
9597
  static setApi(t) {
9709
9598
  e._api = t;
9710
9599
  }
@@ -9715,7 +9604,7 @@ var Vs = "okcls-stat-provisional.", Hs = "okcls-stat-tab.", Us = ys - 360 * 60 *
9715
9604
  e._delta === null && e._api && e.get();
9716
9605
  }
9717
9606
  static get() {
9718
- return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt < Gs ? Promise.resolve(0) : (e._pending || (e._pending = e._measure().finally(() => {
9607
+ return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt < Ks ? Promise.resolve(0) : (e._pending || (e._pending = e._measure().finally(() => {
9719
9608
  e._pending = null;
9720
9609
  })), e._pending) : Promise.resolve(e._delta);
9721
9610
  }
@@ -9745,45 +9634,42 @@ var Vs = "okcls-stat-provisional.", Hs = "okcls-stat-tab.", Us = ys - 360 * 60 *
9745
9634
  return e._idsAwaitingDelta = [], await Q.fillDelta(n, t), t;
9746
9635
  }
9747
9636
  };
9748
- h(Ks, "_api", null), h(Ks, "_delta", null), h(Ks, "_pending", null), h(Ks, "_idsAwaitingDelta", []), h(Ks, "_lastFailureAt", null);
9637
+ h(qs, "_api", null), h(qs, "_delta", null), h(qs, "_pending", null), h(qs, "_idsAwaitingDelta", []), h(qs, "_lastFailureAt", null);
9749
9638
  //#endregion
9750
9639
  //#region src/classes/stat/StatDrainScheduler.ts
9751
- var qs = 500, Js = 100, Ys = 3e4, Xs = 1e3, Zs = 5e3, Qs = 3e3, $s = "okcls-stat-drain", ec = class e {
9640
+ var Js = 500, Ys = 100, Xs = 3e4, Zs = 1e3, Qs = 5e3, $s = 3e3, ec = 6e4, tc = "okcls-stat-drain", nc = class e {
9752
9641
  static setApi(t) {
9753
- e._api = t, Ks.setApi(t);
9642
+ e._api = t, qs.setApi(t);
9754
9643
  }
9755
9644
  static start(t) {
9756
- e.setApi(t), e.importUnloadJournal().catch((e) => z.error("[StatDrainScheduler] failed to import unload journal", e)).then(async () => (Rs.prune(), await Q.evictOlderThan(ys), await Q.evictToLimit(vs), e._drain())).catch((e) => z.error("[StatDrainScheduler] failed to start", e));
9757
- }
9758
- static importUnloadJournal() {
9759
- return e._withLock(() => Bs.drainToQueue());
9645
+ e.setApi(t), Promise.resolve().then(async () => (zs.prune(), await Q.evictOlderThan(bs), await Q.evictToLimit(ys), e._drain())).catch((e) => z.error("[StatDrainScheduler] failed to start", e));
9760
9646
  }
9761
9647
  static notifyAppended() {
9762
9648
  if (e._api) {
9763
- if (e._localCount += 1, e._localCount >= Js) {
9649
+ if (e._localCount += 1, e._localCount >= Ys) {
9764
9650
  e._drain();
9765
9651
  return;
9766
9652
  }
9767
- e._state === "IDLE" && e._arm(Ys);
9653
+ e._state === "IDLE" && e._arm(Xs);
9768
9654
  }
9769
9655
  }
9770
9656
  static notifyCallFinished() {
9771
9657
  if (e._api) {
9772
- if (e._directBuffer.length > 0 && e._armDirect(Xs), e._state === "DRAINING") {
9658
+ if (e._directBuffer.length > 0 && e._armDirect(Zs), e._state === "DRAINING") {
9773
9659
  e._callFinishedDuringDrain = !0;
9774
9660
  return;
9775
9661
  }
9776
- e._arm(Xs);
9662
+ e._arm(Zs);
9777
9663
  }
9778
9664
  }
9779
9665
  static drainOnce() {
9780
9666
  return e._withLock(async () => {
9781
9667
  let t = e._api;
9782
9668
  if (!t) return !1;
9783
- await e._adoptProvisionalFinishes();
9669
+ await e._adoptCallTails();
9784
9670
  let n = e._currentUserId(), r = await Q.listUids(), i = !1, a = null;
9785
9671
  for (let o of r) try {
9786
- (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === qs && (i = !0);
9672
+ (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Js && (i = !0);
9787
9673
  } catch (e) {
9788
9674
  a === null && (a = e);
9789
9675
  }
@@ -9797,27 +9683,46 @@ var qs = 500, Js = 100, Ys = 3e4, Xs = 1e3, Zs = 5e3, Qs = 3e3, $s = "okcls-stat
9797
9683
  z.error("[StatDrainScheduler] direct send skipped: event belongs to another user");
9798
9684
  return;
9799
9685
  }
9800
- e._directBuffer.push(t), e._directTimer === null && e._armDirect(Qs);
9686
+ e._directBuffer.push(t), e._directTimer === null && e._armDirect($s);
9801
9687
  }
9802
9688
  }
9803
9689
  static __resetForTests() {
9804
- Ks.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9690
+ qs.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._clearTailRecheckTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9805
9691
  }
9806
9692
  static _currentUserId() {
9807
9693
  return y.userId;
9808
9694
  }
9809
- static async _adoptProvisionalFinishes() {
9695
+ static async _adoptCallTails() {
9696
+ if (typeof navigator > "u" || !navigator.locks) return 0;
9697
+ let t = 0, n = !1;
9810
9698
  try {
9811
- await Ws.adoptOrphans();
9699
+ for (let e of await Q.listTailKeys()) await navigator.locks.request(Gs.lockName(e), { ifAvailable: !0 }, async (r) => {
9700
+ if (r === null) {
9701
+ n = !0;
9702
+ return;
9703
+ }
9704
+ await Q.adoptTail(e) === "added" && (t += 1);
9705
+ });
9812
9706
  } catch (e) {
9813
- z.error("[StatDrainScheduler] failed to adopt provisional finishes", e);
9707
+ z.error("[StatDrainScheduler] failed to adopt call tails", e);
9814
9708
  }
9709
+ return t > 0 && z.debug("[StatDrainScheduler] adopted", t, "call tails"), n && e._armTailRecheck(), t;
9710
+ }
9711
+ static _armTailRecheck() {
9712
+ e._tailRecheckTimer === null && (e._tailRecheckTimer = window.setTimeout(() => {
9713
+ e._tailRecheckTimer = null, e._withLock(() => e._adoptCallTails()).then((t) => {
9714
+ t > 0 && e.notifyCallFinished();
9715
+ }).catch((e) => z.error("[StatDrainScheduler] failed to recheck call tails", e));
9716
+ }, ec));
9717
+ }
9718
+ static _clearTailRecheckTimer() {
9719
+ e._tailRecheckTimer !== null && (window.clearTimeout(e._tailRecheckTimer), e._tailRecheckTimer = null);
9815
9720
  }
9816
9721
  static async _drainCurrent(t, n) {
9817
9722
  if (e._isSessionBlocked()) return 0;
9818
- let r = await Q.readOldest(n, qs);
9723
+ let r = await Q.readOldest(n, Js);
9819
9724
  if (r.length === 0) return 0;
9820
- let i = await Ks.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9725
+ let i = await qs.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9821
9726
  try {
9822
9727
  await t.logClientStats(a);
9823
9728
  } catch (t) {
@@ -9828,22 +9733,22 @@ var qs = 500, Js = 100, Ys = 3e4, Xs = 1e3, Zs = 5e3, Qs = 3e3, $s = "okcls-stat
9828
9733
  return await Q.remove(o), r.length;
9829
9734
  }
9830
9735
  static async _drainStored(t, n) {
9831
- let r = Rs.get(n);
9832
- if (!r || r.endpoint !== Rs.currentEndpoint()) return 0;
9833
- let i = await Q.readOldest(n, qs);
9736
+ let r = zs.get(n);
9737
+ if (!r || r.endpoint !== zs.currentEndpoint()) return 0;
9738
+ let i = await Q.readOldest(n, Js);
9834
9739
  if (i.length === 0) return 0;
9835
- let a = await Ks.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9740
+ let a = await qs.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9836
9741
  try {
9837
9742
  await t.logClientStatsWith(r.sessionKey, o), z.debug("[StatDrainScheduler] delivered", i.length, "stored events of uid", n);
9838
9743
  } catch (t) {
9839
- if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Rs.forget(n), 0;
9744
+ if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), zs.forget(n), 0;
9840
9745
  if (e._isRetryable(t)) throw t;
9841
9746
  return z.error("[StatDrainScheduler] batch rejected, dropping", t), await Q.remove(s), i.length;
9842
9747
  }
9843
9748
  return await Q.remove(s), i.length;
9844
9749
  }
9845
9750
  static _withLock(e) {
9846
- return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request($s, e);
9751
+ return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(tc, e);
9847
9752
  }
9848
9753
  static _isSessionError(e) {
9849
9754
  return fs(e?.error_code);
@@ -9884,7 +9789,7 @@ var qs = 500, Js = 100, Ys = 3e4, Xs = 1e3, Zs = 5e3, Qs = 3e3, $s = "okcls-stat
9884
9789
  static async _flushDirect() {
9885
9790
  let t = e._api, n = e._directBuffer;
9886
9791
  if (e._directBuffer = [], !(!t || n.length === 0)) try {
9887
- let r = await Ks.get();
9792
+ let r = await qs.get();
9888
9793
  await t.logClientStats(n.map((t) => e._toClientStats(t, r)));
9889
9794
  } catch (e) {
9890
9795
  z.error("[StatDrainScheduler] direct send failed, events lost", e);
@@ -9903,28 +9808,28 @@ var qs = 500, Js = 100, Ys = 3e4, Xs = 1e3, Zs = 5e3, Qs = 3e3, $s = "okcls-stat
9903
9808
  e._clearTimer(), e._state = "DRAINING", e._localCount = 0, e._callFinishedDuringDrain = !1;
9904
9809
  try {
9905
9810
  if (await e.drainOnce()) {
9906
- e._arm(Zs);
9811
+ e._arm(Qs);
9907
9812
  return;
9908
9813
  }
9909
9814
  if (e._callFinishedDuringDrain) {
9910
- e._arm(Xs);
9815
+ e._arm(Zs);
9911
9816
  return;
9912
9817
  }
9913
9818
  if (e._localCount > 0) {
9914
- e._arm(Ys);
9819
+ e._arm(Xs);
9915
9820
  return;
9916
9821
  }
9917
9822
  e._state = "IDLE";
9918
9823
  } catch (t) {
9919
- z.error("[StatDrainScheduler] drain failed", t), e._arm(Ys);
9824
+ z.error("[StatDrainScheduler] drain failed", t), e._arm(Xs);
9920
9825
  }
9921
9826
  }
9922
9827
  }
9923
9828
  };
9924
- h(ec, "_api", null), h(ec, "_state", "IDLE"), h(ec, "_timer", null), h(ec, "_localCount", 0), h(ec, "_callFinishedDuringDrain", !1), h(ec, "_blockedSession", null), h(ec, "_directBuffer", []), h(ec, "_directTimer", null);
9829
+ h(nc, "_api", null), h(nc, "_state", "IDLE"), h(nc, "_timer", null), h(nc, "_localCount", 0), h(nc, "_callFinishedDuringDrain", !1), h(nc, "_blockedSession", null), h(nc, "_directBuffer", []), h(nc, "_directTimer", null), h(nc, "_tailRecheckTimer", null);
9925
9830
  //#endregion
9926
9831
  //#region src/classes/StatsLogger.ts
9927
- var tc = class extends f {
9832
+ var rc = class extends f {
9928
9833
  constructor(e, t, n, r = () => void 0) {
9929
9834
  super(), h(this, "_externalLogger", void 0), h(this, "_api", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_batchInterval", 3e3), h(this, "_batchedClientStats", []), h(this, "_batchTimeout", null), h(this, "_serverTimeDelta", 0), h(this, "_waitingForServerTime", !0), h(this, "_deferredClientStats", []), this._api = e, this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._calculateServerTimeDelta();
9930
9835
  }
@@ -10004,7 +9909,7 @@ var tc = class extends f {
10004
9909
  _now() {
10005
9910
  return Date.now() - this._serverTimeDelta;
10006
9911
  }
10007
- }, nc = class e extends f {
9912
+ }, ic = class e extends f {
10008
9913
  static __resetForTests() {
10009
9914
  e._pending = [], e._pendingOverflow = !1;
10010
9915
  }
@@ -10020,18 +9925,16 @@ var tc = class extends f {
10020
9925
  return e._pending = [], e._pendingOverflow = !1, t;
10021
9926
  }
10022
9927
  constructor(e, t, n, r = () => void 0) {
10023
- super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new tc(e, t, n, r);
9928
+ super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new rc(e, t, n, r);
10024
9929
  }
10025
9930
  log(e, t, n = !1) {
10026
9931
  this._externalLogger && this._externalLogger.log(e, t, n);
10027
9932
  }
10028
9933
  enterUnloadMode() {
10029
- this._legacy || (this._unloadMode = !0, Bs.beginTabSession());
9934
+ this._legacy || (this._unloadMode = !0);
10030
9935
  }
10031
9936
  exitUnloadMode() {
10032
- this._legacy || !this._unloadMode || (this._unloadMode = !1, ec.importUnloadJournal().then((e) => {
10033
- e > 0 && ec.notifyAppended();
10034
- }).catch((e) => z.error("[StatEventCollector] failed to import unload journal", e)));
9937
+ this._unloadMode = !1;
10035
9938
  }
10036
9939
  logClientStats(t, n = {}) {
10037
9940
  let r = this._makeEntry(t, n);
@@ -10043,7 +9946,8 @@ var tc = class extends f {
10043
9946
  this._legacy.logClientStats(t, n);
10044
9947
  return;
10045
9948
  }
10046
- Ks.ensure();
9949
+ if (this._unloadMode) return;
9950
+ qs.ensure();
10047
9951
  let i = y.userId;
10048
9952
  if (i === null) {
10049
9953
  e._remember(r);
@@ -10061,7 +9965,7 @@ var tc = class extends f {
10061
9965
  buildEntry(t, n = {}) {
10062
9966
  if (this._legacy) return null;
10063
9967
  let r = y.userId;
10064
- return r === null || e._pending.length > 0 ? null : (Ks.ensure(), {
9968
+ return r === null || e._pending.length > 0 ? null : (qs.ensure(), {
10065
9969
  uid: r,
10066
9970
  ...this._makeEntry(t, n)
10067
9971
  });
@@ -10082,17 +9986,17 @@ var tc = class extends f {
10082
9986
  }), {
10083
9987
  vcid: n,
10084
9988
  ts: r,
10085
- delta: Ks.delta(),
9989
+ delta: qs.delta(),
10086
9990
  ev: i
10087
9991
  };
10088
9992
  }
10089
9993
  _store(e) {
10090
- this._unloadMode && Bs.writeSync(e) || Q.append(e).then((t) => {
9994
+ Q.append(e).then((t) => {
10091
9995
  if (t !== null) {
10092
- typeof e.delta != "number" && Ks.noteAppended(t), ec.notifyAppended();
9996
+ typeof e.delta != "number" && qs.noteAppended(t), nc.notifyAppended();
10093
9997
  return;
10094
9998
  }
10095
- z.error("[StatEventCollector] failed to store event, sending directly"), ec.sendDirect(e);
9999
+ z.error("[StatEventCollector] failed to store event, sending directly"), nc.sendDirect(e);
10096
10000
  }).catch((e) => z.error("[StatEventCollector] failed to store event", e));
10097
10001
  }
10098
10002
  _getConversationId() {
@@ -10110,10 +10014,10 @@ var tc = class extends f {
10110
10014
  }
10111
10015
  }
10112
10016
  };
10113
- h(nc, "_pending", []), h(nc, "_pendingOverflow", !1);
10017
+ h(ic, "_pending", []), h(ic, "_pendingOverflow", !1);
10114
10018
  //#endregion
10115
10019
  //#region src/classes/stat/ApiCallStats.ts
10116
- var rc = class {
10020
+ var ac = class {
10117
10021
  constructor(e) {
10118
10022
  h(this, "_statAggregator", void 0), this._statAggregator = e;
10119
10023
  }
@@ -10125,8 +10029,8 @@ var rc = class {
10125
10029
  string_value: n
10126
10030
  });
10127
10031
  }
10128
- }, ic = { monotonicNow: () => performance.now() }, ac = class {
10129
- constructor(e, t = ic) {
10032
+ }, oc = { monotonicNow: () => performance.now() }, sc = class {
10033
+ constructor(e, t = oc) {
10130
10034
  h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_battery", null), h(this, "_previous", null), h(this, "_destroyed", !1), h(this, "_handleChargingChange", () => {
10131
10035
  this._previous = null;
10132
10036
  }), h(this, "_handleLevelChange", () => {
@@ -10160,7 +10064,7 @@ var rc = class {
10160
10064
  }
10161
10065
  this._destroyed || (this._battery = t, t.addEventListener("levelchange", this._handleLevelChange), t.addEventListener("chargingchange", this._handleChargingChange));
10162
10066
  }
10163
- }, oc = "invalid-error-metadata", sc = 64, cc = new Set(Object.values(O)), lc = new Set(Object.values(b)), uc = {
10067
+ }, cc = "invalid-error-metadata", lc = 64, uc = new Set(Object.values(O)), dc = new Set(Object.values(b)), fc = {
10164
10068
  [O.CANCELED]: {
10165
10069
  type: "semantic",
10166
10070
  reason: "canceled"
@@ -10281,7 +10185,7 @@ var rc = class {
10281
10185
  type: "semantic",
10282
10186
  reason: "obsolete_client"
10283
10187
  }
10284
- }, dc = {
10188
+ }, pc = {
10285
10189
  [b.MIC_CAMERA_PERMISSION]: {
10286
10190
  type: "direct-error",
10287
10191
  error: {
@@ -10370,14 +10274,14 @@ var rc = class {
10370
10274
  }
10371
10275
  }
10372
10276
  };
10373
- function fc(e) {
10374
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return oc;
10277
+ function mc(e) {
10278
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return cc;
10375
10279
  let t = String(e).trim();
10376
- if (!t) return oc;
10280
+ if (!t) return cc;
10377
10281
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
10378
- return !n || !/^[a-z0-9.-]+$/.test(n) ? oc : n.length > sc ? `${n.slice(0, sc - 3)}...` : n;
10282
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? cc : n.length > lc ? `${n.slice(0, lc - 3)}...` : n;
10379
10283
  }
10380
- function pc(e) {
10284
+ function hc(e) {
10381
10285
  if (!e || typeof e != "object") return !1;
10382
10286
  let t = e;
10383
10287
  switch (t.scope) {
@@ -10389,50 +10293,50 @@ function pc(e) {
10389
10293
  default: return !1;
10390
10294
  }
10391
10295
  }
10392
- function mc(e) {
10393
- let t = fc(e.description);
10296
+ function gc(e) {
10297
+ let t = mc(e.description);
10394
10298
  if (e.scope === "unknown") return `unknown:${t}`;
10395
- let n = fc(e.code);
10299
+ let n = mc(e.code);
10396
10300
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
10397
10301
  }
10398
- function hc(e, t) {
10302
+ function _c(e, t) {
10399
10303
  return t === null ? e.type === "direct-error" ? {
10400
10304
  reason: "error",
10401
- string_value: mc(e.error)
10402
- } : { reason: "failed" } : pc(t) ? {
10305
+ string_value: gc(e.error)
10306
+ } : { reason: "failed" } : hc(t) ? {
10403
10307
  reason: "error",
10404
- string_value: mc(t)
10308
+ string_value: gc(t)
10405
10309
  } : { reason: "failed" };
10406
10310
  }
10407
- function gc(e) {
10311
+ function vc(e) {
10408
10312
  if (e.hangup) {
10409
- let t = uc[e.hangup];
10313
+ let t = fc[e.hangup];
10410
10314
  return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
10411
10315
  reason: t.reason,
10412
10316
  string_value: e.custom_error.vchat_detailed_api_error.code
10413
- } : { reason: t.reason } : hc(t, e.callError) : { reason: "failed" };
10317
+ } : { reason: t.reason } : _c(t, e.callError) : { reason: "failed" };
10414
10318
  }
10415
10319
  if (e.error) {
10416
- let t = dc[e.error];
10417
- return t ? hc(t, e.callError) : { reason: "failed" };
10320
+ let t = pc[e.error];
10321
+ return t ? _c(t, e.callError) : { reason: "failed" };
10418
10322
  }
10419
10323
  return { reason: "failed" };
10420
10324
  }
10421
- function _c(e) {
10422
- return e instanceof k ? gc(e) : typeof e == "string" && (cc.has(e) || lc.has(e)) ? gc(new k(e)) : { reason: "failed" };
10325
+ function yc(e) {
10326
+ return e instanceof k ? vc(e) : typeof e == "string" && (uc.has(e) || dc.has(e)) ? vc(new k(e)) : { reason: "failed" };
10423
10327
  }
10424
10328
  //#endregion
10425
10329
  //#region src/classes/stat/CallLifecycleStats.ts
10426
- var vc = {
10330
+ var bc = {
10427
10331
  wallNow: () => Date.now(),
10428
10332
  monotonicNow: () => performance.now()
10429
10333
  };
10430
- function yc(e) {
10334
+ function xc(e) {
10431
10335
  return e === "anonym_join" ? "join" : e;
10432
10336
  }
10433
- var bc = class {
10434
- constructor(e, t = vc, n = null) {
10435
- h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_provisional", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_pendingEvents", []), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t, this._provisional = n;
10337
+ var Sc = class {
10338
+ constructor(e, t = bc, n = null) {
10339
+ h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_tail", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_pendingEvents", []), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t, this._tail = n;
10436
10340
  }
10437
10341
  get firstMediaSentReported() {
10438
10342
  return this._firstMediaSent;
@@ -10443,13 +10347,13 @@ var bc = class {
10443
10347
  markInitializationStarted({ source: e, conversationId: t }) {
10444
10348
  if (this._destroyed || this._callStartLabel !== null) return;
10445
10349
  let n = this._clock.wallNow();
10446
- this._callStartLabel = yc(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
10350
+ this._callStartLabel = xc(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
10447
10351
  name: U.CALL_INIT,
10448
10352
  source: e
10449
- }, n), this._startProvisional();
10353
+ }, n), this._startTail();
10450
10354
  }
10451
10355
  bindConversationId(e) {
10452
- this._destroyed || this._conversationId || !e || (this._conversationId = e, this._flushPendingEvents(), this._startProvisional());
10356
+ this._destroyed || this._conversationId || !e || (this._conversationId = e, this._flushPendingEvents(), this._startTail());
10453
10357
  }
10454
10358
  markCallStarted() {
10455
10359
  !this._canRecord() || this._callStarted || !this._callStartLabel || (this._callStarted = !0, this._record({
@@ -10471,19 +10375,19 @@ var bc = class {
10471
10375
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
10472
10376
  }
10473
10377
  markFinished(e) {
10474
- this._finish(_c(e));
10378
+ this._finish(yc(e));
10475
10379
  }
10476
10380
  markTerminated() {
10477
10381
  this._finish({ reason: "terminated" });
10478
10382
  }
10479
10383
  markHidden() {
10480
- this._canRecord() && this._provisional?.update();
10384
+ this._canRecord() && this._tail?.touch();
10481
10385
  }
10482
10386
  markVisible() {
10483
- this._canRecord() && this._provisional?.update();
10387
+ this._canRecord() && this._tail?.touch();
10484
10388
  }
10485
10389
  destroy() {
10486
- this._destroyed || (this._provisional?.stop(), this._destroyed = !0, this._pendingEvents = []);
10390
+ this._destroyed || (this._tail?.stop(), this._destroyed = !0, this._pendingEvents = []);
10487
10391
  }
10488
10392
  _canRecord() {
10489
10393
  return this._callStartLabel !== null && !this._finished && !this._destroyed;
@@ -10491,8 +10395,8 @@ var bc = class {
10491
10395
  _durationSince(e) {
10492
10396
  return Math.max(0, Math.round(this._clock.monotonicNow() - e));
10493
10397
  }
10494
- _startProvisional() {
10495
- this._provisional && this._conversationId && this._canRecord() && this._provisional.start(this._conversationId, () => {
10398
+ _startTail() {
10399
+ this._tail && this._conversationId && this._canRecord() && this._tail.start(this._conversationId, () => {
10496
10400
  this._finished = !0;
10497
10401
  });
10498
10402
  }
@@ -10508,11 +10412,11 @@ var bc = class {
10508
10412
  occurredAt: this._clock.wallNow(),
10509
10413
  immediately: !0
10510
10414
  };
10511
- if (!this._provisional) {
10415
+ if (!this._tail) {
10512
10416
  this._logEvent(n);
10513
10417
  return;
10514
10418
  }
10515
- this._provisional.complete(() => this._logEvent(n));
10419
+ this._tail.complete(() => this._logEvent(n));
10516
10420
  }
10517
10421
  _ensureConversationId() {
10518
10422
  this._conversationId || (this._conversationId = M.uuid(), this._flushPendingEvents());
@@ -10544,7 +10448,7 @@ var bc = class {
10544
10448
  ...n && { immediately: !0 }
10545
10449
  });
10546
10450
  }
10547
- }, xc = 1e3, Sc = class {
10451
+ }, Cc = 1e3, wc = class {
10548
10452
  constructor(e, t = z) {
10549
10453
  h(this, "_sources", void 0), h(this, "_debug", void 0), h(this, "_timer", null), h(this, "_participantsMax", 0), h(this, "_areaMpxMax", 0), h(this, "_features", /* @__PURE__ */ new Set()), h(this, "_sample", () => {
10550
10454
  try {
@@ -10553,7 +10457,7 @@ var bc = class {
10553
10457
  } catch (e) {
10554
10458
  this._debug.warn("ClientResourceStats sample error", e);
10555
10459
  }
10556
- }), this._sources = e, this._debug = t, this._timer = window.setInterval(this._sample, xc);
10460
+ }), this._sources = e, this._debug = t, this._timer = window.setInterval(this._sample, Cc);
10557
10461
  }
10558
10462
  takeReport() {
10559
10463
  this._sample();
@@ -10567,7 +10471,7 @@ var bc = class {
10567
10471
  let e = window.devicePixelRatio || 1, t = window.innerWidth * window.innerHeight * e * e;
10568
10472
  return Math.round(t / 1e6);
10569
10473
  }
10570
- }, Cc = class {
10474
+ }, Tc = class {
10571
10475
  constructor(e, t) {
10572
10476
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
10573
10477
  }
@@ -10597,6 +10501,13 @@ var bc = class {
10597
10501
  }
10598
10502
  });
10599
10503
  }
10504
+ usageReports() {
10505
+ let e = [];
10506
+ return this._codecUsages.forEach((t) => {
10507
+ let n = this._toLog(t);
10508
+ n && e.push(n);
10509
+ }), e;
10510
+ }
10600
10511
  saveUsage({ kind: e, codecName: t, totalEncodeTime: n, audioCodecParams: r, topology: i }) {
10601
10512
  let a = this._codecUsages.get(e);
10602
10513
  if (a && a.codecName !== t && this.report(a), a && a.codecName === t) {
@@ -10616,87 +10527,23 @@ var bc = class {
10616
10527
  });
10617
10528
  }
10618
10529
  report(e) {
10619
- if (e.kind === "video" && e.totalEncodeTime === 0) return;
10530
+ let t = this._toLog(e);
10531
+ t && this._logger.logClientStats(t);
10532
+ }
10533
+ _toLog(e) {
10534
+ if (e.kind === "video" && e.totalEncodeTime === 0) return null;
10620
10535
  let t = {
10621
10536
  name: U.CODEC_USAGE,
10622
10537
  codec_implementation: e.codecName,
10623
10538
  value: Math.round(e.totalEncodeTime),
10624
10539
  call_topology: e.topology === J.DIRECT ? "D" : "S"
10625
10540
  };
10626
- e.audioCodecParams && (t.string_value = e.audioCodecParams), this._logger.logClientStats(t);
10541
+ return e.audioCodecParams && (t.string_value = e.audioCodecParams), t;
10627
10542
  }
10628
10543
  destroy() {
10629
- this._codecUsages.forEach((e) => {
10630
- this.report(e);
10631
- }), this._codecUsages.clear();
10632
- }
10633
- }, wc = 3e4, Tc = { wallNow: () => Date.now() }, Ec = class {
10634
- constructor(e, t = Ws, n = Tc) {
10635
- h(this, "_logger", void 0), h(this, "_store", void 0), h(this, "_clock", void 0), h(this, "_status", "idle"), h(this, "_vcid", null), h(this, "_onAdopted", null), h(this, "_timer", null), this._logger = e, this._store = t, this._clock = n;
10636
- }
10637
- start(e, t) {
10638
- if (this._status === "idle") try {
10639
- this._status = "active", this._vcid = e, this._onAdopted = t, this._store.hold(), this.update(), this._timer = window.setInterval(() => this.update(), wc);
10640
- } catch (e) {
10641
- z.error("[ProvisionalFinish] failed to start", e);
10642
- }
10643
- }
10644
- update() {
10645
- try {
10646
- if (this._status !== "active" || this._vcid === null) return;
10647
- let e = this._vcid;
10648
- if (this._store.isAdopted(e)) {
10649
- this._adopt();
10650
- return;
10651
- }
10652
- let t = this._logger.buildEntry({
10653
- name: U.CALL_FINISH,
10654
- reason: "terminated"
10655
- }, {
10656
- conversationId: e,
10657
- occurredAt: this._clock.wallNow()
10658
- });
10659
- if (t === null) return;
10660
- this._store.save({
10661
- ...t,
10662
- vcid: e,
10663
- tab: this._store.tabId
10664
- });
10665
- } catch (e) {
10666
- z.error("[ProvisionalFinish] failed to update", e);
10667
- }
10668
- }
10669
- complete(e) {
10670
- if (this._status === "idle") {
10671
- e();
10672
- return;
10673
- }
10674
- if (this._status !== "active" || this._vcid === null) return;
10675
- let t = this._vcid;
10676
- this._status = "done", this._clearTimer(), this._store.whenOwned(() => {
10677
- let n = !1;
10678
- try {
10679
- n = this._store.isAdopted(t), this._store.remove(t), this._store.unhold();
10680
- } catch (e) {
10681
- z.error("[ProvisionalFinish] failed to remove record", e);
10682
- }
10683
- n || e();
10684
- });
10685
- }
10686
- stop() {
10687
- if (this._status !== "active" || this._vcid === null) return;
10688
- let e = this._vcid;
10689
- this._status = "done", this._clearTimer(), this._store.whenOwned(() => {
10690
- this._store.remove(e), this._store.unhold();
10691
- });
10544
+ this.usageReports().forEach((e) => this._logger.logClientStats(e)), this._codecUsages.clear();
10692
10545
  }
10693
- _adopt() {
10694
- this._status = "adopted", this._clearTimer(), this._vcid !== null && this._store.remove(this._vcid), this._store.unhold(), this._onAdopted?.();
10695
- }
10696
- _clearTimer() {
10697
- this._timer !== null && (window.clearInterval(this._timer), this._timer = null);
10698
- }
10699
- }, Dc = class {
10546
+ }, Ec = class {
10700
10547
  constructor(e, t = null) {
10701
10548
  h(this, "_logger", void 0), h(this, "_resources", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e, this._resources = t;
10702
10549
  }
@@ -10743,7 +10590,7 @@ var bc = class {
10743
10590
  for (let [t, r] of Object.entries(e)) r !== void 0 && (r === null ? delete n[t] : n[t] = r);
10744
10591
  this._logger.logClientStats(n, { occurredAt: t });
10745
10592
  }
10746
- }, Oc = class {
10593
+ }, Dc = class {
10747
10594
  constructor(e) {
10748
10595
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
10749
10596
  1,
@@ -10802,7 +10649,7 @@ var bc = class {
10802
10649
  5
10803
10650
  ];
10804
10651
  }
10805
- }, kc = class {
10652
+ }, Oc = class {
10806
10653
  constructor() {
10807
10654
  h(this, "n", 0), h(this, "mean", 0);
10808
10655
  }
@@ -10814,9 +10661,9 @@ var bc = class {
10814
10661
  get avg() {
10815
10662
  return this.n ? this.mean : NaN;
10816
10663
  }
10817
- }, Ac = class {
10664
+ }, kc = class {
10818
10665
  constructor() {
10819
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new kc()), h(this, "p50", new Oc(.5)), h(this, "p95", new Oc(.95));
10666
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new Oc()), h(this, "p50", new Dc(.5)), h(this, "p95", new Dc(.95));
10820
10667
  }
10821
10668
  add(e) {
10822
10669
  e < this.minVal && (this.minVal = e), e > this.maxVal && (this.maxVal = e), this.mean.add(e), this.p50.add(e), this.p95.add(e), this.count++;
@@ -10834,82 +10681,89 @@ var bc = class {
10834
10681
  get hasData() {
10835
10682
  return this.count > 0;
10836
10683
  }
10837
- }, jc = 120 * 1e3, Mc = class {
10684
+ }, Ac = 120 * 1e3, jc = class {
10838
10685
  constructor(e) {
10839
10686
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
10840
- ws: new Ac(),
10841
- wt: new Ac()
10687
+ ws: new kc(),
10688
+ wt: new kc()
10842
10689
  }), h(this, "lastSeen", {}), this._logger = e;
10843
10690
  }
10844
10691
  mark(e) {
10845
10692
  let t = Date.now(), n = this.lastSeen[e];
10846
10693
  if (typeof n == "number") {
10847
10694
  let r = t - n;
10848
- r >= 0 && r <= jc && this.trackerByTransport[e].add(r);
10695
+ r >= 0 && r <= Ac && this.trackerByTransport[e].add(r);
10849
10696
  }
10850
10697
  this.lastSeen[e] = t;
10851
10698
  }
10852
10699
  logMetrics() {
10853
- [Tr.WEBSOCKET, Tr.WEBTRANSPORT].forEach((e) => {
10854
- if (!this.trackerByTransport[e].hasData) return;
10855
- let t = this.trackerByTransport[e].snapshot();
10856
- this._logger.logClientStats({
10700
+ this.summaries().forEach((e) => this._logger.logClientStats(e));
10701
+ }
10702
+ summaries() {
10703
+ let e = [];
10704
+ return [Tr.WEBSOCKET, Tr.WEBTRANSPORT].forEach((t) => {
10705
+ if (!this.trackerByTransport[t].hasData) return;
10706
+ let n = this.trackerByTransport[t].snapshot();
10707
+ e.push({
10857
10708
  name: U.SIGNALING_PING_SUMMARY,
10858
- min_value: t.min,
10859
- max_value: t.max,
10860
- avg_value: t.avg,
10861
- median_value: t.median,
10862
- p95_value: t.p95,
10863
- values_count: t.count,
10864
- signaling_transport: e
10709
+ min_value: n.min,
10710
+ max_value: n.max,
10711
+ avg_value: n.avg,
10712
+ median_value: n.median,
10713
+ p95_value: n.p95,
10714
+ values_count: n.count,
10715
+ signaling_transport: t
10865
10716
  });
10866
- });
10717
+ }), e;
10867
10718
  }
10868
10719
  resetBaseline() {
10869
10720
  this.lastSeen = {};
10870
10721
  }
10871
10722
  destroy() {
10872
10723
  this.trackerByTransport = {
10873
- ws: new Ac(),
10874
- wt: new Ac()
10724
+ ws: new kc(),
10725
+ wt: new kc()
10875
10726
  }, this.lastSeen = {};
10876
10727
  }
10877
- }, Nc = class {
10728
+ }, Mc = class {
10878
10729
  constructor(e) {
10879
10730
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
10880
10731
  }
10881
10732
  mark(e, t, n) {
10882
10733
  let r = `${e}|${n}`, i;
10883
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new Ac(), this.trackerByCommand.set(r, i)), i.add(t);
10734
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new kc(), this.trackerByCommand.set(r, i)), i.add(t);
10884
10735
  }
10885
10736
  logMetrics() {
10886
- for (let [e, t] of this.trackerByCommand.entries()) {
10887
- if (!t.hasData) continue;
10888
- let [n, r] = e.split("|"), i = t.snapshot();
10889
- this._logger.logClientStats({
10737
+ this.summaries().forEach((e) => this._logger.logClientStats(e));
10738
+ }
10739
+ summaries() {
10740
+ let e = [];
10741
+ for (let [t, n] of this.trackerByCommand.entries()) {
10742
+ if (!n.hasData) continue;
10743
+ let [r, i] = t.split("|"), a = n.snapshot();
10744
+ e.push({
10890
10745
  name: U.SIGNALING_COMMAND_SUMMARY,
10891
- api_method: n,
10892
- min_value: i.min,
10893
- max_value: i.max,
10894
- avg_value: i.avg,
10895
- median_value: i.median,
10896
- p95_value: i.p95,
10897
- values_count: i.count,
10898
- signaling_transport: r
10746
+ api_method: r,
10747
+ min_value: a.min,
10748
+ max_value: a.max,
10749
+ avg_value: a.avg,
10750
+ median_value: a.median,
10751
+ p95_value: a.p95,
10752
+ values_count: a.count,
10753
+ signaling_transport: i
10899
10754
  });
10900
10755
  }
10756
+ return e;
10901
10757
  }
10902
10758
  destroy() {
10903
10759
  this.trackerByCommand.clear();
10904
10760
  }
10905
- }, Pc = class {
10761
+ }, Nc = class {
10906
10762
  constructor(e, t, n, r, i) {
10907
- h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), h(this, "apiCalls", void 0), h(this, "resources", void 0), h(this, "battery", void 0), h(this, "_api", void 0), h(this, "_unloading", !1), this.logger = new nc(e, t, n, r);
10908
- let a = N.statQueueEnabled && Ws.isSupported() ? new Ec(this.logger) : null;
10909
- this.lifecycle = new bc(this.logger, void 0, a), this.resources = new Sc(i), this.statAggregator = new Dc(this.logger, this.resources), this.codecStatsAggregator = new Cc(this.logger, r), this.pings = new Mc(this.logger), this.signalingCommands = new Nc(this.logger), this.apiCalls = new rc(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls), this.battery = new ac(this.logger);
10763
+ h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), h(this, "apiCalls", void 0), h(this, "resources", void 0), h(this, "battery", void 0), h(this, "_api", void 0), h(this, "_tail", void 0), h(this, "_unloading", !1), this.logger = new ic(e, t, n, r), this._tail = N.statQueueEnabled && Gs.isSupported() ? new Gs(this.logger, () => this._callSummaries()) : null, this.lifecycle = new Sc(this.logger, void 0, this._tail), this.resources = new wc(i), this.statAggregator = new Ec(this.logger, this.resources), this.codecStatsAggregator = new Tc(this.logger, r), this.pings = new jc(this.logger), this.signalingCommands = new Mc(this.logger), this.apiCalls = new ac(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls), this.battery = new sc(this.logger);
10910
10764
  }
10911
10765
  prepareForUnload() {
10912
- N.statQueueEnabled && (this._unloading = !0, this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
10766
+ N.statQueueEnabled && (this._unloading = !0, this._tail?.abandon(), this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
10913
10767
  }
10914
10768
  restoreAfterUnload() {
10915
10769
  N.statQueueEnabled && (this._unloading = !1, this.logger.exitUnloadMode());
@@ -10930,9 +10784,16 @@ var bc = class {
10930
10784
  this.codecStatsAggregator.destroy(), this.pings.logMetrics(), this.pings.destroy(), this.signalingCommands.logMetrics(), this.signalingCommands.destroy();
10931
10785
  }
10932
10786
  destroy() {
10933
- this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.resources.destroy(), this.battery.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading && ec.notifyCallFinished();
10787
+ this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.resources.destroy(), this.battery.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading && nc.notifyCallFinished();
10934
10788
  }
10935
- }, Fc = class {
10789
+ _callSummaries() {
10790
+ return [
10791
+ ...this.codecStatsAggregator.usageReports(),
10792
+ ...this.pings.summaries(),
10793
+ ...this.signalingCommands.summaries()
10794
+ ];
10795
+ }
10796
+ }, Pc = class {
10936
10797
  constructor(e) {
10937
10798
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
10938
10799
  }
@@ -10957,8 +10818,8 @@ var bc = class {
10957
10818
  call_type: this._callType
10958
10819
  }));
10959
10820
  }
10960
- }, Ic = 1e3, Lc = 1e4;
10961
- function Rc(e, t, n, r) {
10821
+ }, Fc = 1e3, Ic = 1e4;
10822
+ function Lc(e, t, n, r) {
10962
10823
  return new k(e, {
10963
10824
  callError: {
10964
10825
  scope: "external",
@@ -10969,7 +10830,7 @@ function Rc(e, t, n, r) {
10969
10830
  message: r
10970
10831
  });
10971
10832
  }
10972
- var zc = 15, $ = class e extends Je {
10833
+ var Rc = 15, $ = class e extends Je {
10973
10834
  constructor(e, t) {
10974
10835
  super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", X.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", z.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", Gr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), h(this, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_onRestore", void 0), h(this, "_onVisibilityChange", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_toggleLocalVideo", Wo((e) => {
10975
10836
  if (this._mediaSource) return this._stats.logger.log(S.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
@@ -10985,7 +10846,7 @@ var zc = 15, $ = class e extends Je {
10985
10846
  captureAudio: !1
10986
10847
  });
10987
10848
  }
10988
- }, 100)), this._stats = new Pc(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology, {
10849
+ }, 100)), this._stats = new Nc(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology, {
10989
10850
  getActiveFeatures: () => this._mediaSource?.activeFeatures ?? [],
10990
10851
  getParticipantsCount: () => this._getParticipantsCount()
10991
10852
  }), this._api = e, this._signaling = new go(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new rs(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new $o({
@@ -11005,13 +10866,13 @@ var zc = 15, $ = class e extends Je {
11005
10866
  return;
11006
10867
  }
11007
10868
  this._stats.markVisible();
11008
- }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), document.addEventListener("visibilitychange", this._onVisibilityChange), this._statFirstMediaReceived = new Fc(this._stats.statAggregator), this._audioOutput = new Ko(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Ic));
10869
+ }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), document.addEventListener("visibilitychange", this._onVisibilityChange), this._statFirstMediaReceived = new Pc(this._stats.statAggregator), this._audioOutput = new Ko(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Fc));
11009
10870
  }
11010
10871
  static current() {
11011
10872
  return B.getActive() ?? (N.hold ? null : B.getFirst());
11012
10873
  }
11013
10874
  static hangupAfterInit(e) {
11014
- let t = Bc;
10875
+ let t = zc;
11015
10876
  if (t) {
11016
10877
  if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
11017
10878
  t._delayedHangup = !0, t._abortController?.abort(new k(O.CANCELED));
@@ -11084,7 +10945,7 @@ var zc = 15, $ = class e extends Je {
11084
10945
  this._stats.lifecycle.markInitializationStarted({
11085
10946
  source: "outgoing",
11086
10947
  conversationId: u
11087
- }), this._debug.setConversationId(u), Bc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10948
+ }), this._debug.setConversationId(u), zc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
11088
10949
  try {
11089
10950
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
11090
10951
  let l = this._mediaSource.mediaSettings;
@@ -11116,18 +10977,18 @@ var zc = 15, $ = class e extends Je {
11116
10977
  let e = B.get(this._conversation.id);
11117
10978
  e && e !== this && e._close(new k(O.HUNGUP, { remote: !0 }));
11118
10979
  }
11119
- return B.add(this), await B.setActive(this.id), Bc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10980
+ return B.add(this), await B.setActive(this.id), zc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
11120
10981
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
11121
10982
  }, f)), this._conversation;
11122
10983
  } catch (e) {
11123
- throw Bc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10984
+ throw zc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
11124
10985
  }
11125
10986
  }
11126
10987
  async onJoin(e) {
11127
10988
  this._stats.lifecycle.markInitializationStarted({
11128
10989
  source: e.anonymous ? "anonym_join" : "join",
11129
10990
  conversationId: e.conversationId
11130
- }), Bc = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10991
+ }), zc = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
11131
10992
  try {
11132
10993
  let t = !!e.observedIds?.length;
11133
10994
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
@@ -11144,9 +11005,9 @@ var zc = 15, $ = class e extends Je {
11144
11005
  code: "conversation",
11145
11006
  description: "not-initialized-after-join"
11146
11007
  } });
11147
- return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), Bc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
11008
+ return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), zc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
11148
11009
  } catch (e) {
11149
- throw Bc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
11010
+ throw zc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
11150
11011
  }
11151
11012
  }
11152
11013
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -11161,7 +11022,7 @@ var zc = 15, $ = class e extends Je {
11161
11022
  if (this._delayedHangup) throw new k(O.CANCELED);
11162
11023
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
11163
11024
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
11164
- R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), Bc = null);
11025
+ R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), zc = null);
11165
11026
  let i = this._extractLocalParticipantFromConnection(e);
11166
11027
  if (i) {
11167
11028
  let e = M.mapParticipantState(i);
@@ -11169,7 +11030,7 @@ var zc = 15, $ = class e extends Je {
11169
11030
  }
11170
11031
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
11171
11032
  } catch (e) {
11172
- throw Bc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
11033
+ throw zc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
11173
11034
  }
11174
11035
  }
11175
11036
  _extractExternalRooms(e) {
@@ -11189,7 +11050,7 @@ var zc = 15, $ = class e extends Je {
11189
11050
  B.reserve(e), this._reservedId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
11190
11051
  source: "incoming",
11191
11052
  conversationId: e
11192
- }), this._debug.setConversationId(e), Bc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
11053
+ }), this._debug.setConversationId(e), zc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
11193
11054
  try {
11194
11055
  let a = await this._prepareConversation(e, t, n, r, i);
11195
11056
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
@@ -11198,9 +11059,9 @@ var zc = 15, $ = class e extends Je {
11198
11059
  description: "incoming-not-initialized"
11199
11060
  } });
11200
11061
  if (!a.conversation.participants.find((e) => e.state === X.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(S.PUSH, "rejected"), new k(O.REJECTED);
11201
- if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(S.PUSH, "accepted"), B.add(this), Bc = null, this._delayedHangup) throw new k(O.CANCELED);
11062
+ if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(S.PUSH, "accepted"), B.add(this), zc = null, this._delayedHangup) throw new k(O.CANCELED);
11202
11063
  } catch (e) {
11203
- throw Bc = null, this._cleanupRegistry(), this._close(e, {
11064
+ throw zc = null, this._cleanupRegistry(), this._close(e, {
11204
11065
  errorText: "Unable to handle inbound call push",
11205
11066
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
11206
11067
  }), e;
@@ -11489,10 +11350,10 @@ var zc = 15, $ = class e extends Je {
11489
11350
  isVideo: f,
11490
11351
  joiningAllowed: a,
11491
11352
  requireAuthToJoin: o
11492
- }, this._abortController?.signal), !e) throw Rc(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
11353
+ }, this._abortController?.signal), !e) throw Lc(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
11493
11354
  if (!e.internalCallerParams) {
11494
11355
  let t = e.rejectedParticipants[0]?.status;
11495
- throw Rc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
11356
+ throw Lc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
11496
11357
  }
11497
11358
  } catch (e) {
11498
11359
  throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_START_ERROR, { message: e.message }) : new k(O.FAST_START_ERROR, { message: String(e) });
@@ -11514,7 +11375,7 @@ var zc = 15, $ = class e extends Je {
11514
11375
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
11515
11376
  }, this._debug.debug("FastStart", p), m = "fastStart";
11516
11377
  } catch {
11517
- throw Rc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
11378
+ throw Lc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
11518
11379
  }
11519
11380
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
11520
11381
  qo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
@@ -11542,9 +11403,9 @@ var zc = 15, $ = class e extends Je {
11542
11403
  joinLink: i,
11543
11404
  isVideo: c,
11544
11405
  internalParams: this._buildInternalParams()
11545
- }, this._abortController?.signal), !e) throw Rc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
11546
- if (!e.internalCallerParams) throw Rc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
11547
- if (!e.conversationId) throw Rc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
11406
+ }, this._abortController?.signal), !e) throw Lc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
11407
+ if (!e.internalCallerParams) throw Lc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
11408
+ if (!e.conversationId) throw Lc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
11548
11409
  } catch (e) {
11549
11410
  throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_JOIN_ERROR, { message: e.message }) : new k(O.FAST_JOIN_ERROR, { message: String(e) });
11550
11411
  }
@@ -11562,7 +11423,7 @@ var zc = 15, $ = class e extends Je {
11562
11423
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
11563
11424
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
11564
11425
  } catch (e) {
11565
- throw e instanceof k ? e : Rc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
11426
+ throw e instanceof k ? e : Lc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
11566
11427
  }
11567
11428
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
11568
11429
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -12073,7 +11934,7 @@ var zc = 15, $ = class e extends Je {
12073
11934
  _onRemoveParticipant(e) {
12074
11935
  this._debug.debug(`Remove participant [${e}]`);
12075
11936
  let t = [], n = this._participants;
12076
- for (let r = 0; r <= zc; r++) {
11937
+ for (let r = 0; r <= Rc; r++) {
12077
11938
  let i = n[M.compose(e, r)];
12078
11939
  i && t.push(i);
12079
11940
  }
@@ -12296,7 +12157,7 @@ var zc = 15, $ = class e extends Je {
12296
12157
  });
12297
12158
  }
12298
12159
  }
12299
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new Vc("Could not allocate one or more participants", r);
12160
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new Bc("Could not allocate one or more participants", r);
12300
12161
  }
12301
12162
  async _cleanupCooldownQueue() {
12302
12163
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -12304,7 +12165,7 @@ var zc = 15, $ = class e extends Je {
12304
12165
  let n = t.next();
12305
12166
  if (n.done) break;
12306
12167
  let r = n.value;
12307
- if (r[1] + Lc > Date.now()) break;
12168
+ if (r[1] + Ic > Date.now()) break;
12308
12169
  let i = r[0];
12309
12170
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
12310
12171
  } while (!0);
@@ -13821,11 +13682,11 @@ var zc = 15, $ = class e extends Je {
13821
13682
  _getParticipant(e) {
13822
13683
  return this._participants[e];
13823
13684
  }
13824
- }, Bc = null, Vc = class e extends Error {
13685
+ }, zc = null, Bc = class e extends Error {
13825
13686
  constructor(t, n) {
13826
13687
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
13827
13688
  }
13828
- }, Hc = class {
13689
+ }, Vc = class {
13829
13690
  constructor() {
13830
13691
  h(this, "_abortSignal", void 0), h(this, "_apiCallStats", null);
13831
13692
  }
@@ -13870,7 +13731,7 @@ var zc = 15, $ = class e extends Je {
13870
13731
  async getInbounds() {
13871
13732
  return [];
13872
13733
  }
13873
- }, Uc = class e {
13734
+ }, Hc = class e {
13874
13735
  constructor() {
13875
13736
  h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
13876
13737
  }
@@ -13905,27 +13766,27 @@ var zc = 15, $ = class e extends Je {
13905
13766
  clear() {
13906
13767
  this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
13907
13768
  }
13908
- }, Wc = "anonymLogin:", Gc = 700, Kc = 3e3;
13909
- function qc(e) {
13769
+ }, Uc = "anonymLogin:", Wc = 700, Gc = 3e3;
13770
+ function Kc(e) {
13910
13771
  let t = e.error_code;
13911
13772
  switch (t) {
13912
- case 2: return Jc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13913
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? Jc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Jc(b.API, t, "request-error");
13914
- case 300: return Jc(O.NOT_FOUND, t, "not-found");
13915
- case 1101: return Jc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13916
- case 1102: return Jc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13917
- case 1103: return Jc(O.NOT_FRIENDS, t, "friendship-required");
13918
- case 1104: return Xc(t, "youla-api-error");
13919
- case 1106: return Xc(t, "vk-api-error");
13920
- case 1113: return Jc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13773
+ case 2: return qc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13774
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? qc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : qc(b.API, t, "request-error");
13775
+ case 300: return qc(O.NOT_FOUND, t, "not-found");
13776
+ case 1101: return qc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13777
+ case 1102: return qc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13778
+ case 1103: return qc(O.NOT_FRIENDS, t, "friendship-required");
13779
+ case 1104: return Yc(t, "youla-api-error");
13780
+ case 1106: return Yc(t, "vk-api-error");
13781
+ case 1113: return qc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13921
13782
  case 1114: {
13922
13783
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
13923
- return Jc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13784
+ return qc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13924
13785
  }
13925
- default: return Jc(b.API, t, "api-error");
13786
+ default: return qc(b.API, t, "api-error");
13926
13787
  }
13927
13788
  }
13928
- function Jc(e, t, n, r) {
13789
+ function qc(e, t, n, r) {
13929
13790
  return {
13930
13791
  type: e,
13931
13792
  callError: {
@@ -13937,10 +13798,10 @@ function Jc(e, t, n, r) {
13937
13798
  message: r
13938
13799
  };
13939
13800
  }
13940
- function Yc(e) {
13801
+ function Jc(e) {
13941
13802
  return e?.error_code === void 0 ? e instanceof k && e.callError && "code" in e.callError ? String(e.callError.code) : e instanceof Error ? e.name : "network" : String(e.error_code);
13942
13803
  }
13943
- function Xc(e, t) {
13804
+ function Yc(e, t) {
13944
13805
  return {
13945
13806
  type: O.EXTERNAL_API_ERROR,
13946
13807
  callError: {
@@ -13951,21 +13812,21 @@ function Xc(e, t) {
13951
13812
  }
13952
13813
  };
13953
13814
  }
13954
- var Zc = class extends Hc {
13815
+ var Xc = class extends Vc {
13955
13816
  constructor() {
13956
- super(), h(this, "_uuid", void 0), h(this, "_idCache", new Uc()), this._cacheSelfExternalId();
13817
+ super(), h(this, "_uuid", void 0), h(this, "_idCache", new Hc()), this._cacheSelfExternalId();
13957
13818
  }
13958
13819
  async _callUnsafe(e, t = {}, n = !1) {
13959
13820
  let r = async (i) => {
13960
13821
  let a = performance.now();
13961
13822
  try {
13962
- let r = await As(e, t, n);
13823
+ let r = await js(e, t, n);
13963
13824
  return this._apiCallStats?.log(e, performance.now() - a), r;
13964
13825
  } catch (t) {
13965
- if (this._apiCallStats?.log(e, performance.now() - a, Yc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13826
+ if (this._apiCallStats?.log(e, performance.now() - a, Jc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13966
13827
  i++;
13967
13828
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
13968
- if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * Gc, Kc), { signal: this._abortSignal }), r(i);
13829
+ if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * Wc, Gc), { signal: this._abortSignal }), r(i);
13969
13830
  }
13970
13831
  throw z.warn(e, "error", t), t;
13971
13832
  }
@@ -13982,8 +13843,8 @@ var Zc = class extends Hc {
13982
13843
  message: i?.error_msg,
13983
13844
  code: i?.error_code
13984
13845
  };
13985
- if (i.custom_error && (a.custom_error = i.custom_error), Qc(i)) {
13986
- let e = qc(i);
13846
+ if (i.custom_error && (a.custom_error = i.custom_error), Zc(i)) {
13847
+ let e = Kc(i);
13987
13848
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
13988
13849
  }
13989
13850
  throw new k(b.API, a);
@@ -14035,22 +13896,22 @@ var Zc = class extends Hc {
14035
13896
  return e && (t.session_data.auth_token = e, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0);
14036
13897
  }
14037
13898
  _getAnonymLoginCacheKey() {
14038
- return N.authToken ? `${Wc}${N.authToken}` : null;
13899
+ return N.authToken ? `${Uc}${N.authToken}` : null;
14039
13900
  }
14040
13901
  _getCachedAnonymLogin() {
14041
13902
  let e = this._getAnonymLoginCacheKey();
14042
13903
  if (!e) return null;
14043
13904
  let t = ht.get(e);
14044
- return tl(t) ? t : (t && ht.remove(e), null);
13905
+ return el(t) ? t : (t && ht.remove(e), null);
14045
13906
  }
14046
13907
  _setCachedAnonymLogin(e) {
14047
13908
  let t = this._getAnonymLoginCacheKey();
14048
- if (!t || !$c(e)) return;
13909
+ if (!t || !Qc(e)) return;
14049
13910
  let n = {
14050
13911
  session_key: e.session_key,
14051
13912
  session_secret_key: e.session_secret_key,
14052
13913
  uid: e.uid,
14053
- external_user_id: el(e)
13914
+ external_user_id: $c(e)
14054
13915
  };
14055
13916
  ht.set(t, n);
14056
13917
  }
@@ -14063,13 +13924,13 @@ var Zc = class extends Hc {
14063
13924
  }
14064
13925
  _applyAnonymLogin(e) {
14065
13926
  e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key;
14066
- let t = el(e);
13927
+ let t = $c(e);
14067
13928
  y.selfExternalId = e.uid && t !== null ? {
14068
13929
  participantId: M.composeParticipantId(Number(e.uid), j.USER, 0),
14069
13930
  externalId: Z.fromId(t, Mo.USER, 0)
14070
- } : null, this._cacheSelfExternalId(), N.statQueueEnabled && e.uid && Rs.remember(Number(e.uid), {
13931
+ } : null, this._cacheSelfExternalId(), N.statQueueEnabled && e.uid && zs.remember(Number(e.uid), {
14071
13932
  sessionKey: e.session_key,
14072
- endpoint: Rs.currentEndpoint()
13933
+ endpoint: zs.currentEndpoint()
14073
13934
  });
14074
13935
  }
14075
13936
  _cacheSelfExternalId() {
@@ -14092,7 +13953,7 @@ var Zc = class extends Hc {
14092
13953
  });
14093
13954
  }
14094
13955
  async _sendClientStatsWith(e, t) {
14095
- let n = await As("vchat.clientStats", {
13956
+ let n = await js("vchat.clientStats", {
14096
13957
  ...t,
14097
13958
  session_key: e
14098
13959
  }, !0);
@@ -14100,7 +13961,7 @@ var Zc = class extends Hc {
14100
13961
  }
14101
13962
  async _sendClientStats(e, t, n = !0) {
14102
13963
  try {
14103
- let n = t ? await js("vchat.clientStats", e) : await As("vchat.clientStats", e);
13964
+ let n = t ? await Ms("vchat.clientStats", e) : await js("vchat.clientStats", e);
14104
13965
  this._reportClientStatsItemErrors(n);
14105
13966
  } catch (r) {
14106
13967
  if (!n || !fs(r?.error_code)) throw r;
@@ -14127,7 +13988,7 @@ var Zc = class extends Hc {
14127
13988
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
14128
13989
  o.append("file", s, "log.json");
14129
13990
  let c = new URL(a.upload_url);
14130
- return c.searchParams.append("size", s.size.toString()), Ps(c.toString(), o);
13991
+ return c.searchParams.append("size", s.size.toString()), Fs(c.toString(), o);
14131
13992
  }
14132
13993
  async joinConversation(e, t = !1, n) {
14133
13994
  let r = {
@@ -14245,9 +14106,9 @@ var Zc = class extends Hc {
14245
14106
  return y.userId;
14246
14107
  }
14247
14108
  setUserId(e) {
14248
- y.userId = e, N.statQueueEnabled && y.sessionKey && Rs.remember(Number(e), {
14109
+ y.userId = e, N.statQueueEnabled && y.sessionKey && zs.remember(Number(e), {
14249
14110
  sessionKey: y.sessionKey,
14250
- endpoint: Rs.currentEndpoint()
14111
+ endpoint: zs.currentEndpoint()
14251
14112
  });
14252
14113
  }
14253
14114
  hangupConversation(e, t = O.HUNGUP, n) {
@@ -14255,7 +14116,7 @@ var Zc = class extends Hc {
14255
14116
  conversationId: e,
14256
14117
  reason: t
14257
14118
  };
14258
- N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), ks("vchat.hangupConversation", r);
14119
+ N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), As("vchat.hangupConversation", r);
14259
14120
  }
14260
14121
  async removeHistoryRecords(e) {
14261
14122
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -14271,26 +14132,26 @@ var Zc = class extends Hc {
14271
14132
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
14272
14133
  }
14273
14134
  };
14274
- function Qc(e) {
14135
+ function Zc(e) {
14275
14136
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
14276
14137
  }
14277
- function $c(e) {
14138
+ function Qc(e) {
14278
14139
  return typeof e == "object" && !!e && "session_key" in e && "session_secret_key" in e && typeof e.session_key == "string" && e.session_key.length > 0 && typeof e.session_secret_key == "string" && e.session_secret_key.length > 0;
14279
14140
  }
14280
- function el(e) {
14141
+ function $c(e) {
14281
14142
  let t = e?.external_user_id;
14282
14143
  return typeof t == "string" && t.length > 0 ? t : null;
14283
14144
  }
14284
- function tl(e) {
14285
- return $c(e) && "external_user_id" in e && (typeof e.external_user_id == "string" || e.external_user_id === null);
14145
+ function el(e) {
14146
+ return Qc(e) && "external_user_id" in e && (typeof e.external_user_id == "string" || e.external_user_id === null);
14286
14147
  }
14287
14148
  //#endregion
14288
14149
  //#region src/enums/RecordRole.ts
14289
- var nl = /* @__PURE__ */ function(e) {
14150
+ var tl = /* @__PURE__ */ function(e) {
14290
14151
  return e.KING = "KING", e.PAWN = "PAWN", e;
14291
- }(nl || {}), rl = /* @__PURE__ */ function(e) {
14152
+ }(tl || {}), nl = /* @__PURE__ */ function(e) {
14292
14153
  return e.OFF = "0", e.ON = "1", e;
14293
- }({}), il = class {
14154
+ }({}), rl = class {
14294
14155
  constructor(e) {
14295
14156
  h(this, "_queue", void 0), h(this, "_readCursor", void 0), h(this, "_writeCursor", void 0), h(this, "_moveReadCursor", void 0), h(this, "_left", void 0), this._queue = Array(e).fill(null), this._readCursor = this._writeCursor = this._left = 0, this._moveReadCursor = !1;
14296
14157
  }
@@ -14313,12 +14174,12 @@ var nl = /* @__PURE__ */ function(e) {
14313
14174
  let e = this._queue[this._readCursor];
14314
14175
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
14315
14176
  }
14316
- }, al = class {
14177
+ }, il = class {
14317
14178
  constructor(e, t, n, r = null) {
14318
14179
  h(this, "_uuid", void 0), h(this, "_apiKey", void 0), h(this, "_callToken", void 0), h(this, "_apiEnv", void 0), h(this, "_baseApiUrl", void 0), h(this, "_sessionKey", void 0), this._uuid = M.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
14319
14180
  }
14320
14181
  async authorize() {
14321
- let e = await As("auth.anonymLogin", {
14182
+ let e = await js("auth.anonymLogin", {
14322
14183
  session_data: {
14323
14184
  device_id: this._uuid,
14324
14185
  client_version: N.apiClientVersion,
@@ -14327,7 +14188,7 @@ var nl = /* @__PURE__ */ function(e) {
14327
14188
  version: 3
14328
14189
  },
14329
14190
  application_key: this._apiKey
14330
- }, !0, await Ds(this._baseApiUrl, this._apiEnv));
14191
+ }, !0, await Os(this._baseApiUrl, this._apiEnv));
14331
14192
  return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
14332
14193
  }
14333
14194
  async hangupConversation(e, t) {
@@ -14337,9 +14198,9 @@ var nl = /* @__PURE__ */ function(e) {
14337
14198
  application_key: this._apiKey,
14338
14199
  session_key: this._sessionKey
14339
14200
  };
14340
- t?.peerId && (n.peerId = t.peerId), await As("vchat.hangupConversation", n, !0, await Ds(this._baseApiUrl, this._apiEnv));
14201
+ t?.peerId && (n.peerId = t.peerId), await js("vchat.hangupConversation", n, !0, await Os(this._baseApiUrl, this._apiEnv));
14341
14202
  }
14342
- }, ol, sl = null, cl = !1, ll = {
14203
+ }, al, ol = null, sl = !1, cl = {
14343
14204
  getCameras: E.getCameras,
14344
14205
  getMicrophones: E.getMicrophones,
14345
14206
  getOutput: E.getOutput,
@@ -14367,27 +14228,27 @@ var nl = /* @__PURE__ */ function(e) {
14367
14228
  baseChromeVersion: w.baseChromeVersion,
14368
14229
  getAudioContext: E.getAudioContext,
14369
14230
  isAudioShareSupported: w.isAudioShareSupported
14370
- }, ul = { participantMarkerCompare: M.participantMarkerCompare };
14371
- function dl(e) {
14372
- sl = e;
14231
+ }, ll = { participantMarkerCompare: M.participantMarkerCompare };
14232
+ function ul(e) {
14233
+ ol = e;
14373
14234
  }
14374
- function fl(e) {
14235
+ function dl(e) {
14375
14236
  N.videoEffects = e;
14376
14237
  }
14377
- function pl(e) {
14238
+ function fl(e) {
14378
14239
  N.audioEffects = e;
14379
14240
  }
14380
- function ml(e, t = {}) {
14241
+ function pl(e, t = {}) {
14381
14242
  N.vad = e, N.vadOptions = t;
14382
14243
  }
14383
- function hl(e, t = null, n = {}, r = 1) {
14244
+ function ml(e, t = null, n = {}, r = 1) {
14384
14245
  N.vmoji = e, N.vmojiOptions = {
14385
14246
  protocolVersion: r,
14386
14247
  renderingOptions: n
14387
14248
  }, t && e.setSDK(t);
14388
14249
  }
14389
- async function gl(t) {
14390
- N.set(t), ol || (ol = new Zc()), N.statQueueEnabled && (Ks.setApi(ol), N.autoStartStats && Cl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
14250
+ async function hl(t) {
14251
+ N.set(t), al || (al = new Xc()), N.statQueueEnabled && (qs.setApi(al), N.autoStartStats && Sl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
14391
14252
  let n = w.getBrowserSupportFailure();
14392
14253
  if (n) throw new k(b.UNSUPPORTED, { callError: {
14393
14254
  scope: "internal",
@@ -14396,19 +14257,19 @@ async function gl(t) {
14396
14257
  } });
14397
14258
  z.log("UserAgent:", navigator.userAgent), z.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), z.log("Permissions:", `Camera: ${E.hasCameraPermission()}, Mic: ${E.hasMicrophonePermission()}`), z.log("Simulcast:", `${t.simulcast} => ${N.simulcast}`);
14398
14259
  }
14399
- async function _l(e, t = [x.AUDIO], n = "", r = !1, i = !1, a, o, s) {
14260
+ async function gl(e, t = [x.AUDIO], n = "", r = !1, i = !1, a, o, s) {
14400
14261
  let c = [];
14401
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), yl([], vo.USER, t, n, r, i, a, c, o, s);
14262
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), vl([], vo.USER, t, n, r, i, a, c, o, s);
14402
14263
  }
14403
- function vl(e, t = []) {
14264
+ function _l(e, t = []) {
14404
14265
  let n = e.getIncomingCallerExternalId();
14405
14266
  return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
14406
14267
  }
14407
- async function yl(e, t = vo.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
14268
+ async function vl(e, t = vo.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
14408
14269
  if (!N.hold && B.getActive()) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
14409
14270
  let u = B.getAll().find((e) => e.isIncomingRinging);
14410
- if (!N.hold && u && !vl(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
14411
- return new $(new Zc(), sl).onStart({
14271
+ if (!N.hold && u && !_l(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
14272
+ return new $(new Xc(), ol).onStart({
14412
14273
  opponentIds: e,
14413
14274
  opponentType: t,
14414
14275
  mediaOptions: n,
@@ -14421,49 +14282,49 @@ async function yl(e, t = vo.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
14421
14282
  conversationId: l
14422
14283
  });
14423
14284
  }
14424
- async function bl(e, t) {
14425
- return xl(e, j.USER, void 0, t);
14285
+ async function yl(e, t) {
14286
+ return bl(e, j.USER, void 0, t);
14426
14287
  }
14427
- async function xl(e, t = j.USER, n, r, i, a) {
14288
+ async function bl(e, t = j.USER, n, r, i, a) {
14428
14289
  if (e === $.id()) throw Error("Push has already been processed");
14429
- return new $(new Zc(), sl).onPush(e, t, n, r, i, a);
14290
+ return new $(new Xc(), ol).onPush(e, t, n, r, i, a);
14430
14291
  }
14431
- async function Sl() {
14432
- return ol.getInbounds();
14292
+ async function xl() {
14293
+ return al.getInbounds();
14433
14294
  }
14434
- function Cl() {
14295
+ function Sl() {
14435
14296
  if (N.statQueueEnabled) {
14436
- if (!ol) {
14297
+ if (!al) {
14437
14298
  z.error("[CallsSDK] startStats() called before init()");
14438
14299
  return;
14439
14300
  }
14440
- cl || (cl = !0, ec.start(ol));
14301
+ sl || (sl = !0, nc.start(al));
14441
14302
  }
14442
14303
  }
14443
- async function wl(e, t) {
14444
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, Ts()), ol.authorize();
14304
+ async function Cl(e, t) {
14305
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, Es()), al.authorize();
14445
14306
  }
14446
- async function Tl(e = [x.AUDIO], t) {
14447
- return Xu(t).accept(e);
14307
+ async function wl(e = [x.AUDIO], t) {
14308
+ return Yu(t).accept(e);
14448
14309
  }
14449
- async function El(e) {
14450
- let t = qu(e?.conversationId);
14310
+ async function Tl(e) {
14311
+ let t = Ku(e?.conversationId);
14451
14312
  if (t) return t.decline(e);
14452
14313
  }
14453
- async function Dl(e, t = [x.AUDIO]) {
14454
- return Ol(e, t);
14314
+ async function El(e, t = [x.AUDIO]) {
14315
+ return Dl(e, t);
14455
14316
  }
14456
- async function Ol(e, t, n) {
14317
+ async function Dl(e, t, n) {
14457
14318
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
14458
- return new $(new Zc(), sl).onJoin({
14319
+ return new $(new Xc(), ol).onJoin({
14459
14320
  conversationId: e,
14460
14321
  mediaOptions: t,
14461
14322
  chatId: n
14462
14323
  });
14463
14324
  }
14464
- async function kl(e, t = [x.AUDIO], n, r, i, a) {
14325
+ async function Ol(e, t = [x.AUDIO], n, r, i, a) {
14465
14326
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
14466
- return n && (N.anonymToken = n), new $(new Zc(), sl).onJoin({
14327
+ return n && (N.anonymToken = n), new $(new Xc(), ol).onJoin({
14467
14328
  joinLink: e,
14468
14329
  mediaOptions: t,
14469
14330
  observedIds: r,
@@ -14472,30 +14333,30 @@ async function kl(e, t = [x.AUDIO], n, r, i, a) {
14472
14333
  anonymous: !!N.anonymToken
14473
14334
  });
14474
14335
  }
14475
- function Al(e) {
14476
- let t = qu(e?.conversationId);
14336
+ function kl(e) {
14337
+ let t = Ku(e?.conversationId);
14477
14338
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
14478
14339
  }
14479
- async function jl(e, t) {
14340
+ async function Al(e, t) {
14480
14341
  let n = Array.isArray(e) ? e : [e], r = $.current();
14481
14342
  if (r) return r.addParticipant(n, t);
14482
14343
  }
14483
- async function Ml(e, t) {
14344
+ async function jl(e, t) {
14484
14345
  let n = $.current();
14485
14346
  if (n) {
14486
14347
  let r = e.map((e) => M.composeUserId(e));
14487
14348
  await n.addParticipantLegacy(r, t);
14488
14349
  }
14489
14350
  }
14490
- async function Nl(e, t = !1) {
14491
- let n = Zu(e, "removeParticipant");
14351
+ async function Ml(e, t = !1) {
14352
+ let n = Xu(e, "removeParticipant");
14492
14353
  if (n) try {
14493
14354
  await n.conversation.removeParticipant(M.decomposeParticipantId(n.participantId).compositeUserId, t);
14494
14355
  } catch (e) {
14495
14356
  z.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
14496
14357
  }
14497
14358
  }
14498
- async function Pl(e, t = !1) {
14359
+ async function Nl(e, t = !1) {
14499
14360
  let n = $.current();
14500
14361
  if (n) try {
14501
14362
  await n.removeParticipant(M.composeUserId(e), t);
@@ -14503,13 +14364,13 @@ async function Pl(e, t = !1) {
14503
14364
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
14504
14365
  }
14505
14366
  }
14506
- async function Fl(e, t) {
14367
+ async function Pl(e, t) {
14507
14368
  let n = $.current();
14508
14369
  if (e === "videoinput" && It.contains(t)) return N.videoFacingMode = t, n ? (w.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
14509
14370
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
14510
14371
  if (n) return n.changeDevice(e);
14511
14372
  }
14512
- async function Il(e, t) {
14373
+ async function Fl(e, t) {
14513
14374
  let n = typeof e == "object" ? {
14514
14375
  ...e,
14515
14376
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -14518,40 +14379,40 @@ async function Il(e, t) {
14518
14379
  captureScreen: e,
14519
14380
  fastScreenSharing: !1,
14520
14381
  captureAudio: !1
14521
- }, r = qu(t);
14382
+ }, r = Ku(t);
14522
14383
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
14523
14384
  }
14524
- function Ll(e) {
14385
+ function Il(e) {
14525
14386
  let t = $.current();
14526
14387
  t && t.toggleAnimojiCapturing(e);
14527
14388
  }
14528
- async function Rl(e, t = !1) {
14389
+ async function Ll(e, t = !1) {
14529
14390
  let n = $.current();
14530
14391
  n && await n.setVideoStream(e, t);
14531
14392
  }
14532
- async function zl(e, t) {
14533
- let n = qu(t);
14393
+ async function Rl(e, t) {
14394
+ let n = Ku(t);
14534
14395
  n && await n.toggleLocalVideo(e);
14535
14396
  }
14536
- async function Bl(e, t) {
14537
- let n = qu(t);
14397
+ async function zl(e, t) {
14398
+ let n = Ku(t);
14538
14399
  n && await n.toggleLocalAudio(e);
14539
14400
  }
14540
- async function Vl(e) {
14401
+ async function Bl(e) {
14541
14402
  let t = $.current();
14542
14403
  if (t) return t.setLocalResolution(e);
14543
14404
  }
14544
- async function Hl(e) {
14405
+ async function Vl(e) {
14545
14406
  let t = $.current();
14546
14407
  t && await t.changePriorities(e);
14547
14408
  }
14548
- async function Ul(e, t) {
14409
+ async function Hl(e, t) {
14549
14410
  let n = $.current();
14550
14411
  if (n) {
14551
14412
  if (t) {
14552
14413
  let r = n.getCachedParticipantIdByExternalId(t);
14553
14414
  if (!r) {
14554
- Ju(t, "changeParticipantState", n);
14415
+ qu(t, "changeParticipantState", n);
14555
14416
  return;
14556
14417
  }
14557
14418
  await n.changeParticipantState(e, r);
@@ -14560,161 +14421,161 @@ async function Ul(e, t) {
14560
14421
  await n.changeParticipantState(e);
14561
14422
  }
14562
14423
  }
14563
- async function Wl() {
14424
+ async function Ul() {
14564
14425
  let e = $.current();
14565
14426
  e && await e.putHandsDown();
14566
14427
  }
14567
- async function Gl(e) {
14428
+ async function Wl(e) {
14568
14429
  let t = $.current();
14569
14430
  t && await t.updateDisplayLayout(e);
14570
14431
  }
14571
- async function Kl(e) {
14432
+ async function Gl(e) {
14572
14433
  let t = $.current();
14573
14434
  t && await t.requestDisplayLayout(e);
14574
14435
  }
14575
- async function ql(e, t, n = !1) {
14576
- let r = Zu(e, "grantRoles");
14436
+ async function Kl(e, t, n = !1) {
14437
+ let r = Xu(e, "grantRoles");
14577
14438
  r && await r.conversation.grantRoles(r.participantId, t, n);
14578
14439
  }
14579
- async function Jl(e, t, n, r = !1) {
14440
+ async function ql(e, t, n, r = !1) {
14580
14441
  let i = $.current();
14581
14442
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
14582
14443
  }
14583
- async function Yl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
14444
+ async function Jl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
14584
14445
  if (e) {
14585
- let i = Zu(e, "muteParticipant");
14446
+ let i = Xu(e, "muteParticipant");
14586
14447
  return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
14587
14448
  }
14588
14449
  let i = $.current();
14589
14450
  i && await i.muteParticipant(null, t, n, r);
14590
14451
  }
14591
- async function Xl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
14452
+ async function Yl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
14592
14453
  let a = $.current();
14593
14454
  if (a) {
14594
14455
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
14595
14456
  await a.muteParticipant(o, t, n, i);
14596
14457
  }
14597
14458
  }
14598
- async function Zl(e, t = !1, n = null) {
14599
- let r = Zu(e, "pinParticipant");
14459
+ async function Xl(e, t = !1, n = null) {
14460
+ let r = Xu(e, "pinParticipant");
14600
14461
  r && await r.conversation.pinParticipant(r.participantId, t, n);
14601
14462
  }
14602
- async function Ql(e, t = !1, n = 0, r = null) {
14463
+ async function Zl(e, t = !1, n = 0, r = null) {
14603
14464
  let i = $.current();
14604
14465
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
14605
14466
  }
14606
- async function $l(e) {
14467
+ async function Ql(e) {
14607
14468
  let t = $.current();
14608
14469
  t && await t.updateMediaModifiers(e);
14609
14470
  }
14610
- async function eu(e) {
14471
+ async function $l(e) {
14611
14472
  let t = $.current();
14612
14473
  t && await t.enableVideoSuspend(e);
14613
14474
  }
14614
- async function tu(e) {
14475
+ async function eu(e) {
14615
14476
  let t = $.current();
14616
14477
  t && await t.enableVideoSuspendSuggest(e);
14617
14478
  }
14618
- async function nu(e) {
14479
+ async function tu(e) {
14619
14480
  let t = $.current();
14620
14481
  t && await t.changeOptions(e);
14621
14482
  }
14622
- async function ru(e, t = null) {
14483
+ async function nu(e, t = null) {
14623
14484
  if (t) {
14624
- let n = Zu(t, "chatMessage");
14485
+ let n = Xu(t, "chatMessage");
14625
14486
  return n ? n.conversation.chatMessage(e, M.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
14626
14487
  }
14627
14488
  let n = $.current();
14628
14489
  n && await n.chatMessage(e, null);
14629
14490
  }
14630
- async function iu(e, t = null) {
14491
+ async function ru(e, t = null) {
14631
14492
  let n = $.current();
14632
14493
  if (n) {
14633
14494
  let r = t ? M.composeUserId(t) : null;
14634
14495
  await n.chatMessage(e, r);
14635
14496
  }
14636
14497
  }
14637
- async function au(e = 10) {
14498
+ async function iu(e = 10) {
14638
14499
  let t = $.current();
14639
14500
  if (t) return t.chatHistory(e);
14640
14501
  }
14641
- async function ou(e, t = null) {
14502
+ async function au(e, t = null) {
14642
14503
  if (t) {
14643
- let n = Zu(t, "customData");
14504
+ let n = Xu(t, "customData");
14644
14505
  return n ? n.conversation.customData(e, n.participantId) : void 0;
14645
14506
  }
14646
14507
  let n = $.current();
14647
14508
  n && await n.customData(e, null);
14648
14509
  }
14649
- async function su(e, t = null, n = 0) {
14510
+ async function ou(e, t = null, n = 0) {
14650
14511
  let r = $.current();
14651
14512
  if (r) {
14652
14513
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
14653
14514
  await r.customData(e, i);
14654
14515
  }
14655
14516
  }
14656
- async function cu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14657
- return (await ol.createConversation(a ?? M.uuid(), e, t, {
14517
+ async function su(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14518
+ return (await al.createConversation(a ?? M.uuid(), e, t, {
14658
14519
  onlyAdminCanShareMovie: n,
14659
14520
  waitForAdmin: r,
14660
14521
  closedConversation: i
14661
14522
  })).join_link;
14662
14523
  }
14663
- async function lu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14524
+ async function cu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14664
14525
  let a = i.map((e) => Z.fromId(e));
14665
- return (await ol.createConversation(M.uuid(), e, t, {
14526
+ return (await al.createConversation(M.uuid(), e, t, {
14666
14527
  onlyAdminCanShareMovie: n,
14667
14528
  audienceMode: !0,
14668
14529
  audioOnly: r
14669
14530
  }, a)).join_link;
14670
14531
  }
14671
- async function uu() {
14532
+ async function lu() {
14672
14533
  let e = $.current();
14673
14534
  return e ? e.createJoinLink() : Promise.reject();
14674
14535
  }
14675
- async function du() {
14536
+ async function uu() {
14676
14537
  let e = $.current();
14677
14538
  return e ? e.removeJoinLink() : Promise.reject();
14678
14539
  }
14679
- async function fu(e, t) {
14680
- return ol.getAnonymTokenByLink(e, t);
14540
+ async function du(e, t) {
14541
+ return al.getAnonymTokenByLink(e, t);
14681
14542
  }
14682
- function pu(e) {
14543
+ function fu(e) {
14683
14544
  let t = $.current();
14684
14545
  t && t.setVolume(e);
14685
14546
  }
14686
- function mu(e) {
14547
+ function pu(e) {
14687
14548
  N.forceRelayPolicy = e;
14688
14549
  }
14689
- async function hu(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14550
+ async function mu(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14690
14551
  let o = $.current();
14691
14552
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
14692
14553
  }
14693
- async function gu(e = null, t) {
14554
+ async function hu(e = null, t) {
14694
14555
  let n = $.current();
14695
14556
  return n ? n.stopStream(e, t) : Promise.reject();
14696
14557
  }
14697
- async function _u(e = null) {
14558
+ async function gu(e = null) {
14698
14559
  let t = $.current();
14699
14560
  return t ? t.publishStream(e) : Promise.reject();
14700
14561
  }
14701
- async function vu() {
14562
+ async function _u() {
14702
14563
  let e = $.current();
14703
14564
  return e ? e.getStreamInfo() : Promise.reject();
14704
14565
  }
14705
- async function yu(e) {
14566
+ async function vu(e) {
14706
14567
  let t = $.current();
14707
14568
  return t ? t.addMovie(e) : Promise.reject();
14708
14569
  }
14709
- async function bu(e) {
14570
+ async function yu(e) {
14710
14571
  let t = $.current();
14711
14572
  return t ? t.updateMovie(e) : Promise.reject();
14712
14573
  }
14713
- async function xu(e) {
14574
+ async function bu(e) {
14714
14575
  let t = $.current();
14715
14576
  return t ? t.removeMovie(e) : Promise.reject();
14716
14577
  }
14717
- async function Su(e, t) {
14578
+ async function xu(e, t) {
14718
14579
  let n = $.current();
14719
14580
  if (n) {
14720
14581
  let r = [], i = [];
@@ -14736,46 +14597,46 @@ async function Su(e, t) {
14736
14597
  });
14737
14598
  }
14738
14599
  if (i.length) {
14739
- Yu(i, "updateRooms", n);
14600
+ Ju(i, "updateRooms", n);
14740
14601
  return;
14741
14602
  }
14742
14603
  return n.updateRooms(r, t);
14743
14604
  }
14744
14605
  return Promise.reject();
14745
14606
  }
14746
- async function Cu(e, t) {
14607
+ async function Su(e, t) {
14747
14608
  let n = $.current();
14748
14609
  return n ? n.activateRooms(e, t) : Promise.reject();
14749
14610
  }
14750
- async function wu(e = null, t = null) {
14611
+ async function Cu(e = null, t = null) {
14751
14612
  let n = $.current();
14752
14613
  if (!n) return Promise.reject();
14753
14614
  let r;
14754
14615
  if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
14755
- Ju(t, "switchRoom", n);
14616
+ qu(t, "switchRoom", n);
14756
14617
  return;
14757
14618
  }
14758
14619
  return n.switchRoom(e, r);
14759
14620
  }
14760
- async function Tu(e) {
14621
+ async function wu(e) {
14761
14622
  let t = $.current();
14762
14623
  return t ? t.removeRooms(e) : Promise.reject();
14763
14624
  }
14764
- function Eu(e) {
14625
+ function Tu(e) {
14765
14626
  N.statisticsInterval = e;
14766
14627
  let t = $.current();
14767
14628
  if (t) return t.updateStatisticsInterval();
14768
14629
  }
14769
- function Du(t) {
14630
+ function Eu(t) {
14770
14631
  e.disableLog(!t), z.toggle(t);
14771
14632
  }
14772
- function Ou(e, ...t) {
14633
+ function Du(e, ...t) {
14773
14634
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
14774
14635
  }
14775
- function ku(e, t, ...n) {
14636
+ function Ou(e, t, ...n) {
14776
14637
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
14777
14638
  }
14778
- var Au = {
14639
+ var ku = {
14779
14640
  list: Ne,
14780
14641
  get: Pe,
14781
14642
  getJson: Fe,
@@ -14783,7 +14644,7 @@ var Au = {
14783
14644
  clear: Le,
14784
14645
  stats: Re
14785
14646
  };
14786
- function ju() {
14647
+ function Au() {
14787
14648
  let e = [
14788
14649
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
14789
14650
  ["UserAgent:", navigator.userAgent],
@@ -14801,139 +14662,139 @@ function ju() {
14801
14662
  d: e
14802
14663
  }));
14803
14664
  }
14804
- async function Mu() {
14665
+ async function ju() {
14805
14666
  let e = $.id(), t = $.debugSessionId();
14806
14667
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
14807
14668
  let n = await Pe({ sessionId: t });
14808
14669
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
14809
14670
  let r = n[0].t, i = n[n.length - 1].t;
14810
14671
  try {
14811
- return ol?.uploadDebugLogs(e, r, i, JSON.stringify([...ju(), ...n]));
14672
+ return al?.uploadDebugLogs(e, r, i, JSON.stringify([...Au(), ...n]));
14812
14673
  } catch (e) {
14813
14674
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
14814
14675
  }
14815
14676
  }
14816
- async function Nu(e) {
14677
+ async function Mu(e) {
14817
14678
  let t = $.current();
14818
14679
  if (t) return t.videoEffect(e);
14819
14680
  }
14820
- async function Pu(e, t) {
14681
+ async function Nu(e, t) {
14821
14682
  let n = $.current();
14822
14683
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
14823
14684
  }
14824
- async function Fu(e) {
14685
+ async function Pu(e) {
14825
14686
  let t = $.current();
14826
14687
  t && await t.setAudioStream(e);
14827
14688
  }
14828
- async function Iu(e, t = null, n = null) {
14689
+ async function Fu(e, t = null, n = null) {
14829
14690
  let r = $.current();
14830
14691
  if (!r) return;
14831
14692
  let i = n ?? t?.id, a = null;
14832
14693
  if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
14833
- Ju(t, "setVmojiSvg", r);
14694
+ qu(t, "setVmojiSvg", r);
14834
14695
  return;
14835
14696
  }
14836
14697
  r.setAnimojiSvg(e, a, i);
14837
14698
  }
14838
- function Lu(e) {
14699
+ function Iu(e) {
14839
14700
  let t = $.current();
14840
14701
  t && t.setAnimojiFill(e);
14841
14702
  }
14842
- async function Ru(e = null, t, n = !1) {
14843
- return Xu().getWaitingHall(e, t, n);
14703
+ async function Lu(e = null, t, n = !1) {
14704
+ return Yu().getWaitingHall(e, t, n);
14844
14705
  }
14845
- async function zu() {
14846
- return Xu().getAudienceModeHands();
14706
+ async function Ru() {
14707
+ return Yu().getAudienceModeHands();
14847
14708
  }
14848
- async function Bu(e, t = !1) {
14849
- let n = Xu(), r;
14709
+ async function zu(e, t = !1) {
14710
+ let n = Yu(), r;
14850
14711
  if (e) {
14851
14712
  let t = n.getCachedParticipantIdByExternalId(e);
14852
14713
  if (!t) {
14853
- Ju(e, "promoteParticipant", n);
14714
+ qu(e, "promoteParticipant", n);
14854
14715
  return;
14855
14716
  }
14856
14717
  r = M.decomposeParticipantId(t).compositeUserId;
14857
14718
  }
14858
14719
  return n.promoteParticipant(r, t);
14859
14720
  }
14721
+ async function Bu(e = !1) {
14722
+ return Yu().requestPromotion(e);
14723
+ }
14860
14724
  async function Vu(e = !1) {
14861
- return Xu().requestPromotion(e);
14725
+ return Yu().acceptPromotion(e);
14862
14726
  }
14863
- async function Hu(e = !1) {
14864
- return Xu().acceptPromotion(e);
14727
+ async function Hu(e) {
14728
+ return Yu().getParticipantListChunk(e);
14865
14729
  }
14866
14730
  async function Uu(e) {
14867
- return Xu().getParticipantListChunk(e);
14731
+ return Yu().getParticipants(e);
14868
14732
  }
14869
14733
  async function Wu(e) {
14870
- return Xu().getParticipants(e);
14871
- }
14872
- async function Gu(e) {
14873
- return Xu().feedback(e);
14734
+ return Yu().feedback(e);
14874
14735
  }
14875
- async function Ku(e, t, n) {
14876
- return Xu(n).enableFeatureForRoles(e, t);
14736
+ async function Gu(e, t, n) {
14737
+ return Yu(n).enableFeatureForRoles(e, t);
14877
14738
  }
14878
- function qu(e) {
14739
+ function Ku(e) {
14879
14740
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
14880
14741
  }
14881
- function Ju(e, t, n) {
14742
+ function qu(e, t, n) {
14882
14743
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
14883
14744
  }
14884
- function Yu(e, t, n) {
14745
+ function Ju(e, t, n) {
14885
14746
  let r = Array.from(new Set(e));
14886
14747
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
14887
14748
  }
14888
- function Xu(e) {
14889
- let t = qu(e);
14749
+ function Yu(e) {
14750
+ let t = Ku(e);
14890
14751
  if (!t) throw Error("Conversation not found");
14891
14752
  return t;
14892
14753
  }
14893
- function Zu(e, t) {
14754
+ function Xu(e, t) {
14894
14755
  let n = $.current();
14895
14756
  if (!n) return null;
14896
14757
  let r = n.getCachedParticipantIdByExternalId(e);
14897
14758
  return r ? {
14898
14759
  conversation: n,
14899
14760
  participantId: r
14900
- } : (Ju(e, t, n), null);
14761
+ } : (qu(e, t, n), null);
14901
14762
  }
14902
- async function Qu(e) {
14903
- await ol.removeHistoryRecords(e);
14763
+ async function Zu(e) {
14764
+ await al.removeHistoryRecords(e);
14904
14765
  }
14905
- async function $u(e) {
14766
+ async function Qu(e) {
14906
14767
  let t = $.current() ?? B.getFirst();
14907
14768
  t && await t.startAsr(e);
14908
14769
  }
14909
- async function ed(e) {
14770
+ async function $u(e) {
14910
14771
  let t = $.current() ?? B.getFirst();
14911
14772
  t && await t.stopAsr(e);
14912
14773
  }
14913
- async function td(e) {
14774
+ async function ed(e) {
14914
14775
  let t = $.current() ?? B.getFirst();
14915
14776
  t && await t.requestAsr(e);
14916
14777
  }
14917
- async function nd(e) {
14778
+ async function td(e) {
14918
14779
  let t = $.current();
14919
14780
  return t ? t.startUrlSharing(e) : Promise.reject();
14920
14781
  }
14921
- async function rd() {
14782
+ async function nd() {
14922
14783
  let e = $.current();
14923
14784
  return e ? e.stopUrlSharing() : Promise.reject();
14924
14785
  }
14925
- async function id(e) {
14786
+ async function rd(e) {
14926
14787
  await B.switchCall(e);
14927
14788
  }
14928
- function ad() {
14789
+ function id() {
14929
14790
  return B.getActiveId();
14930
14791
  }
14931
- function od() {
14792
+ function ad() {
14932
14793
  return $.getSyncedTime();
14933
14794
  }
14934
- function sd() {
14795
+ function od() {
14935
14796
  return N.sdkVersion;
14936
14797
  }
14937
14798
  typeof window < "u" && (window.__CALLS_SDK = wn);
14938
14799
  //#endregion
14939
- export { Zc as Api, al as ApiExternal, il as ArrayDequeue, y as AuthData, f as BaseLogger, _o as CallDirection, vo as CallType, yo as ChatRoomEventType, bo as ConversationFeature, xo as ConversationOption, Dn as DebugMessageType, Mo as ExternalIdType, It as FacingMode, b as FatalError, k as HangupReason, O as HangupType, x as MediaOption, A as MediaTrackKind, H as MediaType, wo as MuteState, X as ParticipantState, rl as ParticipantStateDataValue, P as ParticipantStatus, nl as RecordRole, To as RoomsEventType, go as Signaling, V as SignalingCommandType, Cr as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, Oo as UserRole, j as UserType, ts as VolumeDetector, Tl as acceptCall, Hu as acceptPromotion, Cu as activateRooms, yu as addMovie, jl as addParticipant, Ml as addParticipantInternal, wl as authorize, ll as browser, yl as callInternal, _l as callTo, Il as captureScreen, Ll as captureVmoji, Pu as changeAudioEffect, nu as changeConversationOptions, Fl as changeDevice, Ul as changeParticipantState, Hl as changePriorities, Nu as changeVideoEffect, au as chatHistory, ru as chatMessage, iu as chatMessageInternal, uu as createJoinLink, ou as customData, su as customDataInternal, Du as debug, Au as debugLogs, Ou as debugMessage, ku as debugMessageWithContext, El as declineCall, Ku as enableFeatureForRoles, eu as enableVideoSuspend, tu as enableVideoSuspendSuggest, Gu as feedback, mu as forceRelayPolicy, ad as getActiveCallId, fu as getAnonymTokenByLink, zu as getAudienceModeHands, Sl as getInbounds, Uu as getParticipantListChunk, Wu as getParticipants, vu as getStreamInfo, od as getSyncedTime, Ru as getWaitingHall, ql as grantRoles, Jl as grantRolesInternal, Al as hangup, gl as init, Dl as joinCall, kl as joinCallByLink, Ol as joinCallInternal, Yl as muteParticipant, Xl as muteParticipantInternal, Zl as pinParticipant, Ql as pinParticipantInternal, bl as processPush, xl as processPushInternal, Bu as promoteParticipant, _u as publishStream, Wl as putHandsDown, Qu as removeHistoryRecords, du as removeJoinLink, xu as removeMovie, Nl as removeParticipant, Pl as removeParticipantInternal, Tu as removeRooms, td as requestAsr, Kl as requestDisplayLayout, Vu as requestPromotion, pl as setAudioEffects, Fu as setAudioStream, Vl as setLocalResolution, dl as setLogger, $l as setMediaModifiers, Eu as setStatisticsInterval, ml as setVad, fl as setVideoEffects, Rl as setVideoStream, hl as setVmoji, Lu as setVmojiFill, Iu as setVmojiSvg, pu as setVolume, $u as startAsr, lu as startAudienceConversation, cu as startConversation, Cl as startStats, hu as startStream, nd as startUrlSharing, ed as stopAsr, gu as stopStream, rd as stopUrlSharing, id as switchCall, wu as switchRoom, Bl as toggleLocalAudio, zl as toggleLocalVideo, Gl as updateDisplayLayout, bu as updateMovie, Su as updateRooms, Mu as uploadDebugLogs, ul as utils, sd as version };
14800
+ export { Xc as Api, il as ApiExternal, rl as ArrayDequeue, y as AuthData, f as BaseLogger, _o as CallDirection, vo as CallType, yo as ChatRoomEventType, bo as ConversationFeature, xo as ConversationOption, Dn as DebugMessageType, Mo as ExternalIdType, It as FacingMode, b as FatalError, k as HangupReason, O as HangupType, x as MediaOption, A as MediaTrackKind, H as MediaType, wo as MuteState, X as ParticipantState, nl as ParticipantStateDataValue, P as ParticipantStatus, tl as RecordRole, To as RoomsEventType, go as Signaling, V as SignalingCommandType, Cr as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, Oo as UserRole, j as UserType, ts as VolumeDetector, wl as acceptCall, Vu as acceptPromotion, Su as activateRooms, vu as addMovie, Al as addParticipant, jl as addParticipantInternal, Cl as authorize, cl as browser, vl as callInternal, gl as callTo, Fl as captureScreen, Il as captureVmoji, Nu as changeAudioEffect, tu as changeConversationOptions, Pl as changeDevice, Hl as changeParticipantState, Vl as changePriorities, Mu as changeVideoEffect, iu as chatHistory, nu as chatMessage, ru as chatMessageInternal, lu as createJoinLink, au as customData, ou as customDataInternal, Eu as debug, ku as debugLogs, Du as debugMessage, Ou as debugMessageWithContext, Tl as declineCall, Gu as enableFeatureForRoles, $l as enableVideoSuspend, eu as enableVideoSuspendSuggest, Wu as feedback, pu as forceRelayPolicy, id as getActiveCallId, du as getAnonymTokenByLink, Ru as getAudienceModeHands, xl as getInbounds, Hu as getParticipantListChunk, Uu as getParticipants, _u as getStreamInfo, ad as getSyncedTime, Lu as getWaitingHall, Kl as grantRoles, ql as grantRolesInternal, kl as hangup, hl as init, El as joinCall, Ol as joinCallByLink, Dl as joinCallInternal, Jl as muteParticipant, Yl as muteParticipantInternal, Xl as pinParticipant, Zl as pinParticipantInternal, yl as processPush, bl as processPushInternal, zu as promoteParticipant, gu as publishStream, Ul as putHandsDown, Zu as removeHistoryRecords, uu as removeJoinLink, bu as removeMovie, Ml as removeParticipant, Nl as removeParticipantInternal, wu as removeRooms, ed as requestAsr, Gl as requestDisplayLayout, Bu as requestPromotion, fl as setAudioEffects, Pu as setAudioStream, Bl as setLocalResolution, ul as setLogger, Ql as setMediaModifiers, Tu as setStatisticsInterval, pl as setVad, dl as setVideoEffects, Ll as setVideoStream, ml as setVmoji, Iu as setVmojiFill, Fu as setVmojiSvg, fu as setVolume, Qu as startAsr, cu as startAudienceConversation, su as startConversation, Sl as startStats, mu as startStream, td as startUrlSharing, $u as stopAsr, hu as stopStream, nd as stopUrlSharing, rd as switchCall, Cu as switchRoom, zl as toggleLocalAudio, Rl as toggleLocalVideo, Wl as updateDisplayLayout, yu as updateMovie, xu as updateRooms, ju as uploadDebugLogs, ll as utils, od as version };