@dtelecom/livekit-client 1.12.13 → 1.12.15

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.
@@ -328,27 +328,11 @@ function setLogExtension(extension) {
328
328
 
329
329
  loglevelExports.getLogger('lk-e2ee');
330
330
 
331
- /**
332
- * @license
333
- * Copyright 2009 The Closure Library Authors
334
- * Copyright 2020 Daniel Wirtz / The long.js Authors.
335
- *
336
- * Licensed under the Apache License, Version 2.0 (the "License");
337
- * you may not use this file except in compliance with the License.
338
- * You may obtain a copy of the License at
339
- *
340
- * http://www.apache.org/licenses/LICENSE-2.0
341
- *
342
- * Unless required by applicable law or agreed to in writing, software
343
- * distributed under the License is distributed on an "AS IS" BASIS,
344
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345
- * See the License for the specific language governing permissions and
346
- * limitations under the License.
347
- *
348
- * SPDX-License-Identifier: Apache-2.0
349
- */
331
+ var long = Long;
350
332
 
351
- // WebAssembly optimizations to do native i64 multiplication and divide
333
+ /**
334
+ * wasm optimizations, to do native i64 multiplication and divide
335
+ */
352
336
  var wasm = null;
353
337
  try {
354
338
  wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
@@ -356,32 +340,32 @@ try {
356
340
  // no wasm support :(
357
341
  }
358
342
 
359
- /**
360
- * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
361
- * See the from* functions below for more convenient ways of constructing Longs.
362
- * @exports Long
363
- * @class A Long class for representing a 64 bit two's-complement integer value.
364
- * @param {number} low The low (signed) 32 bits of the long
365
- * @param {number} high The high (signed) 32 bits of the long
366
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
367
- * @constructor
343
+ /**
344
+ * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
345
+ * See the from* functions below for more convenient ways of constructing Longs.
346
+ * @exports Long
347
+ * @class A Long class for representing a 64 bit two's-complement integer value.
348
+ * @param {number} low The low (signed) 32 bits of the long
349
+ * @param {number} high The high (signed) 32 bits of the long
350
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
351
+ * @constructor
368
352
  */
369
353
  function Long(low, high, unsigned) {
370
- /**
371
- * The low 32 bits as a signed value.
372
- * @type {number}
354
+ /**
355
+ * The low 32 bits as a signed value.
356
+ * @type {number}
373
357
  */
374
358
  this.low = low | 0;
375
359
 
376
- /**
377
- * The high 32 bits as a signed value.
378
- * @type {number}
360
+ /**
361
+ * The high 32 bits as a signed value.
362
+ * @type {number}
379
363
  */
380
364
  this.high = high | 0;
381
365
 
382
- /**
383
- * Whether unsigned or not.
384
- * @type {boolean}
366
+ /**
367
+ * Whether unsigned or not.
368
+ * @type {boolean}
385
369
  */
386
370
  this.unsigned = !!unsigned;
387
371
  }
@@ -403,65 +387,54 @@ function Long(low, high, unsigned) {
403
387
  // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
404
388
  // methods on which they depend.
405
389
 
406
- /**
407
- * An indicator used to reliably determine if an object is a Long or not.
408
- * @type {boolean}
409
- * @const
410
- * @private
390
+ /**
391
+ * An indicator used to reliably determine if an object is a Long or not.
392
+ * @type {boolean}
393
+ * @const
394
+ * @private
411
395
  */
412
396
  Long.prototype.__isLong__;
413
397
  Object.defineProperty(Long.prototype, "__isLong__", {
414
398
  value: true
415
399
  });
416
400
 
417
- /**
418
- * @function
419
- * @param {*} obj Object
420
- * @returns {boolean}
421
- * @inner
401
+ /**
402
+ * @function
403
+ * @param {*} obj Object
404
+ * @returns {boolean}
405
+ * @inner
422
406
  */
423
407
  function isLong(obj) {
424
408
  return (obj && obj["__isLong__"]) === true;
425
409
  }
426
410
 
427
- /**
428
- * @function
429
- * @param {*} value number
430
- * @returns {number}
431
- * @inner
432
- */
433
- function ctz32(value) {
434
- var c = Math.clz32(value & -value);
435
- return value ? 31 - c : c;
436
- }
437
-
438
- /**
439
- * Tests if the specified object is a Long.
440
- * @function
441
- * @param {*} obj Object
442
- * @returns {boolean}
411
+ /**
412
+ * Tests if the specified object is a Long.
413
+ * @function
414
+ * @param {*} obj Object
415
+ * @returns {boolean}
443
416
  */
444
417
  Long.isLong = isLong;
445
418
 
446
- /**
447
- * A cache of the Long representations of small integer values.
448
- * @type {!Object}
449
- * @inner
419
+ /**
420
+ * A cache of the Long representations of small integer values.
421
+ * @type {!Object}
422
+ * @inner
450
423
  */
451
424
  var INT_CACHE = {};
452
425
 
453
- /**
454
- * A cache of the Long representations of small unsigned integer values.
455
- * @type {!Object}
456
- * @inner
426
+ /**
427
+ * A cache of the Long representations of small unsigned integer values.
428
+ * @type {!Object}
429
+ * @inner
457
430
  */
458
431
  var UINT_CACHE = {};
459
432
 
460
- /**
461
- * @param {number} value
462
- * @param {boolean=} unsigned
463
- * @returns {!Long}
464
- * @inner
433
+ /**
434
+ * @param {number} value
435
+ * @param {boolean=} unsigned
436
+ * @returns {!Long}
437
+ * @inner
465
438
  */
466
439
  function fromInt(value, unsigned) {
467
440
  var obj, cachedObj, cache;
@@ -471,7 +444,7 @@ function fromInt(value, unsigned) {
471
444
  cachedObj = UINT_CACHE[value];
472
445
  if (cachedObj) return cachedObj;
473
446
  }
474
- obj = fromBits(value, 0, true);
447
+ obj = fromBits(value, (value | 0) < 0 ? -1 : 0, true);
475
448
  if (cache) UINT_CACHE[value] = obj;
476
449
  return obj;
477
450
  } else {
@@ -486,20 +459,20 @@ function fromInt(value, unsigned) {
486
459
  }
487
460
  }
488
461
 
489
- /**
490
- * Returns a Long representing the given 32 bit integer value.
491
- * @function
492
- * @param {number} value The 32 bit integer in question
493
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
494
- * @returns {!Long} The corresponding Long value
462
+ /**
463
+ * Returns a Long representing the given 32 bit integer value.
464
+ * @function
465
+ * @param {number} value The 32 bit integer in question
466
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
467
+ * @returns {!Long} The corresponding Long value
495
468
  */
496
469
  Long.fromInt = fromInt;
497
470
 
498
- /**
499
- * @param {number} value
500
- * @param {boolean=} unsigned
501
- * @returns {!Long}
502
- * @inner
471
+ /**
472
+ * @param {number} value
473
+ * @param {boolean=} unsigned
474
+ * @returns {!Long}
475
+ * @inner
503
476
  */
504
477
  function fromNumber(value, unsigned) {
505
478
  if (isNaN(value)) return unsigned ? UZERO : ZERO;
@@ -514,63 +487,62 @@ function fromNumber(value, unsigned) {
514
487
  return fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
515
488
  }
516
489
 
517
- /**
518
- * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
519
- * @function
520
- * @param {number} value The number in question
521
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
522
- * @returns {!Long} The corresponding Long value
490
+ /**
491
+ * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
492
+ * @function
493
+ * @param {number} value The number in question
494
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
495
+ * @returns {!Long} The corresponding Long value
523
496
  */
524
497
  Long.fromNumber = fromNumber;
525
498
 
526
- /**
527
- * @param {number} lowBits
528
- * @param {number} highBits
529
- * @param {boolean=} unsigned
530
- * @returns {!Long}
531
- * @inner
499
+ /**
500
+ * @param {number} lowBits
501
+ * @param {number} highBits
502
+ * @param {boolean=} unsigned
503
+ * @returns {!Long}
504
+ * @inner
532
505
  */
533
506
  function fromBits(lowBits, highBits, unsigned) {
534
507
  return new Long(lowBits, highBits, unsigned);
535
508
  }
536
509
 
537
- /**
538
- * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
539
- * assumed to use 32 bits.
540
- * @function
541
- * @param {number} lowBits The low 32 bits
542
- * @param {number} highBits The high 32 bits
543
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
544
- * @returns {!Long} The corresponding Long value
510
+ /**
511
+ * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
512
+ * assumed to use 32 bits.
513
+ * @function
514
+ * @param {number} lowBits The low 32 bits
515
+ * @param {number} highBits The high 32 bits
516
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
517
+ * @returns {!Long} The corresponding Long value
545
518
  */
546
519
  Long.fromBits = fromBits;
547
520
 
548
- /**
549
- * @function
550
- * @param {number} base
551
- * @param {number} exponent
552
- * @returns {number}
553
- * @inner
521
+ /**
522
+ * @function
523
+ * @param {number} base
524
+ * @param {number} exponent
525
+ * @returns {number}
526
+ * @inner
554
527
  */
555
528
  var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
556
529
 
557
- /**
558
- * @param {string} str
559
- * @param {(boolean|number)=} unsigned
560
- * @param {number=} radix
561
- * @returns {!Long}
562
- * @inner
530
+ /**
531
+ * @param {string} str
532
+ * @param {(boolean|number)=} unsigned
533
+ * @param {number=} radix
534
+ * @returns {!Long}
535
+ * @inner
563
536
  */
564
537
  function fromString(str, unsigned, radix) {
565
538
  if (str.length === 0) throw Error('empty string');
539
+ if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") return ZERO;
566
540
  if (typeof unsigned === 'number') {
567
541
  // For goog.math.long compatibility
568
- radix = unsigned;
569
- unsigned = false;
542
+ radix = unsigned, unsigned = false;
570
543
  } else {
571
544
  unsigned = !!unsigned;
572
545
  }
573
- if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") return unsigned ? UZERO : ZERO;
574
546
  radix = radix || 10;
575
547
  if (radix < 2 || 36 < radix) throw RangeError('radix');
576
548
  var p;
@@ -597,22 +569,22 @@ function fromString(str, unsigned, radix) {
597
569
  return result;
598
570
  }
599
571
 
600
- /**
601
- * Returns a Long representation of the given string, written using the specified radix.
602
- * @function
603
- * @param {string} str The textual representation of the Long
604
- * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed
605
- * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
606
- * @returns {!Long} The corresponding Long value
572
+ /**
573
+ * Returns a Long representation of the given string, written using the specified radix.
574
+ * @function
575
+ * @param {string} str The textual representation of the Long
576
+ * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed
577
+ * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
578
+ * @returns {!Long} The corresponding Long value
607
579
  */
608
580
  Long.fromString = fromString;
609
581
 
610
- /**
611
- * @function
612
- * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
613
- * @param {boolean=} unsigned
614
- * @returns {!Long}
615
- * @inner
582
+ /**
583
+ * @function
584
+ * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
585
+ * @param {boolean=} unsigned
586
+ * @returns {!Long}
587
+ * @inner
616
588
  */
617
589
  function fromValue(val, unsigned) {
618
590
  if (typeof val === 'number') return fromNumber(val, unsigned);
@@ -621,188 +593,185 @@ function fromValue(val, unsigned) {
621
593
  return fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);
622
594
  }
623
595
 
624
- /**
625
- * Converts the specified value to a Long using the appropriate from* function for its type.
626
- * @function
627
- * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
628
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
629
- * @returns {!Long}
596
+ /**
597
+ * Converts the specified value to a Long using the appropriate from* function for its type.
598
+ * @function
599
+ * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
600
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
601
+ * @returns {!Long}
630
602
  */
631
603
  Long.fromValue = fromValue;
632
604
 
633
605
  // NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
634
606
  // no runtime penalty for these.
635
607
 
636
- /**
637
- * @type {number}
638
- * @const
639
- * @inner
608
+ /**
609
+ * @type {number}
610
+ * @const
611
+ * @inner
640
612
  */
641
613
  var TWO_PWR_16_DBL = 1 << 16;
642
614
 
643
- /**
644
- * @type {number}
645
- * @const
646
- * @inner
615
+ /**
616
+ * @type {number}
617
+ * @const
618
+ * @inner
647
619
  */
648
620
  var TWO_PWR_24_DBL = 1 << 24;
649
621
 
650
- /**
651
- * @type {number}
652
- * @const
653
- * @inner
622
+ /**
623
+ * @type {number}
624
+ * @const
625
+ * @inner
654
626
  */
655
627
  var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
656
628
 
657
- /**
658
- * @type {number}
659
- * @const
660
- * @inner
629
+ /**
630
+ * @type {number}
631
+ * @const
632
+ * @inner
661
633
  */
662
634
  var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
663
635
 
664
- /**
665
- * @type {number}
666
- * @const
667
- * @inner
636
+ /**
637
+ * @type {number}
638
+ * @const
639
+ * @inner
668
640
  */
669
641
  var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
670
642
 
671
- /**
672
- * @type {!Long}
673
- * @const
674
- * @inner
643
+ /**
644
+ * @type {!Long}
645
+ * @const
646
+ * @inner
675
647
  */
676
648
  var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
677
649
 
678
- /**
679
- * @type {!Long}
680
- * @inner
650
+ /**
651
+ * @type {!Long}
652
+ * @inner
681
653
  */
682
654
  var ZERO = fromInt(0);
683
655
 
684
- /**
685
- * Signed zero.
686
- * @type {!Long}
656
+ /**
657
+ * Signed zero.
658
+ * @type {!Long}
687
659
  */
688
660
  Long.ZERO = ZERO;
689
661
 
690
- /**
691
- * @type {!Long}
692
- * @inner
662
+ /**
663
+ * @type {!Long}
664
+ * @inner
693
665
  */
694
666
  var UZERO = fromInt(0, true);
695
667
 
696
- /**
697
- * Unsigned zero.
698
- * @type {!Long}
668
+ /**
669
+ * Unsigned zero.
670
+ * @type {!Long}
699
671
  */
700
672
  Long.UZERO = UZERO;
701
673
 
702
- /**
703
- * @type {!Long}
704
- * @inner
674
+ /**
675
+ * @type {!Long}
676
+ * @inner
705
677
  */
706
678
  var ONE = fromInt(1);
707
679
 
708
- /**
709
- * Signed one.
710
- * @type {!Long}
680
+ /**
681
+ * Signed one.
682
+ * @type {!Long}
711
683
  */
712
684
  Long.ONE = ONE;
713
685
 
714
- /**
715
- * @type {!Long}
716
- * @inner
686
+ /**
687
+ * @type {!Long}
688
+ * @inner
717
689
  */
718
690
  var UONE = fromInt(1, true);
719
691
 
720
- /**
721
- * Unsigned one.
722
- * @type {!Long}
692
+ /**
693
+ * Unsigned one.
694
+ * @type {!Long}
723
695
  */
724
696
  Long.UONE = UONE;
725
697
 
726
- /**
727
- * @type {!Long}
728
- * @inner
698
+ /**
699
+ * @type {!Long}
700
+ * @inner
729
701
  */
730
702
  var NEG_ONE = fromInt(-1);
731
703
 
732
- /**
733
- * Signed negative one.
734
- * @type {!Long}
704
+ /**
705
+ * Signed negative one.
706
+ * @type {!Long}
735
707
  */
736
708
  Long.NEG_ONE = NEG_ONE;
737
709
 
738
- /**
739
- * @type {!Long}
740
- * @inner
710
+ /**
711
+ * @type {!Long}
712
+ * @inner
741
713
  */
742
714
  var MAX_VALUE = fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
743
715
 
744
- /**
745
- * Maximum signed value.
746
- * @type {!Long}
716
+ /**
717
+ * Maximum signed value.
718
+ * @type {!Long}
747
719
  */
748
720
  Long.MAX_VALUE = MAX_VALUE;
749
721
 
750
- /**
751
- * @type {!Long}
752
- * @inner
722
+ /**
723
+ * @type {!Long}
724
+ * @inner
753
725
  */
754
726
  var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
755
727
 
756
- /**
757
- * Maximum unsigned value.
758
- * @type {!Long}
728
+ /**
729
+ * Maximum unsigned value.
730
+ * @type {!Long}
759
731
  */
760
732
  Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
761
733
 
762
- /**
763
- * @type {!Long}
764
- * @inner
734
+ /**
735
+ * @type {!Long}
736
+ * @inner
765
737
  */
766
738
  var MIN_VALUE = fromBits(0, 0x80000000 | 0, false);
767
739
 
768
- /**
769
- * Minimum signed value.
770
- * @type {!Long}
740
+ /**
741
+ * Minimum signed value.
742
+ * @type {!Long}
771
743
  */
772
744
  Long.MIN_VALUE = MIN_VALUE;
773
745
 
774
- /**
775
- * @alias Long.prototype
776
- * @inner
746
+ /**
747
+ * @alias Long.prototype
748
+ * @inner
777
749
  */
778
750
  var LongPrototype = Long.prototype;
779
751
 
780
- /**
781
- * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
782
- * @this {!Long}
783
- * @returns {number}
752
+ /**
753
+ * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
754
+ * @returns {number}
784
755
  */
785
756
  LongPrototype.toInt = function toInt() {
786
757
  return this.unsigned ? this.low >>> 0 : this.low;
787
758
  };
788
759
 
789
- /**
790
- * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
791
- * @this {!Long}
792
- * @returns {number}
760
+ /**
761
+ * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
762
+ * @returns {number}
793
763
  */
794
764
  LongPrototype.toNumber = function toNumber() {
795
765
  if (this.unsigned) return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
796
766
  return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
797
767
  };
798
768
 
799
- /**
800
- * Converts the Long to a string written in the specified radix.
801
- * @this {!Long}
802
- * @param {number=} radix Radix (2-36), defaults to 10
803
- * @returns {string}
804
- * @override
805
- * @throws {RangeError} If `radix` is out of range
769
+ /**
770
+ * Converts the Long to a string written in the specified radix.
771
+ * @param {number=} radix Radix (2-36), defaults to 10
772
+ * @returns {string}
773
+ * @override
774
+ * @throws {RangeError} If `radix` is out of range
806
775
  */
807
776
  LongPrototype.toString = function toString(radix) {
808
777
  radix = radix || 10;
@@ -837,46 +806,41 @@ LongPrototype.toString = function toString(radix) {
837
806
  }
838
807
  };
839
808
 
840
- /**
841
- * Gets the high 32 bits as a signed integer.
842
- * @this {!Long}
843
- * @returns {number} Signed high bits
809
+ /**
810
+ * Gets the high 32 bits as a signed integer.
811
+ * @returns {number} Signed high bits
844
812
  */
845
813
  LongPrototype.getHighBits = function getHighBits() {
846
814
  return this.high;
847
815
  };
848
816
 
849
- /**
850
- * Gets the high 32 bits as an unsigned integer.
851
- * @this {!Long}
852
- * @returns {number} Unsigned high bits
817
+ /**
818
+ * Gets the high 32 bits as an unsigned integer.
819
+ * @returns {number} Unsigned high bits
853
820
  */
854
821
  LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
855
822
  return this.high >>> 0;
856
823
  };
857
824
 
858
- /**
859
- * Gets the low 32 bits as a signed integer.
860
- * @this {!Long}
861
- * @returns {number} Signed low bits
825
+ /**
826
+ * Gets the low 32 bits as a signed integer.
827
+ * @returns {number} Signed low bits
862
828
  */
863
829
  LongPrototype.getLowBits = function getLowBits() {
864
830
  return this.low;
865
831
  };
866
832
 
867
- /**
868
- * Gets the low 32 bits as an unsigned integer.
869
- * @this {!Long}
870
- * @returns {number} Unsigned low bits
833
+ /**
834
+ * Gets the low 32 bits as an unsigned integer.
835
+ * @returns {number} Unsigned low bits
871
836
  */
872
837
  LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
873
838
  return this.low >>> 0;
874
839
  };
875
840
 
876
- /**
877
- * Gets the number of bits needed to represent the absolute value of this Long.
878
- * @this {!Long}
879
- * @returns {number}
841
+ /**
842
+ * Gets the number of bits needed to represent the absolute value of this Long.
843
+ * @returns {number}
880
844
  */
881
845
  LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
882
846
  if (this.isNegative())
@@ -887,62 +851,56 @@ LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
887
851
  return this.high != 0 ? bit + 33 : bit + 1;
888
852
  };
889
853
 
890
- /**
891
- * Tests if this Long's value equals zero.
892
- * @this {!Long}
893
- * @returns {boolean}
854
+ /**
855
+ * Tests if this Long's value equals zero.
856
+ * @returns {boolean}
894
857
  */
895
858
  LongPrototype.isZero = function isZero() {
896
859
  return this.high === 0 && this.low === 0;
897
860
  };
898
861
 
899
- /**
900
- * Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}.
901
- * @returns {boolean}
862
+ /**
863
+ * Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}.
864
+ * @returns {boolean}
902
865
  */
903
866
  LongPrototype.eqz = LongPrototype.isZero;
904
867
 
905
- /**
906
- * Tests if this Long's value is negative.
907
- * @this {!Long}
908
- * @returns {boolean}
868
+ /**
869
+ * Tests if this Long's value is negative.
870
+ * @returns {boolean}
909
871
  */
910
872
  LongPrototype.isNegative = function isNegative() {
911
873
  return !this.unsigned && this.high < 0;
912
874
  };
913
875
 
914
- /**
915
- * Tests if this Long's value is positive or zero.
916
- * @this {!Long}
917
- * @returns {boolean}
876
+ /**
877
+ * Tests if this Long's value is positive.
878
+ * @returns {boolean}
918
879
  */
919
880
  LongPrototype.isPositive = function isPositive() {
920
881
  return this.unsigned || this.high >= 0;
921
882
  };
922
883
 
923
- /**
924
- * Tests if this Long's value is odd.
925
- * @this {!Long}
926
- * @returns {boolean}
884
+ /**
885
+ * Tests if this Long's value is odd.
886
+ * @returns {boolean}
927
887
  */
928
888
  LongPrototype.isOdd = function isOdd() {
929
889
  return (this.low & 1) === 1;
930
890
  };
931
891
 
932
- /**
933
- * Tests if this Long's value is even.
934
- * @this {!Long}
935
- * @returns {boolean}
892
+ /**
893
+ * Tests if this Long's value is even.
894
+ * @returns {boolean}
936
895
  */
937
896
  LongPrototype.isEven = function isEven() {
938
897
  return (this.low & 1) === 0;
939
898
  };
940
899
 
941
- /**
942
- * Tests if this Long's value equals the specified's.
943
- * @this {!Long}
944
- * @param {!Long|number|string} other Other value
945
- * @returns {boolean}
900
+ /**
901
+ * Tests if this Long's value equals the specified's.
902
+ * @param {!Long|number|string} other Other value
903
+ * @returns {boolean}
946
904
  */
947
905
  LongPrototype.equals = function equals(other) {
948
906
  if (!isLong(other)) other = fromValue(other);
@@ -950,134 +908,128 @@ LongPrototype.equals = function equals(other) {
950
908
  return this.high === other.high && this.low === other.low;
951
909
  };
952
910
 
953
- /**
954
- * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
955
- * @function
956
- * @param {!Long|number|string} other Other value
957
- * @returns {boolean}
911
+ /**
912
+ * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
913
+ * @function
914
+ * @param {!Long|number|string} other Other value
915
+ * @returns {boolean}
958
916
  */
959
917
  LongPrototype.eq = LongPrototype.equals;
960
918
 
961
- /**
962
- * Tests if this Long's value differs from the specified's.
963
- * @this {!Long}
964
- * @param {!Long|number|string} other Other value
965
- * @returns {boolean}
919
+ /**
920
+ * Tests if this Long's value differs from the specified's.
921
+ * @param {!Long|number|string} other Other value
922
+ * @returns {boolean}
966
923
  */
967
924
  LongPrototype.notEquals = function notEquals(other) {
968
925
  return !this.eq( /* validates */other);
969
926
  };
970
927
 
971
- /**
972
- * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
973
- * @function
974
- * @param {!Long|number|string} other Other value
975
- * @returns {boolean}
928
+ /**
929
+ * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
930
+ * @function
931
+ * @param {!Long|number|string} other Other value
932
+ * @returns {boolean}
976
933
  */
977
934
  LongPrototype.neq = LongPrototype.notEquals;
978
935
 
979
- /**
980
- * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
981
- * @function
982
- * @param {!Long|number|string} other Other value
983
- * @returns {boolean}
936
+ /**
937
+ * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
938
+ * @function
939
+ * @param {!Long|number|string} other Other value
940
+ * @returns {boolean}
984
941
  */
985
942
  LongPrototype.ne = LongPrototype.notEquals;
986
943
 
987
- /**
988
- * Tests if this Long's value is less than the specified's.
989
- * @this {!Long}
990
- * @param {!Long|number|string} other Other value
991
- * @returns {boolean}
944
+ /**
945
+ * Tests if this Long's value is less than the specified's.
946
+ * @param {!Long|number|string} other Other value
947
+ * @returns {boolean}
992
948
  */
993
949
  LongPrototype.lessThan = function lessThan(other) {
994
950
  return this.comp( /* validates */other) < 0;
995
951
  };
996
952
 
997
- /**
998
- * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
999
- * @function
1000
- * @param {!Long|number|string} other Other value
1001
- * @returns {boolean}
953
+ /**
954
+ * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
955
+ * @function
956
+ * @param {!Long|number|string} other Other value
957
+ * @returns {boolean}
1002
958
  */
1003
959
  LongPrototype.lt = LongPrototype.lessThan;
1004
960
 
1005
- /**
1006
- * Tests if this Long's value is less than or equal the specified's.
1007
- * @this {!Long}
1008
- * @param {!Long|number|string} other Other value
1009
- * @returns {boolean}
961
+ /**
962
+ * Tests if this Long's value is less than or equal the specified's.
963
+ * @param {!Long|number|string} other Other value
964
+ * @returns {boolean}
1010
965
  */
1011
966
  LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
1012
967
  return this.comp( /* validates */other) <= 0;
1013
968
  };
1014
969
 
1015
- /**
1016
- * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
1017
- * @function
1018
- * @param {!Long|number|string} other Other value
1019
- * @returns {boolean}
970
+ /**
971
+ * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
972
+ * @function
973
+ * @param {!Long|number|string} other Other value
974
+ * @returns {boolean}
1020
975
  */
1021
976
  LongPrototype.lte = LongPrototype.lessThanOrEqual;
1022
977
 
1023
- /**
1024
- * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
1025
- * @function
1026
- * @param {!Long|number|string} other Other value
1027
- * @returns {boolean}
978
+ /**
979
+ * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
980
+ * @function
981
+ * @param {!Long|number|string} other Other value
982
+ * @returns {boolean}
1028
983
  */
1029
984
  LongPrototype.le = LongPrototype.lessThanOrEqual;
1030
985
 
1031
- /**
1032
- * Tests if this Long's value is greater than the specified's.
1033
- * @this {!Long}
1034
- * @param {!Long|number|string} other Other value
1035
- * @returns {boolean}
986
+ /**
987
+ * Tests if this Long's value is greater than the specified's.
988
+ * @param {!Long|number|string} other Other value
989
+ * @returns {boolean}
1036
990
  */
1037
991
  LongPrototype.greaterThan = function greaterThan(other) {
1038
992
  return this.comp( /* validates */other) > 0;
1039
993
  };
1040
994
 
1041
- /**
1042
- * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
1043
- * @function
1044
- * @param {!Long|number|string} other Other value
1045
- * @returns {boolean}
995
+ /**
996
+ * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
997
+ * @function
998
+ * @param {!Long|number|string} other Other value
999
+ * @returns {boolean}
1046
1000
  */
1047
1001
  LongPrototype.gt = LongPrototype.greaterThan;
1048
1002
 
1049
- /**
1050
- * Tests if this Long's value is greater than or equal the specified's.
1051
- * @this {!Long}
1052
- * @param {!Long|number|string} other Other value
1053
- * @returns {boolean}
1003
+ /**
1004
+ * Tests if this Long's value is greater than or equal the specified's.
1005
+ * @param {!Long|number|string} other Other value
1006
+ * @returns {boolean}
1054
1007
  */
1055
1008
  LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
1056
1009
  return this.comp( /* validates */other) >= 0;
1057
1010
  };
1058
1011
 
1059
- /**
1060
- * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
1061
- * @function
1062
- * @param {!Long|number|string} other Other value
1063
- * @returns {boolean}
1012
+ /**
1013
+ * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
1014
+ * @function
1015
+ * @param {!Long|number|string} other Other value
1016
+ * @returns {boolean}
1064
1017
  */
1065
1018
  LongPrototype.gte = LongPrototype.greaterThanOrEqual;
1066
1019
 
1067
- /**
1068
- * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
1069
- * @function
1070
- * @param {!Long|number|string} other Other value
1071
- * @returns {boolean}
1020
+ /**
1021
+ * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
1022
+ * @function
1023
+ * @param {!Long|number|string} other Other value
1024
+ * @returns {boolean}
1072
1025
  */
1073
1026
  LongPrototype.ge = LongPrototype.greaterThanOrEqual;
1074
1027
 
1075
- /**
1076
- * Compares this Long's value with the specified's.
1077
- * @this {!Long}
1078
- * @param {!Long|number|string} other Other value
1079
- * @returns {number} 0 if they are the same, 1 if the this is greater and -1
1080
- * if the given one is greater
1028
+ /**
1029
+ * Compares this Long's value with the specified's.
1030
+ * @param {!Long|number|string} other Other value
1031
+ * @returns {number} 0 if they are the same, 1 if the this is greater and -1
1032
+ * if the given one is greater
1081
1033
  */
1082
1034
  LongPrototype.compare = function compare(other) {
1083
1035
  if (!isLong(other)) other = fromValue(other);
@@ -1092,37 +1044,35 @@ LongPrototype.compare = function compare(other) {
1092
1044
  return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1;
1093
1045
  };
1094
1046
 
1095
- /**
1096
- * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
1097
- * @function
1098
- * @param {!Long|number|string} other Other value
1099
- * @returns {number} 0 if they are the same, 1 if the this is greater and -1
1100
- * if the given one is greater
1047
+ /**
1048
+ * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
1049
+ * @function
1050
+ * @param {!Long|number|string} other Other value
1051
+ * @returns {number} 0 if they are the same, 1 if the this is greater and -1
1052
+ * if the given one is greater
1101
1053
  */
1102
1054
  LongPrototype.comp = LongPrototype.compare;
1103
1055
 
1104
- /**
1105
- * Negates this Long's value.
1106
- * @this {!Long}
1107
- * @returns {!Long} Negated Long
1056
+ /**
1057
+ * Negates this Long's value.
1058
+ * @returns {!Long} Negated Long
1108
1059
  */
1109
1060
  LongPrototype.negate = function negate() {
1110
1061
  if (!this.unsigned && this.eq(MIN_VALUE)) return MIN_VALUE;
1111
1062
  return this.not().add(ONE);
1112
1063
  };
1113
1064
 
1114
- /**
1115
- * Negates this Long's value. This is an alias of {@link Long#negate}.
1116
- * @function
1117
- * @returns {!Long} Negated Long
1065
+ /**
1066
+ * Negates this Long's value. This is an alias of {@link Long#negate}.
1067
+ * @function
1068
+ * @returns {!Long} Negated Long
1118
1069
  */
1119
1070
  LongPrototype.neg = LongPrototype.negate;
1120
1071
 
1121
- /**
1122
- * Returns the sum of this and the specified Long.
1123
- * @this {!Long}
1124
- * @param {!Long|number|string} addend Addend
1125
- * @returns {!Long} Sum
1072
+ /**
1073
+ * Returns the sum of this and the specified Long.
1074
+ * @param {!Long|number|string} addend Addend
1075
+ * @returns {!Long} Sum
1126
1076
  */
1127
1077
  LongPrototype.add = function add(addend) {
1128
1078
  if (!isLong(addend)) addend = fromValue(addend);
@@ -1155,41 +1105,39 @@ LongPrototype.add = function add(addend) {
1155
1105
  return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
1156
1106
  };
1157
1107
 
1158
- /**
1159
- * Returns the difference of this and the specified Long.
1160
- * @this {!Long}
1161
- * @param {!Long|number|string} subtrahend Subtrahend
1162
- * @returns {!Long} Difference
1108
+ /**
1109
+ * Returns the difference of this and the specified Long.
1110
+ * @param {!Long|number|string} subtrahend Subtrahend
1111
+ * @returns {!Long} Difference
1163
1112
  */
1164
1113
  LongPrototype.subtract = function subtract(subtrahend) {
1165
1114
  if (!isLong(subtrahend)) subtrahend = fromValue(subtrahend);
1166
1115
  return this.add(subtrahend.neg());
1167
1116
  };
1168
1117
 
1169
- /**
1170
- * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
1171
- * @function
1172
- * @param {!Long|number|string} subtrahend Subtrahend
1173
- * @returns {!Long} Difference
1118
+ /**
1119
+ * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
1120
+ * @function
1121
+ * @param {!Long|number|string} subtrahend Subtrahend
1122
+ * @returns {!Long} Difference
1174
1123
  */
1175
1124
  LongPrototype.sub = LongPrototype.subtract;
1176
1125
 
1177
- /**
1178
- * Returns the product of this and the specified Long.
1179
- * @this {!Long}
1180
- * @param {!Long|number|string} multiplier Multiplier
1181
- * @returns {!Long} Product
1126
+ /**
1127
+ * Returns the product of this and the specified Long.
1128
+ * @param {!Long|number|string} multiplier Multiplier
1129
+ * @returns {!Long} Product
1182
1130
  */
1183
1131
  LongPrototype.multiply = function multiply(multiplier) {
1184
- if (this.isZero()) return this;
1132
+ if (this.isZero()) return ZERO;
1185
1133
  if (!isLong(multiplier)) multiplier = fromValue(multiplier);
1186
1134
 
1187
1135
  // use wasm support if present
1188
1136
  if (wasm) {
1189
- var low = wasm["mul"](this.low, this.high, multiplier.low, multiplier.high);
1190
- return fromBits(low, wasm["get_high"](), this.unsigned);
1137
+ var low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high);
1138
+ return fromBits(low, wasm.get_high(), this.unsigned);
1191
1139
  }
1192
- if (multiplier.isZero()) return this.unsigned ? UZERO : ZERO;
1140
+ if (multiplier.isZero()) return ZERO;
1193
1141
  if (this.eq(MIN_VALUE)) return multiplier.isOdd() ? MIN_VALUE : ZERO;
1194
1142
  if (multiplier.eq(MIN_VALUE)) return this.isOdd() ? MIN_VALUE : ZERO;
1195
1143
  if (this.isNegative()) {
@@ -1237,20 +1185,19 @@ LongPrototype.multiply = function multiply(multiplier) {
1237
1185
  return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
1238
1186
  };
1239
1187
 
1240
- /**
1241
- * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
1242
- * @function
1243
- * @param {!Long|number|string} multiplier Multiplier
1244
- * @returns {!Long} Product
1188
+ /**
1189
+ * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
1190
+ * @function
1191
+ * @param {!Long|number|string} multiplier Multiplier
1192
+ * @returns {!Long} Product
1245
1193
  */
1246
1194
  LongPrototype.mul = LongPrototype.multiply;
1247
1195
 
1248
- /**
1249
- * Returns this Long divided by the specified. The result is signed if this Long is signed or
1250
- * unsigned if this Long is unsigned.
1251
- * @this {!Long}
1252
- * @param {!Long|number|string} divisor Divisor
1253
- * @returns {!Long} Quotient
1196
+ /**
1197
+ * Returns this Long divided by the specified. The result is signed if this Long is signed or
1198
+ * unsigned if this Long is unsigned.
1199
+ * @param {!Long|number|string} divisor Divisor
1200
+ * @returns {!Long} Quotient
1254
1201
  */
1255
1202
  LongPrototype.divide = function divide(divisor) {
1256
1203
  if (!isLong(divisor)) divisor = fromValue(divisor);
@@ -1265,8 +1212,8 @@ LongPrototype.divide = function divide(divisor) {
1265
1212
  // be consistent with non-wasm code path
1266
1213
  return this;
1267
1214
  }
1268
- var low = (this.unsigned ? wasm["div_u"] : wasm["div_s"])(this.low, this.high, divisor.low, divisor.high);
1269
- return fromBits(low, wasm["get_high"](), this.unsigned);
1215
+ var low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high);
1216
+ return fromBits(low, wasm.get_high(), this.unsigned);
1270
1217
  }
1271
1218
  if (this.isZero()) return this.unsigned ? UZERO : ZERO;
1272
1219
  var approx, rem, res;
@@ -1338,279 +1285,183 @@ LongPrototype.divide = function divide(divisor) {
1338
1285
  return res;
1339
1286
  };
1340
1287
 
1341
- /**
1342
- * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
1343
- * @function
1344
- * @param {!Long|number|string} divisor Divisor
1345
- * @returns {!Long} Quotient
1288
+ /**
1289
+ * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
1290
+ * @function
1291
+ * @param {!Long|number|string} divisor Divisor
1292
+ * @returns {!Long} Quotient
1346
1293
  */
1347
1294
  LongPrototype.div = LongPrototype.divide;
1348
1295
 
1349
- /**
1350
- * Returns this Long modulo the specified.
1351
- * @this {!Long}
1352
- * @param {!Long|number|string} divisor Divisor
1353
- * @returns {!Long} Remainder
1296
+ /**
1297
+ * Returns this Long modulo the specified.
1298
+ * @param {!Long|number|string} divisor Divisor
1299
+ * @returns {!Long} Remainder
1354
1300
  */
1355
1301
  LongPrototype.modulo = function modulo(divisor) {
1356
1302
  if (!isLong(divisor)) divisor = fromValue(divisor);
1357
1303
 
1358
1304
  // use wasm support if present
1359
1305
  if (wasm) {
1360
- var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])(this.low, this.high, divisor.low, divisor.high);
1361
- return fromBits(low, wasm["get_high"](), this.unsigned);
1306
+ var low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high);
1307
+ return fromBits(low, wasm.get_high(), this.unsigned);
1362
1308
  }
1363
1309
  return this.sub(this.div(divisor).mul(divisor));
1364
1310
  };
