TelegramPWA/dist/5769.c88c06a2239f9329d9f0.js
Alexander Zinchuk 9b64fac501 [Build]
2023-08-14 18:08:55 +02:00

2 lines
351 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[5769],{96201:(e,t,s)=>{s.r(t),s.d(t,{LockScreen:()=>ac,Main:()=>Xr});var n=s(33555),a=s(601),i=s(83716),o=s(60748),r=s(31664),c=s(57710),d=s(73760),l=(s(65456),s(27225)),u=s(6137),m=s(91713),h=s(92387),g=s(60782),p=s(60298),f=s(7054),I=s(69118),v=s(48670),w=s(59692),y=s(81396),b=s(44271),P=s(65054),Z=s(84112),C=s(28406),S=s(74399);const M=32*S.Gw,E=45.5*S.Gw,R=26.5*S.Gw,k=16*S.Gw,T=16.125*S.Gw;var A=s(43858),N=s(53475),x=s(4907),B=s(42797);function U(e,t){return t-((0,f.jUK)(e).isLeftColumnShown&&!(0,B.W7)()?e.leftColumnWidth||((s=A.Z.get().width)>i._mX?Math.min(Math.max(.25*s,k),.33*s):s>i.ksF?Math.min(Math.max(.33*s,k),.4*s):R):0);var s}function L(e,t,s){const n=t.reactions||{results:[]},a=(0,f._5C)(e,t.chatId),i=n.results.map((e=>(0,v.Bt)(e)?{...e,chosenOrder:void 0,count:e.count-1}:e)).filter((e=>{let{count:t}=e;return t>0}));s.forEach(((e,t)=>{const s=i.findIndex((t=>(0,v.Hl)(t.reaction,e)));s>-1?i[s]={...i[s],chosenOrder:t,count:i[s].count+1}:i.push({reaction:e,chosenOrder:t,count:1})}));let{recentReactions:o=[]}=n;return o.length&&(o=o.filter((t=>{let{isOwn:s,peerId:n}=t;return!s&&n!==e.currentUserId}))),s.forEach((t=>{const{currentUserId:s}=e;o.unshift({peerId:a?.id||s,reaction:t,addedDate:Math.floor(Date.now()/1e3),isOwn:!0})})),(0,x.cY)(e,t.chatId,t.id,{reactions:{...n,results:i,recentReactions:o}})}function O(e,t,s){return(0,N.a4)(e,t,s,void 0,!0)}const j=350;function _(e,t,s,n,a,i,o){const r=o?.reactions;if(r&&(0,Z.A)(n,r))return e;if(e=(0,p.cY)(e,t,s,{reactions:n}),!i)return e;const c=a.unreadReactions?.includes(s);if((0,v.yL)(e,n)&&!c){e=O(e,t,{unreadReactionsCount:(a?.unreadReactionsCount||0)+1,unreadReactions:[...a?.unreadReactions||[],s]});const n=(0,f.hjO)(e,t,s);if(!a||!n)return e;(0,I.R3)((()=>{(0,C.rh)({chat:a,message:n,isReaction:!0})}))}else c&&(e=O(e,t,{unreadReactionsCount:(a?.unreadReactionsCount||1)-1,unreadReactions:a?.unreadReactions?.filter((e=>e!==s))}));return e}function F(e,t,s,n){let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const i=a?(0,f.TmO)(e,t,s):(0,f.hjO)(e,t,s);if(i&&n.content){const{photo:e,video:t,sticker:s,document:a}=(0,v.qp)(i);e&&n.content.photo?(n.content.photo.blobUrl=e.blobUrl,n.content.photo.thumbnail=e.thumbnail):t&&n.content.video?n.content.video.blobUrl=t.blobUrl:s&&n.content.sticker?n.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:a&&n.content.document&&(n.content.document.previewBlobUrl=a.previewBlobUrl)}const o=i?{...i,...n}:n;return a?(0,p.P4)(e,t,s,o):(0,p.cY)(e,t,s,o)}function D(e,t,s,n){const{chatId:a}=s,{threadInfo:i}=(0,f.DbP)(e,s)||{};if(!i&&s.replyToMessageId){const i=(0,f.hjO)(e,a,s.replyToMessageId);i?e=(0,p.lG)(e,i,a,s.id,n):t.loadMessage({chatId:a,messageId:s.replyToMessageId,threadUpdate:{isDeleting:n,lastMessageId:s.id}})}return e}function q(e,t,s){const{id:n,chatId:a}=s,{threadInfo:i,firstMessageId:o}=(0,f.DbP)(e,s)||{},r=(0,f.Z1J)(e,a)?.unreadCount&&!(0,f.gbs)(e,a,u._f);return e=D(e,t,s),i&&(!o&&(0,v.CI)(s)||(e=(0,p.xj)(e,a,i.threadId,[n]),Object.values(e.byTabId).forEach((t=>{let{id:r}=t;(0,f.b9T)(e,a,i.threadId,r)&&(e=(0,p.$S)(e,a,i.threadId,n,r),o||(e=(0,p.pf)(e,a,i.threadId,"firstMessageId",s.id)))}))),e=(0,p.pf)(e,a,i.threadId,"threadInfo",{...i,lastMessageId:s.id}),(0,v.CI)(s)||(0,v.FT)(s)||(e=(0,p.Xg)(e,a,i.threadId,{messagesCount:(i.messagesCount||0)+1}))),r||(e=(0,p.xj)(e,a,u._f,[n]),Object.values(e.byTabId).forEach((t=>{let{id:s}=t;if((0,f.b9T)(e,a,u._f,s)){const t=(0,f.It8)(e,a,u._f),i=(0,p.$S)(e,a,u._f,n,s),o=(0,f.Cbz)(i,a,u._f,s);t&&!o.includes(t)||(e=i)}}))),e}function G(e,t,s){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:a}=e,i=a.byId[t],o=i?.lastMessage,r=i?.isForum?(0,f.p$s)(e,s):void 0;return r&&(e=(0,p.Cn)(e,t,r.id,{lastMessageId:s.id})),!o||n||o.id===s.id||o.id===s.previousLocalId||s.id>o.id?(0,p.a4)(e,t,{lastMessage:s}):e}function H(e,t){const s=(0,f.Zwk)(e,t),n=(0,f.gbs)(e,t,u._f);if(!s||!n)return;let a=n.length;for(;a--;){const e=s[n[a]];if(!e.isDeleting)return e}}function $(e,t,s,a){if(t){const i=(0,f.Z1J)(e,t);if(!i)return;s.forEach((s=>{e=(0,p.cY)(e,t,s,{isDeleting:!0});const n=H(e=(0,p.CE)(e,t,s),t);n&&(e=G(e,t,n,!0)),i.topics?.[s]&&(e=(0,p.BK)(e,t,s))})),a.requestChatUpdate({chatId:t});const o=[];return s.forEach((s=>{const n=(0,f.hjO)(e,t,s);if(!n)return;e=D(e,a,n,!0);const i=(0,f.nrh)(e,n);i&&o.push(i)})),(0,n.R3)(e),void setTimeout((()=>{e=(0,n.Rd)(),e=(0,p.K4)(e,t,s),(0,n.R3)(e),(0,g.Tw)(o).forEach((e=>{a.requestThreadInfoUpdate({chatId:t,threadId:e})}))}),j)}const i=[];s.forEach((t=>{const s=(0,f.X5I)(e,t);if(s){i.push(s);const a=H(e=(0,p.cY)(e,s,t,{isDeleting:!0}),s);a&&(e=G(e,s,a,!0)),setTimeout((()=>{e=(0,n.Rd)(),e=(0,p.K4)(e,s,[t]),(0,n.R3)(e)}),j)}})),(0,n.R3)(e),(0,g.Tw)(i).forEach((e=>{a.requestChatUpdate({chatId:e})}))}(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:a,id:i,message:o,shouldForceReply:r}=s;e=q(e=F(e,a,i,o),t,o),o.repliesThreadInfo&&(e=(0,p.Xg)(e,o.repliesThreadInfo.chatId,o.repliesThreadInfo.threadId,o.repliesThreadInfo));const c=(0,f.hjO)(e,a,i);(0,f.Z1J)(e,a)?.isForum&&c.isTopicReply&&!(0,f.p$s)(e,c)&&c.replyToMessageId&&t.loadTopicById({chatId:a,topicId:c.replyToMessageId}),Object.values(e.byTabId).forEach((s=>{let{id:d}=s;const l=(0,v.CI)(o);if((0,f.KAC)(e,a,o,d)){if(l&&o.isOutgoing&&!o.content?.action&&!o.replyToStoryId&&!o.content?.storyData){const s=(0,f.Btg)(e,d);s&&t.focusMessage({chatId:a,threadId:s.threadId,messageId:o.id,noHighlight:!0,isResizingContainer:!0,tabId:d})}const{threadInfo:s}=(0,f.DbP)(e,o)||{};s&&!l&&t.requestThreadInfoUpdate({chatId:a,threadId:s.threadId}),l||setTimeout((()=>{e=(0,n.Rd)(),r&&(e=(0,p.pf)(e,a,u._f,"replyingToId",i)),e=G(e,a,c),(0,n.R3)(e)}),j)}else e=G(e,a,c)})),(0,n.R3)(e),(0,f.Nap)(e,a)||t.loadTopChats();break}case"updateStartEmojiInteraction":Object.values(e.byTabId).forEach((t=>{let{id:n}=t;const{chatId:a}=(0,f.Btg)(e,n)||{};if(a!==s.id)return;const i=(0,f.hjO)(e,a,s.messageId);if(!i)return;if((0,v.UD)(i)!==s.emoji)return;const o=(0,f.jUK)(e,n);e=(0,b.i)(e,{activeEmojiInteractions:[...o.activeEmojiInteractions||[],{id:o.activeEmojiInteractions?.length||0,animatedEffect:s.emoji,messageId:s.messageId}]},n)})),(0,n.R3)(e);break;case"newScheduledMessage":{const{chatId:t,id:a,message:i}=s;e=F(e,t,a,i,!0);const o=(0,f.qyA)(e,t,u._f)||[];e=(0,p.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...o,a]));const r=(0,f.nrh)(e,i);if(r!==u._f){const s=(0,f.qyA)(e,t,r)||[];e=(0,p.pf)(e,t,r,"scheduledIds",(0,g.Tw)([...s,a]))}(0,n.R3)(e);break}case"updateMessage":{const{chatId:t,id:a,message:i}=s,o=(0,f.hjO)(e,t,a),r=(0,f.Z1J)(e,t);e=F(e,t,a,i);const c=(0,f.hjO)(e,t,a);i.repliesThreadInfo&&(e=(0,p.Xg)(e,i.repliesThreadInfo.chatId,i.repliesThreadInfo.threadId,i.repliesThreadInfo)),o&&(e=G(e,t,c)),i.reactions&&r&&(e=_(e,t,a,i.reactions,r,c.isOutgoing,o)),i.content?.text?.text!==o?.content?.text?.text&&(e=(0,p.CE)(e,t,a)),(0,n.R3)(e);break}case"updateScheduledMessage":{const{chatId:t,id:a,message:i}=s,o=(0,f.TmO)(e,t,a);if(!o)return;e=F(e,t,a,i,!0);const r=Object.keys((0,f.yBV)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,p.pf)(e,t,u._f,"scheduledIds",r);const c=(0,f.nrh)(e,o);if(c!==u._f){const s=(0,f.qyA)(e,t,c)||[];e=(0,p.pf)(e,t,c,"scheduledIds",s.sort(((e,t)=>t-e)))}(0,n.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:i,message:o}=s;e=q(e,t,o);const r=(0,f.hjO)(e,a,i);e=(0,p.K4)(e,a,[i]),o.isScheduled&&(e=(0,p.bV)(e,a,[i])),e=(0,p.cY)(e,a,o.id,{...r,...o,previousLocalId:i}),e={...e,fileUploads:{byMessageLocalId:(0,g.CE)(e.fileUploads.byMessageLocalId,[i.toString()])}};const c=(0,f.hjO)(e,a,o.id);e=G(e,a,c);const d=(0,f.DbP)(e,o);Object.values(e.byTabId).forEach((s=>{let{id:n}=s;const{chatId:i,threadId:r}=(0,f.Btg)(e,n)||{};i===a&&(d?.threadInfo?.threadId||u._f)===r&&t.markMessageListRead({maxId:o.id,tabId:n})})),d?.threadInfo&&(e=(0,p.pf)(e,a,d.threadInfo.threadId,"threadInfo",{...d.threadInfo,lastMessageId:o.id,lastReadInboxMessageId:o.id})),e=(0,p.a4)(e,a,{lastReadInboxMessageId:o.id}),(0,n.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:i}=s,o=(0,f.qyA)(e,t,u._f)||[];e=(0,p.pf)(e,t,u._f,"scheduledIds",[...o,i.id]);const r=(0,f.nrh)(e,i);if(r!==u._f){const s=(0,f.qyA)(e,t,r)||[];e=(0,p.pf)(e,t,r,"scheduledIds",[...s,i.id])}const c=(0,f.TmO)(e,t,a);e=(0,p.bV)(e,t,[a]),e=(0,p.P4)(e,t,i.id,{...c,...i,previousLocalId:a}),(0,n.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:i}=s,o=(0,g.q0)((0,f.Zwk)(e,t),i),r={[u._f]:i};Object.values(o).forEach((s=>{const n=(0,f.nrh)(e,s);if(e=(0,p.cY)(e,t,s.id,{isPinned:a}),n===u._f)return;const i=r[n]||[];i.push(s.id),r[n]=i})),Object.entries(r).forEach((s=>{let[n,i]=s;const o=(0,f.KBA)(e,t,u._f)||[],r=a?(0,g.Tw)(o.concat(i)).sort(((e,t)=>t-e)):o.filter((e=>!i.includes(e)));e=(0,p.pf)(e,t,Number(n),"pinnedIds",r)})),(0,n.R3)(e);break}case"updateThreadInfo":{const{chatId:a,threadId:i,threadInfo:o,firstMessageId:r}=s,c=(0,f.tZg)(e,a,i),d={...c,...o};if(!d.threadId)return;e=(0,p.Xg)(e,a,i,d),r&&(e=(0,p.pf)(e,a,i,"firstMessageId",r));const l=(0,f.Z1J)(e,a);if(l?.isForum&&o.lastReadInboxMessageId!==c?.lastReadInboxMessageId&&t.loadTopicById({chatId:a,topicId:i}),o.topMessageId===i&&!l?.isForum){const t=l?.lastReadInboxMessageId,s=d.lastReadInboxMessageId||t;t&&s&&(e=(0,p.Xg)(e,a,i,{lastReadInboxMessageId:Math.max(s,t)}))}(0,n.R3)(e);break}case"resetMessages":{const{id:a}=s,i=(0,f.Zwk)(e,a);if(i&&!(0,v.YC)(a)){const s=(0,P._w)();e=(0,p.K4)(e,a,Object.keys(i).map(Number)),(0,n.R3)(e),t.loadFullChat({chatId:a,force:!0,tabId:s}),t.loadViewportMessages({chatId:a,threadId:u._f,tabId:s})}break}case"deleteMessages":{const{ids:n,chatId:a}=s;$(e,a,n,t);break}case"deleteScheduledMessages":{const{ids:t,chatId:a}=s;!function(e,t,s,a){e&&(t.forEach((t=>{a=(0,p.P4)(a,e,t,{isDeleting:!0})})),(0,n.R3)(a),setTimeout((()=>{a=(0,n.Rd)(),a=(0,p.bV)(a,e,t);const s=(0,f.yBV)(a,e);a=(0,p.pf)(a,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,n.R3)(a)}),j))}(a,t,0,e);break}case"deleteHistory":{const{chatId:a}=s,o=e.messages.byChatId[a];if(a===i.awM&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>({...e,isDeleted:!0})))},(0,n.R3)(e)),o){const s=Object.keys(o.byId).map(Number);$(e=(0,n.Rd)(),a,s,t)}else t.requestChatUpdate({chatId:a});e=(0,n.Rd)(),e=(0,p.kq)(e,a),(0,n.R3)(e);break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=s;t.forEach((t=>{const s=(0,f.X5I)(e,t);s&&(e=(0,p.cY)(e,s,t,a))})),(0,n.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:i}=s;a.forEach((s=>{e=(0,p.cY)(e,t,s,i)})),(0,n.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=s,i=(0,f.ZBV)(e,t);if(i?.content.poll){const t=i.content.poll.results;let s=t;a.results?.results&&(t.results&&a.results.isMin?t.results&&(s={...a.results,results:a.results.results.map((e=>({...e,isChosen:t.results.find((t=>t.option===e.option))?.isChosen}))),isMin:void 0}):s=a.results);const o={...i.content.poll,...a,results:s};e=(0,p.cY)(e,i.chatId,i.id,{content:{...i.content,poll:o}}),(0,n.R3)(e)}break}case"updateMessagePollVote":{const{pollId:t,peerId:a,options:i}=s,o=(0,f.ZBV)(e,t);if(!o||!o.content.poll||!o.content.poll.results)break;const{poll:r}=o.content,c=(0,f._5C)(e,o.chatId),{recentVoterIds:d,totalVoters:l,results:u}=r.results,m=d?[...d]:[],h=l?l+1:1,g=u?[...u]:[];m.push(a),i.forEach((t=>{const s=g.findIndex((e=>e.option===t)),n=g[s],i=n?{...n}:{option:t,votersCount:0};i.votersCount+=1,c?.id!==a&&a!==e.currentUserId||(i.isChosen=!0),s?g[s]=i:g.push(i)})),e=(0,p.cY)(e,o.chatId,o.id,{content:{...o.content,poll:{...r,results:{...r.results,recentVoterIds:m,totalVoters:h,results:g}}}}),(0,n.R3)(e);break}case"updateServiceNotification":{const{message:n}=s;(0,f.UWV)(e)&&t.createServiceNotification({message:n});break}case"updateMessageReactions":{const{chatId:t,id:a,reactions:i}=s,o=(0,f.hjO)(e,t,a),r=(0,f.Z1J)(e,s.chatId);if(!r||!o)return;e=_(e,t,a,i,r,o.isOutgoing,o),(0,n.R3)(e);break}case"updateMessageExtendedMedia":{const{chatId:t,id:a,media:i,preview:o}=s,r=(0,f.hjO)(e,t,a);if(!(0,f.Z1J)(e,s.chatId)||!r)return;if(o){if(!r.content.invoice)return;e=(0,p.cY)(e,t,a,{content:{...r.content,invoice:{...r.content.invoice,extendedMedia:o}}}),(0,n.R3)(e)}else i&&(e=(0,p.cY)(e,t,a,{content:{...i}}),(0,n.R3)(e));break}case"updateTranscribedAudio":{const{transcriptionId:t,text:a,isPending:i}=s;e={...e,transcriptions:{...e.transcriptions,[t]:{...e.transcriptions[t]||{},transcriptionId:t,text:a,isPending:i}}},(0,n.R3)(e);break}case"updateMessageSendFailed":{const{chatId:a,localId:i,error:o}=s;o.match(/CHAT_SEND_.+?FORBIDDEN/)&&Object.values(e.byTabId).forEach((e=>{let{id:s}=e;t.showAllowedMessageTypesNotification({chatId:a,tabId:s})})),e=(0,p.cY)(e,a,i,{sendingState:"messageSendingStateFailed"}),(0,n.R3)(e);break}case"updateMessageTranslations":{const{chatId:t,messageIds:a,toLanguageCode:i,translations:o}=s;e=(0,p.TD)(e,t,a,i,o),(0,n.R3)(e);break}}}));const V=new Map,K=(0,I.Ds)((e=>e()),500,!1);async function J(e,t,s,a,o){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5],c=arguments.length>6&&void 0!==arguments[6]&&arguments[6];for(var d=arguments.length,l=new Array(d>7?d-7:0),I=7;I<d;I++)l[I-7]=arguments[I];let[v=(0,P._w)()]=l;const w=t.id;let y,b=i.hT6;switch(o){case m.Uq.Backwards:a?(y=-1,b+=1):y=void 0;break;case m.Uq.Around:y=-(Math.round(i.hT6/2)+1);break;case m.Uq.Forwards:y=-(i.hT6+1),a&&(b+=1)}e=(0,n.Rd)();const Z=await(0,h.t9)("fetchMessages",{chat:(0,f.Z1J)(e,w),offsetId:a,addOffset:y,limit:b,threadId:s});if(!Z)return;const{messages:C,users:S,chats:M,repliesThreadInfos:E}=Z;e=(0,n.Rd)();const R=w===i.awM?e.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],k=[].concat(C,R),T=(0,g.ee)(k,"id"),A=Object.keys(T).map(Number);if(s!==u._f){const t=(0,f.yZJ)(e,w,s)||{};A[0]&&t!==A[0]||t===s||A.unshift(s)}e=(0,p.c_)(e,w,T),e=r?(0,p.hv)(e,w,s,A):(0,p.xj)(e,w,s,A),e=(0,p.Sh)(e,(0,g.ee)(S,"id")),e=(0,p.fZ)(e,(0,g.ee)(M,"id")),e=(0,p.j6)(e,E);let N=(0,f.gbs)(e,w,s);const x=a?(0,f.ofg)(e,w,s,a):void 0;if(r&&N&&x&&(x.length&&!(0,g.YE)(N,x)||(e=(0,p.xj)(e,w,s,x),N=(0,f.gbs)(e,w,s),e=(0,p.IU)(e,w,s,x),r=!1)),!c){const t=r?x:N,{newViewportIds:n}=z(t,a,o);e=(0,p.y9)(e,w,s,n,v)}(0,n.R3)(e)}function z(e,t,s){const{length:n}=e,a=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,n)=>s===t||s<t&&e[n+1]>t))}(e,t):-1,o=s===m.Uq.Backwards?a:a+1||n,r=s===m.Uq.Around?Math.round(i.hT6/2):i.hT6,c=o-r,d=o+r-1,l=e.slice(Math.max(0,c),d+1);let u,h;switch(s){case m.Uq.Backwards:u=o>=0,h=c>=0;break;case m.Uq.Forwards:u=o<n,h=d<=n-1;break;case m.Uq.Around:default:u=l.length>0,h=l.length===i.hT6}return{newViewportIds:l,areSomeLocal:u,areAllLocal:h}}async function W(e,t){let s;const i=t.attachment?(t,a)=>{V.has(a)||(s=a,V.set(a,i)),e=(0,n.Rd)(),e={...e,fileUploads:{byMessageLocalId:{...e.fileUploads.byMessageLocalId,[a]:{progress:t}}}},(0,n.R3)(e)}:void 0;(t.replyingTo||a.cj)&&await(0,I.Pn)(),void 0!==t.currentThreadId&&(t.currentThreadId!==u._f&&(t.replyingTo&&"replyingTo"in t.replyingTo||(t.replyingTo={replyingTo:t.currentThreadId}),t.replyingTo.replyingTo||(t.replyingTo.replyingTo=t.currentThreadId),t.replyingTo.replyingTo&&!t.replyingTo.replyingToTopId&&(t.replyingTo.replyingToTopId=t.currentThreadId)),await(0,h.t9)("sendMessage",t,i),i&&s&&V.delete(s))}(0,n.iw)("loadViewportMessages",((e,t,s)=>{const{direction:a=m.Uq.Around,isBudgetPreload:i=!1,shouldForceRender:o=!1,tabId:r=(0,P._w)()}=s||{};let{chatId:c,threadId:d}=s||{};if(!c||!d){const t=(0,f.Btg)(e,r);if(!t)return;c=t.chatId,d=t.threadId}const l=(0,f.Z1J)(e,c);if(!l||l.isRestricted)return;const u=(0,f.Cbz)(e,c,d,r),h=(0,f.gbs)(e,c,d);if(u&&u.length&&a!==m.Uq.Around){const s=a===m.Uq.Backwards?u[0]:u[u.length-1],n=Boolean(h&&!h.includes(s)),o=n?(0,f.ofg)(e,c,d,s):h,{newViewportIds:g,areSomeLocal:v,areAllLocal:w}=z(o,s,a);if(v&&(e=(0,p.y9)(e,c,d,g,r)),(0,I.R3)((()=>{!async function(e,t,s,n,a,i,o,r,c){for(var d=arguments.length,l=new Array(d>9?d-9:0),u=9;u<d;u++)l[u-9]=arguments[u];let[m=(0,P._w)()]=l;s||await J(e,i,o,c,r,n,a,m),a||t.loadViewportMessages({chatId:i.id,threadId:o,direction:r,isBudgetPreload:!0,tabId:m})}(e,t,w,n,i,l,d,a,s,r)})),i)return}else{const t=(0,f.G$N)(e,c,r)||(0,f.rdT)(e,c,d),s=Boolean(t&&h&&!h.includes(t)),n=(s?(0,f.ofg)(e,c,d,t):h)||[],{newViewportIds:a,areSomeLocal:o,areAllLocal:u}=z(n,t,m.Uq.Around);o&&(e=(0,p.y9)(e,c,d,a,r)),u||(0,I.R3)((()=>{J(e,l,d,t,m.Uq.Around,s,i,r)}))}(0,n.R3)(e,{forceOnHeavyAnimation:o})})),(0,n.iw)("loadMessage",(async(e,t,s)=>{const{chatId:a,messageId:i,replyOriginForId:o,threadUpdate:r}=s,c=(0,f.Z1J)(e,a);if(!c)return;const d=await async function(e,t,s,a){const i=await(0,h.t9)("fetchMessage",{chat:t,messageId:s});if(i){if(i!==u._Q)return e=(0,n.Rd)(),e=(0,p.cY)(e,t.id,s,i.message),e=(0,p.Sh)(e,(0,g.ee)(i.users,"id")),(0,n.R3)(e),i.message;if(a){e=(0,n.Rd)();const s=(0,f.hjO)(e,t.id,a);e=(0,p.cY)(e,t.id,a,{...s,replyToMessageId:void 0}),(0,n.R3)(e)}}}(e,c,i,o);if(d&&r){const{lastMessageId:t,isDeleting:s}=r;e=(0,n.Rd)(),e=(0,p.lG)(e,d,a,t,s),(0,n.R3)(e)}})),(0,n.iw)("sendMessage",((e,t,s)=>{const{messageList:n,tabId:a=(0,P._w)()}=s,{storyId:o,userId:r}=(0,f.pri)(e,a),c=Boolean(o&&r);if(!n&&!c)return;let{chatId:d,threadId:l,type:m}=n||{};if(c&&(d=r,l=u._f,m="thread"),s=(0,g.CE)(s,["tabId"]),"scheduled"===m&&!s.scheduledAt)return(0,b.i)(e,{contentToBeScheduled:s},a);const h=(0,f.Z1J)(e,d),p=c?void 0:(0,f.Yyv)(e,d,l),I=p?(0,f.hjO)(e,d,p):void 0,v=h.isForum?(0,f.qSq)(e,d,l):I?.replyToTopMessageId||I?.replyToMessageId,w=p?{replyingTo:p,replyingToTopId:v}:c?{userId:r,storyId:o}:void 0,y={...s,chat:h,currentThreadId:l,replyingTo:w,noWebPage:(0,f.tVX)(e,d,l),sendAs:(0,f._5C)(e,d)};t.setReplyingToId({messageId:void 0,tabId:a}),t.clearWebPagePreview({tabId:a});const Z=!s.attachments||s.attachments.length<=1,C=!Z&&s.shouldGroupMessages;if(Z){const{attachments:t,...s}=y;W(e,{...s,attachment:t?t[0]:void 0})}else if(C){const{text:t,entities:s,attachments:n,...a}=y,o=function(e){return e.reduce(((e,t,s,n)=>0===s?(e.push([t]),e):(ee(t)===ee(n[s-1])?e[e.length-1].push(t):e.push([t]),e)),[])}(n);o.forEach(((n,o)=>{const r=(0,g.Vl)(n,i.DUi);for(let n=0;n<r.length;n++){const[i,...c]=r[n],d=`${Date.now()}${o}${n}`,l=0===n&&0===o;W(e,{...a,text:l?t:void 0,entities:l?s:void 0,attachment:i,groupedId:c.length>0?d:void 0}),c.forEach((t=>{W(e,{...a,attachment:t,groupedId:d})}))}}))}else{const{text:t,entities:s,attachments:n,replyingTo:a,...i}=y;t&&W(e,{...i,text:t,entities:s,replyingTo:a}),n?.forEach((t=>{W(e,{...i,attachment:t})}))}})),(0,n.iw)("editMessage",((e,t,s)=>{const{messageList:n,text:a,entities:i,tabId:o=(0,P._w)()}=s;if(!n)return;const{chatId:r,threadId:c,type:d}=n,l=(0,f.Z1J)(e,r),u=(0,f.kKD)(e,r,c,d);l&&u&&((0,h.t9)("editMessage",{chat:l,message:u,text:a,entities:i,noWebPage:(0,f.tVX)(e,r,c)}),t.setEditingId({messageId:void 0,tabId:o}))})),(0,n.iw)("cancelSendingMessage",((e,t,s)=>{const{chatId:n,messageId:a}=s,i=(0,f.hjO)(e,n,a),o=i&&V.get((0,v.KK)(i));o&&(0,h.u3)(o),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:n})})),(0,n.iw)("saveDraft",(async(e,t,s)=>{const{chatId:a,threadId:i,draft:o,shouldForce:r}=s;if(!o)return;const{text:c,entities:d}=o,l=(0,f.Z1J)(e,a),u=(0,f.dyD)(e,a);u&&(0,v.NB)(u)||(o.isLocal=!0,o.shouldForce=r,e=(0,p.pf)(e,a,i,"draft",o),e=(0,p.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)}),(0,n.R3)(e),await(0,h.t9)("saveDraft",{chat:l,text:c,entities:d,replyToMsgId:(0,f.Yyv)(e,a,i),threadId:(0,f.qSq)(e,a,i)})&&(o.isLocal=!1),e=(0,n.Rd)(),e=(0,p.pf)(e,a,i,"draft",o),e=(0,p.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)}),(0,n.R3)(e))})),(0,n.iw)("clearDraft",((e,t,s)=>{const{chatId:n,threadId:a=u._f,localOnly:i,shouldForce:o}=s;if(!(0,f.Mst)(e,n,a))return;const r=(0,f.Z1J)(e,n);i||(0,h.t9)("clearDraft",r,(0,f.qSq)(e,n,a));const c=o?{shouldForce:o,text:""}:void 0;return e=(0,p.pf)(e,n,a,"draft",c),(0,p.a4)(e,n,{draftDate:void 0})})),(0,n.iw)("toggleMessageWebPage",((e,t,s)=>{const{chatId:n,threadId:a,noWebPage:i}=s;return(0,p.pf)(e,n,a,"noWebPage",i)})),(0,n.iw)("pinMessage",((e,t,s)=>{const{messageId:n,isUnpin:a,isOneSide:i,isSilent:o,tabId:r=(0,P._w)()}=s,c=(0,f.jrE)(e,r);c&&(0,h.t9)("pinMessage",{chat:c,messageId:n,isUnpin:a,isOneSide:i,isSilent:o})})),(0,n.iw)("unpinAllMessages",(async(e,t,s)=>{const{chatId:a,threadId:i}=s,o=(0,f.Z1J)(e,a);if(!o)return;const r=(0,f.qSq)(e,a,i);await(0,h.t9)("unpinAllMessages",{chat:o,threadId:r}),e=(0,n.Rd)(),(0,f.KBA)(e,a,i)?.forEach((t=>{e=(0,p.cY)(e,a,t,{isPinned:!1})})),e=(0,p.pf)(e,o.id,u._f,"pinnedIds",[]),(0,n.R3)(e)})),(0,n.iw)("deleteMessages",((e,t,s)=>{const{messageIds:n,shouldDeleteForAll:a,tabId:i=(0,P._w)()}=s,o=(0,f.Btg)(e,i);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,f.Z1J)(e,r),l=n.filter((t=>{const s=(0,f.hjO)(e,r,t);return s&&!(0,v.CI)(s)}));if(!l.length&&n.length)return void $(e,(0,v.eA)(d)?r:void 0,n,t);(0,h.t9)("deleteMessages",{chat:d,messageIds:l,shouldDeleteForAll:a});const u=(0,f._$9)(e,r,c);u&&n.includes(u)&&t.setEditingId({messageId:void 0,tabId:i})})),(0,n.iw)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:n,tabId:a=(0,P._w)()}=s,i=(0,f.Btg)(e,a);if(!i)return;const{chatId:o}=i,r=(0,f.Z1J)(e,o);(0,h.t9)("deleteScheduledMessages",{chat:r,messageIds:n});const c=(0,f.nBP)(e,o);c&&n.includes(c)&&t.setEditingId({messageId:void 0,tabId:a})})),(0,n.iw)("deleteHistory",(async(e,t,s)=>{const{chatId:a,shouldDeleteForAll:i,tabId:o=(0,P._w)()}=s,r=(0,f.Z1J)(e,a);if(!r)return;await(0,h.t9)("deleteHistory",{chat:r,shouldDeleteForAll:i}),e=(0,n.Rd)();const c=(0,f.Btg)(e,o);c&&c.chatId===a&&t.openChat({id:void 0,tabId:o});const d=e.chatFolders.byId;Object.values(d).forEach((e=>{if(e.includedChatIds.includes(a)||e.pinnedChatIds?.includes(a)){const t=e.includedChatIds.filter((e=>e!==a)),s=e.pinnedChatIds?.filter((e=>e!==a)),n={...e,includedChatIds:t,pinnedChatIds:s};(0,h.t9)("editChatFolder",{id:e.id,folderUpdate:n})}}))})),(0,n.iw)("reportMessages",(async(e,t,s)=>{const{messageIds:n,reason:a,description:i,tabId:o=(0,P._w)()}=s,r=(0,f.Btg)(e,o);if(!r)return;const{chatId:c}=r,d=(0,f.Z1J)(e,c),l=await(0,h.t9)("reportMessages",{peer:d,messageIds:n,reason:a,description:i});t.showNotification({message:l?(0,w.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:o})})),(0,n.iw)("sendMessageAction",(async(e,t,s)=>{const{action:n,chatId:a,threadId:i}=s;if("connectionStateReady"!==e.connectionState)return;if(a===e.currentUserId)return;const o=(0,f.Z1J)(e,a);if(!o)return;const r=(0,f.dyD)(e,a);r&&((0,v.cS)(r)||(0,v.NB)(r))||await(0,h.t9)("sendMessageAction",{peer:o,threadId:i,action:n})})),(0,n.iw)("markMessageListRead",((e,t,s)=>{const{maxId:n,tabId:a=(0,P._w)()}=s,o=(0,f.Btg)(e,a);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,f.Z1J)(e,r);if(!d)return;K((()=>{(0,h.t9)("markMessageListRead",{chat:d,threadId:c,maxId:n})})),r===i.awM&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=n?{...e,isUnread:!1}:e))});const l=(0,f.Cbz)(e,r,c,a),m=(0,f.It8)(e,r,c);if(!l||!m||!d.unreadCount)return e;const g=function(e,t,s){let n=0;for(let a=0,i=e.length;a<i&&(e[a]>=t&&e[a]<=s&&n++,!(e[a]>=s));a++);return n}(l,m,n);if(!g)return e;if(d.isForum&&d.topics?.[c]){const t=d.topics[c];e=(0,p.Xg)(e,r,c,{lastReadInboxMessageId:n});const s=Math.max(0,t.unreadCount-g);return 0===s&&(e=(0,p.a4)(e,r,{unreadCount:Math.max(0,d.unreadCount-1)})),(0,p.Cn)(e,r,c,{unreadCount:s})}return c===u._f?(0,p.a4)(e,r,{lastReadInboxMessageId:n,unreadCount:Math.max(0,d.unreadCount-g)}):void 0})),(0,n.iw)("markMessagesRead",((e,t,s)=>{const{messageIds:n,tabId:a=(0,P._w)()}=s,i=(0,f.jrE)(e,a);i&&(0,h.t9)("markMessagesRead",{chat:i,messageIds:n})})),(0,n.iw)("loadWebPagePreview",(async(e,t,s)=>{const{text:a,tabId:i=(0,P._w)()}=s,o=await(0,h.t9)("fetchWebPagePreview",{text:a});e=(0,n.Rd)(),e=(0,b.i)(e,{webPagePreview:o},i),(0,n.R3)(e)})),(0,n.iw)("clearWebPagePreview",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};if((0,f.jUK)(e,n).webPagePreview)return(0,b.i)(e,{webPagePreview:void 0},n)})),(0,n.iw)("sendPollVote",((e,t,s)=>{const{chatId:n,messageId:a,options:i}=s,o=(0,f.Z1J)(e,n);o&&(0,h.t9)("sendPollVote",{chat:o,messageId:a,options:i})})),(0,n.iw)("cancelPollVote",((e,t,s)=>{const{chatId:n,messageId:a}=s,i=(0,f.Z1J)(e,n);i&&(0,h.t9)("sendPollVote",{chat:i,messageId:a,options:[]})})),(0,n.iw)("closePoll",((e,t,s)=>{const{chatId:n,messageId:a}=s,i=(0,f.Z1J)(e,n),o=(0,f.hjO)(e,n,a)?.content.poll;i&&o&&(0,h.t9)("closePoll",{chat:i,messageId:a,poll:o})})),(0,n.iw)("loadPollOptionResults",(async(e,t,s)=>{const{chat:a,messageId:i,option:o,offset:r,limit:c,shouldResetVoters:d,tabId:l=(0,P._w)()}=s,u=await(0,h.t9)("loadPollOptionResults",{chat:a,messageId:i,option:o,offset:r,limit:c});if(!u)return;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(u.users,"id")),e=(0,p.fZ)(e,(0,g.ee)(u.chats,"id"));const m=(0,f.jUK)(e,l),{pollResults:I}=m,{voters:v}=m.pollResults;e=(0,b.i)(e,{pollResults:{...I,voters:{...v,[o]:(0,g.Tw)([...!d&&v?.[o]?v[o]:[],...u.votes.map((e=>e.peerId))])},offsets:{...I.offsets?I.offsets:{},[o]:u.nextOffset||""}}},l),(0,n.R3)(e)})),(0,n.iw)("loadExtendedMedia",((e,t,s)=>{const{chatId:n,ids:a}=s,i=(0,f.Z1J)(e,n);i&&(0,h.t9)("fetchExtendedMedia",{chat:i,ids:a})})),(0,n.iw)("forwardMessages",((e,t,s)=>{const{isSilent:a,scheduledAt:i,tabId:o=(0,P._w)()}=s,{fromChatId:r,messageIds:c,toChatId:d,withMyScore:l,noAuthors:m,noCaptions:g,toThreadId:p}=(0,f.jUK)(e,o).forwardMessages,w=(0,f.wVz)(e),y=r?(0,f.Z1J)(e,r):void 0,Z=d?(0,f.Z1J)(e,d):void 0,C=r&&c?c.sort(((e,t)=>e-t)).map((t=>(0,f.hjO)(e,r,t))).filter(Boolean):void 0;if(!y||!Z||!C||p&&!Z.isForum)return;const S=(0,f._5C)(e,d),M=C.filter((e=>!(0,v.jM)(e)));M.length&&(async()=>{await(0,I.Pn)(),(0,h.t9)("forwardMessages",{fromChat:y,toChat:Z,toThreadId:p,messages:M,isSilent:a,scheduledAt:i,sendAs:S,withMyScore:l,noAuthors:m,noCaptions:g,isCurrentUserPremium:w})})(),C.filter((e=>(0,v.jM)(e))).forEach((t=>{const{text:s,entities:n}=t.content.text||{},{sticker:o,poll:r}=t.content;W(e,{chat:Z,replyingTo:p?{replyingTo:p,replyingToTopId:p}:void 0,currentThreadId:p||u._f,text:s,entities:n,sticker:o,poll:r,isSilent:a,scheduledAt:i,sendAs:S})})),e=(0,n.Rd)(),e=(0,b.i)(e,{forwardMessages:{}},o),(0,n.R3)(e)})),(0,n.iw)("loadScheduledHistory",(async(e,t,s)=>{const{chatId:a}=s,i=(0,f.Z1J)(e,a);if(!i)return;const o=await(0,h.t9)("fetchScheduledHistory",{chat:i});if(!o)return;const{messages:r}=o,c=(0,g.ee)(r,"id"),d=Object.keys(c).map(Number).sort(((e,t)=>t-e));if(e=(0,n.Rd)(),e=(0,p.w3)(e,i.id,c),e=(0,p.pf)(e,i.id,u._f,"scheduledIds",d),i?.isForum){const t={};r.forEach((s=>{const n=(0,f.nrh)(e,s),a=t[n]||[];a.push(s.id),t[n]=a})),Object.entries(t).forEach((t=>{let[s,n]=t;e=(0,p.pf)(e,i.id,Number(s),"scheduledIds",n)}))}(0,n.R3)(e)})),(0,n.iw)("sendScheduledMessages",((e,t,s)=>{const{chatId:n,id:a}=s,i=(0,f.Z1J)(e,n);i&&(0,h.t9)("sendScheduledMessages",{chat:i,ids:[a]})})),(0,n.iw)("rescheduleMessage",((e,t,s)=>{const{chatId:n,messageId:a,scheduledAt:i}=s,o=(0,f.Z1J)(e,n),r=o&&(0,f.TmO)(e,o.id,a);o&&r&&(0,h.t9)("rescheduleMessage",{chat:o,message:r,scheduledAt:i})})),(0,n.iw)("requestThreadInfoUpdate",(async(e,t,s)=>{const{chatId:a,threadId:i}=s,o=(0,f.Z1J)(e,a);if(!o)return;const r=(0,f.CmE)(e,a,i)?.id,c=await(0,h.t9)("requestThreadInfoUpdate",{chat:o,threadId:i,originChannelId:r});c&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(c.users,"id")),(0,n.R3)(e))})),(0,n.iw)("transcribeAudio",(async(e,t,s)=>{const{messageId:a,chatId:i}=s,o=(0,f.Z1J)(e,i);if(!o)return;e=(0,p.cY)(e,i,a,{transcriptionId:""}),(0,n.R3)(e);const r=await(0,h.t9)("transcribeAudio",{chat:o,messageId:a});e=(0,n.Rd)(),e=(0,p.cY)(e,i,a,{transcriptionId:r,isTranscriptionError:!r}),(0,n.R3)(e)})),(0,n.iw)("loadCustomEmojis",(async(e,t,s)=>{const{ids:a,ignoreCache:i}=s,o=i?a:(0,g.Tw)(a.filter((t=>!e.customEmojis.byId[t]))),r=await(0,h.t9)("fetchCustomEmoji",{documentId:o});r&&(e=(0,n.Rd)(),e={...e,customEmojis:{...e.customEmojis,byId:{...e.customEmojis.byId,...(0,g.ee)(r,"id")}}},(0,n.R3)(e))})),(0,n.iw)("loadPinnedMessages",(async(e,t,s)=>{const{chatId:a,threadId:i}=s,o=(0,f.Z1J)(e,a);if(!o)return;const r=await(0,h.t9)("fetchPinnedMessages",{chat:o,threadId:i});if(!r)return;const{messages:c,chats:d,users:l}=r,u=(0,g.ee)(c,"id"),m=Object.keys(u).map(Number).sort(((e,t)=>t-e));e=(0,n.Rd)(),e=(0,p.c_)(e,o.id,u),e=(0,p.HX)(e,o.id,i,m),e=(0,p.Sh)(e,(0,g.ee)(l,"id")),e=(0,p.fZ)(e,(0,g.ee)(d,"id")),(0,n.R3)(e)})),(0,n.iw)("loadSeenBy",(async(e,t,s)=>{const{chatId:a,messageId:i}=s,o=(0,f.Z1J)(e,a);if(!o)return;const r=await(0,h.t9)("fetchSeenBy",{chat:o,messageId:i});r&&(e=(0,n.Rd)(),e=(0,p.cY)(e,a,i,{seenByDates:r}),(0,n.R3)(e))})),(0,n.iw)("saveDefaultSendAs",((e,t,s)=>{const{chatId:n,sendAsId:a}=s,i=(0,f.Z1J)(e,n),o=(0,f.Z1J)(e,a)||(0,f.dyD)(e,a);if(i&&o)return(0,h.t9)("saveDefaultSendAs",{sendAs:o,chat:i}),(0,p.US)(e,n,{sendAsId:a})})),(0,n.iw)("loadSendAs",(async(e,t,s)=>{const{chatId:a}=s,i=(0,f.Z1J)(e,a);if(!i)return;const o=await(0,h.t9)("fetchSendAs",{chat:i});if(!o)return e=(0,n.Rd)(),e=(0,p.a4)(e,a,{sendAsPeerIds:[]}),void(0,n.R3)(e);e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,p.fZ)(e,(0,g.ee)(o.chats,"id")),e=(0,p.a4)(e,a,{sendAsPeerIds:o.sendAs}),(0,n.R3)(e)})),(0,n.iw)("loadSponsoredMessages",(async(e,t,s)=>{const{chatId:a}=s,i=(0,f.Z1J)(e,a);if(!i)return;const o=await(0,h.t9)("fetchSponsoredMessages",{chat:i});o&&(e=(0,n.Rd)(),e=(0,p.Fn)(e,a,o.messages[0]),e=(0,p.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,p.fZ)(e,(0,g.ee)(o.chats,"id")),(0,n.R3)(e))})),(0,n.iw)("viewSponsoredMessage",((e,t,s)=>{const{chatId:n}=s,a=(0,f.Z1J)(e,n),i=(0,f.fSe)(e,n);a&&i&&(0,h.t9)("viewSponsoredMessage",{chat:a,random:i.randomId})})),(0,n.iw)("fetchUnreadMentions",(async(e,t,s)=>{const{chatId:a,offsetId:i}=s,o=(0,f.Z1J)(e,a);if(!o)return;const r=await(0,h.t9)("fetchUnreadMentions",{chat:o,offsetId:i});if(!r)return;const{messages:c,chats:d,users:l}=r,u=(0,g.ee)(c,"id"),m=Object.keys(u).map(Number);e=(0,n.Rd)(),e=(0,p.c_)(e,o.id,u),e=(0,p.Sh)(e,(0,g.ee)(l,"id")),e=(0,p.fZ)(e,(0,g.ee)(d,"id")),e=(0,p.a4)(e,a,{unreadMentions:[...o.unreadMentions||[],...m]}),(0,n.R3)(e)})),(0,n.iw)("markMentionsRead",((e,t,s)=>{const{messageIds:a,tabId:i=(0,P._w)()}=s,o=(0,f.jrE)(e,i);if(!o)return;const r=(o.unreadMentions||[]).filter((e=>!a.includes(e)));e=(0,p.a4)(e,o.id,{unreadMentions:r}),(0,n.R3)(e),t.markMessagesRead({messageIds:a,tabId:i})})),(0,n.iw)("focusNextMention",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jrE)(e,n);a?.unreadMentions&&t.focusMessage({chatId:a.id,messageId:a.unreadMentions[0],tabId:n})})),(0,n.iw)("readAllMentions",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jrE)(e,n);if(a)return(0,h.t9)("readAllMentions",{chat:a}),(0,p.a4)(e,a.id,{unreadMentionsCount:void 0,unreadMentions:void 0})})),(0,n.iw)("openUrl",((e,t,s)=>{const{url:n,shouldSkipModal:a,tabId:o=(0,P._w)()}=s,r=(0,y.X)(n),c=Boolean((0,f.jUK)(e,o).storyViewer.userId);if(r.match(i.FSu)||r.match(i.g$l))return c&&t.closeStoryViewer({tabId:o}),void t.openTelegramLink({url:n,tabId:o});const{appConfig:d,config:l}=e;if(d){const e=new URL(r);if(l?.autologinToken&&d.autologinDomains.includes(e.hostname))return e.searchParams.set("autologin_token",l.autologinToken),void window.open(e.href,"_blank","noopener");if(d.urlAuthDomains.includes(e.hostname))return c&&t.closeStoryViewer({tabId:o}),void t.requestLinkUrlAuth({url:n,tabId:o})}r.match(i.jL5)||a?window.open(r,"_blank","noopener"):t.toggleSafeLinkModal({url:r,tabId:o})})),(0,n.iw)("setForwardChatOrTopic",(async(e,t,s)=>{const{chatId:a,topicId:i,tabId:o=(0,P._w)()}=s;let r=(0,f.dyD)(e,a);if(r&&(0,f.Nm0)(e,o)){let s=(0,f.ccz)(e,a);if(!s){const{accessHash:t}=r,i=await(0,h.t9)("fetchFullUser",{id:a,accessHash:t});e=(0,n.Rd)(),r=i?.user,s=i?.fullInfo}if(s.noVoiceMessages)return void t.showDialog({data:{message:(0,w.Iu)("VoiceMessagesRestrictedByPrivacy",(0,v.Js)(r))},tabId:o})}(0,f.GQU)(e,a,o)?(e=(0,b.i)(e,{forwardMessages:{...(0,f.jUK)(e,o).forwardMessages,toChatId:a,toThreadId:i,isModalShown:!1}},o),(0,n.R3)(e),t.openChat({id:a,threadId:i,tabId:o}),t.closeMediaViewer({tabId:o}),t.exitMessageSelectMode({tabId:o})):t.showAllowedMessageTypesNotification({chatId:a,tabId:o})})),(0,n.iw)("forwardToSavedMessages",((e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{};e=(0,b.i)(e,{forwardMessages:{...(0,f.jUK)(e,a).forwardMessages,toChatId:e.currentUserId}},a),(0,n.R3)(e),t.exitMessageSelectMode({tabId:a}),t.forwardMessages({isSilent:!0,tabId:a})})),(0,n.iw)("forwardStory",((e,t,s)=>{const{toChatId:a,tabId:i=(0,P._w)()}=s||{},{fromChatId:o,storyId:r}=(0,f.jUK)(e,i).forwardMessages,c=o?(0,f.Z1J)(e,o):void 0,d=a?(0,f.Z1J)(e,a):void 0,l=o&&r?(0,f.o9F)(e,o,r):void 0;if(!c||!d||!l||"isDeleted"in l)return;const{text:m,entities:h}=l.content.text||{};W(e,{chat:d,currentThreadId:u._f,text:m,entities:h,story:l}),e=(0,n.Rd)(),e=(0,b.i)(e,{forwardMessages:{}},i),(0,n.R3)(e)})),(0,n.iw)("requestMessageTranslation",((e,t,s)=>{const{chatId:n,id:a,toLanguageCode:i=(0,f.Mc4)(e),tabId:o=(0,P._w)()}=s;return e=(0,p.ql)(e,n,a,i,o),(0,p.BI)(e,{translationLanguage:i})})),(0,n.iw)("showOriginalMessage",((e,t,s)=>{const{chatId:n,id:a,tabId:i=(0,P._w)()}=s;return(0,p.IR)(e,n,a,i)})),(0,n.iw)("markMessagesTranslationPending",((e,t,s)=>{const{chatId:n,messageIds:a,toLanguageCode:i=(0,f.rB0)(e)}=s;return a.forEach((t=>{e=(0,p.qt)(e,n,t,i,{isPending:!0})})),e})),(0,n.iw)("translateMessages",((e,t,s)=>{const{chatId:n,messageIds:a,toLanguageCode:i=(0,f.rB0)(e)}=s,o=(0,f.Z1J)(e,n);if(o)return t.markMessagesTranslationPending({chatId:n,messageIds:a,toLanguageCode:i}),(0,h.t9)("translateText",{chat:o,messageIds:a,toLanguageCode:i}),e}));let Y,X={};function Q(){Y&&(clearTimeout(Y),Y=void 0);const{loadMessageViews:e}=(0,n.Sv)();Object.entries(X).forEach((t=>{let[s,n]=t;e({chatId:s,ids:Array.from(n),shouldIncrement:!0})})),X={}}function ee(e){const{shouldSendAsFile:t,mimeType:s}=e;return t?"file":s===i.s11?"gif":i.oGt.has(s)||i.wGh.has(s)?"media":i.e74.has(s)?"audio":e.voice?"voice":"file"}(0,n.iw)("scheduleForViewsIncrement",((e,t,s)=>{const{ids:n,chatId:a}=s;Y||setTimeout(Q,1e3),X[a]||(X[a]=new Set),n.forEach((e=>{X[a].add(e)}))})),(0,n.iw)("loadMessageViews",(async(e,t,s)=>{const{chatId:a,ids:i,shouldIncrement:o}=s,r=(0,f.Z1J)(e,a);if(!r)return;const c=await(0,h.t9)("fetchMessageViews",{chat:r,ids:i,shouldIncrement:o});c&&(e=(0,n.Rd)(),c.forEach((t=>{e=(0,p.cY)(e,a,t.id,{views:t.views,forwards:t.forwards});const s=(0,f.hjO)(e,a,t.id);if(!s)return;const n=s.repliesThreadInfo?.chatId,i=s.repliesThreadInfo?.threadId;n&&i&&(e=(0,p.Xg)(e,n,i,{messagesCount:t.messagesCount,recentReplierIds:t.recentReplierIds,lastMessageId:t.maxId,lastReadInboxMessageId:t.readMaxId}))})),(0,n.R3)(e))}));var te=s(85765),se=s(9211);const ne=(0,I.P2)((e=>e()),500,!1);async function ae(e,t){const s=await(0,h.t9)("fetchRecentStickers",{hash:t});s&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,recent:s}},(0,n.R3)(e))}async function ie(e,t,s){for(var a=arguments.length,i=new Array(a>3?a-3:0),o=3;o<a;o++)i[o-3]=arguments[o];let r,[c=(0,P._w)()]=i;try{r=await(0,h.t9)("fetchStickers",{stickerSetInfo:s})}catch(a){if("STICKERSET_INVALID"===a.message)return t.showNotification({message:(0,w.Iu)("StickerPack.ErrorNotFound"),tabId:c}),void("shortName"in s&&(0,f.jUK)(e,c).openedStickerSetShortName===s.shortName&&(e=(0,b.i)(e,{openedStickerSetShortName:void 0},c),(0,n.R3)(e)))}if(e=(0,n.Rd)(),!r)return;const{set:d,stickers:l,packs:u}=r,m=(e=(0,p.Rg)(e,d.id,{...d,stickers:l,packs:u})).stickers.forEmoji.emoji;m&&u[m]&&(e=(0,p.vy)(e)),(0,n.R3)(e)}async function oe(e,t,s,a){for(var i=arguments.length,o=new Array(i>4?i-4:0),r=4;r<i;r++)o[r-4]=arguments[r];let[c=(0,P._w)()]=o;const d=await(0,h.t9)("searchGifs",{query:t,offset:a,username:s});d&&(e=(0,n.Rd)(),e=(0,p.rq)(e,!a,d.gifs,d.nextOffset,c),(0,n.R3)(e))}(0,n.iw)("loadStickerSets",(async(e,t)=>{const[s,a]=await Promise.all([(0,h.t9)("fetchStickerSets",{hash:e.stickers.added.hash}),(0,h.t9)("fetchCustomEmojiSets",{hash:e.customEmojis.added.hash})]);a&&s&&(e=(0,n.Rd)(),e=(0,p.z3)(e,"added",s.hash,s.sets),e=(0,p.cU)(e,a.hash,a.sets),(0,n.R3)(e),t.loadCustomEmojis({ids:e.recentCustomEmojis}))})),(0,n.iw)("loadAddedStickers",(async(e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{added:{setIds:a=[]},setsById:i}=e.stickers,{added:{setIds:o=[]}}=e.customEmojis,r=[...a,...o];if(r.length)for(let e=0;e<r.length;e++){const s=r[e];i[s]?.stickers||(t.loadStickers({stickerSetInfo:{id:s,accessHash:i[s].accessHash},tabId:n}),e%10==0&&e>0&&await(0,I.wO)(200))}})),(0,n.iw)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};ae(e,t)})),(0,n.iw)("loadFavoriteStickers",(async e=>{const{hash:t}=e.stickers.favorite||{},s=await(0,h.t9)("fetchFavoriteStickers",{hash:t});s&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,favorite:s}},(0,n.R3)(e))})),(0,n.iw)("loadPremiumStickers",(async e=>{const{hash:t}=e.stickers.premium||{},s=await(0,h.t9)("fetchStickersForEmoji",{emoji:"⭐️⭐️",hash:t});s&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,premium:{hash:s.hash,stickers:s.stickers}}},(0,n.R3)(e))})),(0,n.iw)("loadPremiumSetStickers",(async e=>{const{hash:t}=e.stickers.premium||{},s=await(0,h.t9)("fetchStickersForEmoji",{emoji:"📂⭐️",hash:t});s&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,premiumSet:{hash:s.hash,stickers:s.stickers}}},(0,n.R3)(e))})),(0,n.iw)("loadGreetingStickers",(async e=>{const{hash:t}=e.stickers.greeting||{},s=await(0,h.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});s&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,greeting:{hash:s.hash,stickers:s.stickers.filter((e=>"👋"===e.emoji))}}},(0,n.R3)(e))})),(0,n.iw)("loadFeaturedStickers",(async e=>{const{hash:t}=e.stickers.featured||{},s=await(0,h.t9)("fetchFeaturedStickers",{hash:t});s&&(e=(0,n.Rd)(),e=(0,p.z3)(e,"featured",s.hash,s.sets),(0,n.R3)(e))})),(0,n.iw)("loadPremiumGifts",(async e=>{const t=await(0,h.t9)("fetchPremiumGifts");if(!t)return;const{set:s,stickers:a}=t;e=(0,n.Rd)(),e={...e,premiumGifts:{...s,stickers:a}},(0,n.R3)(e)})),(0,n.iw)("loadDefaultTopicIcons",(async e=>{const t=await(0,h.t9)("fetchDefaultTopicIcons");if(!t)return;e=(0,n.Rd)();const{set:s,stickers:a}=t,i={...s,stickers:a};e=(0,p.Rg)(e,i.id,i),e={...e,defaultTopicIconsId:i.id},(0,n.R3)(e)})),(0,n.iw)("loadDefaultStatusIcons",(async e=>{const t=await(0,h.t9)("fetchDefaultStatusEmojis");if(!t)return;e=(0,n.Rd)();const{set:s,stickers:a}=t,i={...s,stickers:a};e=(0,p.Rg)(e,i.id,i),e={...e,defaultStatusIconsId:i.id},(0,n.R3)(e)})),(0,n.iw)("loadStickers",((e,t,s)=>{const{stickerSetInfo:n,tabId:a=(0,P._w)()}=s,i=(0,f.Ny0)(e,n);i&&i.count===i?.stickers?.length||ie(e,t,n,a)})),(0,n.iw)("loadAnimatedEmojis",(async e=>{const[t,s]=await Promise.all([(0,h.t9)("fetchAnimatedEmojis"),(0,h.t9)("fetchAnimatedEmojiEffects")]);t&&s&&(e=(0,n.Rd)(),e=(0,p.g_)(e,{...t.set,stickers:t.stickers}),e={...e,animatedEmojiEffects:{...s.set,stickers:s.stickers}},(0,n.R3)(e))})),(0,n.iw)("loadGenericEmojiEffects",(async e=>{const t=await(0,h.t9)("fetchGenericEmojiEffects");if(!t)return;e=(0,n.Rd)();const{set:s,stickers:a}=t;e={...e,genericEmojiEffects:{...s,stickers:a}},(0,n.R3)(e)})),(0,n.iw)("loadSavedGifs",(async e=>{const{hash:t}=e.gifs.saved,s=await(0,h.t9)("fetchSavedGifs",{hash:t});s&&(e=(0,n.Rd)(),e={...e,gifs:{...e.gifs,saved:s}},(0,n.R3)(e))})),(0,n.iw)("saveGif",(async(e,t,s)=>{const{gif:a,shouldUnsave:i,tabId:o=(0,P._w)()}=s,r=e.gifs.saved.gifs?.length,c=(0,se.M)(e,"savedGifs"),d=(0,se.P)(e,"savedGifs"),l=(0,f.wVz)(e);if(!i&&r&&r>=c&&t.showNotification({title:w.Iu("LimitReachedFavoriteGifs",c.toString()),message:l?w.Iu("LimitReachedFavoriteGifsSubtitlePremium"):w.Iu("LimitReachedFavoriteGifsSubtitle",d.toString()),...!l&&{action:{action:"openPremiumModal",payload:{tabId:o}}},className:"bold-link",tabId:o}),!await(0,h.t9)("saveGif",{gif:a,shouldUnsave:i}))return;const u=(e=(0,n.Rd)()).gifs.saved.gifs?.filter((e=>{let{id:t}=e;return t!==a.id}))||[],m=i?u:[a,...u];e={...e,gifs:{...e.gifs,saved:{...e.gifs.saved,gifs:m}}},(0,n.R3)(e)})),(0,n.iw)("faveSticker",((e,t,s)=>{const{sticker:n,tabId:a=(0,P._w)()}=s,i=e.stickers.favorite.stickers.length,o=(0,se.M)(e,"stickersFaved"),r=(0,se.P)(e,"stickersFaved"),c=(0,f.wVz)(e);i>=o&&t.showNotification({title:w.Iu("LimitReachedFavoriteStickers",o.toString()),message:c?w.Iu("LimitReachedFavoriteStickersSubtitlePremium"):w.Iu("LimitReachedFavoriteStickersSubtitle",r.toString()),...!c&&{action:{action:"openPremiumModal",payload:{tabId:a}}},className:"bold-link",tabId:a}),n&&(0,h.t9)("faveSticker",{sticker:n})})),(0,n.iw)("unfaveSticker",((e,t,s)=>{const{sticker:a}=s;a&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,favorite:{...e.stickers.favorite,stickers:e.stickers.favorite.stickers.filter((e=>{let{id:t}=e;return t!==a.id}))}}},(0,n.R3)(e),(0,h.t9)("faveSticker",{sticker:a,unfave:!0}))})),(0,n.iw)("removeRecentSticker",(async(e,t,s)=>{const{sticker:a}=s;await(0,h.t9)("removeRecentSticker",{sticker:a})&&ae((0,n.Rd)())})),(0,n.iw)("clearRecentStickers",(async e=>{await(0,h.t9)("clearRecentStickers")&&(e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,recent:{stickers:[]}}},(0,n.R3)(e))})),(0,n.iw)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:n}=s,a=(0,f.Ny0)(e,n);if(!a)return;const{accessHash:i,installedDate:o,isArchived:r}=a,c=!r&&Boolean(o);(0,h.t9)(c?"uninstallStickerSet":"installStickerSet",{stickerSetId:n,accessHash:i})})),(0,n.iw)("loadEmojiKeywords",(async(e,t,s)=>{const{language:a}=s;let i=e.emojiKeywords[a];if(i?.isLoading)return;e={...e,emojiKeywords:{...e.emojiKeywords,[a]:{...i,isLoading:!0}}},(0,n.R3)(e);const o=await(0,h.t9)("fetchEmojiKeywords",{language:a,fromVersion:i?i.version:0});if(i=(e=(0,n.Rd)()).emojiKeywords[a],!o)return e={...e,emojiKeywords:{...e.emojiKeywords,[a]:{...i,isLoading:!1}}},void(0,n.R3)(e);e={...e,emojiKeywords:{...e.emojiKeywords,[a]:{isLoading:!1,version:o.version,keywords:{...i?.keywords,...o.keywords}}}},(0,n.R3)(e)})),(0,n.iw)("setStickerSearchQuery",((e,t,s)=>{const{query:a,tabId:i=(0,P._w)()}=s;a&&ne((async()=>{const t=await(0,h.t9)("searchStickers",{query:a});if(!t)return;e=(0,n.Rd)();const{setsById:s,added:o}=e.stickers,r=t.sets.map((e=>{let{id:t}=e;return t}));o.setIds&&o.setIds.forEach((e=>{if(!r.includes(e)){const{title:t}=s[e]||{};t&&(0,te.Z)(t,a)&&r.unshift(e)}})),e=(0,p.z3)(e,"search",t.hash,t.sets),e=(0,p.fH)(e,t.hash,r,i),(0,n.R3)(e)}))})),(0,n.iw)("setGifSearchQuery",((e,t,s)=>{const{query:a,tabId:i=(0,P._w)()}=s;"string"==typeof a&&ne((()=>{oe(e=(0,n.Rd)(),a,e.config?.gifSearchUsername,void 0,i)}))})),(0,n.iw)("searchMoreGifs",((e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{},{query:i,offset:o}=(0,f.jUK)(e,a).gifSearch;"string"==typeof i&&ne((()=>{oe(e=(0,n.Rd)(),i,e.config?.gifSearchUsername,o,a)}))})),(0,n.iw)("loadStickersForEmoji",((e,t,s)=>{const{emoji:a}=s,{hash:i}=e.stickers.forEmoji;ne((async()=>{e=(0,n.Rd)(),e={...e,stickers:{...e.stickers,forEmoji:{...e.stickers.forEmoji,emoji:a}}},(0,n.R3)(e);const t=await(0,h.t9)("fetchStickersForEmoji",{emoji:a,hash:i});e=(0,n.Rd)(),t&&e.stickers.forEmoji.emoji===a&&(e=(0,p.IM)(e,a,t.stickers,t.hash),(0,n.R3)(e))}))})),(0,n.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,n.iw)("loadCustomEmojiForEmoji",((e,t,s)=>{const{emoji:n}=s;return(0,p.AA)(e,n)})),(0,n.iw)("clearCustomEmojiForEmoji",(e=>({...e,customEmojis:{...e.customEmojis,forEmoji:{}}}))),(0,n.iw)("loadFeaturedEmojiStickers",(async e=>{const t=await(0,h.t9)("fetchFeaturedEmojiStickers");t&&(e=(0,n.Rd)(),e={...e,customEmojis:{...e.customEmojis,featuredIds:t.sets.map((e=>{let{id:t}=e;return t})),byId:{...e.customEmojis.byId,...(0,g.ee)(t.sets.flatMap((e=>e.stickers||[])),"id")}},stickers:{...e.stickers,setsById:{...e.stickers.setsById,...(0,g.ee)(t.sets,"id")}}},(0,n.R3)(e))})),(0,n.iw)("openStickerSet",(async(e,t,s)=>{const{stickerSetInfo:a,tabId:i=(0,P._w)()}=s;(0,f.Ny0)(e,a)||await ie(e,t,a,i),e=(0,n.Rd)();const o=(0,f.Ny0)(e,a);o?.shortName&&(e=(0,b.i)(e,{openedStickerSetShortName:o.shortName},i),(0,n.R3)(e))})),(0,n.iw)("loadRecentEmojiStatuses",(async e=>{const t=await(0,h.t9)("fetchRecentEmojiStatuses");t&&(e=(0,n.Rd)(),e=(0,p.et)(e,t.hash,t.emojiStatuses),(0,n.R3)(e))}));var re=s(790);const ce=(0,I.P2)((e=>e()),500,!1);async function de(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,r=arguments.length>5?arguments[5]:void 0,c=arguments.length>6?arguments[6]:void 0;for(var d=arguments.length,l=new Array(d>7?d-7:0),u=7;u<d;u++)l[u-7]=arguments[u];let m,[I=(0,P._w)()]=l;if(o){const e=(0,h.t9)("searchMessagesLocal",{chat:o,query:t,type:s,limit:i.Hkl,offsetId:a,minDate:c,maxDate:r}),n=o.isForum?(0,h.t9)("fetchTopics",{chat:o,query:t,limit:i.XM3}):void 0,[d,l]=await Promise.all([e,n]);if(d){const{messages:e,users:t,totalCount:s,nextOffsetId:n}=d,{topics:a,count:i}=l||{};m={topics:a,totalTopicsCount:i,messages:e,users:t,chats:[],totalCount:s,nextRate:n}}}else m=await(0,h.t9)("searchMessagesGlobal",{query:t,offsetRate:a,limit:i.Hkl,type:s,maxDate:r,minDate:c});e=(0,n.Rd)();const v=(0,f.JXM)(e,I);if(!m||""!==t&&t!==v)return e=(0,p.xv)(e,{messages:!1},I),void(0,n.R3)(e);const{messages:w,users:y,chats:b,totalCount:Z,nextRate:C}=m;b.length&&(e=(0,p.fZ)(e,(0,g.ee)(b,"id"))),y.length&&(e=(0,p.Sh)(e,(0,g.ee)(y,"id"))),w.length&&(e=(0,p.m6)(e,w)),e=(0,p.px)(e,w,Z,s,C,I),m.topics&&(e=(0,p.XG)(e,o.id,m.totalTopicsCount,m.topics));const S=m.topics?.map((e=>{let{id:t}=e;return t})).sort(((e,t)=>t-e));e=(0,p.No)(e,{foundTopicIds:S},I),(0,n.R3)(e)}async function le(e,t,s,a,o){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];for(var c=arguments.length,d=new Array(c>6?c-6:0),l=6;l<c;l++)d[l-6]=arguments[l];let[m=(0,P._w)()]=d;const I=await(0,h.t9)("searchMessagesLocal",{chat:t,type:a,limit:2*i.ENB,topMessageId:s===u._f?void 0:s,offsetId:o});if(!I)return;const{chats:v,users:w,messages:y,totalCount:b,nextOffsetId:Z}=I,C=(0,g.ee)(y,"id"),S=Object.keys(C).map(Number);e=(0,n.Rd)();const M=(0,f.weG)(e,m);M&&(e=(0,p.fZ)(e,(0,g.ee)(v,"id")),e=(0,p.Sh)(e,(0,g.ee)(w,"id")),e=(0,p.c_)(e,t.id,C),e=(0,p.c1)(e,t.id,s,a,S,b,Z,m),(0,n.R3)(e),r||le(e,t,s,a,Z,!0,m))}(0,n.iw)("setGlobalSearchQuery",((e,t,s)=>{const{query:a,tabId:i=(0,P._w)()}=s,{chatId:o}=(0,f.jUK)(e,i).globalSearch;a&&!o&&ce((async()=>{const t=await(0,h.t9)("searchChats",{query:a});e=(0,n.Rd)();const s=(0,f.JXM)(e,i);if(!t||!s||a!==s)return e=(0,p.xv)(e,{chats:!1},i),void(0,n.R3)(e);const{localChats:o,localUsers:r,globalChats:c,globalUsers:d}=t;(o.length||c.length)&&(e=(0,p.fZ)(e,(0,g.ee)([...o,...c],"id"))),(r.length||d.length)&&(e=(0,p.Sh)(e,(0,g.ee)([...r,...d],"id"))),e=(0,p.xv)(e,{chats:!1},i),e=(0,p.No)(e,{localResults:{chatIds:o.map((e=>{let{id:t}=e;return t})),userIds:r.map((e=>{let{id:t}=e;return t}))},globalResults:{...(0,f.jUK)(e,i).globalSearch.globalResults,chatIds:c.map((e=>{let{id:t}=e;return t})),userIds:d.map((e=>{let{id:t}=e;return t}))}},i),(0,n.R3)(e)}))})),(0,n.iw)("setGlobalSearchDate",((e,t,s)=>{const{date:a,tabId:i=(0,P._w)()}=s,o=a?(0,re.IS)(a):a;e=(0,p.No)(e,{date:a,query:"",resultsByType:{...(0,f.jUK)(e,i).globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}},i),(0,n.R3)(e);const{chatId:r}=(0,f.jUK)(e,i).globalSearch;de(e,"","text",void 0,r?(0,f.Z1J)(e,r):void 0,o,a,i)})),(0,n.iw)("searchMessagesGlobal",((e,t,s)=>{const{type:n,tabId:a=(0,P._w)()}=s,{query:i,resultsByType:o,chatId:r,date:c}=(0,f.jUK)(e,a).globalSearch,d=c?(0,re.IS)(c):c,l=o?.[n]?.nextOffsetId;de(e,i,n,l,r?(0,f.Z1J)(e,r):void 0,d,c,a)})),(0,n.iw)("searchTextMessagesLocal",(async(e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{},{chatId:o,threadId:r}=(0,f.Btg)(e,a)||{},c=o?(0,f.Z1J)(e,o):void 0;let d=(0,f.n5x)(e,a);if(!c||!d||!r)return;const{query:l,results:m}=d,I=m?.nextOffsetId;let v;if(r!==u._f&&(v=(0,f.tZg)(e,o,r)?.topMessageId),!l)return;const w=await(0,h.t9)("searchMessagesLocal",{chat:c,type:"text",query:l,topMessageId:v,limit:i.pnA,offsetId:I});if(!w)return;const{chats:y,users:b,messages:Z,totalCount:C,nextOffsetId:S}=w,M=(0,g.ee)(Z,"id"),E=Object.keys(M).map(Number);e=(0,n.Rd)(),d=(0,f.n5x)(e,a),d&&l===d.query&&(e=(0,p.fZ)(e,(0,g.ee)(y,"id")),e=(0,p.Sh)(e,(0,g.ee)(b,"id")),e=(0,p.c_)(e,c.id,M),e=(0,p.dx)(e,c.id,r,E,C,S,a),(0,n.R3)(e))})),(0,n.iw)("searchMediaMessagesLocal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{chatId:a,threadId:i}=(0,f.Btg)(e,n)||{};if(!a||!i)return;const o=(0,f.Z1J)(e,a),r=(0,f.weG)(e,n);if(!o||!r)return;const{currentType:c,resultsByType:d}=r,l=(c&&d&&d[c])?.nextOffsetId;c&&le(e,o,i,c,l,void 0,n)})),(0,n.iw)("searchMessagesByDate",(async(e,t,s)=>{const{timestamp:n,tabId:a=(0,P._w)()}=s,{chatId:i}=(0,f.Btg)(e,a)||{};if(!i)return;const o=(0,f.Z1J)(e,i);if(!o)return;const r=await(0,h.t9)("findFirstMessageIdAfterDate",{chat:o,timestamp:n});r&&t.focusMessage({chatId:o.id,messageId:r,tabId:a})})),(0,n.iw)("checkPublicLink",(async(e,t,s)=>{const{username:a,tabId:i=(0,P._w)()}=s,{chatId:o}=(0,f.Btg)(e,i)||{};if(!o)return;if((0,f.jUK)(e,i).management.progress===m.wv.InProgress)return;e=(0,p.fw)(e,o,{isUsernameAvailable:void 0,checkedUsername:void 0},i),(0,n.R3)(e);const{result:r,error:c}=await(0,h.t9)("checkChatUsername",{username:a});e=(0,n.Rd)(),e=(0,p.H9)(e,!0===r?m.wv.Complete:m.wv.Error,i),e=(0,p.fw)(e,o,{isUsernameAvailable:!0===r,checkedUsername:a,error:c},i),(0,n.R3)(e),void 0===r&&t.openLimitReachedModal({limit:"channelsPublic",tabId:i})})),(0,n.iw)("updatePublicLink",(async(e,t,s)=>{const{username:a,shouldDisableUsernames:i,tabId:o=(0,P._w)()}=s,{chatId:r}=(0,f.Btg)(e,o)||{};if(!r)return;const c=await(0,l.X9)(e,t,r,o);if(!c)return;e=(0,n.Rd)(),e=(0,p.H9)(e,m.wv.InProgress,o),(0,n.R3)(e);const d=await(0,h.t9)("setChatUsername",{chat:c,username:a});i&&await(0,h.t9)("deactivateAllUsernames",{chat:c}),e=(0,n.Rd)(),e=(0,p.H9)(e,d?m.wv.Complete:m.wv.Error,o),e=(0,p.fw)(e,r,{isUsernameAvailable:void 0,checkedUsername:void 0,error:void 0},o),(0,n.R3)(e)})),(0,n.iw)("updatePrivateLink",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{chatId:a}=(0,f.Btg)(e,n)||{},i=a&&(0,f.Z1J)(e,a);a&&i&&(0,h.t9)("updatePrivateLink",{chat:i})})),(0,n.iw)("setEditingExportedInvite",((e,t,s)=>{const{chatId:a,invite:i,tabId:o=(0,P._w)()}=s;e=(0,p.fw)(e,a,{editingInvite:i},o),(0,n.R3)(e)})),(0,n.iw)("setOpenedInviteInfo",((e,t,s)=>{const{chatId:a,invite:i,tabId:o=(0,P._w)()}=s,r=i?{inviteInfo:{invite:i}}:{inviteInfo:void 0};e=(0,p.fw)(e,a,r,o),(0,n.R3)(e)})),(0,n.iw)("loadExportedChatInvites",(async(e,t,s)=>{const{chatId:a,adminId:i,isRevoked:o,limit:r,tabId:c=(0,P._w)()}=s,d=(0,f.Z1J)(e,a),l=(0,f.dyD)(e,i||e.currentUserId);if(!d||!l)return;const u=await(0,h.t9)("fetchExportedChatInvites",{peer:d,admin:l,isRevoked:o,limit:r});if(!u)return;e=(0,n.Rd)();const{invites:m,users:I}=u;e=(0,p.Sh)(e,(0,g.ee)(I,"id"));const v=o?{revokedInvites:m}:{invites:m};e=(0,p.fw)(e,a,v,c),(0,n.R3)(e)})),(0,n.iw)("editExportedChatInvite",(async(e,t,s)=>{const{chatId:a,link:i,isRevoked:o,expireDate:r,usageLimit:c,isRequestNeeded:d,title:l,tabId:u=(0,P._w)()}=s,m=(0,f.Z1J)(e,a);if(!m)return;const I=await(0,h.t9)("editExportedChatInvite",{peer:m,link:i,isRevoked:o,expireDate:r,usageLimit:c,isRequestNeeded:d,title:l});if(!I)return;const{oldInvite:v,newInvite:w,users:y}=I;e=(0,n.Rd)();const{management:b}=(0,f.jUK)(e,u),Z=(b.byChatId[a].invites||[]).filter((e=>e.link!==v.link)),C=[...b.byChatId[a].revokedInvites||[]];w.isRevoked?C.unshift(w):Z.push(w),e=(0,p.Sh)(e,(0,g.ee)(y,"id")),e=(0,p.fw)(e,a,{invites:Z,revokedInvites:C},u),(0,n.R3)(e)})),(0,n.iw)("exportChatInvite",(async(e,t,s)=>{const{chatId:a,expireDate:i,usageLimit:o,isRequestNeeded:r,title:c,tabId:d=(0,P._w)()}=s,l=(0,f.Z1J)(e,a);if(!l)return;const u=await(0,h.t9)("exportChatInvite",{peer:l,expireDate:i,usageLimit:o,isRequestNeeded:r,title:c});if(!u)return;e=(0,n.Rd)();const m=(0,f.jUK)(e,d).management.byChatId[a].invites||[];e=(0,p.fw)(e,a,{invites:[...m,u]},d),(0,n.R3)(e)})),(0,n.iw)("deleteExportedChatInvite",(async(e,t,s)=>{const{chatId:a,link:i,tabId:o=(0,P._w)()}=s,r=(0,f.Z1J)(e,a);if(!r)return;if(!await(0,h.t9)("deleteExportedChatInvite",{peer:r,link:i}))return;e=(0,n.Rd)();const c=(0,f.jUK)(e,o).management.byChatId[a];e=(0,p.fw)(e,a,{invites:c?.invites?.filter((e=>e.link!==i)),revokedInvites:c?.revokedInvites?.filter((e=>e.link!==i))},o),(0,n.R3)(e)})),(0,n.iw)("deleteRevokedExportedChatInvites",(async(e,t,s)=>{const{chatId:a,adminId:i,tabId:o=(0,P._w)()}=s,r=(0,f.Z1J)(e,a),c=(0,f.dyD)(e,i||e.currentUserId);r&&c&&await(0,h.t9)("deleteRevokedExportedChatInvites",{peer:r,admin:c})&&(e=(0,n.Rd)(),e=(0,p.fw)(e,a,{revokedInvites:[]},o),(0,n.R3)(e))})),(0,n.iw)("loadChatInviteImporters",(async(e,t,s)=>{const{chatId:a,link:i,offsetDate:o,offsetUserId:r,limit:c,tabId:d=(0,P._w)()}=s,l=(0,f.Z1J)(e,a),u=r?(0,f.dyD)(e,r):void 0;if(!l||r&&!u)return;const m=await(0,h.t9)("fetchChatInviteImporters",{peer:l,link:i,offsetDate:o,offsetUser:u,limit:c});if(!m)return;const{importers:g,users:I}=m;e=(0,n.Rd)();const v=(0,f.jUK)(e,d).management.byChatId[a]?.inviteInfo;v?.invite&&v.invite.link===i&&(e=(0,p.fw)(e,a,{inviteInfo:{...v,importers:g}},d),e=(0,p.Sh)(e,I),(0,n.R3)(e))})),(0,n.iw)("loadChatInviteRequesters",(async(e,t,s)=>{const{chatId:a,link:i,offsetDate:o,offsetUserId:r,limit:c,tabId:d=(0,P._w)()}=s,l=(0,f.Z1J)(e,a),u=r?(0,f.dyD)(e,r):void 0;if(!l||r&&!u)return;const m=await(0,h.t9)("fetchChatInviteImporters",{peer:l,link:i,offsetDate:o,offsetUser:u,limit:c,isRequested:!0});if(!m)return;const{importers:g,users:I}=m;e=(0,n.Rd)();const v=(0,f.jUK)(e,d).management.byChatId[a]?.inviteInfo;v?.invite&&v.invite.link===i&&(e=(0,p.fw)(e,a,{inviteInfo:{...v,requesters:g}},d),e=(0,p.Sh)(e,I),(0,n.R3)(e))})),(0,n.iw)("loadChatJoinRequests",(async(e,t,s)=>{const{chatId:a,offsetDate:i=0,offsetUserId:o,limit:r=0}=s,c=(0,f.Z1J)(e,a),d=o?(0,f.dyD)(e,o):void 0;if(!c||o&&!d)return;const l=await(0,h.t9)("fetchChatInviteImporters",{peer:c,offsetDate:i,offsetUser:d,limit:r,isRequested:!0});if(!l)return;const{importers:u,users:m}=l;e=(0,n.Rd)(),e=(0,p.a4)(e,a,{joinRequests:u}),e=(0,p.Sh)(e,m),(0,n.R3)(e)})),(0,n.iw)("hideChatJoinRequest",(async(e,t,s)=>{const{chatId:a,userId:i,isApproved:o}=s,r=(0,f.Z1J)(e,a),c=(0,f.dyD)(e,i);if(!r||!c)return;if(!await(0,h.t9)("hideChatJoinRequest",{peer:r,user:c,isApproved:o}))return;e=(0,n.Rd)();const d=(0,f.Z1J)(e,a);d&&(e=(0,p.a4)(e,a,{joinRequests:d.joinRequests?.filter((e=>e.userId!==i))}),(0,n.R3)(e))})),(0,n.iw)("hideAllChatJoinRequests",(async(e,t,s)=>{const{chatId:a,isApproved:i,link:o}=s,r=(0,f.Z1J)(e,a);r&&await(0,h.t9)("hideAllChatJoinRequests",{peer:r,isApproved:i,link:o})&&(e=(0,n.Rd)(),(0,f.Z1J)(e,a)&&(e=(0,p.a4)(e,a,{joinRequests:[]}),e=(0,p.US)(e,a,{recentRequesterIds:[],requestsPending:0}),(0,n.R3)(e)))})),(0,n.iw)("hideChatReportPanel",(async(e,t,s)=>{const{chatId:a}=s,i=(0,f.Z1J)(e,a);i&&await(0,h.t9)("hideChatReportPanel",i)&&(e=(0,n.Rd)(),e=(0,p.a4)(e,a,{settings:void 0}),(0,n.R3)(e))})),(0,n.iw)("uploadContactProfilePhoto",(async(e,t,s)=>{const{userId:a,file:i,isSuggest:o,tabId:r=(0,P._w)()}=s,c=(0,f.dyD)(e,a);if(!c)return;e=(0,p.H9)(e,m.wv.InProgress,r),(0,n.R3)(e);const d=await(0,h.t9)("uploadContactProfilePhoto",{user:c,file:i,isSuggest:o});if(!d)return e=(0,n.Rd)(),e=(0,p.H9)(e,m.wv.Error,r),void(0,n.R3)(e);e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(d.users,"id")),(0,n.R3)(e);const{id:l,accessHash:u}=c;if(!await(0,h.t9)("fetchFullUser",{id:l,accessHash:u}))return e=(0,n.Rd)(),e=(0,p.H9)(e,m.wv.Error,r),void(0,n.R3)(e);t.loadProfilePhotos({profileId:a}),e=(0,n.Rd)(),e=(0,p.H9)(e,m.wv.Complete,r),(0,n.R3)(e),i&&!o&&t.showNotification({message:w.Iu("UserInfo.SetCustomPhoto.SuccessPhotoText",(0,v.Vl)(c)),tabId:r})})),(0,n.iw)("resetManagementError",((e,t,s)=>{const{chatId:n,tabId:a=(0,P._w)()}=s||{};return(0,p.fw)(e,n,{error:void 0},a)}));var ue=s(65116),me=s(16974);let he,ge;(0,n.iw)("sync",((e,t)=>{i.eMD&&console.log(">>> START SYNC"),he&&clearTimeout(he),e=(0,n.Rd)(),e={...e,isSyncing:!0},(0,n.R3)(e),he=window.setTimeout((()=>{e=(0,n.Rd)(),e={...e,isSyncing:!1},(0,n.R3)(e),he=void 0}),15e3);const{loadAllChats:s,preloadTopChatMessages:a,loadAllStories:o,loadAllHiddenStories:r}=t;s({listType:"active",shouldReplace:!0,onReplace:async()=>{await async function(e,t){let s=!1;e=(0,n.Rd)();let a=!1;const o=Object.keys(e.messages.byChatId).reduce(((t,s)=>(t[s]=Object.keys(e.messages.byChatId[s].threadsById).reduce(((t,n)=>(t[Number(n)]={draft:(0,f.Mst)(e,s,Number(n)),editingId:(0,f._$9)(e,s,Number(n)),editingDraft:(0,f.saH)(e,s,Number(n)),replyingToId:(0,f.Yyv)(e,s,Number(n))},t)),{}),t)),{});for(const{id:o}of Object.values(e.byTabId)){e=(0,n.Rd)();const{chatId:l,threadId:m}=(0,f.Btg)(e,o)||{},I=m||u._f,v=m&&l?(0,f.tZg)(e,l,m):void 0,w=l?e.chats.byId[l]:void 0;if(l&&w){const t=await(r=w,c=I,d=v?.lastReadInboxMessageId,(0,h.t9)("fetchMessages",{chat:r,threadId:c,offsetId:d||r.lastReadInboxMessageId,addOffset:-(Math.round(i.hT6/2)+1),limit:i.hT6}));e=(0,n.Rd)();const{chatId:u}=(0,f.Btg)(e,o)||{};if(t&&u===l){const n=(0,f.Zwk)(e,l),o=l===i.awM?e.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],r=w.isForum&&w.topics?Object.values(w.topics).map((e=>{let{lastMessageId:t}=e;return n[t]})).filter(Boolean):[],c=[].concat(t.messages,o),d=c.concat(r),u=(0,g.ee)(d,"id"),m=c.map((e=>{let{id:t}=e;return t}));a||(e={...e,messages:{...e.messages,byChatId:{}}},Object.values(e.byTabId).forEach((t=>{let{id:s}=t;e=(0,b.i)(e,{tabThreads:{}},s)})),a=!0),e=(0,p.c_)(e,l,u),e=(0,p.xj)(e,l,I,m),v?.originChannelId&&(e=(0,p.Xg)(e,l,I,v)),Object.values(e.byTabId).forEach((t=>{let{id:s}=t;const{chatId:n,threadId:a}=(0,f.Btg)(e,s)||{};n===l&&a===I&&(e=(0,p.y9)(e,l,I,m,s))})),e=(0,p.GL)(e,(0,g.ee)(t.chats,"id")),e=(0,p.eD)(e,(0,g.ee)(t.users,"id")),t.repliesThreadInfos.length&&(e=(0,p.j6)(e,t.repliesThreadInfos)),s=!0}}(0,n.R3)(e),w?.isForum&&(t.loadTopics({chatId:l,force:!0}),m&&m!==u._f&&t.loadTopicById({chatId:l,topicId:m,shouldCloseChatOnError:!0}))}var r,c,d;e=(0,n.Rd)(),s||(e={...e,messages:{...e.messages,byChatId:{}}},Object.values(e.byTabId).forEach((t=>{let{id:s}=t;e=(0,b.i)(e,{tabThreads:{}},s)}))),Object.keys(o).forEach((t=>{const s=o[t];Object.keys(s).forEach((s=>{e=(0,p.sN)(e,t,Number(s),o[t][Number(s)])}))})),(0,n.R3)(e),Object.values(e.byTabId).forEach((s=>{let{id:n}=s;const{chatId:a,messageId:i}=(0,f.jUK)(e,n).audioPlayer;a&&i&&!(0,f.hjO)(e,a,i)&&t.closeAudioPlayer({tabId:n})}))}(e,t),e=(0,n.Rd)(),e={...e,isSyncing:!1,isSynced:!0},(0,n.R3)(e),i.eMD&&console.log(">>> FINISH SYNC"),(0,me.S1)(),s({listType:"archived",shouldReplace:!0}),(0,h.t9)("fetchCurrentUser"),a(),o(),r()}})})),(0,ue.ll)((e=>{const{connectionState:t,authState:s,isSynced:a}=e,{isMasterTab:i}=(0,f.jUK)(e);!i||a||ge?.connectionState===t&&ge?.authState===s||"connectionStateReady"===t&&"authorizationStateReady"===s&&(0,n.Sv)().sync(),ge=e})),(0,n.iw)("reportPeer",(async(e,t,s)=>{const{chatId:n,reason:a,description:i,tabId:o=(0,P._w)()}=s;if(!n)return;const r=(0,f.Z1J)(e,n);if(!r)return;const c=await(0,h.t9)("reportPeer",{peer:r,reason:a,description:i});t.showNotification({message:c?(0,w.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:o})})),(0,n.iw)("reportProfilePhoto",(async(e,t,s)=>{const{chatId:n,reason:a,description:i,photo:o,tabId:r=(0,P._w)()}=s;if(!n)return;const c=(0,f.Z1J)(e,n);if(!c||!o)return;const d=await(0,h.t9)("reportProfilePhoto",{peer:c,photo:o,reason:a,description:i});t.showNotification({message:d?(0,w.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:r})})),(0,n.iw)("loadAuthorizations",(async e=>{const t=await(0,h.t9)("fetchAuthorizations");t&&(e=(0,n.Rd)(),e={...e,activeSessions:{byHash:t.authorizations,orderedHashes:Object.keys(t.authorizations),ttlDays:t.ttlDays}},(0,n.R3)(e))})),(0,n.iw)("terminateAuthorization",(async(e,t,s)=>{const{hash:a}=s;if(!await(0,h.t9)("terminateAuthorization",a))return;e=(0,n.Rd)();const{[a]:i,...o}=e.activeSessions.byHash;e={...e,activeSessions:{byHash:o,orderedHashes:e.activeSessions.orderedHashes.filter((e=>e!==a))}},(0,n.R3)(e)})),(0,n.iw)("terminateAllAuthorizations",(async e=>{if(!await(0,h.t9)("terminateAllAuthorizations"))return;const t=(e=(0,n.Rd)()).activeSessions.orderedHashes.find((t=>e.activeSessions.byHash[t].isCurrent));if(!t)return;const s=e.activeSessions.byHash[t];e={...e,activeSessions:{byHash:{[t]:s},orderedHashes:[t]}},(0,n.R3)(e)})),(0,n.iw)("changeSessionSettings",(async(e,t,s)=>{const{hash:a,areCallsEnabled:i,areSecretChatsEnabled:o}=s;await(0,h.t9)("changeSessionSettings",{hash:a,areCallsEnabled:i,areSecretChatsEnabled:o})&&(e=(0,n.Rd)(),e={...e,activeSessions:{...e.activeSessions,byHash:{...e.activeSessions.byHash,[a]:{...e.activeSessions.byHash[a],...void 0!==i?{areCallsEnabled:i}:void 0,...void 0!==o?{areSecretChatsEnabled:o}:void 0}}}},(0,n.R3)(e))})),(0,n.iw)("changeSessionTtl",(async(e,t,s)=>{const{days:a}=s;await(0,h.t9)("changeSessionTtl",{days:a})&&(e=(0,n.Rd)(),e={...e,activeSessions:{...e.activeSessions,ttlDays:a}},(0,n.R3)(e))})),(0,n.iw)("loadWebAuthorizations",(async e=>{const t=await(0,h.t9)("fetchWebAuthorizations");if(!t)return;const{users:s,webAuthorizations:a}=t;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(s,"id")),e={...e,activeWebSessions:{byHash:a,orderedHashes:Object.keys(a)}},(0,n.R3)(e)})),(0,n.iw)("terminateWebAuthorization",(async(e,t,s)=>{const{hash:a}=s;if(!await(0,h.t9)("terminateWebAuthorization",a))return;e=(0,n.Rd)();const{[a]:i,...o}=e.activeWebSessions.byHash;e={...e,activeWebSessions:{byHash:o,orderedHashes:e.activeWebSessions.orderedHashes.filter((e=>e!==a))}},(0,n.R3)(e)})),(0,n.iw)("terminateAllWebAuthorizations",(async e=>{await(0,h.t9)("terminateAllWebAuthorizations")&&(e=(0,n.Rd)(),e={...e,activeWebSessions:{byHash:{},orderedHashes:[]}},(0,n.R3)(e))}));var pe=s(82267);const fe=(0,I.P2)((e=>e()),500,!1);function Ie(e,t,s){for(var n=arguments.length,a=new Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];let[o=(0,P._w)()]=a;const r=(0,f.jUK)(e,o);return(0,b.i)(e,{inlineBots:{...r.inlineBots,byUsername:{...r.inlineBots.byUsername,[t]:s}}},o)}function ve(e,t){for(var s=arguments.length,n=new Array(s>2?s-2:0),a=2;a<s;a++)n[a-2]=arguments[a];let[i=(0,P._w)()]=n;return(0,b.i)(e,{inlineBots:{...(0,f.jUK)(e,i).inlineBots,isLoading:t}},i)}(0,n.iw)("loadFullUser",(async(e,t,s)=>{const{userId:a}=s,i=(0,f.dyD)(e,a);if(!i)return;const{id:o,accessHash:r}=i,c=await(0,h.t9)("fetchFullUser",{id:o,accessHash:r});if(!c?.user)return;e=(0,n.Rd)();const d=(0,f.ccz)(e,a),{user:l,fullInfo:u}=c;(i.avatarHash!==l.avatarHash||d?.profilePhoto?.id!==u?.profilePhoto?.id||d?.fallbackPhoto?.id!==u?.fallbackPhoto?.id||d?.personalPhoto?.id!==u?.personalPhoto?.id)&&i.photos?.length&&t.loadProfilePhotos({profileId:a})})),(0,n.iw)("loadUser",(async(e,t,s)=>{const{userId:a}=s,i=(0,f.dyD)(e,a);if(!i)return;const o=await(0,h.t9)("fetchUsers",{users:[i]});if(!o)return;const{users:r,userStatusesById:c}=o;e=(0,n.Rd)(),e=(0,p.eD)(e,(0,g.ee)(r,"id")),e=(0,p.ps)(e,{...e.users.statusesById,...c}),(0,n.R3)(e)})),(0,n.iw)("loadTopUsers",(async e=>{const{topPeers:{lastRequestedAt:t}}=e;if(t&&!((0,pe.bp)()-t>60))return;const s=await(0,h.t9)("fetchTopUsers");if(!s)return;const{ids:a,users:i}=s;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(i,"id")),e={...e,topPeers:{...e.topPeers,userIds:a,lastRequestedAt:(0,pe.bp)()}},(0,n.R3)(e)})),(0,n.iw)("loadContactList",(async e=>{const t=await(0,h.t9)("fetchContactList");if(!t)return;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(t.users,"id")),e=(0,p.fZ)(e,(0,g.ee)(t.chats,"id")),e=(0,p.zn)(e,t.userStatusesById);const s=e=>e.lastName||e.firstName||"",a=new Intl.Collator("en-US"),i=t.users.sort(((e,t)=>a.compare(s(e),s(t)))).filter((e=>!e.isSelf));e={...e,contactList:{userIds:i.map((e=>e.id))}},(0,n.R3)(e)})),(0,n.iw)("loadCurrentUser",(()=>{(0,h.t9)("fetchCurrentUser")})),(0,n.iw)("loadCommonChats",(async(e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{},{chatId:i}=(0,f.Btg)(e,a)||{},o=i?(0,f.dyD)(e,i):void 0;if(!o||(0,v.cS)(o)||o.commonChats?.isFullyLoaded)return;const r=o.commonChats?.maxId,c=await(0,h.t9)("fetchCommonChats",o.id,o.accessHash,r);if(!c)return;const{chats:d,chatIds:l,isFullyLoaded:u}=c;e=(0,n.Rd)(),d.length&&(e=(0,p.fZ)(e,(0,g.ee)(d,"id"))),e=(0,p.Nq)(e,o.id,{commonChats:{maxId:l.length?l[l.length-1]:"0",ids:(0,g.Tw)((o.commonChats?.ids||[]).concat(l)),isFullyLoaded:u}}),(0,n.R3)(e)})),(0,n.iw)("updateContact",(async(e,t,s)=>{const{userId:a,isMuted:i=!1,firstName:o,lastName:r,shouldSharePhoneNumber:c,tabId:d=(0,P._w)()}=s,l=(0,f.dyD)(e,a);if(!l)return;let u;if(t.updateChatMutedState({chatId:a,isMuted:i}),e=(0,n.Rd)(),e=(0,p.H9)(e,m.wv.InProgress,d),(0,n.R3)(e),!l.isContact&&l.phoneNumber)u=await(0,h.t9)("importContact",{phone:l.phoneNumber,firstName:o,lastName:r});else{const{id:e,accessHash:t}=l;u=await(0,h.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:o,lastName:r,shouldSharePhoneNumber:c})}u&&(t.loadChatSettings({chatId:a}),t.loadUserStories({userId:a}),e=(0,n.Rd)(),e=(0,p.Nq)(e,l.id,{firstName:o,lastName:r}),(0,n.R3)(e)),e=(0,n.Rd)(),e=(0,p.H9)(e,m.wv.Complete,d),e=(0,p.ft)(e,d),(0,n.R3)(e)})),(0,n.iw)("deleteContact",(async(e,t,s)=>{const{userId:n}=s,a=(0,f.dyD)(e,n);if(!a)return;const{id:i,accessHash:o}=a;await(0,h.t9)("deleteContact",{id:i,accessHash:o})})),(0,n.iw)("loadProfilePhotos",(async(e,t,s)=>{const{profileId:a}=s,i=(0,v.YC)(a);let o=i?(0,f.dyD)(e,a):void 0;const r=i?void 0:(0,f.Z1J)(e,a);if(!o&&!r)return;let c=(0,f.ccz)(e,a);if(o&&!c?.profilePhoto){const{id:e,accessHash:t}=o,s=await(0,h.t9)("fetchFullUser",{id:e,accessHash:t});if(!s?.user)return;o=s.user,c=s.fullInfo}const d=await(0,h.t9)("fetchProfilePhotos",o,r);if(!d||!d.photos)return;e=(0,n.Rd)();const l=o||r,{photos:u,users:m}=d;u.sort((e=>e.id===l?.avatarHash?-1:1));const I=c?.fallbackPhoto,w=c?.personalPhoto;I&&u.push(I),w&&u.unshift(w),e=(0,p.Sh)(e,(0,g.ee)(m,"id")),e=i?(0,p.Nq)(e,a,{photos:u}):(0,p.a4)(e,a,{photos:u}),(0,n.R3)(e)})),(0,n.iw)("setUserSearchQuery",((e,t,s)=>{const{query:a,tabId:i=(0,P._w)()}=s;a&&fe((async()=>{const t=await(0,h.t9)("searchChats",{query:a});e=(0,n.Rd)();const s=(0,f.jUK)(e,i).userSearch.query;if(!t||!s||a!==s)return e=(0,p.Q3)(e,!1,i),void(0,n.R3)(e);const{localUsers:o,globalUsers:r}=t;let c,d;o.length&&(e=(0,p.Sh)(e,(0,g.ee)(o,"id")),c=o.map((e=>{let{id:t}=e;return t}))),r.length&&(e=(0,p.Sh)(e,(0,g.ee)(r,"id")),d=r.map((e=>{let{id:t}=e;return t}))),e=(0,p.Q3)(e,!1,i),e=(0,p.Lm)(e,{localUserIds:c,globalUserIds:d},i),(0,n.R3)(e)}))})),(0,n.iw)("importContact",(async(e,t,s)=>{const{phoneNumber:a,firstName:i,lastName:o,tabId:r=(0,P._w)()}=s,c=await(0,h.t9)("importContact",{phone:a,firstName:i,lastName:o});c?(t.openChat({id:c,tabId:r}),e=(0,n.Rd)(),e=(0,p.ft)(e,r),(0,n.R3)(e)):t.showNotification({message:w.Iu("Contacts.PhoneNumber.NotRegistred"),tabId:r})})),(0,n.iw)("reportSpam",((e,t,s)=>{const{chatId:n}=s,a=(0,v.YC)(n)?(0,f.dyD)(e,n):(0,f.Z1J)(e,n);a&&(0,h.t9)("reportSpam",a)})),(0,n.iw)("setEmojiStatus",((e,t,s)=>{const{emojiStatus:n,expires:a}=s;(0,h.t9)("updateEmojiStatus",n,a)})),(0,n.iw)("saveCloseFriends",(async(e,t,s)=>{const{userIds:a}=s;await(0,h.t9)("saveCloseFriends",a)&&((e=(0,n.Rd)()).contactList?.userIds.forEach((t=>{const{isCloseFriend:s}=e.users.byId[t]||{};s&&!a.includes(t)&&(e=(0,p.Nq)(e,t,{isCloseFriend:void 0}))})),a.forEach((t=>{e=(0,p.Nq)(e,t,{isCloseFriend:!0})})),(0,n.R3)(e))}));var we=s(18629);const ye=a.cj||a.wZ;class be{constructor(e,t){var s,n,a;this.features=e,this.onFail=t,s=this,a=void 0,(n=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(n="preOpened"))in s?Object.defineProperty(s,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[n]=a}preOpenIfNeeded(){ye&&(this.preOpened=window.open("about:blank",void 0,this.features),this.preOpened?this.preOpened.blur():this.onFail?.())}open(e){if(this.preOpened)return this.preOpened.location.href=e,this.preOpened.focus(),void(this.preOpened=void 0);if(!ye){const t=window.open(e,void 0,this.features);t?t.focus():this.onFail?.()}}cancelPreOpen(){this.preOpened?.close(),this.preOpened=void 0}}const Pe="https://prizes.gamee.com/",Ze=(0,I.Ds)((e=>e()),500,!1);async function Ce(e,t,s,a){await(0,h.t9)("toggleAttachBot",{bot:t,isWriteAllowed:a,isEnabled:s}),e=(0,n.Rd)(),await Se(e)}async function Se(e,t){const s=await(0,h.t9)("loadAttachBots",{hash:t});s&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(s.users,"id")),e={...e,attachMenu:{hash:s.hash,bots:s.bots}},(0,n.R3)(e))}function Me(e,t,s,a){for(var i=arguments.length,o=new Array(i>4?i-4:0),r=4;r<i;r++)o[r-4]=arguments[r];let[c=(0,P._w)()]=o;if("request"===a.type){e=(0,n.Rd)();const t=(0,f.jUK)(e,c);if(!t.urlAuth)return;const{domain:s,bot:i,shouldRequestWriteAccess:o}=a;return e=(0,b.i)(e,{urlAuth:{...t.urlAuth,request:{domain:s,botId:i.id,shouldRequestWriteAccess:o}}},c),void(0,n.R3)(e)}const d="accepted"===a.type?a.url:s;window.open(d,"_blank","noopener"),t.closeUrlAuthModal({tabId:c})}async function Ee(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u._f,s=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;await(0,h.t9)("sendMessage",{chat:e,replyingTo:n?{replyingTo:n,replyingToTopId:t}:void 0,text:s,sendAs:a})}let Re;async function ke(e,t,s,n,a){let i=arguments.length>5&&void 0!==arguments[5]&&arguments[5];for(var o=arguments.length,r=new Array(o>6?o-6:0),c=6;c<o;c++)r[c-6]=arguments[c];let[d=(0,P._w)()]=r;const{showDialog:l,showNotification:u,openUrl:m,openGame:g}=t;i&&(Re||(Re=new be("popup,width=800,height=600",(()=>{u({message:"Allow browser to open popup window",tabId:d})}))),Re.preOpenIfNeeded());const p=await(0,h.t9)("answerCallbackButton",{chatId:s.id,accessHash:s.accessHash,messageId:n,data:a,isGame:i});if(!p)return;const{message:f,alert:I,url:v}=p;I?l({data:{message:f||"Error"},tabId:d}):f?u({message:f,tabId:d}):v&&(i?v.includes(Pe)?Re.open(v):(Re.cancelPreOpen(),g({url:v,chatId:s.id,messageId:n,tabId:d})):m({url:v,tabId:d}))}function Te(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}async function Ae(e,t){for(var s=arguments.length,a=new Array(s>2?s-2:0),i=2;i<s;i++)a[i-2]=arguments[i];let[o=(0,P._w)()]=a;const r=await(0,h.t9)("getPaymentForm",t);if(!r)return;const{form:c,invoice:d,users:l}=r;return e=(0,n.Rd)(),e=(0,p._7)(e,c,o),e=(0,p.Q$)(e,m.KB.Checkout,o),e=(0,p.Sh)(e,(0,g.ee)(l,"id")),(0,n.R3)(e),d}async function Ne(e,t,s,a){for(var i=arguments.length,o=new Array(i>4?i-4:0),r=4;r<i;r++)o[r-4]=arguments[r];let[c=(0,P._w)()]=o;const d=await(0,h.t9)("validateRequestedInfo",{inputInvoice:t,requestInfo:s,shouldSave:a});if(!d)return;const{id:l,shippingOptions:u}=d;e=(0,n.Rd)(),e=(0,p.vT)(e,l,c),u?(e=(0,p.TM)(e,u,c),e=(0,p.Q$)(e,m.KB.Shipping,c)):e=(0,p.Q$)(e,m.KB.Checkout,c),(0,n.R3)(e)}(0,n.iw)("clickBotInlineButton",((e,t,s)=>{const{messageId:n,button:a,tabId:i=(0,P._w)()}=s;switch(a.type){case"command":t.sendBotCommand({command:a.text,tabId:i});break;case"url":{const{url:e}=a;t.openUrl({url:e,tabId:i});break}case"callback":{const s=(0,f.jrE)(e,i);if(!s)return;ke(e,t,s,n,a.data,void 0,i);break}case"requestPoll":t.openPollModal({isQuiz:a.isQuiz,tabId:i});break;case"requestPhone":{const s=e.currentUserId?(0,f.dyD)(e,e.currentUserId):void 0;if(!s)return;t.showDialog({data:{phoneNumber:s.phoneNumber,firstName:s.firstName||"",lastName:s.lastName||"",userId:s.id},tabId:i});break}case"receipt":{const s=(0,f.jrE)(e,i);if(!s)return;const{receiptMessageId:o}=a;t.getReceipt({receiptMessageId:o,chatId:s.id,messageId:n,tabId:i});break}case"buy":{const s=(0,f.jrE)(e,i);if(!s)return;t.openInvoice({chatId:s.id,messageId:n,tabId:i});break}case"game":{const s=(0,f.jrE)(e,i);if(!s)return;ke(e,t,s,n,void 0,!0,i);break}case"switchBotInline":{const{query:e,isSamePeer:s}=a;t.switchBotInline({query:e,isSamePeer:s,messageId:n,tabId:i});break}case"userProfile":{const{userId:e}=a;t.openChatWithInfo({id:e,tabId:i});break}case"simpleWebView":{const{url:s}=a,{chatId:o}=(0,f.Btg)(e,i)||{};if(!o)return;const r=(0,f.hjO)(e,o,n);if(!r?.senderId)return;const c=(0,we.BS)();t.requestSimpleWebView({url:s,botId:r?.senderId,theme:c,buttonText:a.text,tabId:i});break}case"webView":{const{url:s}=a,o=(0,f.jrE)(e,i);if(!o)return;const r=(0,f.hjO)(e,o.id,n);if(!r)return;const c=r.viaBotId||r.senderId;if(!c)return;const d=(0,we.BS)();t.requestWebView({url:s,botId:c,peerId:o.id,theme:d,buttonText:a.text,tabId:i});break}case"urlAuth":{const{url:s}=a,o=(0,f.jrE)(e,i);if(!o)return;t.requestBotUrlAuth({chatId:o.id,messageId:n,buttonId:a.buttonId,url:s,tabId:i});break}}})),(0,n.iw)("sendBotCommand",((e,t,s)=>{const{command:n,chatId:a,tabId:i=(0,P._w)()}=s,o=a?(0,f.Z1J)(e,a):(0,f.jrE)(e,i),r=(0,f.Btg)(e,i);if(!o||!r)return;const{threadId:c}=r;t.setReplyingToId({messageId:void 0,tabId:i}),t.clearWebPagePreview({tabId:i}),Ee(o,c,n,(0,f.Yyv)(e,o.id,c),(0,f._5C)(e,o.id))})),(0,n.iw)("restartBot",(async(e,t,s)=>{const{chatId:a,tabId:i=(0,P._w)()}=s,{currentUserId:o}=e,r=(0,f.jrE)(e,i),c=o&&(0,f.kBx)(e,a);o&&r&&c&&await(0,h.t9)("unblockContact",c.id,c.accessHash)&&(e=(0,n.Rd)(),e=(0,p.rB)(e,c.id),(0,n.R3)(e),Ee(r,u._f,"/start",void 0,(0,f._5C)(e,a)))})),(0,n.iw)("loadTopInlineBots",(async e=>{const{lastRequestedAt:t}=e.topInlineBots;if(t&&(0,pe.bp)()-t<60)return;const s=await(0,h.t9)("fetchTopInlineBots");if(!s)return;const{ids:a,users:i}=s;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(i,"id")),e={...e,topInlineBots:{...e.topInlineBots,userIds:a,lastRequestedAt:(0,pe.bp)()}},(0,n.R3)(e)})),(0,n.iw)("queryInlineBot",(async(e,t,s)=>{const{chatId:a,username:i,query:o,offset:r,tabId:c=(0,P._w)()}=s;let d=(0,f.jUK)(e,c).inlineBots.byUsername[i];if(!1!==d){if(void 0===d){const{user:t,chat:s}=await(0,h.t9)("fetchInlineBot",{username:i})||{};if(e=(0,n.Rd)(),!t||!s)return e=Ie(e,i,!1,c),void(0,n.R3)(e);e=(0,p.Sh)(e,{[t.id]:t}),e=(0,p.fZ)(e,{[s.id]:s}),d={id:t.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[],cacheTime:0},e=Ie(e,i,d,c),(0,n.R3)(e)}(o!==d.query||d.canLoadMore)&&Ze((()=>{!async function(e,t){let{username:s,inlineBotData:a,chatId:i,query:o,offset:r}=t;for(var c=arguments.length,d=new Array(c>2?c-2:0),l=2;l<c;l++)d[l-2]=arguments[l];let[u=(0,P._w)()]=d;e=(0,n.Rd)();const m=(0,f.dyD)(e,a.id),g=(0,f.Z1J)(e,i);if(!m||!g)return;const p=a.query!==o;e=Ie(e=ve(e,!0,u),s,{...a,query:o,...p&&{offset:void 0,results:[]}},u),(0,n.R3)(e);const I=await(0,h.t9)("fetchInlineBotResults",{bot:m,chat:g,query:o,offset:p?void 0:r});e=(0,n.Rd)();const v=(0,f.jUK)(e,u).inlineBots.byUsername[s];if(e=ve(e,!1,u),!I||!v||o!==v.query)return void(0,n.R3)(e);const w=new Set((v.results||[]).map((e=>e.id))),y=I.results.filter((e=>!w.has(e.id)));e=Ie(e,s,{...v,help:I.help,cacheTime:Date.now()+1e3*I.cacheTime,...y.length&&{isGallery:I.isGallery},...I.switchPm&&{switchPm:I.switchPm},...I.switchWebview&&{switchWebview:I.switchWebview},canLoadMore:I.results.length>0&&Boolean(I.nextOffset),results:""===v.offset||v.offset===I.nextOffset?I.results:(v.results||[]).concat(y),offset:y.length?I.nextOffset:""},u),(0,n.R3)(e)}(e,{username:i,inlineBotData:d,chatId:a,query:o,offset:r},c)}))}})),(0,n.iw)("switchBotInline",((e,t,s)=>{const{query:n,isSamePeer:a,messageId:i,filter:o,tabId:r=(0,P._w)()}=s;let{botId:c}=s;const d=(0,f.jrE)(e,r);if(!d)return;if(!c&&i){const t=(0,f.hjO)(e,d.id,i);if(!t)return;c=t.viaBotId||t.senderId}if(!c)return;const l=(0,f.dyD)(e,c);l&&t.openChatWithDraft({text:`@${l.usernames[0].username} ${n}`,chatId:a?d.id:void 0,filter:o,tabId:r})})),(0,n.iw)("sendInlineBotResult",((e,t,s)=>{const{id:n,queryId:a,isSilent:i,scheduledAt:o,messageList:r,tabId:c=(0,P._w)()}=s;if(!n)return;const{chatId:d,threadId:l}=r,m=(0,f.Z1J)(e,d),g=(0,f.Yyv)(e,d,l),p=g?(0,f.hjO)(e,d,g):void 0,I=m.isForum||l!==u._f?(0,f.qSq)(e,d,l):p?.replyToTopMessageId||p?.replyToMessageId;t.setReplyingToId({messageId:void 0,tabId:c}),t.clearWebPagePreview({tabId:c}),(0,h.t9)("sendInlineBotResult",{chat:m,resultId:n,queryId:a,replyingTo:g||I,replyingToTopId:I,sendAs:(0,f._5C)(e,d),isSilent:i,scheduleDate:o})})),(0,n.iw)("resetInlineBot",((e,t,s)=>{const{username:a,force:i,tabId:o=(0,P._w)()}=s;let r=(0,f.jUK)(e,o).inlineBots.byUsername[a];r&&(!i&&Date.now()<r.cacheTime||(r={id:r.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[],cacheTime:0},e=Ie(e,a,r,o),(0,n.R3)(e)))})),(0,n.iw)("resetAllInlineBots",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n).inlineBots.byUsername;Object.keys(a).forEach((e=>{t.resetInlineBot({username:e,tabId:n})}))})),(0,n.iw)("startBot",(async(e,t,s)=>{const{botId:n,param:a}=s,i=(0,f.dyD)(e,n);if(!i)return;let o=(0,f.ccz)(e,n);o||(o=(await(0,h.t9)("fetchFullUser",{id:i.id,accessHash:i.accessHash}))?.fullInfo),o?.isBlocked&&await(0,h.t9)("unblockContact",i.id,i.accessHash),await(0,h.t9)("startBot",{bot:i,startParam:a})})),(0,n.iw)("requestSimpleWebView",(async(e,t,s)=>{const{url:a,botId:i,theme:o,buttonText:r,tabId:c=(0,P._w)()}=s,d=(0,f.dyD)(e,i);if(!d)return;if(!(0,f.LM9)(e,i))return e=(0,b.i)(e,{botTrustRequest:{botId:i,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:s}}},c),void(0,n.R3)(e);const l=await(0,h.t9)("requestSimpleWebView",{url:a,bot:d,theme:o});l&&(e=(0,n.Rd)(),e=(0,b.i)(e,{webApp:{url:l,botId:i,buttonText:r}},c),(0,n.R3)(e))})),(0,n.iw)("requestWebView",(async(e,t,s)=>{const{url:a,botId:i,peerId:o,theme:r,isSilent:c,buttonText:d,isFromBotMenu:l,startParam:u,tabId:m=(0,P._w)()}=s,g=(0,f.dyD)(e,i);if(!g)return;const p=(0,f.Z1J)(e,o);if(!p)return;if(!(0,f.LM9)(e,i))return e=(0,b.i)(e,{botTrustRequest:{botId:i,type:"webApp",onConfirm:{action:"requestWebView",payload:s}}},m),void(0,n.R3)(e);const I=(0,f.Btg)(e,m);if(!I)return;const{chatId:v,threadId:w}=I,y=v&&(0,f.Yyv)(e,v,w),Z=(0,f._5C)(e,v),C=await(0,h.t9)("requestWebView",{url:a,bot:g,peer:p,theme:r,isSilent:c,replyToMessageId:y||void 0,threadId:w,isFromBotMenu:l,startParam:u,sendAs:Z});if(!C)return;const{url:S,queryId:M}=C;e=(0,n.Rd)(),e=(0,b.i)(e,{webApp:{url:S,botId:i,queryId:M,replyToMessageId:y||void 0,threadId:w,buttonText:d}},m),(0,n.R3)(e)})),(0,n.iw)("requestAppWebView",(async(e,t,s)=>{const{botId:a,appName:i,startApp:o,theme:r,isWriteAllowed:c,tabId:d=(0,P._w)()}=s,l=(0,f.dyD)(e,a);if(!l)return;const u=await(0,h.t9)("fetchBotApp",{bot:l,appName:i});if(e=(0,n.Rd)(),!u)return void t.showNotification({message:(0,w.Iu)("lng_username_app_not_found"),tabId:d});if(u.isInactive&&!(0,f.LM9)(e,a))return e=(0,b.i)(e,{botTrustRequest:{botId:a,shouldRequestWriteAccess:u.shouldRequestWriteAccess,type:"botApp",onConfirm:{action:"requestAppWebView",payload:s}}},d),void(0,n.R3)(e);const m=(0,f.jrE)(e,d),g=await(0,h.t9)("requestAppWebView",{peer:m||l,app:u,startParam:o,isWriteAllowed:c,theme:r});e=(0,n.Rd)(),g&&(e=(0,b.i)(e,{webApp:{url:g,botId:a,buttonText:""}},d),(0,n.R3)(e))})),(0,n.iw)("prolongWebView",(async(e,t,s)=>{const{botId:n,peerId:a,isSilent:i,replyToMessageId:o,queryId:r,threadId:c,tabId:d=(0,P._w)()}=s,l=(0,f.dyD)(e,n);if(!l)return;const u=(0,f.Z1J)(e,a);if(!u)return;const m=(0,f._5C)(e,a);await(0,h.t9)("prolongWebView",{bot:l,peer:u,isSilent:i,replyToMessageId:o,threadId:c,queryId:r,sendAs:m})||t.closeWebApp({tabId:d})})),(0,n.iw)("sendWebViewData",((e,t,s)=>{const{bot:n,data:a,buttonText:i}=s;(0,h.t9)("sendWebViewData",{bot:n,data:a,buttonText:i})})),(0,n.iw)("closeWebApp",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{webApp:void 0},n)})),(0,n.iw)("setWebAppPaymentSlug",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s,a=(0,f.jUK)(e,n);if(a.webApp?.url)return(0,b.i)(e,{webApp:{...a.webApp,slug:s.slug}},n)})),(0,n.iw)("cancelBotTrustRequest",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{botTrustRequest:void 0},n)})),(0,n.iw)("markBotTrusted",((e,t,s)=>{const{botId:a,isWriteAllowed:i,tabId:o=(0,P._w)()}=s,{trustedBotIds:r}=e,c=new Set(r);c.add(a),e={...e,trustedBotIds:Array.from(c)};const d=(0,f.jUK)(e,o);if(d.botTrustRequest?.onConfirm){const{action:e,payload:s}=d.botTrustRequest.onConfirm;t[e]({...s,isWriteAllowed:i})}e=(0,b.i)(e,{botTrustRequest:void 0},o),(0,n.R3)(e)})),(0,n.iw)("loadAttachBots",(async(e,t,s)=>{const{hash:n}=s||{};await Se(e,n)})),(0,n.iw)("toggleAttachBot",(async(e,t,s)=>{const{botId:n,isWriteAllowed:a,isEnabled:i}=s,o=(0,f.dyD)(e,n);o&&await Ce(e,o,i,a)})),(0,n.iw)("callAttachBot",((e,t,s)=>{const{chatId:n,bot:a,url:i,startParam:o,threadId:r,tabId:c=(0,P._w)()}=s,d=!a;if(!d&&!e.attachMenu.bots[a.id])return(0,b.i)(e,{requestedAttachBotInstall:{bot:a,onConfirm:{action:"callAttachBot",payload:s}}},c);const l=(0,we.BS)();t.openChat({id:n,threadId:r,tabId:c}),t.requestWebView({url:i,peerId:n,botId:d?n:a.id,theme:l,buttonText:"",isFromBotMenu:d,startParam:o,tabId:c})})),(0,n.iw)("confirmAttachBotInstall",(async(e,t,s)=>{const{isWriteAllowed:a,tabId:i=(0,P._w)()}=s,{requestedAttachBotInstall:o}=(0,f.jUK)(e,i),{bot:r,onConfirm:c}=o;e=(0,b.i)(e,{requestedAttachBotInstall:void 0},i),(0,n.R3)(e);const d=(0,f.dyD)(e,r.id);if(d&&(await Ce(e,d,!0,a),c)){const{action:e,payload:s}=c;t[e](s)}})),(0,n.iw)("cancelAttachBotInstall",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{requestedAttachBotInstall:void 0},n)})),(0,n.iw)("requestAttachBotInChat",((e,t,s)=>{const{bot:a,filter:i,startParam:o,tabId:r=(0,P._w)()}=s,c=(0,f.Btg)(e,r)?.chatId,d=a.peerTypes.filter((e=>"self"!==e&&i.includes(e)));d.length?(e=(0,b.i)(e,{requestedAttachBotInChat:{bot:a,filter:d,startParam:o}},r),(0,n.R3)(e)):t.callAttachBot({chatId:c||a.id,bot:a,startParam:o,tabId:r})})),(0,n.iw)("cancelAttachBotInChat",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{requestedAttachBotInChat:void 0},n)})),(0,n.iw)("requestBotUrlAuth",(async(e,t,s)=>{const{chatId:a,buttonId:i,messageId:o,url:r,tabId:c=(0,P._w)()}=s,d=(0,f.Z1J)(e,a);if(!d)return;const l=await(0,h.t9)("requestBotUrlAuth",{chat:d,buttonId:i,messageId:o});l&&(e=(0,n.Rd)(),e=(0,b.i)(e,{urlAuth:{url:r,button:{buttonId:i,messageId:o,chatId:d.id}}},c),(0,n.R3)(e),Me(e,t,r,l,c))})),(0,n.iw)("acceptBotUrlAuth",(async(e,t,s)=>{const{isWriteAllowed:a,tabId:i=(0,P._w)()}=s,o=(0,f.jUK)(e,i);if(!o.urlAuth?.button)return;const{button:r,url:c}=o.urlAuth,{chatId:d,messageId:l,buttonId:u}=r,m=(0,f.Z1J)(e,d);if(!m)return;const g=await(0,h.t9)("acceptBotUrlAuth",{chat:m,messageId:l,buttonId:u,isWriteAllowed:a});g&&Me(e=(0,n.Rd)(),t,c,g,i)})),(0,n.iw)("requestLinkUrlAuth",(async(e,t,s)=>{const{url:a,tabId:i=(0,P._w)()}=s,o=await(0,h.t9)("requestLinkUrlAuth",{url:a});o&&(e=(0,n.Rd)(),e=(0,b.i)(e,{urlAuth:{url:a}},i),(0,n.R3)(e),Me(e,t,a,o,i))})),(0,n.iw)("acceptLinkUrlAuth",(async(e,t,s)=>{const{isWriteAllowed:a,tabId:i=(0,P._w)()}=s,o=(0,f.jUK)(e,i);if(!o.urlAuth?.url)return;const{url:r}=o.urlAuth,c=await(0,h.t9)("acceptLinkUrlAuth",{url:r,isWriteAllowed:a});c&&Me(e=(0,n.Rd)(),t,r,c,i)})),(0,n.iw)("closeUrlAuthModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{urlAuth:void 0},n)})),s(55282),(0,n.iw)("loadPasswordInfo",(async e=>{const t=await(0,h.t9)("getPasswordInfo");t&&(e=(0,n.Rd)(),e=(0,p.BI)(e,{hasPassword:t.hasPassword}),e=(0,p.IE)(e,{hint:t.hint}),(0,n.R3)(e))})),(0,n.iw)("checkPassword",(async(e,t,s)=>{const{currentPassword:a,onSuccess:i}=s;e=(0,p.IE)(e,{isLoading:!0,error:void 0}),(0,n.R3)(e);const o=await(0,h.t9)("checkPassword",a);e=(0,n.Rd)(),e=(0,p.IE)(e,{isLoading:!1}),(0,n.R3)(e),o&&i()})),(0,n.iw)("clearPassword",(async(e,t,s)=>{const{currentPassword:a,onSuccess:i}=s;e=(0,p.IE)(e,{isLoading:!0,error:void 0}),(0,n.R3)(e);const o=await(0,h.t9)("clearPassword",a);e=(0,n.Rd)(),e=(0,p.IE)(e,{isLoading:!1}),(0,n.R3)(e),o&&i()})),(0,n.iw)("updatePassword",(async(e,t,s)=>{const{currentPassword:a,password:i,hint:o,email:r,onSuccess:c}=s;e=(0,p.IE)(e,{isLoading:!0,error:void 0}),(0,n.R3)(e);const d=await(0,h.t9)("updatePassword",a,i,o,r);e=(0,n.Rd)(),e=(0,p.IE)(e,{isLoading:!1}),(0,n.R3)(e),d&&c()})),(0,n.iw)("updateRecoveryEmail",(async(e,t,s)=>{const{currentPassword:a,email:i,onSuccess:o}=s;e=(0,p.IE)(e,{isLoading:!0,error:void 0}),(0,n.R3)(e);const r=await(0,h.t9)("updateRecoveryEmail",a,i);e=(0,n.Rd)(),e=(0,p.IE)(e,{isLoading:!1,waitingEmailCodeLength:void 0}),(0,n.R3)(e),r&&o()})),(0,n.iw)("provideTwoFaEmailCode",((e,t,s)=>{const{code:n}=s;(0,h.t9)("provideRecoveryEmailCode",n)})),(0,n.iw)("clearTwoFaError",(e=>(0,p.IE)(e,{error:void 0}))),(0,n.iw)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:n,saveInfo:a,tabId:i=(0,P._w)()}=s,o=(0,f.kbX)(e,i);if(o)if("slug"in o)Ne(e,o,n,a,i);else{const t=(0,f.Z1J)(e,o.chatId);if(!t)return;Ne(e,{chat:t,messageId:o.messageId},n,a,i)}})),(0,n.iw)("openInvoice",(async(e,t,s)=>{const{tabId:a=(0,P._w)()}=s;let i;if("slug"in s)i=await Ae(e,{slug:s.slug},a);else{const t=(0,f.Z1J)(e,s.chatId);if(!t)return;i=await Ae(e,{chat:t,messageId:s.messageId},a)}i&&(e=(0,n.Rd)(),e=(0,p.bs)(e,i,a),e=(0,b.i)(e,{payment:{...(0,f.jUK)(e,a).payment,inputInvoice:s,isPaymentModalOpen:!0,status:"cancelled",isExtendedMedia:s.isExtendedMedia}},a),(0,n.R3)(e))})),(0,n.iw)("getReceipt",(async(e,t,s)=>{const{receiptMessageId:a,chatId:i,messageId:o,tabId:r=(0,P._w)()}=s,c=i&&(0,f.Z1J)(e,i);if(!o||!a||!c)return;const d=await(0,h.t9)("getReceipt",c,a);if(!d)return;e=(0,n.Rd)();const l=(0,f.hjO)(e,c.id,o);e=(0,p.Sh)(e,(0,g.ee)(d.users,"id")),e=(0,p.Dq)(e,d.receipt,l,r),(0,n.R3)(e)})),(0,n.iw)("clearPaymentError",((e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{};e=(0,b.i)(e,{payment:{...(0,f.jUK)(e,a).payment,error:void 0}},a),(0,n.R3)(e)})),(0,n.iw)("clearReceipt",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{payment:{...(0,f.jUK)(e,n).payment,receipt:void 0}},n)})),(0,n.iw)("sendCredentialsInfo",((e,t,s)=>{const{credentials:a,tabId:o=(0,P._w)()}=s,{nativeProvider:r}=(0,f.jUK)(e,o).payment,{data:c}=a;if("stripe"===r){const t=(0,f.$$M)(e,o);if(!t)return;!async function(e,t,s){for(var a=arguments.length,i=new Array(a>3?a-3:0),o=3;o<a;o++)i[o-3]=arguments[o];let[r=(0,P._w)()]=i;const c=Te({"card[number]":t.cardNumber,"card[exp_month]":t.expiryMonth,"card[exp_year]":t.expiryYear,"card[cvc]":t.cvv,"card[address_zip]":t.zip,"card[address_country]":t.country}),d=await fetch(`https://api.stripe.com/v1/tokens${c}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${s}`}}),l=await d.json();if(l.error){const t=(0,v.Ow)(l.error);return e=(0,n.Rd)(),e=(0,b.i)(e,{payment:{...(0,f.jUK)(e,r).payment,status:"failed",error:{...t}}},r),void(0,n.R3)(e)}e=(0,n.Rd)(),e=(0,p.QH)(e,{type:l.type,id:l.id},r),e=(0,p.Q$)(e,m.KB.Checkout,r),(0,n.R3)(e)}(e,c,t,o)}else if("smartglocal"===r){const t=(0,f.EBU)(e,o);if(!t)return;!async function(e,t,s){for(var a=arguments.length,o=new Array(a>3?a-3:0),r=3;r<a;r++)o[r-3]=arguments[r];let[c=(0,P._w)()]=o;const d={card:{number:t.cardNumber.replace(/\D+/g,""),expiration_month:t.expiryMonth,expiration_year:t.expiryYear,security_code:t.cvv.replace(/\D+/g,"")}},l=i.eAU?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",u=await fetch(l,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":s},body:JSON.stringify(d)}),h=await u.json();if("ok"!==h.status){const t={description:"payment error"};return e=(0,n.Rd)(),e=(0,b.i)(e,{payment:{...(0,f.jUK)(e,c).payment,status:"failed",error:{...t}}},c),void(0,n.R3)(e)}e=(0,n.Rd)(),e=(0,p.QD)(e,{type:"card",token:h.data.token},c),e=(0,p.Q$)(e,m.KB.Checkout,c),(0,n.R3)(e)}(e,c,t,o)}})),(0,n.iw)("sendPaymentForm",(async(e,t,s)=>{const{shippingOptionId:a,saveCredentials:i,savedCredentialId:o,tipAmount:r,tabId:c=(0,P._w)()}=s,d=(0,f.kbX)(e,c),l=(0,f.ehD)(e,c),u=(0,f.sp9)(e,c),{nativeProvider:m,temporaryPassword:g}=(0,f.jUK)(e,c).payment,I="stripe"===m?(0,f.$$M)(e,c):(0,f.EBU)(e,c);if(!(d&&I&&l&&m))return;let v;if("slug"in d)v={slug:d.slug};else{const t=(0,f.Z1J)(e,d.chatId);if(!t)return;v={chat:t,messageId:d.messageId}}e=(0,p.cQ)(e,{status:"pending"},c),(0,n.R3)(e);const w={save:i,data:"stripe"===m?(0,f.i31)(e,c):(0,f.Jg1)(e,c)};await(0,h.t9)("sendPaymentForm",{inputInvoice:v,formId:l,credentials:w,requestedInfoId:u,shippingOptionId:a,savedCredentialId:o,temporaryPassword:g?.value,tipAmount:r})&&(e=(0,n.Rd)(),e=(0,p.cQ)(e,{status:"paid"},c),e=(0,p.WY)(e,c),(0,n.R3)(e))})),(0,n.iw)("setPaymentStep",((e,t,s)=>{const{step:n,tabId:a=(0,P._w)()}=s;return(0,p.Q$)(e,null!=n?n:m.KB.Checkout,a)})),(0,n.iw)("closePremiumModal",((e,t,s)=>{const{isClosed:n,tabId:a=(0,P._w)()}=s||{},i=(0,f.jUK)(e,a);if(i.premiumModal)return(0,b.i)(e,{premiumModal:{...i.premiumModal,...n&&{isOpen:!1},isClosing:!n}},a)})),(0,n.iw)("openPremiumModal",(async(e,t,s)=>{const{initialSection:a,fromUserId:i,isSuccess:o,isGift:r,monthsAmount:c,toUserId:d,tabId:l=(0,P._w)()}=s||{};t.loadPremiumStickers();const u=await(0,h.t9)("fetchPremiumPromo");u&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(u.users,"id")),e=(0,b.i)(e,{premiumModal:{promo:u.promo,initialSection:a,isOpen:!0,fromUserId:i,toUserId:d,isGift:r,monthsAmount:c,isSuccess:o}},l),(0,n.R3)(e))})),(0,n.iw)("openGiftPremiumModal",(async(e,t,s)=>{const{forUserId:a,tabId:i=(0,P._w)()}=s||{},o=await(0,h.t9)("fetchPremiumPromo");if(!o)return;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(o.users,"id"));const r=o.promo.options.find((e=>1===e.months));e=(0,b.i)(e,{giftPremiumModal:{isOpen:!0,forUserId:a,monthlyCurrency:r.currency,monthlyAmount:r.amount}},i),(0,n.R3)(e)})),(0,n.iw)("closeGiftPremiumModal",((e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{};e=(0,b.i)(e,{giftPremiumModal:{isOpen:!1}},a),(0,n.R3)(e)})),(0,n.iw)("validatePaymentPassword",(async(e,t,s)=>{const{password:a,tabId:i=(0,P._w)()}=s,o=await(0,h.t9)("fetchTemporaryPaymentPassword",a);e=(0,n.Rd)(),e=o?"error"in o?(0,p.cQ)(e,{error:{message:o.error,field:"password"}},i):(0,p.cQ)(e,{temporaryPassword:o,step:m.KB.Checkout},i):(0,p.cQ)(e,{error:{message:"Unknown Error",field:"password"}},i),(0,n.R3)(e)}));var xe=s(40647);let Be=0;(0,n.iw)("loadAvailableReactions",(async e=>{const t=await(0,h.t9)("getAvailableReactions");t&&(t.forEach((e=>{e.aroundAnimation&&xe.he(`sticker${e.aroundAnimation.id}`,u.IU.BlobUrl),e.centerIcon&&xe.he(`sticker${e.centerIcon.id}`,u.IU.BlobUrl),e.appearAnimation&&xe.he(`sticker${e.appearAnimation.id}`,u.IU.BlobUrl),e.selectAnimation&&xe.he((0,v.ym)(e.selectAnimation),u.IU.BlobUrl)})),e=(0,n.Rd)(),e={...e,availableReactions:t},(0,n.R3)(e))})),(0,n.iw)("interactWithAnimatedEmoji",((e,t,s)=>{const{emoji:n,x:a,y:i,startSize:o,isReversed:r,tabId:c=(0,P._w)()}=s,d={id:Be++,animatedEffect:n,x:U(e,a)+40*Math.random()-20,y:i+40*Math.random()-20,startSize:o,isReversed:r};return(0,b.i)(e,{activeEmojiInteractions:[...(0,f.jUK)(e,c).activeEmojiInteractions||[],d]},c)})),(0,n.iw)("sendEmojiInteraction",((e,t,s)=>{const{messageId:n,chatId:a,emoji:i,interactions:o}=s;if("connectionStateReady"!==e.connectionState)return;const r=(0,f.Z1J)(e,a);r&&i&&a!==e.currentUserId&&(0,h.t9)("sendEmojiInteraction",{chat:r,messageId:n,emoticon:i,timestamps:o})})),(0,n.iw)("sendDefaultReaction",((e,t,s)=>{const{chatId:n,messageId:a,tabId:i=(0,P._w)()}=s,o=(0,f.q6x)(e,n),r=(0,f.hjO)(e,n,a);o&&r&&!(0,v.CI)(r)&&t.toggleReaction({chatId:n,messageId:a,reaction:o,tabId:i})})),(0,n.iw)("toggleReaction",(async(e,t,s)=>{const{chatId:a,reaction:i,shouldAddToRecent:o,tabId:r=(0,P._w)()}=s;let{messageId:c}=s;const d=(0,f.Z1J)(e,a);let l=(0,f.hjO)(e,a,c);if(!d||!l)return;const u=Boolean(l.groupedId)&&!l.isInAlbum,m=u?(0,f.xHX)(e,a,l.groupedId)[0]:void 0;l=u&&(0,f.hjO)(e,a,m)||l,c=l?.id||c;const p=(0,v.UZ)(l),I=p.some((e=>(0,v.Hl)(e,i))),w=I?p.filter((e=>!(0,v.Hl)(e,i))):[...p,i],y=(0,f.oC7)(e),Z=w.slice(-y),C=(0,f.jUK)(e,r);if((0,f.$Yd)(e,"reactionEffects")){const t=I?(0,g.CE)(C.activeReactions,[c]):{...C.activeReactions,[c]:[...C.activeReactions[c]||[],{messageId:c,reaction:i}]};e=(0,b.i)(e,{activeReactions:t},r)}e=L(e,l,Z),(0,n.R3)(e);try{await(0,h.t9)("sendReaction",{chat:d,messageId:c,reactions:Z,shouldAddToRecent:o})}catch(t){e=L(e=(0,n.Rd)(),l,p),(0,n.R3)(e)}})),(0,n.iw)("stopActiveReaction",((e,t,s)=>{const{messageId:n,reaction:a,tabId:i=(0,P._w)()}=s,o=(0,f.jUK)(e,i);if(!o.activeReactions[n]?.some((e=>(0,v.Hl)(e.reaction,a))))return e;const r=o.activeReactions[n].filter((e=>!(0,v.Hl)(e.reaction,a))),c=r.length?{...o.activeReactions,[n]:r}:(0,g.CE)(o.activeReactions,[n]);return(0,b.i)(e,{activeReactions:c},i)})),(0,n.iw)("setDefaultReaction",(async(e,t,s)=>{const{reaction:a}=s;await(0,h.t9)("setDefaultReaction",{reaction:a})&&((e=(0,n.Rd)()).config?(e={...e,config:{...e.config,defaultReaction:a}},(0,n.R3)(e)):t.loadConfig())})),(0,n.iw)("stopActiveEmojiInteraction",((e,t,s)=>{const{id:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{activeEmojiInteractions:(0,f.jUK)(e,a).activeEmojiInteractions?.filter((e=>e.id!==n))},a)})),(0,n.iw)("loadReactors",(async(e,t,s)=>{const{chatId:a,messageId:i,reaction:o}=s,r=(0,f.Z1J)(e,a),c=(0,f.hjO)(e,a,i);if(!r||!c)return;const d=c.reactors?.nextOffset,l=await(0,h.t9)("fetchMessageReactionsList",{reaction:o,chat:r,messageId:i,offset:d});l&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(l.users,"id")),e=(0,p.fZ)(e,(0,g.ee)(l.chats,"id")),e=(0,p.cY)(e,a,i,{reactors:l}),(0,n.R3)(e))})),(0,n.iw)("loadMessageReactions",((e,t,s)=>{const{ids:n,chatId:a}=s,i=(0,f.Z1J)(e,a);i&&"connectionStateReady"===e.connectionState&&(0,h.t9)("fetchMessageReactions",{ids:n,chat:i})})),(0,n.iw)("sendWatchingEmojiInteraction",((e,t,s)=>{const{chatId:n,emoticon:a,x:i,y:o,startSize:r,isReversed:c,id:d,tabId:l=(0,P._w)()}=s,u=(0,f.Z1J)(e,n),m=(0,f.jUK)(e,l);if(u&&m.activeEmojiInteractions?.some((e=>e.id===d))&&n!==e.currentUserId)return"connectionStateReady"===e.connectionState&&(0,h.t9)("sendWatchingEmojiInteraction",{chat:u,emoticon:a}),(0,b.i)(e,{activeEmojiInteractions:m.activeEmojiInteractions.map((t=>t.id===d?{...t,x:U(e,i),y:o,startSize:r,isReversed:c}:t))},l)})),(0,n.iw)("fetchUnreadReactions",(async(e,t,s)=>{const{chatId:a,offsetId:i}=s,o=(0,f.Z1J)(e,a);if(!o)return;const r=await(0,h.t9)("fetchUnreadReactions",{chat:o,offsetId:i,addOffset:i?-1:void 0});if(!r||!r.messages.length)return e=O(e=(0,n.Rd)(),a,{unreadReactionsCount:0}),void(0,n.R3)(e);const{messages:c,chats:d,users:l}=r,u=(0,g.ee)(c,"id"),m=Object.keys(u).map(Number);e=(0,n.Rd)(),e=(0,p.c_)(e,o.id,u),e=(0,p.Sh)(e,(0,g.ee)(l,"id")),e=O(e=(0,p.fZ)(e,(0,g.ee)(d,"id")),a,{unreadReactions:[...o.unreadReactions||[],...m]}),(0,n.R3)(e)})),(0,n.iw)("animateUnreadReaction",((e,t,s)=>{const{messageIds:a,tabId:i=(0,P._w)()}=s,o=(0,f.jrE)(e,i);if(o){if(o.unreadReactionsCount){const s=o.unreadReactionsCount-a.length,i=(o.unreadReactions||[]).filter((e=>!a.includes(e)));e=O(e,o.id,{unreadReactions:i}),(0,n.R3)(e),!i.length&&s&&t.fetchUnreadReactions({chatId:o.id,offsetId:Math.min(...a)})}if(t.markMessagesRead({messageIds:a,tabId:i}),(0,f.$Yd)(e,"reactionEffects"))return e=(0,n.Rd)(),(0,b.i)(e,{activeReactions:{...(0,f.jUK)(e,i).activeReactions,...Object.fromEntries(a.map((t=>{const s=(0,f.hjO)(e,o.id,t);if(!s)return;const n=s.reactions?.recentReactions?.filter((e=>{let{isUnread:t}=e;return t}));if(!n)return;const a=n.map((e=>e.reaction));return[t,a.map((e=>({messageId:t,reaction:e})))]})).filter(Boolean))}},i)}})),(0,n.iw)("focusNextReaction",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jrE)(e,n);a?.unreadReactions&&t.focusMessage({chatId:a.id,messageId:a.unreadReactions[0],tabId:n})})),(0,n.iw)("readAllReactions",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jrE)(e,n);if(a)return(0,h.t9)("readAllReactions",{chat:a}),O(e,a.id,{unreadReactionsCount:void 0,unreadReactions:void 0})})),(0,n.iw)("loadTopReactions",(async e=>{const t=await(0,h.t9)("fetchTopReactions",{});t&&(e=(0,n.Rd)(),e={...e,topReactions:t.reactions},(0,n.R3)(e))})),(0,n.iw)("loadRecentReactions",(async e=>{const t=await(0,h.t9)("fetchRecentReactions",{});t&&(e=(0,n.Rd)(),e={...e,recentReactions:t.reactions},(0,n.R3)(e))})),(0,n.iw)("clearRecentReactions",(async e=>{await(0,h.t9)("clearRecentReactions")&&(e=(0,n.Rd)(),e={...e,recentReactions:[]},(0,n.R3)(e))})),(0,n.iw)("loadStatistics",(async(e,t,s)=>{const{chatId:a,isGroup:i,tabId:o=(0,P._w)()}=s,r=(0,f.Z1J)(e,a),c=(0,f.x67)(e,a);if(!r||!c)return;const d=await(0,h.t9)(i?"fetchGroupStatistics":"fetchChannelStatistics",{chat:r,dcId:c.statisticsDcId});if(!d)return;e=(0,n.Rd)();const{stats:l,users:u}=d;if(e=(0,p.Sh)(e,(0,g.ee)(u,"id")),"recentTopMessages"in l&&l.recentTopMessages.length){const t=(0,f.Zwk)(e,a);l.recentTopMessages=l.recentTopMessages.map((e=>({...e,...t[e.msgId]})))}e=(0,p.ze)(e,a,l,o),(0,n.R3)(e)})),(0,n.iw)("loadMessageStatistics",(async(e,t,s)=>{const{chatId:a,messageId:i,tabId:o=(0,P._w)()}=s,r=(0,f.Z1J)(e,a),c=(0,f.x67)(e,a);if(!r||!c)return;const d=c.statisticsDcId;let l=await(0,h.t9)("fetchMessageStatistics",{chat:r,messageId:i,dcId:d});l||(l={}),e=(0,n.Rd)();const{views:u,forwards:m}=(0,f.Zwk)(e,a)[i];l.views=u,l.forwards=m;const g=await(0,h.t9)("fetchMessagePublicForwards",{chat:r,messageId:i,dcId:d});l.publicForwards=g?.length,l.publicForwardsData=g,e=(0,n.Rd)(),e=(0,p.kM)(e,l,o),(0,n.R3)(e)})),(0,n.iw)("loadStatisticsAsyncGraph",(async(e,t,s)=>{const{chatId:a,token:i,name:o,isPercentage:r,tabId:c=(0,P._w)()}=s,d=(0,f.x67)(e,a);if(!d)return;const l=d.statisticsDcId,u=await(0,h.t9)("fetchStatisticsAsyncGraph",{token:i,dcId:l,isPercentage:r});u&&(e=(0,n.Rd)(),e=(0,p.yC)(e,a,o,u,c),(0,n.R3)(e))})),(0,n.iw)("loadAllStories",(async e=>{let t=0;for(;e.stories.hasNext;){if(t++>=100)return void(i.eMD&&console.error("`actions/loadAllStories`: Infinite loop detected"));e=(0,n.Rd)();const{stateHash:s,hasNext:a}=e.stories;if(s&&!a)return;const o=await(0,h.t9)("fetchAllStories",{isFirstRequest:!s,stateHash:s});if(!o)return;(e=(0,n.Rd)()).stories.stateHash=o.state,"userStories"in o&&(e=(0,p.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,p.p1)(e,o.userStories),(e=(0,p.GC)(e,o.userStories)).stories.hasNext=o.hasMore),(0,n.R3)(e)}})),(0,n.iw)("loadAllHiddenStories",(async e=>{let t=0;for(;e.stories.hasNextInArchive;){if(t++>=100)return void(i.eMD&&console.error("`actions/loadAllHiddenStories`: Infinite loop detected"));e=(0,n.Rd)();const{archiveStateHash:s,hasNextInArchive:a}=e.stories;if(s&&!a)return;const o=await(0,h.t9)("fetchAllStories",{isFirstRequest:!s,stateHash:s,isHidden:!0});if(!o)return;(e=(0,n.Rd)()).stories.archiveStateHash=o.state,"userStories"in o&&(e=(0,p.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,p.p1)(e,o.userStories),(e=(0,p.GC)(e,o.userStories)).stories.hasNextInArchive=o.hasMore),(0,n.R3)(e)}})),(0,n.iw)("loadUserSkippedStories",(async(e,t,s)=>{const{userId:a}=s,i=(0,f.dyD)(e,a),o=(0,f.GZu)(e,a);if(!i||!o)return;const r=Object.values(o.byId).reduce(((e,t)=>("content"in t||e.push(t.id),e)),[]);if(0===r.length)return;const c=await(0,h.t9)("fetchUserStoriesByIds",{user:i,ids:r});c&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(c.users,"id")),e=(0,p.Eq)(e,a,c.stories),(0,n.R3)(e))})),(0,n.iw)("viewStory",(async(e,t,s)=>{const{userId:a,storyId:i,tabId:o=(0,P._w)()}=s,r=(0,f.dyD)(e,a),c=(0,f.o9F)(e,a,i);if(!r||!c||!("content"in c))return;e=(0,p.gK)(e,a,i,o),(0,n.R3)(e);const d=(0,pe.bp)();c.expireDate<d&&c.isPinned&&(0,h.t9)("viewStory",{user:r,storyId:i}),(e.stories.byUserId[a].lastReadId||0)<c.id&&await(0,h.t9)("markStoryRead",{user:r,storyId:i})&&(e=(0,n.Rd)(),e=(0,p.kO)(e,a,i),(0,n.R3)(e))})),(0,n.iw)("deleteStory",(async(e,t,s)=>{const{storyId:a}=s;await(0,h.t9)("deleteStory",{storyId:a})&&(e=(0,n.Rd)(),e=(0,p.mv)(e,e.currentUserId,a),(0,n.R3)(e))})),(0,n.iw)("toggleStoryPinned",(async(e,t,s)=>{const{storyId:a,isPinned:i}=s,o=(0,f.o9F)(e,e.currentUserId,a),r=o&&"content"in o?o.isPinned:void 0;e=(0,p.xg)(e,e.currentUserId,{id:a,isPinned:i}),e=(0,p.zK)(e,e.currentUserId,a,i),(0,n.R3)(e),await(0,h.t9)("toggleStoryPinned",{storyId:a,isPinned:i})||(e=(0,n.Rd)(),e=(0,p.xg)(e,e.currentUserId,{id:a,isPinned:r}),e=(0,p.zK)(e,e.currentUserId,a,r),(0,n.R3)(e))})),(0,n.iw)("loadUserStories",(async(e,t,s)=>{const{userId:a}=s,i=(0,f.dyD)(e,a);if(!i)return;const o=await(0,h.t9)("fetchUserStories",{user:i});o&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,p.Eq)(e,a,o.stories),o.lastReadStoryId&&(e=(0,p.kO)(e,a,o.lastReadStoryId)),(0,n.R3)(e))})),(0,n.iw)("loadUserPinnedStories",(async(e,t,s)=>{const{userId:a,offsetId:i}=s,o=(0,f.dyD)(e,a);if(!o)return;const r=await(0,h.t9)("fetchUserPinnedStories",{user:o,offsetId:i});r&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(r.users,"id")),e=(0,p.Eq)(e,a,r.stories),(0,n.R3)(e))})),(0,n.iw)("loadStoriesArchive",(async(e,t,s)=>{const{offsetId:a}=s,i=e.currentUserId,o=await(0,h.t9)("fetchStoriesArchive",{currentUserId:i,offsetId:a});o&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,p.Eq)(e,i,o.stories,!0),(0,n.R3)(e))})),(0,n.iw)("loadUserStoriesByIds",(async(e,t,s)=>{const{userId:a,storyIds:i}=s,o=(0,f.dyD)(e,a);if(!o)return;const r=await(0,h.t9)("fetchUserStoriesByIds",{user:o,ids:i});r&&(e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(r.users,"id")),e=(0,p.Eq)(e,a,r.stories),(0,n.R3)(e))})),(0,n.iw)("loadStorySeenBy",(async(e,t,s)=>{const{storyId:a,offsetId:o}=s,r=await(0,h.t9)("fetchStorySeenBy",{storyId:a,offsetId:o});if(!r)return;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(r.users,"id")),e=(0,p.GE)(e,e.currentUserId,a,r.seenByDates);const c=Object.keys(r.seenByDates);if(!o&&c.length){const t=c.slice(-i.Ob7).reverse();e=(0,p.xg)(e,e.currentUserId,{id:a,recentViewerIds:t,viewsCount:r.count})}(0,n.R3)(e)})),(0,n.iw)("reportStory",(async(e,t,s)=>{const{userId:n,storyId:a,reason:i,description:o,tabId:r=(0,P._w)()}=s,c=(0,f.dyD)(e,n);if(!c)return;const d=await(0,h.t9)("reportStory",{user:c,storyId:a,reason:i,description:o});t.showNotification({message:d?(0,w.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:r})})),(0,n.iw)("editStoryPrivacy",((e,t,s)=>{const{storyId:n,privacy:a}=s,i=a.allowUserIds?.map((t=>(0,f.dyD)(e,t))).filter(Boolean),o=a.blockUserIds?.map((t=>(0,f.dyD)(e,t))).filter(Boolean);(0,h.t9)("editStoryPrivacy",{id:n,visibility:a.visibility,allowedUserList:i,deniedUserList:o})})),(0,n.iw)("toggleStoriesHidden",(async(e,t,s)=>{const{userId:a,isHidden:i}=s,o=(0,f.dyD)(e,a);o&&await(0,h.t9)("toggleStoriesHidden",{user:o,isHidden:i})&&(e=(0,n.Rd)(),e=(0,p.QI)(e,a,i),(0,n.R3)(e))})),(0,n.iw)("loadStoriesMaxIds",(async(e,t,s)=>{const{userIds:a}=s,i=a.map((t=>(0,f.dyD)(e,t))).filter(Boolean);if(!i.length)return;const o=await(0,h.t9)("fetchStoriesMaxIds",{users:i});if(!o)return;const r=[];e=(0,n.Rd)(),o.forEach(((t,s)=>{const n=i[s];e=(0,p.Nq)(e,n.id,{maxStoryId:t,hasStories:0!==t}),0!==t&&r.push(n.id)})),(0,n.R3)(e),r?.forEach((e=>t.loadUserStories({userId:e})))})),s(89005);var Ue=s(70735);function Le(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];let[a=(0,P._w)()]=s;const{chatId:i,threadId:o}=(0,f.Btg)(e,a)||{};return i&&o?(e=(0,p.qr)(e,i,o,!1,void 0,a),e=(0,p.Pb)(e,i,o,void 0,void 0,void 0,a)):e}(0,n.iw)("openLocalTextSearch",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{chatId:a,threadId:i}=(0,f.Btg)(e,n)||{};if(a&&i)return(0,p.qr)(e,a,i,!0,void 0,n)})),(0,n.iw)("closeLocalTextSearch",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return Le(e,n)})),(0,n.iw)("setLocalTextSearchQuery",((e,t,s)=>{const{query:n,tabId:a=(0,P._w)()}=s,{chatId:i,threadId:o}=(0,f.Btg)(e,a)||{};if(!i||!o)return;const r=(0,v.uw)(i,o),{query:c}=(0,f.jUK)(e,a).localTextSearch.byChatThreadKey[r]||{};return n!==c&&(e=(0,p.Pb)(e,i,o,Ue.D,void 0,void 0,a)),(0,p.qr)(e,i,o,!0,n,a)})),(0,n.iw)("setLocalMediaSearchType",((e,t,s)=>{const{mediaType:n,tabId:a=(0,P._w)()}=s,{chatId:i,threadId:o}=(0,f.Btg)(e,a)||{};if(i&&o)return(0,p.z5)(e,i,o,n,a)}));var Oe=s(15780);(0,n.iw)("openChat",((e,t,s)=>{const{id:n,threadId:a=u._f,type:i="thread",shouldReplaceHistory:o=!1,shouldReplaceLast:r=!1,noForumTopicPanel:c,tabId:d=(0,P._w)()}=s,l=(0,f.Btg)(e,d),m=(0,f.jUK)(e,d);return m.premiumModal?.promo&&m.premiumModal?.isOpen&&(e=(0,b.i)(e,{premiumModal:{...m.premiumModal,isOpen:!1}},d)),l&&l.chatId===n&&l.threadId===a&&l.type===i||(n&&(e=(0,p.O8)(e,n,a,"replyStack",[],d),e=(0,b.i)(e,{activeReactions:{}},d)),e=Le(e=(0,p.i9)(e,d),d),e=(0,b.i)(e,{isStatisticsShown:!1,contentToBeScheduled:void 0,...n!==(0,f.jUK)(e,d).forwardMessages.toChatId&&{forwardMessages:{}}},d)),n&&((0,f.Z1J)(e,n)?.isForum&&!c?t.openForumPanel({chatId:n,tabId:d}):n!==(0,f.jUK)(e,d).forumPanelChatId&&t.closeForumPanel({tabId:d})),t.updatePageTitle({tabId:d}),(0,p.Wy)(e,n,a,i,o,r,d)})),(0,n.iw)("openChatInNewTab",((e,t,s)=>{const{chatId:n,threadId:a=u._f}=s,o=(0,Oe.Ex)(n,"thread",a);i.D$V?window.electron.openNewWindow(o):window.open(o,"_blank")})),(0,n.iw)("openPreviousChat",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return t.updatePageTitle({tabId:n}),(0,p.Wy)(e,void 0,void 0,void 0,void 0,void 0,n)})),(0,n.iw)("openChatWithInfo",((e,t,s)=>{const{profileTab:a,tabId:i=(0,P._w)()}=s;e=(0,b.i)(e,{...(0,f.jUK)(e,i),isChatInfoShown:!0,nextProfileTab:a},i),e={...e,lastIsChatInfoShown:!0},(0,n.R3)(e),t.openChat({...s,tabId:i})})),(0,n.iw)("openChatWithDraft",((e,t,s)=>{const{chatId:n,text:a,threadId:i,files:o,filter:r,tabId:c=(0,P._w)()}=s;return n&&t.openChat({id:n,threadId:i,tabId:c}),(0,b.i)(e,{requestedDraft:{chatId:n,text:a,files:o,filter:r}},c)})),(0,n.iw)("resetChatCreation",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{chatCreation:void 0},n)})),(0,n.iw)("setNewChatMembersDialogState",((e,t,s)=>{const{newChatMembersProgress:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{newChatMembersProgress:n},a)})),(0,n.iw)("openNextChat",((e,t,s)=>{const{targetIndexDelta:n,orderedIds:a,tabId:i=(0,P._w)()}=s,{chatId:o}=(0,f.Btg)(e,i)||{};if(!o)return void t.openChat({id:a[0],tabId:i});const r=a.indexOf(o);if(-1===r)return;const c=a[r+n];t.openChat({id:c,shouldReplaceHistory:!0,tabId:i})})),(0,n.iw)("closeDeleteChatFolderModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{deleteFolderDialogModal:void 0},n)})),(0,n.iw)("closeChatlistModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{chatlistModal:void 0},n)})),(0,n.iw)("requestChatTranslation",((e,t,s)=>{const{chatId:n,toLanguageCode:a,tabId:i=(0,P._w)()}=s;return(0,p.LV)(e,n,a,i)}));var je=s(83099),_e=s(64319),Fe=s(996),De=s(42986);const qe=i.ckE+i.fK3;let Ge;function He(e,t,s){const{type:n,threadId:a}=(0,f.Btg)(e)||{},i=w.Iu,o=(0,f.Z1J)(e,t),r="scheduled"===n?(0,f.yBV)(e,t):(0,f.Zwk)(e,t);if(!o||!r||!a)return;const c=s.map((e=>r[e])).filter((t=>(0,f._kf)(e,t,a).canCopy)).sort(((e,t)=>e.id-t.id)),d=[],l=[];c.forEach((t=>{const s=(0,v.eA)(o)?o:(0,f.Urc)(e,t),n=`> ${s?(0,v.OU)(i,s):t.forwardInfo?.hiddenUserName||""}:`;d.push(n),d.push(`${function(e,t){const s=(0,De.Eb)(t),n=s?`${s} `:"",a=(0,Fe.X)(t,void 0,void 0,void 0,void 0,void 0,!0)?.join("");return`${n}${(0,De.Kk)(e,t,a,!0)}`}(i,t)}\n`),l.push(n),l.push(`${(0,v.MK)(i,t,!1,0,!0)}\n`)})),(0,_e.qN)(d.join("\n"),l.join("\n"))}(0,n.iw)("setScrollOffset",((e,t,s)=>{const{chatId:n,threadId:a,scrollOffset:i,tabId:o=(0,P._w)()}=s;return e=(0,p.pf)(e,n,a,"lastScrollOffset",i),(0,p.O8)(e,n,a,"scrollOffset",i,o)})),(0,n.iw)("setReplyingToId",((e,t,s)=>{const{messageId:n,tabId:a=(0,P._w)()}=s,i=(0,f.Btg)(e,a);if(!i)return;const{chatId:o,threadId:r}=i;return(0,p.pf)(e,o,r,"replyingToId",n)})),(0,n.iw)("setEditingId",((e,t,s)=>{const{messageId:n,tabId:a=(0,P._w)()}=s,i=(0,f.Btg)(e,a);if(!i)return;const{chatId:o,threadId:r,type:c}=i,d="scheduled"===c?"editingScheduledId":"editingId";return(0,p.pf)(e,o,r,d,n)})),(0,n.iw)("setEditingDraft",((e,t,s)=>{const{text:n,chatId:a,threadId:i,type:o}=s,r="scheduled"===o?"editingScheduledDraft":"editingDraft";return(0,p.pf)(e,a,i,r,n)})),(0,n.iw)("editLastMessage",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{chatId:a,threadId:i}=(0,f.Btg)(e,n)||{};if(!a||!i)return;const o=(0,f.Zwk)(e,a),r=(0,f.Cbz)(e,a,i,n);if(!o||!r)return;const c=(0,g.dF)(r,(t=>Boolean(o[t]&&(0,f._kf)(e,o[t],i).canEdit)));return c?(0,p.pf)(e,a,i,"editingId",c):void 0})),(0,n.iw)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:n,tabId:a=(0,P._w)()}=s,{chatId:i,threadId:o}=(0,f.Btg)(e,a)||{};if(!i||!o)return;const r=(0,f.Zwk)(e,i),c=(0,f.Cbz)(e,i,o,a);if(!r||!c)return;const d=(0,f.Yyv)(e,i,o);let l;if((0,f.b9T)(e,i,o,a)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+n;l=t<=e.length+1&&t>=0?Number(e[t]):void 0}else l=o===u._f?(0,f.Z1J)(e,i)?.lastMessage?.id:(0,f.tZg)(e,i,o)?.lastMessageId;t.setReplyingToId({messageId:l,tabId:a}),t.focusMessage({chatId:i,threadId:o,messageId:l,tabId:a})})),(0,n.iw)("openAudioPlayer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:i,origin:o,volume:r,playbackRate:c,isMuted:d,tabId:l=(0,P._w)()}=s,u=(0,f.jUK)(e,l);return(0,b.i)(e,{audioPlayer:{chatId:n,threadId:a,messageId:i,origin:null!=o?o:u.audioPlayer.origin,volume:null!=r?r:u.audioPlayer.volume,playbackRate:c||u.audioPlayer.playbackRate||e.audioPlayer.lastPlaybackRate,isPlaybackRateActive:void 0===u.audioPlayer.isPlaybackRateActive?e.audioPlayer.isLastPlaybackRateActive:u.audioPlayer.isPlaybackRateActive,isMuted:d||u.audioPlayer.isMuted}},l)})),(0,n.iw)("setAudioPlayerVolume",((e,t,s)=>{const{volume:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{audioPlayer:{...(0,f.jUK)(e,a).audioPlayer,volume:n,isMuted:!1}},a)})),(0,n.iw)("setAudioPlayerPlaybackRate",((e,t,s)=>{const{playbackRate:n,isPlaybackRateActive:a,tabId:i=(0,P._w)()}=s;return e={...e,audioPlayer:{...e.audioPlayer,lastPlaybackRate:n,isLastPlaybackRateActive:a}},(0,b.i)(e,{audioPlayer:{...(0,f.jUK)(e,i).audioPlayer,playbackRate:n,isPlaybackRateActive:a}},i)})),(0,n.iw)("setAudioPlayerMuted",((e,t,s)=>{const{isMuted:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{audioPlayer:{...(0,f.jUK)(e,a).audioPlayer,isMuted:n}},a)})),(0,n.iw)("setAudioPlayerOrigin",((e,t,s)=>{const{origin:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{audioPlayer:{...(0,f.jUK)(e,a).audioPlayer,origin:n}},a)})),(0,n.iw)("closeAudioPlayer",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);return(0,b.i)(e,{audioPlayer:{volume:a.audioPlayer.volume,playbackRate:a.audioPlayer.playbackRate,isPlaybackRateActive:a.audioPlayer.isPlaybackRateActive,isMuted:a.audioPlayer.isMuted}},n)})),(0,n.iw)("openPollResults",((e,t,s)=>{const{chatId:a,messageId:i,tabId:o=(0,P._w)()}=s,r=(0,f.Jf5)(e,(0,B.W7)(),o),c=(0,f.jUK)(e,o);if(r){if(a!==c.pollResults.chatId||i!==c.pollResults.messageId)return(0,b.i)(e,{pollResults:{chatId:a,messageId:i,voters:{}}},o)}else window.setTimeout((()=>{e=(0,n.Rd)(),e=(0,b.i)(e,{pollResults:{chatId:a,messageId:i,voters:{}}},o),(0,n.R3)(e)}),450)})),(0,n.iw)("closePollResults",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{pollResults:{}},n)})),(0,n.iw)("focusLastMessage",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.Btg)(e,n);if(!a)return;const{chatId:i,threadId:o,type:r}=a;let c;if(o===u._f)if("pinned"===r){const t=(0,f.KBA)(e,i,u._f);if(!t?.length)return;c=t[t.length-1]}else c=(0,f.Z1J)(e,i)?.lastMessage?.id;else c=(0,f.tZg)(e,i,o)?.lastMessageId;c&&t.focusMessage({chatId:i,threadId:o,messageListType:r,messageId:c,noHighlight:!0,noForumTopicPanel:!0,tabId:n})})),(0,n.iw)("focusNextReply",((e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{},i=(0,f.Btg)(e,a);if(!i)return;const{chatId:o,threadId:r}=i,c=(0,f.p9o)(e,o,r,a);if(c&&0!==c.length){const s=c.pop();e=(0,p.O8)(e,o,r,"replyStack",[...c],a),(0,n.R3)(e),t.focusMessage({chatId:o,threadId:r,messageId:s,tabId:a,noForumTopicPanel:!0})}else t.focusLastMessage({tabId:a})})),(0,n.iw)("focusMessage",((e,t,s)=>{const{chatId:a,threadId:i=u._f,messageListType:o="thread",noHighlight:r,groupedId:c,groupedChatId:d,replyMessageId:l,isResizingContainer:h,shouldReplaceHistory:I,noForumTopicPanel:v,tabId:w=(0,P._w)()}=s;let{messageId:y}=s;if(void 0!==c){const t=(0,f.y84)(e,d,c);t?.length&&([y]=(0,g.oA)(t))}const b=(0,f.Btg)(e,w),Z=!b||a!==b.chatId||i!==b.threadId||o!==b.type;if(Ge&&(clearTimeout(Ge),Ge=void 0),Ge=window.setTimeout((()=>{e=(0,n.Rd)(),e=(0,p.cq)(e,void 0,void 0,void 0,void 0,void 0,w),e=(0,p.wV)(e,void 0,w),(0,n.R3)(e)}),r?qe:1500),e=(0,p.cq)(e,a,y,i,r,h,w),e=(0,p.wV)(e,void 0,w),l){const t=(0,f.p9o)(e,a,i,w)||[];e=(0,p.O8)(e,a,i,"replyStack",[...t,l],w)}Z&&(e=(0,p.wV)(e,m.fo.Static,w));const C=(0,f.Cbz)(e,a,i,w);if(C&&C.includes(y))return(0,n.R3)(e,{forceOnHeavyAnimation:!0}),void t.openChat({id:a,threadId:i,type:o,shouldReplaceHistory:I,noForumTopicPanel:v,tabId:w});if(Z&&(e=(0,p.O8)(e,a,i,"viewportIds",void 0,w)),C&&!Z){const t=y>C[0]?m.fo.Down:m.fo.Up;e=(0,p.wV)(e,t,w)}(0,n.R3)(e,{forceOnHeavyAnimation:!0}),t.openChat({id:a,threadId:i,type:o,shouldReplaceHistory:I,noForumTopicPanel:v,tabId:w}),t.loadViewportMessages({tabId:w,shouldForceRender:!0})})),(0,n.iw)("openForwardMenu",((e,t,s)=>{const{fromChatId:n,messageIds:a,storyId:i,groupedId:o,withMyScore:r,tabId:c=(0,P._w)()}=s;let d;return o&&(d=(0,f.xHX)(e,n,o)),(0,b.i)(e,{forwardMessages:{fromChatId:n,messageIds:d||a,storyId:i,isModalShown:!0,withMyScore:r}},c)})),(0,n.iw)("changeForwardRecipient",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{forwardMessages:{...(0,f.jUK)(e,n).forwardMessages,toChatId:void 0,isModalShown:!0,noAuthors:!1,noCaptions:!1}},n)})),(0,n.iw)("setForwardNoAuthors",((e,t,s)=>{const{noAuthors:n,tabId:a=(0,P._w)()}=s,i=(0,f.jUK)(e,a);return(0,b.i)(e,{forwardMessages:{...i.forwardMessages,noAuthors:n,noCaptions:n&&i.forwardMessages.noCaptions}},a)})),(0,n.iw)("setForwardNoCaptions",((e,t,s)=>{const{noCaptions:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{forwardMessages:{...(0,f.jUK)(e,a).forwardMessages,noCaptions:n,noAuthors:n}},a)})),(0,n.iw)("exitForwardMode",((e,t,s)=>{const{tabId:a=(0,P._w)()}=s||{};e=(0,b.i)(e,{forwardMessages:{}},a),(0,n.R3)(e)})),(0,n.iw)("openForwardMenuForSelectedMessages",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);if(!a.selectedMessages)return;const{chatId:i,messageIds:o}=a.selectedMessages;t.openForwardMenu({fromChatId:i,messageIds:o,tabId:n})})),(0,n.iw)("cancelMessageMediaDownload",((e,t,s)=>{const{message:n,tabId:a=(0,P._w)()}=s;return(0,p.wI)(e,n,a)})),(0,n.iw)("cancelMessagesMediaDownload",((e,t,s)=>{const{messages:n,tabId:a=(0,P._w)()}=s;for(const t of n)e=(0,p.wI)(e,t,a);return e})),(0,n.iw)("downloadMessageMedia",((e,t,s)=>{const{message:n,tabId:a=(0,P._w)()}=s;return(0,p.fC)(e,n,a)})),(0,n.iw)("downloadSelectedMessages",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);if(!a.selectedMessages)return;const{chatId:i,messageIds:o}=a.selectedMessages,{threadId:r}=(0,f.Btg)(e,n)||{},c=(0,f.Zwk)(e,i);c&&r&&o.map((e=>c[e])).filter((t=>(0,f._kf)(e,t,r).canDownload)).forEach((e=>t.downloadMessageMedia({message:e,tabId:n})))})),(0,n.iw)("enterMessageSelectMode",((e,t,s)=>{const{messageId:n,tabId:a=(0,P._w)()}=s||{},i=(0,f.jrE)(e,a);return i?(0,p.M6)(e,i.id,n,a):e})),(0,n.iw)("toggleMessageSelection",((e,t,s)=>{const{messageId:i,groupedId:o,childMessageIds:r,withShift:c,tabId:d=(0,P._w)()}=s,l=(0,f.Btg)(e,d);if(!l)return;const{chatId:u,threadId:m,type:h}=l;e=(0,p.Ob)(e,u,m,h,i,o,r,c,d),(0,n.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${a.$b?"long tap":"right click"} on a message.`,tabId:d}))})),(0,n.iw)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,n.iw)("exitMessageSelectMode",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,p.i9)(e,n)})),(0,n.iw)("openPollModal",((e,t,s)=>{const{isQuiz:n,tabId:a=(0,P._w)()}=s||{};return(0,b.i)(e,{pollModal:{isOpen:!0,isQuiz:n}},a)})),(0,n.iw)("closePollModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{pollModal:{isOpen:!1}},n)})),(0,n.iw)("checkVersionNotification",((e,t)=>{if(i.V61&&Date.now()>Number(i.V61)+2592e5)return;const s="10.0.0".split(".").slice(0,2).join("."),{serviceNotifications:n}=e;if(n.find((e=>{let{version:t}=e;return t===s})))return;const a={chatId:i.awM,date:(0,pe.bp)(),content:{text:(0,je.ZP)("**Introducing Telegram Web A v10.0!**\n\nToday marks a special occasion. Telegram is celebrating its 10th anniversary! In honor of this milestone, and to highlight our web version's long-awaited parity with the native apps, we've leaped from version 1.x straight to 10.0. Big day!\n\n🌟 **Stories on Telegram**\nIntroducing [Telegram Stories](https://t.me/durov/216) - share moments of your life, beyond just text.\n\n💻 **Desktop Version**\nAn experimental standalone version is now available for enthusiasts and early adopters on all desktop platforms: **[web.telegram.org/a/get](https://web.telegram.org/a/get)**.\n\n🚀 **Massive Connection Improvements**\nWeb A is now more optimized ensuring speedy and seamless conversations. Less loading, more chatting.\n\n🎙 **Redesigned Group Calls**\nGroup calls have been overhauled to bring exceptional clarity, connectivity, and functionality.\n\n🌍 **Real-Time Translation**\nPremium users can tap to translate entire chats, dynamically updating as they scroll.\n\n⏱ **Custom Mute Durations**\nNotifications from any chat can be temporarily muted for a specific period like hours, days, or weeks.\n\n🔖 **Read Time in Groups**\nYou can see at what time other members read your message in the 'Seen By' section.\n\n😄 **Emoji v15 Support**\nWeb A now supports the latest from Emoji v15, so you can express yourself fully.\n\n🎨 **Dynamic Sticker Packs**\nDynamic order for your sticker packs can be toggled on or off whichever you prefer.\n\n🚀 **Performance Upgrades**\nWe've implemented multiple memory and performance optimizations for a smoother, faster, more efficient Telegram experience.\n\n🔧 **Fixes & Improvements**\nWe've patched several problems, including issues with sending messages while uploading files, freezes while scrolling, and messages incorrectly marking as read with Web A in the background. See if you can spot the host of UI refinements we added as well.😉\n\n📱 **More for iPad Users**\niPad users, we heard you! Web A now has improved iPad support.\n\nThank you for being with us. Here's to the next decade together! 🎉🥳\n\n🦄 **We also welcome** you to join our official channels in **[English](https://t.me/webachannel)** and **[Russian](https://t.me/webachannelru)** — where we post app updates and share our experiences building one of the worlds most feature-rich web applications.\n",!0)},isOutgoing:!1};t.createServiceNotification({message:a,version:s})})),(0,n.iw)("createServiceNotification",((e,t,s)=>{const{message:a,version:o}=s,{serviceNotifications:r}=e,c=(0,f.Z1J)(e,i.awM),d=Math.max(c.lastMessage?.id||0,...r.map((e=>{let{id:t}=e;return t}))),l=(r.length+1)/1e3,u=Math.floor(d)+l;a.previousLocalId=a.id,a.id=u;const m={id:u,message:a,version:o,isUnread:!0};e={...e,serviceNotifications:[...r.slice(-1e3),m]},(0,n.R3)(e),t.apiUpdate({"@type":"newMessage",id:a.id,chatId:a.chatId,message:a})})),(0,n.iw)("openReactorListModal",((e,t,s)=>{const{chatId:n,messageId:a,tabId:i=(0,P._w)()}=s;return(0,b.i)(e,{reactorModal:{chatId:n,messageId:a}},i)})),(0,n.iw)("closeReactorListModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{reactorModal:void 0},n)})),(0,n.iw)("openSeenByModal",((e,t,s)=>{const{chatId:n,messageId:a,tabId:i=(0,P._w)()}=s;return(0,b.i)(e,{seenByModal:{chatId:n,messageId:a}},i)})),(0,n.iw)("closeSeenByModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{seenByModal:void 0},n)})),(0,n.iw)("openChatLanguageModal",((e,t,s)=>{const{chatId:n,messageId:a,tabId:i=(0,P._w)()}=s,o=a?(0,f.Bdn)(e,n,a,i):(0,f.lpX)(e,n,i);return(0,b.i)(e,{chatLanguageModal:{chatId:n,messageId:a,activeLanguage:o}},i)})),(0,n.iw)("closeChatLanguageModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{chatLanguageModal:void 0},n)})),(0,n.iw)("copySelectedMessages",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);if(!a.selectedMessages)return;const{chatId:i,messageIds:o}=a.selectedMessages;He(e,i,o)})),(0,n.iw)("copyMessagesByIds",((e,t,s)=>{const{messageIds:n,tabId:a=(0,P._w)()}=s,i=(0,f.jrE)(e,a);n&&0!==n.length&&i&&He(e,i.id,n)})),(0,n.iw)("setGlobalSearchQuery",((e,t,s)=>{const{query:n,tabId:a=(0,P._w)()}=s,{chatId:i}=(0,f.jUK)(e,a).globalSearch;return(0,p.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...n?{fetchingStatus:{chats:!i,messages:!0}}:{fetchingStatus:void 0},query:n},a)})),(0,n.iw)("setGlobalSearchClosing",((e,t,s)=>{const{tabId:n=(0,P._w)(),isClosing:a}=s||{};return(0,p.No)(e,{isClosing:a},n)})),(0,n.iw)("addRecentlyFoundChatId",((e,t,s)=>{const{id:n}=s,{recentlyFoundChatIds:a}=e;if(!a)return{...e,recentlyFoundChatIds:[n]};const i=a.filter((e=>e!==n));return i.unshift(n),i.length>10&&i.pop(),{...e,recentlyFoundChatIds:i}})),(0,n.iw)("clearRecentlyFoundChats",(e=>({...e,recentlyFoundChatIds:void 0}))),(0,n.iw)("setGlobalSearchContent",((e,t,s)=>{const{content:n,tabId:a=(0,P._w)()}=s;return(0,p.Og)(e,n,a)})),(0,n.iw)("setGlobalSearchChatId",((e,t,s)=>{const{id:n,tabId:a=(0,P._w)()}=s;return(0,p.No)(e,{chatId:n,query:void 0,resultsByType:void 0},a)})),(0,n.iw)("setStickerSearchQuery",((e,t,s)=>{const{query:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{stickerSearch:{query:n,resultIds:void 0}},a)})),(0,n.iw)("setGifSearchQuery",((e,t,s)=>{const{query:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{gifSearch:{query:n,offset:void 0,results:void 0}},a)})),(0,n.iw)("setUserSearchQuery",((e,t,s)=>{const{query:n,tabId:a=(0,P._w)()}=s;return(0,p.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(n),query:n},a)})),(0,n.iw)("openAddContactDialog",((e,t,s)=>{const{userId:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{newContact:{userId:n}},a)})),(0,n.iw)("openNewContactDialog",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{newContact:{isByPhoneNumber:!0}},n)})),(0,n.iw)("closeNewContactDialog",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,p.ft)(e,n)})),s(73456);var $e=s(91947),Ve=s(69995);function Ke(e){document.querySelectorAll('link[rel="icon"], link[rel="alternate icon"]').forEach((t=>{e?t.href.includes("favicon-unread")||(t.href=t.href.replace("favicon","favicon-unread")):t.href=t.href.replace("favicon-unread","favicon")}))}function Je(e){i.D$V?window.electron.setWindowTitle(e):document.title!==e&&(document.title=e)}const ze=(0,I.Ds)(Je,200,!1);let We,Ye;(0,n.iw)("toggleChatInfo",((e,t,s)=>{const{force:n,tabId:a=(0,P._w)()}=s||{},i=void 0!==n?n:!(0,f.jUK)(e,a).isChatInfoShown;return e=(0,b.i)(e,{isChatInfoShown:i},a),{...e,lastIsChatInfoShown:i}})),(0,n.iw)("setLeftColumnWidth",((e,t,s)=>{const{leftColumnWidth:n}=s;return{...e,leftColumnWidth:n}})),(0,n.iw)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,n.iw)("toggleManagement",((e,t,s)=>{const{force:n,tabId:a=(0,P._w)()}=s||{},{chatId:i}=(0,f.Btg)(e,a)||{};if(!i)return;const o=(0,f.jUK)(e,a);return(0,b.i)(e,{management:{byChatId:{...o.management.byChatId,[i]:{...o.management.byChatId[i],isActive:void 0!==n?n:!(o.management.byChatId[i]||{}).isActive}}}},a)})),(0,n.iw)("requestNextManagementScreen",((e,t,s)=>{const{screen:n,tabId:a=(0,P._w)()}=s||{},{chatId:i}=(0,f.Btg)(e,a)||{};if(!i)return;const o=(0,f.jUK)(e,a);return(0,b.i)(e,{management:{byChatId:{...o.management.byChatId,[i]:{...o.management.byChatId[i],isActive:!0,nextScreen:n}}}},a)})),(0,n.iw)("closeManagement",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{chatId:a}=(0,f.Btg)(e,n)||{};if(!a)return;const i=(0,f.jUK)(e,n);return(0,b.i)(e,{management:{byChatId:{...i.management.byChatId,[a]:{...i.management.byChatId[a],isActive:!1}}}},n)})),(0,n.iw)("openChat",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s;if((0,B.W7)()||(0,B.c9)())return(0,b.i)(e,{isLeftColumnShown:0===(0,f.jUK)(e,n).messageLists.length},n)})),(0,n.iw)("resetNextProfileTab",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{chatId:a}=(0,f.Btg)(e,n)||{};if(a)return(0,b.i)(e,{nextProfileTab:void 0},n)})),(0,n.iw)("toggleStatistics",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);return(0,b.i)(e,{isStatisticsShown:!a.isStatisticsShown,statistics:{...a.statistics,currentMessageId:void 0}},n)})),(0,n.iw)("toggleMessageStatistics",((e,t,s)=>{const{tabId:n=(0,P._w)(),messageId:a}=s||{};return(0,b.i)(e,{statistics:{...(0,f.jUK)(e,n).statistics,currentMessageId:a}},n)})),(0,n.iw)("toggleLeftColumn",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{isLeftColumnShown:!(0,f.jUK)(e,n).isLeftColumnShown},n)})),(0,n.iw)("addRecentEmoji",((e,t,s)=>{const{emoji:n}=s,{recentEmojis:a}=e;if(!a)return{...e,recentEmojis:[n]};const i=a.filter((e=>e!==n));return i.unshift(n),i.length>32&&i.pop(),{...e,recentEmojis:i}})),(0,n.iw)("addRecentSticker",((e,t,s)=>{const{sticker:n}=s,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[n]}}};const i=a.stickers.filter((e=>e.id!==n.id));return i.unshift(n),{...e,stickers:{...e.stickers,recent:{...a,stickers:i}}}})),(0,n.iw)("addRecentCustomEmoji",((e,t,s)=>{const{documentId:n}=s,{recentCustomEmojis:a}=e;if(!a)return{...e,recentCustomEmojis:[n]};const i=a.filter((e=>e!==n));return i.unshift(n),i.length>32&&i.pop(),{...e,recentCustomEmojis:i}})),(0,n.iw)("clearRecentCustomEmoji",(e=>({...e,recentCustomEmojis:[]}))),(0,n.iw)("reorderStickerSets",((e,t,s)=>{const{order:n,isCustomEmoji:a}=s;return{...e,stickers:{...e.stickers,added:{setIds:a?e.stickers.added.setIds:n}},customEmojis:{...e.customEmojis,added:{setIds:a?n:e.customEmojis.added.setIds}}}})),(0,n.iw)("showNotification",((e,t,s)=>{const{tabId:n=(0,P._w)(),...a}=s;a.localId=(0,Ve.Z)();const i=[...(0,f.jUK)(e,n).notifications],o=i.findIndex((e=>e.message===a.message));return-1!==o&&i.splice(o,1),i.push(a),(0,b.i)(e,{notifications:i},n)})),(0,n.iw)("showAllowedMessageTypesNotification",((e,t,s)=>{const{chatId:n,tabId:a=(0,P._w)()}=s,i=(0,f.Z1J)(e,n);if(!i)return;const{canSendPlainText:o,canSendPhotos:r,canSendVideos:c,canSendDocuments:d,canSendAudios:l,canSendStickers:u,canSendRoundVideos:m,canSendVoices:h}=(0,v.H5)(i),p=(0,g.oA)([o?"Chat.SendAllowedContentTypeText":void 0,r?"Chat.SendAllowedContentTypePhoto":void 0,c?"Chat.SendAllowedContentTypeVideo":void 0,h?"Chat.SendAllowedContentTypeVoiceMessage":void 0,m?"Chat.SendAllowedContentTypeVideoMessage":void 0,d?"Chat.SendAllowedContentTypeFile":void 0,l?"Chat.SendAllowedContentTypeMusic":void 0,u?"Chat.SendAllowedContentTypeSticker":void 0]).map((e=>w.Iu(e)));if(!p.length)return void t.showNotification({message:w.Iu("Chat.SendNotAllowedText"),tabId:a});const I=w.Iu("AutoDownloadSettings.LastDelimeter"),y=p.join(", ").replace(/,([^,]*)$/,`${I}$1`);t.showNotification({message:w.Iu("Chat.SendAllowedContentText",y),tabId:a})})),(0,n.iw)("dismissNotification",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s,a=(0,f.jUK)(e,n).notifications.filter((e=>{let{localId:t}=e;return t!==s.localId}));return(0,b.i)(e,{notifications:a},n)})),(0,n.iw)("showDialog",((e,t,s)=>{const{data:n,tabId:a=(0,P._w)()}=s;if("message"in n&&n.hasErrorKey&&!(0,$e.ZP)(n))return e;const i=[...(0,f.jUK)(e,a).dialogs];if("message"in n){const e=i.findIndex((e=>e.message===n.message));-1!==e&&i.splice(e,1)}return i.push(n),(0,b.i)(e,{dialogs:i},a)})),(0,n.iw)("dismissDialog",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=[...(0,f.jUK)(e,n).dialogs];return a.pop(),(0,b.i)(e,{dialogs:a},n)})),(0,n.iw)("toggleSafeLinkModal",((e,t,s)=>{const{url:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{safeLinkModalUrl:n},a)})),(0,n.iw)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{historyCalendarSelectedAt:n},a)})),(0,n.iw)("closeHistoryCalendar",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{historyCalendarSelectedAt:void 0},n)})),(0,n.iw)("openGame",((e,t,s)=>{const{url:a,chatId:i,messageId:o,tabId:r=(0,P._w)()}=s,c=(0,f.hjO)(e,i,o);if(!c)return;const d=c.viaBotId||c.senderId;if(d){if(!(0,f.LM9)(e,d))return e=(0,b.i)(e,{botTrustRequest:{botId:d,type:"game",onConfirm:{action:"openGame",payload:s}}},r),void(0,n.R3)(e);e=(0,b.i)(e,{openedGame:{url:a,chatId:i,messageId:o}},r),(0,n.R3)(e)}})),(0,n.iw)("closeGame",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{openedGame:void 0},n)})),(0,n.iw)("requestConfetti",((e,t,s)=>{const{top:n,left:a,width:i,height:o,tabId:r=(0,P._w)()}=s||{};if((0,f.FOo)(e))return(0,b.i)(e,{confetti:{lastConfettiTime:Date.now(),top:n,left:a,width:i,height:o}},r)})),(0,n.iw)("updateAttachmentSettings",((e,t,s)=>{const{shouldCompress:n,shouldSendGrouped:a}=s;return{...e,attachmentSettings:{shouldCompress:null!=n?n:e.attachmentSettings.shouldCompress,shouldSendGrouped:null!=a?a:e.attachmentSettings.shouldSendGrouped}}})),(0,n.iw)("openLimitReachedModal",((e,t,s)=>{const{limit:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{limitReachedModal:{limit:n}},a)})),(0,n.iw)("closeLimitReachedModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{limitReachedModal:void 0},n)})),(0,n.iw)("closeStickerSetModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{openedStickerSetShortName:void 0},n)})),(0,n.iw)("openCustomEmojiSets",((e,t,s)=>{const{setIds:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{openedCustomEmojiSetIds:n},a)})),(0,n.iw)("closeCustomEmojiSets",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{openedCustomEmojiSetIds:void 0},n)})),(0,n.iw)("updateLastRenderedCustomEmojis",((e,t,s)=>{const{ids:n}=s,{lastRendered:a}=e.customEmojis;return{...e,customEmojis:{...e.customEmojis,lastRendered:(0,g.Tw)([...a,...n]).slice(0,i.j7i)}}})),(0,n.iw)("openCreateTopicPanel",((e,t,s)=>{const{chatId:n,tabId:a=(0,P._w)()}=s;return(0,f.jrE)(e,a)||t.openChat({id:n,threadId:u._f,tabId:a}),(0,b.i)(e,{createTopicPanel:{chatId:n}},a)})),(0,n.iw)("closeCreateTopicPanel",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{createTopicPanel:void 0},n)})),(0,n.iw)("openEditTopicPanel",((e,t,s)=>{const{chatId:n,topicId:a,tabId:i=(0,P._w)()}=s;return(0,f.jrE)(e,i)||t.openChat({id:n,tabId:i}),(0,b.i)(e,{editTopicPanel:{chatId:n,topicId:a}},i)})),(0,n.iw)("closeEditTopicPanel",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{};return(0,b.i)(e,{editTopicPanel:void 0},n)})),(0,n.iw)("updateArchiveSettings",((e,t,s)=>{const{archiveSettings:n}=e,{isHidden:a=n.isHidden,isMinimized:i=n.isMinimized}=s;return{...e,archiveSettings:{isHidden:a,isMinimized:i}}})),(0,n.iw)("checkAppVersion",(e=>{if(i.D$V)return;const t=/^\d+\.\d+(\.\d+)?$/;fetch(`version.txt?${Date.now()}`).then((e=>e.text())).then((s=>{s=s.trim(),t.test(s)&&"10.0.0"!==s&&(e=(0,n.Rd)(),e={...e,isUpdateAvailable:!0},(0,n.R3)(e))})).catch((e=>{i.eMD&&console.error("[checkAppVersion failed] ",e)}))})),(0,n.iw)("setIsAppUpdateAvailable",((e,t,s)=>{e=(0,n.Rd)(),e={...e,isUpdateAvailable:Boolean(s)},(0,n.R3)(e)})),(0,n.iw)("afterHangUp",(e=>{(0,f.jUK)(e,(0,P._w)()).multitabNextAction&&(0,P.g)()})),(0,n.iw)("onTabFocusChange",((e,t,s)=>{const{isBlurred:n,tabId:a=(0,P._w)()}=s;return n?(We&&clearInterval(We),We=window.setInterval((()=>{t.updatePageTitle({tabId:a})}),500)):(clearInterval(We),We=void 0),e=(0,b.i)(e,{isBlurred:n},a),{...e,initialUnreadNotifications:n?(0,me.xW)():void 0}})),(0,n.iw)("updatePageTitle",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{canDisplayChatInTitle:a}=e.settings.byKey,o=e.currentUserId;if(document.title.includes(i.ouc))return Ke(!1),void Je(`${i.Tih} ${i.ouc}`);if(e.initialUnreadNotifications&&Math.round(Date.now()/1e3)%2==0){const t=(0,me.xW)()-e.initialUnreadNotifications;if(t>0)return Je(`${t} notification${t>1?"s":""}`),void Ke(!0)}Ke(!1);const r=(0,f.Btg)(e,n);if(r&&a&&!e.passcode.isScreenLocked){const{chatId:t,threadId:s}=r,n=(0,f.Z1J)(e,t);if(n){const e=(0,v.U)(w.Iu,n,t===o);return n.isForum&&n.topics?.[s]?void ze(`${e} ${n.topics[s].title}`):void ze(e)}}Je(i.D$V?"":i.Tih)}));let Xe,Qe=0;(0,ue.ll)((e=>{const{updatePageTitle:t,updateIsOnline:s}=(0,n.Sv)(),a=e.passcode.isScreenLocked!==Ye,i=Object.values(e.byTabId).filter((e=>e.isBlurred)).length,o=(0,f.jUK)(e,(0,P._w)()).isMasterTab;a&&t(),i!==Qe&&o&&(Xe&&clearTimeout(Xe),Xe=window.setTimeout((()=>{e=(0,n.Rd)();const t=Object.values(e.byTabId).filter((e=>e.isBlurred)).length;s(t!==(0,P.s1)().length)}),100)),Ye=e.passcode.isScreenLocked,Qe=i})),(0,n.iw)("closePaymentModal",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n).payment.status;return e=(0,p.bp)(e,n),e=(0,p.WY)(e,n),(0,b.i)(e,{payment:{...(0,f.jUK)(e,n).payment,status:a}},n)})),(0,n.iw)("addPaymentError",((e,t,s)=>{const{error:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{payment:{...(0,f.jUK)(e,a).payment,status:"failed",error:n}},a)}));var et=s(88422);(0,n.iw)("openMediaViewer",((e,t,s)=>{const{chatId:n,threadId:a,mediaId:i,avatarOwnerId:o,profilePhotoIndex:r,origin:c,volume:d,playbackRate:l,isMuted:u,tabId:m=(0,P._w)()}=s,h=(0,f.jUK)(e,m);return(0,b.i)(e,{mediaViewer:{...h.mediaViewer,chatId:n,threadId:a,mediaId:i,avatarOwnerId:o,profilePhotoIndex:r,origin:c,isHidden:!1,volume:null!=d?d:h.mediaViewer.volume,playbackRate:l||h.mediaViewer.playbackRate||e.mediaViewer.lastPlaybackRate,isMuted:u||h.mediaViewer.isMuted},forwardMessages:{}},m)})),(0,n.iw)("closeMediaViewer",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{volume:a,isMuted:i,playbackRate:o,isHidden:r}=(0,f.jUK)(e,n).mediaViewer;return(0,b.i)(e,{mediaViewer:{volume:a,isMuted:i,isHidden:r,playbackRate:o}},n)})),(0,n.iw)("setMediaViewerVolume",((e,t,s)=>{const{volume:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{mediaViewer:{...(0,f.jUK)(e,a).mediaViewer,volume:n,isMuted:!1}},a)})),(0,n.iw)("setMediaViewerPlaybackRate",((e,t,s)=>{const{playbackRate:n,tabId:a=(0,P._w)()}=s;return e={...e,mediaViewer:{...e.mediaViewer,lastPlaybackRate:n}},(0,b.i)(e,{mediaViewer:{...(0,f.jUK)(e,a).mediaViewer,playbackRate:n}},a)})),(0,n.iw)("setMediaViewerMuted",((e,t,s)=>{const{isMuted:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{mediaViewer:{...(0,f.jUK)(e,a).mediaViewer,isMuted:n}},a)})),(0,n.iw)("setMediaViewerHidden",((e,t,s)=>{const{isHidden:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{mediaViewer:{...(0,f.jUK)(e,a).mediaViewer,isHidden:n}},a)}));var tt=s(50214),st=s(95281),nt=s(5872),at=s(35369);let it=!1;(0,I.Gq)((()=>{(0,n.Rd)().passcode.hasPasscode&&!it&&1===Object.keys((0,n.Rd)().byTabId).length&&(0,tt.jv)()})),(0,n.iw)("setPasscode",(async(e,t,s)=>{const{passcode:a,tabId:i=(0,P._w)()}=s;e=(0,p.vu)(e,{isLoading:!0}),(0,n.R3)(e),await(0,st.AU)(a);const o=JSON.stringify({...(0,tt.K8)(),userId:e.currentUserId});e=(0,n.Rd)();const r=(0,nt.Uf)((0,p.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}));try{await(0,st.H4)(o,r),(0,P.Z6)(),e=(0,n.Rd)(),e=(0,p.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}),(0,n.R3)(e),(0,nt.jA)(!0)}catch(s){(0,st.J9)(),e=(0,n.Rd)(),e=(0,p.vu)(e,{isLoading:!1}),(0,n.R3)(e),t.showNotification({message:"Failed to set passcode",tabId:i}),t.requestNextSettingsScreen({screen:m.MT.PasscodeDisabled,tabId:i})}})),(0,n.iw)("clearPasscode",(e=>((0,st.C8)(),(0,p.Kn)(e)))),(0,n.iw)("unlockScreen",((e,t,s)=>{const a=Object.values(e.byTabId),{sessionJson:i,globalJson:o}=s,r=JSON.parse(i);(0,tt.wX)(r,r.userId);const c=e;(e=JSON.parse(o)).byTabId=c.byTabId,(0,nt.nE)(e,(0,g.Xh)(at.g9)),e=(0,p.vu)(e,{isScreenLocked:!1,error:void 0,invalidAttemptsCount:0}),(0,n.R3)(e),(0,P.Z6)(),a.forEach((e=>{let{id:s,isMasterTab:n}=e;return t.init({tabId:s,isMasterTab:n})})),t.initApi()})),(0,n.iw)("decryptSession",((e,t,s)=>{const{passcode:n}=s;(0,st.so)(n).then(t.unlockScreen,(()=>{t.logInvalidUnlockAttempt()}))})),(0,n.iw)("logInvalidUnlockAttempt",(e=>{var t;const s=(null!==(t=e.passcode?.invalidAttemptsCount)&&void 0!==t?t:0)+1;return(0,p.vu)(e,{invalidAttemptsCount:s,timeoutUntil:s>=5?Date.now()+15e3:void 0})})),(0,n.iw)("resetInvalidUnlockAttempts",(e=>(0,p.vu)(e,{invalidAttemptsCount:0,timeoutUntil:void 0}))),(0,n.iw)("setPasscodeError",((e,t,s)=>{const{error:n}=s;return(0,p.vu)(e,{error:n})})),(0,n.iw)("clearPasscodeError",(e=>(0,p.vu)(e,{error:void 0}))),(0,n.iw)("skipLockOnUnload",(()=>{it=!0})),(0,n.iw)("openChat",((e,t,s)=>{const{id:n,tabId:a=(0,P._w)()}=s;return n?(0,b.i)(e,{reactionPicker:{chatId:n,messageId:void 0,position:void 0}},a):(0,b.i)(e,{reactionPicker:void 0},a)})),(0,n.iw)("openMessageReactionPicker",((e,t,s)=>{const{chatId:n,messageId:a,position:i,tabId:o=(0,P._w)()}=s;return(0,b.i)(e,{reactionPicker:{chatId:n,messageId:a,position:i}},o)})),(0,n.iw)("openStoryReactionPicker",((e,t,s)=>{const{storyUserId:n,storyId:a,position:i,tabId:o=(0,P._w)()}=s;return(0,b.i)(e,{reactionPicker:{storyUserId:n,storyId:a,position:i}},o)})),(0,n.iw)("closeReactionPicker",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);return(0,b.i)(e,{reactionPicker:{...a.reactionPicker,messageId:void 0,position:void 0,storyId:void 0,storyUserId:void 0}},n)})),(0,n.iw)("openStoryViewer",(async(e,t,s)=>{const{userId:a,storyId:i,isSingleUser:o,isSingleStory:r,isPrivate:c,isArchive:d,tabId:l=(0,P._w)()}=s,u=(0,f.dyD)(e,a);if(!u)return;const m=(0,f.jUK)(e,l),I=(0,f.GZu)(e,a);if(i&&(!I||!I.byId[i])){const t=await(0,h.t9)("fetchUserStoriesByIds",{user:u,ids:[i]});if(!t)return;e=(0,n.Rd)(),e=(0,p.Sh)(e,(0,g.ee)(t.users,"id")),e=(0,p.Eq)(e,a,t.stories)}e=(0,b.i)(e,{storyViewer:{...m.storyViewer,userId:a,storyId:i||(0,f.EHF)(e,a)||(0,f.UFi)(e,a),isSingleUser:o,isPrivate:c,isArchive:d,isSingleStory:r,storyIdSeenBy:void 0}},l),(0,n.R3)(e)})),(0,n.iw)("openStoryViewerByUsername",(async(e,t,s)=>{const{username:n,storyId:a,tabId:i=(0,P._w)()}=s,o=await(0,l.Co)(e,n);o&&t.openStoryViewer({userId:o.id,storyId:a,isSingleUser:!0,isSingleStory:!0,tabId:i})})),(0,n.iw)("closeStoryViewer",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},{isMuted:a,isRibbonShown:i,isArchivedRibbonShown:o,storyId:r}=(0,f.jUK)(e,n).storyViewer;return r?(e=(0,b.i)(e,{storyViewer:{isMuted:a,isRibbonShown:i,isArchivedRibbonShown:o,lastViewedByUserIds:void 0}},n),Object.keys(e.byTabId).find((t=>(0,f.jUK)(e,Number(t)).storyViewer.userId))||(e={...e,stories:{...e.stories,seenByDates:void 0}}),e):e})),(0,n.iw)("setStoryViewerMuted",((e,t,s)=>{const{isMuted:n,tabId:a=(0,P._w)()}=s;return(0,b.i)(e,{storyViewer:{...(0,f.jUK)(e,a).storyViewer,isMuted:n}},a)})),(0,n.iw)("toggleStoryRibbon",((e,t,s)=>{const{isShown:n,isArchived:a,tabId:i=(0,P._w)()}=s;return e.stories.orderedUserIds[a?"archived":"active"]?.length?(0,b.i)(e,{storyViewer:{...(0,f.jUK)(e,i).storyViewer,[a?"isArchivedRibbonShown":"isRibbonShown"]:n}},i):e})),(0,n.iw)("openPreviousStory",((e,t,s)=>{var n,a;const{tabId:i=(0,P._w)()}=s||{},o=(0,f.jUK)(e,i),{userId:r,storyId:c,isSingleUser:d,isSingleStory:l,isPrivate:u,isArchive:m}=o.storyViewer;if(l)return void t.closeStoryViewer({tabId:i});const{orderedUserIds:{active:h,archived:g}}=e.stories;if(!r||!c)return;const p=(0,f.dyD)(e,r),I=(0,f.GZu)(e,r);if(!I||!p)return;const v=null!==(n=p.areStoriesHidden?g:h)&&void 0!==n?n:[],w=m?"archiveIds":u?"pinnedIds":"orderedIds",y=(null!==(a=I[w])&&void 0!==a?a:[]).indexOf(c);let Z,C;if(y>0)Z=y-1,C=r;else{const t=v.indexOf(r)-1;if(d||t<0)return;C=v[t],Z=((0,f.GZu)(e,C)?.orderedIds.length||1)-1}const S=(0,f.GZu)(e,C)?.[w]?.[Z];return S?(0,b.i)(e,{storyViewer:{...o.storyViewer,userId:C,storyId:S}},i):void 0})),(0,n.iw)("openNextStory",((e,t,s)=>{var n,a;const{tabId:i=(0,P._w)()}=s||{},o=(0,f.jUK)(e,i),{userId:r,storyId:c,isSingleUser:d,isSingleStory:l,isPrivate:u,isArchive:m}=o.storyViewer;if(l)return void t.closeStoryViewer({tabId:i});const{orderedUserIds:{active:h,archived:g}}=e.stories;if(!r||!c)return;const p=(0,f.dyD)(e,r),I=(0,f.GZu)(e,r);if(!I||!p)return;const v=null!==(n=p.areStoriesHidden?g:h)&&void 0!==n?n:[],w=m?"archiveIds":u?"pinnedIds":"orderedIds",y=null!==(a=I[w])&&void 0!==a?a:[],Z=y.indexOf(c);let C,S;if(Z<y.length-1)C=Z+1,S=r;else{const e=v.indexOf(r)+1;if(d||e>v.length-1)return void t.closeStoryViewer({tabId:i});S=v[e],C=0}const M=(0,f.GZu)(e,S)?.[w]?.[C];return M?(0,b.i)(e,{storyViewer:{...o.storyViewer,userId:S,storyId:M}},i):void 0})),(0,n.iw)("openStorySeenBy",((e,t,s)=>{const{storyId:n,tabId:a=(0,P._w)()}=s,i=(0,f.jUK)(e,a);return(0,b.i)(e,{storyViewer:{...i.storyViewer,storyIdSeenBy:n}},a)})),(0,n.iw)("closeStorySeenBy",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);return(0,b.i)(e,{storyViewer:{...a.storyViewer,storyIdSeenBy:void 0}},n)})),(0,n.iw)("copyStoryLink",(async(e,t,s)=>{const{userId:n,storyId:a,tabId:i=(0,P._w)()}=s,o=await(0,h.t9)("fetchStoryLink",{userId:n,storyId:a});o&&((0,_e.TE)(o),t.showNotification({message:w.Iu("LinkCopied"),tabId:i}))})),(0,n.iw)("sendMessage",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s,{storyId:a,userId:i}=(0,f.pri)(e,n);if(!Boolean(a&&i))return;const{gif:o,sticker:r,isReaction:c}=s;let d;d=o?"Story.Tooltip.GifSent":r?"Story.Tooltip.StickerSent":c?"Story.Tooltip.ReactionSent":"Story.Tooltip.MessageSent",t.showNotification({message:w.Iu(d),actionText:w.Iu("Story.ToastViewInChat"),action:[{action:"closeStoryViewer",payload:void 0},{action:"openChat",payload:{id:i}}],tabId:n})})),(0,n.iw)("openStoryPrivacyEditor",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);return(0,b.i)(e,{storyViewer:{...a.storyViewer,isPrivacyModalOpen:!0}},n)})),(0,n.iw)("closeStoryPrivacyEditor",((e,t,s)=>{const{tabId:n=(0,P._w)()}=s||{},a=(0,f.jUK)(e,n);return(0,b.i)(e,{storyViewer:{...a.storyViewer,isPrivacyModalOpen:!1}},n)})),s(28304),(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{const{isForum:a,lastReadOutboxMessageId:i}=(0,f.Z1J)(e,s.id)||{};return s.chat.lastReadOutboxMessageId&&i&&s.chat.lastReadOutboxMessageId<i&&(s={...s,chat:(0,g.CE)(s.chat,["lastReadInboxMessageId"])}),e=(0,p.a4)(e,s.id,s.chat,s.newProfilePhoto),(0,n.R3)(e),s.noTopChatsRequest||(0,f.Nap)(e,s.id)||t.loadTopChats(),s.chat.id&&(0,C.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId}),void Object.values(e.byTabId).forEach((n=>{let{id:i}=n;const{chatId:o}=(0,f.Btg)(e,i)||{},r=s;o===r.id&&"isForum"in r.chat&&a!==r.chat.isForum&&(a&&t.closeForumPanel({tabId:i}),t.openChat({id:o,tabId:i}))}))}case"updateChatJoin":{const a=(0,f.EkO)(e,s.id);if(!a)return;e=(0,p.B1)(e,a,[s.id]),e=(0,p.a4)(e,s.id,{isNotJoined:!1}),(0,n.R3)(e);const i=(0,f.Z1J)(e,s.id);return void(i&&t.requestChatUpdate({chatId:i.id}))}case"updateChatLeave":return(0,p.Dd)(e,s.id);case"updateChatInbox":return(0,p.a4)(e,s.id,s.chat);case"updateChatTypingStatus":{const{id:t,threadId:a=u._f,typingStatus:i}=s;return e=(0,p.pf)(e,t,a,"typingStatus",i),(0,n.R3)(e),void setTimeout((()=>{e=(0,n.Rd)();const s=(0,f.WPz)(e,t,a,"typingStatus");i&&s&&i.timestamp===s.timestamp&&(e=(0,p.pf)(e,t,a,"typingStatus",void 0),(0,n.R3)(e))}),6e3)}case"newMessage":{const{message:t}=s;if(t.senderId===e.currentUserId&&!t.isFromScheduled)return;const a=(0,f.Z1J)(e,s.chatId);if(!a)return;const i=Boolean(s.message.id&&s.message.hasUnreadMention);return e=(0,p.a4)(e,s.chatId,{unreadCount:a.unreadCount?a.unreadCount+1:1,...i&&{unreadMentionsCount:(a.unreadMentionsCount||0)+1}}),i&&(e=(0,p.a4)(e,s.chatId,{unreadMentions:[...a.unreadMentions||[],s.message.id]})),(0,n.R3)(e),void(0,C.rh)({chat:a,message:t})}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:n}=s;if(!1!==n.hasUnreadMention)return;return t.forEach((t=>{const n="channelId"in s?s.channelId:(0,f.X5I)(e,t),a=(0,f.Z1J)(e,n);a?.unreadReactionsCount&&(e=O(e,n,{unreadReactionsCount:a.unreadReactionsCount-1||void 0,unreadReactions:a.unreadReactions?.filter((e=>e!==t))})),a?.unreadMentionsCount&&(e=(0,p.a4)(e,n,{unreadMentionsCount:a.unreadMentionsCount-1||void 0,unreadMentions:a.unreadMentions?.filter((e=>e!==t))}))})),e}case"updateChatFullInfo":return(0,p.US)(e,s.id,s.fullInfo);case"updatePinnedChatIds":{const{ids:t,folderId:n}=s,a=n===i.WSp?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[a]:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:n}=s,a=(0,f.EkO)(e,t);if(!a)return;const{[a]:o}=e.chats.orderedPinnedIds;let r=o||[];if(n){if(!r.includes(t)){if("active"===a&&r.length>=i.EGK){const t=e.chats.listIds.active;r=r.filter((e=>t&&t.includes(e)))}r=[t,...r]}}else r=r.filter((e=>e!==t));return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[a]:r.length?r:void 0}}}}case"updateChatListType":{const{id:t,folderId:n}=s;return(0,p.Pi)(e,t,n)}case"updateChatFolder":{const{id:t,folder:n}=s,{byId:a,orderedIds:i}=e.chatFolders,o=void 0===n;Object.values(e.byTabId).forEach((s=>{let{id:n}=s;const i=(0,f.jUK)(e,n);Object.values(a)[i.activeChatFolder-1]?.id===t&&(e=(0,b.i)(e,{activeChatFolder:0},n))}));const r=o?(0,g.CE)(a,[t]):{...a,[t]:n},c=o?i?.filter((e=>e!==t)):i?.includes(t)?i:[...i||[],t];return{...e,chatFolders:{...e.chatFolders,byId:r,orderedIds:c,invites:(0,g.CE)(e.chatFolders.invites,[t])}}}case"updateChatFoldersOrder":{const{orderedIds:t}=s;return{...e,chatFolders:{...e.chatFolders,orderedIds:t}}}case"updateRecommendedChatFolders":{const{folders:t}=s;return{...e,chatFolders:{...e.chatFolders,recommended:t}}}case"updateChatMembers":{const t=(0,f.x67)(e,s.id),{replacedMembers:n,addedMember:a,deletedMemberId:i}=s;if(!t)return;let o=!1,r=t?.members?[...t.members]:[];if(n)r=n,o=!0;else if(a)r.length&&r.some((e=>e.userId===a.userId))||(r.push(a),o=!0);else if(r.length&&i){const e=r.findIndex((e=>e.userId===i));e>-1&&(r.slice(e,1),o=!0)}if(o){const t=r.filter((e=>{let{isOwner:t,isAdmin:s}=e;return t||s}));return e=(0,p.a4)(e,s.id,{membersCount:r.length}),e=(0,p.US)(e,s.id,{members:r,adminMembersById:(0,g.ee)(t,"userId")})}return}case"deleteProfilePhotos":{const{chatId:t,ids:n}=s,a=e.chats.byId[t];return a?.photos?(0,p.a4)(e,t,{photos:a.photos.filter((e=>!n.includes(e.id)))}):void 0}case"draftMessage":{const{chatId:t,formattedText:n,date:a,replyingToId:i,threadId:o}=s;if(!e.chats.byId[t])return;return e=(0,p.pf)(e,t,o||u._f,"draft",n),e=(0,p.pf)(e,t,o||u._f,"replyingToId",i),e=(0,p.a4)(e,t,{draftDate:a})}case"showInvite":{const{data:n}=s;return void Object.values(e.byTabId).forEach((e=>{let{id:s}=e;t.showDialog({data:n,tabId:s})}))}case"updatePendingJoinRequests":{const{chatId:a,requestsPending:i,recentRequesterIds:o}=s;if(!e.chats.byId[a])return;return e=(0,p.US)(e,a,{requestsPending:i,recentRequesterIds:o}),(0,n.R3)(e),void t.loadChatJoinRequests({chatId:a})}case"updatePinnedTopic":{const{chatId:t,topicId:a,isPinned:i}=s;if(!e.chats.byId[t])return;return e=(0,p.Cn)(e,t,a,{isPinned:i}),void(0,n.R3)(e)}case"updatePinnedTopicsOrder":{const{chatId:t,order:a}=s;if(!e.chats.byId[t])return;return e=(0,p.a4)(e,t,{orderedPinnedTopicIds:a}),void(0,n.R3)(e)}case"updateTopic":{const{chatId:n,topicId:a}=s;if(!(0,f.Z1J)(e,n)?.isForum)return;return void t.loadTopicById({chatId:n,topicId:a})}case"updateTopics":{const{chatId:n}=s;if(!(0,f.Z1J)(e,n)?.isForum)return;return void t.loadTopics({chatId:n,force:!0})}}}));const ot=(0,I.P2)((function(){let e=(0,n.Rd)();e=(0,p.ps)(e,{...e.users.statusesById,...rt}),(0,n.R3)(e),rt={}}),3e3,!0);let rt={};(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteContact":return(0,p.GK)(e,s.id);case"updateUser":{Object.values(e.byTabId).forEach((n=>{let{id:a}=n;s.id===e.currentUserId&&s.user.isPremium!==(0,f.wVz)(e)&&(s.user.isPremium&&t.openPremiumModal({isSuccess:!0,tabId:a}),e={...e,translations:{byChatId:{}}})}));const n=(0,f.dyD)(e,s.id);return e=(0,p.Nq)(e,s.id,s.user),s.fullInfo&&(e=(0,p.ap)(e,s.id,s.fullInfo)),n?.areStoriesHidden!==s.user.areStoriesHidden&&(e=(0,p.QI)(e,s.id,s.user.areStoriesHidden||!1)),e}case"updateRequestUserUpdate":t.loadFullUser({userId:s.id});break;case"updateUserEmojiStatus":return(0,p.Nq)(e,s.userId,{emojiStatus:s.emojiStatus});case"updateUserStatus":return n=s.userId,a=s.status,rt[n]=a,void ot();case"updateUserFullInfo":{const{id:t,fullInfo:n}=s;return(0,p.ap)(e,t,n)}case"updateBotMenuButton":{const{botId:t,button:n}=s,a=(0,f.ccz)(e,t);if(!a?.botInfo)return;return(0,p.ap)(e,t,{botInfo:{...a.botInfo,menuButton:n}})}}var n,a})),(0,n.iw)("apiUpdate",((e,t,s)=>{if("updateStickerSet"===s["@type"])return(0,p.Rg)(e,s.id,s.stickerSet)})),(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,p.O4)(e,s.id):(0,p.rB)(e,s.id);case"updateResetContactList":e={...e,contactList:{userIds:[]}},(0,n.R3)(e);break;case"updateConfig":t.loadConfig();break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updateRecentStickers":t.loadRecentStickers();break;case"updateRecentReactions":t.loadRecentReactions();break;case"updateRecentEmojiStatuses":t.loadRecentEmojiStatuses();break;case"updateMoveStickerSetToTop":{const n=s.isCustomEmoji?e.customEmojis.added.setIds:e.stickers.added.setIds;if(!n)return e;const a=[s.id,...n.filter((e=>e!==s.id))];t.reorderStickerSets({order:a,isCustomEmoji:s.isCustomEmoji});break}case"updateStickerSets":t.loadStickerSets();break;case"updateStickerSetsOrder":{const n=s.order.filter((t=>Boolean(e.stickers.setsById[t])));t.reorderStickerSets({order:n,isCustomEmoji:s.isCustomEmoji});break}case"updateSavedGifs":t.loadSavedGifs();break;case"updatePrivacy":e={...e,settings:{...e.settings,privacy:{...e.settings.privacy,[s.key]:s.rules}}},(0,n.R3)(e);break;case"updatePaymentVerificationNeeded":Object.values(e.byTabId).forEach((t=>{let{id:n}=t;e=(0,p.fS)(e,s.url,n),e=(0,p.Q$)(e,m.KB.ConfirmPayment,n)})),(0,n.R3)(e);break;case"updateWebViewResultSent":Object.values(e.byTabId).forEach((e=>{e.webApp?.queryId===s.queryId&&(t.setReplyingToId({messageId:void 0,tabId:e.id}),t.closeWebApp({tabId:e.id}))}));break;case"updateStory":e=(0,p.Eq)(e,s.userId,{[s.story.id]:s.story}),e=(0,p.GC)(e,{[s.userId]:(0,f.GZu)(e,s.userId)}),(0,n.R3)(e);break;case"deleteStory":e=(0,p.mv)(e,s.userId,s.storyId),(0,n.R3)(e);break;case"updateReadStories":e=(0,p.kO)(e,s.userId,s.lastReadId),(0,n.R3)(e)}})),(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,p.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:a,isSilent:i,shouldShowPreviews:o}=s;e.chats.byId[t]&&(e=(0,p.a4)(e,t,{isMuted:a})),e=(0,p.aK)(e,t,{isMuted:a,isSilent:i,shouldShowPreviews:o}),(0,n.R3)(e);break}case"updateTopicNotifyExceptions":{const{chatId:t,topicId:a,isMuted:i}=s;e=(0,p.Cn)(e,t,a,{isMuted:i}),(0,n.R3)(e);break}}})),(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:s.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:s.message}}}}));var ct=s(78958),dt=s(42431);(0,n.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateGroupCall":{if("discarded"===s.call.connectionState)return e.groupCalls.activeGroupCallId?void("leaveGroupCall"in t&&t.leaveGroupCall({shouldRemove:!0,tabId:(0,P._w)()})):(0,ct.dc)(e,s.call.id);const n=(0,dt.$5)(e,s.call.id),a=n?.chatId;return a&&(e=(0,p.a4)(e,a,{isCallNotEmpty:n.participantsCount>0||Boolean(n.participants?.length)})),(0,ct.AH)(e,s.call.id,(0,g.CE)(s.call,["connectionState"]),void 0,s.call.participantsCount)}case"updateGroupCallChatId":return(0,f.Z1J)(e,s.chatId)&&(e=(0,p.US)(e,s.chatId,{groupCallId:s.call.id})),e;case"updateGroupCallParticipants":{const{groupCallId:t,participants:a,nextOffset:i}=s,{currentUserId:o}=e;e=(0,n.Rd)(),a.forEach((s=>{s.id&&(e=(0,ct.B6)(e,t,s.id,s,Boolean(i)||o===s.id))})),i&&(e=(0,ct.AH)(e,t,{nextOffset:i}));const r=(0,dt.$5)(e,t),c=r?.chatId;return c&&(e=(0,p.a4)(e,c,{isCallNotEmpty:r.participantsCount>0||Boolean(r.participants?.length)})),e}case"updatePhoneCall":{if(!a.Bi)return;const{phoneCall:i,currentUserId:o}=e,{call:r}=s;if(i)return"discarded"===r.state?(t.playGroupCallSound({sound:"end"}),"hangUp"in t&&t.hangUp({tabId:(0,P._w)()}),{...e,...r.needRating&&{ratingPhoneCall:r}}):void 0;if(r?.adminId!==o&&"requested"===r.state)return(0,I.R3)((()=>{e=(0,n.Rd)(),(0,C.TO)({call:r,user:(0,dt.fu)(e)})})),(0,et.EP)(),(0,et.CW)(e,t,r.isVideo,(0,P._w)()),e={...e,phoneCall:r},(0,b.i)(e,{isCallPanelVisible:!1},(0,P._w)())}}}));var lt=s(9937);(0,n.iw)("apiUpdate",((e,t,s)=>{"updatePaymentStateCompleted"===s["@type"]&&Object.values(e.byTabId).forEach((n=>{let{id:i}=n;const{inputInvoice:o}=(0,f.jUK)(e,i).payment;if(o&&"chatId"in o&&"messageId"in o){const s=(0,f.hjO)(e,o.chatId,o.messageId);if(s&&s.content.invoice){const{amount:e,currency:n,title:a}=s.content.invoice;t.showNotification({tabId:i,message:w.Iu("PaymentInfoHint",[(0,lt.x)(e,n,w.QO().code),a])})}}a.Xp||(e=(0,p.WY)(e,i)),s.slug&&o&&"slug"in o&&o.slug!==s.slug||(e=(0,b.i)(e,{payment:{...(0,f.jUK)(e,i).payment,status:"paid"}},i))}))}));var ut=s(46752),mt=s(1279),ht=s(53551),gt=s(99203),pt=s(25190),ft=s(45332),It=s(58637),vt=s(34446);const wt=document.querySelector('meta[name="viewport"]'),yt=wt?.getAttribute("content")||"",bt="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function Pt(e){e.preventDefault()}var Zt=s(65326),Ct=s(31212),St=s(18674),Mt=s(62357),Et=s(36413),Rt=s(28183),kt=s(48778);const Tt=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"StickerSetModal",!t);return s?o.ZP.createElement(s,e):void 0};var At=s(2155),Nt=s(95616),xt=s(17358);const Bt=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,Nt.yi)();const s=(0,me.xW)();if((0,o.d4)((()=>{t&&(0,xt.w)(s)}),[t,s]),!t&&s)return o.ZP.createElement("div",{className:"unread-count active"},(0,At.bi)(s))}));var Ut=s(23989),Lt=s(53455),Ot=s(73541),jt=s(2255),_t=s(59107),Ft=s(54416),Dt=s(706);let qt=function(e){return e[e.waitingForNetwork=0]="waitingForNetwork",e[e.syncing=1]="syncing",e[e.online=2]="online",e}({});function Gt(e,t,s,n,a,i){let r,c,d;return r=function(){const[e,t]=(0,o.eJ)(window.navigator.onLine);return(0,o.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}()&&"connectionStateConnecting"!==t?s?qt.syncing:qt.online:qt.waitingForNetwork,c=r===qt.online||i?"none":n?"middleHeader":a?"minimized":"overlay",r===qt.waitingForNetwork?d=e("WaitingForNetwork"):r===qt.syncing&&(d=e("Updating")),"middleHeader"===c&&(d=d.toLowerCase().replace(/\.+$/,"")),{connectionStatus:r,connectionStatusPosition:c,connectionStatusText:d}}var Ht=s(36046),$t=s(73217),Vt=s(97458),Kt=s(53106),Jt=s(58964),zt=s(231),Wt=s(69589),Yt=s(49187),Xt=s(83321),Qt=s(40126),es=s(49204);const ts=(0,o.X$)((e=>{let{connectionStatus:t,connectionStatusText:s,onClick:n}=e;const a=(0,_t.Z)();return o.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:a.isRtl?"rtl":void 0,onClick:n},o.ZP.createElement(es.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},o.ZP.createElement(jt.Z,{activeKey:t,name:"slideFade"},s)),o.ZP.createElement(zt.Z,{round:!0,size:"tiny",color:"translucent-black"},o.ZP.createElement("span",{className:"icon icon-close"})))}));var ss=s(60706),ns=s(274),as=s(96459),is=s(4863),os=s(6202);const rs="HO3tML0GAC9vTH28baKB",cs=(0,o.X$)((e=>{let{reaction:t,isLottie:s,className:n}=e;const i=(0,v.RK)(t.documentId),r=(0,os.Z)(s?void 0:i),c=(0,o.Ye)((()=>a._G?Array.from({length:7}).map((()=>function(){const e=(10+60*Math.random())*(Math.random()>.5?1:-1),t=20+80*Math.random();return`M 0 0 C 0 0 ${e} ${-t-20} ${e} ${t}`}())):[]),[]);if(r||s)return o.ZP.createElement("div",{className:(0,ut.Z)("HAg4STRlxDV3frYuABYr",n)},c.map((e=>{const n=`--offset-path: path('${e}');`;return s?o.ZP.createElement(as.Z,{documentId:t.documentId,className:rs,style:n,withSharedAnimation:!0}):o.ZP.createElement("img",{src:r,alt:"",className:rs,style:n})})))})),ds=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"StatusPickerMenu",!t);return s?o.ZP.createElement(s,e):void 0},ls=(0,o.X$)((0,n.c$)((e=>{const{currentUserId:t}=e;return{emojiStatus:(t?(0,f.dyD)(e,t):void 0)?.emojiStatus}}))((e=>{let{emojiStatus:t}=e;const{setEmojiStatus:s,loadCurrentUser:a}=(0,n.Sv)(),r=(0,o.sO)(null),[c,d,l]=(0,ss.Z)(!1),[u,m,h]=(0,ss.Z)(!1),[g,p,f]=(0,ss.Z)(!1),{isMobile:I}=(0,B.ZP)(),v=t?.until?1e3*t.until-Date.now()+1e3*(0,pe.Qj)():void 0;(0,Rt.Z)(a,v),(0,ns.Z)((e=>{let[s]=e;c&&t&&s&&t.documentId!==s.documentId&&(m(),l())}),[t,c,m,l]);const w=(0,o.I4)((e=>{d(),s({emojiStatus:e})}),[d,s]);(0,Rt.Z)(h,u?1500:void 0);const y=(0,o.I4)((()=>{p()}),[p]);return o.ZP.createElement("div",{className:"extra-spacing"},Boolean(u&&t)&&o.ZP.createElement(cs,{reaction:t,isLottie:!0,className:"emoji-status-effect"}),o.ZP.createElement(zt.Z,{round:!0,ref:r,ripple:!I,size:"smaller",color:"translucent",className:"emoji-status",onClick:y},t?o.ZP.createElement(as.Z,{key:t.documentId,documentId:t.documentId,size:24,loopLimit:i.y3O}):o.ZP.createElement(is.Z,null)),o.ZP.createElement(ds,{statusButtonRef:r,isOpen:g,onEmojiStatusSelect:w,onClose:f}))})));var us=s(79994),ms=s(66372);const hs={date:void 0},gs={id:void 0},ps=(0,o.X$)((0,n.c$)((e=>{const t=(0,f.jUK)(e),{query:s,fetchingStatus:n,chatId:a,date:i}=t.globalSearch,{currentUserId:o,connectionState:r,isSyncing:c,archiveSettings:d,isFetchingDifference:l}=e,{isConnectionStatusMinimized:u,animationLevel:m}=e.settings.byKey;return{searchQuery:s,isLoading:!!n&&Boolean(n.chats||n.messages),currentUserId:o,globalSearchChatId:a,searchDate:i,theme:(0,f.Puy)(e),animationLevel:m,connectionState:r,isSyncing:c,isFetchingDifference:l,isMessageListOpen:Boolean((0,f.Btg)(e)),isConnectionStatusMinimized:u,isCurrentUserPremium:(0,f.wVz)(e),areChatsLoaded:Boolean(e.chats.listIds.active),hasPasscode:Boolean(e.passcode.hasPasscode),canInstall:Boolean(t.canInstall),archiveSettings:d,canSetPasscode:(0,f.eB8)(e)}}))((e=>{let{shouldHideSearch:t,content:s,contactsFilter:r,onSearchQuery:c,isClosingSearch:d,onSelectSettings:l,onSelectContacts:u,onSelectArchived:h,onReset:g,searchQuery:p,isLoading:f,isCurrentUserPremium:I,shouldSkipTransition:v,currentUserId:w,globalSearchChatId:y,searchDate:b,theme:P,animationLevel:Z,connectionState:C,isSyncing:S,isFetchingDifference:M,isMessageListOpen:E,isConnectionStatusMinimized:R,areChatsLoaded:k,hasPasscode:T,canSetPasscode:A,canInstall:N,archiveSettings:x}=e;const{openChat:U,openChatWithInfo:L,setGlobalSearchDate:O,setSettingOption:j,setGlobalSearchChatId:_,openChatByUsername:F,lockScreen:D,requestNextSettingsScreen:q,skipLockOnUnload:G,openUrl:H,updatePerformanceSettings:$}=(0,n.Sv)(),V=(0,_t.Z)(),{isMobile:K}=(0,B.ZP)(),J=s===m.du.ChatList,z=(0,o.Ye)((()=>b?(0,re.xH)(new Date(1e3*b)):void 0),[b]),W=(0,Nt.yi)()[i.WSp]?.chatsCount||0,{connectionStatus:Y,connectionStatusText:X,connectionStatusPosition:Q}=Gt(V,C,S||M,E,R,!k),ee=(0,pt.Z)((e=>{e.preventDefault(),e.stopPropagation(),T?D():q({screen:m.MT.PasscodeDisabled})})),te=(0,pt.Z)((()=>{L({id:w,shouldReplaceHistory:!0,profileTab:"stories"})}));(0,Ot.y)(A?{"Ctrl+Shift+L":ee,"Alt+Shift+L":ee,"Meta+Shift+L":ee,...a.RM&&{"Mod+L":ee}}:void 0);const se=window.location.hostname===i.xHY||i.Cgt,ne=(0,o.Ye)((()=>e=>{let{onTrigger:t,isOpen:s}=e;return o.ZP.createElement(zt.Z,{round:!0,ripple:J&&!K,size:"smaller",color:"translucent",className:s?"active":"",onClick:J?t:()=>g(),ariaLabel:J?V("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,ut.Z)("animated-menu-icon",!J&&"state-back",v&&"no-animation")}))}),[J,K,V,g,v]),ae=(0,pt.Z)((()=>{p||c("")})),ie=(0,pt.Z)((()=>{j({isConnectionStatusMinimized:!R})})),oe=(0,pt.Z)((()=>{U({id:w,shouldReplaceHistory:!0})})),ce=(0,pt.Z)((e=>{e.stopPropagation(),j({theme:"light"===P?"dark":"light"}),j({shouldUseSystemTheme:!1})})),de=(0,pt.Z)((e=>{e.stopPropagation();let t=Z+1;t>i.zy8&&(t=i.oBh);const s=t===i.oBh?at.ww:t===i.zy8?at.WD:at.LN;j({animationLevel:t}),$(s)})),le=(0,pt.Z)((()=>{window.open(i.ulW,"_blank","noopener")})),ue=(0,pt.Z)((()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,Dt.W8)(),G()})),me=(0,pt.Z)((()=>{F({username:V("Settings.TipsUsername")})})),he=(0,pt.Z)((()=>{H({url:i.mUA})})),ge=(0,pt.Z)((()=>{D()})),pe=Boolean(y)||s===m.du.GlobalSearch||s===m.du.Contacts;(0,o.d4)((()=>pe?(0,Ut.Z)((()=>g())):void 0),[pe,g]);const fe=s===m.du.Contacts?V("SearchFriends"):V("Search"),Ie=i.Tjg?"10.0.0 Beta (master)":i.eMD?"master":"10.0.0",ve=Z!==i.oBh?Z===i.zy8?"max":"mid":"min",we=(0,Et.Ar)(),{shouldDisableDropdownMenuTransitionRef:ye,handleDropdownMenuTransitionEnd:be}=(0,$t.Z)(t),Pe=(0,o.sO)(null);(0,Vt.Z)(Pe);const Ze=(0,o.Ye)((()=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Jt.Z,{icon:"saved-messages",onClick:oe},V("SavedMessages")),x.isHidden&&o.ZP.createElement(Jt.Z,{icon:"archive",onClick:h},o.ZP.createElement("span",{className:"menu-item-name"},V("ArchivedChats")),W>0&&o.ZP.createElement("div",{className:"right-badge"},W)),o.ZP.createElement(Jt.Z,{icon:"user",onClick:u},V("Contacts")),o.ZP.createElement(Jt.Z,{icon:"play-story",onClick:te},V("Settings.MyStories")),o.ZP.createElement(Jt.Z,{icon:"settings",onClick:l},V("Settings")),o.ZP.createElement(Jt.Z,{icon:"darkmode",onClick:ce},o.ZP.createElement("span",{className:"menu-item-name"},V("lng_menu_night_mode")),o.ZP.createElement(Xt.Z,{id:"darkmode",label:V("dark"===P?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===P,noAnimation:!0})),o.ZP.createElement(Jt.Z,{icon:"animations",onClick:de},o.ZP.createElement("span",{className:"menu-item-name capitalize"},V("Appearance.Animations").toLowerCase()),o.ZP.createElement(us.Z,{value:ve})),o.ZP.createElement(Jt.Z,{icon:"help",onClick:me},V("TelegramFeatures")),o.ZP.createElement(Jt.Z,{icon:"bug",onClick:he},"Report Bug"),i.Tjg&&o.ZP.createElement(Jt.Z,{icon:"permissions",onClick:le},"Beta Changelog"),se&&o.ZP.createElement(Jt.Z,{icon:"K",isCharIcon:!0,href:"https://web.telegram.org/k/",onClick:ue},"Switch to K Version"),N&&o.ZP.createElement(Jt.Z,{icon:"install",onClick:(0,Ht.G)()},"Install App"))),[ve,W,N,de,he,V,le,ce,me,oe,ue,h,u,l,P,se,x]),Ce=(0,o.Ye)((()=>o.ZP.createElement(o.ZP.Fragment,null,z&&o.ZP.createElement(Yt.Z,{icon:"calendar",title:z,canClose:!0,isMinimized:Boolean(y),className:"search-date",onClick:O,clickArg:hs}),y&&o.ZP.createElement(Yt.Z,{chatOrUserId:y,onClick:_,canClose:!0,clickArg:gs}))),[y,z]);return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header",ref:Pe},V.isRtl&&o.ZP.createElement("div",{className:"DropdownMenuFiller"}),o.ZP.createElement(Kt.Z,{trigger:ne,footer:`${i.iCi} ${Ie}`,className:(0,ut.Z)("main-menu",V.isRtl&&"rtl",t&&V.isRtl&&"right-aligned",ye.current&&V.isRtl&&"disable-transition"),positionX:t&&V.isRtl?"right":"left",transformOriginX:i.D$V&&a.jm&&!we?90:void 0,onTransitionEnd:V.isRtl?be:void 0},Ze),o.ZP.createElement(Wt.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:(0,ut.Z)(y||b?"with-picker-item":void 0,t&&"SearchInput--hidden"),value:d?void 0:r||p,focused:pe,isLoading:f||"minimized"===Q,spinnerColor:"minimized"===Q?"yellow":void 0,spinnerBackgroundColor:"minimized"===Q&&"light"===P?"light":void 0,placeholder:fe,autoComplete:"off",canClose:Boolean(y||b),onChange:c,onReset:g,onFocus:ae,onSpinnerClick:"minimized"===Q?ie:void 0},Ce,o.ZP.createElement(ms.Z,{canShow:!pe&&!z&&!y})),I&&o.ZP.createElement(ls,null),T&&o.ZP.createElement(zt.Z,{round:!0,ripple:!K,size:"smaller",color:"translucent",ariaLabel:`${V("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:ge,className:(0,ut.Z)(!I&&"extra-spacing")},o.ZP.createElement("i",{className:"icon icon-lock"})),o.ZP.createElement(Qt.Z,{isOpen:"overlay"===Q,isCustom:!0,className:"connection-state-wrapper"},o.ZP.createElement(ts,{connectionStatus:Y,connectionStatusText:X,onClick:ie}))))})));var fs=s(64963),Is=s(46590),vs=s(31711),ws=s(59148),ys=s(78853);const bs=200+i.fK3,Ps=(0,o.X$)((0,n.c$)((e=>{const{chatFolders:{byId:t,orderedIds:s,invites:n},chats:{listIds:{archived:a}},stories:{orderedUserIds:{archived:i}},currentUserId:o,archiveSettings:r}=e,{shouldSkipHistoryAnimations:c,activeChatFolder:d}=(0,f.jUK)(e),{storyViewer:{isRibbonShown:l}}=(0,f.jUK)(e);return{chatFoldersById:t,folderInvitesById:n,orderedFolderIds:s,activeChatFolder:d,currentUserId:o,shouldSkipHistoryAnimations:c,hasArchivedChats:Boolean(a?.length),hasArchivedStories:Boolean(i?.length),maxFolders:(0,se.M)(e,"dialogFilters"),maxFolderInvites:(0,se.M)(e,"chatlistInvites"),maxChatLists:(0,se.M)(e,"chatlistJoined"),archiveSettings:r,isStoryRibbonShown:l}}))((e=>{let{foldersDispatch:t,onSettingsScreenSelect:s,onLeftColumnContentChange:r,chatFoldersById:c,orderedFolderIds:d,activeChatFolder:l,currentUserId:u,isForumPanelOpen:m,shouldSkipHistoryAnimations:h,maxFolders:g,maxChatLists:p,shouldHideFolderTabs:I,folderInvitesById:v,maxFolderInvites:w,hasArchivedChats:y,hasArchivedStories:b,archiveSettings:P,isStoryRibbonShown:Z}=e;const{loadChatFolders:C,setActiveChatFolder:S,openChat:M,openShareChatFolderModal:E,openDeleteChatFolderModal:R,openEditChatFolder:k,openLimitReachedModal:T}=(0,n.Sv)(),A=(0,o.sO)(null),N=(0,_t.Z)(),[x,B]=(0,o.eJ)(!1);(0,o.d4)((()=>{C()}),[]),(0,o.bt)((()=>{let e;return Z?e=window.setTimeout((()=>{B(!0)}),bs):B(!1),()=>{window.clearTimeout(e)}}),[Z]);const{shouldRender:U,transitionClassNames:L,isClosing:O}=(0,Ct.Z)(Z,void 0,void 0,""),j=(0,o.Ye)((()=>({id:i.NfV,title:d?.[0]===i.NfV?N("FilterAllChatsShort"):N("FilterAllChats"),includedChatIds:Ue.D,excludedChatIds:Ue.D})),[d,N]),_=(0,o.Ye)((()=>d?d.map((e=>e===i.NfV?j:c[e]||{})).filter(Boolean):void 0),[c,j,d]),F=_?.findIndex((e=>e.id===i.NfV)),D=F===l,q=0===l,G=(0,Nt.yi)(),H=(0,o.Ye)((()=>{if(_&&_.length)return _.map(((e,t)=>{const{id:s,title:a}=e,o=s!==i.NfV&&t>g-1,r=[];return(0,f.yEv)((0,n.Rd)(),s)&&r.push({title:N("ChatList.ContextMenuShare"),icon:"link",handler:()=>{Object.values(c).reduce(((e,t)=>e+(t.isChatList?1:0)),0)>=p&&!e.isChatList?T({limit:"chatlistJoined"}):v[s]?.length>=w?T({limit:"chatlistInvites"}):E({folderId:s})}}),s!==i.NfV&&(r.push({title:N("FilterEdit"),icon:"edit",handler:()=>{k({folderId:s})}}),r.push({title:N("FilterDeleteItem"),icon:"delete",destructive:!0,handler:()=>{R({folderId:s})}})),{id:s,title:a,badgeCount:G[s]?.chatsCount,isBadgeActive:Boolean(G[s]?.notificationsCount),isBlocked:o,contextActions:r?.length?r:void 0}}))}),[_,g,G,N,c,p,v,w]),$=(0,pt.Z)((e=>{S({activeChatFolder:e},{forceOnHeavyAnimation:!0})}));(0,o.d4)((()=>{H?.length&&l>=H.length&&S({activeChatFolder:0})}),[l,H,S]),(0,o.d4)((()=>{if(a.$b&&H?.length&&!m)return(0,fs.sf)(A.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===fs.eM.Left?(S({activeChatFolder:Math.min(l+1,H.length-1)},{forceOnHeavyAnimation:!0}),!0):t===fs.eM.Right&&(S({activeChatFolder:Math.max(0,l-1)},{forceOnHeavyAnimation:!0}),!0)})}),[l,H,m,S]);const V=(0,o.sO)();V.current=!q,(0,o.d4)((()=>V.current?(0,Ut.Z)((()=>{V.current&&S({activeChatFolder:0})})):void 0),[l,S]),(0,Is.Z)({isActive:!q,onBack:()=>S({activeChatFolder:0},{forceOnHeavyAnimation:!0})}),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&H){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void M({id:u,shouldReplaceHistory:!0});const s=Number(t)-1;if(s>H.length-1)return;S({activeChatFolder:s},{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}),[u,H,M,S]);const{shouldRender:K,transitionClassNames:J}=(0,Ct.Z)(!d,void 0,!0);function z(e){const n=Object.values(c).find((e=>{let{id:t}=e;return t===H[l].id})),a=n&&!D;return o.ZP.createElement(ws.Z,{folderType:a?"folder":"all",folderId:a?n.id:void 0,isActive:e,isForumPanelOpen:m,foldersDispatch:t,onSettingsScreenSelect:s,onLeftColumnContentChange:r,canDisplayArchive:(y||b)&&!P.isHidden,archiveSettings:P})}const W=H&&H.length>1;return o.ZP.createElement("div",{className:(0,ut.Z)("ChatFolders",W&&I&&"ChatFolders--tabs-hidden",U&&!x&&"withStoryRibbon",L)},U&&o.ZP.createElement(ys.Z,{isClosing:O}),W?o.ZP.createElement(vs.Z,{contextRootElementSelector:"#LeftColumn",tabs:H,activeTab:l,onSwitchTab:$,areFolders:!0}):K?o.ZP.createElement("div",{className:(0,ut.Z)("tabs-placeholder",J)}):void 0,o.ZP.createElement(jt.Z,{ref:A,name:h?"none":N.isRtl?"slideOptimizedRtl":"slideOptimized",activeKey:l,renderCount:W?H.length:void 0},z))})));var Zs=s(34288);const Cs=e=>{const t=(0,kt.Z)(gt.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},Ss=e=>{const t=(0,kt.Z)(gt.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)};var Ms=s(52328);const Es=e=>{let{isShown:t,onNewPrivateChat:s,onNewChannel:n,onNewGroup:a}=e;const[i,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{t||r(!1)}),[t]);const c=(0,_t.Z)(),d=(0,ut.Z)("NewChatButton",t&&"revealed",i&&"menu-is-open"),l=(0,o.I4)((()=>{r(!i)}),[i]),u=(0,o.I4)((()=>{r(!1)}),[]),m=(0,o.Ye)((()=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Jt.Z,{icon:"channel",onClick:n},c("NewChannel")),o.ZP.createElement(Jt.Z,{icon:"group",onClick:a},c("NewGroup")),o.ZP.createElement(Jt.Z,{icon:"user",onClick:s},c("NewMessageTitle")))),[c,n,a,s]);return o.ZP.createElement("div",{className:d,dir:c.isRtl?"rtl":void 0},o.ZP.createElement(zt.Z,{round:!0,color:"primary",className:i?"active":"",onClick:l,ariaLabel:c(i?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon icon-close"})),o.ZP.createElement(Ms.Z,{isOpen:i,positionX:c.isRtl?"left":"right",positionY:"bottom",autoClose:!0,onClose:u},m))};var Rs=s(59690);const ks=Object.keys(m.du).length/2;let Ts;const As=(0,o.X$)((e=>{let{content:t,searchQuery:s,searchDate:r,isClosingSearch:c,contactsFilter:d,shouldSkipTransition:l,foldersDispatch:u,isUpdateAvailable:h,isForumPanelOpen:g,onSearchQuery:p,onContentChange:f,onSettingsScreenSelect:I,onReset:v,onTopicSearch:w}=e;const{closeForumPanel:y}=(0,n.Sv)(),[b,P]=(0,o.eJ)(a.$b),{shouldRenderForumPanel:Z,handleForumPanelAnimationEnd:C,handleForumPanelAnimationStart:S,isAnimationStarted:M}=(0,Ft.Z)(g),E=g&&t===m.du.ChatList,R=E&&M,{shouldRender:k,transitionClassNames:T}=(0,Ct.Z)(h),A=(0,o.sO)(!1),N=(0,pt.Z)((()=>{t===m.du.ChatList&&(A.current=!0,P(!0))})),x=(0,pt.Z)((()=>{A.current=!1,Ts&&(clearTimeout(Ts),Ts=void 0),Ts=window.setTimeout((()=>{A.current||P(!1)}),250)})),B=(0,pt.Z)((()=>{f(m.du.Settings)})),U=(0,pt.Z)((()=>{f(m.du.Contacts)})),L=(0,pt.Z)((()=>{f(m.du.Archived),y()})),O=(0,pt.Z)((()=>{i.D$V?window.electron?.installUpdate():window.location.reload()})),j=(0,pt.Z)((()=>{f(m.du.NewChannelStep1)})),_=(0,pt.Z)((()=>{f(m.du.NewGroupStep1)}));(0,o.d4)((()=>{let e;return t!==m.du.ChatList?e=window.setTimeout((()=>{P(!1)}),250):(A.current||a.$b)&&P(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const F=(0,_t.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:a.$b?void 0:N,onMouseLeave:a.$b?void 0:x},o.ZP.createElement(ps,{shouldHideSearch:R,content:t,contactsFilter:d,onSearchQuery:p,onSelectSettings:B,onSelectContacts:U,onSelectArchived:L,onReset:v,shouldSkipTransition:l,isClosingSearch:c}),o.ZP.createElement(jt.Z,{name:l?"none":"zoomFade",renderCount:ks,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList,shouldWrap:!0,wrapExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return o.ZP.createElement(Ps,{shouldHideFolderTabs:R,onSettingsScreenSelect:I,onLeftColumnContentChange:f,foldersDispatch:u,isForumPanelOpen:R});case m.du.GlobalSearch:return o.ZP.createElement(Cs,{searchQuery:s,searchDate:r,isActive:e,onReset:v});case m.du.Contacts:return o.ZP.createElement(Ss,{filter:d,isActive:e,onReset:v});default:return}})),k&&o.ZP.createElement(zt.Z,{fluid:!0,pill:!0,className:(0,ut.Z)("btn-update",T),onClick:O},F("lng_update_telegram")),Z&&o.ZP.createElement(Rs.Z,{isOpen:g,isHidden:!E,onTopicSearch:w,onOpenAnimationStart:S,onCloseAnimationEnd:C}),o.ZP.createElement(Es,{isShown:b,onNewPrivateChat:U,onNewChannel:j,onNewGroup:_}))})),Ns=e=>{const t=(0,kt.Z)(gt.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},xs=e=>{const t=(0,kt.Z)(gt.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},Bs=e=>{const t=(0,kt.Z)(gt.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)};var Us=function(e){return e[e.Main=0]="Main",e[e.Settings=1]="Settings",e[e.Archived=2]="Archived",e[e.NewGroup=3]="NewGroup",e[e.NewChannel=4]="NewChannel",e}(Us||{});const Ls=Object.keys(Us).length/2,Os=(0,o.X$)((0,n.c$)((e=>{const t=(0,f.jUK)(e),{globalSearch:{query:s,date:n},shouldSkipHistoryAnimations:a,activeChatFolder:i,nextSettingsScreen:o,nextFoldersAction:r,storyViewer:{isArchivedRibbonShown:c}}=t,{currentUserId:d,passcode:{hasPasscode:l},isUpdateAvailable:u,archiveSettings:m}=e,h=(0,f.jrE)(e);return{searchQuery:s,searchDate:n,isFirstChatFolderActive:0===i,shouldSkipHistoryAnimations:a,currentUserId:d,hasPasscode:l,nextSettingsScreen:o,nextFoldersAction:r,isChatOpen:Boolean(h?.id),isUpdateAvailable:u,isForumPanelOpen:(0,f.nd)(e),forumPanelChatId:t.forumPanelChatId,isClosingSearch:t.globalSearch.isClosing,archiveSettings:m,isArchivedStoryRibbonShown:c}}))((function(e){let{ref:t,searchQuery:s,searchDate:i,isFirstChatFolderActive:r,shouldSkipHistoryAnimations:c,currentUserId:d,hasPasscode:l,nextSettingsScreen:u,nextFoldersAction:h,isChatOpen:g,isUpdateAvailable:p,isForumPanelOpen:f,forumPanelChatId:I,isClosingSearch:v,archiveSettings:w,isArchivedStoryRibbonShown:y}=e;const{setGlobalSearchQuery:b,setGlobalSearchClosing:P,setGlobalSearchChatId:Z,resetChatCreation:C,setGlobalSearchDate:S,loadPasswordInfo:M,clearTwoFaError:E,openChat:R,requestNextSettingsScreen:k}=(0,n.Sv)(),[T,A]=(0,o.eJ)(m.du.ChatList),[N,x]=(0,o.eJ)(m.MT.Main),[B,U]=(0,o.eJ)(""),[L,O]=(0,Lt.ZP)(),[j,_]=(0,o.eJ)(0);let F=Us.Main;switch(T){case m.du.Archived:F=Us.Archived;break;case m.du.Settings:F=Us.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:F=Us.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:F=Us.NewGroup}const D=(0,pt.Z)((e=>{function t(){A(m.du.ChatList),x(m.MT.Main),U(""),P({isClosing:!0}),C(),setTimeout((()=>{b({query:""}),S({date:void 0}),Z({id:void 0}),P({isClosing:!1}),_(Date.now())}),250)}if(!0!==e)if(T!==m.du.NewGroupStep2)if(T!==m.du.NewChannelStep2){if(T===m.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(T===m.du.Settings)switch(N){case m.MT.EditProfile:case m.MT.Folders:case m.MT.General:case m.MT.Notifications:case m.MT.DataStorage:case m.MT.Privacy:case m.MT.Performance:case m.MT.ActiveSessions:case m.MT.Language:case m.MT.Stickers:case m.MT.Experimental:return void x(m.MT.Main);case m.MT.GeneralChatBackground:return void x(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void x(m.MT.GeneralChatBackground);case m.MT.PrivacyPhoneNumber:case m.MT.PrivacyLastSeen:case m.MT.PrivacyProfilePhoto:case m.MT.PrivacyPhoneCall:case m.MT.PrivacyPhoneP2P:case m.MT.PrivacyForwarding:case m.MT.PrivacyGroupChats:case m.MT.PrivacyVoiceMessages:case m.MT.PrivacyBlockedUsers:case m.MT.ActiveWebsites:case m.MT.TwoFaDisabled:case m.MT.TwoFaEnabled:case m.MT.TwoFaCongratulations:case m.MT.PasscodeDisabled:case m.MT.PasscodeEnabled:case m.MT.PasscodeCongratulations:return void x(m.MT.Privacy);case m.MT.PasscodeNewPasscode:return void x(l?m.MT.PasscodeEnabled:m.MT.PasscodeDisabled);case m.MT.PasscodeChangePasscodeCurrent:case m.MT.PasscodeTurnOff:return void x(m.MT.PasscodeEnabled);case m.MT.PasscodeNewPasscodeConfirm:return void x(m.MT.PasscodeNewPasscode);case m.MT.PasscodeChangePasscodeNew:return void x(m.MT.PasscodeChangePasscodeCurrent);case m.MT.PasscodeChangePasscodeConfirm:return void x(m.MT.PasscodeChangePasscodeNew);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void x(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void x(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void x(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyPhoneCallAllowedContacts:case m.MT.PrivacyPhoneCallDeniedContacts:return void x(m.MT.PrivacyPhoneCall);case m.MT.PrivacyPhoneP2PAllowedContacts:case m.MT.PrivacyPhoneP2PDeniedContacts:return void x(m.MT.PrivacyPhoneP2P);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void x(m.MT.PrivacyForwarding);case m.MT.PrivacyVoiceMessagesAllowedContacts:case m.MT.PrivacyVoiceMessagesDeniedContacts:return void x(m.MT.PrivacyVoiceMessages);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void x(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void x(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void x(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void x(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void x(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void x(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void x(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void x(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void x(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void x(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void x(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void x(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void x(m.MT.Folders);case m.MT.FoldersShare:return void x(m.MT.FoldersEditFolder);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void x(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:case m.MT.FoldersEditFolderInvites:return A(m.du.ChatList),void x(m.MT.Main);case m.MT.QuickReaction:case m.MT.CustomEmoji:return void x(m.MT.Stickers);case m.MT.DoNotTranslate:return void x(m.MT.Language)}T===m.du.ChatList&&r?A(m.du.GlobalSearch):t()}else A(m.du.NewChannelStep1);else A(m.du.NewGroupStep1);else t()})),q=(0,pt.Z)((e=>{T!==m.du.Contacts?(A(m.du.GlobalSearch),e!==s&&b({query:e})):U(e)})),G=(0,pt.Z)((()=>{A(m.du.GlobalSearch),b({query:""}),Z({id:I})}));(0,o.d4)((()=>{const e=T===m.du.Archived,t=T===m.du.ChatList,s=!g&&!f;return e&&s||!t&&!e||r&&s?(0,Ut.Z)((()=>{D()})):void 0}),[r,T,D,g,f]);const H=(0,pt.Z)((e=>{T!==m.du.GlobalSearch&&(e.preventDefault(),A(m.du.GlobalSearch))})),$=(0,pt.Z)((e=>{e.preventDefault(),R({id:d,shouldReplaceHistory:!0})})),V=(0,pt.Z)((e=>{e.preventDefault(),A(m.du.Archived)})),K=(0,pt.Z)((e=>{e.preventDefault(),A(m.du.Settings)}));(0,Ot.y)({"Mod+Shift+F":H,"Mod+Shift+S":$,...a.RM&&{"Mod+0":$,"Mod+9":V},...a.jm&&a.RM&&{"Mod+,":K}}),(0,o.d4)((()=>{E(),N===m.MT.Privacy&&M()}),[E,M,N]),(0,vt.Z)((()=>{void 0!==u&&(A(m.du.Settings),x(u),k({screen:void 0})),h&&O(h)}),[O,h,u,k]);const J=(0,pt.Z)((e=>{A(m.du.Settings),x(e)}));function z(e){switch(F){case Us.Archived:return o.ZP.createElement(Bs,{isActive:e,onReset:D,onTopicSearch:G,foldersDispatch:O,onSettingsScreenSelect:J,onLeftColumnContentChange:A,isForumPanelOpen:f,archiveSettings:w,isStoryRibbonShown:y});case Us.Settings:return o.ZP.createElement(Ns,{isActive:e,currentScreen:N,foldersState:L,foldersDispatch:O,onScreenSelect:J,onReset:D,shouldSkipTransition:c});case Us.NewChannel:return o.ZP.createElement(xs,{key:j,isActive:e,isChannel:!0,content:T,onContentChange:A,onReset:D});case Us.NewGroup:return o.ZP.createElement(xs,{key:j,isActive:e,content:T,onContentChange:A,onReset:D});default:return o.ZP.createElement(As,{content:T,isClosingSearch:v,searchQuery:s,searchDate:i,contactsFilter:B,foldersDispatch:O,onContentChange:A,onSearchQuery:q,onSettingsScreenSelect:J,onReset:D,shouldSkipTransition:c,isUpdateAvailable:p,isForumPanelOpen:f,onTopicSearch:G})}}return o.ZP.createElement(jt.Z,{ref:t,name:c?"none":a.s0,renderCount:Ls,activeKey:F,shouldCleanup:!0,cleanupExceptionKey:Us.Main,shouldWrap:!0,wrapExceptionKey:Us.Main,id:"LeftColumn"},z)})));var js=s(12420),_s=s(80036),Fs=s(49524),Ds=s(71394);var qs=s(12255),Gs=s(52678),Hs=s(87204),$s=s(28712),Vs=s(3570),Ks=s(33799),Js=s(39415),zs=s(75790),Ws=s(18360),Ys=s(86203),Xs=s(6058),Qs=s(98799),en=s(59188),tn=s(32340),sn=s(2903),nn=s(17891),an=s(68512),on=s(17551);const rn={"pinned-message-border":"II9Qj_b_XQlgwGAOoy7u",pinnedMessageBorder:"II9Qj_b_XQlgwGAOoy7u","pinned-message-border-wrapper-1":"QpNjYZM0KJrGrocs69__",pinnedMessageBorderWrapper1:"QpNjYZM0KJrGrocs69__","pinned-message-border-wrapper":"sNpxwL0ihB0aXnfphNmp",pinnedMessageBorderWrapper:"sNpxwL0ihB0aXnfphNmp","pinned-message-border-mark":"YX_iyQuDtga6uKXRQqR0",pinnedMessageBorderMark:"YX_iyQuDtga6uKXRQqR0"};function cn(e,t,s,n,a){return`M${e},${t+a}a${a},${a},0,0,1,\n ${s},0v${n-2*a}a${a},${a},0,0,1,${-s},0Z`}const dn=(0,o.X$)((e=>{let{count:t,index:s}=e;const n=(0,o.sO)(null),a=(0,o.Ye)((()=>function(e,t){const s=e-t-1,n=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),a=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),i=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,n),o=`clipPath${e}`,r=function(e,t,s){let n="";if(3===s)n=cn(0,0,2,t,1)+cn(0,12,2,t+1,1)+cn(0,25,2,t,1);else for(let e=0;e<s;e++)n+=cn(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${n}" />\n </clipPath>`}(o,n,e),c=function(e,t,s){return 1===s?0:2===s?0===e?0:t+2:3===s?0===e?0:1===e?12:25:(t+2)*e}(s,n,e),d=function(e,t,s,n){return t<=4||e<=1?0:e>=t-2?n-36:(s+4)/2+(e-2)*(s+2)}(s,e,n,i);return{markHeight:a,clipPath:r,markTranslateY:c,trackTranslateY:d,trackHeight:i,clipPathId:o}}(t,s)),[t,s]);if((0,o.bt)((()=>{if(!n.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:s,markTranslateY:i,clipPathId:o,clipPath:r}=a,c=n.current.firstElementChild;if(n?.current){const a=n.current,{style:d}=a;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${o}")`;const l=a.querySelector("svg"),u=a.querySelector("div"),m=a.querySelector("defs");l||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${r} </defs></svg>`),m&&(m.innerHTML=r),u&&(u.style.height=`${s}px`,u.style.transform=`translateY(${i}px)`)}}),[a]),1===t)return o.ZP.createElement("div",{className:rn.pinnedMessageBorder},o.ZP.createElement("div",{className:rn.pinnedMessageBorderWrapper1,ref:n}));const{trackHeight:i,trackTranslateY:r,markHeight:c,markTranslateY:d,clipPathId:l}=a;return o.ZP.createElement("div",{className:(0,ut.Z)(rn.pinnedMessageBorder,t>4&&rn.pinnedMessageBorderMask)},o.ZP.createElement("div",{className:rn.pinnedMessageBorderWrapper,ref:n,style:`clip-path: url("#${l}"); width: 2px;\n height: ${i}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:rn.pinnedMessageBorderMark,style:`--height: ${c}px; --translate-y: ${d}px; --translate-track: ${r}px;`})))}));var ln=s(45370),un=s(62230),mn=s(34076);const hn="DusHAy2Lx0SlaPpVAb_o",gn="jSVbc8Hb7PjitJujB_dQ",pn=1.125*S.Gw,fn=(0,o.X$)((e=>{let{message:t,count:s,index:i,customTitle:r,className:c,onUnpinMessage:d,onClick:l,onAllPinnedClick:u,isLoading:m,isFullWidth:h}=e;const{clickBotInlineButton:g}=(0,n.Sv)(),p=(0,_t.Z)(),f=(0,sn.Z)(t),I=(0,os.Z)((0,v.Ti)(t,"pictogram")),w=(0,v.NE)(t),y=(0,nn.Z)([m],450)&&m,[b,P,Z]=(0,ss.Z)(),C=(0,pt.Z)((()=>{Z(),d&&d(t.id)})),M=(0,v.eH)(t),E=(0,pt.Z)((()=>{M&&g({messageId:t.id,button:M})})),[R,k,T]=(0,ss.Z)(),{handleClick:A,handleMouseDown:N}=(0,Js.m)(l);return o.ZP.createElement("div",{className:(0,ut.Z)("HeaderPinnedMessageWrapper","TMOjo7XfD1ZiiuRtfpkm",h&&"full-width",c)},(s>1||y)&&o.ZP.createElement(zt.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:p("EventLogFilterPinnedMessages"),onClick:y?void 0:u},m&&o.ZP.createElement(es.Z,{color:"blue",className:(0,ut.Z)("d7XDT4Keip1KHh7mcCv9",hn,!y&&gn)}),o.ZP.createElement("i",{className:(0,ut.Z)("icon","icon-pin-list",hn,y&&gn)})),d&&o.ZP.createElement(zt.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:p("UnpinMessageAlertTitle"),onClick:P},o.ZP.createElement("i",{className:"icon icon-close"})),o.ZP.createElement(on.Z,{isOpen:b,onClose:Z,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:C}),o.ZP.createElement("div",{className:(0,ut.Z)("uhn_g6FmUELuGJrCm45w",R&&"jeTsUEkDCkzGUVwy6lrL"),onClick:A,onMouseDown:N,dir:p.isRtl?"rtl":void 0},o.ZP.createElement(dn,{count:s,index:i}),o.ZP.createElement(jt.Z,{activeKey:t.id,name:"slideVertical",className:"EK6juGhJwhsLLm4Aag2F"},function(e,t,s){const{width:n,height:a}=(0,S.W7)(),i=t||e;return o.ZP.createElement("div",{className:"RFnmHP92f6CwfuR2Upaw"},e&&!s&&o.ZP.createElement("img",{className:"JfPOYkOcaMjS7Y5rsHZ4",src:i,width:n,height:a,alt:""}),e&&o.ZP.createElement(un.Z,{thumbDataUri:i,isVisible:Boolean(s),width:n,height:a}))}(f,I,w)),o.ZP.createElement("div",{className:(0,ut.Z)("bSvmca5kaTIUh3yJBxnF",f&&"FBCNFm307_rxATSHPSiN")},o.ZP.createElement("div",{className:"q9_FnsHlndM1hZqZjxjM",dir:"auto"},!r&&o.ZP.createElement(mn.Z,{text:`${p("PinnedMessage")} ${i>0?"#"+(s-i):""}`}),r&&(0,tn.Z)(r)),o.ZP.createElement(jt.Z,{activeKey:t.id,name:"slideVerticalFade",className:"ugsKEK4Xb166oFMP8hHy"},o.ZP.createElement("p",{dir:"auto",className:"WRuyhyQK6mv28Mz8iK28"},o.ZP.createElement(ln.Z,{lang:p,message:t,noEmoji:Boolean(f),emojiSize:pn})))),o.ZP.createElement(an.Z,null),M&&o.ZP.createElement(zt.Z,{size:"tiny",className:"kXRuktM2s7UN91zOl0Tx",onClick:E,shouldStopPropagation:!0,onMouseEnter:a.$b?void 0:k,onMouseLeave:a.$b?void 0:T},M.text)))}));var In=s(10396),vn=s(64532),wn=s(23186),yn=s(93447),bn=s(77510);const Pn=s.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",Zn={width:200,height:200},Cn=115;var Sn=s(17240),Mn=s(18051);const En={.5:.66,.75:.8,1:1,1.5:1.4,2:1.8},Rn=Object.keys(En).sort().map(Number),kn=(0,n.c$)(((e,t)=>{let{message:s}=t;const n=(0,f.Urc)(e,s),a=(0,f.Z1J)(e,s.chatId),{volume:i,playbackRate:o,isMuted:r,isPlaybackRateActive:c}=(0,f.jUK)(e).audioPlayer;return{sender:n,chat:a,volume:i,playbackRate:o,isPlaybackRateActive:c,isMuted:r}}))((e=>{let{message:t,className:s,noUi:r,sender:c,chat:d,volume:l,playbackRate:u,isPlaybackRateActive:m,isMuted:h}=e;const{setAudioPlayerVolume:g,setAudioPlayerPlaybackRate:p,setAudioPlayerMuted:f,focusMessage:I,closeAudioPlayer:w}=(0,n.Sv)(),y=(0,o.sO)(null),b=(0,_t.Z)(),{isMobile:P}=(0,B.ZP)(),{audio:Z,voice:C,video:M}=(0,v.qp)(t),E=Boolean(C||M),R=E||(Z?.duration||0)>i.J0S,k=c?(0,v.OU)(b,c):void 0,T=xe.UV((0,v.Ti)(t,"inline")),A=((e,t,s)=>{const n=(0,_t.Z)(),{audio:a,voice:i}=(0,v.qp)(e),r=a?a.title||a.fileName:i?"Voice message":"",c=a?.performer||t&&(0,v.OU)(n,t),d=s&&(0,v.U)(n,s)||"Telegram",l=a&&(0,v.MR)(a)&&(0,v.Ti)(e,"pictogram"),u=t&&(0,v.RT)(t,"big"),m=a&&l||i&&u,h=(0,os.Z)(m),g=(0,o.Ye)((()=>function(e,t,s){if(!s)return Zn;if(e){if(!e.thumbnailSizes?.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?S.vY:void 0}(a,i,h)),[a,h,i]),{result:p}=(0,bn.Z)((()=>function(e,t){if(!e)return Promise.resolve(Pn);if(!t)return(0,yn.t)(e,Cn,Cn);const s=Math.min(t.width,t.height);if(s<Cn){const t=Cn/s;return(0,yn.j)(e,t)}return Promise.resolve(e)}(h,g)),[h,g],Pn);return(0,o.Ye)((()=>(0,vn.Of)({title:r,artist:c,album:d,artwork:[{src:p}]})),[d,c,r,p])})(t,c,d),{playPause:N,stop:x,isPlaying:U,requestNextTrack:L,requestPreviousTrack:O,isFirst:j,isLast:_,setVolume:F,toggleMuted:D,setPlaybackRate:q}=(0,wn.Z)((0,In.An)(t),(0,v.XV)(t),E?"voice":"audio",T,void 0,A,void 0,!0,void 0,void 0,(0,v.CI)(t),!0),{isContextMenuOpen:G,handleBeforeContextMenu:H,handleContextMenu:$,handleContextMenuClose:V,handleContextMenuHide:K}=(0,Sn.Z)(y),J=(0,pt.Z)((()=>{I({chatId:t.chatId,messageId:t.id})})),z=(0,pt.Z)((()=>{U&&N(),w(),(0,vn.Ay)(),x()})),W=(0,pt.Z)((e=>{g({volume:e/100}),F(e/100)})),Y=(0,pt.Z)((()=>{a.$b&&!a.cj||(D(),f({isMuted:!h}))})),X=(0,pt.Z)((function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const s=En[e],n=1!==e&&t;p({playbackRate:s,isPlaybackRateActive:n}),q(n?s:1)})),Q=(0,pt.Z)((()=>{V();const e=Number(Object.entries(En).find((e=>{let[,t]=e;return t===u}))?.[0])||1,t=!m;X(t&&1===e?2:e,t)})),ee=(0,pt.Z)((()=>{const e=Object.entries(En).find((e=>{let[,t]=e;return t===u}))?.[0]||1,t=`${1===u?2:e}Х`;return o.ZP.createElement("div",{className:"playback-wrapper"},G&&o.ZP.createElement("div",{className:"playback-backdrop",onClick:V}),o.ZP.createElement(zt.Z,{round:!0,className:(0,ut.Z)("playback-button",m&&"applied",G&&"on-top"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!P,onMouseEnter:$,onClick:Q,onMouseDown:H,onContextMenu:$},o.ZP.createElement("span",{className:(0,ut.Z)("playback-button-inner",4===t.length&&"small",5===t.length&&"tiny")},t)))})),te=(0,o.Ye)((()=>0===l||h?"icon-muted":l<.3?"icon-volume-1":l<.6?"icon-volume-2":"icon-volume-3"),[l,h]);if(!r)return o.ZP.createElement("div",{className:(0,ut.Z)("AudioPlayer",s),dir:b.isRtl?"rtl":void 0,ref:y},o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:J},Z?function(e){const{title:t,performer:s,fileName:n}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,tn.Z)(t||n)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,tn.Z)(s)))}(Z):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,tn.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(b("AttachAudio"),k),o.ZP.createElement(an.Z,null)),o.ZP.createElement(zt.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:"player-button",disabled:j(),onClick:O,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon icon-skip-previous"})),o.ZP.createElement(zt.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:(0,ut.Z)("toggle-play","player-button",U?"pause":"play"),onClick:N,ariaLabel:U?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon icon-play"}),o.ZP.createElement("i",{className:"icon icon-pause"})),o.ZP.createElement(zt.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:"player-button",disabled:_(),onClick:L,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon icon-skip-next"})),o.ZP.createElement("div",{className:"volume-button-wrapper"},o.ZP.createElement(zt.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",onClick:Y,ripple:!P},o.ZP.createElement("i",{className:(0,ut.Z)("icon",te)})),!a.cj&&o.ZP.createElement("div",{className:"volume-slider-wrapper"},o.ZP.createElement("div",{className:"volume-slider-spacer"}),o.ZP.createElement("div",{className:"volume-slider"},o.ZP.createElement(Mn.Z,{bold:!0,value:h?0:100*l,onChange:W})))),R&&o.ZP.createElement(Kt.Z,{forceOpen:G,positionX:"right",positionY:"top",className:"playback-rate-menu",trigger:ee,onClose:V,onHide:K,onMouseEnterBackdrop:V},Rn.map((e=>function(e,t,s,n){const a=t===En[e]&&n||1===e&&!n;return o.ZP.createElement(Jt.Z,{key:e,onClick:()=>s(e),icon:a?"check":void 0,customIcon:a?void 0:o.ZP.createElement("i",{className:"icon icon-placeholder"})},e,"X")}(e,u,X,m)))),o.ZP.createElement(zt.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:z,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon icon-close"})))}));var Tn=s(4794),An=s(14605);const Nn=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s}=t;return{currentUserId:e.currentUserId,chat:(0,f.Z1J)(e,s),user:(0,v.YC)(s)?(0,f.dyD)(e,s):void 0}}))((e=>{let{chatId:t,className:s,chat:a,user:i,settings:r,currentUserId:c}=e;const{openAddContactDialog:d,blockContact:l,reportSpam:u,deleteChat:m,leaveChannel:h,deleteChatUser:g,deleteHistory:p,toggleChatArchived:f,hideChatReportPanel:I}=(0,n.Sv)(),w=(0,_t.Z)(),[y,b,P]=(0,ss.Z)(),[Z,C]=(0,o.eJ)(!0),[S,M]=(0,o.eJ)(!0),{accessHash:E}=a||{},{isAutoArchived:R,canReportSpam:k,canAddContact:T,canBlockContact:A}=r||{},N=a&&(0,v.G9)(a),x=(0,pt.Z)((()=>{d({userId:t}),R&&f({id:t})})),B=(0,pt.Z)((()=>{P(),l({contactId:t,accessHash:E}),k&&Z&&u({chatId:t}),S&&m({chatId:t})})),U=(0,pt.Z)((()=>{I({chatId:t})})),L=(0,pt.Z)((()=>{P(),u({chatId:t}),N?(g({chatId:t,userId:c}),p({chatId:t,shouldDeleteForAll:!1})):h({chatId:t})}));if(r&&(a||i))return o.ZP.createElement("div",{className:(0,ut.Z)("ChatReportPanel",s),dir:w.isRtl?"rtl":void 0},T&&o.ZP.createElement(zt.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:x},w("lng_new_contact_add")),A&&o.ZP.createElement(zt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:b},w("lng_new_contact_block")),k&&!A&&o.ZP.createElement(zt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:b},w("lng_report_spam_and_leave")),o.ZP.createElement(zt.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:U,ariaLabel:w("Close")},o.ZP.createElement("i",{className:"icon icon-close"})),o.ZP.createElement(on.Z,{isOpen:y,onClose:P,title:w("BlockUserTitle",i?(0,v.Vl)(i):(0,v.U)(w,a)),text:i?w("UserInfo.BlockConfirmationTitle",(0,v.Js)(i)):w("Chat.Confirm.ReportSpam.Channel"),confirmIsDestructive:!0,confirmLabel:w("Block"),confirmHandler:i?B:L},i&&o.ZP.createElement(An.Z,{label:w("DeleteThisChat"),checked:S,onCheck:M}),i&&k&&o.ZP.createElement(An.Z,{label:w("ReportChat"),checked:Z,onCheck:C})))}))),xn=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s,threadId:n,messageListType:a,isMobile:i}=t;const{isLeftColumnShown:o,shouldSkipHistoryAnimations:r,audioPlayer:c,messageLists:d}=(0,f.jUK)(e),l=(0,f.Z1J)(e,s),{chatId:m,messageId:h}=c,g=m&&h?(0,f.hjO)(e,m,h):void 0;let p;"pinned"===a?p=(0,f.KBA)(e,s,n)?.length:"scheduled"===a?p=(0,f.qyA)(e,s,n)?.length:"thread"===a&&n!==u._f&&(p=(0,f.tZg)(e,s,n)?.messagesCount||0);const I="thread"===a&&n===u._f,w=l&&(0,f.xoo)(e,l),y=Boolean(w&&(0,f.s4q)(e,s)),b=w&&!y&&Boolean((0,f.pkN)(e,s)),P=Boolean(l&&(I||l.isForum)&&((0,v.eA)(l)||(0,v.ZV)(l))&&l.isNotJoined),Z=Boolean(l?.isNotJoined&&l.isJoinRequest),C={typingStatus:(0,f.WPz)(e,s,n,"typingStatus"),isLeftColumnShown:o,isRightColumnShown:(0,f.Jf5)(e,i),isSelectModeActive:(0,f.CAb)(e),audioMessage:g,chat:l,messagesCount:p,isChatWithSelf:(0,f.FM1)(e,s),shouldSkipHistoryAnimations:r,currentTransitionKey:Math.max(0,d.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing,isSynced:e.isSynced,isFetchingDifference:e.isFetchingDifference,hasButtonInHeader:b||y||P||Z},S=(0,f.Zwk)(e,s);if("thread"!==a||!S)return C;if(n!==u._f&&!l?.isForum){const t=(0,f.qSq)(e,s,n),a=t?(0,f.hjO)(e,s,t):void 0,i=a?(0,f.cve)(e,a):void 0,o=(0,f.tZg)(e,s,n);return{...C,pinnedMessageIds:t,messagesById:S,canUnpin:!1,topMessageSender:i,isComments:Boolean(o?.originChannelId)}}const M=(0,f.KBA)(e,s,n);if(M?.length){const t=S[M[0]],{canUnpin:s}=t&&(0,f._kf)(e,t,n)||{};return{...C,pinnedMessageIds:M,messagesById:S,canUnpin:s}}return C}))((e=>{let{chatId:t,threadId:s,messageListType:a,isReady:r,isMobile:d,pinnedMessageIds:l,messagesById:m,canUnpin:h,topMessageSender:g,typingStatus:p,isSelectModeActive:f,isLeftColumnShown:I,isRightColumnShown:w,audioMessage:y,chat:b,messagesCount:P,isComments:Z,isChatWithSelf:C,hasButtonInHeader:S,shouldSkipHistoryAnimations:M,currentTransitionKey:E,connectionState:R,isSyncing:k,isSynced:T,isFetchingDifference:A,getCurrentPinnedIndexes:N,getLoadingPinnedId:x,onFocusPinnedMessage:U}=e;const{openChatWithInfo:L,pinMessage:O,focusMessage:j,openChat:_,openPreviousChat:F,loadPinnedMessages:D,toggleLeftColumn:q,exitMessageSelectMode:G}=(0,n.Sv)(),H=(0,_t.Z)(),$=(0,o.sO)(!0),{isTablet:V}=(0,B.ZP)(),K=(0,Ys.Z)(N)[`${t}_${s}`]||0,J=(0,Ys.Z)(x),z=Array.isArray(l)?l[K]:l,W=m&&z?m[z]:void 0,Y=Array.isArray(l)?l.length:l?1:void 0,X=b&&(0,v.U)(H,b).length,Q=g?(0,v.OU)(H,g):void 0,{settings:ee}=b||{},te=b?.isForum;(0,o.d4)((()=>{T&&r&&(s===u._f||te)&&D({chatId:t,threadId:s})}),[t,s,T,r,te]),(0,zs.Z)(t,z,W);const{width:se}=(0,qs.Z)(),ne=se<=i.ksF,ae=V&&I,ie=(0,o.sO)(null),oe=(0,o.sO)(!0),{handleClick:re,handleMouseDown:ce}=(0,Js.m)((()=>{L({id:t,threadId:s})})),de=(0,pt.Z)((e=>{O({messageId:e,isUnpin:!0})})),le=(0,pt.Z)((e=>{const n=e.shiftKey&&Array.isArray(l)?l[(0,Vs.Z)(l.length,l.indexOf(z)-2)]:z;U(n)&&j({chatId:t,threadId:s,messageId:n,noForumTopicPanel:!0})})),ue=(0,pt.Z)((()=>{_({id:t,threadId:s,type:"pinned"})})),me=(0,pt.Z)((()=>{setTimeout((()=>{$.current=!0}),450)})),he=(0,pt.Z)((e=>{if($.current){if($.current=!1,d&&document.querySelector(i.Edp)?.blur(),f)return G(),void me();if("thread"===a&&0===E)return!V||ae?(e.stopPropagation(),_({id:void 0},{forceOnHeavyAnimation:!0})):q(),void me();F(),me()}})),ge=se>=i.ksF&&se<i.jT7||se>i.l35&&se<i.ksF&&(!X||X>30),pe=ge||se>i._mX&&se<i.QU1,fe=Boolean(ee?.canAddContact||ee?.canBlockContact||ee?.canReportSpam),{shouldRender:Ie,transitionClassNames:ve}=(0,Ct.Z)(fe),we=(0,Ws.Z)(fe?ee:void 0,!0),{shouldRender:ye,transitionClassNames:be}=(0,Ct.Z)(Boolean(y)),Pe=(0,Ws.Z)(y,!0),{shouldRender:Ze,transitionClassNames:Ce}=(0,Ct.Z)(Boolean(W),void 0,!0),Se=(0,Ws.Z)(W,!0),Me=(0,Ws.Z)(Y,!0),Ee=(0,Ws.Z)(h,!0),Re=(0,Ws.Z)(Q),ke=(0,Hs.Z)(E),Te=void 0!==ke&&ke<E?ke:void 0,Ae=Ze&&Se||ye&&Pe;(0,o.bt)((()=>{const e=ie.current;if(e)return pe&&Ae?void(w||ge?(oe.current&&(e.classList.add("tools-stacked","animated"),oe.current=!1),setTimeout((()=>{(0,c.WM)((()=>{e.classList.remove("animated")}))}),350)):(e.classList.remove("tools-stacked"),oe.current=!0)):(e.classList.remove("tools-stacked","animated"),void(oe.current=!0))}),[pe,Ae,ge,w]);const{connectionStatusText:Ne}=Gt(H,R,k||A,!0);function xe(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(zt.Z,{round:!0,size:"smaller",color:"translucent",onClick:he,ariaLabel:H(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,ut.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(Bt,null))}const Be=Boolean(ye&&Pe),Ue=Be||!d&&S&&se<i.sgm;return(0,Vt.Z)(ie),o.ZP.createElement("div",{className:"MiddleHeader",ref:ie},o.ZP.createElement(jt.Z,{name:M?"none":"slideFade",activeKey:E,shouldCleanup:!0,cleanupExceptionKey:Te},"thread"!==a||s!==u._f&&!b?.isForum?o.ZP.createElement(o.ZP.Fragment,null,xe(),o.ZP.createElement("h3",null,void 0!==P?"thread"===a?H(Z?"CommentsCount":"Replies",P,"i"):"pinned"===a?H("PinnedMessagesCount",P,"i"):"scheduled"===a?C?H("Reminders"):H("messages",P,"i"):void 0:H("Loading"))):o.ZP.createElement(o.ZP.Fragment,null,(ne||E>0)&&xe(ae,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:re,onMouseDown:ce},(0,v.YC)(t)?o.ZP.createElement(Xs.Z,{key:t,userId:t,typingStatus:p,status:Ne,withDots:Boolean(Ne),withFullInfo:!0,withMediaViewer:!0,withStory:!C,withUpdatingStatus:!0,emojiStatusSize:22,noRtl:!0}):o.ZP.createElement(Qs.Z,{key:t,chatId:t,threadId:s,typingStatus:p,status:Ne,withDots:Boolean(Ne),withMediaViewer:s===u._f,withFullInfo:s===u._f,withUpdatingStatus:!0,noRtl:!0})))),s===u._f&&!b?.isForum&&o.ZP.createElement(Tn.Z,{hasPinnedOffset:Ze&&Boolean(Se)||ye&&Boolean(Pe),chatId:t}),Ze&&Se&&o.ZP.createElement(fn,{key:t,message:Se,count:Me||0,index:K,customTitle:Re,className:Ce,onUnpinMessage:Ee?de:void 0,onClick:le,onAllPinnedClick:ue,isLoading:void 0!==J,isFullWidth:Ue}),Ie&&o.ZP.createElement(Nn,{key:t,chatId:t,settings:we,className:ve}),o.ZP.createElement("div",{className:"header-tools"},Be&&o.ZP.createElement(kn,{key:(0,v.Tp)(Pe),message:Pe,className:be}),o.ZP.createElement(en.Z,{chatId:t,threadId:s,messageListType:a,isMobile:d,canExpandActions:!Be})))})));function Bn(e){return"albumId"in e}function Un(e,t){let s,n=[],a={originalDate:e[0].date,datetime:(0,re._F)(1e3*e[0].date),senderGroups:[n]};const i=[a];return e.forEach(((o,r)=>{o.isInAlbum?s?(s.messages.push(o),o.content.text&&(s.mainMessage=o)):s={albumId:o.groupedId,messages:[o],mainMessage:o}:n.push(o);const c=e[r+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(n.push(s),s=void 0),c){const e=(0,re._F)(1e3*c.date);a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},i.push(a),n=[],a.senderGroups.push(n)):(c.id===t||o.senderId!==c.senderId||o.isOutgoing!==c.isOutgoing||(0,v.FT)(o)&&!o.content.action?.phoneCall||(0,v.FT)(c)&&!c.content.action?.phoneCall||o.forwardInfo&&c.forwardInfo&&(o.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||o.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||o.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||o.inlineButtons||c.inlineButtons||c.date-o.date>600)&&(n=[],a.senderGroups.push(n))}})),i}var Ln=s(30386),On=s(87675),jn=s(81740),_n=s(70971),Fn=s(88957);var Dn=s(60998);var qn=s(72645),Gn=s(78722),Hn=s(3657),$n=s(93862),Vn=s(11309);const Kn=a.wZ?1e3:350;var Jn=s(71790),zn=s(83967);function Wn(e,t){return e.reduce(((e,t)=>e+t),t)}function Yn(e){const t={width:0,height:0};return e.forEach((e=>{let{dimensions:s,sides:n}=e;2&n&&(t.width=s.width+s.x),4&n&&(t.height=s.height+s.y)})),t}function Xn(e,t,s,n,a){const i=function(e,t){return e.map((e=>{const s=(0,zn.GH)(e,void 0,void 0,t);return s.width/s.height}))}(n.messages,a),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(i),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(i),c=i.length,d=i.some((e=>e>2)),l=(0,S.kc)(e,t,!1,s,a)-(t?2.5:0)*S.Gw;let u;const m={ratios:i,proportions:o,averageRatio:r,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return u=c>=5||d?function(e){let{ratios:t,averageRatio:s,maxWidth:n,minWidth:a,spacing:i,maxHeight:o=4*n/3}=e;const r=function(e,t){return e.map((e=>t>1.1?(0,$s.uZ)(e,1,2.75):(0,$s.uZ)(e,.6667,1)))}(t,s),c=t.length,d=new Array(c),l=[],u=e=>{const t=[];let s=0;e.forEach((e=>{t.push(((e,t)=>{const s=Wn(r.slice(e,e+t),0);return(n-(t-1)*i)/s})(s,e)),s+=e})),l.push({lineCounts:e,heights:t})};for(let e=1;e!==c;++e){const t=c-e;e<=3&&t<=3&&u([e,t])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t){const n=c-e-t;e<=3&&t<=(s<.85?4:3)&&n<=3&&u([e,t,n])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t)for(let s=1;s!==c-e-t;++s){const n=c-e-t-s;e<=3&&t<=3&&s<=3&&n<=4&&u([e,t,s,n])}let m,h=0;for(let e=0;e<l.length;e++){const{heights:t,lineCounts:s}=l[e],n=s.length,r=Wn(t,0)+i*(n-1),c=Math.min(...t)<a?1.5:1,d=(()=>{for(let e=1;e!==n;++e)if(s[e-1]>s[e])return 1.5;return 1})(),u=Math.abs(r-o)*c*d;(!m||u<h)&&(m=l[e],h=u)}const g=m.lineCounts,p=m.heights,f=g.length;let I=0,v=0;for(let e=0;e!==f;++e){const t=g[e],s=p[e],a=Math.round(s);let o=0;for(let c=0;c!==t;++c){const l=0|(0===e?1:0)|(e===f-1?4:0)|(0===c?8:0)|(c===t-1?2:0),u=r[I],m=c===t-1?n-o:Math.round(u*s);d[I]={dimensions:{x:o,y:v,width:m,height:a},sides:l},o+=m+i,++I}v+=a+i}return d}(m):2===c?function(e){const{ratios:t,proportions:s,averageRatio:n}=e;return"ww"===s&&n>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,i=Math.round(Math.min(s/t[0],Math.min(s/t[1],(a-n)/2)));return[{dimensions:{x:0,y:0,width:s,height:i},sides:11},{dimensions:{x:0,y:i+n,width:s,height:i},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,i=(s-n)/2,o=Math.round(Math.min(i/t[0],Math.min(i/t[1],a)));return[{dimensions:{x:0,y:0,width:i,height:o},sides:13},{dimensions:{x:i+n,y:0,width:i,height:o},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:n,spacing:a,maxHeight:i}=e,o=Math.round(1.5*s),r=Math.min(Math.round(Math.max(.4*(n-a),(n-a)/t[0]/(1/t[0]+1/t[1]))),n-a-o),c=n-r-a,d=Math.min(i,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:13},{dimensions:{x:c+a,y:0,width:r,height:d},sides:7}]}(e)}(m):3===c?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:n,maxWidth:a,minWidth:i}=e,o=t,r=Math.round(Math.min((t-s)/2,n[1]*(a-s)/(n[2]+n[1]))),c=o-r-s,d=Math.max(i,Math.round(Math.min((a-s)/2,Math.min(r*n[2],c*n[1])))),l=Math.min(Math.round(o*n[0]),a-s-d);return[{dimensions:{x:0,y:0,width:l,height:o},sides:13},{dimensions:{x:l+s,y:0,width:d,height:c},sides:3},{dimensions:{x:l+s,y:c+s,width:d,height:r},sides:6}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:n,spacing:a}=e,i=t,o=Math.round(Math.min(i/s[0],.66*(n-a))),r=(t-a)/2,c=Math.min(n-o-a,Math.round(Math.min(r/s[1],r/s[2])));return[{dimensions:{x:0,y:0,width:i,height:o},sides:11},{dimensions:{x:0,y:o+a,width:r,height:c},sides:12},{dimensions:{x:r+a,y:o+a,width:i-r-a,height:c},sides:6}]}(e)}(m):function(e){const{proportions:t}=e;return"w"===t[0]?function(e){let{maxWidth:t,ratios:s,spacing:n,maxHeight:a,minWidth:i}=e;const o=t,r=Math.round(Math.min(o/s[0],.66*(a-n))),c=Math.round((t-2*n)/(s[1]+s[2]+s[3])),d=Math.max(i,Math.round(Math.min(.4*(t-2*n),c*s[1]))),l=Math.round(Math.max(Math.max(i,.33*(t-2*n)),c*s[3])),u=o-d-l-2*n,m=Math.min(a-r-n,c);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+n,width:d,height:m},sides:12},{dimensions:{x:d+n,y:r+n,width:u,height:m},sides:4},{dimensions:{x:d+n+u+n,y:r+n,width:l,height:m},sides:6}]}(e):function(e){let{maxHeight:t,ratios:s,maxWidth:n,spacing:a,minWidth:i}=e;const o=t,r=Math.round(Math.min(o*s[0],.6*(n-a))),c=Math.round((t-2*a)/(1/s[1]+1/s[2]+1/s[3])),d=Math.round(c/s[1]),l=Math.round(c/s[2]),u=o-d-l-2*a,m=Math.max(i,Math.min(n-r-a,c));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+a,y:0,width:m,height:d},sides:3},{dimensions:{x:r+a,y:d+a,width:m,height:l},sides:2},{dimensions:{x:r+a,y:d+l+2*a,width:m,height:u},sides:6}]}(e)}(m),{layout:u,containerStyle:Yn(u)}}var Qn=s(55254),ea=s(44139),ta=s(45277),sa=s(3858),na=s(3927);const aa=3*S.Gw,ia=Number(S.Gw),oa="data-is-document-group-hover";function ra(e,t,s,i,r,d,l,u,m,h,g,p,f){const{setReplyingToId:I,sendDefaultReaction:v}=(0,n.Sv)(),[w,y,b]=(0,ss.Z)(),[P,Z,C]=(0,ss.Z)(),S=(0,o.sO)(),M=(0,na.Z)((e=>{const t=g.current;if(!t)return;const{clientX:s,clientY:n}=e,{x:a,width:i,y:o,height:r}=t.getBoundingClientRect(),c=a+i/2,d=o+r/2,l=Math.abs(c-s)<aa,u=Math.abs(d-n)<ia;l&&u?y():b()}),[g],c.i$);return(0,o.d4)((()=>{if(!a.$b||i||!r||h||!f())return;let e;return(0,fs.sf)(t.current,{selectorToPreventScroll:".MessageList",excludedClosestSelector:".no-word-wrap",onSwipe:(t,s)=>s===fs.eM.Left&&(e||(e=Date.now()),Z(),!0),onRelease:()=>{e&&r&&(I({messageId:s}),setTimeout(C,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,i,s,I,Z,C,r,h,f]),{handleMouseDown:i?void 0:function(e){(0,Ln.q)(e),u(e)},handleClick:function(t){if(i)e(t);else if(a.$b)return S.current?(clearInterval(S.current),S.current=void 0,void v({chatId:m,messageId:s})):void(S.current=setTimeout((()=>{S.current=void 0,function(e){if(a.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;A.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:i?d?sa.Z:void 0:function(t){if(a.wZ){if(t.target.matches("a[href]")||h)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:i?void 0:function(){!a.$b&&r&&I({messageId:s})},handleContentDoubleClick:a.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:M,handleSendQuickReaction:function(e){e.stopPropagation(),v({chatId:m,messageId:s})},handleMouseLeave:function(e){(0,c.i$)(b),p&&function(e){const t=da(e.currentTarget);t&&t.removeAttribute(oa)}(e)},isSwiped:P,isQuickReactionVisible:w,handleDocumentGroupMouseEnter:ca}}function ca(e){const t=da(e.currentTarget);t&&t.setAttribute(oa,"")}function da(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var la=s(75368),ua=s(74095),ma=s(46586);let ha;const ga=new ma.Z;a.SX&&setTimeout((function(){ha||(ha=(0,ua.K)(new Worker(new URL(s.p+s.u(4923),s.b))),ga.resolve())}),4e3);var pa=s(31526);let fa,Ia;function va(e,t,s){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}fa=Symbol.toStringTag,Ia=Symbol.iterator;class wa{constructor(e){this.limit=e,va(this,"map",void 0),va(this,"insertionQueue",void 0),this.map=new Map,this.insertionQueue=new Set}get(e){return this.map.get(e)}set(e,t){if(this.map.size===this.limit){const e=Array.from(this.insertionQueue).shift();e&&(this.map.delete(e),this.insertionQueue.delete(e))}return this.map.set(e,t),this.insertionQueue.add(e),this}delete(e){const t=this.map.delete(e);return t&&this.insertionQueue.delete(e),t}clear(){this.map.clear(),this.insertionQueue.clear()}forEach(e,t){this.map.forEach(e,t)}get size(){return this.map.size}get[fa](){return this.map[Symbol.toStringTag]}[Ia](){return this.map[Symbol.iterator]()}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}}const ya=new Map;const ba=(0,I.P2)((function(e){const{updateChatDetectedLanguage:t}=(0,n.Sv)(),s=ya.get(e);if(!s)return;const a=s.size;if(a<8)return;let i=0,o=0;const r=new Map;for(const e of s.values()){e.isTranslatable&&i++,e.detectedLanguage&&o++;const t=e.detectedLanguage;if(t){const e=r.get(t)||0;r.set(t,e+1)}}if(i/a<.3||o/a<.6)return;t({chatId:e,detectedLanguage:Array.from(r.entries()).sort(((e,t)=>{let[,s]=e,[,n]=t;return n-s}))[0][0]})}),1e3);var Pa=s(96634),Za=s(84441),Ca=s(82535),Sa=s(54752),Ma=s(8018);const Ea=(0,o.X$)((e=>{let{message:t,outgoingStatus:s,signature:a,withReactionOffset:i,repliesThreadInfo:r,renderQuickReactionButton:c,noReplies:d,isTranslated:l,isPinned:u,onClick:m,onTranslationClick:h,onOpenThread:g}=e;const{showNotification:p}=(0,n.Sv)(),f=(0,_t.Z)(),[I,v]=(0,ss.Z)();function w(e){e.stopPropagation(),p({message:f("ImportedInfo")})}const y=(0,o.Ye)((()=>{if(!I)return;const e=(0,re.SA)(1e3*t.date,f.code,void 0,f.timeFormat),s=t.isEdited&&(0,re.SA)(1e3*t.editDate,f.code,void 0,f.timeFormat),n=t.forwardInfo&&(0,re.SA)(1e3*t.forwardInfo.date,f.code,void 0,f.timeFormat);let a=e;return s&&(a+="\n",a+=f("lng_edited_date").replace("{date}",s)),n&&(a+="\n",a+=f("lng_forwarded_date").replace("{date}",n)),a}),[I,f,t,f.timeFormat]),b=(0,ut.Z)("MessageMeta",i&&"reactions-offset",t.forwardInfo?.isImported&&"is-imported");return o.ZP.createElement("span",{className:b,dir:f.isRtl?"rtl":"ltr",onClick:m,"data-ignore-on-paste":!0},l&&o.ZP.createElement("i",{className:"icon icon-language message-translated",onClick:h}),Boolean(t.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,At.bi)(t.views)),o.ZP.createElement("i",{className:"icon icon-channelviews"})),!d&&Boolean(r?.messagesCount)&&o.ZP.createElement("span",{onClick:function(e){e.stopPropagation(),g()},className:"message-replies-wrapper"},o.ZP.createElement("span",{className:"message-replies"},o.ZP.createElement(mn.Z,{text:(0,At.bi)(r.messagesCount)})),o.ZP.createElement("i",{className:"icon icon-reply-filled"})),u&&o.ZP.createElement("i",{className:"icon icon-pinned-message message-pinned"}),a&&o.ZP.createElement("span",{className:"message-signature"},(0,tn.Z)(a)),o.ZP.createElement("span",{className:"message-time",title:y,onMouseEnter:v},t.forwardInfo?.isImported&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-imported",onClick:w},(0,re.SA)(1e3*t.forwardInfo.date,f.code,!0)),o.ZP.createElement("span",{className:"message-imported",onClick:w},f("ImportedMessage"))),t.isEdited&&`${f("EditedMessage")} `,(0,re.mr)(f,1e3*t.date)),s&&o.ZP.createElement(Ma.Z,{status:s}),c&&c())}));var Ra=s(97182),ka=s(36765),Ta=s(97799);const Aa=e=>{let{message:t,observeIntersection:s,observeIntersectionForPlaying:i,shouldLoop:r,shouldPlayEffect:c,withEffect:d,onPlayEffect:l,onStopEffect:m}=e;const{showNotification:h,openStickerSet:g}=(0,n.Sv)(),p=(0,_t.Z)(),{isMobile:f}=(0,B.ZP)(),I=(0,o.sO)(null),w=t.content.sticker,{stickerSetInfo:y,isVideo:b,hasEffect:P}=w,Z=w.isPreloadedGlobally?void 0:(0,v.Ti)(t,b&&!a.Hh?"pictogram":"inline"),C=(0,Hn.Op)(I,s),M=(0,Hn.Op)(I,i),E=`sticker${w.id}?size=f`,R=(0,os.Z)(E,!C||!P,u.IU.BlobUrl),[k,T,A]=(0,ss.Z)(),N=(0,pt.Z)((()=>{A(),m?.()})),x=(0,Hs.Z)(c);(0,o.d4)((()=>{P&&d&&M&&(c||x)&&(T(),l?.())}),[P,M,l,c,x,T,d]);const U=(0,pt.Z)((()=>{g({stickerSetInfo:w.stickerSetInfo})})),L=(0,pt.Z)((()=>{if(P){if(k||!d)return void h({message:p("PremiumStickerTooltip"),action:{action:"openStickerSet",payload:{stickerSetInfo:w.stickerSetInfo}},actionText:p("ViewAction")});if(d)return T(),void l?.()}U()})),O="isMissing"in y,{width:j,height:_}=(0,S.Wr)(w,f),F=(0,ut.Z)("Sticker media-inner",O&&"inactive",P&&!t.isOutgoing&&"reversed");return o.ZP.createElement("div",{ref:I,className:F,style:`width: ${j}px; height: ${_}px;`,onClick:O?void 0:L},o.ZP.createElement(ka.Z,{containerRef:I,sticker:w,fullMediaHash:Z,fullMediaClassName:"full-media",size:j,shouldLoop:r,noLoad:!C,noPlay:!M,withSharedAnimation:!0}),P&&d&&C&&k&&o.ZP.createElement(Ta.Z,{key:E,className:"effect-sticker",tgsUrl:R,size:1.49*j,play:!0,isLowPriority:!0,noLoop:!0,onEnded:N}))};var Na=s(74753);const xa=7*S.Gw;function Ba(e,t,s,a,r,c,d){const{interactWithAnimatedEmoji:l,sendEmojiInteraction:u,sendWatchingEmojiInteraction:m}=(0,n.Sv)(),h=(0,o.sO)(null),g=(0,o.sO)(null),p=(0,os.Z)(s?`document${s}`:void 0,!s),f=d||xa,I=(0,_s.Z)(`width: ${f}px`,`height: ${f}px`,c&&!i.D$V&&"cursor: pointer"),v=(0,o.sO)(void 0),w=(0,o.sO)(void 0),y=(0,pt.Z)((()=>{h.current&&(u({chatId:e,messageId:t,emoji:c,interactions:v.current}),w.current=void 0,v.current=void 0)})),b=(0,pt.Z)((()=>{const e=g.current;p&&(e&&(e.pause(),e.remove()),g.current=new Audio,g.current.src=p,(0,Na.Z)(g.current),g.current.addEventListener("ended",(()=>{g.current=void 0}),{once:!0}))})),P=(0,pt.Z)((()=>{b();const s=h.current;if(!(c&&s&&t&&e))return;const{x:n,y:a}=s.getBoundingClientRect();l({emoji:c,x:n,y:a,startSize:f,isReversed:!r}),v.current||(v.current=[],w.current=performance.now(),setTimeout(y,1e3)),v.current.push(w.current?(performance.now()-w.current)/1e3:0)}));return(0,o.d4)((()=>{const s=h.current;s&&a&&a.forEach((n=>{let{id:a,startSize:i,messageId:o}=n;if(i||t!==o)return;const{x:d,y:l}=s.getBoundingClientRect();m({id:a,chatId:e,emoticon:c,startSize:f,x:d,y:l,isReversed:!r}),b()}))}),[a,e,c,r,t,b,m,f]),{ref:h,size:f,style:I,handleClick:P}}var Ua=s(45601);const La=(0,o.X$)((0,n.c$)(((e,t)=>{let{emoji:s,withEffects:n}=t;return{sticker:(0,f.zB_)(e,s),effect:n?(0,f.tHA)(e,s):void 0,soundId:(0,f.Ohz)(e,s)}}))((e=>{let{isOwn:t,observeIntersection:s,forceLoadPreview:n,messageId:a,chatId:i,activeEmojiInteractions:r,sticker:c,effect:d,soundId:l}=e;const{ref:u,size:m,style:h,handleClick:g}=Ba(i,a,l,r,t,d?.emoji),p=(0,Hn.Op)(u,s);return o.ZP.createElement(Ua.Z,{sticker:c,size:m,quality:1,noLoad:!p,forcePreview:n,play:p,forceOnHeavyAnimation:!0,ref:u,className:(0,ut.Z)("AnimatedEmoji media-inner",c?.id===S.wB&&"like-sticker-thumb"),style:h,onClick:g})}))),Oa=(0,o.X$)((0,n.c$)(((e,t)=>{let{customEmojiId:s,withEffects:n}=t;const a=e.customEmojis.byId[s];return{sticker:a,effect:a?.emoji&&n?(0,f.tHA)(e,a.emoji):void 0,soundId:a?.emoji&&(0,f.Ohz)(e,a.emoji),noPlay:!(0,f.W9H)(e)}}))((e=>{let{isOwn:t,customEmojiId:s,messageId:n,chatId:a,activeEmojiInteractions:i,sticker:r,effect:c,soundId:d,noPlay:l,observeIntersection:u}=e;const{ref:m,size:h,style:g,handleClick:p}=Ba(a,n,d,i,t,c?.emoji,(0,ea.qo)(1));return o.ZP.createElement(as.Z,{ref:m,documentId:s,className:(0,ut.Z)("AnimatedEmoji media-inner",r?.id===S.wB&&"like-sticker-thumb"),style:g,size:h,isBig:!0,noPlay:l,withSharedAnimation:!0,forceOnHeavyAnimation:!0,observeIntersectionForLoading:u,onClick:p})})));var ja=s(95822),_a=s(35269),Fa=s(6272);const Da=(0,n.c$)(((e,t)=>{let{contact:s}=t;const{countryList:{phoneCodes:n}}=e;return{user:(0,f.dyD)(e,s.userId),phoneCodeList:n}}))((e=>{let{contact:t,user:s,phoneCodeList:a}=e;const{openChat:i}=(0,n.Sv)(),{firstName:r,lastName:c,phoneNumber:d,userId:l}=t,u="0"!==l,m=(0,pt.Z)((()=>{i({id:l})}));return o.ZP.createElement("div",{className:(0,ut.Z)("Contact",u&&"interactive"),onClick:u?m:void 0},o.ZP.createElement(Pa.Z,{size:"large",peer:s,text:r||c}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},r," ",c),o.ZP.createElement("div",{className:"contact-phone"},(0,Fa.WZ)(a,d))))}));var qa=s(20230),Ga=s(51218),Ha=s(14434),$a=s(96937);function Va(e,t){return t>0?(e/t*100).toFixed():0}const Ka=e=>{let{answer:t,voteResults:s,totalVoters:n,maxVotersCount:a,correctResults:i,shouldAnimate:r}=e;const c=s&&s.find((e=>e.option===t.option)),d=0===i.length||-1!==i.indexOf(t.option),l=i.length>0&&d||c?.isChosen,u=c?Va(c.votersCount,n||0):0,[m,h]=(0,o.eJ)(r?0:u),g=c?Va(c.votersCount,a||0):0,p=m!==u;if((0,o.d4)((()=>{r&&h(u)}),[r,u]),!s||!c)return;const f=`width: ${g}%; transform:scaleX(${p?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",l&&o.ZP.createElement("span",{className:(0,ut.Z)("poll-option-chosen",!d&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:(0,ut.Z)("icon",d?"icon-check":"icon-close")}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,tn.Z)(t.text)),o.ZP.createElement("div",{className:(0,ut.Z)("poll-option-answer",l&&!d&&"wrong")},r&&o.ZP.createElement("svg",{className:"poll-line",style:p?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44"},o.ZP.createElement("path",{d:"M4.47 5.33v13.6a9 9 0 009 9h13"})),o.ZP.createElement("div",{className:"poll-option-line",style:f}))))},Ja=12*Math.PI;function za(e){e.stopPropagation()}const Wa=(0,o.X$)((0,n.c$)(((e,t)=>{let{poll:s}=t;const{recentVoterIds:n}=s.results,{users:{byId:a}}=e;return n&&0!==n.length?{recentVoterIds:n,usersById:a}:{}}))((e=>{let{message:t,poll:s,recentVoterIds:a,onSendVote:i}=e;const{loadMessage:r,openPollResults:c,requestConfetti:d}=(0,n.Sv)(),{id:l,chatId:u}=t,{summary:m,results:h}=s,[g,p]=(0,o.eJ)(!1),[f,I]=(0,o.eJ)([]),[v,w]=(0,o.eJ)(!1),[y,b]=(0,o.eJ)(!1),[P,Z]=(0,o.eJ)(!m.closed&&m.closeDate&&m.closeDate>0?Math.min(m.closeDate-(0,pe.bp)(),m.closePeriod):0),C=(0,o.sO)(null),S=(0,o.sO)(null),{results:M,totalVoters:E}=h,R=M&&M.some((e=>e.isChosen)),k=!m.closed&&!R,T=!k&&m.isPublic&&Number(h.totalVoters)>0,A=k&&m.multipleChoice,N=M?Math.max(...M.map((e=>e.votersCount))):E,x=(0,o.Ye)((()=>M?.filter((e=>e.isCorrect)).map((e=>e.option))||[]),[M]),B=(0,o.Ye)((()=>m.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(m.quiz&&m.closePeriod&&P<=0)})))),[P,m]);(0,o.d4)((()=>{const e=s.results.results?.find((e=>e.isChosen));g&&e&&(e.isCorrect&&d(),p(!1))}),[g,s.results.results,d]),(0,o.bt)((()=>{if(P>0&&setTimeout((()=>Z(P-1)),1e3),!S.current)return;P<=5&&C.current.classList.add("hurry-up");const e=(m.closePeriod-P)/m.closePeriod*Ja;S.current.setAttribute("stroke-dashoffset",`-${e}`)}),[P,m.closePeriod]),(0,o.d4)((()=>{m.quiz&&(P<=0||R&&!m.closed)&&r({chatId:u,messageId:l})}),[u,P,R,r,l,m.closed,m.quiz]),(0,o.d4)((()=>{let e;return m.quiz&&!m.closed&&m.closePeriod&&m.closePeriod>0&&(e=window.setTimeout((()=>{r({chatId:u,messageId:l})}),1e3*m.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[k,u,r,l,m.closePeriod,m.closed,m.quiz]);const U=(0,o.Ye)((()=>{const e=(0,n.Rd)().chats.byId,t=(0,n.Rd)().users.byId;return a?a.reduce(((s,n)=>{const a=e[n],i=t[n];return i?s.push(i):a&&s.push(a),s}),[]):[]}),[a]),L=(0,pt.Z)((e=>{I([e]),p(!0),b(!0),i([e])})),O=(0,pt.Z)((e=>{I(e)})),j=(0,pt.Z)((()=>{p(!0),b(!0),i(f)})),_=(0,pt.Z)((()=>{c({chatId:u,messageId:l})})),F=(0,pt.Z)((()=>{w(!0)})),D=(0,pt.Z)((()=>{w(!1),b(!1)}));(0,o.d4)((()=>{y&&R&&m.quiz&&h.results&&s.results.solution&&(h.results.find((e=>e.isChosen&&e.isCorrect))||w(!0))}),[R,y,h.results,m.quiz,s.results.solution]);const q=(0,_t.Z)();return o.ZP.createElement("div",{className:"Poll",dir:q.isRtl?"auto":"ltr"},v&&s.results.solution&&o.ZP.createElement($a.Z,{message:(0,qa.H)({text:s.results.solution,entities:s.results.solutionEntities}),duration:5e3,onDismiss:D,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,tn.Z)(m.question,["emoji","br"])),o.ZP.createElement("div",{className:"poll-type"},q(function(e){return void 0===e.isPublic?" ":e.closed?"FinalResults":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.isPublic?"PublicPoll":"AnonymousPoll"}(m)),U.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},U.map((e=>o.ZP.createElement(Pa.Z,{key:e.id,size:"micro",peer:e})))),P>0&&k&&o.ZP.createElement("div",{ref:C,className:"poll-countdown"},o.ZP.createElement("span",null,(0,re.k9)(P)),o.ZP.createElement("svg",{width:"16px",height:"16px"},o.ZP.createElement("circle",{ref:S,cx:"8",cy:"8",r:6,className:"poll-countdown-progress",transform:"rotate(-90, 8, 8)","stroke-dasharray":Ja,"stroke-dashoffset":"0"}))),m.quiz&&s.results.solution&&!k&&o.ZP.createElement(zt.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:v,onClick:F,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon icon-lamp"}))),k&&o.ZP.createElement("div",{className:"poll-answers",onClick:za},A?o.ZP.createElement(Ga.Z,{options:B,onChange:O,disabled:t.isScheduled||g,loadingOptions:g?f:void 0,round:!0}):o.ZP.createElement(Ha.Z,{name:`poll-${l}`,options:B,onChange:L,disabled:t.isScheduled||g,loadingOption:g?f[0]:void 0})),!k&&o.ZP.createElement("div",{className:"poll-results"},m.answers.map((function(e){return o.ZP.createElement(Ka,{key:e.option,shouldAnimate:y||!k,answer:e,voteResults:M,totalVoters:E,maxVotersCount:N,correctResults:x})}))),!T&&!A&&o.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,s){return s?e(t?"Answer":"Vote",s,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(q,m.quiz,h.totalVoters)),A&&o.ZP.createElement(zt.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:j},q("PollSubmitVotes")),T&&o.ZP.createElement(zt.Z,{isText:!0,size:"tiny",onClick:_},q("PollViewResults")))})));var Ya=s(54659),Xa=s(26593),Qa=s(41280),ei=s(17921);const ti=(0,o.X$)((e=>{let{message:t,shouldAffectAppendix:s,isInSelectMode:n,isSelected:a,theme:r,forcedWidth:c}=e;const d=(0,o.sO)(null),l=(0,_t.Z)(),u=(0,v.eO)(t),{title:m,text:h,amount:g,currency:p,isTest:f,photo:I}=u,w=(0,os.Z)((0,v.O9)(I)),y=Boolean(c),b=(0,Qa.Z)(t,!y,w);(0,qn.Z)((e=>{let[t]=e;if(s){if(w){const e=d.current.closest(i.be_);(0,Xa.Z)(w,!1,a,r).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(i.s22,"")}))}}else t&&d.current.closest(i.be_).removeAttribute(i.s22)}),[s,w,n,a,r]);const P=c||I?.dimensions?.width,Z=(0,_s.Z)(I?.dimensions&&`width: ${P}px`,I?.dimensions&&`aspect-ratio: ${I.dimensions.width} / ${I.dimensions.height}`,Boolean(!I?.dimensions&&c)&&`width: ${c}px`);return o.ZP.createElement("div",{ref:d,className:"Invoice"},m&&o.ZP.createElement("p",{className:"title"},(0,tn.Z)(m)),h&&o.ZP.createElement("div",null,(0,tn.Z)(h,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(I?"has-image":"")},Boolean(I)&&o.ZP.createElement("div",{className:"invoice-image-container"},y&&o.ZP.createElement("canvas",{ref:b,className:"thumbnail blurred-bg"}),w&&o.ZP.createElement("img",{className:"invoice-image",src:w,alt:"",style:Z,crossOrigin:"anonymous"}),!w&&I&&o.ZP.createElement(ei.Z,{width:P,height:I.dimensions?.height,forceAspectRatio:!0})),o.ZP.createElement("p",{className:"description-text"},(0,lt.x)(g,p,l.code),f&&o.ZP.createElement("span",null,l("PaymentTestInvoice")))))})),si={root:"rwnm0xOh31c2MY4kK2No",duration:"lKSp02aI8WDGX3393nkh",buy:"gxQfWp0jp0_2Z4qWiXKN",spoiler:"z2tB5Vd_jKJ9IYX4Nijd"},ni=(0,o.X$)((e=>{let{message:t,isConnected:s}=e;const{openInvoice:a,loadExtendedMedia:i}=(0,n.Sv)(),r=(0,_t.Z)(),c=(0,v.eO)(t),{chatId:d,id:l}=t,u=(0,pt.Z)((()=>{i({chatId:d,ids:[l]})}));(0,Mt.Z)(u,s?3e4:void 0);const{amount:m,currency:h,extendedMedia:g}=c,{width:p,height:f,thumbnail:I,duration:w}=g,y=(0,pt.Z)((()=>{a({chatId:d,messageId:l,isExtendedMedia:!0})}));return o.ZP.createElement("div",{className:(0,ut.Z)(si.root,"media-inner"),onClick:y},o.ZP.createElement(un.Z,{thumbDataUri:I?.dataUri,width:p,height:f,isVisible:!0,className:si.spoiler}),Boolean(w)&&o.ZP.createElement("div",{className:si.duration},(0,re.k9)(w)),o.ZP.createElement("div",{className:si.buy},o.ZP.createElement("i",{className:(0,ut.Z)("icon","icon-lock",si.lock)}),r("Checkout.PayPrice",(0,lt.x)(m,h))))})),ai=new Map(Object.entries({"building/medical":"#43b3f4","building/gym":"#43b3f4","education/cafeteria":"#f7943f","travel/bedandbreakfast":"#9987ff","travel/hotel":"#9987ff","travel/hostel":"#9987ff","travel/resort":"#9987ff","travel/hotel_bar":"#e56dd6",arts_entertainment:"#e56dd6",building:"#6e81b2",education:"#a57348",event:"#959595",food:"#f7943f",home:"#00aeef",nightlife:"#e56dd6",parks_outdoors:"#6cc039",shops:"#ffb300",travel:"#1c9fff",work:"#ad7854"})),ii=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"],oi=s.p+"map-pin.899635f6fe777c28998a.svg",ri=24*Math.PI,ci=1e-4,di={width:400,height:300,zoom:16,scale:2};function li(){return o.ZP.createElement("svg",{className:"round-pin",style:"enable-background:new 0 0 64 64",viewBox:"0 0 64 64"},o.ZP.createElement("circle",{cx:"32",cy:"32",r:"24.5"}),o.ZP.createElement("path",{d:"M32 8c13.23 0 24 10.77 24 24S45.23 56 32 56 8 45.23 8 32 18.77 8 32 8m0-1C18.19 7 7 18.19 7 32s11.19 25 25 25 25-11.19 25-25S45.81 7 32 7z"}),o.ZP.createElement("path",{d:"m29.38 57.67-1.98-1.59 3.02-1.66L32 51.54l1.58 2.88 3.02 1.66-1.91 1.53L32 60.73z"}),o.ZP.createElement("path",{d:"m32 52.58 1.07 1.95.14.26.26.14 2.24 1.22-1.33 1.06-.07.06-.06.07L32 59.96l-2.24-2.61-.06-.07-.07-.06-1.33-1.06 2.24-1.22.26-.14.14-.26L32 52.58m0-2.08-1.94 3.56L26.5 56l2.5 2 3 3.5 3-3.5 2.5-2-3.56-1.94L32 50.5z"}))}const ui=(0,o.X$)((e=>{let{message:t,peer:s}=e;const{openUrl:a}=(0,n.Sv)(),i=(0,o.sO)(null),r=(0,o.sO)(null),d=(0,_t.Z)(),l=(0,Zt.Z)(),u=(0,v.nf)(t),{type:m,geo:h}=u,g=(0,pe.bp)(),p=(0,v.$R)(t),f="geoLive"!==m||p?void 0:t.date+u.period-g,[I,w]=(0,o.eJ)(h),y="venue"===m||"geoLive"===m&&!p,{width:b,height:P,zoom:Z,scale:C}=di,S=(0,v.k6)(I,b,P,Z,C),M=(0,os.Z)(S),E=(0,Hs.Z)(M,!0),R=M||E,k=(0,o.Ye)((()=>{if("geoLive"!==m||!I.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=I;return t/function(e,t){return 156543.03392*Math.cos(e*(Math.PI/180))/2**t}(e,Z)}),[m,I,Z]),T=(0,pt.Z)((e=>{if("geoLive"!==m)return;const s=e.lastElementChild,n=e.firstElementChild,a=t.date+u.period-(0,pe.bp)(),i=(1-a/u.period)*ri,o=(0,re.mB)(d,1e3*a);n.textContent=o,s.firstElementChild.setAttribute("stroke-dashoffset",`-${i}`)}));return(0,o.bt)((()=>{r.current&&T(r.current)}),[T]),(0,o.d4)((()=>{Math.abs(h.lat-I.lat)<ci&&Math.abs(h.long-I.long)<ci?I.accuracyRadius!==h.accuracyRadius&&w({...I,accuracyRadius:h.accuracyRadius}):w(h)}),[h,I]),(0,Rt.Z)((()=>{l()}),p?void 0:1e3*(f||0)),(0,Mt.Z)((()=>{(0,c.WM)((()=>{const e=r.current;e&&T(e)}))}),f?1e3:void 0),o.ZP.createElement("div",{ref:i,className:"Location media-inner interactive",onClick:()=>{const e=function(e,t,s){return`https://maps.google.com/maps/place/${e}+${t}/@${e},${t},${s}z`}(I.lat,I.long,Z);a({url:e})}},o.ZP.createElement("div",{className:"map-wrapper"},R?o.ZP.createElement("img",{className:"full-media map",src:R,alt:"Location on a map",style:`width: ${di.width}px; height: ${di.height}px;`}):o.ZP.createElement(ei.Z,{width:b,height:P}),function(){if(R)return o.ZP.createElement(o.ZP.Fragment,null,Boolean(k)&&!p&&o.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*k}px; height: ${2*k}px`}),function(){const e=(0,ut.Z)("pin",m,p&&"expired");if("geoLive"===m)return o.ZP.createElement("div",{className:e},o.ZP.createElement(li,null),o.ZP.createElement(Pa.Z,{peer:s,className:"location-avatar"}),void 0!==u.heading&&o.ZP.createElement("div",{className:"direction",style:`--direction: ${u.heading}deg`}));if("venue"===m){const t=function(e){return e?ai.get(e)||ai.get(e.split("/")[0])||ii[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%ii.length)]:"#008df2";var t}(u.venueType),s=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(u.venueType);if(s)return o.ZP.createElement("div",{className:e,style:`--pin-color: ${t}`},o.ZP.createElement(li,null),o.ZP.createElement("img",{src:s,className:"venue-icon",alt:""}))}return o.ZP.createElement("img",{className:e,src:oi,alt:""})}())}()),function(){if(y)return"venue"===m?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},u.title),o.ZP.createElement("div",{className:"location-info-subtitle"},u.address)):"geoLive"===m?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},d("AttachLiveLocation")),o.ZP.createElement("div",{className:"location-info-subtitle"},(0,re.dJ)(d,g,t.editDate)),!p&&o.ZP.createElement("div",{className:"geo-countdown",ref:r},o.ZP.createElement("span",{className:"geo-countdown-text"}),o.ZP.createElement("svg",{width:"32px",height:"32px"},o.ZP.createElement("circle",{cx:"16",cy:"16",r:12,className:"geo-countdown-progress",transform:"rotate(-90, 16, 16)","stroke-dasharray":ri,"stroke-dashoffset":"0"})))):void 0}())})),mi=(0,o.X$)((e=>{let{message:t,canAutoLoadMedia:s}=e;const{clickBotInlineButton:a}=(0,n.Sv)(),i=t.content.game,{title:r,description:c}=i,d=(0,v.N)(i),l=(0,v.Wc)(i),u=(0,os.Z)(d,!s),m=(0,os.Z)(l,!s);return o.ZP.createElement("div",{className:"Game"},o.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{a({messageId:t.id,button:t.inlineButtons[0][0]})}},!u&&!m&&o.ZP.createElement(ei.Z,{className:"skeleton preview-content"}),u&&o.ZP.createElement("img",{className:"preview-content",src:u,alt:r}),m&&o.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,disablePictureInPicture:!0,autoPlay:!0,loop:!0,src:m})),o.ZP.createElement("div",{className:"title"},r),!(0,v.UD)(t)&&o.ZP.createElement("div",{className:"description"},c))}));function hi(e){return(0,o.X$)((0,n.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,f.CAb)(e),isSelected:(0,f.vkB)(e,s.id)}}))((t=>{const{isInSelectMode:s,isSelected:a,message:i,dimensions:r}=t,{toggleMessageSelection:c}=(0,n.Sv)(),d=(0,pt.Z)((e=>{e.stopPropagation(),c({messageId:i.id,withShift:e?.shiftKey})})),l=(0,o.Ye)((()=>{const{dimensions:e,onClick:n}=t;return{...t,isInSelectMode:s,isSelected:a,dimensions:{...e,x:0,y:0},onClick:s?void 0:n}}),[t,s,a]);return o.ZP.createElement("div",{className:(0,ut.Z)("album-item-select-wrapper",a&&"is-selected"),style:r?`left: ${r.x}px; top: ${r.y}px;`:"",onClick:s?d:void 0},s&&o.ZP.createElement("div",{className:"message-select-control"},a&&o.ZP.createElement("i",{className:"icon icon-select"})),o.ZP.createElement(e,l))})))}const gi=hi(ja.Z),pi=hi(_a.Z),fi=(0,n.c$)(((e,t)=>{let{album:s}=t;const{chatId:n}=s.mainMessage,a=(0,f.Puy)(e),i=(0,f.f21)(e,n),o=s.mainMessage.isScheduled;return{theme:a,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:o?i?.scheduledIds:i?.ids}}))((e=>{let{album:t,observeIntersection:s,hasCustomAppendix:a,isOwn:i,isProtected:r,albumLayout:c,onMediaClick:d,uploadsById:l,activeDownloadIds:u,theme:m}=e;const{cancelSendingMessage:h}=(0,n.Sv)(),g=t.messages.length,p=(0,pt.Z)((e=>{h({chatId:e.chatId,messageId:e.id})})),{width:I,height:w}=c.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${I}px; height: ${w}px;`},t.messages.map((function(e,t){const{photo:h,video:I}=(0,v.qp)(e),w=l[(0,v.KK)(e)]?.progress,{dimensions:y,sides:b}=c.layout[t],P=(0,f.bHC)((0,n.Rd)(),e),Z=(0,f.__o)((0,n.Rd)(),e);if(h){const n=a&&(i?t===g-1:Boolean(8&b&&4&b));return o.ZP.createElement(gi,{id:`album-media-${(0,v.d0)(e.id)}`,message:e,observeIntersectionForLoading:s,canAutoLoad:P,shouldAffectAppendix:n,uploadProgress:w,dimensions:y,isProtected:r,onClick:d,onCancelUpload:p,isDownloading:u?.includes(e.id),theme:m})}if(I)return o.ZP.createElement(pi,{id:`album-media-${(0,v.d0)(e.id)}`,message:e,observeIntersectionForLoading:s,canAutoLoad:P,canAutoPlay:Z,uploadProgress:w,dimensions:y,isProtected:r,onClick:d,onCancelUpload:p,isDownloading:u?.includes(e.id),theme:m})})))}));var Ii=s(6701),vi=s(70692),wi=s(39196),yi=s(57080);const bi=S.Rj/2,Pi=2*(bi-6)*Math.PI;let Zi;const Ci=e=>{let{message:t,observeIntersection:s,canAutoLoad:a,isDownloading:i}=e;const r=(0,o.sO)(null),c=(0,o.sO)(null),d=(0,o.sO)(null),l=t.content.video,m=(0,Hn.Op)(r,s),[h,g]=(0,o.eJ)(a),p=Boolean(h&&m),{mediaData:f,loadProgress:I}=(0,Ii.Z)((0,v.Ti)(t,"inline"),!p,(0,v.kG)(t,"inline")),{loadProgress:w}=(0,Ii.Z)((0,v.Ti)(t,"download"),!i,u.IU.BlobUrl),[y,b]=(0,ss.Z)(),P=!Boolean((0,v.DH)(t))||y,Z=(0,Qa.Z)(t,P),C=(0,vi.Z)(!P),M=h&&!y||i,E=!1===(0,Hs.Z)(h),{shouldRender:R,transitionClassNames:k}=(0,Ct.Z)(M,void 0,E),[T,A]=(0,o.eJ)(!1),[N,x]=(0,Ks.Z)(0),B=(0,Vn.WR)(N,16);(0,o.d4)((()=>{if(!T)return;const e=c.current;x(e.currentTime/e.duration)}),[x,T,B]),(0,o.bt)((()=>{if(!T||!d.current)return;const e=Pi-B()*Pi;d.current.setAttribute("stroke-dashoffset",e.toString())}),[T,B]);const U=Boolean(f&&m),L=(0,pt.Z)((()=>{c.current&&(A(!1),x(0),(0,Na.Z)(c.current))})),O=(0,pt.Z)((()=>{Zi?.(),Zi=L})),j=(0,pt.Z)((()=>{if(!f)return void g((e=>!e));if(i)return void(0,n.Sv)().cancelMessageMediaDownload({message:t});const e=c.current;T?e.paused?((0,Na.Z)(e),(0,In.Es)()):e.pause():(O(),e.pause(),e.currentTime=0,(0,Na.Z)(e),(0,In.Es)(),A(!0))})),_=(0,pt.Z)((e=>{const t=e.currentTarget;x(t.currentTime/t.duration)}));return o.ZP.createElement("div",{ref:r,className:"RoundVideo media-inner",onClick:j},f&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement(yi.Z,{canPlay:U,ref:c,src:f,className:"full-media",width:S.Rj,height:S.Rj,autoPlay:!0,disablePictureInPicture:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?L:void 0,onTimeUpdate:T?_:void 0,onReady:b})),o.ZP.createElement("canvas",{ref:Z,className:(0,ut.Z)("thumbnail",C),style:`width: ${S.Rj}px; height: ${S.Rj}px`}),o.ZP.createElement("div",{className:"progress"},T&&o.ZP.createElement("svg",{width:S.Rj,height:S.Rj},o.ZP.createElement("circle",{ref:d,cx:bi,cy:bi,r:bi-6,className:"progress-circle",transform:`rotate(-90, ${bi}, ${bi})`,"stroke-dasharray":Pi,"stroke-dashoffset":Pi}))),R&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(wi.Z,{progress:i?w:I})),!f&&!h&&o.ZP.createElement("i",{className:"icon icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},T?(0,re.k9)(c.current.currentTime):(0,re.k9)(l.duration),(!T||c.current.paused)&&o.ZP.createElement("i",{className:"icon icon-muted"})))},Si=e=>{let{message:t,onClick:s}=e;const n=(0,_t.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(zt.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===e.type,onClick:()=>s({messageId:t.id,button:e})},o.ZP.createElement("span",{className:"inline-button-text"},(0,tn.Z)(n(e.text))),(e=>{const{type:t}=e;switch(t){case"url":if(!i.FSu.test(e.url))return o.ZP.createElement("i",{className:"icon icon-arrow-right"});break;case"urlAuth":return o.ZP.createElement("i",{className:"icon icon-arrow-right"});case"buy":case"receipt":return o.ZP.createElement("i",{className:"icon icon-cart"});case"switchBotInline":return o.ZP.createElement("i",{className:"icon icon-share-filled"});case"webView":case"simpleWebView":return o.ZP.createElement("i",{className:"icon icon-webapp"})}})(e))))))))},Mi=(0,o.X$)((e=>{let{threadInfo:t,disabled:s}=e;const{openComments:a}=(0,n.Sv)(),i=(0,_t.Z)(),{threadId:r,chatId:c,messagesCount:d,lastMessageId:l,lastReadInboxMessageId:u,recentReplierIds:m,originChannelId:h}=t,g=(0,pt.Z)((()=>{a({id:c,threadId:r,originChannelId:h})})),p=(0,o.Ye)((()=>{if(!m?.length)return;const{users:{byId:e},chats:{byId:t}}=(0,n.Rd)();return m.map((s=>(0,v.YC)(s)?e[s]:t[s])).filter(Boolean)}),[m]);if(void 0===d)return;const f=Boolean(u&&l&&u<l),I=d?i("Comments","%COMMENTS_COUNT%",void 0,d).split("%").map((e=>"COMMENTS_COUNT"===e?o.ZP.createElement(mn.Z,{text:(0,At.bi)(d)}):e)):void 0;return o.ZP.createElement("div",{"data-cnt":(0,At.bi)(d),className:(0,ut.Z)("CommentButton",f&&"has-unread",s&&"disabled"),dir:i.isRtl?"rtl":"ltr",onClick:g},o.ZP.createElement("i",{className:"icon icon-comments-sticker"}),(!p||0===p.length)&&o.ZP.createElement("i",{className:"icon icon-comments"}),Boolean(p?.length)&&o.ZP.createElement("div",{className:"recent-repliers",dir:i.isRtl?"rtl":"ltr"},p.map((e=>o.ZP.createElement(Pa.Z,{key:e.id,size:"small",peer:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},d?I:i("LeaveAComment")),o.ZP.createElement("i",{className:"icon icon-next"}))}));var Ei=s(65351),Ri=s(60422),ki=s(48198);const Ti={root:"JY0NZH9bysPBqR3sIbLu","animated-icon":"WTrBqa2uxq57nYJAIelk",animatedIcon:"WTrBqa2uxq57nYJAIelk",effect:"z9v8vlAIGxI3ITxuyEG1",animating:"sB0FGOzwkiDvNWHWcVEL"},Ai=2.5*S.Gw,Ni=6.5*S.Gw,xi=(0,o.X$)((e=>{let{reaction:t,genericEffects:s,activeReactions:a,availableReactions:i,observeIntersection:r,withEffects:c}=e;const{stopActiveReaction:d}=(0,n.Sv)(),l=(0,o.sO)(null),u="documentId"in t,m=(0,o.Ye)((()=>i?.find((e=>(0,v.Hl)(e.reaction,t)))),[i,t]),h=m?.centerIcon?.id,{customEmoji:g}=(0,Ri.Z)(u?t.documentId:void 0),p=(0,o.Ye)((()=>{if(!u)return m?.aroundAnimation?.id;if(!g)return;const e=i?.find((e=>e.reaction.emoticon===g.emoji))?.aroundAnimation?.id;return e}),[m,i,g,u]),f=(0,o.Ye)((()=>{if(p)return p;if(!s?.stickers)return;const{stickers:e}=s;return e[Math.floor(Math.random()*e.length)].id}),[p,s]),I=(0,Hn.Op)(l,r),w=h&&`sticker${h}`,y=f&&`sticker${f}`,b=(0,os.Z)(w,!h),P=(0,os.Z)(y,!f),Z=(0,o.Ye)((()=>a?.find((e=>(0,v.Hl)(e.reaction,t)))),[a,t]),C=Boolean(c&&Z&&(u||b)&&P),{shouldRender:S,transitionClassNames:M}=(0,Ct.Z)(C,void 0,!0,"slow"),E=(0,pt.Z)((()=>{Z?.messageId&&d({messageId:Z.messageId,reaction:t})})),[R,k,T]=(0,ss.Z)(),A=!(u||C&&R),N=(0,ut.Z)(Ti.root,S&&Ti.animating,u&&Ti.isCustomEmoji);return o.ZP.createElement("div",{className:N,ref:l},A&&o.ZP.createElement(ki.Z,{reaction:t,availableReactions:i}),u&&o.ZP.createElement(as.Z,{documentId:t.documentId,className:Ti.customEmoji,observeIntersectionForPlaying:r}),S&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ta.Z,{key:f,className:(0,ut.Z)(Ti.effect,M),size:Ni,tgsUrl:P,play:I,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:E}),u?!p&&I&&o.ZP.createElement(cs,{reaction:t}):o.ZP.createElement(Ta.Z,{key:h,className:(0,ut.Z)(Ti.animatedIcon,M),size:Ai,tgsUrl:b,play:I,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:k,onEnded:T})))})),Bi=(0,o.X$)((e=>{let{reaction:t,message:s,activeReactions:a,availableReactions:i,withRecentReactors:r,withEffects:c,genericEffects:d,observeIntersection:l}=e;const{toggleReaction:u}=(0,n.Sv)(),{recentReactions:m}=s.reactions,h=(0,o.Ye)((()=>{if(!r||!m)return;const e=(0,n.Rd)().chats.byId,s=(0,n.Rd)().users.byId;return m.filter((e=>(0,v.Hl)(e.reaction,t.reaction))).map((t=>s[t.peerId]||e[t.peerId])).filter(Boolean)}),[t.reaction,m,r]),g=(0,pt.Z)((()=>{u({reaction:t.reaction,chatId:s.chatId,messageId:s.id})}));return o.ZP.createElement(zt.Z,{className:(0,ut.Z)((0,v.Bt)(t)&&"chosen"),size:"tiny",onClick:g},o.ZP.createElement(xi,{activeReactions:a,reaction:t.reaction,availableReactions:i,genericEffects:d,observeIntersection:l,withEffects:c}),h?.length?o.ZP.createElement(Ei.Z,{size:"mini",peers:h}):o.ZP.createElement(mn.Z,{text:(0,At.bi)(t.count),className:"counter"}))})),Ui=(0,o.X$)((e=>{let{message:t,isOutside:s,maxWidth:n,activeReactions:a,availableReactions:i,metaChildren:r,genericEffects:c,observeIntersection:d,noRecentReactors:l,withEffects:u}=e;const m=(0,_t.Z)(),h=(0,o.Ye)((()=>t.reactions.results.reduce(((e,t)=>e+t.count),0)),[t]);return o.ZP.createElement("div",{className:(0,ut.Z)("Reactions",s&&"is-outside"),style:n?`max-width: ${n}px`:void 0,dir:m.isRtl?"rtl":"ltr"},t.reactions.results.map((e=>o.ZP.createElement(Bi,{key:(0,v.$d)(e.reaction),reaction:e,message:t,activeReactions:a,availableReactions:i,withRecentReactors:h<=3&&!l,genericEffects:c,observeIntersection:d,withEffects:u}))),r)})),Li=(0,o.X$)((e=>{let{phoneCall:t,message:s,chatId:i}=e;const{requestMasterAndRequestCall:r}=(0,n.Sv)(),c=(0,_t.Z)(),{isOutgoing:d,isVideo:l,reason:u,duration:m}=t,h="missed"===u,g="busy"===u||void 0===m,p=(0,pt.Z)((()=>{r({isVideo:l,userId:i})})),f=(0,o.Ye)((()=>l?h?d?"CallMessageVideoOutgoingMissed":"CallMessageVideoIncomingMissed":g?"CallMessageVideoIncomingDeclined":d?"CallMessageVideoOutgoing":"CallMessageVideoIncoming":h?d?"CallMessageOutgoingMissed":"CallMessageIncomingMissed":g?"CallMessageIncomingDeclined":d?"CallMessageOutgoing":"CallMessageIncoming"),[g,h,d,l]),I=(0,o.Ye)((()=>t.duration?(0,re.J_)(c,t.duration):void 0),[c,t.duration]),v=(0,re.mr)(c,1e3*s.date);return o.ZP.createElement("div",{className:"vDeypQzM845_JE14qGId"},o.ZP.createElement(zt.Z,{size:"smaller",color:"translucent",round:!0,ripple:!0,onClick:p,className:"OtJi45yywgt1n_y6VPkE",disabled:!a.Bi,ariaLabel:c(d?"CallAgain":"CallBack")},o.ZP.createElement("i",{className:(0,ut.Z)("icon",l?"icon-video-outlined":"icon-phone")})),o.ZP.createElement("div",{className:"_0BG8sziTJQ_NYrsspMg"},o.ZP.createElement("div",{className:"LWVSvxVjeEyHPBrCb2sD"},c(f)),o.ZP.createElement("div",{className:"nuIsoCP15iD4ETadJ44R"},o.ZP.createElement("i",{className:(0,ut.Z)("icon","icon-arrow-right","wrUkWet7enyh9L1iPKvA",h&&"V5tKkKZpcY5yq_f5nO8l",g&&"Q7dh9ssyXXCzatPRmIDv",!d&&"e0Vhbj8gfzQn1zJQoFLK")}),o.ZP.createElement("span",{className:"TJ2lYkLxYUie3A0JqtMR"},I?c("CallMessageWithDuration",[v,I]):v))))}));var Oi=s(78780),ji=s(50685),_i=s(14612),Fi=s(98138),Di=s(2995);var qi=s(69123);const Gi=1.125*S.Gw,Hi=(0,o.X$)((e=>{let{topic:t,className:s,onClick:n}=e;const a=(0,_t.Z)();return o.ZP.createElement("div",{className:(0,ut.Z)("wUl1jHjVuMxmGhsdl358",s),style:`--topic-button-accent-color: var(${(0,Fi.gZ)(t?.iconColor)})`,onClick:n},t?o.ZP.createElement(Di.Z,{topic:t,size:Gi}):o.ZP.createElement("img",{src:qi,alt:""}),t?.title?(0,tn.Z)(t.title):a("Loading"),t?.isClosed&&o.ZP.createElement("i",{className:"icon icon-lock"}),o.ZP.createElement("i",{className:"icon icon-next"}))})),$i=e=>{let{story:t,sender:s,noUserColors:a,isProtected:i,observeIntersectionForLoading:r,onClick:c}=e;const{showNotification:d}=(0,n.Sv)(),l=(0,_t.Z)(),u=(0,o.sO)(null),m=(0,Hn.Op)(u,r),h=t&&"content"in t,g=t&&"isDeleted"in t,p=h&&Boolean(t.content.video),f=h?"Story":g?"ExpiredStory":"Loading",I=(0,os.Z)(h&&(0,v.Cc)(t,"pictogram"),!m),w=p?t.content.video.thumbnail?.dataUri:void 0,y=I||w,b=s?(0,v.OU)(l,s):void 0,P=(0,pt.Z)((()=>{t&&!g?c():d({message:l("StoryNotFound")})})),{handleClick:Z,handleMouseDown:C}=(0,Js.m)(P);return o.ZP.createElement("div",{ref:u,className:(0,ut.Z)("EmbeddedMessage",s&&!a&&`color-${(0,v.Rs)(s)}`),onClick:Z,onMouseDown:C},y&&function(e,t){const{width:s,height:n}=(0,S.W7)();return o.ZP.createElement("div",{className:"embedded-thumb"},o.ZP.createElement("img",{src:e,width:s,height:n,alt:"",className:"pictogram",draggable:!1}),t&&o.ZP.createElement("span",{className:"protector"}))}(y,i),o.ZP.createElement("div",{className:(0,ut.Z)("message-text",g&&"with-message-color")},o.ZP.createElement("p",{dir:"auto"},g&&o.ZP.createElement("i",{className:"icon icon-story-expired","aria-hidden":!0}),l(f)),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,tn.Z)(b||" "))))};var Vi=s(93609);const Ki=(0,o.X$)((0,n.c$)(((e,t)=>{let{message:s}=t;const{id:n,userId:a}=s.content.storyData;return{story:(0,f.o9F)(e,a,n),isConnected:"connectionStateReady"===e.connectionState}}))((function(e){let{message:t,story:s,isProtected:n,isConnected:a}=e;const{storyData:i}=t.content;return o.ZP.createElement(Vi.Z,{story:s||i,isProtected:n,isConnected:a})}))),Ji=(0,o.X$)((0,n.c$)(((e,t)=>{let{message:s}=t;const{id:n,userId:a}=s.content.storyData,i=(0,f.GZu)(e,a)?.lastReadId;return{story:(0,f.o9F)(e,a,n),user:(0,f.dyD)(e,a),targetUser:(0,f.dyD)(e,s.chatId),isUnread:Boolean(i&&i<n)}}))((function(e){let{message:t,story:s,user:a,isUnread:i,targetUser:r}=e;const{openStoryViewer:c}=(0,n.Sv)(),d=(0,_t.Z)(),{storyData:l}=t.content,u=(0,pt.Z)((()=>{c({userId:s.userId,storyId:s.id,isSingleUser:!0,isSingleStory:!0})})),m=s&&"isDeleted"in s,h=s&&"content"in s,g=h?s.content.video:void 0,p=h?(0,v.Cc)(s,"pictogram"):void 0,f=(0,os.Z)(p)||g?.thumbnail?.dataUri;return(0,pa.Z)(l.userId,l.id,s),o.ZP.createElement("div",{className:(0,ut.Z)("action-message-story-mention",i&&"is-unread",h&&"with-preview"),tabIndex:0,role:"button",onClick:h?u:void 0},h&&o.ZP.createElement("span",{className:"story-media-wrapper"},f&&o.ZP.createElement("img",{src:f,alt:"",className:"story-media"})),o.ZP.createElement("span",{className:"story-title"},(0,tn.Z)(a?.isSelf?d(m?"ExpiredStoryMentioned":"StoryYouMentionedTitle",(0,v.Vl)(r)):m?d("ExpiredStoryMention"):d("StoryMentionedTitle",(0,v.Vl)(a)),["emoji","simple_markdown"])))}))),zi=1.75*S.Gw,Wi=2.25*S.Gw;function Yi(e){let{isOwn:t}=e;const s=t?"M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z":"M3 17h6V0c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 003 17z";return o.ZP.createElement("svg",{width:"9",height:"20",className:"svg-appendix"},o.ZP.createElement("defs",null,o.ZP.createElement("filter",{x:"-50%",y:"-14.7%",width:"200%",height:"141.2%",filterUnits:"objectBoundingBox",id:"messageAppendix"},o.ZP.createElement("feOffset",{dy:"1",in:"SourceAlpha",result:"shadowOffsetOuter1"}),o.ZP.createElement("feGaussianBlur",{stdDeviation:"1",in:"shadowOffsetOuter1",result:"shadowBlurOuter1"}),o.ZP.createElement("feColorMatrix",{values:"0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0",in:"shadowBlurOuter1"}))),o.ZP.createElement("g",{fill:"none","fill-rule":"evenodd"},o.ZP.createElement("path",{d:s,fill:"#000",filter:"url(#messageAppendix)"}),o.ZP.createElement("path",{d:s,fill:t?"#EEFFDE":"FFF",className:"corner"})))}const Xi=(0,o.X$)((0,n.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:n,activeReactions:o,activeEmojiInteractions:r}=(0,f.jUK)(e),{message:c,album:d,withSenderName:l,withAvatar:m,threadId:h,messageListType:g,isLastInDocumentGroup:p,isFirstInGroup:I}=t,{id:w,chatId:y,viaBotId:b,replyToChatId:P,replyToMessageId:Z,isOutgoing:C,forwardInfo:S,transcriptionId:M,isPinned:E,replyToStoryUserId:R,replyToStoryId:k,repliesThreadInfo:T}=c,A=(0,f.Z1J)(e,y),N=(0,f.FM1)(e,y),x=(0,v.pK)(y),B=A&&(0,v.eA)(A),U=A&&(0,v.Bf)(A),L=A?.usernames,O=(0,v.YC)(y)?void 0:(0,f.x67)(e,y),j=c.content.webPage?.story,_=j?(0,f.o9F)(e,j.userId,j.id):void 0,F=n.messageIds&&n.messageIds.includes(w),D=!N&&(0,v.Ul)(c),q=l||m||D,G=(0,f.Urc)(e,c),H=(0,f.cve)(e,c),$=b?(0,f.dyD)(e,b):void 0,V=G?.id&&U?O?.adminMembersById?.[G?.id]:void 0,K=h?(0,f.qSq)(e,y,h):void 0,J=c.id===K,z=Z===K,W=Z&&!z?(0,f.hjO)(e,x&&P?P:y,Z):void 0,Y=W&&(0,f.BzW)(e,W,Boolean(S)),X="topicCreate"===W?.content.action?.type,Q=k&&R?(0,f.o9F)(e,R,k):void 0,ee=R?(0,f.dyD)(e,R):void 0,te=(0,f.uZE)(e,c),se="thread"===g&&(d?d.messages.some((t=>(0,f._XY)(e,t,h))):(0,f._XY)(e,c,h)),{direction:ne,noHighlight:ae,isResizingContainer:ie}=se&&s||{},{query:oe}=(0,f.n5x)(e)||{},re=(0,v.h_)(c),ce=re&&(0,f.zB_)(e,re)?re:void 0,de=(0,v.HW)(c);let le;le=d?.messages?d.messages.every((t=>{let{id:s}=t;return(0,f.vkB)(e,s)})):(0,f.vkB)(e,w);const{canReply:ue}="thread"===g&&(0,f._kf)(e,c,h)||{},me=(0,f.teg)(e,c),he=T?(0,f.tZg)(e,T.chatId,T.threadId)||T:void 0,ge=Boolean(c.groupedId)&&!c.isInAlbum,pe=ge?(0,f.xHX)(e,y,c.groupedId)[0]:void 0,fe=ge?p?(0,f.hjO)(e,y,pe):void 0:c,Ie=A?.unreadReactions?.includes(c.id),ve=h===u._f&&A?.isForum&&I,we=ve?(0,f.p$s)(e,c)||A?.topics?.[i.OxA]:void 0,ye=Boolean((0,v.nf)(c)),be=(0,f.xfm)(e,y),Pe=(0,f.Bdn)(e,y,c.id),Ze=(0,f.lpX)(e,y),Ce=a.SX&&e.settings.byKey.canTranslate&&!Ze,Se="connectionStateReady"===e.connectionState;return{theme:(0,f.Puy)(e),chatUsernames:L,forceSenderName:D,canShowSender:q,originSender:H,botSender:$,shouldHideReply:z||X,isThreadTop:J,replyMessage:W,replyMessageSender:Y,replyStory:Q,storySender:ee,isInDocumentGroup:ge,isProtected:(0,f.EVS)(e,c),isChatProtected:(0,f.AmN)(e,y),isFocused:se,isForwarding:F,reactionMessage:fe,isChatWithSelf:N,isRepliesChat:x,isChannel:B,isGroup:U,canReply:ue,highlight:oe,animatedEmoji:ce,animatedCustomEmoji:de,isInSelectMode:(0,f.CAb)(e),isSelected:le,isGroupSelected:Boolean(c.groupedId)&&!c.isInAlbum&&(0,f.a65)(e,y,c.groupedId),threadId:h,isDownloading:me,isPinnedList:"pinned"===g,isPinned:E,canAutoLoadMedia:(0,f.bHC)(e,c),canAutoPlayMedia:(0,f.__o)(e,c),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,f.yBd)(e),repliesThreadInfo:he,availableReactions:e.availableReactions,defaultReaction:(0,v.CI)(c)||"scheduled"===g?void 0:(0,f.q6x)(e,y),activeReactions:fe&&o[fe.id],activeEmojiInteractions:r,hasUnreadReaction:Ie,isTranscribing:void 0!==M&&e.transcriptions[M]?.isPending,transcribedText:void 0!==M?e.transcriptions[M]?.text:void 0,isPremium:(0,f.wVz)(e),senderAdminMember:V,messageTopic:we,genericEffects:e.genericEmojiEffects,hasTopicChip:ve,chatTranslations:be,areTranslationsEnabled:Ce,shouldDetectChatLanguage:(0,f.J1l)(e,y),requestedTranslationLanguage:Pe,requestedChatTranslationLanguage:Ze,hasLinkedChat:Boolean(O?.linkedChatId),withReactionEffects:(0,f.$Yd)(e,"reactionEffects"),withStickerEffects:(0,f.$Yd)(e,"stickerEffects"),webPageStory:_,isConnected:Se,...(q||ye)&&{sender:G},...C&&{outgoingStatus:(0,f.dTW)(e,c,"scheduled"===g)},..."number"==typeof te&&{uploadProgress:te},...se&&{focusDirection:ne,noFocusHighlight:ae,isResizingContainer:ie}}}))((e=>{let{message:t,chatUsernames:s,observeIntersectionForBottom:r,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,album:h,noAvatars:g,withAvatar:p,withSenderName:f,noComments:I,noReplies:w,appearanceOrder:y,isJustAdded:b,isFirstInGroup:P,isPremium:Z,isLastInGroup:C,isFirstInDocumentGroup:M,isLastInDocumentGroup:E,isTranscribing:R,transcribedText:k,isLastInList:T,theme:A,forceSenderName:N,sender:x,canShowSender:U,originSender:L,botSender:O,isThreadTop:j,shouldHideReply:_,replyMessage:F,replyMessageSender:D,replyStory:q,storySender:G,outgoingStatus:H,uploadProgress:$,isInDocumentGroup:V,isProtected:K,isChatProtected:J,isFocused:z,focusDirection:W,noFocusHighlight:Y,isResizingContainer:X,isForwarding:Q,isChatWithSelf:ee,isRepliesChat:te,isChannel:se,isGroup:ne,canReply:ae,highlight:ie,animatedEmoji:oe,animatedCustomEmoji:re,genericEffects:ce,hasLinkedChat:de,isInSelectMode:le,isSelected:ue,isGroupSelected:me,threadId:he,reactionMessage:ge,availableReactions:pe,defaultReaction:fe,activeReactions:Ie,activeEmojiInteractions:ve,messageListType:we,isPinnedList:ye,isPinned:be,isDownloading:Pe,canAutoLoadMedia:Ze,canAutoPlayMedia:Ce,shouldLoopStickers:Se,autoLoadFileMaxSizeMb:Me,repliesThreadInfo:Ee,hasUnreadReaction:Re,memoFirstUnreadIdRef:ke,senderAdminMember:Te,messageTopic:Ae,hasTopicChip:Ne,chatTranslations:xe,areTranslationsEnabled:Be,shouldDetectChatLanguage:Ue,requestedTranslationLanguage:Le,requestedChatTranslationLanguage:Oe,withReactionEffects:je,withStickerEffects:_e,webPageStory:Fe,isConnected:De,onPinnedIntersectionChange:qe,getIsMessageListReady:Ge}=e;const{toggleMessageSelection:He,clickBotInlineButton:$e,disableContextMenuHint:Ve,animateUnreadReaction:Ke,focusLastMessage:Je}=(0,n.Sv)(),ze=(0,o.sO)(null),We=(0,o.sO)(null),Ye=(0,o.sO)(null),Xe=(0,o.sO)(0),Qe=(0,_t.Z)(),[et,tt]=(0,o.eJ)(!1),[st,nt,at]=(0,ss.Z)(),{isMobile:it,isTouchScreen:ot}=(0,B.ZP)();(0,Hn._N)(We,r);const{isContextMenuOpen:rt,contextMenuPosition:ct,contextMenuTarget:dt,handleBeforeContextMenu:lt,handleContextMenu:mt,handleContextMenuClose:ht,handleContextMenuHide:gt}=(0,Sn.Z)(ze,ot&&le,!i.D$V,a.wZ,Ge);(0,o.d4)((()=>{rt&&Ve()}),[rt,Ve]);const ft=y<=0,[It,vt]=(0,ss.Z)(ft);(0,o.d4)((()=>{ft||setTimeout(vt,10*y)}),[y,vt,ft]);const{transitionClassNames:wt}=(0,Ct.Z)(It||b,void 0,ft&&!b,!1),{id:yt,chatId:bt,forwardInfo:Pt,viaBotId:Zt,isTranscriptionError:Mt}=t;(0,o.d4)((()=>{if(!be)return;const e=h?h.mainMessage.id:yt;return()=>{qe({viewportPinnedIdsToRemove:[e],isUnmount:!0})}}),[h,be,yt,qe]);const Et=(0,v.CI)(t),Rt=(0,v.B4)(t),kt="scheduled"===we||t.isScheduled,Tt=(0,v.ss)(t)&&!_,At=Boolean(t.replyToStoryId),Nt=Boolean(Ee)&&"thread"===we,xt=(0,v.$D)(t),Bt=xt&&(oe||re),Ut=ge?.reactions&&!(0,v.JE)(ge.reactions),Lt=Pt&&(!ee||kt)&&!te&&!Pt.isLinkedChannelPost&&!xt||Boolean(t.content.storyData&&!t.content.storyData.isMention),Ot=t.content.storyData?.isMention,jt=Boolean(h)&&h.messages.length>1&&!h?.messages.some((e=>0===Object.keys(e.content).length)),Ft=V&&!M,Dt=V&&!E,qt=void 0!==ct,Gt=!(qt||le||Q||Dt||Ot),Ht=se&&!kt&&t.isForwardingAllowed&&!J,$t=Boolean(ye||Pt&&(Pt.isChannelPost||ee&&!Rt||te)&&Pt.fromMessageId),Vt=Ne||Tt||At,Kt=(0,pt.Z)(((e,t)=>{He({messageId:yt,groupedId:t,...e?.shiftKey&&{withShift:!0},...jt&&{childMessageIds:h.messages.map((e=>{let{id:t}=e;return t}))}})})),Jt=U?x:void 0,Wt=Boolean(!et&&(Mt||k)),Yt=Pt&&(ee||te||!Jt)?L:Jt,Xt=Pt?L:Jt,{handleMouseDown:Qt,handleClick:es,handleContextMenu:ts,handleDoubleClick:ns,handleContentDoubleClick:os,handleMouseMove:rs,handleSendQuickReaction:cs,handleMouseLeave:ds,isSwiped:ls,isQuickReactionVisible:us,handleDocumentGroupMouseEnter:ms}=ra(Kt,ze,yt,Boolean(le),Boolean(ae),Boolean(K),mt,lt,bt,qt,Ye,Dt,Ge),{handleAvatarClick:hs,handleSenderClick:gs,handleViaBotClick:ps,handleReplyClick:fs,handleMediaClick:Is,handleAudioPlay:vs,handleAlbumMediaClick:ws,handleMetaClick:ys,handleTranslationClick:bs,handleOpenThread:Ps,handleReadMedia:Zs,handleCancelUpload:Cs,handleVoteSend:Ss,handleGroupForward:Ms,handleForward:Es,handleFocus:Rs,handleFocusForwarded:ks,handleDocumentGroupSelectAll:Ts,handleTopicChipClick:As,handleStoryClick:Ns}=function(e,t,s,a,i,o,r,c,d,l,h,g,p,f,I,v){const{openChat:w,showNotification:y,focusMessage:b,openMediaViewer:P,openAudioPlayer:Z,markMessagesRead:C,cancelSendingMessage:S,sendPollVote:M,openForwardMenu:E,openChatLanguageModal:R,openStoryViewer:k,focusMessageInComments:T}=(0,n.Sv)(),{id:A,forwardInfo:N,replyToMessageId:x,replyToChatId:B,replyToTopMessageId:U,groupedId:L}=s,O=(0,pt.Z)((()=>{h&&w({id:h.id})})),j=(0,pt.Z)((()=>{g?r&&N?.channelPostId?b({chatId:g.id,messageId:N.channelPostId}):w({id:g.id}):y({message:e("HidAccount")})})),_=(0,pt.Z)((()=>{p&&w({id:p.id})})),F=(0,pt.Z)((()=>{b({chatId:d&&B?B:a,threadId:i,messageId:x,replyMessageId:d&&B?void 0:A,noForumTopicPanel:!0})})),D=(0,pt.Z)((()=>{P({chatId:a,threadId:i,mediaId:A,origin:c?m.bZ.ScheduledInline:m.bZ.Inline})})),q=(0,pt.Z)((()=>{Z({chatId:a,messageId:A})})),G=(0,pt.Z)((e=>{P({chatId:a,threadId:i,mediaId:e,origin:c?m.bZ.ScheduledAlbum:m.bZ.Album})})),H=(0,pt.Z)((()=>{C({messageIds:[A]})})),$=(0,pt.Z)((()=>{S({chatId:a,messageId:A})})),V=(0,pt.Z)((e=>{M({chatId:a,messageId:A,options:e})})),K=(0,pt.Z)((()=>{E({fromChatId:a,groupedId:L})})),J=(0,pt.Z)((()=>{if(l&&l.messages){const e=l.messages.map((e=>{let{id:t}=e;return t}));E({fromChatId:a,messageIds:e})}else E({fromChatId:a,messageIds:[A]})})),z=(0,pt.Z)((()=>{b({chatId:a,threadId:u._f,messageId:A})})),W=(0,pt.Z)((()=>{o?b({chatId:N.fromChatId,groupedId:L,groupedChatId:a,messageId:N.fromMessageId}):d&&B?T({chatId:B,threadId:U,messageId:N.fromMessageId}):b({chatId:N.fromChatId,messageId:N.fromMessageId})})),Y=(0,pt.Z)((e=>{e.stopPropagation(),t(e,L)}));return{handleAvatarClick:O,handleSenderClick:j,handleViaBotClick:_,handleReplyClick:F,handleMediaClick:D,handleAudioPlay:q,handleAlbumMediaClick:G,handleMetaClick:Y,handleTranslationClick:(0,pt.Z)((e=>{e.stopPropagation(),R({chatId:a,messageId:I?void 0:A})})),handleOpenThread:(0,pt.Z)((()=>{w({id:s.chatId,threadId:s.id})})),handleReadMedia:H,handleCancelUpload:$,handleVoteSend:V,handleGroupForward:K,handleForward:J,handleFocus:z,handleFocusForwarded:W,handleDocumentGroupSelectAll:Y,handleTopicChipClick:(0,pt.Z)((()=>{f&&b({chatId:d&&B?B:a,threadId:f.id,messageId:A})})),handleStoryClick:(0,pt.Z)((()=>{v&&k({userId:v.userId,storyId:v.id,isSingleStory:!0})}))}}(Qe,Kt,t,bt,he,V,Lt,kt,te,h,Yt,Xt,O,Ae,Boolean(Oe),q&&"content"in q?q:void 0);(0,o.d4)((()=>{T&&Wt&&k&&Je()}),[Je,T,k,Wt]);const xs=(0,ut.Z)("Message message-list-item",P&&"first-in-group",K?"is-protected":"allow-selection",C&&"last-in-group",M&&"first-in-document-group",E&&"last-in-document-group",T&&"last-in-list",Rt&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",Tt&&"has-reply",rt&&"has-menu-open",z&&!Y&&"focused",Q&&"is-forwarding",t.isDeleting&&"is-deleting",V&&"is-in-document-group",jt&&"is-album",t.hasUnreadMention&&"has-unread-mention",ue&&"is-selected",le&&"is-in-selection-mode",j&&!p&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",ls&&"is-swiped",wt,b&&"is-just-added",(Boolean(Ie)||st)&&"has-active-reaction",Ot&&"is-story-mention"),{text:Bs,photo:Us,video:Ls,audio:Os,voice:js,document:_s,sticker:Fs,contact:Ds,poll:qs,webPage:Gs,invoice:$s,location:Vs,action:Ks,game:Js,storyData:Ws}=(0,v.qp)(t),Ys=function(e,t,s){const[n,a]=(0,o.eJ)();return(0,o.d4)((()=>{t||s&&!s()||(e?async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.2;return ha||await ga.promise,await ha.request({name:"detectLanguage",args:[e,t]})}(e).then(a):a(void 0))}),[t,e,s]),n}(Bs?.text,!(Be||Ue),Ge);!function(e,t,s,n){(0,o.d4)((()=>{if(s||n&&!n())return;const a=Boolean(e.content.text?.text.length);!function(e,t,s,n){const a=ya.get(e)||new wa(150),i=a.get(t);i&&i.detectedLanguage===n&&i.isTranslatable===s||(a.set(t,{id:t,isTranslatable:s,detectedLanguage:n}),ya.set(e,a),ba(e))}(e.chatId,e.id,a,t)}),[e,t,s,n])}(t,Ys,!Ue,Ge);const Xs=(0,v.cT)(t,!Oe),{isPending:Qs,translatedText:en}=(0,la.Z)(xe,bt,Xs?yt:void 0,Le),sn=(0,Hs.Z)(en,Boolean(Xs)),nn=en||sn,{phoneCall:an}=Ks||{},on=(Ee||de&&se&&Et)&&!Dt&&"thread"===we&&!I,rn=Ee&&!Dt&&"thread"===we&&!I,cn=!ot&&!an&&!le&&fe&&!Dt&&!Ot,dn=function(e){let{hasSubheader:t,isCustomShape:s,isLastInGroup:n,asForwarded:a,hasThread:o,forceSenderName:r,hasComments:c,hasActionButton:d,hasReactions:l,isGeoLiveActive:u,withVoiceTranscription:m}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:h,photo:g,video:p,audio:f,voice:I,document:w,poll:y,webPage:b,contact:P,location:Z,invoice:C,storyData:S}=(0,v.qp)(e),M=[i.gnl],E=S||g||p||Z||C?.extendedMedia,R=h||"venue"===Z?.type||u,k=E&&!R,T=Boolean(e.viaBotId);return!E&&e.emojiOnlyCount?(M.push("emoji-only"),e.emojiOnlyCount<=i.L5X&&M.push(`emoji-only-${e.emojiOnlyCount}`)):R?M.push("text"):M.push("no-text"),d&&M.push("has-action-button"),s&&(M.push("custom-shape"),p?.isRound&&M.push("round"),c&&M.push("has-comments")),E?M.push("media"):f?M.push("audio"):I?(M.push("voice"),m&&M.push("with-voice-transcription")):w?M.push("document"):P?M.push("contact"):y?M.push("poll"):b&&(M.push("web-page"),(b.photo||b.video)&&M.push("media")),C&&!C.extendedMedia&&M.push("invoice"),S&&M.push("story"),a&&M.push("is-forwarded"),t&&M.push("has-subheader"),o&&M.push("has-replies"),l&&M.push("has-reactions"),T&&M.push("is-via-bot"),r&&M.push("force-sender-name"),s||(M.push("has-shadow"),E&&c&&M.push("has-background"),(t||a||T||!k||r)&&M.push("has-solid-background"),n&&(g||!k||Z&&a)&&M.push("has-appendix")),M.join(" ")}(t,{hasSubheader:Vt,isCustomShape:xt,isLastInGroup:C,asForwarded:Lt,hasThread:Nt&&!I,forceSenderName:N,hasComments:Ee&&Ee.messagesCount>0,hasActionButton:Ht||$t,hasReactions:Ut,isGeoLiveActive:"geoLive"===Vs?.type&&!(0,v.$R)(t),withVoiceTranscription:Wt}),ln=dn.includes("has-appendix"),un=(0,v.fY)(t),mn=(0,ea.qo)(t.emojiOnlyCount);let hn,gn;hn=an||Dt?"none":!un||Gs||mn?"standalone":"in-text",Ut?xt||(Us||Ls||Ws||Vs&&"geo"===Vs.type)&&!un?gn="outside":Lt?(hn="standalone",gn="inside"):gn="inside":gn="none";const pn=xt?"in-meta":"in-content";(0,zs.Z)(te&&t.replyToChatId?t.replyToChatId:bt,Tt?t.replyToMessageId:void 0,F,t.id),(0,pa.Z)(t.replyToStoryUserId?t.replyToStoryUserId:bt,t.replyToStoryId,q),(0,ta.Z)(ze,bt,z,W,Y,X,b);const fn=se&&t.postAuthorTitle||!Lt&&Pt?.postAuthorTitle||void 0;!function(e,t){(0,o.bt)((()=>{t&&(0,c.lT)((()=>{const t=e.current.querySelector(".message-signature")?.offsetWidth;if(t)return()=>{e.current.style.setProperty("--meta-safe-author-width",`${t}px`)}}))}),[e,t])}(ze,fn);const In=T,vn=(0,pt.Z)((e=>{const t=Xe.current,s=e.contentRect.height;if(Xe.current=s,(0,jn.Ni)()||!t||s<=t)return;const n=e.target.closest(".MessageList");if(!n)return;(0,St.YW)(400);const a=s-t,{offsetHeight:i,scrollHeight:o,scrollTop:r}=n;Math.round(o-r-i)-a<=5&&Je()})),wn=(0,na.Z)(vn,[vn],300,!1);(0,Gn.Z)(ze,wn,!In),(0,o.d4)((()=>{const e=We.current;Re&&e&&(0,Qn.P)(e)&&Ke({messageIds:[yt]})}),[Re,yt,Ke]);const yn=(0,o.Ye)((()=>jt?Xn(Rt,Boolean(Lt),Boolean(g),h,it):void 0),[jt,Rt,Lt,g,h,it]),bn=Lt?28:0,Pn=(0,o.Ye)((()=>{let e,s,n,a=!1,i="";if(!jt&&(Us||Ls||$s?.extendedMedia)){let n;if(Us)n=(0,zn.GH)(t,Lt,g,it).width;else if(Ls)n=Ls.isRound?S.Rj:(0,zn.GH)(t,Lt,g,it).width;else if($s?.extendedMedia&&$s.extendedMedia.width&&$s.extendedMedia.height){const{width:e,height:t}=$s.extendedMedia;n=(0,S.Kf)({width:e,height:t,fromOwnMessage:Rt,asForwarded:Lt,noAvatars:g,isMobile:it}).width}n&&(n<zn.Vx&&(s=n),e=Math.max((0,zn.Pw)(Bs?.text,on),n),$s?.extendedMedia&&e-n>18&&(a=!0))}else yn&&(e=Math.max((0,zn.Pw)(Bs?.text,on),yn.containerStyle.width),e-yn.containerStyle.width>18&&(a=!0));if(e)i=`width: ${e+bn}px`,n=e+Wi;else if(Fs&&!Vt){const{width:e}=(0,S.Wr)(Fs,it);i=`width: ${e+bn}px`,n=e+Wi}return{contentWidth:s,noMediaCorners:a,style:i,reactionsMaxWidth:n}}),[yn,Lt,bn,Vt,$s?.extendedMedia,jt,on,it,Rt,t,g,Us,Fs,Bs?.text,Ls]),{contentWidth:Zn,noMediaCorners:Cn,style:Mn,reactionsMaxWidth:En}=Pn;function Rn(e){return o.ZP.createElement(_i.Z,{messageOrStory:t,translatedText:Le?nn:void 0,isForAnimation:e,emojiSize:mn,highlight:ie,isProtected:K,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,withTranslucentThumbs:xt})}const kn=(0,o.I4)((()=>{if(fe)return o.ZP.createElement("div",{className:(0,ut.Z)("quick-reaction",us&&!Ie&&"visible"),onClick:cs,ref:Ye},o.ZP.createElement(ki.Z,{reaction:fe,size:zi,availableReactions:pe,observeIntersection:l}))}),[Ie,pe,fe,cs,us,l]);function Tn(){const e=o.ZP.createElement(Ea,{message:t,isPinned:be,noReplies:w,repliesThreadInfo:Ee,outgoingStatus:H,signature:fn,withReactionOffset:"inside"===gn,renderQuickReactionButton:cn&&"in-meta"===pn?kn:void 0,availableReactions:pe,isTranslated:Boolean(Le?nn:void 0),onClick:ys,onTranslationClick:bs,onOpenThread:Ps});return"inside"!==gn?e:o.ZP.createElement(Ui,{activeReactions:Ie,message:ge,metaChildren:e,availableReactions:pe,genericEffects:ce,observeIntersection:l,noRecentReactors:se,withEffects:je})}const An=ne&&Lt?t.postAuthorTitle:void 0,Nn=(0,o.Ye)((()=>s?.find((e=>e.isActive))),[s]);return o.ZP.createElement("div",{ref:ze,id:(0,v.d0)(t.id),className:xs,"data-message-id":yt,onMouseDown:Qt,onClick:es,onContextMenu:ts,onDoubleClick:ns,onMouseEnter:Dt?ms:void 0,onMouseMove:cn?rs:void 0,onMouseLeave:cn||Dt?ds:void 0},o.ZP.createElement("div",{ref:We,className:"bottom-marker","data-message-id":yt,"data-last-message-id":h?h.messages[h.messages.length-1].id:void 0,"data-album-main-id":h?h.mainMessage.id:void 0,"data-has-unread-mention":t.hasUnreadMention||void 0,"data-has-unread-reaction":Re||void 0,"data-is-pinned":be||void 0,"data-should-update-views":void 0!==t.views}),!V&&o.ZP.createElement("div",{className:"message-select-control"},ue&&o.ZP.createElement("i",{className:"icon icon-select"})),E&&o.ZP.createElement("div",{className:(0,ut.Z)("message-select-control group-select",me&&"is-selected"),onClick:Ts},me&&o.ZP.createElement("i",{className:"icon icon-select"})),p&&function(){const e=!Yt&&Pt?Pt.hiddenUserName:void 0;return o.ZP.createElement(Pa.Z,{size:it?"small-mobile":"small",peer:Yt,text:e,onClick:Yt?hs:void 0})}(),o.ZP.createElement("div",{className:(0,ut.Z)("message-content-wrapper",dn.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:dn,style:Mn,dir:"auto"},Lt&&!Ft&&o.ZP.createElement("div",{className:"message-title"},Qe(Ws?"ForwardedStory":"ForwardedMessage"),An&&o.ZP.createElement("span",{className:"admin-title",dir:"auto"},An)),function(){const e=(0,ut.Z)("content-inner",Lt&&"forwarded-message",Vt&&"with-subheader",Cn&&"no-media-corners"),s=C&&!un&&!Lt&&!rn,n=(0,ut.Z)("text-content","clearfix","in-text"===hn&&"with-meta",H&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:os,dir:"auto"},function(){if(xt&&!Zt||!(f&&(!(Us||Ls||Vs)||Ne)||Lt||Zt||N)||Ft||Tt&&xt)return;let e,s;!Xt||xt&&Zt?Pt?.hiddenUserName?e=Pt.hiddenUserName:Ws&&L&&(e=(0,v.OU)(Qe,L)):(e=(0,v.OU)(Qe,Xt),Lt||Rt||(s=`color-${(0,v.Rs)(Xt)}`));const n=Xt&&"emojiStatus"in Xt&&Xt.emojiStatus,a=Xt&&"isPremium"in Xt&&Xt.isPremium;return o.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?o.ZP.createElement("span",{className:(0,ut.Z)("message-title-name interactive",s),onClick:gs,dir:"ltr"},(0,tn.Z)(e),!Lt&&n&&o.ZP.createElement(as.Z,{documentId:n.documentId,loopLimit:i.y3O,observeIntersectionForLoading:d,observeIntersectionForPlaying:l}),!Lt&&!n&&a&&o.ZP.createElement(is.Z,null),Xt?.fakeType&&o.ZP.createElement(ji.Z,{fakeType:Xt.fakeType})):O?void 0:" ",O&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},Qe("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:ps},(0,tn.Z)(`@${O.usernames[0].username}`))),Pt?.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Qe("DiscussChannel")):t.forwardInfo?.postAuthorTitle&&ne&&Lt?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.forwardInfo?.postAuthorTitle):t.postAuthorTitle&&ne&&!Lt?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.postAuthorTitle):!Te||Lt||Zt?void 0:o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Te.customTitle||Qe(Te.isOwner?"GroupInfo.LabelOwner":"GroupInfo.LabelAdmin")))}(),Vt&&o.ZP.createElement("div",{className:"message-subheader"},Ne&&o.ZP.createElement(Hi,{topic:Ae,onClick:As,className:"message-topic"}),Tt&&o.ZP.createElement(Za.Z,{message:F,noUserColors:Rt||se,isProtected:K,sender:D,chatTranslations:xe,requestedChatTranslationLanguage:Oe,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,onClick:fs}),At&&o.ZP.createElement($i,{story:q,sender:G,noUserColors:Rt||se,isProtected:K,observeIntersectionForLoading:d,onClick:Ns})),Fs&&o.ZP.createElement(Aa,{message:t,observeIntersection:d,observeIntersectionForPlaying:l,shouldLoop:Se,shouldPlayEffect:Fs.hasEffect&&(ke.current&&yt>=ke.current||Et)||void 0,withEffect:_e,onPlayEffect:nt,onStopEffect:at}),Bt&&re&&o.ZP.createElement(Oa,{customEmojiId:re,withEffects:_e&&(0,v.YC)(bt),isOwn:Rt,observeIntersection:d,forceLoadPreview:Et,messageId:yt,chatId:bt,activeEmojiInteractions:ve}),Bt&&oe&&o.ZP.createElement(La,{emoji:oe,withEffects:_e&&(0,v.YC)(bt),isOwn:Rt,observeIntersection:d,forceLoadPreview:Et,messageId:yt,chatId:bt,activeEmojiInteractions:ve}),jt&&o.ZP.createElement(fi,{album:h,albumLayout:yn,observeIntersection:d,isOwn:Rt,isProtected:K,hasCustomAppendix:s,onMediaClick:ws}),an&&o.ZP.createElement(Li,{message:t,phoneCall:an,chatId:bt}),!jt&&Us&&o.ZP.createElement(ja.Z,{message:t,observeIntersection:d,noAvatars:g,canAutoLoad:Ze,uploadProgress:$,shouldAffectAppendix:s,isDownloading:Pe,isProtected:K,asForwarded:Lt,theme:A,forcedWidth:Zn,onClick:Is,onCancelUpload:Cs}),!jt&&Ls&&Ls.isRound&&o.ZP.createElement(Ci,{message:t,observeIntersection:d,canAutoLoad:Ze,isDownloading:Pe}),!jt&&Ls&&!Ls.isRound&&o.ZP.createElement(_a.Z,{message:t,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,forcedWidth:Zn,noAvatars:g,canAutoLoad:Ze,canAutoPlay:Ce,uploadProgress:$,isDownloading:Pe,isProtected:K,asForwarded:Lt,onClick:Is,onCancelUpload:Cs}),(Os||js)&&o.ZP.createElement(Sa.ZP,{theme:A,message:t,origin:m.Cr.Inline,uploadProgress:$,isSelectable:V,isSelected:ue,noAvatars:g,onPlay:vs,onReadMedia:!js||Rt&&!ee?void 0:Zs,onCancelUpload:Cs,isDownloading:Pe,isTranscribing:R,isTranscriptionHidden:et,isTranscribed:Boolean(k),isTranscriptionError:Mt,canDownload:!K,onHideTranscription:tt,canTranscribe:Z}),_s&&o.ZP.createElement(Ca.Z,{message:t,observeIntersection:d,canAutoLoad:Ze,autoLoadFileMaxSizeMb:Me,uploadProgress:$,isSelectable:V,isSelected:ue,onMediaClick:Is,onCancelUpload:Cs,isDownloading:Pe}),Ws&&!Ot&&o.ZP.createElement(Ki,{message:t,isProtected:K}),Ot&&o.ZP.createElement(Ji,{message:t}),Ds&&o.ZP.createElement(Da,{contact:Ds}),qs&&o.ZP.createElement(Wa,{message:t,poll:qs,onSendVote:Ss}),Js&&o.ZP.createElement(mi,{message:t,canAutoLoadMedia:Ze}),$s?.extendedMedia&&o.ZP.createElement(ni,{message:t,isConnected:De}),Wt&&o.ZP.createElement("p",{className:(0,ut.Z)("transcription",!et&&Mt&&"transcription-error"),dir:"auto"},Mt?Qe("NoWordsRecognized"):R&&k?o.ZP.createElement(Oi.Z,{content:k}):k),!Bt&&un&&o.ZP.createElement("div",{className:n,dir:"auto"},Rn(),Qs&&o.ZP.createElement("div",{className:"translation-animation"},o.ZP.createElement("div",{className:"text-loading"},Rn(!0))),"in-text"===hn&&Tn()),Gs&&o.ZP.createElement(Ya.Z,{message:t,observeIntersection:d,noAvatars:g,canAutoLoad:Ze,canAutoPlay:Ce,asForwarded:Lt,isDownloading:Pe,isProtected:K,theme:A,story:Fe,isConnected:De,onMediaClick:Is,onCancelMediaTransfer:Cs}),$s&&!$s.extendedMedia&&o.ZP.createElement(ti,{message:t,shouldAffectAppendix:s&&!Ut,isInSelectMode:le,isSelected:ue,theme:A,forcedWidth:Zn}),Vs&&o.ZP.createElement(ui,{message:t,isInSelectMode:le,isSelected:ue,theme:A,peer:x}))}(),!Dt&&"standalone"===hn&&!Ot&&Tn(),Gt&&Ht?o.ZP.createElement(zt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:Qe("lng_context_forward_msg"),onClick:E?Ms:Es},o.ZP.createElement("i",{className:"icon icon-share-filled"})):Gt&&$t?o.ZP.createElement(zt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:ye?Rs:ks},o.ZP.createElement("i",{className:"icon icon-arrow-right"})):void 0,rn&&o.ZP.createElement(Mi,{threadInfo:Ee,disabled:I}),ln&&o.ZP.createElement(Yi,{isOwn:Rt}),cn&&"in-content"===pn&&kn()),t.inlineButtons&&o.ZP.createElement(Si,{message:t,onClick:$e}),"outside"===gn&&!Ot&&o.ZP.createElement(Ui,{message:ge,isOutside:!0,maxWidth:En,activeReactions:Ie,availableReactions:pe,genericEffects:ce,observeIntersection:l,noRecentReactors:se,withEffects:je})),ct&&o.ZP.createElement(Ra.Z,{isOpen:rt,anchor:ct,targetHref:dt?.matches("a[href]")?dt.href:void 0,message:t,album:h,chatUsername:Nn?.username,messageListType:we,onClose:ht,onCloseAnimationEnd:gt,repliesThreadInfo:Ee,noReplies:w,detectedLanguage:Ys}))}))),Qi=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"AboutAdsModal",!t);return s?o.ZP.createElement(s,e):void 0},eo=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0},to=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s}=t;const n=(0,f.fSe)(e,s),{chatId:a,isBot:i}=n||{};return{message:n,bot:a&&i?(0,f.dyD)(e,a):void 0,channel:!i&&a?(0,f.Z1J)(e,a):void 0}}))((e=>{let{chatId:t,message:s,containerRef:i,bot:r,channel:c}=e;const{viewSponsoredMessage:d,openChat:l,openChatByInvite:u,startBot:m,focusMessage:h}=(0,n.Sv)(),g=(0,_t.Z)(),p=(0,o.sO)(null),f=(0,o.sO)(null),I=Boolean(s),{observe:w}=(0,Hn.S1)({rootRef:i,debounceMs:200,threshold:1}),{isContextMenuOpen:y,contextMenuPosition:b,handleBeforeContextMenu:P,handleContextMenu:Z,handleContextMenuClose:C,handleContextMenuHide:S}=(0,Sn.Z)(p,a.$b,!0,a.wZ),[M,E,R]=(0,ss.Z)(!1);(0,o.d4)((()=>I?w(f.current,(e=>{e.isIntersecting&&d({chatId:t})})):void 0),[t,I,w,d]);const k=(0,pt.Z)((()=>{s&&(s.chatInviteHash?u({hash:s.chatInviteHash}):s.channelPostId?h({chatId:s.chatId,messageId:s.channelPostId}):(l({id:s.chatId}),s.startParam&&m({botId:s.chatId,param:s.startParam})))}));if(s)return o.ZP.createElement("div",{ref:p,key:"sponsored-message",className:"SponsoredMessage Message open",onMouseDown:e=>{(0,Ln.q)(e),P(e)},onContextMenu:Z},o.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},o.ZP.createElement("div",{className:"content-inner",dir:"auto"},o.ZP.createElement("div",{className:"message-title",dir:"ltr"},r&&(0,tn.Z)((0,v.Js)(r)||""),c&&(0,tn.Z)(s.chatInviteTitle||(0,v.U)(g,c)||"")),o.ZP.createElement("div",{className:"text-content with-meta",dir:"auto",ref:f},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,qa.H)({text:s.text.text,entities:s.text.entities})),o.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},o.ZP.createElement("span",{className:"message-signature"},s.isRecommended?g("Message.RecommendedLabel"):g("SponsoredMessage")))),o.ZP.createElement(zt.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:k,className:"SponsoredMessage__button"},g(s.isBot?"Conversation.ViewBot":s.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))),b&&o.ZP.createElement(eo,{isOpen:y,anchor:b,message:s,onAboutAds:E,onClose:C,onCloseAnimationEnd:S}),o.ZP.createElement(Qi,{isOpen:M,onClose:R}))})));var so=s(78323);const no=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s}=t;const n=(0,f.kBx)(e,s);let a,i=!1;if(n){const t=(0,f.ccz)(e,n.id);t?a=t.botInfo:i=!0}return{botInfo:a,isLoadingBotInfo:i}}))((e=>{let{botInfo:t,isLoadingBotInfo:s,isInMessageList:n}=e;const i=(0,_t.Z)(),r=(0,os.Z)(t?.photo?(0,v.NF)(t.photo):void 0),c=(0,os.Z)(t?.gif?(0,v.ym)(t.gif):void 0),d=t?.photo?(0,v.bV)(t.photo):t?.gif?(0,v.jC)(t.gif):void 0,l=d&&{width:d.width/a.cL,height:d.height/a.cL},u=t&&!t.description&&!t.gif&&!t.photo,{width:m,height:h}=l||{};if(!u&&!s||!n)return o.ZP.createElement("div",{className:(0,ut.Z)("Lsq8MNpDNQOesVld_hE2","empty")},s&&o.ZP.createElement("span",null,i("Loading")),u&&!s&&o.ZP.createElement("span",null,i("NoMessages")),t&&o.ZP.createElement("div",{className:"QDlMH9oNVNDnHBMnbvhw",style:l&&`width: ${l.width}px`},r&&o.ZP.createElement("img",{src:r,width:l?.width,height:l?.height,alt:"Bot info"}),c&&o.ZP.createElement(yi.Z,{canPlay:!0,src:c,loop:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0,style:(0,_s.Z)(Boolean(m)&&`width: ${m}px`,Boolean(h)&&`height: ${h}px`)}),d&&!r&&!c&&o.ZP.createElement(ei.Z,{width:l?.width,height:l?.height}),t.description&&o.ZP.createElement("div",{className:"qhxnNXJM8_CyuUQ0pxo7"},o.ZP.createElement("p",{className:"mdOWgfW0GwJTT3vqO5_M"},i("BotInfoTitle")),(0,tn.Z)(t.description,["br","emoji","links"]))))}))),ao=(0,o.X$)((e=>{let{isCurrentUserPremium:t,chatId:s,threadId:r,messageIds:d,messageGroups:l,getContainerHeight:h,isViewportNewest:p,isUnread:f,isComments:w,withUsers:y,isChannelChat:b,noAvatars:P,containerRef:Z,anchorIdRef:C,memoUnreadDividerBeforeIdRef:S,memoFirstUnreadIdRef:M,type:E,isReady:R,threadTopMessageId:k,hasLinkedChat:T,isSchedule:A,shouldRenderBotInfo:N,noAppearanceAnimation:x,onFabToggle:U,onNotchToggle:L,onPinnedIntersectionChange:O}=e;const{openHistoryCalendar:j}=(0,n.Sv)(),_=(0,Jn.Z)(R),{observeIntersectionForReading:F,observeIntersectionForLoading:D,observeIntersectionForPlaying:q}=function(e,t,s,a,i){const{markMessageListRead:o,markMentionsRead:r,animateUnreadReaction:c,scheduleForViewsIncrement:d}=(0,n.Sv)(),{isMobile:l}=(0,B.ZP)(),u=l?300:500,{observe:m,freeze:h,unfreeze:g}=(0,Hn.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e||(0,ft.q)())return;let n=0;const l=[],u=[],m=[],h=[],g=[];let p=!1;t.forEach((e=>{const{isIntersecting:t,target:s,boundingClientRect:a,rootBounds:i}=e,{dataset:o}=s,r=Number(o.lastMessageId||o.messageId),c="true"===o.shouldUpdateViews,d=o.albumMainId?Number(o.albumMainId):void 0;t?(r>n&&(n=r),o.hasUnreadMention&&l.push(r),o.hasUnreadReaction&&u.push(r),o.isPinned&&m.push(d||r),c&&g.push(d||r)):o.isPinned&&(i&&a.bottom<i.top&&(p=!0),h.push(d||r))})),s.current&&n>=s.current&&o({maxId:n}),l.length&&r({messageIds:l}),u.length&&c({messageIds:u}),(m.length||h.length)&&a({viewportPinnedIdsToAdd:m,viewportPinnedIdsToRemove:h,isReversed:p}),g.length&&d({chatId:i,ids:g})}));(0,ft.Z)(h,g);const{observe:p}=(0,Hn.S1)({rootRef:t,throttleMs:Kn,margin:u}),{observe:f}=(0,Hn.S1)({rootRef:t,throttleMs:Kn});return{observeIntersectionForReading:m,observeIntersectionForLoading:p,observeIntersectionForPlaying:f}}(E,Z,M,O,s),{withHistoryTriggers:G,backwardsTriggerRef:H,forwardsTriggerRef:$,fabTriggerRef:V}=function(e,t,s,i,r,d,l,u,h){const{loadViewportMessages:g}=(0,n.Sv)(),[p,f]=(0,o.Ye)((()=>"thread"===e?[(0,I.Ds)((()=>g({direction:m.Uq.Backwards})),1e3,!0,!1),(0,I.Ds)((()=>g({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[g,s]),w=(0,o.sO)(null),y=(0,o.sO)(null),b=(0,o.sO)(null),P=(0,pt.Z)((()=>{if(!h)return;if(!s?.length)return l(!1),void u(!1);if(!r)return l(!0),void u(!0);const e=t.current;if(!e)return;const{offsetHeight:n,scrollHeight:a,scrollTop:i}=e,o=Math.round(a-i-n),c=o<=1;0!==a&&(l(d?!c:!(o<=50)),u(!c))})),{observe:Z}=(0,Hn.S1)({rootRef:t,margin:a.gZ},(e=>{f&&p&&((0,v.AJ)(s[0])||e.forEach((e=>{let{isIntersecting:t,target:s}=e;t&&("backwards-trigger"===s.className&&p(),"forwards-trigger"===s.className&&f())})))})),C=s&&s.length>1;(0,Hn._N)(w,C?Z:void 0),(0,Hn._N)(y,C?Z:void 0);const{observe:S,freeze:M,unfreeze:E}=(0,Hn.S1)({rootRef:t,margin:100,throttleScheduler:c.i$},P);(0,Hn._N)(b,S);const{observe:R,freeze:k,unfreeze:T}=(0,Hn.S1)({rootRef:t,margin:1,throttleScheduler:c.i$},P);(0,Hn._N)(b,R),(0,o.d4)((()=>{h&&P()}),[h,P]);const A=(0,pt.Z)((()=>{M(),k(),setTimeout((()=>{T(),E()}),350)}));(0,vt.Z)(A,[A,s]);const N=(0,Vn.Vr)(i,200);return(0,$n.b)(A,[A,N]),{withHistoryTriggers:C,backwardsTriggerRef:w,forwardsTriggerRef:y,fabTriggerRef:b}}(E,Z,d,h,p,f,U,L,R),K=(0,_t.Z)(),J=o.ZP.createElement("div",{className:(0,ut.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,K("UnreadMessages"))),z=x?0:l.reduce(((e,t)=>e+t.senderGroups.flat().length),0);let W=0;const Y=(0,Hs.Z)(d),X=Boolean(d&&Y&&d[d.length-2]===Y[Y.length-1]),Q=l.map(((e,t,s)=>{const n=e.senderGroups.map(((e,n,a)=>{if(1===e.length&&!Bn(e[0])&&(0,v.FT)(e[0])&&!e[0].content.action?.phoneCall){const i=e[0],c=n===a.length-1&&t===s.length-1;return(0,g.oA)([i.id===S.current&&J,o.ZP.createElement(so.Z,{key:i.id,message:i,threadId:r,messageListType:E,isInsideTopic:Boolean(r&&r!==u._f),observeIntersectionForReading:F,observeIntersectionForLoading:D,observeIntersectionForPlaying:q,memoFirstUnreadIdRef:M,appearanceOrder:z-++W,isJustAdded:c&&X,isLastInList:c,onPinnedIntersectionChange:O})])}let i;return e.map(((c,d)=>{const l=Bn(c)?c.mainMessage:c,m=Bn(c)?c:void 0,h=(0,v.B4)(l),p=Bn(c),f=e[d+1];l.previousLocalId&&C.current===(0,v.d0)(l.previousLocalId)&&(C.current=(0,v.d0)(l.id));const I=!p&&l.groupedId?l.groupedId:void 0,Z=f&&!Bn(f)?f.groupedId:void 0,R={isFirstInGroup:0===d,isLastInGroup:d===e.length-1,isFirstInDocumentGroup:Boolean(I&&I!==i),isLastInDocumentGroup:Boolean(I&&I!==Z),isLastInList:d===e.length-1&&n===a.length-1&&t===s.length-1};i=I;const A=(0,v.KK)(l),N=(0,v.jM)(l)?`${l.date}_${A}`:A,x=!1===T||!b,B=l.id===k;return(0,g.oA)([l.id===S.current&&J,o.ZP.createElement(Xi,{key:N,message:l,observeIntersectionForBottom:F,observeIntersectionForLoading:D,observeIntersectionForPlaying:q,album:m,noAvatars:P,withAvatar:R.isLastInGroup&&y&&!h&&(!B||!w),withSenderName:R.isFirstInGroup&&y&&!h,threadId:r,messageListType:E,noComments:x,noReplies:!x||r!==u._f||"scheduled"===E,appearanceOrder:z-++W,isJustAdded:R.isLastInList&&X,isFirstInGroup:R.isFirstInGroup,isLastInGroup:R.isLastInGroup,isFirstInDocumentGroup:R.isFirstInDocumentGroup,isLastInDocumentGroup:R.isLastInDocumentGroup,isLastInList:R.isLastInList,memoFirstUnreadIdRef:M,onPinnedIntersectionChange:O,getIsMessageListReady:_}),l.id===k&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,K("DiscussionStarted")))])})).flat()}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:Ln.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,ut.Z)("sticky-date",!A&&"interactive"),key:"date-header",onMouseDown:Ln.q,onClick:A?void 0:()=>j({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},A&&e.originalDate===i.t4X&&K("MessageScheduledUntilOnline"),A&&e.originalDate!==i.t4X&&K("MessageScheduledOn",(0,re.j1)(K,e.datetime,void 0,!0)),!A&&(0,re.j1)(K,e.datetime))),n.flat())}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},G&&o.ZP.createElement("div",{ref:H,key:"backwards-trigger",className:"backwards-trigger"}),N&&o.ZP.createElement(no,{isInMessageList:!0,key:`bot_info_${s}`,chatId:s}),Q.flat(),!t&&p&&o.ZP.createElement(to,{key:s,chatId:s,containerRef:Z}),G&&o.ZP.createElement("div",{ref:$,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:V,key:"fab-trigger",className:"fab-trigger"}))}));var io=s(73547);const oo=(0,o.X$)((0,n.c$)(((e,t)=>{let{userId:s}=t;const{stickers:n}=e.stickers.greeting,a=(0,v.db)(s)+(0,v.db)(e.currentUserId),i=n?.length?n[a%n.length]:void 0,o=(0,f.Z1J)(e,s);return o?{sticker:i,lastUnreadMessageId:o.lastMessage&&o.lastMessage.id!==o.lastReadInboxMessageId?o.lastMessage.id:void 0,connectionState:e.connectionState,currentMessageList:(0,f.Btg)(e)}:{}}))((e=>{let{sticker:t,connectionState:s,lastUnreadMessageId:a,currentMessageList:i}=e;const{loadGreetingStickers:r,sendMessage:c,markMessageListRead:d}=(0,n.Sv)(),l=(0,_t.Z)(),u=(0,o.sO)(null),{observe:m}=(0,Hn.S1)({rootRef:u,debounceMs:200});(0,o.d4)((()=>{t||"connectionStateReady"!==s||r()}),[s,r,t]),(0,o.d4)((()=>{"connectionStateReady"===s&&a&&d({maxId:a})}),[s,d,a]);const h=(0,pt.Z)((e=>{i&&(e={...e,isPreloadedGlobally:!0},c({sticker:e,messageList:i}))}));return o.ZP.createElement("div",{className:"ContactGreeting",ref:u},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},l("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},l("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},t&&o.ZP.createElement(io.Z,{sticker:t,onClick:h,clickArg:t,observeIntersection:m,size:160,className:"large",noContextMenu:!0,isCurrentUserPremium:!0}))))}))),ro=3*S.Gw,co=(0,o.X$)((e=>{let{isChatWithSelf:t,type:s,isGroupChatJustCreated:n,topic:a}=e;const i=(0,_t.Z)();return"scheduled"===s?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(i):t?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon no-messages-icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(i):n?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(i):a?function(e,t){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement(Di.Z,{topic:t,size:ro,className:"no-messages-icon topic-icon"}),o.ZP.createElement("h3",{className:"title"},e("Chat.EmptyTopicPlaceholder.Title")),o.ZP.createElement("p",{className:"description topic-description"},(0,tn.Z)(e("Chat.EmptyTopicPlaceholder.Text"),["br"]))))}(i,a):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,i("NoMessages")))})),lo=(0,I.Ds)((e=>e()),200,!1),uo=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s,threadId:n,type:a}=t;const o=(0,f.Z1J)(e,s);if(!o)return{};const r=(0,f.$Wy)(e,s,n,a),c="scheduled"===a?(0,f.yBV)(e,s):(0,f.Zwk)(e,s),d=(0,f.qSq)(e,s,n),l=(0,f.tZg)(e,s,n);if(!(n===u._f||o?.isForum||c&&d&&c[d]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=o,p=(0,f.G$N)(e,s),I=n===u._f&&!r&&!o.unreadCount&&!p&&g&&!g.groupedId,w=(0,f.kBx)(e,s),y=o.topics?.[n],b=(0,v.YC)(s)?void 0:(0,f.x67)(e,s);return{isCurrentUserPremium:(0,f.wVz)(e),isChatLoaded:!0,isRestricted:m,restrictionReason:h,isChannelChat:(0,v.eA)(o),isGroupChat:(0,v.Bf)(o),isCreator:o.isCreator,isChatWithSelf:(0,f.FM1)(e,s),isRepliesChat:(0,v.pK)(s),isBot:Boolean(w),messageIds:r,messagesById:c,isComments:Boolean(l?.originChannelId),firstUnreadId:(0,f.It8)(e,s,n),isViewportNewest:"thread"!==a||(0,f.b9T)(e,s,n),focusingId:p,isSelectModeActive:(0,f.CAb)(e),threadTopMessageId:d,hasLinkedChat:b?Boolean(b.linkedChatId):void 0,topic:y,noMessageSendingAnimation:!(0,f.$Yd)(e,"messageSendingAnimations"),isServiceNotificationsChat:s===i.awM,...I&&{lastMessage:g}}}))((e=>{let{chatId:t,threadId:s,type:a,hasTools:d,onFabToggle:l,onNotchToggle:h,isCurrentUserPremium:p,isChatLoaded:w,isChannelChat:y,isGroupChat:b,canPost:P,isReady:Z,isChatWithSelf:C,isRepliesChat:S,isCreator:M,isBot:E,messageIds:R,messagesById:k,firstUnreadId:T,isComments:A,isViewportNewest:N,isRestricted:x,restrictionReason:B,focusingId:U,isSelectModeActive:L,lastMessage:O,threadTopMessageId:j,hasLinkedChat:_,withBottomShift:F,withDefaultBg:D,topic:q,noMessageSendingAnimation:G,isServiceNotificationsChat:H,onPinnedIntersectionChange:$,getForceNextPinnedInHeader:V}=e;const{loadViewportMessages:K,setScrollOffset:J,loadSponsoredMessages:z,loadMessageReactions:W,copyMessagesByIds:Y,loadMessageViews:X,loadUserStoriesByIds:Q}=(0,n.Sv)(),ee=(0,o.sO)(null),te=(0,o.sO)("thread"===a&&(0,f.Vtl)((0,n.Rd)(),t,s)||(0,f.T6o)((0,n.Rd)(),t,s)||0),se=(0,o.sO)(),ne=(0,o.sO)(),ae=(0,o.sO)(),ie=(0,o.sO)(),oe=(0,o.sO)(),re=(0,o.sO)(),ce=(0,o.sO)(!1),de=(0,o.sO)(Boolean(O)),le=Boolean(R);(0,vt.Z)((()=>{le&&(0,I.R3)((()=>{de.current=!1}))}),[le]),(0,vt.Z)((()=>{ie.current=T}),[T]),(0,o.d4)((()=>{!p&&y&&Z&&z({chatId:t})}),[p,t,Z,y]),(0,vt.Z)((()=>{le&&(oe.current=ie.current)}),[le]),(0,vt.Z)((()=>{re.current=U}),[U]),(e=>{(0,Ot.y)({"Mod+C":function(t){const s=(0,Dn.Z)();s&&s.length>1&&(t.preventDefault(),e({messageIds:s}))}})})(Y);const ue=(0,o.Ye)((()=>{if(!R?.length||!k)return;const e=R.map((e=>k[e])).filter(Boolean),t="scheduled"===a||H?["date","id"]:["id"];return e.length?Un((0,g.Xo)(e,t),oe.current):void 0}),[R,k,a,H]);(0,Mt.Z)((()=>{if(!R||!k||"scheduled"===a)return;const e=R.filter((e=>k[e]?.reactions));e.length&&W({chatId:t,ids:e})}),15e3),(0,Mt.Z)((()=>{if(!R||!k||"scheduled"===a)return;const e=R.map((e=>k[e]?.content.storyData)).filter(Boolean);if(!e.length)return;const t=e.reduce(((e,t)=>{const{userId:s,id:n}=t;return e[s]||(e[s]=[]),e[s].push(n),e}),{});Object.entries(t).forEach((e=>{let[t,s]=e;Q({userId:t,storyIds:s})}))}),3e5),(0,Mt.Z)((()=>{if(!R||!k||s!==u._f||"scheduled"===a)return;const e=R.filter((e=>k[e]?.repliesThreadInfo?.isComments||void 0!==k[e]?.views));e.length&&X({chatId:t,ids:e})}),15e3);const me=(0,o.Ye)((()=>{if("thread"===a)return(0,I.Ds)((()=>K({direction:m.Uq.Around})),1e3,!0,!1)}),[K,R]),{isScrolled:he,updateStickyDates:ge}=function(){const[e,t]=(0,ss.Z)(!1),s=(0,Fn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,pt.Z)(((e,n)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,c.WM)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{const t=function(e,t){const s=e.querySelectorAll(".sticky-date"),n=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:a}=e,i=s-n;return-a<=i&&i<=(t?60:10)}))}(e,n);t&&(0,c.WM)((()=>{t.classList.add("stuck")})),(0,c.WM)((()=>{const e=document.querySelector(".stuck");e&&e.classList.remove("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}))}}(),pe=(0,pt.Z)((()=>{if(ce.current)return void(ce.current=!1);const e=ee.current;e&&(re.current||ge(e,d),lo((()=>{const i=(0,n.Rd)();V()&&!(0,f.jUK)(i).focusedMessage?.chatId&&$({hasScrolled:!0}),e.parentElement&&(te.current=e.scrollHeight-e.scrollTop,"thread"===a&&J({chatId:t,threadId:s,scrollOffset:te.current}))})))})),[fe,Ie]=function(e,t){const[s,n]=(0,Ks.Z)(),a=(0,pt.Z)((e=>{n(e.contentRect.height)}));(0,Gn.Z)(e,a),(0,o.d4)((()=>{const n=Number(e.current.dataset.normalHeight)||0,a=s();a&&a>n&&t&&(e.current.dataset.normalHeight=String(a))}),[t,e,s]);const i=(0,o.sO)();return[s,i]}(ee,P&&!L);(0,o.d4)((()=>{if(!me||!w||x||U)return;if(R&&(0,v.AJ)(R[R.length-1]))return;const e=ee.current;(!R||R.length<i.hT6/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&me()}),[w,R,me,U,x]);const ve=(0,_n.Y)((()=>{if(!R||!ae.current)return;const e=ae.current.filter((e=>R.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(se.current=t.id,ne.current=t.getBoundingClientRect().top)}));(0,vt.Z)((()=>(0,c.yn)((()=>ve.current()))),[R,N,d,ve]),(0,o.d4)((()=>ve.current()),[fe,ve]),(0,qn.Z)((e=>{let[t,s]=e;const n=fe(),a=Ie.current;if(Ie.current=n,R===t&&N===s&&n!==a&&void 0===a)return;const o=ee.current;ae.current=Array.from(o.querySelectorAll(".message-list-item"));const l=ae.current[ae.current.length-1],u=ie.current?o.querySelector(`#${(0,v.d0)(ie.current)}`):void 0,m=R&&t&&R[R.length-1]!==t[t.length-1],h=R?.[0]!==t?.[0]&&R?.length===i.hT6/2+1,g=m&&!h;N&&g&&R&&R.length<i.hT6/2&&!o.parentElement.classList.contains("force-messages-scroll")&&(0,c.yn)((()=>o.firstElementChild.clientHeight<=2*o.offsetHeight))&&((0,r.D_)(o.parentElement,"force-messages-scroll"),o.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{o.parentElement&&(0,r.mC)(o.parentElement,"force-messages-scroll")}),500)),(0,c.lT)((()=>{const{scrollTop:e,scrollHeight:t,offsetHeight:i}=o,r=te.current;let m=r-(a||i);g&&(m-=l?l.offsetHeight:0);const h=N&&s&&m<=50,p=R&&re.current===R[R.length-1];g&&h&&!p&&(0,c.i$)((()=>{const e=!(0,ft.q)()||!u;(0,jn.ZP)(o,e?l:u,e?"end":"start",20,void 0,void 0,G?0:void 0)}));const f=void 0!==a&&a!==n;if(f&&(0,jn.Ni)())return;const I=se.current&&o.querySelector(`#${se.current}`),v=!I&&oe.current&&o.querySelector(".unread-divider");let w;if(h&&f)w=t-i;else if(I){const t=I.getBoundingClientRect().top;w=e+(t-(ne.current||0))}else w=v?Math.min(v.offsetTop-(d?60:10),t-r):t-r;return()=>{(0,On.Z)(o,Math.ceil(w)),(0,jn.wA)(),te.current=Math.max(Math.ceil(t-w),i),re.current||(ce.current=!0,(0,c.i$)((()=>{ce.current=!1})))}}))}),[R,N,d,fe,Ie,G]),(0,ns.Z)((e=>{let[t]=e;void 0!==t&&(0,St.YW)(200+i.fK3)}),[L]);const we=Boolean(t&&(0,v.YC)(t)),ye=Boolean(!we&&!y||C||S),be=Boolean(!ye||y),Pe=(0,v.YC)(t)&&!C&&!E&&(!ue&&!O&&R&&(!ae.current||0===ae.current.length)||1===R?.length&&"contactSignUp"===k?.[R[0]]?.content.action?.type||"contactSignUp"===O?.content?.action?.type),Ze=b&&M&&1===R?.length&&"chatCreate"===k?.[R[0]]?.content.action?.type,Ce=1===R?.length&&"topicCreate"===k?.[R[0]]?.content.action?.type,Se=(0,ut.Z)("MessageList custom-scroll",be&&"no-avatars",!P&&"no-composer","pinned"===a&&"type-pinned",F&&"with-bottom-shift",D&&"with-default-bg",L&&"select-mode-active",he&&"scrolled",!Z&&"is-animating"),Me=R&&ue||O;return o.ZP.createElement("div",{ref:ee,className:Se,onScroll:pe,onMouseDown:Ln.q},x?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,B?B.text:"This is a private "+(y?"channel":"chat"))):E&&!Me?o.ZP.createElement(no,{chatId:t}):Pe?o.ZP.createElement(oo,{userId:t}):R&&(!ue||Ze||Ce)?o.ZP.createElement(co,{chatId:t,topic:q,type:a,isChatWithSelf:C,isGroupChatJustCreated:Ze}):Me?o.ZP.createElement(ao,{isCurrentUserPremium:p,chatId:t,isComments:A,isChannelChat:y,messageIds:R||[O.id],messageGroups:ue||Un([O]),getContainerHeight:fe,isViewportNewest:Boolean(N),isUnread:Boolean(T),withUsers:ye,noAvatars:be,containerRef:ee,anchorIdRef:se,memoUnreadDividerBeforeIdRef:oe,memoFirstUnreadIdRef:ie,threadId:s,type:a,isReady:Z,threadTopMessageId:j,hasLinkedChat:_,isSchedule:!!ue&&"scheduled"===a,shouldRenderBotInfo:E,noAppearanceAnimation:!ue||!de.current,onFabToggle:l,onNotchToggle:h,onPinnedIntersectionChange:$}):o.ZP.createElement(Zs.Z,{color:"white",backgroundColor:"dark"}))}))),mo=(0,o.X$)((e=>{let{icon:t,ariaLabelLang:s,unreadCount:n,onClick:a,onReadAll:i,className:r}=e;const c=(0,_t.Z)(),d=(0,o.sO)(null),{isContextMenuOpen:l,handleContextMenu:u,handleContextMenuClose:m,handleContextMenuHide:h}=(0,Sn.Z)(d,!i);return o.ZP.createElement("div",{className:(0,ut.Z)("KboxtoWkfx23zfklH_Zg",r),ref:d},o.ZP.createElement(zt.Z,{color:"secondary",round:!0,className:"sgkkv3bmIMAZS9G9BHUz",onClick:a,onContextMenu:u,ariaLabel:c(s)},o.ZP.createElement("i",{className:(0,ut.Z)("AafG9_xBi_2eJ_bFNnNg","icon",`icon-${t}`)})),Boolean(n)&&o.ZP.createElement("div",{className:"yKN1kQ3YXf4SHHIBcotS"},(0,At.bi)(n)),i&&o.ZP.createElement(Ms.Z,{isOpen:l,onClose:m,onCloseAnimationEnd:h,autoClose:!0,positionX:"right",positionY:"bottom"},o.ZP.createElement(Jt.Z,{icon:"readchats",onClick:i},c("MarkAllAsRead"))))})),ho="EcdaljLbQ7DJN9gbQpSC",go=(0,o.X$)((0,n.c$)((e=>{const t=(0,f.Btg)(e);if(!t)return{};const{chatId:s,threadId:n,type:a}=t,i=(0,f.Z1J)(e,s),o=i&&n===u._f&&"thread"===a;return{messageListType:a,chatId:s,reactionsCount:o?i.unreadReactionsCount:void 0,mentionsCount:o?i.unreadMentionsCount:void 0,unreadCount:o?i.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:s,messageListType:a,chatId:i,unreadCount:r,reactionsCount:c,mentionsCount:d,withExtraShift:l}=e;const{focusNextReply:u,focusNextReaction:m,focusNextMention:h,fetchUnreadReactions:g,readAllMentions:p,readAllReactions:f,fetchUnreadMentions:I}=(0,n.Sv)(),v=(0,o.sO)(null),w=Boolean(c),y=Boolean(d);(0,o.d4)((()=>{w&&i&&g({chatId:i})}),[i,g,w]),(0,o.d4)((()=>{y&&i&&I({chatId:i})}),[i,I,y]);const b=(0,pt.Z)((()=>{if(t)if("thread"===a)u();else{const e=v.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,jn.ZP)(e,s,"end",20)}})),P=(0,ut.Z)("quM3aP53TOfurCEOYgOE",(t||Boolean(c)||Boolean(d))&&"Gutr8PrNAFFTnrIdgK_l",(Boolean(c)||Boolean(d))&&!t&&"bHOz3QboabL0RvHuj3ku",!s&&"r7RXnwv5TF4Cf2V0d5Mf",!l&&"S98OqutuQVCNVHgTrKv4");return o.ZP.createElement("div",{ref:v,className:P},o.ZP.createElement(mo,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:m,onReadAll:f,unreadCount:c,className:(0,ut.Z)("wHTB_MNtk9J6I3F_4eVE",!w&&ho,!y&&"uHEtFnXb6pb14Jf0EsDr")}),o.ZP.createElement(mo,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:h,onReadAll:p,unreadCount:d,className:!y&&ho}),o.ZP.createElement(mo,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:b,unreadCount:r,className:"Hoi4yrJrfBHTmvB8TPce"}))}))),po=e=>{const{isActive:t}=e,s=(0,kt.Z)(gt.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0},fo=e=>{const{isActive:t}=e,s=(0,kt.Z)(gt.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0},Io=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0},vo=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"SeenByModal",!t);return s?o.ZP.createElement(s,e):void 0},wo=e=>{const{activeEmojiInteraction:t}=e,s=(0,kt.Z)(gt.gl.Extra,"EmojiInteractionAnimation",!t);return s?o.ZP.createElement(s,e):void 0},yo=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"ReactorListModal",!t);return s?o.ZP.createElement(s,e):void 0},bo=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"GiftPremiumModal",!t);return s?o.ZP.createElement(s,e):void 0},Po=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"ChatLanguageModal",!t);return s?o.ZP.createElement(s,e):void 0};var Zo=s(4949);function Co(e){return"file"===e.kind&&e.type&&i.oGt.has(e.type)}const So=450+i.fK3,Mo=(0,o.X$)((0,n.c$)(((e,t)=>{let{isMobile:s}=t;const n=(0,f.Puy)(e),{isBlurred:a,background:o,backgroundColor:r,patternColor:c}=e.settings.themes[n]||{},{messageLists:d,isLeftColumnShown:l,activeEmojiInteractions:m,seenByModal:h,giftPremiumModal:g,reactorModal:p,audioPlayer:I,shouldSkipHistoryAnimations:w,chatLanguageModal:y}=(0,f.jUK)(e),b=(0,f.Btg)(e),{leftColumnWidth:P}=e,Z={theme:n,customBackground:o,backgroundColor:r,patternColor:c,isLeftColumnShown:l,isRightColumnShown:(0,f.Jf5)(e,s),isBackgroundBlurred:a,hasCurrentTextSearch:Boolean((0,f.n5x)(e)),isSelectModeActive:(0,f.CAb)(e),isSeenByModalOpen:Boolean(h),isReactorListModalOpen:Boolean(p),isGiftPremiumModalOpen:g?.isOpen,isChatLanguageModalOpen:Boolean(y),withInterfaceAnimations:(0,f.FOo)(e),currentTransitionKey:Math.max(0,d.length-1),activeEmojiInteractions:m,leftColumnWidth:P};if(!b)return Z;const{chatId:C,threadId:S,type:M}=b,E=(0,v.YC)(C),R=(0,f.Z1J)(e,C),k=(0,f.kBx)(e,C),T=(0,f.KBA)(e,C,S),{chatId:A,messageId:N}=I,x=(0,f.tZg)(e,C,S),B=Boolean(x?.originChannelId),U=R&&(0,v.Qm)(R,S,B),L=(0,f.pkN)(e,C),O="pinned"===M,j="thread"===M&&S===u._f,_=Boolean(R&&(0,v.eA)(R)),F=Boolean(R&&j&&(_||(0,v.ZV)(R))&&R.isNotJoined&&!R.joinRequests),D=Boolean(R?.isNotJoined&&R.isJoinToSend),q=Boolean(R?.isNotJoined&&R.isJoinRequest),G=Boolean(k&&(0,f.s4q)(e,k.id)),H=!G&&L,$=Boolean(R&&(0,v.Bf)(R)&&!(0,f.x67)(e,R.id)),V=(0,f.Yyv)(e,C,S),K=!!R?.isForum&&S===u._f&&!V&&R.topics?.[i.OxA]?.isClosed,J=A&&N?(0,f.hjO)(e,A,N):void 0,z=S!==u._f&&!R?.isForum,W=z?(0,f.qSq)(e,C,S):void 0,Y=R&&(E||R?.isCreator||!_&&!(0,v.Mg)(R,"pinMessages")||(0,v.VE)(R,"pinMessages"));return{...Z,chatId:C,threadId:S,messageListType:M,chat:R,replyingToId:V,isPrivate:E,areChatSettingsLoaded:Boolean(R?.settings),canPost:!O&&(!R||U)&&!L&&!(D&&R?.isNotJoined)&&!K,isPinnedMessageList:O,currentUserBannedRights:R?.currentUserBannedRights,defaultBannedRights:R?.defaultBannedRights,hasPinned:z||Boolean(!O&&T?.length),hasAudioPlayer:Boolean(J),hasButtonInHeader:H||G||F||q,pinnedMessagesCount:T?T.length:0,shouldSkipHistoryAnimations:w,isChannel:_,canSubscribe:F,canStartBot:H,canRestartBot:G,shouldJoinToSend:D,shouldSendJoinRequest:q,shouldLoadFullChat:$,pinnedIds:T,topMessageId:W,canUnpin:Y}}))((function(e){let{leftColumnRef:t,chatId:s,threadId:r,messageListType:d,isMobile:l,chat:u,replyingToId:m,isPrivate:h,isPinnedMessageList:p,canPost:I,currentUserBannedRights:w,defaultBannedRights:y,hasPinned:b,hasAudioPlayer:P,hasButtonInHeader:Z,pinnedMessagesCount:C,customBackground:A,theme:N,backgroundColor:x,patternColor:U,isLeftColumnShown:L,isRightColumnShown:O,isBackgroundBlurred:j,leftColumnWidth:_,hasCurrentTextSearch:F,isSelectModeActive:D,isSeenByModalOpen:q,isReactorListModalOpen:G,isGiftPremiumModalOpen:H,isChatLanguageModalOpen:$,withInterfaceAnimations:V,shouldSkipHistoryAnimations:K,currentTransitionKey:J,isChannel:z,areChatSettingsLoaded:W,canSubscribe:Y,canStartBot:X,canRestartBot:Q,activeEmojiInteractions:ee,shouldJoinToSend:te,shouldSendJoinRequest:se,shouldLoadFullChat:ne,pinnedIds:ae,topMessageId:ie,canUnpin:oe}=e;const{openChat:re,openPreviousChat:ce,unpinAllMessages:de,loadUser:le,loadChatSettings:ue,closeLocalTextSearch:me,exitMessageSelectMode:he,joinChannel:ge,sendBotCommand:pe,restartBot:fe,showNotification:Ie,loadFullChat:ve,setLeftColumnWidth:we,resetLeftColumnWidth:ye}=(0,n.Sv)(),{width:be}=(0,qs.Z)(),{isTablet:Pe,isDesktop:Ze}=(0,B.ZP)(),Ce=(0,_t.Z)(),[Se,Me]=(0,o.eJ)(js.t.None),[Ee,Re]=(0,o.eJ)(),[ke,Te]=(0,o.eJ)(),[Ae,Ne]=(0,o.eJ)(!1),{onIntersectionChanged:xe,onFocusPinnedMessage:Be,getCurrentPinnedIndexes:Ue,getLoadingPinnedId:Le,getForceNextPinnedInHeader:Oe}=function(e,t,s,a){const[i,r]=(0,Ks.Z)({}),[c,d]=(0,Ks.Z)(),l=(0,o.sO)(),[u,m]=(0,Ks.Z)(),h=e?`${e}_${t}`:void 0;return(0,o.d4)((()=>{d(void 0),l.current=void 0,m(void 0)}),[e,r,d,m,t]),(0,o.d4)((()=>{if(!h)return;const e=i()[h],t=s?.length||0;e>=t&&r({...i(),[h]:Math.max(0,t-1)})}),[i,h,s?.length,r]),{onIntersectionChanged:(0,pt.Z)((a=>{let{viewportPinnedIdsToAdd:o=[],viewportPinnedIdsToRemove:p=[],isReversed:I,hasScrolled:v,isUnmount:w}=a;if(!e||!t||!h)return;const y=(0,n.Rd)();if(!s?.length||!s)return;const b=u();if(b&&!v){const e=s.indexOf(b);r({...i(),[h]:e}),m(void 0)}v&&(d(void 0),m(void 0));const P=c(),Z=l.current;if(w&&0===o.length&&1===p.length&&!Z?.includes(p[0]))return;const C=(0,g.Tw)((Z?.filter((e=>!p.includes(e)))||[]).concat(o));l.current=C;const S=(0,f.G$N)(y,e);if(!C.length&&w&&S&&!s.includes(S)){const e=s.find((e=>e<S));if(e){const t=s.indexOf(e);r({...i(),[h]:t})}}if(P||w)return;const M=Math.max(...C),E=s.findIndex((e=>e===M)),R=I?0:1,k=C.length?E:Z?.length?(0,$s.uZ)(s.indexOf(Z[0])+R,0,s.length-1):0;r({...i(),[h]:k})})),onFocusPinnedMessage:(0,pt.Z)((o=>{if(!e||!t||!h||u())return!1;const c=(0,n.Rd)();if(!s?.length)return a===o;const l=s.indexOf(o),g=(0,Vs.Z)(s.length,l+1);return d(!0),(0,f.gbs)(c,e,t)?.includes(o)||(0,f.ofg)(c,e,t,o)?(r({...i(),[h]:g}),!0):(m(s[g]),!0)})),getCurrentPinnedIndexes:i,getLoadingPinnedId:u,getForceNextPinnedInHeader:c}}(s,r,ae,ie),je=l&&F,_e=l?So:void 0,Fe=b&&(be<i.l35||P||O&&be>i._mX&&be<i.QU1||!l&&Z&&be<i.sgm),De=(0,Gs.Z)(s,_e),qe=(0,Gs.Z)(r,_e),Ge=(0,Gs.Z)(d,_e),He=(0,Gs.Z)(Y,_e),$e=(0,Gs.Z)(X,_e),Ve=(0,Gs.Z)(Q,_e),Ke=(0,Gs.Z)(I,_e)&&!Ve&&!$e&&!He&&s!==i.mzl,Je=(0,Gs.Z)(Fe,_e),ze=(0,Gs.Z)(Ee,_e)&&s!==i.mzl,We=(0,Gs.Z)(z,_e),Ye=(0,Gs.Z)(te,_e),Xe=(0,Gs.Z)(se,_e),Qe=(0,Gs.Z)(s?xe:void 0,_e),et=(0,Hs.Z)(J),tt=void 0!==et&&et<J?et:void 0,{isReady:st,handleCssTransitionEnd:nt,handleSlideTransitionStop:at}=function(e,t,s,n,a){const[i,r]=(0,o.eJ)(!a),c=(0,Zt.Z)(),d=void 0!==s&&s!==t;return d&&(e?(r(!1),setTimeout((()=>{r(!0)}),So)):c()),(0,vt.Z)((()=>{e||r(!0)}),[e]),{isReady:i&&!d,handleCssTransitionEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&r(Boolean(n))}:void 0,handleSlideTransitionStop:e?function(){r(!0)}:void 0}}(!K&&V,J,et,s,l);(0,o.d4)((()=>s?(0,Ut.Z)((()=>{re({id:void 0})})):void 0),[s,re]),(0,vt.Z)((()=>{Me(js.t.None),Te(void 0)}),[s]),(0,o.d4)((()=>{if(!a.cj&&!a.wZ)return;const{visualViewport:e}=window;if(!e)return;const t=()=>{const t=e.height!==document.documentElement.clientHeight;(0,c.WM)((()=>{document.body.classList.toggle("keyboard-visible",t),(0,c.i$)((()=>{!t&&e.offsetTop&&(0,c.WM)((()=>{window.scrollTo({top:0})}))}))}))};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}})),(0,o.d4)((()=>{h&&le({userId:s})}),[s,h,le]),(0,o.d4)((()=>{W||ue({chatId:s})}),[s,h,W]),(0,o.d4)((()=>{s&&ne&&st&&ve({chatId:s})}),[ne,s,st,ve]);const{initResize:it,resetResize:ot,handleMouseUp:rt}=function(e,t,s,n,a){const[i,r,d]=(0,ss.Z)(),[l,u]=(0,o.eJ)(0),[m,h]=(0,o.eJ)(0),g=(0,pt.Z)((t=>{(0,c.WM)((()=>{if(!e.current)return;const s=t?`${t}px`:"";e.current.style.width=s,e.current.style.setProperty(a,s)}))}));function p(){(0,c.WM)((()=>{document.body.classList.remove("cursor-ew-resize")}))}return(0,o.bt)((()=>{e.current&&n&&g(n)}),[a,e,n,g]),(0,o.d4)((()=>{if(!i)return;const s=e=>{const t=Math.ceil(m+e.clientX-l);g(t)};function n(){a(),t(e.current.offsetWidth)}function a(){p(),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",n,!1),document.removeEventListener("blur",n,!1),d()}return document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",n,!1),document.addEventListener("blur",n,!1),a}),[m,l,e,t,i,d,g]),{initResize:function(t){t.preventDefault(),(0,c.WM)((()=>{document.body.classList.add("cursor-ew-resize")})),u(t.clientX),h(e.current.offsetWidth),r()},resetResize:function(e){e.preventDefault(),g(void 0),s()},handleMouseUp:p}}(t,(e=>we({leftColumnWidth:e})),ye,_,"--left-column-width"),ct=(0,pt.Z)((e=>{const{items:t}=e.dataTransfer||{},s=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(Co);Me(s?js.t.QuickFile:js.t.Document)})),dt=(0,pt.Z)((()=>{Me(js.t.None)})),lt=(0,pt.Z)((()=>{Ne(!0)})),mt=(0,pt.Z)((()=>{Ne(!1)})),ht=(0,pt.Z)((()=>{de({chatId:s,threadId:r}),mt(),ce()})),gt=(0,pt.Z)((()=>{re({id:s})})),ft=(0,pt.Z)((()=>{ge({chatId:s}),Xe&&Ie({message:Ce(z?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})})),It=(0,pt.Z)((()=>{pe({command:"/start"})})),wt=(0,pt.Z)((()=>{fe({chatId:s})})),yt=((e,t)=>{const[s,n]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?n(t):Fs.fetch(i.foQ,e,Fs.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,Ds.pt)(t).then((()=>{n(`url(${t})`)}))})))}),[t,e]),t?s:void 0})(N,A),bt=(0,ut.Z)(Je&&"has-header-tools",a.aZ?"mask-image-disabled":"mask-image-enabled"),Pt=(0,ut.Z)("ON5E8MkEVA1mAlkuIxhG","OWFg9Wf1uioPWDz_IgS8",A&&"Ik9ZZlj3eKtKXRrUZKVk",x&&"avVozLQe3SaWcSkIt6pG",A&&j&&"Tipa66fYcSvl6w0587Xz",O&&"vhOr8s3T_LCKSt2BF7fs"),Ct=(0,ut.Z)("messaging-disabled",!D&&"shown"),St=(0,v.q8)(Ce,w,y),Mt=(0,v.mt)(Ce,u,r,Boolean(m)),Et=St||Mt,{composerHiddenScale:Rt,toolbarHiddenScale:kt,composerTranslateX:Tt,toolbarTranslateX:At,unpinHiddenScale:Nt,toolbarForUnpinHiddenScale:xt}=(0,o.Ye)((()=>function(e,t){const s=e<=i.l35?S.Gw:2*S.Gw,n=function(e){if(e>i._mX){const t=Math.min(Math.max(.25*e,k),R),s=Math.min(.25*e,R);return Math.min(e-t-s,E)}if(e>i.ksF){const t=Math.min(Math.max(.4*e,k),R);return Math.min(e-t,E)}return e>E?E:e}(e),a=e<=i.l35?3.375*S.Gw:4*S.Gw,o=t?n-s-a:n-s,r=e>i.l35?Math.min(n-s,M):n-s,c=r/o,d=o/r;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?a/2*d:0,toolbarTranslateX:t?a/2*-1*c:0,unpinHiddenScale:r/T,toolbarForUnpinHiddenScale:T/r}}(be,Ke)),[Ke,be]),Bt=(0,ut.Z)("middle-column-footer",!Ke&&"no-composer",Ke&&ke&&!D&&"with-notch");(0,Is.Z)({isActive:D,onBack:he}),(0,Is.Z)({isActive:je,onBack:me});const Lt=Boolean(!p&&!Ke&&!Ve&&!$e&&!He&&Et),Ot=Boolean(Ve||He||Xe||$e||p),Ft=Boolean(Lt||D||p);return o.ZP.createElement("div",{id:"MiddleColumn",className:bt,onTransitionEnd:nt,style:(0,_s.Z)(`--composer-hidden-scale: ${Rt}`,`--toolbar-hidden-scale: ${kt}`,`--unpin-hidden-scale: ${Nt}`,`--toolbar-unpin-hidden-scale: ${xt},`,`--composer-translate-x: ${Tt}px`,`--toolbar-translate-x: ${At}px`,`--pattern-color: ${U}`,x&&`--theme-background-color: ${x}`),onClick:Pe&&L?gt:void 0},Ze&&o.ZP.createElement("div",{className:"resize-handle",onMouseDown:it,onMouseUp:rt,onDoubleClick:ot}),o.ZP.createElement("div",{className:Pt,style:yt?`--custom-background: ${yt}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),Boolean(De&&qe)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:Ke?ct:void 0},o.ZP.createElement(xn,{chatId:De,threadId:qe,messageListType:Ge,isReady:st,isMobile:l,getCurrentPinnedIndexes:Ue,getLoadingPinnedId:Le,onFocusPinnedMessage:Be}),o.ZP.createElement(jt.Z,{name:K?"none":V?"slide":"fade",activeKey:J,shouldCleanup:!0,cleanupExceptionKey:tt,onStop:at},o.ZP.createElement(uo,{key:`${De}-${qe}-${Ge}`,chatId:De,threadId:qe,type:Ge,canPost:Ke,hasTools:Je,onFabToggle:Re,onNotchToggle:Te,isReady:st,withBottomShift:Ot,withDefaultBg:Boolean(!A&&!x),onPinnedIntersectionChange:Qe,getForceNextPinnedInHeader:Oe}),o.ZP.createElement("div",{className:Bt},Ke&&o.ZP.createElement(Zo.Z,{type:"messageList",chatId:De,threadId:qe,messageListType:Ge,dropAreaState:Se,onDropHide:dt,isReady:st,isMobile:l,editableInputId:i.R2F,editableInputCssSelector:i.Edp,inputId:"message-input-text"}),p&&oe&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Ce.isRtl?"rtl":void 0},o.ZP.createElement(zt.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:lt},o.ZP.createElement("i",{className:"icon icon-unpin"}),o.ZP.createElement("span",null,Ce("Chat.Pinned.UnpinAll",C,"i")))),Lt&&o.ZP.createElement("div",{className:Ct},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,Et))),l&&(He||Ye&&!Xe)&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Ce.isRtl?"rtl":void 0},o.ZP.createElement(zt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:ft},Ce(We?"ProfileJoinChannel":"ProfileJoinGroup"))),l&&Xe&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Ce.isRtl?"rtl":void 0},o.ZP.createElement(zt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:ft},Ce("ChannelJoinRequest"))),l&&$e&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Ce.isRtl?"rtl":void 0},o.ZP.createElement(zt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:It},Ce("BotStart"))),l&&Ve&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Ce.isRtl?"rtl":void 0},o.ZP.createElement(zt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:wt},Ce("BotRestart"))),o.ZP.createElement(fo,{messageListType:Ge,isActive:D,canPost:Ke}),o.ZP.createElement(vo,{isOpen:q}),o.ZP.createElement(yo,{isOpen:G}),a.SX&&o.ZP.createElement(Po,{isOpen:$}))),o.ZP.createElement(go,{isShown:ze,canPost:Ke,withExtraShift:Ft})),l&&o.ZP.createElement(po,{isActive:Boolean(je)})),s&&o.ZP.createElement(Io,{isOpen:Ae,chatId:s,pinnedMessagesCount:C,onClose:mt,onUnpin:ht}),o.ZP.createElement("div",{teactFastList:!0},ee?.map(((e,t)=>o.ZP.createElement(wo,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))),o.ZP.createElement(bo,{isOpen:H}))}))),Eo=450+i.fK3,Ro=(0,I.Ds)((e=>e()),200,!1);var ko=function(e){return e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.StoryList=3]="StoryList",e[e.Search=4]="Search",e[e.Statistics=5]="Statistics",e[e.MessageStatistics=6]="MessageStatistics",e[e.Management=7]="Management",e[e.ManageInitial=8]="ManageInitial",e[e.ManageChannelSubscribers=9]="ManageChannelSubscribers",e[e.ManageChatAdministrators=10]="ManageChatAdministrators",e[e.ManageChatPrivacyType=11]="ManageChatPrivacyType",e[e.ManageDiscussion=12]="ManageDiscussion",e[e.ManageGroupPermissions=13]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=14]="ManageGroupRemovedUsers",e[e.ManageChannelRemovedUsers=15]="ManageChannelRemovedUsers",e[e.ManageGroupUserPermissionsCreate=16]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=17]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=18]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=19]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=20]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=21]="ManageGroupMembers",e[e.ManageGroupAddAdmins=22]="ManageGroupAddAdmins",e[e.StickerSearch=23]="StickerSearch",e[e.GifSearch=24]="GifSearch",e[e.PollResults=25]="PollResults",e[e.AddingMembers=26]="AddingMembers",e[e.ManageInvites=27]="ManageInvites",e[e.ManageEditInvite=28]="ManageEditInvite",e[e.ManageReactions=29]="ManageReactions",e[e.ManageInviteInfo=30]="ManageInviteInfo",e[e.ManageJoinRequests=31]="ManageJoinRequests",e[e.CreateTopic=32]="CreateTopic",e[e.EditTopic=33]="EditTopic",e}(ko||{});const To=(0,n.c$)(((e,t)=>{let{chatId:s,isProfile:n,isManagement:a,threadId:i}=t;const o=(0,f.jUK)(e),{query:r}=(0,f.n5x)(e)||{},{query:c}=(0,f.y5E)(e)||{},{query:d}=(0,f.yNS)(e)||{},l=s?(0,f.Z1J)(e,s):void 0,m=n&&s&&(0,v.YC)(s)?(0,f.dyD)(e,s):void 0,h=l&&(0,v.eA)(l),g=l?.isForum&&Boolean(i&&i!==u._f),p=g?l.topics?.[i]:void 0,I=g&&p&&(0,v.GU)(l,p),w=m&&(0,v.cS)(m),y=m&&(0,v.kw)(m),b=Boolean(!a&&n&&s&&(0,f.Yo)(e,s)),P=Boolean(s&&o.management.byChatId[s]?.editingInvite),Z=!g&&s?(0,f.x67)(e,s)?.canViewStatistics:void 0,C=s?o.management.byChatId[s]?.inviteInfo?.invite:void 0;return{canManage:b,canAddContact:y,canViewStatistics:Z,isChannel:h,isBot:w,isInsideTopic:g,canEditTopic:I,userId:m?.id,isSelf:m?.isSelf,messageSearchQuery:r,stickerSearchQuery:c,gifSearchQuery:d,isEditingInvite:P,currentInviteInfo:C,shouldSkipHistoryAnimations:o.shouldSkipHistoryAnimations}}))((e=>{var t;let{chatId:s,threadId:a,isColumnOpen:i,isProfile:r,isSearch:c,isManagement:d,isStatistics:l,isMessageStatistics:u,isStickerSearch:h,isGifSearch:g,isPollResults:p,isCreatingTopic:f,isEditingTopic:I,isAddingChatMembers:v,profileState:w,managementScreen:y,canAddContact:b,userId:P,isSelf:Z,canManage:C,isChannel:S,onClose:M,onScreenSelect:E,messageSearchQuery:R,stickerSearchQuery:k,gifSearchQuery:T,isEditingInvite:A,canViewStatistics:N,currentInviteInfo:x,shouldSkipHistoryAnimations:U,isBot:L,isInsideTopic:O,canEditTopic:j}=e;const{setLocalTextSearchQuery:_,setStickerSearchQuery:F,setGifSearchQuery:D,searchTextMessagesLocal:q,toggleManagement:G,openHistoryCalendar:H,openAddContactDialog:$,toggleStatistics:V,setEditingExportedInvite:K,deleteExportedChatInvite:J,openEditTopicPanel:z}=(0,n.Sv)(),[W,Y,X]=(0,ss.Z)(),{isMobile:Q}=(0,B.ZP)(),ee=(0,pt.Z)((()=>{K({chatId:s,invite:x}),E(m.u1.EditInvite)})),te=(0,pt.Z)((()=>{J({chatId:s,link:x.link}),E(m.u1.Invites),X()})),se=(0,pt.Z)((e=>{_({query:e}),e.length&&Ro(q)})),ne=(0,pt.Z)((e=>{F({query:e})})),ae=(0,pt.Z)((e=>{D({query:e})})),ie=(0,pt.Z)((()=>{$({userId:P})})),oe=(0,pt.Z)((()=>{s&&a&&z({chatId:s,topicId:a})})),ce=(0,pt.Z)((()=>{G()})),de=(0,pt.Z)((()=>{V()})),[le,ue]=(0,o.eJ)(!i);(0,o.d4)((()=>{setTimeout((()=>{ue(!i)}),Eo)}),[i]);const me=(0,_t.Z)(),he=r?w===m.vi.Profile?ko.Profile:w===m.vi.SharedMedia?ko.SharedMedia:w===m.vi.MemberList?ko.MemberList:w===m.vi.StoryList?ko.StoryList:-1:c?ko.Search:p?ko.PollResults:h?ko.StickerSearch:g?ko.GifSearch:v?ko.AddingMembers:d?y===m.u1.Initial?ko.ManageInitial:y===m.u1.ChatPrivacyType?ko.ManageChatPrivacyType:y===m.u1.Discussion?ko.ManageDiscussion:y===m.u1.ChannelSubscribers?ko.ManageChannelSubscribers:y===m.u1.GroupPermissions?ko.ManageGroupPermissions:y===m.u1.ChatAdministrators?ko.ManageChatAdministrators:y===m.u1.GroupRemovedUsers?ko.ManageGroupRemovedUsers:y===m.u1.ChannelRemovedUsers?ko.ManageChannelRemovedUsers:y===m.u1.GroupUserPermissionsCreate?ko.ManageGroupUserPermissionsCreate:y===m.u1.GroupUserPermissions?ko.ManageGroupUserPermissions:y===m.u1.GroupRecentActions?ko.ManageGroupRecentActions:y===m.u1.ChatAdminRights?ko.ManageGroupAdminRights:y===m.u1.ChatNewAdminRights?ko.ManageGroupNewAdminRights:y===m.u1.GroupMembers?ko.ManageGroupMembers:y===m.u1.Invites?ko.ManageInvites:y===m.u1.EditInvite?ko.ManageEditInvite:y===m.u1.GroupAddAdmins?ko.ManageGroupAddAdmins:y===m.u1.Reactions?ko.ManageReactions:y===m.u1.InviteInfo?ko.ManageInviteInfo:y===m.u1.JoinRequests?ko.ManageJoinRequests:void 0:l?ko.Statistics:u?ko.MessageStatistics:f?ko.CreateTopic:I?ko.EditTopic:void 0,ge=null!==(t=(0,Ws.Z)(he,!0))&&void 0!==t?t:-1,pe=Q||he===ko.SharedMedia||he===ko.MemberList||he===ko.StoryList||he===ko.AddingMembers||he===ko.MessageStatistics||d,fe=(0,ut.Z)("animated-close-icon",pe&&"state-back",(le||U)&&"no-transition"),Ie=(0,o.sO)(null);return(0,Vt.Z)(Ie),o.ZP.createElement("div",{className:"RightHeader",ref:Ie},o.ZP.createElement(zt.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:M,ariaLabel:me(pe?"Common.Back":"Common.Close")},o.ZP.createElement("div",{className:fe})),o.ZP.createElement(jt.Z,{name:le||U?"none":"slideFade",activeKey:ge},function(){if(-1!==ge)switch(ge){case ko.PollResults:return o.ZP.createElement("h3",null,me("PollResults"));case ko.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Wt.Z,{parentContainerClassName:"RightSearch",value:R,onChange:se}),o.ZP.createElement(zt.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>H({selectedAt:(0,re._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon icon-calendar"})));case ko.AddingMembers:return o.ZP.createElement("h3",null,me(S?"ChannelAddSubscribers":"GroupAddMembers"));case ko.ManageInitial:return o.ZP.createElement("h3",null,me("Edit"));case ko.ManageChatPrivacyType:return o.ZP.createElement("h3",null,me(S?"ChannelTypeHeader":"GroupTypeHeader"));case ko.ManageDiscussion:return o.ZP.createElement("h3",null,me("Discussion"));case ko.ManageChatAdministrators:return o.ZP.createElement("h3",null,me("ChannelAdministrators"));case ko.ManageGroupRecentActions:return o.ZP.createElement("h3",null,me("Group.Info.AdminLog"));case ko.ManageGroupAdminRights:return o.ZP.createElement("h3",null,me("EditAdminRights"));case ko.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,me("SetAsAdmin"));case ko.ManageGroupPermissions:return o.ZP.createElement("h3",null,me("ChannelPermissions"));case ko.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,me("BlockedUsers"));case ko.ManageChannelRemovedUsers:return o.ZP.createElement("h3",null,me("ChannelBlockedUsers"));case ko.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,me("ChannelAddException"));case ko.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,me("UserRestrictions"));case ko.ManageInvites:return o.ZP.createElement("h3",null,me("lng_group_invite_title"));case ko.ManageEditInvite:return o.ZP.createElement("h3",null,me(A?"EditLink":"NewLink"));case ko.ManageInviteInfo:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,me("InviteLink")),o.ZP.createElement("section",{className:"tools"},x&&!x.isRevoked&&o.ZP.createElement(zt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:me("Edit"),onClick:ee},o.ZP.createElement("i",{className:"icon icon-edit"})),x&&x.isRevoked&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(zt.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:me("Delete"),onClick:Y},o.ZP.createElement("i",{className:"icon icon-delete"})),o.ZP.createElement(on.Z,{isOpen:W,onClose:X,title:me("DeleteLink"),text:me("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:me("Delete"),confirmHandler:te}))));case ko.ManageJoinRequests:return o.ZP.createElement("h3",null,me(S?"SubscribeRequests":"MemberRequests"));case ko.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,me("Channel.Management.AddModerator"));case ko.StickerSearch:return o.ZP.createElement(Wt.Z,{value:k,placeholder:me("SearchStickersHint"),autoFocusSearch:!0,onChange:ne});case ko.GifSearch:return o.ZP.createElement(Wt.Z,{value:T,placeholder:me("SearchGifsTitle"),autoFocusSearch:!0,onChange:ae});case ko.Statistics:return o.ZP.createElement("h3",null,me(S?"ChannelStats.Title":"GroupStats.Title"));case ko.MessageStatistics:return o.ZP.createElement("h3",null,me("Stats.MessageTitle"));case ko.SharedMedia:return o.ZP.createElement("h3",null,me("SharedMedia"));case ko.ManageChannelSubscribers:return o.ZP.createElement("h3",null,me("ChannelSubscribers"));case ko.MemberList:case ko.ManageGroupMembers:return o.ZP.createElement("h3",null,me("GroupMembers"));case ko.StoryList:return o.ZP.createElement("h3",null,me(Z?"Settings.MyStories":"PeerInfo.PaneStories"));case ko.ManageReactions:return o.ZP.createElement("h3",null,me("Reactions"));case ko.CreateTopic:return o.ZP.createElement("h3",null,me("NewTopic"));case ko.EditTopic:return o.ZP.createElement("h3",null,me("EditTopic"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,me(O?"AccDescrTopic":S?"Channel.TitleInfo":P?L?"lng_info_bot_title":"lng_info_user_title":"GroupInfo.Title")),o.ZP.createElement("section",{className:"tools"},b&&o.ZP.createElement(zt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:me("AddContact"),onClick:ie},o.ZP.createElement("i",{className:"icon icon-add-user","aria-hidden":!0})),C&&!O&&o.ZP.createElement(zt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:me("Edit"),onClick:ce},o.ZP.createElement("i",{className:"icon icon-edit"})),j&&o.ZP.createElement(zt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:me("EditTopic"),onClick:oe},o.ZP.createElement("i",{className:"icon icon-edit"})),N&&o.ZP.createElement(zt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:me("Statistics"),onClick:de},o.ZP.createElement("i",{className:"icon icon-stats"}))))}}()))}));var Ao=s(91);var No=s(27407);function xo(e,t){const[s,n]=(0,No.Z)(e,t,void 0,i.Vk);return[s,n,!(!s||!t||s[0]===t[0])]}function Bo(e,t,s,n,a,r){const c=(0,o.sO)();(0,vt.Z)((()=>{c.current=void 0}),[r]),(0,vt.Z)((()=>{t===e&&n&&a&&(c.current=(0,v.R5)(n,a,e))}),[n,a,t,e]);const[d,l]=(0,No.Z)(s,c.current,void 0,"media"===e?i.ENB:i.pnA);return[d,l,!(!d||!c.current||d[0]===c.current[0])]}const Uo=(0,I.P2)((e=>e()),250,!1);let Lo=!1;var Oo=s(47783),jo=s(21273),_o=s(31876),Fo=s(16568),Do=s(70180),qo=s(13709),Go=s(12644);const Ho=(0,o.X$)((function(e){let{story:t,isProtected:s,isArchive:a}=e;const{openStoryViewer:i,loadUserSkippedStories:r,toggleStoryPinned:c,showNotification:d}=(0,n.Sv)(),l=(0,_t.Z)(),u=(0,o.sO)(null),m=(0,pt.Z)((()=>u.current)),h=(0,pt.Z)((()=>document.body)),g=(0,pt.Z)((()=>document.querySelector("#portals .story-context-menu .bubble"))),p=(0,pt.Z)((()=>({withPortal:!0,isDense:!0}))),f=t&&"content"in t,I=t&&"isDeleted"in t,w=f?t.content.video:void 0,y=f?(0,v.Cc)(t):void 0,b=(0,os.Z)(y)||w?.thumbnail?.dataUri;(0,o.d4)((()=>{!t||f||I||r({userId:t.userId})}),[I,f,t]);const{isContextMenuOpen:P,contextMenuPosition:Z,handleBeforeContextMenu:C,handleContextMenu:S,handleContextMenuClose:M,handleContextMenuHide:E}=(0,Sn.Z)(u),{positionX:R,positionY:k,transformOriginX:T,transformOriginY:A,style:N}=(0,Go.Z)(Z,m,h,g,p),x=(0,o.I4)((()=>{i({userId:t.userId,storyId:t.id,isSingleUser:!0,isPrivate:!0,isArchive:a})}),[a,t.id,t.userId]),B=(0,pt.Z)((e=>{(0,Ln.b)(e),C(e)})),U=(0,pt.Z)((e=>{(0,sa.Z)(e),c({storyId:t.id,isPinned:!0}),d({message:l("Story.ToastSavedToProfileText")}),M()})),L=(0,pt.Z)((e=>{(0,sa.Z)(e),c({storyId:t.id,isPinned:!1}),d({message:l("Story.ToastRemovedFromProfileText")}),M()}));return o.ZP.createElement("div",{ref:u,className:(0,ut.Z)("ox1yTGx4NBVANs7q4Ste","scroll-item"),onMouseDown:B,onClick:x,onContextMenu:S},I&&o.ZP.createElement("span",null,o.ZP.createElement("i",{className:(0,ut.Z)("eg5740UDe7iAc7dGlyex","icon icon-story-expired"),"aria-hidden":!0}),l("ExpiredStory")),o.ZP.createElement("div",{className:"g34egFNlUSZiOR5Y9K9A"},b&&o.ZP.createElement("img",{src:b,alt:"",className:"gyVqf8gGVz_cu2HCjifT"}),s&&o.ZP.createElement("span",{className:"protector"})),void 0!==Z&&o.ZP.createElement(Ms.Z,{isOpen:P,transformOriginX:T,transformOriginY:A,positionX:R,positionY:k,style:N,className:(0,ut.Z)("rhvyma7da0HVZh3rYFnr","story-context-menu"),autoClose:!0,onClose:M,onCloseAnimationEnd:E,withPortal:!0},a&&o.ZP.createElement(Jt.Z,{icon:"pin",onClick:U},l("StoryList.SaveToProfile")),!a&&o.ZP.createElement(Jt.Z,{icon:"unpin",onClick:L},l("Story.Context.RemoveFromProfile"))))}));var $o=s(45418),Vo=s(47262),Ko=s(41151),Jo=s(22275);const zo=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"}],Wo=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s,topicId:n,isMobile:a}=t;const i=(0,f.Z1J)(e,s),o=(0,f.x67)(e,s),r=(0,f.Zwk)(e,s),{currentType:c,resultsByType:d}=(0,f.weG)(e)||{},{foundIds:l}=d&&c&&d[c]||{},{byId:u,statusesById:m}=e.users,{byId:h}=e.chats,g=i&&(0,v.Bf)(i),p=i&&(0,v.eA)(i),I=!n&&(g||p&&(0,v.Nl)(i)),w=o?.members,y=o?.adminMembersById,b=I&&i&&(i.isForbidden||o&&!o.canViewMembers),P=I&&i&&((0,v.VE)(i,"inviteUsers")||!(0,v.Mg)(i,"inviteUsers")||i.isCreator),Z=I&&i&&((0,v.VE)(i,"banUsers")||i.isCreator),C=(0,f.f21)(e,s);let S,M,E,R,k,T,A;if((0,v.YC)(s)){E=s,R=(0,f.dyD)(e,E),S=R&&!R.isSelf&&!(0,v.cS)(R),M=R?.isSelf||R?.hasStories&&!R.areStoriesHidden;const t=M?(0,f.GZu)(e,R.id):void 0;k=t?.pinnedIds,A=t?.byId,T=t?.archiveIds}return{theme:(0,f.Puy)(e),isChannel:p,resolvedUserId:E,messagesById:r,foundIds:l,mediaSearchType:c,hasCommonChatsTab:S,hasStoriesTab:M,hasMembersTab:I,areMembersHidden:b,canAddMembers:P,canDeleteMembers:Z,currentUserId:e.currentUserId,isRightColumnShown:(0,f.Jf5)(e,a),isRestricted:i?.isRestricted,activeDownloadIds:C?.ids,usersById:u,userStatusesById:m,chatsById:h,storyIds:k,archiveStoryIds:T,storyByIds:A,isChatProtected:i?.isProtected,nextProfileTab:(0,f.jUK)(e).nextProfileTab,...I&&w&&{members:w,adminMembersById:y},...S&&R&&{commonChatIds:R.commonChats?.ids}}}))((e=>{let{chatId:t,topicId:s,profileState:r,onProfileStateChange:d,theme:l,isChannel:h,resolvedUserId:g,currentUserId:p,messagesById:f,foundIds:I,storyIds:w,archiveStoryIds:y,storyByIds:b,mediaSearchType:P,hasCommonChatsTab:Z,hasStoriesTab:C,hasMembersTab:S,areMembersHidden:M,canAddMembers:E,canDeleteMembers:R,commonChatIds:k,members:T,adminMembersById:A,usersById:N,userStatusesById:x,chatsById:B,isRightColumnShown:U,isRestricted:L,activeDownloadIds:O,isChatProtected:j,nextProfileTab:_}=e;const{setLocalMediaSearchType:F,loadMoreMembers:D,loadCommonChats:q,openChat:G,searchMediaMessagesLocal:H,openMediaViewer:$,openAudioPlayer:V,focusMessage:K,loadProfilePhotos:J,setNewChatMembersDialogState:z,loadUserPinnedStories:W,loadStoriesArchive:Y}=(0,n.Sv)(),X=(0,o.sO)(null),Q=(0,o.sO)(null),ee=(0,_t.Z)(),[te,se]=(0,o.eJ)(),ne=(0,o.Ye)((()=>[...C?[{type:"stories",title:"ProfileStories"}]:[],...C&&p===t?[{type:"storiesArchive",title:"ProfileStoriesArchive"}]:[],...S?[{type:"members",title:h?"ChannelSubscribers":"GroupMembers"}]:[],...zo,...s?[]:[{type:"voice",title:"SharedVoiceTab2"}],...Z?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[t,p,Z,S,C,h,s]),ae=(0,o.Ye)((()=>{if(!_)return 0;const e=ne.findIndex((e=>{let{type:t}=e;return t===_}));return-1===e?0:e}),[_,ne]),[ie,oe]=(0,o.eJ)(ae);(0,o.d4)((()=>{if(!_)return;const e=ne.findIndex((e=>{let{type:t}=e;return t===_}));-1!==e&&oe(e)}),[_,ne]);const re=ie>ne.length-1?ne.length-1:ie,ce=ne[re].type,de=(0,o.I4)((e=>{let{offsetId:s}=e;W({userId:t,offsetId:s})}),[t]),le=(0,o.I4)((e=>{let{offsetId:t}=e;Y({offsetId:t})}),[]),[ue,me,he,ge]=function(e,t,s,n,a,i,r,c,d,l,u,m,h,g,p,f,I){const w="members"!==i&&r?r:i,y=(0,o.Ye)((()=>{if(c&&l&&u)return(0,v.Z0)(c.map((e=>{let{userId:t}=e;return t})),l,u)}),[c,l,u]),b=(0,o.Ye)((()=>{if(d&&m)return(0,v.ih)(d,m,!0)}),[m,d]),[P,Z,C]=xo(e,y),[S,M,E]=Bo("media",w,s,h,g,p),[R,k,T]=Bo("documents",w,s,h,g,p),[A,N,x]=Bo("links",w,s,h,g,p),[B,U,L]=Bo("audio",w,s,h,g,p),[O,j,_]=Bo("voice",w,s,h,g,p),[F,D,q]=xo(t,b),[G,H,$]=xo(n,f),[V,K,J]=xo(a,I);let z,W,Y=!1;switch(w){case"members":z=P,W=Z,Y=C;break;case"commonChats":z=F,W=D,Y=q;break;case"media":z=S,W=M,Y=E;break;case"documents":z=R,W=k,Y=T;break;case"links":z=A,W=N,Y=x;break;case"audio":z=B,W=U,Y=L;break;case"voice":z=O,W=j,Y=_;break;case"stories":z=G,W=H,Y=$;break;case"storiesArchive":z=V,W=K,Y=J}return[w,z,W,Y]}(D,q,H,de,le,ce,P,T,k,N,x,B,f,I,s,w,y),pe=C&&"stories"===ue||"members"===ue||!S&&"media"===ue,fe=ne.findIndex((e=>{let{type:t}=e;return t===ue}));(0,Oo.Z)("members"===ue?me:void 0);const{handleScroll:Ie}=function(e,t,s,n){(0,ns.Z)((s=>{let[a]=s;if(a&&a!==t){const s=e.current,a=s.querySelector(".TabList");s.scrollTop<a.offsetTop&&(n("members"===t?m.vi.MemberList:"stories"===t?m.vi.StoryList:m.vi.SharedMedia),Lo=!0,(0,jn.ZP)(s,a,"start",void 0,void 0,void 0,300),setTimeout((()=>{Lo=!1}),350))}}),[t,n,e]),(0,ns.Z)((t=>{let[a]=t;if(s!==m.vi.Profile||s===a)return;const i=e.current;if(!i)return;const o=i.querySelector(".TabList");!o||o.offsetTop>i.scrollTop||(Lo=!0,(0,jn.ZP)(i,i.firstElementChild,"start",void 0,2*i.offsetHeight),setTimeout((()=>{Lo=!1}),350),n(s))}),[s,e,n]);const a=(0,pt.Z)((()=>{const s=e.current;if(!s)return;const a=s.querySelector(".TabList");if(!a)return;let i=m.vi.Profile;s.scrollTop>=a.offsetTop&&(i="members"===t?m.vi.MemberList:"stories"===t?m.vi.StoryList:m.vi.SharedMedia),n(i)}));return(0,o.d4)((()=>{Lo||a()}),[a,t]),{handleScroll:(0,pt.Z)((()=>{Lo||Uo(a)}))}}(X,ue,r,d),{applyTransitionFix:ve,releaseTransitionFix:we}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,o.d4)((()=>{function s(){const s=e.current,n=s.querySelector(t),a=s.querySelector(".TabList");if(n&&a){const e=s.offsetHeight-a.offsetHeight;(0,c.WM)((()=>{n.style.minHeight=`${e}px`}))}}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]);const s=(0,pt.Z)((()=>{(0,c.i$)((()=>{const t=e.current;if("hidden"===t.style.overflowY)return;const s=t.offsetWidth-t.clientWidth;(0,c.WM)((()=>{t.style.overflowY="hidden",t.style.paddingRight=`${s}px`}))}))})),n=(0,pt.Z)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.paddingRight="0"}));return{applyTransitionFix:s,releaseTransitionFix:n}}(X),[ye,be]=(()=>{const[e,t]=(0,o.eJ)(0);return[e,(0,o.I4)((()=>{t((e=>e+1))}),[])]})(),{observe:Pe}=(0,Hn.S1)({rootRef:X,throttleMs:500}),Ze=(0,pt.Z)((()=>{we(),be()})),Ce=(0,pt.Z)((()=>{z({newChatMembersProgress:m.WB.InProgress})}));(0,o.d4)((()=>{F({mediaType:ce})}),[F,ce,s]);const Se=g||t;(0,o.d4)((()=>{J({profileId:Se})}),[Se]);const Me=(0,pt.Z)((e=>{$({chatId:Se,threadId:u._f,mediaId:e,origin:m.bZ.SharedMedia})})),Ee=(0,pt.Z)((e=>{V({chatId:Se,messageId:e})})),Re=(0,pt.Z)((e=>{G({id:e})})),ke=(0,pt.Z)((e=>{K({chatId:Se,messageId:e})})),Te=(0,pt.Z)((()=>{se(void 0)}));let Ae;(0,ns.Z)((e=>{let[t]=e;if(void 0===t||0===ie||t===S)return;const s=ie+(S?1:-1);oe(Math.min(s,ne.length-1))}),[S,ie,ne]),(0,o.d4)((()=>{if(Q.current&&a.$b)return(0,fs.sf)(Q.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===fs.eM.Left?(oe(Math.min(re+1,ne.length-1)),!0):t===fs.eM.Right&&(oe(Math.max(0,re-1)),!0)})}),[re,ne.length]),pe?Ae=U?0:1e3:me||(Ae=i.Yan);const Ne=(0,nn.Z)([t,s,ue,re],Ae);return o.ZP.createElement(jo.Z,{ref:X,className:"Profile custom-scroll",itemSelector:`.shared-media-transition > .Transition_slide-active.${ue}-list > .scroll-item`,items:Ne?me:void 0,cacheBuster:ye,sensitiveArea:i.qUX,preloadBackwards:Ne?"members"===ue?i.Vk:i.ENB:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:he,onScroll:Ie},!ge&&function(e,t,s){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Fo.Z,{userId:t||e,canPlayVideo:s}),o.ZP.createElement(Do.Z,{chatOrUserId:t||e}))}(t,g,U&&Ne),!L&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(jt.Z,{ref:Q,name:ee.isRtl?"slideOptimizedRtl":"slideOptimized",activeKey:fe,renderCount:ne.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:ve,onStop:Ze},function(){if(!me||!Ne||!f){const e=pe&&!Ne,t=Boolean("members"===ue&&M);return o.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&o.ZP.createElement(es.Z,null),t&&o.ZP.createElement(Vo.Z,{text:"You have no access to group members list."}))}if(!me.length){let e;switch(ue){case"members":e=M?"You have no access to group members list.":"No members found";break;case"commonChats":e=ee("NoGroupsInCommon");break;case"documents":e=ee("lng_media_file_empty");break;case"links":e=ee("lng_media_link_empty");break;case"audio":e=ee("lng_media_song_empty");break;case"voice":e=ee("lng_media_audio_empty");break;case"stories":e=ee("StoryList.SavedEmptyState.Title");break;case"storiesArchive":e=ee("StoryList.ArchivedEmptyState.Title");break;default:e=ee("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(Vo.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${ue}-list`,dir:ee.isRtl&&"media"===ue?"rtl":void 0,teactFastList:!0},"media"===ue?me.map((e=>f[e]&&o.ZP.createElement(qo.Z,{key:e,message:f[e],isProtected:j||f[e].isProtected,observeIntersection:Pe,onClick:Me}))):"stories"===ue||"storiesArchive"===ue?me.map((e=>b?.[e]&&o.ZP.createElement(Ho,{key:`${ue}_${e}`,story:b[e],isProtected:j,isArchive:"storiesArchive"===ue}))):"documents"===ue?me.map((e=>f[e]&&o.ZP.createElement(Ca.Z,{key:e,message:f[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:O?.includes(e),observeIntersection:Pe,onDateClick:ke}))):"links"===ue?me.map((e=>f[e]&&o.ZP.createElement($o.Z,{key:e,message:f[e],isProtected:j||f[e].isProtected,observeIntersection:Pe,onMessageClick:ke}))):"audio"===ue?me.map((e=>f[e]&&o.ZP.createElement(Sa.ZP,{key:e,theme:l,message:f[e],origin:m.Cr.SharedMedia,date:f[e].date,className:"scroll-item",onPlay:Ee,onDateClick:ke,canDownload:!j&&!f[e].isProtected,isDownloading:O?.includes(e)}))):"voice"===ue?me.map((e=>f[e]&&o.ZP.createElement(Sa.ZP,{key:e,theme:l,message:f[e],senderTitle:(0,Ao.F)(ee,f[e],B,N),origin:m.Cr.SharedMedia,date:f[e].date,className:"scroll-item",onPlay:Ee,onDateClick:ke,canDownload:!j&&!f[e].isProtected,isDownloading:O?.includes(e)}))):"members"===ue?me.map(((e,t)=>{return o.ZP.createElement(_o.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable contact-list-item scroll-item small-icon",onClick:()=>Re(e),contextActions:(s=e,s!==p&&R?[{title:ee("lng_context_remove_from_group"),icon:"stop",handler:()=>{se(s)}}]:void 0)},o.ZP.createElement(Xs.Z,{userId:e,adminMember:A?.[e],forceShowSelf:!0,withStory:!0}));var s})):"commonChats"===ue?me.map(((e,t)=>o.ZP.createElement(_o.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>G({id:e})},o.ZP.createElement(Qs.Z,{chatId:e})))):void 0)}()),o.ZP.createElement(vs.Z,{big:!0,activeTab:re,tabs:ne,onSwitchTab:oe})),E&&o.ZP.createElement(Ko.Z,{isShown:"members"===ue,onClick:Ce,ariaLabel:ee("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon icon-add-user-filled"})),R&&o.ZP.createElement(Jo.Z,{isOpen:Boolean(te),userId:te,onClose:Te}))}))),Yo=e=>{const t=(0,kt.Z)(gt.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},Xo=e=>{const t=(0,kt.Z)(gt.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},Qo=e=>{const t=(0,kt.Z)(gt.gl.Extra,"Statistics");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},er=e=>{const t=(0,kt.Z)(gt.gl.Extra,"MessageStatistics");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},tr=()=>{const e=(0,kt.Z)(gt.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Zs.Z,null)},sr=()=>{const e=(0,kt.Z)(gt.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Zs.Z,null)},nr=()=>{const e=(0,kt.Z)(gt.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(Zs.Z,null)};var ar=s(11820);const ir=(0,o.X$)((0,n.c$)(((e,t)=>{let{chatId:s}=t;const n=(0,f.Z1J)(e,s),{userIds:a}=e.contactList||{},{byId:i}=e.chats,{newChatMembersProgress:o}=(0,f.jUK)(e),{currentUserId:r}=e,c=n&&(0,v.eA)(n),{query:d,fetchingStatus:l,globalUserIds:u,localUserIds:h}=(0,f.jUK)(e).userSearch;return{isChannel:c,members:(0,f.x67)(e,s)?.members,currentUserId:r,chatsById:i,localContactIds:a,searchQuery:d,isSearching:l,isLoading:o===m.WB.Loading,globalUserIds:u,localUserIds:h}}))((e=>{let{isChannel:t,members:s,onNextStep:a,currentUserId:i,chatsById:r,localContactIds:c,isLoading:d,searchQuery:l,isSearching:u,localUserIds:m,globalUserIds:h,onClose:p,isActive:f}=e;const{setUserSearchQuery:I}=(0,n.Sv)(),w=(0,_t.Z)(),[y,b]=(0,o.eJ)([]),P=(0,Hs.Z)(y)===y;(0,Is.Z)({isActive:f,onBack:p});const Z=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),C=(0,o.I4)((e=>{I({query:e})}),[I]),S=(0,o.Ye)((()=>{const e=(0,n.Rd)().users.byId,s=c?(0,v.kK)(c,e,l):[];return(0,v.ih)((0,g.Tw)([...s,...m||[],...h||[]]).filter((s=>{const n=e[s];return!Z.includes(s)&&s!==i&&(!n||!(0,v.cS)(n)||!t&&n.canBeInvitedToGroup)})),r)}),[c,r,l,m,h,i,Z,t]),M=(0,o.I4)((()=>{y.length&&(I({query:""}),a(y))}),[y,I,a]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(ar.Z,{itemIds:S,selectedIds:y,filterValue:l,filterPlaceholder:w("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:u,onSelectedIdsChange:b,onFilterChange:C,isSearchable:!0,noScrollRestore:P}),o.ZP.createElement(Ko.Z,{isShown:Boolean(y.length),disabled:d,ariaLabel:w("lng_channel_add_users"),onClick:M},d?o.ZP.createElement(es.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon icon-arrow-right"}))))}))),or=e=>{const t=(0,kt.Z)(gt.gl.Extra,"CreateTopic");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},rr=e=>{const t=(0,kt.Z)(gt.gl.Extra,"EditTopic");return t?o.ZP.createElement(t,e):o.ZP.createElement(Zs.Z,null)},cr=450+i.fK3,dr=Object.keys(m.qt).length/2,lr=Object.keys(m.u1).length/2;function ur(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const mr=(0,o.X$)((0,n.c$)(((e,t)=>{let{isMobile:s}=t;const{chatId:n,threadId:a}=(0,f.Btg)(e)||{},i=(0,f.g4C)(e),{management:o,shouldSkipHistoryAnimations:r,nextProfileTab:c}=(0,f.jUK)(e),d=n?o.byChatId[n]?.nextScreen:void 0,l=(n?(0,f.Z1J)(e,n)?.isForum:void 0)&&Boolean(a&&a!==u._f);return{contentKey:(0,f.WqZ)(e,s),chatId:n,threadId:a,isInsideTopic:l,isChatSelected:Boolean(n&&i),shouldSkipHistoryAnimations:r,nextManagementScreen:d,nextProfileTab:c}}))((e=>{var t;let{contentKey:s,chatId:a,threadId:r,isMobile:c,isInsideTopic:d,isChatSelected:l,shouldSkipHistoryAnimations:u,nextManagementScreen:h,nextProfileTab:g}=e;const{toggleChatInfo:p,toggleManagement:f,closeLocalTextSearch:I,setStickerSearchQuery:v,setGifSearchQuery:w,closePollResults:y,addChatMembers:b,setNewChatMembersDialogState:P,setEditingExportedInvite:Z,toggleStatistics:C,toggleMessageStatistics:S,setOpenedInviteInfo:M,requestNextManagementScreen:E,resetNextProfileTab:R,closeCreateTopicPanel:k,closeEditTopicPanel:T}=(0,n.Sv)(),{width:A}=(0,qs.Z)(),[N,x]=(0,o.eJ)(m.vi.Profile),[B,U]=(0,o.eJ)(m.u1.Initial),[L,O]=(0,o.eJ)(),[j,_]=(0,o.eJ)(),F=N!==m.vi.Profile,D=void 0!==s,q=s===m.qt.ChatInfo,G=s===m.qt.Search,H=s===m.qt.Management,$=s===m.qt.Statistics,V=s===m.qt.MessageStatistics,K=s===m.qt.StickerSearch,J=s===m.qt.GifSearch,z=s===m.qt.PollResults,W=s===m.qt.AddingMembers,Y=s===m.qt.CreateTopic,X=s===m.qt.EditTopic,Q=A<=i._mX,[ee,te]=(0,o.eJ)(!D),se=null!==(t=(0,Ws.Z)(s,!0,!l))&&void 0!==t?t:-1,ne=(0,pt.Z)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];switch(s){case m.qt.AddingMembers:P({newChatMembersProgress:m.WB.Closed});break;case m.qt.ChatInfo:if(F&&e){x(m.vi.Profile);break}p({force:!1},{forceSyncOnIOs:!0});break;case m.qt.Management:switch(B){case m.u1.Initial:f();break;case m.u1.ChatPrivacyType:case m.u1.Discussion:case m.u1.GroupPermissions:case m.u1.GroupType:case m.u1.ChatAdministrators:case m.u1.ChannelSubscribers:case m.u1.GroupMembers:case m.u1.Invites:case m.u1.Reactions:case m.u1.JoinRequests:case m.u1.ChannelRemovedUsers:U(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:U(m.u1.GroupPermissions),O(void 0),_(void 0);break;case m.u1.ChatAdminRights:case m.u1.ChatNewAdminRights:case m.u1.GroupAddAdmins:case m.u1.GroupRecentActions:U(m.u1.ChatAdministrators);break;case m.u1.EditInvite:case m.u1.InviteInfo:U(m.u1.Invites),M({chatId:a,invite:void 0}),Z({chatId:a,invite:void 0})}break;case m.qt.MessageStatistics:S();break;case m.qt.Statistics:C();break;case m.qt.Search:ur(),I();break;case m.qt.StickerSearch:ur(),v({query:void 0});break;case m.qt.GifSearch:ur(),w({query:void 0});break;case m.qt.PollResults:y();break;case m.qt.CreateTopic:k();break;case m.qt.EditTopic:T()}})),ae=(0,pt.Z)(((e,t)=>{O(e),_(t)})),ie=(0,pt.Z)((e=>{b({chatId:a,memberIds:e})}));function oe(e){if(-1!==se)switch(se){case m.qt.AddingMembers:return o.ZP.createElement(ir,{key:`add_chat_members_${a}`,chatId:a,isActive:D&&e,onNextStep:ie,onClose:ne});case m.qt.ChatInfo:return o.ZP.createElement(Wo,{key:`profile_${a}`,chatId:a,topicId:d?r:void 0,profileState:N,isMobile:c,onProfileStateChange:x});case m.qt.Search:return o.ZP.createElement(Yo,{key:`right_search_${a}`,chatId:a,threadId:r,onClose:ne,isActive:D&&e});case m.qt.Management:return o.ZP.createElement(Xo,{key:`management_${a}_${B}`,chatId:a,currentScreen:B,isPromotedByCurrentUser:j,selectedChatMemberId:L,isActive:D&&e,onScreenSelect:U,onChatMemberSelect:ae,onClose:ne});case m.qt.Statistics:return o.ZP.createElement(Qo,{chatId:a});case m.qt.MessageStatistics:return o.ZP.createElement(er,{chatId:a,isActive:D&&e});case m.qt.StickerSearch:return o.ZP.createElement(tr,{onClose:ne,isActive:D&&e});case m.qt.GifSearch:return o.ZP.createElement(sr,{onClose:ne,isActive:D&&e});case m.qt.PollResults:return o.ZP.createElement(nr,{onClose:ne,isActive:D&&e});case m.qt.CreateTopic:return o.ZP.createElement(or,{onClose:ne,isActive:D&&e});case m.qt.EditTopic:return o.ZP.createElement(rr,{onClose:ne,isActive:D&&e})}}return(0,o.d4)((()=>D?(0,Ut.Z)(ne):void 0),[D,ne]),(0,o.d4)((()=>{setTimeout((()=>{te(!D)}),cr)}),[D]),(0,o.d4)((()=>{h&&(U(h),E(void 0))}),[h]),(0,o.d4)((()=>{g&&R()}),[g]),(0,o.d4)((()=>{D&&Q&&ne()}),[Q]),(0,qn.Z)((e=>{let[t]=e;t!==a&&(x(m.vi.Profile),U(m.u1.Initial))}),[a]),(0,Is.Z)({isActive:l&&(s===m.qt.ChatInfo||s===m.qt.Management||s===m.qt.AddingMembers||s===m.qt.CreateTopic||s===m.qt.EditTopic),onBack:()=>ne(!1)}),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:l?void 0:"is-hidden"},Q&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:ne}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(To,{chatId:a,threadId:r,isColumnOpen:D,isProfile:q,isSearch:G,isManagement:H,isStatistics:$,isMessageStatistics:V,isStickerSearch:K,isGifSearch:J,isPollResults:z,isCreatingTopic:Y,isEditingTopic:X,isAddingChatMembers:W,profileState:N,managementScreen:B,onClose:ne,onScreenSelect:U}),o.ZP.createElement(jt.Z,{name:ee||u?"none":"zoomFade",renderCount:dr+lr,activeKey:H?dr+B:se,shouldCleanup:!0,cleanupExceptionKey:se===m.qt.MessageStatistics?m.qt.Statistics:void 0},oe)))}))),hr=e=>{let{isOpen:t}=e;const s=(0,kt.Z)(gt.gl.Extra,"MediaViewer",!t);return s?o.ZP.createElement(s,null):void 0};var gr=s(6562);const pr=new Set,fr=new Set,Ir=(0,o.X$)((0,n.c$)((e=>({activeDownloads:(0,f.jUK)(e).activeDownloads.byChatId})))((e=>{let{activeDownloads:t}=e;const{cancelMessagesMediaDownload:s,showNotification:i}=(0,n.Sv)(),r=(0,Fn.Z)(1e3,!0),c=(0,pt.Z)((e=>{fr.add(e),r((()=>{fr.size&&(s({messages:Array.from(fr)}),fr.clear())}))}));(0,o.d4)((()=>{const e=(0,n.Rd)().messages.byChatId,s=(0,n.Rd)().scheduledMessages.byChatId,o=Object.entries(t).map((t=>{let[n,a]=t;const i=a.ids?.map((t=>e[n]?.byId[t])),o=a.scheduledIds?.map((e=>s[n]?.byId[e]));return(0,g.oA)([...i||[],...o||[]])})).flat();o.length?o.forEach((e=>{if(pr.has(e))return;pr.add(e);const t=(0,v.Ti)(e,"download");if(!t)return void c(e);const s=xe.UV(t);if(s)return(0,gr.Z)(s,(0,v.w6)(e)),void c(e);const{document:n,video:o,audio:r}=e.content;if(((n||o||r)?.size||0)>a.l0&&!a.rT&&!a.Mc)return i({message:"Downloading files bigger than 2GB is not supported in your browser."}),void c(e);const d=(0,v.kG)(e,"download");xe.he(t,d,!0).then((t=>{if(d===u.IU.DownloadUrl){const s=new URL(t,window.document.baseURI),n=(0,v.w6)(e);s.searchParams.set("filename",encodeURIComponent(n)),window.open(s.toString())?.addEventListener("beforeunload",(()=>{i({message:"Download started. Please, do not close the app before it is finished."})}))}else t&&(0,gr.Z)(t,(0,v.w6)(e));c(e)}))})):pr.clear()}),[t,s,c,i])})));var vr=s(56389),wr=s(34563);const yr=(0,o.X$)((0,n.c$)(((e,t)=>{let{openedGame:s}=t;const{chatId:n}=s||{},a=n&&(0,f.Z1J)(e,n);return{canPost:Boolean(a)&&(0,v.Qm)(a,u._f)}}))((e=>{let{openedGame:t,gameTitle:s,canPost:n}=e;const{closeGame:a,openForwardMenu:i}=(0,ue.Sv)(),r=(0,_t.Z)(),{url:c,chatId:d,messageId:l}=t||{},u=Boolean(c),m=(0,vr.Z)(d);(0,Mt.Z)((()=>{m({type:"playingGame"})}),u&&n?5e3:void 0);const h=(0,o.I4)((e=>{try{const t=JSON.parse(e.data);"share_score"===t.eventType&&(i({fromChatId:d,messageIds:[l],withMyScore:!0}),a()),"share_game"===t.eventType&&(i({fromChatId:d,messageIds:[l]}),a())}catch(e){}}),[d,a,l,i]),g=(0,o.I4)((e=>{e.currentTarget.focus()}),[]);return(0,o.d4)((()=>(window.addEventListener("message",h),()=>window.removeEventListener("message",h))),[h]),o.ZP.createElement(wr.Z,{className:"GameModal",isOpen:u,onClose:a,title:s,hasCloseButton:!0},u&&o.ZP.createElement("iframe",{className:"game-frame",onLoad:g,src:c,title:r("AttachGame"),sandbox:"allow-scripts allow-same-origin allow-orientation-lock",allow:"fullscreen"}))}))),br=e=>{let{isOpen:t}=e;const s=(0,kt.Z)(gt.gl.Extra,"Notifications",!t);return s?o.ZP.createElement(s,null):void 0},Pr=e=>{let{isOpen:t}=e;const s=(0,kt.Z)(gt.gl.Extra,"Dialogs",!t);return s?o.ZP.createElement(s,null):void 0},Zr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"ForwardRecipientPicker",!t);return s?o.ZP.createElement(s,e):void 0},Cr=e=>{const{url:t}=e,s=(0,kt.Z)(gt.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0},Sr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0},Mr=e=>{const{groupCallId:t}=e,s=(0,kt.Z)(gt.gl.Calls,"GroupCall",!t);return s?o.ZP.createElement(s,e):void 0},Er=e=>{const{isActive:t}=e,s=(0,kt.Z)(gt.gl.Calls,"ActiveCallHeader",!t);return s?o.ZP.createElement(s,null):void 0},Rr=e=>{const{isActive:t}=e,s=(0,kt.Z)(gt.gl.Calls,"PhoneCall",!t);return s?o.ZP.createElement(s,null):void 0};function kr(){return kr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},kr.apply(this,arguments)}const Tr=(0,o.X$)((0,n.c$)((e=>({messageLists:(0,f.jUK)(e).messageLists})))((e=>{let{messageLists:t}=e;const{openChat:s}=(0,n.Sv)(),a=()=>{s({id:void 0},{forceSyncOnIOs:!0})},i=e=>{let{chatId:t,type:s,threadId:n}=e;(0,Is.Z)({isActive:!0,hash:(0,Oe.tB)(t,s,n),onBack:a})};return o.ZP.createElement("div",null,t?.map(((e,t)=>o.ZP.createElement(i,kr({key:`${e.chatId}_${e.threadId}_${e.type}_${t}`},e)))))}))),Ar=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"NewContactModal",!t);return s?o.ZP.createElement(s,e):void 0},Nr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Calls,"RatePhoneCallModal",!t);return s?o.ZP.createElement(s,e):void 0},xr=e=>{const{webApp:t}=e,s=(0,kt.Z)(gt.gl.Extra,"WebAppModal",!t);return s?o.ZP.createElement(s,e):void 0},Br=e=>{const{bot:t}=e,s=(0,kt.Z)(gt.gl.Extra,"BotTrustModal",!t);return s?o.ZP.createElement(s,e):void 0},Ur=e=>{const{bot:t}=e,s=(0,kt.Z)(gt.gl.Extra,"AttachBotInstallModal",!t);return s?o.ZP.createElement(s,e):void 0},Lr={root:"vfd0Bo1X6k19aaxQ577t"},Or=["#E8BC2C","#D0049E","#02CBFE","#5723FD","#FE8C27","#6CB859"],jr=(0,o.X$)((0,n.c$)((e=>(0,g.ei)((0,f.jUK)(e),["confetti"])))((e=>{let{confetti:t}=e;const s=(0,o.sO)(null),n=(0,o.sO)([]),a=(0,o.sO)(!1),i=(0,qs.Z)(),r=(0,Zt.Z)(),{isMobile:d}=(0,B.ZP)(),l=d?50:100,{lastConfettiTime:u,top:m,width:h,left:g,height:p}=t||{},f=(0,o.I4)((function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l;for(let a=0;a<s;a++){const s=a%2,i={x:e*(s?-.1:1.1),y:.75*t},o=Math.random()*e*1.5,r={x:s?o:-1*o,y:-t/2-Math.random()*t},c=Or[Math.floor(Math.random()*Or.length)],d=10;n.current.push({pos:i,size:d,color:c,velocity:r,flicker:d,flickerFrequency:.2*Math.random(),rotation:0,lastDrawnAt:Date.now(),frameCount:0})}}),[l]),I=(0,o.I4)((()=>{if(!s.current||!a.current)return;const e=s.current,t=e.getContext("2d");if(!t)return;const{width:i,height:o}=e;t.clearRect(0,0,i,o);const r=[];n.current.forEach(((e,s)=>{const{pos:a,velocity:i,size:c,color:d,flicker:l,flickerFrequency:u,rotation:m,lastDrawnAt:h,frameCount:g}=e,p=(Date.now()-h)/1e3,f={x:a.x+i.x*p,y:a.y+i.y*p},I={x:.98*i.x,y:i.y+=1e3*p},v=c*Math.abs(Math.sin(g*u)),w=5*g*u*(Math.PI/180),y=g+1,b=Date.now();if(f.y>o+e.size)return void r.push(e);const P={...e,pos:f,velocity:I,flicker:v,rotation:w,lastDrawnAt:b,frameCount:y};n.current[s]=P,t.fillStyle=d,t.beginPath(),t.ellipse(a.x,a.y,c,l,m,0,2*Math.PI),t.fill()})),n.current=n.current.filter((e=>!r.includes(e))),n.current.length?(0,c.i$)(I):a.current=!1}),[]);if((0,vt.Z)((e=>{let t,[s]=e;return s!==u&&(f(h||i.width,p||i.height),t=setTimeout(r,1e4),a.current||(a.current=!0,(0,c.i$)(I))),()=>{clearTimeout(t)}}),[u,r,I]),!u||Date.now()-u>1e4)return;const v=(0,_s.Z)(Boolean(m)&&`top: ${m}px`,Boolean(g)&&`left: ${g}px`,Boolean(h)&&`width: ${h}px`,Boolean(p)&&`height: ${p}px`);return o.ZP.createElement("div",{id:"Confetti",className:Lr.root,style:v},o.ZP.createElement("canvas",{ref:s,className:Lr.canvas,width:i.width,height:i.height}))}))),_r=e=>{const{urlAuth:t}=e,s=(0,kt.Z)(gt.gl.Extra,"UrlAuthModal",!t);return s?o.ZP.createElement(s,e):void 0},Fr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"PremiumMainModal",!t);return s?o.ZP.createElement(s,e):void 0},Dr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0},qr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0},Gr=e=>{const{limit:t}=e,s=(0,kt.Z)(gt.gl.Extra,"PremiumLimitReachedModal",!t);return s?o.ZP.createElement(s,e):void 0},Hr=e=>{const{folder:t}=e,s=(0,kt.Z)(gt.gl.Extra,"DeleteFolderDialog",!t);return s?o.ZP.createElement(s,e):void 0},$r=e=>{const{customEmojiSetIds:t}=e,s=(0,kt.Z)(gt.gl.Extra,"CustomEmojiSetsModal",!t);return s?o.ZP.createElement(s,e):void 0},Vr=e=>{const{requestedDraft:t}=e,s=(0,kt.Z)(gt.gl.Extra,"DraftRecipientPicker",!t);return s?o.ZP.createElement(s,e):void 0},Kr=e=>{const{requestedAttachBotInChat:t}=e,s=(0,kt.Z)(gt.gl.Extra,"AttachBotRecipientPicker",!t);return s?o.ZP.createElement(s,e):void 0},Jr=e=>{const{isOpen:t}=e,s=(0,kt.Z)(gt.gl.Extra,"ReactionPicker",!t);return s?o.ZP.createElement(s,e):void 0},zr=e=>{const{info:t}=e,s=(0,kt.Z)(gt.gl.Extra,"ChatlistModal",!t);return s?o.ZP.createElement(s,e):void 0},Wr=(0,o.X$)((e=>{let{isOpen:t}=e;const s=(0,kt.Z)(gt.gl.Extra,"StoryViewer",!t);return s?o.ZP.createElement(s,null):void 0}));let Yr=!1;const Xr=(0,o.X$)((0,n.c$)(((e,t)=>{let{isMobile:s}=t;const{settings:{byKey:{language:n,wasTimeFormatSetManually:a}}}=e,{botTrustRequest:i,requestedAttachBotInstall:o,requestedAttachBotInChat:r,requestedDraft:c,urlAuth:d,webApp:l,safeLinkModalUrl:u,openedStickerSetShortName:m,openedCustomEmojiSetIds:h,shouldSkipHistoryAnimations:g,openedGame:p,audioPlayer:I,isLeftColumnShown:w,historyCalendarSelectedAt:y,notifications:b,dialogs:P,newContact:Z,ratingPhoneCall:C,premiumModal:S,isMasterTab:M,payment:E,limitReachedModal:R,deleteFolderDialogModal:k,chatlistModal:T}=(0,f.jUK)(e),{chatId:A,messageId:N}=I,x=A&&N?(0,f.hjO)(e,A,N):void 0,B=(p&&(0,f.hjO)(e,p.chatId,p.messageId))?.content.game?.title,U=e.currentUserId?(0,f.dyD)(e,e.currentUserId):void 0,{chatId:L}=(0,f.Btg)(e)||{},O=!(0,f.$Yd)(e,"rightColumnAnimations")||!(0,f.FOo)(e),j=k?(0,f.MwT)(e,k):void 0;return{isLeftColumnOpen:w,isMiddleColumnOpen:Boolean(L),isRightColumnOpen:(0,f.Jf5)(e,s),isMediaViewerOpen:(0,f.zQd)(e),isStoryViewerOpen:(0,f.TuN)(e),isForwardModalOpen:(0,f.Evo)(e),isReactionPickerOpen:(0,f.Io8)(e),hasNotifications:Boolean(b.length),hasDialogs:Boolean(P.length),audioMessage:x,safeLinkModalUrl:u,isHistoryCalendarOpen:Boolean(y),shouldSkipHistoryAnimations:g,openedStickerSetShortName:m,openedCustomEmojiSetIds:h,isServiceChatReady:(0,f.UWV)(e),activeGroupCallId:M?e.groupCalls.activeGroupCallId:void 0,withInterfaceAnimations:(0,f.FOo)(e),language:n,wasTimeFormatSetManually:a,isPhoneCallActive:M?Boolean(e.phoneCall):void 0,addedSetIds:e.stickers.added.setIds,addedCustomEmojiIds:e.customEmojis.added.setIds,newContactUserId:Z?.userId,newContactByPhoneNumber:Z?.isByPhoneNumber,openedGame:p,gameTitle:B,isRatePhoneCallModalOpen:Boolean(C),botTrustRequest:i,botTrustRequestBot:i&&(0,f.dyD)(e,i.botId),attachBotToInstall:o?.bot,requestedAttachBotInChat:r,webApp:l,currentUserName:(0,v.Js)(U),urlAuth:d,isCurrentUserPremium:(0,f.wVz)(e),isPremiumModalOpen:S?.isOpen,limitReached:R?.limit,isPaymentModalOpen:E.isPaymentModalOpen,isReceiptModalOpen:Boolean(E.receipt),deleteFolderDialog:j,isMasterTab:M,requestedDraft:c,chatlistModal:T,noRightColumnAnimation:O,isSynced:e.isSynced}}))((e=>{let{isMobile:t,isLeftColumnOpen:s,isMiddleColumnOpen:l,isRightColumnOpen:u,isMediaViewerOpen:m,isStoryViewerOpen:h,isForwardModalOpen:g,hasNotifications:p,hasDialogs:f,audioMessage:I,activeGroupCallId:v,safeLinkModalUrl:w,isHistoryCalendarOpen:y,shouldSkipHistoryAnimations:b,limitReached:P,openedStickerSetShortName:Z,openedCustomEmojiSetIds:C,isServiceChatReady:S,withInterfaceAnimations:M,language:E,wasTimeFormatSetManually:R,addedSetIds:k,addedCustomEmojiIds:T,isPhoneCallActive:A,newContactUserId:N,newContactByPhoneNumber:x,openedGame:U,gameTitle:L,isRatePhoneCallModalOpen:O,botTrustRequest:j,botTrustRequestBot:_,attachBotToInstall:F,requestedAttachBotInChat:D,requestedDraft:q,webApp:G,currentUserName:H,urlAuth:$,isPremiumModalOpen:V,isPaymentModalOpen:K,isReceiptModalOpen:J,isReactionPickerOpen:z,isCurrentUserPremium:W,deleteFolderDialog:Y,isMasterTab:X,chatlistModal:Q,noRightColumnAnimation:ee,isSynced:te}=e;const{initMain:se,loadAnimatedEmojis:ne,loadNotificationSettings:ae,loadNotificationExceptions:ie,updateIsOnline:oe,onTabFocusChange:re,loadTopInlineBots:ce,loadEmojiKeywords:de,loadCountryList:le,loadAvailableReactions:ue,loadStickerSets:me,loadPremiumGifts:he,loadDefaultTopicIcons:ge,loadAddedStickers:pe,loadFavoriteStickers:fe,loadDefaultStatusIcons:Ie,ensureTimeFormat:ve,closeStickerSetModal:we,closeCustomEmojiSets:ye,checkVersionNotification:be,loadConfig:Pe,loadAppConfig:Ze,loadAttachBots:Ce,loadContactList:Se,loadCustomEmojis:Me,loadGenericEmojiEffects:Ee,closePaymentModal:Re,clearReceipt:ke,checkAppVersion:Te,openChat:Ae,toggleLeftColumn:Ne,loadRecentEmojiStatuses:xe,updatePageTitle:Be,loadTopReactions:Ue,loadRecentReactions:Le,loadFeaturedEmojiStickers:je,setIsAppUpdateAvailable:_e}=(0,n.Sv)();i.eMD&&!Yr&&(Yr=!0,console.log(">>> RENDER MAIN")),(0,Rt.Z)((()=>{(0,gt.Pb)(gt.gl.Calls)}),5e3);const Fe=(0,o.sO)(null),De=(0,o.sO)(null),{isDesktop:qe}=(0,B.ZP)();(0,o.d4)((()=>{s||l||qe?s&&l&&t&&Ne():Ne()}),[qe,s,l,t,Ne]),(0,Mt.Z)(Te,X&&!i.D$V?3e5:void 0,!0),(0,o.d4)((()=>{if(!i.D$V)return;const e=window.electron.on(d.I.UPDATE_DOWNLOADED,(()=>{_e(!0)})),t=window.electron.on(d.I.UPDATE_ERROR,(()=>{_e(!1),e?.()}));return()=>{t?.(),e?.()}}),[]),(0,o.d4)((()=>{X&&te&&(oe(!0),Pe(),Ze(),se(),ue(),ne(),Ee(),ae(),ie(),ce(),de({language:i.pRL}),Ce(),Se(),he(),ge(),Te(),Ue(),Le(),je())}),[X,te]),(0,o.d4)((()=>{X&&W&&(Ie(),xe())}),[W,X]),(0,o.d4)((()=>{X&&(E!==i.pRL&&de({language:E}),le({langCode:E}))}),[E,X]),(0,o.d4)((()=>{X&&Me({ids:Object.keys((0,n.Rd)().customEmojis.byId),ignoreCache:!0})}),[X]),(0,o.d4)((()=>{X&&te&&(k&&T||(me(),fe()),k&&T&&pe())}),[k,T,X,te]),(0,o.d4)((()=>{S&&X&&be()}),[S,X]),(0,o.d4)((()=>{R||ve()}),[R]),(0,o.d4)((()=>{const e=(0,Oe.dx)();e?.tgaddr&&(0,ht.ou)(decodeURIComponent(e.tgaddr))}),[]),(0,o.d4)((()=>{const e=(0,Oe.VX)();e&&Ae({id:e.chatId,threadId:e.threadId,type:e.type})}),[]),(0,o.bt)((()=>{const e=Fe.current;1===e.parentNode.childElementCount&&(0,r.D_)(e,"Transition_slide-active")}),[]);const Ge=(0,Ct.Z)(s,void 0,!0,void 0,b,void 0,!0),He=(0,o.sO)(!1),$e=(0,Zt.Z)();(0,vt.Z)((e=>{let[t]=e;if(void 0===t||s===t||!M)return;He.current=!0,a.wZ&&(0,c.Yq)((()=>{document.body.classList.toggle("android-left-blackout-open",!s)}));const n=(0,St.YW)();(0,mt.L)(document.getElementById("MiddleColumn"),(()=>{n(),He.current=!1,$e()}))}),[s,M,$e]);const Ve=(0,Ct.Z)(u,void 0,!0,void 0,b,void 0,!0),Je=(0,o.sO)(!1),[ze,We]=(0,o.eJ)(u),Ye=(0,Et.Ar)();(0,vt.Z)((e=>{let[t,s]=e;if(void 0===s||u===s)return;if(!t||ee)return void We(u);Je.current=!0;const n=(0,St.YW)();(0,mt.L)(document.getElementById("RightColumn"),(()=>{n(),Je.current=!1,$e(),We(u)}))}),[l,u,ee,$e]);const Xe=(0,ut.Z)(Ge.hasShownClass&&"left-column-shown",Ge.hasOpenClass&&"left-column-open",He.current&&"left-column-animating",Ve.hasShownClass&&"right-column-shown",Ve.hasOpenClass&&"right-column-open",Je.current&&"right-column-animating",ze&&"narrow-message-list",b&&"history-animation-disabled",Ye&&"is-fullscreen"),Qe=(0,pt.Z)((()=>{re({isBlurred:!0})})),et=(0,pt.Z)((()=>{re({isBlurred:!1}),document.title.includes(i.ouc)||Be(),Ke(!1)})),tt=(0,pt.Z)((()=>{we()})),st=(0,pt.Z)((()=>{ye()}));return(0,ft.Z)(Qe,et,!!i.D$V),(0,It.Z)(Qe),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,o.d4)((()=>{if(a.$b){if(!e)return wt?.setAttribute("content",yt),a.cj&&!a.fl&&document.addEventListener("gesturestart",Pt),()=>{wt?.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),a.cj&&!a.fl&&document.removeEventListener("gesturestart",Pt)};wt?.setAttribute("content",bt)}}),[e])}(m||h),o.ZP.createElement("div",{ref:Fe,id:"Main",className:Xe},o.ZP.createElement(Os,{ref:De}),o.ZP.createElement(Mo,{leftColumnRef:De,isMobile:t}),o.ZP.createElement(mr,{isMobile:t}),o.ZP.createElement(hr,{isOpen:m}),o.ZP.createElement(Wr,{isOpen:h}),o.ZP.createElement(Zr,{isOpen:g}),o.ZP.createElement(Vr,{requestedDraft:q}),o.ZP.createElement(br,{isOpen:p}),o.ZP.createElement(Pr,{isOpen:f}),I&&o.ZP.createElement(kn,{key:I.id,message:I,noUi:!0}),o.ZP.createElement(Cr,{url:w}),o.ZP.createElement(_r,{urlAuth:$,currentUserName:H}),o.ZP.createElement(Sr,{isOpen:y}),o.ZP.createElement(Tt,{isOpen:Boolean(Z),onClose:tt,stickerSetShortName:Z}),o.ZP.createElement($r,{customEmojiSetIds:C,onClose:st}),v&&o.ZP.createElement(Mr,{groupCallId:v}),o.ZP.createElement(Er,{isActive:Boolean(v||A)}),o.ZP.createElement(Ar,{isOpen:Boolean(N||x),userId:N,isByPhoneNumber:x}),o.ZP.createElement(zr,{info:Q}),o.ZP.createElement(yr,{openedGame:U,gameTitle:L}),o.ZP.createElement(xr,{webApp:G}),o.ZP.createElement(Ir,null),o.ZP.createElement(jr,null),o.ZP.createElement(Rr,{isActive:A}),o.ZP.createElement(Bt,{isForAppBadge:!0}),o.ZP.createElement(Nr,{isOpen:O}),o.ZP.createElement(Br,{bot:_,type:j?.type,shouldRequestWriteAccess:j?.shouldRequestWriteAccess}),o.ZP.createElement(Ur,{bot:F}),o.ZP.createElement(Kr,{requestedAttachBotInChat:D}),o.ZP.createElement(Tr,null),V&&o.ZP.createElement(Fr,{isOpen:V}),o.ZP.createElement(Gr,{limit:P}),o.ZP.createElement(Dr,{isOpen:K,onClose:Re}),o.ZP.createElement(qr,{isOpen:J,onClose:ke}),o.ZP.createElement(Hr,{folder:Y}),o.ZP.createElement(Jr,{isOpen:z}))})));var Qr=s(57773),ec=s(21179),tc=s(99364),sc=s(8337);var nc=s(2092);const ac=(0,o.X$)((0,n.c$)((e=>({passcodeSettings:e.passcode})))((e=>{let{isLocked:t,passcodeSettings:s}=e;const{unlockScreen:a,signOut:i,logInvalidUnlockAttempt:r,resetInvalidUnlockAttempts:c}=(0,n.Sv)(),{invalidAttemptsCount:d,timeoutUntil:l,isLoading:u}=s,m=(0,_t.Z)(),[h,g]=(0,o.eJ)(""),[p,f]=(0,o.eJ)(!1),[I,v,w]=(0,ss.Z)(!1),{shouldRender:y}=(0,Ct.Z)(t);(0,Rt.Z)(c,l?l-Date.now():void 0);const b=(0,o.I4)((()=>{g("")}),[]),P=(0,o.I4)((e=>{void 0===l?(g(""),(0,st.so)(e).then(a,(()=>{r(),g(m("lng_passcode_wrong"))}))):g(m("FloodWait"))}),[m,l]);(0,o.d4)((()=>{void 0!==l?g(m("FloodWait")):0===d&&g("")}),[l,m,d]);const Z=(0,o.I4)((()=>{w(),i({forceInitApi:!0})}),[w,i]);if(y)return o.ZP.createElement("div",{className:"sY59IPNwkaRsrfYPhEJc"},o.ZP.createElement("div",{className:"DlErQEIDwmZ0duQgO_2b",dir:m.isRtl?"rtl":void 0},o.ZP.createElement(ec.Z,{tgsUrl:Qr.l.Lock,previewUrl:nc,size:160,className:"ar9YdQbWJreREHmnZa9m"}),o.ZP.createElement(tc.Z,{key:"password-form",shouldShowSubmit:!0,shouldDisablePasswordManager:!0,isLoading:u,error:h,placeholder:m("Passcode.EnterPasscodePlaceholder"),submitLabel:m("Next"),clearError:b,isPasswordVisible:p,noRipple:!0,onChangePasswordVisibility:f,onSubmit:P}),o.ZP.createElement("div",{className:"uOmdTQr_cJEvuTkQipx7"},o.ZP.createElement("p",null,o.ZP.createElement(sc.Z,{onClick:v},"Log out")," ","if you don't remember your passcode."),o.ZP.createElement("p",null,o.ZP.createElement(zt.Z,{color:"translucent",size:"tiny",isText:!0,onClick:v},m("AccountSettings.Logout"))))),o.ZP.createElement(on.Z,{isOpen:I,onClose:w,text:m("lng_sure_logout"),confirmLabel:m("AccountSettings.Logout"),confirmHandler:Z,confirmIsDestructive:!0}))})));i.eMD&&console.log(">>> FINISH LOAD MAIN BUNDLE");const{passcode:{isScreenLocked:ic},connectionState:oc}=(0,n.Rd)();oc||ic||a.Eo||(0,n.Sv)().initApi()}}]);
//# sourceMappingURL=5769.c88c06a2239f9329d9f0.js.map