@vkontakte/calls-sdk 2.8.13-beta.11 → 2.8.13-beta.12

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-beta.11
3
- * Thu, 22 Oct 2026 12:54:38 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-beta.12
3
+ * Tue, 27 Oct 2026 16:04:29 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -55,31 +55,31 @@ function h(e, t, n) {
55
55
  }
56
56
  //#endregion
57
57
  //#region src/utils/DebugStorage.ts
58
- var te = 25 * 1024 * 1024, ne = 10, re = "_okcls_logs_session_", ie = 3e4, ae = "ok-calls-sdk-debug-logs", oe = 1, g = "sessions", _ = "chunks", se = 120 * 1e3, ce = new Set(["WARN", "ERROR"]);
59
- function le() {
60
- return `${Date.now()}_${Math.random().toString(36).slice(2)}`;
61
- }
58
+ var te = 25 * 1024 * 1024, ne = 10, re = "_okcls_logs_session_", ie = 3e4, ae = "ok-calls-sdk-debug-logs", oe = 1, g = "sessions", se = "chunks", ce = 120 * 1e3, le = new Set(["WARN", "ERROR"]);
62
59
  function ue() {
63
- let e = le();
64
- return de(e), e;
60
+ return `${Date.now()}_${Math.random().toString(36).slice(2)}`;
65
61
  }
