@rqmii_immersive/agent-react-sdk 5.6.5 → 5.6.6

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.
Files changed (45) hide show
  1. package/dist/Orb-B1DErA0O.cjs +4517 -0
  2. package/dist/Orb-B1DErA0O.cjs.map +1 -0
  3. package/dist/RqmiiAgentChat-C0ymqkkq.cjs +2 -0
  4. package/dist/RqmiiAgentChat-C0ymqkkq.cjs.map +1 -0
  5. package/dist/RqmiiCloudAvatarPlayer-CmovoCKk.cjs +2918 -0
  6. package/dist/RqmiiCloudAvatarPlayer-CmovoCKk.cjs.map +1 -0
  7. package/dist/RqmiiErrorBoundary-Byif85f5.cjs +2 -0
  8. package/dist/RqmiiErrorBoundary-Byif85f5.cjs.map +1 -0
  9. package/dist/embed/chunks/Orb-CBt2svdc.js +40903 -0
  10. package/dist/embed/chunks/Orb-CBt2svdc.js.map +1 -0
  11. package/dist/embed/chunks/RqmiiCloudAvatarPlayer-DpvI9bmI.js +3357 -0
  12. package/dist/embed/chunks/RqmiiCloudAvatarPlayer-DpvI9bmI.js.map +1 -0
  13. package/dist/embed/chunks/chat-box-avatar-DlUI3fDi.js +10 -0
  14. package/dist/embed/chunks/chat-box-avatar-DlUI3fDi.js.map +1 -0
  15. package/dist/embed/chunks/chat-box-text-and-voice-BgdFP0_P.js +112 -0
  16. package/dist/embed/chunks/chat-box-text-and-voice-BgdFP0_P.js.map +1 -0
  17. package/dist/embed/chunks/chat-box-voice-D0gPyOVt.js +74 -0
  18. package/dist/embed/chunks/chat-box-voice-D0gPyOVt.js.map +1 -0
  19. package/dist/embed/chunks/embed-core-B3d4u3wf.js +12623 -0
  20. package/dist/embed/chunks/embed-core-B3d4u3wf.js.map +1 -0
  21. package/dist/embed/chunks/highlighted-body-KPVGNVTW-CJl4AHHd.js +19 -0
  22. package/dist/embed/chunks/highlighted-body-KPVGNVTW-CJl4AHHd.js.map +1 -0
  23. package/dist/embed/chunks/mermaid-HWGCJPDP-DD9SRoUR.js +22773 -0
  24. package/dist/embed/chunks/mermaid-HWGCJPDP-DD9SRoUR.js.map +1 -0
  25. package/dist/embed/chunks/use-rqmii-vad-COqAsQsT.js +10225 -0
  26. package/dist/embed/chunks/use-rqmii-vad-COqAsQsT.js.map +1 -0
  27. package/dist/embed/core.js +6 -0
  28. package/dist/embed/core.js.map +1 -0
  29. package/dist/embed.js +2 -0
  30. package/dist/embed.js.map +1 -0
  31. package/dist/highlighted-body-KPVGNVTW-CSL27xRm.cjs +2 -0
  32. package/dist/highlighted-body-KPVGNVTW-CSL27xRm.cjs.map +1 -0
  33. package/dist/index.cjs +50 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/lazy.cjs +2 -0
  36. package/dist/lazy.cjs.map +1 -0
  37. package/dist/mermaid-HWGCJPDP-CssnmrD3.cjs +2 -0
  38. package/dist/mermaid-HWGCJPDP-CssnmrD3.cjs.map +1 -0
  39. package/dist/schedule-load-DbAlv7OH.cjs +2 -0
  40. package/dist/schedule-load-DbAlv7OH.cjs.map +1 -0
  41. package/dist/ui-1UzY5QCI.cjs +251 -0
  42. package/dist/ui-1UzY5QCI.cjs.map +1 -0
  43. package/dist/ui.cjs +2 -0
  44. package/dist/ui.cjs.map +1 -0
  45. package/package.json +1 -1
