TelegramPWA/dist/8422.6bcf9d888c6fdb705009.js
Alexander Zinchuk 5fcdd0fecd [Build]
2022-12-27 02:47:54 +01:00

2 lines
28 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),r=a(5161),c=a(11192),l=a(60782),h=a(69118),u=a(56112),f=a(53551),p=a(78958),C=a(42431),I=a(16974),g=a(50711),m=a(9211);const w={id:n.aw,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 f=(0,c.VF)(u)?.message,p=await(0,d.t9)("fetchChats",{limit:n.Ov,offsetDate:a,archived:"archived"===t,withPinned:o,serverTimeOffset:u.serverTimeOffset,lastLocalServiceMessage:f});if(!p)return;const{chatIds:C}=p;if(C.length>0&&C[0]===e&&C.shift(),u=(0,i.Rd)(),o&&"active"===t){if(!C.includes(n.aw)){const t=await(0,d.t9)("fetchChat",{type:"user",user:w});u=(0,i.Rd)();const e=t&&(0,c.Z1)(u,t.chatId);e&&(C.unshift(e.id),p.chats.unshift(e),f&&(e.lastMessage=f))}const e=(0,c.jr)(u),a=e?[e]:[],s=(0,c.P2)(u)||[];u.currentUserId&&u.users.byId[u.currentUserId]&&s.push(u.users.byId[u.currentUserId]),u=(0,r.s5)(u,(0,l.ee)(s.concat(p.users),"id")),u=(0,r.ps)(u,p.userStatusesById),u=(0,r.SL)(u,(0,l.ee)(a.concat(p.chats),"id")),u=(0,r.Mg)(u,t,C)}else o&&"archived"===t?(u=(0,r.Sh)(u,(0,l.ee)(p.users,"id")),u=(0,r.zn)(u,p.userStatusesById),u=(0,r.GL)(u,(0,l.ee)(p.chats,"id")),u=(0,r.Mg)(u,t,C)):(u=(0,r.Sh)(u,(0,l.ee)(p.users,"id")),u=(0,r.zn)(u,p.userStatusesById),u=(0,r.GL)(u,(0,l.ee)(p.chats,"id")),u=(0,r.B1)(u,t,C));u=(0,r.vv)(u,t,p);const I=h?p.chatIds:Object.keys(p.draftsById);I.forEach((t=>{(0,c.Ms)(u,t,s._f)?.isLocal||(u=(0,r.pf)(u,t,s._f,"draft",p.draftsById[t]))}));const g=h?p.chatIds:Object.keys(p.replyingToById);g.forEach((t=>{u=(0,r.pf)(u,t,s._f,"replyingToId",p.replyingToById[t])})),0!==C.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:c}=e;let h=(0,i.Rd)();if(a&&(h=(0,r.Sh)(h,(0,l.ee)(a,"id"))),s&&(h=(0,r.zn)(h,s)),n){const t=(0,C.$5)(h,n.id);h=(0,p.AH)(h,n.id,(0,l.CE)(n,["connectionState"]),void 0,t?void 0:n.participantsCount)}h=(0,r.a4)(h,t.id,{fullInfo:o,...c&&{membersCount:c}}),(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,c.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,r.a4)((0,i.Rd)(),s.id,s)),o&&(0,i.R3)((0,r.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,c.dy)(t,a.id);return s?(0,u.cS)(s)&&s.isAttachBot?s:void(0,i.Sv)().showNotification({message:g.i0("WebApp.AddToAttachmentUnavailableError")}):void 0}async function H(t,e,a,s){const o=await P(a);if(!o)return;const n=(0,c.dy)((0,i.Rd)(),o.id);n&&n.isAttachBot?t.callAttachBot({botId:n.id,chatId:e,..."string"==typeof s&&{startParam:s}}):t.showNotification({message:g.i0("WebApp.AddToAttachmentUnavailableError")})}(0,i.iw)("preloadTopChatMessages",(async(t,e)=>{const a=new Set;for(let i=0;i<n.Mo;i++){await(0,h.wO)(100);const{chatId:i}=(0,c.Bt)(t)||{},o=(0,I.gO)(n.Nf)?.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}=a;if(!i)return;const{currentUserId:n}=t,r=(0,c.Z1)(t,i);if(r?.hasUnreadMark&&e.toggleChatUnread({id:i}),r?.lastMessage?.threadInfo&&e.requestThreadInfoUpdate({chatId:r.lastMessage.threadInfo.chatId,threadId:r.lastMessage.threadInfo.threadId}),r)(0,u.Hp)(r)&&!r.isMin&&e.requestChatUpdate({chatId:i});else if(i===n)(0,d.t9)("fetchChat",{type:"self"});else{const e=(0,c.dy)(t,i);e&&(0,d.t9)("fetchChat",{type:"user",user:e})}o!==s._f&&((0,c.qS)(t,i,o)||e.requestThreadInfoUpdate({chatId:i,threadId:o}))})),(0,i.iw)("openLinkedChat",(async(t,e,a)=>{const{id:i}=a,s=(0,c.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:i,threadId:s,messageId:o}=a,n=(0,c.Z1)(t,i);n&&await(0,d.t9)("requestThreadInfoUpdate",{chat:n,threadId:s})&&e.focusMessage({chatId:i,threadId:s,messageId:o})})),(0,i.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:n.AJ,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,r=0;const l=t=>t.lastMessage?.date||t.joinDate;for(;d||!(0,i.Rd)().chats.isFullyLoaded[s];){if(r++>=100)return void(n.eM&&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.aw&&!(0,c.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,c.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,c.Z1)(t,s);o&&(0,d.t9)("requestChatUpdate",{chat:o,serverTimeOffset:i,...s===n.aw&&{lastLocalMessage:(0,c.VF)(t)?.message}})})),(0,i.iw)("updateChatMutedState",((t,e,a)=>{const{serverTimeOffset:s}=t,{chatId:o,isMuted:n}=a,l=(0,c.Z1)(t,o);l&&((0,i.R3)((0,r.a4)(t,o,{isMuted:n})),(0,d.t9)("updateChatMutedState",{chat: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:c,accessHash:l}=n;let h=(0,i.Rd)();h=(0,r.a4)(h,c,n),h={...h,chatCreation:{...h.chatCreation,progress:n?o.Nh.Complete:o.Nh.Error}},(0,i.R3)(h),(0,i.Sv)().openChat({id:c,shouldReplaceHistory:!0}),c&&l&&s&&await(0,d.t9)("editChatPhoto",{chatId:c,accessHash:l,photo:s})}(s,h.map((e=>(0,c.dy)(t,e))).filter(Boolean),n,l)})),(0,i.iw)("joinChannel",((t,e,a)=>{const{chatId:s}=a,o=(0,c.Z1)(t,s);if(!o)return;const{id:n,accessHash:r}=o;n&&r&&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,r)})),(0,i.iw)("deleteChatUser",((t,e,a)=>{const{chatId:s,userId:o}=a,n=(0,c.Z1)(t,s),l=(0,c.dy)(t,o);n&&l&&(t=(0,r.Dd)(t,s),(0,i.R3)(t),(0,c.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,c.Z1)(t,s);o&&(t=(0,r.Dd)(t,s),(0,i.R3)(t),(0,c.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,c.Z1)(t,s);if(!o)return;t=(0,r.Dd)(t,s),(0,i.R3)(t),(0,c.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,c.Z1)(t,s);if(!o)return;t=(0,r.Dd)(t,s),(0,i.R3)(t),(0,c.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 c=(0,i.Rd)();c=(0,r.a4)(c,n,s),c={...c,chatCreation:{...c.chatCreation,progress:s?o.Nh.Complete:o.Nh.Error}},(0,i.R3)(c),(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,c.dy)(t,e))).filter(Boolean),l)})),(0,i.iw)("toggleChatPinned",((t,e,a)=>{const{id:i,folderId:s}=a,o=(0,c.Z1)(t,i);if(!o)return;const r=(0,m.M)(t,"dialogFolderPinned");if(s){const e=(0,c.Mw)(t,s);if(e){const a=!(0,c.ep)(t,i,s),{pinnedChatIds:o,includedChatIds:n}=e,r=a?[i,...o||[]]:(o||[]).filter((t=>t!==i)),l=[i,...n];(0,d.t9)("editChatFolder",{id:s,folderUpdate:{...e,pinnedChatIds:r,includedChatIds:l}})}}else{const a=(0,c.Ek)(t,i),s=(0,c.ep)(t,i,"archived"===a?n.WS:void 0);if((t.chats.orderedPinnedIds["archived"===a?"archived":"active"]?.length||0)>=r&&!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,c.Z1)(t,i);s&&(0,d.t9)("toggleChatArchived",{chat:s,folderId:(0,u.pE)(s)?0:n.WS})})),(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,m.M)(t,"dialogFiltersChats");o.some((e=>(0,c.Mw)(t,e).includedChatIds.length>=n))?e.openLimitReachedModal({limit:"dialogFiltersChats"}):(s.forEach((async e=>{const a=(0,c.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,c.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,c.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:r}=t.chatFolders,c=(0,m.M)(t,"dialogFilters");Object.keys(r).length>=c?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:r}=n.chatFolders;r&&(0,i.R3)({...n,chatFolders:{...n.chatFolders,recommended:r.filter((t=>{let{id:e}=t;return e!==a}))}})}(s,Math.max(...o||[],n.WS))})),(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,c.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,c.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)("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.AJ});const h=await async function(t){const e=(0,i.Rd)(),a=(0,c.Bk)(e,t);if(a&&!a.isMin)return(0,c.Z1)(e,a.id);const{chat:s,user:o}=await(0,d.t9)("getChatByPhoneNumber",t)||{};return s?((0,i.R3)((0,r.a4)((0,i.Rd)(),s.id,s)),o&&(0,i.R3)((0,r.Nq)((0,i.Rd)(),o.id,o)),s):void 0}(s);if(!h)return e.openPreviousChat(),void e.showNotification({message:g.i0("lng_username_by_phone_not_found").replace("{phone}",s)});e.openChat({id:h.id}),l&&H(e,h.id,l,o)})),(0,i.iw)("openTelegramLink",((t,e,a)=>{const{url:i}=a,{openChatByPhoneNumber:s,openChatByInvite:o,openStickerSet:d,openChatWithDraft:r,joinVoiceChatByLink:l,showNotification:h,focusMessage:u,openInvoice:p,processAttachBotParameters:C,openChatByUsername:I}=e;if(i.match(n.g$))return void(0,f.ou)(i);const g=new URL(i.startsWith("http")?i:`https://${i}`);if("t.me"===g.hostname&&"/"===g.pathname)return void window.open(g.toString(),"_blank","noopener");const m=g.hostname.split(".");if(m.length>3)return;const w=3===m.length?`${m[0]}/${g.pathname}`:g.pathname,[v,y,R]=w.split("/").filter(Boolean).map((t=>decodeURI(t))),b=Object.fromEntries(g.searchParams);let M;"joinchat"===v&&(M=y);const P=!(!b.hasOwnProperty("startattach")||b.startattach)||b.startattach,S=(0,f.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 H=y||void 0,A=R?Number(R):void 0,B=b.comment?Number(b.comment):void 0;if("share"===v)r({text:(0,f.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&&H&&A){const e=`-${H}`;if(!(0,c.Z1)(t,e))return void h({message:"Chat does not exist"});u({chatId:e,messageId:A})}else v.startsWith("$")?p({slug:v.substring(1)}):"invoice"===v?p({slug:y}):P&&S?C({username:v,filter:S,..."string"==typeof P&&{startParam:P}}):I({username:v,messageId:A||Number(H),commentId:B,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:r,startParam:l,startAttach:h,attach:u}=a,f=(0,c.jr)(t);if(!r)return h||l||!f?.usernames?.some((t=>t.username===s))?void await async function(t,e,a,s,o,d){const r=(0,i.Rd)(),l=(0,c.jr)(r);if(o&&!d){const a=await S(r,e);if(!l||!a)return;return void t.callAttachBot({botId:a.id,chatId:l.id,..."string"==typeof o&&{startParam:o}})}const h=l?.usernames?.some((t=>t.username===e));h||t.openChat({id:n.AJ});const u=await P(e);u?(a?t.focusMessage({chatId:u.id,messageId:a}):h||t.openChat({id:u.id}),s&&t.startBot({botId:u.id,param:s}),d&&H(t,u.id,d,o)):h||(t.openPreviousChat(),t.showNotification({message:"User does not exist"}))}(e,s,o,l,h,u):void e.focusMessage({chatId:f.id,messageId:o});const{chatId:p,type:C}=(0,c.Bt)(t)||{},I=(0,c.DI)(t,s);if(p&&I&&"thread"===C){const a=(0,c.tZ)(t,p,o);if(a&&a.chatId===p)return void e.focusMessage({chatId:a.chatId,threadId:a.threadId,messageId:r})}o&&async function(t,e,a,s){t.openChat({id:n.AJ});const o=await P(e);if(!o)return;const r=(0,i.Rd)(),l=(0,c.tZ)(r,o.id,a);let h;if(l)h=l.chatId;else{const t=await(0,d.t9)("requestThreadInfoUpdate",{chat:o,threadId:a});if(!t)return;h=t.discussionChatId}h&&t.focusMessage({chatId:h,threadId:a,messageId:Number(s)})}(e,s,o,r)})),(0,i.iw)("togglePreHistoryHidden",(async(t,e,a)=>{const{chatId:s,isEnabled:o}=a;let n=(0,c.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,r.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,c.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,c.Z1)(t,s);const h=(0,c.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 f=(0,c.Z1)(t,s);if(!f||!f.fullInfo)return;const{members:p,kickedMembers:C}=f.fullInfo,I=Boolean(n.viewMessages),g=!Object.keys(n).length;(0,i.R3)((0,r.a4)(t,s,{fullInfo:{...f.fullInfo,...p&&I&&{members:p.filter((t=>t.userId!==o))},...p&&!I&&{members:p.map((t=>t.userId===o?{...t,bannedRights:n}:t))},...g&&C&&{kickedMembers:C.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,c.Z1)(t,s);const f=(0,c.dy)(t,o);if(!h||!f)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:f,adminRights:n,customTitle:l});const p=await(0,d.t9)("fetchFullChat",h);if(!p?.fullInfo)return;const{adminMembersById:C}=p.fullInfo,I=!Object.keys(n).length;let g;if(C)if(I){const{[o]:t,...e}=C;g=e}else g={...C,[o]:{...C[o],adminRights:n,customTitle:l}};t=(0,i.Rd)(),(0,i.R3)((0,r.a4)(t,s,{fullInfo:{...p.fullInfo,...g&&{adminMembersById:g}}}))})),(0,i.iw)("updateChat",(async(t,e,a)=>{const{chatId:s,title:n,about:l,photo:h}=a,u=(0,c.Z1)(t,s);u&&((0,i.R3)((0,r.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,r.H9)((0,i.Rd)(),o.wv.Complete)))})),(0,i.iw)("updateChatPhoto",(async(t,e,a)=>{const{photo:s,chatId:o}=a,n=(0,c.Z1)(t,o);n&&((0,i.R3)((0,r.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,c.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,r.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,c.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&&(t[e.id]=e),t)),{});t=(0,i.Rd)(),t=(0,r.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,c.Z1)(t,s);let l=(0,c.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&&((0,i.R3)((0,r.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,c.Z1)(t,i);if(!s)return;let o;s.fullInfo?.linkedChatId&&(o=(0,c.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,m.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,c.Bt)(t)||{},a=e?(0,c.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:f}=o;n&&n.length&&(t=(0,i.Rd)(),t=(0,r.Sh)(t,(0,l.ee)(h,"id")),t=(0,r.zn)(t,f),t=(0,r.iX)(t,a,n),(0,i.R3)(t))})),(0,i.iw)("addChatMembers",(async(t,e,a)=>{const{chatId:i,memberIds:s}=a,n=(0,c.Z1)(t,i),r=s.map((e=>(0,c.dy)(t,e))).filter(Boolean);n&&r.length&&(e.setNewChatMembersDialogState(o.WB.Loading),await(0,d.t9)("addChatMembers",n,r),e.setNewChatMembersDialogState(o.WB.Closed),b(n))})),(0,i.iw)("deleteChatMember",(async(t,e,a)=>{const{chatId:i,userId:s}=a,o=(0,c.Z1)(t,i),n=(0,c.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,c.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,c.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,c.Z1)(t,s);if(!o)return;const n=await(0,d.t9)("fetchChatSettings",o);n&&(0,i.R3)((0,r.a4)((0,i.Rd)(),o.id,{settings:n}))})),(0,i.iw)("toggleJoinToSend",(async(t,e,a)=>{const{chatId:i,isEnabled:s}=a,o=(0,c.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,c.Z1)(t,i);o&&((0,u.ZV)(o)||(0,u.eA)(o))&&await(0,d.t9)("toggleJoinRequest",o,s)})),(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:r}}=t;r[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}}}})}))},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),r=a(42431),c=a(11192),l=a(56112),h=a(64319),u=a(60782),f=a(74753),p=a(77361),C=a(50711);let I,g,m,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 r=new Audio("./call_ringing.mp3");return r.loop=!0,m={join:t,allowTalk:i,leave:a,connecting:e,incoming:d,end:n,connect:o,busy:s,ringing:r},w=Promise.all(Object.values(m).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,r.$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 I}function M(){return g}function P(){I?.pause(),g=void 0,I=void 0}function S(t){t?navigator.mediaDevices.getUserMedia({video:!0}).then((t=>{0===t.getVideoTracks().length?(0,i.Sv)().showNotification({message:C.i0("Call.Camera.Error")}):H()})).catch((()=>{(0,i.Sv)().showNotification({message:C.i0("Call.Camera.Error")})})):H()}function H(){navigator.mediaDevices.getUserMedia({audio:!0}).then((t=>{0===t.getAudioTracks().length&&(0,i.Sv)().showNotification({message:C.i0("RequestAcces.Error.HaveNotAccess.Call")})})).catch((()=>{(0,i.Sv)().showNotification({message:C.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,r.$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,c.Z1)(t,o);if(!n)return;const r=await(0,s.t9)("createGroupCall",{peer:n});r&&(t=(0,i.Rd)(),(0,i.R3)((0,d.AH)(t,r.id,{...r,chatId:o})),e.joinGroupCall({id:r.id,accessHash:r.accessHash}))})),(0,i.iw)("createGroupCallInviteLink",(async(t,e)=>{const a=(0,r.mU)(t);if(!a||!a.chatId)return;const i=(0,c.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:C.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(!p.Bi)return;if(t.phoneCall)return void e.toggleGroupCallPanel();const{chatId:s,id:o,accessHash:n,inviteHash:c}=a;!function(){const t=new(window.AudioContext||window.webkitAudioContext);I=new Audio,g=t,I.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,f.Z)(I)}(),await v(),S(!0);const{groupCalls:{activeGroupCallId:l}}=t;let h=o?(0,r.$5)(t,o):(0,r.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:c},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(!m[i])return;const s=()=>{"connecting"!==i&&m.connecting.pause(),"incoming"!==i&&m.incoming.pause(),"ringing"!==i&&m.ringing.pause(),(0,f.Z)(m[i])};w?w.then(s):s()})),(0,i.iw)("loadMoreGroupCallParticipants",(t=>{const e=(0,r.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,c.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:()=>c,dc:()=>r});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 r(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 c(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}},42431:(t,e,a)=>{a.d(e,{$5:()=>d,Bj:()=>n,GU:()=>r,Ht:()=>c,fu:()=>h,mU:()=>l});var i=a(14342),s=a(56112),o=a(86087);function n(t,e){const a=(0,i.Z1)(t,e);if(a&&a.fullInfo&&a.fullInfo.groupCallId)return d(t,a.fullInfo.groupCallId)}function d(t,e){return t.groupCalls.byId[e]}function r(t,e,a){return d(t,e)?.participants[a]}function c(t){const e=l(t)?.chatId;if(!e)return!1;const a=(0,i.Z1)(t,e);return!!a&&((0,s.G9)(a)&&a.isCreator||Boolean(a.adminRights?.manageCall))}function l(t){const{groupCalls:{activeGroupCallId:e}}=t;if(e)return d(t,e)}function h(t){const{phoneCall:e,currentUserId:a}=t;if(!e||!e.participantId||!e.adminId)return;const i=e.adminId===a?e.participantId:e.adminId;return(0,o.dy)(t,i)}}}]);
//# sourceMappingURL=8422.6bcf9d888c6fdb705009.js.map