2 lines
25 KiB
JavaScript
2 lines
25 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[970],{2275:(t,e,a)=>{a.d(e,{Z:()=>h});var n=a(4050),s=a(3555),o=a(1192),i=a(5806),r=a(2340),d=a(9107),c=a(3103),l=a(231);const h=(0,n.X$)((0,s.c$)(((t,e)=>{let{userId:a}=e;const n=(0,o.jr)(t),s=a&&(0,o.dy)(t,a);return{chat:n,contactName:s?(0,i.Vl)(s):void 0}}))((t=>{let{isOpen:e,chat:a,userId:o,contactName:i,onClose:h}=t;const{deleteChatMember:u}=(0,s.Sv)(),f=(0,d.Z)(),p=(0,n.I4)((()=>{u({chatId:a.id,userId:o}),h()}),[a,u,h,o]);if(a&&o)return n.ZP.createElement(c.Z,{isOpen:e,onClose:h,onEnter:p,className:"delete",title:f("GroupRemoved.Remove")},n.ZP.createElement("p",null,(0,r.Z)(f("PeerInfo.Confirm.RemovePeer",i))),n.ZP.createElement(l.Z,{color:"danger",className:"confirm-dialog-button",isText:!0,onClick:p},f("lng_box_remove")),n.ZP.createElement(l.Z,{className:"confirm-dialog-button",isText:!0,onClick:h},f("Cancel")))})))},7225:(t,e,a)=>{a.d(e,{Co:()=>b,ft:()=>y});var n=a(3555),s=a(6137),o=a(1713),i=a(3716),r=a(1226),d=a(5406),c=a(1192),l=a(782),h=a(9118),u=a(5806),f=a(3551),p=a(8958),C=a(2431),m=a(6974),I=a(711);const g=(0,h.P2)((t=>t()),3e3,!0),v=(0,h.Ds)((t=>t()),500,!1,!0);async function w(t,e,a){var o;let h=arguments.length>3&&void 0!==arguments[3]&&arguments[3],u=(0,n.Rd)();const f=await(0,r.t9)("fetchChats",{limit:i.Ov,offsetDate:a,archived:"archived"===t,withPinned:h,serverTimeOffset:u.serverTimeOffset,lastLocalServiceMessage:null===(o=(0,c.VF)(u))||void 0===o?void 0:o.message});if(!f)return;const{chatIds:p}=f;if(p.length>0&&p[0]===e&&p.shift(),u=(0,n.Rd)(),h&&"active"===t){const e=(0,c.jr)(u),a=e?[e]:[],n=(0,c.P2)(u)||[];u.currentUserId&&u.users.byId[u.currentUserId]&&n.push(u.users.byId[u.currentUserId]),u=(0,d.s5)(u,(0,l.ee)(n.concat(f.users),"id")),u=(0,d.ps)(u,f.userStatusesById),u=(0,d.SL)(u,(0,l.ee)(a.concat(f.chats),"id")),u=(0,d.Mg)(u,t,p)}else h&&"archived"===t?(u=(0,d.Sh)(u,(0,l.ee)(f.users,"id")),u=(0,d.zn)(u,f.userStatusesById),u=(0,d.GL)(u,(0,l.ee)(f.chats,"id")),u=(0,d.Mg)(u,t,p)):(u=(0,d.Sh)(u,(0,l.ee)(f.users,"id")),u=(0,d.zn)(u,f.userStatusesById),u=(0,d.GL)(u,(0,l.ee)(f.chats,"id")),u=(0,d.B1)(u,t,p));u=(0,d.vv)(u,t,f),Object.keys(f.draftsById).forEach((t=>{u=(0,d.pf)(u,t,s._f,"draft",f.draftsById[t])})),Object.keys(f.replyingToById).forEach((t=>{u=(0,d.pf)(u,t,s._f,"replyingToId",f.replyingToById[t])})),0!==p.length||u.chats.isFullyLoaded[t]||(u={...u,chats:{...u.chats,isFullyLoaded:{...u.chats.isFullyLoaded,[t]:!0}}}),(0,n.R3)(u)}async function y(t){const e=await(0,r.t9)("fetchFullChat",t);if(!e)return;const{users:a,fullInfo:s,groupCall:o,membersCount:i}=e;let c=(0,n.Rd)();if(a&&(c=(0,d.Sh)(c,(0,l.ee)(a,"id"))),o){const t=(0,C.$5)(c,o.id);c=(0,p.AH)(c,o.id,(0,l.CE)(o,["connectionState"]),void 0,t?void 0:o.participantsCount)}return c=(0,d.a4)(c,t.id,{fullInfo:s,...i&&{membersCount:i}}),(0,n.R3)(c),e}async function b(t){const e=(0,n.Rd)(),a=(0,c.DI)(e,t);if(a&&!a.isMin)return a;const s=await(0,r.t9)("getChatByUsername",t);return s?((0,n.R3)((0,d.a4)((0,n.Rd)(),s.id,s)),s):void 0}(0,n.iw)("preloadTopChatMessages",(async(t,e)=>{const a=new Set;for(let n=0;n<i.ul;n++){await(0,h.wO)(100);const{chatId:n}=(0,c.Bt)(t)||{},o=(0,m.gO)(i.Nf),r=null==o?void 0:o.find((t=>t!==n&&!a.has(t)));if(!r)return;a.add(r),e.loadViewportMessages({chatId:r,threadId:s._f})}})),(0,n.iw)("openChat",((t,e,a)=>{const{id:n,threadId:o=s._f}=a;if(!n)return;const{currentUserId:i}=t,d=(0,c.Z1)(t,n);if(null!=d&&d.hasUnreadMark&&e.toggleChatUnread({id:n}),d&&d.lastMessage&&d.lastMessage.threadInfo&&e.requestThreadInfoUpdate({chatId:d.lastMessage.threadInfo.chatId,threadId:d.lastMessage.threadInfo.threadId}),d)(0,u.Hp)(d)&&!d.isMin&&e.requestChatUpdate({chatId:n});else if(n===i)(0,r.t9)("fetchChat",{type:"self"});else{const e=(0,c.dy)(t,n);e&&(0,r.t9)("fetchChat",{type:"user",user:e})}o!==s._f&&((0,c.qS)(t,n,o)||e.requestThreadInfoUpdate({chatId:n,threadId:o}))})),(0,n.iw)("openLinkedChat",(async(t,e,a)=>{var n;const{id:s}=a,o=(0,c.Z1)(t,s);if(!o)return;const i=await(0,r.t9)("fetchFullChat",o);null!=i&&null!==(n=i.fullInfo)&&void 0!==n&&n.linkedChatId&&e.openChat({id:i.fullInfo.linkedChatId})})),(0,n.iw)("focusMessageInComments",(async(t,e,a)=>{const{chatId:n,threadId:s,messageId:o}=a,i=(0,c.Z1)(t,n);i&&await(0,r.t9)("requestThreadInfoUpdate",{chat:i,threadId:s})&&e.focusMessage({chatId:n,threadId:s,messageId:o})})),(0,n.iw)("openSupportChat",(async(t,e)=>{const a=(0,c.P_)(t);if(a)return void e.openChat({id:a.id,shouldReplaceHistory:!0});e.openChat({id:i.AJ,shouldReplaceHistory:!0});const n=await(0,r.t9)("fetchChat",{type:"support"});n&&e.openChat({id:n.chatId,shouldReplaceHistory:!0})})),(0,n.iw)("openTipsChat",((t,e,a)=>{const{langCode:n}=a,s="pt-br"===n?"BR":i.Db.includes(n)?n.toUpperCase():"";e.openChatByUsername({username:`${i.vi}${s}`})})),(0,n.iw)("loadAllChats",(async(t,e,a)=>{const s=a.listType,{onReplace:o}=a;let{shouldReplace:r}=a,d=0;for(;r||!(0,n.Rd)().chats.isFullyLoaded[s];){if(d++>=100)return void(i.eM&&console.error("`actions/loadAllChats`: Infinite loop detected"));if("connectionStateReady"!==(t=(0,n.Rd)()).connectionState||"authorizationStateReady"!==t.authState)return;const e=!r&&t.chats.listIds[s],a=e?e.map((e=>t.chats.byId[e])).filter((e=>Boolean(null==e?void 0:e.lastMessage)&&!(0,c.ep)(t,e.id))).sort(((t,e)=>t.lastMessage.date-e.lastMessage.date))[0]:void 0;await w(s,null==a?void 0:a.id,null==a?void 0:a.lastMessage.date,r),r&&(null==o||o(),r=!1)}})),(0,n.iw)("loadFullChat",((t,e,a)=>{const{chatId:n,force:s}=a,o=(0,c.Z1)(t,n);o&&(s?y(o):v((()=>y(o))))})),(0,n.iw)("loadTopChats",(()=>{g((()=>w("active")))})),(0,n.iw)("requestChatUpdate",((t,e,a)=>{var n;const{serverTimeOffset:s}=t,{chatId:o}=a,d=(0,c.Z1)(t,o);d&&(0,r.t9)("requestChatUpdate",{chat:d,serverTimeOffset:s,...o===i.aw&&{lastLocalMessage:null===(n=(0,c.VF)(t))||void 0===n?void 0:n.message}})})),(0,n.iw)("updateChatMutedState",((t,e,a)=>{const{serverTimeOffset:s}=t,{chatId:o,isMuted:i}=a,l=(0,c.Z1)(t,o);l&&((0,n.R3)((0,d.a4)(t,o,{isMuted:i})),(0,r.t9)("updateChatMutedState",{chat:l,isMuted:i,serverTimeOffset:s}))})),(0,n.iw)("createChannel",((t,e,a)=>{const{title:s,about:i,photo:l,memberIds:h}=a;!async function(t,e,a,s){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:o.Nh.InProgress}});const i=await(0,r.t9)("createChannel",{title:t,about:a,users:e});if(!i)return;const{id:c,accessHash:l}=i;let h=(0,n.Rd)();h=(0,d.a4)(h,c,i),h={...h,chatCreation:{...h.chatCreation,progress:i?o.Nh.Complete:o.Nh.Error}},(0,n.R3)(h),(0,n.Sv)().openChat({id:c,shouldReplaceHistory:!0}),c&&l&&s&&await(0,r.t9)("editChatPhoto",{chatId:c,accessHash:l,photo:s})}(s,h.map((e=>(0,c.dy)(t,e))).filter(Boolean),i,l)})),(0,n.iw)("joinChannel",((t,e,a)=>{const{chatId:n}=a,s=(0,c.Z1)(t,n);if(!s)return;const{id:o,accessHash:i}=s;o&&i&&(0,r.t9)("joinChannel",{channelId:o,accessHash:i})})),(0,n.iw)("deleteChatUser",((t,e,a)=>{var s;const{chatId:o,userId:i}=a,l=(0,c.Z1)(t,o),h=(0,c.dy)(t,i);l&&h&&(t=(0,d.Dd)(t,o),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===o&&e.openChat({id:void 0}),(0,r.t9)("deleteChatUser",{chat:l,user:h}))})),(0,n.iw)("deleteChat",((t,e,a)=>{var s;const{chatId:o}=a,i=(0,c.Z1)(t,o);i&&(t=(0,d.Dd)(t,o),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===o&&e.openChat({id:void 0}),(0,r.t9)("deleteChat",{chatId:i.id}))})),(0,n.iw)("leaveChannel",((t,e,a)=>{var s;const{chatId:o}=a,i=(0,c.Z1)(t,o);if(!i)return;t=(0,d.Dd)(t,o),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===o&&e.openChat({id:void 0});const{id:l,accessHash:h}=i;l&&h&&(0,r.t9)("leaveChannel",{channelId:l,accessHash:h})})),(0,n.iw)("deleteChannel",((t,e,a)=>{var s;const{chatId:o}=a,i=(0,c.Z1)(t,o);if(!i)return;t=(0,d.Dd)(t,o),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===o&&e.openChat({id:void 0});const{id:l,accessHash:h}=i;l&&h&&(0,r.t9)("deleteChannel",{channelId:l,accessHash:h})})),(0,n.iw)("createGroupChat",((t,e,a)=>{const{title:s,memberIds:i,photo:l}=a;!async function(t,e,a){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:o.Nh.InProgress}});try{const s=await(0,r.t9)("createGroupChat",{title:t,users:e});if(!s)return;const{id:i}=s;let c=(0,n.Rd)();c=(0,d.a4)(c,i,s),c={...c,chatCreation:{...c.chatCreation,progress:s?o.Nh.Complete:o.Nh.Error}},(0,n.R3)(c),(0,n.Sv)().openChat({id:i,shouldReplaceHistory:!0}),i&&a&&await(0,r.t9)("editChatPhoto",{chatId:i,photo:a})}catch(t){if("USERS_TOO_FEW"===t.message){const t=(0,n.Rd)();(0,n.R3)({...t,chatCreation:{...t.chatCreation,progress:o.Nh.Error,error:"CreateGroupError"}})}}}(s,i.map((e=>(0,c.dy)(t,e))).filter(Boolean),l)})),(0,n.iw)("toggleChatPinned",((t,e,a)=>{const{id:n,folderId:s}=a,o=(0,c.Z1)(t,n);if(o)if(s){const e=(0,c.Mw)(t,s);if(e){const a=!(0,c.ep)(t,n,s),{pinnedChatIds:o,includedChatIds:i}=e,d=a?[n,...o||[]]:(o||[]).filter((t=>t!==n)),l=[n,...i];(0,r.t9)("editChatFolder",{id:s,folderUpdate:{...e,pinnedChatIds:d,includedChatIds:l}})}}else{const e=(0,c.Ek)(t,n),a=(0,c.ep)(t,n,"archived"===e?i.WS:void 0);(0,r.t9)("toggleChatPinned",{chat:o,shouldBePinned:!a})}})),(0,n.iw)("toggleChatArchived",((t,e,a)=>{const{id:n}=a,s=(0,c.Z1)(t,n);s&&(0,r.t9)("toggleChatArchived",{chat:s,folderId:(0,u.pE)(s)?0:i.WS})})),(0,n.iw)("loadChatFolders",(()=>{!async function(){const t=await(0,r.t9)("fetchChatFolders");if(t){const e=(0,n.Rd)();(0,n.R3)({...e,chatFolders:{...e.chatFolders,...t}})}}()})),(0,n.iw)("loadRecommendedChatFolders",(()=>{!async function(){const t=await(0,r.t9)("fetchRecommendedChatFolders");if(t){const e=(0,n.Rd)();(0,n.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}})}}()})),(0,n.iw)("editChatFolders",((t,e,a)=>{const{chatId:n,idsToRemove:s,idsToAdd:o}=a;s.forEach((async e=>{const a=(0,c.Mw)(t,e);var s;a&&await(0,r.t9)("editChatFolder",{id:e,folderUpdate:{...a,pinnedChatIds:null===(s=a.pinnedChatIds)||void 0===s?void 0:s.filter((t=>t!==n)),includedChatIds:a.includedChatIds.filter((t=>t!==n))}})})),o.forEach((async e=>{const a=(0,c.Mw)(t,e);a&&await(0,r.t9)("editChatFolder",{id:e,folderUpdate:{...a,includedChatIds:a.includedChatIds.concat(n)}})}))})),(0,n.iw)("editChatFolder",((t,e,a)=>{const{id:n,folderUpdate:s}=a,o=(0,c.Mw)(t,n);o&&(0,r.t9)("editChatFolder",{id:n,folderUpdate:{id:n,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...s}})})),(0,n.iw)("addChatFolder",((t,e,a)=>{const{folder:s}=a,{orderedIds:o}=t.chatFolders;!async function(t,e){const{id:a,description:s,...o}=t;if(await(0,r.t9)("editChatFolder",{id:e+1,folderUpdate:{id:e+1,...o}}),!s)return;const i=(0,n.Rd)(),{recommended:d}=i.chatFolders;d&&(0,n.R3)({...i,chatFolders:{...i.chatFolders,recommended:d.filter((t=>{let{id:e}=t;return e!==a}))}})}(s,null!=o&&o.length?Math.max.apply(Math.max,o):i.WS)})),(0,n.iw)("deleteChatFolder",((t,e,a)=>{const{id:n}=a;(0,c.Mw)(t,n)&&async function(t){await(0,r.t9)("deleteChatFolder",t)}(n)})),(0,n.iw)("toggleChatUnread",((t,e,a)=>{const{id:n}=a,{serverTimeOffset:o}=t,i=(0,c.Z1)(t,n);i&&(i.unreadCount?(0,r.t9)("markMessageListRead",{serverTimeOffset:o,chat:i,threadId:s._f}):(0,r.t9)("toggleDialogUnread",{chat:i,hasUnreadMark:!i.hasUnreadMark}))})),(0,n.iw)("openChatByInvite",(async(t,e,a)=>{const{hash:n}=a,s=await(0,r.t9)("openChatByInvite",n);s&&e.openChat({id:s.chatId})})),(0,n.iw)("openChatByPhoneNumber",(async(t,e,a)=>{const{phoneNumber:s}=a;e.openChat({id:i.AJ});const o=await async function(t){const e=(0,n.Rd)(),a=(0,c.Bk)(e,t);if(a&&!a.isMin)return(0,c.Z1)(e,a.id);const s=await(0,r.t9)("getChatByPhoneNumber",t);return s?((0,n.R3)((0,d.a4)((0,n.Rd)(),s.id,s)),s):void 0}(s);if(!o)return e.openPreviousChat(),void e.showNotification({message:I.i0("lng_username_by_phone_not_found").replace("{phone}",s)});e.openChat({id:o.id})})),(0,n.iw)("openTelegramLink",((t,e,a)=>{const{url:n}=a;if(n.match(i.g$))return void(0,f.o)(n.match(i.g$)[0]);const s=new URL(n.startsWith("http")?n:`https://${n}`),[o,r,d]=s.pathname.split("/").filter(Boolean).map((t=>decodeURI(t))),l=Object.fromEntries(s.searchParams);let h;if("joinchat"===o&&(h=r),o.match(/^\+([0-9]+)(\?|$)/))return void e.openChatByPhoneNumber({phoneNumber:o.substr(1,o.length-1)});if((o.startsWith(" ")||o.startsWith("+"))&&(h=o.substr(1,o.length-1)),h)return void e.openChatByInvite({hash:h});if("addstickers"===o)return void e.openStickerSetShortName({stickerSetShortName:r});const u=r||void 0,p=d?Number(d):void 0,C=l.comment?Number(l.comment):void 0;if(l.hasOwnProperty("voicechat")||l.hasOwnProperty("livestream"))e.joinVoiceChatByLink({username:o,inviteHash:l.voicechat||l.livestream});else if("c"===o&&u&&p){const a=`-${u}`;if(!(0,c.Z1)(t,a))return void e.showNotification({message:"Chat does not exist"});e.focusMessage({chatId:a,messageId:p})}else e.openChatByUsername({username:o,messageId:p||Number(u),commentId:C,startParam:l.start})})),(0,n.iw)("acceptInviteConfirmation",(async(t,e,a)=>{const{hash:n}=a,s=await(0,r.t9)("importChatInvite",{hash:n});s&&e.openChat({id:s.id})})),(0,n.iw)("openChatByUsername",(async(t,e,a)=>{const{username:s,messageId:o,commentId:d,startParam:l}=a,h=(0,c.jr)(t);if(!d)return h&&h.username===s?void e.focusMessage({chatId:h.id,messageId:o}):void await async function(t,e,a,n){t.openChat({id:i.AJ});const s=await b(e);if(!s)return t.openPreviousChat(),void t.showNotification({message:"User does not exist"});a?t.focusMessage({chatId:s.id,messageId:a}):t.openChat({id:s.id}),n&&t.startBot({botId:s.id,param:n})}(e,s,o,l);const{chatId:u,type:f}=(0,c.Bt)(t)||{},p=(0,c.DI)(t,s);if(u&&p&&"thread"===f){const a=(0,c.tZ)(t,u,o);if(a&&a.chatId===u)return void e.focusMessage({chatId:a.chatId,threadId:a.threadId,messageId:d})}o&&async function(t,e,a,s){t.openChat({id:i.AJ});const o=await b(e);if(!o)return;const d=(0,n.Rd)(),l=(0,c.tZ)(d,o.id,a);let h;if(l)h=l.chatId;else{const t=await(0,r.t9)("requestThreadInfoUpdate",{chat:o,threadId:a});if(!t)return;h=t.discussionChatId}h&&t.focusMessage({chatId:h,threadId:a,messageId:Number(s)})}(e,s,o,d)})),(0,n.iw)("togglePreHistoryHidden",(async(t,e,a)=>{const{chatId:n,isEnabled:s}=a;let o=(0,c.Z1)(t,n);if(o){if((0,u.G9)(o)){if(o=await(0,r.t9)("migrateChat",o),!o)return;e.openChat({id:o.id})}(0,r.t9)("togglePreHistoryHidden",{chat:o,isEnabled:s})}})),(0,n.iw)("updateChatDefaultBannedRights",((t,e,a)=>{const{chatId:n,bannedRights:s}=a,o=(0,c.Z1)(t,n);o&&(0,r.t9)("updateChatDefaultBannedRights",{chat:o,bannedRights:s})})),(0,n.iw)("updateChatMemberBannedRights",(async(t,e,a)=>{const{chatId:s,userId:o,bannedRights:i}=a;let l=(0,c.Z1)(t,s);const h=(0,c.dy)(t,o);if(!l||!h)return;if((0,u.G9)(l)){if(l=await(0,r.t9)("migrateChat",l),!l)return;e.openChat({id:l.id})}await(0,r.t9)("updateChatMemberBannedRights",{chat:l,user:h,bannedRights:i}),t=(0,n.Rd)();const f=(0,c.Z1)(t,s);if(!f||!f.fullInfo)return;const{members:p,kickedMembers:C}=f.fullInfo,m=Boolean(i.viewMessages),I=!Object.keys(i).length;return(0,d.a4)(t,s,{fullInfo:{...f.fullInfo,...p&&m&&{members:p.filter((t=>t.userId!==o))},...p&&!m&&{members:p.map((t=>t.userId===o?{...t,bannedRights:i}:t))},...I&&C&&{kickedMembers:C.filter((t=>t.userId!==o))}}})})),(0,n.iw)("updateChatAdmin",(async(t,e,a)=>{const{chatId:s,userId:o,adminRights:i,customTitle:l}=a;let h=(0,c.Z1)(t,s);const f=(0,c.dy)(t,o);if(!h||!f)return;if((0,u.G9)(h)){if(h=await(0,r.t9)("migrateChat",h),!h)return;e.openChat({id:h.id})}await(0,r.t9)("updateChatAdmin",{chat:h,user:f,adminRights:i,customTitle:l});const p=await(0,r.t9)("fetchFullChat",h);if(null==p||!p.fullInfo)return;const{adminMembers:C}=p.fullInfo,m=!Object.keys(i).length;return t=(0,n.Rd)(),(0,d.a4)(t,s,{fullInfo:{...p.fullInfo,...C&&m&&{adminMembers:C.filter((t=>t.userId!==o))},...C&&!m&&{adminMembers:C.map((t=>t.userId===o?{...t,adminRights:i,customTitle:l}:t))}}})})),(0,n.iw)("updateChat",(async(t,e,a)=>{const{chatId:s,title:i,about:l,photo:h}=a,u=(0,c.Z1)(t,s);if(u)return(0,n.R3)((0,d.H9)((0,n.Rd)(),o.wv.InProgress)),await Promise.all([u.title!==i?(0,r.t9)("updateChatTitle",u,i):void 0,u.fullInfo&&u.fullInfo.about!==l?(0,r.t9)("updateChatAbout",u,l):void 0,h?(0,r.t9)("editChatPhoto",{chatId:s,accessHash:u.accessHash,photo:h}):void 0]),(0,d.H9)((0,n.Rd)(),o.wv.Complete)})),(0,n.iw)("toggleSignatures",((t,e,a)=>{const{chatId:n,isEnabled:s}=a,o=(0,c.Z1)(t,n);o&&(0,r.t9)("toggleSignatures",{chat:o,isEnabled:s})})),(0,n.iw)("loadGroupsForDiscussion",(async t=>{const e=await(0,r.t9)("fetchGroupsForDiscussion");if(!e)return;const a=e.reduce(((t,e)=>(e&&(t[e.id]=e),t)),{});return t=(0,n.Rd)(),t=(0,d.fZ)(t,a),{...t,chats:{...t.chats,forDiscussionIds:Object.keys(a)}}})),(0,n.iw)("linkDiscussionGroup",(async(t,e,a)=>{const{channelId:n,chatId:s}=a,o=(0,c.Z1)(t,n);let i=(0,c.Z1)(t,s);if(!o||!i)return;if((0,u.G9)(i)){if(i=await(0,r.t9)("migrateChat",i),!i)return;e.openChat({id:i.id})}let{fullInfo:d}=i;if(!d){const t=await(0,r.t9)("fetchFullChat",i);if(!t)return;d=t.fullInfo}d.isPreHistoryHidden&&await(0,r.t9)("togglePreHistoryHidden",{chat:i,isEnabled:!1}),(0,r.t9)("setDiscussionGroup",{channel:o,chat:i})})),(0,n.iw)("unlinkDiscussionGroup",(async(t,e,a)=>{var n;const{channelId:s}=a,o=(0,c.Z1)(t,s);if(!o)return;let i;null!==(n=o.fullInfo)&&void 0!==n&&n.linkedChatId&&(i=(0,c.Z1)(t,o.fullInfo.linkedChatId)),await(0,r.t9)("setDiscussionGroup",{channel:o}),i&&y(i)})),(0,n.iw)("setActiveChatFolder",((t,e,a)=>({...t,chatFolders:{...t.chatFolders,activeChatFolder:a}}))),(0,n.iw)("loadMoreMembers",(async t=>{var e,a;const{chatId:s}=(0,c.Bt)(t)||{},o=s?(0,c.Z1)(t,s):void 0;if(!o||(0,u.G9)(o))return;const i=(null===(e=o.fullInfo)||void 0===e||null===(a=e.members)||void 0===a?void 0:a.length)||void 0,h=await(0,r.t9)("fetchMembers",o.id,o.accessHash,"recent",i);if(!h)return;const{members:f,users:p}=h;return f&&f.length?(t=(0,n.Rd)(),t=(0,d.Sh)(t,(0,l.ee)(p,"id")),t=(0,d.iX)(t,o,f)):void 0})),(0,n.iw)("addChatMembers",(async(t,e,a)=>{const{chatId:n,memberIds:s}=a,i=(0,c.Z1)(t,n),d=s.map((e=>(0,c.dy)(t,e))).filter(Boolean);i&&d.length&&(e.setNewChatMembersDialogState(o.WB.Loading),await(0,r.t9)("addChatMembers",i,d),e.setNewChatMembersDialogState(o.WB.Closed),y(i))})),(0,n.iw)("deleteChatMember",(async(t,e,a)=>{const{chatId:n,userId:s}=a,o=(0,c.Z1)(t,n),i=(0,c.dy)(t,s);o&&i&&(await(0,r.t9)("deleteChatMember",o,i),y(o))})),(0,n.iw)("toggleIsProtected",((t,e,a)=>{const{chatId:n,isProtected:s}=a,o=(0,c.Z1)(t,n);o&&(0,r.t9)("toggleIsProtected",{chat:o,isProtected:s})})),(0,n.iw)("setChatEnabledReactions",(async(t,e,a)=>{const{chatId:n,enabledReactions:s}=a,o=(0,c.Z1)(t,n);o&&(await(0,r.t9)("setChatEnabledReactions",{chat:o,enabledReactions:s}),y(o))})),(0,n.iw)("loadChatSettings",(async(t,e,a)=>{const{chatId:s}=a,o=(0,c.Z1)(t,s);if(!o)return;const i=await(0,r.t9)("fetchChatSettings",o);return i?(0,d.a4)((0,n.Rd)(),o.id,{settings:i}):void 0}))},8422:(t,e,a)=>{a.d(e,{FF:()=>M,Mt:()=>k,NH:()=>Z});var n=a(3555),s=a(2431),o=a(1226),i=a(1192),r=a(4319),d=a(8958),c=a(782),l=a(5406),h=a(7225),u=a(4753),f=a(7361),p=a(711);let C,m;const I=new Audio("./voicechat_join.mp3"),g=new Audio("./voicechat_connecting.mp3");g.loop=!0;const v=new Audio("./voicechat_leave.mp3"),w={join:I,allowTalk:new Audio("./voicechat_onallowtalk.mp3"),leave:v,connecting:g};let y=Promise.resolve();async function b(t){const e=await(0,o.t9)("getGroupCall",{call:t});if(!e)return;let a=(0,n.Rd)();const i=(0,s.$5)(a,t.id);return a=(0,d.AH)(a,t.id,(0,c.CE)(e.groupCall,["connectionState"]),void 0,null!=i&&i.isLoaded?void 0:e.groupCall.participantsCount),a=(0,l.Sh)(a,(0,c.ee)(e.users,"id")),a=(0,l.fZ)(a,(0,c.ee)(e.chats,"id")),(0,n.R3)(a),e.groupCall}async function R(t,e){const a=await(0,o.t9)("fetchGroupCallParticipants",{call:t,offset:e});if(!a)return;let s=(0,n.Rd)();s=(0,l.Sh)(s,(0,c.ee)(a.users,"id")),s=(0,l.fZ)(s,(0,c.ee)(a.chats,"id")),(0,n.R3)(s)}function M(){return C}function Z(){return m}function k(){var t;null===(t=C)||void 0===t||t.pause(),m=void 0,C=void 0}(0,n.iw)("toggleGroupCallPanel",(t=>({...t,groupCalls:{...t.groupCalls,isGroupCallPanelHidden:!t.groupCalls.isGroupCallPanelHidden}}))),(0,n.iw)("subscribeToGroupCallUpdates",(async(t,e,a)=>{const{subscribed:n,id:i}=a,r=(0,s.$5)(t,i);r&&(n&&(await b(r),await R(r)),await(0,o.t9)("toggleGroupCallStartSubscription",{subscribed:n,call:r}))})),(0,n.iw)("createGroupCall",(async(t,e,a)=>{const{chatId:s}=a,r=(0,i.Z1)(t,s);if(!r)return;const c=await(0,o.t9)("createGroupCall",{peer:r});c&&(t=(0,n.Rd)(),(0,n.R3)((0,d.AH)(t,c.id,{...c,chatId:s})),e.joinGroupCall({id:c.id,accessHash:c.accessHash}))})),(0,n.iw)("createGroupCallInviteLink",(async(t,e)=>{const a=(0,s.mU)(t);if(!a||!a.chatId)return;const n=(0,i.Z1)(t,a.chatId);if(!n)return;const d=Boolean(n.username);let{inviteLink:c}=n.fullInfo;d&&(c=await(0,o.t9)("exportGroupCallInvite",{call:a,canSelfUnmute:!1})),c&&((0,r.TE)(c),e.showNotification({message:"Link copied to clipboard"}))})),(0,n.iw)("joinVoiceChatByLink",(async(t,e,a)=>{const{username:n,inviteHash:s}=a,o=await(0,h.Co)(n);if(!o)return void e.showNotification({message:p.i0("NoUsernameFound")});const i=await(0,h.ft)(o);null!=i&&i.groupCall&&e.joinGroupCall({id:i.groupCall.id,accessHash:i.groupCall.accessHash,inviteHash:s})})),(0,n.iw)("joinGroupCall",(async(t,e,a)=>{var o;if(!f.Bi)return;const{chatId:i,id:r,accessHash:c,inviteHash:l}=a;!function(){const t=new(window.AudioContext||window.webkitAudioContext);C=new Audio,m=t,C.srcObject=(t=>{const e=t.createOscillator(),a=e.connect(t.createMediaStreamDestination());return e.start(),new MediaStream([Object.assign(a.stream.getAudioTracks()[0],{enabled:!1})])})(t),(0,u.Z)(C)}(),await(y?(y=Promise.all(Object.values(w).map((t=>(t.muted=!0,t.volume=1e-4,t.play().then((()=>{t.pause(),t.volume=1,t.currentTime=0,t.muted=!1})))))).then((()=>{y=void 0})),y):Promise.resolve());const{groupCalls:{activeGroupCallId:h}}=t;let p=r?(0,s.$5)(t,r):(0,s.Bj)(t,i);if((null===(o=p)||void 0===o?void 0:o.id)!==h){if(h)e.leaveGroupCall({rejoin:a});else if(p&&h===p.id)e.toggleGroupCallPanel();else if(p||r&&c||(p=await b({id:r,accessHash:c})),p)return t=(0,n.Rd)(),t=(0,d.AH)(t,p.id,{...p,inviteHash:l},void 0,p.participantsCount+1),{...t,groupCalls:{...t.groupCalls,activeGroupCallId:p.id,isGroupCallPanelHidden:!1}}}else e.toggleGroupCallPanel()})),(0,n.iw)("playGroupCallSound",((t,e,a)=>{const{sound:n}=a;w[n]&&(y?y.then((()=>{(0,u.Z)(w[n])})):("connecting"!==n&&w.connecting.pause(),(0,u.Z)(w[n])))})),(0,n.iw)("loadMoreGroupCallParticipants",(t=>{const e=(0,s.mU)(t);e&&R(e,e.nextOffset)})),(0,n.iw)("openCallFallbackConfirm",(t=>({...t,groupCalls:{...t.groupCalls,isFallbackConfirmOpen:!0}}))),(0,n.iw)("closeCallFallbackConfirm",(t=>({...t,groupCalls:{...t.groupCalls,isFallbackConfirmOpen:!1}})))},8958:(t,e,a)=>{a.d(e,{AH:()=>r,B6:()=>l,Ic:()=>c,dc:()=>d});var n=a(2431),s=a(782),o=a(3475),i=a(1192);function r(t,e,a,n,o){var i;const r=Object.values({...null===(i=t.groupCalls.byId[e])||void 0===i?void 0:i.participants,...a.participants}).filter((t=>!t.isLeft)).reduce(((t,e)=>(t[e.id]=e,t)),{});return{...t,groupCalls:{...t.groupCalls,byId:{...t.groupCalls.byId,[e]:{...t.groupCalls.byId[e],...(0,s.CE)(a,["participantsCount"]),...n&&{participantsCount:t.groupCalls.byId[e].participantsCount+n},...void 0!==o&&{participantsCount:o},participants:r}}}}}function d(t,e){const a=(0,n.$5)(t,e);if(a&&a.chatId){const e=(0,i.Z1)(t,a.chatId);e&&(t=(0,o.a4)(t,a.chatId,{fullInfo:{...e.fullInfo,groupCallId:void 0}}))}return{...t,groupCalls:{...t.groupCalls,byId:{...(0,s.CE)(t.groupCalls.byId,[e.toString()])}}}}function c(t,e,a){return t.groupCalls.activeGroupCallId?r(t,t.groupCalls.activeGroupCallId,e,void 0,a):t}function l(t,e,a,s){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const i=(0,n.$5)(t,e);return i?r(t,e,{participants:{...i.participants,[a]:{...i.participants[a],...s}}},s.isLeft?o?0:-1:i.participants[a]||o?0:1):t}},2431:(t,e,a)=>{a.d(e,{$5:()=>r,Bj:()=>i,GU:()=>d,Ht:()=>c,mU:()=>l,oq:()=>h});var n=a(4342),s=a(5806),o=a(6087);function i(t,e){const a=(0,n.Z1)(t,e);if(a&&a.fullInfo&&a.fullInfo.groupCallId)return r(t,a.fullInfo.groupCallId)}function r(t,e){return t.groupCalls.byId[e]}function d(t,e,a){var n;return null===(n=r(t,e))||void 0===n?void 0:n.participants[a]}function c(t){var e,a;const o=null===(e=l(t))||void 0===e?void 0:e.chatId;if(!o)return!1;const i=(0,n.Z1)(t,o);return!!i&&((0,s.G9)(i)&&i.isCreator||Boolean(null===(a=i.adminRights)||void 0===a?void 0:a.manageCall))}function l(t){const{groupCalls:{activeGroupCallId:e}}=t;if(e)return r(t,e)}function h(t){const e=(0,o.dy)(t,t.currentUserId);return`Calls: ${(0,s.Js)(e)}`}},3551:(t,e,a)=>{a.d(e,{o:()=>o});var n=a(3555),s=a(7361);const o=t=>{const{protocol:e,searchParams:a,pathname:o,hostname:i}=new URL(t);if("tg:"!==e)return;const{openChatByInvite:r,openChatByUsername:d,openChatByPhoneNumber:c,openStickerSetShortName:l,focusMessage:h,joinVoiceChatByLink:u}=(0,n.Sv)(),f=(s.s$?i:o).replace(/^\/\//,""),p={};switch(a.forEach(((t,e)=>{p[e]=t})),f){case"resolve":{const{domain:t,phone:e,post:a,comment:n,voicechat:s,livestream:o,start:i}=p;"telegrampassport"!==t&&(p.hasOwnProperty("voicechat")||p.hasOwnProperty("livestream")?u({username:t,inviteHash:s||o}):e?c({phone:e}):d({username:t,messageId:Number(a),commentId:Number(n),startParam:i}));break}case"privatepost":{const{post:t,channel:e}=p;h({chatId:`-${e}`,id:t});break}case"bg":case"share":case"msg":case"login":default:break;case"join":{const{invite:t}=p;r({hash:t});break}case"addstickers":{const{set:t}=p;l({stickerSetShortName:t});break}}}}}]);
|
|
//# sourceMappingURL=970.e8597645f1a969d6225c.js.map
|