66
- function de(e) {
67
- He.has(e) || He.set(e, []), Ue.has(e) || Ue.set(e, 0), We.has(e) || We.set(e, null);
62
+ function de() {
63
+ let e = ue();
64
+ return fe(e), e;
68
65
  }
69
66
  function fe(e) {
70
- return We.get(e) ?? null;
67
+ Ue.has(e) || Ue.set(e, []), We.has(e) || We.set(e, 0), Ge.has(e) || Ge.set(e, null);
71
68
  }
72
69
  function pe(e) {
73
- let t = Ue.get(e) ?? 0;
74
- return Ue.set(e, t + 1), t;
70
+ return Ge.get(e) ?? null;
75
71
  }
76
- function me(e, t) {
72
+ function me(e) {
73
+ let t = We.get(e) ?? 0;
74
+ return We.set(e, t + 1), t;
75
+ }
76
+ function he(e, t) {
77
77
  return `${e}:${String(t).padStart(12, "0")}`;
78
78
  }
79
- function he(e) {
79
+ function ge(e) {
80
80
  return new Blob([e]).size;
81
81
  }
82
- function ge() {
82
+ function _e() {
83
83
  try {
84
84
  let e = window.localStorage;
85
85
  for (let t of Object.keys(e)) t.indexOf(re) === 0 && e.removeItem(t);
@@ -87,7 +87,7 @@ function ge() {
87
87
  console.error("Storage is blocked", e);
88
88
  }
89
89
  }
90
- var v = new class {
90
+ var _ = new class {
91
91
  constructor() {
92
92
  h(this, "_db", null), h(this, "_dbPromise", null), h(this, "_dbName", ae), h(this, "_supported", this.isSupported());
93
93
  }
@@ -117,8 +117,8 @@ var v = new class {
117
117
  if (this._supported = this.isSupported(), this._dbName === ae && (this._dbName = `${ae}-test-${Math.random().toString(36).slice(2)}`, this.close()), this._supported) {
118
118
  let e = await this.open();
119
119
  if (e) {
120
- let t = e.transaction([g, _], "readwrite");
121
- t.objectStore(g).clear(), t.objectStore(_).clear(), await this.txDone(t).catch((e) => console.warn("Failed to clear debug log storage", e));
120
+ let t = e.transaction([g, se], "readwrite");
121
+ t.objectStore(g).clear(), t.objectStore(se).clear(), await this.txDone(t).catch((e) => console.warn("Failed to clear debug log storage", e));
122
122
  }
123
123
  }
124
124
  }
@@ -143,7 +143,7 @@ var v = new class {
143
143
  async getChunksBySession(e) {
144
144
  let t = await this.open();
145
145
  if (!t) return [];
146
- let n = t.transaction(_, "readonly"), r = await this.requestToPromise(n.objectStore(_).index("sessionId").getAll(e));
146
+ let n = t.transaction(se, "readonly"), r = await this.requestToPromise(n.objectStore(se).index("sessionId").getAll(e));
147
147
  return await this.txDone(n), r.sort((e, t) => e.sequence - t.sequence);
148
148
  }
149
149
  async putSession(e) {
@@ -155,8 +155,8 @@ var v = new class {
155
155
  async putSessionAndChunk(e, t) {
156
156
  let n = await this.open();
157
157
  if (!n) return !1;
158
- let r = n.transaction([g, _], "readwrite");
159
- return r.objectStore(g).put(e), r.objectStore(_).put(t), await this.txDone(r), !0;
158
+ let r = n.transaction([g, se], "readwrite");
159
+ return r.objectStore(g).put(e), r.objectStore(se).put(t), await this.txDone(r), !0;
160
160
  }
161
161
  async updateSessionConversationId(e, t) {
162
162
  let [n] = await this.getSessionBySessionId(e);
@@ -169,14 +169,14 @@ var v = new class {
169
169
  async deleteSession(e) {
170
170
  let t = await this.open();
171
171
  if (!t) return 0;
172
- let n = await this.getChunksBySession(e), r = t.transaction([g, _], "readwrite"), i = r.objectStore(_), a = 0;
172
+ let n = await this.getChunksBySession(e), r = t.transaction([g, se], "readwrite"), i = r.objectStore(se), a = 0;
173
173
  for (let e of n) a += e.bytes, i.delete(e.id);
174
174
  return r.objectStore(g).delete(e), await this.txDone(r), a;
175
175
  }
176
176
  async deleteChunks(e) {
177
177
  let t = await this.open();
178
178
  if (!t || !e.length) return;
179
- let n = t.transaction(_, "readwrite"), r = n.objectStore(_);
179
+ let n = t.transaction(se, "readwrite"), r = n.objectStore(se);
180
180
  for (let t of e) r.delete(t.id);
181
181
  await this.txDone(n);
182
182
  }
@@ -210,7 +210,7 @@ var v = new class {
210
210
  let t = e.createObjectStore(g, { keyPath: "sessionId" });
211
211
  t.createIndex("conversationId", "conversationId", { unique: !1 }), t.createIndex("updatedAt", "updatedAt", { unique: !1 });
212
212
  }
213
- e.objectStoreNames.contains(_) || e.createObjectStore(_, { keyPath: "id" }).createIndex("sessionId", "sessionId", { unique: !1 });
213
+ e.objectStoreNames.contains(se) || e.createObjectStore(se, { keyPath: "id" }).createIndex("sessionId", "sessionId", { unique: !1 });
214
214
  }
215
215
  isSupported() {
216
216
  return typeof window < "u" && !!window.indexedDB;
@@ -281,15 +281,15 @@ var v = new class {
281
281
  return i;
282
282
  }
283
283
  }();
284
- async function _e(e) {
285
- return e.sessionId ? v.getSessionBySessionId(e.sessionId) : e.conversationId ? v.getSessionsByConversationId(e.conversationId) : [];
284
+ async function ve(e) {
285
+ return e.sessionId ? _.getSessionBySessionId(e.sessionId) : e.conversationId ? _.getSessionsByConversationId(e.conversationId) : [];
286
286
  }
287
- async function ve(e, t, n, r) {
287
+ async function ye(e, t, n, r) {
288
288
  if (!r.length) return;
289
- let i = fe(e) || t, a = r, o = JSON.stringify(a), s = he(o);
290
- for (; s > te && a.length > 1;) a = a.slice(Math.floor(a.length / 2)), o = JSON.stringify(a), s = he(o);
289
+ let i = pe(e) || t, a = r, o = JSON.stringify(a), s = ge(o);
290
+ for (; s > te && a.length > 1;) a = a.slice(Math.floor(a.length / 2)), o = JSON.stringify(a), s = ge(o);
291
291
  if (s > te) return;
292
- let c = a[0].t, l = a[a.length - 1].t, [u] = await v.getSessionBySessionId(e), d = u || {
292
+ let c = a[0].t, l = a[a.length - 1].t, [u] = await _.getSessionBySessionId(e), d = u || {
293
293
  sessionId: e,
294
294
  conversationId: i,
295
295
  startTime: c,
@@ -306,7 +306,7 @@ async function ve(e, t, n, r) {
306
306
  bytes: d.bytes + s,
307
307
  entriesCount: d.entriesCount + a.length
308
308
  }, p = {
309
- id: me(e, n),
309
+ id: he(e, n),
310
310
  sessionId: e,
311
311
  sequence: n,
312
312
  startTime: c,
@@ -314,9 +314,9 @@ async function ve(e, t, n, r) {
314
314
  bytes: s,
315
315
  items: a
316
316
  };
317
- await v.putSessionAndChunk(f, p) && await v.enforceRetentionPolicy();
317
+ await _.putSessionAndChunk(f, p) && await _.enforceRetentionPolicy();
318
318
  }
319
- function ye(e) {
319
+ function be(e) {
320
320
  let t = /* @__PURE__ */ new WeakSet();
321
321
  try {
322
322
  return JSON.parse(JSON.stringify(e, (e, n) => {
@@ -331,101 +331,101 @@ function ye(e) {
331
331
  return e.map((e) => String(e));
332
332
  }
333
333
  }
334
- function be(e) {
335
- let t = He.get(e);
336
- if (!t?.length) return qe;
337
- let n = t.splice(0), r = fe(e), i = pe(e);
338
- return qe = qe.then(() => ve(e, r, i, n)).catch((e) => {
334
+ function xe(e) {
335
+ let t = Ue.get(e);
336
+ if (!t?.length) return Je;
337
+ let n = t.splice(0), r = pe(e), i = me(e);
338
+ return Je = Je.then(() => ye(e, r, i, n)).catch((e) => {
339
339
  console.warn("Failed to write debug log to storage", e);
340
- }), qe;
340
+ }), Je;
341
341
  }
342
- function xe(e) {
343
- if (e) return be(e);
344
- for (let e of He.keys()) be(e);
345
- return qe;
342
+ function Se(e) {
343
+ if (e) return xe(e);
344
+ for (let e of Ue.keys()) xe(e);
345
+ return Je;
346
346
  }
347
- async function Se(e) {
347
+ async function Ce(e) {
348
348
  let t = [];
349
349
  for (let n of e.sort((e, t) => e.startTime - t.startTime)) {
350
- let e = await v.getChunksBySession(n.sessionId);
350
+ let e = await _.getChunksBySession(n.sessionId);
351
351
  for (let n of e) t.push(...n.items);
352
352
  }
353
353
  return t;
354
354
  }
355
- async function Ce(e) {
356
- let t = await Se(e);
355
+ async function we(e) {
356
+ let t = await Ce(e);
357
357
  if (!t.length) return t;
358
- let n = t.sort(Te), r = n[0].t, i = n[n.length - 1].t;
359
- return [...await we(r, i, new Set(e.map((e) => e.sessionId))), ...n].sort(Te);
358
+ let n = t.sort(Ee), r = n[0].t, i = n[n.length - 1].t;
359
+ return [...await Te(r, i, new Set(e.map((e) => e.sessionId))), ...n].sort(Ee);
360
360
  }
361
- async function we(e, t, n) {
362
- let r = (await v.getAllSessions()).filter((r) => !n.has(r.sessionId) && r.conversationId === null && r.endTime >= e - se && r.startTime <= t), i = [];
361
+ async function Te(e, t, n) {
362
+ let r = (await _.getAllSessions()).filter((r) => !n.has(r.sessionId) && r.conversationId === null && r.endTime >= e - ce && r.startTime <= t), i = [];
363
363
  for (let n of r) {
364
- let r = await v.getChunksBySession(n.sessionId);
365
- for (let n of r) n.endTime < e - se || n.startTime > t || i.push(...n.items.filter((n) => n.t >= e - se && n.t <= e ? !0 : n.t >= e && n.t <= t && ce.has(n.l)));
364
+ let r = await _.getChunksBySession(n.sessionId);
365
+ for (let n of r) n.endTime < e - ce || n.startTime > t || i.push(...n.items.filter((n) => n.t >= e - ce && n.t <= e ? !0 : n.t >= e && n.t <= t && le.has(n.l)));
366
366
  }
367
367
  return i;
368
368
  }
369
- function Te(e, t) {
369
+ function Ee(e, t) {
370
370
  return e.t - t.t;
371
371
  }
372
- function Ee(e, t) {
372
+ function De(e, t) {
373
373
  let n = document.createElement("a"), r = new Blob([e], { type: "text/json" }), i = URL.createObjectURL(r);
374
374
  n.href = i, n.download = t, n.click(), URL.revokeObjectURL(i);
375
375
  }
376
- function De() {
377
- xe();
378
- }
379
376
  function Oe() {
380
- document.visibilityState === "hidden" && xe();
377
+ Se();
381
378
  }
382
- function ke(e, t, n = Ge) {
383
- Ve || Ae(), de(n);
379
+ function ke() {
380
+ document.visibilityState === "hidden" && Se();
381
+ }
382
+ function Ae(e, t, n = Ke) {
383
+ He || je(), fe(n);
384
384
  let r = /* @__PURE__ */ new Date(), i = {
385
385
  t: r.getTime(),
386
386
  l: e,
387
- d: ye(t),
387
+ d: be(t),
388
388
  h: r.toLocaleString("ru-RU", {
389
389
  dateStyle: "short",
390
390
  timeStyle: "long"
391
391
  })
392
392
  };
393
- return He.get(n)?.push(i), Ke || (Ke = window.setTimeout(() => {
394
- Ke = null, xe();
393
+ return Ue.get(n)?.push(i), qe || (qe = window.setTimeout(() => {
394
+ qe = null, Se();
395
395
  }, ie)), i;
396
396
  }
397
- function Ae() {
398
- Ve || (Ve = !0, ge(), v.open(), window.addEventListener("pagehide", De), document.addEventListener("visibilitychange", Oe));
399
- }
400
397
  function je() {
401
- return Ve || Ae(), xe(), ue();
398
+ He || (He = !0, _e(), _.open(), window.addEventListener("pagehide", Oe), document.addEventListener("visibilitychange", ke));
402
399
  }
403
- function Me(e, t = Ge) {
404
- t && (de(t), We.set(t, e), e && v.updateSessionConversationId(t, e));
400
+ function Me() {
401
+ return He || je(), Se(), de();
405
402
  }
406
- async function Ne() {
407
- return await xe(), (await v.getAllSessions()).sort((e, t) => t.updatedAt - e.updatedAt);
403
+ function Ne(e, t = Ke) {
404
+ t && (fe(t), Ge.set(t, e), e && _.updateSessionConversationId(t, e));
408
405
  }
409
- async function Pe(e) {
410
- return await xe(), Ce(await _e(e));
406
+ async function Pe() {
407
+ return await Se(), (await _.getAllSessions()).sort((e, t) => t.updatedAt - e.updatedAt);
411
408
  }
412
409
  async function Fe(e) {
413
- return JSON.stringify(await Pe(e));
410
+ return await Se(), we(await ve(e));
414
411
  }
415
412
  async function Ie(e) {
416
- let t = await Fe(e), n = `logs_${e.sessionId || e.conversationId}_${Date.now()}.json`;
417
- return Ee(t, n), n;
413
+ return JSON.stringify(await Fe(e));
418
414
  }
419
415
  async function Le(e) {
420
- await xe();
421
- let t = e ? await _e(e) : await v.getAllSessions();
422
- for (let e of t) await v.deleteSession(e.sessionId);
416
+ let t = await Ie(e), n = `logs_${e.sessionId || e.conversationId}_${Date.now()}.json`;
417
+ return De(t, n), n;
423
418
  }
424
- async function Re() {
425
- await xe();
426
- let e = await v.getStorageSummary(), t = await v.estimateStorage();
419
+ async function Re(e) {
420
+ await Se();
421
+ let t = e ? await ve(e) : await _.getAllSessions();
422
+ for (let e of t) await _.deleteSession(e.sessionId);
423
+ }
424
+ async function ze() {
425
+ await Se();
426
+ let e = await _.getStorageSummary(), t = await _.estimateStorage();
427
427
  return {
428
- supported: v.supported,
428
+ supported: _.supported,
429
429
  callsCount: e.callsCount,
430
430
  sessionsCount: e.sessions.length,
431
431
  usedBytes: e.usedBytes,
@@ -435,20 +435,20 @@ async function Re() {
435
435
  usageBytes: t?.usage
436
436
  };
437
437
  }
438
- async function ze() {
439
- await xe();
440
- let e = await Se(await v.getAllSessions());
441
- return JSON.stringify(e.sort(Te));
442
- }
443
438
  async function Be() {
444
- let e = await ze(), t = `logs_${Date.now()}.json`;
445
- return Ee(e, t), t;
439
+ await Se();
440
+ let e = await Ce(await _.getAllSessions());
441
+ return JSON.stringify(e.sort(Ee));
446
442
  }
447
- var Ve = !1, He = /* @__PURE__ */ new Map(), Ue = /* @__PURE__ */ new Map(), We = /* @__PURE__ */ new Map(), Ge = ue(), Ke = null, qe = Promise.resolve();
448
- window.__VKCallsSDKLogs__ = (e = !1) => (Ve || Ae(), e ? ze() : Be());
443
+ async function Ve() {
444
+ let e = await Be(), t = `logs_${Date.now()}.json`;
445
+ return De(e, t), t;
446
+ }
447
+ var He = !1, Ue = /* @__PURE__ */ new Map(), We = /* @__PURE__ */ new Map(), Ge = /* @__PURE__ */ new Map(), Ke = de(), qe = null, Je = Promise.resolve();
448
+ window.__VKCallsSDKLogs__ = (e = !1) => (He || je(), e ? Be() : Ve());
449
449
  //#endregion
450
450
  //#region src/static/AuthData.ts
451
- var y = class e {
451
+ var v = class e {
452
452
  static get sessionKey() {
453
453
  return e._sessionKey;
454
454
  }
@@ -488,10 +488,10 @@ var y = class e {
488
488
  })), e._reauthorizePromise;
489
489
  }
490
490
  };
491
- h(y, "_sessionKey", void 0), h(y, "_sessionSecretKey", void 0), h(y, "_accessToken", void 0), h(y, "_userId", null), h(y, "_selfExternalId", null), h(y, "_reauthorizePromise", null);
491
+ h(v, "_sessionKey", void 0), h(v, "_sessionSecretKey", void 0), h(v, "_accessToken", void 0), h(v, "_userId", null), h(v, "_selfExternalId", null), h(v, "_reauthorizePromise", null);
492
492
  //#endregion
493
493
  //#region src/classes/EventEmitter.ts
494
- var Je = class {
494
+ var Ye = class {
495
495
  constructor() {
496
496
  h(this, "_handlers", {}), h(this, "_listeners", []);
497
497
  }
@@ -517,41 +517,41 @@ var Je = class {
517
517
  e.dispose();
518
518
  });
519
519
  }
520
- }, Ye = /* @__PURE__ */ function(e) {
520
+ }, Xe = /* @__PURE__ */ function(e) {
521
521
  return e.MICROPHONE = "MICROPHONE", e.CAMERA = "CAMERA", e.SCREEN = "SCREEN", e.ANIMOJI = "ANIMOJI", e;
522
- }(Ye || {}), b = /* @__PURE__ */ function(e) {
522
+ }(Xe || {}), y = /* @__PURE__ */ function(e) {
523
523
  return e.MIC_CAMERA_PERMISSION = "mic_camera", e.CAMERA_PERMISSION = "camera", e.MIC_PERMISSION = "mic", e.CAMERA_ACCESS = "cameralock", e.MIC_ACCESS = "miclock", e.MIC_NOT_FOUND = "nomic", e.SCREEN_PERMISSION = "screenpermission", e.SCREEN_ACCESS = "screenlock", e.CONNECTION = "connection", e.NETWORK = "network", e.UNKNOWN = "unknown", e.UNSUPPORTED = "unsupported", e.SIGNALING_FAILED = "signalingfailed", e.API = "api", e.AUTH = "auth", e.OVERCONSTRAINED = "overconstrained", e;
524
- }(b || {}), x = /* @__PURE__ */ function(e) {
524
+ }(y || {}), b = /* @__PURE__ */ function(e) {
525
525
  return e.AUDIO = "AUDIO", e.VIDEO = "VIDEO", e.SCREEN_SHARING = "SCREEN_SHARING", e.MOVIE_SHARING = "MOVIE_SHARING", e.AUDIO_SHARING = "AUDIO_SHARING", e.ANIMOJI = "ANIMOJI", e;
526
- }(x || {}), S = /* @__PURE__ */ function(e) {
526
+ }(b || {}), x = /* @__PURE__ */ function(e) {
527
527
  return e.ACCEPT_CONCURRENT = "callAcceptConcurrent", e.ACCEPT_INCOMING = "callAcceptIncoming", e.ACCEPTED_OUTGOING = "callAcceptedOutgoing", e.ADD_PARTICIPANT = "callAddParticipant", e.CALL_SPEC_ERROR = "callSpecError", e.DECLINE_INCOMING = "callDeclineIncoming", e.DEVICE_CHANGED = "callDeviceChanged", e.DEVICES = "callDevices", e.ERROR = "callError", e.HANGUP = "callHangup", e.ICE_CONNECTION_STATE = "callIceConnectionState", e.ICE_CONNECTION_TYPE = "callIceConnectionType", e.ICE_RESTART = "callIceRestart", e.JOIN_CONVERSATION = "callJoinConversation", e.MEDIA_STATUS = "callMediaStatus", e.OUTGOING_CALL = "callStart", e.OUTGOING_MULTIPARTY_CALL = "callStartMultiparty", e.PAT_ALLOCATED = "patAllocate", e.PAT_DEALLOCATED = "patDeallocate", e.PAT_ERROR = "patError", e.PAT_OUTDATED_RESPONSE = "patOutdatedResponse", e.PAT_WAITING_TIME_ERROR = "patWaitingTimeError", e.POOR_CONNECTION = "callPoorConnection", e.PUSH = "callPush", e.RECONNECT = "callReconnect", e.RELAY_POLICY = "callForceRelay", e.REMOVE_PARTICIPANT = "callRemoveParticipant", e.SOCKET_ACTION = "callSocketAction", e.TOPOLOGY_CHANGE_REQUESTED = "callTopologyChangeRequested", e;
528
- }(S || {}), Xe = null, Ze = "", Qe = null, $e = [], et = navigator.appVersion, tt = navigator.appName, nt = navigator.userAgent;
529
- function rt() {
530
- return $e.length || ($e = (() => {
531
- let e, t = !1, n = 0, r = "0", i = nt.match(/(opera|chrome|safari|firefox)\/?\s*(\d+)/i) || [];
528
+ }(x || {}), Ze = null, Qe = "", $e = null, et = [], tt = navigator.appVersion, nt = navigator.appName, rt = navigator.userAgent;
529
+ function it() {
530
+ return et.length || (et = (() => {
531
+ let e, t = !1, n = 0, r = "0", i = rt.match(/(opera|chrome|safari|firefox)\/?\s*(\d+)/i) || [];
532
532
  if (i[1] === "Safari") {
533
- if (e = nt.match(/\bCriOS\/(\d+)/), e) return [
533
+ if (e = rt.match(/\bCriOS\/(\d+)/), e) return [
534
534
  "Chrome",
535
535
  e[1],
536
536
  !0,
537
537
  Number(e[1]),
538
538
  r
539
539
  ];
540
- if (e = nt.match(/\bFxiOS\/(\d+)/), e) return [
540
+ if (e = rt.match(/\bFxiOS\/(\d+)/), e) return [
541
541
  "Firefox",
542
542
  e[1],
543
543
  !1,
544
544
  n,
545
545
  r
546
546
  ];
547
- if (e = nt.match(/\bYaBrowser\/(\d+)/), e) return [
547
+ if (e = rt.match(/\bYaBrowser\/(\d+)/), e) return [
548
548
  "Yandex",
549
549
  e[1],
550
550
  !1,
551
551
  n,
552
552
  r
553
553
  ];
554
- if (e = nt.match(/\bOPT\/(\d+)/), e) return [
554
+ if (e = rt.match(/\bOPT\/(\d+)/), e) return [
555
555
  "Opera",
556
556
  e[1],
557
557
  !1,
@@ -560,28 +560,28 @@ function rt() {
560
560
  ];
561
561
  }
562
562
  if (i[1] === "Chrome") {
563
- if (t = !0, n = Number(i[2]), e = nt.match(/\bOPR\/(\d+)/), e) return [
563
+ if (t = !0, n = Number(i[2]), e = rt.match(/\bOPR\/(\d+)/), e) return [
564
564
  "Opera",
565
565
  e[1] || "Unknown",
566
566
  t,
567
567
  n,
568
568
  r
569
569
  ];
570
- if (e = nt.match(/\bYaBrowser\/(\d+)/), e) return [
570
+ if (e = rt.match(/\bYaBrowser\/(\d+)/), e) return [
571
571
  "Yandex",
572
572
  e[1] || "Unknown",
573
573
  t,
574
574
  n,
575
575
  r
576
576
  ];
577
- if (e = nt.match(/\bSferum\/((\d+)(?:\.\d+)*)/), e) return [
577
+ if (e = rt.match(/\bSferum\/((\d+)(?:\.\d+)*)/), e) return [
578
578
  "Sferum",
579
579
  e[1] || "Unknown",
580
580
  t,
581
581
  n,
582
582
  r
583
583
  ];
584
- if (e = nt.match(/\bEdge?\/(\d+)/), e) return [
584
+ if (e = rt.match(/\bEdge?\/(\d+)/), e) return [
585
585
  "Edge",
586
586
  e[1] || "Unknown",
587
587
  t,
@@ -596,16 +596,16 @@ function rt() {
596
596
  r
597
597
  ];
598
598
  }
599
- return e = nt.match(/version\/(\d+)(?:(?:\.)(\d+))?/i), e && e[2] !== void 0 && (r = e[2]), [
600
- i[2] ? i[1] : tt,
601
- e && e[1] || i[2] || et,
599
+ return e = rt.match(/version\/(\d+)(?:(?:\.)(\d+))?/i), e && e[2] !== void 0 && (r = e[2]), [
600
+ i[2] ? i[1] : nt,
601
+ e && e[1] || i[2] || tt,
602
602
  t,
603
603
  n,
604
604
  r
605
605
  ];
606
- })()), $e;
606
+ })()), et;
607
607
  }
608
- var C;
608
+ var S;
609
609
  (function(e) {
610
610
  async function t(e) {
611
611
  if ("userAgentData" in navigator) try {
@@ -615,7 +615,7 @@ var C;
615
615
  return;
616
616
  }
617
617
  let n = parseInt(t.split(".")[0]);
618
- Qe = isNaN(n) ? null : n;
618
+ $e = isNaN(n) ? null : n;
619
619
  } catch (t) {
620
620
  e("Failed to get OS version", t);
621
621
  }
@@ -645,42 +645,42 @@ var C;
645
645
  e.canSelectAudioInput = a;
646
646
  function o() {
647
647
  if (typeof HTMLMediaElement > "u" || typeof HTMLMediaElement.prototype.setSinkId != "function") return !1;
648
- let e = C.os();
648
+ let e = S.os();
649
649
  if (["iPhone", "iPad"].includes(e) || e === "MacOS" && navigator.maxTouchPoints > 1) return !1;
650
- if (C.browserName() !== "Safari") return !0;
651
- let t = Number(C.browserVersion()), n = Number(C.browserSubVersion());
650
+ if (S.browserName() !== "Safari") return !0;
651
+ let t = Number(S.browserVersion()), n = Number(S.browserSubVersion());
652
652
  return e === "MacOS" && (t > 18 || t === 18 && n >= 4);
653
653
  }
654
654
  e.canSelectAudioOutput = o;
655
655
  function s() {
656
- let e = C.browserName() === "Opera", t = C.browserName() === "Yandex";
656
+ let e = S.browserName() === "Opera", t = S.browserName() === "Yandex";
657
657
  return e || t;
658
658
  }
659
659
  e.isBrokenH264Decoder = s;
660
660
  function c() {
661
- return C.browserName() === "Yandex" && C.os() === "Windows";
661
+ return S.browserName() === "Yandex" && S.os() === "Windows";
662
662
  }
663
663
  e.isBrokenVP9Encoder = c;
664
664
  function l() {
665
- let e = C.browserName() === "Safari" && Number(C.browserVersion()) === 17 && [
665
+ let e = S.browserName() === "Safari" && Number(S.browserVersion()) === 17 && [
666
666
  4,
667
667
  5,
668
668
  6
669
- ].includes(Number(C.browserSubVersion())), t = C.osVersion(), n = C.os() === "Windows" && t != null && t > 0 && t < 13;
669
+ ].includes(Number(S.browserSubVersion())), t = S.osVersion(), n = S.os() === "Windows" && t != null && t > 0 && t < 13;
670
670
  return e || n;
671
671
  }
672
672
  e.isBrokenVP9Decoder = l;
673
673
  function u() {
674
- return !(C.baseChromeVersion() && C.isMobile());
674
+ return !(S.baseChromeVersion() && S.isMobile());
675
675
  }
676
676
  e.canPreferH264 = u;
677
677
  function d() {
678
- let e = C.browserName(), t = Number(C.browserVersion());
678
+ let e = S.browserName(), t = Number(S.browserVersion());
679
679
  return e === "Safari" ? t >= 18 : e === "Firefox" ? t >= 134 : !0;
680
680
  }
681
681
  e.isSimulcastSupportedByBrowser = d;
682
682
  function f() {
683
- return Ze || (Ze = (() => {
683
+ return Qe || (Qe = (() => {
684
684
  let e = {
685
685
  Windows: /Win/,
686
686
  Android: /Android/,
@@ -697,41 +697,41 @@ var C;
697
697
  OS2: /OS\/2/,
698
698
  Bot: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/
699
699
  };
700
- for (let t in e) if (Object.hasOwn(e, t) && e[t].test(nt)) return t;
700
+ for (let t in e) if (Object.hasOwn(e, t) && e[t].test(rt)) return t;
701
701
  return "Unknown";
702
- })()), Ze;
702
+ })()), Qe;
703
703
  }
704
704
  e.os = f;
705
705
  function p() {
706
- return Qe;
706
+ return $e;
707
707
  }
708
708
  e.osVersion = p;
709
709
  function m() {
710
- return Xe === null && (Xe = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(et)), Xe;
710
+ return Ze === null && (Ze = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(tt)), Ze;
711
711
  }
712
712
  e.isMobile = m;
713
713
  function ee() {
714
- return rt()[0];
714
+ return it()[0];
715
715
  }
716
716
  e.browserName = ee;
717
717
  function h() {
718
- return rt()[1];
718
+ return it()[1];
719
719
  }
720
720
  e.browserVersion = h;
721
721
  function te() {
722
- return rt()[3];
722
+ return it()[3];
723
723
  }
724
724
  e.baseChromeVersion = te;
725
725
  function ne() {
726
- return rt()[4];
726
+ return it()[4];
727
727
  }
728
728
  e.browserSubVersion = ne;
729
729
  function re() {
730
- return C.baseChromeVersion() >= 105 && !C.isMobile();
730
+ return S.baseChromeVersion() >= 105 && !S.isMobile();
731
731
  }
732
732
  e.isAudioShareSupported = re;
733
- })(C || (C = {}));
734
- var w = C, it = (e) => e.stop(), at = (e) => e.getTracks().forEach(it), ot = (e) => e.getVideoTracks().forEach(it);
733
+ })(S || (S = {}));
734
+ var C = S, at = (e) => e.stop(), w = (e) => e.getTracks().forEach(at), ot = (e) => e.getVideoTracks().forEach(at);
735
735
  async function st(e, t) {
736
736
  try {
737
737
  let n = typeof t.width == "number" ? t.width : void 0, r = typeof t.height == "number" ? t.height : void 0;
@@ -757,7 +757,7 @@ var ct = class {
757
757
  h(this, "_cameraPermissionStatus", void 0), h(this, "_microphonePermissionStatus", void 0), h(this, "_listener", void 0);
758
758
  }
759
759
  static isSupported() {
760
- return w.browserName() !== "Firefox" && "permissions" in navigator && "PermissionStatus" in window;
760
+ return C.browserName() !== "Firefox" && "permissions" in navigator && "PermissionStatus" in window;
761
761
  }
762
762
  async init(e) {
763
763
  try {
@@ -853,7 +853,7 @@ var Lt = class {
853
853
  };
854
854
  let t = T.getMicrophones(), n, r;
855
855
  if (wt && (r = wt.groupId, n = wt.deviceId), typeof e == "string") r = t.find((t) => t.deviceId === e)?.groupId, n = e;
856
- else if (!wt && w.os() === "MacOS" && t.find((e) => e.label.includes("iPhone"))) {
856
+ else if (!wt && C.os() === "MacOS" && t.find((e) => e.label.includes("iPhone"))) {
857
857
  let e = t.find((e) => !e.label.includes("Virtual") && !e.label.includes("iPhone"));
858
858
  e && (r = e.groupId, n = e.deviceId);
859
859
  }
@@ -877,7 +877,7 @@ var Lt = class {
877
877
  };
878
878
  let e = T.getCameras(), a, s;
879
879
  if (Ct && (s = Ct.groupId, a = Ct.deviceId), typeof t == "string") s = e.find((e) => e.deviceId === t)?.groupId, a = t;
880
- else if (!Ct && w.os() === "MacOS" && e.find((e) => e.label.includes("iPhone"))) {
880
+ else if (!Ct && C.os() === "MacOS" && e.find((e) => e.label.includes("iPhone"))) {
881
881
  let t = e.find((e) => !e.label.includes("Virtual") && !e.label.includes("iPhone"));
882
882
  t && (s = t.groupId, a = t.deviceId);
883
883
  }
@@ -906,8 +906,8 @@ var Lt = class {
906
906
  }
907
907
  }, Rt = class extends Lt {
908
908
  constructor(e, t, n, r) {
909
- if (super(!1, !0), h(this, "captureController", void 0), this.captureController = "CaptureController" in window ? new CaptureController() : null, typeof this.video == "object" ? (delete this.video.deviceId, delete this.video.groupId, delete this.video.aspectRatio, delete this.video.frameRate, delete this.video.facingMode, delete this.video.width, delete this.video.height) : this.video = {}, this.video.cursor = "motion", e && (this.video.width = e), t && (this.video.height = t), this.video.frameRate = n, this.video.displaySurface = N.displaySurface, w.browserName() === "Safari") {
910
- let n = Number(w.browserVersion());
909
+ if (super(!1, !0), h(this, "captureController", void 0), this.captureController = "CaptureController" in window ? new CaptureController() : null, typeof this.video == "object" ? (delete this.video.deviceId, delete this.video.groupId, delete this.video.aspectRatio, delete this.video.frameRate, delete this.video.facingMode, delete this.video.width, delete this.video.height) : this.video = {}, this.video.cursor = "motion", e && (this.video.width = e), t && (this.video.height = t), this.video.frameRate = n, this.video.displaySurface = N.displaySurface, C.browserName() === "Safari") {
910
+ let n = Number(C.browserVersion());
911
911
  n === 16 ? (e && (this.video.width = { max: e }), t && (this.video.height = { max: t })) : n === 17 && (delete this.video.width, delete this.video.height);
912
912
  }
913
913
  r && (this.audio = {
@@ -928,7 +928,7 @@ var Lt = class {
928
928
  h(this, "_lockId", Math.round(Math.random() * 99998) + 1);
929
929
  }
930
930
  busy(t = null) {
931
- if (e._lockId) throw t?.log(S.ERROR, "change_device"), z.warn("Device change failed: MediaSource is busy"), Error("MediaSource is busy");
931
+ if (e._lockId) throw t?.log(x.ERROR, "change_device"), z.warn("Device change failed: MediaSource is busy"), Error("MediaSource is busy");
932
932
  e._lockId = this._lockId;
933
933
  }
934
934
  free() {
@@ -989,30 +989,30 @@ async function Wt(e, t, n = z, r = null) {
989
989
  case "SecurityError":
990
990
  case "DOMException":
991
991
  case "NotFoundError":
992
- t = e.isVideoRequested() ? b.CAMERA_PERMISSION : b.MIC_PERMISSION;
992
+ t = e.isVideoRequested() ? y.CAMERA_PERMISSION : y.MIC_PERMISSION;
993
993
  break;
994
994
  case "OverconstrainedError":
995
- t = b.OVERCONSTRAINED;
995
+ t = y.OVERCONSTRAINED;
996
996
  break;
997
997
  case "TypeError":
998
- t = b.UNKNOWN;
998
+ t = y.UNKNOWN;
999
999
  break;
1000
1000
  case "AbortError":
1001
1001
  case "NotReadableError":
1002
- t = e.isVideoRequested() ? b.CAMERA_ACCESS : b.MIC_ACCESS;
1002
+ t = e.isVideoRequested() ? y.CAMERA_ACCESS : y.MIC_ACCESS;
1003
1003
  break;
1004
1004
  case "Error": if (i.message === "MediaSource is busy") {
1005
- t = e.isVideoRequested() ? b.CAMERA_ACCESS : b.MIC_ACCESS;
1005
+ t = e.isVideoRequested() ? y.CAMERA_ACCESS : y.MIC_ACCESS;
1006
1006
  break;
1007
1007
  }
1008
1008
  }
1009
1009
  if (e.canSimplify()) return Wt(e.simplify(), t, n, r);
1010
- let o = t || b.UNKNOWN;
1010
+ let o = t || y.UNKNOWN;
1011
1011
  throw R.onPermissionsError(o, i), o;
1012
1012
  }
1013
1013
  }
1014
1014
  async function Gt(e = z) {
1015
- if (!(jt || w.browserName() !== "Firefox" || !navigator.mediaDevices?.getUserMedia)) try {
1015
+ if (!(jt || C.browserName() !== "Firefox" || !navigator.mediaDevices?.getUserMedia)) try {
1016
1016
  T.hasMicrophonePermission() || R.onPermissionsRequested(), jt = await navigator.mediaDevices.getUserMedia({
1017
1017
  audio: !0,
1018
1018
  video: !1
@@ -1040,9 +1040,9 @@ async function Kt(e, t = z, n = null) {
1040
1040
  switch (e.name) {
1041
1041
  case "PermissionDeniedError":
1042
1042
  case "NotAllowedError":
1043
- case "SecurityError": throw b.SCREEN_PERMISSION;
1043
+ case "SecurityError": throw y.SCREEN_PERMISSION;
1044
1044
  case "AbortError":
1045
- case "NotReadableError": throw b.SCREEN_ACCESS;
1045
+ case "NotReadableError": throw y.SCREEN_ACCESS;
1046
1046
  default: throw e;
1047
1047
  }
1048
1048
  } finally {
@@ -1052,7 +1052,7 @@ async function Kt(e, t = z, n = null) {
1052
1052
  var T;
1053
1053
  (function(e) {
1054
1054
  async function t() {
1055
- await Ht(), await w.initOsVersion(z.warn);
1055
+ await Ht(), await C.initOsVersion(z.warn);
1056
1056
  }
1057
1057
  e.init = t;
1058
1058
  function n() {
@@ -1117,7 +1117,7 @@ var T;
1117
1117
  }
1118
1118
  e.hasPermissions = h;
1119
1119
  function te() {
1120
- jt && (at(jt), jt = null);
1120
+ jt && (w(jt), jt = null);
1121
1121
  }
1122
1122
  e.releaseFirefoxMicrophonePermissionWarmup = te;
1123
1123
  async function ne(e = !1, t = !0, n = !0, r = z, i = null) {
@@ -1155,53 +1155,53 @@ var T;
1155
1155
  return st(n, t);
1156
1156
  }
1157
1157
  e.setResolution = g;
1158
- async function _(e, t) {
1158
+ async function se(e, t) {
1159
1159
  let n = (await Ht()).find((n) => n.kind === e && n.deviceId === t);
1160
1160
  return n ? (e === "videoinput" ? Ct = n : e === "audioinput" ? wt = n : e === "audiooutput" && (Tt = n), ht.set(e, t), n) : null;
1161
1161
  }
1162
- e._saveDeviceId = _;
1163
- function se() {
1162
+ e._saveDeviceId = se;
1163
+ function ce() {
1164
1164
  if (!At || At.readyState === "ended") {
1165
1165
  let e = T.getAudioContext(), t = e.createMediaStreamDestination(), n = e.createGain();
1166
- n.gain.value = 1e-5, n.connect(t), w.browserName() === "Safari" && n.connect(e.destination);
1166
+ n.gain.value = 1e-5, n.connect(t), C.browserName() === "Safari" && n.connect(e.destination);
1167
1167
  let r = e.createOscillator();
1168
1168
  r.type = "sine", r.frequency.value = 0, r.connect(n), r.start(), At = t.stream.getAudioTracks()[0];
1169
1169
  }
1170
1170
  return Object.assign(At.clone(), { enabled: !1 });
1171
1171
  }
1172
- e.getSilentMediaTrack = se;
1173
- function ce(e = N.videoMinWidth, t = N.videoMinHeight) {
1172
+ e.getSilentMediaTrack = ce;
1173
+ function le(e = N.videoMinWidth, t = N.videoMinHeight) {
1174
1174
  kt || (kt = document.createElement("canvas")), kt.width = e, kt.height = t;
1175
1175
  let n = kt.getContext("2d");
1176
1176
  return n.rect(0, 0, e, t), n.fillStyle = "black", n.fill(), (!Ot || Ot.readyState === "ended") && (Ot = kt.captureStream(N.videoFrameRate).getVideoTracks()[0]), Object.assign(Ot.clone(), { enabled: !1 });
1177
1177
  }
1178
- e.getBlackMediaTrack = ce;
1179
- function le(e) {
1178
+ e.getBlackMediaTrack = le;
1179
+ function ue(e) {
1180
1180
  Pt.add(e), Mt && T.getAudioContext();
1181
1181
  }
1182
- e.retainAudioContext = le;
1183
- function ue(e) {
1182
+ e.retainAudioContext = ue;
1183
+ function de(e) {
1184
1184
  Pt.delete(e) && Pt.size === 0 && Mt?.suspend().catch((e) => z.warn("Failed to suspend AudioContext", e));
1185
1185
  }
1186
- e.releaseAudioContext = ue;
1187
- function de() {
1186
+ e.releaseAudioContext = de;
1187
+ function fe() {
1188
1188
  return Mt || (Mt = new (window.AudioContext || window.webkitAudioContext)()), Mt.resume().catch(() => {
1189
1189
  z.warn("Failed to resume AudioContext");
1190
1190
  }), Mt;
1191
1191
  }
1192
- e.getAudioContext = de;
1193
- function fe(e, t) {
1192
+ e.getAudioContext = fe;
1193
+ function pe(e, t) {
1194
1194
  Nt[e] || (Nt[e] = []), Nt[e].push(t);
1195
1195
  }
1196
- e.addEventListener = fe;
1197
- function pe(e, t) {
1196
+ e.addEventListener = pe;
1197
+ function me(e, t) {
1198
1198
  if (Nt[e]) if (!t) delete Nt[e];
1199
1199
  else {
1200
1200
  let n = Nt[e].indexOf(t);
1201
1201
  n > -1 && Nt[e].splice(n, 1);
1202
1202
  }
1203
1203
  }
1204
- e.removeEventListener = pe;
1204
+ e.removeEventListener = me;
1205
1205
  })(T || (T = {}));
1206
1206
  var E = T;
1207
1207
  //#endregion
@@ -1231,7 +1231,7 @@ var O = /* @__PURE__ */ function(e) {
1231
1231
  }
1232
1232
  }, Jt = /* @__PURE__ */ function(e) {
1233
1233
  return e.FpsLimit = "fps-limit", e;
1234
- }({}), Yt = class extends Je {
1234
+ }({}), Yt = class extends Ye {
1235
1235
  constructor(e = z) {
1236
1236
  super(), h(this, "FPS_LIMITS", [
1237
1237
  13,
@@ -1277,15 +1277,15 @@ var O = /* @__PURE__ */ function(e) {
1277
1277
  return e.audio = "audio", e.video = "video", e.screen = "screen", e.audioshare = "audioshare", e;
1278
1278
  }({}), Zt = /* @__PURE__ */ function(e) {
1279
1279
  return e[e.CAMERA = 1] = "CAMERA", e[e.SCREEN = 2] = "SCREEN", e;
1280
- }({}), Qt = class extends Je {
1280
+ }({}), Qt = class extends Ye {
1281
1281
  constructor(e = z, t = null) {
1282
- super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_cameraTrackSetAt", 0), h(this, "_cameraMuteRecoveredAt", 0), h(this, "_micTrackSetAt", 0), h(this, "_micMuteRecoveredAt", 0), h(this, "videoTrackMuteHandler", () => {
1283
- !this._mediaSettings.isVideoEnabled || this._cameraMuteRecoveredAt >= this._cameraTrackSetAt || w.browserName() !== "Safari" || (this._cameraMuteRecoveredAt = Date.now(), this._logger?.log(S.ERROR, "camera_mute_recover"), this._debug.log("[MediaSource] Safari camera mute recovery"), this.toggleVideo(!0).then(() => this._logger?.log(S.ERROR, "camera_mute_recover_success")).catch((e) => {
1284
- this._logger?.log(S.ERROR, "camera_mute_recover_fail"), this._debug.warn("[MediaSource] Camera mute recovery failed", e);
1282
+ super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_screenCaptureRequest", 0), h(this, "_destroyed", !1), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_cameraTrackSetAt", 0), h(this, "_cameraMuteRecoveredAt", 0), h(this, "_micTrackSetAt", 0), h(this, "_micMuteRecoveredAt", 0), h(this, "videoTrackMuteHandler", () => {
1283
+ !this._mediaSettings.isVideoEnabled || this._cameraMuteRecoveredAt >= this._cameraTrackSetAt || C.browserName() !== "Safari" || (this._cameraMuteRecoveredAt = Date.now(), this._logger?.log(x.ERROR, "camera_mute_recover"), this._debug.log("[MediaSource] Safari camera mute recovery"), this.toggleVideo(!0).then(() => this._logger?.log(x.ERROR, "camera_mute_recover_success")).catch((e) => {
1284
+ this._logger?.log(x.ERROR, "camera_mute_recover_fail"), this._debug.warn("[MediaSource] Camera mute recovery failed", e);
1285
1285
  }));
1286
1286
  }), h(this, "micTrackMuteHandler", () => {
1287
- !this._mediaSettings.isAudioEnabled || this._micMuteRecoveredAt >= this._micTrackSetAt || w.browserName() !== "Safari" || (this._micMuteRecoveredAt = Date.now(), this._logger?.log(S.ERROR, "mic_mute_recover"), this._debug.log("[MediaSource] Safari mic mute recovery"), this.toggleAudio(!0).then(() => this._logger?.log(S.ERROR, "mic_mute_recover_success")).catch((e) => {
1288
- this._logger?.log(S.ERROR, "mic_mute_recover_fail"), this._debug.warn("[MediaSource] Mic mute recovery failed", e);
1287
+ !this._mediaSettings.isAudioEnabled || this._micMuteRecoveredAt >= this._micTrackSetAt || C.browserName() !== "Safari" || (this._micMuteRecoveredAt = Date.now(), this._logger?.log(x.ERROR, "mic_mute_recover"), this._debug.log("[MediaSource] Safari mic mute recovery"), this.toggleAudio(!0).then(() => this._logger?.log(x.ERROR, "mic_mute_recover_success")).catch((e) => {
1288
+ this._logger?.log(x.ERROR, "mic_mute_recover_fail"), this._debug.warn("[MediaSource] Mic mute recovery failed", e);
1289
1289
  }));
1290
1290
  }), this._debug = e, this._logger = t, this._initDeviceChangeListener(), N.audioShare && (this._audioShareTrack = this.getSilentAudioShareTrack()), N.enableVideoEffectsFpsDegradation && (this._videoEffectsFpsLimiter = new Yt(this._debug), this._videoEffectsFpsLimiter.addEventListener(Jt.FpsLimit, this.handleVideoEffectsLowFps.bind(this))), E.retainAudioContext(this);
1291
1291
  }
@@ -1293,18 +1293,23 @@ var O = /* @__PURE__ */ function(e) {
1293
1293
  return this._cameraVideoTrack;
1294
1294
  }
1295
1295
  set cameraVideoTrack(e) {
1296
- this._cameraVideoTrack && this._cameraVideoTrack.removeEventListener("mute", this.videoTrackMuteHandler), this._cameraVideoTrack = e, this._cameraVideoTrack && (this._cameraTrackSetAt = Date.now(), this._cameraVideoTrack.addEventListener("mute", this.videoTrackMuteHandler)), N.consumerFastScreenShare && (this._screenShareTrack = this.getBlackScreenShareTrack());
1296
+ this._cameraVideoTrack && this._cameraVideoTrack.removeEventListener("mute", this.videoTrackMuteHandler), this._cameraVideoTrack = e, this._cameraVideoTrack && (this._cameraTrackSetAt = Date.now(), this._cameraVideoTrack.addEventListener("mute", this.videoTrackMuteHandler)), N.consumerFastScreenShare && !this._screenShareTrack && (this._screenShareTrack = this.getBlackScreenShareTrack());
1297
1297
  }
1298
- async request(e = [x.AUDIO], t = !0) {
1299
- if (this._stream) return;
1300
- let n = e.includes(x.VIDEO), r = e.includes(x.AUDIO), i = e.includes(x.ANIMOJI), a = w.getBrowserSupportFailure();
1301
- if (a) throw new k(b.UNSUPPORTED, { callError: {
1298
+ async request(e = [b.AUDIO], t = !0) {
1299
+ if (this._stream || this._destroyed) return;
1300
+ let n = e.includes(b.VIDEO), r = e.includes(b.AUDIO), i = e.includes(b.ANIMOJI), a = C.getBrowserSupportFailure();
1301
+ if (a) throw new k(y.UNSUPPORTED, { callError: {
1302
1302
  scope: "internal",
1303
1303
  code: "environment",
1304
1304
  description: a
1305
1305
  } });
1306
1306
  try {
1307
- this._stream = await E.getUserMedia(n, r, t, this._debug, this._logger), this.cameraVideoTrack?.stop(), this.cameraVideoTrack = this._stream.getVideoTracks()[0], this._micAudioTrack?.stop(), this._setMicAudioTrack(this._stream.getAudioTracks()[0]), this._audioEffectsTrack?.stop(), this._mediaSettings.isVideoEnabled = n && this._stream.getVideoTracks().filter((e) => e.enabled).length > 0 || !1, this._mediaSettings.isAudioEnabled = r && this._stream.getAudioTracks().filter((e) => e.enabled).length > 0 || !1, this._mediaSettings.isAnimojiEnabled = i && !this._mediaSettings.isVideoEnabled || !1, this._animojiEnabled = i, this._triggerEvent("SOURCE_READY");
1307
+ let e = await E.getUserMedia(n, r, t, this._debug, this._logger);
1308
+ if (this._destroyed) {
1309
+ w(e);
1310
+ return;
1311
+ }
1312
+ this._stream = e, this.cameraVideoTrack?.stop(), this.cameraVideoTrack = this._stream.getVideoTracks()[0], this._micAudioTrack?.stop(), this._setMicAudioTrack(this._stream.getAudioTracks()[0]), this._audioEffectsTrack?.stop(), this._mediaSettings.isVideoEnabled = n && this._stream.getVideoTracks().filter((e) => e.enabled).length > 0 || !1, this._mediaSettings.isAudioEnabled = r && this._stream.getAudioTracks().filter((e) => e.enabled).length > 0 || !1, this._mediaSettings.isAnimojiEnabled = i && !this._mediaSettings.isVideoEnabled || !1, this._animojiEnabled = i, this._mediaSettings.isAudioSharingEnabled && this._audioShareTrack && this._stream.addTrack(this._audioShareTrack), this._triggerEvent("SOURCE_READY");
1308
1313
  } catch (e) {
1309
1314
  throw new k(e);
1310
1315
  }
@@ -1338,7 +1343,7 @@ var O = /* @__PURE__ */ function(e) {
1338
1343
  }
1339
1344
  get activeFeatures() {
1340
1345
  let e = [];
1341
- return this._mediaSettings.isAudioEnabled && e.push(Ye.MICROPHONE), this._mediaSettings.isVideoEnabled && e.push(Ye.CAMERA), (this._mediaSettings.isScreenSharingEnabled || this._mediaSettings.isFastScreenSharingEnabled) && e.push(Ye.SCREEN), this._mediaSettings.isAnimojiEnabled && e.push(Ye.ANIMOJI), e;
1346
+ return this._mediaSettings.isAudioEnabled && e.push(Xe.MICROPHONE), this._mediaSettings.isVideoEnabled && e.push(Xe.CAMERA), (this._mediaSettings.isScreenSharingEnabled || this._mediaSettings.isFastScreenSharingEnabled) && e.push(Xe.SCREEN), this._mediaSettings.isAnimojiEnabled && e.push(Xe.ANIMOJI), e;
1342
1347
  }
1343
1348
  async changeDevice(e) {
1344
1349
  switch (e) {
@@ -1348,7 +1353,7 @@ var O = /* @__PURE__ */ function(e) {
1348
1353
  case "audioinput":
1349
1354
  if (this._mediaSettings.isAudioEnabled) return this._changeAudioInput();
1350
1355
  break;
1351
- default: return Promise.reject(b.UNKNOWN);
1356
+ default: return Promise.reject(y.UNKNOWN);
1352
1357
  }
1353
1358
  }
1354
1359
  stopVideoTrack() {
@@ -1373,61 +1378,106 @@ var O = /* @__PURE__ */ function(e) {
1373
1378
  this._onDeviceChange && E.removeEventListener("devicechange", this._onDeviceChange);
1374
1379
  }
1375
1380
  async _changeVideoInput(e) {
1381
+ if (this._destroyed) {
1382
+ e && w(e);
1383
+ return;
1384
+ }
1376
1385
  try {
1377
1386
  let t = e ? "stream" : "video", n = e || await E._getUserVideo(!!this._effect, this._frameRate, this._debug, this._logger);
1378
- if (this.cameraVideoTrack?.stop(), this.cameraVideoTrack = n.getVideoTracks()[0], !this._stream) at(n);
1387
+ if (this._destroyed) {
1388
+ w(n);
1389
+ return;
1390
+ }
1391
+ if (this.cameraVideoTrack?.stop(), this.cameraVideoTrack = n.getVideoTracks()[0], !this._stream) w(n);
1379
1392
  else {
1380
1393
  let e = await this._setEffect(this._effect, this.cameraVideoTrack);
1381
- this._logger?.log(S.DEVICE_CHANGED, t), this._debug.log("Video stream changed"), await this._replaceLocalTrack(e), this._mediaSettings.isVideoEnabled = !0, this._triggerEvent("SOURCE_CHANGED", { kind: "video" });
1394
+ if (this._destroyed) {
1395
+ e.stop();
1396
+ return;
1397
+ }
1398
+ if (this._logger?.log(x.DEVICE_CHANGED, t), this._debug.log("Video stream changed"), await this._replaceLocalTrack(e), this._destroyed) return;
1399
+ this._mediaSettings.isVideoEnabled = !0, this._triggerEvent("SOURCE_CHANGED", { kind: "video" });
1382
1400
  }
1383
1401
  } catch (e) {
1384
- throw this._logger?.log(S.ERROR, "change_video"), this._debug.warn("Camera change failed", e), e;
1402
+ throw this._logger?.log(x.ERROR, "change_video"), this._debug.warn("Camera change failed", e), e;
1385
1403
  }
1386
1404
  }
1387
1405
  async setAudioStream(e) {
1388
1406
  return this._changeAudioInput(e);
1389
1407
  }
1390
1408
  async _changeAudioInput(e = null) {
1409
+ if (this._destroyed) {
1410
+ e && w(e);
1411
+ return;
1412
+ }
1391
1413
  try {
1392
1414
  let t = e || await E.getUserAudio(void 0, this._debug, this._logger);
1393
- if (this._micAudioTrack?.stop(), this._setMicAudioTrack(t.getAudioTracks()[0]), !this._stream) at(t);
1415
+ if (this._destroyed) {
1416
+ w(t);
1417
+ return;
1418
+ }
1419
+ if (this._micAudioTrack?.stop(), this._setMicAudioTrack(t.getAudioTracks()[0]), !this._stream) w(t);
1394
1420
  else {
1395
1421
  let e = await this._applyAudioEffect();
1396
- this._logger?.log(S.DEVICE_CHANGED, "audio"), this._debug.log("Audio stream changed", e), await this._replaceLocalTrack(e), this._mediaSettings.isAudioEnabled = !0, this._triggerEvent("SOURCE_CHANGED", { kind: "audio" });
1422
+ if (this._destroyed) {
1423
+ e?.stop();
1424
+ return;
1425
+ }
1426
+ if (this._logger?.log(x.DEVICE_CHANGED, "audio"), this._debug.log("Audio stream changed", e), await this._replaceLocalTrack(e), this._destroyed) return;
1427
+ this._mediaSettings.isAudioEnabled = !0, this._triggerEvent("SOURCE_CHANGED", { kind: "audio" });
1397
1428
  }
1398
1429
  } catch (e) {
1399
- throw this._logger?.log(S.ERROR, "change_audio"), this._debug.error("Microphone change failed", e), e;
1430
+ throw this._logger?.log(x.ERROR, "change_audio"), this._debug.error("Microphone change failed", e), e;
1400
1431
  }
1401
1432
  }
1402
1433
  async _changeScreen(e, t, n) {
1434
+ let r = ++this._screenCaptureRequest;
1435
+ if (this._destroyed) {
1436
+ n && w(n);
1437
+ return;
1438
+ }
1403
1439
  try {
1404
- if (n = n || await E.getScreenMedia(e, t, this._debug, this._logger), !this._stream) at(n);
1405
- else {
1406
- let r = n.getVideoTracks()[0];
1407
- if (r.addEventListener("ended", () => {
1408
- this._mediaSettings.isScreenSharingEnabled && this.disableScreenCapturing();
1409
- }, !1), this._logger?.log(S.DEVICE_CHANGED, "screen"), this._debug.log("Screen capturing started"), this._screenTrack = r, this._mediaSettings.isScreenSharingEnabled = !0, this._mediaSettings.isFastScreenSharingEnabled = e, N.consumerFastScreenShare && this._mediaSettings.isFastScreenSharingEnabled && (r.contentHint = "motion", this._screenShareTrack = r), n.getAudioTracks().length > 0) {
1410
- let e = n.getAudioTracks()[0];
1411
- e.contentHint = "music", this._audioShareTrack = e, await this._addLocalTrack(e), this._mediaSettings.isAudioSharingEnabled = !0;
1440
+ if (n = n || await E.getScreenMedia(e, t, this._debug, this._logger), r !== this._screenCaptureRequest || this._destroyed) {
1441
+ w(n);
1442
+ return;
1443
+ }
1444
+ let i = n.getVideoTracks()[0];
1445
+ if (!i) throw Error("Screen video track not found");
1446
+ if (this._screenTrack && (await this._disableScreenCapture(), r !== this._screenCaptureRequest || this._destroyed)) {
1447
+ w(n);
1448
+ return;
1449
+ }
1450
+ if (i.addEventListener("ended", () => {
1451
+ this._screenTrack === i && this.disableScreenCapturing();
1452
+ }, !1), this._screenTrack = i, n.getAudioTracks().length > 0) {
1453
+ let e = n.getAudioTracks()[0];
1454
+ e.contentHint = "music";
1455
+ let t = this._audioShareTrack;
1456
+ if (t?.stop(), this._audioShareTrack = e, this._mediaSettings.isAudioSharingEnabled = !0, t ? await this._replaceTrack(t, e) : await this._addLocalTrack(e), r !== this._screenCaptureRequest || this._destroyed) {
1457
+ w(n), this._screenTrack === i && await this._disableScreenCapture();
1458
+ return;
1412
1459
  }
1413
- t && !this._mediaSettings.isAudioSharingEnabled && this._debug.debug("Audio share requested but not captured"), this._triggerEvent("SCREEN_STATUS", { track: r }), this._triggerEvent("SOURCE_CHANGED", { kind: "screen" });
1414
1460
  }
1461
+ this._mediaSettings.isScreenSharingEnabled = !0, this._mediaSettings.isFastScreenSharingEnabled = e, N.consumerFastScreenShare && e && (this._screenShareTrack?.stop(), i.contentHint = "motion", this._screenShareTrack = i), t && !this._mediaSettings.isAudioSharingEnabled && this._debug.debug("Audio share requested but not captured"), this._logger?.log(x.DEVICE_CHANGED, "screen"), this._debug.log("Screen capturing started"), this._triggerEvent("SCREEN_STATUS", { track: i }), this._triggerEvent("SOURCE_CHANGED", { kind: "screen" });
1415
1462
  } catch (e) {
1416
- throw this._logger?.log(S.ERROR, "screen"), this._debug.warn("Screen capturing failed", e), e;
1463
+ throw n && (w(n), this._screenTrack && n.getVideoTracks().includes(this._screenTrack) && await this._disableScreenCapture().catch((e) => this._debug.warn("Screen capture cleanup failed", e))), this._logger?.log(x.ERROR, "screen"), this._debug.warn("Screen capturing failed", e), e;
1417
1464
  }
1418
1465
  }
1419
1466
  async _disableScreenCapture() {
1420
- this._sendVideoTrack && (this._sendVideoTrack.stop(), this._sendVideoTrack = null), this._screenTrack && (this._screenTrack.stop(), this._screenTrack = null), this._screenShareTrack && (this._screenShareTrack.stop(), this._screenShareTrack = this.getBlackScreenShareTrack()), await this.stopAudioShareTrack(), this._mediaSettings.isScreenSharingEnabled && (this._mediaSettings.isScreenSharingEnabled = !1, this._mediaSettings.isFastScreenSharingEnabled = !1, this._triggerEvent("SCREEN_STATUS", { track: null }), this._triggerEvent("SOURCE_CHANGED", { kind: "screen" }));
1467
+ this._sendVideoTrack && (this._sendVideoTrack.stop(), this._sendVideoTrack = null), this._screenTrack && (this._screenTrack.stop(), this._screenTrack = null), this._screenShareTrack && (this._screenShareTrack.stop(), this._screenShareTrack = this.getBlackScreenShareTrack());
1468
+ let e = this.stopAudioShareTrack();
1469
+ this._mediaSettings.isScreenSharingEnabled && (this._mediaSettings.isScreenSharingEnabled = !1, this._mediaSettings.isFastScreenSharingEnabled = !1, this._triggerEvent("SCREEN_STATUS", { track: null }), this._triggerEvent("SOURCE_CHANGED", { kind: "screen" })), await e;
1421
1470
  }
1422
1471
  async stopAudioShareTrack() {
1423
1472
  if (this._audioShareTrack) {
1424
- let e = this.getSilentAudioShareTrack();
1425
- await this._replaceTrack(this._audioShareTrack, e), this._mediaSettings.isAudioSharingEnabled = !1;
1473
+ let e = this._audioShareTrack, t = this.getSilentAudioShareTrack();
1474
+ e.stop(), this._audioShareTrack = t, this._mediaSettings.isAudioSharingEnabled = !1, await this._replaceTrack(e, t);
1426
1475
  }
1427
1476
  }
1428
1477
  async _applyAudioEffect() {
1429
1478
  if (!N.audioEffects || !this._audioEffectParams) return N.audioEffects?.pause(), this._micAudioTrack;
1430
- N.audioEffects.isInitialized || await N.audioEffects.init(), N.audioEffects.resume(), N.audioEffects.setEffects(this._audioEffectParams.effects, this._audioEffectParams.isPreset), N.audioEffects.setSource(this._micAudioTrack);
1479
+ if (N.audioEffects.isInitialized || await N.audioEffects.init(), this._destroyed) return this._micAudioTrack;
1480
+ N.audioEffects.resume(), N.audioEffects.setEffects(this._audioEffectParams.effects, this._audioEffectParams.isPreset), N.audioEffects.setSource(this._micAudioTrack);
1431
1481
  let e = N.audioEffects.outputStream.getAudioTracks()[0];
1432
1482
  return (!this._audioEffectsTrack || this._audioEffectsTrack.id !== e.id) && (this._audioEffectsTrack = e), this._audioEffectsTrack;
1433
1483
  }
@@ -1440,14 +1490,26 @@ var O = /* @__PURE__ */ function(e) {
1440
1490
  return e.contentHint = "motion", e.stop(), e;
1441
1491
  }
1442
1492
  async _replaceLocalTrack(e, t) {
1493
+ if (this._destroyed) {
1494
+ e.stop(), t?.stop();
1495
+ return;
1496
+ }
1443
1497
  if (!this._stream) return;
1444
1498
  let n = this._stream.getTracks().filter((t) => t.kind === e.kind), r = n.find((t) => t.contentHint === e.contentHint) ?? n.find((e) => e !== this._audioEffectsTrack);
1445
1499
  r?.id !== e.id && (r ? await this._replaceTrack(r, e, t) : await this._addLocalTrack(e, t));
1446
1500
  }
1447
1501
  async _replaceTrack(e, t, n) {
1502
+ if (this._destroyed) {
1503
+ t.stop(), n?.stop();
1504
+ return;
1505
+ }
1448
1506
  this._stream && (e !== this._audioEffectsTrack && e.stop(), this._stream.removeTrack(e), this._stream.addTrack(t), this._triggerEvent("TRACK_REPLACED", t, n));
1449
1507
  }
1450
1508
  async _addLocalTrack(e, t) {
1509
+ if (this._destroyed) {
1510
+ e.stop(), t?.stop();
1511
+ return;
1512
+ }
1451
1513
  this._stream && (this._stream.addTrack(e), this._triggerEvent("TRACK_REPLACED", e, t));
1452
1514
  }
1453
1515
  async _setEffect(e, t) {
@@ -1466,22 +1528,22 @@ var O = /* @__PURE__ */ function(e) {
1466
1528
  }
1467
1529
  }
1468
1530
  destroy() {
1469
- this._destroyDeviceChangeListener(), E.releaseFirefoxMicrophonePermissionWarmup(), N.videoEffects && (this._effect = null, N.videoEffects.destroy()), N.audioEffects && N.audioEffects.destroy(), this._stream && (at(this._stream), this._stream = null), this.cameraVideoTrack?.stop(), this._micAudioTrack?.stop(), this._audioEffectsTrack?.stop(), this._disableScreenCapture(), E.releaseAudioContext(this), this._videoEffectsFpsLimiter?.destroy();
1531
+ this._destroyed || (this._destroyed = !0, this._screenCaptureRequest++, this._destroyDeviceChangeListener(), E.releaseFirefoxMicrophonePermissionWarmup(), N.videoEffects && (this._effect = null, N.videoEffects.destroy()), N.audioEffects && N.audioEffects.destroy(), this._stream && (w(this._stream), this._stream = null), this.cameraVideoTrack?.stop(), this._micAudioTrack?.stop(), this._audioEffectsTrack?.stop(), this._disableScreenCapture(), E.releaseAudioContext(this), this._videoEffectsFpsLimiter?.destroy());
1470
1532
  }
1471
1533
  async stopLocalMedia() {
1472
- this._mediaSettings.isScreenSharingEnabled && await this.disableScreenCapturing(), this._stream && (this._lastMediaSettings = { ...this._mediaSettings }, this._stream.getAudioTracks().length > 0 && await this.toggleAudio(!1), this._stream.getVideoTracks().length > 0 && await this.toggleVideo(!1), this.cameraVideoTrack = null, this._setMicAudioTrack(null));
1534
+ this._screenCaptureRequest++, (this._screenTrack || this._mediaSettings.isScreenSharingEnabled) && await this.disableScreenCapturing(), this._stream && (this._lastMediaSettings ?? (this._lastMediaSettings = { ...this._mediaSettings }), this._stream.getAudioTracks().length > 0 && await this.toggleAudio(!1), this._stream.getVideoTracks().length > 0 && await this.toggleVideo(!1), this.cameraVideoTrack = null, this._setMicAudioTrack(null));
1473
1535
  }
1474
1536
  async resumeLocalMedia(e) {
1475
1537
  if (!this._lastMediaSettings) return;
1476
1538
  let t = [];
1477
- if ((e ? e.isAudioEnabled : this._lastMediaSettings.isAudioEnabled) && (t.push(x.AUDIO), await this.toggleAudio(!0)), await this.request(t), this._lastMediaSettings = null, this._stream) for (let e of this._stream.getTracks()) this._triggerEvent("TRACK_REPLACED", e);
1539
+ if ((e ? e.isAudioEnabled : this._lastMediaSettings.isAudioEnabled) && (t.push(b.AUDIO), await this.toggleAudio(!0)), await this.request(t), this._lastMediaSettings = null, this._stream) for (let e of this._stream.getTracks()) this._triggerEvent("TRACK_REPLACED", e);
1478
1540
  }
1479
1541
  async toggleScreenCapturing(e) {
1480
1542
  if (e.captureScreen) {
1481
1543
  await this._changeScreen(e.fastScreenSharing, e.captureAudio);
1482
1544
  return;
1483
1545
  }
1484
- return this._disableScreenCapture();
1546
+ return this._screenCaptureRequest++, this._disableScreenCapture();
1485
1547
  }
1486
1548
  async disableScreenCapturing() {
1487
1549
  return this.toggleScreenCapturing({
@@ -1491,30 +1553,44 @@ var O = /* @__PURE__ */ function(e) {
1491
1553
  });
1492
1554
  }
1493
1555
  async toggleVideo(e) {
1494
- if (!this._stream) return;
1556
+ if (this._destroyed || !this._stream) return;
1495
1557
  this.cameraVideoTrack?.stop();
1496
1558
  let t;
1497
1559
  if (e) {
1498
1560
  let e = await E._getUserVideo(!!this._effect, this._frameRate, this._debug, this._logger);
1561
+ if (this._destroyed) {
1562
+ w(e);
1563
+ return;
1564
+ }
1499
1565
  this.cameraVideoTrack = e.getVideoTracks()[0], t = await this._setEffect(this._effect, this.cameraVideoTrack);
1500
1566
  } else t = E.getBlackMediaTrack(N.videoMinWidth, N.videoMinHeight), this._stopEffect();
1501
- if (this._mediaSettings.isVideoEnabled = e, await this._replaceLocalTrack(t), this._animojiEnabled) {
1502
- this._triggerEvent("ANIMOJI_STATUS", !e);
1567
+ if (this._destroyed) {
1568
+ t.stop();
1503
1569
  return;
1504
1570
  }
1505
- this._triggerEvent("SOURCE_CHANGED", { kind: "video" });
1571
+ if (this._mediaSettings.isVideoEnabled = e, await this._replaceLocalTrack(t), !this._destroyed) {
1572
+ if (this._animojiEnabled) {
1573
+ this._triggerEvent("ANIMOJI_STATUS", !e);
1574
+ return;
1575
+ }
1576
+ this._triggerEvent("SOURCE_CHANGED", { kind: "video" });
1577
+ }
1506
1578
  }
1507
1579
  async toggleAudio(e) {
1508
- if (!this._stream) return;
1580
+ if (this._destroyed || !this._stream) return;
1509
1581
  this._micAudioTrack?.stop();
1510
1582
  let t = async (e, t) => {
1511
- await this._replaceLocalTrack(e), this._mediaSettings.isAudioEnabled = t, this._triggerEvent("SOURCE_CHANGED", { kind: "audio" });
1583
+ await this._replaceLocalTrack(e), !this._destroyed && (this._mediaSettings.isAudioEnabled = t, this._triggerEvent("SOURCE_CHANGED", { kind: "audio" }));
1512
1584
  };
1513
1585
  if (e) try {
1514
1586
  let e = await E.getUserAudio(void 0, this._debug, this._logger);
1587
+ if (this._destroyed) {
1588
+ w(e);
1589
+ return;
1590
+ }
1515
1591
  this._setMicAudioTrack(e.getAudioTracks()[0]), await t(await this._applyAudioEffect(), !0);
1516
1592
  } catch (e) {
1517
- throw N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e;
1593
+ throw this._destroyed ? e : (N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e);
1518
1594
  }
1519
1595
  else N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1);
1520
1596
  }
@@ -1541,40 +1617,46 @@ var O = /* @__PURE__ */ function(e) {
1541
1617
  if (e.enabled) return e.applyConstraints({ noiseSuppression: N.noiseSuppression });
1542
1618
  }
1543
1619
  async videoEffect(e) {
1544
- if (!N.videoEffects) throw Error("Video Effects library is not set");
1545
- if (this._logger?.log(S.DEVICE_CHANGED, `effect_${e?.effect || "none"}`), !this._mediaSettings.isVideoEnabled) {
1546
- this._effect = e;
1547
- return;
1548
- }
1549
- if (this._stream && e !== this._effect && this.cameraVideoTrack) {
1550
- let t = this._effect;
1551
- this._effect = e;
1552
- try {
1553
- let e = this.cameraVideoTrack.clone(), t = new MediaStream([e]);
1554
- await this._applyVideoConstraints(e), await this._changeVideoInput(t);
1555
- } catch (e) {
1556
- this._effect = t;
1620
+ if (!this._destroyed) {
1621
+ if (!N.videoEffects) throw Error("Video Effects library is not set");
1622
+ if (this._logger?.log(x.DEVICE_CHANGED, `effect_${e?.effect || "none"}`), !this._mediaSettings.isVideoEnabled) {
1623
+ this._effect = e;
1624
+ return;
1625
+ }
1626
+ if (this._stream && e !== this._effect && this.cameraVideoTrack) {
1627
+ let t = this._effect;
1628
+ this._effect = e;
1557
1629
  let n = this.cameraVideoTrack.clone(), r = new MediaStream([n]);
1558
- throw await this._changeVideoInput(r), e;
1630
+ try {
1631
+ await this._applyVideoConstraints(n), await this._changeVideoInput(r);
1632
+ } catch (e) {
1633
+ if (this._destroyed) throw w(r), e;
1634
+ this._effect = t;
1635
+ let n = this.cameraVideoTrack.clone(), i = new MediaStream([n]);
1636
+ throw await this._changeVideoInput(i), e;
1637
+ }
1559
1638
  }
1560
1639
  }
1561
1640
  }
1562
1641
  async audioEffect(e) {
1563
- if (!N.audioEffects) throw Error("Audio Effects library is not set");
1564
- if (!this._mediaSettings.isAudioEnabled) {
1565
- this._audioEffectParams = e;
1566
- return;
1567
- }
1568
- if (this._stream && (!e && this._audioEffectParams || e && !this._audioEffectParams || !M.isArraysEquals(e?.effects || [], this._audioEffectParams?.effects || [])) && this._micAudioTrack) {
1569
- let t = this._audioEffectParams;
1570
- this._audioEffectParams = e;
1571
- try {
1572
- let e = this._micAudioTrack.clone(), t = new MediaStream([e]);
1573
- await this._changeAudioInput(t);
1574
- } catch (e) {
1575
- this._audioEffectParams = t;
1576
- let n = this._micAudioTrack.clone(), r = new MediaStream([n]);
1577
- throw await this._changeAudioInput(r), e;
1642
+ if (!this._destroyed) {
1643
+ if (!N.audioEffects) throw Error("Audio Effects library is not set");
1644
+ if (!this._mediaSettings.isAudioEnabled) {
1645
+ this._audioEffectParams = e;
1646
+ return;
1647
+ }
1648
+ if (this._stream && (!e && this._audioEffectParams || e && !this._audioEffectParams || !M.isArraysEquals(e?.effects || [], this._audioEffectParams?.effects || [])) && this._micAudioTrack) {
1649
+ let t = this._audioEffectParams;
1650
+ this._audioEffectParams = e;
1651
+ try {
1652
+ let e = this._micAudioTrack.clone(), t = new MediaStream([e]);
1653
+ await this._changeAudioInput(t);
1654
+ } catch (e) {
1655
+ if (this._destroyed) throw e;
1656
+ this._audioEffectParams = t;
1657
+ let n = this._micAudioTrack.clone(), r = new MediaStream([n]);
1658
+ throw await this._changeAudioInput(r), e;
1659
+ }
1578
1660
  }
1579
1661
  }
1580
1662
  }
@@ -1893,15 +1975,15 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1893
1975
  if (e.decorativeUserId) return ie(e.decorativeUserId, e.idType || j.USER, e.deviceIdx);
1894
1976
  }
1895
1977
  e.composeDecorativeId = g;
1896
- function _(e) {
1897
- return e.participant ? oe(e.participant) : ie(e.participantId, e.participantType || j.USER, e.deviceIdx);
1898
- }
1899
- e.composeMessageId = _;
1900
1978
  function se(e) {
1901
- return typeof e == "string" ? ce(le(e).compositeUserId).id : e;
1979
+ return e.participant ? oe(e.participant) : ie(e.participantId, e.participantType || j.USER, e.deviceIdx);
1902
1980
  }
1903
- e.extractOkId = se;
1981
+ e.composeMessageId = se;
1904
1982
  function ce(e) {
1983
+ return typeof e == "string" ? le(ue(e).compositeUserId).id : e;
1984
+ }
1985
+ e.extractOkId = ce;
1986
+ function le(e) {
1905
1987
  let t = String(e), n = t.match(ne);
1906
1988
  return n ? {
1907
1989
  id: Number(n[2]),
@@ -1911,24 +1993,24 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1911
1993
  type: j.USER
1912
1994
  });
1913
1995
  }
1914
- e.decomposeId = ce;
1915
- function le(e) {
1996
+ e.decomposeId = le;
1997
+ function ue(e) {
1916
1998
  let t = e.split(":d");
1917
1999
  return {
1918
2000
  compositeUserId: t[0],
1919
2001
  deviceIdx: t.length > 1 ? parseInt(t[1], 10) : 0
1920
2002
  };
1921
2003
  }
1922
- e.decomposeParticipantId = le;
1923
- function ue() {
2004
+ e.decomposeParticipantId = ue;
2005
+ function de() {
1924
2006
  let e = window.crypto?.randomUUID?.();
1925
2007
  if (e) return e;
1926
2008
  let t = "0123456789abcdefghijklmnopqrstuvwxyz".split(""), n = Array(36), r = 0, i, a;
1927
2009
  for (a = 0; a < 36; a++) a === 8 || a === 13 || a === 18 || a === 23 ? n[a] = "-" : a === 14 ? n[a] = "4" : (r <= 2 && (r = 33554432 + Math.random() * 16777216 | 0), i = r & 15, r >>= 4, n[a] = t[a === 19 ? i & 3 | 8 : i]);
1928
2010
  return n.join("");
1929
2011
  }
1930
- e.uuid = ue;
1931
- function de(e, t) {
2012
+ e.uuid = de;
2013
+ function fe(e, t) {
1932
2014
  let n;
1933
2015
  function r(...r) {
1934
2016
  let i = this;
@@ -1938,8 +2020,8 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1938
2020
  }
1939
2021
  return r;
1940
2022
  }
1941
- e.debounce = de;
1942
- function fe(e) {
2023
+ e.debounce = fe;
2024
+ function pe(e) {
1943
2025
  if (!window.BigInt) return null;
1944
2026
  let t = "", n = mn(e);
1945
2027
  for (let e of n) if (e.startsWith("a=fingerprint")) {
@@ -1957,8 +2039,8 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1957
2039
  }
1958
2040
  return BigInt.asIntN(64, i);
1959
2041
  }
1960
- e.sdpFingerprint = fe;
1961
- async function pe(e, { signal: t } = {}) {
2042
+ e.sdpFingerprint = pe;
2043
+ async function me(e, { signal: t } = {}) {
1962
2044
  return new Promise((n, r) => {
1963
2045
  if (t?.aborted) return r(t.reason);
1964
2046
  let i = setTimeout(() => {
@@ -1969,13 +2051,13 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1969
2051
  t?.addEventListener("abort", a, { once: !0 });
1970
2052
  });
1971
2053
  }
1972
- e.delay = pe;
1973
- function me(e, t, n, r = z) {
2054
+ e.delay = me;
2055
+ function he(e, t, n, r = z) {
1974
2056
  let i = [];
1975
- return e.getSenders().forEach((e) => he(t, e, e.track, n, i, r)), i;
2057
+ return e.getSenders().forEach((e) => ge(t, e, e.track, n, i, r)), i;
1976
2058
  }
1977
- e.applySettings = me;
1978
- function he(e, t, n, r, i, a = z) {
2059
+ e.applySettings = he;
2060
+ function ge(e, t, n, r, i, a = z) {
1979
2061
  if (!RTCRtpSender.prototype.getParameters || !RTCRtpSender.prototype.setParameters || !e || !n || n.kind !== A.video) return;
1980
2062
  let o = n.getSettings();
1981
2063
  if (!o) return;
@@ -2009,21 +2091,21 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2009
2091
  a.error("Failed to set sender parameters", m, e);
2010
2092
  });
2011
2093
  }
2012
- e.applyVideoTrackSettings = he;
2013
- function ge(e, t) {
2094
+ e.applyVideoTrackSettings = ge;
2095
+ function _e(e, t) {
2014
2096
  Array.isArray(t) || (t = [t]);
2015
2097
  for (let n of t) if (e.includes(n)) return !0;
2016
2098
  return !1;
2017
2099
  }
2018
- e.includesOneOf = ge;
2019
- function v(e) {
2100
+ e.includesOneOf = _e;
2101
+ function _(e) {
2020
2102
  return Object.entries(e.participantState?.state || {}).reduce((t, [n, r]) => (e.participantState && (t[n] = {
2021
2103
  ts: e.participantState.stateUpdateTs[n],
2022
2104
  state: r
2023
2105
  }), t), {});
2024
2106
  }
2025
- e.mapParticipantState = v;
2026
- function _e(e) {
2107
+ e.mapParticipantState = _;
2108
+ function ve(e) {
2027
2109
  let t = e.map((e) => ({
2028
2110
  uid: e.externalId,
2029
2111
  mediaSettings: e.mediaSettings,
@@ -2037,37 +2119,37 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2037
2119
  }));
2038
2120
  return N.filterObservers ? t.filter((e) => !e.uid.observer) : t;
2039
2121
  }
2040
- e.mapSharedParticipants = _e;
2041
- function ve(e, t) {
2122
+ e.mapSharedParticipants = ve;
2123
+ function ye(e, t) {
2042
2124
  let n = Object.keys(e), r = Object.keys(t);
2043
2125
  if (n.length !== r.length) return !1;
2044
2126
  for (let i of n) if (!Object.hasOwn(r, i) || e[i].state !== t[i].state || e[i].ts !== t[i].ts) return !1;
2045
2127
  return !0;
2046
2128
  }
2047
- e.isEqualParticipantState = ve;
2048
- function ye(e, t, n = !1) {
2129
+ e.isEqualParticipantState = ye;
2130
+ function be(e, t, n = !1) {
2049
2131
  let r = Object.keys(e), i = Object.keys(t);
2050
2132
  if (r.length !== i.length) return !1;
2051
2133
  for (let i of r) {
2052
2134
  if (!Object.hasOwn(t, i)) return !1;
2053
2135
  let r = e[i], a = t[i];
2054
- if (n && Te(r) && Te(a)) return ye(r, a, n);
2136
+ if (n && Ee(r) && Ee(a)) return be(r, a, n);
2055
2137
  if (r !== a) return !1;
2056
2138
  }
2057
2139
  return !0;
2058
2140
  }
2059
- e.isObjectsEquals = ye;
2060
- function be(e, t) {
2141
+ e.isObjectsEquals = be;
2142
+ function xe(e, t) {
2061
2143
  if (e.length !== t.length) return !1;
2062
2144
  for (let n of e) if (t.indexOf(n) < 0) return !1;
2063
2145
  return !0;
2064
2146
  }
2065
- e.isArraysEquals = be;
2066
- function xe(e) {
2147
+ e.isArraysEquals = xe;
2148
+ function Se(e) {
2067
2149
  return !Object.keys(e).length;
2068
2150
  }
2069
- e.isEmptyObject = xe;
2070
- function Se(e, t) {
2151
+ e.isEmptyObject = Se;
2152
+ function Ce(e, t) {
2071
2153
  if (!e && !t) return 0;
2072
2154
  if (!e || !t) return e ? -1 : 1;
2073
2155
  return r(t.rank, e.rank) || r(e.ts, t.ts) || n(e, t);
@@ -2075,24 +2157,24 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2075
2157
  let n = {
2076
2158
  [j.USER]: 0,
2077
2159
  [j.GROUP]: 1
2078
- }, { compositeUserId: i, deviceIdx: a } = le(e.id), { compositeUserId: o, deviceIdx: s } = le(t.id), { id: c, type: l } = ce(i), { id: u, type: d } = ce(o);
2160
+ }, { compositeUserId: i, deviceIdx: a } = ue(e.id), { compositeUserId: o, deviceIdx: s } = ue(t.id), { id: c, type: l } = le(i), { id: u, type: d } = le(o);
2079
2161
  return r(n[l], n[d]) || r(c, u) || r(a, s);
2080
2162
  }
2081
2163
  function r(e, t) {
2082
2164
  return e < t ? -1 : e === t ? 0 : 1;
2083
2165
  }
2084
2166
  }
2085
- e.participantMarkerCompare = Se;
2086
- function Ce(e, t) {
2167
+ e.participantMarkerCompare = Ce;
2168
+ function we(e, t) {
2087
2169
  return dn(Object.entries(e).filter(([, e]) => Array.isArray(t) ? !t.includes(e) : e !== t));
2088
2170
  }
2089
- e.objectFilterOutValues = Ce;
2090
- function we(e, t, n) {
2171
+ e.objectFilterOutValues = we;
2172
+ function Te(e, t, n) {
2091
2173
  let r = n;
2092
2174
  for (let n in e) Object.hasOwn(e, n) && (r = t(r, e[n], n));
2093
2175
  return r;
2094
2176
  }
2095
- e.objectReduce = we, e.setImmediate = (() => {
2177
+ e.objectReduce = Te, e.setImmediate = (() => {
2096
2178
  let e = 1, t = {}, n = null;
2097
2179
  return typeof MessageChannel < "u" && (n = new MessageChannel(), n.port1.onmessage = (e) => {
2098
2180
  let n = e.data;
@@ -2108,10 +2190,10 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2108
2190
  return () => clearTimeout(i);
2109
2191
  };
2110
2192
  })();
2111
- function Te(e) {
2193
+ function Ee(e) {
2112
2194
  return typeof e == "object" && !!e && !Array.isArray(e);
2113
2195
  }
2114
- e.isObject = Te;
2196
+ e.isObject = Ee;
2115
2197
  })(yn || (yn = {}));
2116
2198
  var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2117
2199
  set(e, t) {
@@ -2200,7 +2282,7 @@ var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2200
2282
  h(Cn, "instance", null);
2201
2283
  var wn = Cn.getInstance(), N = class e {
2202
2284
  static set(t) {
2203
- Object.hasOwn(t, "voiceParams") && (Object.assign(e._params.voiceParams, t.voiceParams), delete t.voiceParams), Object.hasOwn(t, "specListenerParams") && (Object.assign(e._params.specListenerParams, t.specListenerParams), delete t.specListenerParams), Object.hasOwn(t, "apiAuth") && (y.accessToken = t.apiAuth.accessToken, y.sessionKey = t.apiAuth.sessionKey, y.sessionSecretKey = t.apiAuth.sessionSecretKey, y.selfExternalId = null);
2285
+ Object.hasOwn(t, "voiceParams") && (Object.assign(e._params.voiceParams, t.voiceParams), delete t.voiceParams), Object.hasOwn(t, "specListenerParams") && (Object.assign(e._params.specListenerParams, t.specListenerParams), delete t.specListenerParams), Object.hasOwn(t, "apiAuth") && (v.accessToken = t.apiAuth.accessToken, v.sessionKey = t.apiAuth.sessionKey, v.sessionSecretKey = t.apiAuth.sessionSecretKey, v.selfExternalId = null);
2204
2286
  let n = wn.params.applyOverrides(t);
2205
2287
  Object.assign(e._params, M.objectFilterOutValues(n, void 0));
2206
2288
  }
@@ -2220,7 +2302,7 @@ var wn = Cn.getInstance(), N = class e {
2220
2302
  return 1.1;
2221
2303
  }
2222
2304
  static get sdkVersion() {
2223
- return "2.8.13-beta.11";
2305
+ return "2.8.13-beta.12";
2224
2306
  }
2225
2307
  static get debug() {
2226
2308
  return e._params.debug;
@@ -2400,7 +2482,7 @@ var wn = Cn.getInstance(), N = class e {
2400
2482
  return e._params.videoFrameRate;
2401
2483
  }
2402
2484
  static get videoFacingMode() {
2403
- return e._params.videoFacingMode || (w.isMobile() ? It.USER : null);
2485
+ return e._params.videoFacingMode || (C.isMobile() ? It.USER : null);
2404
2486
  }
2405
2487
  static set videoFacingMode(t) {
2406
2488
  e._params.videoFacingMode = t;
@@ -2568,7 +2650,7 @@ var wn = Cn.getInstance(), N = class e {
2568
2650
  return e._params.preserveAudioTracks;
2569
2651
  }
2570
2652
  static get audioShare() {
2571
- return w.isAudioShareSupported() && e._params.audioShare;
2653
+ return C.isAudioShareSupported() && e._params.audioShare;
2572
2654
  }
2573
2655
  static get audioShareWindowInclude() {
2574
2656
  return e._params.audioShareWindowInclude;
@@ -2610,7 +2692,7 @@ var wn = Cn.getInstance(), N = class e {
2610
2692
  return e._params.enableVideoEffectsFpsDegradation;
2611
2693
  }
2612
2694
  static get simulcast() {
2613
- return w.isSimulcastSupportedByBrowser() && e._params.simulcast;
2695
+ return C.isSimulcastSupportedByBrowser() && e._params.simulcast;
2614
2696
  }
2615
2697
  static get webtransport() {
2616
2698
  return e._params.webtransport;
@@ -2912,164 +2994,164 @@ var En;
2912
2994
  I("onRemoteSharedUrl", e, t, n, r);
2913
2995
  }
2914
2996
  e.onRemoteSharedUrl = g;
2915
- function _(e, t, n) {
2997
+ function se(e, t, n) {
2916
2998
  I("onParticipantAdded", e, t, n);
2917
2999
  }
2918
- e.onParticipantAdded = _;
2919
- function se(e, t, n) {
3000
+ e.onParticipantAdded = se;
3001
+ function ce(e, t, n) {
2920
3002
  I("onParticipantJoined", e, t, n);
2921
3003
  }
2922
- e.onParticipantJoined = se;
2923
- function ce(e, t = !1, n) {
3004
+ e.onParticipantJoined = ce;
3005
+ function le(e, t = !1, n) {
2924
3006
  F("onLocalParticipantState", L(e), t, n);
2925
3007
  }
2926
- e.onLocalParticipantState = ce;
2927
- function le(e, t, n, r) {
3008
+ e.onLocalParticipantState = le;
3009
+ function ue(e, t, n, r) {
2928
3010
  I("onRemoteParticipantState", e, L(t), n, r);
2929
3011
  }
2930
- e.onRemoteParticipantState = le;
2931
- function ue(e, t, n) {
3012
+ e.onRemoteParticipantState = ue;
3013
+ function de(e, t, n) {
2932
3014
  F("onRemoteParticipantsState", e, t, n);
2933
3015
  }
2934
- e.onRemoteParticipantsState = ue;
2935
- function de(e, t, n = null, r) {
3016
+ e.onRemoteParticipantsState = de;
3017
+ function fe(e, t, n = null, r) {
2936
3018
  z.debug("Remote status:", t, e), I("onRemoteStatus", e, t, n, r);
2937
3019
  }
2938
- e.onRemoteStatus = de;
2939
- function fe() {
3020
+ e.onRemoteStatus = fe;
3021
+ function pe() {
2940
3022
  F("onPermissionsRequested");
2941
3023
  }
2942
- e.onPermissionsRequested = fe;
2943
- function pe(e, t) {
3024
+ e.onPermissionsRequested = pe;
3025
+ function me(e, t) {
2944
3026
  F("onPermissionsError", e, t);
2945
3027
  }
2946
- e.onPermissionsError = pe;
2947
- function me(e, t, n) {
3028
+ e.onPermissionsError = me;
3029
+ function he(e, t, n) {
2948
3030
  I("onRemoteRemoved", e, t, n);
2949
3031
  }
2950
- e.onRemoteRemoved = me;
2951
- function he(e, t, n, r) {
3032
+ e.onRemoteRemoved = he;
3033
+ function ge(e, t, n, r) {
2952
3034
  F("onCallState", e, t, L(n), r);
2953
3035
  }
2954
- e.onCallState = he;
2955
- function ge(e, t, n) {
3036
+ e.onCallState = ge;
3037
+ function _e(e, t, n) {
2956
3038
  F("onDeviceSwitched", e, t, n);
2957
3039
  }
2958
- e.onDeviceSwitched = ge;
2959
- function v(e, t, n, r = !1, i = !1, a = null, o = null, s, c, l = null, u) {
3040
+ e.onDeviceSwitched = _e;
3041
+ function _(e, t, n, r = !1, i = !1, a = null, o = null, s, c, l = null, u) {
2960
3042
  let d = c ? Tn(c) : void 0;
2961
3043
  F("onMuteStates", L(e), Tn(t), Tn(n), r, i, a, o, s, d, l, u);
2962
3044
  }
2963
- e.onMuteStates = v;
2964
- function _e(e, t, n = !1, r) {
3045
+ e.onMuteStates = _;
3046
+ function ve(e, t, n = !1, r) {
2965
3047
  I("onRolesChanged", e, Tn(t), n, r);
2966
3048
  }
2967
- e.onRolesChanged = _e;
2968
- function ve(e, t = !1, n) {
3049
+ e.onRolesChanged = ve;
3050
+ function ye(e, t = !1, n) {
2969
3051
  F("onLocalRolesChanged", Tn(e), t, n);
2970
3052
  }
2971
- e.onLocalRolesChanged = ve;
2972
- function ye(e, t, n, r, i) {
3053
+ e.onLocalRolesChanged = ye;
3054
+ function be(e, t, n, r, i) {
2973
3055
  I("onPinnedParticipant", e, t, n, r, i);
2974
3056
  }
2975
- e.onPinnedParticipant = ye;
2976
- function be(e, t, n) {
3057
+ e.onPinnedParticipant = be;
3058
+ function xe(e, t, n) {
2977
3059
  F("onLocalPin", e, t, n);
2978
3060
  }
2979
- e.onLocalPin = be;
2980
- function xe(e, t) {
3061
+ e.onLocalPin = xe;
3062
+ function Se(e, t) {
2981
3063
  F("onOptionsChanged", Tn(e), t);
2982
3064
  }
2983
- e.onOptionsChanged = xe;
2984
- function Se(e) {
3065
+ e.onOptionsChanged = Se;
3066
+ function Ce(e) {
2985
3067
  F("onCallAccepted", e);
2986
3068
  }
2987
- e.onCallAccepted = Se;
2988
- function Ce(e) {
3069
+ e.onCallAccepted = Ce;
3070
+ function we(e) {
2989
3071
  F("onCallActive", e);
2990
3072
  }
2991
- e.onCallActive = Ce;
2992
- function we(e, t, n) {
3073
+ e.onCallActive = we;
3074
+ function Te(e, t, n) {
2993
3075
  I("onAcceptedCall", e, t, n);
2994
3076
  }
2995
- e.onAcceptedCall = we;
2996
- function Te(e) {
3077
+ e.onAcceptedCall = Te;
3078
+ function Ee(e) {
2997
3079
  F("onRateNeeded", e);
2998
3080
  }
2999
- e.onRateNeeded = Te;
3000
- function Ee(e, t) {
3081
+ e.onRateNeeded = Ee;
3082
+ function De(e, t) {
3001
3083
  I("onSpeakerChanged", e, t);
3002
3084
  }
3003
- e.onSpeakerChanged = Ee;
3004
- function De(e, t) {
3085
+ e.onSpeakerChanged = De;
3086
+ function Oe(e, t) {
3005
3087
  F("onVolumesDetected", Tn(e), t);
3006
3088
  }
3007
- e.onVolumesDetected = De;
3008
- function Oe(e, t) {
3089
+ e.onVolumesDetected = Oe;
3090
+ function ke(e, t) {
3009
3091
  F("onLocalVolume", e, t);
3010
3092
  }
3011
- e.onLocalVolume = Oe;
3012
- function ke(e, t, n) {
3093
+ e.onLocalVolume = ke;
3094
+ function Ae(e, t, n) {
3013
3095
  F("onJoinStatus", e, t, n);
3014
3096
  }
3015
- e.onJoinStatus = ke;
3016
- function Ae(e, t) {
3097
+ e.onJoinStatus = Ae;
3098
+ function je(e, t) {
3017
3099
  F("onHangup", e, t);
3018
3100
  }
3019
- e.onHangup = Ae;
3020
- function je(e) {
3101
+ e.onHangup = je;
3102
+ function Me(e) {
3021
3103
  F("onMultipartyChatCreated", L(e));
3022
3104
  }
3023
- e.onMultipartyChatCreated = je;
3024
- function Me() {
3105
+ e.onMultipartyChatCreated = Me;
3106
+ function Ne() {
3025
3107
  F("onDeviceChange");
3026
3108
  }
3027
- e.onDeviceChange = Me;
3028
- function Ne(e) {
3109
+ e.onDeviceChange = Ne;
3110
+ function Pe(e) {
3029
3111
  F("onFingerprintChange", e);
3030
3112
  }
3031
- e.onFingerprintChange = Ne;
3032
- function Pe() {
3113
+ e.onFingerprintChange = Pe;
3114
+ function Fe() {
3033
3115
  F("onTokenExpired");
3034
3116
  }
3035
- e.onTokenExpired = Pe;
3036
- function Fe(e, t, n = !1, r) {
3117
+ e.onTokenExpired = Fe;
3118
+ function Ie(e, t, n = !1, r) {
3037
3119
  F("onChatMessage", e, t, n, r);
3038
3120
  }
3039
- e.onChatMessage = Fe;
3040
- function Ie(e, t, n = !1, r) {
3121
+ e.onChatMessage = Ie;
3122
+ function Le(e, t, n = !1, r) {
3041
3123
  F("onCustomData", e, t, n, r);
3042
3124
  }
3043
- e.onCustomData = Ie;
3044
- function Le(e, t, n, r, i, a, o = null, s) {
3125
+ e.onCustomData = Le;
3126
+ function Re(e, t, n, r, i, a, o = null, s) {
3045
3127
  F("onRecordStarted", e, t, n, r, i, a, o, s);
3046
3128
  }
3047
- e.onRecordStarted = Le;
3048
- function Re(e = null, t, n) {
3129
+ e.onRecordStarted = Re;
3130
+ function ze(e = null, t, n) {
3049
3131
  F("onRecordStopped", e, t, n);
3050
3132
  }
3051
- e.onRecordStopped = Re;
3052
- function ze(e, t) {
3133
+ e.onRecordStopped = ze;
3134
+ function Be(e, t) {
3053
3135
  F("onLocalNetworkStatusChanged", e, t);
3054
3136
  }
3055
- e.onLocalNetworkStatusChanged = ze;
3056
- function Be(e, t) {
3137
+ e.onLocalNetworkStatusChanged = Be;
3138
+ function Ve(e, t) {
3057
3139
  F("onNetworkStatusChanged", e, t);
3058
3140
  }
3059
- e.onNetworkStatusChanged = Be;
3060
- function Ve(e, ...t) {
3141
+ e.onNetworkStatusChanged = Ve;
3142
+ function He(e, ...t) {
3061
3143
  F("onDebugMessage", e, ...t);
3062
3144
  }
3063
- e.onDebugMessage = Ve;
3064
- function He(e, t, ...n) {
3145
+ e.onDebugMessage = He;
3146
+ function Ue(e, t, ...n) {
3065
3147
  F("onDebugMessageWithContext", e, t, ...n);
3066
3148
  }
3067
- e.onDebugMessageWithContext = He;
3068
- function Ue(e, t) {
3149
+ e.onDebugMessageWithContext = Ue;
3150
+ function We(e, t) {
3069
3151
  F("onStatistics", Object.assign({}, e, { memory: t }));
3070
3152
  }
3071
- e.onStatistics = Ue;
3072
- function We(e) {
3153
+ e.onStatistics = We;
3154
+ function Ge(e) {
3073
3155
  let t = N.get("onClientStats");
3074
3156
  if (typeof t == "function") try {
3075
3157
  t(e);
@@ -3077,99 +3159,103 @@ var En;
3077
3159
  z.error("[CallsSDK] onClientStats callback failed", e);
3078
3160
  }
3079
3161
  }
3080
- e.onClientStats = We;
3081
- function Ge() {
3162
+ e.onClientStats = Ge;
3163
+ function Ke() {
3082
3164
  F("onAutoplayError");
3083
3165
  }
3084
- e.onAutoplayError = Ge;
3085
- function Ke(e, t, n, r, i, a) {
3166
+ e.onAutoplayError = Ke;
3167
+ function qe(e, t, n, r, i, a) {
3086
3168
  F("onChatRoomUpdated", e, t, n, r, i, a);
3087
3169
  }
3088
- e.onChatRoomUpdated = Ke;
3089
- function qe(e, t) {
3170
+ e.onChatRoomUpdated = qe;
3171
+ function Je(e, t) {
3090
3172
  F("onPromoted", e, t);
3091
3173
  }
3092
- e.onPromoted = qe;
3093
- function y(e, t) {
3174
+ e.onPromoted = Je;
3175
+ function v(e, t) {
3094
3176
  F("onRemoteMixedAudioStream", e, t);
3095
3177
  }
3096
- e.onRemoteMixedAudioStream = y;
3097
- function Je(e, t) {
3178
+ e.onRemoteMixedAudioStream = v;
3179
+ function Ye(e, t) {
3098
3180
  F("onJoinLinkChanged", e, t);
3099
3181
  }
3100
- e.onJoinLinkChanged = Je;
3101
- function Ye(e, t) {
3182
+ e.onJoinLinkChanged = Ye;
3183
+ function Xe(e, t) {
3102
3184
  F("onRoomsUpdated", e, t);
3103
3185
  }
3104
- e.onRoomsUpdated = Ye;
3105
- function b(e, t, n, r, i) {
3186
+ e.onRoomsUpdated = Xe;
3187
+ function y(e, t, n, r, i) {
3106
3188
  F("onRoomUpdated", e, t, n, r, i);
3107
3189
  }
3108
- e.onRoomUpdated = b;
3109
- function x(e, t) {
3190
+ e.onRoomUpdated = y;
3191
+ function b(e, t) {
3110
3192
  F("onRoomParticipantsUpdated", e, t);
3111
3193
  }
3112
- e.onRoomParticipantsUpdated = x;
3113
- function S(e, t) {
3194
+ e.onRoomParticipantsUpdated = b;
3195
+ function x(e, t) {
3114
3196
  F("onRoomSwitched", e, t);
3115
3197
  }
3116
- e.onRoomSwitched = S;
3117
- function Xe(e, t) {
3198
+ e.onRoomSwitched = x;
3199
+ function Ze(e, t) {
3118
3200
  F("onRoomStart", e, t);
3119
3201
  }
3120
- e.onRoomStart = Xe;
3121
- function Ze(e, t = null, n) {
3202
+ e.onRoomStart = Ze;
3203
+ function Qe(e, t = null, n) {
3122
3204
  F("onFeedback", e, t, n);
3123
3205
  }
3124
- e.onFeedback = Ze;
3125
- function Qe(e, t) {
3206
+ e.onFeedback = Qe;
3207
+ function $e(e, t) {
3126
3208
  F("onFeaturesPerRoleChanged", e, t);
3127
3209
  }
3128
- e.onFeaturesPerRoleChanged = Qe;
3129
- function $e(e, t) {
3210
+ e.onFeaturesPerRoleChanged = $e;
3211
+ function et(e, t) {
3130
3212
  F("onParticipantVmojiUpdate", e, t);
3131
3213
  }
3132
- e.onParticipantVmojiUpdate = $e;
3133
- function et(e, t, n) {
3214
+ e.onParticipantVmojiUpdate = et;
3215
+ function tt(e, t, n) {
3134
3216
  F("onAsrSet", e, t, n);
3135
3217
  }
3136
- e.onAsrSet = et;
3137
- function tt(e, t, n, r) {
3218
+ e.onAsrSet = tt;
3219
+ function nt(e, t, n, r) {
3138
3220
  F("onAsrStarted", e, t, n, r);
3139
3221
  }
3140
- e.onAsrStarted = tt;
3141
- function nt(e, t) {
3222
+ e.onAsrStarted = nt;
3223
+ function rt(e, t) {
3142
3224
  F("onAsrStopped", e, t);
3143
3225
  }
3144
- e.onAsrStopped = nt;
3145
- function rt(e, t, n, r, i) {
3226
+ e.onAsrStopped = rt;
3227
+ function it(e, t, n, r, i) {
3146
3228
  F("onAsrTranscription", e, t, n, r, i);
3147
3229
  }
3148
- e.onAsrTranscription = rt;
3149
- function C(e, t, n) {
3230
+ e.onAsrTranscription = it;
3231
+ function S(e, t, n) {
3150
3232
  F("onParticipantIdChanged", e, t, n);
3151
3233
  }
3152
- e.onParticipantIdChanged = C;
3153
- function w(e, t) {
3234
+ e.onParticipantIdChanged = S;
3235
+ function C(e, t) {
3154
3236
  F("onVideoSuspendSuggest", e, t);
3155
3237
  }
3156
- e.onVideoSuspendSuggest = w;
3157
- function it(e) {
3238
+ e.onVideoSuspendSuggest = C;
3239
+ function at(e) {
3240
+ F("onSignalingConnected", e);
3241
+ }
3242
+ e.onSignalingConnected = at;
3243
+ function w(e) {
3158
3244
  F("onSignalingMessage", typeof e == "string" ? e : L(e));
3159
3245
  }
3160
- e.onSignalingMessage = it;
3161
- function at(e, t) {
3246
+ e.onSignalingMessage = w;
3247
+ function ot(e, t) {
3162
3248
  F("onPromotionApproved", e, t);
3163
3249
  }
3164
- e.onPromotionApproved = at;
3165
- function ot(e, t) {
3250
+ e.onPromotionApproved = ot;
3251
+ function st(e, t) {
3166
3252
  F("onPeerRegistered", e, t);
3167
3253
  }
3168
- e.onPeerRegistered = ot;
3169
- function st(e, t) {
3254
+ e.onPeerRegistered = st;
3255
+ function ct(e, t) {
3170
3256
  F("onNonFatalError", e, t);
3171
3257
  }
3172
- e.onNonFatalError = st;
3258
+ e.onNonFatalError = ct;
3173
3259
  })(En || (En = {}));
3174
3260
  var R = En, Dn = /* @__PURE__ */ function(e) {
3175
3261
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -3191,7 +3277,7 @@ var R = En, Dn = /* @__PURE__ */ function(e) {
3191
3277
  }
3192
3278
  function u(e, t, n) {
3193
3279
  let u = l(n);
3194
- if (N.debugLog && ke(e, t, u.sessionId || void 0), c) switch (e) {
3280
+ if (N.debugLog && Ae(e, t, u.sessionId || void 0), c) switch (e) {
3195
3281
  case "DEBUG":
3196
3282
  i(...t);
3197
3283
  break;
@@ -3228,7 +3314,7 @@ var R = En, Dn = /* @__PURE__ */ function(e) {
3228
3314
  }
3229
3315
  e.enabled = ee;
3230
3316
  function h(e) {
3231
- c = e, N.debugLog && Ae();
3317
+ c = e, N.debugLog && je();
3232
3318
  }
3233
3319
  e.toggle = h;
3234
3320
  function te(e, ...t) {
@@ -3260,7 +3346,7 @@ var R = En, Dn = /* @__PURE__ */ function(e) {
3260
3346
  function re(e = null) {
3261
3347
  let t = null, n = e;
3262
3348
  function r() {
3263
- !N.debugLog || t || (t = je(), n && Me(n, t));
3349
+ !N.debugLog || t || (t = Me(), n && Ne(n, t));
3264
3350
  }
3265
3351
  let i = () => (r(), {
3266
3352
  sessionId: t,
@@ -3274,7 +3360,7 @@ var R = En, Dn = /* @__PURE__ */ function(e) {
3274
3360
  return n;
3275
3361
  },
3276
3362
  setConversationId(e) {
3277
- n = e, t && Me(n, t);
3363
+ n = e, t && Ne(n, t);
3278
3364
  },
3279
3365
  send: (e, ...t) => u(e, t, i),
3280
3366
  debug: (...e) => u("DEBUG", e, i),
@@ -3289,32 +3375,74 @@ var R = En, Dn = /* @__PURE__ */ function(e) {
3289
3375
  })(On || (On = {}));
3290
3376
  var z = On, B = new class {
3291
3377
  constructor() {
3292
- h(this, "_conversations", /* @__PURE__ */ new Map()), h(this, "_reserved", /* @__PURE__ */ new Set()), h(this, "_activeId", null), h(this, "_mutex", !1), h(this, "_pendingRemovals", /* @__PURE__ */ new Set());
3378
+ h(this, "_conversations", /* @__PURE__ */ new Map()), h(this, "_pending", /* @__PURE__ */ new Set()), h(this, "_initialIds", /* @__PURE__ */ new Map()), h(this, "_hangups", /* @__PURE__ */ new Map()), h(this, "_activeId", null), h(this, "_selected", null), h(this, "_mutex", !1), h(this, "_pendingRemovals", /* @__PURE__ */ new Map());
3379
+ }
3380
+ addPending(e) {
3381
+ this._pending.add(e), e.id && this._initialIds.set(e, e.id);
3382
+ }
3383
+ selectPending(e) {
3384
+ let t = this._selected;
3385
+ return this._pending.has(e) && (this._selected = e), t;
3293
3386
  }
3294
- reserve(e) {
3295
- if (this._conversations.has(e) || this._reserved.has(e)) throw Error(`CallRegistry: conversation ${e} already exists`);
3296
- this._reserved.add(e);
3387
+ isSelected(e) {
3388
+ return this._selected === e;
3389
+ }
3390
+ releaseSelection(e, t = this.getActive()) {
3391
+ this._selected === e && (this._selected = t && !this._pendingRemovals.has(t) && (this.get(t.id) === t || this._pending.has(t)) ? t : null);
3392
+ }
3393
+ selectIfNone(e) {
3394
+ this._selected ?? (this._selected = e);
3297
3395
  }
3298
3396
  add(e) {
3299
3397
  let t = e.id;
3300
- if (this._conversations.has(t)) {
3301
- z.warn(`CallRegistry: conversation ${t} already exists, skip duplicate add`), this._reserved.delete(t);
3398
+ if (this._pending.delete(e), this._conversations.has(t)) {
3399
+ z.warn(`CallRegistry: conversation ${t} already exists, skip duplicate add`);
3302
3400
  return;
3303
3401
  }
3304
- this._conversations.set(t, e), this._reserved.delete(t);
3402
+ this._conversations.set(t, e);
3305
3403
  }
3306
3404
  remove(e) {
3307
- if (e) {
3308
- if (this._reserved.delete(e), this._mutex) {
3309
- this._pendingRemovals.add(e);
3405
+ this._pending.delete(e), this._initialIds.delete(e), this._selected === e && (this._selected = null);
3406
+ let t = e.id;
3407
+ if (this._conversations.get(t) === e) {
3408
+ if (this._mutex) {
3409
+ this._pendingRemovals.set(e, t);
3310
3410
  return;
3311
3411
  }
3312
- this._conversations.delete(e), this._activeId === e && (this._activeId = null);
3412
+ this._conversations.delete(t), this._activeId === t && (this._activeId = null);
3313
3413
  }
3314
3414
  }
3315
3415
  get(e) {
3316
3416
  return this._conversations.get(e);
3317
3417
  }
3418
+ getPending(e) {
3419
+ let t = Array.from(this._pending).filter((t) => e === void 0 || e !== "" && t.id === e);
3420
+ return t.length === 1 ? t[0] : null;
3421
+ }
3422
+ isPending(e) {
3423
+ return this._pending.has(e);
3424
+ }
3425
+ getLocal(e) {
3426
+ if (e !== void 0) {
3427
+ let t = this.get(e);
3428
+ if (t || !e) return t ?? null;
3429
+ let n = Array.from(this._pending).filter((t) => t.id === e);
3430
+ if (n.length) return n.length === 1 ? n[0] : null;
3431
+ let r = Array.from(this._initialIds).filter(([, t]) => t === e);
3432
+ return r.length === 1 ? r[0][0] : null;
3433
+ }
3434
+ return this.getActive() ?? this.getFirst() ?? this.getPending();
3435
+ }
3436
+ trackHangup(e, t) {
3437
+ this._hangups.set(t, [e.id, this._initialIds.get(e) ?? ""]);
3438
+ }
3439
+ getHangup(e) {
3440
+ let t = Array.from(this._hangups).filter(([, t]) => e === void 0 || e !== "" && t.includes(e));
3441
+ return e === void 0 ? t.length === 1 ? t[0][0] : void 0 : t[t.length - 1]?.[0];
3442
+ }
3443
+ removeHangup(e) {
3444
+ this._hangups.delete(e);
3445
+ }
3318
3446
  getActive() {
3319
3447
  return this._activeId ? this._conversations.get(this._activeId) ?? null : null;
3320
3448
  }
@@ -3324,8 +3452,9 @@ var z = On, B = new class {
3324
3452
  getActiveId() {
3325
3453
  return this._activeId;
3326
3454
  }
3327
- has(e) {
3328
- return this._conversations.has(e) || this._reserved.has(e);
3455
+ has(e, t) {
3456
+ let n = this._conversations.get(e);
3457
+ return !!(n && n !== t || Array.from(this._pending).some((n) => n !== t && n.id === e) || Array.from(this._initialIds).some(([n, r]) => n !== t && r === e));
3329
3458
  }
3330
3459
  getAll() {
3331
3460
  return Array.from(this._conversations.values());
@@ -3334,41 +3463,41 @@ var z = On, B = new class {
3334
3463
  return this._conversations.size;
3335
3464
  }
3336
3465
  async setActive(e) {
3337
- if (!(this._activeId === e || !this._conversations.has(e) || this._mutex)) {
3338
- this._mutex = !0;
3339
- try {
3340
- let t = this.getActive(), n;
3341
- if (t) {
3342
- n = t.mediaSettings;
3343
- try {
3344
- await t.hold(!0);
3345
- } catch (e) {
3346
- throw z.error(`Can't hold previous active, error: ${e}`), Error("Cannot switch call: hold failed");
3347
- }
3348
- }
3349
- this._conversations.has(e) && (this._activeId = e, R.onCallActive(e));
3350
- let r = this._conversations.get(e);
3351
- if (r && r?.isCallHeld) try {
3352
- await r.hold(!1, n);
3466
+ let t = this.get(e) ?? this.getPending(e);
3467
+ if (!t || this._mutex) return;
3468
+ let n = this._selected;
3469
+ this._selected = t, this._mutex = !0;
3470
+ try {
3471
+ let r = this.getActive(), i;
3472
+ for (let e of new Set([r, n])) if (!(!e || e === t || e !== r && !this._pending.has(e))) {
3473
+ i ?? (i = e.mediaSettings);
3474
+ try {
3475
+ await e.hold(!0);
3353
3476
  } catch (e) {
3354
- throw z.error(`Can't hold next active, error: ${e}`), Error("Cannot switch call: hold failed");
3477
+ throw z.error(`Can't hold previous active, error: ${e}`), Error("Cannot switch call: hold failed");
3355
3478
  }
3356
- } finally {
3357
- this._mutex = !1, this._flushPendingRemovals();
3358
3479
  }
3480
+ if (this._selected !== t || this._pendingRemovals.has(t)) return;
3481
+ if (this._conversations.get(e) === t && this._activeId !== e && (this._activeId = e, R.onCallActive(e)), t.isCallHeld) try {
3482
+ await t.hold(!1, i);
3483
+ } catch (e) {
3484
+ throw z.error(`Can't hold next active, error: ${e}`), Error("Cannot switch call: hold failed");
3485
+ }
3486
+ } finally {
3487
+ this._mutex = !1, this._flushPendingRemovals();
3359
3488
  }
3360
3489
  }
3361
3490
  async setHold(e) {
3362
- if (!(this._activeId !== e || !this._conversations.has(e) || this._mutex)) {
3363
- this._mutex = !0;
3491
+ let t = this.get(e) ?? this.getPending(e);
3492
+ if (!(!t || this._activeId !== e && this._selected !== t || this._mutex)) {
3493
+ this._selected = null, this._mutex = !0;
3364
3494
  try {
3365
- let e = this.getActive();
3366
- if (e) try {
3367
- await e.hold(!0);
3495
+ try {
3496
+ await t.hold(!0);
3368
3497
  } catch (e) {
3369
3498
  throw z.error(`Can't hold previous active, error: ${e}`), Error("Cannot switch call: hold failed");
3370
3499
  }
3371
- this._activeId = null;
3500
+ this._activeId === e && (this._activeId = null);
3372
3501
  } finally {
3373
3502
  this._mutex = !1, this._flushPendingRemovals();
3374
3503
  }
@@ -3378,11 +3507,11 @@ var z = On, B = new class {
3378
3507
  this._activeId === e ? await this.setHold(e) : await this.setActive(e);
3379
3508
  }
3380
3509
  clear() {
3381
- this._conversations.clear(), this._reserved.clear(), this._pendingRemovals.clear(), this._activeId = null;
3510
+ this._conversations.clear(), this._pending.clear(), this._initialIds.clear(), this._hangups.clear(), this._pendingRemovals.clear(), this._activeId = null, this._selected = null;
3382
3511
  }
3383
3512
  _flushPendingRemovals() {
3384
3513
  if (this._pendingRemovals.size !== 0) {
3385
- for (let e of this._pendingRemovals) this._conversations.delete(e), this._activeId === e && (this._activeId = null);
3514
+ for (let [e, t] of this._pendingRemovals) this._conversations.get(t) === e && (this._conversations.delete(t), this._activeId === t && (this._activeId = null));
3386
3515
  this._pendingRemovals.clear();
3387
3516
  }
3388
3517
  }
@@ -3394,7 +3523,7 @@ var z = On, B = new class {
3394
3523
  constructor(e) {
3395
3524
  super(e ? `Producer connection closed. Command ${e}` : "Producer connection closed"), this.name = "ProducerConnectionClosedError";
3396
3525
  }
3397
- }, jn = class extends Je {
3526
+ }, jn = class extends Ye {
3398
3527
  constructor(...e) {
3399
3528
  super(...e), h(this, "_abortSignal", void 0);
3400
3529
  }
@@ -4190,7 +4319,7 @@ var ei = class {
4190
4319
  this._timer = null, this._poll();
4191
4320
  }, this._pollIntervalMs));
4192
4321
  }
4193
- }, ti = class extends Je {
4322
+ }, ti = class extends Ye {
4194
4323
  constructor(e, t, n = null) {
4195
4324
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_state", q.IDLE), h(this, "_pc", null), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbe", null), h(this, "_firstMediaSentProbeStopped", !1), this._signaling = e, this._mediaSource = t, this._onFirstMediaSent = n;
4196
4325
  }
@@ -4224,7 +4353,7 @@ var ei = class {
4224
4353
  getValue() {
4225
4354
  return this.value;
4226
4355
  }
4227
- }, ri = .25, ii = .35, ai = 85, oi = .1, si = 1.5, ci = .1, li = 1, ui = .6, di = .3, fi = class extends Je {
4356
+ }, ri = .25, ii = .35, ai = 85, oi = .1, si = 1.5, ci = .1, li = 1, ui = .6, di = .3, fi = class extends Ye {
4228
4357
  constructor(e, t = z) {
4229
4358
  super(), h(this, "_signaling", void 0), h(this, "_localNetworkStat", void 0), h(this, "_remoteNetworkStat", void 0), h(this, "_lastNetworkStat", void 0), h(this, "_networkLimits", {
4230
4359
  badNet: {
@@ -4325,7 +4454,7 @@ var ei = class {
4325
4454
  try {
4326
4455
  this._mediaSource.addTrackToPeerConnection(this._pc, !1, !0), this._applySettings();
4327
4456
  } catch (e) {
4328
- this._logger?.log(S.ERROR, "addTrack-direct"), this._debug.error("Unable to add media source tracks", e, { participantId: this._participantId }), this._failedOnCreate = e;
4457
+ this._logger?.log(x.ERROR, "addTrack-direct"), this._debug.error("Unable to add media source tracks", e, { participantId: this._participantId }), this._failedOnCreate = e;
4329
4458
  return;
4330
4459
  }
4331
4460
  this._createOffer(!1).catch((e) => {
@@ -4359,7 +4488,7 @@ var ei = class {
4359
4488
  if (this._debug.debug("DirectTransport: Open transport", { participantId: this._participantId }), this._isOpen = !0, this._remotePeerId = e, this._connectionStartedAt = Date.now(), !this._isMaster) try {
4360
4489
  this._mediaSource.addTrackToPeerConnection(this._pc, !1, !0), this._applySettings();
4361
4490
  } catch (e) {
4362
- this._logger?.log(S.ERROR, "addTrack-direct"), this._debug.error("DirectTransport: Unable to add media source tracks", e, { participantId: this._participantId }), this.close(e);
4491
+ this._logger?.log(x.ERROR, "addTrack-direct"), this._debug.error("DirectTransport: Unable to add media source tracks", e, { participantId: this._participantId }), this.close(e);
4363
4492
  return;
4364
4493
  }
4365
4494
  this._startFirstMediaSentProbe(), this._setState(q.OPENED);
@@ -4472,7 +4601,7 @@ var ei = class {
4472
4601
  try {
4473
4602
  await this._pc.addIceCandidate(new RTCIceCandidate(t));
4474
4603
  } catch (e) {
4475
- throw this._logger?.log(S.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
4604
+ throw this._logger?.log(x.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
4476
4605
  participantId: this._participantId,
4477
4606
  candidate: t
4478
4607
  }), e;
@@ -4503,7 +4632,7 @@ var ei = class {
4503
4632
  try {
4504
4633
  await this._pc.setRemoteDescription(n), await this._setRemoteCandidates(t), this._processAnimojiProtocolVersion(this._remoteAnimojiVersion);
4505
4634
  } catch (e) {
4506
- throw this._logger?.log(S.ERROR, "setRemoteDescription-direct"), this._sdpStats.logSetRemoteFailed(n, e), this._debug.error("Unable to set remote description", e, {
4635
+ throw this._logger?.log(x.ERROR, "setRemoteDescription-direct"), this._sdpStats.logSetRemoteFailed(n, e), this._debug.error("Unable to set remote description", e, {
4507
4636
  participantId: this._participantId,
4508
4637
  sdp: n
4509
4638
  }), e;
@@ -4554,17 +4683,17 @@ var ei = class {
4554
4683
  participantId: this._participantId,
4555
4684
  connectionState: this._pc?.connectionState,
4556
4685
  iceConnectionState: this._pc?.iceConnectionState
4557
- }), this._logger?.log(S.ERROR, "iceConnectionState-fallback"), this._markConnected());
4686
+ }), this._logger?.log(x.ERROR, "iceConnectionState-fallback"), this._markConnected());
4558
4687
  break;
4559
4688
  }
4560
4689
  }
4561
4690
  _markConnected() {
4562
4691
  this._serverRequestedOnNoConnection && (this._networkAdaptationStats.logServerTopologyRequested(Yr.SUCCESS_CONNECTION, Date.now() - this._connectionStartedAt), this._serverRequestedOnNoConnection = !1), this._neverConnected = !1, this._setState(q.CONNECTED), this._stopReconnection(), this._pc && M.getPeerConnectionHostInfo(this._pc).then((e) => {
4563
- e?.local && (this._logger?.log(S.ICE_CONNECTION_TYPE, e.local.type), this._debug.debug("Selected ICE candidates", e));
4692
+ e?.local && (this._logger?.log(x.ICE_CONNECTION_TYPE, e.local.type), this._debug.debug("Selected ICE candidates", e));
4564
4693
  }), this._startStatInterval();
4565
4694
  }
4566
4695
  _onConnectionStateChange() {
4567
- switch (this._debug.debug(`DirectTransport: Connection state changed to ${this._pc?.connectionState}`, { participantId: this._participantId }), this._logger?.log(S.ICE_CONNECTION_STATE, this._pc?.connectionState), this._pc?.connectionState) {
4696
+ switch (this._debug.debug(`DirectTransport: Connection state changed to ${this._pc?.connectionState}`, { participantId: this._participantId }), this._logger?.log(x.ICE_CONNECTION_STATE, this._pc?.connectionState), this._pc?.connectionState) {
4568
4697
  case "connected":
4569
4698
  this._markConnected();
4570
4699
  break;
@@ -4595,8 +4724,8 @@ var ei = class {
4595
4724
  this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = null), this._iceRestartTimeout && (clearTimeout(this._iceRestartTimeout), this._iceRestartTimeout = null);
4596
4725
  }
4597
4726
  _startIceRestart() {
4598
- this._isMaster ? (this._peerConnectionStats.logIceRestart(), this._logger?.log(S.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
4599
- this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(S.ERROR, "iceRestart-direct"), this._requestTopologySwitch({
4727
+ this._isMaster ? (this._peerConnectionStats.logIceRestart(), this._logger?.log(x.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
4728
+ this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(x.ERROR, "iceRestart-direct"), this._requestTopologySwitch({
4600
4729
  reason: Yr.CONNECTION_FAILED,
4601
4730
  fromAnySide: N.switchTopologyOnReconnectFromAnySide
4602
4731
  });
@@ -4619,7 +4748,7 @@ var ei = class {
4619
4748
  offer: r
4620
4749
  }), this._sdpStats.logSdpGenerated("offer"), r = e._patchLocalDescription(r);
4621
4750
  } catch (e) {
4622
- throw this._debug.error("Unable to create offer", e, { participantId: this._participantId }), this._logger?.log(S.ERROR, "createOffer-direct"), this._sdpStats.logCreateFailed("offer", e), e;
4751
+ throw this._debug.error("Unable to create offer", e, { participantId: this._participantId }), this._logger?.log(x.ERROR, "createOffer-direct"), this._sdpStats.logCreateFailed("offer", e), e;
4623
4752
  }
4624
4753
  try {
4625
4754
  return this._debug.debug("Set local description", {
@@ -4627,7 +4756,7 @@ var ei = class {
4627
4756
  offer: r
4628
4757
  }), this._calcFingerprint(r.sdp), await this._pc?.setLocalDescription(r), r;
4629
4758
  } catch (e) {
4630
- throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(S.ERROR, "setLocalDescription-direct"), this._sdpStats.logSetLocalFailed(r, e), e;
4759
+ throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(x.ERROR, "setLocalDescription-direct"), this._sdpStats.logSetLocalFailed(r, e), e;
4631
4760
  }
4632
4761
  }
4633
4762
  async _createAnswer() {
@@ -4639,7 +4768,7 @@ var ei = class {
4639
4768
  answer: t
4640
4769
  }), this._sdpStats.logSdpGenerated("answer"), t = e._patchLocalDescription(t);
4641
4770
  } catch (e) {
4642
- throw this._debug.error("Unable to create answer", e, { participantId: this._participantId }), this._logger?.log(S.ERROR, "createAnswer-direct"), this._sdpStats.logCreateFailed("answer", e), e;
4771
+ throw this._debug.error("Unable to create answer", e, { participantId: this._participantId }), this._logger?.log(x.ERROR, "createAnswer-direct"), this._sdpStats.logCreateFailed("answer", e), e;
4643
4772
  }
4644
4773
  try {
4645
4774
  return this._debug.debug("Set local description", {
@@ -4647,20 +4776,20 @@ var ei = class {
4647
4776
  answer: t
4648
4777
  }), this._calcFingerprint(t.sdp), await this._pc?.setLocalDescription(t), t;
4649
4778
  } catch (e) {
4650
- throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(S.ERROR, "setLocalDescription-direct"), this._sdpStats.logSetLocalFailed(t, e), e;
4779
+ throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(x.ERROR, "setLocalDescription-direct"), this._sdpStats.logSetLocalFailed(t, e), e;
4651
4780
  }
4652
4781
  }
4653
4782
  static _patchLocalDescription(e) {
4654
- let t = !!w.baseChromeVersion();
4655
- return e.sdp = M.patchLocalSDP(e.sdp, N.preferH264 && w.canPreferH264(), w.isBrokenH264Decoder(), N.preferVP9, t && N.audioNack), e;
4783
+ let t = !!C.baseChromeVersion();
4784
+ return e.sdp = M.patchLocalSDP(e.sdp, N.preferH264 && C.canPreferH264(), C.isBrokenH264Decoder(), N.preferVP9, t && N.audioNack), e;
4656
4785
  }
4657
4786
  static _patchRemoteDescription(e) {
4658
- return e.sdp = M.patchRemoteSDP(e.sdp, !1, !1, N.preferVP9, w.isBrokenVP9Encoder() || N.simulcast, w.isBrokenVP9Decoder()), e;
4787
+ return e.sdp = M.patchRemoteSDP(e.sdp, !1, !1, N.preferVP9, C.isBrokenVP9Encoder() || N.simulcast, C.isBrokenVP9Decoder()), e;
4659
4788
  }
4660
4789
  _onReplacedTrack(e) {
4661
4790
  this._pc && (this._pc.getSenders().forEach((t) => {
4662
4791
  t.track && t.track.kind === e.kind && t.track.contentHint === e.contentHint && t.replaceTrack(e).catch((e) => {
4663
- this._debug.error("DirectTransport: Unable to replace track", e, { participantId: this._participantId }), this._logger?.log(S.ERROR, "replaceTrack-direct");
4792
+ this._debug.error("DirectTransport: Unable to replace track", e, { participantId: this._participantId }), this._logger?.log(x.ERROR, "replaceTrack-direct");
4664
4793
  });
4665
4794
  }), this._applySettings());
4666
4795
  }
@@ -5016,7 +5145,7 @@ var bi = class {
5016
5145
  this._debug.debug(e.data.message);
5017
5146
  break;
5018
5147
  case xi.LOG_ERROR:
5019
- this._logger?.log(S.ERROR, e.data.message);
5148
+ this._logger?.log(x.ERROR, e.data.message);
5020
5149
  break;
5021
5150
  }
5022
5151
  }, this._sendToWorker(xi.INIT, r, i);
@@ -5087,7 +5216,7 @@ var bi = class {
5087
5216
  this._removeWorker(), this._debug.debug("WebCodecsDecoder destroyed");
5088
5217
  }
5089
5218
  static isBrowserSupported() {
5090
- return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !w.isBrokenVP9Decoder() && w.browserName() !== "Firefox";
5219
+ return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !C.isBrokenVP9Decoder() && C.browserName() !== "Firefox";
5091
5220
  }
5092
5221
  }, Ti = class {
5093
5222
  constructor(e = null, t = 0) {
@@ -5242,7 +5371,7 @@ var bi = class {
5242
5371
  this._removeStream(), this._debug.debug("CanvasRenderer destroyed");
5243
5372
  }
5244
5373
  static isBrowserSupported() {
5245
- return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(w.browserName() === "Safari" && Number(w.browserVersion()) === 15);
5374
+ return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(C.browserName() === "Safari" && Number(C.browserVersion()) === 15);
5246
5375
  }
5247
5376
  }, Mi = class extends Ai {
5248
5377
  constructor(e, t = z) {
@@ -6072,7 +6201,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6072
6201
  this._debug.error("SimulcastSender: Failed to sync replaced track", e);
6073
6202
  });
6074
6203
  }).catch((e) => {
6075
- this._debug.error("SimulcastSender: Unable to replace track", e), this._logger?.log(S.ERROR, "replaceTrack-single");
6204
+ this._debug.error("SimulcastSender: Unable to replace track", e), this._logger?.log(x.ERROR, "replaceTrack-single");
6076
6205
  }), !0;
6077
6206
  }
6078
6207
  reset() {
@@ -6227,7 +6356,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6227
6356
  try {
6228
6357
  this._mediaSource.addTrackToPeerConnection(this._pc, this._observer, !1), this._prevConsumerSettings = {}, this._prevConsumerFastSharingSettings = {}, this._applyConsumerSettings();
6229
6358
  } catch (e) {
6230
- this._debug.error("ServerTransport: Unable to add media source tracks", e), this._logger?.log(S.ERROR, "addTrack-single"), this.close(e);
6359
+ this._debug.error("ServerTransport: Unable to add media source tracks", e), this._logger?.log(x.ERROR, "addTrack-single"), this.close(e);
6231
6360
  return;
6232
6361
  }
6233
6362
  this._startFirstMediaSentProbe(), this._createDataChannel(this._pc, Rr.consumerScreenShare, (e) => {
@@ -6408,26 +6537,26 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6408
6537
  try {
6409
6538
  await this._pc.setRemoteDescription(e);
6410
6539
  } catch (t) {
6411
- throw this._debug.error("[single] unable to set remote offer", t), this._logger?.log(S.ERROR, "setRemoteDescription-single"), this._sdpStats.logSetRemoteFailed(e, t), t;
6540
+ throw this._debug.error("[single] unable to set remote offer", t), this._logger?.log(x.ERROR, "setRemoteDescription-single"), this._sdpStats.logSetRemoteFailed(e, t), t;
6412
6541
  }
6413
6542
  if (await this._simulcast.configureFromRemoteOffer(this._pc), await this._handleTracks(), this._debug.debug("[single] create local answer"), !this._pc) throw Error("Interrupt allocation");
6414
6543
  let n;
6415
6544
  try {
6416
6545
  n = await this._pc.createAnswer(), this._sdpStats.logSdpGenerated("answer");
6417
6546
  } catch (e) {
6418
- throw this._debug.error("[single] unable to create answer", e), this._logger?.log(S.ERROR, "createAnswer-single"), this._sdpStats.logCreateFailed("answer", e), e;
6547
+ throw this._debug.error("[single] unable to create answer", e), this._logger?.log(x.ERROR, "createAnswer-single"), this._sdpStats.logCreateFailed("answer", e), e;
6419
6548
  }
6420
6549
  try {
6421
6550
  if (!this._pc) throw Error("Interrupt allocation");
6422
- n.sdp = M.patchLocalSDP(n.sdp, !1, w.isBrokenH264Decoder(), !1), this._debug.debug("[single] set local answer", { answer: n }), await this._pc.setLocalDescription(n);
6551
+ n.sdp = M.patchLocalSDP(n.sdp, !1, C.isBrokenH264Decoder(), !1), this._debug.debug("[single] set local answer", { answer: n }), await this._pc.setLocalDescription(n);
6423
6552
  } catch (e) {
6424
- throw this._debug.error("[single] unable to set local answer", e), this._logger?.log(S.ERROR, "setLocalDescription-single"), this._sdpStats.logSetLocalFailed(n, e), e;
6553
+ throw this._debug.error("[single] unable to set local answer", e), this._logger?.log(x.ERROR, "setLocalDescription-single"), this._sdpStats.logSetLocalFailed(n, e), e;
6425
6554
  }
6426
6555
  n.sdp = this._simulcast.finalizeAnswer(n.sdp);
6427
6556
  try {
6428
6557
  this._debug.debug("[single] transmit local answer", { answer: n }), this._updateSSRCMap(e), await this._signaling.acceptProducer(n, Object.keys(this._ssrcMap), t), this._debug.debug("[single] remote offer has been processed");
6429
6558
  } catch (e) {
6430
- this._debug.warn("[single] unable to send local answer", e), this._logger?.log(S.ERROR, "acceptProducer");
6559
+ this._debug.warn("[single] unable to send local answer", e), this._logger?.log(x.ERROR, "acceptProducer");
6431
6560
  }
6432
6561
  await this._simulcast.sync({ force: !0 });
6433
6562
  }
@@ -6439,7 +6568,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6439
6568
  this._producerOfferIsProcessing = !0;
6440
6569
  let n = {
6441
6570
  type: "offer",
6442
- sdp: M.patchRemoteSDP(e, !1, !1, !1, w.isBrokenVP9Encoder() || N.simulcast, w.isBrokenVP9Decoder())
6571
+ sdp: M.patchRemoteSDP(e, !1, !1, !1, C.isBrokenVP9Encoder() || N.simulcast, C.isBrokenVP9Decoder())
6443
6572
  };
6444
6573
  if (this._debug.debug("[single] set remote offer", { offer: n }), !this._pc) throw Error("Interrupt allocation");
6445
6574
  try {
@@ -6478,7 +6607,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6478
6607
  try {
6479
6608
  e.direction = "sendonly", await e.sender.replaceTrack(this._newAudioShareTrack), this._newAudioShareTrack = null;
6480
6609
  } catch (e) {
6481
- this._debug.error("ServerTransport: Unable to replace track", e), this._logger?.log(S.ERROR, "replaceTrack-single");
6610
+ this._debug.error("ServerTransport: Unable to replace track", e), this._logger?.log(x.ERROR, "replaceTrack-single");
6482
6611
  }
6483
6612
  }
6484
6613
  async _handleScreenShareTrack() {
@@ -6522,13 +6651,13 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6522
6651
  }), n.getTracks().find((e) => e.id === t.track.id) || (this._debug.warn("[single] remote track missing from stream, re-adding", {
6523
6652
  streamId: n.id,
6524
6653
  trackId: t.track.id
6525
- }), this._logger?.log(S.ERROR, "ontrack-empty-stream"), n.addTrack(t.track)), this._rtpReceiversByStreamId[n.id] = t.receiver, this._triggerEvent(Y.REMOTE_TRACK_ADDED, n.id, n, t.track)) : this._debug.error("[single] unable to get media stream from track event");
6654
+ }), this._logger?.log(x.ERROR, "ontrack-empty-stream"), n.addTrack(t.track)), this._rtpReceiversByStreamId[n.id] = t.receiver, this._triggerEvent(Y.REMOTE_TRACK_ADDED, n.id, n, t.track)) : this._debug.error("[single] unable to get media stream from track event");
6526
6655
  }
6527
6656
  _onSignalingStateChange(e, t) {
6528
6657
  this._debug.debug("[single] signaling state changed", { state: e.signalingState }, t);
6529
6658
  }
6530
6659
  _onConnectionStateChange(e, t) {
6531
- switch (this._debug.debug("[single] connection state changed", { state: e.connectionState }, t), this._logger?.log(S.ICE_CONNECTION_STATE, e.connectionState), e.connectionState) {
6660
+ switch (this._debug.debug("[single] connection state changed", { state: e.connectionState }, t), this._logger?.log(x.ICE_CONNECTION_STATE, e.connectionState), e.connectionState) {
6532
6661
  case "failed":
6533
6662
  this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect(!0);
6534
6663
  break;
@@ -6541,7 +6670,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6541
6670
  break;
6542
6671
  case "connected":
6543
6672
  this._setState(q.CONNECTED), M.getPeerConnectionHostInfo(e).then((e) => {
6544
- e?.local && (this._logger?.log(S.ICE_CONNECTION_TYPE, e.local.type), this._debug.debug("Selected ICE candidates", e));
6673
+ e?.local && (this._logger?.log(x.ICE_CONNECTION_TYPE, e.local.type), this._debug.debug("Selected ICE candidates", e));
6545
6674
  });
6546
6675
  break;
6547
6676
  }
@@ -6551,7 +6680,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6551
6680
  this._debug.debug(`_onReplacedTrack: newTrack=${e}, sendTrack=${t}`), t && (e = t);
6552
6681
  let n = (e, t) => {
6553
6682
  e.replaceTrack(t).catch((e) => {
6554
- this._debug.error("ServerTransport: Unable to replace track", e), this._logger?.log(S.ERROR, "replaceTrack-single");
6683
+ this._debug.error("ServerTransport: Unable to replace track", e), this._logger?.log(x.ERROR, "replaceTrack-single");
6555
6684
  });
6556
6685
  };
6557
6686
  if (this._debug.log(`_onReplacedTrack: newTrack=${e.getSettings().width}x${e.getSettings().height}`), !this._simulcast.replaceTrack(e)) {
@@ -6565,14 +6694,14 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6565
6694
  e === A.screen && N.consumerFastScreenShare && this._mediaSource.mediaSettings.isFastScreenSharingEnabled && await this._replaceScreenShareTrack(), this._applyConsumerSettings();
6566
6695
  }
6567
6696
  getStreamWaitingTimeMs(e, t) {
6568
- if (!this._pc) return this._logger?.log(S.PAT_WAITING_TIME_ERROR, "noConnection"), this._debug.error("Cannot get stream waiting time, peer connection is not initialized"), 0;
6569
- if (!RTCRtpReceiver.prototype.getSynchronizationSources) return this._logger?.log(S.PAT_WAITING_TIME_ERROR, "oldBrowser"), this._debug.error("Cannot get stream waiting time, RTCRtpReceiver.getSynchronizationSources is not supported"), 0;
6697
+ if (!this._pc) return this._logger?.log(x.PAT_WAITING_TIME_ERROR, "noConnection"), this._debug.error("Cannot get stream waiting time, peer connection is not initialized"), 0;
6698
+ if (!RTCRtpReceiver.prototype.getSynchronizationSources) return this._logger?.log(x.PAT_WAITING_TIME_ERROR, "oldBrowser"), this._debug.error("Cannot get stream waiting time, RTCRtpReceiver.getSynchronizationSources is not supported"), 0;
6570
6699
  let n = this._rtpReceiversByStreamId[e];
6571
- if (!n) return this._logger?.log(S.PAT_WAITING_TIME_ERROR, "noReceiver"), this._debug.error(`Cannot get stream waiting time, cannot find RTP receiver by stream ID: ${e}`), 0;
6700
+ if (!n) return this._logger?.log(x.PAT_WAITING_TIME_ERROR, "noReceiver"), this._debug.error(`Cannot get stream waiting time, cannot find RTP receiver by stream ID: ${e}`), 0;
6572
6701
  let r = n.getSynchronizationSources();
6573
6702
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6574
6703
  let i = r[0].rtpTimestamp;
6575
- if (!Number.isInteger(i)) return this._logger?.log(S.PAT_WAITING_TIME_ERROR, "timestampNotInteger"), this._debug.error(`Cannot get stream waiting time, ${e} receiver's RTP timestamp is not an integer: ${i}`), 0;
6704
+ if (!Number.isInteger(i)) return this._logger?.log(x.PAT_WAITING_TIME_ERROR, "timestampNotInteger"), this._debug.error(`Cannot get stream waiting time, ${e} receiver's RTP timestamp is not an integer: ${i}`), 0;
6576
6705
  let a = t - i & Aa, o = Math.ceil(a / ka);
6577
6706
  return Math.min(100, Math.max(0, o));
6578
6707
  }
@@ -6608,7 +6737,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6608
6737
  }
6609
6738
  }, Y = /* @__PURE__ */ function(e) {
6610
6739
  return e.REMOTE_TRACK_ADDED = "REMOTE_TRACK_ADDED", e.REMOTE_TRACK_REMOVED = "REMOTE_TRACK_REMOVED", e.REMOTE_STREAM_SECOND = "REMOTE_STREAM_SECOND", e.AUDIO_MIX_STALL = "AUDIO_MIX_STALL", e.REMOTE_DATA_STATS = "REMOTE_DATA_STATS", e.STATE_CHANGED = "STATE_CHANGED", e.LOCAL_STATE_CHANGED = "LOCAL_STATE_CHANGED", e.SIGNALLED_ACTIVE_PARTICIPANTS = "SIGNALLED_ACTIVE_PARTICIPANTS", e.SIGNALLED_SPEAKER_CHANGED = "SIGNALLED_SPEAKER_CHANGED", e.SIGNALLED_STALLED_PARTICIPANTS = "SIGNALLED_STALLED_PARTICIPANTS", e.TOPOLOGY_CHANGED = "TOPOLOGY_CHANGED", e.NETWORK_STATUS = "NETWORK_STATUS", e.PEER_CONNECTION_CLOSED = "PEER_CONNECTION_CLOSED", e.ASR_TRANSCRIPTION = "ASR_TRANSCRIPTION", e.ANIMOJI_STREAM = "ANIMOJI_STREAM", e.ANIMOJI_ERROR = "ANIMOJI_ERROR", e.SCREEN_SHARING_STAT = "SCREEN_SHARING_STAT", e;
6611
- }({}), Ma = class extends Je {
6740
+ }({}), Ma = class extends Ye {
6612
6741
  constructor(e, t, n, r, i = z, a = null, o = null, s = null, c = null) {
6613
6742
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_topology", void 0), h(this, "_allocated", []), h(this, "_opened", []), h(this, "_directTransport", null), h(this, "_serverTransport", null), h(this, "_serverSettings", void 0), h(this, "_dtListeners", []), h(this, "_stListeners", []), h(this, "_states", {}), h(this, "_localState", q.IDLE), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbeStopped", !1), h(this, "_vadController", null), h(this, "_updateVadTrack", () => {
6614
6743
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
@@ -6710,7 +6839,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6710
6839
  }
6711
6840
  _onTopologyChanged(e) {
6712
6841
  if (e.topology !== this._topology) {
6713
- if (this._debug.log(`Topology changed ${this._topology} -> ${e.topology}`), this._logger?.log(S.TOPOLOGY_CHANGE_REQUESTED, e.topology), this._topology = e.topology, this._topology === J.SERVER && (this._serverTransport ? this._serverTransport.allowRestart() : (this._serverTransport = this._createServerTransport(), this._opened.length > 0 && (this._directTransport?.preventRestart(), this._serverTransport.open()))), this._topology === J.DIRECT) {
6842
+ if (this._debug.log(`Topology changed ${this._topology} -> ${e.topology}`), this._logger?.log(x.TOPOLOGY_CHANGE_REQUESTED, e.topology), this._topology = e.topology, this._topology === J.SERVER && (this._serverTransport ? this._serverTransport.allowRestart() : (this._serverTransport = this._createServerTransport(), this._opened.length > 0 && (this._directTransport?.preventRestart(), this._serverTransport.open()))), this._topology === J.DIRECT) {
6714
6843
  let t = e.offerTo || [], n = e.offerToTypes || [], r = e.offerToDeviceIdxs || [], i = t.length && n.length ? M.composeParticipantId(t[0], n[0], r[0]) : null;
6715
6844
  if (this._serverTransport && this._serverTransport.preventRestart(), !this._allocated || this._allocated.length === 0) {
6716
6845
  this._debug.error("Topology changed to DIRECT, but the list of allocated participants is empty");
@@ -6823,9 +6952,9 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6823
6952
  this._animojiSender?.destroy(), this._animojiSender = null, this._animojiReceiver?.destroy(), this._animojiReceiver = null;
6824
6953
  }
6825
6954
  getStreamWaitingTimeMs(e, t) {
6826
- return this._topology === J.SERVER ? this._serverTransport ? this._serverTransport.getStreamWaitingTimeMs(e, t) : (this._logger?.log(S.PAT_WAITING_TIME_ERROR, "noTransport"), this._debug.error("Cannot get stream waiting time, server transport is not initialized"), 0) : (this._logger?.log(S.PAT_WAITING_TIME_ERROR, "wrongTopology"), this._debug.error(`Cannot get stream waiting time, incorrect topology: ${this._topology}`), 0);
6955
+ return this._topology === J.SERVER ? this._serverTransport ? this._serverTransport.getStreamWaitingTimeMs(e, t) : (this._logger?.log(x.PAT_WAITING_TIME_ERROR, "noTransport"), this._debug.error("Cannot get stream waiting time, server transport is not initialized"), 0) : (this._logger?.log(x.PAT_WAITING_TIME_ERROR, "wrongTopology"), this._debug.error(`Cannot get stream waiting time, incorrect topology: ${this._topology}`), 0);
6827
6956
  }
6828
- }, Na = "videochat-epi", Pa = 32767, Fa = 1e4, Ia = 5e3, La = 500, Ra = 6e4, za = 1e4, Ba = 1e3, Va = 3e5, Ha = class extends Je {
6957
+ }, Na = "videochat-epi", Pa = 32767, Fa = 1e4, Ia = 5e3, La = 500, Ra = 6e4, za = 1e4, Ba = 1e3, Va = 3e5, Ha = class extends Ye {
6829
6958
  constructor(e, t, n = null, r = !1, i = z) {
6830
6959
  super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCounters", /* @__PURE__ */ new Map()), h(this, "_previousRemoteInboundRtps", /* @__PURE__ */ new Map()), h(this, "_previousInboundRtps", /* @__PURE__ */ new Map()), h(this, "_previousOutboundRtps", /* @__PURE__ */ new Map()), h(this, "_previousCandidatePair", null), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
6831
6960
  this._screenShareStats.push(e);
@@ -7221,7 +7350,7 @@ var Ja = qa, Ya = {
7221
7350
  }
7222
7351
  }, ao = class {
7223
7352
  static isBrowserSupported() {
7224
- return !(!("WebTransport" in window && typeof WebTransport == "function") || w.browserName() === "Safari");
7353
+ return !(!("WebTransport" in window && typeof WebTransport == "function") || C.browserName() === "Safari");
7225
7354
  }
7226
7355
  constructor(e, t = {}, n = z) {
7227
7356
  h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new ro(this.compression), this.decoder = new io(this.compression), this.connect();
@@ -7583,7 +7712,7 @@ var ho = new Set([
7583
7712
  async connect(e) {
7584
7713
  return new Promise((t, n) => {
7585
7714
  if (this.transport.readyState !== null && this.transport.readyState < WebSocket.CLOSING) {
7586
- this._logger?.log(S.SOCKET_ACTION, "already_opened"), n(Error("Socket already opened"));
7715
+ this._logger?.log(x.SOCKET_ACTION, "already_opened"), n(Error("Socket already opened"));
7587
7716
  return;
7588
7717
  }
7589
7718
  this.conversationResolve = (e) => {
@@ -7865,10 +7994,10 @@ var ho = new Set([
7865
7994
  break;
7866
7995
  case "websocket":
7867
7996
  if (this.transport.readyState === null) {
7868
- this._logger?.log(S.SOCKET_ACTION, "not_opened"), this._debug.warn("[signaling] socket is not opened"), t.reject(/* @__PURE__ */ Error(`Socket not opened [${e}]`), !0);
7997
+ this._logger?.log(x.SOCKET_ACTION, "not_opened"), this._debug.warn("[signaling] socket is not opened"), t.reject(/* @__PURE__ */ Error(`Socket not opened [${e}]`), !0);
7869
7998
  return;
7870
7999
  }
7871
- this.transport.readyState > WebSocket.OPEN && (this._logger?.log(S.SOCKET_ACTION, "invalid_state"), this._debug.warn(`[signaling] socket is not opened, state ${this.transport.readyState}`)), this.websocketCommandsQueue.push(t), this.transport.readyState === WebSocket.OPEN && this._handleCommandsQueue(this.websocketCommandsQueue);
8000
+ this.transport.readyState > WebSocket.OPEN && (this._logger?.log(x.SOCKET_ACTION, "invalid_state"), this._debug.warn(`[signaling] socket is not opened, state ${this.transport.readyState}`)), this.websocketCommandsQueue.push(t), this.transport.readyState === WebSocket.OPEN && this._handleCommandsQueue(this.websocketCommandsQueue);
7872
8001
  }
7873
8002
  };
7874
8003
  return new Promise((a, o) => {
@@ -7894,7 +8023,7 @@ var ho = new Set([
7894
8023
  return this.producerCommandDataChannelEnabled ? e === V.UPDATE_DISPLAY_LAYOUT || e === V.REPORT_PERF_STAT || e === V.REPORT_SHARING_STAT || e === V.REQUEST_ASR || e === V.ENABLE_VIDEO_SUSPEND || e === V.ENABLE_VIDEO_SUSPEND_SUGGEST || e === V.REPORT_NETWORK_STAT || e === V.CHANGE_SIMULCAST : !1;
7895
8024
  }
7896
8025
  _onOpen() {
7897
- this._debug.debug("[signaling] socket opened"), this._logger?.log(S.SOCKET_ACTION, "opened"), this._waitConnectionMessage(), this._logTransportStatSinceMark(this.connectionType === Cr.RETRY ? Er.RECONNECTED : Er.CONNECTED);
8026
+ this._debug.debug("[signaling] socket opened"), this._logger?.log(x.SOCKET_ACTION, "opened"), this._waitConnectionMessage(), this._logTransportStatSinceMark(this.connectionType === Cr.RETRY ? Er.RECONNECTED : Er.CONNECTED);
7898
8027
  }
7899
8028
  _onMessage(e) {
7900
8029
  if (e.data === "ping") {
@@ -7905,7 +8034,7 @@ var ho = new Set([
7905
8034
  let t = JSON.parse(e.data);
7906
8035
  R.onSignalingMessage(t), this._handleMessage(t);
7907
8036
  } catch (t) {
7908
- this._logger?.log(S.SOCKET_ACTION, "parse_error"), this._debug.error("[signaling] unable to parse message", t, e.data);
8037
+ this._logger?.log(x.SOCKET_ACTION, "parse_error"), this._debug.error("[signaling] unable to parse message", t, e.data);
7909
8038
  }
7910
8039
  }
7911
8040
  _handleMessage(e) {
@@ -7925,12 +8054,12 @@ var ho = new Set([
7925
8054
  case "error":
7926
8055
  this._handleErrorMessage(e);
7927
8056
  break;
7928
- default: this._logger?.log(S.SOCKET_ACTION, "unknown_message"), this._debug.warn("[signaling] unhandled message", e);
8057
+ default: this._logger?.log(x.SOCKET_ACTION, "unknown_message"), this._debug.warn("[signaling] unhandled message", e);
7929
8058
  }
7930
8059
  e.stamp && (this.lastStamp = e.stamp, this.transport.setLastStamp(e.stamp));
7931
8060
  }
7932
8061
  _handleErrorMessage(e) {
7933
- this._logger?.log(S.SOCKET_ACTION, `error-${e.error}`);
8062
+ this._logger?.log(x.SOCKET_ACTION, `error-${e.error}`);
7934
8063
  let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = mo(e, "Unknown signaling error");
7935
8064
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
7936
8065
  case fo.SERVICE_UNAVAILABLE:
@@ -7946,7 +8075,7 @@ var ho = new Set([
7946
8075
  });
7947
8076
  break;
7948
8077
  case fo.CONVERSATION_ENDED:
7949
- this.conversationReject ? this.conversationReject(new k(e.reason || b.SIGNALING_FAILED, {
8078
+ this.conversationReject ? this.conversationReject(new k(e.reason || y.SIGNALING_FAILED, {
7950
8079
  callError: n,
7951
8080
  message: r,
7952
8081
  remote: !0
@@ -7958,7 +8087,7 @@ var ho = new Set([
7958
8087
  break;
7959
8088
  case fo.ILLEGAL_PARTICIPANT_STATE:
7960
8089
  case fo.PARTICIPANT_NOT_FOUND:
7961
- this._throwError(new k(b.SIGNALING_FAILED, {
8090
+ this._throwError(new k(y.SIGNALING_FAILED, {
7962
8091
  callError: n,
7963
8092
  message: r,
7964
8093
  remote: !0
@@ -7974,7 +8103,7 @@ var ho = new Set([
7974
8103
  case fo.INVALID_TOKEN:
7975
8104
  default:
7976
8105
  if (e.sequence || t === Tr.WEBTRANSPORT) break;
7977
- if (this.connected) this._throwError(new k(e.reason || b.SIGNALING_FAILED, {
8106
+ if (this.connected) this._throwError(new k(e.reason || y.SIGNALING_FAILED, {
7978
8107
  callError: n ?? {
7979
8108
  scope: "unknown",
7980
8109
  description: "signaling-unrecognized-error"
@@ -7983,7 +8112,7 @@ var ho = new Set([
7983
8112
  remote: !0
7984
8113
  }));
7985
8114
  else if (!e.sequence) {
7986
- let t = new k(e.reason || b.SIGNALING_FAILED, {
8115
+ let t = new k(e.reason || y.SIGNALING_FAILED, {
7987
8116
  callError: n ?? {
7988
8117
  scope: "unknown",
7989
8118
  description: "signaling-unrecognized-error"
@@ -8006,14 +8135,14 @@ var ho = new Set([
8006
8135
  this._triggerEvent(wr.FAILED, e);
8007
8136
  }
8008
8137
  _onError(e) {
8009
- this._logger?.log(S.SOCKET_ACTION, "error"), this._debug.error("[signaling] signaling error", e), this._logTransportStat(Er.FAILED_EXCEPTIONS, { string_value: this._describeErrorEvent(e) });
8138
+ this._logger?.log(x.SOCKET_ACTION, "error"), this._debug.error("[signaling] signaling error", e), this._logTransportStat(Er.FAILED_EXCEPTIONS, { string_value: this._describeErrorEvent(e) });
8010
8139
  }
8011
8140
  _describeErrorEvent(e) {
8012
8141
  let t = e, n = t.error instanceof Error ? t.error : null, r = [n?.name || t.errorInfo?.name, n?.message || t.errorInfo?.message || t.message].filter(Boolean).join(": ") || "Unknown error", i = t.errorInfo?.phase;
8013
8142
  return (i ? `${i}: ${r}` : r).slice(0, lo);
8014
8143
  }
8015
8144
  _onClose(e) {
8016
- this._logger?.log(S.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
8145
+ this._logger?.log(x.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
8017
8146
  code: e.code,
8018
8147
  reason: e.reason
8019
8148
  }), this.connected = !1;
@@ -8065,7 +8194,7 @@ var ho = new Set([
8065
8194
  let r = this.responseHandlers[n.sequence];
8066
8195
  window.clearTimeout(r.responseTimer);
8067
8196
  let i = G.measureMark(r.statMarkName);
8068
- i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(S.SOCKET_ACTION, "response-error"), r.reject(Error(mo(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(S.SOCKET_ACTION, "response-timeout"), r.reject(Error(mo(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
8197
+ i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(x.SOCKET_ACTION, "response-error"), r.reject(Error(mo(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(x.SOCKET_ACTION, "response-timeout"), r.reject(Error(mo(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
8069
8198
  }
8070
8199
  _handleCommandsQueue(e) {
8071
8200
  for (; e.length > 0;) {
@@ -8135,7 +8264,7 @@ var ho = new Set([
8135
8264
  _waitConnectionMessage() {
8136
8265
  let t = this._getSocketType();
8137
8266
  this.connectionMessageWaitTimer = window.setTimeout(() => {
8138
- this.conversationReject && this.conversationReject(new k(b.SIGNALING_FAILED, {
8267
+ this.conversationReject && this.conversationReject(new k(y.SIGNALING_FAILED, {
8139
8268
  callError: {
8140
8269
  scope: "network",
8141
8270
  source: t,
@@ -8157,7 +8286,7 @@ var ho = new Set([
8157
8286
  _onTransportFailed(e) {
8158
8287
  switch (e.failure) {
8159
8288
  case oo.EMPTY_ENDPOINT:
8160
- this.conversationReject?.(new k(b.SIGNALING_FAILED, {
8289
+ this.conversationReject?.(new k(y.SIGNALING_FAILED, {
8161
8290
  callError: {
8162
8291
  scope: "internal",
8163
8292
  code: "configuration",
@@ -8189,7 +8318,7 @@ var ho = new Set([
8189
8318
  }
8190
8319
  }
8191
8320
  _onTransportReconnectScheduled(e) {
8192
- this.connectionType = Cr.RETRY, this._debug.log(`[signaling] reconnect signaling after ${e.delay}ms (${e.count})`), this._logger?.log(S.SOCKET_ACTION, "reconnect"), e.count === 1 && (this.reconnectStartedAt = performance.now());
8321
+ this.connectionType = Cr.RETRY, this._debug.log(`[signaling] reconnect signaling after ${e.delay}ms (${e.count})`), this._logger?.log(x.SOCKET_ACTION, "reconnect"), e.count === 1 && (this.reconnectStartedAt = performance.now());
8193
8322
  }
8194
8323
  _logReconnectTimeout() {
8195
8324
  this.reconnectStartedAt !== null && (this._logTransportStat(Er.TIMEOUT, { value: Math.round(performance.now() - this.reconnectStartedAt) }), this.reconnectStartedAt = null);
@@ -8423,10 +8552,10 @@ function Io(e) {
8423
8552
  }
8424
8553
  function Lo(e, t) {
8425
8554
  switch (e) {
8426
- case x.AUDIO: return !!t.isAudioEnabled;
8427
- case x.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
8428
- case x.VIDEO: return !!t.isVideoEnabled;
8429
- case x.SCREEN_SHARING: return !!t.isFastScreenSharingEnabled || !!t.isScreenSharingEnabled;
8555
+ case b.AUDIO: return !!t.isAudioEnabled;
8556
+ case b.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
8557
+ case b.VIDEO: return !!t.isVideoEnabled;
8558
+ case b.SCREEN_SHARING: return !!t.isFastScreenSharingEnabled || !!t.isScreenSharingEnabled;
8430
8559
  default: return !1;
8431
8560
  }
8432
8561
  }
@@ -8532,10 +8661,10 @@ var Go = class {
8532
8661
  _fixAudioDeviceNoPackets(e) {
8533
8662
  if (!(this._fixNoPacketsApplied && this._fixNoPacketsChecked)) {
8534
8663
  if (this._fixNoPacketsApplied && !this._fixNoPacketsChecked) {
8535
- this._fixNoPacketsChecked = !0, this._logger?.log(S.ERROR, `audio_device_recover_${e.bandwidth ? "success" : "fail"}`);
8664
+ this._fixNoPacketsChecked = !0, this._logger?.log(x.ERROR, `audio_device_recover_${e.bandwidth ? "success" : "fail"}`);
8536
8665
  return;
8537
8666
  }
8538
- !this._fixNoPacketsApplied && !e.bandwidth && e.packetsSent > 0 && (this._fixNoPacketsApplied = !0, this._logger?.log(S.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(E.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
8667
+ !this._fixNoPacketsApplied && !e.bandwidth && e.packetsSent > 0 && (this._fixNoPacketsApplied = !0, this._logger?.log(x.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(E.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
8539
8668
  }
8540
8669
  }
8541
8670
  _fixAudioDeviceTooManyPackets(e) {
@@ -8544,7 +8673,7 @@ var Go = class {
8544
8673
  if (!this._lastPacketsSentTime) e.packetsSent > 0 && (this._lastPacketsSentTime = t, this._lastPacketsSent = e.packetsSent);
8545
8674
  else if (t - this._lastPacketsSentTime > 500) {
8546
8675
  let n = (e.packetsSent - this._lastPacketsSent) * 1e3 / (t - this._lastPacketsSentTime);
8547
- this._lastPacketsSentTime = t, this._lastPacketsSent = e.packetsSent, this._fixTooManyPacketsApplied ? n > 75 ? (this._debug.log("[AudioFix] Failed to fix RV"), this._logger?.log(S.ERROR, "audio_device_recover_rv_fail"), this._fixTooManyPacketsFailed = !0) : t - this._fixTooManyPacketsTime > 6e4 && (this._debug.log("[AudioFix] Fixed RV"), this._logger?.log(S.ERROR, "audio_device_recover_rv_success"), this._fixTooManyPacketsSucceeded = !0) : n > 75 && (this._fixTooManyPacketsApplied = !0, this._logger?.log(S.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (too many packets)"), this._mediaSource.toggleAudio(!0).catch((e) => {
8676
+ this._lastPacketsSentTime = t, this._lastPacketsSent = e.packetsSent, this._fixTooManyPacketsApplied ? n > 75 ? (this._debug.log("[AudioFix] Failed to fix RV"), this._logger?.log(x.ERROR, "audio_device_recover_rv_fail"), this._fixTooManyPacketsFailed = !0) : t - this._fixTooManyPacketsTime > 6e4 && (this._debug.log("[AudioFix] Fixed RV"), this._logger?.log(x.ERROR, "audio_device_recover_rv_success"), this._fixTooManyPacketsSucceeded = !0) : n > 75 && (this._fixTooManyPacketsApplied = !0, this._logger?.log(x.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (too many packets)"), this._mediaSource.toggleAudio(!0).catch((e) => {
8548
8677
  this._debug.warn("[AudioFix] Failed to fix RV (too many packets)", e);
8549
8678
  }), this._fixTooManyPacketsTime = t);
8550
8679
  }
@@ -8604,7 +8733,7 @@ var Go = class {
8604
8733
  let e = E.getSavedOutput();
8605
8734
  e && (await this._audioElement.setSinkId?.(e.deviceId), this._debug.debug("[audio] Output device changed", e));
8606
8735
  } catch (e) {
8607
- throw this._logger?.log(S.ERROR, "change_output"), this._debug.error("[audio] Output change failed", e), e;
8736
+ throw this._logger?.log(x.ERROR, "change_output"), this._debug.error("[audio] Output change failed", e), e;
8608
8737
  }
8609
8738
  }
8610
8739
  _getTracks() {
@@ -8660,11 +8789,11 @@ var Go = class {
8660
8789
  this._autoplayRecoveryController?.abort(), this._autoplayRecoveryController = null;
8661
8790
  }
8662
8791
  _createAudioElement() {
8663
- let e = w.browserName() !== "Safari" || w.isMobile() || N.safariAudioElement;
8792
+ let e = C.browserName() !== "Safari" || C.isMobile() || N.safariAudioElement;
8664
8793
  return document.createElement(e ? "audio" : "video");
8665
8794
  }
8666
8795
  _prepareAudioElement() {
8667
- if (N.muteMode || w.browserName() !== "Safari" || w.isMobile()) return null;
8796
+ if (N.muteMode || C.browserName() !== "Safari" || C.isMobile()) return null;
8668
8797
  let e = this._createAudioElement();
8669
8798
  return e.load(), e;
8670
8799
  }
@@ -8709,7 +8838,7 @@ function Yo(e, t) {
8709
8838
  }
8710
8839
  //#endregion
8711
8840
  //#region src/classes/DebugInfo.ts
8712
- var Xo = 90, Zo = 3, Qo = class extends Je {
8841
+ var Xo = 90, Zo = 3, Qo = class extends Ye {
8713
8842
  constructor(e = z) {
8714
8843
  super(), h(this, "_lastMemoryStat", {
8715
8844
  percent: 0,
@@ -8848,7 +8977,7 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
8848
8977
  try {
8849
8978
  E.retainAudioContext(this);
8850
8979
  let e = E.getAudioContext();
8851
- this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, w.browserName() === "Safari" && (this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser.connect(this._gainNode)), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8980
+ this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, C.browserName() === "Safari" && (this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser.connect(this._gainNode)), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8852
8981
  } catch {
8853
8982
  this.destroy();
8854
8983
  }
@@ -8875,7 +9004,7 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
8875
9004
  destroy() {
8876
9005
  this._mediaStreamSource && (this._mediaStreamSource.disconnect(), this._mediaStreamSource = null), this._gainNode && (this._gainNode.disconnect(), this._gainNode = null), this._analyser && (this._analyser.disconnect(), this._analyser = null, this._fftBins = null, this._lastSmoothedLevel = 0), this._stream.removeTrack(this._track), E.releaseAudioContext(this);
8877
9006
  }
8878
- }, ns = class extends Je {
9007
+ }, ns = class extends Ye {
8879
9008
  constructor(e) {
8880
9009
  super(), h(this, "_detector", null), h(this, "_interval", null);
8881
9010
  let t = () => {
@@ -8921,7 +9050,7 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
8921
9050
  }
8922
9051
  }, is = /* @__PURE__ */ function(e) {
8923
9052
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8924
- }({}), as = class extends Je {
9053
+ }({}), as = class extends Ye {
8925
9054
  constructor(e) {
8926
9055
  super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, Y.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8927
9056
  }
@@ -8985,7 +9114,7 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
8985
9114
  }
8986
9115
  }, os = /* @__PURE__ */ function(e) {
8987
9116
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8988
- }({}), ss = class extends Je {
9117
+ }({}), ss = class extends Ye {
8989
9118
  constructor(e, t, n) {
8990
9119
  super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, is.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, Y.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8991
9120
  }
@@ -9009,7 +9138,7 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
9009
9138
  _onTopologyChanged(e) {
9010
9139
  this._serverSideSpeakerDetection = e === J.SERVER;
9011
9140
  }
9012
- }, cs = 15e3, ls = 15e3, us = class extends Je {
9141
+ }, cs = 15e3, ls = 15e3, us = class extends Ye {
9013
9142
  constructor(e, t, n, r = z, i = null) {
9014
9143
  super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, is.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
9015
9144
  }
@@ -9029,7 +9158,7 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
9029
9158
  return this._transport.getTopology() === J.DIRECT ? ls : N.specListenerParams.volumeTimeout;
9030
9159
  }
9031
9160
  _onTransportStateChanged(e, t) {
9032
- t === q.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === q.CONNECTED && (this._volumeTimeout || (this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout())), this._volumeTimeout && (window.clearTimeout(this._volumeTimeout), this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout()))), t === q.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(S.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
9161
+ t === q.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === q.CONNECTED && (this._volumeTimeout || (this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout())), this._volumeTimeout && (window.clearTimeout(this._volumeTimeout), this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout()))), t === q.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(x.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
9033
9162
  }
9034
9163
  _onVolumesDetected(e) {
9035
9164
  Object.keys(e).forEach((t) => {
@@ -9049,14 +9178,14 @@ var Xo = 90, Zo = 3, Qo = class extends Je {
9049
9178
  }
9050
9179
  t = !0;
9051
9180
  }
9052
- }), this._connectionTimeoutSuppressed = e && !t, t && (this._debug.warn("There is not connected transport, send callSpecError"), this._logger?.log(S.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
9181
+ }), this._connectionTimeoutSuppressed = e && !t, t && (this._debug.warn("There is not connected transport, send callSpecError"), this._logger?.log(x.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
9053
9182
  }
9054
9183
  _onVolumeTimeout() {
9055
9184
  let e = [];
9056
9185
  Object.keys(this._volumes).forEach((t) => {
9057
9186
  if (this._volumes[t] > 0 || this._participants[t]?.isOnHold) return;
9058
9187
  let n = "UNKNOWN", r = this._participants[t];
9059
- r && r.platform && (n = r.platform), e.indexOf(n) < 0 && (e.push(n), this._logger?.log(S.CALL_SPEC_ERROR, `${this._transport.getTopology()}_VOLUME_TIMEOUT_${n}`));
9188
+ r && r.platform && (n = r.platform), e.indexOf(n) < 0 && (e.push(n), this._logger?.log(x.CALL_SPEC_ERROR, `${this._transport.getTopology()}_VOLUME_TIMEOUT_${n}`));
9060
9189
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
9061
9190
  }
9062
9191
  }, ds = /* @__PURE__ */ function(e) {
@@ -9307,7 +9436,7 @@ async function js(e, t = {}, n = !1) {
9307
9436
  return Ms(r, void 0, new Blob([r]).size <= ws);
9308
9437
  }
9309
9438
  async function Ms(e, t, n = !1) {
9310
- let r = `${t ?? Ss}/fb.do`, i = new AbortController(), a = new k(b.NETWORK, { callError: {
9439
+ let r = `${t ?? Ss}/fb.do`, i = new AbortController(), a = new k(y.NETWORK, { callError: {
9311
9440
  scope: "network",
9312
9441
  source: "api",
9313
9442
  code: "timeout",
@@ -9326,7 +9455,7 @@ async function Ms(e, t, n = !1) {
9326
9455
  } catch {
9327
9456
  o = { result: a };
9328
9457
  }
9329
- if (!t.ok && !Ns(o)) throw new k(b.API, { callError: {
9458
+ if (!t.ok && !Ns(o)) throw new k(y.API, { callError: {
9330
9459
  scope: "server",
9331
9460
  source: "api",
9332
9461
  code: `http-${t.status}`,
@@ -9335,7 +9464,7 @@ async function Ms(e, t, n = !1) {
9335
9464
  if (Ns(o)) throw o;
9336
9465
  return o;
9337
9466
  } catch (e) {
9338
- throw e instanceof k ? e : i.signal.aborted ? a : Ns(e) ? e : new k(b.NETWORK, { callError: {
9467
+ throw e instanceof k ? e : i.signal.aborted ? a : Ns(e) ? e : new k(y.NETWORK, { callError: {
9339
9468
  scope: "network",
9340
9469
  source: "api",
9341
9470
  code: "fetch-failed",
@@ -9364,7 +9493,7 @@ async function Ps(e, t) {
9364
9493
  }
9365
9494
  }
9366
9495
  function Fs(e, t = {}, n = !1) {
9367
- 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));
9496
+ t.method = e, t.format = "JSON", t.application_key || (t.application_key = N.apiKey), n || (v.sessionKey ? t.session_key = v.sessionKey : v.accessToken && (t.access_token = v.accessToken));
9368
9497
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
9369
9498
  let r = "";
9370
9499
  for (let [e, n] of Object.entries(t)) r && (r += "&"), r += `${e}=${encodeURIComponent(n)}`;
@@ -9443,7 +9572,7 @@ var Is = "sessions", Ls = 5, Rs = class e {
9443
9572
  e._api = null, e._delta = null, e._pending = null, e._idsAwaitingDelta = [], e._lastFailureAt = null;
9444
9573
  }
9445
9574
  static _hasCredentials() {
9446
- return !!y.sessionKey || !!y.accessToken;
9575
+ return !!v.sessionKey || !!v.accessToken;
9447
9576
  }
9448
9577
  static async _measure() {
9449
9578
  let t;
@@ -9579,7 +9708,7 @@ var Us = 500, Ws = 100, Gs = 3e4, Ks = 1e3, qs = 5e3, Js = 3e3, Ys = "okcls-stat
9579
9708
  Bs.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9580
9709
  }
9581
9710
  static _currentUserId() {
9582
- return y.userId;
9711
+ return v.userId;
9583
9712
  }
9584
9713
  static async _drainCurrent(t, n) {
9585
9714
  if (e._isSessionBlocked()) return 0;
@@ -9617,13 +9746,13 @@ var Us = 500, Ws = 100, Gs = 3e4, Ks = 1e3, qs = 5e3, Js = 3e3, Ys = "okcls-stat
9617
9746
  return fs(e?.error_code);
9618
9747
  }
9619
9748
  static _isReauthorizeFailure(e) {
9620
- return e?.error === b.AUTH;
9749
+ return e?.error === y.AUTH;
9621
9750
  }
9622
9751
  static _blockSession() {
9623
- e._blockedSession = { key: y.sessionKey };
9752
+ e._blockedSession = { key: v.sessionKey };
9624
9753
  }
9625
9754
  static _isSessionBlocked() {
9626
- return e._blockedSession ? e._blockedSession.key === y.sessionKey ? !0 : (e._blockedSession = null, !1) : !1;
9755
+ return e._blockedSession ? e._blockedSession.key === v.sessionKey ? !0 : (e._blockedSession = null, !1) : !1;
9627
9756
  }
9628
9757
  static _isAuthError(t) {
9629
9758
  let n = t?.error_code;
@@ -9822,7 +9951,7 @@ var Zs = class extends f {
9822
9951
  ts: i,
9823
9952
  delta: Bs.delta(),
9824
9953
  ev: a
9825
- }, s = y.userId;
9954
+ }, s = v.userId;
9826
9955
  if (s === null) {
9827
9956
  e._remember(o);
9828
9957
  return;
@@ -9916,7 +10045,7 @@ var $s = class {
9916
10045
  }
9917
10046
  this._destroyed || (this._battery = t, t.addEventListener("levelchange", this._handleLevelChange), t.addEventListener("chargingchange", this._handleChargingChange));
9918
10047
  }
9919
- }, nc = "invalid-error-metadata", rc = 64, ic = new Set(Object.values(O)), ac = new Set(Object.values(b)), oc = {
10048
+ }, nc = "invalid-error-metadata", rc = 64, ic = new Set(Object.values(O)), ac = new Set(Object.values(y)), oc = {
9920
10049
  [O.CANCELED]: {
9921
10050
  type: "semantic",
9922
10051
  reason: "canceled"
@@ -10038,7 +10167,7 @@ var $s = class {
10038
10167
  reason: "obsolete_client"
10039
10168
  }
10040
10169
  }, sc = {
10041
- [b.MIC_CAMERA_PERMISSION]: {
10170
+ [y.MIC_CAMERA_PERMISSION]: {
10042
10171
  type: "direct-error",
10043
10172
  error: {
10044
10173
  scope: "internal",
@@ -10046,7 +10175,7 @@ var $s = class {
10046
10175
  description: "mic-camera-permission"
10047
10176
  }
10048
10177
  },
10049
- [b.CAMERA_PERMISSION]: {
10178
+ [y.CAMERA_PERMISSION]: {
10050
10179
  type: "direct-error",
10051
10180
  error: {
10052
10181
  scope: "internal",
@@ -10054,7 +10183,7 @@ var $s = class {
10054
10183
  description: "camera-permission"
10055
10184
  }
10056
10185
  },
10057
- [b.MIC_PERMISSION]: {
10186
+ [y.MIC_PERMISSION]: {
10058
10187
  type: "direct-error",
10059
10188
  error: {
10060
10189
  scope: "internal",
@@ -10062,7 +10191,7 @@ var $s = class {
10062
10191
  description: "microphone-permission"
10063
10192
  }
10064
10193
  },
10065
- [b.CAMERA_ACCESS]: {
10194
+ [y.CAMERA_ACCESS]: {
10066
10195
  type: "direct-error",
10067
10196
  error: {
10068
10197
  scope: "internal",
@@ -10070,7 +10199,7 @@ var $s = class {
10070
10199
  description: "camera-access"
10071
10200
  }
10072
10201
  },
10073
- [b.MIC_ACCESS]: {
10202
+ [y.MIC_ACCESS]: {
10074
10203
  type: "direct-error",
10075
10204
  error: {
10076
10205
  scope: "internal",
@@ -10078,7 +10207,7 @@ var $s = class {
10078
10207
  description: "microphone-access"
10079
10208
  }
10080
10209
  },
10081
- [b.MIC_NOT_FOUND]: {
10210
+ [y.MIC_NOT_FOUND]: {
10082
10211
  type: "direct-error",
10083
10212
  error: {
10084
10213
  scope: "internal",
@@ -10086,7 +10215,7 @@ var $s = class {
10086
10215
  description: "microphone-not-found"
10087
10216
  }
10088
10217
  },
10089
- [b.SCREEN_PERMISSION]: {
10218
+ [y.SCREEN_PERMISSION]: {
10090
10219
  type: "direct-error",
10091
10220
  error: {
10092
10221
  scope: "internal",
@@ -10094,7 +10223,7 @@ var $s = class {
10094
10223
  description: "screen-permission"
10095
10224
  }
10096
10225
  },
10097
- [b.SCREEN_ACCESS]: {
10226
+ [y.SCREEN_ACCESS]: {
10098
10227
  type: "direct-error",
10099
10228
  error: {
10100
10229
  scope: "internal",
@@ -10102,7 +10231,7 @@ var $s = class {
10102
10231
  description: "screen-access"
10103
10232
  }
10104
10233
  },
10105
- [b.CONNECTION]: {
10234
+ [y.CONNECTION]: {
10106
10235
  type: "direct-error",
10107
10236
  error: {
10108
10237
  scope: "network",
@@ -10111,13 +10240,13 @@ var $s = class {
10111
10240
  description: "connection-failed"
10112
10241
  }
10113
10242
  },
10114
- [b.NETWORK]: { type: "requires-call-error" },
10115
- [b.UNKNOWN]: { type: "failed" },
10116
- [b.UNSUPPORTED]: { type: "requires-call-error" },
10117
- [b.SIGNALING_FAILED]: { type: "requires-call-error" },
10118
- [b.API]: { type: "requires-call-error" },
10119
- [b.AUTH]: { type: "requires-call-error" },
10120
- [b.OVERCONSTRAINED]: {
10243
+ [y.NETWORK]: { type: "requires-call-error" },
10244
+ [y.UNKNOWN]: { type: "failed" },
10245
+ [y.UNSUPPORTED]: { type: "requires-call-error" },
10246
+ [y.SIGNALING_FAILED]: { type: "requires-call-error" },
10247
+ [y.API]: { type: "requires-call-error" },
10248
+ [y.AUTH]: { type: "requires-call-error" },
10249
+ [y.OVERCONSTRAINED]: {
10121
10250
  type: "direct-error",
10122
10251
  error: {
10123
10252
  scope: "internal",
@@ -10629,14 +10758,16 @@ function jc(e, t, n, r) {
10629
10758
  message: r
10630
10759
  });
10631
10760
  }
10632
- var Mc = 15, $ = class e extends Je {
10761
+ var Mc = 15, $ = class e extends Ye {
10633
10762
  constructor(e, t) {
10634
- 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) => {
10635
- if (this._mediaSource) return this._stats.logger.log(S.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
10763
+ 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, "_requestingLocalMedia", !1), h(this, "_requestedLocalAudio", void 0), h(this, "_requestedLocalVideo", void 0), 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, "_serverConversationId", null), h(this, "_onFastHangup", void 0), h(this, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_hangupReason", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_pendingId", null), h(this, "_resolveSignalingInitialization", void 0), h(this, "_signalingInitialization", new Promise((e) => {
10764
+ this._resolveSignalingInitialization = e;
10765
+ })), 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) => {
10766
+ if (this._mediaSource) return this._stats.logger.log(x.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
10636
10767
  })), h(this, "_toggleLocalAudio", Wo((e) => {
10637
- if (this._mediaSource) return this._stats.logger.log(S.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
10768
+ if (this._mediaSource) return this._stats.logger.log(x.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
10638
10769
  })), h(this, "_changeMediaSettings", M.debounce(async (e) => {
10639
- if (this._signaling.ready) try {
10770
+ if (!(!this._signaling.ready || !this._transport || this.isCallHeld)) try {
10640
10771
  await this._signaling.changeMediaSettings(e);
10641
10772
  } catch (e) {
10642
10773
  if (this._debug.warn("changeMediaSettings failed with error", e), e.message === "chatRoom.maxShareCountExceeded") return this.toggleScreenCapturing({
@@ -10666,24 +10797,11 @@ var Mc = 15, $ = class e extends Je {
10666
10797
  static current() {
10667
10798
  return B.getActive() ?? (N.hold ? null : B.getFirst());
10668
10799
  }
10669
- static hangupAfterInit(e) {
10670
- let t = Nc;
10671
- if (t) {
10672
- if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
10673
- t._delayedHangup = !0, t._abortController?.abort(new k(O.CANCELED));
10674
- return;
10675
- }
10676
- t._conversation && t.hangup({
10677
- onFastHangup: e,
10678
- reason: O.CANCELED
10679
- });
10680
- }
10681
- }
10682
10800
  static id() {
10683
10801
  return B.getActiveId();
10684
10802
  }
10685
10803
  get id() {
10686
- return this._conversation?.id ?? "";
10804
+ return this._conversation?.id ?? this._pendingId ?? "";
10687
10805
  }
10688
10806
  get externalId() {
10689
10807
  return this._conversation?.externalId;
@@ -10740,16 +10858,18 @@ var Mc = 15, $ = class e extends Je {
10740
10858
  this._stats.lifecycle.markInitializationStarted({
10741
10859
  source: "outgoing",
10742
10860
  conversationId: u
10743
- }), this._debug.setConversationId(u), Nc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10861
+ }), this._debug.setConversationId(u), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10744
10862
  try {
10745
- this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
10746
- let l = this._mediaSource.mediaSettings;
10747
- t === vo.CHAT || e && e.length > 1 ? this._logWithMediaSettings(S.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(S.OUTGOING_CALL, l);
10748
- let d = await this._startConversation({
10863
+ this._registerPending(u), this._mediaSource = this._createMediaSource(), B.selectPending(this);
10864
+ let l = await this._requestLocalMedia(n);
10865
+ this._throwIfClosed();
10866
+ let d = this._mediaSource.mediaSettings;
10867
+ t === vo.CHAT || e && e.length > 1 ? this._logWithMediaSettings(x.OUTGOING_MULTIPARTY_CALL, d) : this._logWithMediaSettings(x.OUTGOING_CALL, d);
10868
+ let p = await this._startConversation({
10749
10869
  opponentIds: e,
10750
10870
  opponentType: t,
10751
10871
  direction: _o.OUTGOING,
10752
- mediaOptions: n,
10872
+ mediaOptions: l,
10753
10873
  payload: r,
10754
10874
  joiningAllowed: i,
10755
10875
  requireAuthToJoin: a,
@@ -10758,66 +10878,70 @@ var Mc = 15, $ = class e extends Je {
10758
10878
  onFastStart: c,
10759
10879
  conversationId: u
10760
10880
  });
10761
- if (!this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10881
+ if (this._throwIfClosed(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10762
10882
  scope: "internal",
10763
10883
  code: "conversation",
10764
10884
  description: "not-initialized-after-start"
10765
10885
  } });
10766
- if (this._participantState = X.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new k(O.CANCELED);
10767
- if (this._debug.debug("Outgoing call", {
10768
- opponentIds: e,
10769
- opponentType: t,
10770
- mediaOptions: n
10771
- }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), this._conversation?.concurrent) {
10886
+ if (this._participantState = X.ACCEPTED, await this._processConnection(p), this._throwIfClosed(), this._conversation?.concurrent) {
10772
10887
  let e = B.get(this._conversation.id);
10773
10888
  e && e !== this && e._close(new k(O.HUNGUP, { remote: !0 }));
10774
10889
  }
10775
- return B.add(this), await B.setActive(this.id), Nc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10890
+ return await this._applyInitialActiveSelection(), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._changeMediaSettings(this._mediaSource.mediaSettings), this._signaling.readyToSend(), this._throwIfClosed(), this._debug.debug("Outgoing call", {
10891
+ opponentIds: e,
10892
+ opponentType: t,
10893
+ mediaOptions: n
10894
+ }), this._processConnectionSharedMovieInfo(p), this._processConversationUrlSharingInfo(p), R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(p), this._processPinnedParticipants(p), R.onLocalStatus(this.isCallHeld ? P.ONHOLD : P.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), this._conversation.concurrent && (await this._acceptConcurrent(), this._throwIfClosed()), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10776
10895
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
10777
- }, f)), this._conversation;
10896
+ }, f)), this._completeSignalingInitialization(), this._conversation;
10778
10897
  } catch (e) {
10779
- throw Nc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10898
+ throw this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10780
10899
  }
10781
10900
  }
10782
10901
  async onJoin(e) {
10783
10902
  this._stats.lifecycle.markInitializationStarted({
10784
10903
  source: e.anonymous ? "anonym_join" : "join",
10785
10904
  conversationId: e.conversationId
10786
- }), Nc = 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);
10905
+ }), 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);
10787
10906
  try {
10907
+ this._registerPending(e.conversationId);
10788
10908
  let t = !!e.observedIds?.length;
10789
10909
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
10790
10910
  scope: "internal",
10791
10911
  code: "observer-mode",
10792
10912
  description: "video-tracks-count-must-be-zero"
10793
10913
  } });
10794
- this._mediaSource = this._createMediaSource(), await this._mediaSource.request(e.mediaOptions, !t);
10795
- let n = this._mediaSource.mediaSettings;
10796
- this._logWithMediaSettings(S.JOIN_CONVERSATION, n);
10797
- let r = await this._joinConversation(e);
10798
- if (!this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10914
+ this._mediaSource = this._createMediaSource();
10915
+ let n = B.selectPending(this), r = await this._requestLocalMedia(e.mediaOptions, !t);
10916
+ this._throwIfClosed();
10917
+ let i = this._mediaSource.mediaSettings;
10918
+ this._logWithMediaSettings(x.JOIN_CONVERSATION, i);
10919
+ let a = await this._joinConversation({
10920
+ ...e,
10921
+ mediaOptions: r
10922
+ });
10923
+ if (this._throwIfClosed(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10799
10924
  scope: "internal",
10800
10925
  code: "conversation",
10801
10926
  description: "not-initialized-after-join"
10802
10927
  } });
10803
- 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), Nc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
10928
+ return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), B.releaseSelection(this, n), this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id)) : await this._onJoinPart2(a), this._completeSignalingInitialization(), this._conversation;
10804
10929
  } catch (e) {
10805
- throw Nc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10930
+ throw this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10806
10931
  }
10807
10932
  }
10808
10933
  async _onJoinPart2(e, t = !0, n = !1) {
10809
10934
  this._debug.debug("Join conversation part 2");
10810
10935
  try {
10811
- if (this._participantState = X.ACCEPTED, !this._conversation || !this._mediaSource) throw new k(O.UNKNOWN_ERROR, { callError: {
10936
+ if (this._throwIfClosed(), this._participantState = X.ACCEPTED, !this._conversation || !this._mediaSource) throw new k(O.UNKNOWN_ERROR, { callError: {
10812
10937
  scope: "internal",
10813
10938
  code: "join",
10814
10939
  description: "runtime-not-initialized"
10815
10940
  } });
10816
- if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), !n && !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(this._mediaSource.mediaSettings), await this._processConnection(e), t && (this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener()), this._signaling.readyToSend(), this._state === "CLOSE") return this._conversation;
10817
- if (this._delayedHangup) throw new k(O.CANCELED);
10818
- this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
10941
+ if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), await this._processConnection(e), this._throwIfClosed(), t && (this.isCallHeld ? this._previousState = "ACTIVE" : this._state = "ACTIVE", n ? (await this._holdLocally(), B.add(this), B.releaseSelection(this)) : await this._applyInitialActiveSelection(), this._throwIfClosed(), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener()), !this.isCallHeld && !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(this._mediaSource.mediaSettings), this._signaling.readyToSend(), this._state === "CLOSE") return this._conversation;
10942
+ this._throwIfClosed(), this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
10819
10943
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
10820
- 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), Nc = null);
10944
+ R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(t && this.isCallHeld ? P.ONHOLD : P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._changeFeatureSet();
10821
10945
  let i = this._extractLocalParticipantFromConnection(e);
10822
10946
  if (i) {
10823
10947
  let e = M.mapParticipantState(i);
@@ -10825,7 +10949,7 @@ var Mc = 15, $ = class e extends Je {
10825
10949
  }
10826
10950
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
10827
10951
  } catch (e) {
10828
- throw Nc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10952
+ throw this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10829
10953
  }
10830
10954
  }
10831
10955
  _extractExternalRooms(e) {
@@ -10841,22 +10965,22 @@ var Mc = 15, $ = class e extends Je {
10841
10965
  return t && (n.roomId = t), n;
10842
10966
  }
10843
10967
  async onPush(e, t = j.USER, n, r, i, a) {
10844
- if (B.has(e)) throw new k(O.HAS_ACTIVE_CALL);
10845
- B.reserve(e), this._reservedId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
10968
+ this._registerPending(e), this._serverConversationId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
10846
10969
  source: "incoming",
10847
10970
  conversationId: e
10848
- }), this._debug.setConversationId(e), Nc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10971
+ }), this._debug.setConversationId(e), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10849
10972
  try {
10973
+ this._mediaSource = this._createMediaSource();
10850
10974
  let a = await this._prepareConversation(e, t, n, r, i);
10851
- if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10975
+ if (this._throwIfClosed(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10852
10976
  scope: "internal",
10853
10977
  code: "conversation",
10854
10978
  description: "incoming-not-initialized"
10855
10979
  } });
10856
- 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);
10857
- 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), Nc = null, this._delayedHangup) throw new k(O.CANCELED);
10980
+ 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(x.PUSH, "rejected"), new k(O.REJECTED);
10981
+ await this._processConnection(a), this._throwIfClosed(), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(x.PUSH, "accepted"), B.add(this), this._completeSignalingInitialization();
10858
10982
  } catch (e) {
10859
- throw Nc = null, this._cleanupRegistry(), this._close(e, {
10983
+ throw this._cleanupRegistry(), this._close(e, {
10860
10984
  errorText: "Unable to handle inbound call push",
10861
10985
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
10862
10986
  }), e;
@@ -10881,16 +11005,16 @@ var Mc = 15, $ = class e extends Je {
10881
11005
  return this._conversation?.audienceMode && this._conversation?.restricted;
10882
11006
  }
10883
11007
  async _acceptConcurrent() {
10884
- if (!this._mediaSource || !this._conversation || !this._transport) throw new k(O.UNKNOWN_ERROR, { callError: {
11008
+ if (!this._mediaSource || !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
10885
11009
  scope: "internal",
10886
11010
  code: "accept",
10887
11011
  description: "runtime-not-initialized"
10888
11012
  } });
10889
- this._state = "PROCESSING";
11013
+ this.isCallHeld || (this._state = "PROCESSING");
10890
11014
  let e = this._mediaSource.mediaSettings;
10891
- this._logWithMediaSettings(S.ACCEPT_CONCURRENT, e), this._debug.debug("Concurrent call", { conversationId: this._conversation.id });
11015
+ this._logWithMediaSettings(x.ACCEPT_CONCURRENT, e), this._debug.debug("Concurrent call", { conversationId: this._conversation.id });
10892
11016
  try {
10893
- this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), R.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = X.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(this._participants), !0);
11017
+ this._statFirstMediaReceived.markAcceptCall(this._conversation.topology), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._throwIfClosed(), this._stats.lifecycle.markIncomingAccepted(!0), R.onCallAccepted(this.id), this.isCallHeld ? this._previousState = "ACTIVE" : this._state = "ACTIVE", this._participantState = X.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(this._participants), !0);
10894
11018
  } catch (e) {
10895
11019
  this._close(e, { errorText: "Unable to accept concurrent call" });
10896
11020
  }
@@ -10923,7 +11047,7 @@ var Mc = 15, $ = class e extends Je {
10923
11047
  }
10924
11048
  }
10925
11049
  async accept(e) {
10926
- if (this._state !== "IDLE") throw this._stats.logger.log(S.ERROR, "acceptIncoming"), this._debug.error("Unable to accept a call - invalid state"), Error("Unable to accept a call - invalid state");
11050
+ if (this._state !== "IDLE") throw this._stats.logger.log(x.ERROR, "acceptIncoming"), this._debug.error("Unable to accept a call - invalid state"), Error("Unable to accept a call - invalid state");
10927
11051
  if (!this._mediaSource || !this._conversation || !this._transport) throw new k(O.UNKNOWN_ERROR, { callError: {
10928
11052
  scope: "internal",
10929
11053
  code: "accept",
@@ -10931,9 +11055,9 @@ var Mc = 15, $ = class e extends Je {
10931
11055
  } });
10932
11056
  this._state = "PROCESSING", this._debug.setConversationId(this._conversation.id), this._debug.debug("Accept incoming call", e);
10933
11057
  try {
10934
- await this._mediaSource.request(e);
11058
+ await this._requestLocalMedia(e), this._throwIfClosed();
10935
11059
  let t = this._mediaSource.mediaSettings;
10936
- this._logWithMediaSettings(S.ACCEPT_INCOMING, t), this._changeMediaSettings(t), this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(t), this._stats.lifecycle.markIncomingAccepted(!1), this._participantState = X.ACCEPTED;
11060
+ this._logWithMediaSettings(x.ACCEPT_INCOMING, t), this._changeMediaSettings(t), this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(t), this._throwIfClosed(), this._stats.lifecycle.markIncomingAccepted(!1), this._participantState = X.ACCEPTED;
10937
11061
  let n = this._getMuteStatesForCurrentRoom(), r = Object.keys(n);
10938
11062
  r.length && this._onMuteParticipant({
10939
11063
  muteStates: n,
@@ -10942,7 +11066,7 @@ var Mc = 15, $ = class e extends Je {
10942
11066
  stateUpdated: !0
10943
11067
  }), this._registerParticipantLocalMuteState({ muteStates: this._conversation.muteStatesPersonal });
10944
11068
  let i = await this._signaling.getRooms(this._isCallAdmin());
10945
- if (i.rooms?.rooms?.length) {
11069
+ if (this._throwIfClosed(), i.rooms?.rooms?.length) {
10946
11070
  let e = this._participants;
10947
11071
  i.rooms.rooms.forEach((t) => {
10948
11072
  t.participantIds?.forEach((t) => {
@@ -10952,39 +11076,54 @@ var Mc = 15, $ = class e extends Je {
10952
11076
  }
10953
11077
  this._conversation.roomId = i.rooms?.roomId || null;
10954
11078
  let a = this._extractExternalRoomsData(i.rooms?.rooms, i.rooms?.roomId);
10955
- if (R.onCallAccepted(this.id), R.onLocalStream(this._mediaSource.getStream(), t, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), a, this.id), await this._emitHeldParticipantsStatus(), N.useParticipantListChunk) {
10956
- let e = await this._getInitialParticiapntListChunk(), t = this._participants;
11079
+ if (R.onCallAccepted(this.id), R.onLocalStream(this._mediaSource.getStream(), t, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), a, this.id), await this._emitHeldParticipantsStatus(), this._throwIfClosed(), N.useParticipantListChunk) {
11080
+ let e = await this._getInitialParticiapntListChunk();
11081
+ this._throwIfClosed();
11082
+ let t = this._participants;
10957
11083
  e?.participants?.forEach((e) => {
10958
11084
  let n = t[M.composeId(e)];
10959
11085
  n && (n.movieShareInfos = e.movieShareInfos);
10960
11086
  }), this._onConversationParticipantListChunk({ participants: e });
10961
11087
  }
10962
- return R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), this._openTransport(Object.values(this._participants), !0), this._processConversationUrlSharingInfo(), this._processConnectionAsrInfo(), B.setActive(this.id).catch((e) => {
10963
- this._debug.error(e), this._close(e, { errorText: "Unable to activated accepted call" });
10964
- }), this._conversation;
11088
+ return R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), await B.setActive(this.id), this._throwIfClosed(), this._openTransport(Object.values(this._participants), !0), this._processConversationUrlSharingInfo(), this._processConnectionAsrInfo(), this._conversation;
10965
11089
  } catch (e) {
10966
11090
  throw this._close(e, { errorText: "Unable to accept call" }), e;
10967
11091
  }
10968
11092
  }
10969
11093
  async decline(e) {
10970
- if (this._state !== "IDLE") throw this._stats.logger.log(S.ERROR, "declineIncoming"), this._debug.error("Unable to decline a call - invalid state"), Error("Unable to decline a call - invalid state");
11094
+ if (this._state !== "IDLE") throw this._stats.logger.log(x.ERROR, "declineIncoming"), this._debug.error("Unable to decline a call - invalid state"), Error("Unable to decline a call - invalid state");
10971
11095
  let t = e?.reason;
10972
- this._state = "PROCESSING", this._debug.debug("Decline incoming call"), this._logWithMediaSettings(S.DECLINE_INCOMING, this.mediaSettings), this._participantState = X.HUNGUP;
11096
+ this._state = "PROCESSING", this._debug.debug("Decline incoming call"), this._logWithMediaSettings(x.DECLINE_INCOMING, this.mediaSettings), this._participantState = X.HUNGUP;
10973
11097
  let n = t ?? O.REJECTED, r = new k(n);
10974
11098
  this._finishLifecycle(r), this._onFastHangup = e?.onFastHangup ?? this._onFastHangup;
10975
11099
  let i = this._conversation?.id;
10976
- i && typeof this._onFastHangup == "function" && this._sendHangup(i, n, this._onFastHangup), this._close(r, { signalingReason: n });
11100
+ i && typeof this._onFastHangup == "function" && this._sendHangup(i, n, this._onFastHangup, this._abortController?.signal).catch((e) => this._debug.error("Fast hangup error", e)), this._close(r, { signalingReason: n });
10977
11101
  }
10978
11102
  hangup(e) {
10979
11103
  if (this._hangupPromise) return this._hangupPromise;
10980
- let t = e?.reason;
10981
- this._clearCalleeUnavailableWatchdog(), this._debug.debug("Hangup");
10982
- let n = t ?? (this._state === "ACTIVE" || this._state === "HELD" ? O.HUNGUP : O.CANCELED), r = new k(n), i = this._conversation?.id ?? null;
10983
- this._onFastHangup = e?.onFastHangup ?? this._onFastHangup, this._stats.logger.log(S.HANGUP, n), this._finishLifecycle(r);
10984
- let a = !!i && typeof this._onFastHangup == "function";
10985
- return i && a && this._sendHangup(i, n, this._onFastHangup), this._hangupPromise = this._signaling.hangup(n).then(() => void 0).catch((e) => {
10986
- if (!(e instanceof kn)) throw e;
10987
- }).finally(() => (i != null && !a && this._sendHangupApi(i, n), this._close(r))), this._emitHangupOnce(r, i), this._cleanupTransport(), this._cleanupMediaSource(), this._hangupPromise;
11104
+ let t = e?.reason ?? (this._state === "ACTIVE" || this._state === "HELD" ? O.HUNGUP : O.CANCELED), n = new k(t), r = this.id, i = this._conversation?.id ?? this._serverConversationId, a = !!this._conversation && this._signaling.ready, o = new AbortController();
11105
+ return this._onFastHangup = e?.onFastHangup ?? this._onFastHangup, this._hangupPromise = Promise.resolve().then(async () => {
11106
+ let e = [];
11107
+ a && e.push(Promise.resolve().then(() => this._signaling.hangup(t)).catch((e) => {
11108
+ if (!(e instanceof kn)) throw e;
11109
+ })), i && e.push(this._sendHangup(i, t, this._onFastHangup, o.signal));
11110
+ let n = (await this._waitForHangup(Promise.allSettled(e), o)).find((e) => e.status === "rejected");
11111
+ if (n?.status === "rejected") throw n.reason;
11112
+ }).finally(() => {
11113
+ o.abort(), this._signaling.dispose(), B.removeHangup(this._hangupPromise);
11114
+ }), B.trackHangup(this, this._hangupPromise), this._hangupReason = n, this._state = "CLOSE", this._participantState = X.HUNGUP, this._resolveSignalingInitialization(!1), this._abortController?.abort(n), this._emitHangupOnce(n, r || null), this._stats.logger.log(x.HANGUP, t), this._finishLifecycle(n), this._stats.flushCallMetrics(), this._cleanupTransport(), this._destroy(void 0, !0), this._hangupPromise;
11115
+ }
11116
+ async _waitForHangup(e, t) {
11117
+ let n;
11118
+ try {
11119
+ return await Promise.race([e, new Promise((e, r) => {
11120
+ n = window.setTimeout(() => {
11121
+ t.abort(), r(/* @__PURE__ */ Error("Hangup timed out"));
11122
+ }, N.waitResponseDelay);
11123
+ })]);
11124
+ } finally {
11125
+ window.clearTimeout(n);
11126
+ }
10988
11127
  }
10989
11128
  async addParticipant(e, t) {
10990
11129
  if (!this._signaling.ready) {
@@ -11026,7 +11165,7 @@ var Mc = 15, $ = class e extends Je {
11026
11165
  this._transport && this._transport.updateStatisticsInterval();
11027
11166
  }
11028
11167
  _openTransport(e, t) {
11029
- if (!this._transport) return;
11168
+ if (!this._transport || this.isCallHeld || this._state === "CLOSE") return;
11030
11169
  let n = new Set(this._transport.opened()), r = [];
11031
11170
  for (let i of e) (i.state === X.CALLED || i.state === X.ACCEPTED) && (this._transport.isAllocated(i.id) || this._allocateParticipantTransport(i.id, t)), i.state === X.ACCEPTED && !n.has(i.id) && r.push(i.id);
11032
11171
  r.length ? this._transport.open(r, null, !!this._conversation?.observer) : this._transport.getTopology() === J.SERVER && this._forceOpenTransportForAloneInCall();
@@ -11038,8 +11177,21 @@ var Mc = 15, $ = class e extends Je {
11038
11177
  let t = this._transport?.getTopology() === J.DIRECT && this._transport.opened().includes(e);
11039
11178
  this._transport?.close(e), t && (this._directTransportIsMaster = void 0);
11040
11179
  }
11180
+ _registerPending(e) {
11181
+ if (e && B.has(e)) throw new k(O.HAS_ACTIVE_CALL);
11182
+ this._pendingId = e ?? null, B.addPending(this);
11183
+ }
11041
11184
  _cleanupRegistry() {
11042
- B.remove(this._reservedId), B.remove(this.id), this._reservedId = null;
11185
+ B.remove(this), this._pendingId = null;
11186
+ }
11187
+ async _applyInitialActiveSelection() {
11188
+ N.hold && !B.isSelected(this) && await this.hold(!0);
11189
+ let e = !1;
11190
+ for (; e !== this.isCallHeld;) {
11191
+ let t = this.isCallHeld;
11192
+ await this._signaling.hold(t), this._throwIfClosed(), e = t;
11193
+ }
11194
+ B.add(this), !this.isCallHeld && (B.isSelected(this) || !N.hold) && await B.setActive(this.id), N.hold && !B.isSelected(this) && await this.hold(!0), this._throwIfClosed();
11043
11195
  }
11044
11196
  _emitHangupOnce(e, t) {
11045
11197
  this._hangupEmitted || (this._hangupEmitted = !0, R.onHangup(e, t));
@@ -11049,9 +11201,10 @@ var Mc = 15, $ = class e extends Je {
11049
11201
  n != null && (r.peerId = String(n)), this._api.hangupConversation(e, t, r);
11050
11202
  }
11051
11203
  _close(e, t = {}) {
11052
- this._clearCalleeUnavailableWatchdog(), t.errorText && this._debug.error(t.errorText, e), this._debug.debug("Close conversation", e), this._finishLifecycle(e), this._stats.flushCallMetrics();
11204
+ if (this._hangupPromise) return;
11205
+ this._resolveSignalingInitialization(!1), this._clearCalleeUnavailableWatchdog(), t.errorText && this._debug.error(t.errorText, e), this._debug.debug("Close conversation", e), this._finishLifecycle(e), this._stats.flushCallMetrics();
11053
11206
  let n = t.signalingReason ?? (e.error ? O.FAILED : void 0), r = n && this._signaling.ready ? this._signaling.hangup(n) : void 0;
11054
- this._signaling.readyToSend(!1), e.error || this._stats.logger.log(S.ERROR, e.hangup);
11207
+ this._signaling.readyToSend(!1), e.error || this._stats.logger.log(x.ERROR, e.hangup);
11055
11208
  let i = this._conversation && this._conversation.id;
11056
11209
  if ([
11057
11210
  O.CANCELED,
@@ -11081,33 +11234,37 @@ var Mc = 15, $ = class e extends Je {
11081
11234
  this._disposeSignaling(r), this._cleanupMediaSource();
11082
11235
  return;
11083
11236
  }
11084
- this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(r), this._api.cleanup(), this._api.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, this._emitHangupOnce(e || new k(O.UNKNOWN_ERROR), i);
11237
+ this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(r), this._api.cleanup(), this._api.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._abortController = null, this._emitHangupOnce(e || new k(O.UNKNOWN_ERROR), i);
11085
11238
  }
11086
- _sendHangup(e, t, n) {
11087
- typeof n == "function" ? n({
11088
- conversationId: e,
11089
- reason: t,
11090
- internalParams: this._buildInternalParams()
11091
- }, this._abortController?.signal).then((e) => {
11092
- e?.success || this._debug.error("Fast hangup was not successful", e);
11093
- }).catch((e) => {
11094
- this._debug.error("Fast hangup error", e);
11095
- }) : this._sendHangupApi(e, t);
11239
+ async _sendHangup(e, t, n, r) {
11240
+ if (n) {
11241
+ if (!(await n({
11242
+ conversationId: e,
11243
+ reason: t,
11244
+ internalParams: this._buildInternalParams()
11245
+ }, r))?.success) throw Error("Fast hangup was not successful");
11246
+ } else this._sendHangupApi(e, t);
11247
+ }
11248
+ _throwIfClosed() {
11249
+ if (this._state === "CLOSE" || this._abortController?.signal.aborted) throw new k(O.CANCELED);
11250
+ }
11251
+ _applyServerConversation(e) {
11252
+ if (this._serverConversationId = e, this._state === "CLOSE") {
11253
+ let t = new AbortController();
11254
+ throw this._waitForHangup(this._sendHangup(e, this._hangupReason?.hangup ?? O.CANCELED, this._onFastHangup, t.signal), t).catch((e) => this._debug.warn("Unable to cancel late conversation", e)), new k(O.CANCELED);
11255
+ }
11096
11256
  }
11097
11257
  destroy() {
11098
11258
  this._destroy();
11099
11259
  }
11100
- _destroy(e) {
11101
- this._clearCalleeUnavailableWatchdog();
11102
- let t = this._conversation && this._conversation.id;
11103
- if (this._debug.debug("Destroy conversation", { conversationId: t }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = X.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(e), this._delayedHangup && t) try {
11104
- this._sendHangup(t, O.CANCELED, this._onFastHangup);
11105
- } catch {}
11106
- this._api.cleanup(), this._api.setAbortSignal(void 0), this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
11260
+ _destroy(e, t = !1) {
11261
+ this._resolveSignalingInitialization(!1), this._clearCalleeUnavailableWatchdog();
11262
+ let n = this._conversation && this._conversation.id;
11263
+ this._debug.debug("Destroy conversation", { conversationId: n }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = X.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), t || this._disposeSignaling(e), this._api.cleanup(), this._api.setAbortSignal(void 0), this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._abortController = null;
11107
11264
  }
11108
11265
  async _getConversationParams(e) {
11109
11266
  let t = await this._api.getConversationParams(e);
11110
- this._debug.debug("Api.getConversationParams", t);
11267
+ this._throwIfClosed(), this._debug.debug("Api.getConversationParams", t);
11111
11268
  let { turn_server: n, stun_server: r } = t;
11112
11269
  return N.iceServers = Ho(r, n), N.wssBase = t.endpoint, t.wt_endpoint && (N.wtsBase = t.wt_endpoint), N.wssToken = t.token, t.client_type && (N.clientType = t.client_type), t.external_user_type && (N.externalUserType = t.external_user_type), t;
11113
11270
  }
@@ -11124,14 +11281,13 @@ var Mc = 15, $ = class e extends Je {
11124
11281
  async _startConversation({ opponentIds: e, opponentType: t, direction: n, mediaOptions: r, payload: i = "", joiningAllowed: a = !1, requireAuthToJoin: o = !1, onlyAdminCanShareMovie: s, externalIds: c, onFastStart: l, conversationId: u }) {
11125
11282
  G.setMark(U.SIGNALING_CONNECTED);
11126
11283
  let d = u ?? M.uuid();
11127
- if (B.has(d)) throw new k(O.HAS_ACTIVE_CALL);
11128
- B.reserve(d), this._reservedId = d, this._debug.debug("Conversation: start", {
11284
+ this._debug.debug("Conversation: start", {
11129
11285
  conversationId: d,
11130
11286
  opponentIds: e,
11131
11287
  opponentType: t,
11132
11288
  direction: n
11133
11289
  });
11134
- let f = r.includes(x.VIDEO), p, m;
11290
+ let f = r.includes(b.VIDEO), p, m;
11135
11291
  if (l) {
11136
11292
  let e;
11137
11293
  try {
@@ -11151,7 +11307,7 @@ var Mc = 15, $ = class e extends Je {
11151
11307
  throw jc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
11152
11308
  }
11153
11309
  } catch (e) {
11154
- 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) });
11310
+ throw this._state === "CLOSE" ? 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) });
11155
11311
  }
11156
11312
  try {
11157
11313
  let t = JSON.parse(e.internalCallerParams);
@@ -11173,9 +11329,9 @@ var Mc = 15, $ = class e extends Je {
11173
11329
  throw jc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
11174
11330
  }
11175
11331
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
11176
- qo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
11332
+ qo(p, m), this._applyServerConversation(p.id), this._pendingId = p.id, this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
11177
11333
  let ee = await this._connectSignaling(Cr.START, p);
11178
- return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
11334
+ return this._throwIfClosed(), this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
11179
11335
  }
11180
11336
  async _joinConversation(e) {
11181
11337
  G.setMark(U.SIGNALING_CONNECTED);
@@ -11184,8 +11340,8 @@ var Mc = 15, $ = class e extends Je {
11184
11340
  conversationId: t,
11185
11341
  joinLink: i,
11186
11342
  observedIds: a
11187
- }), t && B.has(t)) throw new k(O.HAS_ACTIVE_CALL);
11188
- let c = n.includes(x.VIDEO), l, u;
11343
+ }), t && B.has(t, this)) throw new k(O.HAS_ACTIVE_CALL);
11344
+ let c = n.includes(b.VIDEO), l, u;
11189
11345
  if (s) {
11190
11346
  if (!i) throw new k(O.FAST_JOIN_ERROR, { callError: {
11191
11347
  scope: "internal",
@@ -11202,11 +11358,11 @@ var Mc = 15, $ = class e extends Je {
11202
11358
  if (!e.internalCallerParams) throw jc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
11203
11359
  if (!e.conversationId) throw jc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
11204
11360
  } catch (e) {
11205
- 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) });
11361
+ throw this._state === "CLOSE" ? 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) });
11206
11362
  }
11207
11363
  try {
11208
11364
  let t = JSON.parse(e.internalCallerParams);
11209
- if (B.has(e.conversationId)) throw new k(O.HAS_ACTIVE_CALL);
11365
+ if (B.has(e.conversationId, this)) throw new k(O.HAS_ACTIVE_CALL);
11210
11366
  l = {
11211
11367
  endpoint: t.endpoint,
11212
11368
  wt_endpoint: t.wtEndpoint,
@@ -11227,13 +11383,13 @@ var Mc = 15, $ = class e extends Je {
11227
11383
  code: "join",
11228
11384
  description: "target-missing"
11229
11385
  } });
11230
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), qo(l, u), l.id) {
11231
- if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
11232
- B.reserve(l.id), this._reservedId = l.id;
11386
+ if (this._applyServerConversation(l.id), this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), qo(l, u), l.id) {
11387
+ if (B.has(l.id, this)) throw new k(O.HAS_ACTIVE_CALL);
11388
+ this._pendingId = l.id;
11233
11389
  }
11234
11390
  this._setConversationParams(l);
11235
11391
  let d = await this._connectSignaling(Cr.JOIN, l);
11236
- return this._setConversation(l, d, _o.JOINING), this._stats.lifecycle.markCallStarted(), d;
11392
+ return this._throwIfClosed(), this._setConversation(l, d, _o.JOINING), this._stats.lifecycle.markCallStarted(), d;
11237
11393
  }
11238
11394
  async _prepareConversation(e, t = j.USER, n, r, i) {
11239
11395
  G.setMark(U.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -11295,7 +11451,7 @@ var Mc = 15, $ = class e extends Je {
11295
11451
  }), l.wt_endpoint = c);
11296
11452
  }
11297
11453
  let u = await this._connectSignaling(Cr.ACCEPT, l);
11298
- return B.callsLength >= N.maxParallelCalls || !N.hold && B.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(S.PUSH, "busy"), Promise.reject(new k(O.BUSY))) : (this._setConversation(l, u, _o.INCOMING, t), u);
11454
+ return B.callsLength >= N.maxParallelCalls || !N.hold && B.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(x.PUSH, "busy"), Promise.reject(new k(O.BUSY))) : (this._throwIfClosed(), this._setConversation(l, u, _o.INCOMING, t), u);
11299
11455
  }
11300
11456
  _createParticipant(e, t, n = !0) {
11301
11457
  let r = Object.assign({
@@ -11341,33 +11497,38 @@ var Mc = 15, $ = class e extends Je {
11341
11497
  });
11342
11498
  }
11343
11499
  _setConversation(e, t, n, r = j.USER) {
11344
- let { participants: i } = t.conversation;
11500
+ let { participants: i } = t.conversation, a = t.conversation.id || e.id;
11501
+ if (!a) throw new k(O.UNKNOWN_ERROR, { callError: {
11502
+ scope: "internal",
11503
+ code: "conversation",
11504
+ description: "id-missing"
11505
+ } });
11345
11506
  t.conversationParams?.serverTime && (this._serverTimeOffset = t.conversationParams.serverTime - Date.now()), this._cacheParticipantExternalIds(i);
11346
- let a = this._api.getUserId(), o = this._extractLocalParticipantFromConnection(t), s = e.device_idx || 0;
11347
- if (!a) {
11348
- if (!o) throw new k(O.UNKNOWN_ERROR, { callError: {
11507
+ let o = this._api.getUserId(), s = this._extractLocalParticipantFromConnection(t), c = e.device_idx || 0;
11508
+ if (!o) {
11509
+ if (!s) throw new k(O.UNKNOWN_ERROR, { callError: {
11349
11510
  scope: "internal",
11350
11511
  code: "conversation",
11351
11512
  description: "anonymous-local-participant-missing"
11352
11513
  } });
11353
- a = Number(o.id), o.idType && (r = o.idType), o.deviceIdx && (s = o.deviceIdx), this._api.setUserId(a);
11514
+ o = Number(s.id), s.idType && (r = s.idType), s.deviceIdx && (c = s.deviceIdx), this._api.setUserId(o);
11354
11515
  }
11355
- let c = M.composeParticipantId(a, r, s);
11516
+ let l = M.composeParticipantId(o, r, c);
11356
11517
  this._conversation = {
11357
- userId: a,
11358
- compositeUserId: c,
11359
- externalId: this._getExternalIdByParticipantId(c),
11518
+ userId: o,
11519
+ compositeUserId: l,
11520
+ externalId: this._getExternalIdByParticipantId(l),
11360
11521
  acceptTime: t.conversation.acceptTime,
11361
11522
  features: t.conversation.features || [],
11362
11523
  featuresPerRole: t.conversation.featuresPerRole,
11363
- id: t.conversation.id || e.id,
11524
+ id: a,
11364
11525
  participantsLimit: t.conversation.participantsLimit || 30,
11365
11526
  topology: t.conversation.topology || J.DIRECT,
11366
11527
  direction: n,
11367
11528
  concurrent: t.isConcurrent || e.is_concurrent || !1,
11368
11529
  needRate: !1,
11369
11530
  chatId: t.conversation.multichatId,
11370
- roles: o?.roles ?? [],
11531
+ roles: s?.roles ?? [],
11371
11532
  recordsInfoByRoom: /* @__PURE__ */ new Map(),
11372
11533
  asrInfoByRoom: /* @__PURE__ */ new Map(),
11373
11534
  muteStates: /* @__PURE__ */ new Map(),
@@ -11385,9 +11546,9 @@ var Mc = 15, $ = class e extends Je {
11385
11546
  audienceMode: this._isAudienceMode(t),
11386
11547
  restricted: this._isRestricted(t),
11387
11548
  urlSharingInfoByRoom: /* @__PURE__ */ new Map()
11388
- }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (N.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(S.RELAY_POLICY, N.forceRelayPolicy ? "1" : "0");
11389
- let l = B.get(this._conversation.id);
11390
- if (l && l !== this) this._conversation.concurrent = !0;
11549
+ }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (N.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(x.RELAY_POLICY, N.forceRelayPolicy ? "1" : "0");
11550
+ let u = B.get(this._conversation.id);
11551
+ if (u && u !== this) this._conversation.concurrent = !0;
11391
11552
  else if (!N.hold && B.callsLength > 0) throw new k(O.HAS_ACTIVE_CALL);
11392
11553
  this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
11393
11554
  }
@@ -11399,17 +11560,53 @@ var Mc = 15, $ = class e extends Je {
11399
11560
  } });
11400
11561
  this._conversation.acceptTime = e.conversation.acceptTime, this._conversation.features = e.conversation.features || [], this._conversation.featuresPerRole = e.conversation.featuresPerRole, this._conversation.participantsLimit = e.conversation.participantsLimit || 30, this._conversation.topology = e.conversation.topology || J.DIRECT, this._conversation.concurrent = e.isConcurrent || !1, this._conversation.chatId = e.conversation.multichatId, this._conversation.mediaModifiers = e.mediaModifiers, this._conversation.waitingHall = !1, this._conversation.waitForAdmin = !1, this._conversation.restricted = !1, this._cacheParticipantExternalIds(e.conversation.participants ?? []);
11401
11562
  }
11563
+ async _requestLocalMedia(e, t = !0) {
11564
+ let n = this._mediaSource, r = new Set(e);
11565
+ for (let [e, t] of [[b.AUDIO, this._requestedLocalAudio], [b.VIDEO, this._requestedLocalVideo]]) t === !0 ? r.add(e) : t === !1 && r.delete(e);
11566
+ this._requestingLocalMedia = !0;
11567
+ try {
11568
+ for (await n.request([...r], t);;) {
11569
+ if (this._state === "CLOSE" || this._abortController?.signal.aborted) throw n.destroy(), new k(O.CANCELED);
11570
+ let e = this._requestedLocalAudio, t = this._requestedLocalVideo;
11571
+ if (e !== void 0 && e !== n.mediaSettings.isAudioEnabled) {
11572
+ try {
11573
+ await this._toggleLocalAudio(e);
11574
+ } catch (t) {
11575
+ if (e === this._requestedLocalAudio) throw t;
11576
+ }
11577
+ continue;
11578
+ }
11579
+ if (t !== void 0 && t !== n.mediaSettings.isVideoEnabled) {
11580
+ try {
11581
+ await this._toggleLocalVideo(t);
11582
+ } catch (e) {
11583
+ if (t === this._requestedLocalVideo) throw e;
11584
+ }
11585
+ continue;
11586
+ }
11587
+ break;
11588
+ }
11589
+ this.isCallHeld && (await n.stopLocalMedia(), this._throwIfClosed());
11590
+ for (let [e, t] of [[b.AUDIO, n.mediaSettings.isAudioEnabled], [b.VIDEO, n.mediaSettings.isVideoEnabled]]) t ? r.add(e) : r.delete(e);
11591
+ return R.onLocalStream(n.getStream(), n.mediaSettings, this.id), [...r];
11592
+ } finally {
11593
+ this._requestingLocalMedia = !1;
11594
+ }
11595
+ }
11402
11596
  _createMediaSource() {
11403
11597
  let e = new Qt(this._debug, this._stats.logger);
11404
11598
  return this.subscribe(e, Xt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Xt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Go(e, this._debug, this._stats.logger), e;
11405
11599
  }
11406
11600
  async _connectSignaling(e, t) {
11407
- this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, wr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, wr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, wr.RECONNECT, this._onSignalingReconnect.bind(this));
11601
+ this._throwIfClosed(), this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, wr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, wr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, wr.RECONNECT, this._onSignalingReconnect.bind(this));
11408
11602
  let n = await this._signaling.connect(e, t);
11409
- return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11603
+ return this._throwIfClosed(), this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11604
+ }
11605
+ _completeSignalingInitialization() {
11606
+ this._throwIfClosed(), R.onSignalingConnected(this.id), this._resolveSignalingInitialization(!0);
11410
11607
  }
11411
11608
  async _processConnection(e) {
11412
- await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(yo.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
11609
+ this._throwIfClosed(), await this._registerConnectionParticipants(e), this._throwIfClosed(), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(yo.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
11413
11610
  }
11414
11611
  _onConversationParticipantListChunk(e) {
11415
11612
  let t = e.participants;
@@ -11465,6 +11662,7 @@ var Mc = 15, $ = class e extends Je {
11465
11662
  n && (N.externalUserType = n);
11466
11663
  let r = this._participants;
11467
11664
  for (let n of e) {
11665
+ this._throwIfClosed();
11468
11666
  let e = M.composeId(n);
11469
11667
  if (z.test("Conversation:RegisterParticipant", e), this._isMe(e)) {
11470
11668
  this._conversation.roles = n.roles || [], this._conversation.roles.length && (this._debug.debug(`Local roles changed: ${n.roles}`), R.onLocalRolesChanged(this._conversation.roles, !0, this.id)), this._registerParticipantLocalMuteState(n);
@@ -11621,7 +11819,7 @@ var Mc = 15, $ = class e extends Je {
11621
11819
  for (let t of e.rooms?.rooms ?? []) t.pinnedParticipantId ? this._onPinParticipant(t.pinnedParticipantId, !1, void 0, t.id) : this._conversation?.pinnedParticipantIdByRoom.delete(t.id);
11622
11820
  }
11623
11821
  _allocateTransport() {
11624
- if (!this._conversation || !this._mediaSource) return;
11822
+ if (!this._conversation || !this._mediaSource || this.isCallHeld || this._transport) return;
11625
11823
  this._transport = new Ma(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new Qo(this._debug), this.subscribe(this._transport, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, Y.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, Y.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, Y.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, Y.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, Y.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, Y.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, Y.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
11626
11824
  let e = this._conversation.direction === _o.OUTGOING && !this._conversation.concurrent, t = this._participants;
11627
11825
  for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
@@ -11634,7 +11832,7 @@ var Mc = 15, $ = class e extends Je {
11634
11832
  }
11635
11833
  _logDevices() {
11636
11834
  let e = E.getCameras().length, t = E.getMicrophones().length;
11637
- this._debug.debug("Cameras: " + e + (E.hasCameraPermission() ? "✔" : "✖") + ", Microphones: " + t + (E.hasMicrophonePermission() ? "✔" : "✖")), this._debug.debug("Devices", E.getDevices()), this._stats.logger.log(S.DEVICES, `${e}_${t}`);
11835
+ this._debug.debug("Cameras: " + e + (E.hasCameraPermission() ? "✔" : "✖") + ", Microphones: " + t + (E.hasMicrophonePermission() ? "✔" : "✖")), this._debug.debug("Devices", E.getDevices()), this._stats.logger.log(x.DEVICES, `${e}_${t}`);
11638
11836
  }
11639
11837
  _logWithMediaSettings(e, t) {
11640
11838
  this._stats.logger.log(e, [t?.isAudioEnabled && "audio", t?.isVideoEnabled && "video"].filter(Boolean).join("_"));
@@ -11724,7 +11922,7 @@ var Mc = 15, $ = class e extends Je {
11724
11922
  observedIds: t.observedIds || []
11725
11923
  }, n), r = this._getParticipant(e);
11726
11924
  }
11727
- this._setParticipantsStatus([r], P.WAITING), i && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(r), n ? (r.state = X.HUNGUP, this._removeParticipant(r, n)) : this._transport && (r.state = X.CALLED, this._allocateParticipantTransport(r.id, !0), this._stats.logger.log(S.ADD_PARTICIPANT), this._invokeRolesChangedCallbackIfNeeded(r));
11925
+ this._setParticipantsStatus([r], P.WAITING), i && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(r), n ? (r.state = X.HUNGUP, this._removeParticipant(r, n)) : this._transport && (r.state = X.CALLED, this._allocateParticipantTransport(r.id, !0), this._stats.logger.log(x.ADD_PARTICIPANT), this._invokeRolesChangedCallbackIfNeeded(r));
11728
11926
  }
11729
11927
  _onRemoveParticipant(e) {
11730
11928
  this._debug.debug(`Remove participant [${e}]`);
@@ -11738,19 +11936,19 @@ var Mc = 15, $ = class e extends Je {
11738
11936
  return;
11739
11937
  }
11740
11938
  for (let e of t) this._closeParticipantTransport(e.id);
11741
- this._stats.logger.log(S.REMOVE_PARTICIPANT);
11939
+ this._stats.logger.log(x.REMOVE_PARTICIPANT);
11742
11940
  }
11743
11941
  async changeDevice(e) {
11744
- return e === "audiooutput" ? this._audioOutput.changeOutput() : this._mediaSource ? this._mediaSource.changeDevice(e) : Promise.reject(b.UNKNOWN);
11942
+ return e === "audiooutput" ? this._audioOutput.changeOutput() : this._mediaSource ? this._mediaSource.changeDevice(e) : Promise.reject(y.UNKNOWN);
11745
11943
  }
11746
11944
  stopVideoTrack() {
11747
11945
  return this._mediaSource?.stopVideoTrack();
11748
11946
  }
11749
11947
  async toggleScreenCapturing(e) {
11750
- return this._mediaSource ? this._mediaSource.toggleScreenCapturing(e) : Promise.reject(b.UNKNOWN);
11948
+ return this._mediaSource ? this._mediaSource.toggleScreenCapturing(e) : Promise.reject(y.UNKNOWN);
11751
11949
  }
11752
11950
  async disableScreenCapturing() {
11753
- return this._mediaSource ? this._mediaSource.disableScreenCapturing() : Promise.reject(b.UNKNOWN);
11951
+ return this._mediaSource ? this._mediaSource.disableScreenCapturing() : Promise.reject(y.UNKNOWN);
11754
11952
  }
11755
11953
  toggleAnimojiCapturing(e) {
11756
11954
  this._mediaSource && this._mediaSource.toggleAnimojiCapturing(e);
@@ -11782,10 +11980,10 @@ var Mc = 15, $ = class e extends Je {
11782
11980
  if (this._mediaSource) return this._mediaSource.setAudioStream(e);
11783
11981
  }
11784
11982
  toggleLocalVideo(e) {
11785
- return this._toggleLocalVideo(e);
11983
+ return this._requestedLocalVideo = e, this._requestingLocalMedia || !this._mediaSource?.getStream() ? Promise.resolve() : this._toggleLocalVideo(e);
11786
11984
  }
11787
11985
  toggleLocalAudio(e) {
11788
- return this._toggleLocalAudio(e);
11986
+ return this._requestedLocalAudio = e, this._requestingLocalMedia || !this._mediaSource?.getStream() ? Promise.resolve() : this._toggleLocalAudio(e);
11789
11987
  }
11790
11988
  async changePriorities(e) {
11791
11989
  if (e.length < 2 || !this._signaling.ready) return;
@@ -11806,6 +12004,10 @@ var Mc = 15, $ = class e extends Je {
11806
12004
  t && !this._isCallAdmin() && (t = void 0), await this._signaling.changeParticipantState(e, t);
11807
12005
  }
11808
12006
  async hold(e, t) {
12007
+ if (this._throwIfClosed(), B.isPending(this)) {
12008
+ e ? await this._holdLocally() : await this._resumeLocalMedia(t, P.WAITING);
12009
+ return;
12010
+ }
11809
12011
  if (e) {
11810
12012
  if (this._state === "HELD") return;
11811
12013
  if (this._isWaitingForPromotion()) {
@@ -11820,7 +12022,7 @@ var Mc = 15, $ = class e extends Je {
11820
12022
  return;
11821
12023
  }
11822
12024
  let n = Ja.get();
11823
- await this._signaling.hold(!1, n), this._restoreStateAfterHold();
12025
+ await this._signaling.hold(!1, n), this._throwIfClosed(), this._restoreStateAfterHold();
11824
12026
  let r = null;
11825
12027
  if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, P.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
11826
12028
  let e = this._conversation?.direction === _o.OUTGOING && !this._conversation.concurrent;
@@ -11828,12 +12030,12 @@ var Mc = 15, $ = class e extends Je {
11828
12030
  }
11829
12031
  }
11830
12032
  async _holdLocally() {
11831
- this._state !== "HELD" && (this._previousState = this._state, this._state = "HELD");
12033
+ this._throwIfClosed(), this._state !== "HELD" && (this._previousState = this._state, this._state = "HELD");
11832
12034
  let e = this._mediaSource?.stopLocalMedia();
11833
12035
  this._cleanupTransportForHold(), R.onLocalStatus(P.ONHOLD, this.id), await e;
11834
12036
  }
11835
12037
  async _resumeLocalMedia(e, t) {
11836
- this._restoreStateAfterHold(), await this._mediaSource?.resumeLocalMedia(e), R.onLocalStatus(t, this.id), this._mediaSource && R.onLocalStream(this._mediaSource?.getStream() ?? null, this._mediaSource.mediaSettings, this.id);
12038
+ this._restoreStateAfterHold(), await this._mediaSource?.resumeLocalMedia(e), this._throwIfClosed(), R.onLocalStatus(t, this.id), this._mediaSource && R.onLocalStream(this._mediaSource?.getStream() ?? null, this._mediaSource.mediaSettings, this.id);
11837
12039
  }
11838
12040
  _restoreStateAfterHold() {
11839
12041
  this._state === "HELD" && (this._state = this._previousState || "ACTIVE", this._previousState = null);
@@ -11926,7 +12128,7 @@ var Mc = 15, $ = class e extends Je {
11926
12128
  R.onRemoteScreenStream(r.externalId, null, this.id);
11927
12129
  break;
11928
12130
  }
11929
- this._stats.logger.log(S.PAT_DEALLOCATED);
12131
+ this._stats.logger.log(x.PAT_DEALLOCATED);
11930
12132
  } else this._debug.log(`Cannot find participant to stop streaming: ${n.participantId}`);
11931
12133
  }
11932
12134
  this._streamIdByStreamDescription.delete(e);
@@ -11952,7 +12154,7 @@ var Mc = 15, $ = class e extends Je {
11952
12154
  });
11953
12155
  }
11954
12156
  }
11955
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new Pc("Could not allocate one or more participants", r);
12157
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new Nc("Could not allocate one or more participants", r);
11956
12158
  }
11957
12159
  async _cleanupCooldownQueue() {
11958
12160
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -11974,7 +12176,7 @@ var Mc = 15, $ = class e extends Je {
11974
12176
  }
11975
12177
  }
11976
12178
  async _onParticipantPromoted(e) {
11977
- this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new k(O.REMOVED))) : (this._updateConversation(e), this._waitingHallHoldPending ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !1), this._waitingHallHoldPending = !1) : B.getActive() && N.hold ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !0, !0), this._waitingHallHoldPending = !1) : await this._onJoinPart2(e))), R.onPromoted(e.demote, this.id);
12179
+ this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new k(O.REMOVED))) : (this._updateConversation(e), this._waitingHallHoldPending ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !1), this._waitingHallHoldPending = !1) : B.getActive() && N.hold ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !0, !0), this._waitingHallHoldPending = !1) : (B.selectIfNone(this), await this._onJoinPart2(e)))), R.onPromoted(e.demote, this.id);
11978
12180
  }
11979
12181
  _onChatRoomUpdated(e, t = 0, n = [], r, i) {
11980
12182
  this._debug.log(`Chat room updated: ${e}`);
@@ -12096,7 +12298,7 @@ var Mc = 15, $ = class e extends Je {
12096
12298
  }
12097
12299
  let a = Ln(t), o = this._sequenceNumberByStreamDescription.get(a);
12098
12300
  if (o && o > e.sequenceNumber) {
12099
- this._debug.warn(`Participant ${r} received outdated PAT response: sequence number ${e.sequenceNumber}; last sent sequence number for given participant is ${o}`), this._stats.logger.log(S.PAT_OUTDATED_RESPONSE);
12301
+ this._debug.warn(`Participant ${r} received outdated PAT response: sequence number ${e.sequenceNumber}; last sent sequence number for given participant is ${o}`), this._stats.logger.log(x.PAT_OUTDATED_RESPONSE);
12100
12302
  return;
12101
12303
  }
12102
12304
  i && e.suspend !== void 0 && n && (this._debug.debug(`participant-sources-update: mediaType=${n}, suspend=${e.suspend}`), R.onRemoteStreamSuspended(i.externalId, n, e.suspend, this.id));
@@ -12105,15 +12307,15 @@ var Mc = 15, $ = class e extends Je {
12105
12307
  this._streamWaitTimerByStreamDescription.delete(a);
12106
12308
  let t = this._conversation?.externalId, n = this._isMe(r);
12107
12309
  if (!i && !n) {
12108
- this._stats.logger.log(S.PAT_ERROR, "participantMissing"), this._debug.error(`Could not find participant by ID: ${r}`);
12310
+ this._stats.logger.log(x.PAT_ERROR, "participantMissing"), this._debug.error(`Could not find participant by ID: ${r}`);
12109
12311
  return;
12110
12312
  }
12111
12313
  let o = n ? t : i.externalId, c = this._streamByStreamId.get(s);
12112
12314
  if (!c) {
12113
- this._stats.logger.log(S.PAT_ERROR, "streamNotFound"), this._debug.error(`Could not find stream by ID: ${s}`);
12315
+ this._stats.logger.log(x.PAT_ERROR, "streamNotFound"), this._debug.error(`Could not find stream by ID: ${s}`);
12114
12316
  return;
12115
12317
  }
12116
- this._stats.logger.log(S.PAT_ALLOCATED), this._streamIdByStreamDescription.set(a, s);
12318
+ this._stats.logger.log(x.PAT_ALLOCATED), this._streamIdByStreamDescription.set(a, s);
12117
12319
  let l = e.participantStreamDescription?.mediaType;
12118
12320
  if (l === H.STREAM || l === H.MOVIE) {
12119
12321
  if (e.participantStreamDescription?.streamName) {
@@ -12420,9 +12622,9 @@ var Mc = 15, $ = class e extends Je {
12420
12622
  return this._debug.debug("Get initial participant list chunk", n.chunk), n.chunk;
12421
12623
  }
12422
12624
  _onLocalMediaStreamChanged(e) {
12423
- if (!this._conversation || !this._mediaSource) return;
12625
+ if (!this._mediaSource) return;
12424
12626
  let t = this._mediaSource.mediaSettings;
12425
- this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new Go(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
12627
+ this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new Go(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), e.kind === A.video && !this._requestingLocalMedia && this._state !== "CLOSE" && R.onLocalStream(this._mediaSource.getStream(), t, this.id), this._conversation && !this._conversation.waitingHall && !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
12426
12628
  }
12427
12629
  _onScreenSharingStatus(e) {
12428
12630
  let t = this.mediaSettings;
@@ -12483,7 +12685,7 @@ var Mc = 15, $ = class e extends Je {
12483
12685
  this._state === "ACTIVE" && e.roles && e.roles.length && (this._debug.debug(`Roles for participant [${e.id}] changed: ${e.roles}`), R.onRolesChanged(e.externalId, e.roles, !0, this.id));
12484
12686
  }
12485
12687
  _onSignalingNotification(e) {
12486
- switch (e.notification) {
12688
+ if (this._state !== "CLOSE") switch (e.notification) {
12487
12689
  case K.ACCEPTED_CALL: return this._onAcceptedCall(e);
12488
12690
  case K.HUNGUP: return this._onHungup(e);
12489
12691
  case K.PARTICIPANT_ADDED: return this._onAddedParticipant(e);
@@ -12544,7 +12746,7 @@ var Mc = 15, $ = class e extends Je {
12544
12746
  R.onPromotionApproved(t, this.id);
12545
12747
  }
12546
12748
  async _onSignalingReconnect(e) {
12547
- if (!this._conversation) return;
12749
+ if (!await this._signalingInitialization || this._state === "CLOSE" || !this._conversation) return;
12548
12750
  e.conversationParams?.serverTime && (this._serverTimeOffset = e.conversationParams.serverTime - Date.now()), e.conversation.acceptTime && (this._conversation.acceptTime = e.conversation.acceptTime), e.conversation.participantsLimit && (this._conversation.participantsLimit = e.conversation.participantsLimit), e.conversation.features && (this._conversation.features = e.conversation.features, this._conversation.featuresPerRole = e.conversation.featuresPerRole, this._changeFeatureSet(), this._changeFeaturesPerRole()), this._processPinnedParticipants(e), e.conversation.state;
12549
12751
  let t = null;
12550
12752
  if (e.conversation.participants) {
@@ -12562,30 +12764,29 @@ var Mc = 15, $ = class e extends Je {
12562
12764
  }
12563
12765
  r.push(e);
12564
12766
  let a = this._getParticipant(e);
12565
- if (!a) await this._onJoinedParticipant({
12566
- participantId: n.id,
12567
- participant: n,
12568
- mediaSettings: n.mediaSettings
12569
- });
12570
- else {
12767
+ if (a) {
12571
12768
  this._updateParticipantSessionState(a, e, n.sessionState);
12572
12769
  let t = D(n.mediaSettings);
12573
12770
  qt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
12574
12771
  let r = M.mapParticipantState(n), o = a.participantState;
12575
- M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), ko(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? P.ONHOLD : P.CONNECTED));
12576
- }
12772
+ if (!M.isEqualParticipantState(r, o) && (await this._changeRemoteParticipantState(e, r), !this._conversation)) return;
12773
+ ko(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? P.ONHOLD : P.CONNECTED));
12774
+ } else if (await this._onJoinedParticipant({
12775
+ participantId: n.id,
12776
+ participant: n,
12777
+ mediaSettings: n.mediaSettings
12778
+ }), !this._conversation) return;
12577
12779
  }
12578
12780
  let i = this._participants;
12579
12781
  for (let e of n) r.indexOf(e) < 0 && i[e] && this._removeParticipant(i[e], O.HUNGUP);
12580
12782
  }
12581
12783
  let n = [...e.participants?.participants ?? [], ...e.rooms?.rooms.flatMap((e) => e.participants?.participants ?? []) ?? []];
12582
- await this._reconcileParticipantSessionStates(n);
12784
+ if (await this._reconcileParticipantSessionStates(n), !this._conversation) return;
12583
12785
  let r = e.rooms?.roomId ?? null;
12584
- if (!this._conversation) {
12585
- this._debug.warn("Conversation is empty, but should be filled");
12586
- return;
12587
- }
12588
- this._conversation.roomId === r ? this._processMuteStates(e, !0) : await this._onRoomSwitched(r), t?.(), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options);
12786
+ if (this._conversation.roomId !== r) {
12787
+ if (await this._onRoomSwitched(r), !this._conversation) return;
12788
+ } else this._processMuteStates(e, !0);
12789
+ t?.(), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), R.onSignalingConnected(this.id);
12589
12790
  }
12590
12791
  _onSignalingFailed(e) {
12591
12792
  this._debug.error("Signaling failed", e), this._close(e);
@@ -12610,7 +12811,7 @@ var Mc = 15, $ = class e extends Je {
12610
12811
  let t = Z.fromSignaling(e.externalId, e.deviceIdx);
12611
12812
  r.externalId = t, this._api.cacheExternalId(r.id, t);
12612
12813
  }
12613
- r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(S.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === _o.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
12814
+ r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(x.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === _o.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
12614
12815
  let i = Object.keys(r.muteStates);
12615
12816
  if (i.length && this._onMuteParticipant({
12616
12817
  muteStates: r.muteStates,
@@ -12819,7 +13020,7 @@ var Mc = 15, $ = class e extends Je {
12819
13020
  n && (n.clientType = e.clientType, n.platform = e.platform, R.onPeerRegistered(this.id, [n.externalId]));
12820
13021
  }
12821
13022
  async _onMicSwitched(e) {
12822
- R.onDeviceSwitched(x.AUDIO, !e.mute, this.id), await this.toggleLocalAudio(!e.mute);
13023
+ R.onDeviceSwitched(b.AUDIO, !e.mute, this.id), await this.toggleLocalAudio(!e.mute);
12823
13024
  }
12824
13025
  _onChatMessage(e) {
12825
13026
  let t = M.composeMessageId(e), n = this._getExternalIdByParticipantId(t);
@@ -12984,17 +13185,17 @@ var Mc = 15, $ = class e extends Je {
12984
13185
  for (let [e, i] of d) {
12985
13186
  let a = this._isCallAdmin() && n;
12986
13187
  if (!(i !== wo.MUTE && i !== wo.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === wo.MUTE_PERMANENT && !n && (l[e] = wo.MUTE), !(!t.includes(e) || r))) switch (e) {
12987
- case x.VIDEO:
12988
- u.isVideoEnabled && (R.onDeviceSwitched(x.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
13188
+ case b.VIDEO:
13189
+ u.isVideoEnabled && (R.onDeviceSwitched(b.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
12989
13190
  break;
12990
- case x.AUDIO:
12991
- u.isAudioEnabled && (R.onDeviceSwitched(x.AUDIO, !1, this.id), await this.toggleLocalAudio(!1));
13191
+ case b.AUDIO:
13192
+ u.isAudioEnabled && (R.onDeviceSwitched(b.AUDIO, !1, this.id), await this.toggleLocalAudio(!1));
12992
13193
  break;
12993
- case x.SCREEN_SHARING:
12994
- u.isScreenSharingEnabled && (R.onDeviceSwitched(x.SCREEN_SHARING, !1, this.id), await this.disableScreenCapturing());
13194
+ case b.SCREEN_SHARING:
13195
+ u.isScreenSharingEnabled && (R.onDeviceSwitched(b.SCREEN_SHARING, !1, this.id), await this.disableScreenCapturing());
12995
13196
  break;
12996
- case x.AUDIO_SHARING:
12997
- u.isAudioSharingEnabled && (R.onDeviceSwitched(x.AUDIO_SHARING, !1, this.id), await this.toggleScreenCapturing({
13197
+ case b.AUDIO_SHARING:
13198
+ u.isAudioSharingEnabled && (R.onDeviceSwitched(b.AUDIO_SHARING, !1, this.id), await this.toggleScreenCapturing({
12998
13199
  captureScreen: u.isScreenSharingEnabled,
12999
13200
  fastScreenSharing: u.isFastScreenSharingEnabled,
13000
13201
  captureAudio: !1
@@ -13477,11 +13678,11 @@ var Mc = 15, $ = class e extends Je {
13477
13678
  _getParticipant(e) {
13478
13679
  return this._participants[e];
13479
13680
  }
13480
- }, Nc = null, Pc = class e extends Error {
13681
+ }, Nc = class e extends Error {
13481
13682
  constructor(t, n) {
13482
13683
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
13483
13684
  }
13484
- }, Fc = class {
13685
+ }, Pc = class {
13485
13686
  constructor() {
13486
13687
  h(this, "_abortSignal", void 0), h(this, "_apiCallStats", null);
13487
13688
  }
@@ -13526,7 +13727,7 @@ var Mc = 15, $ = class e extends Je {
13526
13727
  async getInbounds() {
13527
13728
  return [];
13528
13729
  }
13529
- }, Ic = class e {
13730
+ }, Fc = class e {
13530
13731
  constructor() {
13531
13732
  h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
13532
13733
  }
@@ -13561,27 +13762,27 @@ var Mc = 15, $ = class e extends Je {
13561
13762
  clear() {
13562
13763
  this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
13563
13764
  }
13564
- }, Lc = "anonymLogin:", Rc = 700, zc = 3e3;
13565
- function Bc(e) {
13765
+ }, Ic = "anonymLogin:", Lc = 700, Rc = 3e3;
13766
+ function zc(e) {
13566
13767
  let t = e.error_code;
13567
13768
  switch (t) {
13568
- case 2: return Vc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13569
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? Vc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Vc(b.API, t, "request-error");
13570
- case 300: return Vc(O.NOT_FOUND, t, "not-found");
13571
- case 1101: return Vc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13572
- case 1102: return Vc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13573
- case 1103: return Vc(O.NOT_FRIENDS, t, "friendship-required");
13574
- case 1104: return Uc(t, "youla-api-error");
13575
- case 1106: return Uc(t, "vk-api-error");
13576
- case 1113: return Vc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13769
+ case 2: return Bc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13770
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Bc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Bc(y.API, t, "request-error");
13771
+ case 300: return Bc(O.NOT_FOUND, t, "not-found");
13772
+ case 1101: return Bc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13773
+ case 1102: return Bc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13774
+ case 1103: return Bc(O.NOT_FRIENDS, t, "friendship-required");
13775
+ case 1104: return Hc(t, "youla-api-error");
13776
+ case 1106: return Hc(t, "vk-api-error");
13777
+ case 1113: return Bc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13577
13778
  case 1114: {
13578
13779
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
13579
- return Vc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13780
+ return Bc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13580
13781
  }
13581
- default: return Vc(b.API, t, "api-error");
13782
+ default: return Bc(y.API, t, "api-error");
13582
13783
  }
13583
13784
  }
13584
- function Vc(e, t, n, r) {
13785
+ function Bc(e, t, n, r) {
13585
13786
  return {
13586
13787
  type: e,
13587
13788
  callError: {
@@ -13593,10 +13794,10 @@ function Vc(e, t, n, r) {
13593
13794
  message: r
13594
13795
  };
13595
13796
  }
13596
- function Hc(e) {
13797
+ function Vc(e) {
13597
13798
  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);
13598
13799
  }
13599
- function Uc(e, t) {
13800
+ function Hc(e, t) {
13600
13801
  return {
13601
13802
  type: O.EXTERNAL_API_ERROR,
13602
13803
  callError: {
@@ -13607,9 +13808,9 @@ function Uc(e, t) {
13607
13808
  }
13608
13809
  };
13609
13810
  }
13610
- var Wc = class extends Fc {
13811
+ var Uc = class extends Pc {
13611
13812
  constructor() {
13612
- super(), h(this, "_uuid", void 0), h(this, "_idCache", new Ic()), this._cacheSelfExternalId();
13813
+ super(), h(this, "_uuid", void 0), h(this, "_idCache", new Fc()), this._cacheSelfExternalId();
13613
13814
  }
13614
13815
  async _callUnsafe(e, t = {}, n = !1) {
13615
13816
  let r = async (i) => {
@@ -13618,10 +13819,10 @@ var Wc = class extends Fc {
13618
13819
  let r = await As(e, t, n);
13619
13820
  return this._apiCallStats?.log(e, performance.now() - a), r;
13620
13821
  } catch (t) {
13621
- if (this._apiCallStats?.log(e, performance.now() - a, Hc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13822
+ if (this._apiCallStats?.log(e, performance.now() - a, Vc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13622
13823
  i++;
13623
13824
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
13624
- 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 * Rc, zc), { signal: this._abortSignal }), r(i);
13825
+ 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 * Lc, Rc), { signal: this._abortSignal }), r(i);
13625
13826
  }
13626
13827
  throw z.warn(e, "error", t), t;
13627
13828
  }
@@ -13638,22 +13839,22 @@ var Wc = class extends Fc {
13638
13839
  message: i?.error_msg,
13639
13840
  code: i?.error_code
13640
13841
  };
13641
- if (i.custom_error && (a.custom_error = i.custom_error), Gc(i)) {
13642
- let e = Bc(i);
13842
+ if (i.custom_error && (a.custom_error = i.custom_error), Wc(i)) {
13843
+ let e = zc(i);
13643
13844
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
13644
13845
  }
13645
- throw new k(b.API, a);
13846
+ throw new k(y.API, a);
13646
13847
  }
13647
13848
  }
13648
13849
  userId(e) {
13649
- if (y.isEmpty()) {
13850
+ if (v.isEmpty()) {
13650
13851
  let { compositeUserId: t } = M.decomposeParticipantId(e), { id: n } = M.decomposeId(t);
13651
13852
  return Z.fromId(String(n));
13652
13853
  }
13653
13854
  return this._idCache.getExternalId(e);
13654
13855
  }
13655
13856
  async authorize() {
13656
- if (this._ensureUuid(), !N.apiKey) throw new k(b.API, {
13857
+ if (this._ensureUuid(), !N.apiKey) throw new k(y.API, {
13657
13858
  message: "Required argument apiAppKey not passed",
13658
13859
  callError: {
13659
13860
  scope: "internal",
@@ -13669,7 +13870,7 @@ var Wc = class extends Fc {
13669
13870
  return this._anonymLogin(N.authToken).then((e) => {
13670
13871
  this._applyAnonymLogin(e), this._setCachedAnonymLogin(e);
13671
13872
  }).catch((e) => {
13672
- throw e instanceof k ? e : (e?.error_code === ds.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(b.AUTH, {
13873
+ throw e instanceof k ? e : (e?.error_code === ds.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(y.AUTH, {
13673
13874
  message: e?.error_msg,
13674
13875
  code: e?.error_code,
13675
13876
  callError: {
@@ -13691,22 +13892,22 @@ var Wc = class extends Fc {
13691
13892
  return e && (t.session_data.auth_token = e, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0);
13692
13893
  }
13693
13894
  _getAnonymLoginCacheKey() {
13694
- return N.authToken ? `${Lc}${N.authToken}` : null;
13895
+ return N.authToken ? `${Ic}${N.authToken}` : null;
13695
13896
  }
13696
13897
  _getCachedAnonymLogin() {
13697
13898
  let e = this._getAnonymLoginCacheKey();
13698
13899
  if (!e) return null;
13699
13900
  let t = ht.get(e);
13700
- return Jc(t) ? t : (t && ht.remove(e), null);
13901
+ return qc(t) ? t : (t && ht.remove(e), null);
13701
13902
  }
13702
13903
  _setCachedAnonymLogin(e) {
13703
13904
  let t = this._getAnonymLoginCacheKey();
13704
- if (!t || !Kc(e)) return;
13905
+ if (!t || !Gc(e)) return;
13705
13906
  let n = {
13706
13907
  session_key: e.session_key,
13707
13908
  session_secret_key: e.session_secret_key,
13708
13909
  uid: e.uid,
13709
- external_user_id: qc(e)
13910
+ external_user_id: Kc(e)
13710
13911
  };
13711
13912
  ht.set(t, n);
13712
13913
  }
@@ -13715,12 +13916,12 @@ var Wc = class extends Fc {
13715
13916
  e && ht.remove(e);
13716
13917
  }
13717
13918
  _reauthorize() {
13718
- return this._removeCachedAnonymLogin(), y.reauthorize(() => this.authorize());
13919
+ return this._removeCachedAnonymLogin(), v.reauthorize(() => this.authorize());
13719
13920
  }
13720
13921
  _applyAnonymLogin(e) {
13721
- e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key;
13722
- let t = qc(e);
13723
- y.selfExternalId = e.uid && t !== null ? {
13922
+ e.uid && (v.userId = Number(e.uid)), v.sessionKey = e.session_key, v.sessionSecretKey = e.session_secret_key;
13923
+ let t = Kc(e);
13924
+ v.selfExternalId = e.uid && t !== null ? {
13724
13925
  participantId: M.composeParticipantId(Number(e.uid), j.USER, 0),
13725
13926
  externalId: Z.fromId(t, Mo.USER, 0)
13726
13927
  } : null, this._cacheSelfExternalId(), N.statQueueEnabled && e.uid && Rs.remember(Number(e.uid), {
@@ -13729,7 +13930,7 @@ var Wc = class extends Fc {
13729
13930
  });
13730
13931
  }
13731
13932
  _cacheSelfExternalId() {
13732
- let e = y.selfExternalId;
13933
+ let e = v.selfExternalId;
13733
13934
  e && this._idCache.cache(e.participantId, e.externalId);
13734
13935
  }
13735
13936
  _buildClientStatsData(e) {
@@ -13864,7 +14065,7 @@ var Wc = class extends Fc {
13864
14065
  let n = { joinLink: e };
13865
14066
  t && (n.anonymName = t);
13866
14067
  let r = await this._call("vchat.getAnonymTokenByLink", n);
13867
- return y.userId = Number(r.uid), r.token;
14068
+ return v.userId = Number(r.uid), r.token;
13868
14069
  }
13869
14070
  async joinConversationByLink(e, t = !1, n, r) {
13870
14071
  let i = {
@@ -13898,11 +14099,11 @@ var Wc = class extends Fc {
13898
14099
  return N.anonymToken && (t.anonymToken = N.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
13899
14100
  }
13900
14101
  getUserId() {
13901
- return y.userId;
14102
+ return v.userId;
13902
14103
  }
13903
14104
  setUserId(e) {
13904
- y.userId = e, N.statQueueEnabled && y.sessionKey && Rs.remember(Number(e), {
13905
- sessionKey: y.sessionKey,
14105
+ v.userId = e, N.statQueueEnabled && v.sessionKey && Rs.remember(Number(e), {
14106
+ sessionKey: v.sessionKey,
13906
14107
  endpoint: Rs.currentEndpoint()
13907
14108
  });
13908
14109
  }
@@ -13927,26 +14128,26 @@ var Wc = class extends Fc {
13927
14128
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
13928
14129
  }
13929
14130
  };
13930
- function Gc(e) {
14131
+ function Wc(e) {
13931
14132
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
13932
14133
  }
13933
- function Kc(e) {
14134
+ function Gc(e) {
13934
14135
  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;
13935
14136
  }
13936
- function qc(e) {
14137
+ function Kc(e) {
13937
14138
  let t = e?.external_user_id;
13938
14139
  return typeof t == "string" && t.length > 0 ? t : null;
13939
14140
  }
13940
- function Jc(e) {
13941
- return Kc(e) && "external_user_id" in e && (typeof e.external_user_id == "string" || e.external_user_id === null);
14141
+ function qc(e) {
14142
+ return Gc(e) && "external_user_id" in e && (typeof e.external_user_id == "string" || e.external_user_id === null);
13942
14143
  }
13943
14144
  //#endregion
13944
14145
  //#region src/enums/RecordRole.ts
13945
- var Yc = /* @__PURE__ */ function(e) {
14146
+ var Jc = /* @__PURE__ */ function(e) {
13946
14147
  return e.KING = "KING", e.PAWN = "PAWN", e;
13947
- }(Yc || {}), Xc = /* @__PURE__ */ function(e) {
14148
+ }(Jc || {}), Yc = /* @__PURE__ */ function(e) {
13948
14149
  return e.OFF = "0", e.ON = "1", e;
13949
- }({}), Zc = class {
14150
+ }({}), Xc = class {
13950
14151
  constructor(e) {
13951
14152
  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;
13952
14153
  }
@@ -13969,7 +14170,7 @@ var Yc = /* @__PURE__ */ function(e) {
13969
14170
  let e = this._queue[this._readCursor];
13970
14171
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
13971
14172
  }
13972
- }, Qc = class {
14173
+ }, Zc = class {
13973
14174
  constructor(e, t, n, r = null) {
13974
14175
  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;
13975
14176
  }
@@ -13995,7 +14196,7 @@ var Yc = /* @__PURE__ */ function(e) {
13995
14196
  };
13996
14197
  t?.peerId && (n.peerId = t.peerId), await As("vchat.hangupConversation", n, !0, await Ds(this._baseApiUrl, this._apiEnv));
13997
14198
  }
13998
- }, $c, el = null, tl = !1, nl = {
14199
+ }, Qc, $c = null, el = !1, tl = {
13999
14200
  getCameras: E.getCameras,
14000
14201
  getMicrophones: E.getMicrophones,
14001
14202
  getOutput: E.getOutput,
@@ -14012,59 +14213,59 @@ var Yc = /* @__PURE__ */ function(e) {
14012
14213
  getUserVideo: E.getUserVideo,
14013
14214
  getUserAudio: E.getUserAudio,
14014
14215
  setResolution: E.setResolution,
14015
- isBrowserSupported: w.isBrowserSupported,
14016
- isScreenCapturingSupported: w.isScreenCapturingSupported,
14017
- canSelectAudioInput: w.canSelectAudioInput,
14018
- canSelectAudioOutput: w.canSelectAudioOutput,
14019
- os: w.os,
14020
- isMobile: w.isMobile,
14021
- browserName: w.browserName,
14022
- browserVersion: w.browserVersion,
14023
- baseChromeVersion: w.baseChromeVersion,
14216
+ isBrowserSupported: C.isBrowserSupported,
14217
+ isScreenCapturingSupported: C.isScreenCapturingSupported,
14218
+ canSelectAudioInput: C.canSelectAudioInput,
14219
+ canSelectAudioOutput: C.canSelectAudioOutput,
14220
+ os: C.os,
14221
+ isMobile: C.isMobile,
14222
+ browserName: C.browserName,
14223
+ browserVersion: C.browserVersion,
14224
+ baseChromeVersion: C.baseChromeVersion,
14024
14225
  getAudioContext: E.getAudioContext,
14025
- isAudioShareSupported: w.isAudioShareSupported
14026
- }, rl = { participantMarkerCompare: M.participantMarkerCompare };
14027
- function il(e) {
14028
- el = e;
14226
+ isAudioShareSupported: C.isAudioShareSupported
14227
+ }, nl = { participantMarkerCompare: M.participantMarkerCompare };
14228
+ function rl(e) {
14229
+ $c = e;
14029
14230
  }
14030
- function al(e) {
14231
+ function il(e) {
14031
14232
  N.videoEffects = e;
14032
14233
  }
14033
- function ol(e) {
14234
+ function al(e) {
14034
14235
  N.audioEffects = e;
14035
14236
  }
14036
- function sl(e, t = {}) {
14237
+ function ol(e, t = {}) {
14037
14238
  N.vad = e, N.vadOptions = t;
14038
14239
  }
14039
- function cl(e, t = null, n = {}, r = 1) {
14240
+ function sl(e, t = null, n = {}, r = 1) {
14040
14241
  N.vmoji = e, N.vmojiOptions = {
14041
14242
  protocolVersion: r,
14042
14243
  renderingOptions: n
14043
14244
  }, t && e.setSDK(t);
14044
14245
  }
14045
- async function ll(t) {
14046
- N.set(t), $c || ($c = new Wc()), N.statQueueEnabled && (Bs.setApi($c), N.autoStartStats && gl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
14047
- let n = w.getBrowserSupportFailure();
14048
- if (n) throw new k(b.UNSUPPORTED, { callError: {
14246
+ async function cl(t) {
14247
+ N.set(t), Qc || (Qc = new Uc()), N.statQueueEnabled && (Bs.setApi(Qc), N.autoStartStats && hl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
14248
+ let n = C.getBrowserSupportFailure();
14249
+ if (n) throw new k(y.UNSUPPORTED, { callError: {
14049
14250
  scope: "internal",
14050
14251
  code: "environment",
14051
14252
  description: n
14052
14253
  } });
14053
14254
  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}`);
14054
14255
  }
14055
- async function ul(e, t = [x.AUDIO], n = "", r = !1, i = !1, a, o, s) {
14256
+ async function ll(e, t = [b.AUDIO], n = "", r = !1, i = !1, a, o, s) {
14056
14257
  let c = [];
14057
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), fl([], vo.USER, t, n, r, i, a, c, o, s);
14258
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), dl([], vo.USER, t, n, r, i, a, c, o, s);
14058
14259
  }
14059
- function dl(e, t = []) {
14260
+ function ul(e, t = []) {
14060
14261
  let n = e.getIncomingCallerExternalId();
14061
14262
  return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
14062
14263
  }
14063
- async function fl(e, t = vo.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
14264
+ async function dl(e, t = vo.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
14064
14265
  if (!N.hold && B.getActive()) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
14065
14266
  let u = B.getAll().find((e) => e.isIncomingRinging);
14066
- if (!N.hold && u && !dl(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
14067
- return new $(new Wc(), el).onStart({
14267
+ if (!N.hold && u && !ul(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
14268
+ return new $(new Uc(), $c).onStart({
14068
14269
  opponentIds: e,
14069
14270
  opponentType: t,
14070
14271
  mediaOptions: n,
@@ -14077,49 +14278,49 @@ async function fl(e, t = vo.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
14077
14278
  conversationId: l
14078
14279
  });
14079
14280
  }
14080
- async function pl(e, t) {
14081
- return ml(e, j.USER, void 0, t);
14281
+ async function fl(e, t) {
14282
+ return pl(e, j.USER, void 0, t);
14082
14283
  }
14083
- async function ml(e, t = j.USER, n, r, i, a) {
14284
+ async function pl(e, t = j.USER, n, r, i, a) {
14084
14285
  if (e === $.id()) throw Error("Push has already been processed");
14085
- return new $(new Wc(), el).onPush(e, t, n, r, i, a);
14286
+ return new $(new Uc(), $c).onPush(e, t, n, r, i, a);
14086
14287
  }
14087
- async function hl() {
14088
- return $c.getInbounds();
14288
+ async function ml() {
14289
+ return Qc.getInbounds();
14089
14290
  }
14090
- function gl() {
14291
+ function hl() {
14091
14292
  if (N.statQueueEnabled) {
14092
- if (!$c) {
14293
+ if (!Qc) {
14093
14294
  z.error("[CallsSDK] startStats() called before init()");
14094
14295
  return;
14095
14296
  }
14096
- tl || (tl = !0, Xs.start($c));
14297
+ el || (el = !0, Xs.start(Qc));
14097
14298
  }
14098
14299
  }
14099
- async function _l(e, t) {
14100
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, Ts()), $c.authorize();
14300
+ async function gl(e, t) {
14301
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, Ts()), Qc.authorize();
14101
14302
  }
14102
- async function vl(e = [x.AUDIO], t) {
14103
- return Uu(t).accept(e);
14303
+ async function _l(e = [b.AUDIO], t) {
14304
+ return Hu(t).accept(e);
14104
14305
  }
14105
- async function yl(e) {
14106
- let t = Bu(e?.conversationId);
14306
+ async function vl(e) {
14307
+ let t = zu(e?.conversationId);
14107
14308
  if (t) return t.decline(e);
14108
14309
  }
14109
- async function bl(e, t = [x.AUDIO]) {
14110
- return xl(e, t);
14310
+ async function yl(e, t = [b.AUDIO]) {
14311
+ return bl(e, t);
14111
14312
  }
14112
- async function xl(e, t, n) {
14313
+ async function bl(e, t, n) {
14113
14314
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
14114
- return new $(new Wc(), el).onJoin({
14315
+ return new $(new Uc(), $c).onJoin({
14115
14316
  conversationId: e,
14116
14317
  mediaOptions: t,
14117
14318
  chatId: n
14118
14319
  });
14119
14320
  }
14120
- async function Sl(e, t = [x.AUDIO], n, r, i, a) {
14321
+ async function xl(e, t = [b.AUDIO], n, r, i, a) {
14121
14322
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
14122
- return n && (N.anonymToken = n), new $(new Wc(), el).onJoin({
14323
+ return n && (N.anonymToken = n), new $(new Uc(), $c).onJoin({
14123
14324
  joinLink: e,
14124
14325
  mediaOptions: t,
14125
14326
  observedIds: r,
@@ -14128,30 +14329,30 @@ async function Sl(e, t = [x.AUDIO], n, r, i, a) {
14128
14329
  anonymous: !!N.anonymToken
14129
14330
  });
14130
14331
  }
14131
- function Cl(e) {
14132
- let t = Bu(e?.conversationId);
14133
- return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
14332
+ function Sl(e) {
14333
+ let t = B.getLocal(e?.conversationId);
14334
+ return t ? t.hangup(e) : B.getHangup(e?.conversationId) ?? Promise.resolve();
14134
14335
  }
14135
- async function wl(e, t) {
14336
+ async function Cl(e, t) {
14136
14337
  let n = Array.isArray(e) ? e : [e], r = $.current();
14137
14338
  if (r) return r.addParticipant(n, t);
14138
14339
  }
14139
- async function Tl(e, t) {
14340
+ async function wl(e, t) {
14140
14341
  let n = $.current();
14141
14342
  if (n) {
14142
14343
  let r = e.map((e) => M.composeUserId(e));
14143
14344
  await n.addParticipantLegacy(r, t);
14144
14345
  }
14145
14346
  }
14146
- async function El(e, t = !1) {
14147
- let n = Wu(e, "removeParticipant");
14347
+ async function Tl(e, t = !1) {
14348
+ let n = Uu(e, "removeParticipant");
14148
14349
  if (n) try {
14149
14350
  await n.conversation.removeParticipant(M.decomposeParticipantId(n.participantId).compositeUserId, t);
14150
14351
  } catch (e) {
14151
14352
  z.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
14152
14353
  }
14153
14354
  }
14154
- async function Dl(e, t = !1) {
14355
+ async function El(e, t = !1) {
14155
14356
  let n = $.current();
14156
14357
  if (n) try {
14157
14358
  await n.removeParticipant(M.composeUserId(e), t);
@@ -14159,13 +14360,13 @@ async function Dl(e, t = !1) {
14159
14360
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
14160
14361
  }
14161
14362
  }
14162
- async function Ol(e, t) {
14363
+ async function Dl(e, t) {
14163
14364
  let n = $.current();
14164
- if (e === "videoinput" && It.contains(t)) return N.videoFacingMode = t, n ? (w.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
14365
+ if (e === "videoinput" && It.contains(t)) return N.videoFacingMode = t, n ? (C.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
14165
14366
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
14166
14367
  if (n) return n.changeDevice(e);
14167
14368
  }
14168
- async function kl(e, t) {
14369
+ async function Ol(e, t) {
14169
14370
  let n = typeof e == "object" ? {
14170
14371
  ...e,
14171
14372
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -14174,40 +14375,40 @@ async function kl(e, t) {
14174
14375
  captureScreen: e,
14175
14376
  fastScreenSharing: !1,
14176
14377
  captureAudio: !1
14177
- }, r = Bu(t);
14378
+ }, r = B.getLocal(t);
14178
14379
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
14179
14380
  }
14180
- function Al(e) {
14381
+ function kl(e) {
14181
14382
  let t = $.current();
14182
14383
  t && t.toggleAnimojiCapturing(e);
14183
14384
  }
14184
- async function jl(e, t = !1) {
14385
+ async function Al(e, t = !1) {
14185
14386
  let n = $.current();
14186
14387
  n && await n.setVideoStream(e, t);
14187
14388
  }
14188
- async function Ml(e, t) {
14189
- let n = Bu(t);
14389
+ async function jl(e, t) {
14390
+ let n = B.getLocal(t);
14190
14391
  n && await n.toggleLocalVideo(e);
14191
14392
  }
14192
- async function Nl(e, t) {
14193
- let n = Bu(t);
14393
+ async function Ml(e, t) {
14394
+ let n = B.getLocal(t);
14194
14395
  n && await n.toggleLocalAudio(e);
14195
14396
  }
14196
- async function Pl(e) {
14397
+ async function Nl(e) {
14197
14398
  let t = $.current();
14198
14399
  if (t) return t.setLocalResolution(e);
14199
14400
  }
14200
- async function Fl(e) {
14401
+ async function Pl(e) {
14201
14402
  let t = $.current();
14202
14403
  t && await t.changePriorities(e);
14203
14404
  }
14204
- async function Il(e, t) {
14405
+ async function Fl(e, t) {
14205
14406
  let n = $.current();
14206
14407
  if (n) {
14207
14408
  if (t) {
14208
14409
  let r = n.getCachedParticipantIdByExternalId(t);
14209
14410
  if (!r) {
14210
- Vu(t, "changeParticipantState", n);
14411
+ Bu(t, "changeParticipantState", n);
14211
14412
  return;
14212
14413
  }
14213
14414
  await n.changeParticipantState(e, r);
@@ -14216,161 +14417,161 @@ async function Il(e, t) {
14216
14417
  await n.changeParticipantState(e);
14217
14418
  }
14218
14419
  }
14219
- async function Ll() {
14420
+ async function Il() {
14220
14421
  let e = $.current();
14221
14422
  e && await e.putHandsDown();
14222
14423
  }
14223
- async function Rl(e) {
14424
+ async function Ll(e) {
14224
14425
  let t = $.current();
14225
14426
  t && await t.updateDisplayLayout(e);
14226
14427
  }
14227
- async function zl(e) {
14428
+ async function Rl(e) {
14228
14429
  let t = $.current();
14229
14430
  t && await t.requestDisplayLayout(e);
14230
14431
  }
14231
- async function Bl(e, t, n = !1) {
14232
- let r = Wu(e, "grantRoles");
14432
+ async function zl(e, t, n = !1) {
14433
+ let r = Uu(e, "grantRoles");
14233
14434
  r && await r.conversation.grantRoles(r.participantId, t, n);
14234
14435
  }
14235
- async function Vl(e, t, n, r = !1) {
14436
+ async function Bl(e, t, n, r = !1) {
14236
14437
  let i = $.current();
14237
14438
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
14238
14439
  }
14239
- async function Hl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
14440
+ async function Vl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
14240
14441
  if (e) {
14241
- let i = Wu(e, "muteParticipant");
14442
+ let i = Uu(e, "muteParticipant");
14242
14443
  return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
14243
14444
  }
14244
14445
  let i = $.current();
14245
14446
  i && await i.muteParticipant(null, t, n, r);
14246
14447
  }
14247
- async function Ul({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
14448
+ async function Hl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
14248
14449
  let a = $.current();
14249
14450
  if (a) {
14250
14451
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
14251
14452
  await a.muteParticipant(o, t, n, i);
14252
14453
  }
14253
14454
  }
14254
- async function Wl(e, t = !1, n = null) {
14255
- let r = Wu(e, "pinParticipant");
14455
+ async function Ul(e, t = !1, n = null) {
14456
+ let r = Uu(e, "pinParticipant");
14256
14457
  r && await r.conversation.pinParticipant(r.participantId, t, n);
14257
14458
  }
14258
- async function Gl(e, t = !1, n = 0, r = null) {
14459
+ async function Wl(e, t = !1, n = 0, r = null) {
14259
14460
  let i = $.current();
14260
14461
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
14261
14462
  }
14262
- async function Kl(e) {
14463
+ async function Gl(e) {
14263
14464
  let t = $.current();
14264
14465
  t && await t.updateMediaModifiers(e);
14265
14466
  }
14266
- async function ql(e) {
14467
+ async function Kl(e) {
14267
14468
  let t = $.current();
14268
14469
  t && await t.enableVideoSuspend(e);
14269
14470
  }
14270
- async function Jl(e) {
14471
+ async function ql(e) {
14271
14472
  let t = $.current();
14272
14473
  t && await t.enableVideoSuspendSuggest(e);
14273
14474
  }
14274
- async function Yl(e) {
14475
+ async function Jl(e) {
14275
14476
  let t = $.current();
14276
14477
  t && await t.changeOptions(e);
14277
14478
  }
14278
- async function Xl(e, t = null) {
14479
+ async function Yl(e, t = null) {
14279
14480
  if (t) {
14280
- let n = Wu(t, "chatMessage");
14481
+ let n = Uu(t, "chatMessage");
14281
14482
  return n ? n.conversation.chatMessage(e, M.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
14282
14483
  }
14283
14484
  let n = $.current();
14284
14485
  n && await n.chatMessage(e, null);
14285
14486
  }
14286
- async function Zl(e, t = null) {
14487
+ async function Xl(e, t = null) {
14287
14488
  let n = $.current();
14288
14489
  if (n) {
14289
14490
  let r = t ? M.composeUserId(t) : null;
14290
14491
  await n.chatMessage(e, r);
14291
14492
  }
14292
14493
  }
14293
- async function Ql(e = 10) {
14494
+ async function Zl(e = 10) {
14294
14495
  let t = $.current();
14295
14496
  if (t) return t.chatHistory(e);
14296
14497
  }
14297
- async function $l(e, t = null) {
14498
+ async function Ql(e, t = null) {
14298
14499
  if (t) {
14299
- let n = Wu(t, "customData");
14500
+ let n = Uu(t, "customData");
14300
14501
  return n ? n.conversation.customData(e, n.participantId) : void 0;
14301
14502
  }
14302
14503
  let n = $.current();
14303
14504
  n && await n.customData(e, null);
14304
14505
  }
14305
- async function eu(e, t = null, n = 0) {
14506
+ async function $l(e, t = null, n = 0) {
14306
14507
  let r = $.current();
14307
14508
  if (r) {
14308
14509
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
14309
14510
  await r.customData(e, i);
14310
14511
  }
14311
14512
  }
14312
- async function tu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14313
- return (await $c.createConversation(a ?? M.uuid(), e, t, {
14513
+ async function eu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14514
+ return (await Qc.createConversation(a ?? M.uuid(), e, t, {
14314
14515
  onlyAdminCanShareMovie: n,
14315
14516
  waitForAdmin: r,
14316
14517
  closedConversation: i
14317
14518
  })).join_link;
14318
14519
  }
14319
- async function nu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14520
+ async function tu(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14320
14521
  let a = i.map((e) => Z.fromId(e));
14321
- return (await $c.createConversation(M.uuid(), e, t, {
14522
+ return (await Qc.createConversation(M.uuid(), e, t, {
14322
14523
  onlyAdminCanShareMovie: n,
14323
14524
  audienceMode: !0,
14324
14525
  audioOnly: r
14325
14526
  }, a)).join_link;
14326
14527
  }
14327
- async function ru() {
14528
+ async function nu() {
14328
14529
  let e = $.current();
14329
14530
  return e ? e.createJoinLink() : Promise.reject();
14330
14531
  }
14331
- async function iu() {
14532
+ async function ru() {
14332
14533
  let e = $.current();
14333
14534
  return e ? e.removeJoinLink() : Promise.reject();
14334
14535
  }
14335
- async function au(e, t) {
14336
- return $c.getAnonymTokenByLink(e, t);
14536
+ async function iu(e, t) {
14537
+ return Qc.getAnonymTokenByLink(e, t);
14337
14538
  }
14338
- function ou(e) {
14539
+ function au(e) {
14339
14540
  let t = $.current();
14340
14541
  t && t.setVolume(e);
14341
14542
  }
14342
- function su(e) {
14543
+ function ou(e) {
14343
14544
  N.forceRelayPolicy = e;
14344
14545
  }
14345
- async function cu(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14546
+ async function su(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14346
14547
  let o = $.current();
14347
14548
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
14348
14549
  }
14349
- async function lu(e = null, t) {
14550
+ async function cu(e = null, t) {
14350
14551
  let n = $.current();
14351
14552
  return n ? n.stopStream(e, t) : Promise.reject();
14352
14553
  }
14353
- async function uu(e = null) {
14554
+ async function lu(e = null) {
14354
14555
  let t = $.current();
14355
14556
  return t ? t.publishStream(e) : Promise.reject();
14356
14557
  }
14357
- async function du() {
14558
+ async function uu() {
14358
14559
  let e = $.current();
14359
14560
  return e ? e.getStreamInfo() : Promise.reject();
14360
14561
  }
14361
- async function fu(e) {
14562
+ async function du(e) {
14362
14563
  let t = $.current();
14363
14564
  return t ? t.addMovie(e) : Promise.reject();
14364
14565
  }
14365
- async function pu(e) {
14566
+ async function fu(e) {
14366
14567
  let t = $.current();
14367
14568
  return t ? t.updateMovie(e) : Promise.reject();
14368
14569
  }
14369
- async function mu(e) {
14570
+ async function pu(e) {
14370
14571
  let t = $.current();
14371
14572
  return t ? t.removeMovie(e) : Promise.reject();
14372
14573
  }
14373
- async function hu(e, t) {
14574
+ async function mu(e, t) {
14374
14575
  let n = $.current();
14375
14576
  if (n) {
14376
14577
  let r = [], i = [];
@@ -14392,54 +14593,54 @@ async function hu(e, t) {
14392
14593
  });
14393
14594
  }
14394
14595
  if (i.length) {
14395
- Hu(i, "updateRooms", n);
14596
+ Vu(i, "updateRooms", n);
14396
14597
  return;
14397
14598
  }
14398
14599
  return n.updateRooms(r, t);
14399
14600
  }
14400
14601
  return Promise.reject();
14401
14602
  }
14402
- async function gu(e, t) {
14603
+ async function hu(e, t) {
14403
14604
  let n = $.current();
14404
14605
  return n ? n.activateRooms(e, t) : Promise.reject();
14405
14606
  }
14406
- async function _u(e = null, t = null) {
14607
+ async function gu(e = null, t = null) {
14407
14608
  let n = $.current();
14408
14609
  if (!n) return Promise.reject();
14409
14610
  let r;
14410
14611
  if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
14411
- Vu(t, "switchRoom", n);
14612
+ Bu(t, "switchRoom", n);
14412
14613
  return;
14413
14614
  }
14414
14615
  return n.switchRoom(e, r);
14415
14616
  }
14416
- async function vu(e) {
14617
+ async function _u(e) {
14417
14618
  let t = $.current();
14418
14619
  return t ? t.removeRooms(e) : Promise.reject();
14419
14620
  }
14420
- function yu(e) {
14621
+ function vu(e) {
14421
14622
  N.statisticsInterval = e;
14422
14623
  let t = $.current();
14423
14624
  if (t) return t.updateStatisticsInterval();
14424
14625
  }
14425
- function bu(t) {
14626
+ function yu(t) {
14426
14627
  e.disableLog(!t), z.toggle(t);
14427
14628
  }
14428
- function xu(e, ...t) {
14629
+ function bu(e, ...t) {
14429
14630
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
14430
14631
  }
14431
- function Su(e, t, ...n) {
14632
+ function xu(e, t, ...n) {
14432
14633
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
14433
14634
  }
14434
- var Cu = {
14435
- list: Ne,
14436
- get: Pe,
14437
- getJson: Fe,
14438
- download: Ie,
14439
- clear: Le,
14440
- stats: Re
14635
+ var Su = {
14636
+ list: Pe,
14637
+ get: Fe,
14638
+ getJson: Ie,
14639
+ download: Le,
14640
+ clear: Re,
14641
+ stats: ze
14441
14642
  };
14442
- function wu() {
14643
+ function Cu() {
14443
14644
  let e = [
14444
14645
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
14445
14646
  ["UserAgent:", navigator.userAgent],
@@ -14457,139 +14658,139 @@ function wu() {
14457
14658
  d: e
14458
14659
  }));
14459
14660
  }
14460
- async function Tu() {
14661
+ async function wu() {
14461
14662
  let e = $.id(), t = $.debugSessionId();
14462
14663
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
14463
- let n = await Pe({ sessionId: t });
14664
+ let n = await Fe({ sessionId: t });
14464
14665
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
14465
14666
  let r = n[0].t, i = n[n.length - 1].t;
14466
14667
  try {
14467
- return $c?.uploadDebugLogs(e, r, i, JSON.stringify([...wu(), ...n]));
14668
+ return Qc?.uploadDebugLogs(e, r, i, JSON.stringify([...Cu(), ...n]));
14468
14669
  } catch (e) {
14469
14670
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
14470
14671
  }
14471
14672
  }
14472
- async function Eu(e) {
14673
+ async function Tu(e) {
14473
14674
  let t = $.current();
14474
14675
  if (t) return t.videoEffect(e);
14475
14676
  }
14476
- async function Du(e, t) {
14677
+ async function Eu(e, t) {
14477
14678
  let n = $.current();
14478
14679
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
14479
14680
  }
14480
- async function Ou(e) {
14681
+ async function Du(e) {
14481
14682
  let t = $.current();
14482
14683
  t && await t.setAudioStream(e);
14483
14684
  }
14484
- async function ku(e, t = null, n = null) {
14685
+ async function Ou(e, t = null, n = null) {
14485
14686
  let r = $.current();
14486
14687
  if (!r) return;
14487
14688
  let i = n ?? t?.id, a = null;
14488
14689
  if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
14489
- Vu(t, "setVmojiSvg", r);
14690
+ Bu(t, "setVmojiSvg", r);
14490
14691
  return;
14491
14692
  }
14492
14693
  r.setAnimojiSvg(e, a, i);
14493
14694
  }
14494
- function Au(e) {
14695
+ function ku(e) {
14495
14696
  let t = $.current();
14496
14697
  t && t.setAnimojiFill(e);
14497
14698
  }
14498
- async function ju(e = null, t, n = !1) {
14499
- return Uu().getWaitingHall(e, t, n);
14699
+ async function Au(e = null, t, n = !1) {
14700
+ return Hu().getWaitingHall(e, t, n);
14500
14701
  }
14501
- async function Mu() {
14502
- return Uu().getAudienceModeHands();
14702
+ async function ju() {
14703
+ return Hu().getAudienceModeHands();
14503
14704
  }
14504
- async function Nu(e, t = !1) {
14505
- let n = Uu(), r;
14705
+ async function Mu(e, t = !1) {
14706
+ let n = Hu(), r;
14506
14707
  if (e) {
14507
14708
  let t = n.getCachedParticipantIdByExternalId(e);
14508
14709
  if (!t) {
14509
- Vu(e, "promoteParticipant", n);
14710
+ Bu(e, "promoteParticipant", n);
14510
14711
  return;
14511
14712
  }
14512
14713
  r = M.decomposeParticipantId(t).compositeUserId;
14513
14714
  }
14514
14715
  return n.promoteParticipant(r, t);
14515
14716
  }
14717
+ async function Nu(e = !1) {
14718
+ return Hu().requestPromotion(e);
14719
+ }
14516
14720
  async function Pu(e = !1) {
14517
- return Uu().requestPromotion(e);
14721
+ return Hu().acceptPromotion(e);
14518
14722
  }
14519
- async function Fu(e = !1) {
14520
- return Uu().acceptPromotion(e);
14723
+ async function Fu(e) {
14724
+ return Hu().getParticipantListChunk(e);
14521
14725
  }
14522
14726
  async function Iu(e) {
14523
- return Uu().getParticipantListChunk(e);
14727
+ return Hu().getParticipants(e);
14524
14728
  }
14525
14729
  async function Lu(e) {
14526
- return Uu().getParticipants(e);
14730
+ return Hu().feedback(e);
14527
14731
  }
14528
- async function Ru(e) {
14529
- return Uu().feedback(e);
14732
+ async function Ru(e, t, n) {
14733
+ return Hu(n).enableFeatureForRoles(e, t);
14530
14734
  }
14531
- async function zu(e, t, n) {
14532
- return Uu(n).enableFeatureForRoles(e, t);
14533
- }
14534
- function Bu(e) {
14735
+ function zu(e) {
14535
14736
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
14536
14737
  }
14537
- function Vu(e, t, n) {
14738
+ function Bu(e, t, n) {
14538
14739
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
14539
14740
  }
14540
- function Hu(e, t, n) {
14741
+ function Vu(e, t, n) {
14541
14742
  let r = Array.from(new Set(e));
14542
14743
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
14543
14744
  }
14544
- function Uu(e) {
14545
- let t = Bu(e);
14745
+ function Hu(e) {
14746
+ let t = zu(e);
14546
14747
  if (!t) throw Error("Conversation not found");
14547
14748
  return t;
14548
14749
  }
14549
- function Wu(e, t) {
14750
+ function Uu(e, t) {
14550
14751
  let n = $.current();
14551
14752
  if (!n) return null;
14552
14753
  let r = n.getCachedParticipantIdByExternalId(e);
14553
14754
  return r ? {
14554
14755
  conversation: n,
14555
14756
  participantId: r
14556
- } : (Vu(e, t, n), null);
14757
+ } : (Bu(e, t, n), null);
14557
14758
  }
14558
- async function Gu(e) {
14559
- await $c.removeHistoryRecords(e);
14759
+ async function Wu(e) {
14760
+ await Qc.removeHistoryRecords(e);
14560
14761
  }
14561
- async function Ku(e) {
14762
+ async function Gu(e) {
14562
14763
  let t = $.current() ?? B.getFirst();
14563
14764
  t && await t.startAsr(e);
14564
14765
  }
14565
- async function qu(e) {
14766
+ async function Ku(e) {
14566
14767
  let t = $.current() ?? B.getFirst();
14567
14768
  t && await t.stopAsr(e);
14568
14769
  }
14569
- async function Ju(e) {
14770
+ async function qu(e) {
14570
14771
  let t = $.current() ?? B.getFirst();
14571
14772
  t && await t.requestAsr(e);
14572
14773
  }
14573
- async function Yu(e) {
14774
+ async function Ju(e) {
14574
14775
  let t = $.current();
14575
14776
  return t ? t.startUrlSharing(e) : Promise.reject();
14576
14777
  }
14577
- async function Xu() {
14778
+ async function Yu() {
14578
14779
  let e = $.current();
14579
14780
  return e ? e.stopUrlSharing() : Promise.reject();
14580
14781
  }
14581
- async function Zu(e) {
14782
+ async function Xu(e) {
14582
14783
  await B.switchCall(e);
14583
14784
  }
14584
- function Qu() {
14785
+ function Zu() {
14585
14786
  return B.getActiveId();
14586
14787
  }
14587
- function $u() {
14788
+ function Qu() {
14588
14789
  return $.getSyncedTime();
14589
14790
  }
14590
- function ed() {
14791
+ function $u() {
14591
14792
  return N.sdkVersion;
14592
14793
  }
14593
14794
  typeof window < "u" && (window.__CALLS_SDK = wn);
14594
14795
  //#endregion
14595
- export { Wc as Api, Qc as ApiExternal, Zc 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, Xc as ParticipantStateDataValue, P as ParticipantStatus, Yc 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, vl as acceptCall, Fu as acceptPromotion, gu as activateRooms, fu as addMovie, wl as addParticipant, Tl as addParticipantInternal, _l as authorize, nl as browser, fl as callInternal, ul as callTo, kl as captureScreen, Al as captureVmoji, Du as changeAudioEffect, Yl as changeConversationOptions, Ol as changeDevice, Il as changeParticipantState, Fl as changePriorities, Eu as changeVideoEffect, Ql as chatHistory, Xl as chatMessage, Zl as chatMessageInternal, ru as createJoinLink, $l as customData, eu as customDataInternal, bu as debug, Cu as debugLogs, xu as debugMessage, Su as debugMessageWithContext, yl as declineCall, zu as enableFeatureForRoles, ql as enableVideoSuspend, Jl as enableVideoSuspendSuggest, Ru as feedback, su as forceRelayPolicy, Qu as getActiveCallId, au as getAnonymTokenByLink, Mu as getAudienceModeHands, hl as getInbounds, Iu as getParticipantListChunk, Lu as getParticipants, du as getStreamInfo, $u as getSyncedTime, ju as getWaitingHall, Bl as grantRoles, Vl as grantRolesInternal, Cl as hangup, ll as init, bl as joinCall, Sl as joinCallByLink, xl as joinCallInternal, Hl as muteParticipant, Ul as muteParticipantInternal, Wl as pinParticipant, Gl as pinParticipantInternal, pl as processPush, ml as processPushInternal, Nu as promoteParticipant, uu as publishStream, Ll as putHandsDown, Gu as removeHistoryRecords, iu as removeJoinLink, mu as removeMovie, El as removeParticipant, Dl as removeParticipantInternal, vu as removeRooms, Ju as requestAsr, zl as requestDisplayLayout, Pu as requestPromotion, ol as setAudioEffects, Ou as setAudioStream, Pl as setLocalResolution, il as setLogger, Kl as setMediaModifiers, yu as setStatisticsInterval, sl as setVad, al as setVideoEffects, jl as setVideoStream, cl as setVmoji, Au as setVmojiFill, ku as setVmojiSvg, ou as setVolume, Ku as startAsr, nu as startAudienceConversation, tu as startConversation, gl as startStats, cu as startStream, Yu as startUrlSharing, qu as stopAsr, lu as stopStream, Xu as stopUrlSharing, Zu as switchCall, _u as switchRoom, Nl as toggleLocalAudio, Ml as toggleLocalVideo, Rl as updateDisplayLayout, pu as updateMovie, hu as updateRooms, Tu as uploadDebugLogs, rl as utils, ed as version };
14796
+ export { Uc as Api, Zc as ApiExternal, Xc as ArrayDequeue, v 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, y as FatalError, k as HangupReason, O as HangupType, b as MediaOption, A as MediaTrackKind, H as MediaType, wo as MuteState, X as ParticipantState, Yc as ParticipantStateDataValue, P as ParticipantStatus, Jc 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, _l as acceptCall, Pu as acceptPromotion, hu as activateRooms, du as addMovie, Cl as addParticipant, wl as addParticipantInternal, gl as authorize, tl as browser, dl as callInternal, ll as callTo, Ol as captureScreen, kl as captureVmoji, Eu as changeAudioEffect, Jl as changeConversationOptions, Dl as changeDevice, Fl as changeParticipantState, Pl as changePriorities, Tu as changeVideoEffect, Zl as chatHistory, Yl as chatMessage, Xl as chatMessageInternal, nu as createJoinLink, Ql as customData, $l as customDataInternal, yu as debug, Su as debugLogs, bu as debugMessage, xu as debugMessageWithContext, vl as declineCall, Ru as enableFeatureForRoles, Kl as enableVideoSuspend, ql as enableVideoSuspendSuggest, Lu as feedback, ou as forceRelayPolicy, Zu as getActiveCallId, iu as getAnonymTokenByLink, ju as getAudienceModeHands, ml as getInbounds, Fu as getParticipantListChunk, Iu as getParticipants, uu as getStreamInfo, Qu as getSyncedTime, Au as getWaitingHall, zl as grantRoles, Bl as grantRolesInternal, Sl as hangup, cl as init, yl as joinCall, xl as joinCallByLink, bl as joinCallInternal, Vl as muteParticipant, Hl as muteParticipantInternal, Ul as pinParticipant, Wl as pinParticipantInternal, fl as processPush, pl as processPushInternal, Mu as promoteParticipant, lu as publishStream, Il as putHandsDown, Wu as removeHistoryRecords, ru as removeJoinLink, pu as removeMovie, Tl as removeParticipant, El as removeParticipantInternal, _u as removeRooms, qu as requestAsr, Rl as requestDisplayLayout, Nu as requestPromotion, al as setAudioEffects, Du as setAudioStream, Nl as setLocalResolution, rl as setLogger, Gl as setMediaModifiers, vu as setStatisticsInterval, ol as setVad, il as setVideoEffects, Al as setVideoStream, sl as setVmoji, ku as setVmojiFill, Ou as setVmojiSvg, au as setVolume, Gu as startAsr, tu as startAudienceConversation, eu as startConversation, hl as startStats, su as startStream, Ju as startUrlSharing, Ku as stopAsr, cu as stopStream, Yu as stopUrlSharing, Xu as switchCall, gu as switchRoom, Ml as toggleLocalAudio, jl as toggleLocalVideo, Ll as updateDisplayLayout, fu as updateMovie, mu as updateRooms, wu as uploadDebugLogs, nl as utils, $u as version };