TelegramPWA/dist/2394.6c7df024badbfa528a12.js
Alexander Zinchuk daea14f37c [Build]
2025-05-14 19:17:41 +03:00

2 lines
67 KiB
JavaScript

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[2394],{83320:(e,t,n)=>{n.r(t),n.d(t,{ActiveCallHeader:()=>tt,GroupCall:()=>et,PhoneCall:()=>rt,RatePhoneCallModal:()=>ct});var a=n(12859),i=n(96454),o=n(31481);function r(e){return 0|e}function s(e){return e>>>0}function c(e,t=3){if(!e)return 0;const{length:n}=e;let a=0;for(let t=0;t<n;t++)a+=e[t]*e[t];const i=Math.sqrt(a/n)/255;return Math.min(1,i*t)}function l(e){return{id:e.id,name:e.name,"rtcp-fbs":e.feedbackTypes,clockrate:e.clockrate,parameters:e.parameters,channels:e.channels}}const d=.1,u="getDisplayMedia"in(navigator?.mediaDevices||{}),p=navigator?.mediaDevices?.getSupportedConstraints().echoCancellation,m=navigator?.mediaDevices?.getSupportedConstraints().noiseSuppression,g=(e,t=!1)=>{if(!e||!e.sdp)throw Error("Failed parsing SDP: session description is null");const n=e.sdp.split("\r\nm=").map(((e,t)=>0===t?e:`m=${e}`)).reduce(((e,t)=>{const n=t.match(/^m=(.+?)\s/)?.[1]||"header";return e[e.hasOwnProperty(n)&&"video"===n?"screencast":n]=t.split("\r\n").filter(Boolean),e}),{}),a=(e,t)=>t?n[t]?.find((t=>t.startsWith(e)))?.substr(e.length):Object.values(n).map((t=>t.find((t=>t.startsWith(e)))?.substr(e.length))).filter(Boolean)[0],i=e=>n[e].filter((e=>e.startsWith("a=extmap"))).map((e=>{const[,t,n]=e.match(/extmap:(\d+)(?:\/.+)?\s(.+)/);return{id:Number(t),uri:n}})),o=e=>{const t=n[e].filter((e=>e.startsWith("a=rtpmap"))).map((e=>{const[,t,n]=e.match(/:(\d+)\s(.+)/)||[],[a,i,o]=n.split("/");return{id:Number(t),name:a,clockrate:Number(i),...o&&{channels:Number(o)}}})),a=n[e].filter((e=>e.startsWith("a=rtcp-fb"))).map((e=>{const[,t,n]=e.match(/:(\d+)\s(.+)/)||[],[a,i]=n.split(" ");return{id:Number(t),type:a,subtype:i||""}})),i=n[e].filter((e=>e.startsWith("a=fmtp"))).map((e=>{const[,t,n]=e.match(/:(\d+)\s(.+)/)||[],a=n?.split(";").reduce(((e,t)=>{const[n,a]=t.split("=");return e[n]=a,e}),{});if(a&&!Object.values(a).some((e=>!e)))return{id:Number(t),data:a}})).filter(Boolean);return t.map((e=>{const t=i.filter((t=>t.id===e.id)).map((e=>e.data)).reduce(((e,t)=>Object.assign(e,t)),{}),n=a.filter((t=>t.id===e.id)).map((e=>({type:e.type,subtype:e.subtype})));return{...e,...Object.keys(t).length>0&&{parameters:t},...n.length>0&&{feedbackTypes:n}}}))},s=a("a=ssrc:","audio"),c=s&&Number(s.split(" ")[0]),l=a("a=ssrc-group:","video")?.split(" ")||void 0,d=a("a=ssrc-group:","screencast")?.split(" ")||void 0;if(!l)throw Error("Failed parsing SDP: no video ssrc");const[u,p]=a("a=fingerprint:")?.split(" ")||[],m=a("a=setup:");if(!u||!p)throw Error("Failed parsing SDP: no fingerprint");console.log(n);const g=a("a=ice-ufrag:"),f=a("a=ice-pwd:");if(!g||!f)throw Error("Failed parsing SDP: no ICE ufrag or pwd");return{fingerprints:[{fingerprint:p,hash:u,setup:t?m:"active"}],pwd:f,ufrag:g,...c&&{ssrc:r(c)},...l&&{"ssrc-groups":[{semantics:l[0],sources:l.slice(1,l.length).map(Number).map(r)},t&&d&&{semantics:d[0],sources:d.slice(1,d.length).map(Number).map(r)}].filter(Boolean)},...t&&{audioExtmap:i("audio"),videoExtmap:i("video"),screencastExtmap:i("screencast"),audioPayloadTypes:o("audio"),videoPayloadTypes:o("video"),screencastPayloadTypes:o("screencast")}}},f=(e,t=!1,n=!1,a=!1)=>{const i=[],o=e=>{i.push(e)},{sessionId:r,ssrcs:c,audioExtensions:l,videoExtensions:d,audioPayloadTypes:u,videoPayloadTypes:p,transport:{ufrag:m,pwd:g,fingerprints:f,candidates:v}}=e;o("v=0"),o(`o=- ${r} 2 IN IP4 0.0.0.0`),o("s=-"),o("t=0 0"),o("a=ice-options:trickle"),o("a=msid-semantic:WMS *"),o(`a=group:BUNDLE ${c.map((e=>e.mid)).join(" ")}${n?"":" "+(a?"3":"2")}`),a||o("a=ice-lite");const h=e=>{if(e.sdpString)o(`a=${e.sdpString}`);else{let t="";t+="a=candidate:",t+=`${e.foundation} ${e.component} ${e.protocol} ${e.priority} ${e.ip} ${e.port} typ ${e.type}`,"rel-addr"in e&&(t+=` raddr ${e["rel-addr"]} rport ${e["rel-port"]}`),t+=` generation ${e.generation}`,o(t)}},y=()=>{o(`a=ice-ufrag:${m}`),o(`a=ice-pwd:${g}`),f.forEach((e=>{o(`a=fingerprint:${e.hash} ${e.fingerprint}`),o(`a=setup:${a?e.setup:"passive"}`)})),v.forEach(h)},A=e=>{const{channels:t,id:n,name:a,clockrate:i,parameters:r}=e;if(o(`a=rtpmap:${n} ${a}/${i}${t?`/${t}`:""}`),r){const e=Object.keys(r).map((e=>`${e}=${r[e]};`)).join(" ");o(`a=fmtp:${n} ${e}`)}e["rtcp-fbs"]?.forEach((e=>{o(`a=rtcp-fb:${n} ${e.type}${e.subtype?` ${e.subtype}`:""}`)}))},C=e=>{const n=e.isVideo?p:u,i=e.isVideo?"video":"audio";if(o(`m=${i} ${e.isMain?1:0} RTP/SAVPF ${n.map((e=>e.id)).join(" ")}`),o("c=IN IP4 0.0.0.0"),o("b=AS:1300"),o(`a=mid:${e.mid}`),o("a=rtcp-mux"),n.forEach(A),o("a=rtcp:1 IN IP4 0.0.0.0"),e.isVideo&&o("a=rtcp-rsize"),(e.isVideo?d:l).forEach((({id:e,uri:t})=>{o(`a=extmap:${e} ${t}`)})),e.isRemoved)o("a=inactive");else{if(y(),a)o("a=sendrecv"),o("a=bundle-only");else{if(t)return void o("a=recvonly");e.isMain?o("a=sendrecv"):(o("a=sendonly"),o("a=bundle-only"))}e.sourceGroups.forEach((t=>{t.semantics&&o(`a=ssrc-group:${t.semantics} ${t.sources.map(s).join(" ")}`),t.sources.forEach((t=>{const n=s(t);o(`a=ssrc:${n} cname:${e.endpoint}`),o(`a=ssrc:${n} msid:${e.endpoint} ${e.endpoint}`),o(`a=ssrc:${n} mslabel:${e.endpoint}`),o(`a=ssrc:${n} label:${e.endpoint}`)}))}))}};return a?c.filter(C):c.filter((e=>"0"===e.mid||"1"===e.mid)).map(C),n||(o("m=application 1 UDP/DTLS/SCTP webrtc-datachannel"),o("c=IN IP4 0.0.0.0"),y(),o("a=ice-options:trickle"),o("a=mid:"+(a?"3":n?"1":"2")),o("a=sctp-port:5000"),o("a=max-message-size:262144")),a||c.filter((e=>"0"!==e.mid&&"1"!==e.mid)).map(C),`${i.join("\n")}\n`},v=e=>{const t=e.createOscillator(),n=t.connect(e.createMediaStreamDestination());return t.start(),new MediaStream([Object.assign(n.stream.getAudioTracks()[0],{enabled:!1})])},h=({width:e=640,height:t=480}={})=>{const n=Object.assign(document.createElement("canvas"),{width:e,height:t}),a=n.getContext("2d");if(!a)throw Error("Cannot create canvas ctx");a.fillRect(0,0,e,t);const i=n.captureStream();return new MediaStream([Object.assign(i.getVideoTracks()[0],{enabled:!1})])};var y=n(9705),A=n(41733);let C,b;function E(e){C&&(C.screenshareDataChannel?.close(),C.screenshareConnection?.close(),e||C.onUpdate?.({"@type":"updateGroupCallLeavePresentation"}))}function w(e){return C?.streams?.[e]}function S(e,t){const n=C?.participantFunctions?.[e];n&&n.setVolume?.(t)}function k(e,t){const n=t||C?.myId,a=n&&w(n)?.[e];return!!a&&a.getTracks()[0]?.enabled}function P(e){C?.onUpdate?.({"@type":"updateGroupCallStreams",userId:e,hasAudioStream:k("audio",e),hasVideoStream:k("video",e),hasPresentationStream:k("presentation",e),amplitude:C.speaking?.[e]})}async function I(e,t="user"){if("audio"===e&&C?.audioStream)return C.audioStream;if("presentation"===e)return navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0});const n=await navigator.mediaDevices.getUserMedia({audio:"audio"===e&&{...p&&{echoCancellation:!0},...m&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}});if(C&&"audio"===e&&(C.audioStream=n),"video"===e){const e=document.createElement("video");e.srcObject=n;const t=new y.A;e.oncanplay=()=>t.resolve(),await t.promise}return n}async function T(e,t=void 0){if(!(C&&C.myId&&C.connection&&C.streams))return;const n=w(C.myId)?.[e];if(!n)return;const a=n.getTracks()[0];if(!a)return;const i=[...C.connection.getSenders(),...C.screenshareConnection?.getSenders()||[]].find((e=>a.id===e.track?.id));if(i){t=void 0===t?!a.enabled:t;try{if(t&&!a.enabled){const t=await I(e);if(await i.replaceTrack(t.getTracks()[0]),C.streams[C.myId][e]=t,"video"===e)C.facingMode="user";else if("audio"===e){const{audioContext:e}=C;if(!e)return;const n=C.audioSource||e.createMediaStreamSource(t),a=C.audioAnalyser||e.createAnalyser();a.minDecibels=-100,a.maxDecibels=-30,a.smoothingTimeConstant=.05,a.fftSize=1024,n.connect(a),C={...C,audioSource:n,audioAnalyser:a,participantFunctions:{...C.participantFunctions,[C.myId]:{...C.participantFunctions?.[C.myId],getCurrentAmplitude:()=>{const e=new Uint8Array(a.frequencyBinCount);return a.getByteFrequencyData(e),c(e,1.5)}}}}}}else if(!t&&a.enabled){const t="audio"===e?C.silence:C.black;if(!t)return;await i.replaceTrack(t.getTracks()[0]),C.streams[C.myId][e]=t,"video"===e&&(C.facingMode=void 0),"audio"!==e?a.stop():(C.audioSource?.disconnect(),C.audioAnalyser?.disconnect())}P(C.myId),"presentation"!==e||t||E(!0)}catch(e){}}}function N(e){C?.onUpdate?.({"@type":"updateGroupCallConnectionState",connectionState:e})}function M(){C&&(C.myId&&C.streams?.[C.myId]&&Object.values(C.streams[C.myId]||{}).forEach((e=>{e?.getTracks().forEach((e=>{e.stop()}))})),C.audioStream?.getTracks().forEach((e=>{e.stop()})),E(!0),C.dataChannel?.close(),C.connection?.close(),N("disconnected"),C.analyserInterval&&clearInterval(C.analyserInterval),C=void 0)}function x(){C&&C.participantFunctions&&Object.keys(C.participantFunctions).forEach((e=>{const{getCurrentAmplitude:t}=C.participantFunctions[Number(e)];if(t){const n=t(),a=C.speaking[e]||0;C.speaking[e]=n,(n>d&&a<=d||n<=d&&a>d)&&P(e)}}))}async function V(e){if(!C)return;const{participants:t,conference:n,connection:a,myId:i}=C;if(!(t&&n&&a&&n.ssrcs&&n.transport&&i))return;if(e.find((e=>e.isSelf&&e.source!==C?.conference?.ssrcs?.find((e=>e.isMain&&!e.isVideo))?.sourceGroups[0].sources[0])))return void M();const o=[];if(e.forEach((e=>{if(e.isSelf)return void(e.isMuted&&!e.canSelfUnmute&&(T("audio",!1),T("video",!1),T("presentation",!1)));const{isLeft:t}=e,a=e.isMuted||e.isMutedByMe,i=!e.isVideoJoined||!e.video||t,r=!e.presentation||t;let s=!1,c=!1,l=!1;n.ssrcs.filter((t=>t.userId===e.id)).forEach((t=>{t.isVideo||(t.sourceGroups[0].sources[0]===e.source&&(c=!0),t.isRemoved=a),t.isVideo&&(t.isPresentation||(e.video&&t.endpoint===e.video.endpoint&&(s=!0),t.isRemoved=i),t.isPresentation&&(e.presentation&&t.endpoint===e.presentation.endpoint&&(l=!0),t.isRemoved=r))})),a||c||(C.lastMid=C.lastMid+1,n.ssrcs.push({userId:e.id,isMain:!1,endpoint:`audio${e.source}`,isVideo:!1,sourceGroups:[{sources:[e.source]}],mid:C.lastMid.toString()})),i||s||!e.video||(C.lastMid=C.lastMid+1,o.push(e.video.endpoint),n.ssrcs.push({userId:e.id,isMain:!1,endpoint:e.video.endpoint,isVideo:!0,sourceGroups:e.video.sourceGroups,mid:C.lastMid.toString()})),r||l||!e.presentation||(C.lastMid=C.lastMid+1,n.ssrcs.push({isPresentation:!0,userId:e.id,isMain:!1,endpoint:e.presentation.endpoint,isVideo:!0,sourceGroups:e.presentation.sourceGroups,mid:C.lastMid.toString()}))})),C.updatingParticipantsQueue)return void C.updatingParticipantsQueue.push(n);C.updatingParticipantsQueue=[];const r=f(n);await a.setRemoteDescription({type:"offer",sdp:r});try{const e=await a.createAnswer();if(await a.setLocalDescription(e),P(i),C.updatingParticipantsQueue.length>0)for(const e of C.updatingParticipantsQueue){await a.setRemoteDescription({type:"offer",sdp:f(e)});const t=await a.createAnswer();await a.setLocalDescription(t),P(i)}C.updatingParticipantsQueue=void 0}catch(e){console.error(e)}}function G(e){if(!(C&&C.audioElement&&C.audioContext&&C.mediaStream))return;const t=C.conference?.ssrcs?.find((t=>t.endpoint===e.track.id));if(!t||!t.userId)return;const{userId:n,isPresentation:a}=t,i=C.participants?.find((e=>e.id===n)),o="video"===e.track.kind?a?"presentation":"video":"audio";e.track.onended=()=>{delete C?.streams?.[n][o],P(n)};const r=e.streams[0];if("audio"===e.track.kind){const{mediaStream:e}=C,t=new window.AudioContext,a=t.createMediaStreamSource(r),o=t.createGain();o.gain.value=(i?.volume||1e4)/1e4;const s=t.createGain();o.gain.value=1;const l=t.createAnalyser();l.minDecibels=-100,l.maxDecibels=-30,l.smoothingTimeConstant=.05,l.fftSize=1024,a.connect(l).connect(s).connect(o).connect(t.destination),e.addTrack(a.mediaStream.getAudioTracks()[0]);const d=new Audio;d.srcObject=r,d.muted=!0,d.remove(),C={...C,participantFunctions:{...C.participantFunctions,[n]:{...C.participantFunctions?.[n],setVolume:e=>{o.gain.value=e>1?2*e:e},toggleMute:e=>{s.gain.value=e?0:1},getCurrentAmplitude:()=>{const e=new Uint8Array(l.frequencyBinCount);return l.getByteFrequencyData(e),c(e,1.5)}}}}}C={...C,streams:{...C.streams,[n]:{...C.streams?.[n],[o]:r}}},P(n)}function R(e,t,n=!1){const a=new RTCPeerConnection,i=n?void 0:function(e){const t=e.createDataChannel("data",{id:0});return t.onopen=()=>{},t.onmessage=e=>{JSON.parse(e.data).colibriClass},t.onerror=e=>{console.log("%conerror","background: green; font-size: 5em"),console.error(e)},t}(a);return e.forEach((e=>e.getTracks().forEach((t=>{a.addTrack(t,e)})))),n||(a.oniceconnectionstatechange=()=>{const e=a.iceConnectionState;console.log("iceconnectionstatechange",e),"connected"===e||"completed"===e?N("connected"):"checking"===e||"new"===e?N("connecting"):"disconnected"===a.iceConnectionState&&N("reconnecting")}),a.onconnectionstatechange=()=>{console.log("connectionstatechange",a.connectionState)},a.ontrack=G,a.onnegotiationneeded=async()=>{if(!C)return;console.log("onnegotiationneeded");const{myId:i}=C;if(!i)return;const o=await a.createOffer({offerToReceiveVideo:!0,offerToReceiveAudio:!n});if(console.log("offer created"),await a.setLocalDescription(o),console.log("local desc set"),!o.sdp)return;const r=g(o),s=n?void 0:{userId:"",sourceGroups:[{sources:[r.ssrc||0]}],isRemoved:n,isMain:!0,isVideo:!1,isPresentation:n,endpoint:n?"1":"0",mid:n?"1":"0"},c=r["ssrc-groups"]&&{isPresentation:n,userId:"",sourceGroups:r["ssrc-groups"],isMain:!0,isVideo:!0,endpoint:n?"0":"1",mid:n?"0":"1"},l=n?C.screenshareConference:C.conference,d=[];n?(c&&d.push(c),s&&d.push(s)):(s&&d.push(s),c&&d.push(c));const u=e.find((e=>"audio"===e.getTracks()[0].kind)),p=e.find((e=>"video"===e.getTracks()[0].kind));C={...C,...n?{screenshareConference:{...l,ssrcs:d}}:{conference:{...l,ssrcs:d}},streams:{...C.streams,[i]:{...C.streams?.[i],...u&&{audio:u},...!n&&p?{video:p}:{presentation:p}}}},P(i),t(r)},{connection:a,dataChannel:i}}function B(){b?.onUpdate({...b.mediaState,"@type":"updatePhoneCallMediaState"})}function L(e,t="user"){return"presentation"===e?navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0}):navigator.mediaDevices.getUserMedia({audio:"audio"===e&&{...p&&{echoCancellation:!0},...m&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}})}async function O(e,t=void 0){if(!b)return;const n="audio"===e?b.streams.ownAudio:"video"===e?b.streams.ownVideo:b.streams.ownPresentation;if(!n)return;const a=n.getTracks()[0];if(!a)return;const i=b.connection.getSenders().find((e=>a.id===e.track?.id));if(i){t=void 0===t?!a.enabled:t;try{if(t&&!a.enabled){const t=await L(e);t.getTracks()[0].onended=()=>{O(e,!1)},await i.replaceTrack(t.getTracks()[0]),"audio"===e?b.streams.ownAudio=t:"video"===e?(b.streams.ownVideo=t,b.facingMode="user"):b.streams.ownPresentation=t,"video"!==e&&"presentation"!==e||O("video"===e?"presentation":"video",!1)}else if(!t&&a.enabled){a.stop();const t="audio"===e?b.silence:"video"===e?b.blackVideo:b.blackPresentation;if(!t)return;await i.replaceTrack(t.getTracks()[0]),"audio"===e?b.streams.ownAudio=t:"video"===e?b.streams.ownVideo=t:b.streams.ownPresentation=t}B(),_()}catch(e){console.error(e)}}}function U(){b&&(b.streams.ownVideo?.getTracks().forEach((e=>e.stop())),b.streams.ownPresentation?.getTracks().forEach((e=>e.stop())),b.streams.ownAudio?.getTracks().forEach((e=>e.stop())),b.dataChannel.close(),b.connection.close(),b=void 0)}function _(){if(!b)return;const{emitSignalingData:e,streams:t}=b;e({"@type":"MediaState",videoRotation:0,isMuted:!t.ownAudio?.getTracks()[0].enabled,isBatteryLow:!0,videoState:t.ownVideo?.getTracks()[0].enabled?"active":"inactive",screencastState:t.ownPresentation?.getTracks()[0].enabled?"active":"inactive"})}function D(e){if(!b||b.isOutgoing)return e;const{payloadTypes:t}=e,n=t.findIndex((e=>"VP8"===e.name)),a=t[n],i=t.findIndex((e=>Number(e.parameters?.apt)===a.id));return e.payloadTypes=[t[n],t[i]],e}function F(e){if(!b)return;const{emitSignalingData:t}=b;e.ssrc&&e["ssrc-groups"]&&e["ssrc-groups"][0]&&e["ssrc-groups"][1]&&t({"@type":"InitialSetup",fingerprints:e.fingerprints,ufrag:e.ufrag,pwd:e.pwd,audio:{ssrc:s(e.ssrc).toString(),ssrcGroups:[],payloadTypes:e.audioPayloadTypes,rtpExtensions:e.audioExtmap},video:D({ssrc:s(e["ssrc-groups"][0].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][0].semantics,ssrcs:e["ssrc-groups"][0].sources.map(s)}],payloadTypes:e.videoPayloadTypes,rtpExtensions:e.videoExtmap}),screencast:D({ssrc:s(e["ssrc-groups"][1].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][1].semantics,ssrcs:e["ssrc-groups"][1].sources.map(s)}],payloadTypes:e.screencastPayloadTypes,rtpExtensions:e.screencastExtmap})})}async function $(e){if(b&&b.connection)switch(e["@type"]){case"MediaState":b.mediaState=e,B(),_();break;case"Candidates":{const{pendingCandidates:t,gotInitialSetup:n}=b;e.candidates.forEach((e=>{t.push(e.sdpString)})),n&&await J();break}case"InitialSetup":{const{connection:t,isOutgoing:n}=b;if(!t)return;const a={transport:{candidates:[],ufrag:e.ufrag,pwd:e.pwd,fingerprints:e.fingerprints,"rtcp-mux":!1,xmlns:""},sessionId:Date.now(),ssrcs:[e.audio&&{isVideo:!1,isMain:!1,userId:"123",endpoint:"0",mid:"0",sourceGroups:[{sources:[e.audio.ssrc]}]},e.video&&{isVideo:!0,isPresentation:!1,isMain:!1,userId:"123",endpoint:"1",mid:"1",sourceGroups:e.video.ssrcGroups.map((e=>({semantics:e.semantics,sources:e.ssrcs})))},e.screencast&&{isVideo:!0,isPresentation:!0,isMain:!1,userId:"123",endpoint:"2",mid:"2",sourceGroups:e.screencast.ssrcGroups.map((e=>({semantics:e.semantics,sources:e.ssrcs})))}],audioPayloadTypes:e.audio.payloadTypes?.map(l)||[],audioExtensions:e.audio.rtpExtensions,videoPayloadTypes:D(e.video).payloadTypes?.map(l)||[],videoExtensions:e.video.rtpExtensions};if(await t.setRemoteDescription({sdp:f(a,n,void 0,!0),type:n?"answer":"offer"}),b.conference=a,!n){const e=await t.createAnswer();await t.setLocalDescription(e),F(g(t.localDescription,!0))}b.gotInitialSetup=!0,await J();break}}}async function J(){if(!b)return;const{pendingCandidates:e,connection:t}=b;e.length&&(await Promise.all(e.map((e=>async function(e,t){try{await e.addIceCandidate({candidate:t,sdpMLineIndex:0})}catch(e){console.error(e)}}(t,e)))),b.pendingCandidates=[])}async function j(e,t){const n=await e.createOffer(t);await e.setLocalDescription(n),F(g(e.localDescription,!0))}var z=n(14487),H=n(4875),K=n(13439),q=n(80840),W=n(32989),Z=n(29807),Y=n(71331),Q=n(42347);(0,K.aJ)("leaveGroupCall",(async(e,t,n)=>{const{isFromLibrary:i,shouldDiscard:o,shouldRemove:r,rejoin:s,isPageUnload:c,tabId:l=(0,z.g0)()}=n||{},d=(0,Y.iT)(e);d&&(e=(0,q.R6)(e,{connectionState:"disconnected"},d.participantsCount-1),e={...e,groupCalls:{...e.groupCalls,activeGroupCallId:void 0}},(0,K.UF)(e),await(0,H.px)("leaveGroupCall",{call:d,isPageUnload:c}),await(0,H.px)("abortRequestGroup","call"),o&&await(0,H.px)("discardGroupCall",{call:d}),e=(0,K.mS)(),r&&(e=(0,q.um)(e,d.id)),(0,a.ow)(),(0,K.UF)(e),t.toggleGroupCallPanel({force:void 0,tabId:l}),i||M(),t.afterHangUp(),s&&t.requestMasterAndJoinGroupCall({...s,tabId:l}))})),(0,K.aJ)("toggleGroupCallVideo",(async e=>{const t=(0,Y.iT)(e),n=(0,Z.mBe)(e,e.currentUserId);n&&t&&(await T("video"),await(0,H.px)("editGroupCallParticipant",{call:t,videoStopped:!k("video"),participant:n}))})),(0,K.aJ)("requestToSpeak",((e,t,n)=>{const{value:a}=n||{value:!0},i=(0,Y.iT)(e),o=(0,Z.mBe)(e,e.currentUserId);o&&i&&(0,H.px)("editGroupCallParticipant",{call:i,raiseHand:a,participant:o})})),(0,K.aJ)("setGroupCallParticipantVolume",((e,t,n)=>{const{participantId:a,volume:i}=n,r=(0,Y.iT)(e),s=(0,Z.mBe)(e,a);s&&r&&(S(a,Math.floor(i/o.CH0)/100),(0,H.px)("editGroupCallParticipant",{call:r,volume:Number(i),participant:s}))})),(0,K.aJ)("toggleGroupCallMute",(async(e,t,n)=>{const{participantId:a,value:i}=n||{},o=(0,Y.iT)(e),r=(0,Z.mBe)(e,a||e.currentUserId);if(!r||!o)return;const s=void 0===i?k("audio",r.id):i;a?S(a,s?0:1):await T("audio"),await(0,H.px)("editGroupCallParticipant",{call:o,muted:s,participant:r})})),(0,K.aJ)("toggleGroupCallPresentation",(async(e,t,n)=>{const a=(0,Y.iT)(e),i=(0,Z.mBe)(e,e.currentUserId);if(i&&a){if(void 0!==n?.value?n?.value:!k("presentation")){const e=await async function(){if(C)try{const e=await I("presentation");if(!e)return;return e.getTracks()[0].onended=()=>{C&&C.myId&&(delete C.streams?.[C.myId].presentation,P(C.myId),E())},await new Promise((t=>{const{connection:n,dataChannel:a}=R([e],t,!0);C={...C,screenshareConnection:n,screenshareDataChannel:a}}))}catch(e){return}}();if(!e)return;await(0,H.px)("joinGroupCallPresentation",{call:a,params:e})}else await T("presentation",!1),await(0,H.px)("leaveGroupCallPresentation",{call:a});await(0,H.px)("editGroupCallParticipant",{call:a,presentationPaused:!k("presentation"),participant:i})}})),(0,K.aJ)("connectToActiveGroupCall",(async(e,t,n)=>{const{tabId:i=(0,z.g0)()}=n||{},o=(0,Y.iT)(e);if(!o)return;if("discarded"===o.connectionState)return void t.showNotification({message:"This voice chat is not active",tabId:i});const r=(0,a.sN)(),s=(0,a.Hc)();if(!r||!s)return;const{currentUserId:c}=e;if(!c)return;const l=await function(e,t,n,a){if(C)throw Error("Already in call");N("connecting");const i=new MediaStream;return n.srcObject=i,(0,A.A)(n),C={onUpdate:a,participants:[],myId:e,speaking:{},silence:v(t),black:h({width:640,height:480}),analyserInterval:setInterval(x,1e3),audioElement:n,audioContext:t,mediaStream:i,lastMid:3},I("audio"),new Promise((e=>{C={...C,...R([C.silence,C.black],e)}}))}(c,s,r,t.apiUpdate),d=await(0,H.px)("joinGroupCall",{call:o,params:l,inviteHash:o.inviteHash});if(e=(0,K.mS)(),!d)return t.showNotification({message:"Failed to join voice chat",tabId:i}),void t.leaveGroupCall({tabId:i});if(t.loadMoreGroupCallParticipants(),o.chatId){e=(0,K.mS)();const n=(0,Z.hds)(e,o.chatId);if(!n)return;await(0,Q.ad)(e,t,n)}})),(0,K.aJ)("connectToActivePhoneCall",(async(e,t)=>{const{phoneCall:n}=e;if(!n)return;const a=(0,Y.uu)(e);if(!a)return;const i=await(0,H.px)("getDhConfig");if(!i)return;await(0,H.px)("createPhoneCallState",[!0]);const o=await(0,H.px)("requestPhoneCall",[i]);await(0,H.px)("requestCall",{user:a,gAHash:o,isVideo:n.isVideo})||"hangUp"in t&&t.hangUp({tabId:(0,z.g0)()})})),(0,K.aJ)("acceptCall",(async e=>{const{phoneCall:t}=e;if(!t)return;const n=await(0,H.px)("getDhConfig");if(!n)return;await(0,H.px)("createPhoneCallState",[!1]);const a=await(0,H.px)("acceptPhoneCall",[n]);await(0,H.px)("acceptCall",{call:t,gB:a})})),(0,K.aJ)("sendSignalingData",((e,t,n)=>{const{phoneCall:a}=e;if(!a)return;const i=JSON.stringify(n);(async()=>{const e=await(0,H.px)("encodePhoneCallData",[i]);e&&(0,H.px)("sendSignalingData",{data:e,call:a})})()})),(0,K.aJ)("closeCallRatingModal",((e,t,n)=>{const{tabId:a=(0,z.g0)()}=n||{};return(0,W.w)(e,{ratingPhoneCall:void 0},a)})),(0,K.aJ)("setCallRating",((e,t,n)=>{const{rating:a,comment:i,tabId:o=(0,z.g0)()}=n,{ratingPhoneCall:r}=(0,Z.nTw)(e,o);if(r)return(0,H.px)("setCallRating",{call:r,rating:a,comment:i}),(0,W.w)(e,{ratingPhoneCall:void 0},o)})),(0,K.aJ)("hangUp",((e,t,n)=>{const{isPageUnload:a,tabId:i=(0,z.g0)()}=n||{},{phoneCall:o}=e;if(o){if("discarded"===o.state)return(0,H.px)("destroyPhoneCallState"),U(),e={...e,phoneCall:void 0},(0,K.UF)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),void t.afterHangUp();if((0,H.px)("destroyPhoneCallState"),U(),(0,H.px)("discardCall",{call:o,isPageUnload:a}),"requesting"===o.state)return e={...e,phoneCall:void 0},(0,K.UF)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),void t.afterHangUp();setTimeout((()=>{e=(0,K.mS)(),e={...e,phoneCall:void 0},(0,K.UF)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),t.afterHangUp()}),500)}}));var X=n(87894),ee=n(6e4);const te=new Uint16Array([55357,56841,55357,56845,55357,56859,55357,56877,55357,56881,55357,56865,55357,56846,55357,56884,55357,56885,55357,56840,55357,56876,55357,56839,55357,56847,55357,56430,55357,56439,55357,56450,55357,56438,55357,56424,55357,56425,55357,56436,55357,56437,55357,56891,55357,56893,55357,56896,55357,56442,55357,56904,55357,56905,55357,56906,55357,56448,55357,56445,55357,56489,55357,56613,55357,56485,55357,56484,55357,56386,55357,56384,55357,56387,55357,56389,55357,56388,55357,56397,55357,56398,55357,56396,55357,56394,9996,9995,55357,56400,55357,56390,55357,56391,55357,56393,55357,56392,55357,56911,55357,56399,55357,56490,55357,57014,55356,57283,55357,56451,55357,56427,55357,56426,55357,56428,55357,56429,55357,56453,55356,57257,55357,56401,55357,56402,55357,56415,55357,56414,55357,56416,55357,56405,55357,56407,55357,56406,55357,56409,55357,56412,55357,56403,55356,57216,55357,56452,55357,56475,55357,56473,55357,56476,55357,56474,55357,56461,55357,56462,55357,56374,55357,56378,55357,56369,55357,56365,55357,56377,55357,56368,55357,56376,55357,56367,55357,56360,55357,56379,55357,56375,55357,56366,55357,56343,55357,56372,55357,56337,55357,56344,55357,56380,55357,56359,55357,56357,55357,56340,55357,56333,55357,56354,55357,56347,55357,56349,55357,56348,55357,56350,55357,56332,55357,56345,55357,56346,55357,56351,55357,56364,55357,56331,55357,56336,55357,56330,55357,56363,55356,57152,55356,57145,55356,57147,55356,57153,55356,57150,55356,57156,55356,57141,55356,57140,55356,57139,55356,57118,55356,57114,55356,57113,55356,57102,55356,57099,9889,9748,10052,9924,55356,57088,55356,57096,55356,57098,55356,57235,55356,57222,55356,57219,55357,56443,55356,57221,55356,57220,55356,57217,55356,57224,55357,56622,55356,57253,55357,56567,55357,56511,55357,56507,9742,55357,56545,55357,56570,55357,56571,55357,56585,55357,56596,9203,9200,8986,55357,56594,55357,56593,55357,56590,55357,56481,55357,56614,55357,56588,55357,56587,55357,57023,55357,57021,55357,56615,55357,56616,55357,57002,55357,57004,55357,56483,55357,56619,55357,56618,55357,56458,55357,56457,55357,56496,55357,56501,55357,56499,9993,55357,56555,55357,56550,55357,56517,55357,56513,9986,55357,56524,55357,56526,10002,9999,55357,56528,55357,56538,55357,56620,55357,56621,55356,57256,55356,57260,55356,57252,55356,57255,55356,57269,55356,57273,55356,57275,55356,57274,55356,57272,55357,56446,55356,57262,55356,56527,55356,57266,55356,57263,55356,57288,55356,57280,9917,9918,55356,57278,55356,57265,55356,57289,55356,57267,55356,57281,55356,57287,55356,57286,55356,57290,55356,57284,9749,55356,57212,55356,57210,55356,57207,55356,57204,55356,57173,55356,57172,55356,57183,55356,57175,55356,57201,55356,57178,55356,57180,55356,57185,55356,57203,55356,57182,55356,57193,55356,57190,55356,57218,55356,57200,55356,57194,55356,57195,55356,57197,55356,57199,55356,57166,55356,57167,55356,57162,55356,57163,55356,57170,55356,57159,55356,57161,55356,57171,55356,57169,55356,57164,55356,57168,55356,57165,55356,57158,55356,57157,55356,57149,55356,57313,55356,57317,55356,57318,9962,55356,57328,9978,55356,57325,55357,56827,55357,56829,55356,57248,55356,57249,9970,55356,57250,55357,56994,55357,56996,9875,55357,56960,9992,55357,56961,55357,56962,55357,56971,55357,56974,55357,56972,55357,56985,55357,56983,55357,56981,55357,56987,55357,57e3,55357,56980,55357,56978,55357,56977,55357,57010,55357,56992,55357,56988,55357,56998,9888,55357,56999,9981,55356,57264,55357,56831,55356,57258,55356,57261,55356,56815,55356,56821,55356,56816,55356,56823,55356,56809,55356,56810,55356,56808,55356,56819,55356,56826,55356,56824,55356,56811,55356,56823,55356,56810,55356,56824,55356,56814,55356,56825,55356,56823,55356,56826,55356,56812,55356,56807,49,8419,50,8419,51,8419,52,8419,53,8419,54,8419,55,8419,56,8419,57,8419,48,8419,55357,56607,10071,10067,9829,9830,55357,56495,55357,56599,55357,56625,55357,56628,55357,56629,55357,56630,55357,56631]),ne=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,87,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,259,260,261,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,295,297,299,301,303,305,306,307,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,351,353,355,357,359,360,362,364,365,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,407,408,410,412,414,416,418,420,422,424,426,427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499,501,503,505,507,508,510,511,513,515,517,519,521,522,524,526,528,529,531,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,567,569,570,572,574,576,578,582,586,590,594,598,602,606,610,614,618,620,622,624,626,628,630,632,634,636,638,640,641,642,643,644,646,648,650,652,654,656,658];(0,K.aJ)("apiUpdate",((e,t,n)=>{const{activeGroupCallId:a}=e.groupCalls;switch(n["@type"]){case"updateGroupCallLeavePresentation":t.toggleGroupCallPresentation({value:!1});break;case"updateGroupCallStreams":if(!n.userId||!a)break;if(!(0,Y.n5)(e,a,n.userId))break;return(0,q.c5)(e,a,n.userId,(0,X.cJ)(n,["@type","userId"]));case"updateGroupCallConnectionState":if(!a)break;if("disconnected"===n.connectionState){"leaveGroupCall"in t&&t.leaveGroupCall({isFromLibrary:!0,tabId:(0,z.g0)()});break}return(0,q.h9)(e,a,{connectionState:n.connectionState,isSpeakerDisabled:n.isSpeakerDisabled});case"updateGroupCallParticipants":{const{groupCallId:e,participants:t}=n;a===e&&V(t);break}case"updateGroupCallConnection":{if(n.data.stream){t.showNotification({message:"Big live streams are not yet supported",tabId:(0,z.g0)()}),"leaveGroupCall"in t&&t.leaveGroupCall({tabId:(0,z.g0)()});break}!async function(e,t){if(!C)return;const n=t?C.screenshareConference:C.conference,a=t?C.screenshareConnection:C.connection;if(!n||!a||!n.ssrcs)return;const i=Date.now(),o={...n,transport:e.transport,sessionId:i,audioExtensions:e.audio?.["rtp-hdrexts"],audioPayloadTypes:e.audio?.["payload-types"],videoExtensions:e.video?.["rtp-hdrexts"],videoPayloadTypes:e.video?.["payload-types"]};C={...C,...t?{screenshareConference:o}:{conference:o}};try{await a.setRemoteDescription({type:"answer",sdp:f(o,!0,t)})}catch(e){console.error(e)}}(n.data,n.presentation);const a=(0,Y.iT)(e);a?.participants&&Object.keys(a.participants).length>0&&V(Object.values(a.participants));break}case"updatePhoneCallMediaState":return{...e,phoneCall:{...e.phoneCall,...(0,X.cJ)(n,["@type"])}};case"updatePhoneCall":{if(!i.OL)return;const{phoneCall:a,currentUserId:r}=e,s={...a,...n.call},c=a?.adminId===r;if(e={...e,phoneCall:s},(0,K.UF)(e),e=(0,K.mS)(),a&&a.id&&s.id!==a.id)return void("discarded"!==s.state&&(0,H.px)("discardCall",{call:s,isBusy:!0}));const{accessHash:l,state:d,connections:u,gB:p}=s;if(("active"===d||"accepted"===d)&&(o=s.protocol,!o?.libraryVersions.some((e=>"4.0.0"===e||"4.0.1"===e)))){const n=(0,Y.uu)(e);return"hangUp"in t&&t.hangUp({tabId:(0,z.g0)()}),void t.showNotification({message:ee.yE("VoipPeerIncompatible",n?.firstName),tabId:(0,z.g0)()})}if("discarded"===d){if(!a)return;return(0,W.w)(e,{...s.needRating&&{ratingPhoneCall:s},isCallPanelVisible:void 0},(0,z.g0)())}return"accepted"===d&&l&&p?(async()=>{const{gA:t,keyFingerprint:n,emojis:a}=await(0,H.px)("confirmPhoneCall",[p,te,ne]),i={...(e=(0,K.mS)()).phoneCall,emojis:a};e={...e,phoneCall:i},(0,K.UF)(e),(0,H.px)("confirmCall",{call:s,gA:t,keyFingerprint:n})})():"active"===d&&u&&"active"!==a?.state&&(c||((0,H.px)("receivedCall",{call:s}),(async()=>{const{emojis:t}=await(0,H.px)("confirmPhoneCall",[s.gAOrB,te,ne]),n={...(e=(0,K.mS)()).phoneCall,emojis:t};e={...e,phoneCall:n},(0,K.UF)(e)})()),async function(e,t,n,a,i,o){const r=new RTCPeerConnection({iceServers:e.map((e=>({urls:[e.isTurn&&`turn:${e.ip}:${e.port}`,e.isStun&&`stun:${e.ip}:${e.port}`].filter(Boolean),username:e.username,credentialType:"password",credential:e.password}))),iceTransportPolicy:i?"all":"relay",bundlePolicy:"max-bundle",iceCandidatePoolSize:10});r.onicecandidate=e=>{e.candidate&&t({"@type":"Candidates",candidates:[{sdpString:e.candidate.candidate}]})},r.onconnectionstatechange=()=>{o({"@type":"updatePhoneCallConnectionState",connectionState:r.connectionState})},r.ontrack=e=>{if(!b)return;const t=e.streams[0];"audio"===e.track.kind?(b.audio.srcObject=t,b.audio.play().catch(),b.streams.audio=t):"1"===e.transceiver.mid?b.streams.video=t:b.streams.presentation=t,B()},r.oniceconnectionstatechange=async e=>{switch(r.iceConnectionState){case"disconnected":case"failed":n&&await j(r,{offerToReceiveAudio:!0,offerToReceiveVideo:!0,iceRestart:!0})}};const s=v(new AudioContext),c=h({width:640,height:480}),l=h({width:640,height:480});r.addTrack(s.getTracks()[0],s),r.addTrack(c.getTracks()[0],c),r.addTrack(l.getTracks()[0],l);const d=r.createDataChannel("data",{id:0,negotiated:!0});d.onmessage=e=>{$(JSON.parse(e.data))};const u=new Audio;b={audio:u,connection:r,emitSignalingData:t,isOutgoing:n,pendingCandidates:[],onUpdate:o,streams:{ownVideo:c,ownAudio:s,ownPresentation:l},mediaState:{isBatteryLow:!1,screencastState:"inactive",videoState:"inactive",videoRotation:0,isMuted:!0},blackVideo:c,blackPresentation:l,silence:s,dataChannel:d};try{O("audio",!0)}catch(e){console.error(e)}n&&await j(r,{offerToReceiveAudio:!0,offerToReceiveVideo:!0})}(u,t.sendSignalingData,c,Boolean(s?.isVideo),Boolean(s.isP2pAllowed),t.apiUpdate)),e}case"updatePhoneCallConnectionState":{const{connectionState:a}=n;return e.phoneCall?"closed"===a||"disconnected"===a||"failed"===a?void("hangUp"in t&&t.hangUp({tabId:(0,z.g0)()})):{...e,phoneCall:{...e.phoneCall,isConnected:"connected"===a}}:e}case"updatePhoneCallSignalingData":{const{phoneCall:t}=e;if(!t)break;(0,H.px)("decodePhoneCallData",[n.data])?.then($);break}}var o}));var ae=n(84051),ie=n(87357),oe=n(43874),re=n(37661),se=n(5912),ce=n(17712),le=n(59030),de=n(90423),ue=n(73767),pe=n(93545),me=n(18276),ge=n(64493),fe=n(19806),ve=n(12933),he=n(22337),ye=n(96374),Ae=n(46222),Ce=n(4961);function be(e){return Math.floor((e.volume||o.iRY)/o.CH0).toString()}var Ee=n(10722),we=n(21849),Se=n(34431),ke=n(22720),Pe=n(78376),Ie=n(672),Te=n(4438),Ne=n(285),Me=n(71429),xe=n(24433);function Ve(){return Ve=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Ve.apply(this,arguments)}const Ge=[0,17],Re=[17,34],Be=(0,ae.ph)((0,K.EK)((e=>({isAdmin:(0,Y.qI)(e)})))((({participant:e,onCloseAnimationEnd:t,onClose:n,isDropdownOpen:a,isAdmin:i,menuRef:r,...s})=>{const{toggleGroupCallMute:c,setGroupCallParticipantVolume:l,toggleGroupCallPanel:d,openChat:u,requestToSpeak:p}=(0,K.ko)(),m=(0,le.A)(),[g,f,v]=(0,re.A)(),h=e?.id,{isMutedByMe:y,isMuted:A,isSelf:C,canSelfUnmute:b}=e||{},E=Boolean(e?.raiseHandRating),w=!b&&A,[S,k]=(0,ae.J0)(y?0:(e?.volume||o.iRY)/o.CH0),[P,I]=(0,ae.J0)(!1),T=0===S,N=T?Ge:Re;(0,ae.vJ)((()=>{a||I(!1)}),[a]);const M=(0,ce.A)((e=>{k(e),I(0===e!==T)}));(0,ae.vJ)((()=>{k(y?0:(e?.volume||o.iRY)/o.CH0)}),[h]);const x=function(e,t,n=[]){return(0,Ie.A)((e=>{e()}),n,e,t)}(500),V=(0,ce.A)((e=>{e.stopPropagation(),f(),n()})),G=(0,ce.A)((e=>{e.stopPropagation(),p({value:!1}),n()})),R=(0,ce.A)((t=>{t.stopPropagation(),n(),i?w&&M((e?.volume??o.iRY)/o.CH0):M(y?o.iRY/o.CH0:0),c({participantId:h,value:i?!w:!y})})),B=(0,ce.A)((e=>{e.stopPropagation(),d(),u({id:h}),n()}));return ae.Ay.createElement("div",null,ae.Ay.createElement(Me.A,Ve({isOpen:a,ref:r,withPortal:!0,onClose:n,onCloseAnimationEnd:t,className:"participant-menu with-menu-transitions"},s),!C&&!w&&ae.Ay.createElement("div",{className:"group"},ae.Ay.createElement("div",{className:(0,ie.A)("volume-control",S<50&&"low",S>=50&&S<100&&"medium",S>=100&&S<150&&"normal",S>=150&&"high")},ae.Ay.createElement("input",{type:"range",min:"0",max:"200",value:S,onChange:e=>{const t=Number(e.target.value);M(t),x((()=>{0===t?c({participantId:h,value:!0}):l({participantId:h,volume:Math.floor(t*o.CH0)})}))}}),ae.Ay.createElement("div",{className:"info"},ae.Ay.createElement(Te.A,{tgsUrl:Pe.w.Speaker,play:!!P&&N.toString(),playSegment:N,size:24}),ae.Ay.createElement("span",null,S,"%")))),ae.Ay.createElement("div",{className:"group"},E&&C&&ae.Ay.createElement(xe.A,{icon:"stop-raising-hand",onClick:G},m("VoipGroupCancelRaiseHand")),!C&&ae.Ay.createElement(xe.A,{icon:"user",onClick:B},m("VoipGroupOpenProfile")),!C&&ae.Ay.createElement(xe.A,{icon:A&&i&&w?"allow-speak":"microphone-alt",onClick:R},m(i?w?"VoipGroupAllowToSpeak":"VoipMute":y?"VoipGroupUnmuteForMe":"VoipGroupMuteForMe")),!C&&i&&ae.Ay.createElement(xe.A,{icon:"delete-user",destructive:!0,onClick:V},m("VoipGroupUserRemove")))),!C&&i&&ae.Ay.createElement(Ne.A,{isOpen:g,userId:h,onClose:v}))}))),Le=(0,ae.ph)((({participant:e,noColor:t,className:n})=>{const{isMuted:a,isMutedByMe:i}=e,o=(e.amplitude||0)>d,r=Boolean(e.raiseHandRating),s=(0,ue.A)(r),c=!Boolean(e?.canSelfUnmute)&&a,l=(0,ue.A)(a),u=(0,ae.Kr)((()=>a&&!l?[43,64]:!a&&l?[22,42]:r&&!s?[65,84]:!c&&s?[0,21]:a?[22,23]:[43,44]),[a,c,r]),p=(0,ae.Kr)((()=>t?"#ffffff":r?"#4da6e0":c||i?"#ff706f":o?"#57bc6c":"#aaaaaa"),[t,r,c,i,o]);return ae.Ay.createElement(Te.A,{tgsUrl:Pe.w.VoiceOutlined,play:u.toString(),playSegment:u,size:28,color:p,className:n,forceAlways:!0,nonInteractive:!0})})),Oe={root:"Wk7JwPx3",subtitle:"ShcCNemD",subtitleText:"UZLgp2cx",icon:"vRc6jhKf",subtitleBlue:"yA7bxEWw",subtitleRed:"DnuZwImI",subtitleGreen:"BkgYQGFq",avatar:"ouHUJ9ff"},Ue=(0,ae.ph)((0,K.EK)(((e,{participant:t})=>({peer:(0,Z.mBe)(e,t.id)||(0,Z.hds)(e,t.id)})))((({participant:e,peer:t})=>{const n=(0,ae.li)(null),a=(0,ae.li)(null),i=(0,le.A)(),{isSelf:r,isMutedByMe:s,isMuted:c,hasVideoStream:l,hasPresentationStream:u}=e,p=(e.amplitude||0)>d,m=Boolean(e.raiseHandRating),{isContextMenuOpen:g,contextMenuAnchor:f,handleContextMenu:v,handleBeforeContextMenu:h,handleContextMenuClose:y,handleContextMenuHide:A}=(0,Ee.A)(n,r),C=(0,ae.hb)((()=>n.current),[]),b=(0,ae.hb)((()=>n.current.closest(".custom-scroll, .no-scrollbar")),[]),E=(0,ae.hb)((()=>a.current),[]),w=(0,ae.hb)((()=>({withPortal:!0})),[]),S=Boolean(!c&&p&&e.volume&&e.volume!==o.iRY),[k,P]=(0,ae.Kr)((()=>s?[i("VoipGroupMutedForMe"),Oe.subtitleRed]:m?[i("WantsToSpeak"),Oe.subtitleBlue]:S?[i("SpeakingWithVolume",be(e)).replace("%%","%"),Oe.subtitleGreen]:!c&&p?[i("Speaking"),Oe.subtitleGreen]:r?[i("ThisIsYou"),Oe.subtitleBlue]:e.about?[e.about,""]:[i("Listening"),Oe.subtitleBlue]),[s,m,S,c,p,r,e,i]);if(t)return ae.Ay.createElement(ke.A,{leftElement:ae.Ay.createElement(we.A,{peer:t,className:Oe.avatar}),rightElement:ae.Ay.createElement(Le,{participant:e,className:Oe.icon}),className:Oe.root,onClick:v,onMouseDown:h,onContextMenu:v,multiline:!0,ripple:!0,ref:n},ae.Ay.createElement(Se.A,{peer:t,withEmojiStatus:!0,className:Oe.title}),ae.Ay.createElement("span",{className:(0,ie.A)(Oe.subtitle,"subtitle",P)},u&&ae.Ay.createElement(me.A,{name:"share-screen"}),l&&ae.Ay.createElement(me.A,{name:"video"}),S&&ae.Ay.createElement(me.A,{name:"speaker"}),ae.Ay.createElement("span",{className:Oe.subtitleText},(0,Ce.A)(k))),ae.Ay.createElement(Be,{participant:e,isDropdownOpen:g,anchor:f,getTriggerElement:C,getRootElement:b,getMenuElement:E,getLayout:w,onClose:y,onCloseAnimationEnd:A,menuRef:a}))})));function _e(e,t){return(0,X.zV)(!e.isMuted,!t.isMuted)||(0,X.zV)(e.presentation,t.presentation)||(0,X.zV)(e.video,t.video)||(0,X.zV)(e.raiseHandRating,t.raiseHandRating)}const De=(0,ae.ph)((0,K.EK)((e=>{const{participantsCount:t,participants:n}=(0,Y.iT)(e)||{};return{participants:n,participantsCount:t||0}}))((({panelOffset:e,participants:t,participantsCount:n,isLandscape:a})=>{const{loadMoreGroupCallParticipants:i}=(0,K.ko)(),o=(0,ae.Kr)((()=>Object.values(t||{}).sort(_e).map((e=>e.id))),[t]),r=(0,ce.A)((()=>{i()})),[s,c]=(0,ye.A)(r,o,o.length>=n);return ae.Ay.createElement(Ae.A,{items:s,onLoadMore:c,style:`transform: translateY(${e}px);`,className:(0,ie.A)("npTa6CmI",!a&&"v7oB2HTv")},t&&s?.map((e=>t[e]&&ae.Ay.createElement(Ue,{key:e,teactOrderKey:o.indexOf(e),participant:t[e]}))))})));var Fe=n(32610),$e=n(66644),Je=n(19822),je=n(37836),ze=n(32625),He=n(55158);const Ke="eUXuK9Oz",qe="O2bTiH2E",We=(0,ae.ph)((0,K.EK)(((e,{participant:t})=>({user:t.isUser?(0,Z.mBe)(e,t.id):void 0,chat:t.isUser?void 0:(0,Z.hds)(e,t.id)})))((({layout:e,pinnedVideo:t,setPinned:n,canPin:a,className:r,participant:s,user:c,chat:l})=>{const u=(0,le.A)(),p=(0,ae.li)(null),m=(0,ae.li)(null),g=(0,ae.li)(null),{x:f,y:v,width:h,height:y,noAnimate:A,isRemoved:C,type:b}=e,{isSelf:E,isMutedByMe:S,isMuted:k}=s,P=t?.id===s.id&&t?.type===b,I=(s.amplitude||0)>d,T=Boolean(s.raiseHandRating),N="video"===b&&s.isSelf,M=(0,ae.Kr)((()=>E?u("ThisIsYou"):S?u("VoipGroupMutedForMe"):T?u("WantsToSpeak"):k||!I?u("Listening"):s.volume&&s.volume!==o.iRY?u("SpeakingWithVolume",be(s)).replace("%%","%"):u("Speaking")),[E,S,T,k,I,s,u]),x=(0,ae.li)();C||(x.current=e);const{x:V,y:G,width:R,height:B}=x.current||{},[L,O,U,_]=C?[V,G,R,B]:[f,v,h,y],[D,F]=(0,ae.J0)(!A),$=w(c?.id||l.id),J="video"===b?$?.video:$?.presentation,j=(0,ae.li)(J);J?.active&&J?.getVideoTracks()[0].enabled&&(j.current=J);const z=j.current,H=(0,ce.A)((()=>{const e=m.current;e&&(e.srcObject=null)}));(0,ae.vJ)((()=>(z?.addEventListener("inactive",H),()=>{z?.removeEventListener("inactive",H)})),[H,z]),(0,ae.vJ)((()=>{F(!1)}),[]);const[K,q]=(0,ae.J0)(!0),W=(0,ce.A)((()=>{q(!1)}));(0,ze.A)((()=>{if(!z?.active)return;const e=m.current,t=g.current;(0,$e.RK)((()=>{t.width=e.videoWidth,t.height=e.videoHeight,t.getContext("2d").drawImage(e,0,0,t.width,t.height)}))}),1e3),(0,ae.vJ)((()=>{const e=m.current,t=p.current;if(!e||!t||!z)return;const n=t.getContext("2d",{alpha:!1});if(!n)return;let a=!0;return(0,$e.RK)((()=>{a&&(t.width=16,t.height=16,n.filter="blur(2px)",(0,Je.i0)((()=>!!a&&!!z.active&&(n.drawImage(e,0,0,e.videoWidth,e.videoHeight,0,0,t.width,t.height),i.QH||(0,Fe.A)(n,0,0,t.width,t.height,2,2),!0)),je.IJ))})),()=>{a=!1}}),[z]);const Z=(0,ae.li)(null),Y=(0,ae.li)(null),{isContextMenuOpen:Q,contextMenuAnchor:X,handleContextMenu:ee,handleContextMenuClose:te,handleContextMenuHide:ne}=(0,Ee.A)(Z,E),oe=(0,ae.hb)((()=>Z.current),[]),re=(0,ae.hb)((()=>Z.current.closest(".custom-scroll, .no-scrollbar")),[]),se=(0,ae.hb)((()=>Y.current),[]),de=(0,ae.hb)((()=>({withPortal:!0})),[]),ue=(0,ae.hb)((()=>{n(P?void 0:{id:c?.id||l.id,type:b})}),[l,P,n,b,c?.id]);return ae.Ay.createElement("div",{className:(0,ie.A)("DKuzmnN7",(D||C)&&"T_wodAHA",A&&"yPCkJzpi",r,P&&"B4WZhF9P"),style:`--x: ${L}px; --y: ${O}px; --width: ${U}px; --height: ${_}px;`,ref:Z,onContextMenu:ee,onDoubleClick:a?ue:void 0},ae.Ay.createElement("div",{className:(0,ie.A)("eBq1NoLo",I&&"h4NcT6OS")},K&&ae.Ay.createElement(He.A,{className:(0,ie.A)(Ke,"XedVWQii")}),z&&ae.Ay.createElement("video",{className:(0,ie.A)(Ke,N&&qe),muted:!0,autoPlay:!0,playsInline:!0,srcObject:z,ref:m,onCanPlay:W}),ae.Ay.createElement("canvas",{className:(0,ie.A)("eTpvBU_b eUXuK9Oz",N&&qe),ref:g}),ae.Ay.createElement("div",{className:"R5ULTrF9"},ae.Ay.createElement("canvas",{className:(0,ie.A)("cjUWuViy",N&&qe),ref:p})),a&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",ripple:!0,color:"translucent",className:"lPdblo0y",ariaLabel:u(P?"lng_group_call_context_unpin_camera":"lng_group_call_context_pin_camera"),onClick:ue},ae.Ay.createElement(me.A,{name:P?"unpin":"pin"})),ae.Ay.createElement("div",{className:"T1deCDSn"},ae.Ay.createElement("div",{className:"LzFFayK3"},ae.Ay.createElement(Se.A,{peer:c||l,className:"RBwMAuKp"}),ae.Ay.createElement("div",{className:"z1ZZTsjC"},M)),ae.Ay.createElement(Le,{participant:s,className:"j1aDzn1H",noColor:!0}))),ae.Ay.createElement(Be,{participant:s,isDropdownOpen:Q,anchor:X,getTriggerElement:oe,getRootElement:re,getMenuElement:se,getLayout:de,onClose:te,onCloseAnimationEnd:ne,menuRef:Y}))}))),Ze=()=>{navigator.vibrate?.(50)};var Ye=n(57474);const Qe=(0,ae.ph)((0,K.EK)((e=>{const t=(0,Y.iT)(e),{connectionState:n}=t||{},a=t&&(0,Y.n5)(e,t.id,e.currentUserId),{raiseHandRating:i,hasAudioStream:o,canSelfUnmute:r,isMuted:s}=a||{};return{connectionState:n||"discarded",hasRequestedToSpeak:Boolean(i),noAudioStream:!o,canSelfUnmute:r,isMuted:s}}))((({className:e,noAudioStream:t,canSelfUnmute:n,isMuted:a,connectionState:i})=>{const{toggleGroupCallMute:o,requestToSpeak:r,playGroupCallSound:s}=(0,K.ko)(),c=(0,le.A)(),l=(0,ae.li)("up"),[d,u]=(0,ae.J0)(!1),p="connected"!==i,m=!n&&a,g=(0,ue.A)(m);(0,ae.vJ)((()=>{g&&!m&&s({sound:"allowTalk"})}),[s,g,m]);const f=(0,ae.Kr)((()=>{if(d){const e=Math.floor(100*Math.random());return e<32?[0,120]:e<64?[120,240]:e<97?[240,420]:[420,540]}return!g&&m?t?[99,135]:[136,172]:g&&!m?[0,36]:m?[0,0]:t?[69,99]:[36,69]}),[g,d,t,m]),v=d?"HandFilled":"VoiceMini",h=(0,ae.hb)((()=>{Ze(),o()}),[o]),y=(0,ae.hb)((()=>{if(m){if(d)return;return Ze(),r(),u(!0),void setTimeout((()=>{u(!1)}),3e3)}l.current="down",t&&setTimeout((()=>{"down"===l.current&&(l.current="hold",h())}),200)}),[d,t,r,m,h]),A=(0,ae.hb)((()=>{m||(h(),l.current="up")}),[m,h]);return ae.Ay.createElement(ge.A,{round:!0,size:"default",className:(0,ie.A)("lKdhQ5pw",!p&&t&&"bjKqp3SI",!p&&m&&"Ynow5UuE",e),onMouseDown:y,onMouseUp:A,ariaLabel:c(a?"VoipUnmute":"VoipMute"),disabled:p},ae.Ay.createElement(Te.A,{tgsUrl:Pe.w[v],size:36,play:f.toString(),playSegment:f,className:"Ea1XnQaX",forceAlways:!0}),ae.Ay.createElement(Ye.A,{className:(0,ie.A)("tyQNJC6B",p&&"LowChABq"),color:"white"}))}))),Xe={root:"OsO5GKfn",panelWrapper:"cUVoePr_",panel:"Thuz79M3",panelScrollTrigger:"zoK6Y6IS",panelHeader:"DMBtCL9Z",scrolled:"GdEH1Agb",fullscreen:"JJx0QI2w",landscape:"wamCuzMB",headerButton:"gmyieSid",firstButton:"hVnn6KBp",lastButton:"iy78A5rG",panelHeaderText:"TwEEA77i",title:"pNZ9skLf",bigger:"NumT3v5i",subtitle:"gmfUKabx",participants:"iTeC_RxH",participantVideos:"PZmKIdTl",addParticipantButton:"clmu2oBt",videos:"ATwoMlAV",mainVideoContainer:"hqFon3dV",videosHeader:"KPHc659W",appFullscreen:"cl2sfoBF",videosHeaderLastButton:"_t50HVNJ",videosContent:"oEEQZilE",actions:"uGzi9s97",actionButton:"foXbVcnN",destructive:"YIR9Z9CZ",canRequestToSpeak:"ZoiZQu_O",muted:"wpvv1V6m",portrait:"R6HQcMwx",noVideoParticipants:"aepCFyJQ",noSidebar:"XjgP21E6"},et=(0,ae.ph)((0,K.EK)(((e,{groupCallId:t})=>{const{connectionState:n,title:a,participants:i,participantsCount:o,chatId:r}=(0,Y.Ip)(e,t)||{},s=r?(0,Z.hds)(e,r):void 0;return{connectionState:n,title:a||s?.title,participantsCount:o,meParticipant:(0,Y.n5)(e,t,e.currentUserId),isCallPanelVisible:Boolean((0,Z.nTw)(e).isCallPanelVisible),isAdmin:(0,Y.qI)(e),participants:i,canInvite:(0,Y.O7)(e)}}))((({groupCallId:e,isCallPanelVisible:t,connectionState:n,participantsCount:a,title:i,meParticipant:o,isAdmin:r,participants:s,canInvite:c})=>{const{toggleGroupCallVideo:l,toggleGroupCallPresentation:d,leaveGroupCall:p,toggleGroupCallPanel:m,connectToActiveGroupCall:g,playGroupCallSound:f,createGroupCallInviteLink:v}=(0,K.ko)(),h=(0,le.A)(),y=(0,ae.li)(null),A=(0,ae.li)(null),C=(0,ae.li)(null),b=(0,ae.li)(null),E=(0,ae.li)(null),[w,S]=(0,ae.J0)(!1),k=!t&&!w,{observe:P}=(0,se.BL)({rootRef:E,throttleMs:200,isDisabled:!k}),I=!(0,se.Vz)(b,k?P:void 0),{isMobile:T,isLandscape:N}=(0,oe.Ay)(),[M,x,V]=(0,re.A)(),[G,R,B]=(0,re.A)(!0),L=Boolean(M&&N),O=(0,de.zk)(),U=(0,ae.Kr)((()=>Object.values(s).find((({presentation:e})=>e))),[s]),_=(0,ae.Kr)((()=>Object.values(s).filter((({video:e,presentation:t})=>e||t)).flatMap((({id:e,video:t,presentation:n})=>(0,X.oE)([t?{id:e,type:"video"}:void 0,n?{id:e,type:"screen"}:void 0])))),[s]),D=_.length>0,F=i||h("VoipGroupVoiceChat"),$=h("Participants",a,"i"),[J,j,z]=(0,re.A)(),[H,q]=(0,ae.J0)(!1),[W,Z]=(0,ae.J0)(!1),Y=o?.hasVideoStream,Q=o?.hasPresentationStream,ee=o?.hasAudioStream,te="connected"!==n,ne=o?.canSelfUnmute,ye=!ne&&!ee;(0,ae.vJ)((()=>{"connected"===n?f({sound:"join"}):"reconnecting"===n&&f({sound:"connecting"})}),[n]);const Ae=(0,ce.A)((()=>{z(),q(!1)})),Ce=(0,ce.A)((()=>{y.current&&!T&&(M?V():x())})),be=(0,ce.A)((()=>{G?B():R()})),Ee=(0,ce.A)((()=>{m()})),we=(0,ce.A)((()=>{v()})),Se=(0,ce.A)((()=>{l()}));(0,ae.vJ)((()=>{g()}),[g,e]);const ke=(0,ce.A)((()=>{!r||J?(f({sound:"leave"}),S(!0),z()):j()})),Pe=(0,ce.A)((()=>{w&&p({shouldDiscard:W})})),Ie=(0,ce.A)((()=>{d()})),Te=_.length>1&&!T,Ne=L&&D,[Me,xe]=(0,ae.J0)(void 0),{videoLayout:Ve,panelOffset:Ge}=function({primaryContainerRef:e,secondaryContainerRef:t,videoParticipants:n,isLandscapeLayout:a,pinnedVideo:i}){const[o,r]=(0,ae.J0)([]),[s,c]=(0,ae.J0)(0),l=n.length,d=(0,ue.A)(l),u=(0,ue.A)(n),p=(0,ae.Kr)((()=>u?.filter((({id:e,type:t})=>!n.some((n=>n.id===e&&n.type===t))))),[u,n]),m=(0,ce.A)((()=>{const o=e.current,s=t.current;if(!s)return;const u=void 0!==d&&d>l?d-l:0,{x:m,y:g,width:f}=s.getBoundingClientRect(),v=[];if(void 0!==i||!o||!a){const e=!0;let t,s=!1,d=0,h=n;if(i&&o&&a&&(d=h.findIndex((({id:e,type:t})=>e===i.id&&t===i.type)),-1!==d)){const{x:e,y:n,width:a,height:r}=o.getBoundingClientRect(),{id:c,type:l}=i;t={x:e,y:n,width:a,height:r,participantId:c,type:l,orderKey:d},s=!0,h=h.filter((({id:e,type:t})=>e!==c||t!==i.type))}const y=s?l-1:l,A=y%2==1,C=2,b=Math.ceil(y/C),E=(f-10*(C-1))/C,w=Math.max(0,A?240+(b-1)*E+8*(b-1):b*E+8*(b-1));for(let t=0;t<y;t++){const n=A&&0===t,a=n?f:E,i=n?240:E,o=A&&0!==t?t+1:t,r=(e?0:m)+o%C*(a+10),s=(e?0:g)+(A&&0!==t?248+(Math.floor(o/C)-1)*(i+8):Math.floor(o/C)*(i+8));v.push({x:r,y:s,width:a,height:i,shouldRemount:!e,isRemounted:e,noAnimate:!0,participantId:h[t].id,type:h[t].type,orderKey:t>=d?t+1:t})}if(t&&v.splice(d,0,t),p)for(let t=0;t<u;t++)v.push({x:0,y:0,width:0,height:0,isRemounted:e,isRemoved:!0,participantId:p[t].id,type:p[t].type,orderKey:t+l});return c(w),void r(v)}const{x:h,y,width:A,height:C}=o.getBoundingClientRect(),b=function(e){return e>=25?5:e>=13?4:e>=7?3:e>=3?2:1}(l),E=Math.ceil(l/b),w=E*b>l,S=(A-10*(b-1))/b,k=(C-8*(E-1))/E,P=S*(l%b);for(let e=0;e<l;e++){const t=Math.floor(e/b),a=h+e%b*(S+10)+(w&&t===E-1?(A-P)/2:0),i=y+Math.floor(e/b)*(k+8);v.push({x:a,y:i,width:S,height:k,participantId:n[e].id,type:n[e].type,orderKey:e})}if(p)for(let e=0;e<u;e++)v.push({x:0,y:0,width:0,height:0,isRemoved:!0,participantId:p[e].id,type:p[e].type,orderKey:e+l});c(0),r(v)}));return(0,ae.vJ)(m,[m,n,a,i]),(0,pe.A)(e,m,!e.current),(0,pe.A)(t,m,!t.current),{videoLayout:o,panelOffset:s}}({primaryContainerRef:A,secondaryContainerRef:C,videoParticipants:_,isLandscapeLayout:L,pinnedVideo:Me}),Re=(0,ce.A)((e=>{xe(e),e&&!M&&x()})),Be=(0,ce.A)((()=>{U&&xe({id:U.id,type:"screen"})}));return(0,ae.vJ)(Be,[Be,Boolean(U)]),(0,ae.vJ)((()=>{Me&&(_.some((e=>e.type===Me.type&&e.id===Me.id))||xe(void 0))}),[Me,Ve,_]),ae.Ay.createElement(he.A,{isOpen:k,onClose:m,className:(0,ie.A)(Xe.root,(M||T)&&Xe.fullscreen,O&&Xe.appFullscreen,L&&Xe.landscape,!D&&Xe.noVideoParticipants,!L&&Xe.portrait,!G&&Ne&&Xe.noSidebar),dialogRef:y,onCloseAnimationEnd:Pe},Ne&&ae.Ay.createElement("div",{className:Xe.videos},ae.Ay.createElement("div",{className:Xe.videosHeader},!T&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",color:"translucent",onClick:Ce,className:(0,ie.A)(Xe.headerButton,Xe.firstButton),ariaLabel:h(M?"AccExitFullscreen":"AccSwitchToFullscreen")},ae.Ay.createElement(me.A,{name:M?"smallscreen":"fullscreen"})),ae.Ay.createElement("h3",{className:(0,ie.A)(Xe.title,Xe.bigger)},i||h("VoipGroupVoiceChat")),Ne&&!G&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",color:"translucent",className:(0,ie.A)(Xe.headerButton,Xe.videosHeaderLastButton),onClick:be,ariaLabel:h("AccDescrExpandPanel")},ae.Ay.createElement(me.A,{name:"sidebar"}))),ae.Ay.createElement("div",{className:Xe.videosContent,ref:A})),ae.Ay.createElement("div",{className:Xe.panelWrapper,ref:E},ae.Ay.createElement("div",{className:(0,ie.A)(Xe.panel,"custom-scroll")},ae.Ay.createElement("div",{className:Xe.panelScrollTrigger,ref:b}),ae.Ay.createElement("div",{className:(0,ie.A)(Xe.panelHeader,I&&Xe.scrolled)},!Ne&&!T&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",color:"translucent",ripple:!T,className:(0,ie.A)(Xe.firstButton,Xe.headerButton),onClick:Ce,ariaLabel:h("AccSwitchToFullscreen")},ae.Ay.createElement(me.A,{name:"fullscreen"})),T&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",color:"translucent",onClick:Ee,className:(0,ie.A)(Xe.headerButton,Xe.firstButton),ariaLabel:h("Close")},ae.Ay.createElement(me.A,{name:"close"})),Ne&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",ripple:!T,className:(0,ie.A)(Xe.firstButton,Xe.headerButton),color:"translucent",onClick:be,ariaLabel:h("AccDescrCollapsePanel")},ae.Ay.createElement(me.A,{name:"sidebar"})),ae.Ay.createElement("div",{className:Xe.panelHeaderText},ae.Ay.createElement("h3",{className:(0,ie.A)(Xe.title,Ne&&Xe.bigger)},Ne?$:F),!Ne&&ae.Ay.createElement("span",{className:Xe.subtitle},$)),!Ne&&c&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",ripple:!T,className:(0,ie.A)(Xe.lastButton,Xe.headerButton),color:"translucent",onClick:we,ariaLabel:h("VoipGroupInviteMember")},ae.Ay.createElement(me.A,{name:"add-user"}))),ae.Ay.createElement("div",{className:Xe.participants},ae.Ay.createElement("div",{className:Xe.participantVideos,ref:C,style:`height: ${Ge}px;`},Ve.map((e=>{const t=s[e.participantId];return e.isRemounted&&t?ae.Ay.createElement(We,{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`,layout:e,canPin:Te,setPinned:Re,pinnedVideo:Me,participant:t}):ae.Ay.createElement("div",{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`})}))),ae.Ay.createElement(De,{panelOffset:Ge,isLandscape:Ne}))),ae.Ay.createElement(ve.A,{key:"add-participant",isShown:Ne&&c,onClick:we,className:Xe.addParticipantButton,ariaLabel:h("VoipGroupInviteMember")},ae.Ay.createElement(me.A,{name:"add-user-filled"}))),ae.Ay.createElement("div",{className:Xe.mainVideoContainer},Ve.map((e=>{const t=s[e.participantId];return e.isRemounted||!t?ae.Ay.createElement("div",{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`}):ae.Ay.createElement(We,{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`,layout:e,canPin:Te,setPinned:Re,pinnedVideo:Me,participant:t,className:Xe.video})}))),ae.Ay.createElement("div",{className:Xe.actions},ae.Ay.createElement(ge.A,{round:!0,size:"default",ripple:!0,className:(0,ie.A)(Xe.actionButton,!ee&&Xe.muted,ye&&Xe.canRequestToSpeak),onClick:Se,ariaLabel:h(Y?"VoipStopVideo":"VoipStartVideo"),disabled:te},ae.Ay.createElement(me.A,{name:Y?"video":"video-stop"})),ae.Ay.createElement(ge.A,{round:!0,size:"default",ripple:!0,className:(0,ie.A)(Xe.actionButton,!ee&&Xe.muted,ye&&Xe.canRequestToSpeak),onClick:Ie,ariaLabel:h(Q?"lng_group_call_screen_share_stop":"lng_group_call_tooltip_screen"),disabled:te||!u},ae.Ay.createElement(me.A,{name:Q?"share-screen":"share-screen-stop"})),ae.Ay.createElement(Qe,{className:Xe.actionButton}),ae.Ay.createElement(ge.A,{round:!0,size:"default",ripple:!0,className:(0,ie.A)(Xe.actionButton,!ee&&Xe.muted,ye&&Xe.canRequestToSpeak),ariaLabel:h("lng_group_call_settings"),disabled:!0},ae.Ay.createElement(me.A,{name:"settings-filled"})),ae.Ay.createElement(ge.A,{round:!0,size:"default",ripple:!0,className:(0,ie.A)(Xe.actionButton,Xe.destructive),onClick:ke,ariaLabel:h("lng_group_call_leave")},ae.Ay.createElement(me.A,{name:"close"}))),ae.Ay.createElement(he.A,{isOpen:J,onClose:Ae,className:"error",title:h(H?"VoipGroupEndAlertTitle":"VoipGroupLeaveAlertTitle")},ae.Ay.createElement("p",null,h(H?"VoipGroupEndAlertText":"VoipGroupLeaveAlertText")),!H&&ae.Ay.createElement(fe.A,{className:"dialog-checkbox",label:h("VoipGroupEndChat"),checked:W,onCheck:Z}),ae.Ay.createElement("div",{className:"dialog-buttons"},ae.Ay.createElement(ge.A,{isText:!0,className:"confirm-dialog-button",onClick:ke},h(H?"VoipGroupEnd":"VoipGroupLeave")),ae.Ay.createElement(ge.A,{isText:!0,className:"confirm-dialog-button",onClick:Ae},h("Cancel")))))}))),tt=(0,ae.ph)((0,K.EK)((e=>{const t=(0,Z.nTw)(e);return{groupCall:t.isMasterTab?(0,Y.iT)(e):void 0,isCallPanelVisible:t.isCallPanelVisible,phoneCallUser:t.isMasterTab?(0,Y.uu)(e):void 0}}))((({groupCall:e,phoneCallUser:t,isCallPanelVisible:n})=>{const{toggleGroupCallPanel:a}=(0,K.ko)(),i=(0,le.A)();if((0,ae.vJ)((()=>(document.body.classList.toggle("has-call-header",Boolean(n)),window.electron?.setTrafficLightPosition(n?"lowered":"standard"),()=>{document.body.classList.toggle("has-call-header",!1),window.electron?.setTrafficLightPosition("standard")})),[n]),e||t)return ae.Ay.createElement("div",{className:(0,ie.A)("ActiveCallHeader",n&&"open"),onClick:function(){a()}},ae.Ay.createElement("span",{className:"title"},t?.firstName||e?.title||i("VoipGroupVoiceChat")))})));var nt=n(17663),at=n(30857);const it=(0,ae.ph)((({onClick:e,label:t,customIcon:n,icon:a,iconClassName:i,className:o,isDisabled:r,isActive:s})=>ae.Ay.createElement("div",{className:"lBO3RZUM"},ae.Ay.createElement(ge.A,{round:!0,className:(0,ie.A)(o,"ch2sqAKW",s&&"OQxlsRp7"),onClick:e,disabled:r},n||ae.Ay.createElement(me.A,{name:a,className:i})),ae.Ay.createElement("div",{className:"aHguvLcL"},t)))),ot={root:"GNYRVAUg",blurred:"RBmbMiou","single-column":"O7cZE08z",singleColumn:"O7cZE08z",header:"GI6dY5aJ","close-button":"ULiJZuaP",closeButton:"ULiJZuaP","emojis-backdrop":"RFBKZpjx",emojisBackdrop:"RFBKZpjx",open:"zi1NlOXX",emojis:"DFco1VIN","emoji-tooltip":"MRIShZ3V",emojiTooltip:"MRIShZ3V","user-info":"eaUe2A0c",userInfo:"eaUe2A0c",buttons:"qIeflO02",leave:"hclywYYk",accept:"ln_ZBUHy","accept-icon":"cVRd3twS",acceptIcon:"cVRd3twS","main-video":"bGlBFSJq",mainVideo:"bGlBFSJq","second-video":"TOFu1n5x",secondVideo:"TOFu1n5x",visible:"LOnSFN9w",fullscreen:"Omg5T1o6"},rt=(0,ae.ph)((0,K.EK)((e=>{const{phoneCall:t,currentUserId:n}=e,{isCallPanelVisible:a,isMasterTab:i}=(0,Z.nTw)(e),o=(0,Y.uu)(e);return{isCallPanelVisible:Boolean(a),user:o,isOutgoing:t?.adminId===n,phoneCall:i?t:void 0}}))((({user:e,isOutgoing:t,phoneCall:n,isCallPanelVisible:a})=>{const o=(0,le.A)(),{hangUp:r,requestMasterAndAcceptCall:s,playGroupCallSound:c,toggleGroupCallPanel:l,connectToActivePhoneCall:d}=(0,K.ko)(),p=(0,ae.li)(null),[m,g,f]=(0,re.A)(),{isMobile:v}=(0,oe.Ay)(),h=(0,ae.hb)((()=>{m?f():g()}),[f,m,g]),y=(0,ae.hb)((()=>{p.current&&(m?document.exitFullscreen().then(f):p.current.requestFullscreen().then(g))}),[f,m,g]);(0,ae.vJ)((()=>{if(!i.SC)return;const e=p.current;return e?(e.addEventListener("fullscreenchange",h),()=>{e.removeEventListener("fullscreenchange",h)}):void 0}),[h]);const A=(0,ae.hb)((()=>{l(),m&&f()}),[f,m,l]),C="discarded"===n?.state,E="busy"===n?.reason,w="requested"===n?.state&&!t,S=("requested"===n?.state||"waiting"===n?.state)&&t,k="active"===n?.state,P=n?.isConnected,[I,T,N]=(0,re.A)(),M=(0,ae.hb)((()=>{T(),r()}),[r,T]);(0,ae.vJ)((()=>{I?c({sound:"end"}):w?c({sound:"incoming"}):E?c({sound:"busy"}):C?c({sound:"end"}):S?c({sound:"ringing"}):P&&c({sound:"connect"})}),[E,C,w,S,P,c,I]),(0,ae.vJ)((()=>{n?.id?N():d()}),[d,n?.id,N]);const x=(0,at.A)();(0,ze.A)(x,P?1e3:void 0);const V=(0,ae.Kr)((()=>{const e=n?.state;return I?o("lng_call_status_hanging"):E?"busy":"requesting"===e?o("lng_call_status_requesting"):"requested"===e?o(t?"lng_call_status_ringing":"lng_call_status_incoming"):"waiting"===e?o("lng_call_status_waiting"):"active"===e&&P?void 0:o("lng_call_status_exchanging")}),[E,P,I,t,o,n?.state]),G="active"===n?.videoState,R="active"===n?.screencastState,U=b?.streams,_=U?.ownAudio?.getTracks()[0].enabled,D=U?.ownPresentation?.getTracks()[0].enabled,F=U?.ownVideo?.getTracks()[0].enabled,[$,J,j]=(0,re.A)(),[z,H,q]=(0,re.A)(),W=(0,ae.hb)((()=>{D&&J(),F&&H(),setTimeout((async()=>{await O("presentation"),j(),q()}),250)}),[D,F,J,H,j,q]),Z=(0,ae.hb)((()=>{F&&H(),D&&J(),setTimeout((async()=>{await O("video"),j(),q()}),250)}),[D,F,J,H,j,q]),Y=(0,ae.hb)((()=>{O("audio")}),[]),[Q,X,ee]=(0,re.A)(),[te,ne,se]=(0,re.A)(),ce=(0,ae.hb)((()=>{ne(),async function(){if(!b||!b.facingMode)return;const e=b.streams.ownVideo;if(!e)return;const t=e.getTracks()[0];if(!t)return;const n=b.connection.getSenders().find((e=>t.id===e.track?.id));if(n){b.facingMode="environment"===b.facingMode?"user":"environment";try{const e=await L("video",b.facingMode);await n.replaceTrack(e.getTracks()[0]),b.streams.ownVideo=e,B()}catch(e){}}}(),setTimeout(se,250)}),[ne,se]),de=n?.startDate&&Number(new Date)/1e3-n.startDate;return(0,ae.vJ)((()=>{"discarded"===n?.state&&setTimeout(r,250)}),[r,n?.reason,n?.state]),ae.Ay.createElement(he.A,{isOpen:n&&"discarded"!==n?.state&&!a,onClose:A,className:(0,ie.A)(ot.root,v&&ot.singleColumn),dialogRef:p},ae.Ay.createElement(we.A,{peer:e,size:"jumbo",className:G||R?ot.blurred:""}),"active"===n?.screencastState&&U?.presentation&&ae.Ay.createElement("video",{className:ot.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:U.presentation}),"active"===n?.videoState&&U?.video&&ae.Ay.createElement("video",{className:ot.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:U.video}),ae.Ay.createElement("video",{className:(0,ie.A)(ot.secondVideo,!$&&D&&ot.visible,m&&ot.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:U?.ownPresentation}),ae.Ay.createElement("video",{className:(0,ie.A)(ot.secondVideo,!z&&F&&ot.visible,m&&ot.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:U?.ownVideo}),ae.Ay.createElement("div",{className:ot.header},i.SC&&ae.Ay.createElement(ge.A,{round:!0,size:"smaller",color:"translucent",onClick:y,ariaLabel:o(m?"AccExitFullscreen":"AccSwitchToFullscreen")},ae.Ay.createElement(me.A,{name:m?"smallscreen":"fullscreen"})),ae.Ay.createElement(ge.A,{round:!0,size:"smaller",color:"translucent",onClick:A,className:ot.closeButton},ae.Ay.createElement(me.A,{name:"close"}))),ae.Ay.createElement("div",{className:(0,ie.A)(ot.emojisBackdrop,Q&&ot.open),onClick:Q?ee:X},ae.Ay.createElement("div",{className:(0,ie.A)(ot.emojis,Q&&ot.open)},n?.isConnected&&n?.emojis&&(0,Ce.A)(n.emojis,["emoji"])),ae.Ay.createElement("div",{className:(0,ie.A)(ot.emojiTooltip,Q&&ot.open)},o("CallEmojiKeyTooltip",e?.firstName).replace("%%","%"))),ae.Ay.createElement("div",{className:ot.userInfo},ae.Ay.createElement("h1",null,e?.firstName),ae.Ay.createElement("span",{className:ot.status},V||(0,nt.QO)(de||0))),ae.Ay.createElement("div",{className:ot.buttons},ae.Ay.createElement(it,{onClick:Y,icon:"microphone",isDisabled:!k,isActive:_,label:o(_?"lng_call_mute_audio":"lng_call_unmute_audio")}),ae.Ay.createElement(it,{onClick:Z,icon:"video",isDisabled:!k,isActive:F,label:o(F?"lng_call_stop_video":"lng_call_start_video")}),F&&(i.Ni||i.pz)&&ae.Ay.createElement(it,{onClick:ce,customIcon:ae.Ay.createElement(Te.A,{tgsUrl:Pe.w.CameraFlip,playSegment:te?[0,10]:[0,1],size:32}),isDisabled:!k,label:o("VoipFlip")}),u&&ae.Ay.createElement(it,{onClick:W,icon:"share-screen",isDisabled:!k,isActive:D,label:o("lng_call_screencast")}),w&&ae.Ay.createElement(it,{onClick:s,icon:"phone-discard",isDisabled:C,label:o("lng_call_accept"),className:ot.accept,iconClassName:ot.acceptIcon}),ae.Ay.createElement(it,{onClick:M,icon:"phone-discard",isDisabled:C,label:o(w?"lng_call_decline":"lng_call_end_call"),className:ot.leave})))})));var st=n(40664);const ct=(0,ae.ph)((({isOpen:e})=>{const{closeCallRatingModal:t,setCallRating:n}=(0,K.ko)(),a=(0,ae.li)(null),i=(0,le.A)(),[o,r]=(0,ae.J0)(),s=(0,ae.hb)((()=>{o?n({rating:o+1,comment:a.current?.value||""}):t()}),[t,o,n]),c=(0,ae.hb)((()=>{t()}),[t]);return ae.Ay.createElement(he.A,{title:i("lng_call_rate_label"),className:"narrow",onClose:t,isOpen:e},ae.Ay.createElement("div",{className:"P7EfDKJN"},new Array(5).fill(void 0).map(((e,t)=>{const n=void 0!==o&&o>=t;return ae.Ay.createElement(me.A,{name:n?"favorite-filled":"favorite",className:(0,ie.A)(n&&"_XX6q8YW","t8LJLFSN"),onClick:(a=t,()=>r(o===a?void 0:a))});var a}))),ae.Ay.createElement(st.A,{ref:a,placeholder:i("lng_call_rate_comment"),className:(0,ie.A)("EvL0WaKD",4!==o&&void 0!==o&&"v5hn1XvT")}),ae.Ay.createElement("div",{className:"dialog-buttons mt-2"},ae.Ay.createElement(ge.A,{className:"confirm-dialog-button",isText:!0,onClick:s},i("Send")),ae.Ay.createElement(ge.A,{className:"confirm-dialog-button",isText:!0,onClick:c},i("Cancel"))))}));(i.Yw||i.pz)&&document.addEventListener("click",a.cw,{once:!0})},285:(e,t,n)=>{n.d(t,{A:()=>d});var a=n(84051),i=n(13439),o=n(90709),r=n(29807),s=n(4961),c=n(59030),l=n(94189);const d=(0,a.ph)((0,i.EK)(((e,{userId:t})=>{const n=(0,r.meB)(e),a=t&&(0,r.mBe)(e,t);return{chat:n,contactName:a?(0,o.u0)(a):void 0}}))((({isOpen:e,chat:t,userId:n,contactName:o,onClose:r})=>{const{deleteChatMember:d}=(0,i.ko)(),u=(0,c.A)(),p=(0,a.hb)((()=>{d({chatId:t.id,userId:n}),r()}),[t,d,r,n]);if(t&&n)return a.Ay.createElement(l.A,{isOpen:e,onClose:r,title:u("GroupRemoved.Remove"),textParts:(0,s.A)(u("PeerInfo.Confirm.RemovePeer",o)),confirmLabel:u("lng_box_remove"),confirmHandler:p,confirmIsDestructive:!0})})))},71331:(e,t,n)=>{n.d(t,{Ip:()=>s,O7:()=>p,iT:()=>d,mD:()=>r,n5:()=>c,qI:()=>l,uu:()=>u});var a=n(90709),i=n(21133),o=n(19926);function r(e,t){const n=(0,i.AW)(e,t);if(n&&n.groupCallId)return s(e,n.groupCallId)}function s(e,t){return e.groupCalls.byId[t]}function c(e,t,n){return s(e,t)?.participants[n]}function l(e){const t=d(e)?.chatId;if(!t)return!1;const n=(0,i.hd)(e,t);return!!n&&((0,a.yn)(n)&&n.isCreator||Boolean(n.adminRights?.manageCall))}function d(e){const{groupCalls:{activeGroupCallId:t}}=e;if(t)return s(e,t)}function u(e){const{phoneCall:t,currentUserId:n}=e;if(!t||!t.participantId||!t.adminId)return;const a=t.adminId===n?t.participantId:t.adminId;return(0,o.mB)(e,a)}function p(e){const t=d(e);if(!t||!t.chatId)return!1;const n=(0,i.hd)(e,t.chatId);if(!n)return!1;if(Boolean((0,a.Kl)(n)))return!0;const o=(0,i.AW)(e,n.id)?.inviteLink;return Boolean(o)}},64520:(e,t,n)=>{n.d(t,{B:()=>r,d:()=>o});var a=n(31481),i=n(19926);function o(e,t){const{appConfig:n}=e;if(!n)return a.dR$[t][0];const o=(0,i.g2)(e),{limits:r}=n,s=r[t]?.[o?1:0]??a.dR$[t][o?1:0];return"dialogFilters"===t?s+1:s}function r(e,t){const{appConfig:n}=e;if(!n)return a.dR$[t][1];const{limits:i}=n;return i[t][1]}},90423:(e,t,n)=>{n.d(t,{Ay:()=>s,j9:()=>d,zk:()=>c});var a=n(84051),i=n(31791),o=n(96454);const r=l();function s(e,t,n){const[i,s]=(0,a.J0)(Boolean(r&&document[r]));return(0,a.Nf)((()=>{const a=e.current,i=()=>{const e=Boolean(r&&document[r]);s(e),e?n?.(!1):t?.(!1),a instanceof HTMLVideoElement&&(a.controls=e)},o=()=>{s(!0),n&&n(!0)},c=()=>{s(!1),t&&t(!1)};return document.addEventListener("fullscreenchange",i,!1),document.addEventListener("webkitfullscreenchange",i,!1),document.addEventListener("mozfullscreenchange",i,!1),a&&(a.addEventListener("webkitbeginfullscreen",o,!1),a.addEventListener("webkitendfullscreen",c,!1)),()=>{document.removeEventListener("fullscreenchange",i,!1),document.removeEventListener("webkitfullscreenchange",i,!1),document.removeEventListener("mozfullscreenchange",i,!1),a&&(a.removeEventListener("webkitbeginfullscreen",o,!1),a.removeEventListener("webkitendfullscreen",c,!1))}}),[]),r||o.pz?[i,()=>{var t;e.current&&(r||o.pz)&&!i&&((t=e.current).requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.webkitEnterFullscreen?t.webkitEnterFullscreen():t.mozRequestFullScreen&&t.mozRequestFullScreen(),s(!0))},()=>{e.current&&(document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen(),s(!1))}]:[!1]}const c=()=>{const[e,t]=(0,a.J0)(!1);return(0,a.vJ)((()=>{const e=()=>{t(d())},n=window.electron?.on(i.v.FULLSCREEN_CHANGE,t);return window.electron?.isFullscreen().then(t),document.addEventListener("fullscreenchange",e,!1),document.addEventListener("webkitfullscreenchange",e,!1),document.addEventListener("mozfullscreenchange",e,!1),()=>{n?.(),document.removeEventListener("fullscreenchange",e,!1),document.removeEventListener("webkitfullscreenchange",e,!1),document.removeEventListener("mozfullscreenchange",e,!1)}}),[]),e};function l(){return void 0!==document.fullscreenElement?"fullscreenElement":void 0!==document.mozFullScreenElement?"mozFullScreenElement":void 0!==document.webkitFullscreenElement?"webkitFullscreenElement":""}function d(){const e=l();return Boolean(e&&document[e])}},31791:(e,t,n)=>{n.d(t,{v:()=>a});let a=function(e){return e.FULLSCREEN_CHANGE="fullscreen-change",e.UPDATE_ERROR="update-error",e.UPDATE_AVAILABLE="update-available",e.DEEPLINK="deeplink",e}({})}}]);
//# sourceMappingURL=2394.6c7df024badbfa528a12.js.map