@@ -0,0 +1,3357 @@
1
+ import { r as G, j as O, C as W } from "./embed-core-B3d4u3wf.js";
2
+ import { b as dt } from "./mermaid-HWGCJPDP-DD9SRoUR.js";
3
+ var Y = { exports: {} }, le;
4
+ function ct() {
5
+ return le || (le = 1, (function(a) {
6
+ const e = {};
7
+ e.generateIdentifier = function() {
8
+ return Math.random().toString(36).substring(2, 12);
9
+ }, e.localCName = e.generateIdentifier(), e.splitLines = function(t) {
10
+ return t.trim().split(`
11
+ `).map((s) => s.trim());
12
+ }, e.splitSections = function(t) {
13
+ return t.split(`
14
+ m=`).map((n, i) => (i > 0 ? "m=" + n : n).trim() + `\r
15
+ `);
16
+ }, e.getDescription = function(t) {
17
+ const s = e.splitSections(t);
18
+ return s && s[0];
19
+ }, e.getMediaSections = function(t) {
20
+ const s = e.splitSections(t);
21
+ return s.shift(), s;
22
+ }, e.matchPrefix = function(t, s) {
23
+ return e.splitLines(t).filter((n) => n.indexOf(s) === 0);
24
+ }, e.parseCandidate = function(t) {
25
+ let s;
26
+ t.indexOf("a=candidate:") === 0 ? s = t.substring(12).split(" ") : s = t.substring(10).split(" ");
27
+ const n = {
28
+ foundation: s[0],
29
+ component: { 1: "rtp", 2: "rtcp" }[s[1]] || s[1],
30
+ protocol: s[2].toLowerCase(),
31
+ priority: parseInt(s[3], 10),
32
+ ip: s[4],
33
+ address: s[4],
34
+ // address is an alias for ip.
35
+ port: parseInt(s[5], 10),
36
+ // skip parts[6] == 'typ'
37
+ type: s[7]
38
+ };
39
+ for (let i = 8; i < s.length; i += 2)
40
+ switch (s[i]) {
41
+ case "raddr":
42
+ n.relatedAddress = s[i + 1];
43
+ break;
44
+ case "rport":
45
+ n.relatedPort = parseInt(s[i + 1], 10);
46
+ break;
47
+ case "tcptype":
48
+ n.tcpType = s[i + 1];
49
+ break;
50
+ case "ufrag":
51
+ n.ufrag = s[i + 1], n.usernameFragment = s[i + 1];
52
+ break;
53
+ default:
54
+ n[s[i]] === void 0 && (n[s[i]] = s[i + 1]);
55
+ break;
56
+ }
57
+ return n;
58
+ }, e.writeCandidate = function(t) {
59
+ const s = [];
60
+ s.push(t.foundation);
61
+ const n = t.component;
62
+ n === "rtp" ? s.push(1) : n === "rtcp" ? s.push(2) : s.push(n), s.push(t.protocol.toUpperCase()), s.push(t.priority), s.push(t.address || t.ip), s.push(t.port);
63
+ const i = t.type;
64
+ return s.push("typ"), s.push(i), i !== "host" && t.relatedAddress && t.relatedPort !== void 0 && (s.push("raddr"), s.push(t.relatedAddress), s.push("rport"), s.push(t.relatedPort)), t.tcpType && t.protocol.toLowerCase() === "tcp" && (s.push("tcptype"), s.push(t.tcpType)), (t.usernameFragment || t.ufrag) && (s.push("ufrag"), s.push(t.usernameFragment || t.ufrag)), "candidate:" + s.join(" ");
65
+ }, e.parseIceOptions = function(t) {
66
+ return t.substring(14).split(" ");
67
+ }, e.parseRtpMap = function(t) {
68
+ let s = t.substring(9).split(" ");
69
+ const n = {
70
+ payloadType: parseInt(s.shift(), 10)
71
+ // was: id
72
+ };
73
+ return s = s[0].split("/"), n.name = s[0], n.clockRate = parseInt(s[1], 10), n.channels = s.length === 3 ? parseInt(s[2], 10) : 1, n.numChannels = n.channels, n;
74
+ }, e.writeRtpMap = function(t) {
75
+ let s = t.payloadType;
76
+ t.preferredPayloadType !== void 0 && (s = t.preferredPayloadType);
77
+ const n = t.channels || t.numChannels || 1;
78
+ return "a=rtpmap:" + s + " " + t.name + "/" + t.clockRate + (n !== 1 ? "/" + n : "") + `\r
79
+ `;
80
+ }, e.parseExtmap = function(t) {
81
+ const s = t.substring(9).split(" ");
82
+ return {
83
+ id: parseInt(s[0], 10),
84
+ direction: s[0].indexOf("/") > 0 ? s[0].split("/")[1] : "sendrecv",
85
+ uri: s[1],
86
+ attributes: s.slice(2).join(" ")
87
+ };
88
+ }, e.writeExtmap = function(t) {
89
+ return "a=extmap:" + (t.id || t.preferredId) + (t.direction && t.direction !== "sendrecv" ? "/" + t.direction : "") + " " + t.uri + (t.attributes ? " " + t.attributes : "") + `\r
90
+ `;
91
+ }, e.parseFmtp = function(t) {
92
+ const s = {};
93
+ let n;
94
+ const i = t.substring(t.indexOf(" ") + 1).split(";");
95
+ for (let o = 0; o < i.length; o++)
96
+ n = i[o].trim().split("="), s[n[0].trim()] = n[1];
97
+ return s;
98
+ }, e.writeFmtp = function(t) {
99
+ let s = "", n = t.payloadType;
100
+ if (t.preferredPayloadType !== void 0 && (n = t.preferredPayloadType), t.parameters && Object.keys(t.parameters).length) {
101
+ const i = [];
102
+ Object.keys(t.parameters).forEach((o) => {
103
+ t.parameters[o] !== void 0 ? i.push(o + "=" + t.parameters[o]) : i.push(o);
104
+ }), s += "a=fmtp:" + n + " " + i.join(";") + `\r
105
+ `;
106
+ }
107
+ return s;
108
+ }, e.parseRtcpFb = function(t) {
109
+ const s = t.substring(t.indexOf(" ") + 1).split(" ");
110
+ return {
111
+ type: s.shift(),
112
+ parameter: s.join(" ")
113
+ };
114
+ }, e.writeRtcpFb = function(t) {
115
+ let s = "", n = t.payloadType;
116
+ return t.preferredPayloadType !== void 0 && (n = t.preferredPayloadType), t.rtcpFeedback && t.rtcpFeedback.length && t.rtcpFeedback.forEach((i) => {
117
+ s += "a=rtcp-fb:" + n + " " + i.type + (i.parameter && i.parameter.length ? " " + i.parameter : "") + `\r
118
+ `;
119
+ }), s;
120
+ }, e.parseSsrcMedia = function(t) {
121
+ const s = t.indexOf(" "), n = {
122
+ ssrc: parseInt(t.substring(7, s), 10)
123
+ }, i = t.indexOf(":", s);
124
+ return i > -1 ? (n.attribute = t.substring(s + 1, i), n.value = t.substring(i + 1)) : n.attribute = t.substring(s + 1), n;
125
+ }, e.parseSsrcGroup = function(t) {
126
+ const s = t.substring(13).split(" ");
127
+ return {
128
+ semantics: s.shift(),
129
+ ssrcs: s.map((n) => parseInt(n, 10))
130
+ };
131
+ }, e.getMid = function(t) {
132
+ const s = e.matchPrefix(t, "a=mid:")[0];
133
+ if (s)
134
+ return s.substring(6);
135
+ }, e.parseFingerprint = function(t) {
136
+ const s = t.substring(14).split(" ");
137
+ return {
138
+ algorithm: s[0].toLowerCase(),
139
+ // algorithm is case-sensitive in Edge.
140
+ value: s[1].toUpperCase()
141
+ // the definition is upper-case in RFC 4572.
142
+ };
143
+ }, e.getDtlsParameters = function(t, s) {
144
+ return {
145
+ role: "auto",
146
+ fingerprints: e.matchPrefix(
147
+ t + s,
148
+ "a=fingerprint:"
149
+ ).map(e.parseFingerprint)
150
+ };
151
+ }, e.writeDtlsParameters = function(t, s) {
152
+ let n = "a=setup:" + s + `\r
153
+ `;
154
+ return t.fingerprints.forEach((i) => {
155
+ n += "a=fingerprint:" + i.algorithm + " " + i.value + `\r
156
+ `;
157
+ }), n;
158
+ }, e.parseCryptoLine = function(t) {
159
+ const s = t.substring(9).split(" ");
160
+ return {
161
+ tag: parseInt(s[0], 10),
162
+ cryptoSuite: s[1],
163
+ keyParams: s[2],
164
+ sessionParams: s.slice(3)
165
+ };
166
+ }, e.writeCryptoLine = function(t) {
167
+ return "a=crypto:" + t.tag + " " + t.cryptoSuite + " " + (typeof t.keyParams == "object" ? e.writeCryptoKeyParams(t.keyParams) : t.keyParams) + (t.sessionParams ? " " + t.sessionParams.join(" ") : "") + `\r
168
+ `;
169
+ }, e.parseCryptoKeyParams = function(t) {
170
+ if (t.indexOf("inline:") !== 0)
171
+ return null;
172
+ const s = t.substring(7).split("|");
173
+ return {
174
+ keyMethod: "inline",
175
+ keySalt: s[0],
176
+ lifeTime: s[1],
177
+ mkiValue: s[2] ? s[2].split(":")[0] : void 0,
178
+ mkiLength: s[2] ? s[2].split(":")[1] : void 0
179
+ };
180
+ }, e.writeCryptoKeyParams = function(t) {
181
+ return t.keyMethod + ":" + t.keySalt + (t.lifeTime ? "|" + t.lifeTime : "") + (t.mkiValue && t.mkiLength ? "|" + t.mkiValue + ":" + t.mkiLength : "");
182
+ }, e.getCryptoParameters = function(t, s) {
183
+ return e.matchPrefix(
184
+ t + s,
185
+ "a=crypto:"
186
+ ).map(e.parseCryptoLine);
187
+ }, e.getIceParameters = function(t, s) {
188
+ const n = e.matchPrefix(
189
+ t + s,
190
+ "a=ice-ufrag:"
191
+ )[0], i = e.matchPrefix(
192
+ t + s,
193
+ "a=ice-pwd:"
194
+ )[0];
195
+ return n && i ? {
196
+ usernameFragment: n.substring(12),
197
+ password: i.substring(10)
198
+ } : null;
199
+ }, e.writeIceParameters = function(t) {
200
+ let s = "a=ice-ufrag:" + t.usernameFragment + `\r
201
+ a=ice-pwd:` + t.password + `\r
202
+ `;
203
+ return t.iceLite && (s += `a=ice-lite\r
204
+ `), s;
205
+ }, e.parseRtpParameters = function(t) {
206
+ const s = {
207
+ codecs: [],
208
+ headerExtensions: [],
209
+ fecMechanisms: [],
210
+ rtcp: []
211
+ }, i = e.splitLines(t)[0].split(" ");
212
+ s.profile = i[2];
213
+ for (let d = 3; d < i.length; d++) {
214
+ const c = i[d], m = e.matchPrefix(
215
+ t,
216
+ "a=rtpmap:" + c + " "
217
+ )[0];
218
+ if (m) {
219
+ const u = e.parseRtpMap(m), v = e.matchPrefix(
220
+ t,
221
+ "a=fmtp:" + c + " "
222
+ );
223
+ switch (u.parameters = v.length ? e.parseFmtp(v[0]) : {}, u.rtcpFeedback = e.matchPrefix(
224
+ t,
225
+ "a=rtcp-fb:" + c + " "
226
+ ).map(e.parseRtcpFb), s.codecs.push(u), u.name.toUpperCase()) {
227
+ case "RED":
228
+ case "ULPFEC":
229
+ s.fecMechanisms.push(u.name.toUpperCase());
230
+ break;
231
+ }
232
+ }
233
+ }
234
+ e.matchPrefix(t, "a=extmap:").forEach((d) => {
235
+ s.headerExtensions.push(e.parseExtmap(d));
236
+ });
237
+ const o = e.matchPrefix(t, "a=rtcp-fb:* ").map(e.parseRtcpFb);
238
+ return s.codecs.forEach((d) => {
239
+ o.forEach((c) => {
240
+ d.rtcpFeedback.find((u) => u.type === c.type && u.parameter === c.parameter) || d.rtcpFeedback.push(c);
241
+ });
242
+ }), s;
243
+ }, e.writeRtpDescription = function(t, s) {
244
+ let n = "";
245
+ n += "m=" + t + " ", n += s.codecs.length > 0 ? "9" : "0", n += " " + (s.profile || "UDP/TLS/RTP/SAVPF") + " ", n += s.codecs.map((o) => o.preferredPayloadType !== void 0 ? o.preferredPayloadType : o.payloadType).join(" ") + `\r
246
+ `, n += `c=IN IP4 0.0.0.0\r
247
+ `, n += `a=rtcp:9 IN IP4 0.0.0.0\r
248
+ `, s.codecs.forEach((o) => {
249
+ n += e.writeRtpMap(o), n += e.writeFmtp(o), n += e.writeRtcpFb(o);
250
+ });
251
+ let i = 0;
252
+ return s.codecs.forEach((o) => {
253
+ o.maxptime > i && (i = o.maxptime);
254
+ }), i > 0 && (n += "a=maxptime:" + i + `\r
255
+ `), s.headerExtensions && s.headerExtensions.forEach((o) => {
256
+ n += e.writeExtmap(o);
257
+ }), n;
258
+ }, e.parseRtpEncodingParameters = function(t) {
259
+ const s = [], n = e.parseRtpParameters(t), i = n.fecMechanisms.indexOf("RED") !== -1, o = n.fecMechanisms.indexOf("ULPFEC") !== -1, d = e.matchPrefix(t, "a=ssrc:").map((S) => e.parseSsrcMedia(S)).filter((S) => S.attribute === "cname"), c = d.length > 0 && d[0].ssrc;
260
+ let m;
261
+ const u = e.matchPrefix(t, "a=ssrc-group:FID").map((S) => S.substring(17).split(" ").map((P) => parseInt(P, 10)));
262
+ u.length > 0 && u[0].length > 1 && u[0][0] === c && (m = u[0][1]), n.codecs.forEach((S) => {
263
+ if (S.name.toUpperCase() === "RTX" && S.parameters.apt) {
264
+ let y = {
265
+ ssrc: c,
266
+ codecPayloadType: parseInt(S.parameters.apt, 10)
267
+ };
268
+ c && m && (y.rtx = { ssrc: m }), s.push(y), i && (y = JSON.parse(JSON.stringify(y)), y.fec = {
269
+ ssrc: c,
270
+ mechanism: o ? "red+ulpfec" : "red"
271
+ }, s.push(y));
272
+ }
273
+ }), s.length === 0 && c && s.push({
274
+ ssrc: c
275
+ });
276
+ let v = e.matchPrefix(t, "b=");
277
+ return v.length && (v[0].indexOf("b=TIAS:") === 0 ? v = parseInt(v[0].substring(7), 10) : v[0].indexOf("b=AS:") === 0 ? v = parseInt(v[0].substring(5), 10) * 1e3 * 0.95 - 2e3 * 8 : v = void 0, s.forEach((S) => {
278
+ S.maxBitrate = v;
279
+ })), s;
280
+ }, e.parseRtcpParameters = function(t) {
281
+ const s = {}, n = e.matchPrefix(t, "a=ssrc:").map((d) => e.parseSsrcMedia(d)).filter((d) => d.attribute === "cname")[0];
282
+ n && (s.cname = n.value, s.ssrc = n.ssrc);
283
+ const i = e.matchPrefix(t, "a=rtcp-rsize");
284
+ s.reducedSize = i.length > 0, s.compound = i.length === 0;
285
+ const o = e.matchPrefix(t, "a=rtcp-mux");
286
+ return s.mux = o.length > 0, s;
287
+ }, e.writeRtcpParameters = function(t) {
288
+ let s = "";
289
+ return t.reducedSize && (s += `a=rtcp-rsize\r
290
+ `), t.mux && (s += `a=rtcp-mux\r
291
+ `), t.ssrc !== void 0 && t.cname && (s += "a=ssrc:" + t.ssrc + " cname:" + t.cname + `\r
292
+ `), s;
293
+ }, e.parseMsid = function(t) {
294
+ let s;
295
+ const n = e.matchPrefix(t, "a=msid:");
296
+ if (n.length === 1)
297
+ return s = n[0].substring(7).split(" "), { stream: s[0], track: s[1] };
298
+ const i = e.matchPrefix(t, "a=ssrc:").map((o) => e.parseSsrcMedia(o)).filter((o) => o.attribute === "msid");
299
+ if (i.length > 0)
300
+ return s = i[0].value.split(" "), { stream: s[0], track: s[1] };
301
+ }, e.parseSctpDescription = function(t) {
302
+ const s = e.parseMLine(t), n = e.matchPrefix(t, "a=max-message-size:");
303
+ let i;
304
+ n.length > 0 && (i = parseInt(n[0].substring(19), 10)), isNaN(i) && (i = 65536);
305
+ const o = e.matchPrefix(t, "a=sctp-port:");
306
+ if (o.length > 0)
307
+ return {
308
+ port: parseInt(o[0].substring(12), 10),
309
+ protocol: s.fmt,
310
+ maxMessageSize: i
311
+ };
312
+ const d = e.matchPrefix(t, "a=sctpmap:");
313
+ if (d.length > 0) {
314
+ const c = d[0].substring(10).split(" ");
315
+ return {
316
+ port: parseInt(c[0], 10),
317
+ protocol: c[1],
318
+ maxMessageSize: i
319
+ };
320
+ }
321
+ }, e.writeSctpDescription = function(t, s) {
322
+ let n = [];
323
+ return t.protocol !== "DTLS/SCTP" ? n = [
324
+ "m=" + t.kind + " 9 " + t.protocol + " " + s.protocol + `\r
325
+ `,
326
+ `c=IN IP4 0.0.0.0\r
327
+ `,
328
+ "a=sctp-port:" + s.port + `\r
329
+ `
330
+ ] : n = [
331
+ "m=" + t.kind + " 9 " + t.protocol + " " + s.port + `\r
332
+ `,
333
+ `c=IN IP4 0.0.0.0\r
334
+ `,
335
+ "a=sctpmap:" + s.port + " " + s.protocol + ` 65535\r
336
+ `
337
+ ], s.maxMessageSize !== void 0 && n.push("a=max-message-size:" + s.maxMessageSize + `\r
338
+ `), n.join("");
339
+ }, e.generateSessionId = function() {
340
+ return Math.random().toString().substr(2, 22);
341
+ }, e.writeSessionBoilerplate = function(t, s, n) {
342
+ let i;
343
+ const o = s !== void 0 ? s : 2;
344
+ return t ? i = t : i = e.generateSessionId(), `v=0\r
345
+ o=` + (n || "thisisadapterortc") + " " + i + " " + o + ` IN IP4 127.0.0.1\r
346
+ s=-\r
347
+ t=0 0\r
348
+ `;
349
+ }, e.getDirection = function(t, s) {
350
+ const n = e.splitLines(t);
351
+ for (let i = 0; i < n.length; i++)
352
+ switch (n[i]) {
353
+ case "a=sendrecv":
354
+ case "a=sendonly":
355
+ case "a=recvonly":
356
+ case "a=inactive":
357
+ return n[i].substring(2);
358
+ }
359
+ return s ? e.getDirection(s) : "sendrecv";
360
+ }, e.getKind = function(t) {
361
+ return e.splitLines(t)[0].split(" ")[0].substring(2);
362
+ }, e.isRejected = function(t) {
363
+ return t.split(" ", 2)[1] === "0";
364
+ }, e.parseMLine = function(t) {
365
+ const n = e.splitLines(t)[0].substring(2).split(" ");
366
+ return {
367
+ kind: n[0],
368
+ port: parseInt(n[1], 10),
369
+ protocol: n[2],
370
+ fmt: n.slice(3).join(" ")
371
+ };
372
+ }, e.parseOLine = function(t) {
373
+ const n = e.matchPrefix(t, "o=")[0].substring(2).split(" ");
374
+ return {
375
+ username: n[0],
376
+ sessionId: n[1],
377
+ sessionVersion: parseInt(n[2], 10),
378
+ netType: n[3],
379
+ addressType: n[4],
380
+ address: n[5]
381
+ };
382
+ }, e.isValidSDP = function(t) {
383
+ if (typeof t != "string" || t.length === 0)
384
+ return !1;
385
+ const s = e.splitLines(t);
386
+ for (let n = 0; n < s.length; n++)
387
+ if (s[n].length < 2 || s[n].charAt(1) !== "=")
388
+ return !1;
389
+ return !0;
390
+ }, a.exports = e;
391
+ })(Y)), Y.exports;
392
+ }
393
+ var de = ct(), F, M, q = { d: (a, e) => {
394
+ for (var t in e) q.o(e, t) && !q.o(a, t) && Object.defineProperty(a, t, { enumerable: !0, get: e[t] });
395
+ }, o: (a, e) => Object.prototype.hasOwnProperty.call(a, e) }, g = {};
396
+ q.d(g, { Dz: () => Xe, g$: () => Ce, Lt: () => ve, Q9: () => fe, qf: () => re, hV: () => tt, z$: () => ns, J0: () => ae, De: () => xt, $C: () => B, al: () => ke, _W: () => Le, Gv: () => We, m: () => Ne, tz: () => Re, Nu: () => Ze, zg: () => rt, vp: () => je, vU: () => l, wF: () => Be, rv: () => Je, Nh: () => Ye, ss: () => nt, qW: () => Ke, QL: () => He, cf: () => at, eM: () => Ge, Yd: () => r, Tk: () => p, iM: () => me, qy: () => U, ce: () => Tt, sK: () => h, Ok: () => f, q5: () => et, g: () => ss, xl: () => Ie, I: () => Ue, bx: () => ie, dD: () => qe, Ib: () => K, Az: () => E, Iw: () => D, qY: () => ne, db: () => Se, mR: () => N, Tn: () => se, rV: () => ze, gh: () => Fe, Mi: () => Ae, j: () => De, YB: () => Oe, Yt: () => Ve, i5: () => _e, x_: () => I, Am: () => oe, eR: () => Te, r8: () => xe, u3: () => it, vd: () => Ee, iV: () => we, jZ: () => Me, SW: () => Pe, ZH: () => be, Ni: () => ot, lh: () => ye, ZP: () => $e, bq: () => pe, $f: () => lt, eu: () => Qe, Ax: () => bt, Mc: () => wt });
397
+ class r {
398
+ static GetStackTrace() {
399
+ const e = new Error();
400
+ let t = "No Stack Available for this browser";
401
+ return e.stack && (t = e.stack.toString().replace(/Error/g, "")), t;
402
+ }
403
+ static SetLoggerVerbosity(e) {
404
+ this.verboseLogLevel != null && (this.verboseLogLevel = e);
405
+ }
406
+ static Log(e, t, s) {
407
+ if (s > this.verboseLogLevel) return;
408
+ const n = `Level: Log
409
+ Msg: ${t}
410
+ Caller: ${e}`;
411
+ console.log(n);
412
+ }
413
+ static Info(e, t, s) {
414
+ if (s > this.verboseLogLevel) return;
415
+ const n = `Level: Info
416
+ Msg: ${t}`;
417
+ console.info(n);
418
+ }
419
+ static Error(e, t) {
420
+ const s = `Level: Error
421
+ Msg: ${t}
422
+ Caller: ${e}`;
423
+ console.error(s);
424
+ }
425
+ static Warning(e, t) {
426
+ const s = `Level: Warning
427
+ Caller: ${e}
428
+ Msg: ${t}`;
429
+ console.warn(s);
430
+ }
431
+ }
432
+ r.verboseLogLevel = 5, (function(a) {
433
+ a.LIST_STREAMERS = "listStreamers", a.SUBSCRIBE = "subscribe", a.UNSUBSCRIBE = "unsubscribe", a.ICE_CANDIDATE = "iceCandidate", a.OFFER = "offer", a.ANSWER = "answer", a.DATACHANNELREQUEST = "dataChannelRequest", a.SFURECVDATACHANNELREADY = "peerDataChannelsReady", a.PONG = "pong";
434
+ })(F || (F = {}));
435
+ class U {
436
+ sendFilter(e, t) {
437
+ return t;
438
+ }
439
+ payload() {
440
+ return r.Log(r.GetStackTrace(), `Sending =>
441
+ ` + JSON.stringify(this, this.sendFilter, 4), 6), JSON.stringify(this, this.sendFilter);
442
+ }
443
+ }
444
+ class ht extends U {
445
+ constructor() {
446
+ super(), this.type = F.LIST_STREAMERS;
447
+ }
448
+ }
449
+ class ut extends U {
450
+ constructor(e) {
451
+ super(), this.type = F.SUBSCRIBE, this.streamerId = e;
452
+ }
453
+ }
454
+ class gt extends U {
455
+ constructor() {
456
+ super(), this.type = F.UNSUBSCRIBE;
457
+ }
458
+ }
459
+ class mt extends U {
460
+ constructor(e) {
461
+ super(), this.type = F.PONG, this.time = e;
462
+ }
463
+ }
464
+ class pt extends U {
465
+ constructor(e, t) {
466
+ super(), this.type = F.OFFER, this.minBitrate = 0, this.maxBitrate = 0, e && (this.type = e.type, this.sdp = e.sdp, this.minBitrate = t.minBitrateBps, this.maxBitrate = t.maxBitrateBps);
467
+ }
468
+ sendFilter(e, t) {
469
+ if (e != "minBitrate" && e != "maxBitrate" || !(t <= 0)) return t;
470
+ }
471
+ }
472
+ class St extends U {
473
+ constructor(e, t) {
474
+ super(), this.type = F.ANSWER, this.minBitrate = 0, this.maxBitrate = 0, e && (this.type = e.type, this.sdp = e.sdp, this.minBitrate = t.minBitrateBps, this.maxBitrate = t.maxBitrateBps);
475
+ }
476
+ sendFilter(e, t) {
477
+ if (e != "minBitrate" && e != "maxBitrate" || !(t <= 0)) return t;
478
+ }
479
+ }
480
+ class vt extends U {
481
+ constructor() {
482
+ super(), this.type = F.DATACHANNELREQUEST;
483
+ }
484
+ }
485
+ class ft extends U {
486
+ constructor() {
487
+ super(), this.type = F.SFURECVDATACHANNELREADY;
488
+ }
489
+ }
490
+ class Ct {
491
+ constructor(e) {
492
+ this.type = F.ICE_CANDIDATE, this.candidate = e;
493
+ }
494
+ payload() {
495
+ return r.Log(r.GetStackTrace(), `Sending =>
496
+ ` + JSON.stringify(this, void 0, 4), 6), JSON.stringify(this);
497
+ }
498
+ }
499
+ (function(a) {
500
+ a.CONFIG = "config", a.STREAMER_LIST = "streamerList", a.STREAMER_ID_CHANGED = "streamerIDChanged", a.PLAYER_COUNT = "playerCount", a.OFFER = "offer", a.ANSWER = "answer", a.ICE_CANDIDATE = "iceCandidate", a.PEER_DATA_CHANNELS = "peerDataChannels", a.PING = "ping", a.WARNING = "warning";
501
+ })(M || (M = {}));
502
+ class me {
503
+ }
504
+ class Tt extends me {
505
+ }
506
+ class se {
507
+ constructor() {
508
+ this.FromUEMessageHandlers = /* @__PURE__ */ new Map();
509
+ }
510
+ addMessageHandler(e, t) {
511
+ this.FromUEMessageHandlers.set(e, t);
512
+ }
513
+ handleMessage(e, t) {
514
+ this.FromUEMessageHandlers.has(e) ? this.FromUEMessageHandlers.get(e)(t) : r.Error(r.GetStackTrace(), `Message type of ${e} does not have a message handler registered on the frontend - ignoring message.`);
515
+ }
516
+ static setupDefaultHandlers(e) {
517
+ e.signallingProtocol.addMessageHandler(M.PING, ((t) => {
518
+ const s = new mt((/* @__PURE__ */ new Date()).getTime()).payload();
519
+ r.Log(r.GetStackTrace(), M.PING + ": " + t, 6), e.webSocket.send(s);
520
+ })), e.signallingProtocol.addMessageHandler(M.CONFIG, ((t) => {
521
+ r.Log(r.GetStackTrace(), M.CONFIG, 6);
522
+ const s = JSON.parse(t);
523
+ e.onConfig(s);
524
+ })), e.signallingProtocol.addMessageHandler(M.STREAMER_LIST, ((t) => {
525
+ r.Log(r.GetStackTrace(), M.STREAMER_LIST, 6);
526
+ const s = JSON.parse(t);
527
+ e.onStreamerList(s);
528
+ })), e.signallingProtocol.addMessageHandler(M.STREAMER_ID_CHANGED, ((t) => {
529
+ r.Log(r.GetStackTrace(), M.STREAMER_ID_CHANGED, 6);
530
+ const s = JSON.parse(t);
531
+ e.onStreamerIDChanged(s);
532
+ })), e.signallingProtocol.addMessageHandler(M.PLAYER_COUNT, ((t) => {
533
+ r.Log(r.GetStackTrace(), M.PLAYER_COUNT, 6);
534
+ const s = JSON.parse(t);
535
+ r.Log(r.GetStackTrace(), "Player Count: " + s.count, 6), e.onPlayerCount(s);
536
+ })), e.signallingProtocol.addMessageHandler(M.ANSWER, ((t) => {
537
+ r.Log(r.GetStackTrace(), M.ANSWER, 6);
538
+ const s = JSON.parse(t);
539
+ e.onWebRtcAnswer(s);
540
+ })), e.signallingProtocol.addMessageHandler(M.OFFER, ((t) => {
541
+ r.Log(r.GetStackTrace(), M.OFFER, 6);
542
+ const s = JSON.parse(t);
543
+ e.onWebRtcOffer(s);
544
+ })), e.signallingProtocol.addMessageHandler(M.ICE_CANDIDATE, ((t) => {
545
+ r.Log(r.GetStackTrace(), M.ICE_CANDIDATE, 6);
546
+ const s = JSON.parse(t);
547
+ e.onIceCandidate(s.candidate);
548
+ })), e.signallingProtocol.addMessageHandler(M.WARNING, ((t) => {
549
+ r.Warning(r.GetStackTrace(), `Warning received: ${t}`);
550
+ })), e.signallingProtocol.addMessageHandler(M.PEER_DATA_CHANNELS, ((t) => {
551
+ r.Log(r.GetStackTrace(), M.PEER_DATA_CHANNELS, 6);
552
+ const s = JSON.parse(t);
553
+ e.onWebRtcPeerDataChannels(s);
554
+ }));
555
+ }
556
+ }
557
+ class pe {
558
+ constructor() {
559
+ this.WS_OPEN_STATE = 1, this.onOpen = new EventTarget(), this.onClose = new EventTarget(), this.signallingProtocol = new se(), se.setupDefaultHandlers(this);
560
+ }
561
+ connect(e) {
562
+ r.Log(r.GetStackTrace(), e, 6);
563
+ try {
564
+ return this.webSocket = new WebSocket(e), this.webSocket.onopen = (t) => this.handleOnOpen(t), this.webSocket.onerror = () => this.handleOnError(), this.webSocket.onclose = (t) => this.handleOnClose(t), this.webSocket.onmessage = (t) => this.handleOnMessage(t), this.webSocket.onmessagebinary = (t) => this.handleOnMessageBinary(t), !0;
565
+ } catch (t) {
566
+ return r.Error(t, t), !1;
567
+ }
568
+ }
569
+ handleOnMessageBinary(e) {
570
+ e && e.data && e.data.text().then(((t) => {
571
+ const s = new MessageEvent("messageFromBinary", { data: t });
572
+ this.handleOnMessage(s);
573
+ })).catch(((t) => {
574
+ r.Error(r.GetStackTrace(), `Failed to parse binary blob from websocket, reason: ${t}`);
575
+ }));
576
+ }
577
+ handleOnMessage(e) {
578
+ if (e.data && e.data instanceof Blob) return void this.handleOnMessageBinary(e);
579
+ const t = JSON.parse(e.data);
580
+ r.Log(r.GetStackTrace(), `received =>
581
+ ` + JSON.stringify(JSON.parse(e.data), void 0, 4), 6), this.signallingProtocol.handleMessage(t.type, e.data);
582
+ }
583
+ handleOnOpen(e) {
584
+ r.Log(r.GetStackTrace(), "Connected to the signalling server via WebSocket", 6), this.onOpen.dispatchEvent(new Event("open"));
585
+ }
586
+ handleOnError() {
587
+ r.Error(r.GetStackTrace(), "WebSocket error");
588
+ }
589
+ handleOnClose(e) {
590
+ r.Log(r.GetStackTrace(), "Disconnected to the signalling server via WebSocket: " + JSON.stringify(e.code) + " - " + e.reason), this.onClose.dispatchEvent(new CustomEvent("close", { detail: e }));
591
+ }
592
+ requestStreamerList() {
593
+ const e = new ht();
594
+ this.webSocket.send(e.payload());
595
+ }
596
+ sendSubscribe(e) {
597
+ const t = new ut(e);
598
+ this.webSocket.send(t.payload());
599
+ }
600
+ sendUnsubscribe() {
601
+ const e = new gt();
602
+ this.webSocket.send(e.payload());
603
+ }
604
+ sendWebRtcOffer(e, t) {
605
+ const s = new pt(e, t);
606
+ this.webSocket.send(s.payload());
607
+ }
608
+ sendWebRtcAnswer(e, t) {
609
+ const s = new St(e, t);
610
+ this.webSocket.send(s.payload());
611
+ }
612
+ sendWebRtcDatachannelRequest() {
613
+ const e = new vt();
614
+ this.webSocket.send(e.payload());
615
+ }
616
+ sendSFURecvDataChannelReady() {
617
+ const e = new ft();
618
+ this.webSocket.send(e.payload());
619
+ }
620
+ sendIceCandidate(e) {
621
+ if (r.Log(r.GetStackTrace(), "Sending Ice Candidate"), this.webSocket && this.webSocket.readyState === this.WS_OPEN_STATE) {
622
+ const t = new Ct(e);
623
+ this.webSocket.send(t.payload());
624
+ }
625
+ }
626
+ close() {
627
+ var e;
628
+ (e = this.webSocket) === null || e === void 0 || e.close();
629
+ }
630
+ onConfig(e) {
631
+ }
632
+ onStreamerList(e) {
633
+ }
634
+ onStreamerIDChanged(e) {
635
+ }
636
+ onIceCandidate(e) {
637
+ }
638
+ onWebRtcAnswer(e) {
639
+ }
640
+ onWebRtcOffer(e) {
641
+ }
642
+ onWebRtcPeerDataChannels(e) {
643
+ }
644
+ onPlayerCount(e) {
645
+ }
646
+ }
647
+ class yt {
648
+ constructor(e) {
649
+ this.videoElementProvider = e, this.audioElement = document.createElement("Audio"), this.videoElementProvider.setAudioElement(this.audioElement);
650
+ }
651
+ handleOnTrack(e) {
652
+ if (r.Log(r.GetStackTrace(), "handleOnTrack " + JSON.stringify(e.streams), 6), e.track.id == "probator") return;
653
+ const t = this.videoElementProvider.getVideoElement();
654
+ if (e.track && r.Log(r.GetStackTrace(), "Got track - " + e.track.kind + " id=" + e.track.id + " readyState=" + e.track.readyState, 6), e.track.kind != "audio") return e.track.kind == "video" && t.srcObject !== e.streams[0] ? (t.srcObject = e.streams[0], void r.Log(r.GetStackTrace(), "Set video source from video track ontrack.")) : void 0;
655
+ this.CreateAudioTrack(e.streams[0]);
656
+ }
657
+ CreateAudioTrack(e) {
658
+ const t = this.videoElementProvider.getVideoElement();
659
+ t.srcObject != e && t.srcObject && t.srcObject !== e && (this.audioElement.srcObject = e, r.Log(r.GetStackTrace(), "Created new audio element to play separate audio stream."));
660
+ }
661
+ }
662
+ class Et {
663
+ constructor(e) {
664
+ this.freezeFrameHeight = 0, this.freezeFrameWidth = 0, this.rootDiv = e, this.rootElement = document.createElement("div"), this.rootElement.id = "freezeFrame", this.rootElement.style.display = "none", this.rootElement.style.pointerEvents = "none", this.rootElement.style.position = "absolute", this.rootElement.style.zIndex = "20", this.imageElement = document.createElement("img"), this.imageElement.style.position = "absolute", this.rootElement.appendChild(this.imageElement), this.rootDiv.appendChild(this.rootElement);
665
+ }
666
+ setElementForShow() {
667
+ this.rootElement.style.display = "block";
668
+ }
669
+ setElementForHide() {
670
+ this.rootElement.style.display = "none";
671
+ }
672
+ updateImageElementSource(e) {
673
+ const t = btoa(e.reduce(((s, n) => s + String.fromCharCode(n)), ""));
674
+ this.imageElement.src = "data:image/jpeg;base64," + t;
675
+ }
676
+ setDimensionsFromElementAndResize() {
677
+ this.freezeFrameHeight = this.imageElement.naturalHeight, this.freezeFrameWidth = this.imageElement.naturalWidth, this.resize();
678
+ }
679
+ resize() {
680
+ if (this.freezeFrameWidth !== 0 && this.freezeFrameHeight !== 0) {
681
+ let e = 0, t = 0, s = 0, n = 0;
682
+ const i = this.rootDiv.clientWidth / this.rootDiv.clientHeight, o = this.freezeFrameWidth / this.freezeFrameHeight;
683
+ i < o ? (e = this.rootDiv.clientWidth, t = Math.floor(this.rootDiv.clientWidth / o), s = Math.floor(0.5 * (this.rootDiv.clientHeight - t)), n = 0) : (e = Math.floor(this.rootDiv.clientHeight * o), t = this.rootDiv.clientHeight, s = 0, n = Math.floor(0.5 * (this.rootDiv.clientWidth - e))), this.rootElement.style.width = this.rootDiv.offsetWidth + "px", this.rootElement.style.height = this.rootDiv.offsetHeight + "px", this.rootElement.style.left = "0px", this.rootElement.style.top = "0px", this.imageElement.style.width = e + "px", this.imageElement.style.height = t + "px", this.imageElement.style.left = n + "px", this.imageElement.style.top = s + "px";
684
+ }
685
+ }
686
+ }
687
+ class Mt {
688
+ constructor(e) {
689
+ this.receiving = !1, this.size = 0, this.jpeg = void 0, this.valid = !1, this.freezeFrameDelay = 50, this.freezeFrame = new Et(e);
690
+ }
691
+ showFreezeFrame() {
692
+ this.valid && this.freezeFrame.setElementForShow();
693
+ }
694
+ hideFreezeFrame() {
695
+ this.valid = !1, this.freezeFrame.setElementForHide();
696
+ }
697
+ updateFreezeFrameAndShow(e, t) {
698
+ this.freezeFrame.updateImageElementSource(e), this.freezeFrame.imageElement.onload = () => {
699
+ this.freezeFrame.setDimensionsFromElementAndResize(), t();
700
+ };
701
+ }
702
+ processFreezeFrameMessage(e, t) {
703
+ this.receiving || (this.receiving = !0, this.valid = !1, this.size = 0, this.jpeg = void 0), this.size = new DataView(e.slice(1, 5).buffer).getInt32(0, !0);
704
+ const s = e.slice(5);
705
+ if (this.jpeg) {
706
+ const n = new Uint8Array(this.jpeg.length + s.length);
707
+ n.set(this.jpeg, 0), n.set(s, this.jpeg.length), this.jpeg = n;
708
+ } else this.jpeg = s, this.receiving = !0, r.Log(r.GetStackTrace(), `received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`, 6);
709
+ this.jpeg.length === this.size ? (this.receiving = !1, this.valid = !0, r.Log(r.GetStackTrace(), `received complete freeze frame ${this.size}`, 6), this.updateFreezeFrameAndShow(this.jpeg, t)) : this.jpeg.length > this.size && (r.Error(r.GetStackTrace(), `received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`), this.jpeg = void 0, this.receiving = !1);
710
+ }
711
+ }
712
+ class K {
713
+ constructor(e, t, s, n, i = (() => {
714
+ })) {
715
+ this.onChange = i, this.onChangeEmit = () => {
716
+ }, this.id = e, this.description = s, this.label = t, this.value = n;
717
+ }
718
+ set label(e) {
719
+ this._label = e, this.onChangeEmit(this._value);
720
+ }
721
+ get label() {
722
+ return this._label;
723
+ }
724
+ get value() {
725
+ return this._value;
726
+ }
727
+ set value(e) {
728
+ this._value = e, this.onChange(this._value, this), this.onChangeEmit(this._value);
729
+ }
730
+ }
731
+ class E extends K {
732
+ constructor(e, t, s, n, i, o = (() => {
733
+ })) {
734
+ super(e, t, s, n, o);
735
+ const d = new URLSearchParams(window.location.search);
736
+ if (i && d.has(this.id)) {
737
+ const c = this.getUrlParamFlag();
738
+ this.flag = c;
739
+ } else this.flag = n;
740
+ this.useUrlParams = i;
741
+ }
742
+ getUrlParamFlag() {
743
+ const e = new URLSearchParams(window.location.search);
744
+ return !!e.has(this.id) && e.get(this.id) !== "false" && e.get(this.id) !== "False";
745
+ }
746
+ updateURLParams() {
747
+ if (this.useUrlParams) {
748
+ const e = new URLSearchParams(window.location.search);
749
+ this.flag === !0 ? e.set(this.id, "true") : e.set(this.id, "false"), window.history.replaceState({}, "", e.toString() !== "" ? `${location.pathname}?${e}` : `${location.pathname}`);
750
+ }
751
+ }
752
+ enable() {
753
+ this.flag = !0;
754
+ }
755
+ get flag() {
756
+ return !!this.value;
757
+ }
758
+ set flag(e) {
759
+ this.value = e;
760
+ }
761
+ }
762
+ class D extends K {
763
+ constructor(e, t, s, n, i, o, d, c = (() => {
764
+ })) {
765
+ super(e, t, s, o, c), this._min = n, this._max = i;
766
+ const m = new URLSearchParams(window.location.search);
767
+ if (d && m.has(this.id)) {
768
+ const u = Number.parseFloat(m.get(this.id));
769
+ this.number = Number.isNaN(u) ? o : u;
770
+ } else this.number = o;
771
+ this.useUrlParams = d;
772
+ }
773
+ updateURLParams() {
774
+ if (this.useUrlParams) {
775
+ const e = new URLSearchParams(window.location.search);
776
+ e.set(this.id, this.number.toString()), window.history.replaceState({}, "", e.toString() !== "" ? `${location.pathname}?${e}` : `${location.pathname}`);
777
+ }
778
+ }
779
+ set number(e) {
780
+ this.value = this.clamp(e);
781
+ }
782
+ get number() {
783
+ return this.value;
784
+ }
785
+ clamp(e) {
786
+ return this._min == null && this._max == null ? e : this._min == null ? Math.min(this._max, e) : this._max == null ? Math.max(this._min, e) : Math.max(Math.min(this._max, e), this._min);
787
+ }
788
+ get min() {
789
+ return this._min;
790
+ }
791
+ get max() {
792
+ return this._max;
793
+ }
794
+ addOnChangedListener(e) {
795
+ this.onChange = e;
796
+ }
797
+ }
798
+ class Se extends K {
799
+ constructor(e, t, s, n, i, o = (() => {
800
+ })) {
801
+ super(e, t, s, n, o);
802
+ const d = new URLSearchParams(window.location.search);
803
+ if (i && d.has(this.id)) {
804
+ const c = this.getUrlParamText();
805
+ this.text = c;
806
+ } else this.text = n;
807
+ this.useUrlParams = i;
808
+ }
809
+ getUrlParamText() {
810
+ var e;
811
+ const t = new URLSearchParams(window.location.search);
812
+ return t.has(this.id) && (e = t.get(this.id)) !== null && e !== void 0 ? e : "";
813
+ }
814
+ updateURLParams() {
815
+ if (this.useUrlParams) {
816
+ const e = new URLSearchParams(window.location.search);
817
+ e.set(this.id, this.text), window.history.replaceState({}, "", e.toString() !== "" ? `${location.pathname}?${e}` : `${location.pathname}`);
818
+ }
819
+ }
820
+ get text() {
821
+ return this.value;
822
+ }
823
+ set text(e) {
824
+ this.value = e;
825
+ }
826
+ }
827
+ class ne extends K {
828
+ constructor(e, t, s, n, i, o, d = (() => {
829
+ })) {
830
+ super(e, t, s, n, d), this.options = i;
831
+ const c = new URLSearchParams(window.location.search), m = o && c.has(this.id) ? this.getUrlParamText() : n;
832
+ this.selected = m, this.useUrlParams = o;
833
+ }
834
+ getUrlParamText() {
835
+ var e;
836
+ const t = new URLSearchParams(window.location.search);
837
+ return t.has(this.id) && (e = t.get(this.id)) !== null && e !== void 0 ? e : "";
838
+ }
839
+ updateURLParams() {
840
+ if (this.useUrlParams) {
841
+ const e = new URLSearchParams(window.location.search);
842
+ e.set(this.id, this.selected), window.history.replaceState({}, "", e.toString() !== "" ? `${location.pathname}?${e}` : `${location.pathname}`);
843
+ }
844
+ }
845
+ addOnChangedListener(e) {
846
+ this.onChange = e;
847
+ }
848
+ get options() {
849
+ return this._options;
850
+ }
851
+ set options(e) {
852
+ this._options = e, this.onChangeEmit(this.selected);
853
+ }
854
+ get selected() {
855
+ return this.value;
856
+ }
857
+ set selected(e) {
858
+ let t = this.options.filter(((s) => s.indexOf(e) !== -1));
859
+ t.length ? this.value = t[0] : (t = this.options.filter(((s) => s.indexOf(e.split(" ")[0]) !== -1)), t.length && (this.value = t[0]));
860
+ }
861
+ }
862
+ class ve extends Event {
863
+ constructor(e) {
864
+ super("afkWarningActivate"), this.data = e;
865
+ }
866
+ }
867
+ class re extends Event {
868
+ constructor(e) {
869
+ super("afkWarningUpdate"), this.data = e;
870
+ }
871
+ }
872
+ class fe extends Event {
873
+ constructor() {
874
+ super("afkWarningDeactivate");
875
+ }
876
+ }
877
+ class Ce extends Event {
878
+ constructor() {
879
+ super("afkTimedOut");
880
+ }
881
+ }
882
+ class Te extends Event {
883
+ constructor(e) {
884
+ super("videoEncoderAvgQP"), this.data = e;
885
+ }
886
+ }
887
+ class ye extends Event {
888
+ constructor() {
889
+ super("webRtcSdp");
890
+ }
891
+ }
892
+ class Ee extends Event {
893
+ constructor() {
894
+ super("webRtcAutoConnect");
895
+ }
896
+ }
897
+ class Me extends Event {
898
+ constructor() {
899
+ super("webRtcConnecting");
900
+ }
901
+ }
902
+ class we extends Event {
903
+ constructor() {
904
+ super("webRtcConnected");
905
+ }
906
+ }
907
+ class be extends Event {
908
+ constructor() {
909
+ super("webRtcFailed");
910
+ }
911
+ }
912
+ class Pe extends Event {
913
+ constructor(e) {
914
+ super("webRtcDisconnected"), this.data = e;
915
+ }
916
+ }
917
+ class Re extends Event {
918
+ constructor(e) {
919
+ super("dataChannelOpen"), this.data = e;
920
+ }
921
+ }
922
+ class ke extends Event {
923
+ constructor(e) {
924
+ super("dataChannelClose"), this.data = e;
925
+ }
926
+ }
927
+ class Le extends Event {
928
+ constructor(e) {
929
+ super("dataChannelError"), this.data = e;
930
+ }
931
+ }
932
+ class xe extends Event {
933
+ constructor() {
934
+ super("videoInitialized");
935
+ }
936
+ }
937
+ class Fe extends Event {
938
+ constructor() {
939
+ super("streamLoading");
940
+ }
941
+ }
942
+ class Ae extends Event {
943
+ constructor() {
944
+ super("streamConnect");
945
+ }
946
+ }
947
+ class De extends Event {
948
+ constructor() {
949
+ super("streamDisconnect");
950
+ }
951
+ }
952
+ class Oe extends Event {
953
+ constructor() {
954
+ super("streamReconnect");
955
+ }
956
+ }
957
+ class Ie extends Event {
958
+ constructor(e) {
959
+ super("playStreamError"), this.data = e;
960
+ }
961
+ }
962
+ class Ue extends Event {
963
+ constructor() {
964
+ super("playStream");
965
+ }
966
+ }
967
+ class ie extends Event {
968
+ constructor(e) {
969
+ super("playStreamRejected"), this.data = e;
970
+ }
971
+ }
972
+ class Ge extends Event {
973
+ constructor(e) {
974
+ super("loadFreezeFrame"), this.data = e;
975
+ }
976
+ }
977
+ class Be extends Event {
978
+ constructor() {
979
+ super("hideFreezeFrame");
980
+ }
981
+ }
982
+ class ze extends Event {
983
+ constructor(e) {
984
+ super("statsReceived"), this.data = e;
985
+ }
986
+ }
987
+ class _e extends Event {
988
+ constructor(e) {
989
+ super("streamerListMessage"), this.data = e;
990
+ }
991
+ }
992
+ class Ve extends Event {
993
+ constructor(e) {
994
+ super("StreamerIDChangedMessage"), this.data = e;
995
+ }
996
+ }
997
+ class He extends Event {
998
+ constructor(e) {
999
+ super("latencyTestResult"), this.data = e;
1000
+ }
1001
+ }
1002
+ class We extends Event {
1003
+ constructor(e) {
1004
+ super("dataChannelLatencyTestResponse"), this.data = e;
1005
+ }
1006
+ }
1007
+ class Ne extends Event {
1008
+ constructor(e) {
1009
+ super("dataChannelLatencyTestResult"), this.data = e;
1010
+ }
1011
+ }
1012
+ class Ke extends Event {
1013
+ constructor(e) {
1014
+ super("initialSettings"), this.data = e;
1015
+ }
1016
+ }
1017
+ class N extends Event {
1018
+ constructor(e) {
1019
+ super("settingsChanged"), this.data = e;
1020
+ }
1021
+ }
1022
+ class wt extends Event {
1023
+ constructor() {
1024
+ super("xrSessionStarted");
1025
+ }
1026
+ }
1027
+ class bt extends Event {
1028
+ constructor() {
1029
+ super("xrSessionEnded");
1030
+ }
1031
+ }
1032
+ class Qe extends Event {
1033
+ constructor(e) {
1034
+ super("xrFrame"), this.data = e;
1035
+ }
1036
+ }
1037
+ class qe extends Event {
1038
+ constructor(e) {
1039
+ super("playerCount"), this.data = e;
1040
+ }
1041
+ }
1042
+ class $e extends Event {
1043
+ constructor() {
1044
+ super("webRtcTCPRelayDetected");
1045
+ }
1046
+ }
1047
+ class je extends EventTarget {
1048
+ dispatchEvent(e) {
1049
+ return super.dispatchEvent(e);
1050
+ }
1051
+ addEventListener(e, t) {
1052
+ super.addEventListener(e, t);
1053
+ }
1054
+ removeEventListener(e, t) {
1055
+ super.removeEventListener(e, t);
1056
+ }
1057
+ }
1058
+ class l {
1059
+ }
1060
+ l.AutoConnect = "AutoConnect", l.AutoPlayVideo = "AutoPlayVideo", l.AFKDetection = "TimeoutIfIdle", l.BrowserSendOffer = "OfferToReceive", l.HoveringMouseMode = "HoveringMouse", l.ForceMonoAudio = "ForceMonoAudio", l.ForceTURN = "ForceTURN", l.FakeMouseWithTouches = "FakeMouseWithTouches", l.IsQualityController = "ControlsQuality", l.MatchViewportResolution = "MatchViewportRes", l.StartVideoMuted = "StartVideoMuted", l.SuppressBrowserKeys = "SuppressBrowserKeys", l.UseMic = "UseMic", l.KeyboardInput = "KeyboardInput", l.MouseInput = "MouseInput", l.TouchInput = "TouchInput", l.GamepadInput = "GamepadInput", l.XRControllerInput = "XRControllerInput", l.WaitForStreamer = "WaitForStreamer", l.HideUI = "HideUI";
1061
+ const Pt = (a) => Object.getOwnPropertyNames(l).some(((e) => l[e] === a));
1062
+ class h {
1063
+ }
1064
+ h.AFKTimeoutSecs = "AFKTimeout", h.AFKCountdownSecs = "AFKCountdown", h.MinQP = "MinQP", h.MaxQP = "MaxQP", h.WebRTCFPS = "WebRTCFPS", h.WebRTCMinBitrate = "WebRTCMinBitrate", h.WebRTCMaxBitrate = "WebRTCMaxBitrate", h.MaxReconnectAttempts = "MaxReconnectAttempts", h.StreamerAutoJoinInterval = "StreamerAutoJoinInterval";
1065
+ const Rt = (a) => Object.getOwnPropertyNames(h).some(((e) => h[e] === a));
1066
+ class I {
1067
+ }
1068
+ I.SignallingServerUrl = "ss";
1069
+ const kt = (a) => Object.getOwnPropertyNames(I).some(((e) => I[e] === a));
1070
+ class f {
1071
+ }
1072
+ f.PreferredCodec = "PreferredCodec", f.StreamerId = "StreamerId";
1073
+ const Lt = (a) => Object.getOwnPropertyNames(f).some(((e) => f[e] === a));
1074
+ class xt {
1075
+ constructor(e = {}) {
1076
+ this.flags = /* @__PURE__ */ new Map(), this.numericParameters = /* @__PURE__ */ new Map(), this.textParameters = /* @__PURE__ */ new Map(), this.optionParameters = /* @__PURE__ */ new Map();
1077
+ const { initialSettings: t, useUrlParams: s } = e;
1078
+ this._useUrlParams = !!s, this.populateDefaultSettings(this._useUrlParams, t);
1079
+ }
1080
+ get useUrlParams() {
1081
+ return this._useUrlParams;
1082
+ }
1083
+ populateDefaultSettings(e, t) {
1084
+ this.textParameters.set(I.SignallingServerUrl, new Se(I.SignallingServerUrl, "Signalling url", "Url of the signalling server", t && t.hasOwnProperty(I.SignallingServerUrl) ? t[I.SignallingServerUrl] : (location.protocol === "https:" ? "wss://" : "ws://") + window.location.hostname + (window.location.port === "80" || window.location.port === "" ? "" : `:${window.location.port}`), e)), this.optionParameters.set(f.StreamerId, new ne(f.StreamerId, "Streamer ID", "The ID of the streamer to stream.", t && t.hasOwnProperty(f.StreamerId) ? t[f.StreamerId] : "", [], e)), this.optionParameters.set(f.PreferredCodec, new ne(f.PreferredCodec, "Preferred Codec", "The preferred codec to be used during codec negotiation", "H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f", t && t.hasOwnProperty(f.PreferredCodec) ? [t[f.PreferredCodec]] : (function() {
1085
+ const s = [];
1086
+ if (!RTCRtpReceiver.getCapabilities) return s.push("Only available on Chrome"), s;
1087
+ const n = /(VP\d|H26\d|AV1).*/;
1088
+ return RTCRtpReceiver.getCapabilities("video").codecs.forEach(((i) => {
1089
+ const o = i.mimeType.split("/")[1] + " " + (i.sdpFmtpLine || "");
1090
+ n.exec(o) !== null && s.push(o);
1091
+ })), s;
1092
+ })(), e)), this.flags.set(l.AutoConnect, new E(l.AutoConnect, "Auto connect to stream", "Whether we should attempt to auto connect to the signalling server or show a click to start prompt.", !(!t || !t.hasOwnProperty(l.AutoConnect)) && t[l.AutoConnect], e)), this.flags.set(l.AutoPlayVideo, new E(l.AutoPlayVideo, "Auto play video", "When video is ready automatically start playing it as opposed to showing a play button.", !t || !t.hasOwnProperty(l.AutoPlayVideo) || t[l.AutoPlayVideo], e)), this.flags.set(l.BrowserSendOffer, new E(l.BrowserSendOffer, "Browser send offer", "Browser will initiate the WebRTC handshake by sending the offer to the streamer", !(!t || !t.hasOwnProperty(l.BrowserSendOffer)) && t[l.BrowserSendOffer], e)), this.flags.set(l.UseMic, new E(l.UseMic, "Use microphone", "Make browser request microphone access and open an input audio track.", !(!t || !t.hasOwnProperty(l.UseMic)) && t[l.UseMic], e)), this.flags.set(l.StartVideoMuted, new E(l.StartVideoMuted, "Start video muted", "Video will start muted if true.", !(!t || !t.hasOwnProperty(l.StartVideoMuted)) && t[l.StartVideoMuted], e)), this.flags.set(l.SuppressBrowserKeys, new E(l.SuppressBrowserKeys, "Suppress browser keys", "Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.", !t || !t.hasOwnProperty(l.SuppressBrowserKeys) || t[l.SuppressBrowserKeys], e)), this.flags.set(l.IsQualityController, new E(l.IsQualityController, "Is quality controller?", "True if this peer controls stream quality", !t || !t.hasOwnProperty(l.IsQualityController) || t[l.IsQualityController], e)), this.flags.set(l.ForceMonoAudio, new E(l.ForceMonoAudio, "Force mono audio", "Force browser to request mono audio in the SDP", !(!t || !t.hasOwnProperty(l.ForceMonoAudio)) && t[l.ForceMonoAudio], e)), this.flags.set(l.ForceTURN, new E(l.ForceTURN, "Force TURN", "Only generate TURN/Relayed ICE candidates.", !(!t || !t.hasOwnProperty(l.ForceTURN)) && t[l.ForceTURN], e)), this.flags.set(l.AFKDetection, new E(l.AFKDetection, "AFK if idle", "Timeout the experience if user is AFK for a period.", !(!t || !t.hasOwnProperty(l.AFKDetection)) && t[l.AFKDetection], e)), this.flags.set(l.MatchViewportResolution, new E(l.MatchViewportResolution, "Match viewport resolution", "Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.", !(!t || !t.hasOwnProperty(l.MatchViewportResolution)) && t[l.MatchViewportResolution], e)), this.flags.set(l.HoveringMouseMode, new E(l.HoveringMouseMode, "Control Scheme: Locked Mouse", "Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.", !(!t || !t.hasOwnProperty(l.HoveringMouseMode)) && t[l.HoveringMouseMode], e, ((s, n) => {
1093
+ n.label = `Control Scheme: ${s ? "Hovering" : "Locked"} Mouse`;
1094
+ }))), this.flags.set(l.FakeMouseWithTouches, new E(l.FakeMouseWithTouches, "Fake mouse with touches", "A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.", !(!t || !t.hasOwnProperty(l.FakeMouseWithTouches)) && t[l.FakeMouseWithTouches], e)), this.flags.set(l.KeyboardInput, new E(l.KeyboardInput, "Keyboard input", "If enabled, send keyboard events to streamer", !t || !t.hasOwnProperty(l.KeyboardInput) || t[l.KeyboardInput], e)), this.flags.set(l.MouseInput, new E(l.MouseInput, "Mouse input", "If enabled, send mouse events to streamer", !t || !t.hasOwnProperty(l.MouseInput) || t[l.MouseInput], e)), this.flags.set(l.TouchInput, new E(l.TouchInput, "Touch input", "If enabled, send touch events to streamer", !t || !t.hasOwnProperty(l.TouchInput) || t[l.TouchInput], e)), this.flags.set(l.GamepadInput, new E(l.GamepadInput, "Gamepad input", "If enabled, send gamepad events to streamer", !t || !t.hasOwnProperty(l.GamepadInput) || t[l.GamepadInput], e)), this.flags.set(l.XRControllerInput, new E(l.XRControllerInput, "XR controller input", "If enabled, send XR controller events to streamer", !t || !t.hasOwnProperty(l.XRControllerInput) || t[l.XRControllerInput], e)), this.flags.set(l.WaitForStreamer, new E(l.WaitForStreamer, "Wait for streamer", "Will continue trying to connect to the first streamer available.", !t || !t.hasOwnProperty(l.WaitForStreamer) || t[l.WaitForStreamer], e)), this.flags.set(l.HideUI, new E(l.HideUI, "Hide the UI overlay", "Will hide all UI overlay details", !(!t || !t.hasOwnProperty(l.HideUI)) && t[l.HideUI], e)), this.numericParameters.set(h.AFKTimeoutSecs, new D(h.AFKTimeoutSecs, "AFK timeout", "The time (in seconds) it takes for the application to time out if AFK timeout is enabled.", 0, null, t && t.hasOwnProperty(h.AFKTimeoutSecs) ? t[h.AFKTimeoutSecs] : 120, e)), this.numericParameters.set(h.AFKCountdownSecs, new D(h.AFKCountdownSecs, "AFK countdown", "The time (in seconds) for a user to respond before the stream is ended after an AFK timeout.", 10, null, 10, e)), this.numericParameters.set(h.MaxReconnectAttempts, new D(h.MaxReconnectAttempts, "Max Reconnects", "Maximum number of reconnects the application will attempt when a streamer disconnects.", 0, 999, t && t.hasOwnProperty(h.MaxReconnectAttempts) ? t[h.MaxReconnectAttempts] : 3, e)), this.numericParameters.set(h.MinQP, new D(h.MinQP, "Min QP", "The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.", 0, 51, t && t.hasOwnProperty(h.MinQP) ? t[h.MinQP] : 0, e)), this.numericParameters.set(h.MaxQP, new D(h.MaxQP, "Max QP", "The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.", 0, 51, t && t.hasOwnProperty(h.MaxQP) ? t[h.MaxQP] : 51, e)), this.numericParameters.set(h.WebRTCFPS, new D(h.WebRTCFPS, "Max FPS", "The maximum FPS that WebRTC will try to transmit frames at.", 1, 999, t && t.hasOwnProperty(h.WebRTCFPS) ? t[h.WebRTCFPS] : 60, e)), this.numericParameters.set(h.WebRTCMinBitrate, new D(h.WebRTCMinBitrate, "Min Bitrate (kbps)", "The minimum bitrate that WebRTC should use.", 0, 5e5, t && t.hasOwnProperty(h.WebRTCMinBitrate) ? t[h.WebRTCMinBitrate] : 0, e)), this.numericParameters.set(h.WebRTCMaxBitrate, new D(h.WebRTCMaxBitrate, "Max Bitrate (kbps)", "The maximum bitrate that WebRTC should use.", 0, 5e5, t && t.hasOwnProperty(h.WebRTCMaxBitrate) ? t[h.WebRTCMaxBitrate] : 0, e)), this.numericParameters.set(h.StreamerAutoJoinInterval, new D(h.StreamerAutoJoinInterval, "Streamer Auto Join Interval (ms)", "Delay between retries when waiting for an available streamer.", 500, 9e5, t && t.hasOwnProperty(h.StreamerAutoJoinInterval) ? t[h.StreamerAutoJoinInterval] : 3e3, e));
1095
+ }
1096
+ _addOnNumericSettingChangedListener(e, t) {
1097
+ this.numericParameters.has(e) && this.numericParameters.get(e).addOnChangedListener(t);
1098
+ }
1099
+ _addOnOptionSettingChangedListener(e, t) {
1100
+ this.optionParameters.has(e) && this.optionParameters.get(e).addOnChangedListener(t);
1101
+ }
1102
+ getNumericSettingValue(e) {
1103
+ if (this.numericParameters.has(e)) return this.numericParameters.get(e).number;
1104
+ throw new Error(`There is no numeric setting with the id of ${e}`);
1105
+ }
1106
+ getTextSettingValue(e) {
1107
+ if (this.textParameters.has(e)) return this.textParameters.get(e).value;
1108
+ throw new Error(`There is no numeric setting with the id of ${e}`);
1109
+ }
1110
+ setNumericSetting(e, t) {
1111
+ if (!this.numericParameters.has(e)) throw new Error(`There is no numeric setting with the id of ${e}`);
1112
+ this.numericParameters.get(e).number = t;
1113
+ }
1114
+ _addOnSettingChangedListener(e, t) {
1115
+ this.flags.has(e) && (this.flags.get(e).onChange = t);
1116
+ }
1117
+ _addOnTextSettingChangedListener(e, t) {
1118
+ this.textParameters.has(e) && (this.textParameters.get(e).onChange = t);
1119
+ }
1120
+ getSettingOption(e) {
1121
+ return this.optionParameters.get(e);
1122
+ }
1123
+ isFlagEnabled(e) {
1124
+ return this.flags.get(e).flag;
1125
+ }
1126
+ setFlagEnabled(e, t) {
1127
+ this.flags.has(e) ? this.flags.get(e).flag = t : r.Warning(r.GetStackTrace(), `Cannot toggle flag called ${e} - it does not exist in the Config.flags map.`);
1128
+ }
1129
+ setTextSetting(e, t) {
1130
+ this.textParameters.has(e) ? this.textParameters.get(e).text = t : r.Warning(r.GetStackTrace(), `Cannot set text setting called ${e} - it does not exist in the Config.textParameters map.`);
1131
+ }
1132
+ setOptionSettingOptions(e, t) {
1133
+ this.optionParameters.has(e) ? this.optionParameters.get(e).options = t : r.Warning(r.GetStackTrace(), `Cannot set text setting called ${e} - it does not exist in the Config.optionParameters map.`);
1134
+ }
1135
+ setOptionSettingValue(e, t) {
1136
+ if (this.optionParameters.has(e)) {
1137
+ const s = this.optionParameters.get(e), n = s.options;
1138
+ n.includes(t) || (n.push(t), s.options = n), s.selected = t;
1139
+ } else r.Warning(r.GetStackTrace(), `Cannot set text setting called ${e} - it does not exist in the Config.enumParameters map.`);
1140
+ }
1141
+ setFlagLabel(e, t) {
1142
+ this.flags.has(e) ? this.flags.get(e).label = t : r.Warning(r.GetStackTrace(), `Cannot set label for flag called ${e} - it does not exist in the Config.flags map.`);
1143
+ }
1144
+ setSettings(e) {
1145
+ for (const t of Object.keys(e)) Pt(t) ? this.setFlagEnabled(t, e[t]) : Rt(t) ? this.setNumericSetting(t, e[t]) : kt(t) ? this.setTextSetting(t, e[t]) : Lt(t) && this.setOptionSettingValue(t, e[t]);
1146
+ }
1147
+ getSettings() {
1148
+ const e = {};
1149
+ for (const [t, s] of this.flags.entries()) e[t] = s.flag;
1150
+ for (const [t, s] of this.numericParameters.entries()) e[t] = s.number;
1151
+ for (const [t, s] of this.textParameters.entries()) e[t] = s.text;
1152
+ for (const [t, s] of this.optionParameters.entries()) e[t] = s.selected;
1153
+ return e;
1154
+ }
1155
+ getFlags() {
1156
+ return Array.from(this.flags.values());
1157
+ }
1158
+ getTextSettings() {
1159
+ return Array.from(this.textParameters.values());
1160
+ }
1161
+ getNumericSettings() {
1162
+ return Array.from(this.numericParameters.values());
1163
+ }
1164
+ getOptionSettings() {
1165
+ return Array.from(this.optionParameters.values());
1166
+ }
1167
+ _registerOnChangeEvents(e) {
1168
+ for (const t of this.flags.keys()) {
1169
+ const s = this.flags.get(t);
1170
+ s && (s.onChangeEmit = (n) => e.dispatchEvent(new N({ id: s.id, type: "flag", value: n, target: s })));
1171
+ }
1172
+ for (const t of this.numericParameters.keys()) {
1173
+ const s = this.numericParameters.get(t);
1174
+ s && (s.onChangeEmit = (n) => e.dispatchEvent(new N({ id: s.id, type: "number", value: n, target: s })));
1175
+ }
1176
+ for (const t of this.textParameters.keys()) {
1177
+ const s = this.textParameters.get(t);
1178
+ s && (s.onChangeEmit = (n) => e.dispatchEvent(new N({ id: s.id, type: "text", value: n, target: s })));
1179
+ }
1180
+ for (const t of this.optionParameters.keys()) {
1181
+ const s = this.optionParameters.get(t);
1182
+ s && (s.onChangeEmit = (n) => e.dispatchEvent(new N({ id: s.id, type: "option", value: n, target: s })));
1183
+ }
1184
+ }
1185
+ }
1186
+ var B;
1187
+ (function(a) {
1188
+ a[a.LockedMouse = 0] = "LockedMouse", a[a.HoveringMouse = 1] = "HoveringMouse";
1189
+ })(B || (B = {}));
1190
+ class Xe {
1191
+ constructor(e, t, s) {
1192
+ this.active = !1, this.countdownActive = !1, this.warnTimer = void 0, this.countDown = 0, this.countDownTimer = void 0, this.config = e, this.pixelStreaming = t, this.onDismissAfk = s, this.onAFKTimedOutCallback = () => {
1193
+ console.log("AFK timed out, did you want to override this callback?");
1194
+ };
1195
+ }
1196
+ onAfkClick() {
1197
+ clearInterval(this.countDownTimer), (this.active || this.countdownActive) && (this.startAfkWarningTimer(), this.pixelStreaming.dispatchEvent(new fe()));
1198
+ }
1199
+ startAfkWarningTimer() {
1200
+ this.config.getNumericSettingValue(h.AFKTimeoutSecs) > 0 && this.config.isFlagEnabled(l.AFKDetection) ? this.active = !0 : this.active = !1, this.resetAfkWarningTimer();
1201
+ }
1202
+ stopAfkWarningTimer() {
1203
+ this.active = !1, this.countdownActive = !1, clearTimeout(this.warnTimer), clearInterval(this.countDownTimer);
1204
+ }
1205
+ pauseAfkWarningTimer() {
1206
+ this.active = !1;
1207
+ }
1208
+ resetAfkWarningTimer() {
1209
+ this.active && this.config.isFlagEnabled(l.AFKDetection) && (clearTimeout(this.warnTimer), this.warnTimer = setTimeout((() => this.activateAfkEvent()), 1e3 * this.config.getNumericSettingValue(h.AFKTimeoutSecs)));
1210
+ }
1211
+ activateAfkEvent() {
1212
+ this.pauseAfkWarningTimer(), this.pixelStreaming.dispatchEvent(new ve({ countDown: this.countDown, dismissAfk: this.onDismissAfk })), this.countDown = this.config.getNumericSettingValue(h.AFKCountdownSecs), this.countdownActive = !0, this.pixelStreaming.dispatchEvent(new re({ countDown: this.countDown })), this.config.isFlagEnabled(l.HoveringMouseMode) || document.exitPointerLock && document.exitPointerLock(), this.countDownTimer = setInterval((() => {
1213
+ this.countDown--, this.countDown == 0 ? (this.pixelStreaming.dispatchEvent(new Ce()), this.onAFKTimedOutCallback(), r.Log(r.GetStackTrace(), "You have been disconnected due to inactivity"), this.stopAfkWarningTimer()) : this.pixelStreaming.dispatchEvent(new re({ countDown: this.countDown }));
1214
+ }), 1e3);
1215
+ }
1216
+ }
1217
+ class ce {
1218
+ constructor() {
1219
+ this.isReceivingFreezeFrame = !1;
1220
+ }
1221
+ getDataChannelInstance() {
1222
+ return this;
1223
+ }
1224
+ createDataChannel(e, t, s) {
1225
+ this.peerConnection = e, this.label = t, this.datachannelOptions = s, s == null && (this.datachannelOptions = {}, this.datachannelOptions.ordered = !0), this.dataChannel = this.peerConnection.createDataChannel(this.label, this.datachannelOptions), this.setupDataChannel();
1226
+ }
1227
+ setupDataChannel() {
1228
+ this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = (e) => this.handleOnOpen(e), this.dataChannel.onclose = (e) => this.handleOnClose(e), this.dataChannel.onmessage = (e) => this.handleOnMessage(e), this.dataChannel.onerror = (e) => this.handleOnError(e);
1229
+ }
1230
+ handleOnOpen(e) {
1231
+ var t;
1232
+ r.Log(r.GetStackTrace(), `Data Channel (${this.label}) opened.`, 7), this.onOpen((t = this.dataChannel) === null || t === void 0 ? void 0 : t.label, e);
1233
+ }
1234
+ handleOnClose(e) {
1235
+ var t;
1236
+ r.Log(r.GetStackTrace(), `Data Channel (${this.label}) closed.`, 7), this.onClose((t = this.dataChannel) === null || t === void 0 ? void 0 : t.label, e);
1237
+ }
1238
+ handleOnMessage(e) {
1239
+ r.Log(r.GetStackTrace(), `Data Channel (${this.label}) message: ${e}`, 8);
1240
+ }
1241
+ handleOnError(e) {
1242
+ var t;
1243
+ r.Log(r.GetStackTrace(), `Data Channel (${this.label}) error: ${e}`, 7), this.onError((t = this.dataChannel) === null || t === void 0 ? void 0 : t.label, e);
1244
+ }
1245
+ onOpen(e, t) {
1246
+ }
1247
+ onClose(e, t) {
1248
+ }
1249
+ onError(e, t) {
1250
+ }
1251
+ }
1252
+ class Je {
1253
+ }
1254
+ class Ye {
1255
+ }
1256
+ class Ze {
1257
+ }
1258
+ class ae {
1259
+ }
1260
+ class et {
1261
+ }
1262
+ class Ft {
1263
+ }
1264
+ class At {
1265
+ }
1266
+ class tt {
1267
+ constructor() {
1268
+ this.inboundVideoStats = new Ye(), this.inboundAudioStats = new Je(), this.DataChannelStats = new Ze(), this.outBoundVideoStats = new et(), this.sessionStats = new Ft(), this.streamStats = new At(), this.codecs = /* @__PURE__ */ new Map();
1269
+ }
1270
+ processStats(e) {
1271
+ this.localCandidates = new Array(), this.remoteCandidates = new Array(), this.candidatePairs = new Array(), e.forEach(((t) => {
1272
+ switch (t.type) {
1273
+ case "candidate-pair":
1274
+ this.handleCandidatePair(t);
1275
+ break;
1276
+ case "certificate":
1277
+ case "media-source":
1278
+ case "media-playout":
1279
+ case "outbound-rtp":
1280
+ case "peer-connection":
1281
+ case "remote-inbound-rtp":
1282
+ break;
1283
+ case "codec":
1284
+ this.handleCodec(t);
1285
+ break;
1286
+ case "data-channel":
1287
+ this.handleDataChannel(t);
1288
+ break;
1289
+ case "inbound-rtp":
1290
+ this.handleInBoundRTP(t);
1291
+ break;
1292
+ case "local-candidate":
1293
+ this.handleLocalCandidate(t);
1294
+ break;
1295
+ case "remote-candidate":
1296
+ this.handleRemoteCandidate(t);
1297
+ break;
1298
+ case "remote-outbound-rtp":
1299
+ this.handleRemoteOutBound(t);
1300
+ break;
1301
+ case "track":
1302
+ this.handleTrack(t);
1303
+ break;
1304
+ case "transport":
1305
+ this.handleTransport(t);
1306
+ break;
1307
+ case "stream":
1308
+ this.handleStream(t);
1309
+ break;
1310
+ default:
1311
+ r.Error(r.GetStackTrace(), "unhandled Stat Type"), r.Log(r.GetStackTrace(), t);
1312
+ }
1313
+ }));
1314
+ }
1315
+ handleStream(e) {
1316
+ this.streamStats = e;
1317
+ }
1318
+ handleCandidatePair(e) {
1319
+ this.candidatePairs.push(e);
1320
+ }
1321
+ handleDataChannel(e) {
1322
+ this.DataChannelStats.bytesReceived = e.bytesReceived, this.DataChannelStats.bytesSent = e.bytesSent, this.DataChannelStats.dataChannelIdentifier = e.dataChannelIdentifier, this.DataChannelStats.id = e.id, this.DataChannelStats.label = e.label, this.DataChannelStats.messagesReceived = e.messagesReceived, this.DataChannelStats.messagesSent = e.messagesSent, this.DataChannelStats.protocol = e.protocol, this.DataChannelStats.state = e.state, this.DataChannelStats.timestamp = e.timestamp;
1323
+ }
1324
+ handleLocalCandidate(e) {
1325
+ const t = new ae();
1326
+ t.label = "local-candidate", t.address = e.address, t.port = e.port, t.protocol = e.protocol, t.candidateType = e.candidateType, t.id = e.id, t.relayProtocol = e.relayProtocol, t.transportId = e.transportId, this.localCandidates.push(t);
1327
+ }
1328
+ handleRemoteCandidate(e) {
1329
+ const t = new ae();
1330
+ t.label = "remote-candidate", t.address = e.address, t.port = e.port, t.protocol = e.protocol, t.id = e.id, t.candidateType = e.candidateType, t.relayProtocol = e.relayProtocol, t.transportId = e.transportId, this.remoteCandidates.push(t);
1331
+ }
1332
+ handleInBoundRTP(e) {
1333
+ switch (e.kind) {
1334
+ case "video":
1335
+ this.inboundVideoStats = e, this.lastVideoStats != null && (this.inboundVideoStats.bitrate = 8 * (this.inboundVideoStats.bytesReceived - this.lastVideoStats.bytesReceived) / (this.inboundVideoStats.timestamp - this.lastVideoStats.timestamp), this.inboundVideoStats.bitrate = Math.floor(this.inboundVideoStats.bitrate)), this.lastVideoStats = Object.assign({}, this.inboundVideoStats);
1336
+ break;
1337
+ case "audio":
1338
+ this.inboundAudioStats = e, this.lastAudioStats != null && (this.inboundAudioStats.bitrate = 8 * (this.inboundAudioStats.bytesReceived - this.lastAudioStats.bytesReceived) / (this.inboundAudioStats.timestamp - this.lastAudioStats.timestamp), this.inboundAudioStats.bitrate = Math.floor(this.inboundAudioStats.bitrate)), this.lastAudioStats = Object.assign({}, this.inboundAudioStats);
1339
+ break;
1340
+ default:
1341
+ r.Log(r.GetStackTrace(), "Kind is not handled");
1342
+ }
1343
+ }
1344
+ handleRemoteOutBound(e) {
1345
+ e.kind === "video" && (this.outBoundVideoStats.bytesSent = e.bytesSent, this.outBoundVideoStats.id = e.id, this.outBoundVideoStats.localId = e.localId, this.outBoundVideoStats.packetsSent = e.packetsSent, this.outBoundVideoStats.remoteTimestamp = e.remoteTimestamp, this.outBoundVideoStats.timestamp = e.timestamp);
1346
+ }
1347
+ handleTrack(e) {
1348
+ e.type !== "track" || e.trackIdentifier !== "video_label" && e.kind !== "video" || (this.inboundVideoStats.framesDropped = e.framesDropped, this.inboundVideoStats.framesReceived = e.framesReceived, this.inboundVideoStats.frameHeight = e.frameHeight, this.inboundVideoStats.frameWidth = e.frameWidth);
1349
+ }
1350
+ handleTransport(e) {
1351
+ this.transportStats = e;
1352
+ }
1353
+ handleCodec(e) {
1354
+ const t = e.id, s = `${e.mimeType.replace("video/", "").replace("audio/", "")}${e.sdpFmtpLine ? ` ${e.sdpFmtpLine}` : ""}`;
1355
+ this.codecs.set(t, s);
1356
+ }
1357
+ handleSessionStatistics(e, t, s) {
1358
+ const n = Date.now() - e;
1359
+ this.sessionStats.runTime = new Date(n).toISOString().substr(11, 8).toString();
1360
+ const i = t === null ? "Not sent yet" : t ? "true" : "false";
1361
+ this.sessionStats.controlsStreamInput = i, this.sessionStats.videoEncoderAvgQP = s;
1362
+ }
1363
+ isNumber(e) {
1364
+ return typeof e == "number" && isFinite(e);
1365
+ }
1366
+ getActiveCandidatePair() {
1367
+ return this.transportStats ? this.candidatePairs.find(((e) => e.id === this.transportStats.selectedCandidatePairId), null) : this.candidatePairs.find(((e) => e.selected), null);
1368
+ }
1369
+ }
1370
+ const he = (ue = { parseRtpParameters: () => de.parseRtpParameters, splitSections: () => de.splitSections }, Z = {}, q.d(Z, ue), Z);
1371
+ var ue, Z;
1372
+ class st {
1373
+ static isVideoTransciever(e) {
1374
+ return this.canTransceiverReceiveVideo(e) || this.canTransceiverSendVideo(e);
1375
+ }
1376
+ static canTransceiverReceiveVideo(e) {
1377
+ return !!e && (e.direction === "sendrecv" || e.direction === "recvonly") && e.receiver && e.receiver.track && e.receiver.track.kind === "video";
1378
+ }
1379
+ static canTransceiverSendVideo(e) {
1380
+ return !!e && (e.direction === "sendrecv" || e.direction === "sendonly") && e.sender && e.sender.track && e.sender.track.kind === "video";
1381
+ }
1382
+ static isAudioTransciever(e) {
1383
+ return this.canTransceiverReceiveAudio(e) || this.canTransceiverSendAudio(e);
1384
+ }
1385
+ static canTransceiverReceiveAudio(e) {
1386
+ return !!e && (e.direction === "sendrecv" || e.direction === "recvonly") && e.receiver && e.receiver.track && e.receiver.track.kind === "audio";
1387
+ }
1388
+ static canTransceiverSendAudio(e) {
1389
+ return !!e && (e.direction === "sendrecv" || e.direction === "sendonly") && e.sender && e.sender.track && e.sender.track.kind === "audio";
1390
+ }
1391
+ }
1392
+ var _, p, ee = function(a, e, t, s) {
1393
+ return new (t || (t = Promise))((function(n, i) {
1394
+ function o(m) {
1395
+ try {
1396
+ c(s.next(m));
1397
+ } catch (u) {
1398
+ i(u);
1399
+ }
1400
+ }
1401
+ function d(m) {
1402
+ try {
1403
+ c(s.throw(m));
1404
+ } catch (u) {
1405
+ i(u);
1406
+ }
1407
+ }
1408
+ function c(m) {
1409
+ var u;
1410
+ m.done ? n(m.value) : (u = m.value, u instanceof t ? u : new t((function(v) {
1411
+ v(u);
1412
+ }))).then(o, d);
1413
+ }
1414
+ c((s = s.apply(a, [])).next());
1415
+ }));
1416
+ };
1417
+ class Dt {
1418
+ constructor(e, t, s) {
1419
+ this.config = t, this.createPeerConnection(e, s);
1420
+ }
1421
+ createPeerConnection(e, t) {
1422
+ this.config.isFlagEnabled(l.ForceTURN) && (e.iceTransportPolicy = "relay", r.Log(r.GetStackTrace(), "Forcing TURN usage by setting ICE Transport Policy in peer connection config.")), this.peerConnection = new RTCPeerConnection(e), this.peerConnection.onsignalingstatechange = (s) => this.handleSignalStateChange(s), this.peerConnection.oniceconnectionstatechange = (s) => this.handleIceConnectionStateChange(s), this.peerConnection.onicegatheringstatechange = (s) => this.handleIceGatheringStateChange(s), this.peerConnection.ontrack = (s) => this.handleOnTrack(s), this.peerConnection.onicecandidate = (s) => this.handleIceCandidate(s), this.peerConnection.ondatachannel = (s) => this.handleDataChannel(s), this.aggregatedStats = new tt(), this.preferredCodec = t, this.updateCodecSelection = !0;
1423
+ }
1424
+ createOffer(e, t) {
1425
+ return ee(this, void 0, void 0, (function* () {
1426
+ r.Log(r.GetStackTrace(), "Create Offer", 6);
1427
+ const s = location.hostname === "localhost" || location.hostname === "127.0.0.1", n = location.protocol === "https:";
1428
+ let i = t.isFlagEnabled(l.UseMic);
1429
+ !i || s || n || (i = !1, r.Error(r.GetStackTrace(), "Microphone access in the browser will not work if you are not on HTTPS or localhost. Disabling mic access."), r.Error(r.GetStackTrace(), "For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'")), this.setupTransceiversAsync(i).finally((() => {
1430
+ var o;
1431
+ (o = this.peerConnection) === null || o === void 0 || o.createOffer(e).then(((d) => {
1432
+ var c;
1433
+ this.showTextOverlayConnecting(), d.sdp = this.mungeSDP(d.sdp, i), (c = this.peerConnection) === null || c === void 0 || c.setLocalDescription(d), this.onSendWebRTCOffer(d);
1434
+ })).catch((() => {
1435
+ this.showTextOverlaySetupFailure();
1436
+ }));
1437
+ }));
1438
+ }));
1439
+ }
1440
+ receiveOffer(e, t) {
1441
+ var s;
1442
+ return ee(this, void 0, void 0, (function* () {
1443
+ r.Log(r.GetStackTrace(), "Receive Offer", 6), (s = this.peerConnection) === null || s === void 0 || s.setRemoteDescription(e).then((() => {
1444
+ const n = location.hostname === "localhost" || location.hostname === "127.0.0.1", i = location.protocol === "https:";
1445
+ let o = t.isFlagEnabled(l.UseMic);
1446
+ !o || n || i || (o = !1, r.Error(r.GetStackTrace(), "Microphone access in the browser will not work if you are not on HTTPS or localhost. Disabling mic access."), r.Error(r.GetStackTrace(), "For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'")), this.config.setOptionSettingOptions(f.PreferredCodec, this.fuzzyIntersectUEAndBrowserCodecs(e)), this.setupTransceiversAsync(o).finally((() => {
1447
+ var d;
1448
+ (d = this.peerConnection) === null || d === void 0 || d.createAnswer().then(((c) => {
1449
+ var m;
1450
+ return c.sdp = this.mungeSDP(c.sdp, o), (m = this.peerConnection) === null || m === void 0 ? void 0 : m.setLocalDescription(c);
1451
+ })).then((() => {
1452
+ var c;
1453
+ this.onSendWebRTCAnswer((c = this.peerConnection) === null || c === void 0 ? void 0 : c.currentLocalDescription);
1454
+ })).catch((() => {
1455
+ r.Error(r.GetStackTrace(), "createAnswer() failed");
1456
+ }));
1457
+ }));
1458
+ }));
1459
+ }));
1460
+ }
1461
+ receiveAnswer(e) {
1462
+ var t;
1463
+ (t = this.peerConnection) === null || t === void 0 || t.setRemoteDescription(e), this.config.setOptionSettingOptions(f.PreferredCodec, this.fuzzyIntersectUEAndBrowserCodecs(e));
1464
+ }
1465
+ generateStats() {
1466
+ var e;
1467
+ (e = this.peerConnection) === null || e === void 0 || e.getStats(null).then(((t) => {
1468
+ this.aggregatedStats.processStats(t), this.onVideoStats(this.aggregatedStats), this.updateCodecSelection && this.aggregatedStats.inboundVideoStats.codecId && this.config.setOptionSettingValue(f.PreferredCodec, this.aggregatedStats.codecs.get(this.aggregatedStats.inboundVideoStats.codecId));
1469
+ }));
1470
+ }
1471
+ close() {
1472
+ this.peerConnection && (this.peerConnection.close(), this.peerConnection = null);
1473
+ }
1474
+ mungeSDP(e, t) {
1475
+ let s = e.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm, `$1;x-google-start-bitrate=10000;x-google-max-bitrate=100000\r
1476
+ `), n = "maxaveragebitrate=510000;";
1477
+ return t && (n += "sprop-maxcapturerate=48000;"), n += this.config.isFlagEnabled(l.ForceMonoAudio) ? "stereo=0;" : "stereo=1;", n += "useinbandfec=1", s = s.replace("useinbandfec=1", n), s;
1478
+ }
1479
+ handleOnIce(e) {
1480
+ var t;
1481
+ r.Log(r.GetStackTrace(), "peerconnection handleOnIce", 6), this.config.isFlagEnabled(l.ForceTURN) && e.candidate.indexOf("relay") < 0 ? r.Info(r.GetStackTrace(), `Dropping candidate because it was not TURN relay. | Type= ${e.type} | Protocol= ${e.protocol} | Address=${e.address} | Port=${e.port} |`, 6) : (t = this.peerConnection) === null || t === void 0 || t.addIceCandidate(e);
1482
+ }
1483
+ handleSignalStateChange(e) {
1484
+ r.Log(r.GetStackTrace(), "signaling state change: " + e, 6);
1485
+ }
1486
+ handleIceConnectionStateChange(e) {
1487
+ r.Log(r.GetStackTrace(), "ice connection state change: " + e, 6), this.onIceConnectionStateChange(e);
1488
+ }
1489
+ handleIceGatheringStateChange(e) {
1490
+ r.Log(r.GetStackTrace(), "ice gathering state change: " + JSON.stringify(e), 6);
1491
+ }
1492
+ handleOnTrack(e) {
1493
+ this.onTrack(e);
1494
+ }
1495
+ handleIceCandidate(e) {
1496
+ this.onPeerIceCandidate(e);
1497
+ }
1498
+ handleDataChannel(e) {
1499
+ this.onDataChannel(e);
1500
+ }
1501
+ onTrack(e) {
1502
+ }
1503
+ onIceConnectionStateChange(e) {
1504
+ }
1505
+ onPeerIceCandidate(e) {
1506
+ }
1507
+ onDataChannel(e) {
1508
+ }
1509
+ fuzzyIntersectUEAndBrowserCodecs(e) {
1510
+ const t = new Array(), s = this.parseAvailableCodecs(e), n = this.config.getSettingOption(f.PreferredCodec).options;
1511
+ for (const i of s) if (n.includes(i)) t.push(i);
1512
+ else {
1513
+ const o = i.split(" ")[0];
1514
+ for (const d of n) if (d.includes(o)) {
1515
+ t.push(d);
1516
+ break;
1517
+ }
1518
+ }
1519
+ return t;
1520
+ }
1521
+ setupTransceiversAsync(e) {
1522
+ var t, s, n, i, o, d, c, m, u, v, S, y;
1523
+ return ee(this, void 0, void 0, (function* () {
1524
+ let P = !1;
1525
+ for (const C of (s = (t = this.peerConnection) === null || t === void 0 ? void 0 : t.getTransceivers()) !== null && s !== void 0 ? s : []) if (C && C.receiver && C.receiver.track && C.receiver.track.kind === "video") {
1526
+ P = !0;
1527
+ break;
1528
+ }
1529
+ if (P || (n = this.peerConnection) === null || n === void 0 || n.addTransceiver("video", { direction: "recvonly" }), RTCRtpReceiver.getCapabilities && this.preferredCodec != "") {
1530
+ for (const C of (o = (i = this.peerConnection) === null || i === void 0 ? void 0 : i.getTransceivers()) !== null && o !== void 0 ? o : []) if (C && C.receiver && C.receiver.track && C.receiver.track.kind === "video" && C.setCodecPreferences) {
1531
+ const A = this.preferredCodec.split(" "), R = { mimeType: "video/" + A[0], clockRate: 9e4, sdpFmtpLine: A[1] ? A[1] : "" }, w = [R];
1532
+ RTCRtpReceiver.getCapabilities("video").codecs.forEach(((T) => {
1533
+ (T.mimeType != R.mimeType || T?.sdpFmtpLine != R?.sdpFmtpLine) && w.push(T);
1534
+ }));
1535
+ for (const T of w) T?.sdpFmtpLine !== void 0 && T.sdpFmtpLine !== "" || delete T.sdpFmtpLine;
1536
+ C.setCodecPreferences(w);
1537
+ }
1538
+ }
1539
+ let x = !1;
1540
+ for (const C of (c = (d = this.peerConnection) === null || d === void 0 ? void 0 : d.getTransceivers()) !== null && c !== void 0 ? c : []) if (C && C.receiver && C.receiver.track && C.receiver.track.kind === "audio") {
1541
+ x = !0;
1542
+ break;
1543
+ }
1544
+ if (e) {
1545
+ const C = { video: !1, audio: { autoGainControl: !1, channelCount: 1, echoCancellation: !1, latency: 0, noiseSuppression: !1, sampleRate: 48e3, sampleSize: 16, volume: 1 } }, A = yield navigator.mediaDevices.getUserMedia(C);
1546
+ if (A) if (x) {
1547
+ for (const R of (v = (u = this.peerConnection) === null || u === void 0 ? void 0 : u.getTransceivers()) !== null && v !== void 0 ? v : []) if (st.canTransceiverReceiveAudio(R)) for (const w of A.getTracks()) w.kind && w.kind == "audio" && (R.sender.replaceTrack(w), R.direction = "sendrecv");
1548
+ } else for (const R of A.getTracks()) R.kind && R.kind == "audio" && ((S = this.peerConnection) === null || S === void 0 || S.addTransceiver(R, { direction: "sendrecv" }));
1549
+ else x || (y = this.peerConnection) === null || y === void 0 || y.addTransceiver("audio", { direction: "recvonly" });
1550
+ } else x || (m = this.peerConnection) === null || m === void 0 || m.addTransceiver("audio", { direction: "recvonly" });
1551
+ }));
1552
+ }
1553
+ onVideoStats(e) {
1554
+ }
1555
+ onSendWebRTCOffer(e) {
1556
+ }
1557
+ onSendWebRTCAnswer(e) {
1558
+ }
1559
+ showTextOverlayConnecting() {
1560
+ }
1561
+ showTextOverlaySetupFailure() {
1562
+ }
1563
+ parseAvailableCodecs(e) {
1564
+ if (!RTCRtpReceiver.getCapabilities) return ["Only available on Chrome"];
1565
+ const t = [], s = (0, he.splitSections)(e.sdp);
1566
+ return s.shift(), s.forEach(((n) => {
1567
+ const { codecs: i } = (0, he.parseRtpParameters)(n), o = /(VP\d|H26\d|AV1).*/;
1568
+ i.forEach(((d) => {
1569
+ const c = d.name + " " + Object.keys(d.parameters || {}).map(((m) => m + "=" + d.parameters[m])).join(";");
1570
+ if (o.exec(c) !== null) {
1571
+ d.name == "VP9" && (d.parameters = { "profile-id": "0" });
1572
+ const m = d.name + " " + Object.keys(d.parameters || {}).map(((u) => u + "=" + d.parameters[u])).join(";");
1573
+ t.push(m);
1574
+ }
1575
+ }));
1576
+ })), t;
1577
+ }
1578
+ }
1579
+ class nt {
1580
+ constructor() {
1581
+ this.PixelStreamingSettings = new Ot(), this.EncoderSettings = new rt(), this.WebRTCSettings = new it();
1582
+ }
1583
+ ueCompatible() {
1584
+ this.WebRTCSettings.MaxFPS != null && (this.WebRTCSettings.FPS = this.WebRTCSettings.MaxFPS);
1585
+ }
1586
+ }
1587
+ class Ot {
1588
+ }
1589
+ class rt {
1590
+ }
1591
+ class it {
1592
+ }
1593
+ class at {
1594
+ constructor() {
1595
+ this.ReceiptTimeMs = null, this.TransmissionTimeMs = null, this.PreCaptureTimeMs = null, this.PostCaptureTimeMs = null, this.PreEncodeTimeMs = null, this.PostEncodeTimeMs = null, this.EncodeMs = null, this.CaptureToSendMs = null, this.testStartTimeMs = 0, this.browserReceiptTimeMs = 0, this.latencyExcludingDecode = 0, this.testDuration = 0, this.networkLatency = 0, this.browserSendLatency = 0, this.frameDisplayDeltaTimeMs = 0, this.endToEndLatency = 0, this.encodeLatency = 0;
1596
+ }
1597
+ setFrameDisplayDeltaTime(e) {
1598
+ this.frameDisplayDeltaTimeMs == 0 && (this.frameDisplayDeltaTimeMs = Math.round(e));
1599
+ }
1600
+ processFields() {
1601
+ this.EncodeMs != null || this.PreEncodeTimeMs == null && this.PostEncodeTimeMs == null || (r.Log(r.GetStackTrace(), `Setting Encode Ms
1602
+ ${this.PostEncodeTimeMs}
1603
+ ${this.PreEncodeTimeMs}`, 6), this.EncodeMs = this.PostEncodeTimeMs - this.PreEncodeTimeMs), this.CaptureToSendMs != null || this.PreCaptureTimeMs == null && this.PostCaptureTimeMs == null || (r.Log(r.GetStackTrace(), `Setting CaptureToSendMs Ms
1604
+ ${this.PostCaptureTimeMs}
1605
+ ${this.PreCaptureTimeMs}`, 6), this.CaptureToSendMs = this.PostCaptureTimeMs - this.PreCaptureTimeMs);
1606
+ }
1607
+ }
1608
+ class te {
1609
+ static setExtensionFromBytes(e, t) {
1610
+ t.receiving || (t.mimetype = "", t.extension = "", t.receiving = !0, t.valid = !1, t.chunks = 0, t.data = [], t.timestampStart = (/* @__PURE__ */ new Date()).getTime(), r.Log(r.GetStackTrace(), "Received first chunk of file", 6));
1611
+ const s = new TextDecoder("utf-16").decode(e.slice(1));
1612
+ r.Log(r.GetStackTrace(), s, 6), t.extension = s;
1613
+ }
1614
+ static setMimeTypeFromBytes(e, t) {
1615
+ t.receiving || (t.mimetype = "", t.extension = "", t.receiving = !0, t.valid = !1, t.chunks = 0, t.data = [], t.timestampStart = (/* @__PURE__ */ new Date()).getTime(), r.Log(r.GetStackTrace(), "Received first chunk of file", 6));
1616
+ const s = new TextDecoder("utf-16").decode(e.slice(1));
1617
+ r.Log(r.GetStackTrace(), s, 6), t.mimetype = s;
1618
+ }
1619
+ static setContentsFromBytes(e, t) {
1620
+ if (!t.receiving) return;
1621
+ t.chunks = Math.ceil(new DataView(e.slice(1, 5).buffer).getInt32(0, !0) / 16379);
1622
+ const s = e.slice(5);
1623
+ if (t.data.push(s), r.Log(r.GetStackTrace(), `Received file chunk: ${t.data.length}/${t.chunks}`, 6), t.data.length === t.chunks) {
1624
+ t.receiving = !1, t.valid = !0, r.Log(r.GetStackTrace(), "Received complete file", 6);
1625
+ const n = (/* @__PURE__ */ new Date()).getTime() - t.timestampStart, i = Math.round(16384 * t.chunks / n);
1626
+ r.Log(r.GetStackTrace(), `Average transfer bitrate: ${i}kb/s over ${n / 1e3} seconds`, 6);
1627
+ const o = new Blob(t.data, { type: t.mimetype }), d = document.createElement("a");
1628
+ d.setAttribute("href", URL.createObjectURL(o)), d.setAttribute("download", `transfer.${t.extension}`), document.body.append(d), d.remove();
1629
+ } else t.data.length > t.chunks && (t.receiving = !1, r.Error(r.GetStackTrace(), `Received bigger file than advertised: ${t.data.length}/${t.chunks}`));
1630
+ }
1631
+ }
1632
+ class It {
1633
+ constructor() {
1634
+ this.mimetype = "", this.extension = "", this.receiving = !1, this.chunks = 0, this.data = [], this.valid = !1;
1635
+ }
1636
+ }
1637
+ class b {
1638
+ }
1639
+ b.mainButton = 0, b.auxiliaryButton = 1, b.secondaryButton = 2, b.fourthButton = 3, b.fifthButton = 4;
1640
+ class k {
1641
+ }
1642
+ k.primaryButton = 1, k.secondaryButton = 2, k.auxiliaryButton = 4, k.fourthButton = 8, k.fifthButton = 16;
1643
+ class V {
1644
+ constructor() {
1645
+ this.unregisterCallbacks = [];
1646
+ }
1647
+ addUnregisterCallback(e) {
1648
+ this.unregisterCallbacks.push(e);
1649
+ }
1650
+ unregisterAll() {
1651
+ for (const e of this.unregisterCallbacks) e();
1652
+ this.unregisterCallbacks = [];
1653
+ }
1654
+ }
1655
+ class Ut {
1656
+ constructor(e, t, s) {
1657
+ this.touchEventListenerTracker = new V(), this.toStreamerMessagesProvider = e, this.videoElementProvider = t, this.coordinateConverter = s;
1658
+ const n = (d) => this.onTouchStart(d), i = (d) => this.onTouchEnd(d), o = (d) => this.onTouchMove(d);
1659
+ document.addEventListener("touchstart", n, { passive: !1 }), document.addEventListener("touchend", i, { passive: !1 }), document.addEventListener("touchmove", o, { passive: !1 }), this.touchEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("touchstart", n))), this.touchEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("touchend", i))), this.touchEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("touchmove", o)));
1660
+ }
1661
+ unregisterTouchEvents() {
1662
+ this.touchEventListenerTracker.unregisterAll();
1663
+ }
1664
+ setVideoElementParentClientRect(e) {
1665
+ this.videoElementParentClientRect = e;
1666
+ }
1667
+ onTouchStart(e) {
1668
+ if (this.videoElementProvider.isVideoReady() && e.target === this.videoElementProvider.getVideoElement()) {
1669
+ if (this.fakeTouchFinger == null) {
1670
+ const t = e.changedTouches[0];
1671
+ this.fakeTouchFinger = new Gt(t.identifier, t.clientX - this.videoElementParentClientRect.left, t.clientY - this.videoElementParentClientRect.top);
1672
+ const s = this.videoElementProvider.getVideoParentElement(), n = new MouseEvent("mouseenter", t);
1673
+ s.dispatchEvent(n);
1674
+ const i = this.coordinateConverter.normalizeAndQuantizeUnsigned(this.fakeTouchFinger.x, this.fakeTouchFinger.y);
1675
+ this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([b.mainButton, i.x, i.y]);
1676
+ }
1677
+ e.preventDefault();
1678
+ }
1679
+ }
1680
+ onTouchEnd(e) {
1681
+ if (!this.videoElementProvider.isVideoReady() || this.fakeTouchFinger == null) return;
1682
+ const t = this.videoElementProvider.getVideoParentElement(), s = this.toStreamerMessagesProvider.toStreamerHandlers;
1683
+ for (let n = 0; n < e.changedTouches.length; n++) {
1684
+ const i = e.changedTouches[n];
1685
+ if (i.identifier === this.fakeTouchFinger.id) {
1686
+ const o = i.clientX - this.videoElementParentClientRect.left, d = i.clientY - this.videoElementParentClientRect.top, c = this.coordinateConverter.normalizeAndQuantizeUnsigned(o, d);
1687
+ s.get("MouseUp")([b.mainButton, c.x, c.y]);
1688
+ const m = new MouseEvent("mouseleave", i);
1689
+ t.dispatchEvent(m), this.fakeTouchFinger = null;
1690
+ break;
1691
+ }
1692
+ }
1693
+ e.preventDefault();
1694
+ }
1695
+ onTouchMove(e) {
1696
+ if (!this.videoElementProvider.isVideoReady() || this.fakeTouchFinger == null) return;
1697
+ const t = this.toStreamerMessagesProvider.toStreamerHandlers;
1698
+ for (let s = 0; s < e.touches.length; s++) {
1699
+ const n = e.touches[s];
1700
+ if (n.identifier === this.fakeTouchFinger.id) {
1701
+ const i = n.clientX - this.videoElementParentClientRect.left, o = n.clientY - this.videoElementParentClientRect.top, d = this.coordinateConverter.normalizeAndQuantizeUnsigned(i, o), c = this.coordinateConverter.normalizeAndQuantizeSigned(i - this.fakeTouchFinger.x, o - this.fakeTouchFinger.y);
1702
+ t.get("MouseMove")([d.x, d.y, c.x, c.y]), this.fakeTouchFinger.x = i, this.fakeTouchFinger.y = o;
1703
+ break;
1704
+ }
1705
+ }
1706
+ e.preventDefault();
1707
+ }
1708
+ }
1709
+ class Gt {
1710
+ constructor(e, t, s) {
1711
+ this.id = e, this.x = t, this.y = s;
1712
+ }
1713
+ }
1714
+ class L {
1715
+ }
1716
+ L.backSpace = 8, L.shift = 16, L.control = 17, L.alt = 18, L.rightShift = 253, L.rightControl = 254, L.rightAlt = 255;
1717
+ class Bt {
1718
+ constructor(e, t, s) {
1719
+ this.keyboardEventListenerTracker = new V(), this.CodeToKeyCode = { Escape: 27, Digit0: 48, Digit1: 49, Digit2: 50, Digit3: 51, Digit4: 52, Digit5: 53, Digit6: 54, Digit7: 55, Digit8: 56, Digit9: 57, Minus: 173, Equal: 187, Backspace: 8, Tab: 9, KeyQ: 81, KeyW: 87, KeyE: 69, KeyR: 82, KeyT: 84, KeyY: 89, KeyU: 85, KeyI: 73, KeyO: 79, KeyP: 80, BracketLeft: 219, BracketRight: 221, Enter: 13, ControlLeft: 17, KeyA: 65, KeyS: 83, KeyD: 68, KeyF: 70, KeyG: 71, KeyH: 72, KeyJ: 74, KeyK: 75, KeyL: 76, Semicolon: 186, Quote: 222, Backquote: 192, ShiftLeft: 16, Backslash: 220, KeyZ: 90, KeyX: 88, KeyC: 67, KeyV: 86, KeyB: 66, KeyN: 78, KeyM: 77, Comma: 188, Period: 190, Slash: 191, ShiftRight: 253, AltLeft: 18, Space: 32, CapsLock: 20, F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123, Pause: 19, ScrollLock: 145, NumpadDivide: 111, NumpadMultiply: 106, NumpadSubtract: 109, NumpadAdd: 107, NumpadDecimal: 110, Numpad9: 105, Numpad8: 104, Numpad7: 103, Numpad6: 102, Numpad5: 101, Numpad4: 100, Numpad3: 99, Numpad2: 98, Numpad1: 97, Numpad0: 96, NumLock: 144, ControlRight: 254, AltRight: 255, Home: 36, End: 35, ArrowUp: 38, ArrowLeft: 37, ArrowRight: 39, ArrowDown: 40, PageUp: 33, PageDown: 34, Insert: 45, Delete: 46, ContextMenu: 93 }, this.toStreamerMessagesProvider = e, this.config = t, this.activeKeysProvider = s;
1720
+ }
1721
+ registerKeyBoardEvents() {
1722
+ const e = (i) => this.handleOnCompositionEnd(i), t = (i) => this.handleOnKeyDown(i), s = (i) => this.handleOnKeyUp(i), n = (i) => this.handleOnKeyPress(i);
1723
+ document.addEventListener("compositionend", e), document.addEventListener("keydown", t), document.addEventListener("keyup", s), document.addEventListener("keypress", n), this.keyboardEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("compositionend", e))), this.keyboardEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("keydown", t))), this.keyboardEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("keyup", s))), this.keyboardEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("keypress", n)));
1724
+ }
1725
+ unregisterKeyBoardEvents() {
1726
+ this.keyboardEventListenerTracker.unregisterAll();
1727
+ }
1728
+ handleOnKeyDown(e) {
1729
+ const t = this.getKeycode(e);
1730
+ t && t !== 229 && (r.Log(r.GetStackTrace(), `key down ${t}, repeat = ${e.repeat}`, 6), this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyDown")([this.getKeycode(e), e.repeat ? 1 : 0]), this.activeKeysProvider.getActiveKeys().push(t), t === L.backSpace && document.dispatchEvent(new KeyboardEvent("keypress", { charCode: L.backSpace })), this.config.isFlagEnabled(l.SuppressBrowserKeys) && this.isKeyCodeBrowserKey(t) && e.preventDefault());
1731
+ }
1732
+ handleOnKeyUp(e) {
1733
+ const t = this.getKeycode(e);
1734
+ t && (r.Log(r.GetStackTrace(), `key up ${t}`, 6), this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyUp")([t]), this.config.isFlagEnabled(l.SuppressBrowserKeys) && this.isKeyCodeBrowserKey(t) && e.preventDefault());
1735
+ }
1736
+ handleOnKeyPress(e) {
1737
+ if (!("charCode" in e)) return void r.Warning(r.GetStackTrace(), "KeyboardEvent.charCode is deprecated in this browser, cannot send key press.");
1738
+ const t = e.charCode;
1739
+ r.Log(r.GetStackTrace(), `key press ${t}`, 6), this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyPress")([t]);
1740
+ }
1741
+ handleOnCompositionEnd(e) {
1742
+ e.data && e.data.length && e.data.split("").forEach(((t) => {
1743
+ this.handleOnKeyDown(new KeyboardEvent("keydown", { keyCode: t.toUpperCase().charCodeAt(0), charCode: t.charCodeAt(0) })), this.handleOnKeyPress(new KeyboardEvent("keypress", { keyCode: t.toUpperCase().charCodeAt(0), charCode: t.charCodeAt(0) })), this.handleOnKeyUp(new KeyboardEvent("keyup", { keyCode: t.toUpperCase().charCodeAt(0), charCode: t.charCodeAt(0) }));
1744
+ }));
1745
+ }
1746
+ getKeycode(e) {
1747
+ if (!("keyCode" in e)) {
1748
+ const t = e;
1749
+ return t.code in this.CodeToKeyCode ? this.CodeToKeyCode[t.code] : (r.Warning(r.GetStackTrace(), `Keyboard code of ${t.code} is not supported in our mapping, ignoring this key.`), null);
1750
+ }
1751
+ return e.keyCode === L.shift && e.code === "ShiftRight" ? L.rightShift : e.keyCode === L.control && e.code === "ControlRight" ? L.rightControl : e.keyCode === L.alt && e.code === "AltRight" ? L.rightAlt : e.keyCode;
1752
+ }
1753
+ isKeyCodeBrowserKey(e) {
1754
+ return e >= 112 && e <= 123 || e === 9;
1755
+ }
1756
+ }
1757
+ class zt {
1758
+ constructor(e, t, s) {
1759
+ this.x = 0, this.y = 0, this.updateMouseMovePositionEvent = (i) => {
1760
+ this.updateMouseMovePosition(i);
1761
+ }, this.mouseEventListenerTracker = new V(), this.videoElementProvider = e, this.mouseController = t, this.activeKeysProvider = s;
1762
+ const n = this.videoElementProvider.getVideoParentElement();
1763
+ this.x = n.getBoundingClientRect().width / 2, this.y = n.getBoundingClientRect().height / 2, this.coord = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(this.x, this.y);
1764
+ }
1765
+ unregisterMouseEvents() {
1766
+ this.mouseEventListenerTracker.unregisterAll();
1767
+ }
1768
+ lockStateChange() {
1769
+ const e = this.videoElementProvider.getVideoParentElement(), t = this.mouseController.toStreamerMessagesProvider.toStreamerHandlers;
1770
+ if (document.pointerLockElement === e || document.mozPointerLockElement === e) r.Log(r.GetStackTrace(), "Pointer locked", 6), document.addEventListener("mousemove", this.updateMouseMovePositionEvent, !1), this.mouseEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("mousemove", this.updateMouseMovePositionEvent, !1)));
1771
+ else {
1772
+ r.Log(r.GetStackTrace(), "The pointer lock status is now unlocked", 6), document.removeEventListener("mousemove", this.updateMouseMovePositionEvent, !1);
1773
+ let s = this.activeKeysProvider.getActiveKeys();
1774
+ const n = new Set(s), i = [];
1775
+ n.forEach(((o) => {
1776
+ })), i.forEach(((o) => {
1777
+ t.get("KeyUp")([o]);
1778
+ })), s = [];
1779
+ }
1780
+ }
1781
+ updateMouseMovePosition(e) {
1782
+ if (!this.videoElementProvider.isVideoReady()) return;
1783
+ const t = this.mouseController.toStreamerMessagesProvider.toStreamerHandlers, s = this.videoElementProvider.getVideoParentElement().clientWidth, n = this.videoElementProvider.getVideoParentElement().clientHeight;
1784
+ this.x += e.movementX, this.y += e.movementY, this.x > s && (this.x -= s), this.y > n && (this.y -= n), this.x < 0 && (this.x = s + this.x), this.y < 0 && (this.y = n - this.y), this.coord = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(this.x, this.y);
1785
+ const i = this.mouseController.coordinateConverter.normalizeAndQuantizeSigned(e.movementX, e.movementY);
1786
+ t.get("MouseMove")([this.coord.x, this.coord.y, i.x, i.y]);
1787
+ }
1788
+ handleMouseDown(e) {
1789
+ this.videoElementProvider.isVideoReady() && this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([e.button, this.coord.x, this.coord.y]);
1790
+ }
1791
+ handleMouseUp(e) {
1792
+ this.videoElementProvider.isVideoReady() && this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e.button, this.coord.x, this.coord.y]);
1793
+ }
1794
+ handleMouseWheel(e) {
1795
+ this.videoElementProvider.isVideoReady() && this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseWheel")([e.wheelDelta, this.coord.x, this.coord.y]);
1796
+ }
1797
+ handleMouseDouble(e) {
1798
+ this.videoElementProvider.isVideoReady() && this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDouble")([e.button, this.coord.x, this.coord.y]);
1799
+ }
1800
+ handlePressMouseButtons(e) {
1801
+ this.videoElementProvider.isVideoReady() && this.mouseController.pressMouseButtons(e.buttons, this.x, this.y);
1802
+ }
1803
+ handleReleaseMouseButtons(e) {
1804
+ this.videoElementProvider.isVideoReady() && this.mouseController.releaseMouseButtons(e.buttons, this.x, this.y);
1805
+ }
1806
+ }
1807
+ class _t {
1808
+ constructor(e) {
1809
+ this.mouseController = e;
1810
+ }
1811
+ unregisterMouseEvents() {
1812
+ }
1813
+ updateMouseMovePosition(e) {
1814
+ if (!this.mouseController.videoElementProvider.isVideoReady()) return;
1815
+ r.Log(r.GetStackTrace(), "MouseMove", 6);
1816
+ const t = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX, e.offsetY), s = this.mouseController.coordinateConverter.normalizeAndQuantizeSigned(e.movementX, e.movementY);
1817
+ this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseMove")([t.x, t.y, s.x, s.y]), e.preventDefault();
1818
+ }
1819
+ handleMouseDown(e) {
1820
+ if (!this.mouseController.videoElementProvider.isVideoReady()) return;
1821
+ r.Log(r.GetStackTrace(), "onMouse Down", 6);
1822
+ const t = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX, e.offsetY);
1823
+ this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([e.button, t.x, t.y]), e.preventDefault();
1824
+ }
1825
+ handleMouseUp(e) {
1826
+ if (!this.mouseController.videoElementProvider.isVideoReady()) return;
1827
+ r.Log(r.GetStackTrace(), "onMouse Up", 6);
1828
+ const t = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX, e.offsetY);
1829
+ this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e.button, t.x, t.y]), e.preventDefault();
1830
+ }
1831
+ handleContextMenu(e) {
1832
+ this.mouseController.videoElementProvider.isVideoReady() && e.preventDefault();
1833
+ }
1834
+ handleMouseWheel(e) {
1835
+ if (!this.mouseController.videoElementProvider.isVideoReady()) return;
1836
+ const t = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX, e.offsetY);
1837
+ this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseWheel")([e.wheelDelta, t.x, t.y]), e.preventDefault();
1838
+ }
1839
+ handleMouseDouble(e) {
1840
+ if (!this.mouseController.videoElementProvider.isVideoReady()) return;
1841
+ const t = this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX, e.offsetY);
1842
+ this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDouble")([e.button, t.x, t.y]);
1843
+ }
1844
+ handlePressMouseButtons(e) {
1845
+ this.mouseController.videoElementProvider.isVideoReady() && (r.Log(r.GetStackTrace(), "onMouse press", 6), this.mouseController.pressMouseButtons(e.buttons, e.offsetX, e.offsetY));
1846
+ }
1847
+ handleReleaseMouseButtons(e) {
1848
+ this.mouseController.videoElementProvider.isVideoReady() && (r.Log(r.GetStackTrace(), "onMouse release", 6), this.mouseController.releaseMouseButtons(e.buttons, e.offsetX, e.offsetY));
1849
+ }
1850
+ }
1851
+ class Vt {
1852
+ constructor(e, t, s, n) {
1853
+ this.mouseEventListenerTracker = new V(), this.toStreamerMessagesProvider = e, this.coordinateConverter = s, this.videoElementProvider = t, this.activeKeysProvider = n, this.registerMouseEnterAndLeaveEvents();
1854
+ }
1855
+ unregisterMouseEvents() {
1856
+ this.mouseEventListenerTracker.unregisterAll();
1857
+ }
1858
+ registerLockedMouseEvents(e) {
1859
+ const t = this.videoElementProvider.getVideoParentElement(), s = new zt(this.videoElementProvider, e, this.activeKeysProvider);
1860
+ if (t.requestPointerLock = t.requestPointerLock || t.mozRequestPointerLock, document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock, t.requestPointerLock) {
1861
+ const m = () => {
1862
+ t.requestPointerLock();
1863
+ };
1864
+ t.addEventListener("click", m), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("click", m)));
1865
+ }
1866
+ const n = () => s.lockStateChange();
1867
+ document.addEventListener("pointerlockchange", n, !1), document.addEventListener("mozpointerlockchange", n, !1), this.mouseEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("pointerlockchange", n, !1))), this.mouseEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("mozpointerlockchange", n, !1)));
1868
+ const i = (m) => s.handleMouseDown(m), o = (m) => s.handleMouseUp(m), d = (m) => s.handleMouseWheel(m), c = (m) => s.handleMouseDouble(m);
1869
+ t.addEventListener("mousedown", i), t.addEventListener("mouseup", o), t.addEventListener("wheel", d), t.addEventListener("dblclick", c), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("mousedown", i))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("mouseup", o))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("wheel", d))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("dblclick", c))), this.mouseEventListenerTracker.addUnregisterCallback((() => s.unregisterMouseEvents())), this.mouseEventListenerTracker.addUnregisterCallback((() => {
1870
+ !document.exitPointerLock || document.pointerLockElement !== t && document.mozPointerLockElement !== t || document.exitPointerLock();
1871
+ }));
1872
+ }
1873
+ registerHoveringMouseEvents(e) {
1874
+ const t = this.videoElementProvider.getVideoParentElement(), s = new _t(e), n = (u) => s.updateMouseMovePosition(u), i = (u) => s.handleMouseDown(u), o = (u) => s.handleMouseUp(u), d = (u) => s.handleContextMenu(u), c = (u) => s.handleMouseWheel(u), m = (u) => s.handleMouseDouble(u);
1875
+ t.addEventListener("mousemove", n), t.addEventListener("mousedown", i), t.addEventListener("mouseup", o), t.addEventListener("contextmenu", d), t.addEventListener("wheel", c), t.addEventListener("dblclick", m), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("mousemove", n))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("mousedown", i))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("mouseup", o))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("contextmenu", d))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("wheel", c))), this.mouseEventListenerTracker.addUnregisterCallback((() => t.removeEventListener("dblclick", m))), this.mouseEventListenerTracker.addUnregisterCallback((() => s.unregisterMouseEvents()));
1876
+ }
1877
+ registerMouseEnterAndLeaveEvents() {
1878
+ const e = this.videoElementProvider.getVideoParentElement(), t = (n) => {
1879
+ this.videoElementProvider.isVideoReady() && (r.Log(r.GetStackTrace(), "Mouse Entered", 6), this.sendMouseEnter(), this.pressMouseButtons(n.buttons, n.x, n.y));
1880
+ }, s = (n) => {
1881
+ this.videoElementProvider.isVideoReady() && (r.Log(r.GetStackTrace(), "Mouse Left", 6), this.sendMouseLeave(), this.releaseMouseButtons(n.buttons, n.x, n.y));
1882
+ };
1883
+ e.addEventListener("mouseenter", t), e.addEventListener("mouseleave", s), this.mouseEventListenerTracker.addUnregisterCallback((() => e.removeEventListener("mouseenter", t))), this.mouseEventListenerTracker.addUnregisterCallback((() => e.removeEventListener("mouseleave", s)));
1884
+ }
1885
+ releaseMouseButtons(e, t, s) {
1886
+ const n = this.coordinateConverter.normalizeAndQuantizeUnsigned(t, s);
1887
+ e & k.primaryButton && this.sendMouseUp(b.mainButton, n.x, n.y), e & k.secondaryButton && this.sendMouseUp(b.secondaryButton, n.x, n.y), e & k.auxiliaryButton && this.sendMouseUp(b.auxiliaryButton, n.x, n.y), e & k.fourthButton && this.sendMouseUp(b.fourthButton, n.x, n.y), e & k.fifthButton && this.sendMouseUp(b.fifthButton, n.x, n.y);
1888
+ }
1889
+ pressMouseButtons(e, t, s) {
1890
+ if (!this.videoElementProvider.isVideoReady()) return;
1891
+ const n = this.coordinateConverter.normalizeAndQuantizeUnsigned(t, s);
1892
+ e & k.primaryButton && this.sendMouseDown(b.mainButton, n.x, n.y), e & k.secondaryButton && this.sendMouseDown(b.secondaryButton, n.x, n.y), e & k.auxiliaryButton && this.sendMouseDown(b.auxiliaryButton, n.x, n.y), e & k.fourthButton && this.sendMouseDown(b.fourthButton, n.x, n.y), e & k.fifthButton && this.sendMouseDown(b.fifthButton, n.x, n.y);
1893
+ }
1894
+ sendMouseEnter() {
1895
+ this.videoElementProvider.isVideoReady() && this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseEnter")();
1896
+ }
1897
+ sendMouseLeave() {
1898
+ this.videoElementProvider.isVideoReady() && this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseLeave")();
1899
+ }
1900
+ sendMouseDown(e, t, s) {
1901
+ this.videoElementProvider.isVideoReady() && (r.Log(r.GetStackTrace(), `mouse button ${e} down at (${t}, ${s})`, 6), this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseDown")([e, t, s]));
1902
+ }
1903
+ sendMouseUp(e, t, s) {
1904
+ if (!this.videoElementProvider.isVideoReady()) return;
1905
+ r.Log(r.GetStackTrace(), `mouse button ${e} up at (${t}, ${s})`, 6);
1906
+ const n = this.coordinateConverter.normalizeAndQuantizeUnsigned(t, s);
1907
+ this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([e, n.x, n.y]);
1908
+ }
1909
+ }
1910
+ class Ht {
1911
+ constructor(e, t, s) {
1912
+ this.fingers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], this.fingerIds = /* @__PURE__ */ new Map(), this.maxByteValue = 255, this.touchEventListenerTracker = new V(), this.toStreamerMessagesProvider = e, this.videoElementProvider = t, this.coordinateConverter = s, this.videoElementParent = t.getVideoElement();
1913
+ const n = (c) => this.onTouchStart(c), i = (c) => this.onTouchEnd(c), o = (c) => this.onTouchMove(c);
1914
+ this.videoElementParent.addEventListener("touchstart", n), this.videoElementParent.addEventListener("touchend", i), this.videoElementParent.addEventListener("touchmove", o), this.touchEventListenerTracker.addUnregisterCallback((() => this.videoElementParent.removeEventListener("touchstart", n))), this.touchEventListenerTracker.addUnregisterCallback((() => this.videoElementParent.removeEventListener("touchend", i))), this.touchEventListenerTracker.addUnregisterCallback((() => this.videoElementParent.removeEventListener("touchmove", o))), r.Log(r.GetStackTrace(), "Touch Events Registered", 6);
1915
+ const d = (c) => {
1916
+ c.preventDefault();
1917
+ };
1918
+ document.addEventListener("touchmove", d), this.touchEventListenerTracker.addUnregisterCallback((() => document.removeEventListener("touchmove", d)));
1919
+ }
1920
+ unregisterTouchEvents() {
1921
+ this.touchEventListenerTracker.unregisterAll();
1922
+ }
1923
+ rememberTouch(e) {
1924
+ const t = this.fingers.pop();
1925
+ t === void 0 && r.Log(r.GetStackTrace(), "exhausted touch identifiers", 6), this.fingerIds.set(e.identifier, t);
1926
+ }
1927
+ forgetTouch(e) {
1928
+ this.fingers.push(this.fingerIds.get(e.identifier)), this.fingers.sort((function(t, s) {
1929
+ return s - t;
1930
+ })), this.fingerIds.delete(e.identifier);
1931
+ }
1932
+ onTouchStart(e) {
1933
+ if (this.videoElementProvider.isVideoReady()) {
1934
+ for (let t = 0; t < e.changedTouches.length; t++) this.rememberTouch(e.changedTouches[t]);
1935
+ r.Log(r.GetStackTrace(), "touch start", 6), this.emitTouchData("TouchStart", e.changedTouches), e.preventDefault();
1936
+ }
1937
+ }
1938
+ onTouchEnd(e) {
1939
+ if (this.videoElementProvider.isVideoReady()) {
1940
+ r.Log(r.GetStackTrace(), "touch end", 6), this.emitTouchData("TouchEnd", e.changedTouches);
1941
+ for (let t = 0; t < e.changedTouches.length; t++) this.forgetTouch(e.changedTouches[t]);
1942
+ e.preventDefault();
1943
+ }
1944
+ }
1945
+ onTouchMove(e) {
1946
+ this.videoElementProvider.isVideoReady() && (r.Log(r.GetStackTrace(), "touch move", 6), this.emitTouchData("TouchMove", e.touches), e.preventDefault());
1947
+ }
1948
+ emitTouchData(e, t) {
1949
+ if (!this.videoElementProvider.isVideoReady()) return;
1950
+ const s = this.videoElementProvider.getVideoParentElement().getBoundingClientRect(), n = this.toStreamerMessagesProvider.toStreamerHandlers;
1951
+ for (let i = 0; i < t.length; i++) {
1952
+ const d = t[i], c = d.clientX - s.left, m = d.clientY - s.top;
1953
+ r.Log(r.GetStackTrace(), `F${this.fingerIds.get(d.identifier)}=(${c}, ${m})`, 6);
1954
+ const u = this.coordinateConverter.normalizeAndQuantizeUnsigned(c, m);
1955
+ switch (e) {
1956
+ case "TouchStart":
1957
+ n.get("TouchStart")([1, u.x, u.y, this.fingerIds.get(d.identifier), this.maxByteValue * (d.force > 0 ? d.force : 1), u.inRange ? 1 : 0]);
1958
+ break;
1959
+ case "TouchEnd":
1960
+ n.get("TouchEnd")([1, u.x, u.y, this.fingerIds.get(d.identifier), this.maxByteValue * d.force, u.inRange ? 1 : 0]);
1961
+ break;
1962
+ case "TouchMove":
1963
+ n.get("TouchMove")([1, u.x, u.y, this.fingerIds.get(d.identifier), this.maxByteValue * (d.force > 0 ? d.force : 1), u.inRange ? 1 : 0]);
1964
+ }
1965
+ }
1966
+ }
1967
+ }
1968
+ class Wt {
1969
+ constructor(e) {
1970
+ this.gamePadEventListenerTracker = new V(), this.toStreamerMessagesProvider = e, this.requestAnimationFrame = (window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.requestAnimationFrame).bind(window);
1971
+ const t = window;
1972
+ if (window.addEventListener("beforeunload", ((s) => this.onBeforeUnload(s))), "GamepadEvent" in t) {
1973
+ const s = (i) => this.gamePadConnectHandler(i), n = (i) => this.gamePadDisconnectHandler(i);
1974
+ window.addEventListener("gamepadconnected", s), window.addEventListener("gamepaddisconnected", n), this.gamePadEventListenerTracker.addUnregisterCallback((() => window.removeEventListener("gamepadconnected", s))), this.gamePadEventListenerTracker.addUnregisterCallback((() => window.removeEventListener("gamepaddisconnected", n)));
1975
+ } else if ("WebKitGamepadEvent" in t) {
1976
+ const s = (i) => this.gamePadConnectHandler(i), n = (i) => this.gamePadDisconnectHandler(i);
1977
+ window.addEventListener("webkitgamepadconnected", s), window.addEventListener("webkitgamepaddisconnected", n), this.gamePadEventListenerTracker.addUnregisterCallback((() => window.removeEventListener("webkitgamepadconnected", s))), this.gamePadEventListenerTracker.addUnregisterCallback((() => window.removeEventListener("webkitgamepaddisconnected", n)));
1978
+ }
1979
+ if (this.controllers = [], navigator.getGamepads) for (const s of navigator.getGamepads()) s && this.gamePadConnectHandler(new GamepadEvent("gamepadconnected", { gamepad: s }));
1980
+ }
1981
+ unregisterGamePadEvents() {
1982
+ this.gamePadEventListenerTracker.unregisterAll();
1983
+ for (const e of this.controllers) e.id !== void 0 && this.onGamepadDisconnected(e.id);
1984
+ this.controllers = [], this.onGamepadConnected = () => {
1985
+ }, this.onGamepadDisconnected = () => {
1986
+ };
1987
+ }
1988
+ gamePadConnectHandler(e) {
1989
+ r.Log(r.GetStackTrace(), "Gamepad connect handler", 6);
1990
+ const t = e.gamepad, s = { currentState: t, prevState: t, id: void 0 };
1991
+ this.controllers.push(s), this.controllers[t.index].currentState = t, this.controllers[t.index].prevState = t, r.Log(r.GetStackTrace(), "gamepad: " + t.id + " connected", 6), window.requestAnimationFrame((() => this.updateStatus())), this.onGamepadConnected();
1992
+ }
1993
+ gamePadDisconnectHandler(e) {
1994
+ r.Log(r.GetStackTrace(), "Gamepad disconnect handler", 6), r.Log(r.GetStackTrace(), "gamepad: " + e.gamepad.id + " disconnected", 6);
1995
+ const t = this.controllers[e.gamepad.index];
1996
+ delete this.controllers[e.gamepad.index], this.controllers = this.controllers.filter(((s) => s !== void 0)), this.onGamepadDisconnected(t.id);
1997
+ }
1998
+ scanGamePads() {
1999
+ const e = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [];
2000
+ for (let t = 0; t < e.length; t++) e[t] && e[t].index in this.controllers && (this.controllers[e[t].index].currentState = e[t]);
2001
+ }
2002
+ updateStatus() {
2003
+ this.scanGamePads();
2004
+ const e = this.toStreamerMessagesProvider.toStreamerHandlers;
2005
+ for (const t of this.controllers) {
2006
+ const s = t.id === void 0 ? this.controllers.indexOf(t) : t.id, n = t.currentState;
2007
+ for (let i = 0; i < t.currentState.buttons.length; i++) {
2008
+ const o = t.currentState.buttons[i], d = t.prevState.buttons[i];
2009
+ o.pressed ? i == _.LeftTrigger ? e.get("GamepadAnalog")([s, 5, o.value]) : i == _.RightTrigger ? e.get("GamepadAnalog")([s, 6, o.value]) : e.get("GamepadButtonPressed")([s, i, d.pressed ? 1 : 0]) : !o.pressed && d.pressed && (i == _.LeftTrigger ? e.get("GamepadAnalog")([s, 5, 0]) : i == _.RightTrigger ? e.get("GamepadAnalog")([s, 6, 0]) : e.get("GamepadButtonReleased")([s, i, 0]));
2010
+ }
2011
+ for (let i = 0; i < n.axes.length; i += 2) {
2012
+ const o = parseFloat(n.axes[i].toFixed(4)), d = -parseFloat(n.axes[i + 1].toFixed(4));
2013
+ e.get("GamepadAnalog")([s, i + 1, o]), e.get("GamepadAnalog")([s, i + 2, d]);
2014
+ }
2015
+ this.controllers[s].prevState = n;
2016
+ }
2017
+ this.controllers.length > 0 && this.requestAnimationFrame((() => this.updateStatus()));
2018
+ }
2019
+ onGamepadResponseReceived(e) {
2020
+ for (const t of this.controllers) if (t.id === void 0) {
2021
+ t.id = e;
2022
+ break;
2023
+ }
2024
+ }
2025
+ onGamepadConnected() {
2026
+ }
2027
+ onGamepadDisconnected(e) {
2028
+ }
2029
+ onBeforeUnload(e) {
2030
+ for (const t of this.controllers) this.onGamepadDisconnected(t.id);
2031
+ }
2032
+ }
2033
+ (function(a) {
2034
+ a[a.RightClusterBottomButton = 0] = "RightClusterBottomButton", a[a.RightClusterRightButton = 1] = "RightClusterRightButton", a[a.RightClusterLeftButton = 2] = "RightClusterLeftButton", a[a.RightClusterTopButton = 3] = "RightClusterTopButton", a[a.LeftShoulder = 4] = "LeftShoulder", a[a.RightShoulder = 5] = "RightShoulder", a[a.LeftTrigger = 6] = "LeftTrigger", a[a.RightTrigger = 7] = "RightTrigger", a[a.SelectOrBack = 8] = "SelectOrBack", a[a.StartOrForward = 9] = "StartOrForward", a[a.LeftAnalogPress = 10] = "LeftAnalogPress", a[a.RightAnalogPress = 11] = "RightAnalogPress", a[a.LeftClusterTopButton = 12] = "LeftClusterTopButton", a[a.LeftClusterBottomButton = 13] = "LeftClusterBottomButton", a[a.LeftClusterLeftButton = 14] = "LeftClusterLeftButton", a[a.LeftClusterRightButton = 15] = "LeftClusterRightButton", a[a.CentreButton = 16] = "CentreButton", a[a.LeftStickHorizontal = 0] = "LeftStickHorizontal", a[a.LeftStickVertical = 1] = "LeftStickVertical", a[a.RightStickHorizontal = 2] = "RightStickHorizontal", a[a.RightStickVertical = 3] = "RightStickVertical";
2035
+ })(_ || (_ = {}));
2036
+ class Nt {
2037
+ constructor(e, t, s) {
2038
+ this.activeKeys = new Kt(), this.toStreamerMessagesProvider = e, this.videoElementProvider = t, this.coordinateConverter = s;
2039
+ }
2040
+ registerKeyBoard(e) {
2041
+ r.Log(r.GetStackTrace(), "Register Keyboard Events", 7);
2042
+ const t = new Bt(this.toStreamerMessagesProvider, e, this.activeKeys);
2043
+ return t.registerKeyBoardEvents(), t;
2044
+ }
2045
+ registerMouse(e) {
2046
+ r.Log(r.GetStackTrace(), "Register Mouse Events", 7);
2047
+ const t = new Vt(this.toStreamerMessagesProvider, this.videoElementProvider, this.coordinateConverter, this.activeKeys);
2048
+ switch (e) {
2049
+ case B.LockedMouse:
2050
+ t.registerLockedMouseEvents(t);
2051
+ break;
2052
+ case B.HoveringMouse:
2053
+ t.registerHoveringMouseEvents(t);
2054
+ break;
2055
+ default:
2056
+ r.Info(r.GetStackTrace(), "unknown Control Scheme Type Defaulting to Locked Mouse Events"), t.registerLockedMouseEvents(t);
2057
+ }
2058
+ return t;
2059
+ }
2060
+ registerTouch(e, t) {
2061
+ if (r.Log(r.GetStackTrace(), "Registering Touch", 6), e) {
2062
+ const s = new Ut(this.toStreamerMessagesProvider, this.videoElementProvider, this.coordinateConverter);
2063
+ return s.setVideoElementParentClientRect(t), s;
2064
+ }
2065
+ return new Ht(this.toStreamerMessagesProvider, this.videoElementProvider, this.coordinateConverter);
2066
+ }
2067
+ registerGamePad() {
2068
+ return r.Log(r.GetStackTrace(), "Register Game Pad", 7), new Wt(this.toStreamerMessagesProvider);
2069
+ }
2070
+ }
2071
+ class Kt {
2072
+ constructor() {
2073
+ this.activeKeys = [], this.activeKeys = [];
2074
+ }
2075
+ getActiveKeys() {
2076
+ return this.activeKeys;
2077
+ }
2078
+ }
2079
+ class Qt {
2080
+ constructor(e, t) {
2081
+ this.lastTimeResized = (/* @__PURE__ */ new Date()).getTime(), this.videoElement = document.createElement("video"), this.config = t, this.videoElement.id = "streamingVideo", this.videoElement.disablePictureInPicture = !0, this.videoElement.playsInline = !0, this.videoElement.style.width = "100%", this.videoElement.style.height = "100%", this.videoElement.style.position = "absolute", this.videoElement.style.pointerEvents = "all", e.appendChild(this.videoElement), this.onResizePlayerCallback = () => {
2082
+ console.log("Resolution changed, restyling player, did you forget to override this function?");
2083
+ }, this.onMatchViewportResolutionCallback = () => {
2084
+ console.log("Resolution changed and match viewport resolution is turned on, did you forget to override this function?");
2085
+ }, this.videoElement.onclick = () => {
2086
+ this.audioElement != null && this.audioElement.paused && this.audioElement.play(), this.videoElement.paused && this.videoElement.play();
2087
+ }, this.videoElement.onloadedmetadata = () => {
2088
+ this.onVideoInitialized();
2089
+ }, window.addEventListener("resize", (() => this.resizePlayerStyle()), !0), window.addEventListener("orientationchange", (() => this.onOrientationChange()));
2090
+ }
2091
+ setAudioElement(e) {
2092
+ this.audioElement = e;
2093
+ }
2094
+ play() {
2095
+ return this.videoElement.muted = this.config.isFlagEnabled(l.StartVideoMuted), this.videoElement.autoplay = this.config.isFlagEnabled(l.AutoPlayVideo), this.videoElement.play();
2096
+ }
2097
+ isPaused() {
2098
+ return this.videoElement.paused;
2099
+ }
2100
+ isVideoReady() {
2101
+ return this.videoElement.readyState !== void 0 && this.videoElement.readyState > 0;
2102
+ }
2103
+ hasVideoSource() {
2104
+ return this.videoElement.srcObject !== void 0 && this.videoElement.srcObject !== null;
2105
+ }
2106
+ getVideoElement() {
2107
+ return this.videoElement;
2108
+ }
2109
+ getVideoParentElement() {
2110
+ return this.videoElement.parentElement;
2111
+ }
2112
+ setVideoEnabled(e) {
2113
+ this.videoElement.srcObject.getTracks().forEach(((t) => t.enabled = e));
2114
+ }
2115
+ onVideoInitialized() {
2116
+ }
2117
+ onOrientationChange() {
2118
+ clearTimeout(this.orientationChangeTimeout), this.orientationChangeTimeout = window.setTimeout((() => {
2119
+ this.resizePlayerStyle();
2120
+ }), 500);
2121
+ }
2122
+ resizePlayerStyle() {
2123
+ const e = this.getVideoParentElement();
2124
+ e && (this.updateVideoStreamSize(), e.classList.contains("fixed-size") || this.resizePlayerStyleToFillParentElement(), this.onResizePlayerCallback());
2125
+ }
2126
+ resizePlayerStyleToFillParentElement() {
2127
+ this.getVideoParentElement().setAttribute("style", "top: 0px; left: 0px; width: 100%; height: 100%; cursor: default;");
2128
+ }
2129
+ updateVideoStreamSize() {
2130
+ if (this.config.isFlagEnabled(l.MatchViewportResolution)) if ((/* @__PURE__ */ new Date()).getTime() - this.lastTimeResized > 300) {
2131
+ const e = this.getVideoParentElement();
2132
+ if (!e) return;
2133
+ this.onMatchViewportResolutionCallback(e.clientWidth, e.clientHeight), this.lastTimeResized = (/* @__PURE__ */ new Date()).getTime();
2134
+ } else r.Log(r.GetStackTrace(), "Resizing too often - skipping", 6), clearTimeout(this.resizeTimeoutHandle), this.resizeTimeoutHandle = window.setTimeout((() => this.updateVideoStreamSize()), 100);
2135
+ }
2136
+ }
2137
+ class qt {
2138
+ constructor() {
2139
+ this.toStreamerHandlers = /* @__PURE__ */ new Map(), this.fromStreamerHandlers = /* @__PURE__ */ new Map(), this.toStreamerMessages = /* @__PURE__ */ new Map(), this.fromStreamerMessages = /* @__PURE__ */ new Map();
2140
+ }
2141
+ populateDefaultProtocol() {
2142
+ this.toStreamerMessages.set("IFrameRequest", { id: 0, structure: [] }), this.toStreamerMessages.set("RequestQualityControl", { id: 1, structure: [] }), this.toStreamerMessages.set("FpsRequest", { id: 2, structure: [] }), this.toStreamerMessages.set("AverageBitrateRequest", { id: 3, structure: [] }), this.toStreamerMessages.set("StartStreaming", { id: 4, structure: [] }), this.toStreamerMessages.set("StopStreaming", { id: 5, structure: [] }), this.toStreamerMessages.set("LatencyTest", { id: 6, structure: ["string"] }), this.toStreamerMessages.set("RequestInitialSettings", { id: 7, structure: [] }), this.toStreamerMessages.set("TestEcho", { id: 8, structure: [] }), this.toStreamerMessages.set("DataChannelLatencyTest", { id: 9, structure: [] }), this.toStreamerMessages.set("UIInteraction", { id: 50, structure: ["string"] }), this.toStreamerMessages.set("Command", { id: 51, structure: ["string"] }), this.toStreamerMessages.set("KeyDown", { id: 60, structure: ["uint8", "uint8"] }), this.toStreamerMessages.set("KeyUp", { id: 61, structure: ["uint8"] }), this.toStreamerMessages.set("KeyPress", { id: 62, structure: ["uint16"] }), this.toStreamerMessages.set("MouseEnter", { id: 70, structure: [] }), this.toStreamerMessages.set("MouseLeave", { id: 71, structure: [] }), this.toStreamerMessages.set("MouseDown", { id: 72, structure: ["uint8", "uint16", "uint16"] }), this.toStreamerMessages.set("MouseUp", { id: 73, structure: ["uint8", "uint16", "uint16"] }), this.toStreamerMessages.set("MouseMove", { id: 74, structure: ["uint16", "uint16", "int16", "int16"] }), this.toStreamerMessages.set("MouseWheel", { id: 75, structure: ["int16", "uint16", "uint16"] }), this.toStreamerMessages.set("MouseDouble", { id: 76, structure: ["uint8", "uint16", "uint16"] }), this.toStreamerMessages.set("TouchStart", { id: 80, structure: ["uint8", "uint16", "uint16", "uint8", "uint8", "uint8"] }), this.toStreamerMessages.set("TouchEnd", { id: 81, structure: ["uint8", "uint16", "uint16", "uint8", "uint8", "uint8"] }), this.toStreamerMessages.set("TouchMove", { id: 82, structure: ["uint8", "uint16", "uint16", "uint8", "uint8", "uint8"] }), this.toStreamerMessages.set("GamepadConnected", { id: 93, structure: [] }), this.toStreamerMessages.set("GamepadButtonPressed", { id: 90, structure: ["uint8", "uint8", "uint8"] }), this.toStreamerMessages.set("GamepadButtonReleased", { id: 91, structure: ["uint8", "uint8", "uint8"] }), this.toStreamerMessages.set("GamepadAnalog", { id: 92, structure: ["uint8", "uint8", "double"] }), this.toStreamerMessages.set("GamepadDisconnected", { id: 94, structure: ["uint8"] }), this.fromStreamerMessages.set(0, "QualityControlOwnership"), this.fromStreamerMessages.set(1, "Response"), this.fromStreamerMessages.set(2, "Command"), this.fromStreamerMessages.set(3, "FreezeFrame"), this.fromStreamerMessages.set(4, "UnfreezeFrame"), this.fromStreamerMessages.set(5, "VideoEncoderAvgQP"), this.fromStreamerMessages.set(6, "LatencyTest"), this.fromStreamerMessages.set(7, "InitialSettings"), this.fromStreamerMessages.set(8, "FileExtension"), this.fromStreamerMessages.set(9, "FileMimeType"), this.fromStreamerMessages.set(10, "FileContents"), this.fromStreamerMessages.set(11, "TestEcho"), this.fromStreamerMessages.set(12, "InputControlOwnership"), this.fromStreamerMessages.set(13, "GamepadResponse"), this.fromStreamerMessages.set(14, "DataChannelLatencyTest"), this.fromStreamerMessages.set(255, "Protocol");
2143
+ }
2144
+ registerMessageHandler(e, t, s) {
2145
+ switch (e) {
2146
+ case p.ToStreamer:
2147
+ this.toStreamerHandlers.set(t, s);
2148
+ break;
2149
+ case p.FromStreamer:
2150
+ this.fromStreamerHandlers.set(t, s);
2151
+ break;
2152
+ default:
2153
+ r.Log(r.GetStackTrace(), `Unknown message direction ${e}`);
2154
+ }
2155
+ }
2156
+ }
2157
+ (function(a) {
2158
+ a[a.ToStreamer = 0] = "ToStreamer", a[a.FromStreamer = 1] = "FromStreamer";
2159
+ })(p || (p = {}));
2160
+ class $t {
2161
+ constructor() {
2162
+ this.responseEventListeners = /* @__PURE__ */ new Map();
2163
+ }
2164
+ addResponseEventListener(e, t) {
2165
+ this.responseEventListeners.set(e, t);
2166
+ }
2167
+ removeResponseEventListener(e) {
2168
+ this.responseEventListeners.delete(e);
2169
+ }
2170
+ onResponse(e) {
2171
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.Response", 6);
2172
+ const t = new TextDecoder("utf-16").decode(e.slice(1));
2173
+ r.Log(r.GetStackTrace(), t, 6), this.responseEventListeners.forEach(((s) => {
2174
+ s(t);
2175
+ }));
2176
+ }
2177
+ }
2178
+ class jt {
2179
+ constructor(e, t) {
2180
+ this.dataChannelSender = e, this.toStreamerMessagesMapProvider = t;
2181
+ }
2182
+ sendMessageToStreamer(e, t) {
2183
+ t === void 0 && (t = []);
2184
+ const s = this.toStreamerMessagesMapProvider.toStreamerMessages.get(e);
2185
+ if (s === void 0) return void r.Error(r.GetStackTrace(), `Attempted to send a message to the streamer with message type: ${e}, but the frontend hasn't been configured to send such a message. Check you've added the message type in your cpp`);
2186
+ if (s.structure && t && s.structure.length !== t.length) return void r.Error(r.GetStackTrace(), `Provided message data doesn't match expected layout. Expected [ ${s.structure.map(((c) => {
2187
+ switch (c) {
2188
+ case "uint8":
2189
+ case "uint16":
2190
+ case "int16":
2191
+ case "float":
2192
+ case "double":
2193
+ return "number";
2194
+ case "string":
2195
+ return "string";
2196
+ }
2197
+ })).toString()} ] but received [ ${t.map(((c) => typeof c)).toString()} ]`);
2198
+ let n = 0;
2199
+ const i = new TextEncoder();
2200
+ t.forEach(((c, m) => {
2201
+ switch (s.structure[m]) {
2202
+ case "uint8":
2203
+ n += 1;
2204
+ break;
2205
+ case "uint16":
2206
+ case "int16":
2207
+ n += 2;
2208
+ break;
2209
+ case "float":
2210
+ n += 4;
2211
+ break;
2212
+ case "double":
2213
+ n += 8;
2214
+ break;
2215
+ case "string":
2216
+ n += 2, n += 2 * i.encode(c).length;
2217
+ }
2218
+ }));
2219
+ const o = new DataView(new ArrayBuffer(n + 1));
2220
+ o.setUint8(0, s.id);
2221
+ let d = 1;
2222
+ t.forEach(((c, m) => {
2223
+ switch (s.structure[m]) {
2224
+ case "uint8":
2225
+ o.setUint8(d, c), d += 1;
2226
+ break;
2227
+ case "uint16":
2228
+ o.setUint16(d, c, !0), d += 2;
2229
+ break;
2230
+ case "int16":
2231
+ o.setInt16(d, c, !0), d += 2;
2232
+ break;
2233
+ case "float":
2234
+ o.setFloat32(d, c, !0), d += 4;
2235
+ break;
2236
+ case "double":
2237
+ o.setFloat64(d, c, !0), d += 8;
2238
+ break;
2239
+ case "string":
2240
+ o.setUint16(d, c.length, !0), d += 2;
2241
+ for (let u = 0; u < c.length; u++) o.setUint16(d, c.charCodeAt(u), !0), d += 2;
2242
+ }
2243
+ })), this.dataChannelSender.canSend() ? this.dataChannelSender.sendData(o.buffer) : r.Info(r.GetStackTrace(), `Data channel cannot send yet, skipping sending message: ${e} - ${new Uint8Array(o.buffer)}`);
2244
+ }
2245
+ }
2246
+ class Xt {
2247
+ constructor(e) {
2248
+ this.sendMessageController = e;
2249
+ }
2250
+ SendRequestQualityControl() {
2251
+ this.sendMessageController.sendMessageToStreamer("RequestQualityControl");
2252
+ }
2253
+ SendMaxFpsRequest() {
2254
+ this.sendMessageController.sendMessageToStreamer("FpsRequest");
2255
+ }
2256
+ SendAverageBitrateRequest() {
2257
+ this.sendMessageController.sendMessageToStreamer("AverageBitrateRequest");
2258
+ }
2259
+ SendStartStreaming() {
2260
+ this.sendMessageController.sendMessageToStreamer("StartStreaming");
2261
+ }
2262
+ SendStopStreaming() {
2263
+ this.sendMessageController.sendMessageToStreamer("StopStreaming");
2264
+ }
2265
+ SendRequestInitialSettings() {
2266
+ this.sendMessageController.sendMessageToStreamer("RequestInitialSettings");
2267
+ }
2268
+ }
2269
+ class Jt {
2270
+ constructor(e) {
2271
+ this.dataChannelProvider = e;
2272
+ }
2273
+ canSend() {
2274
+ return this.dataChannelProvider.getDataChannelInstance().dataChannel !== void 0 && this.dataChannelProvider.getDataChannelInstance().dataChannel.readyState == "open";
2275
+ }
2276
+ sendData(e) {
2277
+ const t = this.dataChannelProvider.getDataChannelInstance();
2278
+ t.dataChannel.readyState == "open" ? (t.dataChannel.send(e), r.Log(r.GetStackTrace(), `Message Sent: ${new Uint8Array(e)}`, 6), this.resetAfkWarningTimerOnDataSend()) : r.Error(r.GetStackTrace(), `Message Failed: ${new Uint8Array(e)}`);
2279
+ }
2280
+ resetAfkWarningTimerOnDataSend() {
2281
+ }
2282
+ }
2283
+ class Yt {
2284
+ constructor(e) {
2285
+ this.videoElementProvider = e, this.normalizeAndQuantizeUnsignedFunc = () => {
2286
+ throw new Error("Normalize and quantize unsigned, method not implemented.");
2287
+ }, this.normalizeAndQuantizeSignedFunc = () => {
2288
+ throw new Error("Normalize and unquantize signed, method not implemented.");
2289
+ }, this.denormalizeAndUnquantizeUnsignedFunc = () => {
2290
+ throw new Error("Denormalize and unquantize unsigned, method not implemented.");
2291
+ };
2292
+ }
2293
+ normalizeAndQuantizeUnsigned(e, t) {
2294
+ return this.normalizeAndQuantizeUnsignedFunc(e, t);
2295
+ }
2296
+ unquantizeAndDenormalizeUnsigned(e, t) {
2297
+ return this.denormalizeAndUnquantizeUnsignedFunc(e, t);
2298
+ }
2299
+ normalizeAndQuantizeSigned(e, t) {
2300
+ return this.normalizeAndQuantizeSignedFunc(e, t);
2301
+ }
2302
+ setupNormalizeAndQuantize() {
2303
+ if (this.videoElementParent = this.videoElementProvider.getVideoParentElement(), this.videoElement = this.videoElementProvider.getVideoElement(), this.videoElementParent && this.videoElement) {
2304
+ const e = this.videoElementParent.clientWidth || 1, t = this.videoElementParent.clientHeight || 1, s = this.videoElement.videoWidth || 1, n = t / e, i = (this.videoElement.videoHeight || 1) / s;
2305
+ n > i ? (r.Log(r.GetStackTrace(), "Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio", 6), this.ratio = n / i, this.normalizeAndQuantizeUnsignedFunc = (o, d) => this.normalizeAndQuantizeUnsignedPlayerBigger(o, d), this.normalizeAndQuantizeSignedFunc = (o, d) => this.normalizeAndQuantizeSignedPlayerBigger(o, d), this.denormalizeAndUnquantizeUnsignedFunc = (o, d) => this.denormalizeAndUnquantizeUnsignedPlayerBigger(o, d)) : (r.Log(r.GetStackTrace(), "Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio", 6), this.ratio = i / n, this.normalizeAndQuantizeUnsignedFunc = (o, d) => this.normalizeAndQuantizeUnsignedPlayerSmaller(o, d), this.normalizeAndQuantizeSignedFunc = (o, d) => this.normalizeAndQuantizeSignedPlayerSmaller(o, d), this.denormalizeAndUnquantizeUnsignedFunc = (o, d) => this.denormalizeAndUnquantizeUnsignedPlayerSmaller(o, d));
2306
+ }
2307
+ }
2308
+ normalizeAndQuantizeUnsignedPlayerBigger(e, t) {
2309
+ const s = e / this.videoElementParent.clientWidth, n = this.ratio * (t / this.videoElementParent.clientHeight - 0.5) + 0.5;
2310
+ return s < 0 || s > 1 || n < 0 || n > 1 ? new Q(!1, 65535, 65535) : new Q(!0, 65536 * s, 65536 * n);
2311
+ }
2312
+ denormalizeAndUnquantizeUnsignedPlayerBigger(e, t) {
2313
+ const s = e / 65536, n = (t / 65536 - 0.5) / this.ratio + 0.5;
2314
+ return new oe(s * this.videoElementParent.clientWidth, n * this.videoElementParent.clientHeight);
2315
+ }
2316
+ normalizeAndQuantizeSignedPlayerBigger(e, t) {
2317
+ const s = e / (0.5 * this.videoElementParent.clientWidth), n = this.ratio * t / (0.5 * this.videoElementParent.clientHeight);
2318
+ return new ge(32767 * s, 32767 * n);
2319
+ }
2320
+ normalizeAndQuantizeUnsignedPlayerSmaller(e, t) {
2321
+ const s = this.ratio * (e / this.videoElementParent.clientWidth - 0.5) + 0.5, n = t / this.videoElementParent.clientHeight;
2322
+ return s < 0 || s > 1 || n < 0 || n > 1 ? new Q(!1, 65535, 65535) : new Q(!0, 65536 * s, 65536 * n);
2323
+ }
2324
+ denormalizeAndUnquantizeUnsignedPlayerSmaller(e, t) {
2325
+ const s = (e / 65536 - 0.5) / this.ratio + 0.5, n = t / 65536;
2326
+ return new oe(s * this.videoElementParent.clientWidth, n * this.videoElementParent.clientHeight);
2327
+ }
2328
+ normalizeAndQuantizeSignedPlayerSmaller(e, t) {
2329
+ const s = this.ratio * e / (0.5 * this.videoElementParent.clientWidth), n = t / (0.5 * this.videoElementParent.clientHeight);
2330
+ return new ge(32767 * s, 32767 * n);
2331
+ }
2332
+ }
2333
+ class Q {
2334
+ constructor(e, t, s) {
2335
+ this.inRange = e, this.x = t, this.y = s;
2336
+ }
2337
+ }
2338
+ class oe {
2339
+ constructor(e, t) {
2340
+ this.x = e, this.y = t;
2341
+ }
2342
+ }
2343
+ class ge {
2344
+ constructor(e, t) {
2345
+ this.x = e, this.y = t;
2346
+ }
2347
+ }
2348
+ class ot {
2349
+ constructor(e, t) {
2350
+ this.shouldShowPlayOverlay = !0, this.autoJoinTimer = void 0, this.config = e, this.pixelStreaming = t, this.responseController = new $t(), this.file = new It(), this.sdpConstraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !0 }, this.afkController = new Xe(this.config, this.pixelStreaming, this.onAfkTriggered.bind(this)), this.afkController.onAFKTimedOutCallback = () => {
2351
+ this.closeSignalingServer("You have been disconnected due to inactivity");
2352
+ }, this.freezeFrameController = new Mt(this.pixelStreaming.videoElementParent), this.videoPlayer = new Qt(this.pixelStreaming.videoElementParent, this.config), this.videoPlayer.onVideoInitialized = () => this.handleVideoInitialized(), this.videoPlayer.onMatchViewportResolutionCallback = (s, n) => {
2353
+ const i = { "Resolution.Width": s, "Resolution.Height": n };
2354
+ this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify(i)]);
2355
+ }, this.videoPlayer.onResizePlayerCallback = () => {
2356
+ this.setUpMouseAndFreezeFrame();
2357
+ }, this.streamController = new yt(this.videoPlayer), this.coordinateConverter = new Yt(this.videoPlayer), this.sendrecvDataChannelController = new ce(), this.recvDataChannelController = new ce(), this.registerDataChannelEventEmitters(this.sendrecvDataChannelController), this.registerDataChannelEventEmitters(this.recvDataChannelController), this.dataChannelSender = new Jt(this.sendrecvDataChannelController), this.dataChannelSender.resetAfkWarningTimerOnDataSend = () => this.afkController.resetAfkWarningTimer(), this.streamMessageController = new qt(), this.webSocketController = new pe(), this.webSocketController.onConfig = (s) => this.handleOnConfigMessage(s), this.webSocketController.onStreamerList = (s) => this.handleStreamerListMessage(s), this.webSocketController.onStreamerIDChanged = (s) => this.handleStreamerIDChangedMessage(s), this.webSocketController.onPlayerCount = (s) => {
2358
+ this.pixelStreaming._onPlayerCount(s.count);
2359
+ }, this.webSocketController.onOpen.addEventListener("open", (() => {
2360
+ this.config.isFlagEnabled(l.BrowserSendOffer) || this.webSocketController.requestStreamerList();
2361
+ })), this.webSocketController.onClose.addEventListener("close", ((s) => {
2362
+ const n = this.shouldReconnect && s.detail.code != 1001 && this.config.getNumericSettingValue(h.MaxReconnectAttempts) > 0, i = this.disconnectMessage ? this.disconnectMessage : s.detail.reason;
2363
+ this.pixelStreaming._onDisconnect(i, !n && !this.isReconnecting), this.afkController.stopAfkWarningTimer(), this.statsTimerHandle && this.statsTimerHandle !== void 0 && window.clearInterval(this.statsTimerHandle), this.setVideoEncoderAvgQP(0), this.setTouchInputEnabled(!1), this.setMouseInputEnabled(!1), this.setKeyboardInputEnabled(!1), this.setGamePadInputEnabled(!1), n && setTimeout((() => {
2364
+ this.isReconnecting = !0, this.reconnectAttempt++, this.tryReconnect(s.detail.reason);
2365
+ }), 2e3);
2366
+ })), this.sendMessageController = new jt(this.dataChannelSender, this.streamMessageController), this.toStreamerMessagesController = new Xt(this.sendMessageController), this.registerMessageHandlers(), this.streamMessageController.populateDefaultProtocol(), this.inputClassesFactory = new Nt(this.streamMessageController, this.videoPlayer, this.coordinateConverter), this.isUsingSFU = !1, this.isQualityController = !1, this.preferredCodec = "", this.shouldReconnect = !0, this.isReconnecting = !1, this.reconnectAttempt = 0, this.config._addOnOptionSettingChangedListener(f.StreamerId, ((s) => {
2367
+ s !== "" && (this.peerConnectionController.peerConnection.close(), this.peerConnectionController.createPeerConnection(this.peerConfig, this.preferredCodec), this.subscribedStream = s, this.webSocketController.sendSubscribe(s));
2368
+ })), this.setVideoEncoderAvgQP(-1), this.signallingUrlBuilder = () => {
2369
+ let s = this.config.getTextSettingValue(I.SignallingServerUrl);
2370
+ return this.config.isFlagEnabled(l.BrowserSendOffer) && (s += "?" + l.BrowserSendOffer + "=true"), s;
2371
+ };
2372
+ }
2373
+ requestUnquantizedAndDenormalizeUnsigned(e, t) {
2374
+ return this.coordinateConverter.unquantizeAndDenormalizeUnsigned(e, t);
2375
+ }
2376
+ handleOnMessage(e) {
2377
+ const t = new Uint8Array(e.data);
2378
+ r.Log(r.GetStackTrace(), "Message incoming:" + t, 6);
2379
+ const s = this.streamMessageController.fromStreamerMessages.get(t[0]);
2380
+ this.streamMessageController.fromStreamerHandlers.get(s)(e.data);
2381
+ }
2382
+ registerMessageHandlers() {
2383
+ this.streamMessageController.registerMessageHandler(p.FromStreamer, "QualityControlOwnership", ((e) => this.onQualityControlOwnership(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "Response", ((e) => this.responseController.onResponse(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "Command", ((e) => {
2384
+ this.onCommand(e);
2385
+ })), this.streamMessageController.registerMessageHandler(p.FromStreamer, "FreezeFrame", ((e) => this.onFreezeFrameMessage(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "UnfreezeFrame", (() => this.invalidateFreezeFrameAndEnableVideo())), this.streamMessageController.registerMessageHandler(p.FromStreamer, "VideoEncoderAvgQP", ((e) => this.handleVideoEncoderAvgQP(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "LatencyTest", ((e) => this.handleLatencyTestResult(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "DataChannelLatencyTest", ((e) => this.handleDataChannelLatencyTestResponse(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "InitialSettings", ((e) => this.handleInitialSettings(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "FileExtension", ((e) => this.onFileExtension(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "FileMimeType", ((e) => this.onFileMimeType(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "FileContents", ((e) => this.onFileContents(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "TestEcho", (() => {
2386
+ })), this.streamMessageController.registerMessageHandler(p.FromStreamer, "InputControlOwnership", ((e) => this.onInputControlOwnership(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "GamepadResponse", ((e) => this.onGamepadResponse(e))), this.streamMessageController.registerMessageHandler(p.FromStreamer, "Protocol", ((e) => this.onProtocolMessage(e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "IFrameRequest", (() => this.sendMessageController.sendMessageToStreamer("IFrameRequest"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "RequestQualityControl", (() => this.sendMessageController.sendMessageToStreamer("RequestQualityControl"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "FpsRequest", (() => this.sendMessageController.sendMessageToStreamer("FpsRequest"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "AverageBitrateRequest", (() => this.sendMessageController.sendMessageToStreamer("AverageBitrateRequest"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "StartStreaming", (() => this.sendMessageController.sendMessageToStreamer("StartStreaming"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "StopStreaming", (() => this.sendMessageController.sendMessageToStreamer("StopStreaming"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "LatencyTest", ((e) => this.sendMessageController.sendMessageToStreamer("LatencyTest", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "RequestInitialSettings", (() => this.sendMessageController.sendMessageToStreamer("RequestInitialSettings"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "TestEcho", (() => {
2387
+ })), this.streamMessageController.registerMessageHandler(p.ToStreamer, "UIInteraction", ((e) => this.sendMessageController.sendMessageToStreamer("UIInteraction", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "Command", ((e) => this.sendMessageController.sendMessageToStreamer("Command", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "TextboxEntry", ((e) => this.sendMessageController.sendMessageToStreamer("TextboxEntry", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "KeyDown", ((e) => this.sendMessageController.sendMessageToStreamer("KeyDown", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "KeyUp", ((e) => this.sendMessageController.sendMessageToStreamer("KeyUp", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "KeyPress", ((e) => this.sendMessageController.sendMessageToStreamer("KeyPress", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseEnter", ((e) => this.sendMessageController.sendMessageToStreamer("MouseEnter", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseLeave", ((e) => this.sendMessageController.sendMessageToStreamer("MouseLeave", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseDown", ((e) => this.sendMessageController.sendMessageToStreamer("MouseDown", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseUp", ((e) => this.sendMessageController.sendMessageToStreamer("MouseUp", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseMove", ((e) => this.sendMessageController.sendMessageToStreamer("MouseMove", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseWheel", ((e) => this.sendMessageController.sendMessageToStreamer("MouseWheel", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "MouseDouble", ((e) => this.sendMessageController.sendMessageToStreamer("MouseDouble", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "TouchStart", ((e) => this.sendMessageController.sendMessageToStreamer("TouchStart", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "TouchEnd", ((e) => this.sendMessageController.sendMessageToStreamer("TouchEnd", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "TouchMove", ((e) => this.sendMessageController.sendMessageToStreamer("TouchMove", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "GamepadConnected", (() => this.sendMessageController.sendMessageToStreamer("GamepadConnected"))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "GamepadButtonPressed", ((e) => this.sendMessageController.sendMessageToStreamer("GamepadButtonPressed", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "GamepadButtonReleased", ((e) => this.sendMessageController.sendMessageToStreamer("GamepadButtonReleased", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "GamepadAnalog", ((e) => this.sendMessageController.sendMessageToStreamer("GamepadAnalog", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "GamepadDisconnected", ((e) => this.sendMessageController.sendMessageToStreamer("GamepadDisconnected", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XREyeViews", ((e) => this.sendMessageController.sendMessageToStreamer("XREyeViews", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRHMDTransform", ((e) => this.sendMessageController.sendMessageToStreamer("XRHMDTransform", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRControllerTransform", ((e) => this.sendMessageController.sendMessageToStreamer("XRControllerTransform", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRSystem", ((e) => this.sendMessageController.sendMessageToStreamer("XRSystem", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRButtonTouched", ((e) => this.sendMessageController.sendMessageToStreamer("XRButtonTouched", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRButtonTouchReleased", ((e) => this.sendMessageController.sendMessageToStreamer("XRButtonTouchReleased", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRButtonPressed", ((e) => this.sendMessageController.sendMessageToStreamer("XRButtonPressed", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRButtonReleased", ((e) => this.sendMessageController.sendMessageToStreamer("XRButtonReleased", e))), this.streamMessageController.registerMessageHandler(p.ToStreamer, "XRAnalog", ((e) => this.sendMessageController.sendMessageToStreamer("XRAnalog", e)));
2388
+ }
2389
+ onCommand(e) {
2390
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.Command", 6);
2391
+ const t = new TextDecoder("utf-16").decode(e.slice(1));
2392
+ r.Log(r.GetStackTrace(), "Data Channel Command: " + t, 6);
2393
+ const s = JSON.parse(t);
2394
+ s.command === "onScreenKeyboard" && this.pixelStreaming._activateOnScreenKeyboard(s);
2395
+ }
2396
+ onProtocolMessage(e) {
2397
+ try {
2398
+ const t = new TextDecoder("utf-16").decode(e.slice(1)), s = JSON.parse(t);
2399
+ Object.prototype.hasOwnProperty.call(s, "Direction") || r.Error(r.GetStackTrace(), "Malformed protocol received. Ensure the protocol message contains a direction");
2400
+ const n = s.Direction;
2401
+ delete s.Direction, r.Log(r.GetStackTrace(), `Received new ${n == p.FromStreamer ? "FromStreamer" : "ToStreamer"} protocol. Updating existing protocol...`), Object.keys(s).forEach(((i) => {
2402
+ const o = s[i];
2403
+ switch (n) {
2404
+ case p.ToStreamer:
2405
+ if (!Object.prototype.hasOwnProperty.call(o, "id")) return void r.Error(r.GetStackTrace(), `ToStreamer->${i} protocol definition was malformed as it didn't contain at least an id
2406
+
2407
+ Definition was: ${JSON.stringify(o, null, 2)}`);
2408
+ if (i === "UIInteraction" || i === "Command" || i === "LatencyTest") return;
2409
+ this.streamMessageController.toStreamerHandlers.get(i) ? this.streamMessageController.toStreamerMessages.set(i, o) : r.Error(r.GetStackTrace(), `There was no registered handler for "${i}" - try adding one using registerMessageHandler(MessageDirection.ToStreamer, "${i}", myHandler)`);
2410
+ break;
2411
+ case p.FromStreamer:
2412
+ if (!Object.prototype.hasOwnProperty.call(o, "id")) return void r.Error(r.GetStackTrace(), `FromStreamer->${i} protocol definition was malformed as it didn't contain at least an id
2413
+
2414
+ Definition was: ${JSON.stringify(o, null, 2)}`);
2415
+ this.streamMessageController.fromStreamerHandlers.get(i) ? this.streamMessageController.fromStreamerMessages.set(o.id, i) : r.Error(r.GetStackTrace(), `There was no registered handler for "${o}" - try adding one using registerMessageHandler(MessageDirection.FromStreamer, "${i}", myHandler)`);
2416
+ break;
2417
+ default:
2418
+ r.Error(r.GetStackTrace(), `Unknown direction: ${n}`);
2419
+ }
2420
+ })), this.toStreamerMessagesController.SendRequestInitialSettings(), this.toStreamerMessagesController.SendRequestQualityControl();
2421
+ } catch (t) {
2422
+ r.Log(r.GetStackTrace(), t);
2423
+ }
2424
+ }
2425
+ onInputControlOwnership(e) {
2426
+ const t = new Uint8Array(e);
2427
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.InputControlOwnership", 6);
2428
+ const s = new Boolean(t[1]).valueOf();
2429
+ r.Log(r.GetStackTrace(), `Received input controller message - will your input control the stream: ${s}`), this.pixelStreaming._onInputControlOwnership(s);
2430
+ }
2431
+ onGamepadResponse(e) {
2432
+ const t = new TextDecoder("utf-16").decode(e.slice(1)), s = JSON.parse(t);
2433
+ this.gamePadController.onGamepadResponseReceived(s.controllerId);
2434
+ }
2435
+ onAfkTriggered() {
2436
+ this.afkController.onAfkClick(), this.videoPlayer.isPaused() && this.videoPlayer.hasVideoSource() && this.playStream();
2437
+ }
2438
+ setAfkEnabled(e) {
2439
+ e ? this.onAfkTriggered() : this.afkController.stopAfkWarningTimer();
2440
+ }
2441
+ tryReconnect(e) {
2442
+ this.webSocketController ? (this.isReconnecting = !0, this.webSocketController.webSocket && this.webSocketController.webSocket.readyState != WebSocket.CLOSED ? (this.closeSignalingServer(`${e} Restarting stream...`), setTimeout((() => {
2443
+ this.tryReconnect(e);
2444
+ }), 3e3)) : (this.pixelStreaming._onWebRtcAutoConnect(), this.connectToSignallingServer())) : r.Log(r.GetStackTrace(), "The Web Socket Controller does not exist so this will not work right now.");
2445
+ }
2446
+ loadFreezeFrameOrShowPlayOverlay() {
2447
+ this.pixelStreaming.dispatchEvent(new Ge({ shouldShowPlayOverlay: this.shouldShowPlayOverlay, isValid: this.freezeFrameController.valid, jpegData: this.freezeFrameController.jpeg })), this.shouldShowPlayOverlay === !0 ? (r.Log(r.GetStackTrace(), "showing play overlay"), this.resizePlayerStyle()) : (r.Log(r.GetStackTrace(), "showing freeze frame"), this.freezeFrameController.showFreezeFrame()), setTimeout((() => {
2448
+ this.videoPlayer.setVideoEnabled(!1);
2449
+ }), this.freezeFrameController.freezeFrameDelay);
2450
+ }
2451
+ onFreezeFrameMessage(e) {
2452
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.FreezeFrame", 6);
2453
+ const t = new Uint8Array(e);
2454
+ this.freezeFrameController.processFreezeFrameMessage(t, (() => this.loadFreezeFrameOrShowPlayOverlay()));
2455
+ }
2456
+ invalidateFreezeFrameAndEnableVideo() {
2457
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.FreezeFrame", 6), setTimeout((() => {
2458
+ this.pixelStreaming.dispatchEvent(new Be()), this.freezeFrameController.hideFreezeFrame();
2459
+ }), this.freezeFrameController.freezeFrameDelay), this.videoPlayer.getVideoElement() && this.videoPlayer.setVideoEnabled(!0);
2460
+ }
2461
+ onFileExtension(e) {
2462
+ const t = new Uint8Array(e);
2463
+ te.setExtensionFromBytes(t, this.file);
2464
+ }
2465
+ onFileMimeType(e) {
2466
+ const t = new Uint8Array(e);
2467
+ te.setMimeTypeFromBytes(t, this.file);
2468
+ }
2469
+ onFileContents(e) {
2470
+ const t = new Uint8Array(e);
2471
+ te.setContentsFromBytes(t, this.file);
2472
+ }
2473
+ playStream() {
2474
+ if (!this.videoPlayer.getVideoElement()) {
2475
+ const e = "Could not play video stream because the video player was not initialized correctly.";
2476
+ return this.pixelStreaming.dispatchEvent(new Ie({ message: e })), r.Error(r.GetStackTrace(), e), void this.closeSignalingServer("Stream not initialized correctly");
2477
+ }
2478
+ if (this.videoPlayer.hasVideoSource()) {
2479
+ if (this.setTouchInputEnabled(this.config.isFlagEnabled(l.TouchInput)), this.pixelStreaming.dispatchEvent(new Ue()), this.streamController.audioElement.srcObject) {
2480
+ const e = this.config.isFlagEnabled(l.StartVideoMuted);
2481
+ this.streamController.audioElement.muted = e, e ? this.playVideo() : this.streamController.audioElement.play().then((() => {
2482
+ this.playVideo();
2483
+ })).catch(((t) => {
2484
+ r.Log(r.GetStackTrace(), t), r.Log(r.GetStackTrace(), "Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay."), this.pixelStreaming.dispatchEvent(new ie({ reason: t }));
2485
+ }));
2486
+ } else this.playVideo();
2487
+ this.shouldShowPlayOverlay = !1, this.freezeFrameController.showFreezeFrame();
2488
+ } else r.Warning(r.GetStackTrace(), "Cannot play stream, the video element has no srcObject to play.");
2489
+ }
2490
+ playVideo() {
2491
+ this.videoPlayer.play().catch(((e) => {
2492
+ this.streamController.audioElement.srcObject && this.streamController.audioElement.pause(), r.Log(r.GetStackTrace(), e), r.Log(r.GetStackTrace(), "Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay."), this.pixelStreaming.dispatchEvent(new ie({ reason: e }));
2493
+ }));
2494
+ }
2495
+ autoPlayVideoOrSetUpPlayOverlay() {
2496
+ this.config.isFlagEnabled(l.AutoPlayVideo) && this.playStream(), this.resizePlayerStyle();
2497
+ }
2498
+ connectToSignallingServer() {
2499
+ this.locallyClosed = !1, this.shouldReconnect = !0, this.disconnectMessage = null;
2500
+ const e = this.signallingUrlBuilder();
2501
+ this.webSocketController.connect(e);
2502
+ }
2503
+ startSession(e) {
2504
+ if (this.peerConfig = e, this.config.isFlagEnabled(l.ForceTURN) && !this.checkTurnServerAvailability(e)) return r.Info(r.GetStackTrace(), "No turn server was found in the Peer Connection Options. TURN cannot be forced, closing connection. Please use STUN instead"), void this.closeSignalingServer("TURN cannot be forced, closing connection. Please use STUN instead.");
2505
+ this.peerConnectionController = new Dt(this.peerConfig, this.config, this.preferredCodec), this.peerConnectionController.onVideoStats = (s) => this.handleVideoStats(s), this.peerConnectionController.onSendWebRTCOffer = (s) => this.handleSendWebRTCOffer(s), this.peerConnectionController.onSendWebRTCAnswer = (s) => this.handleSendWebRTCAnswer(s), this.peerConnectionController.onPeerIceCandidate = (s) => this.handleSendIceCandidate(s), this.peerConnectionController.onDataChannel = (s) => this.handleDataChannel(s), this.peerConnectionController.showTextOverlayConnecting = () => this.pixelStreaming._onWebRtcConnecting(), this.peerConnectionController.showTextOverlaySetupFailure = () => this.pixelStreaming._onWebRtcFailed();
2506
+ let t = !1;
2507
+ this.peerConnectionController.onIceConnectionStateChange = () => {
2508
+ !t && ["connected", "completed"].includes(this.peerConnectionController.peerConnection.iceConnectionState) && (this.pixelStreaming._onWebRtcConnected(), t = !0);
2509
+ }, this.peerConnectionController.onTrack = (s) => this.streamController.handleOnTrack(s), this.config.isFlagEnabled(l.BrowserSendOffer) && (this.sendrecvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection, "cirrus", this.datachannelOptions), this.sendrecvDataChannelController.handleOnMessage = (s) => this.handleOnMessage(s), this.peerConnectionController.createOffer(this.sdpConstraints, this.config));
2510
+ }
2511
+ checkTurnServerAvailability(e) {
2512
+ if (!e.iceServers) return r.Info(r.GetStackTrace(), "A turn sever was not found"), !1;
2513
+ for (const t of e.iceServers) for (const s of t.urls) if (s.includes("turn")) return r.Log(r.GetStackTrace(), `A turn sever was found at ${s}`), !0;
2514
+ return r.Info(r.GetStackTrace(), "A turn sever was not found"), !1;
2515
+ }
2516
+ handleOnConfigMessage(e) {
2517
+ this.resizePlayerStyle(), this.startSession(e.peerConnectionOptions), this.webSocketController.onWebRtcAnswer = (t) => this.handleWebRtcAnswer(t), this.webSocketController.onWebRtcOffer = (t) => this.handleWebRtcOffer(t), this.webSocketController.onWebRtcPeerDataChannels = (t) => this.handleWebRtcSFUPeerDatachannels(t), this.webSocketController.onIceCandidate = (t) => this.handleIceCandidate(t);
2518
+ }
2519
+ handleStreamerListMessage(e) {
2520
+ r.Log(r.GetStackTrace(), `Got streamer list ${e.ids}`, 6);
2521
+ let t = null;
2522
+ var s = this.config.getSettingOption(f.StreamerId);
2523
+ s.selected.toString().trim() && (t = s.selected);
2524
+ const n = [...e.ids];
2525
+ n.unshift(""), this.config.setOptionSettingOptions(f.StreamerId, n);
2526
+ let i = null;
2527
+ const o = this.config.isFlagEnabled(l.WaitForStreamer), d = this.config.getNumericSettingValue(h.MaxReconnectAttempts), c = this.config.getNumericSettingValue(h.StreamerAutoJoinInterval), m = this.config.useUrlParams, u = new URLSearchParams(window.location.search);
2528
+ m && u.has(f.StreamerId) ? t = u.get(f.StreamerId) : this.subscribedStream && (t = this.subscribedStream), t && e.ids.includes(t) ? i = t : t && o || e.ids.length != 1 || (i = e.ids[0]), i ? (this.isReconnecting = !1, this.reconnectAttempt = 0, this.config.setOptionSettingValue(f.StreamerId, i)) : o && (this.reconnectAttempt < d ? (this.isReconnecting = !0, this.reconnectAttempt++, setTimeout((() => {
2529
+ this.webSocketController.requestStreamerList();
2530
+ }), c)) : (this.reconnectAttempt = 0, this.isReconnecting = !1, this.shouldReconnect = !1)), this.pixelStreaming.dispatchEvent(new _e({ messageStreamerList: e, autoSelectedStreamerId: i, wantedStreamerId: t }));
2531
+ }
2532
+ handleStreamerIDChangedMessage(e) {
2533
+ const t = e.newID;
2534
+ var s = this.config.getSettingOption(f.StreamerId), n = s.onChange;
2535
+ s.onChange = () => {
2536
+ };
2537
+ for (var i = s.options, o = 0; o < i.length; ++o) if (i[o] == this.subscribedStream) {
2538
+ i[o] = t;
2539
+ break;
2540
+ }
2541
+ s.options = i, s.selected = t, s.onChange = n, this.subscribedStream = e.newID, this.pixelStreaming.dispatchEvent(new Ve({ newID: t }));
2542
+ }
2543
+ handleWebRtcAnswer(e) {
2544
+ r.Log(r.GetStackTrace(), `Got answer sdp ${e.sdp}`, 6);
2545
+ const t = { sdp: e.sdp, type: "answer" };
2546
+ this.peerConnectionController.receiveAnswer(t), this.handlePostWebrtcNegotiation();
2547
+ }
2548
+ handleWebRtcOffer(e) {
2549
+ r.Log(r.GetStackTrace(), `Got offer sdp ${e.sdp}`, 6), this.isUsingSFU = !!e.sfu && e.sfu, this.isUsingSFU && (this.peerConnectionController.preferredCodec = "");
2550
+ const t = { sdp: e.sdp, type: "offer" };
2551
+ this.peerConnectionController.receiveOffer(t, this.config), this.handlePostWebrtcNegotiation();
2552
+ }
2553
+ handleWebRtcSFUPeerDatachannels(e) {
2554
+ const t = { ordered: !0, negotiated: !0, id: e.sendStreamId }, s = e.sendStreamId != e.recvStreamId;
2555
+ if (this.sendrecvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection, s ? "send-datachannel" : "datachannel", t), s) {
2556
+ const n = { ordered: !0, negotiated: !0, id: e.recvStreamId };
2557
+ this.recvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection, "recv-datachannel", n), this.recvDataChannelController.handleOnOpen = () => this.webSocketController.sendSFURecvDataChannelReady(), this.recvDataChannelController.handleOnMessage = (i) => this.handleOnMessage(i);
2558
+ } else this.sendrecvDataChannelController.handleOnMessage = (n) => this.handleOnMessage(n);
2559
+ }
2560
+ handlePostWebrtcNegotiation() {
2561
+ this.afkController.startAfkWarningTimer(), this.pixelStreaming._onWebRtcSdp(), this.statsTimerHandle && this.statsTimerHandle !== void 0 && window.clearInterval(this.statsTimerHandle), this.statsTimerHandle = window.setInterval((() => this.getStats()), 1e3), this.setMouseInputEnabled(this.config.isFlagEnabled(l.MouseInput)), this.setKeyboardInputEnabled(this.config.isFlagEnabled(l.KeyboardInput)), this.setGamePadInputEnabled(this.config.isFlagEnabled(l.GamepadInput));
2562
+ }
2563
+ handleIceCandidate(e) {
2564
+ r.Log(r.GetStackTrace(), "Web RTC Controller: onWebRtcIce", 6);
2565
+ const t = new RTCIceCandidate(e);
2566
+ this.peerConnectionController.handleOnIce(t);
2567
+ }
2568
+ handleSendIceCandidate(e) {
2569
+ r.Log(r.GetStackTrace(), "OnIceCandidate", 6), e.candidate && e.candidate.candidate && this.webSocketController.sendIceCandidate(e.candidate);
2570
+ }
2571
+ handleDataChannel(e) {
2572
+ r.Log(r.GetStackTrace(), "Data channel created for us by browser as we are a receiving peer.", 6), this.sendrecvDataChannelController.dataChannel = e.channel, this.sendrecvDataChannelController.setupDataChannel(), this.sendrecvDataChannelController.handleOnMessage = (t) => this.handleOnMessage(t);
2573
+ }
2574
+ handleSendWebRTCOffer(e) {
2575
+ r.Log(r.GetStackTrace(), "Sending the offer to the Server", 6);
2576
+ const t = { minBitrateBps: 1e3 * this.config.getNumericSettingValue(h.WebRTCMinBitrate), maxBitrateBps: 1e3 * this.config.getNumericSettingValue(h.WebRTCMaxBitrate) };
2577
+ this.webSocketController.sendWebRtcOffer(e, t);
2578
+ }
2579
+ handleSendWebRTCAnswer(e) {
2580
+ r.Log(r.GetStackTrace(), "Sending the answer to the Server", 6);
2581
+ const t = { minBitrateBps: 1e3 * this.config.getNumericSettingValue(h.WebRTCMinBitrate), maxBitrateBps: 1e3 * this.config.getNumericSettingValue(h.WebRTCMaxBitrate) };
2582
+ this.webSocketController.sendWebRtcAnswer(e, t), this.isUsingSFU && this.webSocketController.sendWebRtcDatachannelRequest();
2583
+ }
2584
+ setUpMouseAndFreezeFrame() {
2585
+ this.videoElementParentClientRect = this.videoPlayer.getVideoParentElement().getBoundingClientRect(), this.coordinateConverter.setupNormalizeAndQuantize(), this.freezeFrameController.freezeFrame.resize();
2586
+ }
2587
+ closeSignalingServer(e) {
2588
+ var t;
2589
+ this.locallyClosed = !0, this.shouldReconnect = !1, this.disconnectMessage = e, (t = this.webSocketController) === null || t === void 0 || t.close();
2590
+ }
2591
+ closePeerConnection() {
2592
+ var e;
2593
+ (e = this.peerConnectionController) === null || e === void 0 || e.close();
2594
+ }
2595
+ close() {
2596
+ this.closeSignalingServer(""), this.closePeerConnection();
2597
+ }
2598
+ getStats() {
2599
+ this.peerConnectionController.generateStats();
2600
+ }
2601
+ sendLatencyTest() {
2602
+ this.latencyStartTime = Date.now(), this.streamMessageController.toStreamerHandlers.get("LatencyTest")([JSON.stringify({ StartTime: this.latencyStartTime })]);
2603
+ }
2604
+ sendDataChannelLatencyTest(e) {
2605
+ this.streamMessageController.toStreamerHandlers.get("DataChannelLatencyTest")([JSON.stringify(e)]);
2606
+ }
2607
+ sendEncoderMinQP(e) {
2608
+ r.Log(r.GetStackTrace(), `MinQP=${e}
2609
+ `, 6), e != null && this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "Encoder.MinQP": e })]);
2610
+ }
2611
+ sendEncoderMaxQP(e) {
2612
+ r.Log(r.GetStackTrace(), `MaxQP=${e}
2613
+ `, 6), e != null && this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "Encoder.MaxQP": e })]);
2614
+ }
2615
+ sendWebRTCMinBitrate(e) {
2616
+ r.Log(r.GetStackTrace(), `WebRTC Min Bitrate=${e}`, 6), e != null && this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "WebRTC.MinBitrate": e })]);
2617
+ }
2618
+ sendWebRTCMaxBitrate(e) {
2619
+ r.Log(r.GetStackTrace(), `WebRTC Max Bitrate=${e}`, 6), e != null && this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "WebRTC.MaxBitrate": e })]);
2620
+ }
2621
+ sendWebRTCFps(e) {
2622
+ r.Log(r.GetStackTrace(), `WebRTC FPS=${e}`, 6), e != null && (this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "WebRTC.Fps": e })]), this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "WebRTC.MaxFps": e })]));
2623
+ }
2624
+ sendShowFps() {
2625
+ r.Log(r.GetStackTrace(), "---- Sending show stat to UE ----", 6), this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ "stat.fps": "" })]);
2626
+ }
2627
+ sendIframeRequest() {
2628
+ r.Log(r.GetStackTrace(), "---- Sending Request for an IFrame ----", 6), this.streamMessageController.toStreamerHandlers.get("IFrameRequest")();
2629
+ }
2630
+ emitUIInteraction(e) {
2631
+ r.Log(r.GetStackTrace(), "---- Sending custom UIInteraction message ----", 6), this.streamMessageController.toStreamerHandlers.get("UIInteraction")([JSON.stringify(e)]);
2632
+ }
2633
+ emitCommand(e) {
2634
+ r.Log(r.GetStackTrace(), "---- Sending custom Command message ----", 6), this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify(e)]);
2635
+ }
2636
+ emitConsoleCommand(e) {
2637
+ r.Log(r.GetStackTrace(), "---- Sending custom Command:ConsoleCommand message ----", 6), this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify({ ConsoleCommand: e })]);
2638
+ }
2639
+ sendRequestQualityControlOwnership() {
2640
+ r.Log(r.GetStackTrace(), "---- Sending Request to Control Quality ----", 6), this.toStreamerMessagesController.SendRequestQualityControl();
2641
+ }
2642
+ handleLatencyTestResult(e) {
2643
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.latencyTest", 6);
2644
+ const t = new TextDecoder("utf-16").decode(e.slice(1)), s = new at();
2645
+ Object.assign(s, JSON.parse(t)), s.processFields(), s.testStartTimeMs = this.latencyStartTime, s.browserReceiptTimeMs = Date.now(), s.latencyExcludingDecode = ~~(s.browserReceiptTimeMs - s.testStartTimeMs), s.testDuration = ~~(s.TransmissionTimeMs - s.ReceiptTimeMs), s.networkLatency = ~~(s.latencyExcludingDecode - s.testDuration), s.frameDisplayDeltaTimeMs && s.browserReceiptTimeMs && (s.endToEndLatency = (s.frameDisplayDeltaTimeMs, s.networkLatency, ~~+s.CaptureToSendMs)), this.pixelStreaming._onLatencyTestResult(s);
2646
+ }
2647
+ handleDataChannelLatencyTestResponse(e) {
2648
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.dataChannelLatencyResponse", 6);
2649
+ const t = new TextDecoder("utf-16").decode(e.slice(1)), s = JSON.parse(t);
2650
+ this.pixelStreaming._onDataChannelLatencyTestResponse(s);
2651
+ }
2652
+ handleInitialSettings(e) {
2653
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.InitialSettings", 6);
2654
+ const t = new TextDecoder("utf-16").decode(e.slice(1)), s = JSON.parse(t), n = new nt();
2655
+ s.Encoder && (n.EncoderSettings = s.Encoder), s.WebRTC && (n.WebRTCSettings = s.WebRTC), s.PixelStreaming && (n.PixelStreamingSettings = s.PixelStreaming), s.ConfigOptions && s.ConfigOptions.DefaultToHover !== void 0 && this.config.setFlagEnabled(l.HoveringMouseMode, !!s.ConfigOptions.DefaultToHover), n.ueCompatible(), r.Log(r.GetStackTrace(), t, 6), this.pixelStreaming._onInitialSettings(n);
2656
+ }
2657
+ handleVideoEncoderAvgQP(e) {
2658
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.VideoEncoderAvgQP", 6);
2659
+ const t = Number(new TextDecoder("utf-16").decode(e.slice(1)));
2660
+ this.setVideoEncoderAvgQP(t);
2661
+ }
2662
+ handleVideoInitialized() {
2663
+ this.pixelStreaming._onVideoInitialized(), this.autoPlayVideoOrSetUpPlayOverlay(), this.resizePlayerStyle(), this.videoPlayer.updateVideoStreamSize();
2664
+ }
2665
+ onQualityControlOwnership(e) {
2666
+ const t = new Uint8Array(e);
2667
+ r.Log(r.GetStackTrace(), "DataChannelReceiveMessageType.QualityControlOwnership", 6), this.isQualityController = new Boolean(t[1]).valueOf(), r.Log(r.GetStackTrace(), `Received quality controller message, will control quality: ${this.isQualityController}`), this.pixelStreaming._onQualityControlOwnership(this.isQualityController);
2668
+ }
2669
+ handleVideoStats(e) {
2670
+ this.pixelStreaming._onVideoStats(e);
2671
+ }
2672
+ resizePlayerStyle() {
2673
+ this.videoPlayer.resizePlayerStyle();
2674
+ }
2675
+ setPreferredCodec(e) {
2676
+ this.preferredCodec = e, this.peerConnectionController && (this.peerConnectionController.preferredCodec = e, this.peerConnectionController.updateCodecSelection = !1);
2677
+ }
2678
+ setVideoEncoderAvgQP(e) {
2679
+ this.videoAvgQp = e, this.pixelStreaming._onVideoEncoderAvgQP(this.videoAvgQp);
2680
+ }
2681
+ setKeyboardInputEnabled(e) {
2682
+ var t;
2683
+ (t = this.keyboardController) === null || t === void 0 || t.unregisterKeyBoardEvents(), e && (this.keyboardController = this.inputClassesFactory.registerKeyBoard(this.config));
2684
+ }
2685
+ setMouseInputEnabled(e) {
2686
+ var t;
2687
+ if ((t = this.mouseController) === null || t === void 0 || t.unregisterMouseEvents(), e) {
2688
+ const s = this.config.isFlagEnabled(l.HoveringMouseMode) ? B.HoveringMouse : B.LockedMouse;
2689
+ this.mouseController = this.inputClassesFactory.registerMouse(s);
2690
+ }
2691
+ }
2692
+ setTouchInputEnabled(e) {
2693
+ var t;
2694
+ (t = this.touchController) === null || t === void 0 || t.unregisterTouchEvents(), e && (this.touchController = this.inputClassesFactory.registerTouch(this.config.isFlagEnabled(l.FakeMouseWithTouches), this.videoElementParentClientRect));
2695
+ }
2696
+ setGamePadInputEnabled(e) {
2697
+ var t;
2698
+ (t = this.gamePadController) === null || t === void 0 || t.unregisterGamePadEvents(), e && (this.gamePadController = this.inputClassesFactory.registerGamePad(), this.gamePadController.onGamepadConnected = () => {
2699
+ this.streamMessageController.toStreamerHandlers.get("GamepadConnected")();
2700
+ }, this.gamePadController.onGamepadDisconnected = (s) => {
2701
+ this.streamMessageController.toStreamerHandlers.get("GamepadDisconnected")([s]);
2702
+ });
2703
+ }
2704
+ registerDataChannelEventEmitters(e) {
2705
+ e.onOpen = (t, s) => this.pixelStreaming.dispatchEvent(new Re({ label: t, event: s })), e.onClose = (t, s) => this.pixelStreaming.dispatchEvent(new ke({ label: t, event: s })), e.onError = (t, s) => this.pixelStreaming.dispatchEvent(new Le({ label: t, event: s }));
2706
+ }
2707
+ registerMessageHandler(e, t, s) {
2708
+ t === p.FromStreamer && s === void 0 && r.Warning(r.GetStackTrace(), `Unable to register handler for ${e} as no handler was passed`), this.streamMessageController.registerMessageHandler(t, e, ((n) => s === void 0 && t === p.ToStreamer ? this.sendMessageController.sendMessageToStreamer(e, n) : s(n)));
2709
+ }
2710
+ }
2711
+ class $ {
2712
+ constructor(e) {
2713
+ this.toStreamerMessagesProvider = e, this.controllers = [];
2714
+ }
2715
+ static deepCopyGamepad(e) {
2716
+ return JSON.parse(JSON.stringify({ buttons: e.buttons.map(((t) => JSON.parse(JSON.stringify({ pressed: t.pressed, touched: t.touched, value: t.value })))), axes: e.axes }));
2717
+ }
2718
+ updateStatus(e, t, s) {
2719
+ if (e.gamepad) {
2720
+ const n = t.getPose(e.gripSpace, s);
2721
+ if (!n) return;
2722
+ let i = 0;
2723
+ e.profiles.includes("htc-vive") ? i = 1 : e.profiles.includes("oculus-touch") && (i = 2), this.toStreamerMessagesProvider.toStreamerHandlers.get("XRSystem")([i]);
2724
+ let o = 2;
2725
+ switch (e.handedness) {
2726
+ case "left":
2727
+ o = 0;
2728
+ break;
2729
+ case "right":
2730
+ o = 1;
2731
+ }
2732
+ const d = n.transform.matrix, c = [];
2733
+ for (let S = 0; S < 16; S++) c[S] = new Float32Array([d[S]])[0];
2734
+ this.toStreamerMessagesProvider.toStreamerHandlers.get("XRControllerTransform")([c[0], c[4], c[8], c[12], c[1], c[5], c[9], c[13], c[2], c[6], c[10], c[14], c[3], c[7], c[11], c[15], o]), this.controllers[o] === void 0 && (this.controllers[o] = { prevState: void 0, currentState: void 0, id: void 0 }, this.controllers[o].prevState = $.deepCopyGamepad(e.gamepad)), this.controllers[o].currentState = $.deepCopyGamepad(e.gamepad);
2735
+ const m = this.controllers[o], u = m.currentState, v = m.prevState;
2736
+ for (let S = 0; S < u.buttons.length; S++) {
2737
+ const y = u.buttons[S], P = v.buttons[S];
2738
+ if (y.pressed) {
2739
+ let x = P.pressed ? 1 : 0;
2740
+ this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonPressed")([o, S, x]);
2741
+ } else P.pressed && this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonReleased")([o, S, 0]);
2742
+ if (y.touched) {
2743
+ let x = P.touched ? 1 : 0;
2744
+ this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonTouched")([o, S, x]);
2745
+ } else P.touched && this.toStreamerMessagesProvider.toStreamerHandlers.get("XRButtonTouchReleased")([o, S, 0]);
2746
+ }
2747
+ for (let S = 0; S < u.axes.length; S++) {
2748
+ let y = u.axes[S];
2749
+ y != v.axes[S] && this.toStreamerMessagesProvider.toStreamerHandlers.get("XRAnalog")([o, S, y]);
2750
+ }
2751
+ this.controllers[o].prevState = u;
2752
+ }
2753
+ }
2754
+ }
2755
+ class lt {
2756
+ constructor(e) {
2757
+ this.xrViewerPose = null, this.videoTexture = null, this.prevVideoWidth = 0, this.prevVideoHeight = 0, this.leftView = null, this.rightView = null, this.xrSession = null, this.webRtcController = e, this.xrGamepadController = new $(this.webRtcController.streamMessageController), this.onSessionEnded = new EventTarget(), this.onSessionStarted = new EventTarget(), this.onFrame = new EventTarget();
2758
+ }
2759
+ xrClicked() {
2760
+ if (this.xrSession) this.xrSession.end();
2761
+ else {
2762
+ if (!navigator.xr) return void r.Error(r.GetStackTrace(), "This browser does not support XR.");
2763
+ navigator.xr.requestSession("immersive-vr", { optionalFeatures: [] }).then(((e) => {
2764
+ this.onXrSessionStarted(e);
2765
+ }));
2766
+ }
2767
+ }
2768
+ onXrSessionEnded() {
2769
+ r.Log(r.GetStackTrace(), "XR Session ended"), this.xrSession = null, this.onSessionEnded.dispatchEvent(new Event("xrSessionEnded"));
2770
+ }
2771
+ initGL() {
2772
+ if (this.gl) return;
2773
+ const e = document.createElement("canvas");
2774
+ this.gl = e.getContext("webgl2", { xrCompatible: !0 }), this.gl.clearColor(0, 0, 0, 1);
2775
+ }
2776
+ initShaders() {
2777
+ const e = this.gl.createShader(this.gl.VERTEX_SHADER);
2778
+ this.gl.shaderSource(e, `
2779
+ attribute vec2 a_position;
2780
+ attribute vec2 a_texCoord;
2781
+
2782
+ // varyings
2783
+ varying vec2 v_texCoord;
2784
+
2785
+ void main() {
2786
+ gl_Position = vec4(a_position.x, a_position.y, 0, 1);
2787
+ // pass the texCoord to the fragment shader
2788
+ // The GPU will interpolate this value between points.
2789
+ v_texCoord = a_texCoord;
2790
+ }
2791
+ `), this.gl.compileShader(e);
2792
+ const t = this.gl.createShader(this.gl.FRAGMENT_SHADER);
2793
+ this.gl.shaderSource(t, `
2794
+ precision mediump float;
2795
+
2796
+ // our texture
2797
+ uniform sampler2D u_image;
2798
+
2799
+ // the texCoords passed in from the vertex shader.
2800
+ varying vec2 v_texCoord;
2801
+
2802
+ void main() {
2803
+ gl_FragColor = texture2D(u_image, v_texCoord);
2804
+ }
2805
+ `), this.gl.compileShader(t);
2806
+ const s = this.gl.createProgram();
2807
+ this.gl.attachShader(s, e), this.gl.attachShader(s, t), this.gl.linkProgram(s), this.gl.useProgram(s), this.positionLocation = this.gl.getAttribLocation(s, "a_position"), this.texcoordLocation = this.gl.getAttribLocation(s, "a_texCoord");
2808
+ }
2809
+ updateVideoTexture() {
2810
+ this.videoTexture || (this.videoTexture = this.gl.createTexture(), this.gl.bindTexture(this.gl.TEXTURE_2D, this.videoTexture), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR));
2811
+ let e = this.webRtcController.videoPlayer.getVideoElement().videoHeight, t = this.webRtcController.videoPlayer.getVideoElement().videoWidth;
2812
+ this.prevVideoHeight != e || this.prevVideoWidth != t ? this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, t, e, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, this.webRtcController.videoPlayer.getVideoElement()) : this.gl.texSubImage2D(this.gl.TEXTURE_2D, 0, 0, 0, t, e, this.gl.RGBA, this.gl.UNSIGNED_BYTE, this.webRtcController.videoPlayer.getVideoElement()), this.prevVideoHeight = e, this.prevVideoWidth = t;
2813
+ }
2814
+ initBuffers() {
2815
+ this.positionBuffer = this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.positionBuffer), this.gl.enableVertexAttribArray(this.positionLocation), this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([-1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1]), this.gl.STATIC_DRAW), this.gl.vertexAttribPointer(this.positionLocation, 2, this.gl.FLOAT, !1, 0, 0), this.texcoordBuffer = this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texcoordBuffer), this.gl.enableVertexAttribArray(this.texcoordLocation), this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), this.gl.STATIC_DRAW), this.gl.vertexAttribPointer(this.texcoordLocation, 2, this.gl.FLOAT, !1, 0, 0);
2816
+ }
2817
+ onXrSessionStarted(e) {
2818
+ r.Log(r.GetStackTrace(), "XR Session started"), this.xrSession = e, this.xrSession.addEventListener("end", (() => {
2819
+ this.onXrSessionEnded();
2820
+ })), this.initGL(), this.initShaders(), this.initBuffers(), e.requestReferenceSpace("local").then(((t) => {
2821
+ if (this.xrRefSpace = t, this.xrSession.updateRenderState({ baseLayer: new XRWebGLLayer(this.xrSession, this.gl) }), this.xrSession.supportedFrameRates) for (let s of this.xrSession.supportedFrameRates) s == 90 && e.updateTargetFrameRate(90);
2822
+ this.xrSession.requestAnimationFrame(this.onXrFrame.bind(this));
2823
+ })), this.onSessionStarted.dispatchEvent(new Event("xrSessionStarted"));
2824
+ }
2825
+ sendXRDataToUE() {
2826
+ if (this.leftView == null || this.rightView == null) return;
2827
+ const e = this.leftView.transform.matrix, t = this.leftView.projectionMatrix, s = this.rightView.transform.matrix, n = this.rightView.projectionMatrix;
2828
+ this.webRtcController.streamMessageController.toStreamerHandlers.get("XREyeViews")([e[0], e[4], e[8], e[12], e[1], e[5], e[9], e[13], e[2], e[6], e[10], e[14], e[3], e[7], e[11], e[15], t[0], t[4], t[8], t[12], t[1], t[5], t[9], t[13], t[2], t[6], t[10], t[14], t[3], t[7], t[11], t[15], s[0], s[4], s[8], s[12], s[1], s[5], s[9], s[13], s[2], s[6], s[10], s[14], s[3], s[7], s[11], s[15], n[0], n[4], n[8], n[12], n[1], n[5], n[9], n[13], n[2], n[6], n[10], n[14], n[3], n[7], n[11], n[15]]);
2829
+ }
2830
+ onXrFrame(e, t) {
2831
+ if (this.xrViewerPose = t.getViewerPose(this.xrRefSpace), this.xrViewerPose) {
2832
+ if (this.updateViews(), this.leftView == null || this.rightView == null) return;
2833
+ this.sendXRDataToUE(), this.updateVideoTexture(), this.render();
2834
+ }
2835
+ this.webRtcController.config.isFlagEnabled(l.XRControllerInput) && this.xrSession.inputSources.forEach(((s, n, i) => {
2836
+ this.xrGamepadController.updateStatus(s, t, this.xrRefSpace);
2837
+ }), this), this.xrSession.requestAnimationFrame(((s, n) => this.onXrFrame(s, n))), this.onFrame.dispatchEvent(new Qe({ time: e, frame: t }));
2838
+ }
2839
+ updateViews() {
2840
+ if (this.xrViewerPose) for (const e of this.xrViewerPose.views) e.eye === "left" ? this.leftView = e : e.eye === "right" && (this.rightView = e);
2841
+ }
2842
+ render() {
2843
+ if (!this.gl) return;
2844
+ const e = this.xrSession.renderState.baseLayer;
2845
+ this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, e.framebuffer), this.gl.viewport(0, 0, e.framebufferWidth, e.framebufferHeight), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
2846
+ }
2847
+ static isSessionSupported(e) {
2848
+ return location.protocol !== "https:" && r.Info(null, "WebXR requires https, if you want WebXR use https."), navigator.xr ? navigator.xr.isSessionSupported(e) : new Promise((() => !1));
2849
+ }
2850
+ }
2851
+ class Zt {
2852
+ constructor(e) {
2853
+ this.editTextButton = null, this.hiddenInput = null, "ontouchstart" in document.documentElement && this.createOnScreenKeyboardHelpers(e);
2854
+ }
2855
+ unquantizeAndDenormalizeUnsigned(e, t) {
2856
+ return null;
2857
+ }
2858
+ createOnScreenKeyboardHelpers(e) {
2859
+ this.hiddenInput || (this.hiddenInput = document.createElement("input"), this.hiddenInput.id = "hiddenInput", this.hiddenInput.maxLength = 0, this.hiddenInput.style.position = "absolute", this.hiddenInput.style.left = "-10%", this.hiddenInput.style.width = "0px", this.hiddenInput.style.opacity = "0", e.appendChild(this.hiddenInput)), this.editTextButton || (this.editTextButton = document.createElement("button"), this.editTextButton.id = "editTextButton", this.editTextButton.innerHTML = "edit text", e.appendChild(this.editTextButton), this.editTextButton.style.display = "none", this.editTextButton.addEventListener("touchend", ((t) => {
2860
+ this.hiddenInput.focus(), t.preventDefault();
2861
+ })));
2862
+ }
2863
+ showOnScreenKeyboard(e) {
2864
+ if (e.showOnScreenKeyboard) {
2865
+ this.editTextButton.style.display = "default";
2866
+ const t = this.unquantizeAndDenormalizeUnsigned(e.x, e.y);
2867
+ this.editTextButton.style.top = t.y.toString() + "px", this.editTextButton.style.left = (t.x - 40).toString() + "px";
2868
+ } else this.editTextButton.style.display = "none", this.hiddenInput.blur();
2869
+ }
2870
+ }
2871
+ class es {
2872
+ constructor(e) {
2873
+ this.seq = e.Seq, this.playerSentTimestamp = Date.now(), this.requestFillerSize = e.Filler ? e.Filler.length : 0;
2874
+ }
2875
+ update(e) {
2876
+ this.playerReceivedTimestamp = Date.now(), this.streamerReceivedTimestamp = e.ReceivedTimestamp, this.streamerSentTimestamp = e.SentTimestamp, this.responseFillerSize = e.Filler ? e.Filler.length : 0;
2877
+ }
2878
+ }
2879
+ class ts {
2880
+ constructor(e, t) {
2881
+ this.sink = e, this.callback = t, this.records = /* @__PURE__ */ new Map(), this.seq = 0;
2882
+ }
2883
+ start(e) {
2884
+ return !this.isRunning() && (this.startTime = Date.now(), this.records.clear(), this.interval = setInterval((() => {
2885
+ Date.now() - this.startTime >= e.duration ? this.stop() : this.sendRequest(e.requestSize, e.responseSize);
2886
+ }).bind(this), Math.floor(1e3 / e.rps)), !0);
2887
+ }
2888
+ stop() {
2889
+ this.interval && (clearInterval(this.interval), this.interval = void 0, this.callback(this.produceResult()));
2890
+ }
2891
+ produceResult() {
2892
+ const e = new Map(this.records);
2893
+ return { records: e, dataChannelRtt: Math.ceil(Array.from(this.records.values()).reduce(((t, s) => t + (s.playerReceivedTimestamp - s.playerSentTimestamp)), 0) / this.records.size), playerToStreamerTime: Math.ceil(Array.from(this.records.values()).reduce(((t, s) => t + (s.streamerReceivedTimestamp - s.playerSentTimestamp)), 0) / this.records.size), streamerToPlayerTime: Math.ceil(Array.from(this.records.values()).reduce(((t, s) => t + (s.playerReceivedTimestamp - s.streamerSentTimestamp)), 0) / this.records.size), exportLatencyAsCSV: () => {
2894
+ let t = `Timestamp;RTT;PlayerToStreamer;StreamerToPlayer;
2895
+ `;
2896
+ return e.forEach(((s) => {
2897
+ t += s.playerSentTimestamp + ";", t += s.playerReceivedTimestamp - s.playerSentTimestamp + ";", t += s.streamerReceivedTimestamp - s.playerSentTimestamp + ";", t += s.playerReceivedTimestamp - s.streamerSentTimestamp + ";", t += `
2898
+ `;
2899
+ })), t;
2900
+ } };
2901
+ }
2902
+ isRunning() {
2903
+ return !!this.interval;
2904
+ }
2905
+ receive(e) {
2906
+ if (!this.isRunning()) return;
2907
+ if (!e) return void r.Error(r.GetStackTrace(), "Undefined response from server");
2908
+ let t = this.records.get(e.Seq);
2909
+ t && t.update(e);
2910
+ }
2911
+ sendRequest(e, t) {
2912
+ let s = this.createRequest(e, t), n = new es(s);
2913
+ this.records.set(n.seq, n), this.sink(s);
2914
+ }
2915
+ createRequest(e, t) {
2916
+ return { Seq: this.seq++, FillResponseSize: t, Filler: e ? "A".repeat(e) : "" };
2917
+ }
2918
+ }
2919
+ class ss {
2920
+ constructor(e, t) {
2921
+ this.allowConsoleCommands = !1, this.config = e, t?.videoElementParent && (this._videoElementParent = t.videoElementParent), this._eventEmitter = new je(), this.configureSettings(), this.setWebRtcPlayerController(new ot(this.config, this)), this.onScreenKeyboardHelper = new Zt(this.videoElementParent), this.onScreenKeyboardHelper.unquantizeAndDenormalizeUnsigned = (s, n) => this._webRtcController.requestUnquantizedAndDenormalizeUnsigned(s, n), this._activateOnScreenKeyboard = (s) => this.onScreenKeyboardHelper.showOnScreenKeyboard(s), this._webXrController = new lt(this._webRtcController), this._setupWebRtcTCPRelayDetection = this._setupWebRtcTCPRelayDetection.bind(this), this._eventEmitter.addEventListener("webRtcConnected", ((s) => {
2922
+ this._eventEmitter.addEventListener("statsReceived", this._setupWebRtcTCPRelayDetection);
2923
+ }));
2924
+ }
2925
+ get videoElementParent() {
2926
+ return this._videoElementParent || (this._videoElementParent = document.createElement("div"), this._videoElementParent.id = "videoElementParent"), this._videoElementParent;
2927
+ }
2928
+ configureSettings() {
2929
+ this.config._addOnSettingChangedListener(l.IsQualityController, ((e) => {
2930
+ e !== !0 || this._webRtcController.isQualityController || this._webRtcController.sendRequestQualityControlOwnership();
2931
+ })), this.config._addOnSettingChangedListener(l.AFKDetection, ((e) => {
2932
+ this._webRtcController.setAfkEnabled(e);
2933
+ })), this.config._addOnSettingChangedListener(l.MatchViewportResolution, (() => {
2934
+ this._webRtcController.videoPlayer.updateVideoStreamSize();
2935
+ })), this.config._addOnSettingChangedListener(l.HoveringMouseMode, ((e) => {
2936
+ this.config.setFlagLabel(l.HoveringMouseMode, `Control Scheme: ${e ? "Hovering" : "Locked"} Mouse`), this._webRtcController.setMouseInputEnabled(this.config.isFlagEnabled(l.MouseInput));
2937
+ })), this.config._addOnSettingChangedListener(l.KeyboardInput, ((e) => {
2938
+ this._webRtcController.setKeyboardInputEnabled(e);
2939
+ })), this.config._addOnSettingChangedListener(l.MouseInput, ((e) => {
2940
+ this._webRtcController.setMouseInputEnabled(e);
2941
+ })), this.config._addOnSettingChangedListener(l.FakeMouseWithTouches, ((e) => {
2942
+ this._webRtcController.setTouchInputEnabled(this.config.isFlagEnabled(l.TouchInput));
2943
+ })), this.config._addOnSettingChangedListener(l.TouchInput, ((e) => {
2944
+ this._webRtcController.setTouchInputEnabled(e);
2945
+ })), this.config._addOnSettingChangedListener(l.GamepadInput, ((e) => {
2946
+ this._webRtcController.setGamePadInputEnabled(e);
2947
+ })), this.config._addOnNumericSettingChangedListener(h.MinQP, ((e) => {
2948
+ r.Log(r.GetStackTrace(), "-------- Sending MinQP --------", 7), this._webRtcController.sendEncoderMinQP(e), r.Log(r.GetStackTrace(), "-------------------------------------------", 7);
2949
+ })), this.config._addOnNumericSettingChangedListener(h.MaxQP, ((e) => {
2950
+ r.Log(r.GetStackTrace(), "-------- Sending encoder settings --------", 7), this._webRtcController.sendEncoderMaxQP(e), r.Log(r.GetStackTrace(), "-------------------------------------------", 7);
2951
+ })), this.config._addOnNumericSettingChangedListener(h.WebRTCMinBitrate, ((e) => {
2952
+ r.Log(r.GetStackTrace(), "-------- Sending web rtc settings --------", 7), this._webRtcController.sendWebRTCMinBitrate(1e3 * e), r.Log(r.GetStackTrace(), "-------------------------------------------", 7);
2953
+ })), this.config._addOnNumericSettingChangedListener(h.WebRTCMaxBitrate, ((e) => {
2954
+ r.Log(r.GetStackTrace(), "-------- Sending web rtc settings --------", 7), this._webRtcController.sendWebRTCMaxBitrate(1e3 * e), r.Log(r.GetStackTrace(), "-------------------------------------------", 7);
2955
+ })), this.config._addOnNumericSettingChangedListener(h.WebRTCFPS, ((e) => {
2956
+ r.Log(r.GetStackTrace(), "-------- Sending web rtc settings --------", 7), this._webRtcController.sendWebRTCFps(e), r.Log(r.GetStackTrace(), "-------------------------------------------", 7);
2957
+ })), this.config._addOnOptionSettingChangedListener(f.PreferredCodec, ((e) => {
2958
+ this._webRtcController && this._webRtcController.setPreferredCodec(e);
2959
+ })), this.config._registerOnChangeEvents(this._eventEmitter);
2960
+ }
2961
+ _activateOnScreenKeyboard(e) {
2962
+ throw new Error("Method not implemented.");
2963
+ }
2964
+ _onInputControlOwnership(e) {
2965
+ this._inputController = e;
2966
+ }
2967
+ setWebRtcPlayerController(e) {
2968
+ this._webRtcController = e, this._webRtcController.setPreferredCodec(this.config.getSettingOption(f.PreferredCodec).selected), this._webRtcController.resizePlayerStyle(), this.checkForAutoConnect();
2969
+ }
2970
+ connect() {
2971
+ this._eventEmitter.dispatchEvent(new Ae()), this._webRtcController.connectToSignallingServer();
2972
+ }
2973
+ reconnect() {
2974
+ this._eventEmitter.dispatchEvent(new Oe()), this._webRtcController.tryReconnect("Reconnecting...");
2975
+ }
2976
+ disconnect() {
2977
+ this._eventEmitter.dispatchEvent(new De()), this._webRtcController.close();
2978
+ }
2979
+ play() {
2980
+ this._onStreamLoading(), this._webRtcController.playStream();
2981
+ }
2982
+ checkForAutoConnect() {
2983
+ this.config.isFlagEnabled(l.AutoConnect) && (this._onWebRtcAutoConnect(), this._webRtcController.connectToSignallingServer());
2984
+ }
2985
+ unmuteMicrophone(e = !1) {
2986
+ if (!this.config.isFlagEnabled("UseMic")) return e ? (this.config.setFlagEnabled("UseMic", !0), void this.reconnect()) : void r.Warning(r.GetStackTrace(), "Trying to unmute mic, but PixelStreaming was initialized with no microphone track. Call with forceEnable == true to re-connect with a mic track.");
2987
+ this.setMicrophoneMuted(!1);
2988
+ }
2989
+ muteMicrophone() {
2990
+ this.config.isFlagEnabled("UseMic") ? this.setMicrophoneMuted(!0) : r.Info(r.GetStackTrace(), "Trying to mute mic, but PixelStreaming has no microphone track, so sending sound is already disabled.");
2991
+ }
2992
+ setMicrophoneMuted(e) {
2993
+ var t, s, n, i;
2994
+ for (const o of (i = (n = (s = (t = this._webRtcController) === null || t === void 0 ? void 0 : t.peerConnectionController) === null || s === void 0 ? void 0 : s.peerConnection) === null || n === void 0 ? void 0 : n.getTransceivers()) !== null && i !== void 0 ? i : []) st.canTransceiverSendAudio(o) && (o.sender.track.enabled = !e);
2995
+ }
2996
+ _onWebRtcAutoConnect() {
2997
+ this._eventEmitter.dispatchEvent(new Ee());
2998
+ }
2999
+ _onWebRtcSdp() {
3000
+ this._eventEmitter.dispatchEvent(new ye());
3001
+ }
3002
+ _onStreamLoading() {
3003
+ this._eventEmitter.dispatchEvent(new Fe());
3004
+ }
3005
+ _onDisconnect(e, t) {
3006
+ this._eventEmitter.dispatchEvent(new Pe({ eventString: e, allowClickToReconnect: t }));
3007
+ }
3008
+ _onWebRtcConnecting() {
3009
+ this._eventEmitter.dispatchEvent(new Me());
3010
+ }
3011
+ _onWebRtcConnected() {
3012
+ this._eventEmitter.dispatchEvent(new we());
3013
+ }
3014
+ _onWebRtcFailed() {
3015
+ this._eventEmitter.dispatchEvent(new be());
3016
+ }
3017
+ _onVideoInitialized() {
3018
+ this._eventEmitter.dispatchEvent(new xe()), this._videoStartTime = Date.now();
3019
+ }
3020
+ _onLatencyTestResult(e) {
3021
+ this._eventEmitter.dispatchEvent(new He({ latencyTimings: e }));
3022
+ }
3023
+ _onDataChannelLatencyTestResponse(e) {
3024
+ this._eventEmitter.dispatchEvent(new We({ response: e }));
3025
+ }
3026
+ _onVideoStats(e) {
3027
+ this._videoStartTime && this._videoStartTime !== void 0 || (this._videoStartTime = Date.now()), e.handleSessionStatistics(this._videoStartTime, this._inputController, this._webRtcController.videoAvgQp), this._eventEmitter.dispatchEvent(new ze({ aggregatedStats: e }));
3028
+ }
3029
+ _onVideoEncoderAvgQP(e) {
3030
+ this._eventEmitter.dispatchEvent(new Te({ avgQP: e }));
3031
+ }
3032
+ _onInitialSettings(e) {
3033
+ var t;
3034
+ this._eventEmitter.dispatchEvent(new Ke({ settings: e })), e.PixelStreamingSettings && (this.allowConsoleCommands = (t = e.PixelStreamingSettings.AllowPixelStreamingCommands) !== null && t !== void 0 && t, this.allowConsoleCommands === !1 && r.Info(r.GetStackTrace(), "-AllowPixelStreamingCommands=false, sending arbitrary console commands from browser to UE is disabled."));
3035
+ const s = this.config.useUrlParams, n = new URLSearchParams(window.location.search);
3036
+ r.Info(r.GetStackTrace(), `using URL parameters ${s}`), e.EncoderSettings && (this.config.setNumericSetting(h.MinQP, s && n.has(h.MinQP) ? Number.parseFloat(n.get(h.MinQP)) : e.EncoderSettings.MinQP), this.config.setNumericSetting(h.MaxQP, s && n.has(h.MaxQP) ? Number.parseFloat(n.get(h.MaxQP)) : e.EncoderSettings.MaxQP)), e.WebRTCSettings && (this.config.setNumericSetting(h.WebRTCMinBitrate, s && n.has(h.WebRTCMinBitrate) ? Number.parseFloat(n.get(h.WebRTCMinBitrate)) : e.WebRTCSettings.MinBitrate / 1e3), this.config.setNumericSetting(h.WebRTCMaxBitrate, s && n.has(h.WebRTCMaxBitrate) ? Number.parseFloat(n.get(h.WebRTCMaxBitrate)) : e.WebRTCSettings.MaxBitrate / 1e3), this.config.setNumericSetting(h.WebRTCFPS, s && n.has(h.WebRTCFPS) ? Number.parseFloat(n.get(h.WebRTCFPS)) : e.WebRTCSettings.FPS));
3037
+ }
3038
+ _onQualityControlOwnership(e) {
3039
+ this.config.setFlagEnabled(l.IsQualityController, e);
3040
+ }
3041
+ _onPlayerCount(e) {
3042
+ this._eventEmitter.dispatchEvent(new qe({ count: e }));
3043
+ }
3044
+ _setupWebRtcTCPRelayDetection(e) {
3045
+ let t = e.data.aggregatedStats.getActiveCandidatePair();
3046
+ if (t != null) {
3047
+ let s = e.data.aggregatedStats.localCandidates.find(((n) => n.id == t.localCandidateId), null);
3048
+ s != null && s.candidateType == "relay" && s.relayProtocol == "tcp" && this._eventEmitter.dispatchEvent(new $e()), this._eventEmitter.removeEventListener("statsReceived", this._setupWebRtcTCPRelayDetection);
3049
+ }
3050
+ }
3051
+ requestLatencyTest() {
3052
+ return !!this._webRtcController.videoPlayer.isVideoReady() && (this._webRtcController.sendLatencyTest(), !0);
3053
+ }
3054
+ requestDataChannelLatencyTest(e) {
3055
+ return !!this._webRtcController.videoPlayer.isVideoReady() && (this._dataChannelLatencyTestController || (this._dataChannelLatencyTestController = new ts(this._webRtcController.sendDataChannelLatencyTest.bind(this._webRtcController), ((t) => {
3056
+ this._eventEmitter.dispatchEvent(new Ne({ result: t }));
3057
+ })), this.addEventListener("dataChannelLatencyTestResponse", (({ data: { response: t } }) => {
3058
+ this._dataChannelLatencyTestController.receive(t);
3059
+ }))), this._dataChannelLatencyTestController.start(e));
3060
+ }
3061
+ requestShowFps() {
3062
+ return !!this._webRtcController.videoPlayer.isVideoReady() && (this._webRtcController.sendShowFps(), !0);
3063
+ }
3064
+ requestIframe() {
3065
+ return !!this._webRtcController.videoPlayer.isVideoReady() && (this._webRtcController.sendIframeRequest(), !0);
3066
+ }
3067
+ emitUIInteraction(e) {
3068
+ return !!this._webRtcController.videoPlayer.isVideoReady() && (this._webRtcController.emitUIInteraction(e), !0);
3069
+ }
3070
+ emitCommand(e) {
3071
+ return !(!this._webRtcController.videoPlayer.isVideoReady() || !this.allowConsoleCommands && "ConsoleCommand" in e || (this._webRtcController.emitCommand(e), 0));
3072
+ }
3073
+ emitConsoleCommand(e) {
3074
+ return !(!this.allowConsoleCommands || !this._webRtcController.videoPlayer.isVideoReady() || (this._webRtcController.emitConsoleCommand(e), 0));
3075
+ }
3076
+ addResponseEventListener(e, t) {
3077
+ this._webRtcController.responseController.addResponseEventListener(e, t);
3078
+ }
3079
+ removeResponseEventListener(e) {
3080
+ this._webRtcController.responseController.removeResponseEventListener(e);
3081
+ }
3082
+ dispatchEvent(e) {
3083
+ return this._eventEmitter.dispatchEvent(e);
3084
+ }
3085
+ addEventListener(e, t) {
3086
+ this._eventEmitter.addEventListener(e, t);
3087
+ }
3088
+ removeEventListener(e, t) {
3089
+ this._eventEmitter.removeEventListener(e, t);
3090
+ }
3091
+ toggleXR() {
3092
+ this.webXrController.xrClicked();
3093
+ }
3094
+ setSignallingUrlBuilder(e) {
3095
+ this._webRtcController.signallingUrlBuilder = e;
3096
+ }
3097
+ get webSocketController() {
3098
+ return this._webRtcController.webSocketController;
3099
+ }
3100
+ get webXrController() {
3101
+ return this._webXrController;
3102
+ }
3103
+ registerMessageHandler(e, t, s) {
3104
+ t !== p.FromStreamer || s !== void 0 ? t === p.ToStreamer && s === void 0 ? this._webRtcController.streamMessageController.registerMessageHandler(t, e, ((n) => this._webRtcController.sendMessageController.sendMessageToStreamer(e, n))) : this._webRtcController.streamMessageController.registerMessageHandler(t, e, ((n) => s(n))) : r.Warning(r.GetStackTrace(), `Unable to register an undefined handler for ${e}`);
3105
+ }
3106
+ get toStreamerHandlers() {
3107
+ return this._webRtcController.streamMessageController.toStreamerHandlers;
3108
+ }
3109
+ isReconnecting() {
3110
+ return this._webRtcController.isReconnecting;
3111
+ }
3112
+ }
3113
+ class ns {
3114
+ }
3115
+ g.Dz;
3116
+ g.g$;
3117
+ g.Lt;
3118
+ g.Q9;
3119
+ g.qf;
3120
+ g.hV;
3121
+ g.z$;
3122
+ g.J0;
3123
+ var rs = g.De;
3124
+ g.$C;
3125
+ g.al;
3126
+ g._W;
3127
+ g.Gv;
3128
+ g.m;
3129
+ g.tz;
3130
+ g.Nu;
3131
+ g.zg;
3132
+ g.vp;
3133
+ g.vU;
3134
+ g.wF;
3135
+ g.rv;
3136
+ g.Nh;
3137
+ g.ss;
3138
+ g.qW;
3139
+ g.QL;
3140
+ g.cf;
3141
+ g.eM;
3142
+ g.Yd;
3143
+ g.Tk;
3144
+ g.iM;
3145
+ g.qy;
3146
+ g.ce;
3147
+ g.sK;
3148
+ g.Ok;
3149
+ g.q5;
3150
+ var is = g.g;
3151
+ g.xl;
3152
+ g.I;
3153
+ g.bx;
3154
+ g.dD;
3155
+ g.Ib;
3156
+ g.Az;
3157
+ g.Iw;
3158
+ g.qY;
3159
+ g.db;
3160
+ g.mR;
3161
+ g.Tn;
3162
+ g.rV;
3163
+ g.gh;
3164
+ g.Mi;
3165
+ g.j;
3166
+ g.YB;
3167
+ g.Yt;
3168
+ g.i5;
3169
+ g.x_;
3170
+ g.Am;
3171
+ g.eR;
3172
+ g.r8;
3173
+ g.u3;
3174
+ g.vd;
3175
+ g.iV;
3176
+ g.jZ;
3177
+ g.SW;
3178
+ g.ZH;
3179
+ g.Ni;
3180
+ g.lh;
3181
+ g.ZP;
3182
+ g.bq;
3183
+ g.$f;
3184
+ g.eu;
3185
+ g.Ax;
3186
+ g.Mc;
3187
+ const as = ({
3188
+ signallingUrl: a,
3189
+ autoConnect: e = !0,
3190
+ width: t,
3191
+ height: s,
3192
+ onConnecting: n,
3193
+ onLoading: i,
3194
+ onConnected: o,
3195
+ onDisconnected: d,
3196
+ onError: c,
3197
+ muted: m = !1
3198
+ }) => {
3199
+ const u = G.useRef(null), v = G.useRef(null), S = G.useRef(!1), [y, P] = G.useState(!1), [x, C] = G.useState(!1), [A, R] = G.useState(null);
3200
+ return G.useEffect(() => {
3201
+ if (!(!u.current || !a)) {
3202
+ n && n(), "mediaDevices" in navigator || Object.defineProperty(navigator, "mediaDevices", { value: {} }), navigator.mediaDevices.getUserMedia || (navigator.mediaDevices.getUserMedia = function() {
3203
+ return Promise.reject(new Error("getUserMedia is not supported"));
3204
+ });
3205
+ try {
3206
+ const w = new rs({
3207
+ useUrlParams: !1,
3208
+ initialSettings: {
3209
+ ss: a,
3210
+ AutoConnect: e,
3211
+ AutoPlayVideo: !0,
3212
+ StartVideoMuted: m,
3213
+ UseMic: !1,
3214
+ HoveringMouse: !1,
3215
+ FakeMouseWithTouches: !0,
3216
+ TouchInput: !1,
3217
+ MouseInput: !1,
3218
+ KeyboardInput: !1,
3219
+ WaitForStreamer: !0
3220
+ }
3221
+ }), T = new is(w, {
3222
+ videoElementParent: u.current
3223
+ });
3224
+ T.addEventListener("webRtcConnected", () => {
3225
+ S.current = !0, P(!0), C(!1), R(null), o?.();
3226
+ }), T.addEventListener("webRtcDisconnected", () => {
3227
+ S.current = !1, P(!1), d?.();
3228
+ }), T.addEventListener("streamLoading", () => {
3229
+ C(!0), i?.();
3230
+ }), T.addEventListener("playStreamError", () => {
3231
+ R("Failed to play stream"), C(!1), c?.("Failed to play stream");
3232
+ }), T.addEventListener("playStream", () => {
3233
+ C(!1), S.current || (S.current = !0, P(!0), o?.());
3234
+ }), T.addEventListener("videoInitialized", () => {
3235
+ C(!1);
3236
+ }), v.current = T;
3237
+ } catch (w) {
3238
+ R("Failed to initialize streaming: " + w.message), C(!1), c?.(w.message);
3239
+ }
3240
+ return () => {
3241
+ if (v.current) {
3242
+ try {
3243
+ const w = v.current;
3244
+ w._webSocketController && w._webSocketController.close(), v.current.disconnect();
3245
+ } catch {
3246
+ }
3247
+ v.current = null;
3248
+ }
3249
+ };
3250
+ }
3251
+ }, [a, e, n, i, o, d, c]), G.useEffect(() => {
3252
+ if (v.current)
3253
+ try {
3254
+ const T = v.current._webRtcController?.videoPlayer;
3255
+ if (!T) return;
3256
+ let j = !1;
3257
+ if (T.audioElement) {
3258
+ const X = T.audioElement.srcObject;
3259
+ if (X) {
3260
+ const H = X.getAudioTracks();
3261
+ H.length > 0 && (H.forEach((J) => {
3262
+ J.enabled = !m;
3263
+ }), j = !0);
3264
+ }
3265
+ }
3266
+ const z = T.getVideoElement();
3267
+ if (z && z.srcObject && z.srcObject instanceof MediaStream) {
3268
+ const H = z.srcObject.getAudioTracks();
3269
+ H.length > 0 && (H.forEach((J) => {
3270
+ J.enabled = !m;
3271
+ }), j = !0);
3272
+ }
3273
+ !j && z && (z.muted = m);
3274
+ } catch {
3275
+ }
3276
+ }, [m]), /* @__PURE__ */ O.jsxs(
3277
+ "div",
3278
+ {
3279
+ className: "pixel-streaming-container",
3280
+ style: {
3281
+ width: t || "100%",
3282
+ height: s || "100%",
3283
+ position: "relative",
3284
+ display: "flex",
3285
+ flexDirection: "column",
3286
+ touchAction: "none",
3287
+ WebkitTouchCallout: "none",
3288
+ WebkitUserSelect: "none",
3289
+ userSelect: "none"
3290
+ },
3291
+ children: [
3292
+ /* @__PURE__ */ O.jsx(
3293
+ "div",
3294
+ {
3295
+ ref: u,
3296
+ className: "player-container",
3297
+ style: {
3298
+ position: "absolute",
3299
+ top: 0,
3300
+ left: 0,
3301
+ width: "100%",
3302
+ height: "100%",
3303
+ overflow: "hidden",
3304
+ touchAction: "none"
3305
+ }
3306
+ }
3307
+ ),
3308
+ x && /* @__PURE__ */ O.jsxs("div", { className: "loading-overlay", children: [
3309
+ /* @__PURE__ */ O.jsx("div", { className: "loading-spinner" }),
3310
+ /* @__PURE__ */ O.jsx("div", { className: "loading-text", children: "Connecting to stream..." })
3311
+ ] }),
3312
+ !y && !x && A && /* @__PURE__ */ O.jsx("div", { className: "connection-overlay", children: /* @__PURE__ */ O.jsx("div", { className: "error-message", children: A }) })
3313
+ ]
3314
+ }
3315
+ );
3316
+ };
3317
+ function ds({
3318
+ className: a,
3319
+ style: e,
3320
+ autoConnect: t = !0,
3321
+ muted: s = !1,
3322
+ onConnected: n,
3323
+ onDisconnected: i,
3324
+ onError: o
3325
+ }) {
3326
+ const { streamingUrl: d, setCloudStreamState: c } = dt();
3327
+ if (!d)
3328
+ return null;
3329
+ const m = () => {
3330
+ c(W.CONNECTING);
3331
+ }, u = () => {
3332
+ c(W.LOADING);
3333
+ }, v = () => {
3334
+ c(W.CONNECTED), n?.();
3335
+ }, S = () => {
3336
+ c(W.DISCONNECTED), i?.();
3337
+ }, y = (P) => {
3338
+ c(W.ERROR, P), o?.(P);
3339
+ };
3340
+ return /* @__PURE__ */ O.jsx("div", { className: a, style: e, children: /* @__PURE__ */ O.jsx(
3341
+ as,
3342
+ {
3343
+ signallingUrl: d,
3344
+ autoConnect: t,
3345
+ muted: s,
3346
+ onConnecting: m,
3347
+ onLoading: u,
3348
+ onConnected: v,
3349
+ onDisconnected: S,
3350
+ onError: y
3351
+ }
3352
+ ) });
3353
+ }
3354
+ export {
3355
+ ds as RqmiiCloudAvatarPlayer
3356
+ };
3357
+ //# sourceMappingURL=RqmiiCloudAvatarPlayer-DpvI9bmI.js.map