1365
1311
 
1366
- /**
1367
- * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
1368
- * @function
1369
- * @param {!Long|number|string} divisor Divisor
1370
- * @returns {!Long} Remainder
1312
+ /**
1313
+ * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
1314
+ * @function
1315
+ * @param {!Long|number|string} divisor Divisor
1316
+ * @returns {!Long} Remainder
1371
1317
  */
1372
1318
  LongPrototype.mod = LongPrototype.modulo;
1373
1319
 
1374
- /**
1375
- * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
1376
- * @function
1377
- * @param {!Long|number|string} divisor Divisor
1378
- * @returns {!Long} Remainder
1320
+ /**
1321
+ * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
1322
+ * @function
1323
+ * @param {!Long|number|string} divisor Divisor
1324
+ * @returns {!Long} Remainder
1379
1325
  */
1380
1326
  LongPrototype.rem = LongPrototype.modulo;
1381
1327
 
1382
- /**
1383
- * Returns the bitwise NOT of this Long.
1384
- * @this {!Long}
1385
- * @returns {!Long}
1328
+ /**
1329
+ * Returns the bitwise NOT of this Long.
1330
+ * @returns {!Long}
1386
1331
  */
1387
1332
  LongPrototype.not = function not() {
1388
1333
  return fromBits(~this.low, ~this.high, this.unsigned);
1389
1334
  };
