livekit-client 2.19.2 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +23 -23
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +179 -111
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.fm.worker.js +2 -0
- package/dist/{livekit-client.pt.worker.js.map → livekit-client.fm.worker.js.map} +1 -1
- package/dist/{livekit-client.pt.worker.mjs → livekit-client.fm.worker.mjs} +4 -4
- package/dist/livekit-client.fm.worker.mjs.map +1 -0
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +5 -5
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +8 -8
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/{packetTrailer/PacketTrailerManager.d.ts → frameMetadata/FrameMetadataManager.d.ts} +8 -4
- package/dist/src/{packetTrailer/PacketTrailerManager.d.ts.map → frameMetadata/FrameMetadataManager.d.ts.map} +1 -1
- package/dist/src/{packetTrailer/packetTrailer.d.ts → frameMetadata/frameMetadata.d.ts} +7 -7
- package/dist/src/frameMetadata/frameMetadata.d.ts.map +1 -0
- package/dist/src/{packetTrailer → frameMetadata}/types.d.ts +10 -6
- package/dist/src/frameMetadata/types.d.ts.map +1 -0
- package/dist/src/frameMetadata/utils.d.ts +9 -0
- package/dist/src/{packetTrailer → frameMetadata}/utils.d.ts.map +1 -1
- package/dist/src/frameMetadata/worker/frameMetadata.worker.d.ts +2 -0
- package/dist/src/frameMetadata/worker/frameMetadata.worker.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/options.d.ts +8 -4
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +1 -0
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/PCTransportManager.d.ts +1 -0
- package/dist/src/room/PCTransportManager.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +3 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +2 -2
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +2 -2
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/token-source/TokenSource.d.ts.map +1 -1
- package/dist/src/room/token-source/types.d.ts +1 -0
- package/dist/src/room/token-source/types.d.ts.map +1 -1
- package/dist/src/room/token-source/utils.d.ts.map +1 -1
- package/dist/src/room/track/FrameMetadataExtractor.d.ts +19 -0
- package/dist/src/room/track/FrameMetadataExtractor.d.ts.map +1 -0
- package/dist/src/room/track/RemoteVideoTrack.d.ts +7 -7
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +17 -5
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/ts4.2/e2ee/E2eeManager.d.ts +1 -1
- package/dist/ts4.2/e2ee/types.d.ts +5 -5
- package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +8 -8
- package/dist/ts4.2/{packetTrailer/PacketTrailerManager.d.ts → frameMetadata/FrameMetadataManager.d.ts} +8 -4
- package/dist/ts4.2/{packetTrailer/packetTrailer.d.ts → frameMetadata/frameMetadata.d.ts} +7 -7
- package/dist/ts4.2/{packetTrailer → frameMetadata}/types.d.ts +10 -6
- package/dist/ts4.2/frameMetadata/utils.d.ts +9 -0
- package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -0
- package/dist/ts4.2/index.d.ts +9 -3
- package/dist/ts4.2/options.d.ts +8 -4
- package/dist/ts4.2/room/PCTransport.d.ts +1 -0
- package/dist/ts4.2/room/PCTransportManager.d.ts +1 -0
- package/dist/ts4.2/room/RTCEngine.d.ts +3 -1
- package/dist/ts4.2/room/Room.d.ts +2 -2
- package/dist/ts4.2/room/participant/LocalParticipant.d.ts +2 -2
- package/dist/ts4.2/room/token-source/types.d.ts +1 -0
- package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -0
- package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +7 -7
- package/dist/ts4.2/room/track/options.d.ts +17 -5
- package/package.json +23 -18
- package/src/api/SignalClient.test.ts +4 -4
- package/src/api/SignalClient.ts +7 -3
- package/src/api/WebSocketStream.test.ts +7 -7
- package/src/e2ee/E2eeManager.ts +13 -11
- package/src/e2ee/types.ts +5 -5
- package/src/e2ee/worker/FrameCryptor.test.ts +5 -5
- package/src/e2ee/worker/FrameCryptor.ts +27 -23
- package/src/e2ee/worker/e2ee.worker.ts +5 -5
- package/src/e2ee/worker/tsconfig.json +4 -1
- package/src/{packetTrailer/PacketTrailerManager.test.ts → frameMetadata/FrameMetadataManager.test.ts} +10 -8
- package/src/{packetTrailer/PacketTrailerManager.ts → frameMetadata/FrameMetadataManager.ts} +21 -15
- package/src/{packetTrailer/packetTrailer.test.ts → frameMetadata/frameMetadata.test.ts} +1 -1
- package/src/{packetTrailer/packetTrailer.ts → frameMetadata/frameMetadata.ts} +9 -9
- package/src/{packetTrailer → frameMetadata}/types.ts +12 -6
- package/src/{packetTrailer → frameMetadata}/utils.test.ts +19 -19
- package/src/{packetTrailer → frameMetadata}/utils.ts +11 -11
- package/src/{packetTrailer/worker/packetTrailer.worker.ts → frameMetadata/worker/frameMetadata.worker.ts} +5 -5
- package/src/{packetTrailer → frameMetadata}/worker/tsconfig.json +4 -1
- package/src/index.ts +13 -2
- package/src/options.ts +9 -4
- package/src/room/PCTransport.ts +4 -0
- package/src/room/PCTransportManager.ts +4 -0
- package/src/room/RTCEngine.test.ts +143 -9
- package/src/room/RTCEngine.ts +111 -31
- package/src/room/Room.ts +10 -10
- package/src/room/participant/LocalParticipant.test.ts +19 -19
- package/src/room/participant/LocalParticipant.ts +21 -16
- package/src/room/participant/publishUtils.test.ts +6 -0
- package/src/room/participant/publishUtils.ts +4 -1
- package/src/room/rpc/client/RpcClientManager.ts +1 -1
- package/src/room/rpc/server/RpcServerManager.ts +1 -1
- package/src/room/token-source/TokenSource.ts +9 -23
- package/src/room/token-source/types.ts +1 -0
- package/src/room/token-source/utils.ts +1 -0
- package/src/room/track/{PacketTrailerExtractor.ts → FrameMetadataExtractor.ts} +8 -8
- package/src/room/track/RemoteVideoTrack.ts +7 -11
- package/src/room/track/options.ts +19 -5
- package/dist/livekit-client.pt.worker.js +0 -2
- package/dist/livekit-client.pt.worker.mjs.map +0 -1
- package/dist/src/packetTrailer/packetTrailer.d.ts.map +0 -1
- package/dist/src/packetTrailer/types.d.ts.map +0 -1
- package/dist/src/packetTrailer/utils.d.ts +0 -9
- package/dist/src/packetTrailer/worker/packetTrailer.worker.d.ts +0 -2
- package/dist/src/packetTrailer/worker/packetTrailer.worker.d.ts.map +0 -1
- package/dist/src/room/track/PacketTrailerExtractor.d.ts +0 -19
- package/dist/src/room/track/PacketTrailerExtractor.d.ts.map +0 -1
- package/dist/ts4.2/packetTrailer/utils.d.ts +0 -9
- package/dist/ts4.2/packetTrailer/worker/packetTrailer.worker.d.ts +0 -2
- package/dist/ts4.2/room/track/PacketTrailerExtractor.d.ts +0 -19
|
@@ -22,13 +22,13 @@ import {
|
|
|
22
22
|
protoInt64,
|
|
23
23
|
} from '@livekit/protocol';
|
|
24
24
|
import { SignalConnectionState } from '../../api/SignalClient';
|
|
25
|
-
import type { InternalRoomOptions } from '../../options';
|
|
26
25
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} from '../../
|
|
26
|
+
getFrameMetadataFeatures,
|
|
27
|
+
getFrameMetadataPublishOptions,
|
|
28
|
+
hasFrameMetadataPublishOptions,
|
|
29
|
+
isFrameMetadataSupported,
|
|
30
|
+
} from '../../frameMetadata/utils';
|
|
31
|
+
import type { InternalRoomOptions } from '../../options';
|
|
32
32
|
import TypedPromise from '../../utils/TypedPromise';
|
|
33
33
|
import { PCTransportState } from '../PCTransportManager';
|
|
34
34
|
import type RTCEngine from '../RTCEngine';
|
|
@@ -1085,7 +1085,7 @@ export default class LocalParticipant extends Participant {
|
|
|
1085
1085
|
audioFeatures.push(AudioTrackFeature.TF_PRECONNECT_BUFFER);
|
|
1086
1086
|
}
|
|
1087
1087
|
const packetTrailerFeatures: PacketTrailerFeature[] =
|
|
1088
|
-
this.
|
|
1088
|
+
this.normalizeRequestedFrameMetadataOptions(track, opts);
|
|
1089
1089
|
|
|
1090
1090
|
// create track publication from track
|
|
1091
1091
|
const req = new AddTrackRequest({
|
|
@@ -1416,31 +1416,36 @@ export default class LocalParticipant extends Participant {
|
|
|
1416
1416
|
return publication;
|
|
1417
1417
|
}
|
|
1418
1418
|
|
|
1419
|
-
private
|
|
1419
|
+
private canPublishFrameMetadata() {
|
|
1420
1420
|
return !!(
|
|
1421
1421
|
this.roomOptions.e2ee ||
|
|
1422
1422
|
this.roomOptions.encryption ||
|
|
1423
|
-
|
|
1423
|
+
isFrameMetadataSupported(this.roomOptions.frameMetadata ?? this.roomOptions.packetTrailer)
|
|
1424
1424
|
);
|
|
1425
1425
|
}
|
|
1426
1426
|
|
|
1427
|
-
private
|
|
1428
|
-
|
|
1427
|
+
private normalizeRequestedFrameMetadataOptions(track: LocalTrack, opts: TrackPublishOptions) {
|
|
1428
|
+
const fmOpts = opts.frameMetadata ?? opts.packetTrailer;
|
|
1429
|
+
if (track.kind !== Track.Kind.Video || !hasFrameMetadataPublishOptions(fmOpts)) {
|
|
1430
|
+
opts.frameMetadata = undefined;
|
|
1429
1431
|
opts.packetTrailer = undefined;
|
|
1430
1432
|
return [];
|
|
1431
1433
|
}
|
|
1432
1434
|
|
|
1433
|
-
if (!this.
|
|
1434
|
-
this.log.warn('
|
|
1435
|
+
if (!this.canPublishFrameMetadata()) {
|
|
1436
|
+
this.log.warn('frame metadata transform not supported; not advertising features', {
|
|
1435
1437
|
...this.logContext,
|
|
1436
1438
|
...getLogContextFromTrack(track),
|
|
1437
1439
|
});
|
|
1440
|
+
opts.frameMetadata = undefined;
|
|
1438
1441
|
opts.packetTrailer = undefined;
|
|
1439
1442
|
return [];
|
|
1440
1443
|
}
|
|
1441
1444
|
|
|
1442
|
-
const features =
|
|
1443
|
-
|
|
1445
|
+
const features = getFrameMetadataFeatures(fmOpts);
|
|
1446
|
+
const normalized = getFrameMetadataPublishOptions(features);
|
|
1447
|
+
opts.frameMetadata = normalized;
|
|
1448
|
+
opts.packetTrailer = normalized;
|
|
1444
1449
|
return features;
|
|
1445
1450
|
}
|
|
1446
1451
|
|
|
@@ -1496,7 +1501,7 @@ export default class LocalParticipant extends Participant {
|
|
|
1496
1501
|
if (!simulcastTrack) {
|
|
1497
1502
|
return;
|
|
1498
1503
|
}
|
|
1499
|
-
const packetTrailerFeatures = this.
|
|
1504
|
+
const packetTrailerFeatures = this.normalizeRequestedFrameMetadataOptions(track, opts);
|
|
1500
1505
|
|
|
1501
1506
|
const req = new AddTrackRequest({
|
|
1502
1507
|
cid: simulcastTrack.mediaStreamTrack.id,
|
|
@@ -174,6 +174,12 @@ describe('customSimulcastLayers', () => {
|
|
|
174
174
|
expect(sortedPresets[1].encoding.maxFramerate).toBe(15);
|
|
175
175
|
expect(sortedPresets[2].encoding.maxFramerate).toBe(20);
|
|
176
176
|
});
|
|
177
|
+
it('does not mutate the passed-in array', () => {
|
|
178
|
+
const presets = [VideoPresets.h1440, VideoPresets.h360, VideoPresets.h1080, VideoPresets.h90];
|
|
179
|
+
const original = [...presets];
|
|
180
|
+
sortPresets(presets);
|
|
181
|
+
expect(presets).toEqual(original);
|
|
182
|
+
});
|
|
177
183
|
});
|
|
178
184
|
|
|
179
185
|
describe('screenShareSimulcastDefaults', () => {
|
|
@@ -419,7 +419,10 @@ function encodingsFromPresets(
|
|
|
419
419
|
/** @internal */
|
|
420
420
|
export function sortPresets(presets: Array<VideoPreset> | undefined) {
|
|
421
421
|
if (!presets) return;
|
|
422
|
-
|
|
422
|
+
// Sort a copy so we don't mutate the caller's array in place. Mutating the
|
|
423
|
+
// passed-in simulcast layers can cause consumers that compare options by value
|
|
424
|
+
// (e.g. components-react's useLiveKitRoom) to detect a spurious change.
|
|
425
|
+
return presets.slice().sort((a, b) => {
|
|
423
426
|
const { encoding: aEnc } = a;
|
|
424
427
|
const { encoding: bEnc } = b;
|
|
425
428
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataPacket, DataPacket_Kind, RpcRequest } from '@livekit/protocol';
|
|
2
|
-
import EventEmitter from 'events';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
3
|
import type TypedEmitter from 'typed-emitter';
|
|
4
4
|
import { type StructuredLogger } from '../../../logger';
|
|
5
5
|
import { CLIENT_PROTOCOL_DATA_STREAM_RPC } from '../../../version';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataPacket, DataPacket_Kind, RpcAck, RpcRequest, RpcResponse } from '@livekit/protocol';
|
|
2
|
-
import EventEmitter from 'events';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
3
|
import type TypedEmitter from 'typed-emitter';
|
|
4
4
|
import { type StructuredLogger } from '../../../logger';
|
|
5
5
|
import { CLIENT_PROTOCOL_DATA_STREAM_RPC } from '../../../version';
|
|
@@ -27,29 +27,7 @@ abstract class TokenSourceCached extends TokenSourceConfigurable {
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
keyof TokenSourceFetchOptions
|
|
32
|
-
>) {
|
|
33
|
-
switch (key) {
|
|
34
|
-
case 'roomName':
|
|
35
|
-
case 'participantName':
|
|
36
|
-
case 'participantIdentity':
|
|
37
|
-
case 'participantMetadata':
|
|
38
|
-
case 'participantAttributes':
|
|
39
|
-
case 'agentName':
|
|
40
|
-
case 'agentMetadata':
|
|
41
|
-
if (this.cachedFetchOptions[key] !== options[key]) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
// ref: https://stackoverflow.com/a/58009992
|
|
47
|
-
const exhaustiveCheckedKey: never = key;
|
|
48
|
-
throw new Error(`Options key ${exhaustiveCheckedKey} not being checked for equality!`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return true;
|
|
30
|
+
return areTokenSourceFetchOptionsEqual(options, this.cachedFetchOptions);
|
|
53
31
|
}
|
|
54
32
|
|
|
55
33
|
private shouldReturnCachedValueFromFetch(fetchOptions: TokenSourceFetchOptions) {
|
|
@@ -191,6 +169,14 @@ class TokenSourceEndpoint extends TokenSourceCached {
|
|
|
191
169
|
request.roomConfig.agents[0].metadata = options.agentMetadata!;
|
|
192
170
|
break;
|
|
193
171
|
|
|
172
|
+
case 'deployment':
|
|
173
|
+
request.roomConfig = request.roomConfig ?? new RoomConfiguration();
|
|
174
|
+
if (request.roomConfig.agents.length === 0) {
|
|
175
|
+
request.roomConfig.agents.push(new RoomAgentDispatch());
|
|
176
|
+
}
|
|
177
|
+
request.roomConfig.agents[0].deployment = options.deployment!;
|
|
178
|
+
break;
|
|
179
|
+
|
|
194
180
|
default:
|
|
195
181
|
// ref: https://stackoverflow.com/a/58009992
|
|
196
182
|
const exhaustiveCheckedKey: never = key;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FrameMetadata } from '../../frameMetadata/types';
|
|
2
2
|
|
|
3
3
|
const MAX_ENTRIES = 300;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Caches
|
|
6
|
+
* Caches frame metadata extracted from received video frames,
|
|
7
7
|
* keyed by RTP timestamp so it can be looked up when the frame is displayed.
|
|
8
8
|
*
|
|
9
|
-
* Metadata is populated either by the
|
|
10
|
-
* `
|
|
9
|
+
* Metadata is populated either by the frame metadata worker managed by
|
|
10
|
+
* `FrameMetadataManager` (non-E2EE) or by the E2EE FrameCryptor worker
|
|
11
11
|
* after decryption (E2EE).
|
|
12
12
|
*
|
|
13
13
|
* @experimental
|
|
14
14
|
*/
|
|
15
|
-
export class
|
|
16
|
-
private metadataMap = new Map<number,
|
|
15
|
+
export class FrameMetadataExtractor {
|
|
16
|
+
private metadataMap = new Map<number, FrameMetadata>();
|
|
17
17
|
|
|
18
18
|
private activeSsrc: number = 0;
|
|
19
19
|
|
|
20
|
-
storeMetadata(rtpTimestamp: number, ssrc: number, metadata:
|
|
20
|
+
storeMetadata(rtpTimestamp: number, ssrc: number, metadata: FrameMetadata) {
|
|
21
21
|
// Simulcast layer switch: SSRC changed, flush stale entries from old layer.
|
|
22
22
|
if (this.activeSsrc !== 0 && this.activeSsrc !== ssrc) {
|
|
23
23
|
this.metadataMap.clear();
|
|
@@ -32,7 +32,7 @@ export class PacketTrailerExtractor {
|
|
|
32
32
|
this.metadataMap.set(rtpTimestamp, metadata);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
lookupMetadata(rtpTimestamp: number):
|
|
35
|
+
lookupMetadata(rtpTimestamp: number): FrameMetadata | undefined {
|
|
36
36
|
return this.metadataMap.get(rtpTimestamp);
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FrameMetadata } from '../../frameMetadata/types';
|
|
2
2
|
import { debounce } from '../debounce';
|
|
3
3
|
import { TrackEvent } from '../events';
|
|
4
4
|
import type { VideoReceiverStats } from '../stats';
|
|
@@ -7,7 +7,7 @@ import CriticalTimers from '../timers';
|
|
|
7
7
|
import type { LoggerOptions } from '../types';
|
|
8
8
|
import type { ObservableMediaElement } from '../utils';
|
|
9
9
|
import { getDevicePixelRatio, getIntersectionObserver, getResizeObserver, isWeb } from '../utils';
|
|
10
|
-
import type {
|
|
10
|
+
import type { FrameMetadataExtractor } from './FrameMetadataExtractor';
|
|
11
11
|
import RemoteTrack from './RemoteTrack';
|
|
12
12
|
import { Track, attachToElement, detachTrack } from './Track';
|
|
13
13
|
import type { AdaptiveStreamSettings } from './types';
|
|
@@ -26,7 +26,7 @@ export default class RemoteVideoTrack extends RemoteTrack<Track.Kind.Video> {
|
|
|
26
26
|
private lastDimensions?: Track.Dimensions;
|
|
27
27
|
|
|
28
28
|
/** @internal */
|
|
29
|
-
|
|
29
|
+
frameMetadataExtractor?: FrameMetadataExtractor;
|
|
30
30
|
|
|
31
31
|
constructor(
|
|
32
32
|
mediaTrack: MediaStreamTrack,
|
|
@@ -48,16 +48,12 @@ export default class RemoteVideoTrack extends RemoteTrack<Track.Kind.Video> {
|
|
|
48
48
|
* Use with the `TrackEvent.TimeSyncUpdate` event to correlate displayed frames
|
|
49
49
|
* with their capture-time metadata.
|
|
50
50
|
*
|
|
51
|
-
* Requires the room to be configured with the `
|
|
52
|
-
* and the publishing track to have
|
|
51
|
+
* Requires the room to be configured with the `frameMetadata` worker option
|
|
52
|
+
* and the publishing track to have frame metadata features enabled.
|
|
53
53
|
*
|
|
54
54
|
*/
|
|
55
|
-
lookupFrameMetadata({
|
|
56
|
-
rtpTimestamp
|
|
57
|
-
}: {
|
|
58
|
-
rtpTimestamp: number;
|
|
59
|
-
}): PacketTrailerMetadata | undefined {
|
|
60
|
-
return this.packetTrailerExtractor?.lookupMetadata(rtpTimestamp);
|
|
55
|
+
lookupFrameMetadata({ rtpTimestamp }: { rtpTimestamp: number }): FrameMetadata | undefined {
|
|
56
|
+
return this.frameMetadataExtractor?.lookupMetadata(rtpTimestamp);
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
override setStreamState(value: Track.StreamState) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FrameMetadataPublishOptions } from '../../frameMetadata/types';
|
|
2
2
|
import type { Track } from './Track';
|
|
3
3
|
import type {
|
|
4
4
|
AudioProcessorOptions,
|
|
@@ -131,14 +131,19 @@ export interface TrackPublishDefaults {
|
|
|
131
131
|
preConnectBuffer?: boolean;
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
134
|
+
* Frame metadata to append to published video frames.
|
|
135
135
|
*
|
|
136
|
-
* Requires either room-level
|
|
137
|
-
* because encoded frame transforms are used to write the
|
|
136
|
+
* Requires either room-level frame metadata worker configuration or E2EE,
|
|
137
|
+
* because encoded frame transforms are used to write the metadata.
|
|
138
138
|
*
|
|
139
139
|
* @experimental
|
|
140
140
|
*/
|
|
141
|
-
|
|
141
|
+
frameMetadata?: FrameMetadataPublishOptions;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use {@link TrackPublishDefaults.frameMetadata} instead.
|
|
145
|
+
*/
|
|
146
|
+
packetTrailer?: FrameMetadataPublishOptions;
|
|
142
147
|
}
|
|
143
148
|
|
|
144
149
|
/**
|
|
@@ -292,6 +297,15 @@ export interface AudioCaptureOptions {
|
|
|
292
297
|
*/
|
|
293
298
|
voiceIsolation?: ConstrainBoolean;
|
|
294
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @experimental
|
|
302
|
+
* when capturing system/screen-share audio, excludes the local participant's own audio
|
|
303
|
+
* from the captured stream to prevent echo. Browser support is not widespread yet
|
|
304
|
+
* (as of mid 2026, Chromium-based browsers only).
|
|
305
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/restrictOwnAudio
|
|
306
|
+
*/
|
|
307
|
+
restrictOwnAudio?: ConstrainBoolean;
|
|
308
|
+
|
|
295
309
|
/**
|
|
296
310
|
* the sample rate or range of sample rates which are acceptable and/or required.
|
|
297
311
|
*/
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e,t){if(!e)throw new Error(t)}const t=34028234663852886e22,n=-34028234663852886e22,r=4294967295,i=2147483647,a=-2147483648;function o(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>i||e<a)throw new Error("invalid int 32: "+e)}function s(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>r||e<0)throw new Error("invalid uint 32: "+e)}function c(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>t||e<n))throw new Error("invalid float 32: "+e)}const u=Symbol("@bufbuild/protobuf/enum-type");function l(t){const n=t[u];return e(n,"missing enum type on enum object"),n}function d(e,t,n,r){e[u]=f(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function f(e,t,n){const r=Object.create(null),i=Object.create(null),a=[];for(const e of t){const t=p(e);a.push(t),r[e.name]=t,i[e.no]=t}return{typeName:e,values:a,findName:e=>r[e],findNumber:e=>i[e]}}function h(e,t,n){const r={};for(const e of t){const t=p(e);r[t.localName]=t.no,r[t.no]=t.localName}return d(r,e,t),r}function p(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class m{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,r=n.makeReadOptions(t);return n.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){const n=this.getType(),r=n.runtime.json,i=r.makeReadOptions(t);return r.readMessage(n,e,i,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(e){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(e instanceof Error?e.message:String(e)))}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),r=n.writerFactory();return t.writeMessage(this,r,n),r.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function g(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<n,0==(128&r))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,0==(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<n,0==(128&r))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function b(e,t,n){for(let r=0;r<28;r+=7){const i=e>>>r,a=!(i>>>7==0&&0==t),o=255&(a?128|i:i);if(n.push(o),!a)return}const r=e>>>28&15|(7&t)<<4,i=!(t>>3==0);if(n.push(255&(i?128|r:r)),i){for(let e=3;e<31;e+=7){const r=t>>>e,i=!(r>>>7==0),a=255&(i?128|r:r);if(n.push(a),!i)return}n.push(t>>>31&1)}}const y=4294967296;function v(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let r=0,i=0;function a(t,a){const o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=y&&(i+=r/y|0,r%=y)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?T(r,i):w(r,i)}function k(e,t){var n=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t);if(e=n.lo,(t=n.hi)<=2097151)return String(y*t+e);const r=16777215&(e>>>24|t<<8),i=t>>16&65535;let a=(16777215&e)+6777216*r+6710656*i,o=r+8147497*i,s=2*i;const c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+S(o)+S(a)}function w(e,t){return{lo:0|e,hi:0|t}}function T(e,t){return t=~t,e?e=1+~e:t+=1,w(e,t)}const S=e=>{const t=String(e);return"0000000".slice(t.length)+t};function E(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function N(){let e=this.buf[this.pos++],t=127&e;if(0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,0==(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;0!=(128&e)&&t<10;t++)e=this.buf[this.pos++];if(0!=(128&e))throw new Error("invalid varint");return this.assertBounds(),t>>>0}const I=function(){const t=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof t.getBigInt64&&"function"==typeof t.getBigUint64&&"function"==typeof t.setBigInt64&&"function"==typeof t.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const e=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),r=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(t){const r="bigint"==typeof t?t:BigInt(t);if(r>n||r<e)throw new Error("int64 invalid: ".concat(t));return r},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>i||t<r)throw new Error("uint64 invalid: ".concat(e));return t},enc(e){return t.setBigInt64(0,this.parse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(e){return t.setBigInt64(0,this.uParse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(e,n)=>(t.setInt32(0,e,!0),t.setInt32(4,n,!0),t.getBigInt64(0,!0)),uDec:(e,n)=>(t.setInt32(0,e,!0),t.setInt32(4,n,!0),t.getBigUint64(0,!0))}}const n=t=>e(/^-?[0-9]+$/.test(t),"int64 invalid: ".concat(t)),r=t=>e(/^[0-9]+$/.test(t),"uint64 invalid: ".concat(t));return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),r(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),n(e),v(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),r(e),v(e)),dec:(e,t)=>function(e,t){let n=w(e,t);const r=2147483648&n.hi;r&&(n=T(n.lo,n.hi));const i=k(n.lo,n.hi);return r?"-"+i:i}(e,t),uDec:(e,t)=>k(e,t)}}();var O,C,A;function U(e,t,n){if(t===n)return!0;if(e==O.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case O.UINT64:case O.FIXED64:case O.INT64:case O.SFIXED64:case O.SINT64:return t==n}return!1}function L(e,t){switch(e){case O.BOOL:return!1;case O.UINT64:case O.FIXED64:case O.INT64:case O.SFIXED64:case O.SINT64:return 0==t?I.zero:"0";case O.DOUBLE:case O.FLOAT:return 0;case O.BYTES:return new Uint8Array(0);case O.STRING:return"";default:return 0}}function F(e,t){switch(e){case O.BOOL:return!1===t;case O.STRING:return""===t;case O.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?D(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}!function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"}(O||(O={})),function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"}(C||(C={})),function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(A||(A={}));class B{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(s(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return o(e),E(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){c(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){s(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){o(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return o(e),E(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=I.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=I.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=I.enc(e);return b(t.lo,t.hi,this.buf),this}sint64(e){let t=I.enc(e),n=t.hi>>31;return b(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=I.uEnc(e);return b(t.lo,t.hi,this.buf),this}}class P{constructor(e,t){this.varint64=g,this.uint32=N,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case A.Varint:for(;128&this.buf[this.pos++];);break;case A.Bit64:this.pos+=4;case A.Bit32:this.pos+=4;break;case A.LengthDelimited:let n=this.uint32();this.pos+=n;break;case A.StartGroup:for(;;){const e=R(this.tag(),2),n=e[0],r=e[1];if(r===A.EndGroup){if(void 0!==t&&n!==t)throw new Error("invalid end group tag");break}this.skip(r,n)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return I.dec(...this.varint64())}uint64(){return I.uDec(...this.varint64())}sint64(){let e=R(this.varint64(),2),t=e[0],n=e[1],r=-(1&t);return t=(t>>>1|(1&n)<<31)^r,n=n>>>1^r,I.dec(t,n)}bool(){let e=R(this.varint64(),2),t=e[0],n=e[1];return 0!==t||0!==n}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return I.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return I.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function x(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return L(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),M=[];for(let e=0;e<j.length;e++)M[j[e].charCodeAt(0)]=e;M["-".charCodeAt(0)]=j.indexOf("+"),M["_".charCodeAt(0)]=j.indexOf("/");const V={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,r=new Uint8Array(t),i=0,a=0,o=0;for(let t=0;t<e.length;t++){if(n=M[e.charCodeAt(t)],void 0===n)switch(e[t]){case"=":a=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(a){case 0:o=n,a=1;break;case 1:r[i++]=o<<2|(48&n)>>4,o=n,a=2;break;case 2:r[i++]=(15&o)<<4|(60&n)>>2,o=n,a=3;break;case 3:r[i++]=(3&o)<<6|n,a=0}}if(1==a)throw Error("invalid base64 string.");return r.subarray(0,i)},enc(e){let t,n="",r=0,i=0;for(let a=0;a<e.length;a++)switch(t=e[a],r){case 0:n+=j[t>>2],i=(3&t)<<4,r=1;break;case 1:n+=j[i|t>>4],i=(15&t)<<2,r=2;break;case 2:n+=j[i|t>>6],n+=j[63&t],r=0}return r&&(n+=j[i],n+="=",1==r&&(n+="=")),n}};function _(e,t,n){X(t,e);const r=t.runtime.bin.makeReadOptions(n),i=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),a=R(x(t),2),o=a[0],s=a[1];for(const e of i)t.runtime.bin.readField(o,r.readerFactory(e.data),t.field,e.wireType,r);return s()}function J(e,t,n,r){X(t,e);const i=t.runtime.bin.makeReadOptions(r),a=t.runtime.bin.makeWriteOptions(r);if(G(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const o=a.writerFactory();let s=t.field;s.opt||s.repeated||"enum"!=s.kind&&"scalar"!=s.kind||(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,o,a);const c=i.readerFactory(o.finish());for(;c.pos<c.len;){const t=R(c.tag(),2),n=t[0],r=t[1],i=c.skip(r,n);e.getType().runtime.bin.onUnknownField(e,n,r,i)}}function G(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function X(t,n){e(t.extendee.typeName==n.getType().typeName,"extension ".concat(t.typeName," can only be applied to message ").concat(t.extendee.typeName))}function q(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!F(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function W(e,t){const n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=r?e.T.values[0].no:void 0;break;case"scalar":t[n]=r?L(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function H(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(m.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function Y(e,t){return H(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}O.DOUBLE,O.FLOAT,O.INT64,O.UINT64,O.INT32,O.UINT32,O.BOOL,O.STRING,O.BYTES;const K={ignoreUnknownFields:!1},Q={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function z(e){return e?Object.assign(Object.assign({},K),e):K}function $(e){return e?Object.assign(Object.assign({},Q),e):Q}const Z=Symbol(),ee=Symbol();function te(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":'"'.concat(e.split('"').join('\\"'),'"');default:return String(e)}}function ne(t,n,r,i,a){let o=r.localName;if(r.repeated){if(e("map"!=r.kind),null===n)return;if(!Array.isArray(n))throw new Error("cannot decode field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(n)));const s=t[o];for(const e of n){if(null===e)throw new Error("cannot decode field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(e)));switch(r.kind){case"message":s.push(r.T.fromJson(e,i));break;case"enum":const t=ae(r.T,e,i.ignoreUnknownFields,!0);t!==ee&&s.push(t);break;case"scalar":try{s.push(ie(r.T,e,r.L,!0))}catch(t){let n="cannot decode field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(e));throw t instanceof Error&&t.message.length>0&&(n+=": ".concat(t.message)),new Error(n)}}}}else if("map"==r.kind){if(null===n)return;if("object"!=typeof n||Array.isArray(n))throw new Error("cannot decode field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(n)));const e=t[o];for(const t of Object.entries(n)){var s=R(t,2);const o=s[0],c=s[1];if(null===c)throw new Error("cannot decode field ".concat(a.typeName,".").concat(r.name," from JSON: map value null"));let u;try{u=re(r.K,o)}catch(e){let t="cannot decode map key for field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(n));throw e instanceof Error&&e.message.length>0&&(t+=": ".concat(e.message)),new Error(t)}switch(r.V.kind){case"message":e[u]=r.V.T.fromJson(c,i);break;case"enum":const t=ae(r.V.T,c,i.ignoreUnknownFields,!0);t!==ee&&(e[u]=t);break;case"scalar":try{e[u]=ie(r.V.T,c,C.BIGINT,!0)}catch(e){let t="cannot decode map value for field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(n));throw e instanceof Error&&e.message.length>0&&(t+=": ".concat(e.message)),new Error(t)}}}}else switch(r.oneof&&(t=t[r.oneof.localName]={case:o},o="value"),r.kind){case"message":const e=r.T;if(null===n&&"google.protobuf.Value"!=e.typeName)return;let s=t[o];H(s)?s.fromJson(n,i):(t[o]=s=e.fromJson(n,i),e.fieldWrapper&&!r.oneof&&(t[o]=e.fieldWrapper.unwrapField(s)));break;case"enum":const c=ae(r.T,n,i.ignoreUnknownFields,!1);switch(c){case Z:W(r,t);break;case ee:break;default:t[o]=c}break;case"scalar":try{const e=ie(r.T,n,r.L,!1);if(e===Z)W(r,t);else t[o]=e}catch(e){let t="cannot decode field ".concat(a.typeName,".").concat(r.name," from JSON: ").concat(te(n));throw e instanceof Error&&e.message.length>0&&(t+=": ".concat(e.message)),new Error(t)}}}function re(e,t){if(e===O.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return ie(e,t,C.BIGINT,!0).toString()}function ie(e,t,n,r){if(null===t)return r?L(e,n):Z;switch(e){case O.DOUBLE:case O.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const r=Number(t);if(Number.isNaN(r))break;if(!Number.isFinite(r))break;return e==O.FLOAT&&c(r),r;case O.INT32:case O.FIXED32:case O.SFIXED32:case O.SINT32:case O.UINT32:let i;if("number"==typeof t?i=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(i=Number(t)),void 0===i)break;return e==O.UINT32||e==O.FIXED32?s(i):o(i),i;case O.INT64:case O.SFIXED64:case O.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const a=I.parse(t);return n?a.toString():a;case O.FIXED64:case O.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const u=I.uParse(t);return n?u.toString():u;case O.BOOL:if("boolean"!=typeof t)break;return t;case O.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(e){throw new Error("invalid UTF8")}return t;case O.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return V.dec(t)}throw new Error}function ae(e,t,n,r){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:r?e.values[0].no:Z;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const r=e.findName(t);if(void 0!==r)return r.no;if(n)return ee}throw new Error("cannot decode enum ".concat(e.typeName," from JSON: ").concat(te(t)))}function oe(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function se(t,n,r){if("map"==t.kind){e("object"==typeof n&&null!=n);const s={},c=Object.entries(n);switch(t.V.kind){case"scalar":for(const e of c){var i=R(e,2);const n=i[0],r=i[1];s[n.toString()]=ue(t.V.T,r)}break;case"message":for(const e of c){var a=R(e,2);const t=a[0],n=a[1];s[t.toString()]=n.toJson(r)}break;case"enum":const e=t.V.T;for(const t of c){var o=R(t,2);const n=o[0],i=o[1];s[n.toString()]=ce(e,i,r.enumAsInteger)}}return r.emitDefaultValues||c.length>0?s:void 0}if(t.repeated){e(Array.isArray(n));const i=[];switch(t.kind){case"scalar":for(let e=0;e<n.length;e++)i.push(ue(t.T,n[e]));break;case"enum":for(let e=0;e<n.length;e++)i.push(ce(t.T,n[e],r.enumAsInteger));break;case"message":for(let e=0;e<n.length;e++)i.push(n[e].toJson(r))}return r.emitDefaultValues||i.length>0?i:void 0}switch(t.kind){case"scalar":return ue(t.T,n);case"enum":return ce(t.T,n,r.enumAsInteger);case"message":return Y(t.T,n).toJson(r)}}function ce(t,n,r){var i;if(e("number"==typeof n),"google.protobuf.NullValue"==t.typeName)return null;if(r)return n;const a=t.findNumber(n);return null!==(i=null==a?void 0:a.name)&&void 0!==i?i:n}function ue(t,n){switch(t){case O.INT32:case O.SFIXED32:case O.SINT32:case O.FIXED32:case O.UINT32:return e("number"==typeof n),n;case O.FLOAT:case O.DOUBLE:return e("number"==typeof n),Number.isNaN(n)?"NaN":n===Number.POSITIVE_INFINITY?"Infinity":n===Number.NEGATIVE_INFINITY?"-Infinity":n;case O.STRING:return e("string"==typeof n),n;case O.BOOL:return e("boolean"==typeof n),n;case O.UINT64:case O.FIXED64:case O.INT64:case O.SFIXED64:case O.SINT64:return e("bigint"==typeof n||"string"==typeof n||"number"==typeof n),n.toString();case O.BYTES:return e(n instanceof Uint8Array),V.enc(n)}}const le=Symbol("@bufbuild/protobuf/unknown-fields"),de={readUnknownFields:!0,readerFactory:e=>new P(e)},fe={writeUnknownFields:!0,writerFactory:()=>new B};function he(e){return e?Object.assign(Object.assign({},de),e):de}function pe(e){return e?Object.assign(Object.assign({},fe),e):fe}function me(e,t,n,r,i){let a=n.repeated,o=n.localName;switch(n.oneof&&((e=e[n.oneof.localName]).case!=o&&delete e.value,e.case=o,o="value"),n.kind){case"scalar":case"enum":const s="enum"==n.kind?O.INT32:n.T;let c=ye;if("scalar"==n.kind&&n.L>0&&(c=be),a){let n=e[o];if(r==A.LengthDelimited&&s!=O.STRING&&s!=O.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(c(t,s))}else n.push(c(t,s))}else e[o]=c(t,s);break;case"message":const u=n.T;a?e[o].push(ge(t,new u,i,n)):H(e[o])?ge(t,e[o],i,n):(e[o]=ge(t,new u,i,n),!u.fieldWrapper||n.oneof||n.repeated||(e[o]=u.fieldWrapper.unwrapField(e[o])));break;case"map":let l=function(e,t,n){const r=t.uint32(),i=t.pos+r;let a,o;for(;t.pos<i;){switch(R(t.tag(),1)[0]){case 1:a=ye(t,e.K);break;case 2:switch(e.V.kind){case"scalar":o=ye(t,e.V.T);break;case"enum":o=t.int32();break;case"message":o=ge(t,new e.V.T,n,void 0)}}}void 0===a&&(a=L(e.K,C.BIGINT));"string"!=typeof a&&"number"!=typeof a&&(a=a.toString());if(void 0===o)switch(e.V.kind){case"scalar":o=L(e.V.T,C.BIGINT);break;case"enum":o=e.V.T.values[0].no;break;case"message":o=new e.V.T}return[a,o]}(n,t,i),d=R(l,2),f=d[0],h=d[1];e[o][f]=h}}function ge(e,t,n,r){const i=t.getType().runtime.bin,a=null==r?void 0:r.delimited;return i.readMessage(t,e,a?r.no:e.uint32(),n,a),t}function be(e,t){const n=ye(e,t);return"bigint"==typeof n?n.toString():n}function ye(e,t){switch(t){case O.STRING:return e.string();case O.BOOL:return e.bool();case O.DOUBLE:return e.double();case O.FLOAT:return e.float();case O.INT32:return e.int32();case O.INT64:return e.int64();case O.UINT64:return e.uint64();case O.FIXED64:return e.fixed64();case O.BYTES:return e.bytes();case O.FIXED32:return e.fixed32();case O.SFIXED32:return e.sfixed32();case O.SFIXED64:return e.sfixed64();case O.SINT64:return e.sint64();case O.UINT32:return e.uint32();case O.SINT32:return e.sint32()}}function ve(t,n,r,i){e(void 0!==n);const a=t.repeated;switch(t.kind){case"scalar":case"enum":let s="enum"==t.kind?O.INT32:t.T;if(a)if(e(Array.isArray(n)),t.packed)!function(e,t,n,r){if(!r.length)return;e.tag(n,A.LengthDelimited).fork();let i=R(Se(t),2)[1];for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}(r,s,t.no,n);else for(const e of n)Te(r,s,t.no,e);else Te(r,s,t.no,n);break;case"message":if(a){e(Array.isArray(n));for(const e of n)we(r,i,t,e)}else we(r,i,t,n);break;case"map":e("object"==typeof n&&null!=n);for(const e of Object.entries(n)){var o=R(e,2);ke(r,i,t,o[0],o[1])}}}function ke(t,n,r,i,a){t.tag(r.no,A.LengthDelimited),t.fork();let o=i;switch(r.K){case O.INT32:case O.FIXED32:case O.UINT32:case O.SFIXED32:case O.SINT32:o=Number.parseInt(i);break;case O.BOOL:e("true"==i||"false"==i),o="true"==i}switch(Te(t,r.K,1,o),r.V.kind){case"scalar":Te(t,r.V.T,2,a);break;case"enum":Te(t,O.INT32,2,a);break;case"message":e(void 0!==a),t.tag(2,A.LengthDelimited).bytes(a.toBinary(n))}t.join()}function we(e,t,n,r){const i=Y(n.T,r);n.delimited?e.tag(n.no,A.StartGroup).raw(i.toBinary(t)).tag(n.no,A.EndGroup):e.tag(n.no,A.LengthDelimited).bytes(i.toBinary(t))}function Te(t,n,r,i){e(void 0!==i);let a=R(Se(n),2),o=a[0],s=a[1];t.tag(r,o)[s](i)}function Se(e){let t=A.Varint;switch(e){case O.BYTES:case O.STRING:t=A.LengthDelimited;break;case O.DOUBLE:case O.FIXED64:case O.SFIXED64:t=A.Bit64;break;case O.FIXED32:case O.SFIXED32:case O.FLOAT:t=A.Bit32}return[t,O[e].toLowerCase()]}function Ee(e){if(void 0===e)return e;if(H(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function Ne(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class Ie{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function Oe(e,t){const n=Ae(e);return t?n:Re(De(n))}const Ce=Ae;function Ae(e){let t=!1;const n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i)}}return n.join("")}const Ue=new Set(["constructor","toString","toJSON","valueOf"]),Le=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Fe=e=>"".concat(e,"$"),De=e=>Le.has(e)?Fe(e):e,Re=e=>Ue.has(e)?Fe(e):e;class Be{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Oe(e,!1)}addField(t){e(t.oneof===this,"field ".concat(t.name," not one of ").concat(this.name)),this.fields.push(t)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const Pe=(xe=e=>new Ie(e,(e=>function(e,t){var n,r,i,a,o,s;const c=[];let u;for(const t of"function"==typeof e?e():e){const e=t;if(e.localName=Oe(t.name,void 0!==t.oneof),e.jsonName=null!==(n=t.jsonName)&&void 0!==n?n:Ce(t.name),e.repeated=null!==(r=t.repeated)&&void 0!==r&&r,"scalar"==t.kind&&(e.L=null!==(i=t.L)&&void 0!==i?i:C.BIGINT),e.delimited=null!==(a=t.delimited)&&void 0!==a&&a,e.req=null!==(o=t.req)&&void 0!==o&&o,e.opt=null!==(s=t.opt)&&void 0!==s&&s,void 0===t.packed&&(e.packed="enum"==t.kind||"scalar"==t.kind&&t.T!=O.BYTES&&t.T!=O.STRING),void 0!==t.oneof){const n="string"==typeof t.oneof?t.oneof:t.oneof.name;u&&u.name==n||(u=new Be(n)),e.oneof=u,u.addField(e)}c.push(e)}return c}(e))),je=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,r=e;if(t.repeated)r[n]=[];else switch(t.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=L(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:z,makeWriteOptions:$,readMessage(e,t,n,r){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error("cannot decode message ".concat(e.typeName," from JSON: ").concat(te(t)));r=null!=r?r:new e;const i=new Map,a=n.typeRegistry;for(const s of Object.entries(t)){var o=R(s,2);const t=o[0],c=o[1],u=e.fields.findJsonName(t);if(u){if(u.oneof){if(null===c&&"scalar"==u.kind)continue;const n=i.get(u.oneof);if(void 0!==n)throw new Error("cannot decode message ".concat(e.typeName,' from JSON: multiple keys for oneof "').concat(u.oneof.name,'" present: "').concat(n,'", "').concat(t,'"'));i.set(u.oneof,t)}ne(r,c,u,n,e)}else{let i=!1;if((null==a?void 0:a.findExtension)&&t.startsWith("[")&&t.endsWith("]")){const o=a.findExtension(t.substring(1,t.length-1));if(o&&o.extendee.typeName==e.typeName){i=!0;const e=R(x(o),2),t=e[0],a=e[1];ne(t,c,o.field,n,o),J(r,o,a(),n)}}if(!i&&!n.ignoreUnknownFields)throw new Error("cannot decode message ".concat(e.typeName,' from JSON: key "').concat(t,'" is unknown'))}}return r},writeMessage(e,t){const n=e.getType(),r={};let i;try{for(i of n.fields.byNumber()){if(!q(i,e)){if(i.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!oe(i))continue}const n=se(i,i.oneof?e[i.oneof.localName].value:e[i.localName],t);void 0!==n&&(r[t.useProtoFieldName?i.name:i.jsonName]=n)}const a=t.typeRegistry;if(null==a?void 0:a.findExtensionFor)for(const i of n.runtime.bin.listUnknownFields(e)){const o=a.findExtensionFor(n.typeName,i.no);if(o&&G(e,o)){const n=_(e,o,t),i=se(o.field,n,t);void 0!==i&&(r[o.field.jsonName]=i)}}}catch(e){const t=i?"cannot encode field ".concat(n.typeName,".").concat(i.name," to JSON"):"cannot encode message ".concat(n.typeName," to JSON"),r=e instanceof Error?e.message:String(e);throw new Error(t+(r.length>0?": ".concat(r):""))}return r},readScalar:(e,t,n)=>ie(e,t,null!=n?n:C.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||F(e,t)?ue(e,t):void 0},debug:te},bin:{makeReadOptions:he,makeWriteOptions:pe,listUnknownFields(e){var t;return null!==(t=e[le])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[le]},writeUnknownFields(e,t){const n=e[le];if(n)for(const e of n)t.tag(e.no,e.wireType).raw(e.data)},onUnknownField(e,t,n,r){const i=e;Array.isArray(i[le])||(i[le]=[]),i[le].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,i){const a=e.getType(),o=i?t.len:t.pos+n;let s,c;for(;t.pos<o;){var u=R(t.tag(),2);if(s=u[0],c=u[1],!0===i&&c==A.EndGroup)break;const n=a.fields.find(s);if(n)me(e,t,n,c,r);else{const n=t.skip(c,s);r.readUnknownFields&&this.onUnknownField(e,s,c,n)}}if(i&&(c!=A.EndGroup||s!==n))throw new Error("invalid end group tag")},readField:me,writeMessage(e,t,n){const r=e.getType();for(const i of r.fields.byNumber())if(q(i,e))ve(i,i.oneof?e[i.oneof.localName].value:e[i.localName],t,n);else if(i.req)throw new Error("cannot encode field ".concat(r.typeName,".").concat(i.name," to binary: required field not set"));return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,r){void 0!==t&&ve(e,t,n,r)}},util:Object.assign(Object.assign({},{setEnumType:d,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const i of n.fields.byMember()){const n=i.localName,a=t,o=e;if(null!=o[n])switch(i.kind){case"oneof":const e=o[n].case;if(void 0===e)continue;const t=i.findField(e);let s=o[n].value;t&&"message"==t.kind&&!H(s,t.T)?s=new t.T(s):t&&"scalar"===t.kind&&t.T===O.BYTES&&(s=Ne(s)),a[n]={case:e,value:s};break;case"scalar":case"enum":let c=o[n];i.T===O.BYTES&&(c=i.repeated?c.map(Ne):Ne(c)),a[n]=c;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===O.BYTES)for(const e of Object.entries(o[n])){var r=R(e,2);const t=r[0],i=r[1];a[n][t]=Ne(i)}else Object.assign(a[n],o[n]);break;case"message":const e=i.V.T;for(const t of Object.keys(o[n])){let r=o[n][t];e.fieldWrapper||(r=new e(r)),a[n][t]=r}}break;case"message":const u=i.T;if(i.repeated)a[n]=o[n].map((e=>H(e,u)?e:new u(e)));else{const e=o[n];u.fieldWrapper?"google.protobuf.BytesValue"===u.typeName?a[n]=Ne(e):a[n]=e:a[n]=H(e,u)?e:new u(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const r=t[e.localName],i=n[e.localName];if(e.repeated){if(r.length!==i.length)return!1;switch(e.kind){case"message":return r.every(((t,n)=>e.T.equals(t,i[n])));case"scalar":return r.every(((t,n)=>U(e.T,t,i[n])));case"enum":return r.every(((e,t)=>U(O.INT32,e,i[t])))}throw new Error("repeated cannot contain ".concat(e.kind))}switch(e.kind){case"message":let t=r,n=i;return e.T.fieldWrapper&&(void 0===t||H(t)||(t=e.T.fieldWrapper.wrapField(t)),void 0===n||H(n)||(n=e.T.fieldWrapper.wrapField(n))),e.T.equals(t,n);case"enum":return U(O.INT32,r,i);case"scalar":return U(e.T,r,i);case"oneof":if(r.case!==i.case)return!1;const a=e.findField(r.case);if(void 0===a)return!0;switch(a.kind){case"message":return a.T.equals(r.value,i.value);case"enum":return U(O.INT32,r.value,i.value);case"scalar":return U(a.T,r.value,i.value)}throw new Error("oneof cannot contain ".concat(a.kind));case"map":const o=Object.keys(r).concat(Object.keys(i));switch(e.V.kind){case"message":const t=e.V.T;return o.every((e=>t.equals(r[e],i[e])));case"enum":return o.every((e=>U(O.INT32,r[e],i[e])));case"scalar":const n=e.V.T;return o.every((e=>U(n,r[e],i[e])))}}})),clone(e){const t=e.getType(),n=new t,r=n;for(const n of t.fields.byMember()){const t=e[n.localName];let a;if(n.repeated)a=t.map(Ee);else if("map"==n.kind){a=r[n.localName];for(const e of Object.entries(t)){var i=R(e,2);const t=i[0],n=i[1];a[t]=Ee(n)}}else a="oneof"==n.kind?n.findField(t.case)?{case:t.case,value:Ee(t.value)}:{case:void 0}:Ee(t);r[n.localName]=a}for(const n of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,n.no,n.wireType,n.data);return n}}),{newFieldList:xe,initFields:je}),makeMessageType(e,t,n){return function(e,t,n,r){var i;const a=null!==(i=null==r?void 0:r.localName)&&void 0!==i?i:t.substring(t.lastIndexOf(".")+1),o={[a]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[a];return Object.setPrototypeOf(o.prototype,new m),Object.assign(o,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new o).fromBinary(e,t),fromJson:(e,t)=>(new o).fromJson(e,t),fromJsonString:(e,t)=>(new o).fromJsonString(e,t),equals:(t,n)=>e.util.equals(o,t,n)}),o}(this,e,t,n)},makeEnum:h,makeEnumType:f,getEnumType:l,makeExtension(e,t,n){return function(e,t,n,r){let i;return{typeName:t,extendee:n,get field(){if(!i){const n="function"==typeof r?r():r;n.name=t.split(".").pop(),n.jsonName="[".concat(t,"]"),i=e.util.newFieldList([n]).list()[0]}return i},runtime:e}}(this,e,t,n)}});var xe,je;const Me=Pe.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),Ve=Pe.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),_e=Pe.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]);function Je(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}var Ge,Xe;"function"==typeof SuppressedError&&SuppressedError;class qe extends(Xe=Promise){constructor(e){super(e)}catch(e){return super.catch(e)}static reject(e){return super.reject(e)}static all(e){return super.all(e)}static race(e){return super.race(e)}}Ge=qe,qe.resolve=e=>Reflect.get(Xe,"resolve",Ge).call(Ge,e);const We=/version\/(\d+(\.?_?\d+)+)/i;let He;function Ye(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("undefined"==typeof navigator)return;const n=navigator.userAgent.toLowerCase();if(void 0===He||t){const e=Ke.find((e=>e.test.test(n)));He=null==e?void 0:e.describe(n)}return He}const Ke=[{test:/firefox|iceweasel|fxios/i,describe:e=>({name:"Firefox",version:Qe(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:ze(e)})},{test:/chrom|crios|crmo/i,describe:e=>({name:"Chrome",version:Qe(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes("crios")?"iOS":void 0,osVersion:ze(e)})},{test:/safari|applewebkit/i,describe:e=>({name:"Safari",version:Qe(We,e),os:e.includes("mobile/")?"iOS":"macOS",osVersion:ze(e)})}];function Qe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const r=t.match(e);return r&&r.length>=n&&r[n]||""}function ze(e){return e.includes("mac os")?Qe(/\(.+?(\d+_\d+(:?_\d+)?)/,e,1).replace(/_/g,"."):void 0}var $e,Ze,et;!function(e){e[e.NotAllowed=0]="NotAllowed",e[e.ServerUnreachable=1]="ServerUnreachable",e[e.InternalError=2]="InternalError",e[e.Cancelled=3]="Cancelled",e[e.LeaveRequest=4]="LeaveRequest",e[e.Timeout=5]="Timeout",e[e.WebSocket=6]="WebSocket",e[e.ServiceNotFound=7]="ServiceNotFound"}($e||($e={})),function(e){e[e.AlreadyOpened=0]="AlreadyOpened",e[e.AbnormalEnd=1]="AbnormalEnd",e[e.DecodeFailed=2]="DecodeFailed",e[e.LengthExceeded=3]="LengthExceeded",e[e.Incomplete=4]="Incomplete",e[e.HandlerAlreadyRegistered=7]="HandlerAlreadyRegistered",e[e.EncryptionTypeMismatch=8]="EncryptionTypeMismatch"}(Ze||(Ze={})),function(e){e.PermissionDenied="PermissionDenied",e.NotFound="NotFound",e.DeviceInUse="DeviceInUse",e.Other="Other"}(et||(et={})),function(e){e.getFailure=function(t){if(t&&"name"in t)return"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?e.NotFound:"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?e.PermissionDenied:"NotReadableError"===t.name||"TrackStartError"===t.name?e.DeviceInUse:e.Other}}(et||(et={}));var tt,nt={exports:{}};var rt,it=function(){if(tt)return nt.exports;tt=1;var e,t="object"==typeof Reflect?Reflect:null,n=t&&"function"==typeof t.apply?t.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}nt.exports=i,nt.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}p(e,t,a,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&p(e,"error",t,n)}(e,i,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function o(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function s(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,a,c,u;if(o(n),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),c=a[t]),void 0===c)c=a[t]=n,++e._eventsCount;else if("function"==typeof c?c=a[t]=r?[n,c]:[c,n]:r?c.unshift(n):c.push(n),(i=s(e))>0&&c.length>i&&!c.warned){c.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=c.length,u=l,console&&console.warn&&console.warn(u)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=u.bind(r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):h(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function h(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function p(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(a){r.once&&e.removeEventListener(t,i),n(a)}))}}return Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var c=a[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=h(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return o(t),this.on(e,l(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return o(t),this.prependListener(e,l(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,r,i,a,s;if(o(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){s=n[a].listener,i=a;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,a=Object.keys(n);for(r=0;r<a.length;++r)"removeListener"!==(i=a[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},nt.exports}(),at={exports:{}};var ot,st,ct,ut,lt,dt=(rt||(rt=1,st=at.exports,ct=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],i={},a=null;function o(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(){for(var n=this.getLevel(),i=0;i<r.length;i++){var a=r[i];this[a]=i<n?e:this.methodFactory(a,n,this.name)}if(this.log=this.debug,typeof console===t&&n<this.levels.SILENT)return"No console available for logging"}function u(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function l(r,i,a){return function(r){return"debug"===r&&(r="log"),typeof console!==t&&("trace"===r&&n?s:void 0!==console[r]?o(console,r):void 0!==console.log?o(console,"log"):e)}(r)||u.apply(this,arguments)}function d(e,n){var o,s,u,d=this,f="loglevel";function h(){var e;if(typeof window!==t&&f){try{e=window.localStorage[f]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,r=encodeURIComponent(f),i=n.indexOf(r+"=");-1!==i&&(e=/^([^;]+)/.exec(n.slice(i+r.length+1))[1])}catch(e){}return void 0===d.levels[e]&&(e=void 0),e}}function p(e){var t=e;if("string"==typeof t&&void 0!==d.levels[t.toUpperCase()]&&(t=d.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=d.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?f+=":"+e:"symbol"==typeof e&&(f=void 0),d.name=e,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=n||l,d.getLevel=function(){return null!=u?u:null!=s?s:o},d.setLevel=function(e,n){return u=p(e),!1!==n&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t&&f){try{return void(window.localStorage[f]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"="+n+";"}catch(e){}}}(u),c.call(d)},d.setDefaultLevel=function(e){s=p(e),h()||d.setLevel(e,!1)},d.resetLevel=function(){u=null,function(){if(typeof window!==t&&f){try{window.localStorage.removeItem(f)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),c.call(d)},d.enableAll=function(e){d.setLevel(d.levels.TRACE,e)},d.disableAll=function(e){d.setLevel(d.levels.SILENT,e)},d.rebuild=function(){if(a!==d&&(o=p(a.getLevel())),c.call(d),a===d)for(var e in i)i[e].rebuild()},o=p(a?a.getLevel():"WARN");var m=h();null!=m&&(u=p(m)),c.call(d)}(a=new d).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=i[e];return t||(t=i[e]=new d(e,a.methodFactory)),t};var f=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=f),a},a.getLoggers=function(){return i},a.default=a,a},(ot=at).exports?ot.exports=ct():st.log=ct()),at.exports);!function(e){e[e.trace=0]="trace",e[e.debug=1]="debug",e[e.info=2]="info",e[e.warn=3]="warn",e[e.error=4]="error",e[e.silent=5]="silent"}(ut||(ut={})),function(e){e.Default="livekit",e.Room="livekit-room",e.TokenSource="livekit-token-source",e.Participant="livekit-participant",e.Track="livekit-track",e.Publication="livekit-track-publication",e.Engine="livekit-engine",e.Signal="livekit-signal",e.PCManager="livekit-pc-manager",e.PCTransport="livekit-pc-transport",e.E2EE="lk-e2ee",e.DataTracks="livekit-data-tracks"}(lt||(lt={}));let ft=dt.getLogger(lt.Default);function ht(e,t){const n=dt.getLogger(e);return n.setDefaultLevel(ft.getLevel()),n}var pt,mt,gt,bt,yt,vt;Object.values(lt).map((e=>dt.getLogger(e))),ft.setDefaultLevel(ut.info),dt.getLogger(lt.E2EE),function(e){e.Connected="connected",e.Reconnecting="reconnecting",e.SignalReconnecting="signalReconnecting",e.Reconnected="reconnected",e.Disconnected="disconnected",e.ConnectionStateChanged="connectionStateChanged",e.Moved="moved",e.MediaDevicesChanged="mediaDevicesChanged",e.ParticipantConnected="participantConnected",e.ParticipantDisconnected="participantDisconnected",e.TrackPublished="trackPublished",e.TrackSubscribed="trackSubscribed",e.TrackSubscriptionFailed="trackSubscriptionFailed",e.TrackUnpublished="trackUnpublished",e.TrackUnsubscribed="trackUnsubscribed",e.TrackMuted="trackMuted",e.TrackUnmuted="trackUnmuted",e.LocalTrackPublished="localTrackPublished",e.LocalTrackUnpublished="localTrackUnpublished",e.LocalAudioSilenceDetected="localAudioSilenceDetected",e.ActiveSpeakersChanged="activeSpeakersChanged",e.ParticipantMetadataChanged="participantMetadataChanged",e.ParticipantNameChanged="participantNameChanged",e.ParticipantAttributesChanged="participantAttributesChanged",e.ParticipantActive="participantActive",e.RoomMetadataChanged="roomMetadataChanged",e.DataReceived="dataReceived",e.SipDTMFReceived="sipDTMFReceived",e.TranscriptionReceived="transcriptionReceived",e.ConnectionQualityChanged="connectionQualityChanged",e.TrackStreamStateChanged="trackStreamStateChanged",e.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",e.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",e.AudioPlaybackStatusChanged="audioPlaybackChanged",e.VideoPlaybackStatusChanged="videoPlaybackChanged",e.MediaDevicesError="mediaDevicesError",e.ParticipantPermissionsChanged="participantPermissionsChanged",e.SignalConnected="signalConnected",e.RecordingStatusChanged="recordingStatusChanged",e.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",e.EncryptionError="encryptionError",e.DCBufferStatusChanged="dcBufferStatusChanged",e.ActiveDeviceChanged="activeDeviceChanged",e.ChatMessage="chatMessage",e.LocalTrackSubscribed="localTrackSubscribed",e.MetricsReceived="metricsReceived",e.DataTrackPublished="dataTrackPublished",e.DataTrackUnpublished="dataTrackUnpublished",e.LocalDataTrackPublished="localDataTrackPublished",e.LocalDataTrackUnpublished="localDataTrackUnpublished"}(pt||(pt={})),function(e){e.TrackPublished="trackPublished",e.TrackSubscribed="trackSubscribed",e.TrackSubscriptionFailed="trackSubscriptionFailed",e.TrackUnpublished="trackUnpublished",e.TrackUnsubscribed="trackUnsubscribed",e.TrackMuted="trackMuted",e.TrackUnmuted="trackUnmuted",e.LocalTrackPublished="localTrackPublished",e.LocalTrackUnpublished="localTrackUnpublished",e.LocalTrackCpuConstrained="localTrackCpuConstrained",e.LocalSenderCreated="localSenderCreated",e.ParticipantMetadataChanged="participantMetadataChanged",e.ParticipantNameChanged="participantNameChanged",e.DataReceived="dataReceived",e.SipDTMFReceived="sipDTMFReceived",e.TranscriptionReceived="transcriptionReceived",e.IsSpeakingChanged="isSpeakingChanged",e.ConnectionQualityChanged="connectionQualityChanged",e.TrackStreamStateChanged="trackStreamStateChanged",e.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",e.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",e.TrackCpuConstrained="trackCpuConstrained",e.MediaDevicesError="mediaDevicesError",e.AudioStreamAcquired="audioStreamAcquired",e.ParticipantPermissionsChanged="participantPermissionsChanged",e.PCTrackAdded="pcTrackAdded",e.AttributesChanged="attributesChanged",e.LocalTrackSubscribed="localTrackSubscribed",e.ChatMessage="chatMessage",e.Active="active"}(mt||(mt={})),function(e){e.TransportsCreated="transportsCreated",e.Connected="connected",e.Disconnected="disconnected",e.Resuming="resuming",e.Resumed="resumed",e.Restarting="restarting",e.Restarted="restarted",e.SignalResumed="signalResumed",e.SignalRestarted="signalRestarted",e.Closing="closing",e.MediaTrackAdded="mediaTrackAdded",e.ActiveSpeakersUpdate="activeSpeakersUpdate",e.DataPacketReceived="dataPacketReceived",e.RTPVideoMapUpdate="rtpVideoMapUpdate",e.DCBufferStatusChanged="dcBufferStatusChanged",e.ParticipantUpdate="participantUpdate",e.RoomUpdate="roomUpdate",e.SpeakersChanged="speakersChanged",e.StreamStateChanged="streamStateChanged",e.ConnectionQualityUpdate="connectionQualityUpdate",e.SubscriptionError="subscriptionError",e.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",e.RemoteMute="remoteMute",e.SubscribedQualityUpdate="subscribedQualityUpdate",e.LocalTrackUnpublished="localTrackUnpublished",e.LocalTrackSubscribed="localTrackSubscribed",e.Offline="offline",e.SignalRequestResponse="signalRequestResponse",e.SignalConnected="signalConnected",e.RoomMoved="roomMoved",e.PublishDataTrackResponse="publishDataTrackResponse",e.UnPublishDataTrackResponse="unPublishDataTrackResponse",e.DataTrackSubscriberHandles="dataTrackSubscriberHandles",e.DataTrackPacketReceived="dataTrackPacketReceived",e.Joined="joined",e.TokenRefreshed="tokenRefreshed",e.ServerRegionsReported="serverRegionsReported"}(gt||(gt={})),function(e){e.Message="message",e.Muted="muted",e.Unmuted="unmuted",e.Restarted="restarted",e.Ended="ended",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed",e.CpuConstrained="cpuConstrained",e.UpdateSettings="updateSettings",e.UpdateSubscription="updateSubscription",e.AudioPlaybackStarted="audioPlaybackStarted",e.AudioPlaybackFailed="audioPlaybackFailed",e.AudioSilenceDetected="audioSilenceDetected",e.VisibilityChanged="visibilityChanged",e.VideoDimensionsChanged="videoDimensionsChanged",e.VideoPlaybackStarted="videoPlaybackStarted",e.VideoPlaybackFailed="videoPlaybackFailed",e.ElementAttached="elementAttached",e.ElementDetached="elementDetached",e.UpstreamPaused="upstreamPaused",e.UpstreamResumed="upstreamResumed",e.SubscriptionPermissionChanged="subscriptionPermissionChanged",e.SubscriptionStatusChanged="subscriptionStatusChanged",e.SubscriptionFailed="subscriptionFailed",e.TrackProcessorUpdate="trackProcessorUpdate",e.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",e.TranscriptionReceived="transcriptionReceived",e.TimeSyncUpdate="timeSyncUpdate",e.PreConnectBufferFlushed="preConnectBufferFlushed"}(bt||(bt={}));class kt{constructor(e,t,n,r,i){if("object"==typeof e)this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else{if(void 0===t||void 0===n)throw new TypeError("Unsupported options: provide at least width, height and maxBitrate");this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:n,maxFramerate:r,priority:i}}}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}function wt(e){return"mediaStreamTrack"in e?{trackID:e.sid,source:e.source,muted:e.isMuted,enabled:e.mediaStreamTrack.enabled,kind:e.kind,streamID:e.mediaStreamID,streamTrackID:e.mediaStreamTrack.id}:{trackID:e.trackSid,enabled:e.isEnabled,muted:e.isMuted,trackInfo:Object.assign({mimeType:e.mimeType,name:e.trackName,encrypted:e.isEncrypted,kind:e.kind,source:e.source},e.track?wt(e.track):{})}}!function(e){e[e.PREFER_REGRESSION=0]="PREFER_REGRESSION",e[e.SIMULCAST=1]="SIMULCAST",e[e.REGRESSION=2]="REGRESSION"}(yt||(yt={})),function(e){e.telephone={maxBitrate:12e3},e.speech={maxBitrate:24e3},e.music={maxBitrate:48e3},e.musicStereo={maxBitrate:64e3},e.musicHighQuality={maxBitrate:96e3},e.musicHighQualityStereo={maxBitrate:128e3}}(vt||(vt={})),new kt(160,90,9e4,20),new kt(320,180,16e4,20),new kt(384,216,18e4,20),new kt(640,360,45e4,20),new kt(960,540,8e5,25),new kt(1280,720,17e5,30),new kt(1920,1080,3e6,30),new kt(2560,1440,5e6,30),new kt(3840,2160,8e6,30),new kt(160,120,7e4,20),new kt(240,180,125e3,20),new kt(320,240,14e4,20),new kt(480,360,33e4,20),new kt(640,480,5e5,20),new kt(720,540,6e5,25),new kt(960,720,13e5,30),new kt(1440,1080,23e5,30),new kt(1920,1440,38e5,30),new kt(640,360,2e5,3,"medium"),new kt(640,360,4e5,15,"medium"),new kt(1280,720,8e5,5,"medium"),new kt(1280,720,15e5,15,"medium"),new kt(1280,720,2e6,30,"medium"),new kt(1920,1080,25e5,15,"medium"),new kt(1920,1080,5e6,30,"medium"),new kt(0,0,7e6,30,"medium");const Tt=[];var St;!function(e){e[e.LOW=0]="LOW",e[e.MEDIUM=1]="MEDIUM",e[e.HIGH=2]="HIGH"}(St||(St={}));class Et extends it.EventEmitter{get streamState(){return this._streamState}setStreamState(e){this._streamState=e}constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r;super(),this.attachedElements=[],this.isMuted=!1,this._streamState=Et.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=ft,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),"hidden"===document.visibilityState?this.backgroundTimeout=setTimeout((()=>this.handleAppVisibilityChanged()),5e3):this.handleAppVisibilityChanged()},this.log=ht(null!==(r=n.loggerName)&&void 0!==r?r:lt.Track),this.loggerContextCb=n.loggerContextCb,this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=Et.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this)),wt(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let t="audio";this.kind===Et.Kind.Video&&(t="video"),0===this.attachedElements.length&&this.kind===Et.Kind.Video&&this.addAppVisibilityListener(),e||("audio"===t&&(Tt.forEach((t=>{null!==t.parentElement||e||(e=t)})),e&&Tt.splice(Tt.indexOf(e),1)),e||(e=document.createElement(t))),this.attachedElements.includes(e)||this.attachedElements.push(e),function(e,t){let n,r;n=t.srcObject instanceof MediaStream?t.srcObject:new MediaStream;r="audio"===e.kind?n.getAudioTracks():n.getVideoTracks();r.includes(e)||(r.forEach((e=>{n.removeTrack(e)})),n.addTrack(e));It()&&t instanceof HTMLVideoElement||(t.autoplay=!0);t.muted=0===n.getAudioTracks().length,t instanceof HTMLVideoElement&&(t.playsInline=!0);t.srcObject!==n&&(t.srcObject=n,(It()||function(){var e;return"Firefox"===(null===(e=Ye())||void 0===e?void 0:e.name)}())&&t instanceof HTMLVideoElement&&setTimeout((()=>{t.srcObject=n,t.play().catch((()=>{}))}),0))}(this.mediaStreamTrack,e);const n=e.srcObject.getTracks(),r=n.some((e=>"audio"===e.kind));return e.play().then((()=>{this.emit(r?bt.AudioPlaybackStarted:bt.VideoPlaybackStarted)})).catch((t=>{"NotAllowedError"===t.name?this.emit(r?bt.AudioPlaybackFailed:bt.VideoPlaybackFailed,t):"AbortError"===t.name?ft.debug("".concat(r?"audio":"video"," playback aborted, likely due to new play request")):ft.warn("could not playback ".concat(r?"audio":"video"),t),r&&e&&n.some((e=>"video"===e.kind))&&"NotAllowedError"===t.name&&(e.muted=!0,e.play().catch((()=>{})))})),this.emit(bt.ElementAttached,e),e}detach(e){try{if(e){Nt(this.mediaStreamTrack,e);const t=this.attachedElements.indexOf(e);return t>=0&&(this.attachedElements.splice(t,1),this.recycleElement(e),this.emit(bt.ElementDetached,e)),e}const t=[];return this.attachedElements.forEach((e=>{Nt(this.mediaStreamTrack,e),t.push(e),this.recycleElement(e),this.emit(bt.ElementDetached,e)})),this.attachedElements=[],t}finally{0===this.attachedElements.length&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=ht(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),Tt.forEach((e=>{e.parentElement||(t=!1)})),t&&Tt.push(e)}}handleAppVisibilityChanged(){return Je(this,void 0,void 0,(function*(){this.isInBackground="hidden"===document.visibilityState,this.isInBackground||this.kind!==Et.Kind.Video||setTimeout((()=>this.attachedElements.forEach((e=>e.play().catch((()=>{}))))),0)}))}addAppVisibilityListener(){Ot()?(this.isInBackground="hidden"===document.visibilityState,document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Ot()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function Nt(e,t){if(t.srcObject instanceof MediaStream){const n=t.srcObject;n.removeTrack(e),n.getTracks().length>0?t.srcObject=n:t.srcObject=null}}function It(){var e;return"Safari"===(null===(e=Ye())||void 0===e?void 0:e.name)}function Ot(){return"undefined"!=typeof document}function Ct(e){return!(!(null==e?void 0:e.timestamp)&&!(null==e?void 0:e.frameId))}!function(e){let t,n,r;!function(e){e.Audio="audio",e.Video="video",e.Unknown="unknown"}(t=e.Kind||(e.Kind={})),function(e){e.Camera="camera",e.Microphone="microphone",e.ScreenShare="screen_share",e.ScreenShareAudio="screen_share_audio",e.Unknown="unknown"}(n=e.Source||(e.Source={})),function(e){e.Active="active",e.Paused="paused",e.Unknown="unknown"}(r=e.StreamState||(e.StreamState={})),e.kindToProto=function(e){switch(e){case t.Audio:return Me.AUDIO;case t.Video:return Me.VIDEO;default:return Me.DATA}},e.kindFromProto=function(e){switch(e){case Me.AUDIO:return t.Audio;case Me.VIDEO:return t.Video;default:return t.Unknown}},e.sourceToProto=function(e){switch(e){case n.Camera:return Ve.CAMERA;case n.Microphone:return Ve.MICROPHONE;case n.ScreenShare:return Ve.SCREEN_SHARE;case n.ScreenShareAudio:return Ve.SCREEN_SHARE_AUDIO;default:return Ve.UNKNOWN}},e.sourceFromProto=function(e){switch(e){case Ve.CAMERA:return n.Camera;case Ve.MICROPHONE:return n.Microphone;case Ve.SCREEN_SHARE:return n.ScreenShare;case Ve.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}},e.streamStateFromProto=function(e){switch(e){case _e.ACTIVE:return r.Active;case _e.PAUSED:return r.Paused;default:return r.Unknown}}}(Et||(Et={}));const At=Uint8Array.from(["L".charCodeAt(0),"K".charCodeAt(0),"T".charCodeAt(0),"S".charCodeAt(0)]),Ut=1,Lt=2,Ft=5,Dt=10,Rt=6;function Bt(e,t,n){const r=t!==BigInt(0),i=0!==n;if(!r&&!i)return e;const a=(r?Dt:0)+(i?Rt:0)+Ft,o=new Uint8Array(e.length+a);let s=0;return o.set(e,s),s+=e.length,r&&(o[s++]=255^Ut,o[s++]=247,function(e,t,n){const r=Number(n>>BigInt(32)&BigInt(4294967295)),i=Number(n&BigInt(4294967295));e[t]=r>>>24^255,e[t+1]=r>>>16&255^255,e[t+2]=r>>>8&255^255,e[t+3]=255&r^255,e[t+4]=i>>>24^255,e[t+5]=i>>>16&255^255,e[t+6]=i>>>8&255^255,e[t+7]=255&i^255}(o,s,t),s+=8),i&&(o[s++]=255^Lt,o[s++]=251,function(e,t,n){for(let r=3;r>=0;r-=1)e[t+(3-r)]=n>>8*r&255^255}(o,s,n),s+=4),o[s++]=255^a,o.set(At,s),o}function Pt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.length<Ft)return{data:t};if(!function(e,t){for(let n=0;n<At.length;n+=1)if(e[t+n]!==At[n])return!1;return!0}(t,t.length-At.length))return{data:t};const n=255^t[t.length-Ft];if(n<Ft||n>t.length)return{data:t};const r=t.length-n,i=t.length-Ft,a=t.subarray(0,r);let o=r,s=!1;const c={userTimestamp:BigInt(0),frameId:0};for(;o+2<=i;){const e=255^t[o++],n=255^t[o++];if(o+n>i)break;e===Ut&&8===n?(c.userTimestamp=xt(t,o),s=!0):e===Lt&&4===n&&(c.frameId=jt(t,o,n),s=!0),o+=n}return s?{data:a,metadata:c}:{data:t}}function xt(e,t){const n=BigInt(((255^e[t])<<24|(255^e[t+1])<<16|(255^e[t+2])<<8|255^e[t+3])>>>0),r=BigInt(((255^e[t+4])<<24|(255^e[t+5])<<16|(255^e[t+6])<<8|255^e[t+7])>>>0);return n<<BigInt(32)|r}function jt(e,t,n){let r=0;for(let i=0;i<n;i+=1)r=r<<8|255^e[t+i];return r>>>0}function Mt(e){try{const t=e.getMetadata();if("number"==typeof t.synchronizationSource)return t.synchronizationSource}catch(e){}return 0}const Vt=new Map;function _t(e,t,n,r){const i={trackId:n,hasPacketTrailer:r};Vt.set(n,i);const a=new TransformStream({transform(e,t){try{if(i.hasPacketTrailer){const t=function(e,t){if(0===e.data.byteLength)return{};const n=Pt(e.data);if(!n.metadata)return{};const r=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength),i=function(e){try{const t=e.getMetadata();if("number"==typeof t.rtpTimestamp)return t.rtpTimestamp;if("number"==typeof t.timestamp)return t.timestamp}catch(e){}if("number"==typeof e.timestamp)return e.timestamp}(e);return void 0!==i&&t?{data:r,payload:{trackId:t,rtpTimestamp:i,ssrc:Mt(e),metadata:n.metadata}}:{data:r}}(e,i.trackId);if(t.data&&(e.data=t.data),t.payload){const e={kind:"metadata",data:t.payload};postMessage(e)}}}catch(e){}t.enqueue(e)}});e.pipeThrough(a).pipeTo(t).catch((()=>{Vt.delete(i.trackId)}))}function Jt(e,t,n){if(!Ct(n))return void e.pipeTo(t).catch((()=>{}));let r=0;const i=new TransformStream({transform(e,t){try{(null==n?void 0:n.frameId)&&(r=4294967295===r?1:r+1),function(e,t,n){if(!Ct(t)||0===e.data.byteLength)return!1;const r=(null==t?void 0:t.timestamp)?BigInt(Date.now())*BigInt(1e3):BigInt(0),i=(null==t?void 0:t.frameId)?n:0,a=new Uint8Array(e.data),o=Bt(a,r,i);o.byteLength!==a.byteLength&&(e.data=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength))}(e,n,r)}catch(e){}t.enqueue(e)}});e.pipeThrough(i).pipeTo(t).catch((()=>{}))}onmessage=e=>{const t=e.data;switch(t.kind){case"init":postMessage({kind:"initAck"});break;case"decode":_t(t.data.readableStream,t.data.writableStream,t.data.trackId,t.data.hasPacketTrailer);break;case"encode":Jt(t.data.readableStream,t.data.writableStream,t.data.packetTrailer);break;case"updateTrackId":!function(e,t,n){const r=Vt.get(e);r&&(r.trackId=t,r.hasPacketTrailer=n,Vt.delete(e),Vt.set(t,r))}(t.data.oldTrackId,t.data.newTrackId,t.data.hasPacketTrailer)}},self.RTCTransformEvent&&(self.onrtctransform=e=>{const t=e.transformer,n=t.options;"encode"===n.kind?Jt(t.readable,t.writable,n.packetTrailer):_t(t.readable,t.writable,n.trackId,!0)})}));
|
|
2
|
-
//# sourceMappingURL=livekit-client.pt.worker.js.map
|