// Metro module 10522 (f10523). import EmbeddedActivitiesStore from "../../activities/EmbeddedActivitiesStore"; import ChannelRTCStore from "../../calls/ChannelRTCStore"; import VideoSpeakerStore from "../../calls/VideoSpeakerStore"; import ApplicationStreamingStore from "../../../stores/ApplicationStreamingStore"; import "../../../stores/AuthenticationStore"; import ChannelStore from "../../../stores/ChannelStore"; import MediaEngineStore from "../../../stores/MediaEngineStore"; import RTCConnectionStore from "../../../stores/RTCConnectionStore"; import "../../calls/CallConstants"; import { useStateFromStores } from "../../../_bundle/Module589"; function $mk85016($env) { return () => { const r6 = $env.$parent; const r10 = $env[0]; const r7 = r10 != null ? r6[4].getVideoParticipants(r10) : []; const r8 = r10 != null ? r6[4].getSelectedParticipant(r10) : null; const r19 = r7.find($mk107255(r6)); const r13 = r6[5]; const r12 = r6[4]; const r23 = (r10 != null ? r12.getVideoParticipants(r10) : []).find($mk115704(r6)); let r25 = r10 != null ? r12.getParticipant(r10, r13.getSpeaker(r10)) : null; if (r25 == null) { r25 = r23; } const r30 = (0, r6[12])(r25); const r31 = r25; let r32 = r30 ? r31.localVideoDisabled ? null : r31 : r31; const r35 = r10 != null ? r6[6].getAllActiveStreamsForChannel(r10) : []; let env26706 = { $parent: r6 }; env26706[0] = r32; const r40 = (0, r6[11])(r32); let r41 = r32; if (r40) { if (!(r35.filter((item) => { const r2 = env26706.$parent; return (0, r2[0])(r2[2][10]).encodeStreamKey({ streamType: item.streamType, guildId: item.guildId, channelId: item.channelId, ownerId: item.ownerId }) === env26706[0]?.id; }).length > 0)) { env26706[0] = void 0; r32 = void 0; } r41 = r32; } let r46 = r41; if (r46 == null) { r46 = r19; } let r47 = r8 != null && r8.id === r41?.id && r46 != null && r46.id === r41?.id; if (r47) { const r53 = r6[0]; const r54 = r6[2]; r47 = r53(r54[11]).isModalOpen((0, r6[1])(r54[12])); } if (r47) { r46 = r19; } return r46 != null ? r46.type !== r6[13].ACTIVITY ? r46.streamId != null ? r46 : null : null : null; }; } function $mk107255($env) { return (a0) => a0.type === $env[13].USER && !a0.localVideoDisabled; } function $mk115704($env) { return (a0) => { const r2 = $env; let r7 = a0.id !== r2[7].getId(); if (r7) { const r9 = (0, r2[12])(a0); r7 = r9 ? a0.localVideoDisabled : !r9; } return r7; }; } let env7064 = {}; export default function usePipVideoOrStream(a0) { let env18105; const r1 = env18105 = { $parent: env7064 }; env18105[0] = a0; return useStateFromStores([ChannelRTCStore, VideoSpeakerStore, ApplicationStreamingStore], $mk85016(r1), [a0]); }; export function useHasPipParticipant({ isActivityViewFocused }) { let stateFromStores2; stateFromStores2 = void 0; const stateFromStores = useStateFromStores([RTCConnectionStore], () => RTCConnectionStore.getChannelId()); const r13 = stateFromStores == null ? void 0 : stateFromStores; let env18107; const r18 = env18107 = { $parent: env7064 }; env18107[0] = r13; stateFromStores2 = useStateFromStores([ChannelRTCStore, VideoSpeakerStore, ApplicationStreamingStore], $mk85016(r18), [r13]); return useStateFromStores([ChannelStore, EmbeddedActivitiesStore, MediaEngineStore], () => { if (ChannelStore.getChannel(stateFromStores) == null) { return false; } const currentEmbeddedActivity = EmbeddedActivitiesStore.getCurrentEmbeddedActivity(); const r15 = stateFromStores2 != null && MediaEngineStore.isLocalVideoDisabled(stateFromStores2.id); return currentEmbeddedActivity != null && !isActivityViewFocused || stateFromStores2 != null && stateFromStores2.streamId != null && !r15; }, [stateFromStores, stateFromStores2, isActivityViewFocused]); }