1390
1335
 
1391
- /**
1392
- * Returns count leading zeros of this Long.
1393
- * @this {!Long}
1394
- * @returns {!number}
1395
- */
1396
- LongPrototype.countLeadingZeros = function countLeadingZeros() {
1397
- return this.high ? Math.clz32(this.high) : Math.clz32(this.low) + 32;
1398
- };
1399
-
1400
- /**
1401
- * Returns count leading zeros. This is an alias of {@link Long#countLeadingZeros}.
1402
- * @function
1403
- * @param {!Long}
1404
- * @returns {!number}
1405
- */
1406
- LongPrototype.clz = LongPrototype.countLeadingZeros;
1407
-
1408
- /**
1409
- * Returns count trailing zeros of this Long.
1410
- * @this {!Long}
1411
- * @returns {!number}
1412
- */
1413
- LongPrototype.countTrailingZeros = function countTrailingZeros() {
1414
- return this.low ? ctz32(this.low) : ctz32(this.high) + 32;
1415
- };
1416
-
1417
- /**
1418
- * Returns count trailing zeros. This is an alias of {@link Long#countTrailingZeros}.
1419
- * @function
1420
- * @param {!Long}
1421
- * @returns {!number}
1422
- */
1423
- LongPrototype.ctz = LongPrototype.countTrailingZeros;
1424
-
1425
- /**
1426
- * Returns the bitwise AND of this Long and the specified.
1427
- * @this {!Long}
1428
- * @param {!Long|number|string} other Other Long
1429
- * @returns {!Long}
1336
+ /**
1337
+ * Returns the bitwise AND of this Long and the specified.
1338
+ * @param {!Long|number|string} other Other Long
1339
+ * @returns {!Long}
1430
1340
  */
