Files
discord-decomp/sources/modules/external_pip/useExternalPipParticipant.android.tsx
T
2026-07-27 16:20:00 +03:00

648 lines
28 KiB
TypeScript

/* Metro module 15358; source: modules/external_pip/useExternalPipParticipant.android.tsx; dependencies: [57, 31, 4606, 1226, 4259, 4294, 4299, 566, 2] */
function _fun117394(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#117394, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:6, offset: 0x024b15cf, size: 252 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_117397 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_2 = importDefault(57) /* metro dependency 57 */;
const env0_3 = importAll(31) /* metro dependency 31 */;
const channelRTCStore = importDefault(4606) /* metro dependency 4606: ChannelRTCStore */;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const mediaEngineStore = importDefault(4259) /* metro dependency 4259: MediaEngineStore */;
const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */;
const env0_8 = (require(4299) /* metro dependency 4299: CallConstants */).ParticipantTypes;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/external_pip/useExternalPipParticipant.android.tsx');
exports.default = useExternalPipParticipant;
}
function _createForOfIteratorHelperLoose_117395(a0, a1) { // fn#117395, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:189, offset: 0x024b16cb, size: 372 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun117396;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_117397(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_117397(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_117397(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun117396;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
}
function useSelectedParticipant({channelId, focusedParticipantStreamId}) { // fn#117398, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:1099, offset: 0x024b183f, size: 230 bytes, params: 2, frame: 23
const id = (require(566) /* metro dependency 566: flux */).useStateFromStores([AuthenticationStore], function() {
return AuthenticationStore.getId();
});
const [property, env0_3] = id(env0_3Binding.useState(0), 2);
const value4 = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([ChannelRTCStore],
_fun117400, [channelId, focusedParticipantStreamId, id, property]);
env0_3Binding.useEffect(_fun117401, [value4.selectedParticipantSpeaking]);
return value4;
}
function useExternalPipParticipant() { // fn#117405, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:2811, offset: 0x024b1cfb, size: 218 bytes, params: 1, frame: 21
const value2 = undefined;
const r5 = (require(566) /* metro dependency 566: flux */).useStateFromStores([RTCConnectionStore], function() {
return RTCConnectionStore.getChannelId();
}) ?? value2;
const {focusedParticipantStreamId, focusedParticipantUserId,
focusedParticipantType} = useFocusedParticipant({channelId: r5});
const value = useSelectedParticipant({channelId: r5, focusedParticipantStreamId: focusedParticipantStreamId});
const selectedStreamId = value.selectedStreamId;
const selectedParticipantUserId = value.selectedParticipantUserId;
const selectedParticipantSpeaking = value.selectedParticipantSpeaking;
const r4 = focusedParticipantStreamId ?? selectedStreamId ?? value2;
const r3 = focusedParticipantStreamId == null ? selectedParticipantUserId : focusedParticipantUserId;
useExternalPipParticipantUseSetHasActiveVideoOutputSink({selectedParticipantStreamId: r4});
return {channelId: r5, selectedParticipantStreamId: r4, selectedParticipantUserId: r3,
selectedParticipantSpeaking: selectedParticipantSpeaking, focusedParticipantType: focusedParticipantType};
}
function _fun117400() { // fn#117400, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:1310, offset: 0x024b1925, size: 895 bytes, params: 1, frame: 42
var r3;
var id2;
var r17;
var r7;
var r9;
var r10;
var r11;
var r12;
var id3;
var r28;
var selfVideo;
var r30;
var r31;
var r21;
var r22;
var r23;
var r24;
var r1;
var r6;
var r8;
var id4;
var id5;
var r5;
var id6;
var streamId;
var r2;
var Date;
var now;
var value2;
var value3;
var getParticipants;
var value4;
var idBinding;
var length;
var value5;
var _createForOfIteratorHelperLoose_117395Binding;
var value6;
var value7;
var value8;
var done;
var value9;
var value10;
var type;
var ACTIVITY;
var user;
var id7;
var value11;
var value12;
var value13;
var value14;
var value15;
var USER;
var id8;
var STREAM;
var value16;
var value17;
var speaking;
var lastSpoke;
var value18;
var value19;
var voiceState;
var value20;
var value21;
var lastSpoke2;
var value22;
var value23;
var lastSpoke3;
var value24;
var value25;
var object2;
var id9;
var id10;
var id11;
if (channelId != null) {
reducibleJoin62: while (true) {
if (focusedParticipantStreamId == null) {
Date = global.Date;
now = Date.now;
value2 = Reflect.apply(now, Date, []);
value3 = environment.__proto__;
getParticipants = ChannelRTCStore.getParticipants;
value4 = Reflect.apply(getParticipants, ChannelRTCStore, [channelId]);
idBinding = id;
length = value4.length;
value5 = false;
reducibleJoin9: while (true) {
if (3 < length) {
r17 = value5;
break reducibleJoin9;
}
_createForOfIteratorHelperLoose_117395Binding = _createForOfIteratorHelperLoose_117395;
value6 = undefined;
value7 = _createForOfIteratorHelperLoose_117395Binding(value4);
value8 = value7();
done = value8.done;
value9 = true;
if (done) {
r17 = value9;
break reducibleJoin9;
}
r3 = value8;
reducibleLoop4: while (true) {
value10 = r3.value;
type = value10.type;
ACTIVITY = ParticipantTypes.ACTIVITY;
if (type !== ACTIVITY) {
user = value10.user;
reducibleJoin7: while (true) {
if (user == null) {
id2 = value6;
break reducibleJoin7;
}
id7 = user.id;
id2 = id7;
break reducibleJoin7;
}
reducibleJoin8: while (true) {
if (id2 !== idBinding) {
r17 = value5;
break reducibleJoin9;
}
break reducibleJoin8;
}
}
value11 = value7();
done = value11.done;
if (done) {
r17 = value9;
break reducibleJoin9;
}
r3 = value11;
continue reducibleLoop4;
}
}
_createForOfIteratorHelperLoose_117395Binding = _createForOfIteratorHelperLoose_117395;
value12 = undefined;
value13 = _createForOfIteratorHelperLoose_117395Binding(value4);
value14 = value13();
done = value14.done;
if (done) {
r1 = value12;
r3 = value12;
r6 = value12;
r8 = value12;
} else {
r7 = value12;
r9 = value12;
r10 = value12;
r11 = value12;
r12 = value14;
reducibleLoop10: while (true) {
value15 = r12.value;
reducibleJoin36: while (true) {
reducibleJoin15: while (true) {
if (r17) {
break reducibleJoin15;
}
type = value15.type;
USER = ParticipantTypes.USER;
if (type !== USER) {
break reducibleJoin15;
}
user = value15.user;
reducibleJoin14: while (true) {
if (user == null) {
id3 = value12;
break reducibleJoin14;
}
id8 = user.id;
id3 = id8;
break reducibleJoin14;
}
if (id3 === id) {
r21 = r7;
r22 = r9;
r23 = r10;
r24 = r11;
break reducibleJoin36;
}
break reducibleJoin15;
}
type = value15.type;
USER = ParticipantTypes.USER;
if (USER === type) {
speaking = value15.speaking;
reducibleJoin22: while (true) {
if (speaking) {
r28 = speaking;
break reducibleJoin22;
}
lastSpoke = value15.lastSpoke;
value18 = value2 - lastSpoke < 1000;
r28 = value18;
break reducibleJoin22;
}
reducibleJoin24: while (true) {
if (r28) {
value19 = r11 == null;
r28 = value19;
break reducibleJoin24;
}
break reducibleJoin24;
}
if (r28) {
r11 = value15;
}
voiceState = value15.voiceState;
reducibleJoin27: while (true) {
if (voiceState == null) {
selfVideo = value12;
break reducibleJoin27;
}
selfVideo = voiceState.selfVideo;
break reducibleJoin27;
}
value20 = selfVideo != null;
r30 = value20 && selfVideo;
reducibleJoin32: while (true) {
if (r30) {
value21 = r10 == null;
reducibleJoin31: while (true) {
if (value21) {
r31 = value21;
break reducibleJoin31;
}
lastSpoke = r10.lastSpoke;
lastSpoke2 = value15.lastSpoke;
value22 = lastSpoke < lastSpoke2;
r31 = value22;
break reducibleJoin31;
}
r30 = r31;
break reducibleJoin32;
}
break reducibleJoin32;
}
if (r30) {
r10 = value15;
}
value23 = r7 == null;
reducibleJoin35: while (true) {
if (value23) {
r30 = value23;
break reducibleJoin35;
}
lastSpoke = r7.lastSpoke;
lastSpoke3 = value15.lastSpoke;
value24 = lastSpoke < lastSpoke3;
r30 = value24;
break reducibleJoin35;
}
if (r30) {
r21 = value15;
r22 = r9;
r23 = r10;
r24 = r11;
break reducibleJoin36;
}
r21 = r7;
r22 = r9;
r23 = r10;
r24 = r11;
break reducibleJoin36;
}
STREAM = ParticipantTypes.STREAM;
if (STREAM !== type) {
r21 = r7;
r22 = r9;
r23 = r10;
r24 = r11;
break reducibleJoin36;
}
value16 = r9 == null;
reducibleJoin19: while (true) {
if (value16) {
streamId = value15.streamId;
value17 = streamId != null;
r28 = value17;
break reducibleJoin19;
}
r28 = value16;
break reducibleJoin19;
}
if (r28) {
r21 = r7;
r22 = value15;
r23 = r10;
r24 = r11;
break reducibleJoin36;
}
r21 = r7;
r22 = r9;
r23 = r10;
r24 = r11;
break reducibleJoin36;
}
value25 = value13();
done = value25.done;
if (done) {
r1 = r22;
r3 = r24;
r6 = r23;
r8 = r21;
break reducibleLoop10;
}
r7 = r21;
r9 = r22;
r10 = r23;
r11 = r24;
r12 = value25;
continue reducibleLoop10;
}
}
object2 = {selectedParticipantSpeaking: r3 != null};
reducibleJoin40: while (true) {
if (r3 == null) {
id4 = value12;
break reducibleJoin40;
}
user = r3.user;
if (user == null) {
id4 = value12;
break reducibleJoin40;
}
id9 = user.id;
id4 = id9;
break reducibleJoin40;
}
reducibleJoin45: while (true) {
if (id4 != null) {
r5 = id4;
break reducibleJoin45;
}
reducibleJoin44: while (true) {
if (r6 == null) {
id5 = value12;
break reducibleJoin44;
}
user = r6.user;
if (user == null) {
id5 = value12;
break reducibleJoin44;
}
id10 = user.id;
id5 = id10;
break reducibleJoin44;
}
r5 = id5;
break reducibleJoin45;
}
reducibleJoin50: while (true) {
if (r5 != null) {
break reducibleJoin50;
}
reducibleJoin49: while (true) {
if (r8 == null) {
id6 = value12;
break reducibleJoin49;
}
user = r8.user;
if (user == null) {
id6 = value12;
break reducibleJoin49;
}
id11 = user.id;
id6 = id11;
break reducibleJoin49;
}
r5 = id6;
break reducibleJoin50;
}
object2.selectedParticipantUserId = r5;
if (r3 != null) {
streamId = r3.streamId;
r2 = streamId ?? value12;
r1 = r2;
} else {
reducibleJoin53: while (true) {
if (r1 == null) {
streamId = value12;
break reducibleJoin53;
}
streamId = r1.streamId;
break reducibleJoin53;
}
reducibleJoin57: while (true) {
if (streamId != null) {
r5 = streamId;
break reducibleJoin57;
}
reducibleJoin56: while (true) {
if (r6 == null) {
streamId = value12;
break reducibleJoin56;
}
streamId = r6.streamId;
break reducibleJoin56;
}
r5 = streamId;
break reducibleJoin57;
}
r1 = r5 ?? value12;
}
object2.selectedStreamId = r1;
return object2;
}
break reducibleJoin62;
}
}
return {selectedParticipantSpeaking: false, selectedParticipantUserId: undefined, selectedStreamId: undefined};
}
function _fun117401() { // fn#117401, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:2560, offset: 0x024b1ca4, size: 62 bytes, params: 1, frame: 14
if (env0_4.selectedParticipantSpeaking) {
var env0_0 = global.setTimeout(_fun117402, 3000);
return _fun117404;
}
}
function useFocusedParticipant({channelId}) { // fn#117407, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:2935, owner: useExternalPipParticipant.useFocusedParticipant, offset: 0x024b1dd5, size: 108 bytes, params: 2, frame: 15
const env0_1 = env1_3.useRef(undefined);
const env0_2 = env1_3.useRef(undefined);
return (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([ChannelRTCStore], _fun117408);
}
function useExternalPipParticipantUseSetHasActiveVideoOutputSink({selectedParticipantStreamId}) { // fn#117409, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:4026, owner: useExternalPipParticipant.useSetHasActiveVideoOutputSink, offset: 0x024b1fcd, size: 52 bytes, params: 2, frame: 14
env1_3.useEffect(_fun117410, [selectedParticipantStreamId]);
}
function _fun117402() { // fn#117402, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:2617, offset: 0x024b1ce2, size: 25 bytes, params: 1, frame: 11
env1_3(function(a0) {
return a0 + 1;
});
}
function _fun117408() { // fn#117408, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:3069, offset: 0x024b1e41, size: 396 bytes, params: 1, frame: 18
var type;
var r0;
var binding;
var object2;
var ACTIVITY;
const channelIdBinding = channelId;
const value2 = null;
const r6 = value2 != channelIdBinding ? ChannelRTCStore.getSelectedParticipantId(channelId) : value2;
const r5 = value2 != r6 && value2 != channelId && value2 != ChannelRTCStore.getParticipant(channelId,
r6) ? ChannelRTCStore.getParticipant(channelId, r6) : value2;
const current = env0_1.current;
const value7 = undefined;
if (value7 === current) {
binding = env0_1;
binding.current = value2 == r5 ? value7 : r5.id;
binding = env0_2;
binding.current = value2 == r5 ? value7 : r5.type;
}
if (env0_1.current !== (value2 == r5 ? value7 : r5.id)) {
r0 = {focusedParticipantStreamId: value7, focusedParticipantUserId: value7,
focusedParticipantType: env0_2.current};
} else {
object2 = {};
type = value2 == r5 ? value7 : r5.type;
value = environment.__proto__.__proto__;
ACTIVITY = ParticipantTypes.ACTIVITY;
object2.focusedParticipantStreamId = type === ACTIVITY ? value7 : value2 != (value2 == r5 ? value7 : r5.streamId) ? value2 == r5 ? value7 : r5.streamId : value7;
type = value2 == r5 ? value7 : r5.type;
ACTIVITY = ParticipantTypes.ACTIVITY;
object2.focusedParticipantUserId = type === ACTIVITY ? value7 : value2 != (value2 == r5 || value2 == r5.user ? value7 : r5.user.id) ? value2 == r5 || value2 == r5.user ? value7 : r5.user.id : value7;
type = value2 == r5 ? value7 : r5.type;
object2.focusedParticipantType = value2 != type ? type : value7;
r0 = object2;
}
return r0;
}
function _fun117410() { // fn#117410, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:4112, offset: 0x024b2001, size: 77 bytes, params: 1, frame: 12
var environment;
var value;
if (selectedParticipantStreamId != null) {
value = environment.__proto__.__proto__;
value = MediaEngineStore.getMediaEngine();
value.eachConnection(_fun117411);
return _fun117412;
}
}
function _fun117411(a0) { // fn#117411, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:4213, offset: 0x024b204e, size: 31 bytes, params: 2, frame: 15
return a0.setHasActiveVideoOutputSink(selectedParticipantStreamId, true, env0_1);
}
function _fun117412() { // fn#117412, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:4256, offset: 0x024b206d, size: 41 bytes, params: 1, frame: 11
var environment;
const value = environment.__proto__.__proto__.__proto__;
MediaEngineStore.getMediaEngine().eachConnection(_fun117413);
}
function _fun117413(a0) { // fn#117413, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15555:4296, offset: 0x024b2096, size: 31 bytes, params: 2, frame: 15
return a0.setHasActiveVideoOutputSink(selectedParticipantStreamId, false, env1_1);
}