telegram-tt/dist/9970.7666831e8b537f6d4f74.js
Alexander Zinchuk fa6fd018cb [Build]
2022-05-31 22:32:02 +04:00

2 lines
27 KiB
JavaScript

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[9970],{22275:(t,e,a)=>{a.d(e,{Z:()=>h});var n=a(14050),s=a(33555),i=a(11192),o=a(75806),r=a(32340),d=a(59107),c=a(13103),l=a(231);const h=(0,n.X$)((0,s.c$)(((t,e)=>{let{userId:a}=e;const n=(0,i.jr)(t),s=a&&(0,i.dy)(t,a);return{chat:n,contactName:s?(0,o.Vl)(s):void 0}}))((t=>{let{isOpen:e,chat:a,userId:i,contactName:o,onClose:h}=t;const{deleteChatMember:u}=(0,s.Sv)(),p=(0,d.Z)(),f=(0,n.I4)((()=>{u({chatId:a.id,userId:i}),h()}),[a,u,h,i]);if(a&&i)return n.ZP.createElement(c.Z,{isOpen:e,onClose:h,onEnter:f,className:"delete",title:p("GroupRemoved.Remove")},n.ZP.createElement("p",null,(0,r.Z)(p("PeerInfo.Confirm.RemovePeer",o))),n.ZP.createElement(l.Z,{color:"danger",className:"confirm-dialog-button",isText:!0,onClick:f},p("lng_box_remove")),n.ZP.createElement(l.Z,{className:"confirm-dialog-button",isText:!0,onClick:h},p("Cancel")))})))},27225:(t,e,a)=>{a.d(e,{Co:()=>b,ft:()=>y});var n=a(33555),s=a(6137),i=a(91713),o=a(83716),r=a(71226),d=a(5161),c=a(11192),l=a(60782),h=a(69118),u=a(75806),p=a(53551),f=a(78958),C=a(42431),m=a(16974),I=a(50711);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 i;let h=arguments.length>3&&void 0!==arguments[3]&&arguments[3],u=(0,n.Rd)();const p=await(0,r.t9)("fetchChats",{limit:o.Ov,offsetDate:a,archived:"archived"===t,withPinned:h,serverTimeOffset:u.serverTimeOffset,lastLocalServiceMessage:null===(i=(0,c.VF)(u))||void 0===i?void 0:i.message});if(!p)return;const{chatIds:f}=p;if(f.length>0&&f[0]===e&&f.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(p.users),"id")),u=(0,d.ps)(u,p.userStatusesById),u=(0,d.SL)(u,(0,l.ee)(a.concat(p.chats),"id")),u=(0,d.Mg)(u,t,f)}else h&&"archived"===t?(u=(0,d.Sh)(u,(0,l.ee)(p.users,"id")),u=(0,d.zn)(u,p.userStatusesById),u=(0,d.GL)(u,(0,l.ee)(p.chats,"id")),u=(0,d.Mg)(u,t,f)):(u=(0,d.Sh)(u,(0,l.ee)(p.users,"id")),u=(0,d.zn)(u,p.userStatusesById),u=(0,d.GL)(u,(0,l.ee)(p.chats,"id")),u=(0,d.B1)(u,t,f));u=(0,d.vv)(u,t,p),Object.keys(p.draftsById).forEach((t=>{u=(0,d.pf)(u,t,s._f,"draft",p.draftsById[t])})),Object.keys(p.replyingToById).forEach((t=>{u=(0,d.pf)(u,t,s._f,"replyingToId",p.replyingToById[t])})),0!==f.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,userStatusesById:s,fullInfo:i,groupCall:o,membersCount:c}=e;let h=(0,n.Rd)();if(a&&(h=(0,d.Sh)(h,(0,l.ee)(a,"id"))),s&&(h=(0,d.zn)(h,s)),o){const t=(0,C.$5)(h,o.id);h=(0,f.AH)(h,o.id,(0,l.CE)(o,["connectionState"]),void 0,t?void 0:o.participantsCount)}h=(0,d.a4)(h,t.id,{fullInfo:i,...c&&{membersCount:c}}),(0,n.R3)(h);const u=i.stickerSet;return u&&(0,n.Sv)().loadStickers({stickerSetId:u.id,stickerSetAccessHash:u.accessHash,stickerSetShortName:u.shortName}),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}async function R(t,e,a,s){const i=await b(a);if(!i)return;const o=(0,c.dy)((0,n.Rd)(),i.id);o&&o.isAttachMenuBot?t.callAttachMenuBot({botId:o.id,chatId:e,..."string"==typeof s&&{startParam:s}}):t.showNotification({message:I.i0("WebApp.AddToAttachmentUnavailableError")})}(0,n.iw)("preloadTopChatMessages",(async(t,e)=>{const a=new Set;for(let n=0;n<o.Mo;n++){await(0,h.wO)(100);const{chatId:n}=(0,c.Bt)(t)||{},i=(0,m.gO)(o.Nf),r=null==i?void 0:i.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)=>{var n;const{id:i,threadId:o=s._f}=a;if(!i)return;const{currentUserId:d}=t,l=(0,c.Z1)(t,i);if(null!=l&&l.hasUnreadMark&&e.toggleChatUnread({id:i}),null!=l&&null!==(n=l.lastMessage)&&void 0!==n&&n.threadInfo&&e.requestThreadInfoUpdate({chatId:l.lastMessage.threadInfo.chatId,threadId:l.lastMessage.threadInfo.threadId}),l)(0,u.Hp)(l)&&!l.isMin&&e.requestChatUpdate({chatId:i});else if(i===d)(0,r.t9)("fetchChat",{type:"self"});else{const e=(0,c.dy)(t,i);e&&(0,r.t9)("fetchChat",{type:"user",user:e})}o!==s._f&&((0,c.qS)(t,i,o)||e.requestThreadInfoUpdate({chatId:i,threadId:o}))})),(0,n.iw)("openLinkedChat",(async(t,e,a)=>{var n;const{id:s}=a,i=(0,c.Z1)(t,s);if(!i)return;const o=await(0,r.t9)("fetchFullChat",i);null!=o&&null!==(n=o.fullInfo)&&void 0!==n&&n.linkedChatId&&e.openChat({id:o.fullInfo.linkedChatId})})),(0,n.iw)("focusMessageInComments",(async(t,e,a)=>{const{chatId:n,threadId:s,messageId:i}=a,o=(0,c.Z1)(t,n);o&&await(0,r.t9)("requestThreadInfoUpdate",{chat:o,threadId:s})&&e.focusMessage({chatId:n,threadId:s,messageId:i})})),(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:o.AJ,shouldReplaceHistory:!0});const n=await(0,r.t9)("fetchChat",{type:"support"});n&&e.openChat({id:n.chatId,shouldReplaceHistory:!0})})),(0,n.iw)("loadAllChats",(async(t,e,a)=>{const s=a.listType,{onReplace:i}=a;let{shouldReplace:r}=a,d=0;for(;r||!(0,n.Rd)().chats.isFullyLoaded[s];){if(d++>=100)return void(o.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==i||i(),r=!1)}})),(0,n.iw)("loadFullChat",((t,e,a)=>{const{chatId:n,force:s}=a,i=(0,c.Z1)(t,n);i&&(s?y(i):v((()=>y(i))))})),(0,n.iw)("loadTopChats",(()=>{g((()=>w("active")))})),(0,n.iw)("requestChatUpdate",((t,e,a)=>{var n;const{serverTimeOffset:s}=t,{chatId:i}=a,d=(0,c.Z1)(t,i);d&&(0,r.t9)("requestChatUpdate",{chat:d,serverTimeOffset:s,...i===o.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:i,isMuted:o}=a,l=(0,c.Z1)(t,i);l&&((0,n.R3)((0,d.a4)(t,i,{isMuted:o})),(0,r.t9)("updateChatMutedState",{chat:l,isMuted:o,serverTimeOffset:s}))})),(0,n.iw)("createChannel",((t,e,a)=>{const{title:s,about:o,photo:l,memberIds:h}=a;!async function(t,e,a,s){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:i.Nh.InProgress}});const o=await(0,r.t9)("createChannel",{title:t,about:a,users:e});if(!o)return;const{id:c,accessHash:l}=o;let h=(0,n.Rd)();h=(0,d.a4)(h,c,o),h={...h,chatCreation:{...h.chatCreation,progress:o?i.Nh.Complete:i.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),o,l)})),(0,n.iw)("joinChannel",((t,e,a)=>{const{chatId:n}=a,s=(0,c.Z1)(t,n);if(!s)return;const{id:i,accessHash:o}=s;i&&o&&(0,r.t9)("joinChannel",{channelId:i,accessHash:o})})),(0,n.iw)("deleteChatUser",((t,e,a)=>{var s;const{chatId:i,userId:o}=a,l=(0,c.Z1)(t,i),h=(0,c.dy)(t,o);l&&h&&(t=(0,d.Dd)(t,i),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===i&&e.openChat({id:void 0}),(0,r.t9)("deleteChatUser",{chat:l,user:h}))})),(0,n.iw)("deleteChat",((t,e,a)=>{var s;const{chatId:i}=a,o=(0,c.Z1)(t,i);o&&(t=(0,d.Dd)(t,i),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===i&&e.openChat({id:void 0}),(0,r.t9)("deleteChat",{chatId:o.id}))})),(0,n.iw)("leaveChannel",((t,e,a)=>{var s;const{chatId:i}=a,o=(0,c.Z1)(t,i);if(!o)return;t=(0,d.Dd)(t,i),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===i&&e.openChat({id:void 0});const{id:l,accessHash:h}=o;l&&h&&(0,r.t9)("leaveChannel",{channelId:l,accessHash:h})})),(0,n.iw)("deleteChannel",((t,e,a)=>{var s;const{chatId:i}=a,o=(0,c.Z1)(t,i);if(!o)return;t=(0,d.Dd)(t,i),(0,n.R3)(t),(null===(s=(0,c.Bt)(t))||void 0===s?void 0:s.chatId)===i&&e.openChat({id:void 0});const{id:l,accessHash:h}=o;l&&h&&(0,r.t9)("deleteChannel",{channelId:l,accessHash:h})})),(0,n.iw)("createGroupChat",((t,e,a)=>{const{title:s,memberIds:o,photo:l}=a;!async function(t,e,a){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:i.Nh.InProgress}});try{const s=await(0,r.t9)("createGroupChat",{title:t,users:e});if(!s)return;const{id:o}=s;let c=(0,n.Rd)();c=(0,d.a4)(c,o,s),c={...c,chatCreation:{...c.chatCreation,progress:s?i.Nh.Complete:i.Nh.Error}},(0,n.R3)(c),(0,n.Sv)().openChat({id:o,shouldReplaceHistory:!0}),o&&a&&await(0,r.t9)("editChatPhoto",{chatId:o,photo:a})}catch(t){if("USERS_TOO_FEW"===t.message){const t=(0,n.Rd)();(0,n.R3)({...t,chatCreation:{...t.chatCreation,progress:i.Nh.Error,error:"CreateGroupError"}})}}}(s,o.map((e=>(0,c.dy)(t,e))).filter(Boolean),l)})),(0,n.iw)("toggleChatPinned",((t,e,a)=>{const{id:n,folderId:s}=a,i=(0,c.Z1)(t,n);if(i)if(s){const e=(0,c.Mw)(t,s);if(e){const a=!(0,c.ep)(t,n,s),{pinnedChatIds:i,includedChatIds:o}=e,d=a?[n,...i||[]]:(i||[]).filter((t=>t!==n)),l=[n,...o];(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?o.WS:void 0);(0,r.t9)("toggleChatPinned",{chat:i,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:o.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:i}=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))}})})),i.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,i=(0,c.Mw)(t,n);i&&(0,r.t9)("editChatFolder",{id:n,folderUpdate:{id:n,emoticon:i.emoticon,pinnedChatIds:i.pinnedChatIds,...s}})})),(0,n.iw)("addChatFolder",((t,e,a)=>{const{folder:s}=a,{orderedIds:i}=t.chatFolders;!async function(t,e){const{id:a,description:s,...i}=t;if(await(0,r.t9)("editChatFolder",{id:e+1,folderUpdate:{id:e+1,...i}}),!s)return;const o=(0,n.Rd)(),{recommended:d}=o.chatFolders;d&&(0,n.R3)({...o,chatFolders:{...o.chatFolders,recommended:d.filter((t=>{let{id:e}=t;return e!==a}))}})}(s,null!=i&&i.length?Math.max.apply(Math.max,i):o.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:i}=t,o=(0,c.Z1)(t,n);o&&(o.unreadCount?(0,r.t9)("markMessageListRead",{serverTimeOffset:i,chat:o,threadId:s._f}):(0,r.t9)("toggleDialogUnread",{chat:o,hasUnreadMark:!o.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,startAttach:i,attach:l}=a;e.openChat({id:o.AJ});const h=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(!h)return e.openPreviousChat(),void e.showNotification({message:I.i0("lng_username_by_phone_not_found").replace("{phone}",s)});e.openChat({id:h.id}),l&&R(e,h.id,l,i)})),(0,n.iw)("openTelegramLink",((t,e,a)=>{const{url:n}=a;if(n.match(o.g$))return void(0,p.o)(n.match(o.g$)[0]);const s=new URL(n.startsWith("http")?n:`https://${n}`),[i,r,d]=s.pathname.split("/").filter(Boolean).map((t=>decodeURI(t))),l=Object.fromEntries(s.searchParams);let h;"joinchat"===i&&(h=r);const u=!(!l.hasOwnProperty("startattach")||l.startattach)||l.startattach;if(i.match(/^\+([0-9]+)(\?|$)/))return void e.openChatByPhoneNumber({phoneNumber:i.substr(1,i.length-1),startAttach:u,attach:l.attach});if((i.startsWith(" ")||i.startsWith("+"))&&(h=i.substr(1,i.length-1)),h)return void e.openChatByInvite({hash:h});if("addstickers"===i)return void e.openStickerSetShortName({stickerSetShortName:r});const f=r||void 0,C=d?Number(d):void 0,m=l.comment?Number(l.comment):void 0;if(l.hasOwnProperty("voicechat")||l.hasOwnProperty("livestream"))e.joinVoiceChatByLink({username:i,inviteHash:l.voicechat||l.livestream});else if("c"===i&&f&&C){const a=`-${f}`;if(!(0,c.Z1)(t,a))return void e.showNotification({message:"Chat does not exist"});e.focusMessage({chatId:a,messageId:C})}else e.openChatByUsername({username:i,messageId:C||Number(f),commentId:m,startParam:l.start,startAttach:u,attach:l.attach})})),(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:i,commentId:d,startParam:l,startAttach:h,attach:p}=a,f=(0,c.jr)(t);if(!d)return f&&f.username===s&&!h?void e.focusMessage({chatId:f.id,messageId:i}):void await async function(t,e,a,s,i,r){if(i&&!r){const a=await b(e);if(!a)return;const s=(0,n.Rd)(),o=(0,c.dy)(s,a.id);if(!o)return;if(!(0,u.cS)(o)||!o.isAttachMenuBot)return void t.showNotification({message:I.i0("WebApp.AddToAttachmentUnavailableError")});const r=(0,c.jr)(s);if(!r)return;return void t.callAttachMenuBot({botId:o.id,chatId:r.id,..."string"==typeof i&&{startParam:i}})}t.openChat({id:o.AJ});const d=await b(e);if(!d)return t.openPreviousChat(),void t.showNotification({message:"User does not exist"});a?t.focusMessage({chatId:d.id,messageId:a}):t.openChat({id:d.id}),s&&t.startBot({botId:d.id,param:s}),r&&R(t,d.id,r,i)}(e,s,i,l,h,p);const{chatId:C,type:m}=(0,c.Bt)(t)||{},g=(0,c.DI)(t,s);if(C&&g&&"thread"===m){const a=(0,c.tZ)(t,C,i);if(a&&a.chatId===C)return void e.focusMessage({chatId:a.chatId,threadId:a.threadId,messageId:d})}i&&async function(t,e,a,s){t.openChat({id:o.AJ});const i=await b(e);if(!i)return;const d=(0,n.Rd)(),l=(0,c.tZ)(d,i.id,a);let h;if(l)h=l.chatId;else{const t=await(0,r.t9)("requestThreadInfoUpdate",{chat:i,threadId:a});if(!t)return;h=t.discussionChatId}h&&t.focusMessage({chatId:h,threadId:a,messageId:Number(s)})}(e,s,i,d)})),(0,n.iw)("togglePreHistoryHidden",(async(t,e,a)=>{const{chatId:n,isEnabled:s}=a;let i=(0,c.Z1)(t,n);if(i){if((0,u.G9)(i)){if(i=await(0,r.t9)("migrateChat",i),!i)return;e.openChat({id:i.id})}(0,r.t9)("togglePreHistoryHidden",{chat:i,isEnabled:s})}})),(0,n.iw)("updateChatDefaultBannedRights",((t,e,a)=>{const{chatId:n,bannedRights:s}=a,i=(0,c.Z1)(t,n);i&&(0,r.t9)("updateChatDefaultBannedRights",{chat:i,bannedRights:s})})),(0,n.iw)("updateChatMemberBannedRights",(async(t,e,a)=>{const{chatId:s,userId:i,bannedRights:o}=a;let l=(0,c.Z1)(t,s);const h=(0,c.dy)(t,i);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:o}),t=(0,n.Rd)();const p=(0,c.Z1)(t,s);if(!p||!p.fullInfo)return;const{members:f,kickedMembers:C}=p.fullInfo,m=Boolean(o.viewMessages),I=!Object.keys(o).length;(0,n.R3)((0,d.a4)(t,s,{fullInfo:{...p.fullInfo,...f&&m&&{members:f.filter((t=>t.userId!==i))},...f&&!m&&{members:f.map((t=>t.userId===i?{...t,bannedRights:o}:t))},...I&&C&&{kickedMembers:C.filter((t=>t.userId!==i))}}}))})),(0,n.iw)("updateChatAdmin",(async(t,e,a)=>{const{chatId:s,userId:i,adminRights:o,customTitle:l}=a;let h=(0,c.Z1)(t,s);const p=(0,c.dy)(t,i);if(!h||!p)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:p,adminRights:o,customTitle:l});const f=await(0,r.t9)("fetchFullChat",h);if(null==f||!f.fullInfo)return;const{adminMembers:C}=f.fullInfo,m=!Object.keys(o).length;t=(0,n.Rd)(),(0,n.R3)((0,d.a4)(t,s,{fullInfo:{...f.fullInfo,...C&&m&&{adminMembers:C.filter((t=>t.userId!==i))},...C&&!m&&{adminMembers:C.map((t=>t.userId===i?{...t,adminRights:o,customTitle:l}:t))}}}))})),(0,n.iw)("updateChat",(async(t,e,a)=>{const{chatId:s,title:o,about:l,photo:h}=a,u=(0,c.Z1)(t,s);u&&((0,n.R3)((0,d.H9)((0,n.Rd)(),i.wv.InProgress)),await Promise.all([u.title!==o?(0,r.t9)("updateChatTitle",u,o):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,n.R3)((0,d.H9)((0,n.Rd)(),i.wv.Complete)))})),(0,n.iw)("toggleSignatures",((t,e,a)=>{const{chatId:n,isEnabled:s}=a,i=(0,c.Z1)(t,n);i&&(0,r.t9)("toggleSignatures",{chat:i,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)),{});t=(0,n.Rd)(),t=(0,d.fZ)(t,a),(0,n.R3)({...t,chats:{...t.chats,forDiscussionIds:Object.keys(a)}})})),(0,n.iw)("linkDiscussionGroup",(async(t,e,a)=>{const{channelId:n,chatId:s}=a,i=(0,c.Z1)(t,n);let o=(0,c.Z1)(t,s);if(!i||!o)return;if((0,u.G9)(o)){if(o=await(0,r.t9)("migrateChat",o),!o)return;e.openChat({id:o.id})}let{fullInfo:d}=o;if(!d){const t=await(0,r.t9)("fetchFullChat",o);if(!t)return;d=t.fullInfo}d.isPreHistoryHidden&&await(0,r.t9)("togglePreHistoryHidden",{chat:o,isEnabled:!1}),(0,r.t9)("setDiscussionGroup",{channel:i,chat:o})})),(0,n.iw)("unlinkDiscussionGroup",(async(t,e,a)=>{var n;const{channelId:s}=a,i=(0,c.Z1)(t,s);if(!i)return;let o;null!==(n=i.fullInfo)&&void 0!==n&&n.linkedChatId&&(o=(0,c.Z1)(t,i.fullInfo.linkedChatId)),await(0,r.t9)("setDiscussionGroup",{channel:i}),o&&y(o)})),(0,n.iw)("setActiveChatFolder",((t,e,a)=>({...t,chatFolders:{...t.chatFolders,activeChatFolder:a}}))),(0,n.iw)("openChatWithText",((t,e,a)=>{const{chatId:s,text:i}=a;return e.openChat({id:s}),e.exitMessageSelectMode(),t=(0,n.Rd)(),{...t,openChatWithText:{chatId:s,text:i}}})),(0,n.iw)("resetOpenChatWithText",(t=>({...t,openChatWithText:void 0}))),(0,n.iw)("loadMoreMembers",(async t=>{var e,a;const{chatId:s}=(0,c.Bt)(t)||{},i=s?(0,c.Z1)(t,s):void 0;if(!i||(0,u.G9)(i))return;const o=(null===(e=i.fullInfo)||void 0===e||null===(a=e.members)||void 0===a?void 0:a.length)||void 0,h=await(0,r.t9)("fetchMembers",i.id,i.accessHash,"recent",o);if(!h)return;const{members:p,users:f,userStatusesById:C}=h;p&&p.length&&(t=(0,n.Rd)(),t=(0,d.Sh)(t,(0,l.ee)(f,"id")),t=(0,d.zn)(t,C),t=(0,d.iX)(t,i,p),(0,n.R3)(t))})),(0,n.iw)("addChatMembers",(async(t,e,a)=>{const{chatId:n,memberIds:s}=a,o=(0,c.Z1)(t,n),d=s.map((e=>(0,c.dy)(t,e))).filter(Boolean);o&&d.length&&(e.setNewChatMembersDialogState(i.WB.Loading),await(0,r.t9)("addChatMembers",o,d),e.setNewChatMembersDialogState(i.WB.Closed),y(o))})),(0,n.iw)("deleteChatMember",(async(t,e,a)=>{const{chatId:n,userId:s}=a,i=(0,c.Z1)(t,n),o=(0,c.dy)(t,s);i&&o&&(await(0,r.t9)("deleteChatMember",i,o),y(i))})),(0,n.iw)("toggleIsProtected",((t,e,a)=>{const{chatId:n,isProtected:s}=a,i=(0,c.Z1)(t,n);i&&(0,r.t9)("toggleIsProtected",{chat:i,isProtected:s})})),(0,n.iw)("setChatEnabledReactions",(async(t,e,a)=>{const{chatId:n,enabledReactions:s}=a,i=(0,c.Z1)(t,n);i&&(await(0,r.t9)("setChatEnabledReactions",{chat:i,enabledReactions:s}),y(i))})),(0,n.iw)("loadChatSettings",(async(t,e,a)=>{const{chatId:s}=a,i=(0,c.Z1)(t,s);if(!i)return;const o=await(0,r.t9)("fetchChatSettings",i);o&&(0,n.R3)((0,d.a4)((0,n.Rd)(),i.id,{settings:o}))}))},88422:(t,e,a)=>{a.d(e,{FF:()=>b,Mt:()=>M,NH:()=>R,o5:()=>v});var n=a(33555),s=a(42431),i=a(71226),o=a(11192),r=a(64319),d=a(78958),c=a(60782),l=a(5161),h=a(27225),u=a(74753),p=a(77361),f=a(50711);let C,m,I,g=Promise.resolve();const v=()=>{if(!g)return Promise.resolve();const t=new Audio("./voicechat_join.mp3"),e=new Audio("./voicechat_connecting.mp3");e.loop=!0;const a=new Audio("./voicechat_leave.mp3"),n=new Audio("./voicechat_onallowtalk.mp3"),s=new Audio("./call_busy.mp3"),i=new Audio("./call_connect.mp3"),o=new Audio("./call_end.mp3"),r=new Audio("./call_incoming.mp3");r.loop=!0;const d=new Audio("./call_ringing.mp3");return d.loop=!0,I={join:t,allowTalk:n,leave:a,connecting:e,incoming:r,end:o,connect:i,busy:s,ringing:d},g=Promise.all(Object.values(I).map((t=>(t.muted=!0,t.volume=1e-4,t.play().then((()=>{t.pause(),t.volume=1,t.currentTime=0,t.muted=!1})))))).then((()=>{g=void 0})),g};async function w(t){const e=await(0,i.t9)("getGroupCall",{call:t});if(!e)return;let a=(0,n.Rd)();const o=(0,s.$5)(a,t.id);return a=(0,d.AH)(a,t.id,(0,c.CE)(e.groupCall,["connectionState"]),void 0,null!=o&&o.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 y(t,e){const a=await(0,i.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 b(){return C}function R(){return m}function M(){var t;null===(t=C)||void 0===t||t.pause(),m=void 0,C=void 0}(0,n.iw)("toggleGroupCallPanel",(t=>({...t,isCallPanelVisible:!t.isCallPanelVisible}))),(0,n.iw)("subscribeToGroupCallUpdates",(async(t,e,a)=>{const{subscribed:n,id:o}=a,r=(0,s.$5)(t,o);r&&(n&&(await w(r),await y(r)),await(0,i.t9)("toggleGroupCallStartSubscription",{subscribed:n,call:r}))})),(0,n.iw)("createGroupCall",(async(t,e,a)=>{const{chatId:s}=a,r=(0,o.Z1)(t,s);if(!r)return;const c=await(0,i.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,o.Z1)(t,a.chatId);if(!n)return;const d=Boolean(n.username);let{inviteLink:c}=n.fullInfo;d&&(c=await(0,i.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,i=await(0,h.Co)(n);if(!i)return void e.showNotification({message:f.i0("NoUsernameFound")});const o=await(0,h.ft)(i);null!=o&&o.groupCall&&e.joinGroupCall({id:o.groupCall.id,accessHash:o.groupCall.accessHash,inviteHash:s})})),(0,n.iw)("joinGroupCall",(async(t,e,a)=>{var i;if(!p.Bi)return;if(t.phoneCall)return void e.toggleGroupCallPanel();const{chatId:o,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 v();const{groupCalls:{activeGroupCallId:h}}=t;let f=r?(0,s.$5)(t,r):(0,s.Bj)(t,o);(null===(i=f)||void 0===i?void 0:i.id)!==h?h?e.leaveGroupCall({rejoin:a}):f&&h===f.id?e.toggleGroupCallPanel():(f||r&&c||(f=await w({id:r,accessHash:c})),f&&(t=(0,n.Rd)(),t=(0,d.AH)(t,f.id,{...f,inviteHash:l},void 0,f.participantsCount+1),t={...t,groupCalls:{...t.groupCalls,activeGroupCallId:f.id},isCallPanelVisible:!1},(0,n.R3)(t))):e.toggleGroupCallPanel()})),(0,n.iw)("playGroupCallSound",((t,e,a)=>{const{sound:n}=a;if(!I[n])return;const s=()=>{"connecting"!==n&&I.connecting.pause(),"incoming"!==n&&I.incoming.pause(),"ringing"!==n&&I.ringing.pause(),(0,u.Z)(I[n])};g?g.then(s):s()})),(0,n.iw)("loadMoreGroupCallParticipants",(t=>{const e=(0,s.mU)(t);e&&y(e,e.nextOffset)})),(0,n.iw)("requestCall",(async(t,e,a)=>{const{userId:s,isVideo:i}=a;t.phoneCall?e.toggleGroupCallPanel():(0,o.dy)(t,s)&&(await v(),(0,n.R3)({...(0,n.Rd)(),phoneCall:{id:"",state:"requesting",participantId:s,isVideo:i,adminId:t.currentUserId},isCallPanelVisible:!1}))}))},78958:(t,e,a)=>{a.d(e,{AH:()=>r,B6:()=>l,Ic:()=>c,dc:()=>d});var n=a(42431),s=a(60782),i=a(53475),o=a(11192);function r(t,e,a,n,i){var o;const r=Object.values({...null===(o=t.groupCalls.byId[e])||void 0===o?void 0:o.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!==i&&{participantsCount:i},participants:r}}}}}function d(t,e){const a=(0,n.$5)(t,e);if(a&&a.chatId){const e=(0,o.Z1)(t,a.chatId);e&&(t=(0,i.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 i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=(0,n.$5)(t,e);return o?r(t,e,{participants:{...o.participants,[a]:{...o.participants[a],...s}}},s.isLeft?i?0:-1:o.participants[a]||i?0:1):t}},42431:(t,e,a)=>{a.d(e,{$5:()=>r,Bj:()=>o,GU:()=>d,Ht:()=>c,fu:()=>h,mU:()=>l});var n=a(14342),s=a(75806),i=a(86087);function o(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 i=null===(e=l(t))||void 0===e?void 0:e.chatId;if(!i)return!1;const o=(0,n.Z1)(t,i);return!!o&&((0,s.G9)(o)&&o.isCreator||Boolean(null===(a=o.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{phoneCall:e,currentUserId:a}=t;if(!e||!e.participantId||!e.adminId)return;const n=e.adminId===a?e.participantId:e.adminId;return(0,i.dy)(t,n)}},53551:(t,e,a)=>{a.d(e,{o:()=>i});var n=a(33555),s=a(77361);const i=t=>{const{protocol:e,searchParams:a,pathname:i,hostname:o}=new URL(t);if("tg:"!==e)return;const{openChatByInvite:r,openChatByUsername:d,openChatByPhoneNumber:c,openStickerSetShortName:l,focusMessage:h,joinVoiceChatByLink:u}=(0,n.Sv)(),p=(s.s$?o:i).replace(/^\/\//,""),f={};switch(a.forEach(((t,e)=>{f[e]=t})),p){case"resolve":{const{domain:t,phone:e,post:a,comment:n,voicechat:s,livestream:i,start:o,startattach:r,attach:l}=f,h=!(!f.hasOwnProperty("startattach")||r)||r;"telegrampassport"!==t&&(f.hasOwnProperty("voicechat")||f.hasOwnProperty("livestream")?u({username:t,inviteHash:s||i}):e?c({phone:e,startAttach:h,attach:l}):d({username:t,messageId:Number(a),commentId:Number(n),startParam:o,startAttach:h,attach:l}));break}case"privatepost":{const{post:t,channel:e}=f;h({chatId:`-${e}`,id:t});break}case"bg":case"share":case"msg":case"login":default:break;case"join":{const{invite:t}=f;r({hash:t});break}case"addstickers":{const{set:t}=f;l({stickerSetShortName:t});break}}}}}]);
//# sourceMappingURL=9970.7666831e8b537f6d4f74.js.map