1431
1341
  LongPrototype.and = function and(other) {
1432
1342
  if (!isLong(other)) other = fromValue(other);
1433
1343
  return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
1434
1344
  };
1435
1345
 
1436
- /**
1437
- * Returns the bitwise OR of this Long and the specified.
1438
- * @this {!Long}
1439
- * @param {!Long|number|string} other Other Long
1440
- * @returns {!Long}
1346
+ /**
1347
+ * Returns the bitwise OR of this Long and the specified.
1348
+ * @param {!Long|number|string} other Other Long
1349
+ * @returns {!Long}
1441
1350
  */
1442
1351
  LongPrototype.or = function or(other) {
1443
1352
  if (!isLong(other)) other = fromValue(other);
1444
1353
  return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
1445
1354
  };
1446
1355
 
1447
- /**
1448
- * Returns the bitwise XOR of this Long and the given one.
1449
- * @this {!Long}
1450
- * @param {!Long|number|string} other Other Long
1451
- * @returns {!Long}
1356
+ /**
1357
+ * Returns the bitwise XOR of this Long and the given one.
1358
+ * @param {!Long|number|string} other Other Long
1359
+ * @returns {!Long}
1452
1360
  */
1453
1361
  LongPrototype.xor = function xor(other) {
1454
1362
  if (!isLong(other)) other = fromValue(other);
1455
1363
  return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
1456
1364
  };
