TelegramPWA/dist/8422.444fff334605bc757748.js
Alexander Zinchuk faec0d1f57 [Build]
2023-10-10 13:42:41 +02:00

2 lines
44 KiB
JavaScript

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[8422],{27225:(t,e,a)=>{a.d(e,{Co:()=>P,X9:()=>T,ft:()=>_});var i=a(6137),s=a(91713),d=a(83716),o=a(53551),n=a(65054),r=a(16974),c=a(60782),l=a(59692),h=a(69118),u=a(18629),I=a(92387),p=a(4463),f=a(33555),V=a(41020),w=a(78958),g=a(44271),b=a(7054),C=a(42431),m=a(9211);const y={id:d.awM,accessHash:"0",type:"userTypeRegular",isMin:!0,phoneNumber:""},v=new Set(["FILTERS_TOO_MUCH","CHATLISTS_TOO_MUCH","INVITES_TOO_MUCH"]),R=(0,h.P2)((t=>t()),3e3,!0),A=(0,h.Ds)((t=>t()),500,!1,!0);async function M(t,e,a){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0,n=(0,f.Rd)(),r=(0,b.VFo)(n)?.message;const l=await(0,I.t9)("fetchChats",{limit:d.Ov0,offsetDate:a,archived:"archived"===t,withPinned:s,lastLocalServiceMessage:r});if(!l)return;const{chatIds:h}=l;if(h.length>0&&h[0]===e&&h.shift(),n=(0,f.Rd)(),r=(0,b.VFo)(n)?.message,s&&"active"===t){if(!h.includes(d.awM)){const t=await(0,I.t9)("fetchChat",{type:"user",user:y});n=(0,f.Rd)();const e=t&&(0,b.Z1J)(n,t.chatId);e&&(h.unshift(e.id),l.chats.unshift(e),r&&(e.lastMessage=r))}const e=Object.values(n.byTabId),a=e.flatMap((t=>{let{id:e}=t;const a=(0,b.jrE)(n,e);return a?[a]:[]})),i=e.flatMap((t=>{let{id:e}=t;return(0,b.P2Q)(n,e)||[]}));n.currentUserId&&n.users.byId[n.currentUserId]&&i.push(n.users.byId[n.currentUserId]),n=(0,V.s5)(n,(0,c.ee)(i.concat(l.users),"id")),n=(0,V.ps)(n,l.userStatusesById),n=(0,V.SL)(n,(0,c.ee)(a.concat(l.chats),"id")),n=(0,V.Mg)(n,t,h)}else if(s&&"archived"===t)n=(0,V.Sh)(n,(0,c.ee)(l.users,"id")),n=(0,V.zn)(n,l.userStatusesById),n=(0,V.GL)(n,(0,c.ee)(l.chats,"id")),n=(0,V.Mg)(n,t,h);else{const e=(0,c.ee)(l.chats,"id");if(h.includes(d.awM)){const t=e[d.awM];t&&r&&(e[d.awM]={...t,lastMessage:r})}n=(0,V.Sh)(n,(0,c.ee)(l.users,"id")),n=(0,V.zn)(n,l.userStatusesById),n=(0,V.GL)(n,e),n=(0,V.B1)(n,t,h)}n=(0,V.vv)(n,t,l),(o?l.chatIds:Object.keys(l.draftsById)).forEach((t=>{const e=l.draftsById[t],a=(0,b.cii)(n,t,i._f);(e||a)&&((0,b.Mst)(n,t,i._f)?.isLocal||(n=(0,V.pf)(n,t,i._f,"draft",e)))})),(o?l.chatIds:Object.keys(l.replyingToById)).forEach((t=>{const e=l.replyingToById[t],a=(0,b.cii)(n,t,i._f);(e||a)&&(n=(0,V.pf)(n,t,i._f,"replyingToId",e))})),0!==h.length||n.chats.isFullyLoaded[t]||(n={...n,chats:{...n.chats,isFullyLoaded:{...n.chats.isFullyLoaded,[t]:!0}}}),(0,f.R3)(n)}async function _(t,e,a){for(var i=arguments.length,s=new Array(i>3?i-3:0),d=3;d<i;d++)s[d-3]=arguments[d];let[o=(0,n._w)()]=s;const r=await(0,I.t9)("fetchFullChat",a);if(!r)return;const{users:l,userStatusesById:h,fullInfo:u,groupCall:p,membersCount:g}=r;if(t=(0,f.Rd)(),l&&(t=(0,V.Sh)(t,(0,c.ee)(l,"id"))),h&&(t=(0,V.zn)(t,h)),p){const e=(0,C.$5)(t,p.id);t=(0,w.AH)(t,p.id,(0,c.CE)(p,["connectionState","isLoaded"]),void 0,e?void 0:p.participantsCount)}void 0!==g&&(t=(0,V.a4)(t,a.id,{membersCount:g})),t=(0,V.FK)(t,a.id,u),(0,f.R3)(t);const m=u.stickerSet,y=m&&(0,b.Ny0)(t,m);return m&&!y&&e.loadStickers({stickerSetInfo:{id:m.id,accessHash:m.accessHash},tabId:o}),r}async function P(t,e){t=(0,f.Rd)();const a=(0,b.DIA)(t,e);if(a&&!a.isMin)return a;const{chat:i,user:s}=await(0,I.t9)("getChatByUsername",e)||{};return i?(t=(0,f.Rd)(),t=(0,V.a4)(t,i.id,i),s&&(t=(0,V.Nq)(t,s.id,s)),(0,f.R3)(t),i):void 0}async function S(t,e,a){for(var i=arguments.length,s=new Array(i>3?i-3:0),d=3;d<i;d++)s[d-3]=arguments[d];let[o=(0,n._w)()]=s;const r=await P(t,a);if(!r)return;t=(0,f.Rd)();const h=(0,b.dyD)(t,r.id);if(!h)return;if(!(0,p.cS)(h))return;const u=await(0,I.t9)("loadAttachBot",{bot:h});if(t=(0,f.Rd)(),u)return t=(0,V.Sh)(t,(0,c.ee)(u.users,"id")),(0,f.R3)(t),u.bot;e.showNotification({message:l.Iu("WebApp.AddToAttachmentUnavailableError"),tabId:o})}async function F(t,e,a,i,s){for(var d=arguments.length,o=new Array(d>5?d-5:0),r=5;r<d;r++)o[r-5]=arguments[r];let[c=(0,n._w)()]=o;t=(0,f.Rd)();const l=await S(t,e,i,c);l&&e.callAttachBot({bot:l,chatId:a,..."string"==typeof s&&{startParam:s},tabId:c})}async function T(t,e,a){for(var i=arguments.length,s=new Array(i>3?i-3:0),d=3;d<i;d++)s[d-3]=arguments[d];let[o=(0,n._w)()]=s;const r=(0,b.Z1J)(t,a);if(!r||!(0,p.G9)(r))return r;const c=await async function(t,e,a){for(var i=arguments.length,s=new Array(i>3?i-3:0),d=3;d<i;d++)s[d-3]=arguments[d];let[o=(0,n._w)()]=s;try{return await(0,I.t9)("migrateChat",a)}catch(t){return void("CHANNELS_TOO_MUCH"===t.message?e.openLimitReachedModal({limit:"channels",tabId:o}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:o}))}}(t,e,r,o);return c?(e.loadFullChat({chatId:c.id,tabId:o}),e.openChat({id:c.id,tabId:o}),c):void 0}(0,f.iw)("preloadTopChatMessages",(async(t,e)=>{const a=new Set;for(let s=0;s<d.ulj;s++){await(0,h.wO)(100),t=(0,f.Rd)();const s=Object.values(t.byTabId).map((e=>{let{id:a}=e;return(0,b.Btg)(t,a)?.chatId})).filter(Boolean),o=(0,r.gO)(d.NfV),c=o?.find((t=>!s.includes(t)&&!a.has(t)));if(!c)return;a.add(c),e.loadViewportMessages({chatId:c,threadId:i._f,tabId:(0,n._w)()})}})),(0,f.iw)("openChat",((t,e,a)=>{const{id:s,threadId:d=i._f,noRequestThreadInfoUpdate:o,tabId:r=(0,n._w)()}=a,c=(0,b.Btg)(t,r),l=c?.chatId,h=c?.threadId;if(l&&(l!==s||h!==d)){const[e,a]=Object.values(t.byTabId).reduce(((e,a)=>{let[i,s]=e,{id:d}=a;if(d===r||i&&s)return[i,s];const o=(0,b.Btg)(t,d),n=o?.chatId===l;return[i||n,s||n&&o?.threadId===h]}),[l===s,!1]);(!e||!a)&&(0,I.t9)("abortChatRequests",{chatId:l,threadId:e?h:void 0})}if(!s)return;const{currentUserId:u}=t,f=(0,b.Z1J)(t,s);if(f?.hasUnreadMark&&e.toggleChatUnread({id:s}),f)(0,p.Hp)(f)&&!f.isMin&&e.requestChatUpdate({chatId:s});else if(s===u)(0,I.t9)("fetchChat",{type:"self"});else{const e=(0,b.dyD)(t,s);e&&(0,I.t9)("fetchChat",{type:"user",user:e})}e.closeStoryViewer({tabId:r}),d===i._f||o||e.requestThreadInfoUpdate({chatId:s,threadId:d})})),(0,f.iw)("openComments",(async(t,e,a)=>{const{id:s,threadId:d,originChannelId:o,tabId:r=(0,n._w)()}=a;if(d!==i._f){const a=(0,b.qSq)(t,s,d);if(a)e.openChat({id:s,threadId:a,tabId:r,noRequestThreadInfoUpdate:!0});else{const a=(0,b.CmE)(t,s,d);if(!a)return;e.openChat({id:s,threadId:d,tabId:r,noRequestThreadInfoUpdate:!0});const i=await(0,I.t9)("requestThreadInfoUpdate",{chat:a,threadId:d,originChannelId:o});if(!i)return void e.openPreviousChat({tabId:r});t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(i.users,"id")),(0,f.R3)(t),e.openChat({id:s,threadId:i.topMessageId,tabId:r,shouldReplaceLast:!0,noRequestThreadInfoUpdate:!0})}}})),(0,f.iw)("openLinkedChat",(async(t,e,a)=>{const{id:i,tabId:s=(0,n._w)()}=a,d=(0,b.Z1J)(t,i);if(!d)return;const o=await(0,I.t9)("fetchFullChat",d);o?.fullInfo?.linkedChatId&&e.openChat({id:o.fullInfo.linkedChatId,tabId:s})})),(0,f.iw)("focusMessageInComments",(async(t,e,a)=>{const{chatId:i,threadId:s,messageId:d,tabId:o=(0,n._w)()}=a,r=(0,b.Z1J)(t,i);if(!r)return;const l=await(0,I.t9)("requestThreadInfoUpdate",{chat:r,threadId:s});l&&(t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(l.users,"id")),(0,f.R3)(t),e.focusMessage({chatId:i,threadId:s,messageId:d,tabId:o}))})),(0,f.iw)("openSupportChat",(async(t,e,a)=>{const{tabId:i=(0,n._w)()}=a||{},s=(0,b.P_p)(t);if(s)return void e.openChat({id:s.id,shouldReplaceHistory:!0,tabId:i});e.openChat({id:d.mzl,shouldReplaceHistory:!0,tabId:i});const o=await(0,I.t9)("fetchChat",{type:"support"});o&&e.openChat({id:o.chatId,shouldReplaceHistory:!0,tabId:i})})),(0,f.iw)("loadAllChats",(async(t,e,a)=>{const i=a.listType,{onReplace:s}=a;let{shouldReplace:o}=a,n=0;const r=t=>t.lastMessage?.date||t.joinDate;for(;o||!t.chats.isFullyLoaded[i];){if(n++>=100)return void(d.eMD&&console.error("`actions/loadAllChats`: Infinite loop detected"));if("connectionStateReady"!==(t=(0,f.Rd)()).connectionState||"authorizationStateReady"!==t.authState)return;const e=!o&&t.chats.listIds[i],a=e?e.map((e=>t.chats.byId[e])).filter((e=>Boolean(e&&r(e))&&e.id!==d.awM&&!(0,b.epB)(t,e.id))).sort(((t,e)=>r(t)-r(e)))[0]:void 0;await M(i,a?.id,a?r(a):void 0,o,!0),o&&(s?.(),o=!1),t=(0,f.Rd)()}})),(0,f.iw)("loadFullChat",((t,e,a)=>{const{chatId:i,force:s,tabId:d=(0,n._w)(),withPhotos:o}=a,r=(0,b.Z1J)(t,i);if(!r)return;const c=async()=>{await _(t,e,r,d),o&&e.loadProfilePhotos({profileId:i})};s?c():A(c)})),(0,f.iw)("loadTopChats",(()=>{R((()=>{M("active"),M("archived")}))})),(0,f.iw)("requestChatUpdate",((t,e,a)=>{const{chatId:i}=a,s=(0,b.Z1J)(t,i);s&&(0,I.t9)("requestChatUpdate",{chat:s,...i===d.awM&&{lastLocalMessage:(0,b.VFo)(t)?.message}})})),(0,f.iw)("updateChatMutedState",((t,e,a)=>{const{chatId:i,muteUntil:s=0}=a,d=(0,b.Z1J)(t,i);if(!d)return;const o=a.isMuted??s>0;t=(0,V.a4)(t,i,{isMuted:o}),(0,f.R3)(t),(0,I.t9)("updateChatMutedState",{chat:d,isMuted:o,muteUntil:s})})),(0,f.iw)("updateTopicMutedState",((t,e,a)=>{const{chatId:i,topicId:s,muteUntil:d=0}=a,o=(0,b.Z1J)(t,i);if(!o)return;const n=a.isMuted??d>0;t=(0,V.Cn)(t,i,s,{isMuted:n}),(0,f.R3)(t),(0,I.t9)("updateTopicMutedState",{chat:o,topicId:s,isMuted:n,muteUntil:d})})),(0,f.iw)("createChannel",(async(t,e,a)=>{const{title:i,about:d,photo:o,memberIds:r,tabId:c=(0,n._w)()}=a,l=r.map((e=>(0,b.dyD)(t,e))).filter(Boolean);let h;t=(0,g.i)(t,{chatCreation:{progress:s.Nh.InProgress}},c),(0,f.R3)(t);try{h=await(0,I.t9)("createChannel",{title:i,about:d,users:l})}catch(a){t=(0,f.Rd)(),t=(0,g.i)(t,{chatCreation:{progress:s.Nh.Error}},c),(0,f.R3)(t),"CHANNELS_TOO_MUCH"===a.message?e.openLimitReachedModal({limit:"channels",tabId:c}):e.showDialog({data:{...a,hasErrorKey:!0},tabId:c})}if(!h)return;const{id:u,accessHash:p}=h;t=(0,f.Rd)(),t=(0,V.a4)(t,u,h),t=(0,g.i)(t,{chatCreation:{...(0,b.jUK)(t,c).chatCreation,progress:h?s.Nh.Complete:s.Nh.Error}},c),(0,f.R3)(t),e.openChat({id:u,shouldReplaceHistory:!0,tabId:c}),u&&p&&o&&await(0,I.t9)("editChatPhoto",{chatId:u,accessHash:p,photo:o})})),(0,f.iw)("joinChannel",(async(t,e,a)=>{const{chatId:i,tabId:s=(0,n._w)()}=a,d=(0,b.Z1J)(t,i);if(!d)return;const{id:o,accessHash:r}=d;if(o&&r)try{await(0,I.t9)("joinChannel",{channelId:o,accessHash:r})}catch(t){"CHANNELS_TOO_MUCH"===t.message?e.openLimitReachedModal({limit:"channels",tabId:s}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:s})}})),(0,f.iw)("deleteChatUser",((t,e,a)=>{const{chatId:i,userId:s,tabId:d=(0,n._w)()}=a,o=(0,b.Z1J)(t,i),r=(0,b.dyD)(t,s);o&&r&&(t=(0,V.Dd)(t,i),(0,f.R3)(t),(0,b.Btg)(t,d)?.chatId===i&&e.openChat({id:void 0,tabId:d}),(0,I.t9)("deleteChatUser",{chat:o,user:r}))})),(0,f.iw)("deleteChat",((t,e,a)=>{const{chatId:i,tabId:s=(0,n._w)()}=a,d=(0,b.Z1J)(t,i);d&&(t=(0,V.Dd)(t,i),(0,f.R3)(t),(0,b.Btg)(t,s)?.chatId===i&&e.openChat({id:void 0,tabId:s}),(0,I.t9)("deleteChat",{chatId:d.id}))})),(0,f.iw)("leaveChannel",((t,e,a)=>{const{chatId:i,tabId:s=(0,n._w)()}=a,d=(0,b.Z1J)(t,i);if(!d)return;t=(0,V.Dd)(t,i),(0,f.R3)(t),(0,b.Btg)(t,s)?.chatId===i&&e.openChat({id:void 0,tabId:s});const{id:o,accessHash:r}=d;o&&r&&(0,I.t9)("leaveChannel",{channelId:o,accessHash:r})})),(0,f.iw)("deleteChannel",((t,e,a)=>{const{chatId:i,tabId:s=(0,n._w)()}=a,d=(0,b.Z1J)(t,i);if(!d)return;t=(0,V.Dd)(t,i),(0,f.R3)(t),(0,b.Btg)(t,s)?.chatId===i&&e.openChat({id:void 0,tabId:s});const{id:o,accessHash:r}=d;o&&r&&(0,I.t9)("deleteChannel",{channelId:o,accessHash:r})})),(0,f.iw)("createGroupChat",(async(t,e,a)=>{const{title:i,memberIds:d,photo:o,tabId:r=(0,n._w)()}=a,c=d.map((e=>(0,b.dyD)(t,e))).filter(Boolean);t=(0,g.i)(t,{chatCreation:{progress:s.Nh.InProgress}},r),(0,f.R3)(t);try{const a=await(0,I.t9)("createGroupChat",{title:i,users:c});if(!a)return;const{id:d}=a;t=(0,f.Rd)(),t=(0,V.a4)(t,d,a),t=(0,g.i)(t,{chatCreation:{...(0,b.jUK)(t,r).chatCreation,progress:a?s.Nh.Complete:s.Nh.Error}},r),(0,f.R3)(t),e.openChat({id:d,shouldReplaceHistory:!0,tabId:r}),d&&o&&await(0,I.t9)("editChatPhoto",{chatId:d,photo:o})}catch(e){"USERS_TOO_FEW"===e.message&&(t=(0,f.Rd)(),t=(0,g.i)(t,{chatCreation:{...(0,b.jUK)(t,r).chatCreation,progress:s.Nh.Error,error:"CreateGroupError"}},r),(0,f.R3)(t))}})),(0,f.iw)("toggleChatPinned",((t,e,a)=>{const{id:i,folderId:s,tabId:o=(0,n._w)()}=a,r=(0,b.Z1J)(t,i);if(!r)return;const c=(0,m.M)(t,"dialogFolderPinned");if(s){const e=(0,b.MwT)(t,s);if(e){const a=!(0,b.epB)(t,i,s),{pinnedChatIds:d,includedChatIds:o}=e,n=a?[i,...d||[]]:(d||[]).filter((t=>t!==i)),r=[i,...o];(0,I.t9)("editChatFolder",{id:s,folderUpdate:{...e,pinnedChatIds:n,includedChatIds:r}})}}else{const a=(0,b.EkO)(t,i),s=(0,b.epB)(t,i,"archived"===a?d.WSp:void 0),n=t.chats.orderedPinnedIds["archived"===a?"archived":"active"];if((n?.length||0)>=c&&!s)return void e.openLimitReachedModal({limit:"dialogFolderPinned",tabId:o});(0,I.t9)("toggleChatPinned",{chat:r,shouldBePinned:!s})}})),(0,f.iw)("toggleChatArchived",((t,e,a)=>{const{id:i}=a,s=(0,b.Z1J)(t,i);s&&(0,I.t9)("toggleChatArchived",{chat:s,folderId:(0,p.pE)(s)?0:d.WSp})})),(0,f.iw)("loadChatFolders",(async t=>{const e=await(0,I.t9)("fetchChatFolders");e&&(t=(0,f.Rd)(),t={...t,chatFolders:{...t.chatFolders,...e}},(0,f.R3)(t))})),(0,f.iw)("loadRecommendedChatFolders",(async t=>{const e=await(0,I.t9)("fetchRecommendedChatFolders");e&&(t=(0,f.Rd)(),t={...t,chatFolders:{...t.chatFolders,recommended:e}},(0,f.R3)(t))})),(0,f.iw)("editChatFolders",((t,e,a)=>{const{chatId:i,idsToRemove:s,idsToAdd:d,tabId:o=(0,n._w)()}=a,r=(0,m.M)(t,"dialogFiltersChats");d.some((e=>(0,b.MwT)(t,e).includedChatIds.length>=r))?e.openLimitReachedModal({limit:"dialogFiltersChats",tabId:o}):(s.forEach((async e=>{const a=(0,b.MwT)(t,e);a&&await(0,I.t9)("editChatFolder",{id:e,folderUpdate:{...a,pinnedChatIds:a.pinnedChatIds?.filter((t=>t!==i)),includedChatIds:a.includedChatIds.filter((t=>t!==i))}})})),d.forEach((async e=>{const a=(0,b.MwT)(t,e);a&&await(0,I.t9)("editChatFolder",{id:e,folderUpdate:{...a,includedChatIds:a.includedChatIds.concat(i)}})})))})),(0,f.iw)("editChatFolder",((t,e,a)=>{const{id:i,folderUpdate:s}=a,d=(0,b.MwT)(t,i);d&&(0,I.t9)("editChatFolder",{id:i,folderUpdate:{id:i,emoticon:d.emoticon,pinnedChatIds:d.pinnedChatIds,...s}})})),(0,f.iw)("addChatFolder",(async(t,e,a)=>{const{folder:i,tabId:s=(0,n._w)()}=a,{orderedIds:o,byId:r}=t.chatFolders,c=(0,m.M)(t,"dialogFilters");if(Object.keys(r).length>=c)return void e.openLimitReachedModal({limit:"dialogFilters",tabId:s});const l=Math.max(...o||[],d.WSp),{id:h,description:u,...p}=i,V=l+1,w={id:V,...p};if(await(0,I.t9)("editChatFolder",{id:V,folderUpdate:w}),e.apiUpdate({"@type":"updateChatFolder",id:V,folder:w}),e.requestNextSettingsScreen({foldersAction:{type:"setFolderId",payload:l+1},tabId:s}),!u)return;t=(0,f.Rd)();const{recommended:g}=t.chatFolders;g&&(t={...t,chatFolders:{...t.chatFolders,recommended:g.filter((t=>{let{id:e}=t;return e!==h}))}},(0,f.R3)(t))})),(0,f.iw)("sortChatFolders",(async(t,e,a)=>{const{folderIds:i}=a;await(0,I.t9)("sortChatFolders",i)&&(t=(0,f.Rd)(),t={...t,chatFolders:{...t.chatFolders,orderedIds:i}},(0,f.R3)(t))})),(0,f.iw)("deleteChatFolder",(async(t,e,a)=>{const{id:i}=a;(0,b.MwT)(t,i)&&await(0,I.t9)("deleteChatFolder",i)})),(0,f.iw)("toggleChatUnread",((t,e,a)=>{const{id:s}=a,d=(0,b.Z1J)(t,s);d&&(d.unreadCount?(0,I.t9)("markMessageListRead",{chat:d,threadId:i._f}):(0,I.t9)("toggleDialogUnread",{chat:d,hasUnreadMark:!d.hasUnreadMark}))})),(0,f.iw)("markTopicRead",((t,e,a)=>{const{chatId:i,topicId:s}=a,d=(0,b.Z1J)(t,i);if(!d)return;const o=d.topics?.[s]?.lastMessageId;o&&((0,I.t9)("markMessageListRead",{chat:d,threadId:s,maxId:o}),t=(0,f.Rd)(),t=(0,V.Cn)(t,i,s,{unreadCount:0}),t=(0,V.Xg)(t,i,s,{lastReadInboxMessageId:o}),(0,f.R3)(t))})),(0,f.iw)("openChatByInvite",(async(t,e,a)=>{const{hash:i,tabId:s=(0,n._w)()}=a,d=await(0,I.t9)("openChatByInvite",i);d&&e.openChat({id:d.chatId,tabId:s})})),(0,f.iw)("openChatByPhoneNumber",(async(t,e,a)=>{const{phoneNumber:i,startAttach:s,attach:o,tabId:r=(0,n._w)()}=a;e.openChat({id:d.mzl,tabId:r});const c=await async function(t,e){t=(0,f.Rd)();const a=(0,b.Bki)(t,e);if(a&&!a.isMin)return(0,b.Z1J)(t,a.id);const{chat:i,user:s}=await(0,I.t9)("getChatByPhoneNumber",e)||{};return i?(t=(0,f.Rd)(),t=(0,V.a4)(t,i.id,i),s&&(t=(0,V.Nq)(t,s.id,s)),(0,f.R3)(t),i):void 0}(t,i);if(!c)return e.openPreviousChat({tabId:r}),void e.showNotification({message:l.Iu("lng_username_by_phone_not_found").replace("{phone}",i),tabId:r});e.openChat({id:c.id,tabId:r}),o&&F(t=(0,f.Rd)(),e,c.id,o,s,r)})),(0,f.iw)("openTelegramLink",((t,e,a)=>{const{url:i,tabId:s=(0,n._w)()}=a,{openChatByPhoneNumber:r,openChatByInvite:c,openStickerSet:l,openChatWithDraft:h,joinVoiceChatByLink:u,showNotification:I,focusMessage:f,openInvoice:V,processAttachBotParameters:w,checkChatlistInvite:g,openChatByUsername:C,openStoryViewerByUsername:m,processBoostParameters:y}=e;if(i.match(d.g$l))return void(0,o.ou)(i);const v=new URL(i.toLowerCase().startsWith("http")?i:`https://${i}`);if(d.LBg.has(v.hostname)&&"/"===v.pathname)return void window.open(v.toString(),"_blank","noopener");const R=(d.LBg.has(v.hostname)?"t.me":v.hostname).split(".");if(R.length>3)return;const A=3===R.length?`${R[0]}/${v.pathname}`:v.pathname,[M,_,P]=A.split("/").filter(Boolean).map((t=>decodeURI(t))),S=Object.fromEntries(v.searchParams);let F;"joinchat"===M&&(F=_);const T=S.hasOwnProperty("startattach"),B=S.hasOwnProperty("startapp"),U=(0,o.GX)(S.choose),H="s"===_&&(Number(P)||void 0),Z=S.hasOwnProperty("boost");if(M.match(/^\+([0-9]+)(\?|$)/))return void r({phoneNumber:M.substr(1,M.length-1),startAttach:S.startattach,attach:S.attach,tabId:s});if(H)return void m({username:M,storyId:H,tabId:s});if((M.startsWith(" ")||M.startsWith("+"))&&(F=M.substr(1,M.length-1)),F)return void c({hash:F,tabId:s});if("addstickers"===M||"addemoji"===M)return void l({stickerSetInfo:{shortName:_},tabId:s});if("share"===M)return void h({text:(0,o.QH)(S.url,S.text),tabId:s});if("addlist"===M)return void g({slug:_,tabId:s});const E=_||void 0,N=P?Number(P):void 0,J=S.comment?Number(S.comment):void 0;if(S.hasOwnProperty("voicechat")||S.hasOwnProperty("livestream"))u({username:M,inviteHash:S.voicechat||S.livestream,tabId:s});else if("boost"===M){const t=_,e=S.c;y({usernameOrId:t||e,isPrivate:!t&&Boolean(e),tabId:s})}else if(Z)y({usernameOrId:E||M,isPrivate:"c"===M&&Boolean(E),tabId:s});else if("c"===M&&E&&N){const e=(0,p.Yg)(E),a=(0,b.Z1J)(t,e);if(!a)return void I({message:"Chat does not exist",tabId:s});N&&f({chatId:a.id,messageId:N,tabId:s})}else M.startsWith("$")?V({slug:M.substring(1),tabId:s}):"invoice"===M?V({slug:_,tabId:s}):T&&U||!_&&B?w({username:M,filter:U,startParam:S.startattach||S.startapp,tabId:s}):C({username:M,messageId:N||Number(E),threadId:N?Number(E):void 0,commentId:J,startParam:S.start,startAttach:S.startattach,attach:S.attach,startApp:S.startapp,originalParts:[M,_,P],tabId:s})})),(0,f.iw)("processBoostParameters",(async(t,e,a)=>{const{usernameOrId:i,isPrivate:s,tabId:d=(0,n._w)()}=a;let o;if(s){const a=(0,p.Yg)(i);if(o=(0,b.Z1J)(t,a),!o)return void e.showNotification({message:"Chat does not exist",tabId:d})}else if(o=await P(t,i),!o)return void e.showNotification({message:"User does not exist",tabId:d});(0,p.eA)(o)?e.openBoostModal({chatId:o.id,tabId:d}):e.openChat({id:o.id,tabId:d})})),(0,f.iw)("acceptInviteConfirmation",(async(t,e,a)=>{const{hash:i,tabId:s=(0,n._w)()}=a,d=await(0,I.t9)("importChatInvite",{hash:i});d&&e.openChat({id:d.id,tabId:s})})),(0,f.iw)("openChatByUsername",(async(t,e,a)=>{const{username:i,messageId:s,commentId:o,startParam:r,startAttach:l,attach:h,threadId:p,originalParts:w,startApp:g,tabId:C=(0,n._w)()}=a,m=(0,b.jrE)(t,C),y=w?.[1],v=y&&!Number(y)&&!w?.[2];if(!o){if(void 0===l&&s&&!r&&m?.usernames?.some((t=>t.username===i)))return void e.focusMessage({chatId:m.id,threadId:p,messageId:s,tabId:C});if(!v)return void await async function(t,e,a,i,s,o,r,c){for(var l=arguments.length,h=new Array(l>8?l-8:0),u=8;u<l;u++)h[u-8]=arguments[u];let[I=(0,n._w)()]=h;t=(0,f.Rd)();const p=(0,b.jrE)(t,I);if(void 0!==r&&!c){const i=await S(t,e,a,I);if(!p||!i)return;return void e.callAttachBot({bot:i,chatId:p.id,startParam:r,tabId:I})}const V=p?.usernames?.some((t=>t.username===a));V||e.openChat({id:d.mzl,tabId:I});const w=await P(t,a);w?(s?e.focusMessage({chatId:w.id,threadId:i,messageId:s,tabId:I}):V||e.openChat({id:w.id,threadId:i,tabId:I}),o&&e.startBot({botId:w.id,param:o}),c&&F(t=(0,f.Rd)(),e,w.id,c,r,I)):V||(e.openPreviousChat({tabId:I}),e.showNotification({message:"User does not exist",tabId:I}))}(t,e,i,p,s,r,l,h,C)}const{chatId:R,type:A}=(0,b.Btg)(t,C)||{},M=(0,b.DIA)(t,i);if(R&&o&&s&&M&&"thread"===A){const a=(0,b.tZg)(t,R,s);if(a&&a.chatId===R)return void e.focusMessage({chatId:a.chatId,threadId:a.threadId,messageId:o,tabId:C})}v||e.openChat({id:d.mzl,tabId:C});const _=await P(t,i);if(!_)return;if(t=(0,f.Rd)(),v&&_){const t=(0,u.BS)();return void e.requestAppWebView({appName:y,botId:_.id,tabId:C,startApp:g,theme:t})}if(!s)return;const T=(0,b.tZg)(t,_.id,s);let B;if(T)B=T.chatId;else{const e=await(0,I.t9)("requestThreadInfoUpdate",{chat:_,threadId:s});if(!e)return;t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(e.users,"id")),(0,f.R3)(t),B=e.discussionChatId}B&&e.focusMessage({chatId:B,threadId:s,messageId:Number(o),tabId:C})})),(0,f.iw)("togglePreHistoryHidden",(async(t,e,a)=>{const{chatId:i,isEnabled:s,tabId:d=(0,n._w)()}=a,o=await T(t,e,i,d);o&&(t=(0,f.Rd)(),t=(0,V.US)(t,o.id,{isPreHistoryHidden:s}),(0,f.R3)(t),(0,I.t9)("togglePreHistoryHidden",{chat:o,isEnabled:s}))})),(0,f.iw)("updateChatDefaultBannedRights",((t,e,a)=>{const{chatId:i,bannedRights:s}=a,d=(0,b.Z1J)(t,i);d&&(0,I.t9)("updateChatDefaultBannedRights",{chat:d,bannedRights:s})})),(0,f.iw)("updateChatMemberBannedRights",(async(t,e,a)=>{const{chatId:i,userId:s,bannedRights:d,tabId:o=(0,n._w)()}=a,r=(0,b.dyD)(t,s);if(!r)return;const c=await T(t,e,i,o);if(!c)return;await(0,I.t9)("updateChatMemberBannedRights",{chat:c,user:r,bannedRights:d}),t=(0,f.Rd)();const l=(0,b.x67)(t,c.id);if(!l)return;const{members:h,kickedMembers:u}=l,p=Boolean(d.viewMessages),w=!Object.keys(d).length;t=(0,V.US)(t,c.id,{...h&&p&&{members:h.filter((t=>t.userId!==s))},...h&&!p&&{members:h.map((t=>t.userId===s?{...t,bannedRights:d}:t))},...w&&u&&{kickedMembers:u.filter((t=>t.userId!==s))}}),(0,f.R3)(t)})),(0,f.iw)("updateChatAdmin",(async(t,e,a)=>{const{chatId:i,userId:s,adminRights:d,customTitle:o,tabId:r=(0,n._w)()}=a,c=(0,b.dyD)(t,s);if(!c)return;const l=await T(t,e,i,r);if(!l)return;await(0,I.t9)("updateChatAdmin",{chat:l,user:c,adminRights:d,customTitle:o});const h=await(0,I.t9)("fetchFullChat",l);if(!h?.fullInfo)return;const{adminMembersById:u}=h.fullInfo,p=!Object.keys(d).length;let w;if(u)if(p){const{[s]:t,...e}=u;w=e}else w={...u,[s]:{...u[s],adminRights:d,customTitle:o}};w&&(t=(0,f.Rd)(),t=(0,V.US)(t,l.id,{adminMembersById:w}),(0,f.R3)(t))})),(0,f.iw)("updateChat",(async(t,e,a)=>{const{chatId:i,title:d,about:o,photo:r,tabId:c=(0,n._w)()}=a,l=(0,b.Z1J)(t,i),h=(0,b.x67)(t,i);l&&(t=(0,f.Rd)(),t=(0,V.H9)(t,s.wv.InProgress,c),(0,f.R3)(t),await Promise.all([l.title!==d?(0,I.t9)("updateChatTitle",l,d):void 0,h?.about!==o?(0,I.t9)("updateChatAbout",l,o):void 0,r?(0,I.t9)("editChatPhoto",{chatId:i,accessHash:l.accessHash,photo:r}):void 0]),t=(0,f.Rd)(),t=(0,V.H9)(t,s.wv.Complete,c),(0,f.R3)(t),r&&e.loadFullChat({chatId:i,tabId:c,withPhotos:!0}))})),(0,f.iw)("updateChatPhoto",(async(t,e,a)=>{const{photo:i,chatId:s,tabId:d=(0,n._w)()}=a,o=(0,b.Z1J)(t,s);o&&(t=(0,V.a4)(t,s,{avatarHash:void 0}),t=(0,V.US)(t,s,{profilePhoto:void 0}),(0,f.R3)(t),await(0,I.t9)("editChatPhoto",{chatId:s,accessHash:o.accessHash,photo:i}),await(0,I.t9)("deleteProfilePhotos",[i]),e.loadFullChat({chatId:s,tabId:d,withPhotos:!0}))})),(0,f.iw)("deleteChatPhoto",(async(t,e,a)=>{const{photo:i,chatId:s,tabId:d=(0,n._w)()}=a,o=(0,b.Z1J)(t,s);if(!o)return;const r=[i];if(o.avatarHash===i.id){const e=o.photos?.[1];e&&r.push(e),t=(0,V.a4)(t,s,{avatarHash:void 0}),t=(0,V.US)(t,s,{profilePhoto:void 0}),(0,f.R3)(t),await(0,I.t9)("editChatPhoto",{chatId:s,accessHash:o.accessHash,photo:e})}const{photos:c=[]}=o,l=c.filter((t=>r.some((e=>e.id!==t.id))));t=(0,f.Rd)(),t=(0,V.a4)(t,s,{photos:l}),(0,f.R3)(t),await(0,I.t9)("deleteProfilePhotos",r)&&e.loadFullChat({chatId:s,tabId:d,withPhotos:!0})})),(0,f.iw)("toggleSignatures",((t,e,a)=>{const{chatId:i,isEnabled:s}=a,d=(0,b.Z1J)(t,i);d&&(0,I.t9)("toggleSignatures",{chat:d,isEnabled:s})})),(0,f.iw)("loadGroupsForDiscussion",(async t=>{const e=await(0,I.t9)("fetchGroupsForDiscussion");if(!e)return;const a=e.reduce(((t,e)=>(e&&!e.isForum&&(t[e.id]=e),t)),{});t=(0,f.Rd)(),t=(0,V.fZ)(t,a),t={...t,chats:{...t.chats,forDiscussionIds:Object.keys(a)}},(0,f.R3)(t)})),(0,f.iw)("linkDiscussionGroup",(async(t,e,a)=>{const{channelId:i,chatId:s,tabId:d=(0,n._w)()}=a||{},o=(0,b.Z1J)(t,i);if(!o)return;const r=await T(t,e,s,d);if(!r)return;let c=(0,b.x67)(t,r.id);if(!c){const t=await(0,I.t9)("fetchFullChat",r);if(!t)return;c=t.fullInfo}c.isPreHistoryHidden&&(t=(0,f.Rd)(),t=(0,V.US)(t,r.id,{isPreHistoryHidden:!1}),(0,f.R3)(t),await(0,I.t9)("togglePreHistoryHidden",{chat:r,isEnabled:!1})),(0,I.t9)("setDiscussionGroup",{channel:o,chat:r})})),(0,f.iw)("unlinkDiscussionGroup",(async(t,e,a)=>{const{channelId:i,tabId:s=(0,n._w)()}=a,d=(0,b.Z1J)(t,i);if(!d)return;const o=(0,b.x67)(t,i);let r;o?.linkedChatId&&(r=(0,b.Z1J)(t,o.linkedChatId)),await(0,I.t9)("setDiscussionGroup",{channel:d}),r&&_(t=(0,f.Rd)(),e,r,s)})),(0,f.iw)("setActiveChatFolder",((t,e,a)=>{const{activeChatFolder:i,tabId:s=(0,n._w)()}=a;if(!(i+1>(0,m.M)(t,"dialogFilters")))return(0,g.i)(t,{activeChatFolder:i},s);e.openLimitReachedModal({limit:"dialogFilters",tabId:s})})),(0,f.iw)("resetOpenChatWithDraft",((t,e,a)=>{const{tabId:i=(0,n._w)()}=a||{};return(0,g.i)(t,{requestedDraft:void 0},i)})),(0,f.iw)("loadMoreMembers",(async(t,e,a)=>{const{tabId:i=(0,n._w)()}=a||{},{chatId:s}=(0,b.Btg)(t,i)||{},d=s?(0,b.Z1J)(t,s):void 0;if(!d||(0,p.G9)(d))return;const o=(0,b.x67)(t,d.id)?.members?.length;if(void 0!==o&&void 0!==d.membersCount&&o>=d.membersCount)return;const r=await(0,I.t9)("fetchMembers",d.id,d.accessHash,"recent",o);if(!r)return;const{members:l,users:h,userStatusesById:u}=r;l&&l.length&&(t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(h,"id")),t=(0,V.zn)(t,u),t=(0,V.iX)(t,d,l),(0,f.R3)(t))})),(0,f.iw)("addChatMembers",(async(t,e,a)=>{const{chatId:i,memberIds:d,tabId:o=(0,n._w)()}=a,r=(0,b.Z1J)(t,i),c=d.map((e=>(0,b.dyD)(t,e))).filter(Boolean);r&&c.length&&(e.setNewChatMembersDialogState({newChatMembersProgress:s.WB.Loading,tabId:o}),await(0,I.t9)("addChatMembers",r,c),e.setNewChatMembersDialogState({newChatMembersProgress:s.WB.Closed,tabId:o}),_(t=(0,f.Rd)(),e,r,o))})),(0,f.iw)("deleteChatMember",(async(t,e,a)=>{const{chatId:i,userId:s,tabId:d=(0,n._w)()}=a,o=(0,b.Z1J)(t,i),r=(0,b.dyD)(t,s);o&&r&&(await(0,I.t9)("deleteChatMember",o,r),_(t=(0,f.Rd)(),e,o,d))})),(0,f.iw)("toggleIsProtected",((t,e,a)=>{const{chatId:i,isProtected:s}=a,d=(0,b.Z1J)(t,i);d&&(0,I.t9)("toggleIsProtected",{chat:d,isProtected:s})})),(0,f.iw)("setChatEnabledReactions",(async(t,e,a)=>{const{chatId:i,enabledReactions:s,tabId:d=(0,n._w)()}=a,o=(0,b.Z1J)(t,i);o&&(await(0,I.t9)("setChatEnabledReactions",{chat:o,enabledReactions:s}),_(t=(0,f.Rd)(),e,o,d))})),(0,f.iw)("fetchChat",((t,e,a)=>{const{chatId:i}=a;if(!(0,b.Z1J)(t,i))if(i===t.currentUserId)(0,I.t9)("fetchChat",{type:"self"});else{const e=(0,b.dyD)(t,i);e&&(0,I.t9)("fetchChat",{type:"user",user:e})}})),(0,f.iw)("loadChatSettings",(async(t,e,a)=>{const{chatId:i}=a,s=(0,b.Z1J)(t,i);if(!s)return;const d=await(0,I.t9)("fetchChatSettings",s);if(!d)return;const{settings:o,users:n}=d;t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(n,"id")),t=(0,V.a4)(t,s.id,{settings:o}),(0,f.R3)(t)})),(0,f.iw)("toggleJoinToSend",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,d=(0,b.Z1J)(t,i);d&&((0,p.ZV)(d)||(0,p.eA)(d))&&await(0,I.t9)("toggleJoinToSend",d,s)})),(0,f.iw)("toggleJoinRequest",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,d=(0,b.Z1J)(t,i);d&&((0,p.ZV)(d)||(0,p.eA)(d))&&await(0,I.t9)("toggleJoinRequest",d,s)})),(0,f.iw)("openForumPanel",((t,e,a)=>{const{chatId:i,tabId:s=(0,n._w)()}=a;return e.toggleStoryRibbon({isShown:!1,tabId:s}),e.toggleStoryRibbon({isShown:!1,isArchived:!0,tabId:s}),(0,g.i)(t,{forumPanelChatId:i},s)})),(0,f.iw)("closeForumPanel",((t,e,a)=>{const{tabId:i=(0,n._w)()}=a||{};return(0,g.i)(t,{forumPanelChatId:void 0},i)})),(0,f.iw)("processAttachBotParameters",(async(t,e,a)=>{const{username:i,filter:s,startParam:d,tabId:o=(0,n._w)()}=a,r=await S(t,e,i,o);if(!r)return;if(!Boolean(s))return void e.callAttachBot({isFromSideMenu:!0,bot:r,startParam:d,tabId:o});t=(0,f.Rd)();const{attachMenu:{bots:c}}=t;if(!c[r.id])return t=(0,g.i)(t,{requestedAttachBotInstall:{bot:r,onConfirm:{action:"requestAttachBotInChat",payload:{bot:r,filter:s,startParam:d}}}},o),void(0,f.R3)(t);e.requestAttachBotInChat({bot:r,filter:s,startParam:d,tabId:o})})),(0,f.iw)("loadTopics",(async(t,e,a)=>{const{chatId:i,force:s}=a,o=(0,b.Z1J)(t,i);if(!o)return;if(!s&&o.listedTopicIds&&o.listedTopicIds.length===o.topicsCount)return;const n=!s&&o.listedTopicIds?o.listedTopicIds.reduce(((t,e)=>{const a=o.topics?.[e],i=o.topics?.[t];return a&&(!i||a.lastMessageId<i.lastMessageId)?e:t})):void 0,{id:r,date:l,lastMessageId:h}=n&&o.topics?.[n]||{},u=await(0,I.t9)("fetchTopics",{chat:o,offsetTopicId:r,offsetId:h,offsetDate:l,limit:r?d.C1M:d.SC4});u&&(t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(u.users,"id")),t=(0,V.fZ)(t,(0,c.ee)(u.chats,"id")),t=(0,V.m6)(t,u.messages),t=(0,V.XG)(t,i,u.count,u.topics),t=(0,V.Jr)(t,i,u.topics.map((t=>t.id))),Object.entries(u.draftsById||{}).forEach((e=>{let[a,s]=e;t=(0,V.pf)(t,i,Number(a),"draft",s?.formattedText),t=(0,V.pf)(t,i,Number(a),"replyingToId",s?.replyingToId)})),Object.entries(u.readInboxMessageIdByTopicId||{}).forEach((e=>{let[a,s]=e;t=(0,V.Xg)(t,i,Number(a),{lastReadInboxMessageId:s})})),(0,f.R3)(t))})),(0,f.iw)("loadTopicById",(async(t,e,a)=>{const{chatId:i,topicId:s}=a,d=(0,b.Z1J)(t,i);if(!d)return;const o=await(0,I.t9)("fetchTopicById",{chat:d,topicId:s});if(o)t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(o.users,"id")),t=(0,V.fZ)(t,(0,c.ee)(o.chats,"id")),t=(0,V.m6)(t,o.messages),t=(0,V.Cn)(t,i,s,o.topic),(0,f.R3)(t);else if("tabId"in a&&a.shouldCloseChatOnError){const{tabId:t=(0,n._w)()}=a;e.openChat({id:void 0,tabId:t})}})),(0,f.iw)("toggleForum",(async(t,e,a)=>{const{chatId:i,isEnabled:s,tabId:d=(0,n._w)()}=a,o=await T(t,e,i,d);if(!o)return;let r;try{r=await(0,I.t9)("toggleForum",{chat:o,isEnabled:s})}catch(t){t.message.startsWith("A wait of")?e.showNotification({message:l.Iu("FloodWait"),tabId:d}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:d})}r&&(t=(0,f.Rd)(),t=(0,V.a4)(t,o.id,{isForum:s}),(0,f.R3)(t),s?e.openForumPanel({chatId:o.id,tabId:d}):e.closeForumPanel({tabId:d}))})),(0,f.iw)("toggleParticipantsHidden",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,d=(0,b.Z1J)(t,i);if(!d)return;const o=(0,b.x67)(t,d.id)?.areParticipantsHidden;t=(0,V.US)(t,i,{areParticipantsHidden:s}),(0,f.R3)(t),await(0,I.t9)("toggleParticipantsHidden",{chat:d,isEnabled:s})||void 0===o||(t=(0,f.Rd)(),t=(0,V.US)(t,i,{areParticipantsHidden:o}),(0,f.R3)(t))})),(0,f.iw)("createTopic",(async(t,e,a)=>{const{chatId:i,title:s,iconColor:d,iconEmojiId:o,tabId:r=(0,n._w)()}=a,c=(0,b.Z1J)(t,i);if(!c)return;(0,b.jUK)(t,r).createTopicPanel&&(t=(0,g.i)(t,{createTopicPanel:{chatId:i,isLoading:!0}},r),(0,f.R3)(t));const l=await(0,I.t9)("createTopic",{chat:c,title:s,iconColor:d,iconEmojiId:o});l&&e.openChat({id:i,threadId:l,shouldReplaceHistory:!0,tabId:r}),e.closeCreateTopicPanel({tabId:r})})),(0,f.iw)("deleteTopic",(async(t,e,a)=>{const{chatId:i,topicId:s}=a,d=(0,b.Z1J)(t,i);d&&await(0,I.t9)("deleteTopic",{chat:d,topicId:s})&&(t=(0,f.Rd)(),t=(0,V.BK)(t,i,s),(0,f.R3)(t))})),(0,f.iw)("editTopic",(async(t,e,a)=>{const{chatId:i,topicId:s,tabId:d=(0,n._w)(),...o}=a,r=(0,b.Z1J)(t,i),c=r?.topics?.[s];r&&c&&((0,b.jUK)(t,d).editTopicPanel&&(t=(0,g.i)(t,{editTopicPanel:{chatId:i,topicId:s,isLoading:!0}},d),(0,f.R3)(t)),await(0,I.t9)("editTopic",{chat:r,topicId:s,...o})&&(t=(0,f.Rd)(),t=(0,V.Cn)(t,i,s,o),(0,f.R3)(t),e.closeEditTopicPanel({tabId:d})))})),(0,f.iw)("toggleTopicPinned",((t,e,a)=>{const{chatId:i,topicId:s,isPinned:d,tabId:o=(0,n._w)()}=a,{topicsPinnedLimit:r}=t.appConfig||{},c=(0,b.Z1J)(t,i);c&&c.topics&&r&&(d&&Object.values(c.topics).filter((t=>t.isPinned)).length>=r?e.showNotification({message:l.Iu("LimitReachedPinnedTopics",r,"i"),tabId:o}):(0,I.t9)("togglePinnedTopic",{chat:c,topicId:s,isPinned:d}))})),(0,f.iw)("checkChatlistInvite",(async(t,e,a)=>{const{slug:i,tabId:s=(0,n._w)()}=a,d=await(0,I.t9)("checkChatlistInvite",{slug:i});d?(t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(d.users,"id")),t=(0,V.fZ)(t,(0,c.ee)(d.chats,"id")),t=(0,g.i)(t,{chatlistModal:{invite:d.invite}},s),(0,f.R3)(t)):e.showNotification({message:l.Iu("lng_group_invite_bad_link"),tabId:s})})),(0,f.iw)("joinChatlistInvite",(async(t,e,a)=>{const{invite:i,peerIds:s,tabId:d=(0,n._w)()}=a,o=s.map((e=>(0,b.Z1J)(t,e))).filter(Boolean),r=o.filter((t=>t.isNotJoined)).length,c="folderId"in i?(0,b.MwT)(t,i.folderId):void 0,h="title"in i?i.title:c?.title;try{if(!await(0,I.t9)("joinChatlistInvite",{slug:i.slug,peers:o}))return;e.showNotification({title:l.Iu(c?"FolderLinkUpdatedTitle":"FolderLinkAddedTitle",h),message:l.Iu("FolderLinkAddedSubtitle",r,"i"),tabId:d})}catch(t){"CHATLISTS_TOO_MUCH"===t.message?e.openLimitReachedModal({limit:"chatlistJoined",tabId:d}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:d})}})),(0,f.iw)("leaveChatlist",(async(t,e,a)=>{const{folderId:i,peerIds:s,tabId:d=(0,n._w)()}=a,o=(0,b.MwT)(t,i),r=s?.map((e=>(0,b.Z1J)(t,e))).filter(Boolean)||[];await(0,I.t9)("leaveChatlist",{folderId:i,peers:r})&&e.showNotification({title:l.Iu("FolderLinkDeletedTitle",o.title),message:l.Iu("FolderLinkDeletedSubtitle",r.length,"i"),tabId:d})})),(0,f.iw)("loadChatlistInvites",(async(t,e,a)=>{const{folderId:i}=a,s=await(0,I.t9)("fetchChatlistInvites",{folderId:i});s&&(t=(0,f.Rd)(),t=(0,V.Sh)(t,(0,c.ee)(s.users,"id")),t=(0,V.fZ)(t,(0,c.ee)(s.chats,"id")),t={...t,chatFolders:{...t.chatFolders,invites:{...t.chatFolders.invites,[i]:s.invites}}},(0,f.R3)(t))})),(0,f.iw)("createChatlistInvite",(async(t,e,a)=>{const{folderId:i,tabId:d=(0,n._w)()}=a,o=(0,b.MwT)(t,i);if(!o)return;let r;t=(0,g.i)(t,{shareFolderScreen:{...(0,b.jUK)(t,d).shareFolderScreen,isLoading:!0}},d),(0,f.R3)(t);try{r=await(0,I.t9)("createChalistInvite",{folderId:i,peers:o.includedChatIds.concat(o.pinnedChatIds||[]).map((e=>(0,b.Z1J)(t,e)||(0,b.dyD)(t,e))).filter(Boolean)})}catch(t){v.has(t.message)?(e.openLimitReachedModal({limit:"chatlistInvites",tabId:d}),e.requestNextSettingsScreen({screen:s.MT.Folders,tabId:d})):e.showDialog({data:{...t,hasErrorKey:!0},tabId:d})}if(!r||!r.invite)return;const{shareFolderScreen:c}=(0,b.jUK)(t,d);c&&(t=(0,f.Rd)(),t={...t,chatFolders:{...t.chatFolders,byId:{...t.chatFolders.byId,[i]:{...t.chatFolders.byId[i],...r.filter}},invites:{...t.chatFolders.invites,[i]:[...t.chatFolders.invites[i]||[],r.invite]}}},t=(0,g.i)(t,{shareFolderScreen:{...c,url:r.invite.url,isLoading:!1}},d),(0,f.R3)(t))})),(0,f.iw)("editChatlistInvite",(async(t,e,a)=>{const{folderId:i,peerIds:s,url:d,tabId:o=(0,n._w)()}=a,r=d.split("/").pop();if(!r)return;const c=s.map((e=>(0,b.Z1J)(t,e)||(0,b.dyD)(t,e))).filter(Boolean);t=(0,g.i)(t,{shareFolderScreen:{...(0,b.jUK)(t,o).shareFolderScreen,isLoading:!0}},o),(0,f.R3)(t);try{const e=await(0,I.t9)("editChatlistInvite",{folderId:i,slug:r,peers:c});if(!e)return;t=(0,f.Rd)(),t={...t,chatFolders:{...t.chatFolders,invites:{...t.chatFolders.invites,[i]:t.chatFolders.invites[i]?.map((t=>t.url===d?e:t))}}},(0,f.R3)(t)}catch(t){e.showDialog({data:{...t,hasErrorKey:!0},tabId:o})}finally{t=(0,f.Rd)(),t=(0,g.i)(t,{shareFolderScreen:{...(0,b.jUK)(t,o).shareFolderScreen,isLoading:!1}},o),(0,f.R3)(t)}})),(0,f.iw)("deleteChatlistInvite",(async(t,e,a)=>{const{folderId:i,url:s}=a,d=s.split("/").pop();d&&await(0,I.t9)("deleteChatlistInvite",{folderId:i,slug:d})&&(t=(0,f.Rd)(),t={...t,chatFolders:{...t.chatFolders,invites:{...t.chatFolders.invites,[i]:t.chatFolders.invites[i]?.filter((t=>t.url!==s))}}},(0,f.R3)(t))})),(0,f.iw)("openDeleteChatFolderModal",(async(t,e,a)=>{const{folderId:i,isConfirmedForChatlist:s,tabId:d=(0,n._w)()}=a,o=(0,b.MwT)(t,i);if(o){if(o.isChatList&&(!o.hasMyInvites||s)){const e=await(0,I.t9)("fetchLeaveChatlistSuggestions",{folderId:i});return t=(0,f.Rd)(),t=(0,g.i)(t,{chatlistModal:{removal:{folderId:i,suggestedPeerIds:e}}},d),void(0,f.R3)(t)}t=(0,g.i)(t,{deleteFolderDialogModal:i},d),(0,f.R3)(t)}})),(0,f.iw)("updateChatDetectedLanguage",((t,e,a)=>{const{chatId:i,detectedLanguage:s}=a;return t=(0,f.Rd)(),(0,V.a4)(t,i,{detectedLanguage:s})})),(0,f.iw)("togglePeerTranslations",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,d=(0,b.Z1J)(t,i);d&&void 0!==await(0,I.t9)("togglePeerTranslations",{chat:d,isEnabled:s})&&(t=(0,f.Rd)(),t=(0,V.CJ)(t,i,{isTranslationDisabled:!s||void 0}),(0,f.R3)(t))}))},88422:(t,e,a)=>{a.d(e,{CW:()=>T,EP:()=>R,FF:()=>P,Mt:()=>F,NH:()=>S,o5:()=>v});var i=a(57710),s=a(64319),d=a(65054),o=a(60782),n=a(59692),r=a(74753),c=a(97184),l=a(92387),h=a(4463),u=a(33555),I=a(41020),p=a(78958),f=a(44271),V=a(7054),w=a(42431),g=a(27225);const b="data:audio/mpeg;base64,SUQzBAAAAAABEVRYWFgAAAAtAAADY29tbWVudABCaWdTb3VuZEJhbmsuY29tIC8gTGFTb25vdGhlcXVlLm9yZwBURU5DAAAAHQAAA1N3aXRjaCBQbHVzIMKpIE5DSCBTb2Z0d2FyZQBUSVQyAAAABgAAAzIyMzUAVFNTRQAAAA8AAANMYXZmNTcuODMuMTAwAAAAAAAAAAAAAAD/80DEAAAAA0gAAAAATEFNRTMuMTAwVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/zQsRbAAADSAAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/zQMSkAAADSAAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";let C,m,y;function v(){return R(),Promise.all(Object.values(y).map((t=>{const e=t.src;return t.src=b,t.muted=!0,t.volume=1e-4,t.play().then((()=>{t.pause(),t.volume=1,t.currentTime=0,t.muted=!1,(0,i.Yq)((()=>{t.src=e}))}))})))}function R(){if(y)return;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"),d=new Audio("./call_connect.mp3"),o=new Audio("./call_end.mp3"),n=new Audio("./call_incoming.mp3");n.loop=!0;const r=new Audio("./call_ringing.mp3");r.loop=!0,y={join:t,allowTalk:i,leave:a,connecting:e,incoming:n,end:o,connect:d,busy:s,ringing:r}}async function A(t,e){const a=await(0,l.t9)("getGroupCall",{call:e});if(!a)return;t=(0,u.Rd)();const i=(0,w.$5)(t,e.id);return t=(0,p.AH)(t,e.id,(0,o.CE)(a.groupCall,["connectionState"]),void 0,i?.isLoaded?void 0:a.groupCall.participantsCount),t=(0,I.Sh)(t,(0,o.ee)(a.users,"id")),t=(0,I.fZ)(t,(0,o.ee)(a.chats,"id")),(0,u.R3)(t),a.groupCall}async function M(t,e,a){const i=await(0,l.t9)("fetchGroupCallParticipants",{call:e,offset:a});i&&(t=(0,u.Rd)(),t=(0,I.Sh)(t,(0,o.ee)(i.users,"id")),t=(0,I.fZ)(t,(0,o.ee)(i.chats,"id")),(0,u.R3)(t))}(0,u.iw)("toggleGroupCallPanel",((t,e,a)=>{const{force:i,tabId:s=(0,d._w)()}=a||{};return(0,f.i)(t,{isCallPanelVisible:"force"in(a||{})?i:!(0,V.jUK)(t,s).isCallPanelVisible},s)})),(0,u.iw)("subscribeToGroupCallUpdates",(async(t,e,a)=>{const{subscribed:i,id:s}=a,d=(0,w.$5)(t,s);d&&(i&&(await A(t,d),t=(0,u.Rd)(),await M(t,d)),await(0,l.t9)("toggleGroupCallStartSubscription",{subscribed:i,call:d}))})),(0,u.iw)("createGroupCall",(async(t,e,a)=>{const{chatId:i,tabId:s=(0,d._w)()}=a,o=(0,V.Z1J)(t,i);if(!o)return;const n=await(0,l.t9)("createGroupCall",{peer:o});n&&(t=(0,u.Rd)(),t=(0,p.AH)(t,n.id,{...n,chatId:i}),(0,u.R3)(t),e.requestMasterAndJoinGroupCall({id:n.id,accessHash:n.accessHash,tabId:s}))})),(0,u.iw)("createGroupCallInviteLink",(async(t,e,a)=>{const{tabId:i=(0,d._w)()}=a||{},o=(0,w.mU)(t);if(!o||!o.chatId)return;const n=(0,V.Z1J)(t,o.chatId);if(!n)return;const r=Boolean((0,h.WS)(n));let c=(0,V.x67)(t,n.id)?.inviteLink;r&&(c=await(0,l.t9)("exportGroupCallInvite",{call:o,canSelfUnmute:!1})),c&&((0,s.TE)(c),e.showNotification({message:"Link copied to clipboard",tabId:i}))})),(0,u.iw)("joinVoiceChatByLink",(async(t,e,a)=>{const{username:i,inviteHash:s,tabId:o=(0,d._w)()}=a,r=await(0,g.Co)(t,i);if(!r)return void e.showNotification({message:n.Iu("NoUsernameFound"),tabId:o});t=(0,u.Rd)();const c=await(0,g.ft)(t,e,r,o);c?.groupCall&&e.requestMasterAndJoinGroupCall({id:c.groupCall.id,accessHash:c.groupCall.accessHash,inviteHash:s,tabId:o})})),(0,u.iw)("requestMasterAndJoinGroupCall",((t,e,a)=>{e.requestMasterAndCallAction({action:"joinGroupCall",payload:a,tabId:a.tabId||(0,d._w)()})})),(0,u.iw)("requestMasterAndAcceptCall",((t,e,a)=>{e.requestMasterAndCallAction({action:"acceptCall",payload:void 0,tabId:a?.tabId||(0,d._w)()})})),(0,u.iw)("joinGroupCall",(async(t,e,a)=>{const{chatId:i,id:s,accessHash:o,inviteHash:n,tabId:l=(0,d._w)()}=a;if(!c.Bi)return void e.showNotification({message:"Sorry, your browser doesn't support group calls",tabId:l});if(t.phoneCall)return void e.toggleGroupCallPanel({tabId:l});!function(){const t=new(window.AudioContext||window.webkitAudioContext);C=new Audio,m=t,C.srcObject=_(t),(0,r.Z)(C)}(),R(),T(t=(0,u.Rd)(),e,!0,l);const{groupCalls:{activeGroupCallId:h}}=t;let I=s?(0,w.$5)(t,s):(0,w.Bj)(t,i);if(I&&I.id===h)e.toggleGroupCallPanel({tabId:l});else if(h)"leaveGroupCall"in e&&e.leaveGroupCall({rejoin:a,tabId:l});else if(I&&h===I.id)e.toggleGroupCallPanel({tabId:l});else{if(I||s&&o||!i)!I&&s&&o&&(I=await A(t,{id:s,accessHash:o}));else{const a=(0,V.Z1J)(t,i);if(!a)return;await(0,g.ft)(t,e,a,l),t=(0,u.Rd)(),I=(0,w.Bj)(t,i)}I&&(t=(0,u.Rd)(),t=(0,p.AH)(t,I.id,{...I,inviteHash:n},void 0,I.participantsCount+1),t={...t,groupCalls:{...t.groupCalls,activeGroupCallId:I.id}},(0,u.R3)(t),e.toggleGroupCallPanel({force:!1,tabId:l}))}})),(0,u.iw)("playGroupCallSound",((t,e,a)=>{const{sound:i}=a;y[i]&&("connecting"!==i&&y.connecting.pause(),"incoming"!==i&&y.incoming.pause(),"ringing"!==i&&y.ringing.pause(),(0,r.Z)(y[i]))})),(0,u.iw)("loadMoreGroupCallParticipants",(t=>{const e=(0,w.mU)(t);e&&M(t,e,e.nextOffset)})),(0,u.iw)("requestMasterAndRequestCall",((t,e,a)=>{e.requestMasterAndCallAction({action:"requestCall",payload:a,tabId:a.tabId||(0,d._w)()})})),(0,u.iw)("requestCall",((t,e,a)=>{const{userId:i,isVideo:s,tabId:o=(0,d._w)()}=a;t.phoneCall?e.toggleGroupCallPanel({tabId:o}):(0,V.dyD)(t,i)&&(R(),T(t=(0,u.Rd)(),e,s,o),t=(0,u.Rd)(),t={...t,phoneCall:{id:"",state:"requesting",participantId:i,isVideo:s,adminId:t.currentUserId}},(0,u.R3)(t),e.toggleGroupCallPanel({force:!1,tabId:o}))}));const _=t=>{const e=t.createOscillator(),a=e.connect(t.createMediaStreamDestination());return e.start(),new MediaStream([Object.assign(a.stream.getAudioTracks()[0],{enabled:!1})])};function P(){return C}function S(){return m}function F(){C?.pause(),m=void 0,C=void 0}function T(t,e,a){for(var i=arguments.length,s=new Array(i>3?i-3:0),o=3;o<i;o++)s[o-3]=arguments[o];let[r=(0,d._w)()]=s;a?navigator.mediaDevices.getUserMedia({video:!0}).then((a=>{0===a.getVideoTracks().length?e.showNotification({message:n.Iu("Call.Camera.Error"),tabId:r}):(a.getTracks().forEach((t=>t.stop())),B(t,e,r))})).catch((()=>{e.showNotification({message:n.Iu("Call.Camera.Error"),tabId:r})})):B(t,e,r)}function B(t,e){for(var a=arguments.length,i=new Array(a>2?a-2:0),s=2;s<a;s++)i[s-2]=arguments[s];let[o=(0,d._w)()]=i;navigator.mediaDevices.getUserMedia({audio:!0}).then((t=>{0===t.getAudioTracks().length?e.showNotification({message:n.Iu("RequestAcces.Error.HaveNotAccess.Call"),tabId:o}):t.getTracks().forEach((t=>t.stop()))})).catch((()=>{e.showNotification({message:n.Iu("RequestAcces.Error.HaveNotAccess.Call"),tabId:o})}))}},78958:(t,e,a)=>{a.d(e,{AH:()=>n,B6:()=>l,Ic:()=>c,dc:()=>r});var i=a(60782),s=a(7054),d=a(42431),o=a(53475);function n(t,e,a,s,d){const o=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,i.CE)(a,["participantsCount"]),...s&&{participantsCount:t.groupCalls.byId[e].participantsCount+s},...void 0!==d&&{participantsCount:d},participants:o}}}}}function r(t,e){const a=(0,d.$5)(t,e);return a&&a.chatId&&(0,s.Z1J)(t,a.chatId)&&(t=(0,o.US)(t,a.chatId,{groupCallId:void 0})),{...t,groupCalls:{...t.groupCalls,byId:{...(0,i.CE)(t.groupCalls.byId,[e.toString()])}}}}function c(t,e,a){return t.groupCalls.activeGroupCallId?n(t,t.groupCalls.activeGroupCallId,e,void 0,a):t}function l(t,e,a,i){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=(0,d.$5)(t,e);return o?n(t,e,{participants:{...o.participants,[a]:{...o.participants[a],...i}}},i.isLeft?s?0:-1:o.participants[a]||s?0:1):t}}}]);
//# sourceMappingURL=8422.444fff334605bc757748.js.map