mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-11 08:39:59 +01:00
3 lines
62 KiB
JavaScript
3 lines
62 KiB
JavaScript
/*! For license information please see 9954.836adcc6b64f2d9ed43a.js.LICENSE.txt */
|
|
(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[9954],{47903:(e,t,a)=>{"use strict";a.r(t),a.d(t,{ActiveCallHeader:()=>X,GroupCall:()=>z,PhoneCall:()=>ae,RatePhoneCallModal:()=>ie});var n=a(73794),i=a(14050),o=a(33555),s=a(83716),r=a(71226),l=a(11192),c=a(42431),d=a(78958),u=a(88422),p=a(27225);(0,o.iw)("leaveGroupCall",(async(e,t,a)=>{const{isFromLibrary:i,shouldDiscard:s,shouldRemove:l,rejoin:p}=a||{},m=(0,c.mU)(e);m&&((0,o.R3)((0,d.Ic)(e,{connectionState:"disconnected"},m.participantsCount-1)),await(0,r.t9)("leaveGroupCall",{call:m}),s&&await(0,r.t9)("discardGroupCall",{call:m}),e=(0,o.Rd)(),l&&(e=(0,d.dc)(e,m.id)),(0,u.Mt)(),(0,o.R3)({...e,groupCalls:{...e.groupCalls,activeGroupCallId:void 0},isCallPanelVisible:void 0}),i||(0,n.leaveGroupCall)(),p&&t.joinGroupCall(p))})),(0,o.iw)("toggleGroupCallVideo",(async e=>{const t=(0,c.mU)(e),a=(0,l.dy)(e,e.currentUserId);a&&t&&(await(0,n.toggleStream)("video"),await(0,r.t9)("editGroupCallParticipant",{call:t,videoStopped:!(0,n.isStreamEnabled)("video"),participant:a}))})),(0,o.iw)("requestToSpeak",((e,t,a)=>{const{value:n}=a||{value:!0},i=(0,c.mU)(e),o=(0,l.dy)(e,e.currentUserId);o&&i&&(0,r.t9)("editGroupCallParticipant",{call:i,raiseHand:n,participant:o})})),(0,o.iw)("setGroupCallParticipantVolume",((e,t,a)=>{const{participantId:i,volume:o}=a,d=(0,c.mU)(e),u=(0,l.dy)(e,i);u&&d&&((0,n.setVolume)(i,Math.floor(o/s.Ro)/100),(0,r.t9)("editGroupCallParticipant",{call:d,volume:Number(o),participant:u}))})),(0,o.iw)("toggleGroupCallMute",(async(e,t,a)=>{const{participantId:i,value:o}=a||{},s=(0,c.mU)(e),d=(0,l.dy)(e,i||e.currentUserId);if(!d||!s)return;const u=void 0===o?(0,n.isStreamEnabled)("audio",d.id):o;i?(0,n.setVolume)(i,u?0:1):await(0,n.toggleStream)("audio"),await(0,r.t9)("editGroupCallParticipant",{call:s,muted:u,participant:d})})),(0,o.iw)("toggleGroupCallPresentation",(async(e,t,a)=>{const i=(0,c.mU)(e),o=(0,l.dy)(e,e.currentUserId);if(o&&i){if(void 0!==(null==a?void 0:a.value)?null==a?void 0:a.value:!(0,n.isStreamEnabled)("presentation")){const e=await(0,n.startSharingScreen)();if(!e)return;await(0,r.t9)("joinGroupCallPresentation",{call:i,params:e})}else await(0,n.toggleStream)("presentation",!1),await(0,r.t9)("leaveGroupCallPresentation",{call:i});await(0,r.t9)("editGroupCallParticipant",{call:i,presentationPaused:!(0,n.isStreamEnabled)("presentation"),participant:o})}})),(0,o.iw)("connectToActiveGroupCall",(async(e,t)=>{const a=(0,c.mU)(e);if(!a)return;if("discarded"===a.connectionState)return void t.showNotification({message:"This voice chat is not active"});const i=(0,u.FF)(),s=(0,u.NH)();if(!i||!s)return;const{currentUserId:d}=e;if(!d)return;const m=await(0,n.joinGroupCall)(d,s,i,t.apiUpdate);if(await(0,r.t9)("joinGroupCall",{call:a,params:m,inviteHash:a.inviteHash})&&(t.loadMoreGroupCallParticipants(),a.chatId)){const e=(0,l.Z1)((0,o.Rd)(),a.chatId);if(!e)return;await(0,p.ft)(e)}})),(0,o.iw)("connectToActivePhoneCall",(async(e,t)=>{const{phoneCall:a}=e;if(!a)return;const n=(0,c.fu)(e);if(!n)return;const i=await(0,r.t9)("getDhConfig");if(!i)return;await(0,r.t9)("createPhoneCallState",[!0]);const o=await(0,r.t9)("requestPhoneCall",[i]);await(0,r.t9)("requestCall",{user:n,gAHash:o,isVideo:a.isVideo})||t.hangUp()})),(0,o.iw)("acceptCall",(async e=>{const{phoneCall:t}=e;if(!t)return;const a=await(0,r.t9)("getDhConfig");if(!a)return;await(0,r.t9)("createPhoneCallState",[!1]);const n=await(0,r.t9)("acceptPhoneCall",[a]);(0,r.t9)("acceptCall",{call:t,gB:n})})),(0,o.iw)("sendSignalingData",((e,t,a)=>{const{phoneCall:n}=e;if(!n)return;const i=JSON.stringify(a);(async()=>{const e=await(0,r.t9)("encodePhoneCallData",[i]);e&&(0,r.t9)("sendSignalingData",{data:e,call:n})})()})),(0,o.iw)("closeCallRatingModal",(e=>({...e,ratingPhoneCall:void 0}))),(0,o.iw)("setCallRating",((e,t,a)=>{const{ratingPhoneCall:n}=e;if(!n)return;const{rating:i,comment:o}=a;return(0,r.t9)("setCallRating",{call:n,rating:i,comment:o}),{...e,ratingPhoneCall:void 0}})),(0,o.iw)("hangUp",(e=>{const{phoneCall:t}=e;if(t){if("discarded"===t.state)return(0,r.t9)("destroyPhoneCallState"),(0,n.stopPhoneCall)(),{...e,phoneCall:void 0,isCallPanelVisible:void 0};if((0,r.t9)("destroyPhoneCallState"),(0,n.stopPhoneCall)(),(0,r.t9)("discardCall",{call:t}),"requesting"===t.state)return{...e,phoneCall:void 0,isCallPanelVisible:void 0};setTimeout((()=>{(0,o.R3)({...(0,o.Rd)(),phoneCall:void 0,isCallPanelVisible:void 0})}),500)}}));var m=a(60782),v=a(77361),g=a(50711);const f=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]),C=[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,o.iw)("apiUpdate",((e,t,a)=>{const{activeGroupCallId:i}=e.groupCalls;switch(a["@type"]){case"updateGroupCallLeavePresentation":t.toggleGroupCallPresentation({value:!1});break;case"updateGroupCallStreams":if(!a.userId||!i)break;if(!(0,c.GU)(e,i,a.userId))break;return(0,d.B6)(e,i,a.userId,(0,m.CE)(a,["@type","userId"]));case"updateGroupCallConnectionState":if(!i)break;if("disconnected"===a.connectionState){t.leaveGroupCall({isFromLibrary:!0});break}return(0,d.AH)(e,i,{connectionState:a.connectionState,isSpeakerDisabled:a.isSpeakerDisabled});case"updateGroupCallParticipants":{const{groupCallId:e,participants:t}=a;i===e&&(0,n.handleUpdateGroupCallParticipants)(t);break}case"updateGroupCallConnection":{if(a.data.stream){t.showNotification({message:"Big live streams are not yet supported"}),t.leaveGroupCall();break}(0,n.handleUpdateGroupCallConnection)(a.data,a.presentation);const i=(0,c.mU)(e);null!=i&&i.participants&&Object.keys(i.participants).length>0&&(0,n.handleUpdateGroupCallParticipants)(Object.values(i.participants));break}case"updatePhoneCallMediaState":return{...e,phoneCall:{...e.phoneCall,...(0,m.CE)(a,["@type"])}};case"updatePhoneCall":{if(!v.Bi)return;const{phoneCall:i,currentUserId:s}=e,d={...i,...a.call},u=(null==i?void 0:i.adminId)===s;if(e={...e,phoneCall:d},i&&i.id&&d.id!==i.id)return void("discarded"!==d.state&&(0,r.t9)("discardCall",{call:d,isBusy:!0}));const{accessHash:p,state:m,connections:h,gB:P}=d;if(("active"===m||"accepted"===m)&&!(null==(l=d.protocol)?void 0:l.libraryVersions.some((e=>"4.0.0"===e||"4.0.1"===e)))){const a=(0,c.fu)(e);return t.hangUp(),void t.showNotification({message:g.i0("VoipPeerIncompatible",null==a?void 0:a.firstName)})}if("discarded"===m){if(!i)return;return{...e,...d.needRating&&{ratingPhoneCall:d},isCallPanelVisible:void 0}}return"accepted"===m&&p&&P?(async()=>{const{gA:t,keyFingerprint:a,emojis:n}=await(0,r.t9)("confirmPhoneCall",[P,f,C]),i={...(e=(0,o.Rd)()).phoneCall,emojis:n};(0,o.R3)({...e,phoneCall:i}),(0,r.t9)("confirmCall",{call:d,gA:t,keyFingerprint:a})})():"active"===m&&h&&"active"!==(null==i?void 0:i.state)&&(u||((0,r.t9)("receivedCall",{call:d}),(async()=>{const{emojis:t}=await(0,r.t9)("confirmPhoneCall",[d.gAOrB,f,C]),a={...(e=(0,o.Rd)()).phoneCall,emojis:t};(0,o.R3)({...e,phoneCall:a})})()),(0,n.joinPhoneCall)(h,t.sendSignalingData,u,Boolean(null==d?void 0:d.isVideo),t.apiUpdate)),e}case"updatePhoneCallConnectionState":{const{connectionState:n}=a;return e.phoneCall?"closed"===n||"disconnected"===n||"failed"===n?void t.hangUp():{...e,phoneCall:{...e.phoneCall,isConnected:"connected"===n}}:e}case"updatePhoneCallSignalingData":{var s;const{phoneCall:t}=e;if(!t)break;null===(s=(0,r.t9)("decodePhoneCallData",[a.data]))||void 0===s||s.then(n.processSignalingMessage);break}}var l}));var h=a(13365),P=a(46752),S=a(60706),E=a(59107),y=a(34288),b=a(231),Z=a(53106),k=a(58964),w=a(13103);const I=()=>{var e,t;null===(e=(t=navigator).vibrate)||void 0===e||e.call(t,50)};var T=a(87204),N=a(58912);const D=(0,i.X$)((0,o.c$)((e=>{const t=(0,c.mU)(e),{connectionState:a}=t||{},n=t&&(0,c.GU)(e,t.id,e.currentUserId),{raiseHandRating:i,hasAudioStream:o,canSelfUnmute:s,isMuted:r}=n||{};return{connectionState:a||"discarded",hasRequestedToSpeak:Boolean(i),noAudioStream:!o,canSelfUnmute:s,isMuted:r}}))((e=>{let{noAudioStream:t,canSelfUnmute:a,isMuted:n,hasRequestedToSpeak:s,connectionState:r}=e;const{toggleGroupCallMute:l,requestToSpeak:c,playGroupCallSound:d}=(0,o.Sv)(),u=(0,E.Z)(),p=(0,i.sO)("up"),[m,v]=(0,i.eJ)(!1),g="connected"!==r,f=!a&&n,C=(0,T.Z)(f);(0,i.d4)((()=>{C&&!f&&d({sound:"allowTalk"})}),[d,C,f]);const S=(0,i.Ye)((()=>{if(m){const e=Math.floor(100*Math.random());return e<32?[0,120]:e<64?[120,240]:e<97?[240,420]:[420,540]}return!C&&f?t?[99,135]:[136,172]:C&&!f?[0,36]:f?[0,0]:t?[69,99]:[36,69]}),[C,m,t,f]),y=m?"HandFilled":"VoiceMini",b=()=>{I(),l()},Z=u(s?"VoipMutedTapedForSpeak":f?"VoipMutedByAdmin":t?"VoipUnmute":"VoipTapToMute");return i.ZP.createElement("div",{className:"button-wrapper microphone-wrapper"},i.ZP.createElement("button",{className:(0,P.Z)("MicrophoneButton",t&&"crossed",a&&"can-self-unmute",g&&"is-connecting",f&&"muted-by-admin"),onMouseDown:()=>{if(f){if(m)return;return I(),c(),v(!0),void setTimeout((()=>{v(!1)}),3e3)}p.current="down",t&&setTimeout((()=>{"down"===p.current&&(p.current="hold",b())}),200)},onMouseUp:()=>{f||(b(),p.current="up")}},i.ZP.createElement(N.Z,{tgsUrl:h.l[y],size:48,playSegment:S})),i.ZP.createElement("div",{className:"button-text"},Z))})));var M=a(14605),V=a(80036),O=a(69118);var G=a(52328),U=a(22275);const A=[0,17],R=[17,34],_=(0,i.X$)((0,o.c$)((e=>({isAdmin:(0,c.Ht)(e)})))((e=>{let{participant:t,closeDropdown:a,isDropdownOpen:n,anchor:r,isAdmin:l}=e;const{toggleGroupCallMute:c,setGroupCallParticipantVolume:d,toggleGroupCallPanel:u,openChat:p,requestToSpeak:m}=(0,o.Sv)(),v=(0,E.Z)(),[g,f,C]=(0,S.Z)(),y=null==t?void 0:t.id,{isMutedByMe:b,isMuted:Z,isSelf:w,canSelfUnmute:I}=t||{},T=Boolean(null==t?void 0:t.raiseHandRating),D=!I&&Z,[M,_]=(0,i.eJ)(b?0:((null==t?void 0:t.volume)||s.aC)/s.Ro);(0,i.d4)((()=>{_(b?0:((null==t?void 0:t.volume)||s.aC)/s.Ro)}),[y]);const $=function(e,t,a,n){const o=(0,i.I4)((e=>{e()}),[]);return(0,i.Ye)((()=>(0,O.P2)(o,a,!n)),[o,a,n])}(0,0,500,B),j=(0,i.I4)((e=>{e.stopPropagation(),f(),a()}),[f,a]),x=(0,i.I4)((e=>{e.stopPropagation(),m({value:!1}),a()}),[m,a]),L=(0,i.I4)((e=>{e.stopPropagation(),a(),l||_(b?s.aC/s.Ro:0),c({participantId:y,value:l?!D:!b})}),[a,c,y,l,D,b]),F=(0,i.I4)((e=>{e.stopPropagation(),u(),p({id:y}),a()}),[u,a,p,y]),H=0===M?A:R;var B;return i.ZP.createElement("div",null,i.ZP.createElement(G.Z,{isOpen:n,positionX:"right",autoClose:!0,style:(0,V.Z)(r&&`right: 1rem; top: ${r.y}px`),onClose:a,className:"participant-menu"},!w&&!D&&i.ZP.createElement("div",{className:"group"},i.ZP.createElement("div",{className:(0,P.Z)("volume-control",M<50&&"low",M>=50&&M<100&&"medium",M>=100&&M<150&&"normal",M>=150&&"high")},i.ZP.createElement("input",{type:"range",min:"0",max:"200",value:M,onChange:e=>{const t=Number(e.target.value);_(t),$((()=>{0===t?c({participantId:y,value:!0}):d({participantId:y,volume:Math.floor(t*s.Ro)})}))}}),i.ZP.createElement("div",{className:"info"},i.ZP.createElement(N.Z,{tgsUrl:h.l.Speaker,playSegment:H,size:24}),i.ZP.createElement("span",null,M,"%")))),i.ZP.createElement("div",{className:"group"},T&&w&&i.ZP.createElement(k.Z,{icon:"stop-raising-hand",onClick:x},v("VoipGroupCancelRaiseHand")),!w&&i.ZP.createElement(k.Z,{icon:"user",onClick:F},v("VoipGroupOpenProfile")),!w&&i.ZP.createElement(k.Z,{icon:Z&&l?"allow-speak":"microphone-alt",onClick:L},v(l?D?"VoipGroupAllowToSpeak":"VoipMute":b?"VoipGroupUnmuteForMe":"VoipGroupMuteForMe")),!w&&l&&i.ZP.createElement(k.Z,{icon:"delete-user",destructive:!0,onClick:j},v("VoipGroupUserRemove")))),!w&&l&&i.ZP.createElement(U.Z,{isOpen:g,userId:y,onClose:C}))})));var $=a(27407),j=a(70172);const x=(0,i.X$)((e=>{let{participant:t,noColor:a}=e;const{isMuted:o,isMutedByMe:s}=t,r=(t.amplitude||0)>n.THRESHOLD,l=Boolean(t.raiseHandRating),c=(0,T.Z)(l),d=!Boolean(null==t?void 0:t.canSelfUnmute)&&o,u=(0,T.Z)(o),p=(0,i.Ye)((()=>o&&!u?[43,64]:!o&&u?[22,42]:l&&!c?[65,84]:!d&&c?[0,21]:o?[22,23]:[43,44]),[o,d,l]),m=(0,i.Ye)((()=>a?[255,255,255]:l?[77,166,224]:d||s?[255,112,111]:r?[87,188,108]:[132,141,148]),[a,l,d,s,r]);return i.ZP.createElement(N.Z,{tgsUrl:h.l.VoiceOutlined,playSegment:p,size:28,color:m})})),L=(0,i.X$)((0,o.c$)(((e,t)=>{let{participant:a}=t;return{user:a.isUser?(0,l.dy)(e,a.id):void 0,chat:a.isUser?void 0:(0,l.Z1)(e,a.id)}}))((e=>{let{openParticipantMenu:t,participant:a,user:o,chat:r}=e;const l=(0,i.sO)(null),c=(0,E.Z)(),{isSelf:d,isMutedByMe:u,isMuted:p}=a,m=(a.amplitude||0)>n.THRESHOLD,v=Boolean(a.raiseHandRating),[g,f]=(0,i.Ye)((()=>d?[c("ThisIsYou"),"blue"]:u?[c("VoipGroupMutedForMe"),"red"]:v?[c("WantsToSpeak"),"blue"]:!p&&m?[a.volume&&a.volume!==s.aC?c("SpeakingWithVolume",(a.volume/s.Ro).toString()).replace("%%","%"):c("Speaking"),"green"]:a.about?[a.about,""]:[c("Listening"),"blue"]),[m,a.volume,c,d,u,v,p,a.about]);if(!o&&!r)return;const C=o?`${o.firstName||""} ${o.lastName||""}`:null==r?void 0:r.title;return i.ZP.createElement("div",{className:(0,P.Z)("GroupCallParticipant",a.canSelfUnmute&&"can-self-unmute"),onClick:()=>{d||t(l.current,a)},ref:l},i.ZP.createElement(j.Z,{user:o,chat:r,size:"medium"}),i.ZP.createElement("div",{className:"info"},i.ZP.createElement("span",{className:"name"},C),i.ZP.createElement("span",{className:(0,P.Z)("about",f)},g)),i.ZP.createElement("div",{className:"microphone"},i.ZP.createElement(x,{participant:a})))})));var F=a(21273);const H=(0,i.X$)((0,o.c$)((e=>{const{participantsCount:t,participants:a}=(0,c.mU)(e)||{};return{participants:a,participantsCount:t||0}}))((e=>{let{participants:t,participantsCount:a,openParticipantMenu:n}=e;const{createGroupCallInviteLink:s,loadMoreGroupCallParticipants:r}=(0,o.Sv)(),l=(0,E.Z)(),c=(0,i.Ye)((()=>Object.keys(t||{})),[t]),[d,u]=(0,$.Z)(r,c,c.length>=a);return i.ZP.createElement("div",{className:"participants"},i.ZP.createElement("div",{className:"invite-btn",onClick:s},i.ZP.createElement("div",{className:"icon"},i.ZP.createElement("i",{className:"icon-add-user"})),i.ZP.createElement("div",{className:"text"},l("VoipGroupInviteMember"))),i.ZP.createElement(F.Z,{items:d,onLoadMore:u},null==d?void 0:d.map((e=>t[e]&&i.ZP.createElement(L,{key:e,openParticipantMenu:n,participant:t[e]})))))}))),B=(0,i.X$)((0,o.c$)(((e,t)=>{let{participant:a}=t;return{currentUserId:e.currentUserId,user:a.isUser?(0,l.dy)(e,a.id):void 0,chat:a.isUser?void 0:(0,l.Z1)(e,a.id),isActive:(a.amplitude||0)>n.THRESHOLD}}))((e=>{let{type:t,onClick:a,user:o,chat:r,isActive:l,isFullscreen:c}=e;const d=(0,E.Z)(),u=(0,i.I4)((()=>{a&&a((null==o?void 0:o.id)||r.id,t)}),[r,a,t,null==o?void 0:o.id]);if(!o&&!r)return;const p=(0,n.getUserStreams)((null==o?void 0:o.id)||r.id);return i.ZP.createElement("div",{className:(0,P.Z)("GroupCallParticipantVideo",l&&"active"),onClick:u},c&&i.ZP.createElement("button",{className:"back-button"},i.ZP.createElement("i",{className:"icon-arrow-left"}),d("Back")),i.ZP.createElement(j.Z,{user:o,chat:r,className:"thumbnail-avatar"}),!s.gd&&i.ZP.createElement("div",{className:"thumbnail-wrapper"},i.ZP.createElement("video",{className:"thumbnail",muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==p?void 0:p[t]})),i.ZP.createElement("video",{className:"video",muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==p?void 0:p[t]}),i.ZP.createElement("div",{className:"info"},i.ZP.createElement("i",{className:"icon-microphone-alt"}),i.ZP.createElement("span",{className:"name"},(null==o?void 0:o.firstName)||(null==r?void 0:r.title)),"presentation"===t&&i.ZP.createElement("i",{className:"last-icon icon-active-sessions"})))}))),q=(0,i.X$)((0,o.c$)((e=>{const{participants:t}=(0,c.mU)(e)||{};return{participants:t}}))((e=>{let{participants:t,onDoubleClick:a}=e;const[n,o]=(0,i.eJ)(void 0),s=(0,i.Ye)((()=>Object.values(t||{}).filter((e=>e.hasPresentationStream))),[t]),r=(0,i.Ye)((()=>Object.values(t||{}).filter((e=>e.hasVideoStream))),[t]),l=r.length+s.length,c=l<=2?1:l<=6?2:l<=9?3:4,d=3===l||2===c&&l%2!=0,u=(0,i.I4)(((e,t)=>{n&&e===n.id&&t===n.type?o(void 0):o({id:e,type:t})}),[n]);return i.ZP.createElement("div",{className:"streams",onDoubleClick:a},i.ZP.createElement("div",{className:(0,P.Z)("videos",d&&"span-last-video"),style:`--column-count: ${n?1:c}`},n&&i.ZP.createElement(B,{key:n.id,isFullscreen:!0,onClick:u,participant:t[n.id],type:n.type}),n?void 0:s.map((e=>i.ZP.createElement(B,{key:e.id,onClick:u,participant:e,type:"presentation"}))),n?void 0:r.map((e=>i.ZP.createElement(B,{key:e.id,onClick:u,participant:e,type:"video"})))))}))),J=[0,10],z=(0,i.X$)((0,o.c$)(((e,t)=>{let{groupCallId:a}=t;const{connectionState:n,title:i,isSpeakerDisabled:o,participants:s,participantsCount:r}=(0,c.$5)(e,a)||{};return{connectionState:n,title:i,isSpeakerEnabled:!o,participantsCount:r,meParticipant:(0,c.GU)(e,a,e.currentUserId),isCallPanelVisible:Boolean(e.isCallPanelVisible),isAdmin:(0,c.Ht)(e),participants:s}}))((e=>{let{groupCallId:t,isCallPanelVisible:a,connectionState:s,isSpeakerEnabled:r,title:l,meParticipant:c,isAdmin:d,participants:u}=e;const{toggleGroupCallVideo:p,toggleGroupCallPresentation:m,leaveGroupCall:g,toggleGroupCallPanel:f,connectToActiveGroupCall:C,playGroupCallSound:I}=(0,o.Sv)(),T=(0,E.Z)(),V=(0,i.sO)(null),[O,G]=(0,i.eJ)(!1),[U,A,R]=(0,S.Z)(),[$,j,x]=(0,S.Z)(!0),L=u&&Object.values(u).some((e=>e.video||e.presentation)),F=U&&!v.wB&&L,[B,z]=(0,i.eJ)(),[X,Y,K]=(0,S.Z)(),[Q,W,ee]=(0,S.Z)(),[te,ae]=(0,i.eJ)(!1),[ne,ie]=(0,i.eJ)(!1),oe=null==c?void 0:c.hasVideoStream,se=null==c?void 0:c.hasPresentationStream,re="connected"!==s,le=!(null==c?void 0:c.canSelfUnmute)&&(null==c?void 0:c.isMuted),ce=(0,i.I4)(((e,t)=>{const a=e.getBoundingClientRect(),n=V.current;z({anchor:{x:a.left,y:a.top-n.offsetTop+60},participant:t}),Y()}),[Y]);(0,i.d4)((()=>{"connected"===s?I({sound:"join"}):"reconnecting"===s&&I({sound:"connecting"})}),[s,I]);const de=(0,i.I4)((()=>{ee(),ae(!1)}),[ee]),ue=(0,i.Ye)((()=>e=>{let{onTrigger:t,isOpen:a}=e;return i.ZP.createElement(b.Z,{round:!0,size:"smaller",color:"translucent",className:a?"active":void 0,onClick:t,ariaLabel:T("AccDescrMoreOptions")},i.ZP.createElement("i",{className:"icon-more"}))}),[T]),pe=(0,i.I4)((()=>{V.current&&(U?document.exitFullscreen().then(R):V.current.requestFullscreen().then(A))}),[R,U,A]),me=(0,i.I4)((()=>{$?x():j()}),[x,$,j]),ve=(0,i.I4)((()=>{v.t0&&(U||x(),pe())}),[x,pe,U]),ge=(0,i.I4)((()=>{U?R():A()}),[R,U,A]),fe=(0,i.I4)((()=>{f(),U&&R()}),[R,U,f]);(0,i.d4)((()=>{if(!v.t0)return;const e=V.current;return e?(e.addEventListener("fullscreenchange",ge),()=>{e.removeEventListener("fullscreenchange",ge)}):void 0}),[ge]),(0,i.d4)((()=>{C()}),[C,t]);const Ce=(0,i.I4)((()=>{ae(!0),ie(!0),W(),U&&pe()}),[pe,U,W]),he=(0,i.I4)((()=>{if(d&&!Q)return W(),void(U&&pe());I({sound:"leave"}),G(!0),ee()}),[ee,pe,d,Q,U,W,I]),Pe=(0,i.I4)((()=>{O&&g({shouldDiscard:ne})}),[O,g,ne]);return i.ZP.createElement(w.Z,{isOpen:!a&&!O,onClose:f,className:(0,P.Z)("GroupCall",v.wB&&"single-column",F&&"landscape",!$&&"no-sidebar"),dialogRef:V,onCloseAnimationEnd:Pe},i.ZP.createElement("div",{className:"header"},i.ZP.createElement("h3",null,l||T("VoipGroupVoiceChat")),v.t0&&i.ZP.createElement(b.Z,{round:!0,size:"smaller",color:"translucent",onClick:pe,ariaLabel:T(U?"AccExitFullscreen":"AccSwitchToFullscreen")},i.ZP.createElement("i",{className:U?"icon-smallscreen":"icon-fullscreen"})),F&&i.ZP.createElement(b.Z,{round:!0,size:"smaller",color:"translucent",onClick:me},i.ZP.createElement("i",{className:"icon-sidebar"})),(n.IS_SCREENSHARE_SUPPORTED&&!le||d)&&i.ZP.createElement(Z.Z,{positionX:"right",trigger:ue},n.IS_SCREENSHARE_SUPPORTED&&!le&&i.ZP.createElement(k.Z,{icon:"share-screen-outlined",onClick:m},T(se?"VoipChatStopScreenCapture":"VoipChatStartScreenCapture")),d&&i.ZP.createElement(k.Z,{icon:"phone-discard-outline",onClick:Ce,destructive:!0},T("VoipGroupLeaveAlertEndChat"))),i.ZP.createElement(b.Z,{round:!0,size:"smaller",color:"translucent",onClick:fe},i.ZP.createElement("i",{className:"icon-close"}))),i.ZP.createElement("div",{className:"scrollable custom-scroll"},i.ZP.createElement(q,{onDoubleClick:ve}),(!F||$)&&i.ZP.createElement(H,{openParticipantMenu:ce})),i.ZP.createElement(_,{participant:null==B?void 0:B.participant,anchor:null==B?void 0:B.anchor,isDropdownOpen:X,closeDropdown:K}),i.ZP.createElement("div",{className:"buttons"},re&&i.ZP.createElement(y.Z,null),i.ZP.createElement("div",{className:"button-wrapper"},i.ZP.createElement("div",{className:"video-buttons"},oe&&(v.wZ||v.cj)&&i.ZP.createElement("button",{className:"smaller-button",onClick:n.switchCameraInput},i.ZP.createElement(N.Z,{tgsUrl:h.l.CameraFlip,playSegment:J,size:24})),i.ZP.createElement("button",{className:(0,P.Z)("small-button",le?"speaker":"camera",(oe||le&&r)&&"active"),onClick:()=>{le?(0,n.toggleSpeaker)():p()}},i.ZP.createElement("i",{className:le?"icon-speaker":oe?"icon-video-stop":"icon-video"}))),i.ZP.createElement("div",{className:"button-text"},T(le?"VoipSpeaker":"VoipCamera"))),i.ZP.createElement(D,null),i.ZP.createElement("div",{className:"button-wrapper"},i.ZP.createElement("button",{className:"small-button leave",onClick:he},i.ZP.createElement("i",{className:"icon-phone-discard"})),i.ZP.createElement("div",{className:"button-text"},T("VoipGroupLeave")))),i.ZP.createElement(w.Z,{isOpen:Q,onClose:de,className:"error",title:T(te?"VoipGroupEndAlertTitle":"VoipGroupLeaveAlertTitle")},i.ZP.createElement("p",null,T(te?"VoipGroupEndAlertText":"VoipGroupLeaveAlertText")),!te&&i.ZP.createElement(M.Z,{label:T("VoipGroupEndChat"),checked:ne,onCheck:ie}),i.ZP.createElement(b.Z,{isText:!0,className:"confirm-dialog-button",onClick:he},T(te?"VoipGroupEnd":"VoipGroupLeave")),i.ZP.createElement(b.Z,{isText:!0,className:"confirm-dialog-button",onClick:de},T("Cancel"))))}))),X=(0,i.X$)((0,o.c$)((e=>({groupCall:(0,c.mU)(e),isCallPanelVisible:e.isCallPanelVisible,phoneCallUser:(0,c.fu)(e)})))((e=>{let{groupCall:t,phoneCallUser:a,isCallPanelVisible:n}=e;const{toggleGroupCallPanel:s}=(0,o.Sv)(),r=(0,E.Z)();if((0,i.d4)((()=>(document.body.classList.toggle("has-call-header",Boolean(n)),()=>{document.body.classList.toggle("has-call-header",!1)})),[n]),t||a)return i.ZP.createElement("div",{className:(0,P.Z)("ActiveCallHeader",n&&"open"),onClick:s},i.ZP.createElement("span",{className:"title"},(null==a?void 0:a.firstName)||(null==t?void 0:t.title)||r("VoipGroupVoiceChat")))})));var Y=a(32340),K=a(790),Q=a(62357),W=a(65326);const ee=(0,i.X$)((e=>{let{onClick:t,label:a,customIcon:n,icon:o,iconClassName:s,className:r,isDisabled:l,isActive:c}=e;return i.ZP.createElement("div",{className:"eWbOLx__FZXR1sqKEJek"},i.ZP.createElement(b.Z,{round:!0,className:(0,P.Z)(r,"XKOJvKiD4DsRfJLLhnw2",c&&"qvAVe7qcyaEvRQQ1StFI"),onClick:t,disabled:l},n||i.ZP.createElement("i",{className:(0,P.Z)(s,`icon-${o}`)})),i.ZP.createElement("div",{className:"wnAniFJmQ7ocVtjRHNey"},a))})),te={root:"AddQYAOZJv2f7U7qIfC3",blurred:"anFtHj7Wvsv4M_2I2EFF","single-column":"Oi7aFYBAbl4bYichdt52",singleColumn:"Oi7aFYBAbl4bYichdt52",header:"_iK8HccGNSmmo2wL7tMs","close-button":"U66J7V5JKTCiktgwYpcC",closeButton:"U66J7V5JKTCiktgwYpcC","emojis-backdrop":"IekzemHkkO4bfrWHmxlv",emojisBackdrop:"IekzemHkkO4bfrWHmxlv",open:"hiNHKiq2owo1FvdT9a5g",emojis:"BjOb1fDymE5GCiJ4g6YN","emoji-tooltip":"Ci9ie86NFinrXvowDx23",emojiTooltip:"Ci9ie86NFinrXvowDx23","user-info":"eiM2IbZjKKAwrfNtXtAy",userInfo:"eiM2IbZjKKAwrfNtXtAy",buttons:"AtK8DjRToL8Uk7ZAY25p",leave:"uI2mkCTKDcqYPu64xKOk",accept:"PC2FeM0OEDDW0TVFGMkk","accept-icon":"hBxp1Loj3vj4DtnculDA",acceptIcon:"hBxp1Loj3vj4DtnculDA","main-video":"lXMZESnc4CBKQbvV7qkL",mainVideo:"lXMZESnc4CBKQbvV7qkL","second-video":"cnQvI_xwAbO0EEwRcLsg",secondVideo:"cnQvI_xwAbO0EEwRcLsg",visible:"XaD79h6hSiEi0ypkn5OK",fullscreen:"NlF9_Kb2le_3B712PZnO"},ae=(0,i.X$)((0,o.c$)((e=>{const{phoneCall:t,currentUserId:a}=e;return{isCallPanelVisible:Boolean(e.isCallPanelVisible),user:(0,c.fu)(e),isOutgoing:(null==t?void 0:t.adminId)===a,phoneCall:t,animationLevel:e.settings.byKey.animationLevel}}))((e=>{var t,a,s;let{user:r,isOutgoing:l,phoneCall:c,isCallPanelVisible:d,animationLevel:u}=e;const p=(0,E.Z)(),{hangUp:m,acceptCall:g,playGroupCallSound:f,toggleGroupCallPanel:C,connectToActivePhoneCall:y}=(0,o.Sv)(),Z=(0,i.sO)(null),[k,I,T]=(0,S.Z)(),D=(0,i.I4)((()=>{k?T():I()}),[T,k,I]),M=(0,i.I4)((()=>{Z.current&&(k?document.exitFullscreen().then(T):Z.current.requestFullscreen().then(I))}),[T,k,I]);(0,i.d4)((()=>{if(!v.t0)return;const e=Z.current;return e?(e.addEventListener("fullscreenchange",D),()=>{e.removeEventListener("fullscreenchange",D)}):void 0}),[D]);const V=(0,i.I4)((()=>{C(),k&&T()}),[T,k,C]),O="discarded"===(null==c?void 0:c.state),G="busy"===(null==c?void 0:c.reason),U="requested"===(null==c?void 0:c.state)&&!l,A=("requested"===(null==c?void 0:c.state)||"waiting"===(null==c?void 0:c.state))&&l,R="active"===(null==c?void 0:c.state),_=null==c?void 0:c.isConnected,[$,x,L]=(0,S.Z)(),F=(0,i.I4)((()=>{x(),m()}),[m,x]);(0,i.d4)((()=>{$?f({sound:"end"}):U?f({sound:"incoming"}):G?f({sound:"busy"}):O?f({sound:"end"}):A?f({sound:"ringing"}):_&&f({sound:"connect"})}),[G,O,U,A,_,f,$]),(0,i.d4)((()=>{null!=c&&c.id?L():y()}),[y,null==c?void 0:c.id,L]);const H=(0,W.Z)();(0,Q.Z)((()=>{H()}),_?1e3:void 0);const B=(0,i.Ye)((()=>{const e=null==c?void 0:c.state;return $?p("lng_call_status_hanging"):G?"busy":"requesting"===e?p("lng_call_status_requesting"):"requested"===e?p(l?"lng_call_status_ringing":"lng_call_status_incoming"):"waiting"===e?p("lng_call_status_waiting"):"active"===e&&_?void 0:p("lng_call_status_exchanging")}),[G,_,$,l,p,null==c?void 0:c.state]),q="active"===(null==c?void 0:c.videoState),J="active"===(null==c?void 0:c.screencastState),z=(0,n.getStreams)(),X=null==z||null===(t=z.ownAudio)||void 0===t?void 0:t.getTracks()[0].enabled,ae=null==z||null===(a=z.ownPresentation)||void 0===a?void 0:a.getTracks()[0].enabled,ne=null==z||null===(s=z.ownVideo)||void 0===s?void 0:s.getTracks()[0].enabled,[ie,oe,se]=(0,S.Z)(),[re,le,ce]=(0,S.Z)(),de=(0,i.I4)((()=>{ae&&oe(),ne&&le(),setTimeout((async()=>{await(0,n.toggleStreamP2p)("presentation"),se(),ce()}),250)}),[ae,ne,oe,le,se,ce]),ue=(0,i.I4)((()=>{ne&&le(),ae&&oe(),setTimeout((async()=>{await(0,n.toggleStreamP2p)("video"),se(),ce()}),250)}),[ae,ne,oe,le,se,ce]),pe=(0,i.I4)((()=>{(0,n.toggleStreamP2p)("audio")}),[]),[me,ve,ge]=(0,S.Z)(),[fe,Ce,he]=(0,S.Z)(),Pe=(0,i.I4)((()=>{Ce(),(0,n.switchCameraInputP2p)(),setTimeout(he,250)}),[Ce,he]),Se=(null==c?void 0:c.startDate)&&Number(new Date)/1e3-c.startDate;return(0,i.d4)((()=>{"discarded"===(null==c?void 0:c.state)&&setTimeout(m,250)}),[m,null==c?void 0:c.reason,null==c?void 0:c.state]),i.ZP.createElement(w.Z,{isOpen:c&&"discarded"!==(null==c?void 0:c.state)&&!d,onClose:V,className:(0,P.Z)(te.root,v.wB&&te.singleColumn),dialogRef:Z},i.ZP.createElement(j.Z,{user:r,size:"jumbo",className:q||J?te.blurred:"",withVideo:!0,noLoop:"requesting"!==(null==c?void 0:c.state),animationLevel:u}),"active"===(null==c?void 0:c.screencastState)&&(null==z?void 0:z.presentation)&&i.ZP.createElement("video",{className:te.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:z.presentation}),"active"===(null==c?void 0:c.videoState)&&(null==z?void 0:z.video)&&i.ZP.createElement("video",{className:te.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:z.video}),i.ZP.createElement("video",{className:(0,P.Z)(te.secondVideo,!ie&&ae&&te.visible,k&&te.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==z?void 0:z.ownPresentation}),i.ZP.createElement("video",{className:(0,P.Z)(te.secondVideo,!re&&ne&&te.visible,k&&te.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==z?void 0:z.ownVideo}),i.ZP.createElement("div",{className:te.header},v.t0&&i.ZP.createElement(b.Z,{round:!0,size:"smaller",color:"translucent",onClick:M,ariaLabel:p(k?"AccExitFullscreen":"AccSwitchToFullscreen")},i.ZP.createElement("i",{className:k?"icon-smallscreen":"icon-fullscreen"})),i.ZP.createElement(b.Z,{round:!0,size:"smaller",color:"translucent",onClick:V,className:te.closeButton},i.ZP.createElement("i",{className:"icon-close"}))),i.ZP.createElement("div",{className:(0,P.Z)(te.emojisBackdrop,me&&te.open),onClick:me?ge:ve},i.ZP.createElement("div",{className:(0,P.Z)(te.emojis,me&&te.open)},(null==c?void 0:c.isConnected)&&(null==c?void 0:c.emojis)&&(0,Y.Z)(c.emojis,["emoji"])),i.ZP.createElement("div",{className:(0,P.Z)(te.emojiTooltip,me&&te.open)},p("CallEmojiKeyTooltip",null==r?void 0:r.firstName).replace("%%","%"))),i.ZP.createElement("div",{className:te.userInfo},i.ZP.createElement("h1",null,null==r?void 0:r.firstName),i.ZP.createElement("span",{className:te.status},B||(0,K.k9)(Se||0))),i.ZP.createElement("div",{className:te.buttons},i.ZP.createElement(ee,{onClick:pe,icon:"microphone",isDisabled:!R,isActive:X,label:p(X?"lng_call_mute_audio":"lng_call_unmute_audio")}),i.ZP.createElement(ee,{onClick:ue,icon:"video",isDisabled:!R,isActive:ne,label:p(ne?"lng_call_stop_video":"lng_call_start_video")}),ne&&(v.wZ||v.cj)&&i.ZP.createElement(ee,{onClick:Pe,customIcon:i.ZP.createElement(N.Z,{tgsUrl:h.l.CameraFlip,playSegment:fe?[0,10]:[0,1],size:32}),isDisabled:!R,label:p("VoipFlip")}),n.IS_SCREENSHARE_SUPPORTED&&i.ZP.createElement(ee,{onClick:de,icon:"share-screen",isDisabled:!R,isActive:ae,label:p("lng_call_screencast")}),U&&i.ZP.createElement(ee,{onClick:g,icon:"phone-discard",isDisabled:O,label:p("lng_call_accept"),className:te.accept,iconClassName:te.acceptIcon}),i.ZP.createElement(ee,{onClick:F,icon:"phone-discard",isDisabled:O,label:p(U?"lng_call_decline":"lng_call_end_call"),className:te.leave})))})));var ne=a(97687);const ie=(0,i.X$)((e=>{let{isOpen:t}=e;const{closeCallRatingModal:a,setCallRating:n}=(0,o.Sv)(),s=(0,i.sO)(null),r=(0,E.Z)(),[l,c]=(0,i.eJ)(),d=(0,i.I4)((()=>{a()}),[a]);return i.ZP.createElement(w.Z,{title:r("lng_call_rate_label"),className:"narrow",onClose:a,isOpen:t},i.ZP.createElement("div",{className:"wLqZtZzJMOmPkr1Z7kT5"},new Array(5).fill(void 0).map(((e,t)=>{const a=void 0!==l&&l>=t;return i.ZP.createElement("i",{className:(0,P.Z)(a?"icon-favorite-filled":"icon-favorite",a&&"o_nOyYqj5URif5S86StK","OLQPS_OeztNYIaL15tdz"),onClick:(n=t,()=>c(l===n?void 0:n))});var n}))),i.ZP.createElement(ne.Z,{ref:s,placeholder:r("lng_call_rate_comment"),className:(0,P.Z)("ZToDNX6q1Yhf4aDPyuJF",4!==l&&void 0!==l&&"HdCq8jVctaJoit7bdgZd")}),i.ZP.createElement(b.Z,{className:"confirm-dialog-button",isText:!0,onClick:function(){var e;l?n({rating:l+1,comment:(null===(e=s.current)||void 0===e?void 0:e.value)||""}):a()}},r("Send")),i.ZP.createElement(b.Z,{className:"confirm-dialog-button",isText:!0,onClick:d},r("Cancel")))}))},73794:(e,t)=>{(()=>{"use strict";var e={"./src/blacksilence.ts":(e,t,a)=>{a.r(t),a.d(t,{silence:()=>n,black:()=>i});const n=e=>{const t=e.createOscillator(),a=t.connect(e.createMediaStreamDestination());return t.start(),new MediaStream([Object.assign(a.stream.getAudioTracks()[0],{enabled:!1})])},i=function(){let{width:e=640,height:t=480}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=Object.assign(document.createElement("canvas"),{width:e,height:t}),n=a.getContext("2d");if(!n)throw Error("Cannot create canvas ctx");n.fillRect(0,0,e,t);const i=a.captureStream();return new MediaStream([Object.assign(i.getVideoTracks()[0],{enabled:!1})])}},"./src/buildSdp.ts":(e,t,a)=>{a.r(t),a.d(t,{default:()=>i});var n=a("./src/utils.ts");const i=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const o=[],s=e=>{o.push(e)},{sessionId:r,ssrcs:l,audioExtensions:c,videoExtensions:d,audioPayloadTypes:u,videoPayloadTypes:p,transport:{ufrag:m,pwd:v,fingerprints:g,candidates:f}}=e;s("v=0"),s(`o=- ${r} 2 IN IP4 0.0.0.0`),s("s=-"),s("t=0 0"),s("a=ice-options:trickle"),s("a=msid-semantic:WMS *"),s(`a=group:BUNDLE ${l.map((e=>e.endpoint)).join(" ")}${a?"":" "+(i?"3":"2")}`),i||s("a=ice-lite");const C=e=>{if(e.sdpString)s(`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}`,s(t)}},h=()=>{s(`a=ice-ufrag:${m}`),s(`a=ice-pwd:${v}`),g.forEach((e=>{s(`a=fingerprint:${e.hash} ${e.fingerprint}`),s(`a=setup:${i?e.setup:"passive"}`)})),f.forEach(C)},P=e=>{var t;const{channels:a,id:n,name:i,clockrate:o,parameters:r}=e;var l=a?`/${a}`:"";s(`a=rtpmap:${n} ${i}/${o}${l}`),r&&(l=Object.keys(r).map((e=>`${e}=${r[e]};`)).join(" "),s(`a=fmtp:${n} ${l}`)),null===(t=e["rtcp-fbs"])||void 0===t||t.forEach((e=>{s(`a=rtcp-fb:${n} ${e.type}${e.subtype?` ${e.subtype}`:""}`)}))};return e=e=>{const a=e.isVideo?p:u;var o=e.isVideo?"video":"audio";if(s(`m=${o} ${e.isMain?1:0} RTP/SAVPF ${a.map((e=>e.id)).join(" ")}`),s("c=IN IP4 0.0.0.0"),s("b=AS:1300"),s(`a=mid:${e.endpoint}`),s("a=rtcp-mux"),a.forEach(P),s("a=rtcp:1 IN IP4 0.0.0.0"),e.isVideo&&s("a=rtcp-rsize"),(e.isVideo?d:c).forEach((e=>{let{id:t,uri:a}=e;s(`a=extmap:${t} ${a}`)})),e.isRemoved)s("a=inactive");else{if(h(),i)s("a=sendrecv"),s("a=bundle-only");else{if(t)return void s("a=recvonly");e.isMain?s("a=sendrecv"):(s("a=sendonly"),s("a=bundle-only"))}e.sourceGroups.forEach((t=>{s(`a=ssrc-group:${t.semantics} ${t.sources.map(n.fromTelegramSource).join(" ")}`),t.sources.forEach((t=>{t=(0,n.fromTelegramSource)(t),s(`a=ssrc:${t} cname:${e.endpoint}`),s(`a=ssrc:${t} msid:${e.endpoint} ${e.endpoint}`),s(`a=ssrc:${t} mslabel:${e.endpoint}`),s(`a=ssrc:${t} label:${e.endpoint}`)}))}))}},i?l.filter(e):l.filter((e=>"0"===e.endpoint||"1"===e.endpoint)).map(e),a||(s("m=application 1 UDP/DTLS/SCTP webrtc-datachannel"),s("c=IN IP4 0.0.0.0"),h(),s("a=ice-options:trickle"),s("a=mid:"+(i?"3":a?"1":"2")),s("a=sctp-port:5000"),s("a=max-message-size:262144")),i||l.filter((e=>"0"!==e.endpoint&&"1"!==e.endpoint)).map(e),`${o.join("\n")}\n`}},"./src/p2p.ts":(e,t,a)=>{a.r(t),a.d(t,{getStreams:()=>function(){var e;return null===(e=r)||void 0===e?void 0:e.streams},switchCameraInputP2p:()=>async function(){if(r&&r.facingMode){const e=r.streams.ownVideo;if(e){const t=e.getTracks()[0];if(t){const e=r.connection.getSenders().find((e=>{var a;return t.id===(null===(a=e.track)||void 0===a?void 0:a.id)}));if(e){r.facingMode="environment"===r.facingMode?"user":"environment";try{const t=await c("video",r.facingMode);await e.replaceTrack(t.getTracks()[0]),r.streams.ownVideo=t,l()}catch(e){}}}}}},toggleStreamP2p:()=>d,joinPhoneCall:()=>async function(e,t,a,o,s){const c=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}))),iceCandidatePoolSize:2}),u=(0,n.silence)(new AudioContext),p=(0,n.black)({width:640,height:480}),g=(0,n.black)({width:640,height:480});c.addTrack(u.getTracks()[0],u),c.addTrack(p.getTracks()[0],p),c.addTrack(g.getTracks()[0],g),c.onicecandidate=e=>{e.candidate&&t({"@type":"Candidates",candidates:[{sdpString:e.candidate.candidate}]})},c.onconnectionstatechange=()=>{s({"@type":"updatePhoneCallConnectionState",connectionState:c.connectionState})},c.ontrack=e=>{var t;r&&(t=e.streams[0],"audio"===e.track.kind?(r.audio.srcObject=t,r.audio.play().catch(),r.streams.audio=t):"1"===e.transceiver.mid?r.streams.video=t:r.streams.presentation=t,l())};const f=c.createDataChannel("data",{id:0,negotiated:!0});f.onmessage=e=>{v(JSON.parse(e.data))},e=new Audio,r={audio:e,connection:c,emitSignalingData:t,isOutgoing:a,candidates:[],onUpdate:s,streams:{ownVideo:p,ownAudio:u,ownPresentation:g},mediaState:{isBatteryLow:!1,screencastState:"inactive",videoState:"inactive",videoRotation:0,isMuted:!0},blackVideo:p,blackPresentation:g,silence:u,dataChannel:f};try{o&&d("video",!0),d("audio",!0)}catch(e){}a&&(a=await c.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),await c.setLocalDescription(a),m((0,i.default)(a,!0)))},stopPhoneCall:()=>function(){var e,t,a;r&&(null!==(e=r.streams.ownVideo)&&void 0!==e&&e.getTracks().forEach((e=>e.stop())),null!==(t=r.streams.ownPresentation)&&void 0!==t&&t.getTracks().forEach((e=>e.stop())),null!==(a=r.streams.ownAudio)&&void 0!==a&&a.getTracks().forEach((e=>e.stop())),r.dataChannel.close(),r.connection.close(),r=void 0)},processSignalingMessage:()=>v});var n=a("./src/blacksilence.ts"),i=a("./src/parseSdp.ts"),o=a("./src/utils.ts"),s=a("./src/buildSdp.ts");let r;function l(){var e;null===(e=r)||void 0===e||e.onUpdate({...r.mediaState,"@type":"updatePhoneCallMediaState"})}function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"user";return"presentation"===e?navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0}):navigator.mediaDevices.getUserMedia({audio:"audio"===e&&{...o.IS_ECHO_CANCELLATION_SUPPORTED&&{echoCancellation:!0},...o.IS_NOISE_SUPPRESSION_SUPPORTED&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}})}async function d(e,t){if(r){const a="audio"===e?r.streams.ownAudio:"video"===e?r.streams.ownVideo:r.streams.ownPresentation;if(a){const n=a.getTracks()[0];if(n){const a=r.connection.getSenders().find((e=>{var t;return n.id===(null===(t=e.track)||void 0===t?void 0:t.id)}));if(a){t=void 0===t?!n.enabled:t;try{if(t&&!n.enabled){const t=await c(e);t.getTracks()[0].onended=()=>{d(e,!1)},await a.replaceTrack(t.getTracks()[0]),"audio"===e?r.streams.ownAudio=t:"video"===e?(r.streams.ownVideo=t,r.facingMode="user"):r.streams.ownPresentation=t,"video"!==e&&"presentation"!==e||d("video"===e?"presentation":"video",!1)}else if(!t&&n.enabled){n.stop();const t="audio"===e?r.silence:"video"===e?r.blackVideo:r.blackPresentation;if(!t)return;await a.replaceTrack(t.getTracks()[0]),"audio"===e?r.streams.ownAudio=t:"video"===e?r.streams.ownVideo=t:r.streams.ownPresentation=t}l(),u()}catch(e){}}}}}}function u(){if(r){var e,t,a;const{emitSignalingData:n,streams:i}=r;n({"@type":"MediaState",videoRotation:0,isMuted:!(null!==(e=i.ownAudio)&&void 0!==e&&e.getTracks()[0].enabled),isBatteryLow:!0,videoState:null!==(t=i.ownVideo)&&void 0!==t&&t.getTracks()[0].enabled?"active":"inactive",screencastState:null!==(a=i.ownPresentation)&&void 0!==a&&a.getTracks()[0].enabled?"active":"inactive"})}}function p(e){if(!r||r.isOutgoing)return e;const t=e.payloadTypes;var a=t.findIndex((e=>"VP8"===e.name));const n=t[a];var i=t.findIndex((e=>{var t;return Number(null===(t=e.parameters)||void 0===t?void 0:t.apt)===n.id}));return e.payloadTypes=[t[a],t[i]],e}function m(e){if(r){const t=r.emitSignalingData;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:(0,o.fromTelegramSource)(e.ssrc).toString(),ssrcGroups:[],payloadTypes:e.audioPayloadTypes,rtpExtensions:e.audioExtmap},video:p({ssrc:(0,o.fromTelegramSource)(e["ssrc-groups"][0].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][0].semantics,ssrcs:e["ssrc-groups"][0].sources.map(o.fromTelegramSource)}],payloadTypes:e.videoPayloadTypes,rtpExtensions:e.videoExtmap}),screencast:p({ssrc:(0,o.fromTelegramSource)(e["ssrc-groups"][1].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][1].semantics,ssrcs:e["ssrc-groups"][1].sources.map(o.fromTelegramSource)}],payloadTypes:e.screencastPayloadTypes,rtpExtensions:e.screencastExtmap})})}}async function v(e){if(r&&r.connection)switch(e["@type"]){case"MediaState":r.mediaState=e,l(),u();break;case"Candidates":var{candidates:t,gotInitialSetup:a}=r;if(!t)return;e.candidates.forEach((e=>{r.candidates.push(e.sdpString)})),a&&await Promise.all(r.candidates.map((e=>r.connection.addIceCandidate({candidate:e,sdpMLineIndex:0}))));break;case"InitialSetup":{var n,c;const{connection:t,isOutgoing:l}=r;if(!t)return;if(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",sourceGroups:[{semantics:"FID",sources:[e.audio.ssrc]}]},e.video&&{isVideo:!0,isPresentation:!1,isMain:!1,userId:"123",endpoint:"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",sourceGroups:e.screencast.ssrcGroups.map((e=>({semantics:e.semantics,sources:e.ssrcs})))}],audioPayloadTypes:(null===(n=e.audio.payloadTypes)||void 0===n?void 0:n.map(o.p2pPayloadTypeToConference))||[],audioExtensions:e.audio.rtpExtensions,videoPayloadTypes:(null===(c=p(e.video).payloadTypes)||void 0===c?void 0:c.map(o.p2pPayloadTypeToConference))||[],videoExtensions:e.video.rtpExtensions},await t.setRemoteDescription({sdp:(0,s.default)(a,l,void 0,!0),type:l?"answer":"offer"}),r.conference=a,!l){if(a=await t.createAnswer(),!a)return;await t.setLocalDescription(a),m((0,i.default)(a,!0))}r.gotInitialSetup=!0,await Promise.all(r.candidates.map((e=>t.addIceCandidate({candidate:e,sdpMLineIndex:0}))));break}}}},"./src/p2pMessage.ts":(e,t,a)=>{a.r(t)},"./src/parseSdp.ts":(e,t,a)=>{a.r(t),a.d(t,{default:()=>i});var n=a("./src/utils.ts");const i=function(e){var t,a,i;let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e||!e.sdp)throw Error("Failed parsing SDP: session description is null");const s=e.sdp.split("\r\nm=").map(((e,t)=>0===t?e:`m=${e}`)).reduce(((e,t)=>{var a,n=(null===(a=t.match(/^m=(.+?)\s/))||void 0===a?void 0:a[1])||"header";return e[e.hasOwnProperty(n)&&"video"===n?"screencast":n]=t.split("\r\n").filter(Boolean),e}),{});var r=(e,t)=>{var a,n;return t?null===(a=s[t])||void 0===a||null===(n=a.find((t=>t.startsWith(e))))||void 0===n?void 0:n.substr(e.length):Object.values(s).map((t=>{var a;return null===(a=t.find((t=>t.startsWith(e))))||void 0===a?void 0:a.substr(e.length)})).filter(Boolean)[0]},l=e=>s[e].filter((e=>e.startsWith("a=extmap"))).map((e=>{var[,t,e]=e.match(/extmap:(\d+)(?:\/.+)?\s(.+)/);return{id:Number(t),uri:e}})),c=e=>{const t=s[e].filter((e=>e.startsWith("a=rtpmap"))).map((e=>{const[,t,a]=e.match(/:(\d+)\s(.+)/)||[];var[n,i,e]=a.split("/");return{id:Number(t),name:n,clockrate:Number(i),...e&&{channels:Number(e)}}})),a=s[e].filter((e=>e.startsWith("a=rtcp-fb"))).map((e=>{const[,t,a]=e.match(/:(\d+)\s(.+)/)||[];var[n,e]=a.split(" ");return{id:Number(t),type:n,subtype:e||""}})),n=s[e].filter((e=>e.startsWith("a=fmtp"))).map((e=>{const[,t,a]=e.match(/:(\d+)\s(.+)/)||[];if(e=a.split(";").reduce(((e,t)=>{var[a,t]=t.split("=");return e[a]=t,e}),{}),!Object.values(e).some((e=>!e)))return{id:Number(t),data:e}})).filter(Boolean);return t.map((e=>{var t=n.filter((t=>t.id===e.id)).map((e=>e.data)).reduce(((e,t)=>Object.assign(e,t)),{}),i=a.filter((t=>t.id===e.id)).map((e=>({type:e.type,subtype:e.subtype})));return{...e,...0<Object.keys(t).length&&{parameters:t},...0<i.length&&{feedbackTypes:i}}}))};const d=r("a=ssrc:","audio");var u=d&&Number(d.split(" ")[0]);const p=(null===(t=r("a=ssrc-group:","video"))||void 0===t?void 0:t.split(" "))||void 0,m=(null===(a=r("a=ssrc-group:","screencast"))||void 0===a?void 0:a.split(" "))||void 0;if(!p)throw Error("Failed parsing SDP: no video ssrc");var[v,g]=(null===(i=r("a=fingerprint:"))||void 0===i?void 0:i.split(" "))||[],f=r("a=setup:");if(!v||!g)throw Error("Failed parsing SDP: no fingerprint");if(console.log(s),e=r("a=ice-ufrag:"),r=r("a=ice-pwd:"),!e||!r)throw Error("Failed parsing SDP: no ICE ufrag or pwd");return{fingerprints:[{fingerprint:g,hash:v,setup:o?f:"active"}],pwd:r,ufrag:e,...u&&{ssrc:(0,n.toTelegramSource)(u)},...p&&{"ssrc-groups":[{semantics:p[0],sources:p.slice(1,p.length).map(Number).map(n.toTelegramSource)},o&&m&&{semantics:m[0],sources:m.slice(1,m.length).map(Number).map(n.toTelegramSource)}].filter(Boolean)},...o&&{audioExtmap:l("audio"),videoExtmap:l("video"),screencastExtmap:l("screencast"),audioPayloadTypes:c("audio"),videoPayloadTypes:c("video"),screencastPayloadTypes:c("screencast")}}}},"./src/secretsauce.ts":(e,t,a)=>{a.r(t),a.d(t,{getDevices:()=>async function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(await navigator.mediaDevices.enumerateDevices()).filter((a=>a.kind===`${e}${t?"input":"output"}`))},toggleSpeaker:()=>function(){var e,t;r&&(r.isSpeakerDisabled=!r.isSpeakerDisabled,null!==(e=r)&&void 0!==e&&null!==(t=e.onUpdate)&&void 0!==t&&t.call(e,{"@type":"updateGroupCallConnectionState",connectionState:"connected",isSpeakerDisabled:r.isSpeakerDisabled}),r.participantFunctions&&Object.values(r.participantFunctions).forEach((e=>{var t,a;null===(t=e.toggleMute)||void 0===t||t.call(e,!(null===(a=r)||void 0===a||!a.isSpeakerDisabled))})))},toggleNoiseSuppression:()=>function(){if(r&&r.myId&&r.streams){const a=r.streams[r.myId].audio;if(a){const n=a.getTracks()[0];var e,t;n&&(({echoCancellation:e,noiseSuppression:t}=n.getConstraints()),n.applyConstraints({echoCancellation:!e,noiseSuppression:!t}))}}},getUserStreams:()=>c,setVolume:()=>function(e,t){var a,n,i;const o=null===(a=r)||void 0===a||null===(n=a.participantFunctions)||void 0===n?void 0:n[e];o&&(null===(i=o.setVolume)||void 0===i||i.call(o,t))},isStreamEnabled:()=>d,switchCameraInput:()=>async function(){var e;if(null!==(e=r)&&void 0!==e&&e.myId&&r.connection&&r.streams&&r.facingMode){var t;const e=null===(t=c(r.myId))||void 0===t?void 0:t.video;if(e){const t=e.getTracks()[0];if(t){const e=r.connection.getSenders().find((e=>{var a;return t.id===(null===(a=e.track)||void 0===a?void 0:a.id)}));if(e){r.facingMode="environment"===r.facingMode?"user":"environment";try{const t=await p("video",r.facingMode);await e.replaceTrack(t.getTracks()[0]),r.streams[r.myId].video=t}catch(e){}}}}}},toggleStream:()=>m,leaveGroupCall:()=>g,handleUpdateGroupCallParticipants:()=>async function(e){if(r){const{participants:n,conference:o,connection:s,myId:l}=r;if(n&&o&&s&&o.ssrcs&&o.transport&&l)if(e.find((e=>{var t,a,n,i;return e.isSelf&&e.source!==(null===(t=r)||void 0===t||null===(a=t.conference)||void 0===a||null===(n=a.ssrcs)||void 0===n||null===(i=n.find((e=>e.isMain&&!e.isVideo)))||void 0===i?void 0:i.sourceGroups[0].sources[0])})))g();else{const n=[];if(e.forEach((e=>{if(e.isSelf)e.isMuted&&!e.canSelfUnmute&&(m("audio",!1),m("video",!1),m("presentation",!1));else{var t=e.isLeft;const a=e.isMuted||e.isMutedByMe,i=!e.isVideoJoined||!e.video||t,s=!e.presentation||t;let r=!1,l=!1,c=!1;o.ssrcs.filter((t=>t.userId===e.id)).forEach((t=>{t.isVideo||(t.sourceGroups[0].sources[0]===e.source&&(l=!0),t.isRemoved=a),t.isVideo&&(t.isPresentation||(e.video&&t.endpoint===e.video.endpoint&&(r=!0),t.isRemoved=i),t.isPresentation&&(e.presentation&&t.endpoint===e.presentation.endpoint&&(c=!0),t.isRemoved=s))})),a||l||o.ssrcs.push({userId:e.id,isMain:!1,endpoint:`audio${e.source}`,isVideo:!1,sourceGroups:[{semantics:"FID",sources:[e.source]}]}),i||r||!e.video||(n.push(e.video.endpoint),o.ssrcs.push({userId:e.id,isMain:!1,endpoint:e.video.endpoint,isVideo:!0,sourceGroups:e.video.sourceGroups})),s||c||!e.presentation||o.ssrcs.push({isPresentation:!0,userId:e.id,isMain:!1,endpoint:e.presentation.endpoint,isVideo:!0,sourceGroups:e.presentation.sourceGroups})}})),r.updatingParticipantsQueue)r.updatingParticipantsQueue.push(o);else{r.updatingParticipantsQueue=[],e=(0,i.default)(o),await s.setRemoteDescription({type:"offer",sdp:e});try{var t=await s.createAnswer();if(await s.setLocalDescription(t),u(l),0<r.updatingParticipantsQueue.length)for(const e of r.updatingParticipantsQueue){await s.setRemoteDescription({type:"offer",sdp:(0,i.default)(e)});var a=await s.createAnswer();await s.setLocalDescription(a),u(l)}r.updatingParticipantsQueue=void 0}catch(e){console.error(e)}}}}},handleUpdateGroupCallConnection:()=>async function(e,t){if(r){var a=t?r.screenshareConference:r.conference;const d=t?r.screenshareConnection:r.connection;if(a&&d&&a.ssrcs){var n,o,s,l,c=Date.now();e={...a,transport:e.transport,sessionId:c,audioExtensions:null===(n=e.audio)||void 0===n?void 0:n["rtp-hdrexts"],audioPayloadTypes:null===(o=e.audio)||void 0===o?void 0:o["payload-types"],videoExtensions:null===(s=e.video)||void 0===s?void 0:s["rtp-hdrexts"],videoPayloadTypes:null===(l=e.video)||void 0===l?void 0:l["payload-types"]},r={...r,...t?{screenshareConference:e}:{conference:e}};try{await d.setRemoteDescription({type:"answer",sdp:(0,i.default)(e,!0,t)})}catch(e){console.error(e)}}}},startSharingScreen:()=>async function(){if(r)try{const e=await p("presentation");return e?(e.getTracks()[0].onended=()=>{var e;r&&r.myId&&(null!==(e=r.streams)&&void 0!==e&&e[r.myId].presentation,u(r.myId),l())},new Promise((t=>{var{connection:a,dataChannel:t}=h([e],t,!0);r={...r,screenshareConnection:a,screenshareDataChannel:t}}))):void 0}catch(e){return}},joinGroupCall:()=>function(e,t,a,n){if(r)throw Error("Already in call");v("connecting");var i=new MediaStream;return a.srcObject=i,a.play().catch((e=>console.warn(e))),r={onUpdate:n,participants:[],myId:e,speaking:{},silence:(0,o.silence)(t),black:(0,o.black)({width:640,height:480}),analyserInterval:setInterval(f,1e3),audioElement:a,audioContext:t,mediaStream:i},new Promise((e=>{r={...r,...h([r.silence,r.black],e)}}))}});var n=a("./src/parseSdp.ts"),i=a("./src/buildSdp.ts"),o=a("./src/blacksilence.ts"),s=a("./src/utils.ts");let r;function l(e){var t,a,n,i;r&&(null!==(t=r.screenshareDataChannel)&&void 0!==t&&t.close(),null!==(a=r.screenshareConnection)&&void 0!==a&&a.close(),e||null===(n=(i=r).onUpdate)||void 0===n||n.call(i,{"@type":"updateGroupCallLeavePresentation"}))}function c(e){var t,a;return null===(t=r)||void 0===t||null===(a=t.streams)||void 0===a?void 0:a[e]}function d(e,t){var a,n,i;const o=(t=t||(null===(a=r)||void 0===a?void 0:a.myId))&&(null===(n=c(t))||void 0===n?void 0:n[e]);return!!o&&(null===(i=o.getTracks()[0])||void 0===i?void 0:i.enabled)}function u(e){var t,a,n;null===(t=r)||void 0===t||null===(a=t.onUpdate)||void 0===a||a.call(t,{"@type":"updateGroupCallStreams",userId:e,hasAudioStream:d("audio",e),hasVideoStream:d("video",e),hasPresentationStream:d("presentation",e),amplitude:null===(n=r.speaking)||void 0===n?void 0:n[e]})}function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"user";return"presentation"===e?navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0}):navigator.mediaDevices.getUserMedia({audio:"audio"===e&&{...s.IS_ECHO_CANCELLATION_SUPPORTED&&{echoCancellation:!0},...s.IS_NOISE_SUPPRESSION_SUPPORTED&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}})}async function m(e,t){if(r&&r.myId&&r.connection&&r.streams){var a;const o=null===(a=c(r.myId))||void 0===a?void 0:a[e];if(o){const a=o.getTracks()[0];if(a){var n;const o=[...r.connection.getSenders(),...(null===(n=r.screenshareConnection)||void 0===n?void 0:n.getSenders())||[]].find((e=>{var t;return a.id===(null===(t=e.track)||void 0===t?void 0:t.id)}));if(o){t=void 0===t?!a.enabled:t;try{if(t&&!a.enabled){const t=await p(e);if(await o.replaceTrack(t.getTracks()[0]),r.streams[r.myId][e]=t,"video"===e)r.facingMode="user";else if("audio"===e){var i;const e=r.audioContext;if(!e)return;const a=e.createMediaStreamSource(t),n=e.createAnalyser();n.minDecibels=-100,n.maxDecibels=-30,n.smoothingTimeConstant=.05,n.fftSize=1024,a.connect(n),r={...r,participantFunctions:{...r.participantFunctions,[r.myId]:{...null===(i=r.participantFunctions)||void 0===i?void 0:i[r.myId],getCurrentAmplitude:()=>{var e=new Uint8Array(n.frequencyBinCount);return n.getByteFrequencyData(e),(0,s.getAmplitude)(e,1.5)}}}}}}else if(!t&&a.enabled){a.stop();const t="audio"===e?r.silence:r.black;if(!t)return;await o.replaceTrack(t.getTracks()[0]),r.streams[r.myId][e]=t,"video"===e&&(r.facingMode=void 0)}u(r.myId),"presentation"!==e||t||l(!0)}catch(e){}}}}}}function v(e){var t,a;null===(t=r)||void 0===t||null===(a=t.onUpdate)||void 0===a||a.call(t,{"@type":"updateGroupCallConnectionState",connectionState:e})}function g(){var e,t,a;r&&(r.myId&&null!==(e=r.streams)&&void 0!==e&&e[r.myId]&&Object.values(r.streams[r.myId]||{}).forEach((e=>{null==e||e.getTracks().forEach((e=>{e.stop()}))})),l(!0),null!==(t=r.dataChannel)&&void 0!==t&&t.close(),null!==(a=r.connection)&&void 0!==a&&a.close(),v("disconnected"),r.analyserInterval&&clearInterval(r.analyserInterval),r=void 0)}function f(){r&&r.participantFunctions&&Object.keys(r.participantFunctions).forEach((e=>{const t=r.participantFunctions[Number(e)].getCurrentAmplitude;var a,n;t&&(a=t(),n=r.speaking[e]||0,((r.speaking[e]=a)>s.THRESHOLD&&n<=s.THRESHOLD||a<=s.THRESHOLD&&n>s.THRESHOLD)&&u(e))}))}function C(e){if(r&&r.audioElement&&r.audioContext&&r.mediaStream){var t,a,n=null===(t=r.conference)||void 0===t||null===(a=t.ssrcs)||void 0===a?void 0:a.find((t=>t.endpoint===e.track.id));if(n&&n.userId){var i,o;const{userId:t,isPresentation:a}=n;var l=null===(i=r.participants)||void 0===i?void 0:i.find((e=>e.id===t));const d="video"===e.track.kind?a?"presentation":"video":"audio";if(e.track.onended=()=>{var e,a;null!==(e=r)&&void 0!==e&&null!==(a=e.streams)&&void 0!==a&&a[t][d],u(t)},n=e.streams[0],"audio"===e.track.kind){var c;const e=r.mediaStream,a=new window.AudioContext,i=a.createMediaStreamSource(n),o=a.createGain();o.gain.value=((null==l?void 0:l.volume)||1e4)/1e4;const d=a.createGain();o.gain.value=1;const u=a.createAnalyser();u.minDecibels=-100,u.maxDecibels=-30,u.smoothingTimeConstant=.05,u.fftSize=1024,i.connect(u).connect(d).connect(o).connect(a.destination),e.addTrack(i.mediaStream.getAudioTracks()[0]);const p=new Audio;p.srcObject=n,p.muted=!0,p.remove(),r={...r,participantFunctions:{...r.participantFunctions,[t]:{...null===(c=r.participantFunctions)||void 0===c?void 0:c[t],setVolume:e=>{o.gain.value=1<e?2*e:e},toggleMute:e=>{d.gain.value=e?0:1},getCurrentAmplitude:()=>{var e=new Uint8Array(u.frequencyBinCount);return u.getByteFrequencyData(e),(0,s.getAmplitude)(e,1.5)}}}}}r={...r,streams:{...r.streams,[t]:{...null===(o=r.streams)||void 0===o?void 0:o[t],[d]:n}}},u(t)}}}function h(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=new RTCPeerConnection;var o=a?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}(i);return e.forEach((e=>e.getTracks().forEach((t=>{i.addTrack(t,e)})))),a||(i.oniceconnectionstatechange=()=>{var e=i.iceConnectionState;"connected"===e||"completed"===e?v("connected"):"checking"===e||"new"===e?v("connecting"):"disconnected"===i.iceConnectionState&&v("reconnecting")}),i.ontrack=C,i.onnegotiationneeded=async()=>{if(r){var o=r.myId;if(o){var s=await i.createOffer({offerToReceiveVideo:!0,offerToReceiveAudio:!a});if(await i.setLocalDescription(s),s.sdp){var l,c=(0,n.default)(s),d=a?void 0:{userId:"",sourceGroups:[{semantics:"FID",sources:[c.ssrc||0]}],isRemoved:a,isMain:!0,isVideo:!1,isPresentation:a,endpoint:a?"1":"0"},p=c["ssrc-groups"]&&{isPresentation:a,userId:"",sourceGroups:c["ssrc-groups"],isMain:!0,isVideo:!0,endpoint:a?"0":"1"};s=a?r.screenshareConference:r.conference;const i=[];a?(p&&i.push(p),d&&i.push(d)):(d&&i.push(d),p&&i.push(p)),d=e.find((e=>"audio"===e.getTracks()[0].kind)),p=e.find((e=>"video"===e.getTracks()[0].kind)),r={...r,...a?{screenshareConference:{...s,ssrcs:i}}:{conference:{...s,ssrcs:i}},streams:{...r.streams,[o]:{...null===(l=r.streams)||void 0===l?void 0:l[o],...d&&{audio:d},...!a&&p?{video:p}:{presentation:p}}}},u(o),t(c)}}}},{connection:i,dataChannel:o}}},"./src/types.ts":(e,t,a)=>{a.r(t)},"./src/utils.ts":(e,t,a)=>{var n,i,o,s,r;a.r(t),a.d(t,{toTelegramSource:()=>function(e){return e<<0},fromTelegramSource:()=>function(e){return e>>>0},getAmplitude:()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;if(!e)return 0;var a=e.length;let n=0;for(let t=0;t<a;t++)n+=e[t]*e[t];var i=Math.sqrt(n/a)/255;return Math.min(1,i*t)},p2pPayloadTypeToConference:()=>function(e){return{id:e.id,name:e.name,"rtcp-fbs":e.feedbackTypes,clockrate:e.clockrate,parameters:e.parameters,channels:e.channels}},THRESHOLD:()=>l,IS_SCREENSHARE_SUPPORTED:()=>c,IS_ECHO_CANCELLATION_SUPPORTED:()=>d,IS_NOISE_SUPPRESSION_SUPPORTED:()=>u});const l=.1,c="getDisplayMedia"in((null===(n=navigator)||void 0===n?void 0:n.mediaDevices)||{}),d=null===(i=navigator)||void 0===i||null===(o=i.mediaDevices)||void 0===o?void 0:o.getSupportedConstraints().echoCancellation,u=null===(s=navigator)||void 0===s||null===(r=s.mediaDevices)||void 0===r?void 0:r.getSupportedConstraints().noiseSuppression}},a={};function n(t){var i=a[t];return void 0!==i||(i=a[t]={exports:{}},e[t](i,i.exports,n)),i.exports}n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{n.r(i),n.d(i,{handleUpdateGroupCallConnection:()=>e.handleUpdateGroupCallConnection,startSharingScreen:()=>e.startSharingScreen,joinGroupCall:()=>e.joinGroupCall,getDevices:()=>e.getDevices,getUserStreams:()=>e.getUserStreams,setVolume:()=>e.setVolume,isStreamEnabled:()=>e.isStreamEnabled,toggleStream:()=>e.toggleStream,leaveGroupCall:()=>e.leaveGroupCall,handleUpdateGroupCallParticipants:()=>e.handleUpdateGroupCallParticipants,switchCameraInput:()=>e.switchCameraInput,toggleSpeaker:()=>e.toggleSpeaker,toggleNoiseSuppression:()=>e.toggleNoiseSuppression,joinPhoneCall:()=>t.joinPhoneCall,processSignalingMessage:()=>t.processSignalingMessage,getStreams:()=>t.getStreams,toggleStreamP2p:()=>t.toggleStreamP2p,stopPhoneCall:()=>t.stopPhoneCall,switchCameraInputP2p:()=>t.switchCameraInputP2p,IS_SCREENSHARE_SUPPORTED:()=>a.IS_SCREENSHARE_SUPPORTED,THRESHOLD:()=>a.THRESHOLD});var e=n("./src/secretsauce.ts"),t=n("./src/p2p.ts"),a=(n("./src/p2pMessage.ts"),n("./src/utils.ts"));n("./src/types.ts")})();var o,s=t;for(o in i)s[o]=i[o];i.__esModule&&Object.defineProperty(s,"__esModule",{value:!0})})()}}]);
|
|
//# sourceMappingURL=9954.836adcc6b64f2d9ed43a.js.map
|