1457
1365
 
1458
- /**
1459
- * Returns this Long with bits shifted to the left by the given amount.
1460
- * @this {!Long}
1461
- * @param {number|!Long} numBits Number of bits
1462
- * @returns {!Long} Shifted Long
1366
+ /**
1367
+ * Returns this Long with bits shifted to the left by the given amount.
1368
+ * @param {number|!Long} numBits Number of bits
1369
+ * @returns {!Long} Shifted Long
1463
1370
  */
1464
1371
  LongPrototype.shiftLeft = function shiftLeft(numBits) {
1465
1372
  if (isLong(numBits)) numBits = numBits.toInt();
1466
1373
  if ((numBits &= 63) === 0) return this;else if (numBits < 32) return fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned);else return fromBits(0, this.low << numBits - 32, this.unsigned);
1467
1374
  };
1468
1375
 
1469
- /**
1470
- * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
1471
- * @function
1472
- * @param {number|!Long} numBits Number of bits
1473
- * @returns {!Long} Shifted Long
1376
+ /**
1377
+ * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
1378
+ * @function
1379
+ * @param {number|!Long} numBits Number of bits
1380
+ * @returns {!Long} Shifted Long
1474
1381
  */
1475
1382
  LongPrototype.shl = LongPrototype.shiftLeft;
