// Metro module 15913 (f15914). import ChannelRTCStore from "../../../calls/ChannelRTCStore"; import ApplicationStreamingStore from "../../../../stores/ApplicationStreamingStore"; import AuthenticationStore from "../../../../stores/AuthenticationStore"; import { SECONDARY_PIP_TOP_MARGIN, VoicePanelModes } from "../../VoicePanelConstants"; import { PIPReferenceDimensions, SquareActivityPIPReferenceDimensions, SquarePIPReferenceDimensions, VoicePanelPIPModes } from "./VoicePanelPIPConstants"; import { ParticipantTypes } from "../../../calls/CallConstants"; import { MIN_PIP_TOSS_VELOCITY, PIP_WINDOW_OFFSET } from "../../../panels/morphable/native/MorphablePanelConstants"; import { canRenderParticipantVideo } from "../../../video_calls/participantHasVideo"; import { isActivityParticipantCurrentUserCurrentSession } from "../../../activities/isActivityParticipantCurrentUserCurrentSession"; import Module712 from "../../../../_bundle/Module712"; let clamp, getPIPWindowDimensions, pipXYtoAbsoluteXY, xl, lg; let c11397_14 = new Set(); const clamp2 = function clamp(a0, a1, a2) { return Math.min(Math.max(a0, a1), a2); }; clamp2.__closure = {}; clamp2.__workletHash = 10301627783217; clamp2.__initData = { code: "function clamp_VoicePanelPIPUtilsTsx1(value,min,max){return Math.min(Math.max(value,min),max);}" }; clamp = clamp2; const getPIPWindowDimensions2 = function getPIPWindowDimensions(a0, a1) { const xOffset = Math.max(a1.left, PIP_WINDOW_OFFSET); const yOffset = Math.max(a1.top, PIP_WINDOW_OFFSET); return { xOffset, yOffset, xRange: a0.width - xOffset - Math.max(a1.right, PIP_WINDOW_OFFSET), yRange: a0.height - yOffset - Math.max(a1.bottom, PIP_WINDOW_OFFSET) }; }; getPIPWindowDimensions2.__closure = { PIP_WINDOW_OFFSET }; getPIPWindowDimensions2.__workletHash = 10369369214675; getPIPWindowDimensions2.__initData = { code: "function getPIPWindowDimensions_VoicePanelPIPUtilsTsx2(windowDimensions,safeArea){const{PIP_WINDOW_OFFSET}=this.__closure;const xOffset=Math.max(safeArea.left,PIP_WINDOW_OFFSET);const yOffset=Math.max(safeArea.top,PIP_WINDOW_OFFSET);return{xOffset:xOffset,yOffset:yOffset,xRange:windowDimensions.width-xOffset-Math.max(safeArea.right,PIP_WINDOW_OFFSET),yRange:windowDimensions.height-yOffset-Math.max(safeArea.bottom,PIP_WINDOW_OFFSET)};}" }; getPIPWindowDimensions = getPIPWindowDimensions2; const pipXYtoAbsoluteXY2 = function pipXYtoAbsoluteXY({ pipX, pipY, windowDimensions, safeArea }) { const r17 = Math.max(safeArea.left, PIP_WINDOW_OFFSET); const r21 = Math.max(safeArea.top, PIP_WINDOW_OFFSET); return { x: r17 + pipX * (windowDimensions.width - r17 - Math.max(safeArea.right, PIP_WINDOW_OFFSET)), y: r21 + pipY * (windowDimensions.height - r21 - Math.max(safeArea.bottom, PIP_WINDOW_OFFSET)) }; }; pipXYtoAbsoluteXY2.__closure = { getPIPWindowDimensions }; pipXYtoAbsoluteXY2.__workletHash = 13405407399530; pipXYtoAbsoluteXY2.__initData = { code: "function pipXYtoAbsoluteXY_VoicePanelPIPUtilsTsx3({pipX:pipX,pipY:pipY,windowDimensions:windowDimensions,safeArea:safeArea}){const{getPIPWindowDimensions}=this.__closure;const{xOffset:xOffset,yOffset:yOffset,xRange:xRange,yRange:yRange}=getPIPWindowDimensions(windowDimensions,safeArea);return{x:xOffset+pipX*xRange,y:yOffset+pipY*yRange};}" }; pipXYtoAbsoluteXY = pipXYtoAbsoluteXY2; export function getClampedPIPPosition({ pipX, pipY, width, height, windowDimensions, safeArea, bottomAvoidanceRegion = 0, topAvoidanceRegion = 0, positionOffset = { x: 0, y: 0 } }) { const pipX2 = pipX !== -1 ? pipX : 1; const r3 = pipY === -1; const r26 = pipXYtoAbsoluteXY({ pipX: pipX2, pipY: r3 ? 0 : pipY, windowDimensions, safeArea }); const { x: r27, y: r28 } = r26; const r30 = r27 - width / 2; const r32 = r3 ? r28 + 72 : r28 - height / 2; const r18 = Math.max(safeArea.left, PIP_WINDOW_OFFSET); const r42 = Math.max(safeArea.top, PIP_WINDOW_OFFSET); const r47 = windowDimensions.width - r18 - Math.max(safeArea.right, PIP_WINDOW_OFFSET); const r54 = windowDimensions.height - r42 - Math.max(safeArea.bottom, PIP_WINDOW_OFFSET); const r57 = r18 + r47 - width; const r65 = Math.min(Math.max(r30, r18), r57); const r66 = r42 + topAvoidanceRegion; const r69 = r42 + r54 - bottomAvoidanceRegion - height; return { x: r65 + positionOffset.x, y: Math.min(Math.max(r32, r66), r69) + positionOffset.y }; } getClampedPIPPosition.__closure = { pipXYtoAbsoluteXY, getPIPWindowDimensions, clamp }; getClampedPIPPosition.__workletHash = 10462021389431; getClampedPIPPosition.__initData = { code: "function getClampedPIPPosition_VoicePanelPIPUtilsTsx4({pipX:pipX,pipY:pipY,width:width,height:height,windowDimensions:windowDimensions,safeArea:safeArea,bottomAvoidanceRegion=0,topAvoidanceRegion=0,positionOffset={x:0,y:0}}){const{pipXYtoAbsoluteXY,getPIPWindowDimensions,clamp}=this.__closure;let{x:x,y:y}=pipXYtoAbsoluteXY({pipX:pipX===-1?1:pipX,pipY:pipY===-1?0:pipY,windowDimensions:windowDimensions,safeArea:safeArea});const halfWidth=width/2;const halfHeight=height/2;x-=halfWidth;if(pipY===-1){y+=72;}else{y-=halfHeight;}const pipRegion=getPIPWindowDimensions(windowDimensions,safeArea);x=clamp(x,pipRegion.xOffset,pipRegion.xOffset+pipRegion.xRange-width);y=clamp(y,pipRegion.yOffset+topAvoidanceRegion,pipRegion.yOffset+pipRegion.yRange-bottomAvoidanceRegion-height);x+=positionOffset.x;y+=positionOffset.y;return{x:x,y:y};}" }; export function calculatePIPPositionFromVelocity({ velocityX, velocityY, absoluteX, absoluteY, windowDimensions, safeArea }) { let r64, r65; L33: { const r24 = Math.max(safeArea.left, PIP_WINDOW_OFFSET); const r27 = Math.max(safeArea.top, PIP_WINDOW_OFFSET); const r32 = windowDimensions.width - r24 - Math.max(safeArea.right, PIP_WINDOW_OFFSET); const r39 = windowDimensions.height - r27 - Math.max(safeArea.bottom, PIP_WINDOW_OFFSET); const r40 = absoluteX - r24; const r41 = absoluteY - r27; if (Math.max(Math.abs(velocityY), Math.abs(velocityX)) < MIN_PIP_TOSS_VELOCITY) { const r76 = { left: Math.min(Math.max(r40, 0), r32), right: Math.min(Math.max(r32 - r40, 0), r32), top: Math.min(Math.max(r41, 0), r39), bottom: Math.min(Math.max(r39 - r41, 0), r39) }; const r103 = Math; const r112 = r103.min.apply(r103, [...Object.values(r76)]); const r115 = r76.left !== r112 ? r76.top !== r112 ? r76.right === r112 ? "right" : "bottom" : "top" : "left"; if (r115 === "left") { r65 = r41 / r39; r64 = 0; } else if (r115 === "right") { r65 = r41 / r39; r64 = 1; } else if (r115 === "top") { r64 = r40 / r32; r65 = 0; } else { r65 = 0; r64 = 0; if (r115 === "bottom") { r64 = r40 / r32; r65 = 1; } } } else { const r52 = velocityY / velocityX; const r54 = velocityX > 0 ? r32 : 0; const r57 = r41 + r52 * (r54 - r40); if (r57 >= 0 && r57 <= r39) { r64 = r54 / r32; r65 = r57 / r39; break L33; } const r58 = 1 / r52; const r60 = velocityY > 0 ? r39 : 0; r64 = (r40 + r58 * (r60 - r41)) / r32; r65 = r60 / r39; } } return { pipX: Math.min(Math.max(r64, 0), 1), pipY: Math.min(Math.max(r65, 0), 1) }; } calculatePIPPositionFromVelocity.__closure = { getPIPWindowDimensions, MIN_PIP_TOSS_VELOCITY, clamp }; calculatePIPPositionFromVelocity.__workletHash = 14615762848981; calculatePIPPositionFromVelocity.__initData = { code: "function calculatePIPPositionFromVelocity_VoicePanelPIPUtilsTsx5({velocityX:velocityX,velocityY:velocityY,absoluteX:absoluteX,absoluteY:absoluteY,windowDimensions:windowDimensions,safeArea:safeArea}){const{getPIPWindowDimensions,MIN_PIP_TOSS_VELOCITY,clamp}=this.__closure;const pipRegion=getPIPWindowDimensions(windowDimensions,safeArea);const{xRange:xRange,yRange:yRange}=pipRegion;const x=absoluteX-pipRegion.xOffset;const y=absoluteY-pipRegion.yOffset;let pipX=0;let pipY=0;if(Math.max(Math.abs(velocityY),Math.abs(velocityX))0?xRange:0;intersectionY=y+slope*(intersectionX-x);if(intersectionY>=0&&intersectionY<=yRange){pipX=intersectionX/xRange;pipY=intersectionY/yRange;}else{intersectionY=velocityY>0?yRange:0;intersectionX=x+1/slope*(intersectionY-y);pipX=intersectionX/xRange;pipY=intersectionY/yRange;}}return{pipX:clamp(pipX,0,1),pipY:clamp(pipY,0,1)};}" }; xl = Module712.radii.xl; lg = Module712.radii.lg; export function getVoicePanelPIPBorderRadius(a0, a1) { return a0 <= SquareActivityPIPReferenceDimensions.width && a1 <= SquareActivityPIPReferenceDimensions.height ? lg : xl; } getVoicePanelPIPBorderRadius.__closure = { SquareActivityPIPReferenceDimensions, lg, xl }; getVoicePanelPIPBorderRadius.__workletHash = 16698745361037; getVoicePanelPIPBorderRadius.__initData = { code: "function getVoicePanelPIPBorderRadius_VoicePanelPIPUtilsTsx6(width,height){const{SquareActivityPIPReferenceDimensions,lg,xl}=this.__closure;if(width<=SquareActivityPIPReferenceDimensions.width&&height<=SquareActivityPIPReferenceDimensions.height){return lg;}return xl;}" }; export { PIPReferenceDimensions }; export { SquarePIPReferenceDimensions }; export { SquareActivityPIPReferenceDimensions }; export function computePIPSize(a0, a1, a2, a3) { let height2, width2; L15: { const { width, height } = a0; if (!a1 && width !== height) { if (width >= height) { const r20 = a2 ? SquareActivityPIPReferenceDimensions.width : PIPReferenceDimensions.width; height2 = r20 * Math.max(0.5, a0.height / a0.width); width2 = r20; break L15; } height2 = a2 ? SquareActivityPIPReferenceDimensions.height : PIPReferenceDimensions.height; width2 = height2 * Math.max(0.5, a0.width / a0.height); } else { const r29 = a2 ? SquareActivityPIPReferenceDimensions : SquarePIPReferenceDimensions; width2 = r29.width; height2 = r29.height; } } return { width: width2, height: height2, containerHeight: a3 ? 2 * height2 + SECONDARY_PIP_TOP_MARGIN : height2 }; } export function computePIPParticipantToShow({ channelId, panelMode, lastParticipantId, speakingUserId, focusedParticipantId, blockList = c11397_14, showSecondaryPIP }) { let r209; const id = AuthenticationStore.getId(); const r35 = focusedParticipantId != null ? ChannelRTCStore.getParticipant(channelId, focusedParticipantId) : void 0; if (panelMode === VoicePanelModes.PANEL && r35 == null) { return void 0; } if (panelMode === VoicePanelModes.PANEL && focusedParticipantId != null && r35?.type === ParticipantTypes.STREAM && r35?.userVideo === true && !blockList.has(r35.user.id)) { const participant = ChannelRTCStore.getParticipant(channelId, r35.user.id); if (participant != null && canRenderParticipantVideo(participant)) { return { id: participant.id, type: ParticipantTypes.USER }; } } if (focusedParticipantId != null && r35 != null && !blockList.has(focusedParticipantId)) { return { id: focusedParticipantId, type: r35.type }; } if (r35?.type !== ParticipantTypes.ACTIVITY && !showSecondaryPIP) { for (const item of ChannelRTCStore.getActivityParticipants(channelId)) { if (!item.participants.some((participant) => isActivityParticipantCurrentUserCurrentSession(participant))) { continue; } if (blockList.has(item.id)) { continue; } return { id: item.id, type: item.type }; } } for (const item2 of ChannelRTCStore.getStreamParticipants(channelId)) { if (blockList.has(item2.id)) { continue; } if (ApplicationStreamingStore.getActiveStreamForUser(item2.user.id, item2.stream.guildId) == null) { continue; } return { id: item2.id, type: item2.type }; } if (speakingUserId != null && !blockList.has(speakingUserId) && ChannelRTCStore.getParticipant(channelId, speakingUserId) != null) { return { id: speakingUserId, type: ParticipantTypes.USER }; } const r131 = lastParticipantId != null ? ChannelRTCStore.getParticipant(channelId, lastParticipantId) : void 0; if (r131 != null && !blockList.has(r131.id)) { const type = r131.type; if (ParticipantTypes.STREAM === type) { if (ApplicationStreamingStore.getActiveStreamForUser(r131.user.id, r131.stream.guildId) != null && canRenderParticipantVideo(r131)) { return { id: r131.id, type: r131.type }; } } else if (ParticipantTypes.ACTIVITY === type) { if (r131.participants.some((participant) => isActivityParticipantCurrentUserCurrentSession(participant))) { return { id: r131.id, type: r131.type }; } } else if (ParticipantTypes.USER === type) { return { id: r131.id, type: r131.type }; } } const participant2 = ChannelRTCStore.getParticipant(channelId, id); if (!blockList.has(id) && participant2 != null && canRenderParticipantVideo(participant2)) { return { id, type: ParticipantTypes.USER }; } for (const item3 of ChannelRTCStore.getVideoParticipants(channelId)) { if (blockList.has(item3.id)) { continue; } if (!canRenderParticipantVideo(item3)) { continue; } return { id: item3.id, type: item3.type }; } L78: { const r208 = blockList.has(id); r209 = void 0; if (!r208) { const r210 = participant2 == null; r209 = void 0; if (!r210) { if (panelMode === VoicePanelModes.PANEL) { const type2 = r35?.type; const ACTIVITY = ParticipantTypes.ACTIVITY; r209 = void 0; if (type2 !== ACTIVITY) { break L78; } } r209 = { id, type: ParticipantTypes.USER }; } } } return r209; } export function getPIPMode({ channelId, connected, manuallyFocusedId, mode, selfHasVideo }) { if (connected) { const r2 = manuallyFocusedId != null ? ChannelRTCStore.getParticipant(channelId, manuallyFocusedId) : void 0; if (mode === VoicePanelModes.PANEL && r2 != null) { if (r2.type === ParticipantTypes.ACTIVITY) { return VoicePanelPIPModes.IN_PANEL; } if (r2.type === ParticipantTypes.STREAM && r2.userVideo) { let r43 = ChannelRTCStore.getParticipant(channelId, r2.user.id); if (r43 == null) { r43 = void 0; } if (canRenderParticipantVideo(r43)) { return VoicePanelPIPModes.IN_PANEL; } } if (!selfHasVideo) { return void 0; } if (r2.id !== AuthenticationStore.getId()) { return VoicePanelPIPModes.IN_PANEL; } for (const item of ChannelRTCStore.getVideoParticipants(channelId)) { if (item.id === AuthenticationStore.getId()) { continue; } if (!canRenderParticipantVideo(item)) { continue; } return VoicePanelPIPModes.IN_PANEL; } if (r2.id !== AuthenticationStore.getId()) { return VoicePanelPIPModes.IN_PANEL; } } return mode === VoicePanelModes.PIP ? VoicePanelPIPModes.IN_APP : void 0; } } export { getPIPWindowDimensions }; export { pipXYtoAbsoluteXY };