/*! For license information please see 272.b66fb5dcb068235ba702.js.LICENSE.txt */ (self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[272],{544:(e,t,a)=>{"use strict";a.r(t),a.d(t,{ActiveCallHeader:()=>J,GroupCall:()=>X,PhoneCall:()=>ae,RatePhoneCallModal:()=>oe});var n=a(3794),o=a(4050),i=a(3555),s=a(3716),l=a(1226),r=a(1192),c=a(2431),d=a(8958),u=a(8422),p=a(7225);(0,i.iw)("leaveGroupCall",(async(e,t,a)=>{const{isFromLibrary:o,shouldDiscard:s,shouldRemove:r,rejoin:p}=a||{},m=(0,c.mU)(e);m&&((0,i.R3)((0,d.Ic)(e,{connectionState:"disconnected"},m.participantsCount-1)),await(0,l.t9)("leaveGroupCall",{call:m}),s&&await(0,l.t9)("discardGroupCall",{call:m}),e=(0,i.Rd)(),r&&(e=(0,d.dc)(e,m.id)),(0,u.Mt)(),(0,i.R3)({...e,groupCalls:{...e.groupCalls,activeGroupCallId:void 0},isCallPanelVisible:void 0}),o||(0,n.leaveGroupCall)(),p&&t.joinGroupCall(p))})),(0,i.iw)("toggleGroupCallVideo",(async e=>{const t=(0,c.mU)(e),a=(0,r.dy)(e,e.currentUserId);a&&t&&(await(0,n.toggleStream)("video"),await(0,l.t9)("editGroupCallParticipant",{call:t,videoStopped:!(0,n.isStreamEnabled)("video"),participant:a}))})),(0,i.iw)("requestToSpeak",((e,t,a)=>{const{value:n}=a||{value:!0},o=(0,c.mU)(e),i=(0,r.dy)(e,e.currentUserId);i&&o&&(0,l.t9)("editGroupCallParticipant",{call:o,raiseHand:n,participant:i})})),(0,i.iw)("setGroupCallParticipantVolume",((e,t,a)=>{const{participantId:o,volume:i}=a,d=(0,c.mU)(e),u=(0,r.dy)(e,o);u&&d&&((0,n.setVolume)(o,Math.floor(i/s.Ro)/100),(0,l.t9)("editGroupCallParticipant",{call:d,volume:Number(i),participant:u}))})),(0,i.iw)("toggleGroupCallMute",(async(e,t,a)=>{const{participantId:o,value:i}=a||{},s=(0,c.mU)(e),d=(0,r.dy)(e,o||e.currentUserId);if(!d||!s)return;const u=void 0===i?(0,n.isStreamEnabled)("audio",d.id):i;o?(0,n.setVolume)(o,u?0:1):await(0,n.toggleStream)("audio"),await(0,l.t9)("editGroupCallParticipant",{call:s,muted:u,participant:d})})),(0,i.iw)("toggleGroupCallPresentation",(async(e,t,a)=>{const o=(0,c.mU)(e),i=(0,r.dy)(e,e.currentUserId);if(i&&o){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,l.t9)("joinGroupCallPresentation",{call:o,params:e})}else await(0,n.toggleStream)("presentation",!1),await(0,l.t9)("leaveGroupCallPresentation",{call:o});await(0,l.t9)("editGroupCallParticipant",{call:o,presentationPaused:!(0,n.isStreamEnabled)("presentation"),participant:i})}})),(0,i.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 o=(0,u.FF)(),s=(0,u.NH)();if(!o||!s)return;const{currentUserId:d}=e;if(!d)return;const m=await(0,n.joinGroupCall)(d,s,o,t.apiUpdate);if(await(0,l.t9)("joinGroupCall",{call:a,params:m,inviteHash:a.inviteHash})&&(t.loadMoreGroupCallParticipants(),a.chatId)){const e=(0,r.Z1)((0,i.Rd)(),a.chatId);if(!e)return;await(0,p.ft)(e)}})),(0,i.iw)("connectToActivePhoneCall",(async e=>{const{phoneCall:t}=e;if(!t)return;const a=(0,c.fu)(e);if(!a)return;const n=await(0,l.t9)("getDhConfig");if(!n)return;await(0,l.t9)("createPhoneCallState",[!0]);const o=await(0,l.t9)("requestPhoneCall",[n]);await(0,l.t9)("requestCall",{user:a,gAHash:o,isVideo:t.isVideo})})),(0,i.iw)("acceptCall",(async e=>{const{phoneCall:t}=e;if(!t)return;const a=await(0,l.t9)("getDhConfig");if(!a)return;await(0,l.t9)("createPhoneCallState",[!1]);const n=await(0,l.t9)("acceptPhoneCall",[a]);(0,l.t9)("acceptCall",{call:t,gB:n})})),(0,i.iw)("sendSignalingData",((e,t,a)=>{const{phoneCall:n}=e;if(!n)return;const o=JSON.stringify(a);(async()=>{const e=await(0,l.t9)("encodePhoneCallData",[o]);e&&(0,l.t9)("sendSignalingData",{data:e,call:n})})()})),(0,i.iw)("closeCallRatingModal",(e=>({...e,ratingPhoneCall:void 0}))),(0,i.iw)("setCallRating",((e,t,a)=>{const{ratingPhoneCall:n}=e;if(!n)return;const{rating:o,comment:i}=a;return(0,l.t9)("setCallRating",{call:n,rating:o,comment:i}),{...e,ratingPhoneCall:void 0}})),(0,i.iw)("hangUp",(e=>{const{phoneCall:t}=e;if(t)return"discarded"===t.state?((0,l.t9)("destroyPhoneCallState"),(0,n.stopPhoneCall)(),{...e,phoneCall:void 0,isCallPanelVisible:void 0}):((0,l.t9)("destroyPhoneCallState"),(0,n.stopPhoneCall)(),(0,l.t9)("discardCall",{call:t}),"requesting"===t.state?{...e,phoneCall:void 0,isCallPanelVisible:void 0}:void 0)}));var m=a(782),v=a(7361),g=a(711);const h=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]),f=[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,i.iw)("apiUpdate",((e,t,a)=>{const{activeGroupCallId:o}=e.groupCalls;switch(a["@type"]){case"updateGroupCallLeavePresentation":t.toggleGroupCallPresentation({value:!1});break;case"updateGroupCallStreams":if(!a.userId||!o)break;if(!(0,c.GU)(e,o,a.userId))break;return(0,d.B6)(e,o,a.userId,(0,m.CE)(a,["@type","userId"]));case"updateGroupCallConnectionState":if(!o)break;if("disconnected"===a.connectionState){t.leaveGroupCall({isFromLibrary:!0});break}return(0,d.AH)(e,o,{connectionState:a.connectionState,isSpeakerDisabled:a.isSpeakerDisabled});case"updateGroupCallParticipants":{const{groupCallId:e,participants:t}=a;o===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 o=(0,c.mU)(e);null!=o&&o.participants&&Object.keys(o.participants).length>0&&(0,n.handleUpdateGroupCallParticipants)(Object.values(o.participants));break}case"updatePhoneCallMediaState":return{...e,phoneCall:{...e.phoneCall,...(0,m.CE)(a,["@type"])}};case"updatePhoneCall":{if(!v.Bi)return;const{phoneCall:o,currentUserId:s}=e,d={...o,...a.call},u=(null==o?void 0:o.adminId)===s;if(e={...e,phoneCall:d},o&&o.id&&d.id!==o.id)return void("discarded"!==d.state&&(0,l.t9)("discardCall",{call:d,isBusy:!0}));const{accessHash:p,state:m,connections:C,gB:P}=d;if(("active"===m||"accepted"===m)&&!(null==(r=d.protocol)?void 0:r.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(!o)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,l.t9)("confirmPhoneCall",[P,h,f]),o={...(e=(0,i.Rd)()).phoneCall,emojis:n};(0,i.R3)({...e,phoneCall:o}),(0,l.t9)("confirmCall",{call:d,gA:t,keyFingerprint:a})})():"active"===m&&C&&"active"!==(null==o?void 0:o.state)&&(u||((0,l.t9)("receivedCall",{call:d}),(async()=>{const{emojis:t}=await(0,l.t9)("confirmPhoneCall",[d.gAOrB,h,f]),a={...(e=(0,i.Rd)()).phoneCall,emojis:t};(0,i.R3)({...e,phoneCall:a})})()),(0,n.joinPhoneCall)(C,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,l.t9)("decodePhoneCallData",[a.data]))||void 0===s||s.then(n.processSignalingMessage);break}}var r}));var C=a(6752),P=a(706),S=a(9107),y=a(4288),E=a(231),b=a(3106),Z=a(8964),k=a(3103);const w=()=>{var e,t;null===(e=(t=navigator).vibrate)||void 0===e||e.call(t,50)};var I=a(7204),T=a(9332),_=a(7799);const N=(0,o.X$)((e=>{let{size:t,name:a,playSegment:n,color:i}=e;const[s,l]=(0,o.eJ)();return(0,o.d4)((()=>{(0,T.Z)(a).then(l)}),[a]),o.ZP.createElement(_.Z,{id:a,play:!0,noLoop:!0,playSegment:n,size:t,speed:1,animationData:s,color:i})})),M=(0,o.X$)((0,i.c$)((e=>{const t=(0,c.mU)(e),{connectionState:a}=t||{},n=t&&(0,c.GU)(e,t.id,e.currentUserId),{raiseHandRating:o,hasAudioStream:i,canSelfUnmute:s,isMuted:l}=n||{};return{connectionState:a||"discarded",hasRequestedToSpeak:Boolean(o),noAudioStream:!i,canSelfUnmute:s,isMuted:l}}))((e=>{let{noAudioStream:t,canSelfUnmute:a,isMuted:n,hasRequestedToSpeak:s,connectionState:l}=e;const{toggleGroupCallMute:r,requestToSpeak:c,playGroupCallSound:d}=(0,i.Sv)(),u=(0,S.Z)(),p=(0,o.sO)("up"),[m,v]=(0,o.eJ)(!1),g="connected"!==l,h=!a&&n,f=(0,I.Z)(h);(0,o.d4)((()=>{f&&!h&&d({sound:"allowTalk"})}),[d,f,h]);const P=(0,o.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!f&&h?t?[99,135]:[136,172]:f&&!h?[0,36]:h?[0,0]:t?[69,99]:[36,69]}),[f,m,t,h]),y=m?"HandFilled":"VoiceMini",E=()=>{w(),r()},b=(0,o.Ye)((()=>u(s?"VoipMutedTapedForSpeak":h?"VoipMutedByAdmin":t?"VoipUnmute":"VoipTapToMute")),[s,t,u,h]);return o.ZP.createElement("div",{className:"button-wrapper microphone-wrapper"},o.ZP.createElement("button",{className:(0,C.Z)("MicrophoneButton",t&&"crossed",a&&"can-self-unmute",g&&"is-connecting",h&&"muted-by-admin"),onMouseDown:()=>{if(h){if(m)return;return w(),c(),v(!0),void setTimeout((()=>{v(!1)}),3e3)}p.current="down",t&&setTimeout((()=>{"down"===p.current&&(p.current="hold",E())}),200)},onMouseUp:()=>{h||(E(),p.current="up")}},o.ZP.createElement(N,{name:y,size:48,playSegment:P})),o.ZP.createElement("div",{className:"button-text"},b))})));var G=a(4605),D=a(9118);var V=a(2328),O=a(2275);const R=[0,17],U=[17,34],$=(0,o.X$)((0,i.c$)((e=>({isAdmin:(0,c.Ht)(e)})))((e=>{let{participant:t,closeDropdown:a,isDropdownOpen:n,anchor:l,isAdmin:r}=e;const{toggleGroupCallMute:c,setGroupCallParticipantVolume:d,toggleGroupCallPanel:u,openChat:p,requestToSpeak:m}=(0,i.Sv)(),v=(0,S.Z)(),[g,h,f]=(0,P.Z)(),y=null==t?void 0:t.id,{isMutedByMe:E,isMuted:b,isSelf:k,canSelfUnmute:w}=t||{},I=Boolean(null==t?void 0:t.raiseHandRating),T=!w&&b,[_,M]=(0,o.eJ)(E?0:((null==t?void 0:t.volume)||s.aC)/s.Ro);(0,o.d4)((()=>{M(E?0:((null==t?void 0:t.volume)||s.aC)/s.Ro)}),[y]);const G=function(e,t,a,n){const i=(0,o.I4)((e=>{e()}),[]);return(0,o.Ye)((()=>(0,D.P2)(i,a,!n)),[i,a,n])}(0,0,500,B),$=(0,o.I4)((e=>{e.stopPropagation(),h(),a()}),[h,a]),A=(0,o.I4)((e=>{e.stopPropagation(),m({value:!1}),a()}),[m,a]),j=(0,o.I4)((e=>{e.stopPropagation(),a(),r||M(E?s.aC/s.Ro:0),c({participantId:y,value:r?!T:!E})}),[a,c,y,r,T,E]),x=(0,o.I4)((e=>{e.stopPropagation(),u(),p({id:y}),a()}),[u,a,p,y]),L=0===_?R:U;var B;return o.ZP.createElement("div",null,o.ZP.createElement(V.Z,{isOpen:n,positionX:"right",autoClose:!0,style:l?`right: 1rem; top: ${l.y}px;`:void 0,onClose:a,className:"participant-menu"},!k&&!T&&o.ZP.createElement("div",{className:"group"},o.ZP.createElement("div",{className:(0,C.Z)("volume-control",_<50&&"low",_>=50&&_<100&&"medium",_>=100&&_<150&&"normal",_>=150&&"high")},o.ZP.createElement("input",{type:"range",min:"0",max:"200",value:_,onChange:e=>{const t=Number(e.target.value);M(t),G((()=>{0===t?c({participantId:y,value:!0}):d({participantId:y,volume:Math.floor(t*s.Ro)})}))}}),o.ZP.createElement("div",{className:"info"},o.ZP.createElement(N,{name:"Speaker",playSegment:L,size:24}),o.ZP.createElement("span",null,_,"%")))),o.ZP.createElement("div",{className:"group"},I&&k&&o.ZP.createElement(Z.Z,{icon:"stop-raising-hand",onClick:A},v("VoipGroupCancelRaiseHand")),!k&&o.ZP.createElement(Z.Z,{icon:"user",onClick:x},v("VoipGroupOpenProfile")),!k&&o.ZP.createElement(Z.Z,{icon:b&&r?"allow-speak":"microphone-alt",onClick:j},v(r?T?"VoipGroupAllowToSpeak":"VoipMute":E?"VoipGroupUnmuteForMe":"VoipGroupMuteForMe")),!k&&r&&o.ZP.createElement(Z.Z,{icon:"delete-user",destructive:!0,onClick:$},v("VoipGroupUserRemove")))),!k&&r&&o.ZP.createElement(O.Z,{isOpen:g,userId:y,onClose:f}))})));var A=a(7407),j=a(172);const x=(0,o.X$)((e=>{let{participant:t,noColor:a}=e;const{isMuted:i,isMutedByMe:s}=t,l=(t.amplitude||0)>n.THRESHOLD,r=Boolean(t.raiseHandRating),c=(0,I.Z)(r),d=!Boolean(null==t?void 0:t.canSelfUnmute)&&i,u=(0,I.Z)(i),p=(0,o.Ye)((()=>i&&!u?[43,64]:!i&&u?[22,42]:r&&!c?[65,84]:!d&&c?[0,21]:i?[22,23]:[43,44]),[i,d,r]),m=(0,o.Ye)((()=>a?[255,255,255]:r?[77,166,224]:d||s?[255,112,111]:l?[87,188,108]:[132,141,148]),[a,r,d,s,l]);return o.ZP.createElement(N,{name:"VoiceOutlined",playSegment:p,size:28,color:m})})),L=(0,o.X$)((0,i.c$)(((e,t)=>{let{participant:a}=t;return{user:a.isUser?(0,r.dy)(e,a.id):void 0,chat:a.isUser?void 0:(0,r.Z1)(e,a.id)}}))((e=>{let{openParticipantMenu:t,participant:a,user:i,chat:l}=e;const r=(0,o.sO)(null),c=(0,S.Z)(),{isSelf:d,isMutedByMe:u,isMuted:p}=a,m=(a.amplitude||0)>n.THRESHOLD,v=Boolean(a.raiseHandRating),[g,h]=(0,o.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(!i&&!l)return;const f=i?`${i.firstName||""} ${i.lastName||""}`:null==l?void 0:l.title;return o.ZP.createElement("div",{className:(0,C.Z)("GroupCallParticipant",a.canSelfUnmute&&"can-self-unmute"),onClick:()=>{d||t(r.current,a)},ref:r},o.ZP.createElement(j.Z,{user:i,chat:l,size:"medium"}),o.ZP.createElement("div",{className:"info"},o.ZP.createElement("span",{className:"name"},f),o.ZP.createElement("span",{className:(0,C.Z)("about",h)},g)),o.ZP.createElement("div",{className:"microphone"},o.ZP.createElement(x,{participant:a})))})));var B=a(1273);const F=(0,o.X$)((0,i.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:l}=(0,i.Sv)(),r=(0,S.Z)(),c=(0,o.Ye)((()=>Object.keys(t||{})),[t]),[d,u]=(0,A.Z)(l,c,c.length>=a);return o.ZP.createElement("div",{className:"participants"},o.ZP.createElement("div",{className:"invite-btn",onClick:s},o.ZP.createElement("div",{className:"icon"},o.ZP.createElement("i",{className:"icon-add-user"})),o.ZP.createElement("div",{className:"text"},r("VoipGroupInviteMember"))),o.ZP.createElement(B.Z,{items:d,onLoadMore:u},null==d?void 0:d.map((e=>t[e]&&o.ZP.createElement(L,{key:e,openParticipantMenu:n,participant:t[e]})))))}))),H=(0,o.X$)((0,i.c$)(((e,t)=>{let{participant:a}=t;return{currentUserId:e.currentUserId,user:a.isUser?(0,r.dy)(e,a.id):void 0,chat:a.isUser?void 0:(0,r.Z1)(e,a.id),isActive:(a.amplitude||0)>n.THRESHOLD}}))((e=>{let{type:t,onClick:a,user:i,chat:l,isActive:r,isFullscreen:c}=e;const d=(0,S.Z)(),u=(0,o.I4)((()=>{a&&a((null==i?void 0:i.id)||l.id,t)}),[l,a,t,null==i?void 0:i.id]);if(!i&&!l)return;const p=(0,n.getUserStreams)((null==i?void 0:i.id)||l.id);return o.ZP.createElement("div",{className:(0,C.Z)("GroupCallParticipantVideo",r&&"active"),onClick:u},c&&o.ZP.createElement("button",{className:"back-button"},o.ZP.createElement("i",{className:"icon-arrow-left"}),d("Back")),o.ZP.createElement(j.Z,{user:i,chat:l,className:"thumbnail-avatar"}),s.LH&&o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("video",{className:"thumbnail",muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==p?void 0:p[t]})),o.ZP.createElement("video",{className:"video",muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==p?void 0:p[t]}),o.ZP.createElement("div",{className:"info"},o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("span",{className:"name"},(null==i?void 0:i.firstName)||(null==l?void 0:l.title)),"presentation"===t&&o.ZP.createElement("i",{className:"last-icon icon-active-sessions"})))}))),z=(0,o.X$)((0,i.c$)((e=>{const{participants:t}=(0,c.mU)(e)||{};return{participants:t}}))((e=>{let{participants:t,onDoubleClick:a}=e;const[n,i]=(0,o.eJ)(void 0),s=(0,o.Ye)((()=>Object.values(t||{}).filter((e=>e.hasPresentationStream))),[t]),l=(0,o.Ye)((()=>Object.values(t||{}).filter((e=>e.hasVideoStream))),[t]),r=l.length+s.length,c=r<=2?1:r<=6?2:r<=9?3:4,d=3===r||2===c&&r%2!=0,u=(0,o.I4)(((e,t)=>{n&&e===n.id&&t===n.type?i(void 0):i({id:e,type:t})}),[n]);return o.ZP.createElement("div",{className:"streams",onDoubleClick:a},o.ZP.createElement("div",{className:(0,C.Z)("videos",d&&"span-last-video"),style:`--column-count: ${n?1:c}`},n&&o.ZP.createElement(H,{key:n.id,isFullscreen:!0,onClick:u,participant:t[n.id],type:n.type}),n?void 0:s.map((e=>o.ZP.createElement(H,{key:e.id,onClick:u,participant:e,type:"presentation"}))),n?void 0:l.map((e=>o.ZP.createElement(H,{key:e.id,onClick:u,participant:e,type:"video"})))))}))),q=[0,10],X=(0,o.X$)((0,i.c$)(((e,t)=>{let{groupCallId:a}=t;const{connectionState:n,title:o,isSpeakerDisabled:i,participants:s,participantsCount:l}=(0,c.$5)(e,a)||{};return{connectionState:n,title:o,isSpeakerEnabled:!i,participantsCount:l,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:l,title:r,meParticipant:c,isAdmin:d,participants:u}=e;const{toggleGroupCallVideo:p,toggleGroupCallPresentation:m,leaveGroupCall:g,toggleGroupCallPanel:h,connectToActiveGroupCall:f,playGroupCallSound:w}=(0,i.Sv)(),I=(0,S.Z)(),T=(0,o.sO)(null),[_,D]=(0,o.eJ)(!1),[V,O,R]=(0,P.Z)(),[U,A,j]=(0,P.Z)(!0),x=u&&Object.values(u).some((e=>e.video||e.presentation)),L=V&&!v.wB&&x,[B,H]=(0,o.eJ)(),[X,J,Y]=(0,P.Z)(),[W,Q,K]=(0,P.Z)(),[ee,te]=(0,o.eJ)(!1),[ae,ne]=(0,o.eJ)(!1),oe=null==c?void 0:c.hasVideoStream,ie=null==c?void 0:c.hasPresentationStream,se="connected"!==s,le=!(null==c?void 0:c.canSelfUnmute)&&(null==c?void 0:c.isMuted),re=(0,o.I4)(((e,t)=>{const a=e.getBoundingClientRect(),n=T.current;H({anchor:{x:a.left,y:a.top-n.offsetTop+60},participant:t}),J()}),[J]);(0,o.d4)((()=>{"connected"===s?w({sound:"join"}):"reconnecting"===s&&w({sound:"connecting"})}),[s,w]);const ce=(0,o.I4)((()=>{K(),te(!1)}),[K]),de=(0,o.Ye)((()=>e=>{let{onTrigger:t,isOpen:a}=e;return o.ZP.createElement(E.Z,{round:!0,size:"smaller",color:"translucent",className:a?"active":void 0,onClick:t,ariaLabel:I("AccDescrMoreOptions")},o.ZP.createElement("i",{className:"icon-more"}))}),[I]),ue=(0,o.I4)((()=>{T.current&&(V?document.exitFullscreen().then(R):T.current.requestFullscreen().then(O))}),[R,V,O]),pe=(0,o.I4)((()=>{U?j():A()}),[j,U,A]),me=(0,o.I4)((()=>{v.t0&&(V||j(),ue())}),[j,ue,V]),ve=(0,o.I4)((()=>{V?R():O()}),[R,V,O]),ge=(0,o.I4)((()=>{h(),V&&R()}),[R,V,h]);(0,o.d4)((()=>{if(!v.t0)return;const e=T.current;return e?(e.addEventListener("fullscreenchange",ve),()=>{e.removeEventListener("fullscreenchange",ve)}):void 0}),[ve]),(0,o.d4)((()=>{f()}),[f,t]);const he=(0,o.I4)((()=>{te(!0),ne(!0),Q(),V&&ue()}),[ue,V,Q]),fe=(0,o.I4)((()=>{if(d&&!W)return Q(),void(V&&ue());w({sound:"leave"}),D(!0),K()}),[K,ue,d,W,V,Q,w]),Ce=(0,o.I4)((()=>{_&&g({shouldDiscard:ae})}),[_,g,ae]);return o.ZP.createElement(k.Z,{isOpen:!a&&!_,onClose:h,className:(0,C.Z)("GroupCall",v.wB&&"single-column",L&&"landscape",!U&&"no-sidebar"),dialogRef:T,onCloseAnimationEnd:Ce},o.ZP.createElement("div",{className:"header"},o.ZP.createElement("h3",null,r||I("VoipGroupVoiceChat")),v.t0&&o.ZP.createElement(E.Z,{round:!0,size:"smaller",color:"translucent",onClick:ue,ariaLabel:I(V?"AccExitFullscreen":"AccSwitchToFullscreen")},o.ZP.createElement("i",{className:V?"icon-smallscreen":"icon-fullscreen"})),L&&o.ZP.createElement(E.Z,{round:!0,size:"smaller",color:"translucent",onClick:pe},o.ZP.createElement("i",{className:"icon-sidebar"})),(n.IS_SCREENSHARE_SUPPORTED&&!le||d)&&o.ZP.createElement(b.Z,{positionX:"right",trigger:de},n.IS_SCREENSHARE_SUPPORTED&&!le&&o.ZP.createElement(Z.Z,{icon:"share-screen-outlined",onClick:m},I(ie?"VoipChatStopScreenCapture":"VoipChatStartScreenCapture")),d&&o.ZP.createElement(Z.Z,{icon:"phone-discard-outline",onClick:he,destructive:!0},I("VoipGroupLeaveAlertEndChat"))),o.ZP.createElement(E.Z,{round:!0,size:"smaller",color:"translucent",onClick:ge},o.ZP.createElement("i",{className:"icon-close"}))),o.ZP.createElement("div",{className:"scrollable custom-scroll"},o.ZP.createElement(z,{onDoubleClick:me}),(!L||U)&&o.ZP.createElement(F,{openParticipantMenu:re})),o.ZP.createElement($,{participant:null==B?void 0:B.participant,anchor:null==B?void 0:B.anchor,isDropdownOpen:X,closeDropdown:Y}),o.ZP.createElement("div",{className:"buttons"},se&&o.ZP.createElement(y.Z,null),o.ZP.createElement("div",{className:"button-wrapper"},o.ZP.createElement("div",{className:"video-buttons"},oe&&(v.wZ||v.cj)&&o.ZP.createElement("button",{className:"smaller-button",onClick:n.switchCameraInput},o.ZP.createElement(N,{name:"CameraFlip",playSegment:q,size:24})),o.ZP.createElement("button",{className:(0,C.Z)("small-button",le?"speaker":"camera",(oe||le&&l)&&"active"),onClick:()=>{le?(0,n.toggleSpeaker)():p()}},o.ZP.createElement("i",{className:le?"icon-speaker":oe?"icon-video-stop":"icon-video"}))),o.ZP.createElement("div",{className:"button-text"},I(le?"VoipSpeaker":"VoipCamera"))),o.ZP.createElement(M,null),o.ZP.createElement("div",{className:"button-wrapper"},o.ZP.createElement("button",{className:"small-button leave",onClick:fe},o.ZP.createElement("i",{className:"icon-phone-discard"})),o.ZP.createElement("div",{className:"button-text"},I("VoipGroupLeave")))),o.ZP.createElement(k.Z,{isOpen:W,onClose:ce,className:"error",title:I(ee?"VoipGroupEndAlertTitle":"VoipGroupLeaveAlertTitle")},o.ZP.createElement("p",null,I(ee?"VoipGroupEndAlertText":"VoipGroupLeaveAlertText")),!ee&&o.ZP.createElement(G.Z,{label:I("VoipGroupEndChat"),checked:ae,onCheck:ne}),o.ZP.createElement(E.Z,{isText:!0,className:"confirm-dialog-button",onClick:fe},I(ee?"VoipGroupEnd":"VoipGroupLeave")),o.ZP.createElement(E.Z,{isText:!0,className:"confirm-dialog-button",onClick:ce},I("Cancel"))))}))),J=(0,o.X$)((0,i.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,i.Sv)(),l=(0,S.Z)();if((0,o.d4)((()=>(document.body.classList.toggle("has-call-header",Boolean(n)),()=>{document.body.classList.toggle("has-call-header",!1)})),[n]),t||a)return o.ZP.createElement("div",{className:(0,C.Z)("ActiveCallHeader",n&&"open"),onClick:s},o.ZP.createElement("span",{className:"title"},(null==a?void 0:a.firstName)||(null==t?void 0:t.title)||l("VoipGroupVoiceChat")))})));var Y=a(2340),W=a(790),Q=a(2357),K=a(5326);const ee=(0,o.X$)((e=>{let{onClick:t,label:a,customIcon:n,icon:i,iconClassName:s,className:l,isDisabled:r,isActive:c}=e;return o.ZP.createElement("div",{className:"src-components-calls-phone-PhoneCallButton-module__root"},o.ZP.createElement(E.Z,{round:!0,className:(0,C.Z)(l,"src-components-calls-phone-PhoneCallButton-module__button",c&&"src-components-calls-phone-PhoneCallButton-module__active"),onClick:t,disabled:r},n||o.ZP.createElement("i",{className:(0,C.Z)(s,`icon-${i}`)})),o.ZP.createElement("div",{className:"src-components-calls-phone-PhoneCallButton-module__button-text"},a))})),te={root:"src-components-calls-phone-PhoneCall-module__root",blurred:"src-components-calls-phone-PhoneCall-module__blurred","single-column":"src-components-calls-phone-PhoneCall-module__single-column",singleColumn:"src-components-calls-phone-PhoneCall-module__single-column",header:"src-components-calls-phone-PhoneCall-module__header","close-button":"src-components-calls-phone-PhoneCall-module__close-button",closeButton:"src-components-calls-phone-PhoneCall-module__close-button","emojis-backdrop":"src-components-calls-phone-PhoneCall-module__emojis-backdrop",emojisBackdrop:"src-components-calls-phone-PhoneCall-module__emojis-backdrop",open:"src-components-calls-phone-PhoneCall-module__open",emojis:"src-components-calls-phone-PhoneCall-module__emojis","emoji-tooltip":"src-components-calls-phone-PhoneCall-module__emoji-tooltip",emojiTooltip:"src-components-calls-phone-PhoneCall-module__emoji-tooltip","user-info":"src-components-calls-phone-PhoneCall-module__user-info",userInfo:"src-components-calls-phone-PhoneCall-module__user-info",buttons:"src-components-calls-phone-PhoneCall-module__buttons",leave:"src-components-calls-phone-PhoneCall-module__leave",accept:"src-components-calls-phone-PhoneCall-module__accept","accept-icon":"src-components-calls-phone-PhoneCall-module__accept-icon",acceptIcon:"src-components-calls-phone-PhoneCall-module__accept-icon","main-video":"src-components-calls-phone-PhoneCall-module__main-video",mainVideo:"src-components-calls-phone-PhoneCall-module__main-video","second-video":"src-components-calls-phone-PhoneCall-module__second-video",secondVideo:"src-components-calls-phone-PhoneCall-module__second-video",visible:"src-components-calls-phone-PhoneCall-module__visible",fullscreen:"src-components-calls-phone-PhoneCall-module__fullscreen"},ae=(0,o.X$)((0,i.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}}))((e=>{var t,a,s;let{user:l,isOutgoing:r,phoneCall:c,isCallPanelVisible:d}=e;const u=(0,S.Z)(),{hangUp:p,acceptCall:m,playGroupCallSound:g,toggleGroupCallPanel:h,connectToActivePhoneCall:f}=(0,i.Sv)(),y=(0,o.sO)(null),[b,Z,w]=(0,P.Z)(),I=(0,o.I4)((()=>{b?w():Z()}),[w,b,Z]),T=(0,o.I4)((()=>{y.current&&(b?document.exitFullscreen().then(w):y.current.requestFullscreen().then(Z))}),[w,b,Z]);(0,o.d4)((()=>{if(!v.t0)return;const e=y.current;return e?(e.addEventListener("fullscreenchange",I),()=>{e.removeEventListener("fullscreenchange",I)}):void 0}),[I]);const _=(0,o.I4)((()=>{h(),b&&w()}),[w,b,h]),M="discarded"===(null==c?void 0:c.state),G="busy"===(null==c?void 0:c.reason),D="requested"===(null==c?void 0:c.state)&&!r,V=("requested"===(null==c?void 0:c.state)||"waiting"===(null==c?void 0:c.state))&&r,O="active"===(null==c?void 0:c.state),R=null==c?void 0:c.isConnected;(0,o.d4)((()=>{D?g({sound:"incoming"}):G?g({sound:"busy"}):M?g({sound:"end"}):V?g({sound:"ringing"}):R&&g({sound:"connect"})}),[G,M,D,V,R,g]);const[U,$,A]=(0,P.Z)(),x=(0,o.I4)((()=>{$(),p()}),[p,$]);(0,o.d4)((()=>{null!=c&&c.id?A():f()}),[f,null==c?void 0:c.id,A]);const L=(0,K.Z)();(0,Q.Z)((()=>{L()}),R?1e3:void 0);const B=(0,o.Ye)((()=>{const e=null==c?void 0:c.state;return U?u("lng_call_status_hanging"):G?"busy":"requesting"===e?u("lng_call_status_requesting"):"requested"===e?u(r?"lng_call_status_ringing":"lng_call_status_incoming"):"waiting"===e?u("lng_call_status_waiting"):"active"===e&&R?void 0:u("lng_call_status_exchanging")}),[G,R,U,r,u,null==c?void 0:c.state]),F="active"===(null==c?void 0:c.videoState),H="active"===(null==c?void 0:c.screencastState),z=(0,n.getStreams)(),q=null==z||null===(t=z.ownAudio)||void 0===t?void 0:t.getTracks()[0].enabled,X=null==z||null===(a=z.ownPresentation)||void 0===a?void 0:a.getTracks()[0].enabled,J=null==z||null===(s=z.ownVideo)||void 0===s?void 0:s.getTracks()[0].enabled,[ae,ne,oe]=(0,P.Z)(),[ie,se,le]=(0,P.Z)(),re=(0,o.I4)((()=>{X&&ne(),J&&se(),setTimeout((async()=>{await(0,n.toggleStreamP2p)("presentation"),oe(),le()}),250)}),[X,J,ne,se,oe,le]),ce=(0,o.I4)((()=>{J&&se(),X&&ne(),setTimeout((async()=>{await(0,n.toggleStreamP2p)("video"),oe(),le()}),250)}),[X,J,ne,se,oe,le]),de=(0,o.I4)((()=>{(0,n.toggleStreamP2p)("audio")}),[]),[ue,pe,me]=(0,P.Z)(),[ve,ge,he]=(0,P.Z)(),fe=(0,o.I4)((()=>{ge(),(0,n.switchCameraInputP2p)(),setTimeout(he,250)}),[ge,he]),Ce=(null==c?void 0:c.startDate)&&Number(new Date)/1e3-c.startDate;return(0,o.d4)((()=>{"discarded"===(null==c?void 0:c.state)&&setTimeout(p,250)}),[p,null==c?void 0:c.reason,null==c?void 0:c.state]),o.ZP.createElement(k.Z,{isOpen:c&&"discarded"!==(null==c?void 0:c.state)&&!d,onClose:_,className:(0,C.Z)(te.root,v.wB&&te.singleColumn),dialogRef:y},o.ZP.createElement(j.Z,{user:l,size:"jumbo",className:F||H?te.blurred:""}),"active"===(null==c?void 0:c.screencastState)&&(null==z?void 0:z.presentation)&&o.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)&&o.ZP.createElement("video",{className:te.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:z.video}),o.ZP.createElement("video",{className:(0,C.Z)(te.secondVideo,!ae&&X&&te.visible,b&&te.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==z?void 0:z.ownPresentation}),o.ZP.createElement("video",{className:(0,C.Z)(te.secondVideo,!ie&&J&&te.visible,b&&te.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:null==z?void 0:z.ownVideo}),o.ZP.createElement("div",{className:te.header},v.t0&&o.ZP.createElement(E.Z,{round:!0,size:"smaller",color:"translucent",onClick:T,ariaLabel:u(b?"AccExitFullscreen":"AccSwitchToFullscreen")},o.ZP.createElement("i",{className:b?"icon-smallscreen":"icon-fullscreen"})),o.ZP.createElement(E.Z,{round:!0,size:"smaller",color:"translucent",onClick:_,className:te.closeButton},o.ZP.createElement("i",{className:"icon-close"}))),o.ZP.createElement("div",{className:(0,C.Z)(te.emojisBackdrop,ue&&te.open),onClick:ue?me:pe},o.ZP.createElement("div",{className:(0,C.Z)(te.emojis,ue&&te.open)},(null==c?void 0:c.isConnected)&&(null==c?void 0:c.emojis)&&(0,Y.Z)(c.emojis,["emoji"])),o.ZP.createElement("div",{className:(0,C.Z)(te.emojiTooltip,ue&&te.open)},u("CallEmojiKeyTooltip",null==l?void 0:l.firstName).replace("%%","%"))),o.ZP.createElement("div",{className:te.userInfo},o.ZP.createElement("h1",null,null==l?void 0:l.firstName),o.ZP.createElement("span",{className:te.status},B||(0,W.k9)(Ce||0))),o.ZP.createElement("div",{className:te.buttons},o.ZP.createElement(ee,{onClick:de,icon:"microphone",isDisabled:!O,isActive:q,label:u(q?"lng_call_mute_audio":"lng_call_unmute_audio")}),o.ZP.createElement(ee,{onClick:ce,icon:"video",isDisabled:!O,isActive:J,label:u(J?"lng_call_stop_video":"lng_call_start_video")}),J&&(v.wZ||v.cj)&&o.ZP.createElement(ee,{onClick:fe,customIcon:o.ZP.createElement(N,{name:"CameraFlip",playSegment:ve?[0,10]:[0,1],size:32}),isDisabled:!O,label:u("VoipFlip")}),n.IS_SCREENSHARE_SUPPORTED&&o.ZP.createElement(ee,{onClick:re,icon:"share-screen",isDisabled:!O,isActive:X,label:u("lng_call_screencast")}),D&&o.ZP.createElement(ee,{onClick:m,icon:"phone-discard",isDisabled:M,label:u("lng_call_accept"),className:te.accept,iconClassName:te.acceptIcon}),o.ZP.createElement(ee,{onClick:x,icon:"phone-discard",isDisabled:M,label:u(D?"lng_call_decline":"lng_call_end_call"),className:te.leave})))})));var ne=a(7687);const oe=(0,o.X$)((e=>{let{isOpen:t}=e;const{closeCallRatingModal:a,setCallRating:n}=(0,i.Sv)(),s=(0,o.sO)(null),l=(0,S.Z)(),[r,c]=(0,o.eJ)();return o.ZP.createElement(k.Z,{title:l("lng_call_rate_label"),className:"narrow",onClose:a,isOpen:t},o.ZP.createElement("div",{className:"src-components-calls-phone-RatePhoneCallModal-module__stars"},new Array(5).fill(void 0).map(((e,t)=>{const a=void 0!==r&&r>=t;return o.ZP.createElement("i",{className:(0,C.Z)(a?"icon-favorite-filled":"icon-favorite",a&&"src-components-calls-phone-RatePhoneCallModal-module__isFilled","src-components-calls-phone-RatePhoneCallModal-module__star"),onClick:(n=t,()=>c(r===n?void 0:n))});var n}))),o.ZP.createElement(ne.Z,{ref:s,placeholder:l("lng_call_rate_comment"),className:(0,C.Z)("src-components-calls-phone-RatePhoneCallModal-module__comment",4!==r&&void 0!==r&&"src-components-calls-phone-RatePhoneCallModal-module__visible")}),o.ZP.createElement(E.Z,{className:"confirm-dialog-button",isText:!0,onClick:function(){var e;r?n({rating:r+1,comment:(null===(e=s.current)||void 0===e?void 0:e.value)||""}):a()}},l("Send")),o.ZP.createElement(E.Z,{className:"confirm-dialog-button",isText:!0,onClick:a},l("Cancel")))}))},3794:(e,t)=>{(()=>{"use strict";var e={"./src/blacksilence.ts":(e,t,a)=>{a.r(t),a.d(t,{silence:()=>n,black:()=>o});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})])},o=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 o=a.captureStream();return new MediaStream([Object.assign(o.getVideoTracks()[0],{enabled:!1})])}},"./src/buildSdp.ts":(e,t,a)=>{a.r(t),a.d(t,{default:()=>o});var n=a("./src/utils.ts");const o=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=[],s=e=>{i.push(e)},{sessionId:l,ssrcs:r,audioExtensions:c,videoExtensions:d,audioPayloadTypes:u,videoPayloadTypes:p,transport:{ufrag:m,pwd:v,fingerprints:g,candidates:h}}=e;s("v=0"),s(`o=- ${l} 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 ${r.map((e=>e.endpoint)).join(" ")}${a?"":" "+(o?"3":"2")}`),o||s("a=ice-lite");const f=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)}},C=()=>{s(`a=ice-ufrag:${m}`),s(`a=ice-pwd:${v}`),g.forEach((e=>{s(`a=fingerprint:${e.hash} ${e.fingerprint}`),s(`a=setup:${o?e.setup:"passive"}`)})),h.forEach(f)},P=e=>{var t;const{channels:a,id:n,name:o,clockrate:i,parameters:l}=e;var r=a?`/${a}`:"";s(`a=rtpmap:${n} ${o}/${i}${r}`),l&&(r=Object.keys(l).map((e=>`${e}=${l[e]};`)).join(" "),s(`a=fmtp:${n} ${r}`)),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 i=e.isVideo?"video":"audio";if(s(`m=${i} ${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(C(),o)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}`)}))}))}},o?r.filter(e):r.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"),C(),s("a=ice-options:trickle"),s("a=mid:"+(o?"3":a?"1":"2")),s("a=sctp-port:5000"),s("a=max-message-size:262144")),o||r.filter((e=>"0"!==e.endpoint&&"1"!==e.endpoint)).map(e),`${i.join("\n")}\n`}},"./src/p2p.ts":(e,t,a)=>{a.r(t),a.d(t,{getStreams:()=>function(){var e;return null===(e=l)||void 0===e?void 0:e.streams},switchCameraInputP2p:()=>async function(){if(l&&l.facingMode){const e=l.streams.ownVideo;if(e){const t=e.getTracks()[0];if(t){const e=l.connection.getSenders().find((e=>{var a;return t.id===(null===(a=e.track)||void 0===a?void 0:a.id)}));if(e){l.facingMode="environment"===l.facingMode?"user":"environment";try{const t=await c("video",l.facingMode);await e.replaceTrack(t.getTracks()[0]),l.streams.ownVideo=t,r()}catch(e){}}}}}},toggleStreamP2p:()=>d,joinPhoneCall:()=>async function(e,t,a,i,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;l&&(t=e.streams[0],"audio"===e.track.kind?(l.audio.srcObject=t,l.audio.play().catch(),l.streams.audio=t):"1"===e.transceiver.mid?l.streams.video=t:l.streams.presentation=t,r())};const h=c.createDataChannel("data",{id:0,negotiated:!0});h.onmessage=e=>{v(JSON.parse(e.data))},e=new Audio,l={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:h};try{i&&d("video",!0),d("audio",!0)}catch(e){}a&&(a=await c.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),await c.setLocalDescription(a),m((0,o.default)(a,!0)))},stopPhoneCall:()=>function(){var e,t,a;l&&(null!==(e=l.streams.ownVideo)&&void 0!==e&&e.getTracks().forEach((e=>e.stop())),null!==(t=l.streams.ownPresentation)&&void 0!==t&&t.getTracks().forEach((e=>e.stop())),null!==(a=l.streams.ownAudio)&&void 0!==a&&a.getTracks().forEach((e=>e.stop())),l.dataChannel.close(),l.connection.close(),l=void 0)},processSignalingMessage:()=>v});var n=a("./src/blacksilence.ts"),o=a("./src/parseSdp.ts"),i=a("./src/utils.ts"),s=a("./src/buildSdp.ts");let l;function r(){var e;null===(e=l)||void 0===e||e.onUpdate({...l.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&&{...i.IS_ECHO_CANCELLATION_SUPPORTED&&{echoCancellation:!0},...i.IS_NOISE_SUPPRESSION_SUPPORTED&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}})}async function d(e,t){if(l){const a="audio"===e?l.streams.ownAudio:"video"===e?l.streams.ownVideo:l.streams.ownPresentation;if(a){const n=a.getTracks()[0];if(n){const a=l.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?l.streams.ownAudio=t:"video"===e?(l.streams.ownVideo=t,l.facingMode="user"):l.streams.ownPresentation=t,"video"!==e&&"presentation"!==e||d("video"===e?"presentation":"video",!1)}else if(!t&&n.enabled){n.stop();const t="audio"===e?l.silence:"video"===e?l.blackVideo:l.blackPresentation;if(!t)return;await a.replaceTrack(t.getTracks()[0]),"audio"===e?l.streams.ownAudio=t:"video"===e?l.streams.ownVideo=t:l.streams.ownPresentation=t}r(),u()}catch(e){}}}}}}function u(){if(l){var e,t,a;const{emitSignalingData:n,streams:o}=l;n({"@type":"MediaState",videoRotation:0,isMuted:!(null!==(e=o.ownAudio)&&void 0!==e&&e.getTracks()[0].enabled),isBatteryLow:!0,videoState:null!==(t=o.ownVideo)&&void 0!==t&&t.getTracks()[0].enabled?"active":"inactive",screencastState:null!==(a=o.ownPresentation)&&void 0!==a&&a.getTracks()[0].enabled?"active":"inactive"})}}function p(e){if(!l||l.isOutgoing)return e;const t=e.payloadTypes;var a=t.findIndex((e=>"VP8"===e.name));const n=t[a];var o=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[o]],e}function m(e){if(l){const t=l.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,i.fromTelegramSource)(e.ssrc).toString(),ssrcGroups:[],payloadTypes:e.audioPayloadTypes,rtpExtensions:e.audioExtmap},video:p({ssrc:(0,i.fromTelegramSource)(e["ssrc-groups"][0].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][0].semantics,ssrcs:e["ssrc-groups"][0].sources.map(i.fromTelegramSource)}],payloadTypes:e.videoPayloadTypes,rtpExtensions:e.videoExtmap}),screencast:p({ssrc:(0,i.fromTelegramSource)(e["ssrc-groups"][1].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][1].semantics,ssrcs:e["ssrc-groups"][1].sources.map(i.fromTelegramSource)}],payloadTypes:e.screencastPayloadTypes,rtpExtensions:e.screencastExtmap})})}}async function v(e){if(l&&l.connection)switch(e["@type"]){case"MediaState":l.mediaState=e,r(),u();break;case"Candidates":var{candidates:t,gotInitialSetup:a}=l;if(!t)return;e.candidates.forEach((e=>{l.candidates.push(e.sdpString)})),a&&await Promise.all(l.candidates.map((e=>l.connection.addIceCandidate({candidate:e,sdpMLineIndex:0}))));break;case"InitialSetup":{var n,c;const{connection:t,isOutgoing:r}=l;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(i.p2pPayloadTypeToConference))||[],audioExtensions:e.audio.rtpExtensions,videoPayloadTypes:(null===(c=p(e.video).payloadTypes)||void 0===c?void 0:c.map(i.p2pPayloadTypeToConference))||[],videoExtensions:e.video.rtpExtensions},await t.setRemoteDescription({sdp:(0,s.default)(a,r,void 0,!0),type:r?"answer":"offer"}),l.conference=a,!r){if(a=await t.createAnswer(),!a)return;await t.setLocalDescription(a),m((0,o.default)(a,!0))}l.gotInitialSetup=!0,await Promise.all(l.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:()=>o});var n=a("./src/utils.ts");const o=function(e){var t,a,o;let i=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 l=(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]},r=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,o,e]=a.split("/");return{id:Number(t),name:n,clockrate:Number(o),...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)),{}),o=a.filter((t=>t.id===e.id)).map((e=>({type:e.type,subtype:e.subtype})));return{...e,...0{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;l&&(l.isSpeakerDisabled=!l.isSpeakerDisabled,null!==(e=l)&&void 0!==e&&null!==(t=e.onUpdate)&&void 0!==t&&t.call(e,{"@type":"updateGroupCallConnectionState",connectionState:"connected",isSpeakerDisabled:l.isSpeakerDisabled}),l.participantFunctions&&Object.values(l.participantFunctions).forEach((e=>{var t,a;null===(t=e.toggleMute)||void 0===t||t.call(e,!(null===(a=l)||void 0===a||!a.isSpeakerDisabled))})))},toggleNoiseSuppression:()=>function(){if(l&&l.myId&&l.streams){const a=l.streams[l.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,o;const i=null===(a=l)||void 0===a||null===(n=a.participantFunctions)||void 0===n?void 0:n[e];i&&(null===(o=i.setVolume)||void 0===o||o.call(i,t))},isStreamEnabled:()=>d,switchCameraInput:()=>async function(){var e;if(null!==(e=l)&&void 0!==e&&e.myId&&l.connection&&l.streams&&l.facingMode){var t;const e=null===(t=c(l.myId))||void 0===t?void 0:t.video;if(e){const t=e.getTracks()[0];if(t){const e=l.connection.getSenders().find((e=>{var a;return t.id===(null===(a=e.track)||void 0===a?void 0:a.id)}));if(e){l.facingMode="environment"===l.facingMode?"user":"environment";try{const t=await p("video",l.facingMode);await e.replaceTrack(t.getTracks()[0]),l.streams[l.myId].video=t}catch(e){}}}}}},toggleStream:()=>m,leaveGroupCall:()=>g,handleUpdateGroupCallParticipants:()=>async function(e){if(l){const{participants:n,conference:i,connection:s,myId:r}=l;if(n&&i&&s&&i.ssrcs&&i.transport&&r)if(e.find((e=>{var t,a,n,o;return e.isSelf&&e.source!==(null===(t=l)||void 0===t||null===(a=t.conference)||void 0===a||null===(n=a.ssrcs)||void 0===n||null===(o=n.find((e=>e.isMain&&!e.isVideo)))||void 0===o?void 0:o.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,o=!e.isVideoJoined||!e.video||t,s=!e.presentation||t;let l=!1,r=!1,c=!1;i.ssrcs.filter((t=>t.userId===e.id)).forEach((t=>{t.isVideo||(t.sourceGroups[0].sources[0]===e.source&&(r=!0),t.isRemoved=a),t.isVideo&&(t.isPresentation||(e.video&&t.endpoint===e.video.endpoint&&(l=!0),t.isRemoved=o),t.isPresentation&&(e.presentation&&t.endpoint===e.presentation.endpoint&&(c=!0),t.isRemoved=s))})),a||r||i.ssrcs.push({userId:e.id,isMain:!1,endpoint:`audio${e.source}`,isVideo:!1,sourceGroups:[{semantics:"FID",sources:[e.source]}]}),o||l||!e.video||(n.push(e.video.endpoint),i.ssrcs.push({userId:e.id,isMain:!1,endpoint:e.video.endpoint,isVideo:!0,sourceGroups:e.video.sourceGroups})),s||c||!e.presentation||i.ssrcs.push({isPresentation:!0,userId:e.id,isMain:!1,endpoint:e.presentation.endpoint,isVideo:!0,sourceGroups:e.presentation.sourceGroups})}})),l.updatingParticipantsQueue)l.updatingParticipantsQueue.push(i);else{l.updatingParticipantsQueue=[],e=(0,o.default)(i),await s.setRemoteDescription({type:"offer",sdp:e});try{var t=await s.createAnswer();if(await s.setLocalDescription(t),u(r),0async function(e,t){if(l){var a=t?l.screenshareConference:l.conference;const d=t?l.screenshareConnection:l.connection;if(a&&d&&a.ssrcs){var n,i,s,r,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===(i=e.audio)||void 0===i?void 0:i["payload-types"],videoExtensions:null===(s=e.video)||void 0===s?void 0:s["rtp-hdrexts"],videoPayloadTypes:null===(r=e.video)||void 0===r?void 0:r["payload-types"]},l={...l,...t?{screenshareConference:e}:{conference:e}};try{await d.setRemoteDescription({type:"answer",sdp:(0,o.default)(e,!0,t)})}catch(e){console.error(e)}}}},startSharingScreen:()=>async function(){if(l)try{const e=await p("presentation");return e?(e.getTracks()[0].onended=()=>{var e;l&&l.myId&&(null!==(e=l.streams)&&void 0!==e&&e[l.myId].presentation,u(l.myId),r())},new Promise((t=>{var{connection:a,dataChannel:t}=C([e],t,!0);l={...l,screenshareConnection:a,screenshareDataChannel:t}}))):void 0}catch(e){return}},joinGroupCall:()=>function(e,t,a,n){if(l)throw Error("Already in call");v("connecting");var o=new MediaStream;return a.srcObject=o,a.play().catch((e=>console.warn(e))),l={onUpdate:n,participants:[],myId:e,speaking:{},silence:(0,i.silence)(t),black:(0,i.black)({width:640,height:480}),analyserInterval:setInterval(h,1e3),audioElement:a,audioContext:t,mediaStream:o},new Promise((e=>{l={...l,...C([l.silence,l.black],e)}}))}});var n=a("./src/parseSdp.ts"),o=a("./src/buildSdp.ts"),i=a("./src/blacksilence.ts"),s=a("./src/utils.ts");let l;function r(e){var t,a,n,o;l&&(null!==(t=l.screenshareDataChannel)&&void 0!==t&&t.close(),null!==(a=l.screenshareConnection)&&void 0!==a&&a.close(),e||null===(n=(o=l).onUpdate)||void 0===n||n.call(o,{"@type":"updateGroupCallLeavePresentation"}))}function c(e){var t,a;return null===(t=l)||void 0===t||null===(a=t.streams)||void 0===a?void 0:a[e]}function d(e,t){var a,n,o;const i=(t=t||(null===(a=l)||void 0===a?void 0:a.myId))&&(null===(n=c(t))||void 0===n?void 0:n[e]);return!!i&&(null===(o=i.getTracks()[0])||void 0===o?void 0:o.enabled)}function u(e){var t,a,n;null===(t=l)||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=l.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(l&&l.myId&&l.connection&&l.streams){var a;const i=null===(a=c(l.myId))||void 0===a?void 0:a[e];if(i){const a=i.getTracks()[0];if(a){var n;const i=[...l.connection.getSenders(),...(null===(n=l.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(i){t=void 0===t?!a.enabled:t;try{if(t&&!a.enabled){const t=await p(e);if(await i.replaceTrack(t.getTracks()[0]),l.streams[l.myId][e]=t,"video"===e)l.facingMode="user";else if("audio"===e){var o;const e=l.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),l={...l,participantFunctions:{...l.participantFunctions,[l.myId]:{...null===(o=l.participantFunctions)||void 0===o?void 0:o[l.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?l.silence:l.black;if(!t)return;await i.replaceTrack(t.getTracks()[0]),l.streams[l.myId][e]=t,"video"===e&&(l.facingMode=void 0)}u(l.myId),"presentation"!==e||t||r(!0)}catch(e){}}}}}}function v(e){var t,a;null===(t=l)||void 0===t||null===(a=t.onUpdate)||void 0===a||a.call(t,{"@type":"updateGroupCallConnectionState",connectionState:e})}function g(){var e,t,a;l&&(l.myId&&null!==(e=l.streams)&&void 0!==e&&e[l.myId]&&Object.values(l.streams[l.myId]||{}).forEach((e=>{null==e||e.getTracks().forEach((e=>{e.stop()}))})),r(!0),null!==(t=l.dataChannel)&&void 0!==t&&t.close(),null!==(a=l.connection)&&void 0!==a&&a.close(),v("disconnected"),l.analyserInterval&&clearInterval(l.analyserInterval),l=void 0)}function h(){l&&l.participantFunctions&&Object.keys(l.participantFunctions).forEach((e=>{const t=l.participantFunctions[Number(e)].getCurrentAmplitude;var a,n;t&&(a=t(),n=l.speaking[e]||0,((l.speaking[e]=a)>s.THRESHOLD&&n<=s.THRESHOLD||a<=s.THRESHOLD&&n>s.THRESHOLD)&&u(e))}))}function f(e){if(l&&l.audioElement&&l.audioContext&&l.mediaStream){var t,a,n=null===(t=l.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 o,i;const{userId:t,isPresentation:a}=n;var r=null===(o=l.participants)||void 0===o?void 0:o.find((e=>e.id===t));const d="video"===e.track.kind?a?"presentation":"video":"audio";if(e.track.onended=()=>{var e,a;null!==(e=l)&&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=l.mediaStream,a=new window.AudioContext,o=a.createMediaStreamSource(n),i=a.createGain();i.gain.value=((null==r?void 0:r.volume)||1e4)/1e4;const d=a.createGain();i.gain.value=1;const u=a.createAnalyser();u.minDecibels=-100,u.maxDecibels=-30,u.smoothingTimeConstant=.05,u.fftSize=1024,o.connect(u).connect(d).connect(i).connect(a.destination),e.addTrack(o.mediaStream.getAudioTracks()[0]);const p=new Audio;p.srcObject=n,p.muted=!0,p.remove(),l={...l,participantFunctions:{...l.participantFunctions,[t]:{...null===(c=l.participantFunctions)||void 0===c?void 0:c[t],setVolume:e=>{i.gain.value=1{d.gain.value=e?0:1},getCurrentAmplitude:()=>{var e=new Uint8Array(u.frequencyBinCount);return u.getByteFrequencyData(e),(0,s.getAmplitude)(e,1.5)}}}}}l={...l,streams:{...l.streams,[t]:{...null===(i=l.streams)||void 0===i?void 0:i[t],[d]:n}}},u(t)}}}function C(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=new RTCPeerConnection;var i=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}(o);return e.forEach((e=>e.getTracks().forEach((t=>{o.addTrack(t,e)})))),a||(o.oniceconnectionstatechange=()=>{var e=o.iceConnectionState;"connected"===e||"completed"===e?v("connected"):"checking"===e||"new"===e?v("connecting"):"disconnected"===o.iceConnectionState&&v("reconnecting")}),o.ontrack=f,o.onnegotiationneeded=async()=>{if(l){var i=l.myId;if(i){var s=await o.createOffer({offerToReceiveVideo:!0,offerToReceiveAudio:!a});if(await o.setLocalDescription(s),s.sdp){var r,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?l.screenshareConference:l.conference;const o=[];a?(p&&o.push(p),d&&o.push(d)):(d&&o.push(d),p&&o.push(p)),d=e.find((e=>"audio"===e.getTracks()[0].kind)),p=e.find((e=>"video"===e.getTracks()[0].kind)),l={...l,...a?{screenshareConference:{...s,ssrcs:o}}:{conference:{...s,ssrcs:o}},streams:{...l.streams,[i]:{...null===(r=l.streams)||void 0===r?void 0:r[i],...d&&{audio:d},...!a&&p?{video:p}:{presentation:p}}}},u(i),t(c)}}}},{connection:o,dataChannel:i}}},"./src/types.ts":(e,t,a)=>{a.r(t)},"./src/utils.ts":(e,t,a)=>{var n,o,i,s,l;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;tfunction(e){return{id:e.id,name:e.name,"rtcp-fbs":e.feedbackTypes,clockrate:e.clockrate,parameters:e.parameters,channels:e.channels}},THRESHOLD:()=>r,IS_SCREENSHARE_SUPPORTED:()=>c,IS_ECHO_CANCELLATION_SUPPORTED:()=>d,IS_NOISE_SUPPRESSION_SUPPORTED:()=>u});const r=.1,c="getDisplayMedia"in((null===(n=navigator)||void 0===n?void 0:n.mediaDevices)||{}),d=null===(o=navigator)||void 0===o||null===(i=o.mediaDevices)||void 0===i?void 0:i.getSupportedConstraints().echoCancellation,u=null===(s=navigator)||void 0===s||null===(l=s.mediaDevices)||void 0===l?void 0:l.getSupportedConstraints().noiseSuppression}},a={};function n(t){var o=a[t];return void 0!==o||(o=a[t]={exports:{}},e[t](o,o.exports,n)),o.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 o={};(()=>{n.r(o),n.d(o,{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 i,s=t;for(i in o)s[i]=o[i];o.__esModule&&Object.defineProperty(s,"__esModule",{value:!0})})()}}]); //# sourceMappingURL=272.b66fb5dcb068235ba702.js.map