1476
1383
 
1477
- /**
1478
- * Returns this Long with bits arithmetically shifted to the right by the given amount.
1479
- * @this {!Long}
1480
- * @param {number|!Long} numBits Number of bits
1481
- * @returns {!Long} Shifted Long
1384
+ /**
1385
+ * Returns this Long with bits arithmetically shifted to the right by the given amount.
1386
+ * @param {number|!Long} numBits Number of bits
1387
+ * @returns {!Long} Shifted Long
1482
1388
  */
1483
1389
  LongPrototype.shiftRight = function shiftRight(numBits) {
1484
1390
  if (isLong(numBits)) numBits = numBits.toInt();
1485
1391
  if ((numBits &= 63) === 0) return this;else if (numBits < 32) return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned);else return fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned);
1486
1392
  };
1487
1393
 
1488
- /**
1489
- * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
1490
- * @function
1491
- * @param {number|!Long} numBits Number of bits
1492
- * @returns {!Long} Shifted Long
1394
+ /**
1395
+ * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
1396
+ * @function
1397
+ * @param {number|!Long} numBits Number of bits
1398
+ * @returns {!Long} Shifted Long
1493
1399
  */
1494
1400
  LongPrototype.shr = LongPrototype.shiftRight;
1495
1401
 
1496
- /**
1497
- * Returns this Long with bits logically shifted to the right by the given amount.
1498
- * @this {!Long}
1499
- * @param {number|!Long} numBits Number of bits
1500
- * @returns {!Long} Shifted Long
1402
+ /**
1403
+ * Returns this Long with bits logically shifted to the right by the given amount.
1404
+ * @param {number|!Long} numBits Number of bits
1405
+ * @returns {!Long} Shifted Long
1501
1406
  */
1502
1407
  LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
1503
1408
  if (isLong(numBits)) numBits = numBits.toInt();
1504
- if ((numBits &= 63) === 0) return this;
1505
- if (numBits < 32) return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >>> numBits, this.unsigned);
1506
- if (numBits === 32) return fromBits(this.high, 0, this.unsigned);
1507
- return fromBits(this.high >>> numBits - 32, 0, this.unsigned);
1409
+ numBits &= 63;
1410
+ if (numBits === 0) return this;else {
1411
+ var high = this.high;
1412
+ if (numBits < 32) {
1413
+ var low = this.low;
1414
+ return fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits, this.unsigned);
1415
+ } else if (numBits === 32) return fromBits(high, 0, this.unsigned);else return fromBits(high >>> numBits - 32, 0, this.unsigned);
1416
+ }
1508
1417
  };
1509
1418
 
1510
- /**
1511
- * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
1512
- * @function
1513
- * @param {number|!Long} numBits Number of bits
1514
- * @returns {!Long} Shifted Long
1419
+ /**
1420
+ * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
1421
+ * @function
1422
+ * @param {number|!Long} numBits Number of bits
1423
+ * @returns {!Long} Shifted Long
1515
1424
  */
1516
1425
  LongPrototype.shru = LongPrototype.shiftRightUnsigned;
1517
1426
 
1518
- /**
1519
- * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
1520
- * @function
1521
- * @param {number|!Long} numBits Number of bits
1522
- * @returns {!Long} Shifted Long
1427
+ /**
1428
+ * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
1429
+ * @function
1430
+ * @param {number|!Long} numBits Number of bits
1431
+ * @returns {!Long} Shifted Long
1523
1432
  */
1524
1433
  LongPrototype.shr_u = LongPrototype.shiftRightUnsigned;
1525
1434
 
1526
- /**
1527
- * Returns this Long with bits rotated to the left by the given amount.
1528
- * @this {!Long}
1529
- * @param {number|!Long} numBits Number of bits
1530
- * @returns {!Long} Rotated Long
1531
- */
1532
- LongPrototype.rotateLeft = function rotateLeft(numBits) {
1533
- var b;
1534
- if (isLong(numBits)) numBits = numBits.toInt();
1535
- if ((numBits &= 63) === 0) return this;
1536
- if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
1537
- if (numBits < 32) {
1538
- b = 32 - numBits;
1539
- return fromBits(this.low << numBits | this.high >>> b, this.high << numBits | this.low >>> b, this.unsigned);
1540
- }
1541
- numBits -= 32;
1542
- b = 32 - numBits;
1543
- return fromBits(this.high << numBits | this.low >>> b, this.low << numBits | this.high >>> b, this.unsigned);
1544
- };
1545
- /**
1546
- * Returns this Long with bits rotated to the left by the given amount. This is an alias of {@link Long#rotateLeft}.
1547
- * @function
1548
- * @param {number|!Long} numBits Number of bits
1549
- * @returns {!Long} Rotated Long
1550
- */
1551
- LongPrototype.rotl = LongPrototype.rotateLeft;
1552
-
1553
- /**
1554
- * Returns this Long with bits rotated to the right by the given amount.
1555
- * @this {!Long}
1556
- * @param {number|!Long} numBits Number of bits
1557
- * @returns {!Long} Rotated Long
1558
- */
1559
- LongPrototype.rotateRight = function rotateRight(numBits) {
1560
- var b;
1561
- if (isLong(numBits)) numBits = numBits.toInt();
1562
- if ((numBits &= 63) === 0) return this;
1563
- if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
1564
- if (numBits < 32) {
1565
- b = 32 - numBits;
1566
- return fromBits(this.high << b | this.low >>> numBits, this.low << b | this.high >>> numBits, this.unsigned);
1567
- }
1568
- numBits -= 32;
1569
- b = 32 - numBits;
1570
- return fromBits(this.low << b | this.high >>> numBits, this.high << b | this.low >>> numBits, this.unsigned);
1571
- };
1572
- /**
1573
- * Returns this Long with bits rotated to the right by the given amount. This is an alias of {@link Long#rotateRight}.
1574
- * @function
1575
- * @param {number|!Long} numBits Number of bits
1576
- * @returns {!Long} Rotated Long
1577
- */
1578
- LongPrototype.rotr = LongPrototype.rotateRight;
1579
-
1580
- /**
1581
- * Converts this Long to signed.
1582
- * @this {!Long}
1583
- * @returns {!Long} Signed long
1435
+ /**
1436
+ * Converts this Long to signed.
1437
+ * @returns {!Long} Signed long
1584
1438
  */
1585
1439
  LongPrototype.toSigned = function toSigned() {
1586
1440
  if (!this.unsigned) return this;
1587
1441
  return fromBits(this.low, this.high, false);
1588
1442
  };
1589
1443
 
