TelegramPWA/dist/8422.b94cc539089b428eb2fb.js
Alexander Zinchuk ae695e6406 [Build]
2023-01-10 02:19:31 +01:00

2 lines
32 KiB
JavaScript

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[8422],{27225:(t,e,a)=>{a.d(e,{Co:()=>P,bZ:()=>M,ft:()=>b});var i=a(33555),s=a(6137),o=a(91713),n=a(83716),d=a(71226),c=a(5161),r=a(11192),l=a(60782),h=a(69118),u=a(56112),p=a(53551),f=a(78958),I=a(42431),C=a(16974),m=a(50711),g=a(9211);const w={id:n.awM,accessHash:"0",type:"userTypeRegular",isMin:!0,phoneNumber:""},v=(0,h.P2)((t=>t()),3e3,!0),y=(0,h.Ds)((t=>t()),500,!1,!0);async function R(t,e,a){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],h=arguments.length>4?arguments[4]:void 0,u=(0,i.Rd)();const p=(0,r.VF)(u)?.message,f=await(0,d.t9)("fetchChats",{limit:n.Ov0,offsetDate:a,archived:"archived"===t,withPinned:o,serverTimeOffset:u.serverTimeOffset,lastLocalServiceMessage:p});if(!f)return;const{chatIds:I}=f;if(I.length>0&&I[0]===e&&I.shift(),u=(0,i.Rd)(),o&&"active"===t){if(!I.includes(n.awM)){const t=await(0,d.t9)("fetchChat",{type:"user",user:w});u=(0,i.Rd)();const e=t&&(0,r.Z1)(u,t.chatId);e&&(I.unshift(e.id),f.chats.unshift(e),p&&(e.lastMessage=p))}const e=(0,r.jr)(u),a=e?[e]:[],s=(0,r.P2)(u)||[];u.currentUserId&&u.users.byId[u.currentUserId]&&s.push(u.users.byId[u.currentUserId]),u=(0,c.s5)(u,(0,l.ee)(s.concat(f.users),"id")),u=(0,c.ps)(u,f.userStatusesById),u=(0,c.SL)(u,(0,l.ee)(a.concat(f.chats),"id")),u=(0,c.Mg)(u,t,I)}else o&&"archived"===t?(u=(0,c.Sh)(u,(0,l.ee)(f.users,"id")),u=(0,c.zn)(u,f.userStatusesById),u=(0,c.GL)(u,(0,l.ee)(f.chats,"id")),u=(0,c.Mg)(u,t,I)):(u=(0,c.Sh)(u,(0,l.ee)(f.users,"id")),u=(0,c.zn)(u,f.userStatusesById),u=(0,c.GL)(u,(0,l.ee)(f.chats,"id")),u=(0,c.B1)(u,t,I));u=(0,c.vv)(u,t,f);const C=h?f.chatIds:Object.keys(f.draftsById);C.forEach((t=>{(0,r.Ms)(u,t,s._f)?.isLocal||(u=(0,c.pf)(u,t,s._f,"draft",f.draftsById[t]))}));const m=h?f.chatIds:Object.keys(f.replyingToById);m.forEach((t=>{u=(0,c.pf)(u,t,s._f,"replyingToId",f.replyingToById[t])})),0!==I.length||u.chats.isFullyLoaded[t]||(u={...u,chats:{...u.chats,isFullyLoaded:{...u.chats.isFullyLoaded,[t]:!0}}}),(0,i.R3)(u)}async function b(t){const e=await(0,d.t9)("fetchFullChat",t);if(!e)return;const{users:a,userStatusesById:s,fullInfo:o,groupCall:n,membersCount:r}=e;let h=(0,i.Rd)();if(a&&(h=(0,c.Sh)(h,(0,l.ee)(a,"id"))),s&&(h=(0,c.zn)(h,s)),n){const t=(0,I.$5)(h,n.id);h=(0,f.AH)(h,n.id,(0,l.CE)(n,["connectionState"]),void 0,t?void 0:n.participantsCount)}h=(0,c.a4)(h,t.id,{fullInfo:o,...r&&{membersCount:r}}),(0,i.R3)(h);const u=o.stickerSet;return u&&(0,i.Sv)().loadStickers({stickerSetInfo:{id:u.id,accessHash:u.accessHash}}),e}async function M(t){try{return await(0,d.t9)("migrateChat",t)}catch(t){return void("CHANNELS_TOO_MUCH"===t.message?(0,i.Sv)().openLimitReachedModal({limit:"channels"}):(0,i.Sv)().showDialog({data:{...t,hasErrorKey:!0}}))}}async function P(t){const e=(0,i.Rd)(),a=(0,r.DI)(e,t);if(a&&!a.isMin)return a;const{chat:s,user:o}=await(0,d.t9)("getChatByUsername",t)||{};return s?((0,i.R3)((0,c.a4)((0,i.Rd)(),s.id,s)),o&&(0,i.R3)((0,c.Nq)((0,i.Rd)(),o.id,o)),s):void 0}async function S(t,e){const a=await P(e);if(!a)return;t=(0,i.Rd)();const s=(0,r.dy)(t,a.id);return s?(0,u.cS)(s)&&s.isAttachBot?s:void(0,i.Sv)().showNotification({message:m.i0("WebApp.AddToAttachmentUnavailableError")}):void 0}async function T(t,e,a,s){const o=await P(a);if(!o)return;const n=(0,r.dy)((0,i.Rd)(),o.id);n&&n.isAttachBot?t.callAttachBot({botId:n.id,chatId:e,..."string"==typeof s&&{startParam:s}}):t.showNotification({message:m.i0("WebApp.AddToAttachmentUnavailableError")})}(0,i.iw)("preloadTopChatMessages",(async(t,e)=>{const a=new Set;for(let i=0;i<n.ulj;i++){await(0,h.wO)(100);const{chatId:i}=(0,r.Bt)(t)||{},o=(0,C.gO)(n.NfV)?.find((t=>t!==i&&!a.has(t)));if(!o)return;a.add(o),e.loadViewportMessages({chatId:o,threadId:s._f})}})),(0,i.iw)("openChat",((t,e,a)=>{const{id:i,threadId:o=s._f,noForumTopicPanel:n}=a;if(!i)return;const{currentUserId:c}=t,l=(0,r.Z1)(t,i);if(l?.hasUnreadMark&&e.toggleChatUnread({id:i}),l?.lastMessage?.repliesThreadInfo&&e.requestThreadInfoUpdate({chatId:l.lastMessage.repliesThreadInfo.chatId,threadId:l.lastMessage.repliesThreadInfo.threadId}),l?.isForum&&!n&&e.openForumPanel({chatId:i}),l)(0,u.Hp)(l)&&!l.isMin&&e.requestChatUpdate({chatId:i});else if(i===c)(0,d.t9)("fetchChat",{type:"self"});else{const e=(0,r.dy)(t,i);e&&(0,d.t9)("fetchChat",{type:"user",user:e})}o!==s._f&&((0,r.qS)(t,i,o)||e.requestThreadInfoUpdate({chatId:i,threadId:o}))})),(0,i.iw)("openLinkedChat",(async(t,e,a)=>{const{id:i}=a,s=(0,r.Z1)(t,i);if(!s)return;const o=await(0,d.t9)("fetchFullChat",s);o?.fullInfo?.linkedChatId&&e.openChat({id:o.fullInfo.linkedChatId})})),(0,i.iw)("focusMessageInComments",(async(t,e,a)=>{const{chatId:s,threadId:o,messageId:n}=a,h=(0,r.Z1)(t,s);if(!h)return;const u=await(0,d.t9)("requestThreadInfoUpdate",{chat:h,threadId:o});u&&(t=(0,i.Rd)(),t=(0,c.Sh)(t,(0,l.ee)(u.users,"id")),(0,i.R3)(t),e.focusMessage({chatId:s,threadId:o,messageId:n}))})),(0,i.iw)("openSupportChat",(async(t,e)=>{const a=(0,r.P_)(t);if(a)return void e.openChat({id:a.id,shouldReplaceHistory:!0});e.openChat({id:n.mzl,shouldReplaceHistory:!0});const i=await(0,d.t9)("fetchChat",{type:"support"});i&&e.openChat({id:i.chatId,shouldReplaceHistory:!0})})),(0,i.iw)("loadAllChats",(async(t,e,a)=>{const s=a.listType,{onReplace:o}=a;let{shouldReplace:d}=a,c=0;const l=t=>t.lastMessage?.date||t.joinDate;for(;d||!(0,i.Rd)().chats.isFullyLoaded[s];){if(c++>=100)return void(n.eMD&&console.error("`actions/loadAllChats`: Infinite loop detected"));if("connectionStateReady"!==(t=(0,i.Rd)()).connectionState||"authorizationStateReady"!==t.authState)return;const e=!d&&t.chats.listIds[s],a=e?e.map((e=>t.chats.byId[e])).filter((e=>Boolean(e&&l(e))&&e.id!==n.awM&&!(0,r.ep)(t,e.id))).sort(((t,e)=>l(t)-l(e)))[0]:void 0;await R(s,a?.id,a?l(a):void 0,d,!0),d&&(o?.(),d=!1)}})),(0,i.iw)("loadFullChat",((t,e,a)=>{const{chatId:i,force:s}=a,o=(0,r.Z1)(t,i);o&&(s?b(o):y((()=>b(o))))})),(0,i.iw)("loadTopChats",(()=>{v((()=>R("active")))})),(0,i.iw)("requestChatUpdate",((t,e,a)=>{const{serverTimeOffset:i}=t,{chatId:s}=a,o=(0,r.Z1)(t,s);o&&(0,d.t9)("requestChatUpdate",{chat:o,serverTimeOffset:i,...s===n.awM&&{lastLocalMessage:(0,r.VF)(t)?.message}})})),(0,i.iw)("updateChatMutedState",((t,e,a)=>{const{serverTimeOffset:s}=t,{chatId:o,isMuted:n}=a,l=(0,r.Z1)(t,o);l&&((0,i.R3)((0,c.a4)(t,o,{isMuted:n})),(0,d.t9)("updateChatMutedState",{chat:l,isMuted:n,serverTimeOffset:s}))})),(0,i.iw)("updateTopicMutedState",((t,e,a)=>{const{serverTimeOffset:s}=t,{chatId:o,isMuted:n,topicId:l}=a,h=(0,r.Z1)(t,o);h&&((0,i.R3)((0,c.Cn)(t,o,l,{isMuted:n})),(0,d.t9)("updateTopicMutedState",{chat:h,topicId:l,isMuted:n,serverTimeOffset:s}))})),(0,i.iw)("createChannel",((t,e,a)=>{const{title:s,about:n,photo:l,memberIds:h}=a;!async function(t,e,a,s){let n;(0,i.R3)({...(0,i.Rd)(),chatCreation:{progress:o.Nh.InProgress}});try{n=await(0,d.t9)("createChannel",{title:t,about:a,users:e})}catch(t){const e=(0,i.Rd)();(0,i.R3)({...e,chatCreation:{progress:o.Nh.Error}}),"CHANNELS_TOO_MUCH"===t.message?(0,i.Sv)().openLimitReachedModal({limit:"channels"}):(0,i.Sv)().showDialog({data:{...t,hasErrorKey:!0}})}if(!n)return;const{id:r,accessHash:l}=n;let h=(0,i.Rd)();h=(0,c.a4)(h,r,n),h={...h,chatCreation:{...h.chatCreation,progress:n?o.Nh.Complete:o.Nh.Error}},(0,i.R3)(h),(0,i.Sv)().openChat({id:r,shouldReplaceHistory:!0}),r&&l&&s&&await(0,d.t9)("editChatPhoto",{chatId:r,accessHash:l,photo:s})}(s,h.map((e=>(0,r.dy)(t,e))).filter(Boolean),n,l)})),(0,i.iw)("joinChannel",((t,e,a)=>{const{chatId:s}=a,o=(0,r.Z1)(t,s);if(!o)return;const{id:n,accessHash:c}=o;n&&c&&async function(t,e){try{await(0,d.t9)("joinChannel",{channelId:t,accessHash:e})}catch(t){"CHANNELS_TOO_MUCH"===t.message?(0,i.Sv)().openLimitReachedModal({limit:"channels"}):(0,i.Sv)().showDialog({data:{...t,hasErrorKey:!0}})}}(n,c)})),(0,i.iw)("deleteChatUser",((t,e,a)=>{const{chatId:s,userId:o}=a,n=(0,r.Z1)(t,s),l=(0,r.dy)(t,o);n&&l&&(t=(0,c.Dd)(t,s),(0,i.R3)(t),(0,r.Bt)(t)?.chatId===s&&e.openChat({id:void 0}),(0,d.t9)("deleteChatUser",{chat:n,user:l}))})),(0,i.iw)("deleteChat",((t,e,a)=>{const{chatId:s}=a,o=(0,r.Z1)(t,s);o&&(t=(0,c.Dd)(t,s),(0,i.R3)(t),(0,r.Bt)(t)?.chatId===s&&e.openChat({id:void 0}),(0,d.t9)("deleteChat",{chatId:o.id}))})),(0,i.iw)("leaveChannel",((t,e,a)=>{const{chatId:s}=a,o=(0,r.Z1)(t,s);if(!o)return;t=(0,c.Dd)(t,s),(0,i.R3)(t),(0,r.Bt)(t)?.chatId===s&&e.openChat({id:void 0});const{id:n,accessHash:l}=o;n&&l&&(0,d.t9)("leaveChannel",{channelId:n,accessHash:l})})),(0,i.iw)("deleteChannel",((t,e,a)=>{const{chatId:s}=a,o=(0,r.Z1)(t,s);if(!o)return;t=(0,c.Dd)(t,s),(0,i.R3)(t),(0,r.Bt)(t)?.chatId===s&&e.openChat({id:void 0});const{id:n,accessHash:l}=o;n&&l&&(0,d.t9)("deleteChannel",{channelId:n,accessHash:l})})),(0,i.iw)("createGroupChat",((t,e,a)=>{const{title:s,memberIds:n,photo:l}=a;!async function(t,e,a){(0,i.R3)({...(0,i.Rd)(),chatCreation:{progress:o.Nh.InProgress}});try{const s=await(0,d.t9)("createGroupChat",{title:t,users:e});if(!s)return;const{id:n}=s;let r=(0,i.Rd)();r=(0,c.a4)(r,n,s),r={...r,chatCreation:{...r.chatCreation,progress:s?o.Nh.Complete:o.Nh.Error}},(0,i.R3)(r),(0,i.Sv)().openChat({id:n,shouldReplaceHistory:!0}),n&&a&&await(0,d.t9)("editChatPhoto",{chatId:n,photo:a})}catch(t){if("USERS_TOO_FEW"===t.message){const t=(0,i.Rd)();(0,i.R3)({...t,chatCreation:{...t.chatCreation,progress:o.Nh.Error,error:"CreateGroupError"}})}}}(s,n.map((e=>(0,r.dy)(t,e))).filter(Boolean),l)})),(0,i.iw)("toggleChatPinned",((t,e,a)=>{const{id:i,folderId:s}=a,o=(0,r.Z1)(t,i);if(!o)return;const c=(0,g.M)(t,"dialogFolderPinned");if(s){const e=(0,r.Mw)(t,s);if(e){const a=!(0,r.ep)(t,i,s),{pinnedChatIds:o,includedChatIds:n}=e,c=a?[i,...o||[]]:(o||[]).filter((t=>t!==i)),l=[i,...n];(0,d.t9)("editChatFolder",{id:s,folderUpdate:{...e,pinnedChatIds:c,includedChatIds:l}})}}else{const a=(0,r.Ek)(t,i),s=(0,r.ep)(t,i,"archived"===a?n.WSp:void 0);if((t.chats.orderedPinnedIds["archived"===a?"archived":"active"]?.length||0)>=c&&!s)return void e.openLimitReachedModal({limit:"dialogFolderPinned"});(0,d.t9)("toggleChatPinned",{chat:o,shouldBePinned:!s})}})),(0,i.iw)("toggleChatArchived",((t,e,a)=>{const{id:i}=a,s=(0,r.Z1)(t,i);s&&(0,d.t9)("toggleChatArchived",{chat:s,folderId:(0,u.pE)(s)?0:n.WSp})})),(0,i.iw)("loadChatFolders",(()=>{!async function(){const t=await(0,d.t9)("fetchChatFolders");if(t){const e=(0,i.Rd)();(0,i.R3)({...e,chatFolders:{...e.chatFolders,...t}})}}()})),(0,i.iw)("loadRecommendedChatFolders",(()=>{!async function(){const t=await(0,d.t9)("fetchRecommendedChatFolders");if(t){const e=(0,i.Rd)();(0,i.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}})}}()})),(0,i.iw)("editChatFolders",((t,e,a)=>{const{chatId:i,idsToRemove:s,idsToAdd:o}=a,n=(0,g.M)(t,"dialogFiltersChats");o.some((e=>(0,r.Mw)(t,e).includedChatIds.length>=n))?e.openLimitReachedModal({limit:"dialogFiltersChats"}):(s.forEach((async e=>{const a=(0,r.Mw)(t,e);a&&await(0,d.t9)("editChatFolder",{id:e,folderUpdate:{...a,pinnedChatIds:a.pinnedChatIds?.filter((t=>t!==i)),includedChatIds:a.includedChatIds.filter((t=>t!==i))}})})),o.forEach((async e=>{const a=(0,r.Mw)(t,e);a&&await(0,d.t9)("editChatFolder",{id:e,folderUpdate:{...a,includedChatIds:a.includedChatIds.concat(i)}})})))})),(0,i.iw)("editChatFolder",((t,e,a)=>{const{id:i,folderUpdate:s}=a,o=(0,r.Mw)(t,i);o&&(0,d.t9)("editChatFolder",{id:i,folderUpdate:{id:i,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...s}})})),(0,i.iw)("addChatFolder",((t,e,a)=>{const{folder:s}=a,{orderedIds:o,byId:c}=t.chatFolders,r=(0,g.M)(t,"dialogFilters");Object.keys(c).length>=r?e.openLimitReachedModal({limit:"dialogFilters"}):async function(t,e){const{id:a,description:s,...o}=t;if(await(0,d.t9)("editChatFolder",{id:e+1,folderUpdate:{id:e+1,...o}}),!s)return;const n=(0,i.Rd)(),{recommended:c}=n.chatFolders;c&&(0,i.R3)({...n,chatFolders:{...n.chatFolders,recommended:c.filter((t=>{let{id:e}=t;return e!==a}))}})}(s,Math.max(...o||[],n.WSp))})),(0,i.iw)("sortChatFolders",(async(t,e,a)=>{const{folderIds:s}=a;await(0,d.t9)("sortChatFolders",s)&&(t=(0,i.Rd)(),(0,i.R3)({...t,chatFolders:{...t.chatFolders,orderedIds:s}}))})),(0,i.iw)("deleteChatFolder",((t,e,a)=>{const{id:i}=a;(0,r.Mw)(t,i)&&async function(t){await(0,d.t9)("deleteChatFolder",t)}(i)})),(0,i.iw)("toggleChatUnread",((t,e,a)=>{const{id:i}=a,{serverTimeOffset:o}=t,n=(0,r.Z1)(t,i);n&&(n.unreadCount?(0,d.t9)("markMessageListRead",{serverTimeOffset:o,chat:n,threadId:s._f}):(0,d.t9)("toggleDialogUnread",{chat:n,hasUnreadMark:!n.hasUnreadMark}))})),(0,i.iw)("markTopicRead",((t,e,a)=>{const{chatId:s,topicId:o}=a,n=(0,r.Z1)(t,s);if(!n)return;const l=n.topics?.[o]?.lastMessageId;l&&((0,d.t9)("markMessageListRead",{chat:n,threadId:o,maxId:l,serverTimeOffset:t.serverTimeOffset}),t=(0,i.Rd)(),t=(0,c.Cn)(t,s,o,{unreadCount:0}),t=(0,c.Xg)(t,s,o,{lastReadInboxMessageId:l}),(0,i.R3)(t))})),(0,i.iw)("openChatByInvite",(async(t,e,a)=>{const{hash:i}=a,s=await(0,d.t9)("openChatByInvite",i);s&&e.openChat({id:s.chatId})})),(0,i.iw)("openChatByPhoneNumber",(async(t,e,a)=>{const{phoneNumber:s,startAttach:o,attach:l}=a;e.openChat({id:n.mzl});const h=await async function(t){const e=(0,i.Rd)(),a=(0,r.Bk)(e,t);if(a&&!a.isMin)return(0,r.Z1)(e,a.id);const{chat:s,user:o}=await(0,d.t9)("getChatByPhoneNumber",t)||{};return s?((0,i.R3)((0,c.a4)((0,i.Rd)(),s.id,s)),o&&(0,i.R3)((0,c.Nq)((0,i.Rd)(),o.id,o)),s):void 0}(s);if(!h)return e.openPreviousChat(),void e.showNotification({message:m.i0("lng_username_by_phone_not_found").replace("{phone}",s)});e.openChat({id:h.id}),l&&T(e,h.id,l,o)})),(0,i.iw)("openTelegramLink",((t,e,a)=>{const{url:i}=a,{openChatByPhoneNumber:s,openChatByInvite:o,openStickerSet:d,openChatWithDraft:c,joinVoiceChatByLink:l,showNotification:h,focusMessage:u,openInvoice:f,processAttachBotParameters:I,openChatByUsername:C}=e;if(i.match(n.g$l))return void(0,p.ou)(i);const m=new URL(i.startsWith("http")?i:`https://${i}`);if("t.me"===m.hostname&&"/"===m.pathname)return void window.open(m.toString(),"_blank","noopener");const g=m.hostname.split(".");if(g.length>3)return;const w=3===g.length?`${g[0]}/${m.pathname}`:m.pathname,[v,y,R]=w.split("/").filter(Boolean).map((t=>decodeURI(t))),b=Object.fromEntries(m.searchParams);let M;"joinchat"===v&&(M=y);const P=!(!b.hasOwnProperty("startattach")||b.startattach)||b.startattach,S=(0,p.GX)(b.choose);if(v.match(/^\+([0-9]+)(\?|$)/))return void s({phoneNumber:v.substr(1,v.length-1),startAttach:P,attach:b.attach});if((v.startsWith(" ")||v.startsWith("+"))&&(M=v.substr(1,v.length-1)),M)return void o({hash:M});if("addstickers"===v||"addemoji"===v)return void d({stickerSetInfo:{shortName:y}});const T=y||void 0,F=R?Number(R):void 0,H=b.comment?Number(b.comment):void 0;if("share"===v)c({text:(0,p.QH)(b.url,b.text)});else if(b.hasOwnProperty("voicechat")||b.hasOwnProperty("livestream"))l({username:v,inviteHash:b.voicechat||b.livestream});else if("c"===v&&T&&F){const e=`-${T}`;if(!(0,r.Z1)(t,e))return void h({message:"Chat does not exist"});u({chatId:e,messageId:F})}else v.startsWith("$")?f({slug:v.substring(1)}):"invoice"===v?f({slug:y}):P&&S?I({username:v,filter:S,..."string"==typeof P&&{startParam:P}}):C({username:v,messageId:F||Number(T),threadId:F?Number(T):void 0,commentId:H,startParam:b.start,startAttach:P,attach:b.attach})})),(0,i.iw)("acceptInviteConfirmation",(async(t,e,a)=>{const{hash:i}=a,s=await(0,d.t9)("importChatInvite",{hash:i});s&&e.openChat({id:s.id})})),(0,i.iw)("openChatByUsername",(async(t,e,a)=>{const{username:s,messageId:o,commentId:h,startParam:u,startAttach:p,attach:f,threadId:I}=a,C=(0,r.jr)(t);if(!h)return p||u||!C?.usernames?.some((t=>t.username===s))?void await async function(t,e,a,s,o,d,c){const l=(0,i.Rd)(),h=(0,r.jr)(l);if(d&&!c){const a=await S(l,e);if(!h||!a)return;return void t.callAttachBot({botId:a.id,chatId:h.id,..."string"==typeof d&&{startParam:d}})}const u=h?.usernames?.some((t=>t.username===e));u||t.openChat({id:n.mzl});const p=await P(e);p?(s?t.focusMessage({chatId:p.id,threadId:a,messageId:s}):u||t.openChat({id:p.id,threadId:a}),o&&t.startBot({botId:p.id,param:o}),c&&T(t,p.id,c,d)):u||(t.openPreviousChat(),t.showNotification({message:"User does not exist"}))}(e,s,I,o,u,p,f):void e.focusMessage({chatId:C.id,threadId:I,messageId:o});const{chatId:m,type:g}=(0,r.Bt)(t)||{},w=(0,r.DI)(t,s);if(m&&w&&"thread"===g){const a=(0,r.tZ)(t,m,o);if(a&&a.chatId===m)return void e.focusMessage({chatId:a.chatId,threadId:a.threadId,messageId:h})}o&&async function(t,e,a,s){t.openChat({id:n.mzl});const o=await P(e);if(!o)return;let h=(0,i.Rd)();const u=(0,r.tZ)(h,o.id,a);let p;if(u)p=u.chatId;else{const t=await(0,d.t9)("requestThreadInfoUpdate",{chat:o,threadId:a});if(!t)return;h=(0,i.Rd)(),h=(0,c.Sh)(h,(0,l.ee)(t.users,"id")),(0,i.R3)(h),p=t.discussionChatId}p&&t.focusMessage({chatId:p,threadId:a,messageId:Number(s)})}(e,s,o,h)})),(0,i.iw)("togglePreHistoryHidden",(async(t,e,a)=>{const{chatId:s,isEnabled:o}=a;let n=(0,r.Z1)(t,s);if(n){if((0,u.G9)(n)){if(n=await M(n),t=(0,i.Rd)(),!n)return;e.openChat({id:n.id})}(0,i.R3)((0,c.a4)(t,n.id,{fullInfo:{...n.fullInfo,isPreHistoryHidden:o}})),(0,d.t9)("togglePreHistoryHidden",{chat:n,isEnabled:o})}})),(0,i.iw)("updateChatDefaultBannedRights",((t,e,a)=>{const{chatId:i,bannedRights:s}=a,o=(0,r.Z1)(t,i);o&&(0,d.t9)("updateChatDefaultBannedRights",{chat:o,bannedRights:s})})),(0,i.iw)("updateChatMemberBannedRights",(async(t,e,a)=>{const{chatId:s,userId:o,bannedRights:n}=a;let l=(0,r.Z1)(t,s);const h=(0,r.dy)(t,o);if(!l||!h)return;if((0,u.G9)(l)){if(l=await M(l),!l)return;e.openChat({id:l.id})}await(0,d.t9)("updateChatMemberBannedRights",{chat:l,user:h,bannedRights:n}),t=(0,i.Rd)();const p=(0,r.Z1)(t,s);if(!p||!p.fullInfo)return;const{members:f,kickedMembers:I}=p.fullInfo,C=Boolean(n.viewMessages),m=!Object.keys(n).length;(0,i.R3)((0,c.a4)(t,s,{fullInfo:{...p.fullInfo,...f&&C&&{members:f.filter((t=>t.userId!==o))},...f&&!C&&{members:f.map((t=>t.userId===o?{...t,bannedRights:n}:t))},...m&&I&&{kickedMembers:I.filter((t=>t.userId!==o))}}}))})),(0,i.iw)("updateChatAdmin",(async(t,e,a)=>{const{chatId:s,userId:o,adminRights:n,customTitle:l}=a;let h=(0,r.Z1)(t,s);const p=(0,r.dy)(t,o);if(!h||!p)return;if((0,u.G9)(h)){if(h=await M(h),!h)return;e.openChat({id:h.id})}await(0,d.t9)("updateChatAdmin",{chat:h,user:p,adminRights:n,customTitle:l});const f=await(0,d.t9)("fetchFullChat",h);if(!f?.fullInfo)return;const{adminMembersById:I}=f.fullInfo,C=!Object.keys(n).length;let m;if(I)if(C){const{[o]:t,...e}=I;m=e}else m={...I,[o]:{...I[o],adminRights:n,customTitle:l}};t=(0,i.Rd)(),(0,i.R3)((0,c.a4)(t,s,{fullInfo:{...f.fullInfo,...m&&{adminMembersById:m}}}))})),(0,i.iw)("updateChat",(async(t,e,a)=>{const{chatId:s,title:n,about:l,photo:h}=a,u=(0,r.Z1)(t,s);u&&((0,i.R3)((0,c.H9)((0,i.Rd)(),o.wv.InProgress)),await Promise.all([u.title!==n?(0,d.t9)("updateChatTitle",u,n):void 0,u.fullInfo&&u.fullInfo.about!==l?(0,d.t9)("updateChatAbout",u,l):void 0,h?(0,d.t9)("editChatPhoto",{chatId:s,accessHash:u.accessHash,photo:h}):void 0]),(0,i.R3)((0,c.H9)((0,i.Rd)(),o.wv.Complete)))})),(0,i.iw)("updateChatPhoto",(async(t,e,a)=>{const{photo:s,chatId:o}=a,n=(0,r.Z1)(t,o);n&&((0,i.R3)((0,c.a4)(t,o,{avatarHash:void 0,fullInfo:{...n.fullInfo,profilePhoto:void 0}})),await(0,d.t9)("editChatPhoto",{chatId:o,accessHash:n.accessHash,photo:s}),await(0,d.t9)("deleteProfilePhotos",[s]),e.loadFullChat({chatId:o}),e.loadProfilePhotos({profileId:o}))})),(0,i.iw)("deleteChatPhoto",(async(t,e,a)=>{const{photo:s,chatId:o}=a,n=(0,r.Z1)(t,o);if(!n)return;const l=[s];if(n.avatarHash===s.id){const e=n.photos?.[1];e&&l.push(e),(0,i.R3)((0,c.a4)(t,o,{avatarHash:void 0,fullInfo:{...n.fullInfo,profilePhoto:void 0}})),await(0,d.t9)("editChatPhoto",{chatId:o,accessHash:n.accessHash,photo:e})}await(0,d.t9)("deleteProfilePhotos",l)&&(e.loadFullChat({chatId:o}),e.loadProfilePhotos({profileId:o}))})),(0,i.iw)("toggleSignatures",((t,e,a)=>{const{chatId:i,isEnabled:s}=a,o=(0,r.Z1)(t,i);o&&(0,d.t9)("toggleSignatures",{chat:o,isEnabled:s})})),(0,i.iw)("loadGroupsForDiscussion",(async t=>{const e=await(0,d.t9)("fetchGroupsForDiscussion");if(!e)return;const a=e.reduce(((t,e)=>(e&&!e.isForum&&(t[e.id]=e),t)),{});t=(0,i.Rd)(),t=(0,c.fZ)(t,a),(0,i.R3)({...t,chats:{...t.chats,forDiscussionIds:Object.keys(a)}})})),(0,i.iw)("linkDiscussionGroup",(async(t,e,a)=>{const{channelId:s,chatId:o}=a,n=(0,r.Z1)(t,s);let l=(0,r.Z1)(t,o);if(!n||!l)return;if((0,u.G9)(l)){if(l=await M(l),!l)return;e.openChat({id:l.id})}let{fullInfo:h}=l;if(!h){const t=await(0,d.t9)("fetchFullChat",l);if(!t)return;h=t.fullInfo}h.isPreHistoryHidden&&(t=(0,i.Rd)(),(0,i.R3)((0,c.a4)(t,l.id,{fullInfo:{...l.fullInfo,isPreHistoryHidden:!1}})),await(0,d.t9)("togglePreHistoryHidden",{chat:l,isEnabled:!1})),(0,d.t9)("setDiscussionGroup",{channel:n,chat:l})})),(0,i.iw)("unlinkDiscussionGroup",(async(t,e,a)=>{const{channelId:i}=a,s=(0,r.Z1)(t,i);if(!s)return;let o;s.fullInfo?.linkedChatId&&(o=(0,r.Z1)(t,s.fullInfo.linkedChatId)),await(0,d.t9)("setDiscussionGroup",{channel:s}),o&&b(o)})),(0,i.iw)("setActiveChatFolder",((t,e,a)=>{if(!(a+1>(0,g.M)(t,"dialogFilters")))return{...t,chatFolders:{...t.chatFolders,activeChatFolder:a}};e.openLimitReachedModal({limit:"dialogFilters"})})),(0,i.iw)("resetOpenChatWithDraft",(t=>({...t,requestedDraft:void 0}))),(0,i.iw)("loadMoreMembers",(async t=>{const{chatId:e}=(0,r.Bt)(t)||{},a=e?(0,r.Z1)(t,e):void 0;if(!a||(0,u.G9)(a))return;const s=a.fullInfo?.members?.length||void 0,o=await(0,d.t9)("fetchMembers",a.id,a.accessHash,"recent",s);if(!o)return;const{members:n,users:h,userStatusesById:p}=o;n&&n.length&&(t=(0,i.Rd)(),t=(0,c.Sh)(t,(0,l.ee)(h,"id")),t=(0,c.zn)(t,p),t=(0,c.iX)(t,a,n),(0,i.R3)(t))})),(0,i.iw)("addChatMembers",(async(t,e,a)=>{const{chatId:i,memberIds:s}=a,n=(0,r.Z1)(t,i),c=s.map((e=>(0,r.dy)(t,e))).filter(Boolean);n&&c.length&&(e.setNewChatMembersDialogState(o.WB.Loading),await(0,d.t9)("addChatMembers",n,c),e.setNewChatMembersDialogState(o.WB.Closed),b(n))})),(0,i.iw)("deleteChatMember",(async(t,e,a)=>{const{chatId:i,userId:s}=a,o=(0,r.Z1)(t,i),n=(0,r.dy)(t,s);o&&n&&(await(0,d.t9)("deleteChatMember",o,n),b(o))})),(0,i.iw)("toggleIsProtected",((t,e,a)=>{const{chatId:i,isProtected:s}=a,o=(0,r.Z1)(t,i);o&&(0,d.t9)("toggleIsProtected",{chat:o,isProtected:s})})),(0,i.iw)("setChatEnabledReactions",(async(t,e,a)=>{const{chatId:i,enabledReactions:s}=a,o=(0,r.Z1)(t,i);o&&(await(0,d.t9)("setChatEnabledReactions",{chat:o,enabledReactions:s}),b(o))})),(0,i.iw)("loadChatSettings",(async(t,e,a)=>{const{chatId:s}=a,o=(0,r.Z1)(t,s);if(!o)return;const n=await(0,d.t9)("fetchChatSettings",o);if(!n)return;const{settings:h,users:u}=n;t=(0,i.Rd)(),t=(0,c.Sh)(t,(0,l.ee)(u,"id")),(0,i.R3)((0,c.a4)(t,o.id,{settings:h}))})),(0,i.iw)("toggleJoinToSend",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,o=(0,r.Z1)(t,i);o&&((0,u.ZV)(o)||(0,u.eA)(o))&&await(0,d.t9)("toggleJoinToSend",o,s)})),(0,i.iw)("toggleJoinRequest",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,o=(0,r.Z1)(t,i);o&&((0,u.ZV)(o)||(0,u.eA)(o))&&await(0,d.t9)("toggleJoinRequest",o,s)})),(0,i.iw)("openForumPanel",((t,e,a)=>{const{chatId:i}=a;return{...t,forumPanelChatId:i}})),(0,i.iw)("closeForumPanel",(t=>({...t,forumPanelChatId:void 0}))),(0,i.iw)("processAttachBotParameters",(async(t,e,a)=>{const{username:s,filter:o,startParam:n}=a,d=await S(t,s);if(!d)return;t=(0,i.Rd)();const{attachMenu:{bots:c}}=t;c[d.id]?(0,i.Sv)().requestAttachBotInChat({botId:d.id,filter:o,startParam:n}):(0,i.R3)({...t,requestedAttachBotInstall:{botId:d.id,onConfirm:{action:"requestAttachBotInChat",payload:{botId:d.id,filter:o,startParam:n}}}})})),(0,i.iw)("loadTopics",(async(t,e,a)=>{const{chatId:s,force:o}=a,h=(0,r.Z1)(t,s);if(!h)return;if(!o&&h.listedTopicIds&&h.listedTopicIds.length===h.topicsCount)return;const u=!o&&h.listedTopicIds?h.listedTopicIds.reduce(((t,e)=>{const a=h.topics?.[e],i=h.topics?.[t];return a&&(!i||a.lastMessageId<i.lastMessageId)?e:t})):void 0,{id:p,date:f,lastMessageId:I}=u&&h.topics?.[u]||{},C=await(0,d.t9)("fetchTopics",{chat:h,offsetTopicId:p,offsetId:I,offsetDate:f,limit:p?n.C1M:n.SC4});C&&(t=(0,i.Rd)(),t=(0,c.Sh)(t,(0,l.ee)(C.users,"id")),t=(0,c.fZ)(t,(0,l.ee)(C.chats,"id")),t=(0,c.m6)(t,C.messages),t=(0,c.XG)(t,s,C.count,C.topics),t=(0,c.Jr)(t,s,C.topics.map((t=>t.id))),Object.entries(C.draftsById||{}).forEach((e=>{let[a,i]=e;t=(0,c.pf)(t,s,Number(a),"draft",i?.formattedText),t=(0,c.pf)(t,s,Number(a),"replyingToId",i?.replyingToId)})),Object.entries(C.readInboxMessageIdByTopicId||{}).forEach((e=>{let[a,i]=e;t=(0,c.Xg)(t,s,Number(a),{lastReadInboxMessageId:i})})),(0,i.R3)(t))})),(0,i.iw)("loadTopicById",(async(t,e,a)=>{const{chatId:s,topicId:o,shouldCloseChatOnError:n}=a,h=(0,r.Z1)(t,s);if(!h)return;const u=await(0,d.t9)("fetchTopicById",{chat:h,topicId:o});u?(t=(0,i.Rd)(),t=(0,c.Sh)(t,(0,l.ee)(u.users,"id")),t=(0,c.fZ)(t,(0,l.ee)(u.chats,"id")),t=(0,c.m6)(t,u.messages),t=(0,c.Cn)(t,s,o,u.topic),(0,i.R3)(t)):n&&e.openChat({id:void 0})})),(0,i.iw)("toggleForum",(async(t,e,a)=>{const{chatId:s,isEnabled:o}=a,n=(0,r.Z1)(t,s);if(!n)return;const l=n.isForum;t=(0,c.a4)(t,s,{isForum:o}),(0,i.R3)(t),await(0,d.t9)("toggleForum",{chat:n,isEnabled:o})||(t=(0,i.Rd)(),t=(0,c.a4)(t,s,{isForum:l}),(0,i.R3)(t))})),(0,i.iw)("createTopic",(async(t,e,a)=>{const{chatId:s,title:o,iconColor:n,iconEmojiId:c}=a,l=(0,r.Z1)(t,s);if(!l)return;(0,i.R3)({...t,createTopicPanel:{chatId:s,isLoading:!0}});const h=await(0,d.t9)("createTopic",{chat:l,title:o,iconColor:n,iconEmojiId:c});h&&e.openChat({id:s,threadId:h,shouldReplaceHistory:!0}),e.closeCreateTopicPanel()})),(0,i.iw)("deleteTopic",(async(t,e,a)=>{const{chatId:s,topicId:o}=a,n=(0,r.Z1)(t,s);n&&await(0,d.t9)("deleteTopic",{chat:n,topicId:o})&&(t=(0,i.Rd)(),t=(0,c.BK)(t,s,o),(0,i.R3)(t))})),(0,i.iw)("editTopic",(async(t,e,a)=>{const{chatId:s,topicId:o,...n}=a,l=(0,r.Z1)(t,s),h=l?.topics?.[o];l&&h&&((0,i.R3)({...t,editTopicPanel:{chatId:s,topicId:o,isLoading:!0}}),await(0,d.t9)("editTopic",{chat:l,topicId:o,...n})&&(t=(0,i.Rd)(),t=(0,c.Cn)(t,s,o,n),(0,i.R3)(t),e.closeEditTopicPanel()))})),(0,i.iw)("toggleTopicPinned",((t,e,a)=>{const{chatId:i,topicId:s,isPinned:o}=a,{topicsPinnedLimit:n}=t.appConfig||{},c=(0,r.Z1)(t,i);c&&c.topics&&n&&(o&&Object.values(c.topics).filter((t=>t.isPinned)).length>=n?e.showNotification({message:m.i0("LimitReachedPinnedTopics",n,"i")}):(0,d.t9)("togglePinnedTopic",{chat:c,topicId:s,isPinned:o}))}))},88422:(t,e,a)=>{a.d(e,{CW:()=>S,FF:()=>b,Mt:()=>P,NH:()=>M,o5:()=>v});var i=a(33555),s=a(71226),o=a(27225),n=a(5161),d=a(78958),c=a(42431),r=a(11192),l=a(56112),h=a(64319),u=a(60782),p=a(74753),f=a(77361),I=a(50711);let C,m,g,w=Promise.resolve();const v=()=>{if(!w)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"),i=new Audio("./voicechat_onallowtalk.mp3"),s=new Audio("./call_busy.mp3"),o=new Audio("./call_connect.mp3"),n=new Audio("./call_end.mp3"),d=new Audio("./call_incoming.mp3");d.loop=!0;const c=new Audio("./call_ringing.mp3");return c.loop=!0,g={join:t,allowTalk:i,leave:a,connecting:e,incoming:d,end:n,connect:o,busy:s,ringing:c},w=Promise.all(Object.values(g).map((t=>(t.muted=!0,t.volume=1e-4,t.play().then((()=>{t.pause(),t.volume=1,t.currentTime=0,t.muted=!1})))))).then((()=>{w=void 0})),w};async function y(t){const e=await(0,s.t9)("getGroupCall",{call:t});if(!e)return;let a=(0,i.Rd)();const o=(0,c.$5)(a,t.id);return a=(0,d.AH)(a,t.id,(0,u.CE)(e.groupCall,["connectionState"]),void 0,o?.isLoaded?void 0:e.groupCall.participantsCount),a=(0,n.Sh)(a,(0,u.ee)(e.users,"id")),a=(0,n.fZ)(a,(0,u.ee)(e.chats,"id")),(0,i.R3)(a),e.groupCall}async function R(t,e){const a=await(0,s.t9)("fetchGroupCallParticipants",{call:t,offset:e});if(!a)return;let o=(0,i.Rd)();o=(0,n.Sh)(o,(0,u.ee)(a.users,"id")),o=(0,n.fZ)(o,(0,u.ee)(a.chats,"id")),(0,i.R3)(o)}function b(){return C}function M(){return m}function P(){C?.pause(),m=void 0,C=void 0}function S(t){t?navigator.mediaDevices.getUserMedia({video:!0}).then((t=>{0===t.getVideoTracks().length?(0,i.Sv)().showNotification({message:I.i0("Call.Camera.Error")}):T()})).catch((()=>{(0,i.Sv)().showNotification({message:I.i0("Call.Camera.Error")})})):T()}function T(){navigator.mediaDevices.getUserMedia({audio:!0}).then((t=>{0===t.getAudioTracks().length&&(0,i.Sv)().showNotification({message:I.i0("RequestAcces.Error.HaveNotAccess.Call")})})).catch((()=>{(0,i.Sv)().showNotification({message:I.i0("RequestAcces.Error.HaveNotAccess.Call")})}))}(0,i.iw)("toggleGroupCallPanel",(t=>({...t,isCallPanelVisible:!t.isCallPanelVisible}))),(0,i.iw)("subscribeToGroupCallUpdates",(async(t,e,a)=>{const{subscribed:i,id:o}=a,n=(0,c.$5)(t,o);n&&(i&&(await y(n),await R(n)),await(0,s.t9)("toggleGroupCallStartSubscription",{subscribed:i,call:n}))})),(0,i.iw)("createGroupCall",(async(t,e,a)=>{const{chatId:o}=a,n=(0,r.Z1)(t,o);if(!n)return;const c=await(0,s.t9)("createGroupCall",{peer:n});c&&(t=(0,i.Rd)(),(0,i.R3)((0,d.AH)(t,c.id,{...c,chatId:o})),e.joinGroupCall({id:c.id,accessHash:c.accessHash}))})),(0,i.iw)("createGroupCallInviteLink",(async(t,e)=>{const a=(0,c.mU)(t);if(!a||!a.chatId)return;const i=(0,r.Z1)(t,a.chatId);if(!i)return;const o=Boolean((0,l.WS)(i));let{inviteLink:n}=i.fullInfo;o&&(n=await(0,s.t9)("exportGroupCallInvite",{call:a,canSelfUnmute:!1})),n&&((0,h.TE)(n),e.showNotification({message:"Link copied to clipboard"}))})),(0,i.iw)("joinVoiceChatByLink",(async(t,e,a)=>{const{username:i,inviteHash:s}=a,n=await(0,o.Co)(i);if(!n)return void e.showNotification({message:I.i0("NoUsernameFound")});const d=await(0,o.ft)(n);d?.groupCall&&e.joinGroupCall({id:d.groupCall.id,accessHash:d.groupCall.accessHash,inviteHash:s})})),(0,i.iw)("joinGroupCall",(async(t,e,a)=>{if(!f.Bi)return;if(t.phoneCall)return void e.toggleGroupCallPanel();const{chatId:s,id:o,accessHash:n,inviteHash:r}=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,p.Z)(C)}(),await v(),S(!0);const{groupCalls:{activeGroupCallId:l}}=t;let h=o?(0,c.$5)(t,o):(0,c.Bj)(t,s);h?.id!==l?l?e.leaveGroupCall({rejoin:a}):h&&l===h.id?e.toggleGroupCallPanel():(h||o&&n||(h=await y({id:o,accessHash:n})),h&&(t=(0,i.Rd)(),t=(0,d.AH)(t,h.id,{...h,inviteHash:r},void 0,h.participantsCount+1),t={...t,groupCalls:{...t.groupCalls,activeGroupCallId:h.id},isCallPanelVisible:!1},(0,i.R3)(t))):e.toggleGroupCallPanel()})),(0,i.iw)("playGroupCallSound",((t,e,a)=>{const{sound:i}=a;if(!g[i])return;const s=()=>{"connecting"!==i&&g.connecting.pause(),"incoming"!==i&&g.incoming.pause(),"ringing"!==i&&g.ringing.pause(),(0,p.Z)(g[i])};w?w.then(s):s()})),(0,i.iw)("loadMoreGroupCallParticipants",(t=>{const e=(0,c.mU)(t);e&&R(e,e.nextOffset)})),(0,i.iw)("requestCall",(async(t,e,a)=>{const{userId:s,isVideo:o}=a;t.phoneCall?e.toggleGroupCallPanel():(0,r.dy)(t,s)&&(await v(),S(o),(0,i.R3)({...(0,i.Rd)(),phoneCall:{id:"",state:"requesting",participantId:s,isVideo:o,adminId:t.currentUserId},isCallPanelVisible:!1}))}))},78958:(t,e,a)=>{a.d(e,{AH:()=>d,B6:()=>l,Ic:()=>r,dc:()=>c});var i=a(42431),s=a(60782),o=a(53475),n=a(11192);function d(t,e,a,i,o){const n=Object.values({...t.groupCalls.byId[e]?.participants,...a.participants}).filter((t=>{let{isLeft:e}=t;return e})).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"]),...i&&{participantsCount:t.groupCalls.byId[e].participantsCount+i},...void 0!==o&&{participantsCount:o},participants:n}}}}}function c(t,e){const a=(0,i.$5)(t,e);if(a&&a.chatId){const e=(0,n.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 r(t,e,a){return t.groupCalls.activeGroupCallId?d(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 n=(0,i.$5)(t,e);return n?d(t,e,{participants:{...n.participants,[a]:{...n.participants[a],...s}}},s.isLeft?o?0:-1:n.participants[a]||o?0:1):t}}}]);
//# sourceMappingURL=8422.b94cc539089b428eb2fb.js.map