1590
- /**
1591
- * Converts this Long to unsigned.
1592
- * @this {!Long}
1593
- * @returns {!Long} Unsigned long
1444
+ /**
1445
+ * Converts this Long to unsigned.
1446
+ * @returns {!Long} Unsigned long
1594
1447
  */
1595
1448
  LongPrototype.toUnsigned = function toUnsigned() {
1596
1449
  if (this.unsigned) return this;
1597
1450
  return fromBits(this.low, this.high, true);
1598
1451
  };
1599
1452
 
1600
- /**
1601
- * Converts this Long to its byte representation.
1602
- * @param {boolean=} le Whether little or big endian, defaults to big endian
1603
- * @this {!Long}
1604
- * @returns {!Array.<number>} Byte representation
1453
+ /**
1454
+ * Converts this Long to its byte representation.
1455
+ * @param {boolean=} le Whether little or big endian, defaults to big endian
1456
+ * @returns {!Array.<number>} Byte representation
1605
1457
  */
1606
1458
  LongPrototype.toBytes = function toBytes(le) {
1607
1459
  return le ? this.toBytesLE() : this.toBytesBE();
1608
1460
  };
1609
1461
 
1610
- /**
1611
- * Converts this Long to its little endian byte representation.
1612
- * @this {!Long}
1613
- * @returns {!Array.<number>} Little endian byte representation
1462
+ /**
1463
+ * Converts this Long to its little endian byte representation.
1464
+ * @returns {!Array.<number>} Little endian byte representation
1614
1465
  */
1615
1466
  LongPrototype.toBytesLE = function toBytesLE() {
1616
1467
  var hi = this.high,
@@ -1618,10 +1469,9 @@ LongPrototype.toBytesLE = function toBytesLE() {
1618
1469
  return [lo & 0xff, lo >>> 8 & 0xff, lo >>> 16 & 0xff, lo >>> 24, hi & 0xff, hi >>> 8 & 0xff, hi >>> 16 & 0xff, hi >>> 24];
1619
1470
  };
1620
1471
 
1621
- /**
1622
- * Converts this Long to its big endian byte representation.
1623
- * @this {!Long}
1624
- * @returns {!Array.<number>} Big endian byte representation
1472
+ /**
1473
+ * Converts this Long to its big endian byte representation.
1474
+ * @returns {!Array.<number>} Big endian byte representation
1625
1475
  */
1626
1476
  LongPrototype.toBytesBE = function toBytesBE() {
1627
1477
  var hi = this.high,
@@ -1629,36 +1479,37 @@ LongPrototype.toBytesBE = function toBytesBE() {
1629
1479
  return [hi >>> 24, hi >>> 16 & 0xff, hi >>> 8 & 0xff, hi & 0xff, lo >>> 24, lo >>> 16 & 0xff, lo >>> 8 & 0xff, lo & 0xff];
1630
1480
  };
1631
1481
 
1632
- /**
1633
- * Creates a Long from its byte representation.
1634
- * @param {!Array.<number>} bytes Byte representation
1635
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1636
- * @param {boolean=} le Whether little or big endian, defaults to big endian
1637
- * @returns {Long} The corresponding Long value
1482
+ /**
1483
+ * Creates a Long from its byte representation.
1484
+ * @param {!Array.<number>} bytes Byte representation
1485
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1486
+ * @param {boolean=} le Whether little or big endian, defaults to big endian
1487
+ * @returns {Long} The corresponding Long value
1638
1488
  */
1639
1489
  Long.fromBytes = function fromBytes(bytes, unsigned, le) {
1640
1490
  return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
1641
1491
  };
1642
1492
 
1643
- /**
1644
- * Creates a Long from its little endian byte representation.
1645
- * @param {!Array.<number>} bytes Little endian byte representation
1646
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1647
- * @returns {Long} The corresponding Long value
1493
+ /**
1494
+ * Creates a Long from its little endian byte representation.
1495
+ * @param {!Array.<number>} bytes Little endian byte representation
1496
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1497
+ * @returns {Long} The corresponding Long value
1648
1498
  */
1649
1499
  Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
1650
1500
  return new Long(bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24, bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24, unsigned);
1651
1501
  };
1652
1502
 
1653
- /**
1654
- * Creates a Long from its big endian byte representation.
1655
- * @param {!Array.<number>} bytes Big endian byte representation
1656
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1657
- * @returns {Long} The corresponding Long value
1503
+ /**
1504
+ * Creates a Long from its big endian byte representation.
1505
+ * @param {!Array.<number>} bytes Big endian byte representation
1506
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1507
+ * @returns {Long} The corresponding Long value
1658
1508
  */
1659
1509
  Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
1660
1510
  return new Long(bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7], bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], unsigned);
1661
1511
  };
1512
+ var Long$1 = /*@__PURE__*/getDefaultExportFromCjs(long);
1662
1513
 
1663
1514
  var indexMinimal = {};
1664
1515
 
@@ -4158,8 +4009,8 @@ var _m0 = /*@__PURE__*/getDefaultExportFromCjs(minimal);
4158
4009
  }
4159
4010
  throw "Unable to locate global object";
4160
4011
  })();
4161
- if (_m0.util.Long !== Long) {
4162
- _m0.util.Long = Long;
4012
+ if (_m0.util.Long !== Long$1) {
4013
+ _m0.util.Long = Long$1;
4163
4014
  _m0.configure();
4164
4015
  }
4165
4016
 
@@ -6742,8 +6593,8 @@ function longToNumber$1(long) {
6742
6593
  }
6743
6594
  return long.toNumber();
6744
6595
  }
6745
- if (_m0.util.Long !== Long) {
6746
- _m0.util.Long = Long;
6596
+ if (_m0.util.Long !== Long$1) {
6597
+ _m0.util.Long = Long$1;
6747
6598
  _m0.configure();
6748
6599
  }
6749
6600
  function isSet$1(value) {
@@ -14185,8 +14036,8 @@ function longToNumber(long) {
14185
14036
  }
14186
14037
  return long.toNumber();
14187
14038
  }
14188
- if (_m0.util.Long !== Long) {
14189
- _m0.util.Long = Long;
14039
+ if (_m0.util.Long !== Long$1) {
14040
+ _m0.util.Long = Long$1;
14190
14041
  _m0.configure();
14191
14042
  }
14192
14043
  function isSet(value) {
@@ -14347,7 +14198,7 @@ function getMatch(exp, ua) {
14347
14198
  return match && match.length >= id && match[id] || '';
14348
14199
  }
14349
14200
 
14350
- var version$1 = "1.12.13";
14201
+ var version$1 = "1.12.14";
14351
14202
 
14352
14203
  const version = version$1;
14353
14204
  const protocolVersion = 9;
@@ -15344,6 +15195,18 @@ function getNewAudioContext() {
15344
15195
  });
15345
15196
  }
15346
15197
  }
15198
+ /**
15199
+ * @internal
15200
+ */
15201
+ function kindToSource(kind) {
15202
+ if (kind === 'audioinput') {
15203
+ return Track.Source.Microphone;
15204
+ } else if (kind === 'videoinput') {
15205
+ return Track.Source.Camera;
15206
+ } else {
15207
+ return Track.Source.Unknown;
15208
+ }
15209
+ }
15347
15210
  /**
15348
15211
  * @internal
15349
15212
  */
@@ -16513,12 +16376,18 @@ const CryptorEvent = {
16513
16376
 
16514
16377
  const defaultId = 'default';
16515
16378
  class DeviceManager {
16379
+ constructor() {
16380
+ this._previousDevices = [];
16381
+ }
16516
16382
  static getInstance() {
16517
16383
  if (this.instance === undefined) {
16518
16384
  this.instance = new DeviceManager();
16519
16385
  }
16520
16386
  return this.instance;
16521
16387
  }
16388
+ get previousDevices() {
16389
+ return this._previousDevices;
16390
+ }
16522
16391
  getDevices(kind) {
16523
16392
  let requestPermissions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
16524
16393
  var _a;
@@ -16536,10 +16405,10 @@ class DeviceManager {
16536
16405
  }
16537
16406
  }
16538
16407
  let devices = yield navigator.mediaDevices.enumerateDevices();
16539
- if (requestPermissions && kind && (
16408
+ if (requestPermissions &&
16540
16409
  // for safari we need to skip this check, as otherwise it will re-acquire user media and fail on iOS https://bugs.webkit.org/show_bug.cgi?id=179363
16541
- !DeviceManager.userMediaPromiseMap.get(kind) || !isSafari())) {
16542
- const isDummyDeviceOrEmpty = devices.length === 0 || devices.some(device => {
16410
+ !(isSafari() && this.hasDeviceInUse(kind))) {
16411
+ const isDummyDeviceOrEmpty = devices.filter(d => d.kind === kind).length === 0 || devices.some(device => {
16543
16412
  const noLabel = device.label === '';
16544
16413
  const isRelevant = kind ? device.kind === kind : true;
16545
16414
  return noLabel && isRelevant;
@@ -16547,7 +16416,11 @@ class DeviceManager {
16547
16416
  if (isDummyDeviceOrEmpty) {
16548
16417
  const permissionsToAcquire = {
16549
16418
  video: kind !== 'audioinput' && kind !== 'audiooutput',
16550
- audio: kind !== 'videoinput'
16419
+ audio: kind !== 'videoinput' && {
16420
+ deviceId: {
16421
+ ideal: 'default'
16422
+ }
16423
+ }
16551
16424
  };
16552
16425
  const stream = yield navigator.mediaDevices.getUserMedia(permissionsToAcquire);
16553
16426
  devices = yield navigator.mediaDevices.enumerateDevices();
@@ -16556,6 +16429,7 @@ class DeviceManager {
16556
16429
  });
16557
16430
  }
16558
16431
  }
16432
+ this._previousDevices = devices;
16559
16433
  if (kind) {
16560
16434
  devices = devices.filter(device => device.kind === kind);
16561
16435
  }
@@ -16570,10 +16444,22 @@ class DeviceManager {
16570
16444
  // resolve actual device id if it's 'default': Chrome returns it when no
16571
16445
  // device has been chosen
16572
16446
  const devices = yield this.getDevices(kind);
16573
- const device = devices.find(d => d.groupId === groupId && d.deviceId !== defaultId);
16447
+ const defaultDevice = devices.find(d => d.deviceId === defaultId);
16448
+ if (!defaultDevice) {
16449
+ livekitLogger.warn('could not reliably determine default device');
16450
+ return undefined;
16451
+ }
16452
+ const device = devices.find(d => d.deviceId !== defaultId && d.groupId === (groupId !== null && groupId !== void 0 ? groupId : defaultDevice.groupId));
16453
+ if (!device) {
16454
+ livekitLogger.warn('could not reliably determine default device');
16455
+ return undefined;
16456
+ }
16574
16457
  return device === null || device === void 0 ? void 0 : device.deviceId;
16575
16458
  });
16576
16459
  }
16460
+ hasDeviceInUse(kind) {
16461
+ return kind ? DeviceManager.userMediaPromiseMap.has(kind) : DeviceManager.userMediaPromiseMap.size > 0;
16462
+ }
16577
16463
  }
16578
16464
  DeviceManager.mediaDeviceKinds = ['audioinput', 'audiooutput', 'videoinput'];
16579
16465
  DeviceManager.userMediaPromiseMap = new Map();
@@ -23404,6 +23290,50 @@ class Room extends EventEmitter {
23404
23290
  this.emit(RoomEvent.AudioPlaybackStatusChanged, false);
23405
23291
  };
23406
23292
  this.handleDeviceChange = () => __awaiter(this, void 0, void 0, function* () {
23293
+ var _j, _k, _l;
23294
+ const previousDevices = DeviceManager.getInstance().previousDevices;
23295
+ // check for available devices, but don't request permissions in order to avoid prompts for kinds that haven't been used before
23296
+ const availableDevices = yield DeviceManager.getInstance().getDevices(undefined, false);
23297
+ const browser = getBrowser();
23298
+ if ((browser === null || browser === void 0 ? void 0 : browser.name) === 'Chrome' && browser.os !== 'iOS') {
23299
+ for (let availableDevice of availableDevices) {
23300
+ const previousDevice = previousDevices.find(info => info.deviceId === availableDevice.deviceId);
23301
+ if (previousDevice && previousDevice.label !== '' && previousDevice.kind === availableDevice.kind && previousDevice.label !== availableDevice.label) {
23302
+ // label has changed on device the same deviceId, indicating that the default device has changed on the OS level
23303
+ if (this.getActiveDevice(availableDevice.kind) === 'default') {
23304
+ // emit an active device change event only if the selected output device is actually on `default`
23305
+ this.emit(RoomEvent.ActiveDeviceChanged, availableDevice.kind, availableDevice.deviceId);
23306
+ }
23307
+ }
23308
+ }
23309
+ }
23310
+ const kinds = ['audiooutput', 'audioinput', 'videoinput'];
23311
+ for (let kind of kinds) {
23312
+ const targetSource = kindToSource(kind);
23313
+ const targetPublication = this.localParticipant.getTrack(targetSource);
23314
+ if (targetPublication && ((_j = targetPublication.track) === null || _j === void 0 ? void 0 : _j.isUserProvided)) {
23315
+ // if the track is user provided, we don't want to switch devices on behalf of the user
23316
+ continue;
23317
+ }
23318
+ const devicesOfKind = availableDevices.filter(d => d.kind === kind);
23319
+ const activeDevice = this.getActiveDevice(kind);
23320
+ if (activeDevice === ((_k = previousDevices.filter(info => info.kind === kind)[0]) === null || _k === void 0 ? void 0 : _k.deviceId)) {
23321
+ // in Safari the first device is always the default, so we assume a user on the default device would like to switch to the default once it changes
23322
+ // FF doesn't emit an event when the default device changes, so we perform the same best effort and switch to the new device once connected and if it's the first in the array
23323
+ if (devicesOfKind.length > 0 && ((_l = devicesOfKind[0]) === null || _l === void 0 ? void 0 : _l.deviceId) !== activeDevice) {
23324
+ yield this.switchActiveDevice(kind, devicesOfKind[0].deviceId);
23325
+ continue;
23326
+ }
23327
+ }
23328
+ if (kind === 'audioinput' && !isSafari() || kind === 'videoinput') {
23329
+ // airpods on Safari need special handling for audioinput as the track doesn't end as soon as you take them out
23330
+ continue;
23331
+ }
23332
+ // switch to first available device if previously active device is not available any more
23333
+ if (devicesOfKind.length > 0 && !devicesOfKind.find(deviceInfo => deviceInfo.deviceId === this.getActiveDevice(kind))) {
23334
+ yield this.switchActiveDevice(kind, devicesOfKind[0].deviceId);
23335
+ }
23336
+ }
23407
23337
  this.emit(RoomEvent.MediaDevicesChanged);
23408
23338
  });
23409
23339
  this.handleRoomUpdate = room => {
@@ -23441,7 +23371,7 @@ class Room extends EventEmitter {
23441
23371
  this.emit(RoomEvent.TrackUnmuted, pub, this.localParticipant);
23442
23372
  };
23443
23373
  this.onLocalTrackPublished = pub => __awaiter(this, void 0, void 0, function* () {
23444
- var _j;
23374
+ var _m;
23445
23375
  this.emit(RoomEvent.LocalTrackPublished, pub, this.localParticipant);
23446
23376
  if (pub.track instanceof LocalAudioTrack) {
23447
23377
  const trackIsSilent = yield pub.track.checkForSilence();
@@ -23449,7 +23379,7 @@ class Room extends EventEmitter {
23449
23379
  this.emit(RoomEvent.LocalAudioSilenceDetected, pub);
23450
23380
  }
23451
23381
  }
23452
- const deviceId = yield (_j = pub.track) === null || _j === void 0 ? void 0 : _j.getDeviceId();
23382
+ const deviceId = yield (_m = pub.track) === null || _m === void 0 ? void 0 : _m.getDeviceId();
23453
23383
  const deviceKind = sourceToKind(pub.source);
23454
23384
  if (deviceKind && deviceId && deviceId !== this.localParticipant.activeDeviceMap.get(deviceKind)) {
23455
23385
  this.localParticipant.activeDeviceMap.set(deviceKind, deviceId);
@@ -24874,5 +24804,5 @@ function isFacingModeValue(item) {
24874
24804
  return item === undefined || allowedValues.includes(item);
24875
24805
  }
24876
24806
 
24877
- export { AudioPresets, BaseKeyProvider, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createE2EEKey, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, importKey, isBackupCodec, isBrowserSupported, isCodecEqual, isE2EESupported, isInsertableStreamSupported, isScriptTransformSupported, isVideoFrame, mimeTypeToVideoCodecString, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs };
24807
+ export { AudioPresets, BaseKeyProvider, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, Mutex, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createE2EEKey, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, importKey, isBackupCodec, isBrowserSupported, isCodecEqual, isE2EESupported, isInsertableStreamSupported, isScriptTransformSupported, isVideoFrame, mimeTypeToVideoCodecString, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs };
24878
24808
  //# sourceMappingURL=livekit-client.esm.mjs.map