2 lines
393 KiB
JavaScript
2 lines
393 KiB
JavaScript
(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[5769],{22351:(e,t,s)=>{"use strict";s.r(t),s.d(t,{LockScreen:()=>Xc,Main:()=>Jc});var a=s(33555),n=s(83716),o=s(97184),i=(s(65456),s(27225)),r=s(59187),c=s(91713),d=s(64319),l=s(51190),u=s(81396),m=s(65054),h=s(60782),p=s(59692),g=s(490),f=s(69118),I=s(92387),v=s(4463),w=s(11302),b=s(44271),y=s(7054),P=s(84112),Z=s(28406),S=s(26646),C=s(43858),M=s(74399);const E=32*M.Gw,R=45.5*M.Gw,k=26.5*M.Gw,T=16*M.Gw,N=16.125*M.Gw;var A=s(53475),B=s(4907),x=s(42797);function U(e,t){return t-((0,y.jUK)(e).isLeftColumnShown&&!(0,x.W7)()?e.leftColumnWidth||((s=C.Z.get().width)>n._mX?Math.min(Math.max(.25*s,T),.33*s):s>n.ksF?Math.min(Math.max(.33*s,T),.4*s):k):0);var s}function L(e,t,s){const a=(0,y.FM1)(e,t.chatId),n=t.reactions||{results:[],areTags:a},o=(0,y._5C)(e,t.chatId),i=(0,v.vt)(n.results,s);let{recentReactions:r=[]}=n;return r.length&&(r=r.filter((({isOwn:t,peerId:s})=>!t&&s!==e.currentUserId))),s.forEach((t=>{const{currentUserId:s}=e;r.unshift({peerId:o?.id||s,reaction:t,addedDate:Math.floor(Date.now()/1e3),isOwn:!0})})),(0,B.cY)(e,t.chatId,t.id,{reactions:{...n,results:i,recentReactions:r}})}function _(e,t,s){return(0,A.a4)(e,t,s,void 0,!0)}const O=350;function F(e,t,s,a,n,o,i,r){const c=r?.reactions;if(c&&(0,P.A)(n,c))return e;if(e=(0,w.cY)(e,s,a,{reactions:n}),!i)return e;const{reaction:d,isOwn:l,isUnread:u}=n.recentReactions?.[0]??{};if((0,y.$Yd)(e,"reactionEffects")&&r&&d&&u&&!l){const e=(0,g.Tp)(r);t.startActiveReaction({containerId:e,reaction:d,tabId:(0,m._w)()})}const h=o.unreadReactions?.includes(a);if((0,v.yL)(e,n)&&!h){e=_(e,s,{unreadReactionsCount:(o?.unreadReactionsCount||0)+1,unreadReactions:[...o?.unreadReactions||[],a]});const t=(0,y.hjO)(e,s,a);if(!o||!t)return e;(0,f.R3)((()=>{(0,Z.rh)({chat:o,message:t,isReaction:!0})}))}else h&&(e=_(e,s,{unreadReactionsCount:(o?.unreadReactionsCount||1)-1,unreadReactions:o?.unreadReactions?.filter((e=>e!==a))}));return e}function D(e,t,s,a,n=!1){const o=n?(0,y.TmO)(e,t,s):(0,y.hjO)(e,t,s);if(o&&a.content&&!(0,g.AJ)(s)){const{photo:e,video:t,sticker:s,document:n}=(0,v.qp)(o);var i,r;if(e&&a.content.photo)(i=a.content.photo).blobUrl??(i.blobUrl=e.blobUrl),(r=a.content.photo).thumbnail??(r.thumbnail=e.thumbnail);else if(t&&a.content.video){var c;(c=a.content.video).blobUrl??(c.blobUrl=t.blobUrl)}else if(s&&a.content.sticker){var d;(d=a.content.sticker).isPreloadedGlobally??(d.isPreloadedGlobally=s.isPreloadedGlobally)}else if(n&&a.content.document){var l;(l=a.content.document).previewBlobUrl??(l.previewBlobUrl=n.previewBlobUrl)}}const u=o?{...o,...a}:a;return n?(0,w.P4)(e,t,s,u):(0,w.cY)(e,t,s,u)}function j(e,t,s,a){const{chatId:n}=s,o=(0,S.H)(s),{threadInfo:i}=(0,y.DbP)(e,s)||{};if(!i&&o?.replyToMsgId){const i=(0,y.hjO)(e,n,o.replyToMsgId);i?e=(0,w.lG)(e,i,n,s.id,a):t.loadMessage({chatId:n,messageId:o.replyToMsgId,threadUpdate:{isDeleting:a,lastMessageId:s.id}})}return e}function q(e,t,s){const{id:a,chatId:n}=s,o=(0,y.heq)(e,s),{threadInfo:i}=(0,y.DbP)(e,s)||{},c=(0,y.Z1J)(e,n),d=c?.unreadCount&&!(0,y.gbs)(e,n,r._f);e=j(e,t,s);const{threadId:l}=i??{threadId:o};return l&&(e=(0,w.xj)(e,n,l,[a]),Object.values(e.byTabId).forEach((({id:t})=>{if((0,y.b9T)(e,n,l,t)){const s=(0,y.It8)(e,n,l),o=(0,w.$S)(e,n,l,a,t),i=(0,y.Cbz)(o,n,l,t);s&&!i.includes(s)||(e=o)}})),i&&(e=(0,w.pf)(e,n,l,"threadInfo",{...i,lastMessageId:s.id}),(0,v.CI)(s)||(0,v.FT)(s)||(e=(0,w.Xg)(e,n,l,{messagesCount:(i.messagesCount||0)+1})))),d||(e=(0,w.xj)(e,n,r._f,[a]),Object.values(e.byTabId).forEach((({id:t})=>{if((0,y.b9T)(e,n,r._f,t)){const s=(0,y.It8)(e,n,r._f),o=(0,w.$S)(e,n,r._f,a,t),i=(0,y.Cbz)(o,n,r._f,t);s&&!i.includes(s)||(e=o)}}))),e}function G(e,t,s,a=!1){const{chats:n}=e,o=n.byId[t],i=(0,y.xMv)(e,t),r=o?.isForum?(0,y.p$s)(e,s):void 0;r&&(e=(0,w.Cn)(e,t,r.id,{lastMessageId:s.id}));const c=(0,y.heq)(e,s);return c&&(e=(0,w._l)(e,c,s.id,"saved")),!i||a||i===s.id||i===s.previousLocalId||s.id>i?(0,w._l)(e,t,s.id):e}function H(e,t,s=r._f){const a=(0,y.Zwk)(e,t),n=(0,y.gbs)(e,t,s);if(!a||!n)return;let o=n.length;for(;o--;){const e=a[n[o]];if(e&&!e.isDeleting)return e}}function V(e,t,s,n){if(t){const o=(0,y.Z1J)(e,t);if(!o)return;const i=new Set;i.add(r._f),s.forEach((s=>{e=(0,w.cY)(e,t,s,{isDeleting:!0}),o.topics?.[s]&&(e=(0,w.BK)(e,t,s));const a=(0,y.hjO)(e,t,s);if(!a)return;e=j(e,n,a,!0);const r=(0,y.nrh)(e,a);r&&i.add(r)})),n.requestChatUpdate({chatId:t});const c=new Set(s);return i.forEach((s=>{const a=(0,y.tZg)(e,t,s);if(!a?.lastMessageId||!c.has(a.lastMessageId))return;const n=H(e,t,s);n&&(s===r._f&&(e=G(e,t,n,!0)),e=(0,w.Xg)(e,t,s,{lastMessageId:n.id}),o.isForum&&(e=(0,w.Cn)(e,t,Number(s),{lastMessageId:n.id})))})),(0,a.R3)(e),void setTimeout((()=>{e=(0,a.Rd)(),e=(0,w.K4)(e,t,s),(0,a.R3)(e)}),O)}const o=[];s.forEach((t=>{const s=(0,y.X5I)(e,t);if(s){o.push(s);const i=H(e=(0,w.cY)(e,s,t,{isDeleting:!0}),s);i&&(e=G(e,s,i,!0));const r=(0,y.hjO)(e,s,t);if((0,y.FM1)(e,s)&&r){const t=(0,y.nrh)(e,r);if((0,v._o)(s,t,e.currentUserId)){const a=H(e,s,t);n.requestSavedDialogUpdate({chatId:String(t)}),a&&(e=(0,w._l)(e,s,a.id,"saved"))}}setTimeout((()=>{e=(0,a.Rd)(),e=(0,w.K4)(e,s,[t]),(0,a.R3)(e)}),O)}})),(0,a.R3)(e),(0,h.Tw)(o).forEach((e=>{n.requestChatUpdate({chatId:e})}))}(0,a.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:n,id:o,message:i,shouldForceReply:r,wasDrafted:c}=s;e=q(e=D(e,n,o,i),t,i);const d=(0,y.hjO)(e,n,o),l=(0,S.H)(d),u=(0,S.f)(d),m=(0,y.Z1J)(e,n);m?.isForum&&l?.isForumTopic&&!(0,y.p$s)(e,d)&&l.replyToMsgId&&t.loadTopicById({chatId:n,topicId:l.replyToMsgId});const h=(0,v.CI)(i);if(Object.values(e.byTabId).forEach((({id:s})=>{if(h&&c&&(e=G(e,n,d)),(0,y.KAC)(e,n,i,s)){if(h&&i.isOutgoing&&!i.content?.action&&!u?.storyId&&!i.content?.storyData){const a=(0,y.Btg)(e,s);a&&t.focusMessage({chatId:n,threadId:a.threadId,messageId:i.id,noHighlight:!0,isResizingContainer:!0,tabId:s})}h||setTimeout((()=>{e=(0,a.Rd)(),r&&t.updateDraftReplyInfo({replyToMsgId:o,tabId:s}),e=G(e,n,d),(0,a.R3)(e)}),O)}else e=G(e,n,d)})),(0,a.R3)(e),(0,y.Nap)(e,n)||t.loadTopChats(),(0,y.FM1)(e,n)&&!h){const s=(0,y.heq)(e,d);s&&!(0,y.Nap)(e,s,"saved")&&t.requestSavedDialogUpdate({chatId:s})}break}case"updateChatLastMessage":{const{id:t,lastMessage:n}=s;e=G(e,t,n,!0),e=(0,w.m6)(e,[n]),(0,a.R3)(e);break}case"updateStartEmojiInteraction":Object.values(e.byTabId).forEach((({id:t})=>{const{chatId:a}=(0,y.Btg)(e,t)||{};if(a!==s.id)return;const n=(0,y.hjO)(e,a,s.messageId);if(!n)return;if((0,v.UD)(n)!==s.emoji)return;const o=(0,y.jUK)(e,t);e=(0,b.i)(e,{activeEmojiInteractions:[...o.activeEmojiInteractions||[],{id:Math.random(),animatedEffect:s.emoji,messageId:s.messageId}]},t)})),(0,a.R3)(e);break;case"newScheduledMessage":{const{chatId:t,id:n,message:o}=s;e=D(e,t,n,o,!0);const i=(0,y.qyA)(e,t,r._f)||[];e=(0,w.pf)(e,t,r._f,"scheduledIds",(0,h.Tw)([...i,n]));const c=(0,y.nrh)(e,o);if(c!==r._f){const s=(0,y.qyA)(e,t,c)||[];e=(0,w.pf)(e,t,c,"scheduledIds",(0,h.Tw)([...s,n]))}(0,a.R3)(e);break}case"updateMessage":{const{chatId:n,id:o,message:i}=s,r=(0,y.hjO)(e,n,o),c=(0,y.Z1J)(e,n);e=D(e,n,o,i);const d=(0,y.hjO)(e,n,o);i.reactions&&c&&(e=F(e,t,n,o,i.reactions,c,d.isOutgoing,r)),i.content?.text?.text!==r?.content?.text?.text&&(e=(0,w.CE)(e,n,o)),(0,a.R3)(e);break}case"updateScheduledMessage":{const{chatId:t,id:n,message:o}=s,i=(0,y.TmO)(e,t,n);if(!i)return;e=D(e,t,n,o,!0);const c=Object.keys((0,y.yBV)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,w.pf)(e,t,r._f,"scheduledIds",c);const d=(0,y.nrh)(e,i);if(d!==r._f){const s=(0,y.qyA)(e,t,d)||[];e=(0,w.pf)(e,t,d,"scheduledIds",s.sort(((e,t)=>t-e)))}(0,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:n,localId:o,message:i}=s;e=q(e,t,i);const c=(0,y.hjO)(e,n,o);e=(0,w.K4)(e,n,[o]),i.isScheduled&&(e=(0,w.bV)(e,n,[o])),e=(0,w.cY)(e,n,i.id,{...c,...i,previousLocalId:o}),e={...e,fileUploads:{byMessageKey:(0,h.CE)(e.fileUploads.byMessageKey,[(0,g.Tp)(i)])}};const d=(0,y.hjO)(e,n,i.id);e=G(e,n,d);const l=(0,y.DbP)(e,i);if(Object.values(e.byTabId).forEach((({id:s})=>{const{chatId:a,threadId:o}=(0,y.Btg)(e,s)||{};a===n&&(l?.threadInfo?.threadId||r._f)===o&&t.markMessageListRead({maxId:i.id,tabId:s})})),l?.threadInfo?.threadId&&(e=(0,w.pf)(e,n,l.threadInfo.threadId,"threadInfo",{...l.threadInfo,lastMessageId:i.id,lastReadInboxMessageId:i.id})),e=(0,w.a4)(e,n,{lastReadInboxMessageId:i.id}),(0,y.FM1)(e,n)){const s=(0,y.heq)(e,d);s&&!(0,y.Nap)(e,s,"saved")&&t.requestSavedDialogUpdate({chatId:s})}(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:n,message:o}=s,i=(0,y.qyA)(e,t,r._f)||[];e=(0,w.pf)(e,t,r._f,"scheduledIds",[...i,o.id]);const c=(0,y.nrh)(e,o);if(c!==r._f){const s=(0,y.qyA)(e,t,c)||[];e=(0,w.pf)(e,t,c,"scheduledIds",[...s,o.id])}const d=(0,y.TmO)(e,t,n);e=(0,w.bV)(e,t,[n]),e=(0,w.P4)(e,t,o.id,{...d,...o,previousLocalId:n}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:n,messageIds:o}=s,i=(0,h.q0)((0,y.Zwk)(e,t),o),c={[r._f]:o};Object.values(i).forEach((s=>{const a=(0,y.nrh)(e,s);if(e=(0,w.cY)(e,t,s.id,{isPinned:n}),a===r._f)return;const o=c[a]||[];o.push(s.id),c[a]=o})),Object.entries(c).forEach((([s,a])=>{const o=(0,y.KBA)(e,t,r._f)||[],i=n?(0,h.Tw)(o.concat(a)).sort(((e,t)=>t-e)):o.filter((e=>!a.includes(e)));e=(0,w.pf)(e,t,Number(s),"pinnedIds",i)})),(0,a.R3)(e);break}case"updateThreadInfos":{const{threadInfoUpdates:n}=s;e=(0,w.j6)(e,n),n.forEach((s=>{const{chatId:a,threadId:n}=s;if(!a||!n)return;const o=(0,y.Z1J)(e,a),i=(0,y.tZg)(e,a,n);if(o?.isForum&&s.lastReadInboxMessageId!==i?.lastReadInboxMessageId&&t.loadTopicById({chatId:a,topicId:Number(n)}),!o?.isForum){const t=o?.lastReadInboxMessageId,i=s.lastReadInboxMessageId||t;t&&i&&(e=(0,w.Xg)(e,a,n,{lastReadInboxMessageId:Math.max(i,t)}))}})),(0,a.R3)(e);break}case"resetMessages":{const{id:n}=s,o=(0,y.Zwk)(e,n);if(o&&!(0,v.YC)(n)){const s=(0,m._w)();e=(0,w.K4)(e,n,Object.keys(o).map(Number)),(0,a.R3)(e),t.loadFullChat({chatId:n,force:!0,tabId:s}),t.loadViewportMessages({chatId:n,threadId:r._f,tabId:s})}break}case"deleteMessages":{const{ids:a,chatId:n}=s;V(e,n,a,t);break}case"deleteScheduledMessages":{const{ids:t,chatId:n}=s;!function(e,t,s,n){e&&(t.forEach((t=>{n=(0,w.P4)(n,e,t,{isDeleting:!0})})),(0,a.R3)(n),setTimeout((()=>{n=(0,a.Rd)(),n=(0,w.bV)(n,e,t);const s=(0,y.yBV)(n,e);n=(0,w.pf)(n,e,r._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,a.R3)(n)}),O))}(n,t,0,e);break}case"deleteHistory":{const{chatId:o}=s,i=e.messages.byChatId[o];if(o===n.awM&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>({...e,isDeleted:!0})))},(0,a.R3)(e)),i){const s=Object.keys(i.byId).map(Number);V(e=(0,a.Rd)(),o,s,t)}else t.requestChatUpdate({chatId:o});e=(0,a.Rd)(),e=(0,w.kq)(e,o),(0,a.R3)(e);break}case"deleteSavedHistory":{const{chatId:n}=s,o=e.currentUserId;e=(0,w.kq)(e,n,"saved"),(0,a.R3)(e),function(e,t,s,a){const n=(0,y.Zwk)(e,t);if(!n)return;const o=Object.values(n).filter((t=>(0,y.nrh)(e,t)===s)).map((e=>e.id));o.length&&V(e,t,o,a)}(e=(0,a.Rd)(),o,n,t);break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:n}=s;t.forEach((t=>{const s=(0,y.X5I)(e,t);s&&(e=(0,w.cY)(e,s,t,n))})),(0,a.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:n,messageUpdate:o}=s;n.forEach((s=>{e=(0,w.cY)(e,t,s,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:n}=s,o=(0,y.ZBV)(e,t);if(o?.content.poll){const t=o.content.poll.results;let s=t;n.results?.results&&(t.results&&n.results.isMin?t.results&&(s={...n.results,results:n.results.results.map((e=>({...e,isChosen:t.results.find((t=>t.option===e.option))?.isChosen}))),isMin:void 0}):s=n.results);const i={...o.content.poll,...n,results:s};e=(0,w.cY)(e,o.chatId,o.id,{content:{...o.content,poll:i}}),(0,a.R3)(e)}break}case"updateMessagePollVote":{const{pollId:t,peerId:n,options:o}=s,i=(0,y.ZBV)(e,t);if(!i||!i.content.poll||!i.content.poll.results)break;const{poll:r}=i.content,c=(0,y._5C)(e,i.chatId),{recentVoterIds:d,totalVoters:l,results:u}=r.results,m=d?[...d]:[],h=l?l+1:1,p=u?[...u]:[];m.push(n),o.forEach((t=>{const s=p.findIndex((e=>e.option===t)),a=p[s],o=a?{...a}:{option:t,votersCount:0};o.votersCount+=1,c?.id!==n&&n!==e.currentUserId||(o.isChosen=!0),s?p[s]=o:p.push(o)})),e=(0,w.cY)(e,i.chatId,i.id,{content:{...i.content,poll:{...r,results:{...r.results,recentVoterIds:m,totalVoters:h,results:p}}}}),(0,a.R3)(e);break}case"updateServiceNotification":{const{message:a}=s;(0,y.UWV)(e)&&t.createServiceNotification({message:a});break}case"updateMessageReactions":{const{chatId:n,id:o,reactions:i}=s,r=(0,y.hjO)(e,n,o),c=(0,y.Z1J)(e,s.chatId);if(!c||!r)return;e=F(e,t,n,o,i,c,r.isOutgoing,r),(0,a.R3)(e);break}case"updateMessageExtendedMedia":{const{chatId:t,id:n,media:o,preview:i}=s,r=(0,y.hjO)(e,t,n);if(!(0,y.Z1J)(e,s.chatId)||!r)return;if(i){if(!r.content.invoice)return;e=(0,w.cY)(e,t,n,{content:{...r.content,invoice:{...r.content.invoice,extendedMedia:i}}}),(0,a.R3)(e)}else o&&(e=(0,w.cY)(e,t,n,{content:{...o}}),(0,a.R3)(e));break}case"updateTranscribedAudio":{const{transcriptionId:t,text:n,isPending:o}=s;e={...e,transcriptions:{...e.transcriptions,[t]:{...e.transcriptions[t]||{},transcriptionId:t,text:n,isPending:o}}},(0,a.R3)(e);break}case"updateMessageSendFailed":{const{chatId:n,localId:o,error:i}=s;i.match(/CHAT_SEND_.+?FORBIDDEN/)&&Object.values(e.byTabId).forEach((({id:e})=>{t.showAllowedMessageTypesNotification({chatId:n,tabId:e})})),e=(0,w.cY)(e,n,o,{sendingState:"messageSendingStateFailed"}),(0,a.R3)(e);break}case"updateMessageTranslations":{const{chatId:t,messageIds:n,toLanguageCode:o,translations:i}=s;e=(0,w.TD)(e,t,n,o,i),(0,a.R3)(e);break}}}));const $=new Map,z=(0,f.Ds)((e=>e()),500,!1);async function K({global:e,chatId:t,threadId:s,draft:n,isLocalOnly:o,noLocalTimeUpdate:i}){const r=(0,y.Z1J)(e,t),c=(0,y.dyD)(e,t);if(!r||c&&(0,v.NB)(c))return;const d=(0,y.U1D)(e,t,s,n?.replyInfo),l=n?{...n,replyInfo:d,date:Math.floor(Date.now()/1e3),isLocal:!0}:void 0;e=(0,w.pf)(e,t,s,"draft",l),i||(e=(0,w.a4)(e,t,{draftDate:l?.date})),(0,a.R3)(e),o||(await(0,I.t9)("saveDraft",{chat:r,draft:l})&&l&&(l.isLocal=!1),e=(0,a.Rd)(),e=(0,w.pf)(e,t,s,"draft",l),e=(0,w.a4)(e,t,{draftDate:l?.date}),(0,a.R3)(e))}async function J(e,t,s,o,i,d=!1,l=!1,u,...[p=(0,m._w)()]){const g=t.id;let f,b=n.hT6;switch(i){case c.Uq.Backwards:o?(f=-1,b+=1):f=void 0;break;case c.Uq.Around:f=-(Math.round(n.hT6/2)+1);break;case c.Uq.Forwards:f=-(n.hT6+1),o&&(b+=1)}const P=(e=(0,a.Rd)()).currentUserId,Z=(0,v._o)(g,s,P),S=Z?String(s):g,C=await(0,I.t9)("fetchMessages",{chat:(0,y.Z1J)(e,S),offsetId:o,addOffset:f,limit:b,threadId:s,isSavedDialog:Z});if(!C)return;const{messages:M,users:E,chats:R,count:k}=C;e=(0,a.Rd)();const T=g===n.awM?e.serviceNotifications.filter((({isDeleted:e})=>!e)).map((({message:e})=>e)):[],N=[].concat(M,T),A=(0,h.ee)(N,"id"),B=Object.keys(A).map(Number);if(s!==r._f&&!(0,v._o)(g,s,e.currentUserId)){const t=(0,y.yZJ)(e,g,s);B[0]&&t!==B[0]||t===s||B.unshift(Number(s))}e=(0,w.c_)(e,g,A),e=d?(0,w.hv)(e,g,s,B):(0,w.xj)(e,g,s,B),e=(0,w.Sh)(e,(0,h.ee)(E,"id")),e=(0,w.fZ)(e,(0,h.ee)(R,"id"));let x=(0,y.gbs)(e,g,s);const U=o?(0,y.ofg)(e,g,s,o):void 0;if(d&&x&&U&&(U.length&&!(0,h.YE)(x,U)||(e=(0,w.xj)(e,g,s,U),x=(0,y.gbs)(e,g,s),e=(0,w.IU)(e,g,s,U),d=!1)),!l){const t=d&&U?U:x;if(t){const{newViewportIds:a}=W(t,o,i);e=(0,w.y9)(e,g,s,a,p)}}k&&(e=(0,w.Xg)(e,t.id,s,{messagesCount:k})),(0,a.R3)(e),u?.()}function W(e,t,s){const{length:a}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,a)=>s===t||s<t&&e[a+1]>t))}(e,t):-1,i=s===c.Uq.Backwards?o:o+1||a,r=s===c.Uq.Around?Math.round(n.hT6/2):n.hT6,d=i-r,l=i+r-1,u=e.slice(Math.max(0,d),l+1);let m,h;switch(s){case c.Uq.Backwards:m=i>=0,h=d>=0;break;case c.Uq.Forwards:m=i<a,h=l<=a-1;break;case c.Uq.Around:default:m=u.length>0,h=u.length===n.hT6}return{newViewportIds:u,areSomeLocal:m,areAllLocal:h}}async function Y(e,t){let s;const n=t.attachment?(t,o)=>{$.has(o)||(s=o,$.set(o,n)),e=(0,a.Rd)(),e=(0,w.RZ)(e,o,t),(0,a.R3)(e)}:void 0;(t.replyInfo||o.cj)&&await(0,f.Pn)(),await(0,I.t9)("sendMessage",t,n),n&&s&&(e=(0,a.Rd)(),e=(0,w.RZ)(e,s,void 0),(0,a.R3)(e),$.delete(s))}(0,a.iw)("loadViewportMessages",((e,t,s)=>{const{direction:n=c.Uq.Around,isBudgetPreload:o=!1,shouldForceRender:i=!1,onLoaded:r,onError:d,tabId:l=(0,m._w)()}=s||{};let{chatId:u,threadId:h}=s||{};if(!u||!h){const t=(0,y.Btg)(e,l);if(!t)return void d?.();u=t.chatId,h=t.threadId}const p=(0,y.Z1J)(e,u);if(!p||p.isRestricted)return void d?.();const I=(0,y.Cbz)(e,u,h,l),v=(0,y.gbs)(e,u,h);if(I&&I.length&&n!==c.Uq.Around){const s=n===c.Uq.Backwards?I[0]:I[I.length-1];if((0,g.AJ)(s))return;if(s===h&&n===c.Uq.Backwards)return;const a=Boolean(v&&!v.includes(s)),i=a?(0,y.ofg)(e,u,h,s):v,{newViewportIds:d,areSomeLocal:b,areAllLocal:P}=W(i,s,n);if(b&&(e=(0,w.y9)(e,u,h,d,l)),(0,f.R3)((()=>{!async function(e,t,s,a,n,o,i,r,c,d,...[l=(0,m._w)()]){s||await J(e,o,i,c,r,a,n,d,l),n||t.loadViewportMessages({chatId:o.id,threadId:i,direction:r,isBudgetPreload:!0,onLoaded:d,tabId:l})}(e,t,P,a,o,p,h,n,s,r,l)})),o)return}else{const t=(0,y.G$N)(e,u,l)||(0,y.rdT)(e,u,h),s=Boolean(t&&v&&!v.includes(t)),a=(s?(0,y.ofg)(e,u,h,t):v)||[],{newViewportIds:n,areSomeLocal:i,areAllLocal:d}=W(a,t,c.Uq.Around);i&&(e=(0,w.y9)(e,u,h,n,l)),d?r?.():(0,f.R3)((()=>{J(e,p,h,t,c.Uq.Around,s,o,r,l)}))}(0,a.R3)(e,{forceOnHeavyAnimation:i})})),(0,a.iw)("loadMessage",(async(e,t,s)=>{const{chatId:n,messageId:o,replyOriginForId:i,threadUpdate:c}=s,d=(0,y.Z1J)(e,n);if(!d)return;const l=await async function(e,t,s,n){const o=await(0,I.t9)("fetchMessage",{chat:t,messageId:s});if(o){if(o!==r._Q)return e=(0,a.Rd)(),e=(0,w.cY)(e,t.id,s,o.message),e=(0,w.Sh)(e,(0,h.ee)(o.users,"id")),(0,a.R3)(e),o.message;if(n){e=(0,a.Rd)();const s=(0,y.hjO)(e,t.id,n);e=(0,w.cY)(e,t.id,n,{...s,replyInfo:void 0}),(0,a.R3)(e)}}}(e,d,o,i);if(l&&c){const{lastMessageId:t,isDeleting:s}=c;e=(0,a.Rd)(),e=(0,w.lG)(e,l,n,t,s),(0,a.R3)(e)}})),(0,a.iw)("sendMessage",((e,t,s)=>{const{messageList:a,tabId:o=(0,m._w)()}=s,{storyId:i,peerId:c}=(0,y.pri)(e,o),d=Boolean(i&&c);if(!a&&!d)return;let{chatId:l,threadId:u,type:p}=a||{};if(d&&(l=c,u=r._f,p="thread"),s=(0,h.CE)(s,["tabId"]),"scheduled"===p&&!s.scheduledAt)return(0,b.i)(e,{contentToBeScheduled:s},o);const g=(0,y.Z1J)(e,l),f=(0,y.Mst)(e,l,u),I=d?void 0:f?.replyInfo,v=d?{type:"story",peerId:c,storyId:i}:void 0,w=(0,y.U1D)(e,l,u,I),P=v||w,Z=(0,y.xMv)(e,l),S={...s,chat:g,replyInfo:P,noWebPage:(0,y.tVX)(e,l,u),sendAs:(0,y._5C)(e,l),lastMessageId:Z};d||t.clearWebPagePreview({tabId:o});const C=!s.attachments||s.attachments.length<=1,M=!C&&s.shouldGroupMessages;if(C){const{attachments:t,...s}=S;Y(e,{...s,attachment:t?t[0]:void 0,wasDrafted:Boolean(f)})}else if(M){const{text:t,entities:s,attachments:a,...o}=S,i=function(e){return e.reduce(((e,t,s,a)=>0===s?(e.push([t]),e):(te(t)===te(a[s-1])?e[e.length-1].push(t):e.push([t]),e)),[])}(a);i.forEach(((a,i)=>{const r=(0,h.Vl)(a,n.DUi);for(let a=0;a<r.length;a++){const[n,...c]=r[a],d=`${Date.now()}${i}${a}`,l=0===a&&0===i;Y(e,{...o,text:l?t:void 0,entities:l?s:void 0,attachment:n,groupedId:c.length>0?d:void 0,wasDrafted:Boolean(f)}),c.forEach((t=>{Y(e,{...o,attachment:t,groupedId:d})}))}}))}else{const{text:t,entities:s,attachments:a,replyInfo:n,...o}=S;t&&Y(e,{...o,text:t,entities:s,replyInfo:n,wasDrafted:Boolean(f)}),a?.forEach((t=>{Y(e,{...o,attachment:t})}))}})),(0,a.iw)("sendInviteMessages",(async(e,t,s)=>{const{chatId:a,userIds:n,tabId:o=(0,m._w)()}=s,i=(0,y.x67)(e,a);if(!i?.inviteLink)return;const r=[];return await Promise.all(n.map((t=>{const s=(0,y.Z1J)(e,t);if(!s)return;const a=(0,v.Js)((0,y.dyD)(e,t));return a&&r.push(a),Y(e,{chat:s,text:i.inviteLink})}))),t.showNotification({message:(0,p.Iu)("Conversation.ShareLinkTooltip.Chat.One",r.join(", ")),tabId:o})})),(0,a.iw)("editMessage",((e,t,s)=>{const{messageList:n,text:o,entities:i,attachments:r,tabId:c=(0,m._w)()}=s;if(!n)return;let d;const l=r?(t,s)=>{$.has(s)||(d=s,$.set(s,l)),e=(0,a.Rd)(),e=(0,w.RZ)(e,s,t),(0,a.R3)(e)}:void 0,{chatId:u,threadId:h,type:p}=n,g=(0,y.Z1J)(e,u),f=(0,y.kKD)(e,u,h,p);g&&f&&(t.setEditingId({messageId:void 0,tabId:c}),(async()=>{await(0,I.t9)("editMessage",{chat:g,message:f,attachment:r?r[0]:void 0,text:o,entities:i,noWebPage:(0,y.tVX)(e,u,h)},l),l&&d&&(e=(0,a.Rd)(),e=(0,w.RZ)(e,d,void 0),(0,a.R3)(e),$.delete(d))})())})),(0,a.iw)("cancelUploadMedia",((e,t,s)=>{const{chatId:a,messageId:n}=s,o=(0,y.hjO)(e,a,n);if(!o)return;const i=o&&$.get((0,g.Tp)(o));i&&(0,I.u3)(i),(0,v.CI)(o)&&t.apiUpdate({"@type":"deleteMessages",ids:[n],chatId:a})})),(0,a.iw)("saveDraft",((e,t,s)=>{const{chatId:a,threadId:n,text:o}=s;if(!o)return;const i=(0,y.Mst)(e,a,n);K({global:e,chatId:a,threadId:n,draft:{text:o,replyInfo:i?.replyInfo}})})),(0,a.iw)("clearDraft",((e,t,s)=>{const{chatId:a,threadId:n=r._f,isLocalOnly:o,shouldKeepReply:i}=s,c=(0,y.Mst)(e,a,n);if(!c)return;const d=c.replyInfo;K({global:e,chatId:a,threadId:n,draft:i&&d?{replyInfo:d}:void 0,isLocalOnly:o})})),(0,a.iw)("updateDraftReplyInfo",((e,t,s)=>{const{tabId:a=(0,m._w)(),...n}=s,o=(0,y.Btg)(e,a);if(!o)return;const{chatId:i,threadId:r}=o,c=(0,y.Mst)(e,i,r),d={type:"message",...c?.replyInfo,...n};d.replyToMsgId&&K({global:e,chatId:i,threadId:r,draft:{...c,replyInfo:d},isLocalOnly:!0,noLocalTimeUpdate:!0})})),(0,a.iw)("resetDraftReplyInfo",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.Btg)(e,a);if(!n)return;const{chatId:o,threadId:i}=n,r=(0,y.Mst)(e,o,i),c=r?.text?{...r,replyInfo:void 0}:void 0;K({global:e,chatId:o,threadId:i,draft:c,isLocalOnly:Boolean(c)})})),(0,a.iw)("toggleMessageWebPage",((e,t,s)=>{const{chatId:a,threadId:n,noWebPage:o}=s;return(0,w.pf)(e,a,n,"noWebPage",o)})),(0,a.iw)("pinMessage",((e,t,s)=>{const{messageId:a,isUnpin:n,isOneSide:o,isSilent:i,tabId:r=(0,m._w)()}=s,c=(0,y.jrE)(e,r);c&&(0,I.t9)("pinMessage",{chat:c,messageId:a,isUnpin:n,isOneSide:o,isSilent:i})})),(0,a.iw)("unpinAllMessages",(async(e,t,s)=>{const{chatId:n,threadId:o}=s,i=(0,y.Z1J)(e,n);if(!i)return;await(0,I.t9)("unpinAllMessages",{chat:i,threadId:o}),e=(0,a.Rd)();const c=(0,y.KBA)(e,n,o);c?.forEach((t=>{e=(0,w.cY)(e,n,t,{isPinned:!1})})),e=(0,w.pf)(e,i.id,r._f,"pinnedIds",[]),(0,a.R3)(e)})),(0,a.iw)("deleteMessages",((e,t,s)=>{const{messageIds:a,shouldDeleteForAll:n,tabId:o=(0,m._w)()}=s,i=(0,y.Btg)(e,o);if(!i)return;const{chatId:r,threadId:c}=i,d=(0,y.Z1J)(e,r),l=a.filter((t=>{const s=(0,y.hjO)(e,r,t);return s&&!(0,v.CI)(s)}));if(!l.length&&a.length)return void V(e,(0,v.eA)(d)?r:void 0,a,t);(0,I.t9)("deleteMessages",{chat:d,messageIds:l,shouldDeleteForAll:n});const u=(0,y._$9)(e,r,c);u&&a.includes(u)&&t.setEditingId({messageId:void 0,tabId:o})})),(0,a.iw)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:a,tabId:n=(0,m._w)()}=s,o=(0,y.Btg)(e,n);if(!o)return;const{chatId:i}=o,r=(0,y.Z1J)(e,i);(0,I.t9)("deleteScheduledMessages",{chat:r,messageIds:a});const c=(0,y.nBP)(e,i);c&&a.includes(c)&&t.setEditingId({messageId:void 0,tabId:n})})),(0,a.iw)("deleteHistory",(async(e,t,s)=>{const{chatId:n,shouldDeleteForAll:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n);if(!r)return;await(0,I.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o}),e=(0,a.Rd)();const c=(0,y.Btg)(e,i);c&&c.chatId===n&&t.openChat({id:void 0,tabId:i});const d=e.chatFolders.byId;Object.values(d).forEach((e=>{if(e.includedChatIds.includes(n)||e.pinnedChatIds?.includes(n)){const t=e.includedChatIds.filter((e=>e!==n)),s=e.pinnedChatIds?.filter((e=>e!==n)),a={...e,includedChatIds:t,pinnedChatIds:s};(0,I.t9)("editChatFolder",{id:e.id,folderUpdate:a})}}))})),(0,a.iw)("deleteSavedHistory",(async(e,t,s)=>{const{chatId:n,tabId:o=(0,m._w)()}=s,i=(0,y.Z1J)(e,n);if(!i)return;await(0,I.t9)("deleteSavedHistory",{chat:i}),e=(0,a.Rd)();const r=(0,y.Btg)(e,o);r&&r.threadId===n&&t.openChat({id:void 0,tabId:o})})),(0,a.iw)("reportMessages",(async(e,t,s)=>{const{messageIds:a,reason:n,description:o,tabId:i=(0,m._w)()}=s,r=(0,y.Btg)(e,i);if(!r)return;const{chatId:c}=r,d=(0,y.Z1J)(e,c),l=await(0,I.t9)("reportMessages",{peer:d,messageIds:a,reason:n,description:o});t.showNotification({message:l?(0,p.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:i})})),(0,a.iw)("sendMessageAction",(async(e,t,s)=>{const{action:a,chatId:n,threadId:o}=s;if("connectionStateReady"!==e.connectionState)return;if((0,y.FM1)(e,n))return;const i=(0,y.Z1J)(e,n);if(!i)return;const r=(0,y.dyD)(e,n);r&&((0,v.cS)(r)||(0,v.NB)(r))||await(0,I.t9)("sendMessageAction",{peer:i,threadId:o,action:a})})),(0,a.iw)("markMessageListRead",((e,t,s)=>{const{maxId:a,tabId:o=(0,m._w)()}=s,i=(0,y.Btg)(e,o);if(!i)return;const{chatId:c,threadId:d}=i,l=(0,y.Z1J)(e,c);if(!l||(0,v._o)(c,d,e.currentUserId))return;z((()=>{(0,I.t9)("markMessageListRead",{chat:l,threadId:d,maxId:a})})),c===n.awM&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=a?{...e,isUnread:!1}:e))});const u=(0,y.Cbz)(e,c,d,o),h=(0,y.It8)(e,c,d);if(d!==r._f&&!l.isForum)return(0,w.Xg)(e,c,d,{lastReadInboxMessageId:a});if(!u||!h||!l.unreadCount)return e;const p=function(e,t,s){let a=0;for(let n=0,o=e.length;n<o&&(e[n]>=t&&e[n]<=s&&a++,!(e[n]>=s));n++);return a}(u,h,a);if(!p)return e;if(l.isForum&&l.topics?.[d]){const t=l.topics[d];e=(0,w.Xg)(e,c,d,{lastReadInboxMessageId:a});const s=Math.max(0,t.unreadCount-p);return 0===s&&(e=(0,w.a4)(e,c,{unreadCount:Math.max(0,l.unreadCount-1)})),(0,w.Cn)(e,c,Number(d),{unreadCount:s})}return(0,w.a4)(e,c,{lastReadInboxMessageId:a,unreadCount:Math.max(0,l.unreadCount-p)})})),(0,a.iw)("markMessagesRead",((e,t,s)=>{const{messageIds:a,tabId:n=(0,m._w)()}=s,o=(0,y.jrE)(e,n);o&&(0,I.t9)("markMessagesRead",{chat:o,messageIds:a})})),(0,a.iw)("loadWebPagePreview",(async(e,t,s)=>{const{text:n,tabId:o=(0,m._w)()}=s,i=await(0,I.t9)("fetchWebPagePreview",{text:n});e=(0,a.Rd)(),e=(0,b.i)(e,{webPagePreview:i},o),(0,a.R3)(e)})),(0,a.iw)("clearWebPagePreview",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};if((0,y.jUK)(e,a).webPagePreview)return(0,b.i)(e,{webPagePreview:void 0},a)})),(0,a.iw)("sendPollVote",((e,t,s)=>{const{chatId:a,messageId:n,options:o}=s,i=(0,y.Z1J)(e,a);i&&(0,I.t9)("sendPollVote",{chat:i,messageId:n,options:o})})),(0,a.iw)("cancelPollVote",((e,t,s)=>{const{chatId:a,messageId:n}=s,o=(0,y.Z1J)(e,a);o&&(0,I.t9)("sendPollVote",{chat:o,messageId:n,options:[]})})),(0,a.iw)("closePoll",((e,t,s)=>{const{chatId:a,messageId:n}=s,o=(0,y.Z1J)(e,a),i=(0,y.hjO)(e,a,n)?.content.poll;o&&i&&(0,I.t9)("closePoll",{chat:o,messageId:n,poll:i})})),(0,a.iw)("loadPollOptionResults",(async(e,t,s)=>{const{chat:n,messageId:o,option:i,offset:r,limit:c,shouldResetVoters:d,tabId:l=(0,m._w)()}=s,u=await(0,I.t9)("loadPollOptionResults",{chat:n,messageId:o,option:i,offset:r,limit:c});if(!u)return;e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(u.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(u.chats,"id"));const p=(0,y.jUK)(e,l),{pollResults:g}=p,{voters:f}=p.pollResults;e=(0,b.i)(e,{pollResults:{...g,voters:{...f,[i]:(0,h.Tw)([...!d&&f?.[i]?f[i]:[],...u.votes.map((e=>e.peerId))])},offsets:{...g.offsets?g.offsets:{},[i]:u.nextOffset||""}}},l),(0,a.R3)(e)})),(0,a.iw)("loadExtendedMedia",((e,t,s)=>{const{chatId:a,ids:n}=s,o=(0,y.Z1J)(e,a);o&&(0,I.t9)("fetchExtendedMedia",{chat:o,ids:n})})),(0,a.iw)("forwardMessages",((e,t,s)=>{const{isSilent:n,scheduledAt:o,tabId:i=(0,m._w)()}=s,{fromChatId:c,messageIds:d,toChatId:l,withMyScore:u,noAuthors:p,noCaptions:g,toThreadId:w=r._f}=(0,y.jUK)(e,i).forwardMessages,P=(0,y.wVz)(e),Z=w===r._f,S=c?(0,y.Z1J)(e,c):void 0,C=l?(0,y.Z1J)(e,l):void 0,M=c&&d?d.sort(((e,t)=>e-t)).map((t=>(0,y.hjO)(e,c,t))).filter(Boolean):void 0;if(!S||!C||!M||w&&!Z&&!C.isForum)return;const E=(0,y._5C)(e,l),R=(0,y.Mst)(e,l,w||r._f),k=(0,y.xMv)(e,C.id),[T,N]=(0,h.uK)(M,(e=>!(0,v.jM)(e)));T.length&&(async()=>{await(0,f.Pn)(),(0,I.t9)("forwardMessages",{fromChat:S,toChat:C,toThreadId:w,messages:T,isSilent:n,scheduledAt:o,sendAs:E,withMyScore:u,noAuthors:p,noCaptions:g,isCurrentUserPremium:P,wasDrafted:Boolean(R),lastMessageId:k})})(),N.forEach((t=>{const{text:s,entities:a}=t.content.text||{},{sticker:i,poll:r}=t.content,c=(0,y.U1D)(e,C.id,w);Y(e,{chat:C,replyInfo:c,text:s,entities:a,sticker:i,poll:r,isSilent:n,scheduledAt:o,sendAs:E,lastMessageId:k})})),e=(0,a.Rd)(),e=(0,b.i)(e,{forwardMessages:{}},i),(0,a.R3)(e)})),(0,a.iw)("loadScheduledHistory",(async(e,t,s)=>{const{chatId:n}=s,o=(0,y.Z1J)(e,n);if(!o)return;const i=await(0,I.t9)("fetchScheduledHistory",{chat:o});if(!i)return;const{messages:c}=i,d=(0,h.ee)(c,"id"),l=Object.keys(d).map(Number).sort(((e,t)=>t-e));if(e=(0,a.Rd)(),e=(0,w.w3)(e,o.id,d),e=(0,w.pf)(e,o.id,r._f,"scheduledIds",l),o?.isForum){const t={};c.forEach((s=>{const a=(0,y.nrh)(e,s),n=t[a]||[];n.push(s.id),t[a]=n})),Object.entries(t).forEach((([t,s])=>{e=(0,w.pf)(e,o.id,Number(t),"scheduledIds",s)}))}(0,a.R3)(e)})),(0,a.iw)("sendScheduledMessages",((e,t,s)=>{const{chatId:a,id:n}=s,o=(0,y.Z1J)(e,a);o&&(0,I.t9)("sendScheduledMessages",{chat:o,ids:[n]})})),(0,a.iw)("rescheduleMessage",((e,t,s)=>{const{chatId:a,messageId:n,scheduledAt:o}=s,i=(0,y.Z1J)(e,a),r=i&&(0,y.TmO)(e,i.id,n);i&&r&&(0,I.t9)("rescheduleMessage",{chat:i,message:r,scheduledAt:o})})),(0,a.iw)("transcribeAudio",(async(e,t,s)=>{const{messageId:n,chatId:o}=s,i=(0,y.Z1J)(e,o);if(!i)return;e=(0,w.cY)(e,o,n,{transcriptionId:""}),(0,a.R3)(e);const r=await(0,I.t9)("transcribeAudio",{chat:i,messageId:n});e=(0,a.Rd)(),e=(0,w.cY)(e,o,n,{transcriptionId:r,isTranscriptionError:!r}),(0,a.R3)(e)})),(0,a.iw)("loadCustomEmojis",(async(e,t,s)=>{const{ids:n,ignoreCache:o}=s,i=o?n:(0,h.Tw)(n.filter((t=>!e.customEmojis.byId[t]))),r=await(0,I.t9)("fetchCustomEmoji",{documentId:i});r&&(e=(0,a.Rd)(),e={...e,customEmojis:{...e.customEmojis,byId:{...e.customEmojis.byId,...(0,h.ee)(r,"id")}}},(0,a.R3)(e))})),(0,a.iw)("loadPinnedMessages",(async(e,t,s)=>{const{chatId:n,threadId:o}=s,i=(0,y.Z1J)(e,n);if(!i||(0,v._o)(n,o,e.currentUserId))return;const r=await(0,I.t9)("fetchPinnedMessages",{chat:i,threadId:o});if(!r)return;const{messages:c,chats:d,users:l}=r,u=(0,h.ee)(c,"id"),m=Object.keys(u).map(Number).sort(((e,t)=>t-e));e=(0,a.Rd)(),e=(0,w.c_)(e,i.id,u),e=(0,w.HX)(e,i.id,o,m),e=(0,w.Sh)(e,(0,h.ee)(l,"id")),e=(0,w.fZ)(e,(0,h.ee)(d,"id")),(0,a.R3)(e)})),(0,a.iw)("loadSeenBy",(async(e,t,s)=>{const{chatId:n,messageId:o}=s,i=(0,y.Z1J)(e,n);if(!i)return;const r=await(0,I.t9)("fetchSeenBy",{chat:i,messageId:o});r&&(e=(0,a.Rd)(),e=(0,w.cY)(e,n,o,{seenByDates:r}),(0,a.R3)(e))})),(0,a.iw)("saveDefaultSendAs",((e,t,s)=>{const{chatId:a,sendAsId:n}=s,o=(0,y.Z1J)(e,a),i=(0,y.Z1J)(e,n)||(0,y.dyD)(e,n);if(o&&i)return(0,I.t9)("saveDefaultSendAs",{sendAs:i,chat:o}),(0,w.US)(e,a,{sendAsId:n})})),(0,a.iw)("loadSendAs",(async(e,t,s)=>{const{chatId:n}=s,o=(0,y.Z1J)(e,n);if(!o)return;const i=await(0,I.t9)("fetchSendAs",{chat:o});if(!i)return e=(0,a.Rd)(),e=(0,w.a4)(e,n,{sendAsPeerIds:[]}),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(i.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(i.chats,"id")),e=(0,w.a4)(e,n,{sendAsPeerIds:i.sendAs}),(0,a.R3)(e)})),(0,a.iw)("loadSponsoredMessages",(async(e,t,s)=>{const{chatId:n}=s,o=(0,y.Z1J)(e,n);if(!o)return;const i=await(0,I.t9)("fetchSponsoredMessages",{chat:o});i&&(e=(0,a.Rd)(),e=(0,w.Fn)(e,n,i.messages[0]),e=(0,w.Sh)(e,(0,h.ee)(i.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(i.chats,"id")),(0,a.R3)(e))})),(0,a.iw)("viewSponsoredMessage",((e,t,s)=>{const{chatId:a}=s,n=(0,y.Z1J)(e,a),o=(0,y.fSe)(e,a);n&&o&&(0,I.t9)("viewSponsoredMessage",{chat:n,random:o.randomId})})),(0,a.iw)("clickSponsoredMessage",((e,t,s)=>{const{chatId:a}=s,n=(0,y.Z1J)(e,a),o=(0,y.fSe)(e,a);n&&o&&(0,I.t9)("clickSponsoredMessage",{chat:n,random:o.randomId})})),(0,a.iw)("fetchUnreadMentions",(async(e,t,s)=>{const{chatId:n,offsetId:o}=s,i=(0,y.Z1J)(e,n);if(!i)return;const r=await(0,I.t9)("fetchUnreadMentions",{chat:i,offsetId:o});if(!r)return;const{messages:c,chats:d,users:l}=r,u=(0,h.ee)(c,"id"),m=Object.keys(u).map(Number);e=(0,a.Rd)(),e=(0,w.c_)(e,i.id,u),e=(0,w.Sh)(e,(0,h.ee)(l,"id")),e=(0,w.fZ)(e,(0,h.ee)(d,"id")),e=(0,w.a4)(e,n,{unreadMentions:[...i.unreadMentions||[],...m]}),(0,a.R3)(e)})),(0,a.iw)("markMentionsRead",((e,t,s)=>{const{messageIds:n,tabId:o=(0,m._w)()}=s,i=(0,y.jrE)(e,o);if(!i)return;const r=(i.unreadMentions||[]).filter((e=>!n.includes(e)));e=(0,w.a4)(e,i.id,{unreadMentions:r}),(0,a.R3)(e),t.markMessagesRead({messageIds:n,tabId:o})})),(0,a.iw)("focusNextMention",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jrE)(e,a);n?.unreadMentions&&t.focusMessage({chatId:n.id,messageId:n.unreadMentions[0],tabId:a})})),(0,a.iw)("readAllMentions",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jrE)(e,a);if(n)return(0,I.t9)("readAllMentions",{chat:n}),(0,w.a4)(e,n.id,{unreadMentionsCount:void 0,unreadMentions:void 0})})),(0,a.iw)("openUrl",((e,t,s)=>{const{url:a,shouldSkipModal:o,tabId:i=(0,m._w)()}=s,r=(0,u.X)(a),c=Boolean((0,y.jUK)(e,i).storyViewer.peerId);if((0,l.I)(r))return c&&t.closeStoryViewer({tabId:i}),void t.openTelegramLink({url:a,tabId:i});const{appConfig:d,config:h}=e;if(d){const e=new URL(r);if(h?.autologinToken&&d.autologinDomains.includes(e.hostname))return e.searchParams.set("autologin_token",h.autologinToken),void window.open(e.href,"_blank","noopener");if(d.urlAuthDomains.includes(e.hostname))return c&&t.closeStoryViewer({tabId:i}),void t.requestLinkUrlAuth({url:a,tabId:i})}r.match(n.jL5)||o?window.open(r,"_blank","noopener"):t.toggleSafeLinkModal({url:r,tabId:i})})),(0,a.iw)("setForwardChatOrTopic",(async(e,t,s)=>{const{chatId:n,topicId:o,tabId:i=(0,m._w)()}=s;let c=(0,y.dyD)(e,n);if(c&&(0,y.Nm0)(e,i)){let s=(0,y.ccz)(e,n);if(!s){const{accessHash:t}=c,o=await(0,I.t9)("fetchFullUser",{id:n,accessHash:t});e=(0,a.Rd)(),c=o?.user,s=o?.fullInfo}if(s.noVoiceMessages)return void t.showDialog({data:{message:(0,p.Iu)("VoiceMessagesRestrictedByPrivacy",(0,v.Js)(c))},tabId:i})}(0,y.GQU)(e,n,i)?(e=(0,b.i)(e,{forwardMessages:{...(0,y.jUK)(e,i).forwardMessages,toChatId:n,toThreadId:o,isModalShown:!1}},i),(0,a.R3)(e),t.openThread({chatId:n,threadId:o||r._f,tabId:i}),t.closeMediaViewer({tabId:i}),t.exitMessageSelectMode({tabId:i})):t.showAllowedMessageTypesNotification({chatId:n,tabId:i})})),(0,a.iw)("forwardToSavedMessages",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{};e=(0,b.i)(e,{forwardMessages:{...(0,y.jUK)(e,n).forwardMessages,toChatId:e.currentUserId}},n),(0,a.R3)(e),t.exitMessageSelectMode({tabId:n}),t.forwardMessages({isSilent:!0,tabId:n})})),(0,a.iw)("forwardStory",((e,t,s)=>{const{toChatId:n,tabId:o=(0,m._w)()}=s||{},{fromChatId:i,storyId:r}=(0,y.jUK)(e,o).forwardMessages,c=i?(0,y.Z1J)(e,i):void 0,d=n?(0,y.Z1J)(e,n):void 0,l=i&&r?(0,y.JrV)(e,i,r):void 0;if(!c||!d||!l||"isDeleted"in l)return;const u=(0,y.xMv)(e,n),{text:h,entities:p}=l.content.text||{};Y(e,{chat:d,text:h,entities:p,story:l,lastMessageId:u}),e=(0,a.Rd)(),e=(0,b.i)(e,{forwardMessages:{}},o),(0,a.R3)(e)})),(0,a.iw)("requestMessageTranslation",((e,t,s)=>{const{chatId:a,id:n,toLanguageCode:o=(0,y.Mc4)(e),tabId:i=(0,m._w)()}=s;return e=(0,w.ql)(e,a,n,o,i),(0,w.BI)(e,{translationLanguage:o})})),(0,a.iw)("showOriginalMessage",((e,t,s)=>{const{chatId:a,id:n,tabId:o=(0,m._w)()}=s;return(0,w.IR)(e,a,n,o)})),(0,a.iw)("markMessagesTranslationPending",((e,t,s)=>{const{chatId:a,messageIds:n,toLanguageCode:o=(0,y.rB0)(e)}=s;return n.forEach((t=>{e=(0,w.qt)(e,a,t,o,{isPending:!0})})),e})),(0,a.iw)("translateMessages",((e,t,s)=>{const{chatId:a,messageIds:n,toLanguageCode:o=(0,y.rB0)(e)}=s,i=(0,y.Z1J)(e,a);if(i)return t.markMessagesTranslationPending({chatId:a,messageIds:n,toLanguageCode:o}),(0,I.t9)("translateText",{chat:i,messageIds:n,toLanguageCode:o}),e}));let X,Q={};function ee(){X&&(clearTimeout(X),X=void 0);const{loadMessageViews:e}=(0,a.Sv)();Object.entries(Q).forEach((([t,s])=>{e({chatId:t,ids:Array.from(s),shouldIncrement:!0})})),Q={}}function te(e){const{shouldSendAsFile:t,mimeType:s}=e;return t?"file":s===n.s11?"gif":n.oGt.has(s)||n.wGh.has(s)?"media":n.e74.has(s)?"audio":e.voice?"voice":"file"}(0,a.iw)("scheduleForViewsIncrement",((e,t,s)=>{const{ids:a,chatId:n}=s;X||setTimeout(ee,1e3),Q[n]||(Q[n]=new Set),a.forEach((e=>{Q[n].add(e)}))})),(0,a.iw)("loadMessageViews",(async(e,t,s)=>{const{chatId:n,ids:o,shouldIncrement:i}=s,r=(0,y.Z1J)(e,n);if(!r)return;const c=await(0,I.t9)("fetchMessageViews",{chat:r,ids:o,shouldIncrement:i});c&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(c.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(c.chats,"id")),c.viewsInfo.forEach((t=>{e=(0,w.cY)(e,n,t.id,{viewsCount:t.views,forwardsCount:t.forwards}),t.threadInfo&&(e=(0,w.Xg)(e,n,t.id,t.threadInfo))})),(0,a.R3)(e))})),(0,a.iw)("loadOutboxReadDate",(async(e,t,s)=>{const{chatId:n,messageId:o}=s,i=(0,y.Z1J)(e,n);if(i)try{const t=await(0,I.t9)("fetchOutboxReadDate",{chat:i,messageId:o});t?.date&&(e=(0,a.Rd)(),e=(0,w.cY)(e,n,o,{readDate:t.date}),(0,a.R3)(e))}catch(t){const{message:s}=t;if("USER_PRIVACY_RESTRICTED"===s||"YOUR_PRIVACY_RESTRICTED"===s){if(e=(0,a.Rd)(),!(0,y.dyD)(e,n))return;const t=(0,y.ssc)(e,n);if(!t)return;const i="USER_PRIVACY_RESTRICTED"===s?{isReadDateRestricted:!0}:{isReadDateRestrictedByMe:!0};e=(0,w.ps)(e,{[n]:{...t,...i}}),e=(0,w.cY)(e,n,o,{readDate:void 0}),(0,a.R3)(e)}}})),(0,a.iw)("copyMessageLink",(async(e,t,s)=>{const{chatId:a,messageId:n,shouldIncludeThread:o,shouldIncludeGrouped:i,tabId:r=(0,m._w)()}=s,c=(0,y.Z1J)(e,a);if(!c)return void t.showNotification({message:(0,p.Iu)("ErrorOccurred"),tabId:r});if(!(0,v.eA)(c)&&!(0,v.ZV)(c))return void t.showNotification({message:(0,p.Iu)("lng_filters_link_private_error"),tabId:r});const l=await(0,I.t9)("exportMessageLink",{chat:c,id:n,shouldIncludeThread:o,shouldIncludeGrouped:i});l?((0,d.TE)(l),t.showNotification({message:(0,p.Iu)("LinkCopied"),tabId:r})):t.showNotification({message:(0,p.Iu)("ErrorOccurred"),tabId:r})}));var se=s(85765),ae=s(9211);const ne=(0,f.P2)((e=>e()),500,!1);async function oe(e,t){const s=await(0,I.t9)("fetchRecentStickers",{hash:t});s&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,recent:s}},(0,a.R3)(e))}async function ie(e,t,s,...[n=(0,m._w)()]){let o;try{o=await(0,I.t9)("fetchStickers",{stickerSetInfo:s})}catch(o){if("STICKERSET_INVALID"===o.message)return t.showNotification({message:(0,p.Iu)("StickerPack.ErrorNotFound"),tabId:n}),void("shortName"in s&&(0,y.jUK)(e,n).openedStickerSetShortName===s.shortName&&(e=(0,b.i)(e,{openedStickerSetShortName:void 0},n),(0,a.R3)(e)))}if(e=(0,a.Rd)(),!o)return;const{set:i,stickers:r,packs:c}=o,d=(e=(0,w.Rg)(e,i.id,{...i,stickers:r,packs:c})).stickers.forEmoji.emoji;d&&c[d]&&(e=(0,w.vy)(e)),(0,a.R3)(e)}async function re(e,t,s,n,...[o=(0,m._w)()]){const i=await(0,I.t9)("searchGifs",{query:t,offset:n,username:s});i&&(e=(0,a.Rd)(),e=(0,w.rq)(e,!n,i.gifs,i.nextOffset,o),(0,a.R3)(e))}(0,a.iw)("loadStickerSets",(async(e,t)=>{const[s,n]=await Promise.all([(0,I.t9)("fetchStickerSets",{hash:e.stickers.added.hash}),(0,I.t9)("fetchCustomEmojiSets",{hash:e.customEmojis.added.hash})]);n&&s&&(e=(0,a.Rd)(),e=(0,w.z3)(e,"added",s.hash,s.sets),e=(0,w.cU)(e,n.hash,n.sets),(0,a.R3)(e),t.loadCustomEmojis({ids:e.recentCustomEmojis}))})),(0,a.iw)("loadAddedStickers",(async(e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{added:{setIds:n=[]},setsById:o}=e.stickers,{added:{setIds:i=[]}}=e.customEmojis,r=[...n,...i];if(r.length)for(let e=0;e<r.length;e++){const s=r[e];o[s]?.stickers||(t.loadStickers({stickerSetInfo:{id:s,accessHash:o[s].accessHash},tabId:a}),e%10==0&&e>0&&await(0,f.wO)(200))}})),(0,a.iw)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};oe(e,t)})),(0,a.iw)("loadFavoriteStickers",(async e=>{const{hash:t}=e.stickers.favorite||{},s=await(0,I.t9)("fetchFavoriteStickers",{hash:t});s&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,favorite:s}},(0,a.R3)(e))})),(0,a.iw)("loadPremiumStickers",(async e=>{const{hash:t}=e.stickers.premium||{},s=await(0,I.t9)("fetchStickersForEmoji",{emoji:"⭐️⭐️",hash:t});s&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,premium:{hash:s.hash,stickers:s.stickers}}},(0,a.R3)(e))})),(0,a.iw)("loadGreetingStickers",(async e=>{const{hash:t}=e.stickers.greeting||{},s=await(0,I.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});s&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,greeting:{hash:s.hash,stickers:s.stickers.filter((e=>"👋"===e.emoji))}}},(0,a.R3)(e))})),(0,a.iw)("loadFeaturedStickers",(async e=>{const{hash:t}=e.stickers.featured||{},s=await(0,I.t9)("fetchFeaturedStickers",{hash:t});s&&(e=(0,a.Rd)(),e=(0,w.z3)(e,"featured",s.hash,s.sets),(0,a.R3)(e))})),(0,a.iw)("loadPremiumGifts",(async e=>{const t=await(0,I.t9)("fetchPremiumGifts");if(!t)return;const{set:s,stickers:n}=t;e=(0,a.Rd)(),e={...e,premiumGifts:{...s,stickers:n}},(0,a.R3)(e)})),(0,a.iw)("loadDefaultTopicIcons",(async e=>{const t=await(0,I.t9)("fetchDefaultTopicIcons");if(!t)return;e=(0,a.Rd)();const{set:s,stickers:n}=t,o={...s,stickers:n};e=(0,w.Rg)(e,o.id,o),e={...e,defaultTopicIconsId:o.id},(0,a.R3)(e)})),(0,a.iw)("loadDefaultStatusIcons",(async e=>{const t=await(0,I.t9)("fetchDefaultStatusEmojis");if(!t)return;e=(0,a.Rd)();const{set:s,stickers:n}=t,o={...s,stickers:n};e=(0,w.Rg)(e,o.id,o),e={...e,defaultStatusIconsId:o.id},(0,a.R3)(e)})),(0,a.iw)("loadStickers",((e,t,s)=>{const{stickerSetInfo:a,tabId:n=(0,m._w)()}=s,o=(0,y.Ny0)(e,a);o&&o.count===o?.stickers?.length||ie(e,t,a,n)})),(0,a.iw)("loadAnimatedEmojis",(async e=>{const[t,s]=await Promise.all([(0,I.t9)("fetchAnimatedEmojis"),(0,I.t9)("fetchAnimatedEmojiEffects")]);t&&s&&(e=(0,a.Rd)(),e=(0,w.g_)(e,{...t.set,stickers:t.stickers}),e={...e,animatedEmojiEffects:{...s.set,stickers:s.stickers}},(0,a.R3)(e))})),(0,a.iw)("loadGenericEmojiEffects",(async e=>{const t=await(0,I.t9)("fetchGenericEmojiEffects");if(!t)return;e=(0,a.Rd)();const{set:s,stickers:n}=t;e={...e,genericEmojiEffects:{...s,stickers:n}},(0,a.R3)(e)})),(0,a.iw)("loadSavedGifs",(async e=>{const{hash:t}=e.gifs.saved,s=await(0,I.t9)("fetchSavedGifs",{hash:t});s&&(e=(0,a.Rd)(),e={...e,gifs:{...e.gifs,saved:s}},(0,a.R3)(e))})),(0,a.iw)("saveGif",(async(e,t,s)=>{const{gif:n,shouldUnsave:o,tabId:i=(0,m._w)()}=s,r=e.gifs.saved.gifs?.length,c=(0,ae.M)(e,"savedGifs"),d=(0,ae.P)(e,"savedGifs"),l=(0,y.wVz)(e);if(!o&&r&&r>=c&&t.showNotification({title:p.Iu("LimitReachedFavoriteGifs",c.toString()),message:l?p.Iu("LimitReachedFavoriteGifsSubtitlePremium"):p.Iu("LimitReachedFavoriteGifsSubtitle",d.toString()),...!l&&{action:{action:"openPremiumModal",payload:{tabId:i}}},className:"bold-link",tabId:i}),!await(0,I.t9)("saveGif",{gif:n,shouldUnsave:o}))return;e=(0,a.Rd)();const u=e.gifs.saved.gifs?.filter((({id:e})=>e!==n.id))||[],h=o?u:[n,...u];e={...e,gifs:{...e.gifs,saved:{...e.gifs.saved,gifs:h}}},(0,a.R3)(e)})),(0,a.iw)("faveSticker",((e,t,s)=>{const{sticker:a,tabId:n=(0,m._w)()}=s,o=e.stickers.favorite.stickers.length,i=(0,ae.M)(e,"stickersFaved"),r=(0,ae.P)(e,"stickersFaved"),c=(0,y.wVz)(e);o>=i&&t.showNotification({title:p.Iu("LimitReachedFavoriteStickers",i.toString()),message:c?p.Iu("LimitReachedFavoriteStickersSubtitlePremium"):p.Iu("LimitReachedFavoriteStickersSubtitle",r.toString()),...!c&&{action:{action:"openPremiumModal",payload:{tabId:n}}},className:"bold-link",tabId:n}),a&&(0,I.t9)("faveSticker",{sticker:a})})),(0,a.iw)("unfaveSticker",((e,t,s)=>{const{sticker:n}=s;n&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,favorite:{...e.stickers.favorite,stickers:e.stickers.favorite.stickers.filter((({id:e})=>e!==n.id))}}},(0,a.R3)(e),(0,I.t9)("faveSticker",{sticker:n,unfave:!0}))})),(0,a.iw)("removeRecentSticker",(async(e,t,s)=>{const{sticker:n}=s;await(0,I.t9)("removeRecentSticker",{sticker:n})&&oe((0,a.Rd)())})),(0,a.iw)("clearRecentStickers",(async e=>{await(0,I.t9)("clearRecentStickers")&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,recent:{stickers:[]}}},(0,a.R3)(e))})),(0,a.iw)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:a}=s,n=(0,y.Ny0)(e,a);if(!n)return;const{accessHash:o,installedDate:i,isArchived:r}=n,c=!r&&Boolean(i);(0,I.t9)(c?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.iw)("loadEmojiKeywords",(async(e,t,s)=>{const{language:n}=s;let o=e.emojiKeywords[n];if(o?.isLoading)return;e={...e,emojiKeywords:{...e.emojiKeywords,[n]:{...o,isLoading:!0}}},(0,a.R3)(e);const i=await(0,I.t9)("fetchEmojiKeywords",{language:n,fromVersion:o?o.version:0});if(o=(e=(0,a.Rd)()).emojiKeywords[n],!i)return e={...e,emojiKeywords:{...e.emojiKeywords,[n]:{...o,isLoading:!1}}},void(0,a.R3)(e);e={...e,emojiKeywords:{...e.emojiKeywords,[n]:{isLoading:!1,version:i.version,keywords:{...o?.keywords,...i.keywords}}}},(0,a.R3)(e)})),(0,a.iw)("setStickerSearchQuery",((e,t,s)=>{const{query:n,tabId:o=(0,m._w)()}=s;n&&ne((async()=>{const t=await(0,I.t9)("searchStickers",{query:n});if(!t)return;e=(0,a.Rd)();const{setsById:s,added:i}=e.stickers,r=t.sets.map((({id:e})=>e));i.setIds&&i.setIds.forEach((e=>{if(!r.includes(e)){const{title:t}=s[e]||{};t&&(0,se.Z)(t,n)&&r.unshift(e)}})),e=(0,w.z3)(e,"search",t.hash,t.sets),e=(0,w.fH)(e,t.hash,r,o),(0,a.R3)(e)}))})),(0,a.iw)("setGifSearchQuery",((e,t,s)=>{const{query:n,tabId:o=(0,m._w)()}=s;"string"==typeof n&&ne((()=>{re(e=(0,a.Rd)(),n,e.config?.gifSearchUsername,void 0,o)}))})),(0,a.iw)("searchMoreGifs",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{},{query:o,offset:i}=(0,y.jUK)(e,n).gifSearch;"string"==typeof o&&ne((()=>{re(e=(0,a.Rd)(),o,e.config?.gifSearchUsername,i,n)}))})),(0,a.iw)("loadStickersForEmoji",((e,t,s)=>{const{emoji:n}=s,{hash:o}=e.stickers.forEmoji;ne((async()=>{e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,forEmoji:{...e.stickers.forEmoji,emoji:n}}},(0,a.R3)(e);const t=await(0,I.t9)("fetchStickersForEmoji",{emoji:n,hash:o});e=(0,a.Rd)(),t&&e.stickers.forEmoji.emoji===n&&(e=(0,w.IM)(e,n,t.stickers,t.hash),(0,a.R3)(e))}))})),(0,a.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.iw)("loadCustomEmojiForEmoji",((e,t,s)=>{const{emoji:a}=s;return(0,w.AA)(e,a)})),(0,a.iw)("clearCustomEmojiForEmoji",(e=>({...e,customEmojis:{...e.customEmojis,forEmoji:{}}}))),(0,a.iw)("loadFeaturedEmojiStickers",(async e=>{const t=await(0,I.t9)("fetchFeaturedEmojiStickers");t&&(e=(0,a.Rd)(),e={...e,customEmojis:{...e.customEmojis,featuredIds:t.sets.map((({id:e})=>e)),byId:{...e.customEmojis.byId,...(0,h.ee)(t.sets.flatMap((e=>e.stickers||[])),"id")}},stickers:{...e.stickers,setsById:{...e.stickers.setsById,...(0,h.ee)(t.sets,"id")}}},(0,a.R3)(e))})),(0,a.iw)("openStickerSet",(async(e,t,s)=>{const{stickerSetInfo:n,tabId:o=(0,m._w)()}=s;(0,y.Ny0)(e,n)||await ie(e,t,n,o),e=(0,a.Rd)();const i=(0,y.Ny0)(e,n);i?.shortName&&(e=(0,b.i)(e,{openedStickerSetShortName:i.shortName},o),(0,a.R3)(e))})),(0,a.iw)("loadRecentEmojiStatuses",(async e=>{const t=await(0,I.t9)("fetchRecentEmojiStatuses");t&&(e=(0,a.Rd)(),e=(0,w.et)(e,t.hash,t.emojiStatuses),(0,a.R3)(e))}));var ce=s(790),de=s(22825);const le=(0,f.P2)((e=>e()),500,!1);async function ue(e,t="",s,o,i,r,c,...[d=(0,m._w)()]){let u,p;if(i){const e=(0,I.t9)("searchMessagesLocal",{chat:i,query:t,type:s,limit:n.Hkl,offsetId:o,minDate:c,maxDate:r}),a=i.isForum?(0,I.t9)("fetchTopics",{chat:i,query:t,limit:n.XM3}):void 0,[d,l]=await Promise.all([e,a]);if(d){const{messages:e,users:t,totalCount:s,nextOffsetId:a}=d,{topics:n,count:o}=l||{};u={topics:n,totalTopicsCount:o,messages:e,users:t,chats:[],totalCount:s,nextRate:a}}}else if(u=await(0,I.t9)("searchMessagesGlobal",{query:t,offsetRate:o,limit:n.Hkl,type:s,maxDate:r,minDate:c}),(0,l.I)(t)){const s=(0,l.E)(t);"publicMessageLink"===s?.type?p=await async function(e,t){const{username:s,messageId:a}=t,n=(0,y.DIA)(e,s);if(n)return me(e,n,a);const{chat:o}=await(0,I.t9)("getChatByUsername",s)??{};return o?me(e,o,a):void 0}(e,s):"privateMessageLink"===s?.type&&(p=await function(e,t){const{channelId:s,messageId:a}=t,n=(0,de.Yg)(s),o=(0,y.Z1J)(e,n);if(o)return me(e,o,a)}(e,s))}e=(0,a.Rd)();const g=(0,y.JXM)(e,d);if(!u||""!==t&&t!==g)return e=(0,w.xv)(e,{messages:!1},d),void(0,a.R3)(e);p&&(u.totalCount=u.messages.unshift(p));const{messages:f,users:v,chats:b,totalCount:P,nextRate:Z}=u;b.length&&(e=(0,w.fZ)(e,(0,h.ee)(b,"id"))),v.length&&(e=(0,w.Sh)(e,(0,h.ee)(v,"id"))),f.length&&(e=(0,w.m6)(e,f)),e=(0,w.px)(e,f,P,s,Z,d),u.topics&&(e=(0,w.XG)(e,i.id,u.totalTopicsCount,u.topics));const S=u.topics?.map((({id:e})=>e)).sort(((e,t)=>t-e));e=(0,w.No)(e,{foundTopicIds:S},d),(0,a.R3)(e)}async function me(e,t,s){if(!(0,de.Bf)(t)&&!(0,de.eA)(t))return;const a=(0,y.hjO)(e,t.id,s);if(a)return a;const n=await(0,I.t9)("fetchMessage",{chat:t,messageId:s});return"MESSAGE_DELETED"===n?void 0:n?.message}async function he(e,t,s,o,i,r=!1,c,...[d=(0,m._w)()]){const l=c?e.currentUserId:t.id,u=await(0,I.t9)("searchMessagesLocal",{chat:t,type:o,limit:2*n.ENB,threadId:s,offsetId:i,isSavedDialog:c});if(!u)return;const{chats:p,users:g,messages:f,totalCount:v,nextOffsetId:b}=u,P=(0,h.ee)(f,"id"),Z=Object.keys(P).map(Number);e=(0,a.Rd)(),(0,y.weG)(e,d)&&(e=(0,w.fZ)(e,(0,h.ee)(p,"id")),e=(0,w.Sh)(e,(0,h.ee)(g,"id")),e=(0,w.c_)(e,l,P),e=(0,w.c1)(e,l,s,o,Z,v,b,d),(0,a.R3)(e),r||he(e,t,s,o,b,!0,c,d))}(0,a.iw)("setGlobalSearchQuery",((e,t,s)=>{const{query:n,tabId:o=(0,m._w)()}=s,{chatId:i}=(0,y.jUK)(e,o).globalSearch;n&&!i&&le((async()=>{const t=await(0,I.t9)("searchChats",{query:n});e=(0,a.Rd)();const s=(0,y.JXM)(e,o);if(!t||!s||n!==s)return e=(0,w.xv)(e,{chats:!1},o),void(0,a.R3)(e);const{accountChats:i,accountUsers:r,globalChats:c,globalUsers:d}=t;(i.length||c.length)&&(e=(0,w.fZ)(e,(0,h.ee)([...i,...c],"id"))),(r.length||d.length)&&(e=(0,w.Sh)(e,(0,h.ee)([...r,...d],"id"))),e=(0,w.xv)(e,{chats:!1},o),e=(0,w.No)(e,{localResults:{chatIds:i.map((({id:e})=>e)),userIds:i.map((({id:e})=>e))},globalResults:{...(0,y.jUK)(e,o).globalSearch.globalResults,chatIds:c.map((({id:e})=>e)),userIds:d.map((({id:e})=>e))}},o),(0,a.R3)(e)}))})),(0,a.iw)("setGlobalSearchDate",((e,t,s)=>{const{date:n,tabId:o=(0,m._w)()}=s,i=n?(0,ce.IS)(n):n;e=(0,w.No)(e,{date:n,query:"",resultsByType:{...(0,y.jUK)(e,o).globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}},o),(0,a.R3)(e);const{chatId:r}=(0,y.jUK)(e,o).globalSearch;ue(e,"","text",void 0,r?(0,y.Z1J)(e,r):void 0,i,n,o)})),(0,a.iw)("searchMessagesGlobal",((e,t,s)=>{const{type:a,tabId:n=(0,m._w)()}=s,{query:o,resultsByType:i,chatId:r,date:c}=(0,y.jUK)(e,n).globalSearch,d=c?(0,ce.IS)(c):c,l=i?.[a]?.nextOffsetId;ue(e,o,a,l,r?(0,y.Z1J)(e,r):void 0,d,c,n)})),(0,a.iw)("searchTextMessagesLocal",(async(e,t,s)=>{const{tabId:o=(0,m._w)()}=s||{},{chatId:i,threadId:r}=(0,y.Btg)(e,o)||{};if(!i)return;const c=e.currentUserId,d=(0,v._o)(i,r,c),l=d?String(r):i,u=l?(0,y.Z1J)(e,l):void 0;let p=(0,y.n5x)(e,o);if(!u||!r||!p)return;const{query:g,results:f,savedTag:b}=p,P=f?.nextOffsetId;if(!g&&!b)return;const Z=await(0,I.t9)("searchMessagesLocal",{chat:u,type:"text",query:g,threadId:r,limit:n.pnA,offsetId:P,isSavedDialog:d,savedTag:b});if(!Z)return;const{chats:S,users:C,messages:M,totalCount:E,nextOffsetId:R}=Z,k=(0,h.ee)(M,"id"),T=Object.keys(k).map(Number);e=(0,a.Rd)(),p=(0,y.n5x)(e,o);const N=!(0,v.Hl)(b,p?.savedTag);if(!p||g!==p.query||N)return;const A=d?c:u.id;e=(0,w.fZ)(e,(0,h.ee)(S,"id")),e=(0,w.Sh)(e,(0,h.ee)(C,"id")),e=(0,w.c_)(e,A,k),e=(0,w.dx)(e,A,r,T,E,R,o),(0,a.R3)(e)})),(0,a.iw)("searchMediaMessagesLocal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{chatId:n,threadId:o}=(0,y.Btg)(e,a)||{};if(!n||!o)return;const i=(0,v._o)(n,o,e.currentUserId),r=i?String(o):n,c=(0,y.Z1J)(e,r),d=(0,y.weG)(e,a);if(!c||!d)return;const{currentType:l,resultsByType:u}=d,h=l&&u&&u[l],p=h?.nextOffsetId;l&&he(e,c,o,l,p,void 0,i,a)})),(0,a.iw)("searchMessagesByDate",(async(e,t,s)=>{const{timestamp:a,tabId:n=(0,m._w)()}=s,{chatId:o}=(0,y.Btg)(e,n)||{};if(!o)return;const i=(0,y.Z1J)(e,o);if(!i)return;const r=await(0,I.t9)("findFirstMessageIdAfterDate",{chat:i,timestamp:a});r&&t.focusMessage({chatId:i.id,messageId:r,tabId:n})})),(0,a.iw)("checkPublicLink",(async(e,t,s)=>{const{username:n,tabId:o=(0,m._w)()}=s,{chatId:i}=(0,y.Btg)(e,o)||{};if(!i)return;if((0,y.jUK)(e,o).management.progress===c.wv.InProgress)return;e=(0,w.fw)(e,i,{isUsernameAvailable:void 0,checkedUsername:void 0},o),(0,a.R3)(e);const{result:r,error:d}=await(0,I.t9)("checkChatUsername",{username:n});e=(0,a.Rd)(),e=(0,w.H9)(e,!0===r?c.wv.Complete:c.wv.Error,o),e=(0,w.fw)(e,i,{isUsernameAvailable:!0===r,checkedUsername:n,error:d},o),(0,a.R3)(e),void 0===r&&t.openLimitReachedModal({limit:"channelsPublic",tabId:o})})),(0,a.iw)("updatePublicLink",(async(e,t,s)=>{const{username:n,shouldDisableUsernames:o,tabId:r=(0,m._w)()}=s,{chatId:d}=(0,y.Btg)(e,r)||{};if(!d)return;const l=await(0,i.X9)(e,t,d,r);if(!l)return;e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.InProgress,r),(0,a.R3)(e);const u=await(0,I.t9)("setChatUsername",{chat:l,username:n});o&&await(0,I.t9)("deactivateAllUsernames",{chat:l}),e=(0,a.Rd)(),e=(0,w.H9)(e,u?c.wv.Complete:c.wv.Error,r),e=(0,w.fw)(e,l.id,{isUsernameAvailable:void 0,checkedUsername:void 0,error:void 0},r),(0,a.R3)(e)})),(0,a.iw)("updatePrivateLink",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{chatId:n}=(0,y.Btg)(e,a)||{},o=n&&(0,y.Z1J)(e,n);n&&o&&(0,I.t9)("updatePrivateLink",{chat:o})})),(0,a.iw)("setEditingExportedInvite",((e,t,s)=>{const{chatId:n,invite:o,tabId:i=(0,m._w)()}=s;e=(0,w.fw)(e,n,{editingInvite:o},i),(0,a.R3)(e)})),(0,a.iw)("setOpenedInviteInfo",((e,t,s)=>{const{chatId:n,invite:o,tabId:i=(0,m._w)()}=s,r=o?{inviteInfo:{invite:o}}:{inviteInfo:void 0};e=(0,w.fw)(e,n,r,i),(0,a.R3)(e)})),(0,a.iw)("loadExportedChatInvites",(async(e,t,s)=>{const{chatId:n,adminId:o,isRevoked:i,limit:r,tabId:c=(0,m._w)()}=s,d=(0,y.Z1J)(e,n),l=(0,y.dyD)(e,o||e.currentUserId);if(!d||!l)return;const u=await(0,I.t9)("fetchExportedChatInvites",{peer:d,admin:l,isRevoked:i,limit:r});if(!u)return;e=(0,a.Rd)();const{invites:p,users:g}=u;e=(0,w.Sh)(e,(0,h.ee)(g,"id"));const f=i?{revokedInvites:p}:{invites:p};e=(0,w.fw)(e,n,f,c),(0,a.R3)(e)})),(0,a.iw)("editExportedChatInvite",(async(e,t,s)=>{const{chatId:n,link:o,isRevoked:i,expireDate:r,usageLimit:c,isRequestNeeded:d,title:l,tabId:u=(0,m._w)()}=s,p=(0,y.Z1J)(e,n);if(!p)return;const g=await(0,I.t9)("editExportedChatInvite",{peer:p,link:o,isRevoked:i,expireDate:r,usageLimit:c,isRequestNeeded:d,title:l});if(!g)return;const{oldInvite:f,newInvite:v,users:b}=g;e=(0,a.Rd)();const{management:P}=(0,y.jUK)(e,u),Z=(P.byChatId[n].invites||[]).filter((e=>e.link!==f.link)),S=[...P.byChatId[n].revokedInvites||[]];v.isRevoked?S.unshift(v):Z.push(v),e=(0,w.Sh)(e,(0,h.ee)(b,"id")),e=(0,w.fw)(e,n,{invites:Z,revokedInvites:S},u),(0,a.R3)(e)})),(0,a.iw)("exportChatInvite",(async(e,t,s)=>{const{chatId:n,expireDate:o,usageLimit:i,isRequestNeeded:r,title:c,tabId:d=(0,m._w)()}=s,l=(0,y.Z1J)(e,n);if(!l)return;const u=await(0,I.t9)("exportChatInvite",{peer:l,expireDate:o,usageLimit:i,isRequestNeeded:r,title:c});if(!u)return;e=(0,a.Rd)();const h=(0,y.jUK)(e,d).management.byChatId[n].invites||[];e=(0,w.fw)(e,n,{invites:[...h,u]},d),(0,a.R3)(e)})),(0,a.iw)("deleteExportedChatInvite",(async(e,t,s)=>{const{chatId:n,link:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n);if(!r)return;if(!await(0,I.t9)("deleteExportedChatInvite",{peer:r,link:o}))return;e=(0,a.Rd)();const c=(0,y.jUK)(e,i).management.byChatId[n];e=(0,w.fw)(e,n,{invites:c?.invites?.filter((e=>e.link!==o)),revokedInvites:c?.revokedInvites?.filter((e=>e.link!==o))},i),(0,a.R3)(e)})),(0,a.iw)("deleteRevokedExportedChatInvites",(async(e,t,s)=>{const{chatId:n,adminId:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n),c=(0,y.dyD)(e,o||e.currentUserId);r&&c&&await(0,I.t9)("deleteRevokedExportedChatInvites",{peer:r,admin:c})&&(e=(0,a.Rd)(),e=(0,w.fw)(e,n,{revokedInvites:[]},i),(0,a.R3)(e))})),(0,a.iw)("loadChatInviteImporters",(async(e,t,s)=>{const{chatId:n,link:o,offsetDate:i,offsetUserId:r,limit:c,tabId:d=(0,m._w)()}=s,l=(0,y.Z1J)(e,n),u=r?(0,y.dyD)(e,r):void 0;if(!l||r&&!u)return;const h=await(0,I.t9)("fetchChatInviteImporters",{peer:l,link:o,offsetDate:i,offsetUser:u,limit:c});if(!h)return;const{importers:p,users:g}=h;e=(0,a.Rd)();const f=(0,y.jUK)(e,d).management.byChatId[n]?.inviteInfo;f?.invite&&f.invite.link===o&&(e=(0,w.fw)(e,n,{inviteInfo:{...f,importers:p}},d),e=(0,w.Sh)(e,g),(0,a.R3)(e))})),(0,a.iw)("loadChatInviteRequesters",(async(e,t,s)=>{const{chatId:n,link:o,offsetDate:i,offsetUserId:r,limit:c,tabId:d=(0,m._w)()}=s,l=(0,y.Z1J)(e,n),u=r?(0,y.dyD)(e,r):void 0;if(!l||r&&!u)return;const h=await(0,I.t9)("fetchChatInviteImporters",{peer:l,link:o,offsetDate:i,offsetUser:u,limit:c,isRequested:!0});if(!h)return;const{importers:p,users:g}=h;e=(0,a.Rd)();const f=(0,y.jUK)(e,d).management.byChatId[n]?.inviteInfo;f?.invite&&f.invite.link===o&&(e=(0,w.fw)(e,n,{inviteInfo:{...f,requesters:p}},d),e=(0,w.Sh)(e,g),(0,a.R3)(e))})),(0,a.iw)("loadChatJoinRequests",(async(e,t,s)=>{const{chatId:n,offsetDate:o=0,offsetUserId:i,limit:r=0}=s,c=(0,y.Z1J)(e,n),d=i?(0,y.dyD)(e,i):void 0;if(!c||i&&!d)return;const l=await(0,I.t9)("fetchChatInviteImporters",{peer:c,offsetDate:o,offsetUser:d,limit:r,isRequested:!0});if(!l)return;const{importers:u,users:m}=l;e=(0,a.Rd)(),e=(0,w.a4)(e,n,{joinRequests:u}),e=(0,w.Sh)(e,m),(0,a.R3)(e)})),(0,a.iw)("hideChatJoinRequest",(async(e,t,s)=>{const{chatId:n,userId:o,isApproved:i}=s,r=(0,y.Z1J)(e,n),c=(0,y.dyD)(e,o);if(!r||!c)return;if(!await(0,I.t9)("hideChatJoinRequest",{peer:r,user:c,isApproved:i}))return;e=(0,a.Rd)();const d=(0,y.Z1J)(e,n);d&&(e=(0,w.a4)(e,n,{joinRequests:d.joinRequests?.filter((e=>e.userId!==o))}),(0,a.R3)(e))})),(0,a.iw)("hideAllChatJoinRequests",(async(e,t,s)=>{const{chatId:n,isApproved:o,link:i}=s,r=(0,y.Z1J)(e,n);r&&await(0,I.t9)("hideAllChatJoinRequests",{peer:r,isApproved:o,link:i})&&(e=(0,a.Rd)(),(0,y.Z1J)(e,n)&&(e=(0,w.a4)(e,n,{joinRequests:[]}),e=(0,w.US)(e,n,{recentRequesterIds:[],requestsPending:0}),(0,a.R3)(e)))})),(0,a.iw)("hideChatReportPanel",(async(e,t,s)=>{const{chatId:n}=s,o=(0,y.Z1J)(e,n);o&&await(0,I.t9)("hideChatReportPanel",o)&&(e=(0,a.Rd)(),e=(0,w.a4)(e,n,{settings:void 0}),(0,a.R3)(e))})),(0,a.iw)("uploadContactProfilePhoto",(async(e,t,s)=>{const{userId:n,file:o,isSuggest:i,tabId:r=(0,m._w)()}=s,d=(0,y.dyD)(e,n);if(!d)return;e=(0,w.H9)(e,c.wv.InProgress,r),(0,a.R3)(e);const l=await(0,I.t9)("uploadContactProfilePhoto",{user:d,file:o,isSuggest:i});if(!l)return e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.Error,r),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(l.users,"id")),(0,a.R3)(e);const{id:u,accessHash:g}=d;if(!await(0,I.t9)("fetchFullUser",{id:u,accessHash:g}))return e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.Error,r),void(0,a.R3)(e);t.loadProfilePhotos({profileId:n}),e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.Complete,r),(0,a.R3)(e),o&&!i&&t.showNotification({message:p.Iu("UserInfo.SetCustomPhoto.SuccessPhotoText",(0,v.Vl)(d)),tabId:r})})),(0,a.iw)("resetManagementError",((e,t,s)=>{const{chatId:a,tabId:n=(0,m._w)()}=s||{};return(0,w.fw)(e,a,{error:void 0},n)}));var pe=s(65116),ge=s(16974);let fe,Ie;function ve(e,t,s){const a=e.currentUserId,o=(0,v._o)(t,s,a),i=o?String(s):t,r=(0,y.Z1J)(e,i);return(0,I.t9)("fetchMessages",{chat:r,threadId:s,offsetId:o?void 0:r.lastReadInboxMessageId,addOffset:-(Math.round(n.hT6/2)+1),limit:n.hT6,isSavedDialog:o})}(0,a.iw)("sync",((e,t)=>{n.eMD&&console.log(">>> START SYNC"),fe&&clearTimeout(fe),e=(0,a.Rd)(),e={...e,isSyncing:!0},(0,a.R3)(e),fe=window.setTimeout((()=>{e=(0,a.Rd)(),e={...e,isSyncing:!1},(0,a.R3)(e),fe=void 0}),15e3);const{loadAllChats:s,preloadTopChatMessages:o,loadAllStories:i,loadAllHiddenStories:c}=t;s({listType:"active",shouldReplace:!0,onReplace:async()=>{await async function(e,t){let s=!1;e=(0,a.Rd)();let o=!1;const i=Object.keys(e.messages.byChatId).reduce(((t,s)=>(t[s]=Object.keys(e.messages.byChatId[s].threadsById).reduce(((t,a)=>(t[Number(a)]=(0,h.Yc)({draft:(0,y.Mst)(e,s,Number(a)),editingId:(0,y._$9)(e,s,Number(a)),editingDraft:(0,y.saH)(e,s,Number(a))}),t)),{}),t)),{}),c=Object.entries(e.chats.lastMessageIds.all||{}).map((([t,s])=>(0,y.hjO)(e,t,Number(s)))).filter(Boolean),d=Object.values(e.chats.lastMessageIds.saved||{}).map((t=>(0,y.hjO)(e,e.currentUserId,Number(t)))).filter(Boolean);for(const{id:i}of Object.values(e.byTabId)){e=(0,a.Rd)();const{chatId:c,threadId:d}=(0,y.Btg)(e,i)||{},l=d||r._f,u=c&&d?(0,y.tZg)(e,c,d):void 0,m=c?e.chats.byId[c]:void 0;if(c&&m){const[t,d]=await Promise.all([ve(e,c,l),l===r._f||(0,v._o)(m.id,l,e.currentUserId)?void 0:(0,I.t9)("fetchDiscussionMessage",{chat:m,messageId:Number(l)})]);e=(0,a.Rd)();const{chatId:p}=(0,y.Btg)(e,i)||{};if(t&&p===c){const a=(0,y.Zwk)(e,c),i=c===n.awM?e.serviceNotifications.filter((({isDeleted:e})=>!e)).map((({message:e})=>e)):[],p=m.isForum&&m.topics?Object.values(m.topics).map((({lastMessageId:e})=>a[e])).filter(Boolean):[],g=t.messages.map((({id:e})=>e)),f=(0,h.ei)(e.messages.byChatId[c].threadsById,g),I=((!t.messages.length||t.messages.some((({id:e})=>e===d?.firstMessageId)))&&d?.topMessages||[]).concat(t.messages,i),v=I.concat(p),P=(0,h.ee)(v,"id"),Z=(0,h.Tw)(I.map((({id:e})=>e)));o||(e={...e,messages:{...e.messages,byChatId:{}}},Object.values(e.byTabId).forEach((({id:t})=>{e=(0,b.i)(e,{tabThreads:{}},t)})),o=!0),e=(0,w.c_)(e,c,P),e=(0,w.xj)(e,c,l,Z),Object.entries(f).forEach((([t,s])=>{s?.threadInfo&&(e=(0,w.Xg)(e,c,t,s.threadInfo))})),u&&!u.isCommentsInfo&&l!==r._f&&(e=(0,w.Xg)(e,c,l,{...(0,h.ei)(u,["fromChannelId","fromMessageId"])})),Object.values(e.byTabId).forEach((({id:t})=>{const{chatId:s,threadId:a}=(0,y.Btg)(e,t)||{};s===c&&a===l&&(e=(0,w.y9)(e,c,l,Z,t))})),e=(0,w.GL)(e,(0,h.ee)(t.chats,"id")),e=(0,w.eD)(e,(0,h.ee)(t.users,"id")),s=!0}}(0,a.R3)(e),m?.isForum&&(t.loadTopics({chatId:c,force:!0}),d&&d!==r._f&&t.loadTopicById({chatId:c,topicId:Number(d),shouldCloseChatOnError:!0}))}e=(0,a.Rd)(),s||(e={...e,messages:{...e.messages,byChatId:{}}},Object.values(e.byTabId).forEach((({id:t})=>{e=(0,b.i)(e,{tabThreads:{}},t)}))),Object.keys(i).forEach((t=>{const s=i[t];Object.keys(s).forEach((s=>{e=(0,w.sN)(e,t,Number(s),i[t][Number(s)])}))})),e=(0,w.m6)(e,c),e=(0,w.m6)(e,d),(0,a.R3)(e),Object.values(e.byTabId).forEach((({id:s})=>{const{chatId:a,messageId:n}=(0,y.jUK)(e,s).audioPlayer;a&&n&&!(0,y.hjO)(e,a,n)&&t.closeAudioPlayer({tabId:s})}))}(e,t),e=(0,a.Rd)(),e={...e,isSyncing:!1,isSynced:!0,isFetchingDifference:!1},(0,a.R3)(e),n.eMD&&console.log(">>> FINISH SYNC"),(0,ge.S1)(),s({listType:"archived",shouldReplace:!0}),s({listType:"saved",shouldReplace:!0}),o(),i(),c()}})})),(0,pe.ll)((e=>{const{connectionState:t,authState:s,isSynced:n}=e,{isMasterTab:o}=(0,y.jUK)(e);!o||n||Ie?.connectionState===t&&Ie?.authState===s||"connectionStateReady"===t&&"authorizationStateReady"===s&&(0,a.Sv)().sync(),Ie=e})),(0,a.iw)("reportPeer",(async(e,t,s)=>{const{chatId:a,reason:n,description:o,tabId:i=(0,m._w)()}=s;if(!a)return;const r=(0,y.Z1J)(e,a);if(!r)return;const c=await(0,I.t9)("reportPeer",{peer:r,reason:n,description:o});t.showNotification({message:c?(0,p.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:i})})),(0,a.iw)("reportProfilePhoto",(async(e,t,s)=>{const{chatId:a,reason:n,description:o,photo:i,tabId:r=(0,m._w)()}=s;if(!a)return;const c=(0,y.Z1J)(e,a);if(!c||!i)return;const d=await(0,I.t9)("reportProfilePhoto",{peer:c,photo:i,reason:n,description:o});t.showNotification({message:d?(0,p.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:r})})),(0,a.iw)("loadAuthorizations",(async e=>{const t=await(0,I.t9)("fetchAuthorizations");t&&(e=(0,a.Rd)(),e={...e,activeSessions:{byHash:t.authorizations,orderedHashes:Object.keys(t.authorizations),ttlDays:t.ttlDays}},(0,a.R3)(e))})),(0,a.iw)("terminateAuthorization",(async(e,t,s)=>{const{hash:n}=s;if(!await(0,I.t9)("terminateAuthorization",n))return;e=(0,a.Rd)();const{[n]:o,...i}=e.activeSessions.byHash;e={...e,activeSessions:{byHash:i,orderedHashes:e.activeSessions.orderedHashes.filter((e=>e!==n))}},(0,a.R3)(e)})),(0,a.iw)("terminateAllAuthorizations",(async e=>{if(!await(0,I.t9)("terminateAllAuthorizations"))return;const t=(e=(0,a.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,a.R3)(e)})),(0,a.iw)("changeSessionSettings",(async(e,t,s)=>{const{hash:n,areCallsEnabled:o,areSecretChatsEnabled:i,isConfirmed:r}=s;await(0,I.t9)("changeSessionSettings",{hash:n,areCallsEnabled:o,areSecretChatsEnabled:i,isConfirmed:r})&&(e=(0,a.Rd)(),e={...e,activeSessions:{...e.activeSessions,byHash:{...e.activeSessions.byHash,[n]:{...e.activeSessions.byHash[n],...void 0!==o?{areCallsEnabled:o}:void 0,...void 0!==i?{areSecretChatsEnabled:i}:void 0,...r&&{isUnconfirmed:void 0}}}}},(0,a.R3)(e))})),(0,a.iw)("changeSessionTtl",(async(e,t,s)=>{const{days:n}=s;await(0,I.t9)("changeSessionTtl",{days:n})&&(e=(0,a.Rd)(),e={...e,activeSessions:{...e.activeSessions,ttlDays:n}},(0,a.R3)(e))})),(0,a.iw)("loadWebAuthorizations",(async e=>{const t=await(0,I.t9)("fetchWebAuthorizations");if(!t)return;const{users:s,webAuthorizations:n}=t;e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(s,"id")),e={...e,activeWebSessions:{byHash:n,orderedHashes:Object.keys(n)}},(0,a.R3)(e)})),(0,a.iw)("terminateWebAuthorization",(async(e,t,s)=>{const{hash:n}=s;if(!await(0,I.t9)("terminateWebAuthorization",n))return;e=(0,a.Rd)();const{[n]:o,...i}=e.activeWebSessions.byHash;e={...e,activeWebSessions:{byHash:i,orderedHashes:e.activeWebSessions.orderedHashes.filter((e=>e!==n))}},(0,a.R3)(e)})),(0,a.iw)("terminateAllWebAuthorizations",(async e=>{await(0,I.t9)("terminateAllWebAuthorizations")&&(e=(0,a.Rd)(),e={...e,activeWebSessions:{byHash:{},orderedHashes:[]}},(0,a.R3)(e))}));var we=s(82267);const be=(0,f.P2)((e=>e()),500,!1);(0,a.iw)("loadFullUser",(async(e,t,s)=>{const{userId:n,withPhotos:o}=s,i=(0,y.dyD)(e,n);if(!i)return;const{id:r,accessHash:c}=i,d=await(0,I.t9)("fetchFullUser",{id:r,accessHash:c});if(!d?.user)return;e=(0,a.Rd)();const l=(0,y.ccz)(e,n),{user:u,fullInfo:m}=d,h=i.avatarHash!==u.avatarHash||l?.profilePhoto?.id!==m?.profilePhoto?.id||l?.fallbackPhoto?.id!==m?.fallbackPhoto?.id||l?.personalPhoto?.id!==m?.personalPhoto?.id;e=(0,w.Nq)(e,n,d.user),e=(0,w.ap)(e,n,d.fullInfo),(0,a.R3)(e),(o||i.photos?.length&&h)&&t.loadProfilePhotos({profileId:n})})),(0,a.iw)("loadUser",(async(e,t,s)=>{const{userId:n}=s,o=(0,y.dyD)(e,n);if(!o)return;const i=await(0,I.t9)("fetchUsers",{users:[o]});if(!i)return;const{users:r,userStatusesById:c}=i;e=(0,a.Rd)(),e=(0,w.eD)(e,(0,h.ee)(r,"id")),e=(0,w.ps)(e,{...e.users.statusesById,...c}),(0,a.R3)(e)})),(0,a.iw)("loadTopUsers",(async e=>{const{topPeers:{lastRequestedAt:t}}=e;if(t&&!((0,we.bp)()-t>60))return;const s=await(0,I.t9)("fetchTopUsers");if(!s)return;const{ids:n,users:o}=s;e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(o,"id")),e={...e,topPeers:{...e.topPeers,userIds:n,lastRequestedAt:(0,we.bp)()}},(0,a.R3)(e)})),(0,a.iw)("loadContactList",(async e=>{const t=await(0,I.t9)("fetchContactList");if(!t)return;e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(t.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(t.chats,"id")),e=(0,w.zn)(e,t.userStatusesById);const s=e=>e.lastName||e.firstName||"",n=new Intl.Collator("en-US"),o=t.users.sort(((e,t)=>n.compare(s(e),s(t)))).filter((e=>!e.isSelf));e={...e,contactList:{userIds:o.map((e=>e.id))}},(0,a.R3)(e)})),(0,a.iw)("loadCurrentUser",(()=>{(0,I.t9)("fetchCurrentUser")})),(0,a.iw)("loadCommonChats",(async(e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{},{chatId:o}=(0,y.Btg)(e,n)||{},i=o?(0,y.dyD)(e,o):void 0;if(!i||(0,v.cS)(i)||i.commonChats?.isFullyLoaded)return;const r=i.commonChats?.maxId,c=await(0,I.t9)("fetchCommonChats",i.id,i.accessHash,r);if(!c)return;const{chats:d,chatIds:l,isFullyLoaded:u}=c;e=(0,a.Rd)(),d.length&&(e=(0,w.fZ)(e,(0,h.ee)(d,"id"))),e=(0,w.Nq)(e,i.id,{commonChats:{maxId:l.length?l[l.length-1]:"0",ids:(0,h.Tw)((i.commonChats?.ids||[]).concat(l)),isFullyLoaded:u}}),(0,a.R3)(e)})),(0,a.iw)("updateContact",(async(e,t,s)=>{const{userId:n,isMuted:o=!1,firstName:i,lastName:r,shouldSharePhoneNumber:d,tabId:l=(0,m._w)()}=s,u=(0,y.dyD)(e,n);if(!u)return;let h;if(t.updateChatMutedState({chatId:n,isMuted:o}),e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.InProgress,l),(0,a.R3)(e),!u.isContact&&u.phoneNumber)h=await(0,I.t9)("importContact",{phone:u.phoneNumber,firstName:i,lastName:r});else{const{id:e,accessHash:t}=u;h=await(0,I.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:i,lastName:r,shouldSharePhoneNumber:d})}h&&(t.loadChatSettings({chatId:n}),t.loadPeerStories({peerId:n}),e=(0,a.Rd)(),e=(0,w.Nq)(e,u.id,{firstName:i,lastName:r}),(0,a.R3)(e)),e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.Complete,l),e=(0,w.ft)(e,l),(0,a.R3)(e)})),(0,a.iw)("deleteContact",(async(e,t,s)=>{const{userId:a}=s,n=(0,y.dyD)(e,a);if(!n)return;const{id:o,accessHash:i}=n;await(0,I.t9)("deleteContact",{id:o,accessHash:i})})),(0,a.iw)("loadProfilePhotos",(async(e,t,s)=>{const{profileId:n}=s,o=(0,v.YC)(n);let i=o?(0,y.dyD)(e,n):void 0;const r=o?void 0:(0,y.Z1J)(e,n);if(!i&&!r)return;let c=(0,y.ccz)(e,n);if(i&&!c?.profilePhoto){const{id:e,accessHash:t}=i,s=await(0,I.t9)("fetchFullUser",{id:e,accessHash:t});if(!s?.user)return;i=s.user,c=s.fullInfo}const d=await(0,I.t9)("fetchProfilePhotos",i,r);if(!d||!d.photos)return;e=(0,a.Rd)();const l=i||r,{photos:u,users:m}=d,p=c?.fallbackPhoto,g=c?.personalPhoto;p&&u.push(p),g&&u.unshift(g),u.sort((e=>e.id===l?.avatarHash?-1:1)),e=(0,w.Sh)(e,(0,h.ee)(m,"id")),e=o?(0,w.Nq)(e,n,{photos:u}):(0,w.a4)(e,n,{photos:u}),(0,a.R3)(e)})),(0,a.iw)("setUserSearchQuery",((e,t,s)=>{const{query:n,tabId:o=(0,m._w)()}=s;n&&be((async()=>{const t=await(0,I.t9)("searchChats",{query:n});e=(0,a.Rd)();const s=(0,y.jUK)(e,o).userSearch.query;if(!t||!s||n!==s)return e=(0,w.Q3)(e,!1,o),void(0,a.R3)(e);const{accountUsers:i,globalUsers:r}=t;let c,d;i.length&&(e=(0,w.Sh)(e,(0,h.ee)(i,"id")),c=i.map((({id:e})=>e))),r.length&&(e=(0,w.Sh)(e,(0,h.ee)(r,"id")),d=r.map((({id:e})=>e))),e=(0,w.Q3)(e,!1,o),e=(0,w.Lm)(e,{localUserIds:c,globalUserIds:d},o),(0,a.R3)(e)}))})),(0,a.iw)("importContact",(async(e,t,s)=>{const{phoneNumber:n,firstName:o,lastName:i,tabId:r=(0,m._w)()}=s,c=await(0,I.t9)("importContact",{phone:n,firstName:o,lastName:i});c?(t.openChat({id:c,tabId:r}),e=(0,a.Rd)(),e=(0,w.ft)(e,r),(0,a.R3)(e)):t.showNotification({message:p.Iu("Contacts.PhoneNumber.NotRegistred"),tabId:r})})),(0,a.iw)("reportSpam",((e,t,s)=>{const{chatId:a}=s,n=(0,y.RGZ)(e,a);n&&(0,I.t9)("reportSpam",n)})),(0,a.iw)("setEmojiStatus",((e,t,s)=>{const{emojiStatus:a,expires:n}=s;(0,I.t9)("updateEmojiStatus",a,n)})),(0,a.iw)("saveCloseFriends",(async(e,t,s)=>{const{userIds:n}=s;await(0,I.t9)("saveCloseFriends",n)&&(e=(0,a.Rd)(),e.contactList?.userIds.forEach((t=>{const{isCloseFriend:s}=e.users.byId[t]||{};s&&!n.includes(t)&&(e=(0,w.Nq)(e,t,{isCloseFriend:void 0}))})),n.forEach((t=>{e=(0,w.Nq)(e,t,{isCloseFriend:!0})})),(0,a.R3)(e))}));const ye=o.cj||o.wZ;class Pe{constructor(e,t){var s,a,n,o;this.features=e,this.onFail=t,s=this,n=void 0,(a="symbol"==typeof(o=function(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var a=s.call(e,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(a="preOpened"))?o:String(o))in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n}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}}var Ze=s(97690),Se=s(18629);function Ce(e,t,s,...[a=(0,m._w)()]){const n=(0,y.jUK)(e,a);return(0,b.i)(e,{inlineBots:{...n.inlineBots,byUsername:{...n.inlineBots.byUsername,[t]:s}}},a)}function Me(e,t,...[s=(0,m._w)()]){return(0,b.i)(e,{inlineBots:{...(0,y.jUK)(e,s).inlineBots,isLoading:t}},s)}const Ee=(0,f.Ds)((e=>e()),500,!1);let Re,ke;function Te(e,t,s,n,...[o=(0,m._w)()]){if("request"===n.type){e=(0,a.Rd)();const t=(0,y.jUK)(e,o);if(!t.urlAuth)return;const{domain:s,bot:i,shouldRequestWriteAccess:r}=n;return e=(0,b.i)(e,{urlAuth:{...t.urlAuth,request:{domain:s,botId:i.id,shouldRequestWriteAccess:r}}},o),void(0,a.R3)(e)}const i="accepted"===n.type?n.url:s;window.open(i,"_blank","noopener"),t.closeUrlAuthModal({tabId:o})}async function Ne(e,t,s,a,n){await(0,I.t9)("sendMessage",{chat:e,replyInfo:s,text:t,sendAs:a,lastMessageId:n})}async function Ae(e,t,s,a,n,o=!1,...[i=(0,m._w)()]){const{showDialog:r,showNotification:c,openUrl:d,openGame:l}=t;o&&(ke||(ke=new Pe("popup,width=800,height=600",(()=>{c({message:"Allow browser to open popup window",tabId:i})}))),ke.preOpenIfNeeded());const u=await(0,I.t9)("answerCallbackButton",{chatId:s.id,accessHash:s.accessHash,messageId:a,data:n,isGame:o});if(!u)return;const{message:h,alert:p,url:g}=u;p?r({data:{message:h||"Error"},tabId:i}):h?c({message:h,tabId:i}):g&&(o?g.includes("https://prizes.gamee.com/")?ke.open(g):(ke.cancelPreOpen(),l({url:g,chatId:s.id,messageId:a,tabId:i})):d({url:g,tabId:i}))}async function Be(e,t,...[s=(0,m._w)()]){const n=await(0,I.t9)("getPaymentForm",t);if(!n)return;const{form:o,invoice:i,users:r,botId:d}=n;return e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r,"id")),e=(0,w._7)(e,o,s),e=(0,w.Q$)(e,c.KB.Checkout,s),e=(0,w.cQ)(e,{botName:(0,y.dyD)(e,d)?.firstName},s),(0,a.R3)(e),i}async function xe(e,t,s,n,...[o=(0,m._w)()]){const i=await(0,I.t9)("validateRequestedInfo",{inputInvoice:t,requestInfo:s,shouldSave:n});if(!i)return;const{id:r,shippingOptions:d}=i;e=(0,a.Rd)(),e=(0,w.vT)(e,r,o),d?(e=(0,w.TM)(e,d,o),e=(0,w.Q$)(e,c.KB.Shipping,o)):e=(0,w.Q$)(e,c.KB.Checkout,o),(0,a.R3)(e)}(0,a.iw)("clickBotInlineButton",((e,t,s)=>{const{messageId:a,button:n,tabId:o=(0,m._w)()}=s;switch(n.type){case"command":t.sendBotCommand({command:n.text,tabId:o});break;case"url":{const{url:e}=n;t.openUrl({url:e,tabId:o});break}case"callback":{const s=(0,y.jrE)(e,o);if(!s)return;Ae(0,t,s,a,n.data,void 0,o);break}case"requestPoll":t.openPollModal({isQuiz:n.isQuiz,tabId:o});break;case"requestPhone":{const s=e.currentUserId?(0,y.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:o});break}case"receipt":{const s=(0,y.jrE)(e,o);if(!s)return;const{receiptMessageId:i}=n;t.getReceipt({receiptMessageId:i,chatId:s.id,messageId:a,tabId:o});break}case"buy":{const s=(0,y.jrE)(e,o);if(!s)return;t.openInvoice({chatId:s.id,messageId:a,tabId:o});break}case"game":{const s=(0,y.jrE)(e,o);if(!s)return;Ae(0,t,s,a,void 0,!0,o);break}case"switchBotInline":{const{query:e,isSamePeer:s}=n;t.switchBotInline({query:e,isSamePeer:s,messageId:a,tabId:o});break}case"userProfile":{const{userId:e}=n;t.openChatWithInfo({id:e,tabId:o});break}case"simpleWebView":{const{url:s}=n,{chatId:i}=(0,y.Btg)(e,o)||{};if(!i)return;const r=(0,y.hjO)(e,i,a);if(!r?.senderId)return;const c=(0,Se.BS)();t.requestSimpleWebView({url:s,botId:r?.senderId,theme:c,buttonText:n.text,tabId:o});break}case"webView":{const{url:s}=n,i=(0,y.jrE)(e,o);if(!i)return;const r=(0,y.hjO)(e,i.id,a);if(!r)return;const c=r.viaBotId||r.senderId;if(!c)return;const d=(0,Se.BS)();t.requestWebView({url:s,botId:c,peerId:i.id,theme:d,buttonText:n.text,tabId:o});break}case"urlAuth":{const{url:s}=n,i=(0,y.jrE)(e,o);if(!i)return;t.requestBotUrlAuth({chatId:i.id,messageId:a,buttonId:n.buttonId,url:s,tabId:o});break}}})),(0,a.iw)("sendBotCommand",((e,t,s)=>{const{command:a,chatId:n,tabId:o=(0,m._w)()}=s,i=n?(0,y.Z1J)(e,n):(0,y.jrE)(e,o),r=(0,y.Btg)(e,o);if(!i||!r)return;const{threadId:c}=r;t.resetDraftReplyInfo({tabId:o}),t.clearWebPagePreview({tabId:o});const d=(0,y.xMv)(e,i.id);Ne(i,a,(0,y.Mst)(e,i.id,c)?.replyInfo,(0,y._5C)(e,i.id),d)})),(0,a.iw)("restartBot",(async(e,t,s)=>{const{chatId:n,tabId:o=(0,m._w)()}=s,{currentUserId:i}=e,r=(0,y.jrE)(e,o),c=i&&(0,y.kBx)(e,n);if(!i||!r||!c)return;const d=(0,y.xMv)(e,r.id);await(0,I.t9)("unblockUser",{user:c})&&(e=(0,a.Rd)(),e=(0,w.kw)(e,c.id),(0,a.R3)(e),Ne(r,"/start",void 0,(0,y._5C)(e,n),d))})),(0,a.iw)("loadTopInlineBots",(async e=>{const{lastRequestedAt:t}=e.topInlineBots;if(t&&(0,we.bp)()-t<60)return;const s=await(0,I.t9)("fetchTopInlineBots");if(!s)return;const{ids:n,users:o}=s;e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(o,"id")),e={...e,topInlineBots:{...e.topInlineBots,userIds:n,lastRequestedAt:(0,we.bp)()}},(0,a.R3)(e)})),(0,a.iw)("queryInlineBot",(async(e,t,s)=>{const{chatId:n,username:o,query:i,offset:r,tabId:c=(0,m._w)()}=s;let d=(0,y.jUK)(e,c).inlineBots.byUsername[o];if(!1!==d){if(void 0===d){const{user:t,chat:s}=await(0,I.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!t||!s)return e=Ce(e,o,!1,c),void(0,a.R3)(e);e=(0,w.Sh)(e,{[t.id]:t}),e=(0,w.fZ)(e,{[s.id]:s}),d={id:t.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[],cacheTime:0},e=Ce(e,o,d,c),(0,a.R3)(e)}(i!==d.query||d.canLoadMore)&&Ee((()=>{!async function(e,{username:t,inlineBotData:s,chatId:n,query:o,offset:i},...[r=(0,m._w)()]){e=(0,a.Rd)();const c=(0,y.dyD)(e,s.id),d=(0,y.Z1J)(e,n);if(!c||!d)return;const l=s.query!==o;e=Ce(e=Me(e,!0,r),t,{...s,query:o,...l&&{offset:void 0,results:[]}},r),(0,a.R3)(e);const u=await(0,I.t9)("fetchInlineBotResults",{bot:c,chat:d,query:o,offset:l?void 0:i});e=(0,a.Rd)();const h=(0,y.jUK)(e,r).inlineBots.byUsername[t];if(e=Me(e,!1,r),!u||!h||o!==h.query)return void(0,a.R3)(e);const p=new Set((h.results||[]).map((e=>e.id))),g=u.results.filter((e=>!p.has(e.id)));e=Ce(e,t,{...h,help:u.help,cacheTime:Date.now()+1e3*u.cacheTime,...g.length&&{isGallery:u.isGallery},...u.switchPm&&{switchPm:u.switchPm},...u.switchWebview&&{switchWebview:u.switchWebview},canLoadMore:u.results.length>0&&Boolean(u.nextOffset),results:""===h.offset||h.offset===u.nextOffset?u.results:(h.results||[]).concat(g),offset:g.length?u.nextOffset:""},r),(0,a.R3)(e)}(e,{username:o,inlineBotData:d,chatId:n,query:i,offset:r},c)}))}})),(0,a.iw)("switchBotInline",((e,t,s)=>{const{query:a,isSamePeer:n,messageId:o,filter:i,tabId:r=(0,m._w)()}=s;let{botId:c}=s;const d=(0,y.jrE)(e,r);if(!d)return;if(!c&&o){const t=(0,y.hjO)(e,d.id,o);if(!t)return;c=t.viaBotId||t.senderId}if(!c)return;const l=(0,y.dyD)(e,c);l&&t.openChatWithDraft({text:`@${l.usernames[0].username} ${a}`,chatId:n?d.id:void 0,filter:i,tabId:r})})),(0,a.iw)("sendInlineBotResult",((e,t,s)=>{const{id:a,queryId:n,isSilent:o,scheduledAt:i,messageList:r,tabId:c=(0,m._w)()}=s;if(!a)return;const{chatId:d,threadId:l}=r,u=(0,y.Z1J)(e,d),h=(0,y.Mst)(e,d,l)?.replyInfo,p=(0,y.U1D)(e,d,l,h);t.resetDraftReplyInfo({tabId:c}),t.clearWebPagePreview({tabId:c}),(0,I.t9)("sendInlineBotResult",{chat:u,resultId:a,queryId:n,replyInfo:p,sendAs:(0,y._5C)(e,d),isSilent:o,scheduleDate:i})})),(0,a.iw)("resetInlineBot",((e,t,s)=>{const{username:n,force:o,tabId:i=(0,m._w)()}=s;let r=(0,y.jUK)(e,i).inlineBots.byUsername[n];r&&(!o&&Date.now()<r.cacheTime||(r={id:r.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[],cacheTime:0},e=Ce(e,n,r,i),(0,a.R3)(e)))})),(0,a.iw)("resetAllInlineBots",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a).inlineBots.byUsername;Object.keys(n).forEach((e=>{t.resetInlineBot({username:e,tabId:a})}))})),(0,a.iw)("startBot",(async(e,t,s)=>{const{botId:a,param:n}=s,o=(0,y.dyD)(e,a);if(!o)return;let i=(0,y.ccz)(e,a);if(!i){const e=await(0,I.t9)("fetchFullUser",{id:o.id,accessHash:o.accessHash});i=e?.fullInfo}i?.isBlocked&&await(0,I.t9)("unblockUser",{user:o}),await(0,I.t9)("startBot",{bot:o,startParam:n})})),(0,a.iw)("sharePhoneWithBot",(async(e,t,s)=>{const{botId:n}=s,o=(0,y.dyD)(e,n);if(!o)return;let i=(0,y.ccz)(e,n);if(!i){const e=await(0,I.t9)("fetchFullUser",{id:o.id,accessHash:o.accessHash});i=e?.fullInfo}i?.isBlocked&&await(0,I.t9)("unblockUser",{user:o}),e=(0,a.Rd)();const r=(0,y.Z1J)(e,n),c=(0,y.dyD)(e,e.currentUserId);if(!r)return;const d=(0,y.xMv)(e,r.id);await(0,I.t9)("sendMessage",{chat:r,contact:{firstName:c.firstName||"",lastName:c.lastName||"",phoneNumber:c.phoneNumber||"",userId:c.id},lastMessageId:d})})),(0,a.iw)("requestSimpleWebView",(async(e,t,s)=>{const{url:n,botId:o,theme:i,buttonText:r,isFromSideMenu:c,isFromSwitchWebView:d,startParam:l,tabId:u=(0,m._w)()}=s,h=(0,y.dyD)(e,o);if(!h)return;if(!(0,y.LM9)(e,o))return e=(0,b.i)(e,{botTrustRequest:{botId:o,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:s}}},u),void(0,a.R3)(e);const p=await(0,I.t9)("requestSimpleWebView",{url:n,bot:h,theme:i,startParam:l,isFromSideMenu:c,isFromSwitchWebView:d});p&&(e=(0,a.Rd)(),e=(0,b.i)(e,{webApp:{url:p,botId:o,buttonText:r}},u),(0,a.R3)(e))})),(0,a.iw)("requestWebView",(async(e,t,s)=>{const{url:n,botId:o,peerId:i,theme:r,isSilent:c,buttonText:d,isFromBotMenu:l,startParam:u,tabId:h=(0,m._w)()}=s,p=(0,y.dyD)(e,o);if(!p)return;const g=(0,y.Z1J)(e,i);if(!g)return;if(!(0,y.LM9)(e,o))return e=(0,b.i)(e,{botTrustRequest:{botId:o,type:"webApp",onConfirm:{action:"requestWebView",payload:s}}},h),void(0,a.R3)(e);const f=(0,y.Btg)(e,h);if(!f)return;const{chatId:v,threadId:w}=f,P=v?(0,y.Mst)(e,v,w)?.replyInfo:void 0,Z=(0,y.U1D)(e,v,w,P),S=(0,y._5C)(e,v),C=await(0,I.t9)("requestWebView",{url:n,bot:p,peer:g,theme:r,isSilent:c,replyInfo:Z,isFromBotMenu:l,startParam:u,sendAs:S});if(!C)return;const{url:M,queryId:E}=C;e=(0,a.Rd)(),e=(0,b.i)(e,{webApp:{url:M,botId:o,queryId:E,replyInfo:Z,buttonText:d}},h),(0,a.R3)(e)})),(0,a.iw)("requestAppWebView",(async(e,t,s)=>{const{botId:n,appName:o,startApp:i,theme:r,isWriteAllowed:c,isFromConfirm:d,tabId:l=(0,m._w)()}=s,u=(0,y.dyD)(e,n);if(!u)return;const g=Boolean(e.attachMenu.bots[u.id]);if(u.isAttachBot&&!d&&!g){const t=await(0,I.t9)("loadAttachBot",{bot:u});if(t){const n=t.bot;if(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(t.users,"id")),(0,a.R3)(e),n.isDisclaimerNeeded||n.isForAttachMenu||n.isForSideMenu)return e=(0,b.i)(e,{requestedAttachBotInstall:{bot:n,onConfirm:{action:"requestAppWebView",payload:{...s,isFromConfirm:!0}}}},l),void(0,a.R3)(e)}}const f=await(0,I.t9)("fetchBotApp",{bot:u,appName:o});if(e=(0,a.Rd)(),!f)return void t.showNotification({message:(0,p.Iu)("lng_username_app_not_found"),tabId:l});if(f.isInactive&&!(0,y.LM9)(e,n))return e=(0,b.i)(e,{botTrustRequest:{botId:n,shouldRequestWriteAccess:f.shouldRequestWriteAccess,type:"botApp",onConfirm:{action:"requestAppWebView",payload:s}}},l),void(0,a.R3)(e);const v=(0,y.jrE)(e,l),P=await(0,I.t9)("requestAppWebView",{peer:v||u,app:f,startParam:i,isWriteAllowed:c,theme:r});e=(0,a.Rd)(),P&&(e=(0,b.i)(e,{webApp:{url:P,botId:n,buttonText:""}},l),(0,a.R3)(e))})),(0,a.iw)("prolongWebView",(async(e,t,s)=>{const{botId:a,peerId:n,isSilent:o,replyInfo:i,queryId:r,tabId:c=(0,m._w)()}=s,d=(0,y.dyD)(e,a);if(!d)return;const l=(0,y.Z1J)(e,n);if(!l)return;const u=(0,y._5C)(e,n);await(0,I.t9)("prolongWebView",{bot:d,peer:l,isSilent:o,replyInfo:i,queryId:r,sendAs:u})||t.closeWebApp({tabId:c})})),(0,a.iw)("sendWebViewData",((e,t,s)=>{const{bot:a,data:n,buttonText:o}=s;(0,I.t9)("sendWebViewData",{bot:a,data:n,buttonText:o})})),(0,a.iw)("closeWebApp",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{webApp:void 0},a)})),(0,a.iw)("setWebAppPaymentSlug",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s,n=(0,y.jUK)(e,a);if(n.webApp?.url)return(0,b.i)(e,{webApp:{...n.webApp,slug:s.slug}},a)})),(0,a.iw)("cancelBotTrustRequest",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{botTrustRequest:void 0},a)})),(0,a.iw)("markBotTrusted",((e,t,s)=>{const{botId:n,isWriteAllowed:o,tabId:i=(0,m._w)()}=s,{trustedBotIds:r}=e,c=new Set(r);c.add(n),e={...e,trustedBotIds:Array.from(c)};const d=(0,y.jUK)(e,i);if(d.botTrustRequest?.onConfirm){const{action:e,payload:s}=d.botTrustRequest.onConfirm;t[e]({...s,isWriteAllowed:o})}e=(0,b.i)(e,{botTrustRequest:void 0},i),(0,a.R3)(e)})),(0,a.iw)("loadAttachBots",(async(e,t,s)=>{const{hash:o}=s||{},i=await async function(e,t){const s=await(0,I.t9)("loadAttachBots",{hash:t});if(s)return e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(s.users,"id")),e={...e,attachMenu:{hash:s.hash,bots:s.bots}},(0,a.R3)(e),s}(e,o);(0,Ze.Z)({action:"loadAttachBots",payload:{hash:i?.hash}},n.dse)})),(0,a.iw)("toggleAttachBot",(async(e,t,s)=>{const{botId:a,isWriteAllowed:n,isEnabled:o}=s,i=(0,y.dyD)(e,a);i&&await(0,I.t9)("toggleAttachBot",{bot:i,isWriteAllowed:n,isEnabled:o})})),(0,a.iw)("callAttachBot",((e,t,s)=>{const{bot:a,startParam:n,isFromConfirm:o,tabId:i=(0,m._w)()}=s,c="isFromSideMenu"in s&&s.isFromSideMenu,d=!a,l=!d&&!e.attachMenu.bots[a.id]||a?.isInactive||a?.isDisclaimerNeeded;if(!o&&l)return(0,b.i)(e,{requestedAttachBotInstall:{bot:a,onConfirm:{action:"callAttachBot",payload:{...s,isFromConfirm:!0}}}},i);const u=(0,Se.BS)();if(c&&t.requestSimpleWebView({botId:a.id,buttonText:"",isFromSideMenu:!0,startParam:n,theme:u,tabId:i}),"chatId"in s){const{chatId:e,threadId:o=r._f,url:c}=s;t.openThread({chatId:e,threadId:o,tabId:i}),t.requestWebView({url:c,peerId:e,botId:d?e:a.id,theme:u,buttonText:"",isFromBotMenu:d,startParam:n,tabId:i})}})),(0,a.iw)("confirmAttachBotInstall",(async(e,t,s)=>{const{isWriteAllowed:n,tabId:o=(0,m._w)()}=s,{requestedAttachBotInstall:i}=(0,y.jUK)(e,o),{bot:r,onConfirm:c}=i;e=(0,b.i)(e,{requestedAttachBotInstall:void 0},o),(0,a.R3)(e);const d=(0,y.dyD)(e,r.id);if(d&&(t.markBotTrusted({botId:r.id,isWriteAllowed:n,tabId:o}),await(0,I.t9)("toggleAttachBot",{bot:d,isWriteAllowed:n,isEnabled:!0}),c)){const{action:e,payload:s}=c;t[e](s)}})),(0,a.iw)("cancelAttachBotInstall",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{requestedAttachBotInstall:void 0},a)})),(0,a.iw)("requestAttachBotInChat",((e,t,s)=>{const{bot:n,filter:o,startParam:i,tabId:r=(0,m._w)()}=s,c=(0,y.Btg)(e,r)?.chatId,d=n.attachMenuPeerTypes?.filter((e=>"self"!==e&&o.includes(e)));d?.length?(e=(0,b.i)(e,{requestedAttachBotInChat:{bot:n,filter:d,startParam:i}},r),(0,a.R3)(e)):t.callAttachBot({chatId:c||n.id,bot:n,startParam:i,tabId:r})})),(0,a.iw)("cancelAttachBotInChat",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{requestedAttachBotInChat:void 0},a)})),(0,a.iw)("requestBotUrlAuth",(async(e,t,s)=>{const{chatId:n,buttonId:o,messageId:i,url:r,tabId:c=(0,m._w)()}=s,d=(0,y.Z1J)(e,n);if(!d)return;const l=await(0,I.t9)("requestBotUrlAuth",{chat:d,buttonId:o,messageId:i});l&&(e=(0,a.Rd)(),e=(0,b.i)(e,{urlAuth:{url:r,button:{buttonId:o,messageId:i,chatId:d.id}}},c),(0,a.R3)(e),Te(e,t,r,l,c))})),(0,a.iw)("acceptBotUrlAuth",(async(e,t,s)=>{const{isWriteAllowed:n,tabId:o=(0,m._w)()}=s,i=(0,y.jUK)(e,o);if(!i.urlAuth?.button)return;const{button:r,url:c}=i.urlAuth,{chatId:d,messageId:l,buttonId:u}=r,h=(0,y.Z1J)(e,d);if(!h)return;const p=await(0,I.t9)("acceptBotUrlAuth",{chat:h,messageId:l,buttonId:u,isWriteAllowed:n});p&&Te(e=(0,a.Rd)(),t,c,p,o)})),(0,a.iw)("requestLinkUrlAuth",(async(e,t,s)=>{const{url:n,tabId:o=(0,m._w)()}=s,i=await(0,I.t9)("requestLinkUrlAuth",{url:n});i&&(e=(0,a.Rd)(),e=(0,b.i)(e,{urlAuth:{url:n}},o),(0,a.R3)(e),Te(e,t,n,i,o))})),(0,a.iw)("acceptLinkUrlAuth",(async(e,t,s)=>{const{isWriteAllowed:n,tabId:o=(0,m._w)()}=s,i=(0,y.jUK)(e,o);if(!i.urlAuth?.url)return;const{url:r}=i.urlAuth,c=await(0,I.t9)("acceptLinkUrlAuth",{url:r,isWriteAllowed:n});c&&Te(e=(0,a.Rd)(),t,r,c,o)})),(0,a.iw)("closeUrlAuthModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{urlAuth:void 0},a)})),(0,a.iw)("setBotInfo",(async(e,t,s)=>{const{bot:n,name:o,description:i,tabId:r=(0,m._w)()}=s;let{langCode:d}=s;d||(d=e.settings.byKey.language);const{currentUserId:l}=e;l&&n&&(e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.InProgress,r),(0,a.R3)(e),(o||i)&&await(0,I.t9)("setBotInfo",{bot:n,langCode:d,name:o,about:i})&&(e=(0,a.Rd)(),e=(0,w.Nq)(e,n.id,{firstName:o}),e=(0,w.ap)(e,n.id,{bio:i}),(0,a.R3)(e)),e=(0,a.Rd)(),e=(0,w.H9)(e,c.wv.Complete,r),(0,a.R3)(e))})),(0,a.iw)("startBotFatherConversation",(async(e,t,s)=>{const{param:a,tabId:o=(0,m._w)()}=s;if(!Re){const t=await(0,i.Co)(e,n.P1i);if(!t)return;Re=t.id}a&&t.startBot({botId:Re,param:a}),t.openChat({id:Re,tabId:o})})),s(51371),(0,a.iw)("loadPasswordInfo",(async e=>{const t=await(0,I.t9)("getPasswordInfo");t&&(e=(0,a.Rd)(),e=(0,w.BI)(e,{hasPassword:t.hasPassword}),e=(0,w.IE)(e,{hint:t.hint}),(0,a.R3)(e))})),(0,a.iw)("checkPassword",(async(e,t,s)=>{const{currentPassword:n,onSuccess:o}=s;e=(0,w.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const i=await(0,I.t9)("checkPassword",n);e=(0,a.Rd)(),e=(0,w.IE)(e,{isLoading:!1}),(0,a.R3)(e),i&&o()})),(0,a.iw)("clearPassword",(async(e,t,s)=>{const{currentPassword:n,onSuccess:o}=s;e=(0,w.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const i=await(0,I.t9)("clearPassword",n);e=(0,a.Rd)(),e=(0,w.IE)(e,{isLoading:!1}),(0,a.R3)(e),i&&o()})),(0,a.iw)("updatePassword",(async(e,t,s)=>{const{currentPassword:n,password:o,hint:i,email:r,onSuccess:c}=s;e=(0,w.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const d=await(0,I.t9)("updatePassword",n,o,i,r);e=(0,a.Rd)(),e=(0,w.IE)(e,{isLoading:!1}),(0,a.R3)(e),d&&c()})),(0,a.iw)("updateRecoveryEmail",(async(e,t,s)=>{const{currentPassword:n,email:o,onSuccess:i}=s;e=(0,w.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const r=await(0,I.t9)("updateRecoveryEmail",n,o);e=(0,a.Rd)(),e=(0,w.IE)(e,{isLoading:!1,waitingEmailCodeLength:void 0}),(0,a.R3)(e),r&&i()})),(0,a.iw)("provideTwoFaEmailCode",((e,t,s)=>{const{code:a}=s;(0,I.t9)("provideRecoveryEmailCode",a)})),(0,a.iw)("clearTwoFaError",(e=>(0,w.IE)(e,{error:void 0}))),(0,a.iw)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:a,saveInfo:n,tabId:o=(0,m._w)()}=s,i=(0,y.kbX)(e,o);if(i)if("slug"in i)xe(e,i,a,n,o);else{const t=(0,y.Z1J)(e,i.chatId);if(!t)return;xe(e,{chat:t,messageId:i.messageId},a,n,o)}})),(0,a.iw)("openInvoice",(async(e,t,s)=>{const{tabId:n=(0,m._w)()}=s;let o;if("slug"in s)o=await Be(e,{slug:s.slug},n);else{const t=(0,y.Z1J)(e,s.chatId);if(!t)return;o=await Be(e,{chat:t,messageId:s.messageId},n)}o&&(e=(0,a.Rd)(),e=(0,w.bs)(e,o,n),e=(0,b.i)(e,{payment:{...(0,y.jUK)(e,n).payment,inputInvoice:s,isPaymentModalOpen:!0,status:"cancelled",isExtendedMedia:s.isExtendedMedia}},n),(0,a.R3)(e))})),(0,a.iw)("getReceipt",(async(e,t,s)=>{const{receiptMessageId:n,chatId:o,messageId:i,tabId:r=(0,m._w)()}=s,c=o&&(0,y.Z1J)(e,o);if(!i||!n||!c)return;const d=await(0,I.t9)("getReceipt",c,n);if(!d)return;e=(0,a.Rd)();const l=(0,y.hjO)(e,c.id,i);e=(0,w.Sh)(e,(0,h.ee)(d.users,"id")),e=(0,w.Dq)(e,d.receipt,l,r),(0,a.R3)(e)})),(0,a.iw)("clearPaymentError",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{};e=(0,b.i)(e,{payment:{...(0,y.jUK)(e,n).payment,error:void 0}},n),(0,a.R3)(e)})),(0,a.iw)("clearReceipt",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{payment:{...(0,y.jUK)(e,a).payment,receipt:void 0}},a)})),(0,a.iw)("sendCredentialsInfo",((e,t,s)=>{const{credentials:o,tabId:i=(0,m._w)()}=s,{nativeProvider:r}=(0,y.jUK)(e,i).payment,{data:d}=o;if("stripe"===r){const t=(0,y.$$M)(e,i);if(!t)return;!async function(e,t,s,...[n=(0,m._w)()]){const o=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"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}),i=await fetch(`https://api.stripe.com/v1/tokens${o}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${s}`}}),r=await i.json();if(r.error){const t=(0,v.Ow)(r.error);return e=(0,a.Rd)(),e=(0,b.i)(e,{payment:{...(0,y.jUK)(e,n).payment,status:"failed",error:{...t}}},n),void(0,a.R3)(e)}e=(0,a.Rd)(),e=(0,w.QH)(e,{type:r.type,id:r.id},n),e=(0,w.Q$)(e,c.KB.Checkout,n),(0,a.R3)(e)}(e,d,t,i)}else if("smartglocal"===r){const t=(0,y.EBU)(e,i);if(!t)return;!async function(e,t,s,...[o=(0,m._w)()]){const i={card:{number:t.cardNumber.replace(/\D+/g,""),expiration_month:t.expiryMonth,expiration_year:t.expiryYear,security_code:t.cvv.replace(/\D+/g,"")}},r=n.eAU?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",d=await fetch(r,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":s},body:JSON.stringify(i)}),l=await d.json();if("ok"!==l.status){const t={description:"payment error"};return e=(0,a.Rd)(),e=(0,b.i)(e,{payment:{...(0,y.jUK)(e,o).payment,status:"failed",error:{...t}}},o),void(0,a.R3)(e)}e=(0,a.Rd)(),e=(0,w.QD)(e,{type:"card",token:l.data.token},o),e=(0,w.Q$)(e,c.KB.Checkout,o),(0,a.R3)(e)}(e,d,t,i)}})),(0,a.iw)("sendPaymentForm",(async(e,t,s)=>{const{shippingOptionId:n,saveCredentials:o,savedCredentialId:i,tipAmount:r,tabId:c=(0,m._w)()}=s,d=(0,y.kbX)(e,c),l=(0,y.ehD)(e,c),u=(0,y.sp9)(e,c),{nativeProvider:h,temporaryPassword:p}=(0,y.jUK)(e,c).payment;if(!d||!l)return;let g;if("slug"in d)g={slug:d.slug};else{const t=(0,y.Z1J)(e,d.chatId);if(!t)return;g={chat:t,messageId:d.messageId}}e=(0,w.cQ)(e,{status:"pending"},c),(0,a.R3)(e);const f={save:o,data:"stripe"===h?(0,y.i31)(e,c):(0,y.Jg1)(e,c)};await(0,I.t9)("sendPaymentForm",{inputInvoice:g,formId:l,credentials:f,requestedInfoId:u,shippingOptionId:n,savedCredentialId:i,temporaryPassword:p?.value,tipAmount:r})&&(e=(0,a.Rd)(),e=(0,w.cQ)(e,{status:"paid"},c),e=(0,w.WY)(e,c),(0,a.R3)(e))})),(0,a.iw)("setSmartGlocalCardInfo",((e,t,s)=>{const{tabId:a=(0,m._w)(),type:n,token:o}=s;return(0,w.QD)(e,{type:n,token:o},a)})),(0,a.iw)("setPaymentStep",((e,t,s)=>{const{step:a,tabId:n=(0,m._w)()}=s;return(0,w.Q$)(e,a??c.KB.Checkout,n)})),(0,a.iw)("closePremiumModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);if(n.premiumModal)return(0,b.i)(e,{premiumModal:{promo:n.premiumModal.promo,isOpen:!1}},a)})),(0,a.iw)("openPremiumModal",(async(e,t,s)=>{const{initialSection:n,fromUserId:o,isSuccess:i,isGift:r,monthsAmount:c,toUserId:d,tabId:l=(0,m._w)()}=s||{};t.loadPremiumStickers();const u=await(0,I.t9)("fetchPremiumPromo");u&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(u.users,"id")),e=(0,b.i)(e,{premiumModal:{promo:u.promo,initialSection:n,isOpen:!0,fromUserId:o,toUserId:d,isGift:r,monthsAmount:c,isSuccess:i}},l),(0,a.R3)(e),t.closeReactionPicker({tabId:l}))})),(0,a.iw)("openGiftPremiumModal",(async(e,t,s)=>{const{forUserId:n,tabId:o=(0,m._w)()}=s||{},i=await(0,I.t9)("fetchPremiumPromo");i&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(i.users,"id")),e=(0,b.i)(e,{giftPremiumModal:{isOpen:!0,forUserId:n}},o),(0,a.R3)(e))})),(0,a.iw)("closeGiftPremiumModal",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{};e=(0,b.i)(e,{giftPremiumModal:{isOpen:!1}},n),(0,a.R3)(e)})),(0,a.iw)("validatePaymentPassword",(async(e,t,s)=>{const{password:n,tabId:o=(0,m._w)()}=s,i=await(0,I.t9)("fetchTemporaryPaymentPassword",n);e=(0,a.Rd)(),e=i?"error"in i?(0,w.cQ)(e,{error:{message:i.error,field:"password"}},o):(0,w.cQ)(e,{temporaryPassword:i,step:c.KB.Checkout},o):(0,w.cQ)(e,{error:{message:"Unknown Error",field:"password"}},o),(0,a.R3)(e)})),(0,a.iw)("openBoostModal",(async(e,t,s)=>{const{chatId:n,tabId:o=(0,m._w)()}=s,i=(0,y.Z1J)(e,n);if(!i||!(0,v.eA)(i)&&!(0,v.ZV)(i))return;e=(0,b.i)(e,{boostModal:{chatId:n}},o),(0,a.R3)(e);const r=await(0,I.t9)("fetchBoostsStatus",{chat:i});if(!r)return void t.closeBoostModal({tabId:o});e=(0,a.Rd)(),e=(0,b.i)(e,{boostModal:{chatId:n,boostStatus:r}},o),(0,a.R3)(e);const c=await(0,I.t9)("fetchMyBoosts");if(!c)return;e=(0,a.Rd)();const d=(0,y.jUK)(e,o);d.boostModal&&(e=(0,w.fZ)(e,(0,h.ee)(c.chats,"id")),e=(0,w.Sh)(e,(0,h.ee)(c.users,"id")),e=(0,b.i)(e,{boostModal:{...d.boostModal,myBoosts:c.boosts}},o),(0,a.R3)(e))})),(0,a.iw)("openBoostStatistics",(async(e,t,s)=>{const{chatId:n,tabId:o=(0,m._w)()}=s,i=(0,y.Z1J)(e,n);if(!i)return;e=(0,b.i)(e,{boostStatistics:{chatId:n}},o),(0,a.R3)(e);const[r,c]=await Promise.all([(0,I.t9)("fetchBoostsList",{chat:i}),(0,I.t9)("fetchBoostsStatus",{chat:i})]);if(e=(0,a.Rd)(),!r||!c)return e=(0,b.i)(e,{boostStatistics:void 0},o),void(0,a.R3)(e);e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),e=(0,b.i)(e,{boostStatistics:{chatId:n,boostStatus:c,boosters:r.boosters,boosterIds:r.boosterIds,count:r.count,nextOffset:r.nextOffset}},o),(0,a.R3)(e)})),(0,a.iw)("loadMoreBoosters",(async(e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{};let o=(0,y.jUK)(e,n);if(!o.boostStatistics)return;const i=(0,y.Z1J)(e,o.boostStatistics.chatId);if(!i)return;e=(0,b.i)(e,{boostStatistics:{...o.boostStatistics,isLoadingBoosters:!0}},n),(0,a.R3)(e);const r=await(0,I.t9)("fetchBoostsList",{chat:i,offset:o.boostStatistics.nextOffset});r&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),o=(0,y.jUK)(e,n),o.boostStatistics&&(e=(0,b.i)(e,{boostStatistics:{...o.boostStatistics,boosters:{...o.boostStatistics.boosters,...r.boosters},boosterIds:(0,h.Tw)([...o.boostStatistics.boosterIds||[],...r.boosterIds]),count:r.count,nextOffset:r.nextOffset,isLoadingBoosters:!1}},n),(0,a.R3)(e)))})),(0,a.iw)("applyBoost",(async(e,t,s)=>{const{chatId:n,slots:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n);if(!r)return;const c=(0,y.x67)(e,n),d=c?.boostsApplied||0,l=o.length;let u=(0,y.jUK)(e,i);const p=u.boostModal?.boostStatus;if(p){const t=p.nextLevelBoosts?p.nextLevelBoosts-p.currentLevelBoosts:1,s=p.boosts+l,n=p.nextLevelBoosts&&s>=p.nextLevelBoosts,o=n?p.nextLevelBoosts:p.currentLevelBoosts,r=n?p.nextLevelBoosts+t:p.nextLevelBoosts;e=(0,b.i)(e,{boostModal:{...u.boostModal,boostStatus:{...p,level:n?p.level+1:p.level,currentLevelBoosts:o,nextLevelBoosts:r,hasMyBoost:!0,boosts:s}}},i),(0,a.R3)(e)}e=(0,a.Rd)(),u=(0,y.jUK)(e,i);const g=u.boostModal?.myBoosts;if(g){const t=Math.floor(Date.now()/1e3),s=g.map((e=>o.includes(e.slot)?{...e,chatId:n,date:t,cooldownUntil:t+86400}:e));e=(0,b.i)(e,{boostModal:{...u.boostModal,myBoosts:s}},i),(0,a.R3)(e)}const f=await(0,I.t9)("applyBoost",{slots:o,chat:r});if(e=(0,a.Rd)(),f)u=(0,y.jUK)(e,i),e=(0,w.Sh)(e,(0,h.ee)(f.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(f.chats,"id")),c&&(e=(0,w.US)(e,n,{boostsApplied:d+o.length})),u.boostModal&&(e=(0,b.i)(e,{boostModal:{...u.boostModal,myBoosts:f.boosts}},i)),(0,a.R3)(e);else{const t=(0,y.jUK)(e,i).boostModal;t&&(e=(0,b.i)(e,{boostModal:{...t,boostStatus:p,myBoosts:g}},i),(0,a.R3)(e))}})),(0,a.iw)("checkGiftCode",(async(e,t,s)=>{const{slug:n,message:o,tabId:i=(0,m._w)()}=s,r=await(0,I.t9)("checkGiftCode",{slug:n});r?(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(r.chats,"id")),e=(0,b.i)(e,{giftCodeModal:{slug:n,info:r.code,message:o}},i),(0,a.R3)(e)):t.showNotification({message:p.Iu("lng_gift_link_expired"),tabId:i})})),(0,a.iw)("applyGiftCode",(async(e,t,s)=>{const{slug:a,tabId:n=(0,m._w)()}=s;await(0,I.t9)("applyGiftCode",{slug:a})&&(t.requestConfetti({tabId:n}),t.closeGiftCodeModal({tabId:n}))}));var Ue=s(40647);let Le=0;(0,a.iw)("loadAvailableReactions",(async e=>{const t=await(0,I.t9)("fetchAvailableReactions");t&&(t.forEach((e=>{e.aroundAnimation&&Ue.he(`sticker${e.aroundAnimation.id}`,r.IU.BlobUrl),e.centerIcon&&Ue.he(`sticker${e.centerIcon.id}`,r.IU.BlobUrl),e.appearAnimation&&Ue.he(`sticker${e.appearAnimation.id}`,r.IU.BlobUrl),e.selectAnimation&&Ue.he((0,v.ym)(e.selectAnimation),r.IU.BlobUrl)})),e=(0,a.Rd)(),e={...e,reactions:{...e.reactions,availableReactions:t}},(0,a.R3)(e),(0,Ze.Z)({action:"loadAvailableReactions",payload:void 0},n.dse))})),(0,a.iw)("interactWithAnimatedEmoji",((e,t,s)=>{const{emoji:a,x:n,y:o,startSize:i,isReversed:r,tabId:c=(0,m._w)()}=s,d={id:Le++,animatedEffect:a,x:U(e,n)+40*Math.random()-20,y:o+40*Math.random()-20,startSize:i,isReversed:r};return(0,b.i)(e,{activeEmojiInteractions:[...(0,y.jUK)(e,c).activeEmojiInteractions||[],d]},c)})),(0,a.iw)("sendEmojiInteraction",((e,t,s)=>{const{messageId:a,chatId:n,emoji:o,interactions:i}=s;if("connectionStateReady"!==e.connectionState)return;const r=(0,y.Z1J)(e,n);r&&o&&!(0,y.FM1)(e,n)&&(0,I.t9)("sendEmojiInteraction",{chat:r,messageId:a,emoticon:o,timestamps:i})})),(0,a.iw)("sendDefaultReaction",((e,t,s)=>{const{chatId:a,messageId:n,tabId:o=(0,m._w)()}=s,i=(0,y.q6x)(e,a),r=(0,y.hjO)(e,a,n);i&&r&&!(0,v.CI)(r)&&t.toggleReaction({chatId:a,messageId:n,reaction:i,tabId:o})})),(0,a.iw)("toggleReaction",(async(e,t,s)=>{const{chatId:n,reaction:o,shouldAddToRecent:i,tabId:r=(0,m._w)()}=s;let{messageId:c}=s;const d=(0,y.Z1J)(e,n);let l=(0,y.hjO)(e,n,c);if(!d||!l)return;const u=(0,y.FM1)(e,n),h=Boolean(l.groupedId)&&!l.isInAlbum,p=h?(0,y.xHX)(e,n,l.groupedId)[0]:void 0;l=h&&(0,y.hjO)(e,n,p)||l,c=l?.id||c;const f=(0,v.UZ)(l),w=f.some((e=>(0,v.Hl)(e,o))),b=w?f.filter((e=>!(0,v.Hl)(e,o))):[...f,o],P=(0,y.oC7)(e),Z=b.slice(-P),S=(0,g.Tp)(l);(0,y.$Yd)(e,"reactionEffects")&&(w?t.stopActiveReaction({containerId:S,reaction:o,tabId:r}):t.startActiveReaction({containerId:S,reaction:o,tabId:r})),e=L(e,l,Z),(0,a.R3)(e);try{await(0,I.t9)("sendReaction",{chat:d,messageId:c,reactions:Z,shouldAddToRecent:i}),u&&t.loadSavedReactionTags()}catch(t){e=L(e=(0,a.Rd)(),l,f),(0,a.R3)(e)}})),(0,a.iw)("startActiveReaction",((e,t,s)=>{const{containerId:a,reaction:n,tabId:o=(0,m._w)()}=s,i=(0,y.jUK)(e,o);if(!(0,y.$Yd)(e,"reactionEffects"))return;const r=i.activeReactions[a]||[];if(r.some((e=>(0,v.Hl)(e,n))))return;const c=r.concat(n);return(0,b.i)(e,{activeReactions:{...i.activeReactions,[a]:c}},o)})),(0,a.iw)("stopActiveReaction",((e,t,s)=>{const{containerId:a,reaction:n,tabId:o=(0,m._w)()}=s,i=(0,y.jUK)(e,o),r=i.activeReactions[a]||[],c=n?r.filter((e=>!(0,v.Hl)(e,n))):[],d=c.length?{...i.activeReactions,[a]:c}:(0,h.CE)(i.activeReactions,[a]);return(0,b.i)(e,{activeReactions:d},o)})),(0,a.iw)("setDefaultReaction",(async(e,t,s)=>{const{reaction:n}=s;await(0,I.t9)("setDefaultReaction",{reaction:n})&&((e=(0,a.Rd)()).config?(e={...e,config:{...e.config,defaultReaction:n}},(0,a.R3)(e)):t.loadConfig())})),(0,a.iw)("stopActiveEmojiInteraction",((e,t,s)=>{const{id:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{activeEmojiInteractions:(0,y.jUK)(e,n).activeEmojiInteractions?.filter((e=>e.id!==a))},n)})),(0,a.iw)("loadReactors",(async(e,t,s)=>{const{chatId:n,messageId:o,reaction:i}=s,r=(0,y.Z1J)(e,n),c=(0,y.hjO)(e,n,o);if(!r||!c)return;const d=c.reactors?.nextOffset,l=await(0,I.t9)("fetchMessageReactionsList",{reaction:i,chat:r,messageId:o,offset:d});l&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(l.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(l.chats,"id")),e=(0,w.cY)(e,n,o,{reactors:l}),(0,a.R3)(e))})),(0,a.iw)("loadMessageReactions",((e,t,s)=>{const{ids:a,chatId:n}=s,o=(0,y.Z1J)(e,n);o&&"connectionStateReady"===e.connectionState&&(0,I.t9)("fetchMessageReactions",{ids:a,chat:o})})),(0,a.iw)("sendWatchingEmojiInteraction",((e,t,s)=>{const{chatId:a,emoticon:n,x:o,y:i,startSize:r,isReversed:c,id:d,tabId:l=(0,m._w)()}=s,u=(0,y.Z1J)(e,a),h=(0,y.jUK)(e,l);if(u&&h.activeEmojiInteractions?.some((e=>e.id===d))&&!(0,y.FM1)(e,a))return"connectionStateReady"===e.connectionState&&(0,I.t9)("sendWatchingEmojiInteraction",{chat:u,emoticon:n}),(0,b.i)(e,{activeEmojiInteractions:h.activeEmojiInteractions.map((t=>t.id===d?{...t,x:U(e,o),y:i,startSize:r,isReversed:c}:t))},l)})),(0,a.iw)("fetchUnreadReactions",(async(e,t,s)=>{const{chatId:n,offsetId:o}=s,i=(0,y.Z1J)(e,n);if(!i)return;const r=await(0,I.t9)("fetchUnreadReactions",{chat:i,offsetId:o,addOffset:o?-1:void 0});if(!r||!r.messages.length)return e=_(e=(0,a.Rd)(),n,{unreadReactionsCount:0}),void(0,a.R3)(e);const{messages:c,chats:d,users:l}=r,u=(0,h.ee)(c,"id"),m=Object.keys(u).map(Number);e=(0,a.Rd)(),e=(0,w.c_)(e,i.id,u),e=(0,w.Sh)(e,(0,h.ee)(l,"id")),e=_(e=(0,w.fZ)(e,(0,h.ee)(d,"id")),n,{unreadReactions:[...i.unreadReactions||[],...m]}),(0,a.R3)(e)})),(0,a.iw)("animateUnreadReaction",((e,t,s)=>{const{messageIds:n,tabId:o=(0,m._w)()}=s,i=(0,y.jrE)(e,o);if(i){if(i.unreadReactionsCount){const s=i.unreadReactionsCount-n.length,o=(i.unreadReactions||[]).filter((e=>!n.includes(e)));e=_(e,i.id,{unreadReactions:o}),(0,a.R3)(e),!o.length&&s&&t.fetchUnreadReactions({chatId:i.id,offsetId:Math.min(...n)})}if(t.markMessagesRead({messageIds:n,tabId:o}),(0,y.$Yd)(e,"reactionEffects"))return e=(0,a.Rd)(),(0,b.i)(e,{activeReactions:{...(0,y.jUK)(e,o).activeReactions,...Object.fromEntries(n.map((t=>{const s=(0,y.hjO)(e,i.id,t);if(!s)return;const a=s.reactions?.recentReactions?.filter((({isUnread:e})=>e));if(!a)return;const n=a.map((e=>e.reaction));return[t,n.map((e=>({messageId:t,reaction:e})))]})).filter(Boolean))}},o)}})),(0,a.iw)("focusNextReaction",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jrE)(e,a);n?.unreadReactions&&t.focusMessage({chatId:n.id,messageId:n.unreadReactions[0],tabId:a})})),(0,a.iw)("readAllReactions",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jrE)(e,a);if(n)return(0,I.t9)("readAllReactions",{chat:n}),_(e,n.id,{unreadReactionsCount:void 0,unreadReactions:void 0})})),(0,a.iw)("loadTopReactions",(async e=>{const t=await(0,I.t9)("fetchTopReactions",{hash:e.reactions.hash.topReactions});t&&(e=(0,a.Rd)(),e={...e,reactions:{...e.reactions,topReactions:t.reactions,hash:{...e.reactions.hash,topReactions:t.hash}}},(0,a.R3)(e))})),(0,a.iw)("loadRecentReactions",(async e=>{const t=await(0,I.t9)("fetchRecentReactions",{hash:e.reactions.hash.recentReactions});t&&(e=(0,a.Rd)(),e={...e,reactions:{...e.reactions,recentReactions:t.reactions,hash:{...e.reactions.hash,recentReactions:t.hash}}},(0,a.R3)(e))})),(0,a.iw)("clearRecentReactions",(async e=>{await(0,I.t9)("clearRecentReactions")&&(e=(0,a.Rd)(),e={...e,reactions:{...e.reactions,recentReactions:[]}},(0,a.R3)(e))})),(0,a.iw)("loadDefaultTagReactions",(async e=>{const t=await(0,I.t9)("fetchDefaultTagReactions",{hash:e.reactions.hash.defaultTags});t&&(e=(0,a.Rd)(),e={...e,reactions:{...e.reactions,defaultTags:t.reactions,hash:{...e.reactions.hash,defaultTags:t.hash}}},(0,a.R3)(e))})),(0,a.iw)("loadSavedReactionTags",(async e=>{const{hash:t}=e.savedReactionTags||{},s=await(0,I.t9)("fetchSavedReactionTags",{hash:t});if(!s)return;e=(0,a.Rd)();const n=(0,h.RS)(s.tags,(e=>[(0,v.jq)(e.reaction),e]));e={...e,savedReactionTags:{hash:s.hash,byKey:n}},(0,a.R3)(e)})),(0,a.iw)("editSavedReactionTag",(async(e,t,s)=>{const{reaction:n,title:o}=s;if(!await(0,I.t9)("updateSavedReactionTag",{reaction:n,title:o}))return;e=(0,a.Rd)();const i=e.savedReactionTags?.byKey;if(!i)return;const r=(0,v.jq)(n),c={...i[r],title:o};e={...e,savedReactionTags:{...e.savedReactionTags,byKey:{...i,[r]:c}}},(0,a.R3)(e)})),(0,a.iw)("loadStatistics",(async(e,t,s)=>{const{chatId:n,isGroup:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n),c=(0,y.x67)(e,n);if(!r||!c)return;const d=await(0,I.t9)(o?"fetchGroupStatistics":"fetchChannelStatistics",{chat:r,dcId:c.statisticsDcId});if(!d)return;e=(0,a.Rd)();const{stats:l,users:u}=d;e=(0,w.Sh)(e,(0,h.ee)(u,"id")),e=(0,w.ze)(e,n,l,i),(0,a.R3)(e)})),(0,a.iw)("loadMessageStatistics",(async(e,t,s)=>{const{chatId:n,messageId:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n),c=(0,y.x67)(e,n);if(!r||!c)return;const d=c.statisticsDcId;let l=await(0,I.t9)("fetchMessageStatistics",{chat:r,messageId:o,dcId:d});l||(l={}),e=(0,a.Rd)();const{viewsCount:u,forwardsCount:h,reactions:p}=(0,y.Zwk)(e,n)[o]||{};l.viewsCount=u,l.forwardsCount=h,l.reactionsCount=p?.results?p?.results.reduce(((e,t)=>e+t.count),0):void 0,e=(0,w.kM)(e,l,i),(0,a.R3)(e),t.loadMessagePublicForwards({chatId:n,messageId:o,tabId:i})})),(0,a.iw)("loadMessagePublicForwards",(async(e,t,s)=>{const{chatId:n,messageId:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n),c=(0,y.x67)(e,n);if(!r||!c)return;const d=c.statisticsDcId,l=(0,y.jUK)(e,i).statistics.currentMessage||{};if(l?.publicForwards&&!l.nextOffset)return;const u=await(0,I.t9)("fetchMessagePublicForwards",{chat:r,messageId:o,dcId:d,offset:l.nextOffset}),{forwards:h,nextOffset:p,count:g}=u||{},f=l.publicForwardsData?.length&&h?.length&&(0,P.A)(l.publicForwardsData[l.publicForwardsData.length-1],h[0]);e=(0,a.Rd)(),e=(0,w.kM)(e,{...l,publicForwards:g||h?.length,publicForwardsData:(l.publicForwardsData||[]).concat(f?h.slice(1):h||[]),nextOffset:p},i),(0,a.R3)(e)})),(0,a.iw)("loadStatisticsAsyncGraph",(async(e,t,s)=>{const{chatId:n,token:o,name:i,isPercentage:r,tabId:c=(0,m._w)()}=s,d=(0,y.x67)(e,n);if(!d)return;const l=d.statisticsDcId,u=await(0,I.t9)("fetchStatisticsAsyncGraph",{token:o,dcId:l,isPercentage:r});u&&(e=(0,a.Rd)(),e=(0,w.yC)(e,n,i,u,c),(0,a.R3)(e))})),(0,a.iw)("loadStoryStatistics",(async(e,t,s)=>{const{chatId:n,storyId:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n),c=(0,y.x67)(e,n);if(!r||!c)return;const d=c.statisticsDcId;let l=await(0,I.t9)("fetchStoryStatistics",{chat:r,storyId:o,dcId:d});l||(l={}),e=(0,a.Rd)();const u=(0,y.JrV)(e,n,o),{forwardsCount:h=0,viewsCount:p=0,reactionsCount:g=0}=u&&"views"in u&&u.views?u.views:{};l.viewsCount=p,l.forwardsCount=h,l.reactionsCount=g,e=(0,a.Rd)(),e=(0,w.sG)(e,l,i),(0,a.R3)(e),t.loadStoryPublicForwards({chatId:n,storyId:o,tabId:i})})),(0,a.iw)("loadStoryPublicForwards",(async(e,t,s)=>{const{chatId:n,storyId:o,tabId:i=(0,m._w)()}=s,r=(0,y.Z1J)(e,n),c=(0,y.x67)(e,n);if(!r||!c)return;const d=c.statisticsDcId,l=(0,y.jUK)(e,i).statistics.currentStory||{};if(l?.publicForwards&&!l.nextOffset)return;const{publicForwards:u,users:p,chats:g,count:f,nextOffset:v}=await(0,I.t9)("fetchStoryPublicForwards",{chat:r,storyId:o,dcId:d,offset:l.nextOffset})||{};e=(0,a.Rd)(),g&&(e=(0,w.fZ)(e,(0,h.ee)(g,"id"))),p&&(e=(0,w.Sh)(e,(0,h.ee)(p,"id"))),e=(0,w.sG)(e,{...l,publicForwards:f||u?.length,publicForwardsData:(l.publicForwardsData||[]).concat(u||[]),nextOffset:v},i),(0,a.R3)(e)})),(0,a.iw)("loadAllStories",(async e=>{let t=0;for(;e.stories.hasNext;){if(t++>=100)return void(n.eMD&&console.error("`actions/loadAllStories`: Infinite loop detected"));e=(0,a.Rd)();const{stateHash:s,hasNext:o}=e.stories;if(s&&!o)return;const i=await(0,I.t9)("fetchAllStories",{isFirstRequest:!s,stateHash:s});if(!i)return;(e=(0,a.Rd)()).stories.stateHash=i.state,"peerStories"in i&&(e=(0,w.Sh)(e,(0,h.ee)(i.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(i.chats,"id")),e=(0,w.p1)(e,i.peerStories),e=(0,w.Fz)(e,i.peerStories),(e=(0,w.Uq)(e,i.stealthMode)).stories.hasNext=i.hasMore),(0,a.R3)(e)}})),(0,a.iw)("loadAllHiddenStories",(async e=>{let t=0;for(;e.stories.hasNextInArchive;){if(t++>=100)return void(n.eMD&&console.error("`actions/loadAllHiddenStories`: Infinite loop detected"));e=(0,a.Rd)();const{archiveStateHash:s,hasNextInArchive:o}=e.stories;if(s&&!o)return;const i=await(0,I.t9)("fetchAllStories",{isFirstRequest:!s,stateHash:s,isHidden:!0});if(!i)return;(e=(0,a.Rd)()).stories.archiveStateHash=i.state,"peerStories"in i&&(e=(0,w.Sh)(e,(0,h.ee)(i.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(i.chats,"id")),e=(0,w.p1)(e,i.peerStories),e=(0,w.Fz)(e,i.peerStories),(e=(0,w.Uq)(e,i.stealthMode)).stories.hasNextInArchive=i.hasMore),(0,a.R3)(e)}})),(0,a.iw)("loadPeerSkippedStories",(async(e,t,s)=>{const{peerId:n}=s,o=(0,y.RGZ)(e,n),i=(0,y.nST)(e,n);if(!o||!i)return;const r=Object.values(i.byId).reduce(((e,t)=>("content"in t||e.push(t.id),e)),[]);if(0===r.length)return;const c=await(0,I.t9)("fetchPeerStoriesByIds",{peer:o,ids:r});c&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(c.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(c.chats,"id")),e=(0,w._6)(e,n,c.stories),(0,a.R3)(e))})),(0,a.iw)("viewStory",(async(e,t,s)=>{const{peerId:n,storyId:o,tabId:i=(0,m._w)()}=s,r=(0,y.RGZ)(e,n),c=(0,y.JrV)(e,n,o);if(!r||!c||!("content"in c))return;e=(0,w.WW)(e,n,o,i),(0,a.R3)(e);const d=(0,we.bp)();c.expireDate<d&&c.isPinned&&(0,I.t9)("viewStory",{peer:r,storyId:o}),(e.stories.byPeerId[n].lastReadId||0)<c.id&&await(0,I.t9)("markStoryRead",{peer:r,storyId:o})&&(e=(0,a.Rd)(),e=(0,w.P5)(e,n,o),(0,a.R3)(e))})),(0,a.iw)("deleteStory",(async(e,t,s)=>{const{peerId:n,storyId:o}=s,i=(0,y.RGZ)(e,n);i&&await(0,I.t9)("deleteStory",{peer:i,storyId:o})&&(e=(0,a.Rd)(),e=(0,w.se)(e,n,o),(0,a.R3)(e))})),(0,a.iw)("toggleStoryPinned",(async(e,t,s)=>{const{peerId:n,storyId:o,isPinned:i}=s,r=(0,y.RGZ)(e,n);if(!r)return;const c=(0,y.JrV)(e,n,o),d=c&&"content"in c?c.isPinned:void 0;e=(0,w.w2)(e,n,o,{isPinned:i}),e=(0,w.vI)(e,n,o,i),(0,a.R3)(e),await(0,I.t9)("toggleStoryPinned",{peer:r,storyId:o,isPinned:i})||(e=(0,a.Rd)(),e=(0,w.w2)(e,n,o,{isPinned:d}),e=(0,w.vI)(e,n,o,d),(0,a.R3)(e))})),(0,a.iw)("loadPeerStories",(async(e,t,s)=>{const{peerId:n}=s,o=(0,y.RGZ)(e,n);if(!o)return;const i=await(0,I.t9)("fetchPeerStories",{peer:o});i&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(i.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(i.chats,"id")),e=(0,w._6)(e,n,i.stories),i.lastReadStoryId&&(e=(0,w.P5)(e,n,i.lastReadStoryId)),(0,a.R3)(e))})),(0,a.iw)("loadPeerPinnedStories",(async(e,t,s)=>{const{peerId:n,offsetId:o}=s,i=(0,y.RGZ)(e,n);if(!i)return;const r=await(0,I.t9)("fetchPeerPinnedStories",{peer:i,offsetId:o});r&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(r.chats,"id")),e=(0,w._6)(e,n,r.stories),(0,a.R3)(e))})),(0,a.iw)("loadStoriesArchive",(async(e,t,s)=>{const{peerId:n,offsetId:o}=s,i=(0,y.RGZ)(e,n);if(!i)return;const r=await(0,I.t9)("fetchStoriesArchive",{peer:i,offsetId:o});r&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(r.chats,"id")),e=(0,w._6)(e,n,r.stories,!0),(0,a.R3)(e))})),(0,a.iw)("loadPeerStoriesByIds",(async(e,t,s)=>{const{peerId:n,storyIds:o}=s,i=(0,y.RGZ)(e,n);if(!i)return;const r=await(0,I.t9)("fetchPeerStoriesByIds",{peer:i,ids:o});r&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(r.chats,"id")),e=(0,w._6)(e,n,r.stories),(0,a.R3)(e))})),(0,a.iw)("loadStoryViews",(async(e,t,s)=>{const{peerId:n,storyId:o}=s,i=(0,y.RGZ)(e,n);if(!i)return;const r=await(0,I.t9)("fetchStoriesViews",{peer:i,storyIds:[o]});r&&(e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(r.users,"id")),e=(0,w.Qn)(e,n,o,r.views),(0,a.R3)(e))})),(0,a.iw)("loadStoryViewList",(async(e,t,s)=>{const{peerId:n,storyId:o,offset:i,areReactionsFirst:r,areJustContacts:c,query:d,limit:l,tabId:u=(0,m._w)()}=s,p=(0,y.RGZ)(e,n);if(!p)return;e=(0,w.uS)(e,!0,u),(0,a.R3)(e);const g=await(0,I.t9)("fetchStoryViewList",{peer:p,storyId:o,offset:i,areReactionsFirst:r,areJustContacts:c,limit:l,query:d});if(!g)return e=(0,a.Rd)(),e=(0,w.uS)(e,!1,u),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(g.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(g.chats,"id")),e=(0,w.eB)(e,o,g.views,g.nextOffset,u),(0,a.R3)(e)})),(0,a.iw)("reportStory",(async(e,t,s)=>{const{peerId:a,storyId:n,reason:o,description:i,tabId:r=(0,m._w)()}=s,c=(0,y.RGZ)(e,a);if(!c)return;const d=await(0,I.t9)("reportStory",{peer:c,storyId:n,reason:o,description:i});t.showNotification({message:d?(0,p.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:r})})),(0,a.iw)("editStoryPrivacy",((e,t,s)=>{const{peerId:a,storyId:n,privacy:o}=s,i=(0,y.RGZ)(e,a);if(!i)return;const r=[...o.allowUserIds,...o.allowChatIds],c=[...o.blockUserIds,...o.blockChatIds],d=(0,v.wA)(e,{visibility:o.visibility,isUnspecified:o.isUnspecified,allowedIds:r,blockedIds:c});(0,I.t9)("editStoryPrivacy",{peer:i,id:n,privacy:d})})),(0,a.iw)("toggleStoriesHidden",(async(e,t,s)=>{const{peerId:n,isHidden:o}=s,i=(0,y.RGZ)(e,n);i&&await(0,I.t9)("toggleStoriesHidden",{peer:i,isHidden:o})&&(e=(0,a.Rd)(),e=(0,w.QO)(e,n,o),(0,a.R3)(e))})),(0,a.iw)("loadStoriesMaxIds",(async(e,t,s)=>{const{peerIds:n}=s,o=n.map((t=>(0,y.RGZ)(e,t))).filter(Boolean);if(!o.length)return;const i=await(0,I.t9)("fetchStoriesMaxIds",{peers:o});if(!i)return;const r=[];e=(0,a.Rd)(),i.forEach(((t,s)=>{const a=o[s];e=(0,w.GG)(e,a.id,{maxStoryId:t,hasStories:0!==t}),0!==t&&r.push(a.id)})),(0,a.R3)(e),r?.forEach((e=>t.loadPeerStories({peerId:e})))})),(0,a.iw)("sendStoryReaction",(async(e,t,s)=>{const{peerId:n,storyId:o,containerId:i,reaction:r,shouldAddToRecent:c,tabId:d=(0,m._w)()}=s,l=(0,y.RGZ)(e,n);if(!l)return;const u=(0,y.JrV)(e,n,o);if(!u||!("content"in u))return;const h=u.sentReaction;e=(0,w.ed)(e,n,o,r),(0,a.R3)(e),r?t.startActiveReaction({containerId:i,reaction:r,tabId:d}):t.stopActiveReaction({containerId:i,tabId:d});const p=await(0,I.t9)("sendStoryReaction",{peer:l,storyId:o,reaction:r,shouldAddToRecent:c});e=(0,a.Rd)(),p||(e=(0,w.ed)(e,n,o,h)),(0,a.R3)(e)})),(0,a.iw)("activateStealthMode",((e,t,s)=>{const{isForPast:a=!0,isForFuture:n=!0}=s||{};(0,I.t9)("activateStealthMode",{isForPast:a||!0,isForFuture:n||!0})})),s(89005);var _e=s(15780),Oe=s(70735);function Fe(e,...[t=(0,m._w)()]){const{chatId:s,threadId:a}=(0,y.Btg)(e,t)||{};return s&&a?(e=(0,w.S3)(e,s,a,void 0,t),e=(0,w.qr)(e,s,a,void 0,t),e=(0,w.Pb)(e,s,a,void 0,void 0,void 0,t)):e}(0,a.iw)("openLocalTextSearch",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{chatId:n,threadId:o}=(0,y.Btg)(e,a)||{};if(n&&o)return(0,w.qr)(e,n,o,"",a)})),(0,a.iw)("closeLocalTextSearch",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return Fe(e,a)})),(0,a.iw)("setLocalTextSearchQuery",((e,t,s)=>{const{query:a,tabId:n=(0,m._w)()}=s,{chatId:o,threadId:i}=(0,y.Btg)(e,n)||{};if(!o||!i)return;const r=(0,v.uw)(o,i),{query:c}=(0,y.jUK)(e,n).localTextSearch.byChatThreadKey[r]||{};return a!==c&&(e=(0,w.Pb)(e,o,i,Oe.D,void 0,void 0,n)),(0,w.qr)(e,o,i,a,n)})),(0,a.iw)("setLocalTextSearchTag",((e,t,s)=>{const{tag:a,tabId:n=(0,m._w)()}=s,{chatId:o,threadId:i}=(0,y.Btg)(e,n)||{};if(!o||!i)return;const r=(0,v.uw)(o,i),{savedTag:c}=(0,y.jUK)(e,n).localTextSearch.byChatThreadKey[r]||{};return(0,v.Hl)(a,c)||(e=(0,w.Pb)(e,o,i,Oe.D,void 0,void 0,n)),(0,w.S3)(e,o,i,a,n)})),(0,a.iw)("setLocalMediaSearchType",((e,t,s)=>{const{mediaType:a,tabId:n=(0,m._w)()}=s,{chatId:o,threadId:i}=(0,y.Btg)(e,n)||{};if(o&&i)return(0,w.z5)(e,o,i,a,n)})),(0,a.iw)("processOpenChatOrThread",((e,t,s)=>{const{chatId:a,threadId:n=r._f,type:o="thread",shouldReplaceHistory:i=!1,shouldReplaceLast:c=!1,noForumTopicPanel:d,tabId:l=(0,m._w)()}=s,u=(0,y.Btg)(e,l),h=(0,y.jUK)(e,l);if(h.premiumModal?.promo&&h.premiumModal?.isOpen&&(e=(0,b.i)(e,{premiumModal:{...h.premiumModal,isOpen:!1}},l)),u&&u.chatId===a&&u.threadId===n&&u.type===o||(a&&(e=(0,w.O8)(e,a,n,"replyStack",[],l),e=(0,b.i)(e,{activeReactions:{}},l)),e=Fe(e=(0,w.i9)(e,l),l),e=(0,b.i)(e,{isStatisticsShown:!1,boostStatistics:void 0,contentToBeScheduled:void 0,...a!==(0,y.jUK)(e,l).forwardMessages.toChatId&&{forwardMessages:{}}},l)),a){const s=(0,y.Z1J)(e,a);s?.isForum&&!d?t.openForumPanel({chatId:a,tabId:l}):a!==(0,y.jUK)(e,l).forumPanelChatId&&t.closeForumPanel({tabId:l})}return t.updatePageTitle({tabId:l}),(0,w.Wy)(e,a,n,o,i,c,l)})),(0,a.iw)("openChatInNewTab",((e,t,s)=>{const{chatId:a,threadId:n=r._f}=s,i=(0,_e.Ex)(a,"thread",n);o.D$?window.electron.openNewWindow(i):window.open(i,"_blank")})),(0,a.iw)("openPreviousChat",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return t.updatePageTitle({tabId:a}),(0,w.Wy)(e,void 0,void 0,void 0,void 0,void 0,a)})),(0,a.iw)("openChatWithInfo",((e,t,s)=>{const{profileTab:n,forceScrollProfileTab:o=!1,tabId:i=(0,m._w)()}=s;e=(0,b.i)(e,{...(0,y.jUK)(e,i),isChatInfoShown:!0,nextProfileTab:n,forceScrollProfileTab:o},i),e={...e,lastIsChatInfoShown:!0},(0,a.R3)(e),t.openChat({...s,tabId:i})})),(0,a.iw)("openThreadWithInfo",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s;e=(0,b.i)(e,{...(0,y.jUK)(e,n),isChatInfoShown:!0},n),e={...e,lastIsChatInfoShown:!0},(0,a.R3)(e),t.openThread({...s,tabId:n})})),(0,a.iw)("openChatWithDraft",((e,t,s)=>{const{chatId:a,text:n,threadId:o=r._f,files:i,filter:c,tabId:d=(0,m._w)()}=s;return a&&t.openThread({chatId:a,threadId:o,tabId:d}),(0,b.i)(e,{requestedDraft:{chatId:a,text:n,files:i,filter:c}},d)})),(0,a.iw)("resetChatCreation",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{chatCreation:void 0},a)})),(0,a.iw)("setNewChatMembersDialogState",((e,t,s)=>{const{newChatMembersProgress:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{newChatMembersProgress:a},n)})),(0,a.iw)("openNextChat",((e,t,s)=>{const{targetIndexDelta:a,orderedIds:n,tabId:o=(0,m._w)()}=s,{chatId:i}=(0,y.Btg)(e,o)||{};if(!i)return void t.openChat({id:n[0],tabId:o});const r=n.indexOf(i);if(-1===r)return;const c=n[r+a];t.openChat({id:c,shouldReplaceHistory:!0,tabId:o})})),(0,a.iw)("closeDeleteChatFolderModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{deleteFolderDialogModal:void 0},a)})),(0,a.iw)("closeChatlistModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{chatlistModal:void 0},a)})),(0,a.iw)("requestChatTranslation",((e,t,s)=>{const{chatId:a,toLanguageCode:n,tabId:o=(0,m._w)()}=s;return(0,w.LV)(e,a,n,o)}));var De=s(89455),je=s(996),qe=s(42986);const Ge=n.ckE+n.fK3;let He;function Ve(e,t,s){const{type:a,threadId:n}=(0,y.Btg)(e)||{},o=p.Iu,i=(0,y.Z1J)(e,t),r="scheduled"===a?(0,y.yBV)(e,t):(0,y.Zwk)(e,t);if(!i||!r||!n)return;const c=s.map((e=>r[e])).filter((t=>(0,y._kf)(e,t,n).canCopy)).sort(((e,t)=>e.id-t.id)),l=[],u=[];c.forEach((t=>{const s=(0,v.eA)(i)?i:(0,y.Urc)(e,t),a=`> ${s?(0,v.OU)(o,s):t.forwardInfo?.hiddenUserName||""}:`;l.push(a),l.push(`${function(e,t){const s=(0,qe.Eb)(t),a=s?`${s} `:"",n=(0,je.X)({message:t,shouldRenderAsHtml:!0})?.join("");return`${a}${(0,qe.Kk)(e,t,n,!0)}`}(o,t)}\n`),u.push(a),u.push(`${(0,v.MK)(o,t,!1,0,!0)}\n`)})),(0,d.qN)(l.join("\n"),u.join("\n"))}(0,a.iw)("setScrollOffset",((e,t,s)=>{const{chatId:a,threadId:n,scrollOffset:o,tabId:i=(0,m._w)()}=s;return e=(0,w.pf)(e,a,n,"lastScrollOffset",o),(0,w.O8)(e,a,n,"scrollOffset",o,i)})),(0,a.iw)("setEditingId",((e,t,s)=>{const{messageId:a,tabId:n=(0,m._w)()}=s,o=(0,y.Btg)(e,n);if(!o)return;const{chatId:i,threadId:r,type:c}=o,d="scheduled"===c?"editingScheduledId":"editingId";return(0,w.pf)(e,i,r,d,a)})),(0,a.iw)("setEditingDraft",((e,t,s)=>{const{text:a,chatId:n,threadId:o,type:i}=s,r="scheduled"===i?"editingScheduledDraft":"editingDraft";return(0,w.pf)(e,n,o,r,a)})),(0,a.iw)("editLastMessage",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{chatId:n,threadId:o}=(0,y.Btg)(e,a)||{};if(!n||!o)return;const i=(0,y.Zwk)(e,n),r=(0,y.Cbz)(e,n,o,a);if(!i||!r)return;const c=(0,h.dF)(r,(t=>Boolean(i[t]&&(0,y._kf)(e,i[t],o).canEdit)));return c?(0,w.pf)(e,n,o,"editingId",c):void 0})),(0,a.iw)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:a,tabId:n=(0,m._w)()}=s,{chatId:o,threadId:i}=(0,y.Btg)(e,n)||{};if(!o||!i)return;const c=(0,y.Zwk)(e,o),d=(0,y.Cbz)(e,o,i,n);if(!c||!d)return;const l=(0,y.Mst)(e,o,i)?.replyInfo;let u;if((0,y.b9T)(e,o,i,n)&&l?.replyToMsgId){const e=Object.keys(c),t=e.indexOf(l.replyToMsgId.toString())+a;u=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(i===r._f)u=(0,y.xMv)(e,o);else{const t=(0,y.tZg)(e,o,i);u=t?.lastMessageId}t.updateDraftReplyInfo({replyToMsgId:u,tabId:n}),t.focusMessage({chatId:o,threadId:i,messageId:u,tabId:n})})),(0,a.iw)("openAudioPlayer",((e,t,s)=>{const{chatId:a,threadId:n,messageId:o,origin:i,volume:r,playbackRate:c,isMuted:d,tabId:l=(0,m._w)()}=s,u=(0,y.jUK)(e,l);return(0,b.i)(e,{audioPlayer:{chatId:a,threadId:n,messageId:o,origin:i??u.audioPlayer.origin,volume: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,a.iw)("setAudioPlayerVolume",((e,t,s)=>{const{volume:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{audioPlayer:{...(0,y.jUK)(e,n).audioPlayer,volume:a,isMuted:!1}},n)})),(0,a.iw)("setAudioPlayerPlaybackRate",((e,t,s)=>{const{playbackRate:a,isPlaybackRateActive:n,tabId:o=(0,m._w)()}=s;return e={...e,audioPlayer:{...e.audioPlayer,lastPlaybackRate:a,isLastPlaybackRateActive:n}},(0,b.i)(e,{audioPlayer:{...(0,y.jUK)(e,o).audioPlayer,playbackRate:a,isPlaybackRateActive:n}},o)})),(0,a.iw)("setAudioPlayerMuted",((e,t,s)=>{const{isMuted:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{audioPlayer:{...(0,y.jUK)(e,n).audioPlayer,isMuted:a}},n)})),(0,a.iw)("setAudioPlayerOrigin",((e,t,s)=>{const{origin:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{audioPlayer:{...(0,y.jUK)(e,n).audioPlayer,origin:a}},n)})),(0,a.iw)("closeAudioPlayer",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);return(0,b.i)(e,{audioPlayer:{volume:n.audioPlayer.volume,playbackRate:n.audioPlayer.playbackRate,isPlaybackRateActive:n.audioPlayer.isPlaybackRateActive,isMuted:n.audioPlayer.isMuted}},a)})),(0,a.iw)("openPollResults",((e,t,s)=>{const{chatId:n,messageId:o,tabId:i=(0,m._w)()}=s,r=(0,y.Jf5)(e,(0,x.W7)(),i),c=(0,y.jUK)(e,i);if(r){if(n!==c.pollResults.chatId||o!==c.pollResults.messageId)return(0,b.i)(e,{pollResults:{chatId:n,messageId:o,voters:{}}},i)}else window.setTimeout((()=>{e=(0,a.Rd)(),e=(0,b.i)(e,{pollResults:{chatId:n,messageId:o,voters:{}}},i),(0,a.R3)(e)}),450)})),(0,a.iw)("closePollResults",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{pollResults:{}},a)})),(0,a.iw)("focusLastMessage",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.Btg)(e,a);if(!n)return;const{chatId:o,threadId:i,type:c}=n,d=(0,v._o)(o,i,e.currentUserId);let l;if(i===r._f)if("pinned"===c){const t=(0,y.KBA)(e,o,r._f);if(!t?.length)return;l=t[t.length-1]}else{l=(0,y.xMv)(e,o);const t=(0,y.Zwk)(e,o),s=Object.values(t).reverse()[0];l&&(0,v.Pt)(s)&&s.id>l&&(l=s.id)}else if(d)l=(0,y.xMv)(e,String(i),"saved");else{const t=(0,y.tZg)(e,o,i);l=t?.lastMessageId}l&&t.focusMessage({chatId:o,threadId:i,messageListType:c,messageId:l,noHighlight:!0,noForumTopicPanel:!0,tabId:a})})),(0,a.iw)("focusNextReply",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{},o=(0,y.Btg)(e,n);if(!o)return;const{chatId:i,threadId:r}=o,c=(0,y.p9o)(e,i,r,n);if(c&&0!==c.length){const s=c.pop();e=(0,w.O8)(e,i,r,"replyStack",[...c],n),(0,a.R3)(e),t.focusMessage({chatId:i,threadId:r,messageId:s,tabId:n,noForumTopicPanel:!0})}else t.focusLastMessage({tabId:n})})),(0,a.iw)("focusMessage",((e,t,s)=>{const{chatId:n,threadId:o=r._f,messageListType:i="thread",noHighlight:d,groupedId:l,groupedChatId:u,replyMessageId:p,isResizingContainer:g,shouldReplaceHistory:f,noForumTopicPanel:I,quote:v,tabId:b=(0,m._w)()}=s;let{messageId:P}=s;if(void 0!==l){const t=(0,y.y84)(e,u,l);t?.length&&([P]=(0,h.oA)(t))}const Z=(0,y.Btg)(e,b),S=!Z||n!==Z.chatId||o!==Z.threadId||i!==Z.type;if(He&&(clearTimeout(He),He=void 0),He=window.setTimeout((()=>{e=(0,a.Rd)(),e=(0,w.cq)({global:e},b),e=(0,w.wV)(e,void 0,b),(0,a.R3)(e)}),d?Ge:1500),e=(0,w.cq)({global:e,chatId:n,messageId:P,threadId:o,noHighlight:d,isResizingContainer:g,quote:v},b),e=(0,w.wV)(e,void 0,b),p){const t=(0,y.p9o)(e,n,o,b)||[];e=(0,w.O8)(e,n,o,"replyStack",[...t,p],b)}S&&(e=(0,w.wV)(e,c.fo.Static,b));const C=(0,y.Cbz)(e,n,o,b);if(C&&C.includes(P))return(0,a.R3)(e,{forceOnHeavyAnimation:!0}),void t.openThread({chatId:n,threadId:o,type:i,shouldReplaceHistory:f,noForumTopicPanel:I,tabId:b});if(S&&(e=(0,w.O8)(e,n,o,"viewportIds",void 0,b)),C&&!S){const t=P>C[0]?c.fo.Down:c.fo.Up;e=(0,w.wV)(e,t,b)}(0,a.R3)(e,{forceOnHeavyAnimation:!0}),t.openThread({chatId:n,threadId:o,type:i,shouldReplaceHistory:f,noForumTopicPanel:I,tabId:b}),t.loadViewportMessages({chatId:n,threadId:o,tabId:b,shouldForceRender:!0})})),(0,a.iw)("openForwardMenu",((e,t,s)=>{const{fromChatId:a,messageIds:n,storyId:o,groupedId:i,withMyScore:r,tabId:c=(0,m._w)()}=s;let d;return i&&(d=(0,y.xHX)(e,a,i)),(0,b.i)(e,{forwardMessages:{fromChatId:a,messageIds:d||n,storyId:o,isModalShown:!0,withMyScore:r}},c)})),(0,a.iw)("changeForwardRecipient",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{forwardMessages:{...(0,y.jUK)(e,a).forwardMessages,toChatId:void 0,isModalShown:!0,noAuthors:!1,noCaptions:!1}},a)})),(0,a.iw)("setForwardNoAuthors",((e,t,s)=>{const{noAuthors:a,tabId:n=(0,m._w)()}=s,o=(0,y.jUK)(e,n);return(0,b.i)(e,{forwardMessages:{...o.forwardMessages,noAuthors:a,noCaptions:a&&o.forwardMessages.noCaptions}},n)})),(0,a.iw)("setForwardNoCaptions",((e,t,s)=>{const{noCaptions:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{forwardMessages:{...(0,y.jUK)(e,n).forwardMessages,noCaptions:a,noAuthors:a}},n)})),(0,a.iw)("exitForwardMode",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{};e=(0,b.i)(e,{forwardMessages:{}},n),(0,a.R3)(e)})),(0,a.iw)("openForwardMenuForSelectedMessages",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);if(!n.selectedMessages)return;const{chatId:o,messageIds:i}=n.selectedMessages;t.openForwardMenu({fromChatId:o,messageIds:i,tabId:a})})),(0,a.iw)("cancelMessageMediaDownload",((e,t,s)=>{const{message:a,tabId:n=(0,m._w)()}=s;return(0,w.wI)(e,a,n)})),(0,a.iw)("cancelMessagesMediaDownload",((e,t,s)=>{const{messages:a,tabId:n=(0,m._w)()}=s;for(const t of a)e=(0,w.wI)(e,t,n);return e})),(0,a.iw)("downloadMessageMedia",((e,t,s)=>{const{message:a,tabId:n=(0,m._w)()}=s;return(0,w.fC)(e,a,n)})),(0,a.iw)("downloadSelectedMessages",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);if(!n.selectedMessages)return;const{chatId:o,messageIds:i}=n.selectedMessages,{threadId:r}=(0,y.Btg)(e,a)||{},c=(0,y.Zwk)(e,o);c&&r&&i.map((e=>c[e])).filter((t=>(0,y._kf)(e,t,r).canDownload)).forEach((e=>t.downloadMessageMedia({message:e,tabId:a})))})),(0,a.iw)("enterMessageSelectMode",((e,t,s)=>{const{messageId:a,tabId:n=(0,m._w)()}=s||{},o=(0,y.jrE)(e,n);return o?(0,w.M6)(e,o.id,a,n):e})),(0,a.iw)("toggleMessageSelection",((e,t,s)=>{const{messageId:n,groupedId:i,childMessageIds:r,withShift:c,tabId:d=(0,m._w)()}=s,l=(0,y.Btg)(e,d);if(!l)return;const{chatId:u,threadId:h,type:p}=l;e=(0,w.Ob)(e,u,h,p,n,i,r,c,d),(0,a.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${o.$b?"long tap":"right click"} on a message.`,tabId:d}))})),(0,a.iw)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,a.iw)("exitMessageSelectMode",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,w.i9)(e,a)})),(0,a.iw)("openPollModal",((e,t,s)=>{const{isQuiz:a,tabId:n=(0,m._w)()}=s||{};return(0,b.i)(e,{pollModal:{isOpen:!0,isQuiz:a}},n)})),(0,a.iw)("closePollModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{pollModal:{isOpen:!1}},a)})),(0,a.iw)("checkVersionNotification",((e,t)=>{if(n.V61&&Date.now()>Number(n.V61)+2592e5)return;const s="10.9.0".split(".").slice(0,2).join("."),{serviceNotifications:a}=e;if(a.find((({version:e})=>e===s)))return;const o={chatId:n.awM,date:(0,we.bp)(),content:{text:(0,De.ZP)("**Telegram Web A Digest**\n\nMany new features and useful optimizations have been added in recent months. Here is a brief overview of what's been happening in Web A since August.\n\n**September – November** \n\n✏️ __General__\n• [Reply Revolution](https://telegram.org/blog/reply-revolution#reply-revolution) – the app learned to quote specific parts of any message, making your responses 100% precise.\n• Also, [Quote Formatting](https://telegram.org/blog/reply-revolution#quote-formatting) have arrived.\n\n📣 __Channels__\n• Channels added [boosts](https://telegram.org/blog/channel-stories#stories-for-channels) and [giveaways.](https://telegram.org/blog/giveaways#free-telegram-premium) \n• Users also got an option to reassign their boosts between channels.\n\n🌄 __Stories__\n• Numerous improvements have been made to the animations flow, ensuring the stories bar expands more smoothly. Additionally, a package of optimizations has been added to enhance the performance of stories on mobile devices.\n• Stories have been introduced for [channels,](https://telegram.org/blog/channel-stories#stories-for-channels) and the story viewer has been updated with new gestures to expand and reply.\n\n⚙️ __Settings__\n• The app has added an option, 'Who can find me by phone number,' along with a setting under 'Privacy and Security' to manage the visibility of your bio.\n\n✨ __Extra__\n• Some further improvements have been made to the Mini Apps area.\n• New security notifications have been added to the chat list to alert you when your account is logged into from a new device.\n• New design for code blocks formatting.\n\n**December – February**\n\n✏️ __General__\n• [Saved Messages 2.0](https://telegram.org/blog/new-saved-messages-and-9-more#saved-messages-2-0) – including tags, My Notes, Replies and forwards from hidden authors.\n• [One-Time Voice Messages](https://telegram.org/blog/new-saved-messages-and-9-more#one-time-voice-and-video-messages) including both listening and recording. Added support for viewing One-Time Video Messages.\n• [Read-Time in Private Chats](https://telegram.org/blog/new-saved-messages-and-9-more#read-time-in-private-chats)\n• You can now replace media when editing messages.\n• The app learned to [preserve the selected mode](https://telegram.org/blog/similar-channels#improvements-for-topics) for topics in groups.\n• Whenever you create a small group, Web A suggests a name for it based on users' name you have added.\n\n📣 __Channels__ \n• Added [custom channel reactions.](https://telegram.org/blog/similar-channels#custom-reactions-for-channels)\n• Implemented [channel stories stats.](https://telegram.org/blog/similar-channels#story-stats-for-channels)\n• Channel emoji statuses.\n• [Similar Channels.](https://telegram.org/blog/similar-channels#similar-channels)\n\n👥 __Groups__\n• [9 new features for groups.](https://telegram.org/blog/february2024)\n\n🤖 __Bots__\n• Edit your bots info right from their profile.\n\n🌄 __Stories__\n• Added support for [forwarded stories](https://telegram.org/blog/posts-in-stories-and-more#view-reposts-and-more) and [channel posts in stories.](https://telegram.org/blog/posts-in-stories-and-more#share-posts-in-stories)\n\n✨ __Extra__\n• Giveaway Improvements: displaying winners list and additional prizes.\n\n**March**\n\n📣 __Channels__ \n• Admins will soon be able to launch giveaways in their channels.\n\n✨ __Extra__\n• Added support for Emoji v15.1.\n• Some design enhancements for shared contacts, links preview and more.\n",!0)},isOutgoing:!1};t.createServiceNotification({message:o,version:s})})),(0,a.iw)("createServiceNotification",((e,t,s)=>{const{message:o,version:i}=s,{serviceNotifications:r}=e,c=Math.max((0,y.xMv)(e,n.awM)||0,...r.map((({id:e})=>e))),d=(r.length+1)/1e3,l=Math.floor(c)+d;o.previousLocalId=o.id,o.id=l;const u={id:l,message:o,version:i,isUnread:!0};e={...e,serviceNotifications:[...r.slice(-1e3),u]},(0,a.R3)(e),t.apiUpdate({"@type":"newMessage",id:o.id,chatId:o.chatId,message:o})})),(0,a.iw)("openReactorListModal",((e,t,s)=>{const{chatId:a,messageId:n,tabId:o=(0,m._w)()}=s;return(0,b.i)(e,{reactorModal:{chatId:a,messageId:n}},o)})),(0,a.iw)("closeReactorListModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{reactorModal:void 0},a)})),(0,a.iw)("openSeenByModal",((e,t,s)=>{const{chatId:a,messageId:n,tabId:o=(0,m._w)()}=s;return(0,b.i)(e,{seenByModal:{chatId:a,messageId:n}},o)})),(0,a.iw)("closeSeenByModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{seenByModal:void 0},a)})),(0,a.iw)("openPrivacySettingsNoticeModal",((e,t,s)=>{const{chatId:a,isReadDate:n,tabId:o=(0,m._w)()}=s;return(0,b.i)(e,{privacySettingsNoticeModal:{chatId:a,isReadDate:n}},o)})),(0,a.iw)("closePrivacySettingsNoticeModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{privacySettingsNoticeModal:void 0},a)})),(0,a.iw)("openChatLanguageModal",((e,t,s)=>{const{chatId:a,messageId:n,tabId:o=(0,m._w)()}=s,i=n?(0,y.Bdn)(e,a,n,o):(0,y.lpX)(e,a,o);return(0,b.i)(e,{chatLanguageModal:{chatId:a,messageId:n,activeLanguage:i}},o)})),(0,a.iw)("closeChatLanguageModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{chatLanguageModal:void 0},a)})),(0,a.iw)("copySelectedMessages",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);if(!n.selectedMessages)return;const{chatId:o,messageIds:i}=n.selectedMessages;Ve(e,o,i)})),(0,a.iw)("copyMessagesByIds",((e,t,s)=>{const{messageIds:a,tabId:n=(0,m._w)()}=s,o=(0,y.jrE)(e,n);a&&0!==a.length&&o&&Ve(e,o.id,a)})),(0,a.iw)("openOneTimeMediaModal",((e,t,s)=>{const{message:n,tabId:o=(0,m._w)()}=s;e=(0,b.i)(e,{oneTimeMediaModal:{message:n}},o),(0,a.R3)(e)})),(0,a.iw)("closeOneTimeMediaModal",((e,t,s)=>{const{tabId:n=(0,m._w)()}=s||{};e=(0,b.i)(e,{oneTimeMediaModal:void 0},n),(0,a.R3)(e)})),(0,a.iw)("setGlobalSearchQuery",((e,t,s)=>{const{query:a,tabId:n=(0,m._w)()}=s,{chatId:o}=(0,y.jUK)(e,n).globalSearch;return(0,w.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!o,messages:!0}}:{fetchingStatus:void 0},query:a},n)})),(0,a.iw)("setGlobalSearchClosing",((e,t,s)=>{const{tabId:a=(0,m._w)(),isClosing:n}=s||{};return(0,w.No)(e,{isClosing:n},a)})),(0,a.iw)("addRecentlyFoundChatId",((e,t,s)=>{const{id:a}=s,{recentlyFoundChatIds:n}=e;if(!n)return{...e,recentlyFoundChatIds:[a]};const o=n.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),{...e,recentlyFoundChatIds:o}})),(0,a.iw)("clearRecentlyFoundChats",(e=>({...e,recentlyFoundChatIds:void 0}))),(0,a.iw)("setGlobalSearchContent",((e,t,s)=>{const{content:a,tabId:n=(0,m._w)()}=s;return(0,w.Og)(e,a,n)})),(0,a.iw)("setGlobalSearchChatId",((e,t,s)=>{const{id:a,tabId:n=(0,m._w)()}=s;return(0,w.No)(e,{chatId:a,query:void 0,resultsByType:void 0},n)})),(0,a.iw)("setStickerSearchQuery",((e,t,s)=>{const{query:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{stickerSearch:{query:a,resultIds:void 0}},n)})),(0,a.iw)("setGifSearchQuery",((e,t,s)=>{const{query:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{gifSearch:{query:a,offset:void 0,results:void 0}},n)})),(0,a.iw)("setUserSearchQuery",((e,t,s)=>{const{query:a,tabId:n=(0,m._w)()}=s;return(0,w.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a},n)})),(0,a.iw)("openAddContactDialog",((e,t,s)=>{const{userId:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{newContact:{userId:a}},n)})),(0,a.iw)("openNewContactDialog",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{newContact:{isByPhoneNumber:!0}},a)})),(0,a.iw)("closeNewContactDialog",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,w.ft)(e,a)})),s(73456);var $e=s(69995);const ze=/^\d+\.\d+(\.\d+)?$/;var Ke=s(91947);function Je(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 We(e){o.D$?window.electron.setWindowTitle(e):document.title!==e&&(document.title=e)}const Ye=(0,f.Ds)(We,200,!1);let Xe,Qe;(0,a.iw)("toggleChatInfo",((e,t,s)=>{const{force:a,tabId:n=(0,m._w)()}=s||{},o=void 0!==a?a:!(0,y.jUK)(e,n).isChatInfoShown;return e=(0,b.i)(e,{isChatInfoShown:o},n),{...e,lastIsChatInfoShown:o}})),(0,a.iw)("setLeftColumnWidth",((e,t,s)=>{const{leftColumnWidth:a}=s;return{...e,leftColumnWidth:a}})),(0,a.iw)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,a.iw)("toggleManagement",((e,t,s)=>{const{force:a,tabId:n=(0,m._w)()}=s||{},{chatId:o}=(0,y.Btg)(e,n)||{};if(!o)return;const i=(0,y.jUK)(e,n);return(0,b.i)(e,{management:{byChatId:{...i.management.byChatId,[o]:{...i.management.byChatId[o],isActive:void 0!==a?a:!(i.management.byChatId[o]||{}).isActive}}}},n)})),(0,a.iw)("requestNextManagementScreen",((e,t,s)=>{const{screen:a,tabId:n=(0,m._w)()}=s||{},{chatId:o}=(0,y.Btg)(e,n)||{};if(!o)return;const i=(0,y.jUK)(e,n);return(0,b.i)(e,{management:{byChatId:{...i.management.byChatId,[o]:{...i.management.byChatId[o],isActive:!0,nextScreen:a}}}},n)})),(0,a.iw)("closeManagement",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{chatId:n}=(0,y.Btg)(e,a)||{};if(!n)return;const o=(0,y.jUK)(e,a);return(0,b.i)(e,{management:{byChatId:{...o.management.byChatId,[n]:{...o.management.byChatId[n],isActive:!1}}}},a)})),(0,a.iw)("processOpenChatOrThread",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s;if((0,x.W7)()||(0,x.c9)())return(0,b.i)(e,{isLeftColumnShown:0===(0,y.jUK)(e,a).messageLists.length},a)})),(0,a.iw)("resetNextProfileTab",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{chatId:n}=(0,y.Btg)(e,a)||{};if(n)return(0,b.i)(e,{nextProfileTab:void 0,forceScrollProfileTab:!1},a)})),(0,a.iw)("toggleStatistics",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);return(0,b.i)(e,{isStatisticsShown:!n.isStatisticsShown,statistics:{...n.statistics,currentMessageId:void 0,currentStoryId:void 0}},a)})),(0,a.iw)("toggleMessageStatistics",((e,t,s)=>{const{tabId:a=(0,m._w)(),messageId:n}=s||{};return(0,b.i)(e,{statistics:{...(0,y.jUK)(e,a).statistics,currentMessageId:n,currentStoryId:void 0}},a)})),(0,a.iw)("toggleStoryStatistics",((e,t,s)=>{const{tabId:a=(0,m._w)(),storyId:n}=s||{};return(0,b.i)(e,{statistics:{...(0,y.jUK)(e,a).statistics,currentStoryId:n,currentMessageId:void 0}},a)})),(0,a.iw)("toggleLeftColumn",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{isLeftColumnShown:!(0,y.jUK)(e,a).isLeftColumnShown},a)})),(0,a.iw)("addRecentEmoji",((e,t,s)=>{const{emoji:a}=s,{recentEmojis:n}=e;if(!n)return{...e,recentEmojis:[a]};const o=n.filter((e=>e!==a));return o.unshift(a),o.length>32&&o.pop(),{...e,recentEmojis:o}})),(0,a.iw)("addRecentSticker",((e,t,s)=>{const{sticker:a}=s,{recent:n}=e.stickers;if(!n)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[a]}}};const o=n.stickers.filter((e=>e.id!==a.id));return o.unshift(a),{...e,stickers:{...e.stickers,recent:{...n,stickers:o}}}})),(0,a.iw)("addRecentCustomEmoji",((e,t,s)=>{const{documentId:a}=s,{recentCustomEmojis:n}=e;if(!n)return{...e,recentCustomEmojis:[a]};const o=n.filter((e=>e!==a));return o.unshift(a),o.length>32&&o.pop(),{...e,recentCustomEmojis:o}})),(0,a.iw)("clearRecentCustomEmoji",(e=>({...e,recentCustomEmojis:[]}))),(0,a.iw)("reorderStickerSets",((e,t,s)=>{const{order:a,isCustomEmoji:n}=s;return{...e,stickers:{...e.stickers,added:{setIds:n?e.stickers.added.setIds:a}},customEmojis:{...e.customEmojis,added:{setIds:n?a:e.customEmojis.added.setIds}}}})),(0,a.iw)("showNotification",((e,t,s)=>{const{tabId:a=(0,m._w)(),...n}=s;n.localId=(0,$e.Z)();const o=[...(0,y.jUK)(e,a).notifications],i=o.findIndex((e=>e.message===n.message));return-1!==i&&o.splice(i,1),o.push(n),(0,b.i)(e,{notifications:o},a)})),(0,a.iw)("showAllowedMessageTypesNotification",((e,t,s)=>{const{chatId:a,tabId:n=(0,m._w)()}=s,o=(0,y.Z1J)(e,a);if(!o)return;const i=(0,y.x67)(e,a),{canSendPlainText:r,canSendPhotos:c,canSendVideos:d,canSendDocuments:l,canSendAudios:u,canSendStickers:g,canSendRoundVideos:f,canSendVoices:I}=(0,v.H5)(o,i),w=(0,h.oA)([r?"Chat.SendAllowedContentTypeText":void 0,c?"Chat.SendAllowedContentTypePhoto":void 0,d?"Chat.SendAllowedContentTypeVideo":void 0,I?"Chat.SendAllowedContentTypeVoiceMessage":void 0,f?"Chat.SendAllowedContentTypeVideoMessage":void 0,l?"Chat.SendAllowedContentTypeFile":void 0,u?"Chat.SendAllowedContentTypeMusic":void 0,g?"Chat.SendAllowedContentTypeSticker":void 0]).map((e=>p.Iu(e)));if(!w.length)return void t.showNotification({message:p.Iu("Chat.SendNotAllowedText"),tabId:n});const b=p.Iu("AutoDownloadSettings.LastDelimeter"),P=w.join(", ").replace(/,([^,]*)$/,`${b}$1`);t.showNotification({message:p.Iu("Chat.SendAllowedContentText",P),tabId:n})})),(0,a.iw)("dismissNotification",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s,n=(0,y.jUK)(e,a).notifications.filter((({localId:e})=>e!==s.localId));return(0,b.i)(e,{notifications:n},a)})),(0,a.iw)("showDialog",((e,t,s)=>{const{data:a,tabId:n=(0,m._w)()}=s;if("message"in a&&a.hasErrorKey&&!(0,Ke.ZP)(a))return e;const o=[...(0,y.jUK)(e,n).dialogs];if("message"in a){const e=o.findIndex((e=>e.message===a.message));-1!==e&&o.splice(e,1)}return o.push(a),(0,b.i)(e,{dialogs:o},n)})),(0,a.iw)("dismissDialog",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=[...(0,y.jUK)(e,a).dialogs];return n.pop(),(0,b.i)(e,{dialogs:n},a)})),(0,a.iw)("toggleSafeLinkModal",((e,t,s)=>{const{url:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{safeLinkModalUrl:a},n)})),(0,a.iw)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{historyCalendarSelectedAt:a},n)})),(0,a.iw)("closeHistoryCalendar",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{historyCalendarSelectedAt:void 0},a)})),(0,a.iw)("openGame",((e,t,s)=>{const{url:n,chatId:o,messageId:i,tabId:r=(0,m._w)()}=s,c=(0,y.hjO)(e,o,i);if(!c)return;const d=c.viaBotId||c.senderId;if(d){if(!(0,y.LM9)(e,d))return e=(0,b.i)(e,{botTrustRequest:{botId:d,type:"game",onConfirm:{action:"openGame",payload:s}}},r),void(0,a.R3)(e);e=(0,b.i)(e,{openedGame:{url:n,chatId:o,messageId:i}},r),(0,a.R3)(e)}})),(0,a.iw)("closeGame",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{openedGame:void 0},a)})),(0,a.iw)("requestConfetti",((e,t,s)=>{const{tabId:a=(0,m._w)(),...n}=s;if((0,y.FOo)(e))return(0,b.i)(e,{confetti:{lastConfettiTime:Date.now(),...n}},a)})),(0,a.iw)("updateAttachmentSettings",((e,t,s)=>{const{shouldCompress:a,shouldSendGrouped:n}=s;return{...e,attachmentSettings:{shouldCompress:a??e.attachmentSettings.shouldCompress,shouldSendGrouped:n??e.attachmentSettings.shouldSendGrouped}}})),(0,a.iw)("openLimitReachedModal",((e,t,s)=>{const{limit:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{limitReachedModal:{limit:a}},n)})),(0,a.iw)("closeLimitReachedModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{limitReachedModal:void 0},a)})),(0,a.iw)("closeStickerSetModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{openedStickerSetShortName:void 0},a)})),(0,a.iw)("openCustomEmojiSets",((e,t,s)=>{const{setIds:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{openedCustomEmojiSetIds:a},n)})),(0,a.iw)("closeCustomEmojiSets",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{openedCustomEmojiSetIds:void 0},a)})),(0,a.iw)("updateLastRenderedCustomEmojis",((e,t,s)=>{const{ids:a}=s,{lastRendered:o}=e.customEmojis;return{...e,customEmojis:{...e.customEmojis,lastRendered:(0,h.Tw)([...o,...a]).slice(0,n.j7i)}}})),(0,a.iw)("openCreateTopicPanel",((e,t,s)=>{const{chatId:a,tabId:n=(0,m._w)()}=s;return(0,y.jrE)(e,n)||t.openChat({id:a,tabId:n}),(0,b.i)(e,{createTopicPanel:{chatId:a}},n)})),(0,a.iw)("closeCreateTopicPanel",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{createTopicPanel:void 0},a)})),(0,a.iw)("openEditTopicPanel",((e,t,s)=>{const{chatId:a,topicId:n,tabId:o=(0,m._w)()}=s;return(0,y.jrE)(e,o)||t.openChat({id:a,tabId:o}),(0,b.i)(e,{editTopicPanel:{chatId:a,topicId:n}},o)})),(0,a.iw)("closeEditTopicPanel",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{editTopicPanel:void 0},a)})),(0,a.iw)("updateArchiveSettings",((e,t,s)=>{const{archiveSettings:a}=e,{isHidden:n=a.isHidden,isMinimized:o=a.isMinimized}=s;return{...e,archiveSettings:{isHidden:n,isMinimized:o}}})),(0,a.iw)("openMapModal",((e,t,s)=>{const{geoPoint:a,zoom:n,tabId:o=(0,m._w)()}=s;return(0,b.i)(e,{mapModal:{point:a,zoom:n}},o)})),(0,a.iw)("closeMapModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{mapModal:void 0},a)})),(0,a.iw)("checkAppVersion",(e=>{fetch(`version.txt?${Date.now()}`).then((e=>e.text())).then((t=>{(function(e,t,s){const a=e.trim();return!!ze.test(a)&&a!==t})(t=t.trim(),"10.9.0")&&(e=(0,a.Rd)(),e={...e,isAppUpdateAvailable:!0},(0,a.R3)(e))})).catch((e=>{n.eMD&&console.error("[checkAppVersion failed] ",e)}))})),(0,a.iw)("setIsElectronUpdateAvailable",((e,t,s)=>{e=(0,a.Rd)(),e={...e,isElectronUpdateAvailable:Boolean(s)},(0,a.R3)(e)})),(0,a.iw)("afterHangUp",(e=>{(0,y.jUK)(e,(0,m._w)()).multitabNextAction&&(0,m.g)()})),(0,a.iw)("onTabFocusChange",((e,t,s)=>{const{isBlurred:a,tabId:n=(0,m._w)()}=s;return a?(Xe&&clearInterval(Xe),Xe=window.setInterval((()=>{t.updatePageTitle({tabId:n})}),500)):(clearInterval(Xe),Xe=void 0),e=(0,b.i)(e,{isBlurred:a},n),{...e,initialUnreadNotifications:a?(0,ge.xW)():void 0}})),(0,a.iw)("updatePageTitle",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{canDisplayChatInTitle:i}=e.settings.byKey,r=e.currentUserId;if(document.title.includes(n.ouc))return Je(!1),void We(`${n.Tih} ${n.ouc}`);if(e.initialUnreadNotifications&&Math.round(Date.now()/1e3)%2==0){const t=(0,ge.xW)()-e.initialUnreadNotifications;if(t>0)return We(`${t} notification${t>1?"s":""}`),void Je(!0)}Je(!1);const c=(0,y.Btg)(e,a);if(c&&i&&!e.passcode.isScreenLocked){const{chatId:t,threadId:s}=c,a=(0,y.Z1J)(e,t);if(a){const e=(0,v.U)(p.Iu,a,t===r);return a.isForum&&a.topics?.[s]?void Ye(`${e} › ${a.topics[s].title}`):void Ye(e)}}We(o.D$?"":n.Tih)})),(0,a.iw)("closeInviteViaLinkModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s??{};return(0,b.i)(e,{inviteViaLinkModal:void 0},a)}));let et,tt=0;(0,pe.ll)((e=>{const{updatePageTitle:t,updateIsOnline:s}=(0,a.Sv)(),n=e.passcode.isScreenLocked!==Qe,o=Object.values(e.byTabId).filter((e=>e.isBlurred)).length,i=(0,y.jUK)(e,(0,m._w)()).isMasterTab;n&&t(),o!==tt&&i&&(et&&clearTimeout(et),et=window.setTimeout((()=>{e=(0,a.Rd)();const t=Object.values(e.byTabId).filter((e=>e.isBlurred)).length;s(t!==(0,m.s1)().length)}),100)),Qe=e.passcode.isScreenLocked,tt=o})),(0,a.iw)("closePaymentModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a).payment.status;return e=(0,w.bp)(e,a),e=(0,w.WY)(e,a),(0,b.i)(e,{payment:{...(0,y.jUK)(e,a).payment,status:n}},a)})),(0,a.iw)("addPaymentError",((e,t,s)=>{const{error:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{payment:{...(0,y.jUK)(e,n).payment,status:"failed",error:a}},n)})),(0,a.iw)("closeGiftCodeModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{giftCodeModal:void 0},a)}));var st=s(88422);(0,a.iw)("openMediaViewer",((e,t,s)=>{const{chatId:a,threadId:o,mediaId:i,avatarOwnerId:r,profilePhotoIndex:c,origin:d,volume:l,playbackRate:u,isMuted:h,tabId:p=(0,m._w)()}=s,g=(0,y.jUK)(e,p);return(0,b.i)(e,{mediaViewer:{...g.mediaViewer,chatId:a,threadId:o,mediaId:i,avatarOwnerId:r,profilePhotoIndex:c,origin:d,isHidden:!1,volume:l??g.mediaViewer.volume,playbackRate:u||g.mediaViewer.playbackRate||e.mediaViewer.lastPlaybackRate||n.mwi,isMuted:h||g.mediaViewer.isMuted},forwardMessages:{}},p)})),(0,a.iw)("closeMediaViewer",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{volume:n,isMuted:o,playbackRate:i,isHidden:r}=(0,y.jUK)(e,a).mediaViewer;return(0,b.i)(e,{mediaViewer:{volume:n,isMuted:o,isHidden:r,playbackRate:i}},a)})),(0,a.iw)("setMediaViewerVolume",((e,t,s)=>{const{volume:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{mediaViewer:{...(0,y.jUK)(e,n).mediaViewer,volume:a,isMuted:!1}},n)})),(0,a.iw)("setMediaViewerPlaybackRate",((e,t,s)=>{const{playbackRate:a,tabId:n=(0,m._w)()}=s;return e={...e,mediaViewer:{...e.mediaViewer,lastPlaybackRate:a}},(0,b.i)(e,{mediaViewer:{...(0,y.jUK)(e,n).mediaViewer,playbackRate:a}},n)})),(0,a.iw)("setMediaViewerMuted",((e,t,s)=>{const{isMuted:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{mediaViewer:{...(0,y.jUK)(e,n).mediaViewer,isMuted:a}},n)})),(0,a.iw)("setMediaViewerHidden",((e,t,s)=>{const{isHidden:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{mediaViewer:{...(0,y.jUK)(e,n).mediaViewer,isHidden:a}},n)}));var at=s(95281),nt=s(17210),ot=s(5872),it=s(35369);let rt=!1;(0,f.Gq)((()=>{(0,a.Rd)().passcode.hasPasscode&&!rt&&1===Object.keys((0,a.Rd)().byTabId).length&&(0,nt.jv)()})),(0,a.iw)("setPasscode",(async(e,t,s)=>{const{passcode:n,tabId:o=(0,m._w)()}=s;e=(0,w.vu)(e,{isLoading:!0}),(0,a.R3)(e),await(0,at.AU)(n);const i=JSON.stringify({...(0,nt.K8)(),userId:e.currentUserId});e=(0,a.Rd)();const r=(0,ot.Uf)((0,w.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}));try{await(0,at.H4)(i,r),(0,m.Z6)(),e=(0,a.Rd)(),e=(0,w.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}),(0,a.R3)(e),(0,ot.jA)(!0)}catch(s){(0,at.J9)(),e=(0,a.Rd)(),e=(0,w.vu)(e,{isLoading:!1}),(0,a.R3)(e),t.showNotification({message:"Failed to set passcode",tabId:o}),t.requestNextSettingsScreen({screen:c.MT.PasscodeDisabled,tabId:o})}})),(0,a.iw)("clearPasscode",(e=>((0,at.C8)(),(0,w.Kn)(e)))),(0,a.iw)("unlockScreen",((e,t,s)=>{const n=Object.values(e.byTabId),{sessionJson:o,globalJson:i}=s,r=JSON.parse(o);(0,nt.wX)(r,r.userId);const c=e;(e=JSON.parse(i)).byTabId=c.byTabId,(0,ot.nE)(e,(0,h.Xh)(it.g9)),e=(0,w.vu)(e,{isScreenLocked:!1,error:void 0,invalidAttemptsCount:0}),(0,a.R3)(e),(0,m.Z6)(),n.forEach((({id:e,isMasterTab:s})=>t.init({tabId:e,isMasterTab:s}))),t.initApi()})),(0,a.iw)("decryptSession",((e,t,s)=>{const{passcode:a}=s;(0,at.so)(a).then(t.unlockScreen,(()=>{t.logInvalidUnlockAttempt()}))})),(0,a.iw)("logInvalidUnlockAttempt",(e=>{const t=(e.passcode?.invalidAttemptsCount??0)+1;return(0,w.vu)(e,{invalidAttemptsCount:t,timeoutUntil:t>=5?Date.now()+15e3:void 0})})),(0,a.iw)("resetInvalidUnlockAttempts",(e=>(0,w.vu)(e,{invalidAttemptsCount:0,timeoutUntil:void 0}))),(0,a.iw)("setPasscodeError",((e,t,s)=>{const{error:a}=s;return(0,w.vu)(e,{error:a})})),(0,a.iw)("clearPasscodeError",(e=>(0,w.vu)(e,{error:void 0}))),(0,a.iw)("skipLockOnUnload",(()=>{rt=!0})),(0,a.iw)("processOpenChatOrThread",((e,t,s)=>{const{chatId:a,tabId:n=(0,m._w)()}=s;return a?(0,b.i)(e,{reactionPicker:{chatId:a,messageId:void 0,position:void 0}},n):(0,b.i)(e,{reactionPicker:void 0},n)})),(0,a.iw)("openMessageReactionPicker",((e,t,s)=>{const{chatId:a,messageId:n,position:o,tabId:i=(0,m._w)()}=s;return(0,b.i)(e,{reactionPicker:{chatId:a,messageId:n,position:o}},i)})),(0,a.iw)("openStoryReactionPicker",((e,t,s)=>{const{peerId:a,storyId:n,position:o,sendAsMessage:i,tabId:r=(0,m._w)()}=s;return(0,b.i)(e,{reactionPicker:{storyPeerId:a,storyId:n,sendAsMessage:i,position:o}},r)})),(0,a.iw)("closeReactionPicker",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);return(0,b.i)(e,{reactionPicker:{...n.reactionPicker,messageId:void 0,position:void 0,storyId:void 0,storyPeerId:void 0}},a)})),(0,a.iw)("openStoryViewer",(async(e,t,s)=>{const{peerId:n,storyId:o,isSinglePeer:i,isSingleStory:r,isPrivate:c,isArchive:d,origin:l,tabId:u=(0,m._w)()}=s,p=(0,y.RGZ)(e,n);if(!p)return;const g=(0,y.jUK)(e,u),f=(0,y.nST)(e,n);if(o&&(!f||!f.byId[o])){const t=await(0,I.t9)("fetchPeerStoriesByIds",{peer:p,ids:[o]});if(!t)return;e=(0,a.Rd)(),e=(0,w.Sh)(e,(0,h.ee)(t.users,"id")),e=(0,w.fZ)(e,(0,h.ee)(t.chats,"id")),e=(0,w._6)(e,n,t.stories)}const v=g.storyViewer.storyList||(0,y.tWo)(e,n,o,r,i,c,d);e=(0,b.i)(e,{storyViewer:{...g.storyViewer,peerId:n,storyId:o||(0,y.ZEE)(e,n)||(0,y.wUq)(e,n),isSinglePeer:i,isPrivate:c,isArchive:d,isSingleStory:r,viewModal:void 0,origin:l,storyList:v}},u),(0,a.R3)(e)})),(0,a.iw)("openStoryViewerByUsername",(async(e,t,s)=>{const{username:a,storyId:n,origin:o,tabId:r=(0,m._w)()}=s,c=await(0,i.Co)(e,a);c&&t.openStoryViewer({peerId:c.id,storyId:n,isSinglePeer:!0,isSingleStory:!0,origin:o,tabId:r})})),(0,a.iw)("closeStoryViewer",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},{isMuted:n,isRibbonShown:o,isArchivedRibbonShown:i,storyId:r}=(0,y.jUK)(e,a).storyViewer;return r?e=(0,b.i)(e,{storyViewer:{isMuted:n,isRibbonShown:o,isArchivedRibbonShown:i,lastViewedByPeerIds:void 0,storyList:void 0}},a):e})),(0,a.iw)("setStoryViewerMuted",((e,t,s)=>{const{isMuted:a,tabId:n=(0,m._w)()}=s;return(0,b.i)(e,{storyViewer:{...(0,y.jUK)(e,n).storyViewer,isMuted:a}},n)})),(0,a.iw)("toggleStoryRibbon",((e,t,s)=>{const{isShown:a,isArchived:n,tabId:o=(0,m._w)()}=s,i=e.stories.orderedPeerIds[n?"archived":"active"];return i?.length?(0,b.i)(e,{storyViewer:{...(0,y.jUK)(e,o).storyViewer,[n?"isArchivedRibbonShown":"isRibbonShown"]:a}},o):e})),(0,a.iw)("openPreviousStory",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a),{peerId:o,storyId:i,isSinglePeer:r,isSingleStory:c,storyList:d}=n.storyViewer;if(c||!d)return void t.closeStoryViewer({tabId:a});if(!o||!i)return;const l=(0,y.RGZ)(e,o);if(!(0,y.nST)(e,o)||!l)return;const{peerIds:u,storyIdsByPeerId:h}=d,p=(h[o]??[]).indexOf(i);let g,f;if(p>0)g=p-1,f=o;else{const e=u.indexOf(o)-1;if(r||e<0)return;f=u[e],g=(h?.[f]?.length||1)-1}const I=h?.[f]?.[g];return I?(0,b.i)(e,{storyViewer:{...n.storyViewer,peerId:f,storyId:I}},a):void 0})),(0,a.iw)("openNextStory",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a),{peerId:o,storyId:i,isSinglePeer:r,isSingleStory:c,storyList:d}=n.storyViewer;if(c||!d)return void t.closeStoryViewer({tabId:a});if(!o||!i)return;const l=(0,y.RGZ)(e,o);if(!(0,y.nST)(e,o)||!l)return;const{peerIds:u,storyIdsByPeerId:h}=d,p=h[o]??[],g=p.indexOf(i);let f,I;if(g<p.length-1)f=g+1,I=o;else{const e=u.indexOf(o)+1;if(r||e>u.length-1)return void t.closeStoryViewer({tabId:a});I=u[e],f=0}const v=h?.[I]?.[f];return v?(0,b.i)(e,{storyViewer:{...n.storyViewer,peerId:I,storyId:v}},a):void 0})),(0,a.iw)("openStoryViewModal",((e,t,s)=>{const{storyId:a,tabId:n=(0,m._w)()}=s,o=(0,y.jUK)(e,n);return(0,b.i)(e,{storyViewer:{...o.storyViewer,viewModal:{storyId:a,nextOffset:"",isLoading:!0}}},n)})),(0,a.iw)("closeStoryViewModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);return(0,b.i)(e,{storyViewer:(0,h.CE)(n.storyViewer,["viewModal"])},a)})),(0,a.iw)("copyStoryLink",(async(e,t,s)=>{const{peerId:a,storyId:n,tabId:o=(0,m._w)()}=s,i=(0,y.RGZ)(e,a);if(!i)return;const r=await(0,I.t9)("fetchStoryLink",{peer:i,storyId:n});r&&((0,d.TE)(r),t.showNotification({message:p.Iu("LinkCopied"),tabId:o}))})),(0,a.iw)("sendMessage",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s,{storyId:n,peerId:o}=(0,y.pri)(e,a);if(!Boolean(n&&o))return;const{gif:i,sticker:r,isReaction:c}=s;let d;d=i?"Story.Tooltip.GifSent":r?"Story.Tooltip.StickerSent":c?"Story.Tooltip.ReactionSent":"Story.Tooltip.MessageSent",t.showNotification({message:p.Iu(d),actionText:p.Iu("Story.ToastViewInChat"),action:[{action:"closeStoryViewer",payload:void 0},{action:"openChat",payload:{id:o}}],tabId:a})})),(0,a.iw)("openStoryPrivacyEditor",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);return(0,b.i)(e,{storyViewer:{...n.storyViewer,isPrivacyModalOpen:!0}},a)})),(0,a.iw)("closeStoryPrivacyEditor",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{},n=(0,y.jUK)(e,a);return(0,b.i)(e,{storyViewer:{...n.storyViewer,isPrivacyModalOpen:!1}},a)})),(0,a.iw)("toggleStealthModal",((e,t,s)=>{const{isOpen:a,tabId:n=(0,m._w)()}=s||{},o=(0,y.jUK)(e,n);return(0,b.i)(e,{storyViewer:{...o.storyViewer,isStealthModalOpen:a}},n)})),(0,a.iw)("clearStoryViews",((e,t,s)=>{const{isLoading:a,tabId:n=(0,m._w)()}=s||{},o=(0,y.jUK)(e,n);return o.storyViewer.viewModal?(0,b.i)(e,{storyViewer:{...o.storyViewer,viewModal:{...o.storyViewer.viewModal,views:void 0,isLoading:a,nextOffset:""}}},n):e})),(0,a.iw)("updateStoryView",((e,t,s)=>{const{userId:a,isUserBlocked:n,areStoriesBlocked:o,tabId:i=(0,m._w)()}=s,r=(0,y.jUK)(e,i),{viewModal:c}=r.storyViewer;if(!c?.storyId)return;const d=c?.views?.map((e=>e.peerId===a?{...e,isUserBlocked:n||void 0,areStoriesBlocked:o||void 0}:e));return(0,b.i)(e,{storyViewer:{...r.storyViewer,viewModal:{...c,views:d}}},i)})),(0,a.iw)("closeBoostModal",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{boostModal:void 0},a)})),(0,a.iw)("closeBoostStatistics",((e,t,s)=>{const{tabId:a=(0,m._w)()}=s||{};return(0,b.i)(e,{boostStatistics:void 0},a)})),s(28304),s(13522);var ct=s(78058),dt=s(1735),lt=s(24736),ut=s.n(lt);s(89618);var mt=s(57404),ht=s(48764).lW;const pt="BroadcastChannel"in self,gt=pt?new BroadcastChannel(n.tuy):void 0;let ft=[];const It=(0,f.P2)((()=>{gt.postMessage({type:"localDbUpdate",batchedUpdates:ft}),ft=[]}),100);function vt(e){if(e instanceof Uint8Array)return ht.from(e);if("object"==typeof e&&1===Object.keys(e).length&&"value"===Object.keys(e)[0])return ut()(e.value);if(Array.isArray(e))return e.map(vt);if("object"!=typeof e||!("CONSTRUCTOR_ID"in e))return e;const t=e.className.split(".").reduce(((e,t)=>e[t]),mt.constructors),s=function(e){const{flags:t,CONSTRUCTOR_ID:s,SUBCLASS_OF_ID:a,className:n,classType:o,getBytes:i,...r}=e;return r}(e);return new t(Object.keys(s).reduce(((e,t)=>(e[t]=vt(s[t]),e)),{}))}var wt;["localMessages","chats","users","messages","documents","stickerSets","photos","webDocuments","stories","commonBoxState","channelPtsById"].reduce(((e,t)=>{const s=wt?.[t]??{},a=Object.keys(s).reduce(((e,a)=>{if("commonBoxState"===t||"channelPtsById"===t){const t=s;return e[a]=t[a],e}return e[a]=vt(s[a]),e}),{});var n;return e[t]=pt?(n=t,new Proxy(a,{get:(e,t,s)=>Reflect.get(e,t,s),set:(e,t,s)=>(ft.push({name:n,prop:t,value:s}),It(),Reflect.set(e,t,s))})):a,e}),{}),s(48764).lW,s(48960);const bt=1e6,yt="temp";let Pt=0;function Zt(e,t){return{poll:{id:String(t),summary:(0,h.ei)(e.summary,["question","answers"]),results:{}}}}function St(e,t,s,a,o,i,r,c,d,l,u,m,h,p){const g=function(e=0){return e+ ++Pt/bt}(t),f=i&&function(e){const{filename:t,blobUrl:s,previewBlobUrl:a,mimeType:o,size:i,audio:r,shouldSendAsFile:c,shouldSendAsSpoiler:d,ttlSeconds:l}=e;if(!c){if(e.quick){if(n.oGt.has(o)){const{width:t,height:n}=e.quick;return{photo:{id:yt,sizes:[],thumbnail:{width:t,height:n,dataUri:a||s},blobUrl:s,isSpoiler:d}}}if(n.wGh.has(o)){const{width:n,height:r,duration:c}=e.quick;return{video:{id:yt,mimeType:o,duration:c||0,fileName:t,width:n,height:r,blobUrl:s,...a&&{thumbnail:{width:n,height:r,dataUri:a}},size:i,isSpoiler:d}}}}if(e.voice){const{duration:t,waveform:s}=e.voice,{data:a}=(0,dt.C)(s,63);return{voice:{id:yt,duration:t,waveform:a},ttlSeconds:l}}if(n.e74.has(o)){const{duration:e,performer:s,title:a}=r||{};return{audio:{id:yt,mimeType:o,fileName:t,size:i,duration:e||0,title:a,performer:s}}}}return{document:{mimeType:o,fileName:t,size:i,...a&&{previewBlobUrl:a}}}}(i),I="chatTypeChannel"===e.type,v=o&&(y=o,P=e.isForum,"story"===y.type?{type:"story",peerId:y.peerId,storyId:y.storyId}:{type:"message",replyToMsgId:y.replyToMsgId,replyToTopId:y.replyToTopId,replyToPeerId:y.replyToPeerId,quoteText:y.quoteText,isForumTopic:!(!P||!y.replyToTopId)||void 0,...Boolean(y.quoteText)&&{isQuote:!0}}),w={id:g,chatId:e.id,content:{...s&&{text:{text:s,entities:a}},...f,...r&&{sticker:r},...c&&{video:c},...d&&Zt(d,g),...l&&{contact:l},...p&&{storyData:p}},date:m||Math.round(Date.now()/1e3)+(0,we.Qj)(),isOutgoing:!I,senderId:h?.id||undefined,replyInfo:v,...u&&{groupedId:u,...f&&(f.photo||f.video)&&{isInAlbum:!0}},...m&&{isScheduled:!0},isForwardingAllowed:!0},b=(0,ct.k)(w.content,w.groupedId);var y,P;return{...w,...b&&{emojiOnlyCount:b}}}(0,a.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{const{isForum:n,lastReadOutboxMessageId:o}=(0,y.Z1J)(e,s.id)||{};s.chat.lastReadOutboxMessageId&&o&&s.chat.lastReadOutboxMessageId<o&&(s={...s,chat:(0,h.CE)(s.chat,["lastReadInboxMessageId"])});const i=(0,y.Z1J)(e,s.id);return e=(0,w.a4)(e,s.id,s.chat,s.newProfilePhoto),i?.areStoriesHidden!==s.chat.areStoriesHidden&&(e=(0,w.QO)(e,s.id,s.chat.areStoriesHidden||!1)),(0,a.R3)(e),s.noTopChatsRequest||(0,y.Nap)(e,s.id)||t.loadTopChats(),s.chat.id&&(0,Z.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId}),void Object.values(e.byTabId).forEach((({id:a})=>{const{chatId:o}=(0,y.Btg)(e,a)||{},i=s;o===i.id&&"isForum"in i.chat&&n!==i.chat.isForum&&(n&&t.closeForumPanel({tabId:a}),t.openChat({id:o,tabId:a}))}))}case"updateChatJoin":{const n=(0,y.EkO)(e,s.id),o=(0,y.Z1J)(e,s.id);if(o&&(0,v.eA)(o)){t.fetchChannelRecommendations({chatId:o.id});const s=St(o,(0,y.xMv)(e,o.id));s.content.action={text:"you joined this channel",translationValues:["ChannelJoined"],type:"joinedChannel",targetChatId:o.id},t.apiUpdate({"@type":"newMessage",id:s.id,chatId:o.id,message:s})}if(!n)return;return e=(0,w.B1)(e,n,[s.id]),e=(0,w.a4)(e,s.id,{isNotJoined:!1}),(0,a.R3)(e),void(o&&t.requestChatUpdate({chatId:o.id}))}case"updateChatLeave":{e=(0,w.Dd)(e,s.id);const t=(0,y.Z1J)(e,s.id);if(t&&(0,v.eA)(t)){const a=(0,y.Zwk)(e,s.id),n=Object.keys(a).map(Number).filter(g.AJ);e=(0,w.K4)(e,t.id,n)}return e}case"updateChatInbox":return(0,w.a4)(e,s.id,s.chat);case"updateChatTypingStatus":{const{id:t,threadId:n=r._f,typingStatus:o}=s;return e=(0,w.pf)(e,t,n,"typingStatus",o),(0,a.R3)(e),void setTimeout((()=>{e=(0,a.Rd)();const s=(0,y.WPz)(e,t,n,"typingStatus");o&&s&&o.timestamp===s.timestamp&&(e=(0,w.pf)(e,t,n,"typingStatus",void 0),(0,a.R3)(e))}),6e3)}case"newMessage":{const{message:t}=s;if(t.senderId===e.currentUserId&&!t.isFromScheduled)return;const n=(0,y.Z1J)(e,s.chatId);if(!n)return;const o=Boolean(s.message.id&&s.message.hasUnreadMention);e=(0,w.a4)(e,s.chatId,{unreadCount:n.unreadCount?n.unreadCount+1:1,...o&&{unreadMentionsCount:(n.unreadMentionsCount||0)+1}}),o&&(e=(0,w.a4)(e,s.chatId,{unreadMentions:[...n.unreadMentions||[],s.message.id]}));const i=n.isForum?(0,y.p$s)(e,t):void 0;return i&&(e=(0,w.Cn)(e,s.chatId,i.id,{unreadCount:i.unreadCount?i.unreadCount+1:1})),(0,a.R3)(e),void(0,Z.rh)({chat:n,message:t})}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=s;if(!1!==a.hasUnreadMention)return;return t.forEach((t=>{const a="channelId"in s?s.channelId:(0,y.X5I)(e,t),n=(0,y.Z1J)(e,a);n?.unreadReactionsCount&&(e=_(e,a,{unreadReactionsCount:n.unreadReactionsCount-1||void 0,unreadReactions:n.unreadReactions?.filter((e=>e!==t))})),n?.unreadMentionsCount&&(e=(0,w.a4)(e,a,{unreadMentionsCount:n.unreadMentionsCount-1||void 0,unreadMentions:n.unreadMentions?.filter((e=>e!==t))}))})),e}case"updateChatFullInfo":return(0,w.US)(e,s.id,s.fullInfo);case"updatePinnedChatIds":{const{ids:t,folderId:a}=s,o=a===n.WSp?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[o]:t.length?t:void 0}}}}case"updatePinnedSavedDialogIds":{const{ids:t}=s;return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,saved:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:a}=s,o=(0,y.EkO)(e,t);if(!o)return;const{[o]:i}=e.chats.orderedPinnedIds;let r=i||[];if(a){if(!r.includes(t)){if("active"===o&&r.length>=n.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,[o]:r.length?r:void 0}}}}case"updateSavedDialogPinned":{const{id:t,isPinned:a}=s,{saved:n}=e.chats.orderedPinnedIds;let o=n||[];return a?o.includes(t)||(o=[t,...o]):o=o.filter((e=>e!==t)),{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,saved:o.length?o:void 0}}}}case"updateChatListType":{const{id:t,folderId:a}=s;return(0,w.Pi)(e,t,a)}case"updateChatFolder":{const{id:t,folder:a}=s,{byId:n,orderedIds:o}=e.chatFolders,i=void 0===a;Object.values(e.byTabId).forEach((({id:s})=>{const a=(0,y.jUK)(e,s);Object.values(n)[a.activeChatFolder-1]?.id===t&&(e=(0,b.i)(e,{activeChatFolder:0},s))}));const r=i?(0,h.CE)(n,[t]):{...n,[t]:a},c=i?o?.filter((e=>e!==t)):o?.includes(t)?o:[...o||[],t];return{...e,chatFolders:{...e.chatFolders,byId:r,orderedIds:c,invites:(0,h.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,y.x67)(e,s.id),{replacedMembers:a,addedMember:n,deletedMemberId:o}=s;if(!t)return;let i=!1,r=t?.members?[...t.members]:[];if(a)r=a,i=!0;else if(n)r.length&&r.some((e=>e.userId===n.userId))||(r.push(n),i=!0);else if(r.length&&o){const e=r.findIndex((e=>e.userId===o));e>-1&&(r.slice(e,1),i=!0)}if(i){const t=r.filter((({isOwner:e,isAdmin:t})=>e||t));return e=(0,w.a4)(e,s.id,{membersCount:r.length}),e=(0,w.US)(e,s.id,{members:r,adminMembersById:(0,h.ee)(t,"userId")})}return}case"deleteProfilePhotos":{const{chatId:t,ids:a}=s,n=e.chats.byId[t];return n?.photos?(0,w.a4)(e,t,{photos:n.photos.filter((e=>!a.includes(e.id)))}):void 0}case"draftMessage":{const{chatId:t,threadId:a,draft:n}=s;if(!e.chats.byId[t])return;return e=(0,w.pf)(e,t,a||r._f,"draft",n),e=(0,w.a4)(e,t,{draftDate:n?.date})}case"showInvite":{const{data:a}=s;return void Object.values(e.byTabId).forEach((({id:e})=>{t.showDialog({data:a,tabId:e})}))}case"updatePendingJoinRequests":{const{chatId:n,requestsPending:o,recentRequesterIds:i}=s;if(!e.chats.byId[n])return;return e=(0,w.US)(e,n,{requestsPending:o,recentRequesterIds:i}),(0,a.R3)(e),void t.loadChatJoinRequests({chatId:n})}case"updatePinnedTopic":{const{chatId:t,topicId:n,isPinned:o}=s;if(!e.chats.byId[t])return;return e=(0,w.Cn)(e,t,n,{isPinned:o}),void(0,a.R3)(e)}case"updatePinnedTopicsOrder":{const{chatId:t,order:n}=s;if(!e.chats.byId[t])return;return e=(0,w.a4)(e,t,{orderedPinnedTopicIds:n}),void(0,a.R3)(e)}case"updateTopic":{const{chatId:a,topicId:n}=s,o=(0,y.Z1J)(e,a);if(!o?.isForum)return;return void t.loadTopicById({chatId:a,topicId:n})}case"updateTopics":{const{chatId:a}=s,n=(0,y.Z1J)(e,a);if(!n?.isForum)return;return void t.loadTopics({chatId:a,force:!0})}case"updateViewForumAsMessages":{const{chatId:t,isEnabled:n}=s,o=(0,y.Z1J)(e,t);if(!o?.isForum)return;e=(0,w.a4)(e,t,{isForumAsMessages:n}),(0,a.R3)(e)}}}));const Ct=(0,f.P2)((function(){let e=(0,a.Rd)();e=(0,w.ps)(e,{...e.users.statusesById,...Mt}),(0,a.R3)(e),Mt={}}),3e3,!0);let Mt={};(0,a.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteContact":return(0,w.GK)(e,s.id);case"updateUser":{Object.values(e.byTabId).forEach((({id:a})=>{(0,y.FM1)(e,s.id)&&s.user.isPremium!==(0,y.wVz)(e)&&(s.user.isPremium&&e.byTabId[a].premiumModal&&t.openPremiumModal({isSuccess:!0,tabId:a}),e={...e,translations:{byChatId:{}}})}));const a=(0,y.dyD)(e,s.id);return e=(0,w.Nq)(e,s.id,s.user),s.fullInfo&&(e=(0,w.ap)(e,s.id,s.fullInfo)),a?.areStoriesHidden!==s.user.areStoriesHidden&&(e=(0,w.QO)(e,s.id,s.user.areStoriesHidden||!1)),e}case"updateRequestUserUpdate":t.loadFullUser({userId:s.id});break;case"updateUserEmojiStatus":return(0,w.Nq)(e,s.userId,{emojiStatus:s.emojiStatus});case"updateUserStatus":return a=s.userId,n=s.status,Mt[a]=n,void Ct();case"updateUserFullInfo":{const{id:t,fullInfo:a}=s;return(0,w.ap)(e,t,a)}case"updateBotMenuButton":{const{botId:t,button:a}=s,n=(0,y.ccz)(e,t);if(!n?.botInfo)return;return(0,w.ap)(e,t,{botInfo:{...n.botInfo,menuButton:a}})}}var a,n})),(0,a.iw)("apiUpdate",((e,t,s)=>{if("updateStickerSet"===s["@type"])return(0,w.Rg)(e,s.id,s.stickerSet)})),(0,a.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,w.h7)(e,s.id):s.isBlockedFromStories?e:(0,w.kw)(e,s.id);case"updateResetContactList":e={...e,contactList:{userIds:[]}},(0,a.R3)(e);break;case"updateConfig":t.loadConfig();break;case"updateNewAuthorization":t.loadAuthorizations();break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updateRecentStickers":t.loadRecentStickers();break;case"updateRecentReactions":t.loadRecentReactions();break;case"updateRecentEmojiStatuses":t.loadRecentEmojiStatuses();break;case"updateSavedReactionTags":t.loadSavedReactionTags();break;case"updateMoveStickerSetToTop":{const a=s.isCustomEmoji?e.customEmojis.added.setIds:e.stickers.added.setIds;if(!a)return e;const n=[s.id,...a.filter((e=>e!==s.id))];t.reorderStickerSets({order:n,isCustomEmoji:s.isCustomEmoji});break}case"updateStickerSets":t.loadStickerSets();break;case"updateStickerSetsOrder":{const a=s.order.filter((t=>Boolean(e.stickers.setsById[t])));t.reorderStickerSets({order:a,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,a.R3)(e);break;case"updatePaymentVerificationNeeded":Object.values(e.byTabId).forEach((({id:t})=>{e=(0,w.fS)(e,s.url,t),e=(0,w.Q$)(e,c.KB.ConfirmPayment,t)})),(0,a.R3)(e);break;case"updateWebViewResultSent":Object.values(e.byTabId).forEach((e=>{e.webApp?.queryId===s.queryId&&(t.resetDraftReplyInfo({tabId:e.id}),t.closeWebApp({tabId:e.id}))}));break;case"updateStory":e=(0,w._6)(e,s.peerId,{[s.story.id]:s.story}),e=(0,w.Fz)(e,{[s.peerId]:(0,y.nST)(e,s.peerId)}),(0,a.R3)(e);break;case"deleteStory":e=(0,w.se)(e,s.peerId,s.storyId),(0,a.R3)(e);break;case"updateReadStories":e=(0,w.P5)(e,s.peerId,s.lastReadId),(0,a.R3)(e);break;case"updateSentStoryReaction":{const{peerId:t,storyId:n,reaction:o}=s;if(!(0,y.JrV)(e,t,n))return e;e=(0,w.w2)(e,t,n,{sentReaction:o}),(0,a.R3)(e);break}case"updateStealthMode":e=(0,w.Uq)(e,s.stealthMode),(0,a.R3)(e);break;case"updateAttachMenuBots":t.loadAttachBots({hash:e.attachMenu.hash})}})),(0,a.iw)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,w.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:n,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,w.a4)(e,t,{isMuted:n})),e=(0,w.aK)(e,t,{isMuted:n,isSilent:o,shouldShowPreviews:i}),(0,a.R3)(e);break}case"updateTopicNotifyExceptions":{const{chatId:t,topicId:n,isMuted:o}=s;e=(0,w.Cn)(e,t,n,{isMuted:o}),(0,a.R3)(e);break}}})),(0,a.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 Et=s(78958),Rt=s(42431);(0,a.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,m._w)()})):(0,Et.dc)(e,s.call.id);const a=(0,Rt.$5)(e,s.call.id),n=a?.chatId;return n&&(e=(0,w.a4)(e,n,{isCallNotEmpty:a.participantsCount>0||Boolean(a.participants?.length)})),(0,Et.AH)(e,s.call.id,(0,h.CE)(s.call,["connectionState"]),void 0,s.call.participantsCount)}case"updateGroupCallChatId":return(0,y.Z1J)(e,s.chatId)&&(e=(0,w.US)(e,s.chatId,{groupCallId:s.call.id})),e;case"updateGroupCallParticipants":{const{groupCallId:t,participants:n,nextOffset:o}=s,{currentUserId:i}=e;e=(0,a.Rd)(),n.forEach((s=>{s.id&&(e=(0,Et.B6)(e,t,s.id,s,Boolean(o)||i===s.id))})),o&&(e=(0,Et.AH)(e,t,{nextOffset:o}));const r=(0,Rt.$5)(e,t),c=r?.chatId;return c&&(e=(0,w.a4)(e,c,{isCallNotEmpty:r.participantsCount>0||Boolean(r.participants?.length)})),e}case"updatePhoneCall":{if(!o.Bi)return;const{phoneCall:n,currentUserId:i}=e,{call:r}=s;if(n)return"discarded"===r.state?(t.playGroupCallSound({sound:"end"}),"hangUp"in t&&t.hangUp({tabId:(0,m._w)()}),{...e,...r.needRating&&{ratingPhoneCall:r}}):void 0;if(r?.adminId!==i&&"requested"===r.state)return(0,f.R3)((()=>{e=(0,a.Rd)(),(0,Z.TO)({call:r,user:(0,Rt.fu)(e)})})),(0,st.EP)(),(0,st.CW)(e,t,r.isVideo,(0,m._w)()),e={...e,phoneCall:r},(0,b.i)(e,{isCallPanelVisible:!1},(0,m._w)())}}}));var kt=s(9937);(0,a.iw)("apiUpdate",((e,t,s)=>{"updatePaymentStateCompleted"===s["@type"]&&Object.values(e.byTabId).forEach((({id:a})=>{const{inputInvoice:n}=(0,y.jUK)(e,a).payment;if(n&&"chatId"in n&&"messageId"in n){const s=(0,y.hjO)(e,n.chatId,n.messageId);if(s&&s.content.invoice){const{amount:e,currency:n,title:o}=s.content.invoice;t.showNotification({tabId:a,message:p.Iu("PaymentInfoHint",[(0,kt.x)(e,n,p.QO().code),o])})}}o.Xp||(e=(0,w.WY)(e,a)),s.slug&&n&&"slug"in n&&n.slug!==s.slug||(e=(0,b.i)(e,{payment:{...(0,y.jUK)(e,a).payment,status:"paid"}},a))}))}));var Tt=s(60748),Nt=s(31664),At=s(73760),Bt=s(57710),xt=s(46752),Ut=s(1279),Lt=s(53551),_t=s(99203),Ot=s(96557),Ft=s(49488),Dt=s(65326),jt=s(18674),qt=s(25190);const Gt=document.querySelector('meta[name="viewport"]'),Ht=Gt?.getAttribute("content")||"";function Vt(e){e.preventDefault()}var $t=s(31212),zt=s(34446),Kt=s(13819),Jt=s(20797),Wt=s(80498),Yt=s(48778);const Xt=e=>{const{isActive:t}=e,s=(0,Yt.Z)(_t.gl.Calls,"ActiveCallHeader",!t);return s?Tt.ZP.createElement(s,null):void 0},Qt=e=>{const{groupCallId:t}=e,s=(0,Yt.Z)(_t.gl.Calls,"GroupCall",!t);return s?Tt.ZP.createElement(s,e):void 0},es=e=>{const{isActive:t}=e,s=(0,Yt.Z)(_t.gl.Calls,"PhoneCall",!t);return s?Tt.ZP.createElement(s,null):void 0},ts=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Calls,"RatePhoneCallModal",!t);return s?Tt.ZP.createElement(s,e):void 0},ss=e=>{const{customEmojiSetIds:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"CustomEmojiSetsModal",!t);return s?Tt.ZP.createElement(s,e):void 0},as=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"StickerSetModal",!t);return s?Tt.ZP.createElement(s,e):void 0};var ns=s(17358),os=s(2155),is=s(95616);const rs=(0,Tt.X$)((({isForAppBadge:e})=>{(0,is.yi)();const t=(0,ge.xW)();if((0,Tt.d4)((()=>{e&&(0,ns.w)(t)}),[e,t]),!e&&t)return Tt.ZP.createElement("div",{className:"unread-count active"},(0,os.bi)(t))}));var cs=s(23989),ds=s(29371),ls=s(53455),us=s(73541),ms=s(70971),hs=s(2255),ps=s(34288);const gs=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"ArchivedChats");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)};var fs=s(54416),Is=s(59107),vs=s(231),ws=s(52328),bs=s(58964);const ys=({isShown:e,onNewPrivateChat:t,onNewChannel:s,onNewGroup:a})=>{const[n,o]=(0,Tt.eJ)(!1);(0,Tt.d4)((()=>{e||o(!1)}),[e]);const i=(0,Is.Z)(),r=(0,xt.Z)("NewChatButton",e&&"revealed",n&&"menu-is-open"),c=(0,Tt.I4)((()=>{o(!n)}),[n]),d=(0,Tt.I4)((()=>{o(!1)}),[]),l=(0,Tt.Ye)((()=>Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement(bs.Z,{icon:"channel",onClick:s},i("NewChannel")),Tt.ZP.createElement(bs.Z,{icon:"group",onClick:a},i("NewGroup")),Tt.ZP.createElement(bs.Z,{icon:"user",onClick:t},i("NewMessageTitle")))),[i,s,a,t]);return Tt.ZP.createElement("div",{className:r,dir:i.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{round:!0,color:"primary",className:n?"active":"",onClick:c,ariaLabel:i(n?"Close":"NewMessageTitle"),tabIndex:-1},Tt.ZP.createElement("i",{className:"icon icon-new-chat-filled"}),Tt.ZP.createElement("i",{className:"icon icon-close"})),Tt.ZP.createElement(ws.Z,{isOpen:n,positionX:i.isRtl?"left":"right",positionY:"bottom",autoClose:!0,onClose:d},l))},Ps=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"LeftSearch");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)};var Zs=s(64963),Ss=s(46590),Cs=s(47505),Ms=s(31711),Es=s(40340);const Rs=(0,Tt.X$)((0,a.c$)((e=>{const{chatFolders:{byId:t,orderedIds:s,invites:a},chats:{listIds:{archived:n}},stories:{orderedPeerIds:{archived:o}},activeSessions:{byHash:i},currentUserId:r,archiveSettings:c}=e,{shouldSkipHistoryAnimations:d,activeChatFolder:l}=(0,y.jUK)(e),{storyViewer:{isRibbonShown:u}}=(0,y.jUK)(e);return{chatFoldersById:t,folderInvitesById:a,orderedFolderIds:s,activeChatFolder:l,currentUserId:r,shouldSkipHistoryAnimations:d,hasArchivedChats:Boolean(n?.length),hasArchivedStories:Boolean(o?.length),maxFolders:(0,ae.M)(e,"dialogFilters"),maxFolderInvites:(0,ae.M)(e,"chatlistInvites"),maxChatLists:(0,ae.M)(e,"chatlistJoined"),archiveSettings:c,isStoryRibbonShown:u,sessions:i}}))((({foldersDispatch:e,onSettingsScreenSelect:t,onLeftColumnContentChange:s,chatFoldersById:i,orderedFolderIds:r,activeChatFolder:c,currentUserId:d,isForumPanelOpen:l,shouldSkipHistoryAnimations:u,maxFolders:m,maxChatLists:h,shouldHideFolderTabs:p,folderInvitesById:g,maxFolderInvites:f,hasArchivedChats:I,hasArchivedStories:v,archiveSettings:w,isStoryRibbonShown:b,sessions:P})=>{const{loadChatFolders:Z,setActiveChatFolder:S,openChat:C,openShareChatFolderModal:M,openDeleteChatFolderModal:E,openEditChatFolder:R,openLimitReachedModal:k}=(0,a.Sv)(),T=(0,Tt.sO)(null),N=(0,Is.Z)();(0,Tt.d4)((()=>{Z()}),[]);const{shouldRender:A,transitionClassNames:B,isClosing:x}=(0,$t.Z)(b,void 0,void 0,""),U=(0,Tt.Ye)((()=>({id:n.NfV,title:r?.[0]===n.NfV?N("FilterAllChatsShort"):N("FilterAllChats"),includedChatIds:Oe.D,excludedChatIds:Oe.D})),[r,N]),L=(0,Tt.Ye)((()=>r?r.map((e=>e===n.NfV?U:i[e]||{})).filter(Boolean):void 0),[i,U,r]),_=L?.findIndex((e=>e.id===n.NfV)),O=_===c,F=0===c,D=(0,is.yi)(),j=(0,Tt.Ye)((()=>{if(L&&L.length)return L.map(((e,t)=>{const{id:s,title:o}=e,r=s!==n.NfV&&t>m-1,c=[];return(0,y.yEv)((0,a.Rd)(),s)&&c.push({title:N("ChatList.ContextMenuShare"),icon:"link",handler:()=>{Object.values(i).reduce(((e,t)=>e+(t.isChatList?1:0)),0)>=h&&!e.isChatList?k({limit:"chatlistJoined"}):g[s]?.length>=f?k({limit:"chatlistInvites"}):M({folderId:s})}}),s!==n.NfV&&(c.push({title:N("FilterEdit"),icon:"edit",handler:()=>{R({folderId:s})}}),c.push({title:N("FilterDeleteItem"),icon:"delete",destructive:!0,handler:()=>{E({folderId:s})}})),{id:s,title:o,badgeCount:D[s]?.chatsCount,isBadgeActive:Boolean(D[s]?.notificationsCount),isBlocked:r,contextActions:c?.length?c:void 0}}))}),[L,m,D,N,i,h,g,f]),q=(0,qt.Z)((e=>{S({activeChatFolder:e},{forceOnHeavyAnimation:!0})}));(0,Tt.d4)((()=>{j?.length&&c>=j.length&&S({activeChatFolder:0})}),[c,j,S]),(0,Tt.d4)((()=>{if(o.$b&&j?.length&&!l)return(0,Zs.sf)(T.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Zs.eM.Left?(S({activeChatFolder:Math.min(c+1,j.length-1)},{forceOnHeavyAnimation:!0}),!0):t===Zs.eM.Right&&(S({activeChatFolder:Math.max(0,c-1)},{forceOnHeavyAnimation:!0}),!0)})}),[c,j,l,S]);const G=(0,Tt.sO)();G.current=!F,(0,Tt.d4)((()=>G.current?(0,cs.Z)((()=>{G.current&&S({activeChatFolder:0})})):void 0),[c,S]),(0,Ss.Z)({isActive:!F,onBack:()=>S({activeChatFolder:0},{forceOnHeavyAnimation:!0})}),(0,Tt.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&j){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void C({id:d,shouldReplaceHistory:!0});const s=Number(t)-1;if(s>j.length-1)return;S({activeChatFolder:s},{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}),[d,j,C,S]);const{shouldRender:H,transitionClassNames:V}=(0,$t.Z)(!r,void 0,!0);function $(a){const n=Object.values(i).find((({id:e})=>e===j[c].id)),o=n&&!O;return Tt.ZP.createElement(Es.Z,{folderType:o?"folder":"all",folderId:o?n.id:void 0,isActive:a,isForumPanelOpen:l,foldersDispatch:e,onSettingsScreenSelect:t,onLeftColumnContentChange:s,canDisplayArchive:(I||v)&&!w.isHidden,archiveSettings:w,sessions:P})}const z=j&&j.length>1;return Tt.ZP.createElement("div",{className:(0,xt.Z)("ChatFolders",z&&p&&"ChatFolders--tabs-hidden",A&&"with-story-ribbon",B)},A&&Tt.ZP.createElement(Cs.Z,{isClosing:x}),z?Tt.ZP.createElement(Ms.Z,{contextRootElementSelector:"#LeftColumn",tabs:j,activeTab:c,onSwitchTab:q,areFolders:!0}):H?Tt.ZP.createElement("div",{className:(0,xt.Z)("tabs-placeholder",V)}):void 0,Tt.ZP.createElement(hs.ZP,{ref:T,name:u?"none":N.isRtl?"slideOptimizedRtl":"slideOptimized",activeKey:c,renderCount:z?j.length:void 0},$))}))),ks=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"ContactList");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)};var Ts=s(59690);let Ns=function(e){return e[e.waitingForNetwork=0]="waitingForNetwork",e[e.syncing=1]="syncing",e[e.online=2]="online",e}({});function As(e,t,s,a,n,o){let i,r,c;return i=function(){const[e,t]=(0,Tt.eJ)(window.navigator.onLine);return(0,Tt.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?Ns.syncing:Ns.online:Ns.waitingForNetwork,r=i===Ns.online||o?"none":a?"middleHeader":n?"minimized":"overlay",i===Ns.waitingForNetwork?c=e("WaitingForNetwork"):i===Ns.syncing&&(c=e("Updating")),"middleHeader"===r&&(c=c.toLowerCase().replace(/\.+$/,"")),{connectionStatus:i,connectionStatusPosition:r,connectionStatusText:c}}var Bs=s(97458),xs=s(60706),Us=s(73217),Ls=s(49187),_s=s(85194),Os=s(53106),Fs=s(69589),Ds=s(40126),js=s(49204);const qs=(0,Tt.X$)((({connectionStatus:e,connectionStatusText:t,onClick:s})=>{const a=(0,Is.Z)();return Tt.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:a.isRtl?"rtl":void 0,onClick:s},Tt.ZP.createElement(js.Z,{color:"black"}),Tt.ZP.createElement("div",{className:"state-text"},Tt.ZP.createElement(hs.ZP,{activeKey:e,name:"slideFade"},t)),Tt.ZP.createElement(vs.Z,{round:!0,size:"tiny",color:"translucent-black"},Tt.ZP.createElement("span",{className:"icon icon-close"})))}));var Gs=s(36046),Hs=s(17926),Vs=s(43159),$s=s(83321),zs=s(79994);const Ks=(0,Tt.X$)((0,a.c$)((e=>{const t=(0,y.jUK)(e),{currentUserId:s,archiveSettings:a}=e,{animationLevel:n}=e.settings.byKey,o=e.attachMenu.bots;return{currentUserId:s,theme:(0,y.Puy)(e),animationLevel:n,canInstall:Boolean(t.canInstall),archiveSettings:a,attachBots:o}}))((({currentUserId:e,archiveSettings:t,animationLevel:s,theme:i,canInstall:r,attachBots:c,onSelectArchived:d,onSelectContacts:l,onSelectSettings:u,onBotMenuOpened:m,onBotMenuClosed:h})=>{const{openChat:p,setSettingOption:g,updatePerformanceSettings:f,openChatByUsername:I,openUrl:v,openChatWithInfo:w}=(0,a.Sv)(),b=(0,Is.Z)(),y=s!==n.oBh?s===n.zy8?"max":"mid":"min",P=!o.D$&&(window.location.hostname===n.xHY||n.Cgt),Z=(0,is.yi)()[n.WSp]?.chatsCount||0,S=(0,Tt.Ye)((()=>Object.values(c).filter((e=>e.isForSideMenu))),[c]),C=(0,qt.Z)((()=>{p({id:e,shouldReplaceHistory:!0})})),M=(0,qt.Z)((e=>{e.stopPropagation(),g({theme:"light"===i?"dark":"light"}),g({shouldUseSystemTheme:!1})})),E=(0,qt.Z)((e=>{e.stopPropagation();let t=s+1;t>n.zy8&&(t=n.oBh);const a=t===n.oBh?it.ww:t===n.zy8?it.WD:it.LN;g({animationLevel:t}),f(a)})),R=(0,qt.Z)((()=>{window.open(n.ulW,"_blank","noopener")})),k=(0,qt.Z)((()=>{(0,Hs.El)("K")})),T=(0,qt.Z)((()=>{I({username:b("Settings.TipsUsername")})})),N=(0,qt.Z)((()=>{v({url:n.mUA})})),A=(0,qt.Z)((()=>{w({id:e,shouldReplaceHistory:!0,profileTab:"stories"})}));return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement(bs.Z,{icon:"saved-messages",onClick:C},b("SavedMessages")),t.isHidden&&Tt.ZP.createElement(bs.Z,{icon:"archive",onClick:d},Tt.ZP.createElement("span",{className:"menu-item-name"},b("ArchivedChats")),Z>0&&Tt.ZP.createElement("div",{className:"right-badge"},Z)),Tt.ZP.createElement(bs.Z,{icon:"user",onClick:l},b("Contacts")),S.map((e=>Tt.ZP.createElement(Vs.Z,{bot:e,theme:i,isInSideMenu:!0,canShowNew:!0,onMenuOpened:m,onMenuClosed:h}))),Tt.ZP.createElement(bs.Z,{icon:"play-story",onClick:A},b("Settings.MyStories")),Tt.ZP.createElement(bs.Z,{icon:"settings",onClick:u},b("Settings")),Tt.ZP.createElement(bs.Z,{icon:"darkmode",onClick:M},Tt.ZP.createElement("span",{className:"menu-item-name"},b("lng_menu_night_mode")),Tt.ZP.createElement($s.Z,{id:"darkmode",label:b("dark"===i?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===i,noAnimation:!0})),Tt.ZP.createElement(bs.Z,{icon:"animations",onClick:E},Tt.ZP.createElement("span",{className:"menu-item-name capitalize"},b("Appearance.Animations").toLowerCase()),Tt.ZP.createElement(zs.Z,{value:y})),Tt.ZP.createElement(bs.Z,{icon:"help",onClick:T},b("TelegramFeatures")),Tt.ZP.createElement(bs.Z,{icon:"bug",onClick:N},"Report Bug"),n.Tjg&&Tt.ZP.createElement(bs.Z,{icon:"permissions",onClick:R},"Beta Changelog"),P&&Tt.ZP.createElement(bs.Z,{icon:"K",isCharIcon:!0,href:`${n.OfM}k`,onClick:k},"Switch to K Version"),r&&Tt.ZP.createElement(bs.Z,{icon:"install",onClick:(0,Gs.G)()},"Install App"))})));var Js=s(274),Ws=s(96459),Ys=s(4863),Xs=s(67427);const Qs=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"StatusPickerMenu",!t);return s?Tt.ZP.createElement(s,e):void 0},ea=(0,Tt.X$)((0,a.c$)((e=>{const{currentUserId:t}=e,s=t?(0,y.dyD)(e,t):void 0;return{emojiStatus:s?.emojiStatus}}))((({emojiStatus:e})=>{const{setEmojiStatus:t,loadCurrentUser:s}=(0,a.Sv)(),o=(0,Tt.sO)(null),[i,r,c]=(0,xs.Z)(!1),[d,l,u]=(0,xs.Z)(!1),[m,h,p]=(0,xs.Z)(!1),{isMobile:g}=(0,x.ZP)(),f=e?.until?1e3*e.until-Date.now()+1e3*(0,we.Qj)():void 0;(0,Ft.Z)(s,f),(0,Js.Z)((([t])=>{i&&e&&t&&e.documentId!==t.documentId&&(l(),c())}),[e,i,l,c]);const I=(0,Tt.I4)((e=>{r(),t({emojiStatus:e})}),[r,t]);(0,Ft.Z)(u,d?1500:void 0);const v=(0,Tt.I4)((()=>{h()}),[h]);return Tt.ZP.createElement("div",{className:"extra-spacing"},Boolean(d&&e)&&Tt.ZP.createElement(Xs.Z,{reaction:e,isLottie:!0,className:"emoji-status-effect"}),Tt.ZP.createElement(vs.Z,{round:!0,ref:o,ripple:!g,size:"smaller",color:"translucent",className:"emoji-status",onClick:v},e?Tt.ZP.createElement(Ws.Z,{key:e.documentId,documentId:e.documentId,size:24,loopLimit:n.y3O}):Tt.ZP.createElement(Ys.Z,null)),Tt.ZP.createElement(Qs,{statusButtonRef:o,isOpen:m,onEmojiStatusSelect:I,onClose:p}))}))),ta={date:void 0},sa={id:void 0},aa=(0,Tt.X$)((0,a.c$)((e=>{const t=(0,y.jUK)(e),{query:s,fetchingStatus:a,chatId:n,date:o}=t.globalSearch,{connectionState:i,isSyncing:r,isFetchingDifference:c}=e,{isConnectionStatusMinimized:d}=e.settings.byKey;return{searchQuery:s,isLoading:!!a&&Boolean(a.chats||a.messages),globalSearchChatId:n,searchDate:o,theme:(0,y.Puy)(e),connectionState:i,isSyncing:r,isFetchingDifference:c,isMessageListOpen:Boolean((0,y.Btg)(e)),isConnectionStatusMinimized:d,isCurrentUserPremium:(0,y.wVz)(e),areChatsLoaded:Boolean(e.chats.listIds.active),hasPasscode:Boolean(e.passcode.hasPasscode),canSetPasscode:(0,y.eB8)(e)}}))((({shouldHideSearch:e,content:t,contactsFilter:s,isClosingSearch:i,searchQuery:r,isLoading:d,isCurrentUserPremium:l,shouldSkipTransition:u,globalSearchChatId:m,searchDate:h,theme:p,connectionState:g,isSyncing:f,isFetchingDifference:I,isMessageListOpen:v,isConnectionStatusMinimized:w,areChatsLoaded:b,hasPasscode:y,canSetPasscode:P,onSearchQuery:Z,onSelectSettings:S,onSelectContacts:C,onSelectArchived:M,onReset:E})=>{const{setGlobalSearchDate:R,setSettingOption:k,setGlobalSearchChatId:T,lockScreen:N,requestNextSettingsScreen:A}=(0,a.Sv)(),B=(0,Is.Z)(),{isMobile:U}=(0,x.ZP)(),[L,_,O]=(0,xs.Z)(),F=t===c.du.ChatList,D=(0,Tt.Ye)((()=>h?(0,ce.xH)(new Date(1e3*h)):void 0),[h]),{connectionStatus:j,connectionStatusText:q,connectionStatusPosition:G}=As(B,g,f||I,v,w,!b),H=(0,qt.Z)((e=>{e.preventDefault(),e.stopPropagation(),y?N():A({screen:c.MT.PasscodeDisabled})}));(0,us.y)(P?{"Ctrl+Shift+L":H,"Alt+Shift+L":H,"Meta+Shift+L":H,...o.RM&&{"Mod+L":H}}:void 0);const V=(0,Tt.Ye)((()=>({onTrigger:e,isOpen:t})=>Tt.ZP.createElement(vs.Z,{round:!0,ripple:F&&!U,size:"smaller",color:"translucent",className:t?"active":"",onClick:F?e:()=>E(),ariaLabel:F?B("AccDescrOpenMenu2"):"Return to chat list"},Tt.ZP.createElement("div",{className:(0,xt.Z)("animated-menu-icon",!F&&"state-back",u&&"no-animation")}))),[F,U,B,E,u]),$=(0,qt.Z)((()=>{r||Z("")})),z=(0,qt.Z)((()=>{k({isConnectionStatusMinimized:!w})})),K=(0,qt.Z)((()=>{N()})),J=Boolean(m)||t===c.du.GlobalSearch||t===c.du.Contacts;(0,Tt.d4)((()=>J?(0,cs.Z)((()=>E())):void 0),[J,E]);const W=t===c.du.Contacts?B("SearchFriends"):B("Search"),Y=n.Tjg?"10.9.0 Beta (master)":n.eMD?"master":"10.9.0",X=(0,Wt.Ar)(),{shouldDisableDropdownMenuTransitionRef:Q,handleDropdownMenuTransitionEnd:ee}=(0,Us.Z)(e),te=(0,Tt.sO)(null);(0,Bs.Z)(te);const se=(0,Tt.Ye)((()=>Tt.ZP.createElement(Tt.ZP.Fragment,null,D&&Tt.ZP.createElement(Ls.Z,{icon:"calendar",title:D,canClose:!0,isMinimized:Boolean(m),className:"search-date",onClick:R,clickArg:ta}),m&&Tt.ZP.createElement(Ls.Z,{peerId:m,onClick:T,canClose:!0,clickArg:sa}))),[m,D]);return Tt.ZP.createElement("div",{className:"LeftMainHeader"},Tt.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header",ref:te},B.isRtl&&Tt.ZP.createElement("div",{className:"DropdownMenuFiller"}),Tt.ZP.createElement(Os.Z,{trigger:V,footer:`${n.iCi} ${Y}`,className:(0,xt.Z)("main-menu",B.isRtl&&"rtl",e&&B.isRtl&&"right-aligned",Q.current&&B.isRtl&&"disable-transition"),forceOpen:L,positionX:e&&B.isRtl?"right":"left",transformOriginX:o.D$&&o.jm&&!X?90:void 0,onTransitionEnd:B.isRtl?ee:void 0},Tt.ZP.createElement(Ks,{onSelectArchived:M,onSelectContacts:C,onSelectSettings:S,onBotMenuOpened:_,onBotMenuClosed:O})),Tt.ZP.createElement(Fs.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:(0,xt.Z)(m||h?"with-picker-item":void 0,e&&"SearchInput--hidden"),value:i?void 0:s||r,focused:J,isLoading:d||"minimized"===G,spinnerColor:"minimized"===G?"yellow":void 0,spinnerBackgroundColor:"minimized"===G&&"light"===p?"light":void 0,placeholder:W,autoComplete:"off",canClose:Boolean(m||h),onChange:Z,onReset:E,onFocus:$,onSpinnerClick:"minimized"===G?z:void 0},se,Tt.ZP.createElement(_s.Z,{canShow:!J&&!D&&!m})),l&&Tt.ZP.createElement(ea,null),y&&Tt.ZP.createElement(vs.Z,{round:!0,ripple:!U,size:"smaller",color:"translucent",ariaLabel:`${B("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:K,className:(0,xt.Z)(!l&&"extra-spacing")},Tt.ZP.createElement("i",{className:"icon icon-lock"})),Tt.ZP.createElement(Ds.Z,{isOpen:"overlay"===G,isCustom:!0,className:"connection-state-wrapper"},Tt.ZP.createElement(qs,{connectionStatus:j,connectionStatusText:q,onClick:z}))))}))),na=Object.keys(c.du).length/2;let oa;const ia=(0,Tt.X$)((({content:e,searchQuery:t,searchDate:s,isClosingSearch:i,contactsFilter:r,shouldSkipTransition:d,foldersDispatch:l,isAppUpdateAvailable:u,isElectronUpdateAvailable:m,isForumPanelOpen:h,onSearchQuery:p,onContentChange:g,onSettingsScreenSelect:f,onReset:I,onTopicSearch:v})=>{const{closeForumPanel:w}=(0,a.Sv)(),[b,y]=(0,Tt.eJ)(o.$b),[P,Z]=(0,Tt.eJ)(!1);(0,Tt.d4)((()=>{window.electron?.getIsAutoUpdateEnabled().then(Z)}),[]);const{shouldRenderForumPanel:S,handleForumPanelAnimationEnd:C,handleForumPanelAnimationStart:M,isAnimationStarted:E}=(0,fs.Z)(h),R=h&&e===c.du.ChatList,k=R&&E,{shouldRender:T,transitionClassNames:N}=(0,$t.Z)(u||m),A=(0,Tt.sO)(!1),B=(0,qt.Z)((()=>{e===c.du.ChatList&&(A.current=!0,y(!0))})),x=(0,qt.Z)((()=>{A.current=!1,oa&&(clearTimeout(oa),oa=void 0),oa=window.setTimeout((()=>{A.current||y(!1)}),250)})),U=(0,qt.Z)((()=>{g(c.du.Settings)})),L=(0,qt.Z)((()=>{g(c.du.Contacts)})),_=(0,qt.Z)((()=>{g(c.du.Archived),w()})),O=(0,qt.Z)((()=>{o.D$&&!P?window.open(`${n.bl0}/get`,"_blank","noopener"):m?window.electron?.installUpdate():window.location.reload()})),F=(0,qt.Z)((()=>{g(c.du.NewChannelStep1)})),D=(0,qt.Z)((()=>{g(c.du.NewGroupStep1)}));(0,Tt.d4)((()=>{let t;return e!==c.du.ChatList?t=window.setTimeout((()=>{y(!1)}),250):(A.current||o.$b)&&y(!0),()=>{t&&(clearTimeout(t),t=void 0)}}),[e]);const j=(0,Is.Z)();return Tt.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:o.$b?void 0:B,onMouseLeave:o.$b?void 0:x},Tt.ZP.createElement(aa,{shouldHideSearch:k,content:e,contactsFilter:r,onSearchQuery:p,onSelectSettings:U,onSelectContacts:L,onSelectArchived:_,onReset:I,shouldSkipTransition:d,isClosingSearch:i}),Tt.ZP.createElement(hs.ZP,{name:d?"none":"zoomFade",renderCount:na,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:c.du.ChatList,shouldWrap:!0,wrapExceptionKey:c.du.ChatList},(a=>{switch(e){case c.du.ChatList:return Tt.ZP.createElement(Rs,{shouldHideFolderTabs:k,onSettingsScreenSelect:f,onLeftColumnContentChange:g,foldersDispatch:l,isForumPanelOpen:k});case c.du.GlobalSearch:return Tt.ZP.createElement(Ps,{searchQuery:t,searchDate:s,isActive:a,onReset:I});case c.du.Contacts:return Tt.ZP.createElement(ks,{filter:r,isActive:a,onReset:I});default:return}})),T&&Tt.ZP.createElement(vs.Z,{fluid:!0,pill:!0,className:(0,xt.Z)("btn-update",N),onClick:O},j("lng_update_telegram")),S&&Tt.ZP.createElement(Ts.Z,{isOpen:h,isHidden:!R,onTopicSearch:v,onOpenAnimationStart:M,onCloseAnimationEnd:C}),Tt.ZP.createElement(ys,{isShown:b,onNewPrivateChat:L,onNewChannel:F,onNewGroup:D}))})),ra=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"NewChat");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},ca=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"Settings");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)};var da=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}(da||{});const la=Object.keys(da).length/2,ua=(0,Tt.X$)((0,a.c$)((e=>{const t=(0,y.jUK)(e),{globalSearch:{query:s,date:a},shouldSkipHistoryAnimations:n,activeChatFolder:o,nextSettingsScreen:i,nextFoldersAction:r,storyViewer:{isArchivedRibbonShown:c}}=t,{currentUserId:d,passcode:{hasPasscode:l},isAppUpdateAvailable:u,isElectronUpdateAvailable:m,archiveSettings:h}=e,p=(0,y.jrE)(e);return{searchQuery:s,searchDate:a,isFirstChatFolderActive:0===o,shouldSkipHistoryAnimations:n,currentUserId:d,hasPasscode:l,nextSettingsScreen:i,nextFoldersAction:r,isChatOpen:Boolean(p?.id),isAppUpdateAvailable:u,isElectronUpdateAvailable:m,isForumPanelOpen:(0,y.nd)(e),forumPanelChatId:t.forumPanelChatId,isClosingSearch:t.globalSearch.isClosing,archiveSettings:h,isArchivedStoryRibbonShown:c}}))((function({ref:e,searchQuery:t,searchDate:s,isFirstChatFolderActive:n,shouldSkipHistoryAnimations:i,currentUserId:r,hasPasscode:d,nextSettingsScreen:l,nextFoldersAction:u,isChatOpen:m,isAppUpdateAvailable:h,isElectronUpdateAvailable:p,isForumPanelOpen:g,forumPanelChatId:f,isClosingSearch:I,archiveSettings:v,isArchivedStoryRibbonShown:w}){const{setGlobalSearchQuery:b,setGlobalSearchClosing:y,setGlobalSearchChatId:P,resetChatCreation:Z,setGlobalSearchDate:S,loadPasswordInfo:C,clearTwoFaError:M,openChat:E,requestNextSettingsScreen:R}=(0,a.Sv)(),[k,T]=(0,Tt.eJ)(c.du.ChatList),[N,A]=(0,Tt.eJ)(c.MT.Main),[B,x]=(0,Tt.eJ)(""),[U,L]=(0,ls.ZP)(),[_,O]=(0,Tt.eJ)(0);let F=da.Main;switch(k){case c.du.Archived:F=da.Archived;break;case c.du.Settings:F=da.Settings;break;case c.du.NewChannelStep1:case c.du.NewChannelStep2:F=da.NewChannel;break;case c.du.NewGroupStep1:case c.du.NewGroupStep2:F=da.NewGroup}const D=(0,qt.Z)((e=>{function t(){T(c.du.ChatList),A(c.MT.Main),x(""),y({isClosing:!0}),Z(),setTimeout((()=>{b({query:""}),S({date:void 0}),P({id:void 0}),y({isClosing:!1}),O(Date.now())}),250)}if(!0!==e)if(k!==c.du.NewGroupStep2)if(k!==c.du.NewChannelStep2){if(k===c.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(k===c.du.Settings)switch(N){case c.MT.EditProfile:case c.MT.Folders:case c.MT.General:case c.MT.Notifications:case c.MT.DataStorage:case c.MT.Privacy:case c.MT.Performance:case c.MT.ActiveSessions:case c.MT.Language:case c.MT.Stickers:case c.MT.Experimental:return void A(c.MT.Main);case c.MT.GeneralChatBackground:return void A(c.MT.General);case c.MT.GeneralChatBackgroundColor:return void A(c.MT.GeneralChatBackground);case c.MT.PrivacyPhoneNumber:case c.MT.PrivacyAddByPhone:case c.MT.PrivacyLastSeen:case c.MT.PrivacyProfilePhoto:case c.MT.PrivacyBio:case c.MT.PrivacyPhoneCall:case c.MT.PrivacyPhoneP2P:case c.MT.PrivacyForwarding:case c.MT.PrivacyGroupChats:case c.MT.PrivacyVoiceMessages:case c.MT.PrivacyMessages:case c.MT.PrivacyBlockedUsers:case c.MT.ActiveWebsites:case c.MT.TwoFaDisabled:case c.MT.TwoFaEnabled:case c.MT.TwoFaCongratulations:case c.MT.PasscodeDisabled:case c.MT.PasscodeEnabled:case c.MT.PasscodeCongratulations:return void A(c.MT.Privacy);case c.MT.PasscodeNewPasscode:return void A(d?c.MT.PasscodeEnabled:c.MT.PasscodeDisabled);case c.MT.PasscodeChangePasscodeCurrent:case c.MT.PasscodeTurnOff:return void A(c.MT.PasscodeEnabled);case c.MT.PasscodeNewPasscodeConfirm:return void A(c.MT.PasscodeNewPasscode);case c.MT.PasscodeChangePasscodeNew:return void A(c.MT.PasscodeChangePasscodeCurrent);case c.MT.PasscodeChangePasscodeConfirm:return void A(c.MT.PasscodeChangePasscodeNew);case c.MT.PrivacyPhoneNumberAllowedContacts:case c.MT.PrivacyPhoneNumberDeniedContacts:return void A(c.MT.PrivacyPhoneNumber);case c.MT.PrivacyLastSeenAllowedContacts:case c.MT.PrivacyLastSeenDeniedContacts:return void A(c.MT.PrivacyLastSeen);case c.MT.PrivacyProfilePhotoAllowedContacts:case c.MT.PrivacyProfilePhotoDeniedContacts:return void A(c.MT.PrivacyProfilePhoto);case c.MT.PrivacyBioAllowedContacts:case c.MT.PrivacyBioDeniedContacts:return void A(c.MT.PrivacyBio);case c.MT.PrivacyPhoneCallAllowedContacts:case c.MT.PrivacyPhoneCallDeniedContacts:return void A(c.MT.PrivacyPhoneCall);case c.MT.PrivacyPhoneP2PAllowedContacts:case c.MT.PrivacyPhoneP2PDeniedContacts:return void A(c.MT.PrivacyPhoneP2P);case c.MT.PrivacyForwardingAllowedContacts:case c.MT.PrivacyForwardingDeniedContacts:return void A(c.MT.PrivacyForwarding);case c.MT.PrivacyVoiceMessagesAllowedContacts:case c.MT.PrivacyVoiceMessagesDeniedContacts:return void A(c.MT.PrivacyVoiceMessages);case c.MT.PrivacyGroupChatsAllowedContacts:case c.MT.PrivacyGroupChatsDeniedContacts:return void A(c.MT.PrivacyGroupChats);case c.MT.TwoFaNewPassword:return void A(c.MT.TwoFaDisabled);case c.MT.TwoFaNewPasswordConfirm:return void A(c.MT.TwoFaNewPassword);case c.MT.TwoFaNewPasswordHint:return void A(c.MT.TwoFaNewPasswordConfirm);case c.MT.TwoFaNewPasswordEmail:return void A(c.MT.TwoFaNewPasswordHint);case c.MT.TwoFaNewPasswordEmailCode:return void A(c.MT.TwoFaNewPasswordEmail);case c.MT.TwoFaChangePasswordCurrent:case c.MT.TwoFaTurnOff:case c.MT.TwoFaRecoveryEmailCurrentPassword:return void A(c.MT.TwoFaEnabled);case c.MT.TwoFaChangePasswordNew:return void A(c.MT.TwoFaChangePasswordCurrent);case c.MT.TwoFaChangePasswordConfirm:return void A(c.MT.TwoFaChangePasswordNew);case c.MT.TwoFaChangePasswordHint:return void A(c.MT.TwoFaChangePasswordConfirm);case c.MT.TwoFaRecoveryEmail:return void A(c.MT.TwoFaRecoveryEmailCurrentPassword);case c.MT.TwoFaRecoveryEmailCode:return void A(c.MT.TwoFaRecoveryEmail);case c.MT.FoldersCreateFolder:case c.MT.FoldersEditFolder:return void A(c.MT.Folders);case c.MT.FoldersShare:return void A(c.MT.FoldersEditFolder);case c.MT.FoldersIncludedChatsFromChatList:case c.MT.FoldersExcludedChatsFromChatList:return void A(c.MT.FoldersEditFolderFromChatList);case c.MT.FoldersEditFolderFromChatList:case c.MT.FoldersEditFolderInvites:return T(c.du.ChatList),void A(c.MT.Main);case c.MT.QuickReaction:case c.MT.CustomEmoji:return void A(c.MT.Stickers);case c.MT.DoNotTranslate:return void A(c.MT.Language)}k===c.du.ChatList&&n?T(c.du.GlobalSearch):t()}else T(c.du.NewChannelStep1);else T(c.du.NewGroupStep1);else t()})),j=(0,qt.Z)((e=>{k!==c.du.Contacts?(T(c.du.GlobalSearch),e!==t&&b({query:e})):x(e)})),q=(0,qt.Z)((()=>{T(c.du.GlobalSearch),b({query:""}),P({id:f})}));(0,Tt.d4)((()=>{const e=k===c.du.Archived,t=k===c.du.ChatList,s=!m&&!g;return e&&s||!t&&!e||n&&s?(0,cs.Z)((()=>{D()})):void 0}),[n,k,D,m,g]);const G=(0,qt.Z)((e=>{k!==c.du.GlobalSearch&&(e.preventDefault(),T(c.du.GlobalSearch))})),H=(0,qt.Z)((e=>{e.preventDefault(),E({id:r,shouldReplaceHistory:!0})})),V=(0,qt.Z)((e=>{e.preventDefault(),T(c.du.Archived)})),$=(0,qt.Z)((e=>{e.preventDefault(),T(c.du.Settings)}));(0,us.y)({"Mod+Shift+F":G,...!o.D1&&{"Mod+Shift+S":H},...o.RM&&{"Mod+0":H,"Mod+9":V},...o.jm&&o.RM&&{"Mod+,":$}}),(0,Tt.d4)((()=>{M(),N===c.MT.Privacy&&C()}),[M,C,N]),(0,zt.Z)((()=>{void 0!==l&&(T(c.du.Settings),A(l),R({screen:void 0})),u&&L(u)}),[L,u,l,R]);const z=(0,qt.Z)((e=>{T(c.du.Settings),A(e)})),K=(0,ms.Y)(function(e){const t=(0,Tt.sO)(),s=(0,Tt.sO)();return s.current!==e&&(t.current=s.current),s.current=e,t.current}(F===da.Settings?N:-1));function J(e){switch(F){case da.Archived:return Tt.ZP.createElement(gs,{isActive:e,onReset:D,onTopicSearch:q,foldersDispatch:L,onSettingsScreenSelect:z,onLeftColumnContentChange:T,isForumPanelOpen:g,archiveSettings:v,isStoryRibbonShown:w});case da.Settings:return Tt.ZP.createElement(ca,{isActive:e,currentScreen:N,foldersState:U,foldersDispatch:L,shouldSkipTransition:i,onScreenSelect:z,onReset:D});case da.NewChannel:return Tt.ZP.createElement(ra,{key:_,isActive:e,isChannel:!0,content:k,onContentChange:T,onReset:D});case da.NewGroup:return Tt.ZP.createElement(ra,{key:_,isActive:e,content:k,onContentChange:T,onReset:D});default:return Tt.ZP.createElement(ia,{content:k,isClosingSearch:I,searchQuery:t,searchDate:s,contactsFilter:B,foldersDispatch:L,onContentChange:T,onSearchQuery:j,onSettingsScreenSelect:z,onReset:D,shouldSkipTransition:i,isAppUpdateAvailable:h,isElectronUpdateAvailable:p,isForumPanelOpen:g,onTopicSearch:q})}}return(0,Tt.d4)((()=>{if(o.$b)return(0,ds.U)(e.current,{excludedClosestSelector:".ProfileInfo, .color-picker, .hue-picker",selectorToPreventScroll:"#Settings .custom-scroll",onSwipeRightStart:D,onCancel:()=>{T(c.du.Settings),z(K.current)}})}),[K,e]),Tt.ZP.createElement(hs.ZP,{ref:e,name:i?"none":o.s0,renderCount:la,activeKey:F,shouldCleanup:!0,cleanupExceptionKey:da.Main,shouldWrap:!0,wrapExceptionKey:da.Main,id:"LeftColumn",withSwipeControl:!0},J)}))),ma=({isOpen:e})=>{const t=(0,Yt.Z)(_t.gl.Extra,"MediaViewer",!e);return t?Tt.ZP.createElement(t,null):void 0};var ha=s(10396),pa=s(64532),ga=s(32340),fa=s(23186),Ia=s(17240),va=s(93447),wa=s(77510),ba=s(6202);const ya=s.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",Pa={width:200,height:200},Za=115;var Sa=s(18051),Ca=s(68512);const Ma={.5:.66,.75:.8,1:1,1.5:1.4,2:1.8},Ea=Object.keys(Ma).sort().map(Number),Ra=(0,a.c$)(((e,{message:t})=>{const s=(0,y.Urc)(e,t),a=(0,y.Z1J)(e,t.chatId),{volume:n,playbackRate:o,isMuted:i,isPlaybackRateActive:r}=(0,y.jUK)(e).audioPlayer;return{sender:s,chat:a,volume:n,playbackRate:o,isPlaybackRateActive:r,isMuted:i}}))((({message:e,className:t,noUi:s,sender:i,chat:r,volume:c,playbackRate:d,isPlaybackRateActive:l,isMuted:u})=>{const{setAudioPlayerVolume:m,setAudioPlayerPlaybackRate:h,setAudioPlayerMuted:p,focusMessage:g,closeAudioPlayer:f}=(0,a.Sv)(),I=(0,Tt.sO)(null),w=(0,Is.Z)(),{isMobile:b}=(0,x.ZP)(),{audio:y,voice:P,video:Z}=(0,v.qp)(e),S=Boolean(P||Z),C=S||(y?.duration||0)>n.J0S,E=i?(0,v.OU)(w,i):void 0,R=Ue.UV((0,v.Ti)(e,"inline")),k=((e,t,s)=>{const a=(0,Is.Z)(),{audio:n,voice:o}=(0,v.qp)(e),i=n?n.title||n.fileName:o?"Voice message":"",r=n?.performer||t&&(0,v.OU)(a,t),c=s&&(0,v.U)(a,s)||"Telegram",d=n&&(0,v.MR)(n)&&(0,v.Ti)(e,"pictogram"),l=t&&(0,v.RT)(t,"big"),u=n&&d||o&&l,m=(0,ba.Z)(u),h=(0,Tt.Ye)((()=>function(e,t,s){if(!s)return Pa;if(e){if(!e.thumbnailSizes?.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?M.vY:void 0}(n,o,m)),[n,m,o]),{result:p}=(0,wa.Z)((()=>function(e,t){if(!e)return Promise.resolve(ya);if(!t)return(0,va.t)(e,Za,Za);const s=Math.min(t.width,t.height);if(s<Za){const t=Za/s;return(0,va.j)(e,t)}return Promise.resolve(e)}(m,h)),[m,h],ya);return(0,Tt.Ye)((()=>(0,pa.Of)({title:i,artist:r,album:c,artwork:[{src:p}]})),[c,r,i,p])})(e,i,r),{playPause:T,stop:N,isPlaying:A,requestNextTrack:B,requestPreviousTrack:U,isFirst:L,isLast:_,setVolume:O,toggleMuted:F,setPlaybackRate:D}=(0,fa.Z)((0,ha.An)(e),(0,v.XV)(e),S?"voice":"audio",R,void 0,k,void 0,!0,void 0,void 0,(0,v.CI)(e),!0),{isContextMenuOpen:j,handleBeforeContextMenu:q,handleContextMenu:G,handleContextMenuClose:H,handleContextMenuHide:V}=(0,Ia.Z)(I),$=(0,qt.Z)((()=>{g({chatId:e.chatId,messageId:e.id})})),z=(0,qt.Z)((()=>{N&&(A&&T(),f(),(0,pa.Ay)(),N())})),K=(0,qt.Z)((e=>{O&&(m({volume:e/100}),O(e/100))})),J=(0,qt.Z)((()=>{o.$b&&!o.cj||F&&(F(),p({isMuted:!u}))})),W=(0,qt.Z)(((e,t=!0)=>{if(!D)return;const s=Ma[e],a=1!==e&&t;h({playbackRate:s,isPlaybackRateActive:a}),D(a?s:1)})),Y=(0,qt.Z)((()=>{H();const e=Number(Object.entries(Ma).find((([,e])=>e===d))?.[0])||1,t=!l;W(t&&1===e?2:e,t)})),X=(0,qt.Z)((()=>{const e=Object.entries(Ma).find((([,e])=>e===d))?.[0]||1,t=`${1===d?2:e}Х`;return Tt.ZP.createElement("div",{className:"playback-wrapper"},j&&Tt.ZP.createElement("div",{className:"playback-backdrop",onClick:H}),Tt.ZP.createElement(vs.Z,{round:!0,className:(0,xt.Z)("playback-button",l&&"applied",j&&"on-top"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!b,onMouseEnter:G,onClick:Y,onMouseDown:q,onContextMenu:G},Tt.ZP.createElement("span",{className:(0,xt.Z)("playback-button-inner",4===t.length&&"small",5===t.length&&"tiny")},t)))})),Q=(0,Tt.Ye)((()=>0===c||u?"icon-muted":c<.3?"icon-volume-1":c<.6?"icon-volume-2":"icon-volume-3"),[c,u]);if(!s)return Tt.ZP.createElement("div",{className:(0,xt.Z)("AudioPlayer",t),dir:w.isRtl?"rtl":void 0,ref:I},Tt.ZP.createElement("div",{className:"AudioPlayer-content",onClick:$},y?function(e){const{title:t,performer:s,fileName:a}=e;return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:"title",dir:"auto"},(0,ga.Z)(t||a)),s&&Tt.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,ga.Z)(s)))}(y):function(e,t){return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,ga.Z)(t)),Tt.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(w("AttachAudio"),E),Tt.ZP.createElement(Ca.Z,null)),Tt.ZP.createElement(vs.Z,{round:!0,ripple:!b,color:"translucent",size:"smaller",className:"player-button",disabled:L?.(),onClick:U,ariaLabel:"Previous track"},Tt.ZP.createElement("i",{className:"icon icon-skip-previous"})),Tt.ZP.createElement(vs.Z,{round:!0,ripple:!b,color:"translucent",size:"smaller",className:(0,xt.Z)("toggle-play","player-button",A?"pause":"play"),onClick:T,ariaLabel:A?"Pause audio":"Play audio"},Tt.ZP.createElement("i",{className:"icon icon-play"}),Tt.ZP.createElement("i",{className:"icon icon-pause"})),Tt.ZP.createElement(vs.Z,{round:!0,ripple:!b,color:"translucent",size:"smaller",className:"player-button",disabled:_?.(),onClick:B,ariaLabel:"Next track"},Tt.ZP.createElement("i",{className:"icon icon-skip-next"})),Tt.ZP.createElement("div",{className:"volume-button-wrapper"},Tt.ZP.createElement(vs.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",onClick:J,ripple:!b},Tt.ZP.createElement("i",{className:(0,xt.Z)("icon",Q)})),!o.cj&&Tt.ZP.createElement("div",{className:"volume-slider-wrapper"},Tt.ZP.createElement("div",{className:"volume-slider-spacer"}),Tt.ZP.createElement("div",{className:"volume-slider"},Tt.ZP.createElement(Sa.Z,{bold:!0,value:u?0:100*c,onChange:K})))),C&&Tt.ZP.createElement(Os.Z,{forceOpen:j,positionX:"right",positionY:"top",className:"playback-rate-menu",trigger:X,onClose:H,onHide:V,onMouseEnterBackdrop:H},Ea.map((e=>function(e,t,s,a){const n=t===Ma[e]&&a||1===e&&!a;return Tt.ZP.createElement(bs.Z,{key:e,onClick:()=>s(e),icon:n?"check":void 0,customIcon:n?void 0:Tt.ZP.createElement("i",{className:"icon icon-placeholder"})},e,"X")}(e,d,W,l)))),Tt.ZP.createElement(vs.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:z,ariaLabel:"Close player"},Tt.ZP.createElement("i",{className:"icon icon-close"})))})),ka=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"ReactionPicker",!t);return s?Tt.ZP.createElement(s,e):void 0};function Ta(){return Ta=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},Ta.apply(this,arguments)}const Na=(0,Tt.X$)((0,a.c$)((e=>({messageLists:(0,y.jUK)(e).messageLists})))((({messageLists:e})=>{const{openChat:t}=(0,a.Sv)(),s=()=>{t({id:void 0},{forceSyncOnIOs:!0})},n=({chatId:e,type:t,threadId:a})=>{(0,Ss.Z)({isActive:!0,hash:(0,_e.tB)(e,t,a),onBack:s})};return Tt.ZP.createElement("div",null,e?.map(((e,t)=>Tt.ZP.createElement(n,Ta({key:`${e.chatId}_${e.threadId}_${e.type}_${t}`},e)))))})));var Aa=s(80036),Ba=s(49524),xa=s(71394);var Ua=s(52678),La=s(87204),_a=s(22418),Oa=s(3570),Fa=s(28712),Da=s(33799),ja=s(37149);const qa=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"PrivacySettingsNoticeModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Ga=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"SeenByModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Ha=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"UnpinAllMessagesModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Va=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"GiftPremiumModal",!t);return s?Tt.ZP.createElement(s,e):void 0},$a=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"ChatLanguageModal",!t);return s?Tt.ZP.createElement(s,e):void 0};var za=s(12420);const Ka=e=>{const{activeEmojiInteraction:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"EmojiInteractionAnimation",!t);return s?Tt.ZP.createElement(s,e):void 0};var Ja=s(81740);const Wa=(0,Tt.X$)((({icon:e,ariaLabelLang:t,unreadCount:s,onClick:a,onReadAll:n,className:o})=>{const i=(0,Is.Z)(),r=(0,Tt.sO)(null),{isContextMenuOpen:c,handleContextMenu:d,handleContextMenuClose:l,handleContextMenuHide:u}=(0,Ia.Z)(r,!n);return Tt.ZP.createElement("div",{className:(0,xt.Z)("Y2NKrpKj",o),ref:r},Tt.ZP.createElement(vs.Z,{color:"secondary",round:!0,className:"cxwA6gDO",onClick:a,onContextMenu:d,ariaLabel:i(t)},Tt.ZP.createElement("i",{className:(0,xt.Z)("F4zNUFhH","icon",`icon-${e}`)})),Boolean(s)&&Tt.ZP.createElement("div",{className:"GovSzpfQ"},(0,os.bi)(s)),n&&Tt.ZP.createElement(ws.Z,{isOpen:c,onClose:l,onCloseAnimationEnd:u,autoClose:!0,positionX:"right",positionY:"bottom"},Tt.ZP.createElement(bs.Z,{icon:"readchats",onClick:n},i("MarkAllAsRead"))))})),Ya="UMXbiYB3",Xa=(0,Tt.X$)((0,a.c$)((e=>{const t=(0,y.Btg)(e);if(!t)return{};const{chatId:s,threadId:a,type:n}=t,o=(0,y.Z1J)(e,s),i=o&&a===r._f&&"thread"===n;return{messageListType:n,chatId:s,reactionsCount:i?o.unreadReactionsCount:void 0,mentionsCount:i?o.unreadMentionsCount:void 0,unreadCount:i?o.unreadCount:void 0}}))((({isShown:e,canPost:t,messageListType:s,chatId:n,unreadCount:o,reactionsCount:i,mentionsCount:r,withExtraShift:c})=>{const{focusNextReply:d,focusNextReaction:l,focusNextMention:u,fetchUnreadReactions:m,readAllMentions:h,readAllReactions:p,fetchUnreadMentions:g}=(0,a.Sv)(),f=(0,Tt.sO)(null),I=Boolean(i),v=Boolean(r);(0,Tt.d4)((()=>{I&&n&&m({chatId:n})}),[n,m,I]),(0,Tt.d4)((()=>{v&&n&&g({chatId:n})}),[n,g,v]);const w=(0,qt.Z)((()=>{if(e)if("thread"===s)d();else{const e=f.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,Ja.ZP)(e,s,"end",20)}})),b=(0,xt.Z)("VWoOZCD5",(e||Boolean(i)||Boolean(r))&&"iozW83la",(Boolean(i)||Boolean(r))&&!e&&"dpkAoSjW",!t&&"yzzjqibi",!c&&"wDwOdyQH");return Tt.ZP.createElement("div",{ref:f,className:b},Tt.ZP.createElement(Wa,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:l,onReadAll:p,unreadCount:i,className:(0,xt.Z)("eO_Fz8SD",!I&&Ya,!v&&"gn3iLVq1")}),Tt.ZP.createElement(Wa,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:u,onReadAll:h,unreadCount:r,className:!v&&Ya}),Tt.ZP.createElement(Wa,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:w,unreadCount:o,className:"u62x81QI"}))})));var Qa=s(87675);function en(e){return"albumId"in e}function tn(e,t,s,a){let n,o=[],i={originalDate:e[0].date,datetime:(0,ce._F)(1e3*e[0].date),senderGroups:[o]};const r=[i];return e.forEach(((c,d)=>{c.isInAlbum?n?(n.messages.push(c),(c.hasComments||c.content.text&&!n.mainMessage.hasComments)&&(n.mainMessage=c)):n={albumId:c.groupedId,messages:[c],mainMessage:c}:o.push(c);const l=e[d+1];!n||l&&l.groupedId&&l.groupedId===n.albumId||(o.push(n),n=void 0);const u=o[o.length-1];if(l){const e=(0,ce._F)(1e3*l.date);i.datetime!==e?(i={originalDate:l.date,datetime:e,senderGroups:[]},r.push(i),o=[],i.senderGroups.push(o)):(l.id===t||c.senderId!==l.senderId||c.isOutgoing!==l.isOutgoing||(0,v.FT)(c)&&!c.content.action?.phoneCall||(0,v.FT)(l)&&!l.content.action?.phoneCall||c.inlineButtons||l.inlineButtons||l.date-c.date>600||s&&(c.id===s||u&&"mainMessage"in u&&u.mainMessage?.id===s)&&l.id!==s||a&&c.forwardInfo?.fromId!==l.forwardInfo?.fromId)&&(o=[],i.senderGroups.push(o))}})),r}var sn=s(30386),an=s(72645),nn=s(60998);var on=s(78722),rn=s(88957);var cn=s(36765);const dn=(0,Tt.X$)((0,a.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,a=(0,y.Z1J)(e,t);if(!a)return{};const n=(0,y._If)(e,a.id);return{stickers:s,lastUnreadMessageId:n&&n.id!==a.lastReadInboxMessageId?n.id:void 0,connectionState:e.connectionState,currentMessageList:(0,y.Btg)(e)}}))((({stickers:e,connectionState:t,lastUnreadMessageId:s,currentMessageList:n})=>{const{loadGreetingStickers:o,sendMessage:i,markMessageListRead:r}=(0,a.Sv)(),c=(0,Is.Z)(),d=(0,Tt.sO)(null),l=(0,Tt.Ye)((()=>{if(!e?.length)return;const t=Math.floor(Math.random()*e.length);return e[t]}),[e]);(0,Tt.d4)((()=>{e?.length||"connectionStateReady"!==t||o()}),[t,o,e]),(0,Tt.d4)((()=>{"connectionStateReady"===t&&s&&r({maxId:s})}),[t,r,s]);const u=(0,qt.Z)((()=>{n&&i({sticker:{...l,isPreloadedGlobally:!0},messageList:n})}));return Tt.ZP.createElement("div",{className:"ContactGreeting"},Tt.ZP.createElement("div",{className:"wrapper"},Tt.ZP.createElement("p",{className:"title",dir:"auto"},c("Conversation.EmptyPlaceholder")),Tt.ZP.createElement("p",{className:"description",dir:"auto"},c("Conversation.GreetingText")),Tt.ZP.createElement("div",{ref:d,className:"sticker",onClick:u},l&&Tt.ZP.createElement(cn.Z,{containerRef:d,sticker:l,size:160,shouldLoop:!0}))))})));var ln=s(38146),un=s(57080),mn=s(74607);const hn=(0,Tt.X$)((0,a.c$)(((e,{chatId:t})=>{const s=(0,y.kBx)(e,t);let a,n=!1;if(s){const t=(0,y.ccz)(e,s.id);t?a=t.botInfo:n=!0}return{botInfo:a,isLoadingBotInfo:n}}))((({botInfo:e,isLoadingBotInfo:t,isInMessageList:s})=>{const a=(0,Is.Z)(),n=(0,ln.Z)(),o=(0,ba.Z)(e?.photo?(0,v.NF)(e.photo):void 0),i=(0,ba.Z)(e?.gif?(0,v.ym)(e.gif):void 0),r=e?.photo?(0,v.bV)(e.photo):e?.gif?(0,v.jC)(e.gif):void 0,c=r&&{width:r.width/n,height:r.height/n},d=e&&!e.description&&!e.gif&&!e.photo,{width:l,height:u}=c||{};if(!d&&!t||!s)return Tt.ZP.createElement("div",{className:(0,xt.Z)("sqThK406","empty")},t&&Tt.ZP.createElement("span",null,a("Loading")),d&&!t&&Tt.ZP.createElement("span",null,a("NoMessages")),e&&Tt.ZP.createElement("div",{className:"XhDB6LWO",style:c&&`width: ${c.width}px`},o&&Tt.ZP.createElement("img",{className:"y7ijMlDf",src:o,width:c?.width,height:c?.height,alt:"Bot info"}),i&&Tt.ZP.createElement(un.Z,{canPlay:!0,src:i,loop:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0,style:(0,Aa.Z)(Boolean(l)&&`width: ${l}px`,Boolean(u)&&`height: ${u}px`)}),r&&!o&&!i&&Tt.ZP.createElement(mn.Z,{width:c?.width,height:c?.height}),e.description&&Tt.ZP.createElement("div",{className:"lbMO1XqP"},Tt.ZP.createElement("p",{className:"ELYpyMpR"},a("BotInfoTitle")),(0,ga.Z)(e.description,["br","emoji","links"]))))})));var pn=s(71790),gn=s(3657);const fn=o.wZ?1e3:350;var In=s(11309),vn=s(93862),wn=s(64261),bn=s(55254),yn=s(3858),Pn=s(33780),Zn=s(44139),Sn=s(83967);const Cn={None:0,Top:1,Right:2,Bottom:4,Left:8};function Mn(e,t){return e.reduce(((e,t)=>e+t),t)}function En(e){const t={width:0,height:0};return e.forEach((({dimensions:e,sides:s})=>{s&Cn.Right&&(t.width=e.width+e.x),s&Cn.Bottom&&(t.height=e.height+e.y)})),t}function Rn(e,t,s,a,n){const o=function(e,t){return e.map((e=>{const s=(0,Sn.GH)(e,void 0,void 0,t);return s.width/s.height}))}(a.messages,n),i=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(o),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(o),c=o.length,d=o.some((e=>e>2)),l=(0,M.kc)(e,t,!1,s,n)-(t?2.5:0)*M.Gw;let u;const m={ratios:o,proportions:i,averageRatio:r,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return u=c>=5||d?function({ratios:e,averageRatio:t,maxWidth:s,minWidth:a,spacing:n,maxHeight:o=4*s/3}){const i=function(e,t){return e.map((e=>t>1.1?(0,Fa.uZ)(e,1,2.75):(0,Fa.uZ)(e,.6667,1)))}(e,t),r=e.length,c=new Array(r),d=[],l=e=>{const t=[];let a=0;e.forEach((e=>{t.push(((e,t)=>{const a=Mn(i.slice(e,e+t),0);return(s-(t-1)*n)/a})(a,e)),a+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==r;++e){const t=r-e;e<=3&&t<=3&&l([e,t])}for(let e=1;e!==r-1;++e)for(let s=1;s!==r-e;++s){const a=r-e-s;e<=3&&s<=(t<.85?4:3)&&a<=3&&l([e,s,a])}for(let e=1;e!==r-1;++e)for(let t=1;t!==r-e;++t)for(let s=1;s!==r-e-t;++s){const a=r-e-t-s;e<=3&&t<=3&&s<=3&&a<=4&&l([e,t,s,a])}let u,m=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:s}=d[e],i=s.length,r=Mn(t,0)+n*(i-1),c=Math.min(...t)<a?1.5:1,l=(()=>{for(let e=1;e!==i;++e)if(s[e-1]>s[e])return 1.5;return 1})(),h=Math.abs(r-o)*c*l;(!u||h<m)&&(u=d[e],m=h)}const h=u.lineCounts,p=u.heights,g=h.length;let f=0,I=0;for(let e=0;e!==g;++e){const t=h[e],a=p[e],o=Math.round(a);let r=0;for(let d=0;d!==t;++d){const l=Cn.None|(0===e?Cn.Top:Cn.None)|(e===g-1?Cn.Bottom:Cn.None)|(0===d?Cn.Left:Cn.None)|(d===t-1?Cn.Right:Cn.None),u=i[f],m=d===t-1?s-r:Math.round(u*a);c[f]={dimensions:{x:r,y:I,width:m,height:o},sides:l},r+=m+n,++f}I+=o+n}return c}(m):2===c?function(e){const{ratios:t,proportions:s,averageRatio:a}=e;return"ww"===s&&a>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:a,maxHeight:n}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(n-a)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:Cn.Left|Cn.Top|Cn.Right},{dimensions:{x:0,y:o+a,width:s,height:o},sides:Cn.Left|Cn.Bottom|Cn.Right}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:a,maxHeight:n}=e,o=(s-a)/2,i=Math.round(Math.min(o/t[0],Math.min(o/t[1],n)));return[{dimensions:{x:0,y:0,width:o,height:i},sides:Cn.Top|Cn.Left|Cn.Bottom},{dimensions:{x:o+a,y:0,width:o,height:i},sides:Cn.Top|Cn.Right|Cn.Bottom}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:a,spacing:n,maxHeight:o}=e,i=Math.round(1.5*s),r=Math.min(Math.round(Math.max(.4*(a-n),(a-n)/t[0]/(1/t[0]+1/t[1]))),a-n-i),c=a-r-n,d=Math.min(o,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:Cn.Top|Cn.Left|Cn.Bottom},{dimensions:{x:c+n,y:0,width:r,height:d},sides:Cn.Top|Cn.Right|Cn.Bottom}]}(e)}(m):3===c?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:a,maxWidth:n,minWidth:o}=e,i=t,r=Math.round(Math.min((t-s)/2,a[1]*(n-s)/(a[2]+a[1]))),c=i-r-s,d=Math.max(o,Math.round(Math.min((n-s)/2,Math.min(r*a[2],c*a[1])))),l=Math.min(Math.round(i*a[0]),n-s-d);return[{dimensions:{x:0,y:0,width:l,height:i},sides:Cn.Top|Cn.Left|Cn.Bottom},{dimensions:{x:l+s,y:0,width:d,height:c},sides:Cn.Top|Cn.Right},{dimensions:{x:l+s,y:c+s,width:d,height:r},sides:Cn.Bottom|Cn.Right}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:a,spacing:n}=e,o=t,i=Math.round(Math.min(o/s[0],.66*(a-n))),r=(t-n)/2,c=Math.min(a-i-n,Math.round(Math.min(r/s[1],r/s[2]))),d=o-r-n;return[{dimensions:{x:0,y:0,width:o,height:i},sides:Cn.Left|Cn.Top|Cn.Right},{dimensions:{x:0,y:i+n,width:r,height:c},sides:Cn.Bottom|Cn.Left},{dimensions:{x:r+n,y:i+n,width:d,height:c},sides:Cn.Bottom|Cn.Right}]}(e)}(m):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:a,minWidth:n}){const o=e,i=Math.round(Math.min(o/t[0],.66*(a-s))),r=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(n,Math.round(Math.min(.4*(e-2*s),r*t[1]))),d=Math.round(Math.max(Math.max(n,.33*(e-2*s)),r*t[3])),l=o-c-d-2*s,u=Math.min(a-i-s,r);return[{dimensions:{x:0,y:0,width:o,height:i},sides:Cn.Left|Cn.Top|Cn.Right},{dimensions:{x:0,y:i+s,width:c,height:u},sides:Cn.Bottom|Cn.Left},{dimensions:{x:c+s,y:i+s,width:l,height:u},sides:Cn.Bottom},{dimensions:{x:c+s+l+s,y:i+s,width:d,height:u},sides:Cn.Right|Cn.Bottom}]}(e):function({maxHeight:e,ratios:t,maxWidth:s,spacing:a,minWidth:n}){const o=e,i=Math.round(Math.min(o*t[0],.6*(s-a))),r=Math.round((e-2*a)/(1/t[1]+1/t[2]+1/t[3])),c=Math.round(r/t[1]),d=Math.round(r/t[2]),l=o-c-d-2*a,u=Math.max(n,Math.min(s-i-a,r));return[{dimensions:{x:0,y:0,width:i,height:o},sides:Cn.Top|Cn.Left|Cn.Bottom},{dimensions:{x:i+a,y:0,width:u,height:c},sides:Cn.Top|Cn.Right},{dimensions:{x:i+a,y:c+a,width:u,height:d},sides:Cn.Right},{dimensions:{x:i+a,y:c+d+2*a,width:u,height:l},sides:Cn.Bottom|Cn.Right}]}(e)}(m),{layout:u,containerStyle:En(u)}}var kn=s(75790),Tn=s(31526),Nn=s(46586),An=s(74095);let Bn;const xn=new Nn.Z;o.SX&&setTimeout((function(){Bn||(Bn=(0,An.K)(new Worker(new URL(s.p+s.u(4923),s.b))),xn.resolve())}),4e3);var Un=s(3927);let Ln,_n;function On(e,t,s){var a;return(t="symbol"==typeof(a=function(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var a=s.call(e,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t))?a:String(a))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}Ln=Symbol.toStringTag,_n=Symbol.iterator;class Fn{constructor(e){this.limit=e,On(this,"map",void 0),On(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[Ln](){return this.map[Symbol.toStringTag]}[_n](){return this.map[Symbol.iterator]()}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}}const Dn=new Map;const jn=(0,f.P2)((function(e){const{updateChatDetectedLanguage:t}=(0,a.Sv)(),s=Dn.get(e);if(!s)return;const n=s.size;if(n<8)return;let o=0,i=0;const r=new Map;for(const e of s.values()){e.isTranslatable&&o++,e.detectedLanguage&&i++;const t=e.detectedLanguage;if(t){const e=r.get(t)||0;r.set(t,e+1)}}if(o/n<.3||i/n<.6)return;t({chatId:e,detectedLanguage:Array.from(r.entries()).sort((([,e],[,t])=>t-e))[0][0]})}),1e3);var qn=s(45277),Gn=s(75368);const Hn=3*M.Gw,Vn=Number(M.Gw),$n="data-is-document-group-hover";function zn(e,t,s,n,i,r,c,d,l,u,m,h,p){const{updateDraftReplyInfo:g,sendDefaultReaction:f}=(0,a.Sv)(),[I,v,w]=(0,xs.Z)(),[b,y,P]=(0,xs.Z)(),Z=(0,Tt.sO)(),S=(0,Un.Z)((e=>{const t=m.current;if(!t)return;const{clientX:s,clientY:a}=e,{x:n,width:o,y:i,height:r}=t.getBoundingClientRect(),c=n+o/2,d=i+r/2,l=Math.abs(c-s)<Hn,u=Math.abs(d-a)<Vn;l&&u?v():w()}),[m],Bt.i$);return(0,Tt.d4)((()=>{if(!o.$b||n||!i||u||!p())return;let e;return(0,Zs.sf)(t.current,{selectorToPreventScroll:".MessageList",excludedClosestSelector:".no-word-wrap",onSwipe:(t,s)=>s===Zs.eM.Left&&(e||(e=Date.now()),y(),!0),onRelease:()=>{e&&i&&(g({replyToMsgId:s}),setTimeout(P,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,n,s,y,P,i,u,p]),{handleMouseDown:n?void 0:function(e){(0,sn.q)(e),d(e)},handleClick:function(t){if(n)e(t);else if(o.$b)return Z.current?(clearInterval(Z.current),Z.current=void 0,void f({chatId:l,messageId:s})):void(Z.current=setTimeout((()=>{Z.current=void 0,function(e){if(o.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;C.Z.getIsKeyboardVisible()?setTimeout((()=>{c(e)}),350):c(e)}}(t)}),200))},handleContextMenu:n?r?yn.Z:void 0:function(t){if(o.wZ){if(t.target.matches("a[href]")||u)return;t.preventDefault(),e()}else c(t)},handleDoubleClick:n?void 0:function(){!o.$b&&i&&g({replyToMsgId:s})},handleContentDoubleClick:o.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:S,handleSendQuickReaction:function(e){e.stopPropagation(),f({chatId:l,messageId:s})},handleMouseLeave:function(e){(0,Bt.i$)(w),h&&function(e){const t=Jn(e.currentTarget);t&&t.removeAttribute($n)}(e)},isSwiped:b,isQuickReactionVisible:I,handleDocumentGroupMouseEnter:Kn}}function Kn(e){const t=Jn(e.currentTarget);t&&t.setAttribute($n,"")}function Jn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var Wn=s(73482),Yn=s(70172),Xn=s(82535),Qn=s(78780),eo=s(32683),to=s(39415),so=s(65979);const ao=({story:e,sender:t,noUserColors:s,isProtected:n,observeIntersectionForLoading:o,onClick:i})=>{const{showNotification:r}=(0,a.Sv)(),c=(0,Is.Z)(),d=(0,Tt.sO)(null),l=(0,gn.Op)(d,o),u=e&&"content"in e,m=e&&"isDeleted"in e,h=u&&Boolean(e.content.video),p=u?"Story":m?"ExpiredStory":"Loading",g=(0,ba.Z)(u&&(0,v.Cc)(e,"pictogram"),!l),f=h?e.content.video.thumbnail?.dataUri:void 0,I=g||f,w=t?(0,v.OU)(c,t):void 0,b=(0,qt.Z)((()=>{e&&!m?i():r({message:c("StoryNotFound")})})),{handleClick:y,handleMouseDown:P}=(0,to.m)(b);return Tt.ZP.createElement("div",{ref:d,className:(0,xt.Z)("EmbeddedMessage",(0,Pn.D)(t,s,!0),I&&"with-thumb"),onClick:y,onMouseDown:P},I&&function(e,t){const{width:s,height:a}=(0,M.W7)();return Tt.ZP.createElement("div",{className:"embedded-thumb"},Tt.ZP.createElement("img",{src:e,width:s,height:a,alt:"",className:"pictogram",draggable:!1}),t&&Tt.ZP.createElement("span",{className:"protector"}))}(I,n),Tt.ZP.createElement("div",{className:"message-text with-message-color"},Tt.ZP.createElement("p",{className:"embedded-text-wrapper"},m&&Tt.ZP.createElement(so.Z,{name:"story-expired",className:"embedded-origin-icon"}),u&&Tt.ZP.createElement(so.Z,{name:"story-reply",className:"embedded-origin-icon"}),c(p)),Tt.ZP.createElement("div",{className:"message-title"},(0,ga.Z)(w||" "))))};var no=s(50685),oo=s(14612),io=s(48198),ro=s(98138),co=s(2995);var lo=s(69123);const uo=1.125*M.Gw,mo=(0,Tt.X$)((({topic:e,className:t,onClick:s})=>{const a=(0,Is.Z)();return Tt.ZP.createElement("div",{className:(0,xt.Z)("JldIqqof",t),style:`--topic-button-accent-color: var(${(0,ro.gZ)(e?.iconColor)})`,onClick:s},e?Tt.ZP.createElement(co.Z,{topic:e,size:uo}):Tt.ZP.createElement("img",{src:lo,alt:"",draggable:!1}),e?.title?(0,ga.Z)(e.title):a("Loading"),e?.isClosed&&Tt.ZP.createElement("i",{className:"icon icon-lock"}),Tt.ZP.createElement("i",{className:"icon icon-next"}))}));function ho(e){return(0,Tt.X$)((0,a.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,y.CAb)(e),isSelected:(0,y.vkB)(e,s.id)}}))((t=>{const{isInSelectMode:s,isSelected:n,message:o,dimensions:i}=t,{toggleMessageSelection:r}=(0,a.Sv)(),c=(0,qt.Z)((e=>{e.stopPropagation(),r({messageId:o.id,withShift:e?.shiftKey})})),d=(0,Tt.Ye)((()=>{const{dimensions:e,onClick:a}=t;return{...t,isInSelectMode:s,isSelected:n,dimensions:{...e,x:0,y:0},onClick:s?void 0:a}}),[t,s,n]);return Tt.ZP.createElement("div",{className:(0,xt.Z)("album-item-select-wrapper",n&&"is-selected"),style:i?`left: ${i.x}px; top: ${i.y}px;`:"",onClick:s?c:void 0},s&&Tt.ZP.createElement("div",{className:"message-select-control"},n&&Tt.ZP.createElement("i",{className:"icon icon-select"})),Tt.ZP.createElement(e,d))})))}var po=s(95822),go=s(35269);const fo=ho(po.Z),Io=ho(go.Z),vo=(0,a.c$)(((e,{album:t})=>{const{chatId:s}=t.mainMessage,a=(0,y.Puy)(e),n=(0,y.f21)(e,s),o=t.mainMessage.isScheduled;return{theme:a,uploadsByKey:e.fileUploads.byMessageKey,activeDownloadIds:o?n?.scheduledIds:n?.ids}}))((({album:e,observeIntersection:t,hasCustomAppendix:s,isOwn:n,isProtected:o,albumLayout:i,onMediaClick:r,uploadsByKey:c,activeDownloadIds:d,theme:l})=>{const{cancelUploadMedia:u}=(0,a.Sv)(),m=e.messages.length,h=(0,qt.Z)((e=>{u({chatId:e.chatId,messageId:e.id})})),{width:p,height:f}=i.containerStyle;return Tt.ZP.createElement("div",{className:"Album",style:`width: ${p}px; height: ${f}px;`},e.messages.map((function(e,u){const{photo:p,video:f}=(0,v.qp)(e),I=c[(0,g.Tp)(e)],w=I?.progress,{dimensions:b,sides:P}=i.layout[u],Z=(0,y.bHC)((0,a.Rd)(),e),S=(0,y.__o)((0,a.Rd)(),e);if(p){const a=s&&(n?u===m-1:Boolean(P&Cn.Left&&P&Cn.Bottom));return Tt.ZP.createElement(fo,{id:`album-media-${(0,v.d0)(e.id)}`,message:e,observeIntersectionForLoading:t,canAutoLoad:Z,shouldAffectAppendix:a,uploadProgress:w,dimensions:b,isProtected:o,onClick:r,onCancelUpload:h,isDownloading:d?.includes(e.id),theme:l})}if(f)return Tt.ZP.createElement(Io,{id:`album-media-${(0,v.d0)(e.id)}`,message:e,observeIntersectionForLoading:t,canAutoLoad:Z,canAutoPlay:S,uploadProgress:w,dimensions:b,isProtected:o,onClick:r,onCancelUpload:h,isDownloading:d?.includes(e.id),theme:l})})))}));var wo=s(74753);const bo=7*M.Gw;function yo(e,t,s,n,i,r,c){const{interactWithAnimatedEmoji:d,sendEmojiInteraction:l,sendWatchingEmojiInteraction:u}=(0,a.Sv)(),m=(0,Tt.sO)(null),h=(0,Tt.sO)(null),p=(0,ba.Z)(s?`document${s}`:void 0,!s),g=c||bo,f=(0,Aa.Z)(`width: ${g}px`,`height: ${g}px`,r&&!o.D$&&"cursor: pointer"),I=(0,Tt.sO)(void 0),v=(0,Tt.sO)(void 0),w=(0,qt.Z)((()=>{m.current&&(l({chatId:e,messageId:t,emoji:r,interactions:I.current}),v.current=void 0,I.current=void 0)})),b=(0,qt.Z)((()=>{const e=h.current;p&&(e&&(e.pause(),e.remove()),h.current=new Audio,h.current.src=p,(0,wo.Z)(h.current),h.current.addEventListener("ended",(()=>{h.current=void 0}),{once:!0}))})),y=(0,qt.Z)((()=>{b();const s=m.current;if(!(r&&s&&t&&e))return;const{x:a,y:n}=s.getBoundingClientRect();d({emoji:r,x:a,y:n,startSize:g,isReversed:!i}),I.current||(I.current=[],v.current=performance.now(),setTimeout(w,1e3)),I.current.push(v.current?(performance.now()-v.current)/1e3:0)}));return(0,Tt.d4)((()=>{const s=m.current;s&&n&&n.forEach((({id:a,startSize:n,messageId:o})=>{if(n||t!==o)return;const{x:c,y:d}=s.getBoundingClientRect();u({id:a,chatId:e,emoticon:r,startSize:g,x:c,y:d,isReversed:!i}),b()}))}),[n,e,r,i,t,b,u,g]),{ref:m,size:g,style:f,handleClick:y}}const Po=(0,Tt.X$)((0,a.c$)(((e,{customEmojiId:t,withEffects:s})=>{const a=e.customEmojis.byId[t];return{sticker:a,effect:a?.emoji&&s?(0,y.tHA)(e,a.emoji):void 0,soundId:a?.emoji&&(0,y.Ohz)(e,a.emoji),noPlay:!(0,y.W9H)(e)}}))((({isOwn:e,customEmojiId:t,messageId:s,chatId:a,activeEmojiInteractions:n,sticker:o,effect:i,soundId:r,noPlay:c,observeIntersection:d})=>{const{ref:l,size:u,style:m,handleClick:h}=yo(a,s,r,n,e,i?.emoji,(0,Zn.qo)(1));return Tt.ZP.createElement(Ws.Z,{ref:l,documentId:t,className:(0,xt.Z)("AnimatedEmoji media-inner",o?.id===M.wB&&"like-sticker-thumb"),style:m,size:u,isBig:!0,noPlay:c,withSharedAnimation:!0,forceOnHeavyAnimation:Boolean(i&&n?.length),observeIntersectionForLoading:d,onClick:h})})));var Zo=s(45601);const So=(0,Tt.X$)((0,a.c$)(((e,{emoji:t,withEffects:s})=>({sticker:(0,y.zB_)(e,t),effect:s?(0,y.tHA)(e,t):void 0,soundId:(0,y.Ohz)(e,t)})))((({isOwn:e,observeIntersection:t,forceLoadPreview:s,messageId:a,chatId:n,activeEmojiInteractions:o,sticker:i,effect:r,soundId:c})=>{const{ref:d,size:l,style:u,handleClick:m}=yo(n,a,c,o,e,r?.emoji),h=(0,gn.Op)(d,t);return Tt.ZP.createElement(Zo.Z,{sticker:i,size:l,quality:1,noLoad:!h,forcePreview:s,play:h,forceAlways:!0,ref:d,className:(0,xt.Z)("AnimatedEmoji media-inner",i?.id===M.wB&&"like-sticker-thumb"),style:u,onClick:m})})));var Co=s(17891),Mo=s(34076);const Eo=(0,Tt.X$)((({isCustomShape:e,threadInfo:t,disabled:s,isLoading:n})=>{const{openThread:o}=(0,a.Sv)(),i=(0,Co.Z)([n],450),r=(0,Is.Z)(),{originMessageId:c,chatId:d,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h,originChannelId:p}=t,g=(0,qt.Z)((()=>{o({isComments:!0,chatId:d,originMessageId:c,originChannelId:p})})),f=(0,Tt.Ye)((()=>{if(!h?.length)return;const e=(0,a.Rd)();return h.map((t=>(0,y.RGZ)(e,t))).filter(Boolean)}),[h]);if(void 0===l)return;const I=Boolean(m&&u&&m<u),v=l?r("CommentsCount","%COMMENTS_COUNT%",void 0,l).split("%").map((e=>"COMMENTS_COUNT"===e?Tt.ZP.createElement(Mo.Z,{text:(0,os.bi)(l)}):e)):void 0;return Tt.ZP.createElement("div",{"data-cnt":(0,os.bi)(l),className:(0,xt.Z)("CommentButton",I&&"has-unread",s&&"disabled",e&&"CommentButton-custom-shape",n&&"loading"),dir:r.isRtl?"rtl":"ltr",onClick:g,role:"button",tabIndex:0},Tt.ZP.createElement("i",{className:(0,xt.Z)("CommentButton_icon-comments icon icon-comments-sticker",n&&i&&"CommentButton_hidden"),"aria-hidden":!0}),!f?.length&&Tt.ZP.createElement("i",{className:"icon icon-comments","aria-hidden":!0}),Boolean(f?.length)&&Tt.ZP.createElement("div",{className:"recent-repliers",dir:r.isRtl?"rtl":"ltr"},f.map((e=>Tt.ZP.createElement(Yn.Z,{key:e.id,size:"small",peer:e})))),Tt.ZP.createElement("div",{className:"label",dir:"auto"},l?v:r("LeaveAComment")),Tt.ZP.createElement("div",{className:"CommentButton_right"},n&&Tt.ZP.createElement(js.Z,{className:(0,xt.Z)("CommentButton_loading",!i&&"CommentButton_hidden"),color:e?"white":"blue"}),Tt.ZP.createElement("i",{className:(0,xt.Z)("CommentButton_icon-open icon icon-next",n&&i&&"CommentButton_hidden"),"aria-hidden":!0})))}));var Ro=s(6272),ko=s(41278);const To=(0,Tt.X$)((function({peer:e,noUserColors:t,shoudReset:s,className:a,emojiIconClassName:n,children:o}){return Tt.ZP.createElement("div",{className:(0,xt.Z)((0,Pn.D)(e,t,s),a)},e?.color?.backgroundEmojiId&&Tt.ZP.createElement(ko.Z,{className:n,emojiDocumentId:e.color.backgroundEmojiId}),o)})),No="ReDHhQHm";function Ao(e){return e.firstName&&e.lastName?`${e.firstName} ${e.lastName}`:e.firstName?e.firstName:e.lastName?e.lastName:""}const Bo=(0,a.c$)(((e,{contact:t})=>{const{countryList:{phoneCodes:s}}=e;return{user:(0,y.dyD)(e,t.userId),phoneCodeList:s}}))((({contact:e,user:t,phoneCodeList:s,noUserColors:n})=>{const o=(0,Is.Z)(),{openChat:i,openAddContactDialog:r,showNotification:c,openChatWithInfo:l}=(0,a.Sv)(),{phoneNumber:u,userId:m}=e,h="0"!==m,p=h&&t&&(0,v.kw)(t),g=(0,qt.Z)((()=>{i({id:m})})),f=(0,qt.Z)((()=>{r({userId:t?.id})})),I=(0,qt.Z)((()=>{t?l({id:m}):((0,d.TE)(u),c({message:o("PhoneCopied")}))}));return Tt.ZP.createElement(To,{noUserColors:n,peer:t,emojiIconClassName:"SjZYi3sJ",className:"AAHWWWvU"},Tt.ZP.createElement("div",{className:"tpDpg82n",onClick:I},Tt.ZP.createElement(Yn.Z,{size:"large",peer:t,text:Ao(e)}),Tt.ZP.createElement("div",{className:"fpYynE5s"},Tt.ZP.createElement("div",{className:"_PNTJc_V"},t?(0,v.Js)(t):Ao(e)),Tt.ZP.createElement("div",{className:"JP_3wes8"},(0,Ro.WZ)(s,u)))),h&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:"_OSJcuqH"}),Tt.ZP.createElement("div",{className:"Blui4M4G"},Tt.ZP.createElement(vs.Z,{isText:!0,color:"translucent",ripple:!0,onClick:g,className:No},o("SharedContactMessage")),p&&Tt.ZP.createElement(vs.Z,{isText:!0,color:"translucent",ripple:!0,onClick:f,className:No},o("SharedContactAdd")))))}));var xo=s(97182);const Uo=(0,Tt.X$)((({message:e,canAutoLoadMedia:t})=>{const{clickBotInlineButton:s}=(0,a.Sv)(),n=e.content.game,{title:o,description:i}=n,r=(0,v.N)(n),c=(0,v.Wc)(n),d=(0,ba.Z)(r,!t),l=(0,ba.Z)(c,!t);return Tt.ZP.createElement("div",{className:"Game"},Tt.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{s({messageId:e.id,button:e.inlineButtons[0][0]})}},!d&&!l&&Tt.ZP.createElement(mn.Z,{className:"skeleton preview-content"}),d&&Tt.ZP.createElement("img",{className:"preview-content",src:d,alt:o,draggable:!1}),l&&Tt.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,disablePictureInPicture:!0,autoPlay:!0,loop:!0,src:l})),Tt.ZP.createElement("div",{className:"title"},o),!(0,v.UD)(e)&&Tt.ZP.createElement("div",{className:"description"},i))}));var Lo=s(61463),_o=s(89945),Oo=s(21179),Fo=s(17551),Do=s(27150);const jo="ogvcv3mr",qo="MSFa9BPf",Go="HfZ6SuLI",Ho="rPyyNYxK",Vo="FV70u896",$o=(0,Tt.X$)((0,a.c$)(((e,{message:t})=>{const{giveaway:s}=t.content,a=(0,y.Z1J)(e,t.chatId);return{chat:a,sender:(0,y.Z1J)(e,s?.channelIds[0])||(0,y.cve)(e,t)||a,giftSticker:s&&(0,y.PGA)(e,s.months),canPlayAnimatedEmojis:(0,y.W9H)(e)}}))((({chat:e,sender:t,message:s,canPlayAnimatedEmojis:n,giftSticker:o})=>{const{openChat:i}=(0,a.Sv)(),r=(0,Tt.sO)(!1),[c,d]=(0,Tt.eJ)(),l=(0,Is.Z)(),{giveaway:u,giveawayResults:m}=s.content,h=Boolean(m),{months:p,untilDate:g,prizeDescription:f}=u||m,w=(0,v.B4)(s),b=h?m.winnersCount:u.quantity,y=(0,we.bp)()>g,P=(0,Tt.Ye)((()=>{if(h)return;const e=new Intl.DisplayNames([l.code,"en"].filter(Boolean),{type:"region"});return u?.countries?.map((t=>`${(0,Lo.Wg)(t)} ${e.of(t)}`)).join(", ")}),[u,h,l.code]),Z=(0,qt.Z)((e=>{i({id:e})})),S=(0,qt.Z)((async()=>{if(r.current)return;r.current=!0;const t=await(0,I.t9)("fetchGiveawayInfo",{peer:e,messageId:s.id});d(t),r.current=!1})),C=(0,qt.Z)((()=>{d(void 0)})),M=(0,Tt.Ye)((()=>{if(c)return l("results"===c.type?"BoostingGiveawayEnd":"BoostingGiveAwayAbout")}),[c,l]);return Tt.ZP.createElement("div",{className:"CbpKtOey"},Tt.ZP.createElement("div",{className:(0,xt.Z)("hjjKhvVv",h&&"JEiR48jJ")},h?Tt.ZP.createElement(Oo.Z,{size:150,tgsUrl:_o.l.PartyPopper,nonInteractive:!0,noLoop:!0}):Tt.ZP.createElement(Zo.Z,{sticker:o,play:n&&y,noLoop:!0,nonInteractive:!0,size:175}),Tt.ZP.createElement("span",{className:"n_QCMv_A"},`x${b}`)),h?function(e){const t=e.winnerIds;return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:qo},Tt.ZP.createElement("strong",{className:jo},(0,ga.Z)(l("BoostingGiveawayResultsMsgWinnersSelected"),["simple_markdown"])),Tt.ZP.createElement("p",{className:Go},(0,ga.Z)(l("BoostingGiveawayResultsMsgWinnersTitle",t.length),["simple_markdown"])),Tt.ZP.createElement("strong",{className:jo},l("lng_prizes_results_winners")),Tt.ZP.createElement("div",{className:Ho},t.map((e=>Tt.ZP.createElement(Ls.Z,{peerId:e,forceShowSelf:!0,fluid:!0,withPeerColors:!w,className:Vo,clickArg:e,onClick:Z}))))),Tt.ZP.createElement("div",{className:qo},Tt.ZP.createElement("p",{className:Go},l("BoostingGiveawayResultsMsgAllWinnersReceivedLinks"))))}(m):function(e){const t=e.channelIds;return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:qo},Tt.ZP.createElement("strong",{className:jo},(0,ga.Z)(l("BoostingGiveawayPrizes"),["simple_markdown"])),f&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("p",{className:Go},(0,ga.Z)(l("BoostingGiveawayMsgPrizes",[b,f],void 0,b),["simple_markdown"])),Tt.ZP.createElement(Do.Z,null,l("BoostingGiveawayMsgWithDivider"))),Tt.ZP.createElement("p",{className:Go},(0,ga.Z)(l("Chat.Giveaway.Info.Subscriptions",b),["simple_markdown"]),Tt.ZP.createElement("br",null),(0,ga.Z)(l("ActionGiftPremiumSubtitle",l("Chat.Giveaway.Info.Months",p)),["simple_markdown"]))),Tt.ZP.createElement("div",{className:qo},Tt.ZP.createElement("strong",{className:jo},(0,ga.Z)(l("BoostingGiveawayMsgParticipants"),["simple_markdown"])),Tt.ZP.createElement("p",{className:Go},(0,ga.Z)(l("BoostingGiveawayMsgAllSubsPlural",t.length),["simple_markdown"])),Tt.ZP.createElement("div",{className:Ho},t.map((e=>Tt.ZP.createElement(Ls.Z,{peerId:e,forceShowSelf:!0,fluid:!0,withPeerColors:!w,className:Vo,clickArg:e,onClick:Z})))),P&&Tt.ZP.createElement("span",null,(0,ga.Z)(l("Chat.Giveaway.Message.CountriesFrom",P)))),Tt.ZP.createElement("div",{className:qo},Tt.ZP.createElement("strong",{className:jo},(0,ga.Z)(l("BoostingWinnersDate"),["simple_markdown"])),Tt.ZP.createElement("p",{className:Go},(0,ce.SA)(1e3*g,l.code,!0))))}(u),Tt.ZP.createElement(vs.Z,{className:"jMBw7STU",color:"adaptive",size:"smaller",onClick:S},l("BoostingHowItWork")),Tt.ZP.createElement(Fo.Z,{isOpen:Boolean(c),isOnlyConfirm:!0,title:M,confirmHandler:C,onClose:C},function(){if(!t||!c)return;const e="results"===c.type,s=(0,v.Wd)(t)?(0,v.U)(l,t):(0,v.Js)(t),n=l("Chat.Giveaway.Info.Months",p),o=(0,ce.$M)(l,1e3*g),i=u?.channelIds?u.channelIds.length-1:0,r=l("Chat.Giveaway.Info.OtherChannels",i),d=i>0,m=l(e?"BoostingGiveawayHowItWorksTextEnd":"BoostingGiveawayHowItWorksText",[s,b,n],void 0,b),h=f?l("BoostingGiveawayHowItWorksIncludeText",[s,b,f],void 0,b):void 0;let I="";I=e?d?"BoostingGiveawayHowItWorksSubTextSeveralEnd":"BoostingGiveawayHowItWorksSubTextEnd":d?"BoostingGiveawayHowItWorksSubTextSeveral":"BoostingGiveawayHowItWorksSubText";let w=l(I,[o,b,s,i],void 0,b);e&&c.activatedCount&&(w+=` ${l("BoostingGiveawayUsedLinksPlural",c.activatedCount)}`);let y="";e&&(y=c.isRefunded?l("BoostingGiveawayCanceledByPayment"):l(c.isWinner?"BoostingGiveawayYouWon":"BoostingGiveawayYouNotWon"));let P="";if(e);else if(c.disallowedCountry)P=l("BoostingGiveawayNotEligibleCountry");else if(c.adminDisallowedChatId){const e=(0,a.Rd)().chats.byId[c.adminDisallowedChatId],t=e&&(0,v.U)(l,e);P=l("BoostingGiveawayNotEligibleAdmin",t)}else if(c.joinedTooEarlyDate){const e=(0,ce.$M)(l,1e3*c.joinedTooEarlyDate);P=l("BoostingGiveawayNotEligible",e)}else P=c.isParticipating?d?l("Chat.Giveaway.Info.ParticipatingMany",[s,i]):l("Chat.Giveaway.Info.Participating",s):d?l("Chat.Giveaway.Info.NotQualifiedMany",[s,r,o]):l("Chat.Giveaway.Info.NotQualified",[s,o]);return Tt.ZP.createElement(Tt.ZP.Fragment,null,y&&Tt.ZP.createElement("p",{className:"ZQ4aVVkI"},(0,ga.Z)(y,["simple_markdown"])),Tt.ZP.createElement("p",null,(0,ga.Z)(m,["simple_markdown"])),h&&Tt.ZP.createElement("p",null,(0,ga.Z)(h,["simple_markdown"])),Tt.ZP.createElement("p",null,(0,ga.Z)(w,["simple_markdown"])),P&&Tt.ZP.createElement("p",null,(0,ga.Z)(P,["simple_markdown"])))}()))}))),zo=({message:e,onClick:t})=>{const s=(0,Is.Z)();return Tt.ZP.createElement("div",{className:"InlineButtons"},e.inlineButtons.map((a=>Tt.ZP.createElement("div",{className:"row"},a.map((a=>Tt.ZP.createElement(vs.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===a.type,onClick:()=>t({messageId:e.id,button:a})},Tt.ZP.createElement("span",{className:"inline-button-text"},(0,ga.Z)(s(a.text))),(e=>{const{type:t}=e;switch(t){case"url":if(!n.FSu.test(e.url))return Tt.ZP.createElement("i",{className:"icon icon-arrow-right"});break;case"urlAuth":return Tt.ZP.createElement("i",{className:"icon icon-arrow-right"});case"buy":case"receipt":return Tt.ZP.createElement("i",{className:"icon icon-cart"});case"switchBotInline":return Tt.ZP.createElement("i",{className:"icon icon-share-filled"});case"webView":case"simpleWebView":return Tt.ZP.createElement("i",{className:"icon icon-webapp"})}})(a))))))))};var Ko=s(26593),Jo=s(41280);const Wo=(0,Tt.X$)((({message:e,shouldAffectAppendix:t,isInSelectMode:s,isSelected:a,theme:o,forcedWidth:i})=>{const r=(0,Tt.sO)(null),c=(0,Is.Z)(),d=(0,v.eO)(e),{title:l,text:u,amount:m,currency:h,isTest:p,photo:g}=d,f=(0,ba.Z)((0,v.O9)(g)),I=Boolean(i),w=(0,Jo.Z)(e,!I,f);(0,an.Z)((([e])=>{if(t){if(f){const e=r.current.closest(n.be_);(0,Ko.Z)(f,!1,a,o).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(n.s22,"")}))}}else e&&r.current.closest(n.be_).removeAttribute(n.s22)}),[t,f,s,a,o]);const b=i||g?.dimensions?.width,y=(0,Aa.Z)(g?.dimensions&&`width: ${b}px`,g?.dimensions&&`aspect-ratio: ${g.dimensions.width} / ${g.dimensions.height}`,Boolean(!g?.dimensions&&i)&&`width: ${i}px`);return Tt.ZP.createElement("div",{ref:r,className:"Invoice"},l&&Tt.ZP.createElement("p",{className:"title"},(0,ga.Z)(l)),u&&Tt.ZP.createElement("div",null,(0,ga.Z)(u,["emoji","br"])),Tt.ZP.createElement("div",{className:"description "+(g?"has-image":"")},Boolean(g)&&Tt.ZP.createElement("div",{className:"invoice-image-container"},I&&Tt.ZP.createElement("canvas",{ref:w,className:"thumbnail blurred-bg"}),f&&Tt.ZP.createElement("img",{className:"invoice-image",src:f,alt:"",style:y,crossOrigin:"anonymous",draggable:!1}),!f&&g&&Tt.ZP.createElement(mn.Z,{width:b,height:g.dimensions?.height,forceAspectRatio:!0})),Tt.ZP.createElement("p",{className:"description-text"},(0,kt.x)(m,h,c.code),p&&Tt.ZP.createElement("span",null,c("PaymentTestInvoice")))))}));var Yo=s(62230);const Xo={root:"dCK8GQ_8",duration:"CWT8ZMwV",buy:"C38zhCDM",spoiler:"CG55VZP1"},Qo=(0,Tt.X$)((({message:e,isConnected:t})=>{const{openInvoice:s,loadExtendedMedia:n}=(0,a.Sv)(),o=(0,Is.Z)(),i=(0,v.eO)(e),{chatId:r,id:c}=e,d=(0,qt.Z)((()=>{n({chatId:r,ids:[c]})}));(0,Ot.Z)(d,t?3e4:void 0);const{amount:l,currency:u,extendedMedia:m}=i,{width:h,height:p,thumbnail:g,duration:f}=m,I=(0,qt.Z)((()=>{s({chatId:r,messageId:c,isExtendedMedia:!0})}));return Tt.ZP.createElement("div",{className:(0,xt.Z)(Xo.root,"media-inner"),onClick:I},Tt.ZP.createElement(Yo.Z,{thumbDataUri:g?.dataUri,width:h,height:p,isVisible:!0,className:Xo.spoiler}),Boolean(f)&&Tt.ZP.createElement("div",{className:Xo.duration},(0,ce.k9)(f)),Tt.ZP.createElement("div",{className:Xo.buy},Tt.ZP.createElement("i",{className:(0,xt.Z)("icon","icon-lock",Xo.lock)}),o("Checkout.PayPrice",(0,kt.x)(l,u))))}));var ei=s(91489);const ti=s.p+"map-pin.899635f6fe777c28998a.svg",si=24*Math.PI,ai=1e-4,ni={width:400,height:300,zoom:16,scale:2};function oi(){return Tt.ZP.createElement("svg",{className:"round-pin",style:"enable-background:new 0 0 64 64",viewBox:"0 0 64 64"},Tt.ZP.createElement("circle",{cx:"32",cy:"32",r:"24.5"}),Tt.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"}),Tt.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"}),Tt.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 ii=(0,Tt.X$)((({message:e,peer:t})=>{const{openMapModal:s}=(0,a.Sv)(),n=(0,Tt.sO)(null),o=(0,Tt.sO)(null),i=(0,Is.Z)(),r=(0,Dt.Z)(),c=(0,v.nf)(e),{type:d,geo:l}=c,u=(0,we.bp)(),m=(0,v.$R)(e),h="geoLive"!==d||m?void 0:e.date+c.period-u,[p,g]=(0,Tt.eJ)(l),f="venue"===d||"geoLive"===d&&!m,{width:I,height:w,zoom:b,scale:y}=ni,P=(0,v.k6)(p,I,w,b,y),Z=(0,ba.Z)(P),S=(0,La.Z)(Z,!0),C=Z||S,M=(0,Tt.Ye)((()=>{if("geoLive"!==d||!p.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=p;return t/(0,ei.Qw)(e,b)}),[d,p,b]),E=(0,qt.Z)((t=>{if("geoLive"!==d)return;const s=t.lastElementChild,a=t.firstElementChild,n=e.date+c.period-(0,we.bp)(),o=(1-n/c.period)*si,r=(0,ce.mB)(i,1e3*n);a.textContent=r,s.firstElementChild.setAttribute("stroke-dashoffset",`-${o}`)}));return(0,Tt.bt)((()=>{o.current&&E(o.current)}),[E]),(0,Tt.d4)((()=>{Math.abs(l.lat-p.lat)<ai&&Math.abs(l.long-p.long)<ai?p.accuracyRadius!==l.accuracyRadius&&g({...p,accuracyRadius:l.accuracyRadius}):g(l)}),[l,p]),(0,Ft.Z)((()=>{r()}),m?void 0:1e3*(h||0)),(0,Ot.Z)((()=>{(0,Bt.WM)((()=>{const e=o.current;e&&E(e)}))}),h?1e3:void 0),Tt.ZP.createElement("div",{ref:n,className:"Location media-inner interactive",onClick:()=>{s({geoPoint:p,zoom:b})}},Tt.ZP.createElement("div",{className:"map-wrapper"},C?Tt.ZP.createElement("img",{className:"full-media map",src:C,alt:"Location on a map",draggable:!1,style:`width: ${ni.width}px; height: ${ni.height}px;`}):Tt.ZP.createElement(mn.Z,{width:I,height:w}),function(){if(C)return Tt.ZP.createElement(Tt.ZP.Fragment,null,Boolean(M)&&!m&&Tt.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*M}px; height: ${2*M}px`}),function(){const e=(0,xt.Z)("pin",d,m&&"expired");if("geoLive"===d)return Tt.ZP.createElement("div",{className:e},Tt.ZP.createElement(oi,null),Tt.ZP.createElement(Yn.Z,{peer:t,className:"location-avatar"}),void 0!==c.heading&&Tt.ZP.createElement("div",{className:"direction",style:`--direction: ${c.heading}deg`}));if("venue"===d){const t=(0,ei.k4)(c.venueType),s=(0,ei.lZ)(c.venueType);if(s)return Tt.ZP.createElement("div",{className:e,style:`--pin-color: ${t}`},Tt.ZP.createElement(oi,null),Tt.ZP.createElement("img",{src:s,draggable:!1,className:"venue-icon",alt:""}))}return Tt.ZP.createElement("img",{className:e,draggable:!1,src:ti,alt:""})}())}()),function(){if(f)return"venue"===d?Tt.ZP.createElement("div",{className:"location-info"},Tt.ZP.createElement("div",{className:"location-info-title"},c.title),Tt.ZP.createElement("div",{className:"location-info-subtitle"},c.address)):"geoLive"===d?Tt.ZP.createElement("div",{className:"location-info"},Tt.ZP.createElement("div",{className:"location-info-title"},i("AttachLiveLocation")),Tt.ZP.createElement("div",{className:"location-info-subtitle"},(0,ce.dJ)(i,u,e.editDate)),!m&&Tt.ZP.createElement("div",{className:"geo-countdown",ref:o},Tt.ZP.createElement("span",{className:"geo-countdown-text"}),Tt.ZP.createElement("svg",{width:"32px",height:"32px"},Tt.ZP.createElement("circle",{cx:"16",cy:"16",r:12,className:"geo-countdown-progress",transform:"rotate(-90, 16, 16)","stroke-dasharray":si,"stroke-dashoffset":"0"})))):void 0}())})),ri=function({isOwn:e}){const t=e?"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 Tt.ZP.createElement("svg",{width:"9",height:"20",className:"svg-appendix"},Tt.ZP.createElement("defs",null,Tt.ZP.createElement("filter",{x:"-50%",y:"-14.7%",width:"200%",height:"141.2%",filterUnits:"objectBoundingBox",id:"messageAppendix"},Tt.ZP.createElement("feOffset",{dy:"1",in:"SourceAlpha",result:"shadowOffsetOuter1"}),Tt.ZP.createElement("feGaussianBlur",{stdDeviation:"1",in:"shadowOffsetOuter1",result:"shadowBlurOuter1"}),Tt.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"}))),Tt.ZP.createElement("g",{fill:"none","fill-rule":"evenodd"},Tt.ZP.createElement("path",{d:t,fill:"#000",filter:"url(#messageAppendix)"}),Tt.ZP.createElement("path",{d:t,fill:e?"#EEFFDE":"FFF",className:"corner"})))};var ci=s(8018);const di=(0,Tt.X$)((({message:e,outgoingStatus:t,signature:s,withReactionOffset:n,repliesThreadInfo:o,renderQuickReactionButton:i,noReplies:r,isTranslated:c,isPinned:d,withFullDate:l,onClick:u,onTranslationClick:m,onOpenThread:h})=>{const{showNotification:p}=(0,a.Sv)(),g=(0,Is.Z)(),[f,I]=(0,xs.Z)();function v(e){e.stopPropagation(),p({message:g("ImportedInfo")})}const w=(0,Tt.Ye)((()=>{if(!f)return;const t=(0,ce.SA)(1e3*e.date,g.code,void 0,g.timeFormat),s=e.isEdited&&(0,ce.SA)(1e3*e.editDate,g.code,void 0,g.timeFormat),a=e.forwardInfo&&(0,ce.SA)(1e3*(e.forwardInfo.savedDate||e.forwardInfo.date),g.code,void 0,g.timeFormat);let n=t;return s&&(n+="\n",n+=g("lng_edited_date").replace("{date}",s)),a&&(n+="\n",n+=g("lng_forwarded_date").replace("{date}",a)),n}),[f,g,e,g.timeFormat]),b=(0,Tt.Ye)((()=>{const t=(0,ce.mr)(g,1e3*e.date);return l?(0,ce.VX)(g,1e3*(e.forwardInfo?.date||e.date),!0):t}),[g,e.date,e.forwardInfo?.date,l]),y=(0,xt.Z)("MessageMeta",n&&"reactions-offset",e.forwardInfo?.isImported&&"is-imported");return Tt.ZP.createElement("span",{className:y,dir:g.isRtl?"rtl":"ltr",onClick:u,"data-ignore-on-paste":!0},c&&Tt.ZP.createElement("i",{className:"icon icon-language message-translated",onClick:m}),Boolean(e.viewsCount)&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("span",{className:"message-views"},(0,os.bi)(e.viewsCount)),Tt.ZP.createElement("i",{className:"icon icon-channelviews"})),!r&&Boolean(o?.messagesCount)&&Tt.ZP.createElement("span",{onClick:function(e){e.stopPropagation(),h()},className:"message-replies-wrapper"},Tt.ZP.createElement("span",{className:"message-replies"},Tt.ZP.createElement(Mo.Z,{text:(0,os.bi)(o.messagesCount)})),Tt.ZP.createElement("i",{className:"icon icon-reply-filled"})),d&&Tt.ZP.createElement("i",{className:"icon icon-pinned-message message-pinned"}),s&&Tt.ZP.createElement("span",{className:"message-signature"},(0,ga.Z)(s)),Tt.ZP.createElement("span",{className:"message-time",title:w,onMouseEnter:I},e.forwardInfo?.isImported&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("span",{className:"message-imported",onClick:v},(0,ce.SA)(1e3*e.forwardInfo.date,g.code,!0)),Tt.ZP.createElement("span",{className:"message-imported",onClick:v},g("ImportedMessage"))),e.isEdited&&`${g("EditedMessage")} `,b),t&&Tt.ZP.createElement(ci.Z,{status:t}),i&&i())})),li=(0,Tt.X$)((({phoneCall:e,message:t,chatId:s})=>{const{requestMasterAndRequestCall:n}=(0,a.Sv)(),i=(0,Is.Z)(),{isOutgoing:r,isVideo:c,reason:d,duration:l}=e,u="missed"===d,m="busy"===d||void 0===l,h=(0,qt.Z)((()=>{n({isVideo:c,userId:s})})),p=(0,Tt.Ye)((()=>c?u?r?"CallMessageVideoOutgoingMissed":"CallMessageVideoIncomingMissed":m?"CallMessageVideoIncomingDeclined":r?"CallMessageVideoOutgoing":"CallMessageVideoIncoming":u?r?"CallMessageOutgoingMissed":"CallMessageIncomingMissed":m?"CallMessageIncomingDeclined":r?"CallMessageOutgoing":"CallMessageIncoming"),[m,u,r,c]),g=(0,Tt.Ye)((()=>e.duration?(0,ce.J_)(i,e.duration):void 0),[i,e.duration]),f=(0,ce.mr)(i,1e3*t.date);return Tt.ZP.createElement("div",{className:"wqsZyy8u"},Tt.ZP.createElement(vs.Z,{size:"smaller",color:"translucent",round:!0,ripple:!0,onClick:h,className:"NGmo4ADz",disabled:!o.Bi,ariaLabel:i(r?"CallAgain":"CallBack")},Tt.ZP.createElement("i",{className:(0,xt.Z)("icon",c?"icon-video-outlined":"icon-phone")})),Tt.ZP.createElement("div",{className:"iFn6m6hd"},Tt.ZP.createElement("div",{className:"l8QfocIQ"},i(p)),Tt.ZP.createElement("div",{className:"rF5tkx92"},Tt.ZP.createElement("i",{className:(0,xt.Z)("icon","icon-arrow-right","ONmpzmUS",u&&"Alra_BWu",m&&"J7xsuCAm",!r&&"BfgDXljM")}),Tt.ZP.createElement("span",{className:"kKPKwFzu"},g?i("CallMessageWithDuration",[f,g]):f))))}));var ui=s(4809),mi=s(51218),hi=s(96937),pi=s(14434);function gi(e,t){return t>0?(e/t*100).toFixed():0}const fi=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:a,correctResults:n,shouldAnimate:o})=>{const i=t&&t.find((t=>t.option===e.option)),r=0===n.length||-1!==n.indexOf(e.option),c=n.length>0&&r||i?.isChosen,d=i?gi(i.votersCount,s||0):0,[l,u]=(0,Tt.eJ)(o?0:d),m=i?gi(i.votersCount,a||0):0,h=l!==d;if((0,Tt.d4)((()=>{o&&u(d)}),[o,d]),!t||!i)return;const p=`width: ${m}%; transform:scaleX(${h?0:1})`;return Tt.ZP.createElement("div",{className:"PollOption",dir:"ltr"},Tt.ZP.createElement("div",{className:"poll-option-share "+("100"===d?"limit-width":"")},d,"%",c&&Tt.ZP.createElement("span",{className:(0,xt.Z)("poll-option-chosen",!r&&"wrong",o&&"animate")},Tt.ZP.createElement("i",{className:(0,xt.Z)("icon",r?"icon-check":"icon-close")}))),Tt.ZP.createElement("div",{className:"poll-option-right"},Tt.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,ga.Z)(e.text)),Tt.ZP.createElement("div",{className:(0,xt.Z)("poll-option-answer",c&&!r&&"wrong")},o&&Tt.ZP.createElement("svg",{className:"poll-line",style:h?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44"},Tt.ZP.createElement("path",{d:"M4.47 5.33v13.6a9 9 0 009 9h13"})),Tt.ZP.createElement("div",{className:"poll-option-line",style:p}))))},Ii=12*Math.PI;function vi(e){e.stopPropagation()}const wi=(0,Tt.X$)((0,a.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{users:{byId:a}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:a}:{}}))((({message:e,poll:t,recentVoterIds:s,onSendVote:n})=>{const{loadMessage:o,openPollResults:i,requestConfetti:r}=(0,a.Sv)(),{id:c,chatId:d}=e,{summary:l,results:u}=t,[m,h]=(0,Tt.eJ)(!1),[p,g]=(0,Tt.eJ)([]),[f,I]=(0,Tt.eJ)(!1),[v,w]=(0,Tt.eJ)(!1),[b,y]=(0,Tt.eJ)(!l.closed&&l.closeDate&&l.closeDate>0?Math.min(l.closeDate-(0,we.bp)(),l.closePeriod):0),P=(0,Tt.sO)(null),Z=(0,Tt.sO)(null),{results:S,totalVoters:C}=u,M=S&&S.some((e=>e.isChosen)),E=!l.closed&&!M,R=!E&&l.isPublic&&Number(u.totalVoters)>0,k=E&&l.multipleChoice,T=S?Math.max(...S.map((e=>e.votersCount))):C,N=(0,Tt.Ye)((()=>S?.filter((e=>e.isCorrect)).map((e=>e.option))||[]),[S]),A=(0,Tt.Ye)((()=>l.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(l.quiz&&l.closePeriod&&b<=0)})))),[b,l]);(0,Tt.d4)((()=>{const e=t.results.results?.find((e=>e.isChosen));m&&e&&(e.isCorrect&&r({}),h(!1))}),[m,t.results.results,r]),(0,Tt.bt)((()=>{if(b>0&&setTimeout((()=>y(b-1)),1e3),!Z.current)return;b<=5&&P.current.classList.add("hurry-up");const e=(l.closePeriod-b)/l.closePeriod*Ii;Z.current.setAttribute("stroke-dashoffset",`-${e}`)}),[b,l.closePeriod]),(0,Tt.d4)((()=>{l.quiz&&(b<=0||M&&!l.closed)&&o({chatId:d,messageId:c})}),[d,b,M,o,c,l.closed,l.quiz]),(0,Tt.d4)((()=>{let e;return l.quiz&&!l.closed&&l.closePeriod&&l.closePeriod>0&&(e=window.setTimeout((()=>{o({chatId:d,messageId:c})}),1e3*l.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[E,d,o,c,l.closePeriod,l.closed,l.quiz]);const B=(0,Tt.Ye)((()=>{const e=(0,a.Rd)().chats.byId,t=(0,a.Rd)().users.byId;return s?s.reduce(((s,a)=>{const n=e[a],o=t[a];return o?s.push(o):n&&s.push(n),s}),[]):[]}),[s]),x=(0,qt.Z)((e=>{g([e]),h(!0),w(!0),n([e])})),U=(0,qt.Z)((e=>{g(e)})),L=(0,qt.Z)((()=>{h(!0),w(!0),n(p)})),_=(0,qt.Z)((()=>{i({chatId:d,messageId:c})})),O=(0,qt.Z)((()=>{I(!0)})),F=(0,qt.Z)((()=>{I(!1),w(!1)}));(0,Tt.d4)((()=>{v&&M&&l.quiz&&u.results&&t.results.solution&&(u.results.find((e=>e.isChosen&&e.isCorrect))||I(!0))}),[M,v,u.results,l.quiz,t.results.solution]);const D=(0,Is.Z)();return Tt.ZP.createElement("div",{className:"Poll",dir:D.isRtl?"auto":"ltr"},f&&t.results.solution&&Tt.ZP.createElement(hi.Z,{message:(0,ui.H)({text:t.results.solution,entities:t.results.solutionEntities}),duration:5e3,onDismiss:F,containerId:"#middle-column-portals"}),Tt.ZP.createElement("div",{className:"poll-question"},(0,ga.Z)(l.question,["emoji","br"])),Tt.ZP.createElement("div",{className:"poll-type"},D(function(e){return void 0===e.isPublic?" ":e.closed?"FinalResults":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.isPublic?"PublicPoll":"AnonymousPoll"}(l)),B.length>0&&Tt.ZP.createElement("div",{className:"poll-recent-voters"},B.map((e=>Tt.ZP.createElement(Yn.Z,{key:e.id,size:"micro",peer:e})))),b>0&&E&&Tt.ZP.createElement("div",{ref:P,className:"poll-countdown"},Tt.ZP.createElement("span",null,(0,ce.k9)(b)),Tt.ZP.createElement("svg",{width:"16px",height:"16px"},Tt.ZP.createElement("circle",{ref:Z,cx:"8",cy:"8",r:6,className:"poll-countdown-progress",transform:"rotate(-90, 8, 8)","stroke-dasharray":Ii,"stroke-dashoffset":"0"}))),l.quiz&&t.results.solution&&!E&&Tt.ZP.createElement(vs.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:f,onClick:O,ariaLabel:"Show Solution"},Tt.ZP.createElement("i",{className:"icon icon-lamp"}))),E&&Tt.ZP.createElement("div",{className:"poll-answers",onClick:vi},k?Tt.ZP.createElement(mi.Z,{options:A,onChange:U,disabled:e.isScheduled||m,loadingOptions:m?p:void 0,round:!0}):Tt.ZP.createElement(pi.Z,{name:`poll-${c}`,options:A,onChange:x,disabled:e.isScheduled||m,loadingOption:m?p[0]:void 0})),!E&&Tt.ZP.createElement("div",{className:"poll-results"},l.answers.map((function(e){return Tt.ZP.createElement(fi,{key:e.option,shouldAnimate:v||!E,answer:e,voteResults:S,totalVoters:C,maxVotersCount:T,correctResults:N})}))),!R&&!k&&Tt.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")}(D,l.quiz,u.totalVoters)),k&&Tt.ZP.createElement(vs.Z,{isText:!0,disabled:0===p.length,size:"tiny",onClick:L},D("PollSubmitVotes")),R&&Tt.ZP.createElement(vs.Z,{isText:!0,size:"tiny",onClick:_},D("PollViewResults")))})));var bi=s(65351),yi=s(36368),Pi=s(31482);const Zi=1.25*M.Gw,Si=(0,Tt.X$)((({reaction:e,containerId:t,isOwnMessage:s,recentReactors:a,className:n,chosenClassName:o,observeIntersection:i,onClick:r})=>{const c=(0,qt.Z)((()=>{r?.(e.reaction)}));return Tt.ZP.createElement(vs.Z,{className:(0,xt.Z)(Pi.Z.root,s&&Pi.Z.own,(0,v.Bt)(e)&&Pi.Z.chosen,(0,v.Bt)(e)&&o,n),size:"tiny",onClick:c},Tt.ZP.createElement(yi.Z,{className:Pi.Z.animatedEmoji,containerId:t,reaction:e.reaction,size:Zi,observeIntersection:i}),a?.length?Tt.ZP.createElement(bi.Z,{size:"mini",peers:a}):Tt.ZP.createElement(Mo.Z,{text:(0,os.bi)(e.count),className:Pi.Z.counter}))}));var Ci=s(14018);const Mi=(0,Tt.X$)((({message:e,isOutside:t,maxWidth:s,metaChildren:n,observeIntersection:o,noRecentReactors:i,isCurrentUserPremium:r,tags:c})=>{const{toggleReaction:d,setLocalTextSearchTag:l,searchTextMessagesLocal:u,openPremiumModal:m}=(0,a.Sv)(),h=(0,Is.Z)(),{results:p,areTags:f,recentReactions:I}=e.reactions,w=(0,Tt.Ye)((()=>p.reduce(((e,t)=>e+t.count),0)),[p]),b=(0,Tt.Ye)((()=>{const e=(0,a.Rd)();return I?.reduce(((t,s)=>{const{reaction:a,peerId:n}=s,o=(0,v.jq)(a),i=(0,y.RGZ)(e,n);if(!i)return t;const r=t[o]||[];return r.push(i),t[o]=r,t}),{})}),[I]),P=(0,Tt.Ye)((()=>{const t=(0,g.Tp)(e);return p.map((e=>{const s=(0,v.jq)(e.reaction),a=b?.[s],n=w>3||i,o=f?c?.[s]:void 0;return{reaction:e,reactionKey:s,messageKey:t,recentReactors:n?void 0:a,isChosen:(0,v.Bt)(e),tag:o}}))}),[e,i,b,p,f,c,w]),Z=(0,qt.Z)((t=>{if(f)return r?(l({tag:t}),void u()):void m({initialSection:"saved_tags"});d({chatId:e.chatId,messageId:e.id,reaction:t})})),S=(0,qt.Z)((t=>{d({chatId:e.chatId,messageId:e.id,reaction:t})}));return Tt.ZP.createElement("div",{className:(0,xt.Z)("Reactions",t&&"is-outside"),style:s?`max-width: ${s}px`:void 0,dir:h.isRtl?"rtl":"ltr"},P.map((({reaction:t,recentReactors:s,messageKey:a,reactionKey:n,isChosen:i,tag:c})=>f?Tt.ZP.createElement(Ci.Z,{key:n,className:"message-reaction",chosenClassName:"chosen",containerId:a,isOwnMessage:e.isOutgoing,isChosen:i,reaction:t.reaction,tag:c,withContextMenu:r,onClick:Z,onRemove:S,observeIntersection:o}):Tt.ZP.createElement(Si,{key:n,className:"message-reaction",chosenClassName:"chosen",containerId:a,isOwnMessage:e.isOutgoing,recentReactors:s,reaction:t,onClick:Z,observeIntersection:o}))),n)}));var Ei=s(56766),Ri=s(97799);const ki=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:n,shouldPlayEffect:i,withEffect:c,onPlayEffect:d,onStopEffect:l})=>{const{showNotification:u,openStickerSet:m}=(0,a.Sv)(),h=(0,Is.Z)(),{isMobile:p}=(0,x.ZP)(),g=(0,Tt.sO)(null),f=e.content.sticker,{stickerSetInfo:I,isVideo:w,hasEffect:b}=f,y=f.isPreloadedGlobally?void 0:(0,v.Ti)(e,w&&!o.Hh?"pictogram":"inline"),P=(0,gn.Op)(g,t),Z=(0,gn.Op)(g,s),S=`sticker${f.id}?size=f`,C=(0,ba.Z)(S,!P||!b,r.IU.BlobUrl),[E,R,k]=(0,xs.Z)(),T=(0,qt.Z)((()=>{k(),l?.()})),N=(0,La.Z)(i);(0,Tt.d4)((()=>{b&&c&&Z&&(i||N)&&(R(),d?.())}),[b,Z,d,i,N,R,c]);const A=(0,qt.Z)((()=>{m({stickerSetInfo:f.stickerSetInfo})})),B=(0,qt.Z)((()=>{if(b){if(E||!c)return void u({message:h("PremiumStickerTooltip"),action:{action:"openStickerSet",payload:{stickerSetInfo:f.stickerSetInfo}},actionText:h("ViewAction")});if(c)return R(),void d?.()}A()})),U="isMissing"in I,{width:L,height:_}=(0,M.Wr)(f,p),O=(0,xt.Z)("Sticker media-inner",U&&"inactive",b&&!e.isOutgoing&&"reversed");return Tt.ZP.createElement("div",{ref:g,className:O,style:`width: ${L}px; height: ${_}px;`,onClick:U?void 0:B},Tt.ZP.createElement(cn.Z,{containerRef:g,sticker:f,fullMediaHash:y,fullMediaClassName:"full-media",size:L,shouldLoop:n,noLoad:!P,noPlay:!Z,withSharedAnimation:!0}),b&&c&&P&&E&&Tt.ZP.createElement(Ri.Z,{key:S,className:"effect-sticker",tgsUrl:C,size:1.49*L,play:!0,isLowPriority:!0,noLoop:!0,onEnded:T}))};var Ti=s(93609);const Ni=(0,Tt.X$)((0,a.c$)(((e,{message:t})=>{const{id:s,peerId:a}=t.content.storyData;return{story:(0,y.JrV)(e,a,s),isConnected:"connectionStateReady"===e.connectionState}}))((function({message:e,story:t,isProtected:s,isConnected:a}){const{storyData:n}=e.content;return Tt.ZP.createElement(Ti.Z,{story:t||n,isProtected:s,isConnected:a})}))),Ai=(0,Tt.X$)((0,a.c$)(((e,{message:t})=>{const{id:s,peerId:a}=t.content.storyData,n=(0,y.nST)(e,a)?.lastReadId;return{story:(0,y.JrV)(e,a,s),peer:(0,y.RGZ)(e,a),targetUser:(0,y.dyD)(e,t.chatId),isUnread:Boolean(n&&n<s)}}))((function({message:e,story:t,peer:s,isUnread:n,targetUser:o}){const{openStoryViewer:i}=(0,a.Sv)(),r=(0,Is.Z)(),{storyData:c}=e.content,d=(0,qt.Z)((()=>{i({peerId:t.peerId,storyId:t.id,isSinglePeer:!0,isSingleStory:!0})})),l=t&&"isDeleted"in t,u=t&&"content"in t,m=u?t.content.video:void 0,h=u?(0,v.Cc)(t,"pictogram"):void 0,p=(0,ba.Z)(h)||m?.thumbnail?.dataUri;return(0,Tn.Z)(c.peerId,c.id,t),Tt.ZP.createElement("div",{className:(0,xt.Z)("action-message-story-mention",n&&"is-unread",u&&"with-preview"),tabIndex:0,role:"button",onClick:u?d:void 0},u&&Tt.ZP.createElement("span",{className:"story-media-wrapper"},p&&Tt.ZP.createElement("img",{src:p,alt:"",className:"story-media"})),Tt.ZP.createElement("span",{className:"story-title"},(0,ga.Z)(s&&"isSelf"in s&&s.isSelf?r(l?"ExpiredStoryMentioned":"StoryYouMentionedTitle",(0,v.Vl)(o)):l?r("ExpiredStoryMention"):r("StoryMentionedTitle",(0,v.OU)(r,s)),["emoji","simple_markdown"])))})));var Bi=s(54659);const xi=1.75*M.Gw,Ui=2.25*M.Gw,Li=(0,Tt.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:a,activeReactions:i,activeEmojiInteractions:c,loadingThread:d}=(0,y.jUK)(e),{message:l,album:u,withSenderName:m,withAvatar:h,threadId:p,messageListType:f,isLastInDocumentGroup:I,isFirstInGroup:w}=t,{id:b,chatId:P,viaBotId:Z,isOutgoing:C,forwardInfo:M,transcriptionId:E,isPinned:R}=l,k=(0,y.Z1J)(e,P),T=(0,y.FM1)(e,P),N=(0,v.pK)(P),A=(0,v.wo)(P),B=k&&(0,v.eA)(k),x=k&&(0,v.Bf)(k),U=(0,v.YC)(P)?void 0:(0,y.x67)(e,P),L=l.content.webPage?.story,_=L?(0,y.JrV)(e,L.peerId,L.id):void 0,O=a.messageIds&&a.messageIds.includes(b),F=!T&&(0,v.Ul)(l),D=m||h||F,j=(0,y.Urc)(e,l),q=(0,y.cve)(e,l),G=Z?(0,y.dyD)(e,Z):void 0,H=j?.id&&x?U?.adminMembersById?.[j?.id]:void 0,V=l.id===p,{replyToMsgId:$,replyToPeerId:z,replyFrom:K}=(0,S.H)(l)||{},{peerId:J,storyId:W}=(0,S.f)(l)||{},Y=$&&$===p,X=$?(0,y.hjO)(e,z||P,$):void 0,Q=M||K,ee=X?(0,y.BzW)(e,X):!Q||N||A?void 0:(0,y.zDD)(e,Q),te=X&&(0,y.cve)(e,X),se=z?(0,y.Z1J)(e,z):void 0,ae=!N&&!A&&se&&!(0,v.Sb)(se)&&(se.isNotJoined||se.isRestricted),ne="topicCreate"===X?.content.action?.type,oe=W&&J?(0,y.JrV)(e,J,W):void 0,ie=J?(0,y.RGZ)(e,J):void 0,re=(0,y.uZE)(e,l),ce="thread"===f&&(u?u.messages.some((t=>(0,y._XY)(e,t,p))):(0,y._XY)(e,l,p)),{direction:de,noHighlight:le,isResizingContainer:ue,quote:me}=ce&&s||{},{query:he}=(0,y.n5x)(e)||{},pe=(0,v.h_)(l),ge=pe&&(0,y.zB_)(e,pe)?pe:void 0,fe=(0,v.HW)(l);let Ie;Ie=u?.messages?u.messages.every((({id:t})=>(0,y.vkB)(e,t))):(0,y.vkB)(e,b);const{canReply:ve}="thread"===f&&(0,y._kf)(e,l,p)||{},we=(0,y.teg)(e,l),be=(0,y.tZg)(e,P,u?.mainMessage.id||b),ye=Boolean(l.groupedId)&&!l.isInAlbum,Pe=ye?(0,y.xHX)(e,P,l.groupedId)[0]:void 0,Ze=ye?I?(0,y.hjO)(e,P,Pe):void 0:l,Se=k?.unreadReactions?.includes(l.id),Ce=p===r._f&&k?.isForum&&w,Me=Ce?(0,y.p$s)(e,l)||k?.topics?.[n.OxA]:void 0,Ee=(0,y.xfm)(e,P),Re=(0,y.Bdn)(e,P,l.id),ke=(0,y.lpX)(e,P),Te=o.SX&&e.settings.byKey.canTranslate&&!ke,Ne="connectionStateReady"===e.connectionState,Ae=Boolean(Ze&&i[(0,g.Tp)(Ze)]?.length),Be=(0,y.wVz)(e),xe=j&&(0,y.FM1)(e,j.id)?U?.boostsApplied??l.senderBoosts:l.senderBoosts,Ue=k?.boostLevel||0,Le=e.appConfig?.groupTranscribeLevelMin,_e=Be||Boolean(Le&&Ue>=Le);return{theme:(0,y.Puy)(e),forceSenderName:F,sender:j,canShowSender:D,originSender:q,botSender:G,shouldHideReply:Y||ne,isThreadTop:V,replyMessage:X,replyMessageSender:ee,replyMessageForwardSender:te,replyMessageChat:se,replyStory:oe,isReplyPrivate:ae,storySender:ie,isInDocumentGroup:ye,isProtected:(0,y.EVS)(e,l),isChatProtected:(0,y.AmN)(e,P),isFocused:ce,isForwarding:O,reactionMessage:Ze,isChatWithSelf:T,isRepliesChat:N,isAnonymousForwards:A,isChannel:B,isGroup:x,canReply:ve,highlight:he,animatedEmoji:ge,animatedCustomEmoji:fe,isInSelectMode:(0,y.CAb)(e),isSelected:Ie,isGroupSelected:Boolean(l.groupedId)&&!l.isInAlbum&&(0,y.a65)(e,P,l.groupedId),threadId:p,isDownloading:we,isPinnedList:"pinned"===f,isPinned:R,canAutoLoadMedia:(0,y.bHC)(e,l),canAutoPlayMedia:(0,y.__o)(e,l),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,y.yBd)(e),repliesThreadInfo:be,availableReactions:e.reactions.availableReactions,defaultReaction:(0,v.CI)(l)||"scheduled"===f?void 0:(0,y.q6x)(e,P),hasActiveReactions:Ae,activeEmojiInteractions:c,hasUnreadReaction:Se,isTranscribing:void 0!==E&&e.transcriptions[E]?.isPending,transcribedText:void 0!==E?e.transcriptions[E]?.text:void 0,isPremium:Be,senderAdminMember:H,messageTopic:Me,hasTopicChip:Ce,chatTranslations:Ee,areTranslationsEnabled:Te,shouldDetectChatLanguage:(0,y.J1l)(e,P),requestedTranslationLanguage:Re,requestedChatTranslationLanguage:ke,hasLinkedChat:Boolean(U?.linkedChatId),withStickerEffects:(0,y.$Yd)(e,"stickerEffects"),webPageStory:_,isConnected:Ne,isLoadingComments:be?.isCommentsInfo&&d?.loadingChatId===be?.originChannelId&&d?.loadingMessageId===be?.originMessageId,shouldWarnAboutSvg:e.settings.byKey.shouldWarnAboutSvg,...C&&{outgoingStatus:(0,y.dTW)(e,l,"scheduled"===f)},..."number"==typeof re&&{uploadProgress:re},...ce&&{focusDirection:de,noFocusHighlight:le,isResizingContainer:ue,focusedQuote:me},senderBoosts:xe,tags:e.savedReactionTags?.byKey,canTranscribeVoice:_e}}))((({message:e,observeIntersectionForBottom:t,observeIntersectionForLoading:s,observeIntersectionForPlaying:i,album:d,noAvatars:l,withAvatar:u,withSenderName:m,noComments:h,noReplies:p,appearanceOrder:g,isJustAdded:f,isFirstInGroup:I,isPremium:w,isLastInGroup:b,isFirstInDocumentGroup:y,isLastInDocumentGroup:P,isTranscribing:Z,transcribedText:C,isLastInList:E,theme:R,forceSenderName:k,sender:T,canShowSender:N,originSender:A,botSender:B,isThreadTop:U,shouldHideReply:L,replyMessage:_,replyMessageSender:O,replyMessageForwardSender:F,replyMessageChat:D,replyStory:j,isReplyPrivate:q,storySender:G,outgoingStatus:H,uploadProgress:V,isInDocumentGroup:$,isLoadingComments:z,isProtected:K,isChatProtected:J,isFocused:W,focusDirection:Y,focusedQuote:X,noFocusHighlight:Q,isResizingContainer:ee,isForwarding:te,isChatWithSelf:se,isRepliesChat:ae,isAnonymousForwards:ne,isChannel:oe,isGroup:ie,canReply:re,highlight:ce,animatedEmoji:de,animatedCustomEmoji:le,hasActiveReactions:ue,hasLinkedChat:me,isInSelectMode:he,isSelected:pe,isGroupSelected:ge,threadId:fe,reactionMessage:Ie,availableReactions:ve,defaultReaction:we,activeEmojiInteractions:be,messageListType:ye,isPinnedList:Pe,isPinned:Ze,isDownloading:Se,canAutoLoadMedia:Ce,canAutoPlayMedia:Me,shouldLoopStickers:Ee,autoLoadFileMaxSizeMb:Re,repliesThreadInfo:ke,hasUnreadReaction:Te,memoFirstUnreadIdRef:Ne,senderAdminMember:Ae,messageTopic:Be,hasTopicChip:xe,chatTranslations:Ue,areTranslationsEnabled:Le,shouldDetectChatLanguage:_e,requestedTranslationLanguage:Oe,requestedChatTranslationLanguage:Fe,withStickerEffects:De,webPageStory:je,isConnected:qe,getIsMessageListReady:Ge,shouldWarnAboutSvg:He,senderBoosts:Ve,tags:$e,canTranscribeVoice:ze,onPinnedIntersectionChange:Ke})=>{const{toggleMessageSelection:Je,clickBotInlineButton:We,disableContextMenuHint:Ye,animateUnreadReaction:Xe,focusLastMessage:Qe}=(0,a.Sv)(),et=(0,Tt.sO)(null),tt=(0,Tt.sO)(null),st=(0,Tt.sO)(null),at=(0,Tt.sO)(0),nt=(0,Is.Z)(),[ot,it]=(0,Tt.eJ)(!1),[rt,ct,dt]=(0,xs.Z)(),{isMobile:lt,isTouchScreen:ut}=(0,x.ZP)();(0,gn._N)(tt,t);const{isContextMenuOpen:mt,contextMenuPosition:ht,contextMenuTarget:pt,handleBeforeContextMenu:gt,handleContextMenu:ft,handleContextMenuClose:It,handleContextMenuHide:vt}=(0,Ia.Z)(et,ut&&he,!o.D$,o.wZ,Ge);(0,Tt.d4)((()=>{mt&&Ye()}),[mt,Ye]);const wt=g<=0,[bt,yt]=(0,xs.Z)(wt);(0,Tt.d4)((()=>{wt||setTimeout(yt,10*g)}),[g,yt,wt]);const{transitionClassNames:Pt}=(0,$t.Z)(bt||f,void 0,wt&&!f,!1),{id:Zt,chatId:St,forwardInfo:Ct,viaBotId:Mt,isTranscriptionError:Et}=e;(0,Tt.d4)((()=>{if(!Ze)return;const e=d?d.mainMessage.id:Zt;return()=>{Ke({viewportPinnedIdsToRemove:[e],isUnmount:!0})}}),[d,Ze,Zt,Ke]);const Rt=(0,v.CI)(e),kt=(0,v.B4)(e),Nt="scheduled"===ye||e.isScheduled,At=(0,v.V5)(e)&&!L,Bt=(0,S.H)(e),Ut=(0,S.f)(e),Lt=Boolean(Ut),_t=Boolean(ke)&&"thread"===ye,Ot=(0,v.$D)(e),Ft=Ot&&(de||le),Dt=Ie?.reactions&&!(0,v.JE)(Ie.reactions),Gt=Ct&&(!se||Nt)&&!ae&&!ne&&!Ct.isLinkedChannelPost&&!Ot||Boolean(e.content.storyData&&!e.content.storyData.isMention),Ht=e.content.storyData?.isMention,Vt=Boolean(d)&&d.messages.length>1&&!d?.messages.some((e=>0===Object.keys(e.content).length)),zt=$&&!y,Kt=$&&!P,Jt=void 0!==ht,Wt=!(Jt||he||te||Kt||Ht),Yt=oe&&!Nt&&e.isForwardingAllowed&&!J,Xt=Boolean(Pe||Ct&&(Ct.isChannelPost||se&&!kt||ae||ne)&&Ct.fromMessageId),Qt=kt&&!Ot,es=xe||At||Lt,ts=(0,qt.Z)(((e,t)=>{Je({messageId:Zt,groupedId:t,...e?.shiftKey&&{withShift:!0},...Vt&&{childMessageIds:d.messages.map((({id:e})=>e))}})})),ss=N?T:void 0,as=Boolean(!ot&&(Et||C)),ns=Ct&&(se||ae||ne||!ss)?A:ss,os=A||T,is=Ct||e.content.storyData?A:ss,rs=(0,v.fY)(e),cs=(0,v.qR)(e),{handleMouseDown:ds,handleClick:ls,handleContextMenu:us,handleDoubleClick:ms,handleContentDoubleClick:hs,handleMouseMove:ps,handleSendQuickReaction:gs,handleMouseLeave:fs,isSwiped:ws,isQuickReactionVisible:bs,handleDocumentGroupMouseEnter:ys}=zn(ts,et,Zt,Boolean(he),Boolean(re),Boolean(K),ft,gt,St,Jt,st,Kt,Ge),{handleAvatarClick:Ps,handleSenderClick:Zs,handleViaBotClick:Ss,handleReplyClick:Cs,handleMediaClick:Ms,handleAudioPlay:Es,handleAlbumMediaClick:Rs,handleMetaClick:ks,handleTranslationClick:Ts,handleOpenThread:Ns,handleReadMedia:As,handleCancelUpload:Bs,handleVoteSend:Us,handleGroupForward:Ls,handleForward:_s,handleFocus:Os,handleFocusForwarded:Fs,handleDocumentGroupSelectAll:Ds,handleTopicChipClick:js,handleStoryClick:qs}=function(e,t,s,n,o,i,d,l,u,m,h,p,g,f,I,v,w){const{openChat:b,showNotification:y,focusMessage:P,openMediaViewer:Z,openAudioPlayer:C,markMessagesRead:M,cancelUploadMedia:E,sendPollVote:R,openForwardMenu:k,openChatLanguageModal:T,openThread:N,openStoryViewer:A}=(0,a.Sv)(),{id:B,forwardInfo:x,groupedId:U}=s,{replyToMsgId:L,replyToPeerId:_,replyToTopId:O,isQuote:F,quoteText:D}=(0,S.H)(s)||{},j=(0,qt.Z)((()=>{m&&b({id:m.id})})),q=(0,qt.Z)((()=>{h?d&&x?.channelPostId?P({chatId:h.id,messageId:x.channelPostId}):b({id:h.id}):y({message:e("HidAccount")})})),G=(0,qt.Z)((()=>{p&&b({id:p.id})})),H=(0,qt.Z)((()=>{L&&!v?P({chatId:_||n,threadId:w?O:o,messageId:L,replyMessageId:_?void 0:B,noForumTopicPanel:!_,...F&&{quote:D?.text}}):y({message:e(F?"QuotePrivate":"ReplyPrivate")})})),V=(0,qt.Z)((()=>{Z({chatId:n,threadId:o,mediaId:B,origin:l?c.bZ.ScheduledInline:c.bZ.Inline})})),$=(0,qt.Z)((()=>{C({chatId:n,messageId:B})})),z=(0,qt.Z)((e=>{Z({chatId:n,threadId:o,mediaId:e,origin:l?c.bZ.ScheduledAlbum:c.bZ.Album})})),K=(0,qt.Z)((()=>{M({messageIds:[B]})})),J=(0,qt.Z)((()=>{E({chatId:n,messageId:B})})),W=(0,qt.Z)((e=>{R({chatId:n,messageId:B,options:e})})),Y=(0,qt.Z)((()=>{k({fromChatId:n,groupedId:U})})),X=(0,qt.Z)((()=>{if(u&&u.messages){const e=u.messages.map((({id:e})=>e));k({fromChatId:n,messageIds:e})}else k({fromChatId:n,messageIds:[B]})})),Q=(0,qt.Z)((()=>{P({chatId:n,threadId:r._f,messageId:B})})),ee=(0,qt.Z)((()=>{P(i?{chatId:x.fromChatId,groupedId:U,groupedChatId:n,messageId:x.fromMessageId}:_&&O?{chatId:_,threadId:O,messageId:x.fromMessageId}:{chatId:x.fromChatId,messageId:x.fromMessageId})})),te=(0,qt.Z)((e=>{e.stopPropagation(),t(e,U)}));return{handleAvatarClick:j,handleSenderClick:q,handleViaBotClick:G,handleReplyClick:H,handleMediaClick:V,handleAudioPlay:$,handleAlbumMediaClick:z,handleMetaClick:te,handleTranslationClick:(0,qt.Z)((e=>{e.stopPropagation(),T({chatId:n,messageId:f?void 0:B})})),handleOpenThread:(0,qt.Z)((()=>{N({chatId:s.chatId,threadId:s.id})})),handleReadMedia:K,handleCancelUpload:J,handleVoteSend:W,handleGroupForward:Y,handleForward:X,handleFocus:Q,handleFocusForwarded:ee,handleDocumentGroupSelectAll:te,handleTopicChipClick:(0,qt.Z)((()=>{g&&P({chatId:_||n,threadId:g.id,messageId:B})})),handleStoryClick:(0,qt.Z)((()=>{I&&A({peerId:I.peerId,storyId:I.id,isSingleStory:!0})}))}}(nt,ts,e,St,fe,$,Gt,Nt,d,ns,is,B,Be,Boolean(Fe),j&&"content"in j?j:void 0,q,ae);(0,Tt.d4)((()=>{E&&as&&C&&Qe()}),[Qe,E,C,as]);const Gs=(0,xt.Z)("Message message-list-item",I&&"first-in-group",K&&!rs?"is-protected":"allow-selection",b&&"last-in-group",y&&"first-in-document-group",P&&"last-in-document-group",E&&"last-in-list",kt&&"own",Boolean(e.viewsCount)&&"has-views",e.isEdited&&"was-edited",At&&"has-reply",mt&&"has-menu-open",W&&!Q&&"focused",te&&"is-forwarding",e.isDeleting&&"is-deleting",$&&"is-in-document-group",Vt&&"is-album",e.hasUnreadMention&&"has-unread-mention",pe&&"is-selected",he&&"is-in-selection-mode",U&&!u&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",ws&&"is-swiped",Pt,f&&"is-just-added",(ue||rt)&&"has-active-reaction",Ht&&"is-story-mention"),{text:Hs,photo:Vs,video:$s,audio:zs,voice:Ks,document:Js,sticker:Xs,contact:Qs,poll:ea,webPage:ta,invoice:sa,location:aa,action:na,game:oa,storyData:ia,giveaway:ra,giveawayResults:ca}=(0,v.qp)(e),{replyToMsgId:da,replyToPeerId:la,isQuote:ua}=Bt||{},{peerId:ma,storyId:ha}=Ut||{},pa=function(e,t,s){const[a,n]=(0,Tt.eJ)();return(0,Tt.d4)((()=>{t||s&&!s()||(e?async function(e,t=.2){return Bn||await xn.promise,await Bn.request({name:"detectLanguage",args:[e,t]})}(e).then(n):n(void 0))}),[t,e,s]),a}(Hs?.text,!(Le||_e),Ge);!function(e,t,s,a){(0,Tt.d4)((()=>{if(s||a&&!a())return;const n=Boolean(e.content.text?.text.length);!function(e,t,s,a){const n=Dn.get(e)||new Fn(150),o=n.get(t);o&&o.detectedLanguage===a&&o.isTranslatable===s||(n.set(t,{id:t,isTranslatable:s,detectedLanguage:a}),Dn.set(e,n),jn(e))}(e.chatId,e.id,n,t)}),[e,t,s,a])}(e,pa,!_e,Ge);const fa=(0,v.cT)(e,!Fe),{isPending:va,translatedText:wa}=(0,Gn.Z)(Ue,St,fa?Zt:void 0,Oe),ba=(0,La.Z)(wa,Boolean(fa)),ya=wa||ba,{phoneCall:Pa}=na||{},Za=(ke||me&&oe&&Rt)&&!Kt&&"thread"===ye&&!h,Sa=ke?.isCommentsInfo&&!Kt&&"thread"===ye&&!h,Ca=!ut&&!Pa&&!he&&we&&!Kt&&!Ht&&!cs,Ma=function(e,{hasSubheader:t,isCustomShape:s,isLastInGroup:a,asForwarded:o,hasThread:i,forceSenderName:r,hasCommentCounter:c,hasActionButton:d,hasReactions:l,isGeoLiveActive:u,withVoiceTranscription:m,peerColorClass:h}={}){const{text:p,photo:g,video:f,audio:I,voice:w,document:b,poll:y,webPage:P,contact:Z,location:S,invoice:C,storyData:M,giveaway:E,giveawayResults:R}=(0,v.qp)(e),k=[n.gnl],T=M||g||f||S||C?.extendedMedia,N=p||"venue"===S?.type||u,A=T&&!N,B=Boolean(e.viaBotId);return h&&k.push(h),!T&&e.emojiOnlyCount?(k.push("emoji-only"),e.emojiOnlyCount<=n.L5X&&k.push(`emoji-only-${e.emojiOnlyCount}`)):N?k.push("text"):k.push("no-text"),d&&k.push("has-action-button"),s&&(k.push("custom-shape"),f?.isRound&&k.push("round"),c&&k.push("has-comment-counter")),T?k.push("media"):I?k.push("audio"):w?(k.push("voice"),m&&k.push("with-voice-transcription")):b?k.push("document"):Z?k.push("contact"):y?k.push("poll"):E||R?k.push("giveaway"):P&&(k.push("web-page"),(P.photo||P.video)&&k.push("media"),P.document&&k.push("document")),C&&!C.extendedMedia&&k.push("invoice"),M&&k.push("story"),o&&k.push("is-forwarded"),t&&k.push("has-subheader"),i&&k.push("has-replies"),l&&k.push("has-reactions"),B&&k.push("is-via-bot"),r&&k.push("force-sender-name"),s||(k.push("has-shadow"),T&&i&&k.push("has-background"),(t||o||B||!A||r)&&k.push("has-solid-background"),a&&(g||!A||S&&o)&&k.push("has-appendix")),k.join(" ")}(e,{hasSubheader:es,isCustomShape:Ot,isLastInGroup:b,asForwarded:Gt,hasThread:_t&&!h,forceSenderName:k,hasCommentCounter:_t&&ke.messagesCount>0,hasActionButton:Yt||Xt,hasReactions:Dt,isGeoLiveActive:"geoLive"===aa?.type&&!(0,v.$R)(e),withVoiceTranscription:as,peerColorClass:(0,Pn.D)(os,Qt)}),Ea=Ma.includes("has-appendix"),Ra=(0,Zn.qo)(e.emojiOnlyCount);let ka,Ta;ka=Pa||Kt?"none":!rs||ta||Ra?"standalone":"in-text",Dt?Ot||(Vs||$s||ia||"geo"===aa?.type)&&!rs?Ta="outside":Gt?(ka="standalone",Ta="inside"):Ta="inside":Ta="none";const Na=Ot?"in-meta":"in-content";(0,kn.Z)(la||St,da,_,e.id,L||ua||q),(0,Tn.Z)(ma||St,ha,j),(0,qn.Z)(et,St,W,Y,Q,ee,f,Boolean(X));const Aa=oe&&e.postAuthorTitle||(Gt||se)&&Ct?.postAuthorTitle||void 0,Ba=E,xa=(0,qt.Z)((e=>{const t=at.current,s=e.contentRect.height;if(at.current=s,(0,Ja.Ni)()||!t||s<=t)return;const a=e.target.closest(".MessageList");if(!a)return;(0,jt.YW)(400);const n=s-t,{offsetHeight:o,scrollHeight:i,scrollTop:r}=a;Math.round(i-r-o)-n<=5&&Qe()})),Ua=(0,Un.Z)(xa,[xa],300,!1);(0,on.Z)(et,Ua,!Ba),(0,Tt.d4)((()=>{const e=tt.current;Te&&e&&(0,bn.P)(e)&&Xe({messageIds:[Zt]})}),[Te,Zt,Xe]);const _a=(0,Tt.Ye)((()=>Vt?Rn(kt,Boolean(Gt),Boolean(l),d,lt):void 0),[Vt,kt,Gt,l,d,lt]),Oa=Gt?28:0,Fa=(0,Tt.Ye)((()=>{let t,s,a,n=!1,o="";if(!Vt&&(Vs||$s||sa?.extendedMedia)){let a;if(Vs)a=(0,Sn.GH)(e,Gt,l,lt).width;else if($s)a=$s.isRound?M.Rj:(0,Sn.GH)(e,Gt,l,lt).width;else if(sa?.extendedMedia&&sa.extendedMedia.width&&sa.extendedMedia.height){const{width:e,height:t}=sa.extendedMedia;a=(0,M.Kf)({width:e,height:t,fromOwnMessage:kt,asForwarded:Gt,noAvatars:l,isMobile:lt}).width}a&&(a<Sn.Vx&&(s=a),t=Math.max((0,Sn.Pw)(Hs?.text,Za),a),sa?.extendedMedia&&t-a>18&&(n=!0))}else _a&&(t=Math.max((0,Sn.Pw)(Hs?.text,Za),_a.containerStyle.width),t-_a.containerStyle.width>18&&(n=!0));if(t)o=`width: ${t+Oa}px`,a=t+Ui;else if(Xs&&!es){const{width:e}=(0,M.Wr)(Xs,lt);o=`width: ${e+Oa}px`,a=e+Ui}return{contentWidth:s,noMediaCorners:n,style:o,reactionsMaxWidth:a}}),[_a,Gt,Oa,es,sa?.extendedMedia,Vt,Za,lt,kt,e,l,Vs,Xs,Hs?.text,$s]),{contentWidth:Da,noMediaCorners:ja,style:qa,reactionsMaxWidth:Ga}=Fa;function Ha(t){return Tt.ZP.createElement(oo.Z,{messageOrStory:e,translatedText:Oe?ya:void 0,isForAnimation:t,focusedQuote:X,emojiSize:Ra,highlight:ce,isProtected:K,observeIntersectionForLoading:s,observeIntersectionForPlaying:i,withTranslucentThumbs:Ot})}const Va=(0,Tt.I4)((()=>{if(we)return Tt.ZP.createElement("div",{className:(0,xt.Z)("quick-reaction",bs&&!ue&&"visible"),onClick:gs,ref:st},Tt.ZP.createElement(io.Z,{reaction:we,size:xi,availableReactions:ve,observeIntersection:i}))}),[ue,ve,we,gs,bs,i]);function $a(){const t=Tt.ZP.createElement(di,{message:e,isPinned:Ze,withFullDate:se&&!kt,noReplies:p,repliesThreadInfo:ke,outgoingStatus:H,signature:Aa,withReactionOffset:"inside"===Ta,renderQuickReactionButton:Ca&&"in-meta"===Na?Va:void 0,availableReactions:ve,isTranslated:Boolean(Oe?ya:void 0),onClick:ks,onTranslationClick:Ts,onOpenThread:Ns});return"inside"!==Ta?t:Tt.ZP.createElement(Mi,{message:Ie,metaChildren:t,observeIntersection:i,noRecentReactors:oe,tags:$e,isCurrentUserPremium:w})}function za(){if(Ot&&!Mt||!(m&&(!(Vs||$s||aa)||xe)||Gt||Mt||k)||zt||At&&Ot)return;let t;!is||Ot&&Mt?Ct?.hiddenUserName?t=Ct.hiddenUserName:ia&&A&&(t=(0,v.OU)(nt,A)):t=(0,v.OU)(nt,is);const a=is&&"emojiStatus"in is&&is.emojiStatus,o=is&&"isPremium"in is&&is.isPremium;return Tt.ZP.createElement("div",{className:"message-title",dir:"ltr"},t||Gt?Tt.ZP.createElement("span",{className:(0,xt.Z)("message-title-name",Ct?.hiddenUserName?"sender-hidden":"interactive",void 0),onClick:Zs,dir:"ltr"},Gt&&Tt.ZP.createElement(so.Z,{name:Ct?.hiddenUserName?"forward":"share-filled"}),ia&&Tt.ZP.createElement(so.Z,{name:"play-story"}),t?(0,ga.Z)(t):Gt?" ":void 0,!Gt&&a&&Tt.ZP.createElement(Ws.Z,{documentId:a.documentId,loopLimit:n.y3O,observeIntersectionForLoading:s,observeIntersectionForPlaying:i}),!Gt&&!a&&o&&Tt.ZP.createElement(Ys.Z,null),is?.fakeType&&Tt.ZP.createElement(no.Z,{fakeType:is.fakeType})):B?void 0:" ",B&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("span",{className:"via"},nt("ViaBot")),Tt.ZP.createElement("span",{className:"interactive",onClick:Ss},(0,ga.Z)(`@${B.usernames[0].username}`))),Tt.ZP.createElement("div",{className:"title-spacer"}),Ct?.isLinkedChannelPost?Tt.ZP.createElement("span",{className:"admin-title",dir:"auto"},nt("DiscussChannel")):e.forwardInfo?.postAuthorTitle&&ie&&Gt?Tt.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.forwardInfo?.postAuthorTitle):e.postAuthorTitle&&ie&&!Gt?Tt.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.postAuthorTitle):!Ae||Gt||Mt?void 0:Tt.ZP.createElement("span",{className:"admin-title",dir:"auto"},Ae.customTitle||nt(Ae.isOwner?"GroupInfo.LabelOwner":"GroupInfo.LabelAdmin")),Boolean(Ve)&&Tt.ZP.createElement("span",{className:"sender-boosts","aria-hidden":!0},Tt.ZP.createElement(so.Z,{name:Ve>1?"boosts":"boost"}),Ve>1?Ve:void 0))}const Ka=ie&&Gt?e.postAuthorTitle:void 0;return Tt.ZP.createElement("div",{ref:et,id:(0,v.d0)(e.id),className:Gs,"data-message-id":Zt,onCopy:K?yn.Z:void 0,onMouseDown:ds,onClick:ls,onContextMenu:us,onDoubleClick:ms,onMouseEnter:Kt?ys:void 0,onMouseMove:Ca?ps:void 0,onMouseLeave:Ca||Kt?fs:void 0},Tt.ZP.createElement("div",{ref:tt,className:"bottom-marker","data-message-id":Zt,"data-last-message-id":d?d.messages[d.messages.length-1].id:void 0,"data-album-main-id":d?d.mainMessage.id:void 0,"data-has-unread-mention":e.hasUnreadMention||void 0,"data-has-unread-reaction":Te||void 0,"data-is-pinned":Ze||void 0,"data-should-update-views":void 0!==e.viewsCount}),!$&&Tt.ZP.createElement("div",{className:"message-select-control"},pe&&Tt.ZP.createElement("i",{className:"icon icon-select"})),P&&Tt.ZP.createElement("div",{className:(0,xt.Z)("message-select-control group-select",ge&&"is-selected"),onClick:Ds},ge&&Tt.ZP.createElement("i",{className:"icon icon-select"})),u&&function(){const e=!ns&&Ct?Ct.hiddenUserName:void 0;return Tt.ZP.createElement(Yn.Z,{size:lt?"small-mobile":"small",peer:ns,text:e,onClick:ns?Ps:void 0})}(),Tt.ZP.createElement("div",{className:(0,xt.Z)("message-content-wrapper",Ma.includes("text")&&"can-select-text")},Tt.ZP.createElement("div",{className:Ma,style:qa,dir:"auto"},Gt&&!zt&&Tt.ZP.createElement(Tt.ZP.Fragment,null,za(),Ka&&Tt.ZP.createElement("span",{className:"admin-title",dir:"auto"},Ka)),function(){const t=(0,xt.Z)("content-inner",Gt&&"forwarded-message",es&&"with-subheader",ja&&"no-media-corners"),a=b&&!rs&&!Gt&&!Sa,n=(0,xt.Z)("text-content","clearfix","in-text"===ka&&"with-meta",H&&"with-outgoing-icon"),o=!cs||!kt||se;return Tt.ZP.createElement("div",{className:t,onDoubleClick:hs,dir:"auto"},!Gt&&za(),es&&Tt.ZP.createElement("div",{className:"message-subheader"},xe&&Tt.ZP.createElement(mo,{topic:Be,onClick:js,className:"message-topic"}),At&&Tt.ZP.createElement(eo.Z,{message:_,replyInfo:Bt,noUserColors:Qt,isProtected:K,sender:O,senderChat:D,forwardSender:F,chatTranslations:Ue,requestedChatTranslationLanguage:Fe,observeIntersectionForLoading:s,observeIntersectionForPlaying:i,onClick:Cs}),Lt&&Tt.ZP.createElement(ao,{story:j,sender:G,noUserColors:Qt,isProtected:K,observeIntersectionForLoading:s,onClick:qs})),Xs&&Tt.ZP.createElement(ki,{message:e,observeIntersection:s,observeIntersectionForPlaying:i,shouldLoop:Ee,shouldPlayEffect:Xs.hasEffect&&(Ne.current&&Zt>=Ne.current||Rt)||void 0,withEffect:De,onPlayEffect:ct,onStopEffect:dt}),Ft&&le&&Tt.ZP.createElement(Po,{customEmojiId:le,withEffects:De&&(0,v.YC)(St),isOwn:kt,observeIntersection:s,forceLoadPreview:Rt,messageId:Zt,chatId:St,activeEmojiInteractions:be}),Ft&&de&&Tt.ZP.createElement(So,{emoji:de,withEffects:De&&(0,v.YC)(St),isOwn:kt,observeIntersection:s,forceLoadPreview:Rt,messageId:Zt,chatId:St,activeEmojiInteractions:be}),Vt&&Tt.ZP.createElement(vo,{album:d,albumLayout:_a,observeIntersection:s,isOwn:kt,isProtected:K,hasCustomAppendix:a,onMediaClick:Rs}),Pa&&Tt.ZP.createElement(li,{message:e,phoneCall:Pa,chatId:St}),!Vt&&Vs&&Tt.ZP.createElement(po.Z,{message:e,observeIntersection:s,noAvatars:l,canAutoLoad:Ce,uploadProgress:V,shouldAffectAppendix:a,isDownloading:Se,isProtected:K,asForwarded:Gt,theme:R,forcedWidth:Da,onClick:Ms,onCancelUpload:Bs}),!Vt&&$s&&$s.isRound&&Tt.ZP.createElement(Ei.Z,{message:e,observeIntersection:s,canAutoLoad:Ce,isDownloading:Se,onReadMedia:o?As:void 0}),!Vt&&$s&&!$s.isRound&&Tt.ZP.createElement(go.Z,{message:e,observeIntersectionForLoading:s,observeIntersectionForPlaying:i,forcedWidth:Da,noAvatars:l,canAutoLoad:Ce,canAutoPlay:Me,uploadProgress:V,isDownloading:Se,isProtected:K,asForwarded:Gt,onClick:Ms,onCancelUpload:Bs}),(zs||Ks)&&Tt.ZP.createElement(Wn.ZP,{theme:R,message:e,origin:c.Cr.Inline,uploadProgress:V,isSelectable:$,isSelected:pe,noAvatars:l,onPlay:Es,onReadMedia:Ks&&o?As:void 0,onCancelUpload:Bs,isDownloading:Se,isTranscribing:Z,isTranscriptionHidden:ot,isTranscribed:Boolean(C),isTranscriptionError:Et,canDownload:!K,onHideTranscription:it,canTranscribe:ze&&!cs}),Js&&Tt.ZP.createElement(Xn.Z,{message:e,observeIntersection:s,canAutoLoad:Ce,autoLoadFileMaxSizeMb:Re,uploadProgress:V,isSelectable:$,isSelected:pe,onMediaClick:Ms,onCancelUpload:Bs,isDownloading:Se,shouldWarnAboutSvg:He}),ia&&!Ht&&Tt.ZP.createElement(Ni,{message:e,isProtected:K}),Ht&&Tt.ZP.createElement(Ai,{message:e}),Qs&&Tt.ZP.createElement(Bo,{contact:Qs,noUserColors:kt}),ea&&Tt.ZP.createElement(wi,{message:e,poll:ea,onSendVote:Us}),(ra||ca)&&Tt.ZP.createElement($o,{message:e}),oa&&Tt.ZP.createElement(Uo,{message:e,canAutoLoadMedia:Ce}),sa?.extendedMedia&&Tt.ZP.createElement(Qo,{message:e,isConnected:qe}),as&&Tt.ZP.createElement("p",{className:(0,xt.Z)("transcription",!ot&&Et&&"transcription-error"),dir:"auto"},Et?nt("NoWordsRecognized"):Z&&C?Tt.ZP.createElement(Qn.Z,{content:C}):C),!Ft&&rs&&Tt.ZP.createElement("div",{className:n,dir:"auto"},Ha(),va&&Tt.ZP.createElement("div",{className:"translation-animation"},Tt.ZP.createElement("div",{className:"text-loading"},Ha(!0))),"in-text"===ka&&$a()),ta&&Tt.ZP.createElement(Bi.Z,{message:e,observeIntersection:s,noAvatars:l,canAutoLoad:Ce,canAutoPlay:Me,asForwarded:Gt,isDownloading:Se,isProtected:K,theme:R,story:je,isConnected:qe,backgroundEmojiId:T?.color?.backgroundEmojiId,shouldWarnAboutSvg:He,autoLoadFileMaxSizeMb:Re,onAudioPlay:Es,onMediaClick:Ms,onCancelMediaTransfer:Bs}),sa&&!sa.extendedMedia&&Tt.ZP.createElement(Wo,{message:e,shouldAffectAppendix:a&&!Dt,isInSelectMode:he,isSelected:pe,theme:R,forcedWidth:Da}),aa&&Tt.ZP.createElement(ii,{message:e,isInSelectMode:he,isSelected:pe,theme:R,peer:T}))}(),!Kt&&"standalone"===ka&&!Ht&&$a(),Wt&&Yt?Tt.ZP.createElement(vs.Z,{className:(0,xt.Z)("message-action-button",z&&"message-action-button-shown"),color:"translucent-white",round:!0,size:"tiny",ariaLabel:nt("lng_context_forward_msg"),onClick:P?Ls:_s},Tt.ZP.createElement("i",{className:"icon icon-share-filled"})):Wt&&Xt?Tt.ZP.createElement(vs.Z,{className:(0,xt.Z)("message-action-button",z&&"message-action-button-shown"),color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:Pe?Os:Fs},Tt.ZP.createElement("i",{className:"icon icon-arrow-right"})):void 0,Sa&&Tt.ZP.createElement(Eo,{threadInfo:ke,disabled:h,isLoading:z,isCustomShape:Ot}),Ea&&Tt.ZP.createElement(ri,{isOwn:kt}),Ca&&"in-content"===Na&&Va()),e.inlineButtons&&Tt.ZP.createElement(zo,{message:e,onClick:We}),"outside"===Ta&&!Ht&&Tt.ZP.createElement(Mi,{message:Ie,isOutside:!0,isCurrentUserPremium:w,maxWidth:Ga,observeIntersection:i,noRecentReactors:oe,tags:$e})),ht&&Tt.ZP.createElement(xo.Z,{isOpen:mt,anchor:ht,targetHref:pt?.matches("a[href]")?pt.href:void 0,message:e,album:d,messageListType:ye,onClose:It,onCloseAnimationEnd:vt,repliesThreadInfo:ke,noReplies:p,detectedLanguage:pa}))}))),_i=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"AboutAdsModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Oi=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return s?Tt.ZP.createElement(s,e):void 0},Fi=(0,Tt.X$)((0,a.c$)(((e,{chatId:t})=>{const s=(0,y.fSe)(e,t),a=s?.chatId?(0,y.Z1J)(e,s?.chatId):void 0,{chatId:n,isBot:o}=s||{};return{message:s,peer:a,bot:n&&o?(0,y.dyD)(e,n):void 0,channel:!o&&n?(0,y.Z1J)(e,n):void 0}}))((({chatId:e,peer:t,message:s,containerRef:n,bot:i,channel:r})=>{const{viewSponsoredMessage:c,openChat:d,openChatByInvite:l,requestAppWebView:u,startBot:m,focusMessage:h,openUrl:p,openPremiumModal:g,clickSponsoredMessage:f}=(0,a.Sv)(),I=(0,Is.Z)(),w=(0,Tt.sO)(null),b=(0,Tt.sO)(null),y=Boolean(s),{observe:P}=(0,gn.S1)({rootRef:n,debounceMs:200,threshold:1}),{isContextMenuOpen:Z,contextMenuPosition:S,handleBeforeContextMenu:C,handleContextMenu:M,handleContextMenuClose:E,handleContextMenuHide:R}=(0,Ia.Z)(w,o.$b,!0,o.wZ),[k,T,N]=(0,xs.Z)(!1),{isMobile:A}=(0,x.ZP)(),B=Boolean(s?.isAvatarShown&&t),U=Boolean(s?.botApp);(0,Tt.d4)((()=>y?P(b.current,(t=>{t.isIntersecting&&c({chatId:e})})):void 0),[e,y,P,c]);const L=(0,qt.Z)((()=>{t&&d({id:t.id})})),_=(0,qt.Z)((t=>(t.preventDefault(),f({chatId:e}),p({url:s.webPage.url,shouldSkipModal:!0}),!1))),O=(0,qt.Z)((()=>{g()})),F=(0,qt.Z)((()=>{if(s)if(f({chatId:e}),U){const{shortName:e}=s.botApp,t=(0,Se.BS)();u({botId:s.chatId,appName:e,startApp:s.startParam,theme:t})}else s.chatInviteHash?l({hash:s.chatInviteHash}):s.channelPostId?h({chatId:s.chatId,messageId:s.channelPostId}):(d({id:s.chatId}),s.startParam&&m({botId:s.chatId,param:s.startParam}))}));if(!s)return;const D=(0,xt.Z)("message-content has-shadow has-solid-background has-appendix",(0,Pn.D)(i||t||r));return Tt.ZP.createElement("div",{ref:w,key:"sponsored-message",className:(0,xt.Z)("SponsoredMessage Message open",B&&"with-avatar")},B&&Tt.ZP.createElement(Yn.Z,{size:A?"small-mobile":"small",peer:t,onClick:t?L:void 0}),Tt.ZP.createElement("div",{className:D,dir:"auto",onMouseDown:e=>{(0,sn.q)(e),C(e)},onContextMenu:M},Tt.ZP.createElement("div",{className:"content-inner",dir:"auto"},function(){if(s?.botApp){if(!s.botApp.photo)return;return Tt.ZP.createElement(Yn.Z,{size:"large",peer:i,photo:s.botApp.photo,className:(0,xt.Z)("channel-avatar",I.isRtl&&"is-rtl")})}if(r)return Tt.ZP.createElement(Yn.Z,{size:"large",peer:r,className:(0,xt.Z)("channel-avatar",I.isRtl&&"is-rtl")})}(),Tt.ZP.createElement("span",{className:"message-title message-type"},s.isRecommended?I("Message.RecommendedLabel"):I("SponsoredMessage")),function(){if(s?.webPage)return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:"text-content with-meta",dir:"auto",ref:b},Tt.ZP.createElement("div",{className:"message-title message-peer",dir:"ltr"},(0,ga.Z)(s.webPage.siteName)),Tt.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,ui.H)({text:s.text.text,entities:s.text.entities}))),Tt.ZP.createElement(vs.Z,{className:"SponsoredMessage__button",size:"tiny",color:"translucent",isRectangular:!0,onClick:_},Tt.ZP.createElement("i",{className:"icon icon-arrow-right","aria-hidden":!0}),I("OpenLink")));const e=s?.buttonText??(U?I("BotWebAppInstantViewOpen"):s.isBot?I("Conversation.ViewBot"):I(s.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")),t=U?s.botApp.title:i?(0,ga.Z)((0,v.Js)(i)||""):r?(0,ga.Z)(s.chatInviteTitle||(0,v.U)(I,r)||""):"";return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:"message-title message-peer",dir:"auto"},t),Tt.ZP.createElement("div",{className:"text-content with-meta",dir:"auto",ref:b},Tt.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,ui.H)({text:s.text.text,entities:s.text.entities}))),Tt.ZP.createElement(vs.Z,{className:"SponsoredMessage__button",size:"tiny",color:"translucent",isRectangular:!0,onClick:F},e))}()),Tt.ZP.createElement(ri,null),Tt.ZP.createElement(vs.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:I("Close"),onClick:O},Tt.ZP.createElement("i",{className:"icon icon-close","aria-hidden":!0}))),S&&Tt.ZP.createElement(Oi,{isOpen:Z,anchor:S,message:s,onAboutAds:T,onClose:E,onCloseAnimationEnd:R}),Tt.ZP.createElement(_i,{isOpen:k,onClose:N}))}))),Di=(0,Tt.X$)((({isCurrentUserPremium:e,chatId:t,threadId:s,messageIds:i,messageGroups:d,getContainerHeight:l,isViewportNewest:u,isUnread:m,isComments:p,isEmptyThread:g,withUsers:I,isChannelChat:w,noAvatars:b,containerRef:y,anchorIdRef:P,memoUnreadDividerBeforeIdRef:Z,memoFirstUnreadIdRef:S,type:C,isReady:M,hasLinkedChat:E,isSchedule:R,shouldRenderBotInfo:k,noAppearanceAnimation:T,isSavedDialog:N,onFabToggle:A,onNotchToggle:B,onPinnedIntersectionChange:U})=>{const{openHistoryCalendar:L}=(0,a.Sv)(),_=(0,pn.Z)(M),O=!N&&!R,{observeIntersectionForReading:F,observeIntersectionForLoading:D,observeIntersectionForPlaying:j}=function(e,t,s,n,o){const{markMessageListRead:i,markMentionsRead:r,animateUnreadReaction:c,scheduleForViewsIncrement:d}=(0,a.Sv)(),{isMobile:l}=(0,x.ZP)(),u=l?300:500,{observe:m,freeze:h,unfreeze:p}=(0,gn.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e||(0,Kt.q)())return;let a=0;const l=[],u=[],m=[],h=[],p=[];let g=!1;t.forEach((e=>{const{isIntersecting:t,target:s,boundingClientRect:n,rootBounds:o}=e,{dataset:i}=s,r=Number(i.lastMessageId||i.messageId),c="true"===i.shouldUpdateViews,d=i.albumMainId?Number(i.albumMainId):void 0;t?(r>a&&(a=r),i.hasUnreadMention&&l.push(r),i.hasUnreadReaction&&u.push(r),i.isPinned&&m.push(d||r),c&&p.push(d||r)):i.isPinned&&(o&&n.bottom<o.top&&(g=!0),h.push(d||r))})),s.current&&a>=s.current&&i({maxId:a}),l.length&&r({messageIds:l}),u.length&&c({messageIds:u}),(m.length||h.length)&&n({viewportPinnedIdsToAdd:m,viewportPinnedIdsToRemove:h,isReversed:g}),p.length&&d({chatId:o,ids:p})}));(0,Kt.Z)(h,p);const{observe:g}=(0,gn.S1)({rootRef:t,throttleMs:fn,margin:u}),{observe:f}=(0,gn.S1)({rootRef:t,throttleMs:fn});return{observeIntersectionForReading:m,observeIntersectionForLoading:g,observeIntersectionForPlaying:f}}(C,y,S,U,t),{withHistoryTriggers:q,backwardsTriggerRef:G,forwardsTriggerRef:H,fabTriggerRef:V}=function(e,t,s,n,i,r,d,l,u){const{loadViewportMessages:m}=(0,a.Sv)(),[h,p]=(0,Tt.Ye)((()=>"thread"===e?[(0,f.Ds)((()=>m({direction:c.Uq.Backwards})),1e3,!0,!1),(0,f.Ds)((()=>m({direction:c.Uq.Forwards})),1e3,!0,!1)]:[]),[m,s]),g=(0,Tt.sO)(null),I=(0,Tt.sO)(null),v=(0,Tt.sO)(null),w=(0,qt.Z)((()=>{if(!u)return;if(!s?.length)return d(!1),void l(!1);if(!i)return d(!0),void l(!0);const e=t.current;if(!e)return;const{offsetHeight:a,scrollHeight:n,scrollTop:o}=e,c=Math.round(n-o-a),m=c<=1;0!==n&&(d(r?!m:!(c<=50)),l(!m))})),{observe:b}=(0,gn.S1)({rootRef:t,margin:o.gZ},(e=>{p&&h&&e.forEach((({isIntersecting:e,target:t})=>{e&&("backwards-trigger"===t.className&&h(),"forwards-trigger"===t.className&&p())}))})),y=s&&s.length>1;(0,gn._N)(g,y?b:void 0),(0,gn._N)(I,y?b:void 0);const{observe:P,freeze:Z,unfreeze:S}=(0,gn.S1)({rootRef:t,margin:100,throttleScheduler:Bt.i$},w);(0,gn._N)(v,P);const{observe:C,freeze:M,unfreeze:E}=(0,gn.S1)({rootRef:t,margin:1,throttleScheduler:Bt.i$},w);(0,gn._N)(v,C),(0,Tt.d4)((()=>{u&&w()}),[u,w]);const R=(0,qt.Z)((()=>{Z(),M(),setTimeout((()=>{E(),S()}),350)}));(0,zt.Z)(R,[R,s]);const k=(0,In.Vr)(n,200);return(0,vn.b)(R,[R,k]),{withHistoryTriggers:y,backwardsTriggerRef:g,forwardsTriggerRef:I,fabTriggerRef:v}}(C,y,i,l,u,m,A,B,M),$=(0,Is.Z)(),z=Tt.ZP.createElement("div",{className:(0,xt.Z)("unread-divider","local-action-message"),key:"unread-messages"},Tt.ZP.createElement("span",null,$("UnreadMessages"))),K=T?0:d.reduce(((e,t)=>e+t.senderGroups.flat().length),0);let J=0;const W=(0,La.Z)(i),Y=Boolean(i&&W&&i[i.length-2]===W[W.length-1]),X=d.map(((e,t,a)=>{const o=e.senderGroups.map(((e,n,o)=>{if(1===e.length&&!en(e[0])&&(0,v.FT)(e[0])&&!e[0].content.action?.phoneCall){const i=e[0],c=n===o.length-1&&t===a.length-1;return(0,h.oA)([i.id===Z.current&&z,Tt.ZP.createElement(wn.Z,{key:i.id,message:i,threadId:s,messageListType:C,isInsideTopic:Boolean(s&&s!==r._f&&!N),observeIntersectionForReading:F,observeIntersectionForLoading:D,observeIntersectionForPlaying:j,memoFirstUnreadIdRef:S,appearanceOrder:K-++J,isJustAdded:c&&Y,isLastInList:c,onPinnedIntersectionChange:U})])}let i;return e.map(((c,d)=>{const l=en(c)?c.mainMessage:c,u=en(c)?c:void 0,m=(0,v.B4)(l),f=en(c),y=e[d+1];l.previousLocalId&&P.current===(0,v.d0)(l.previousLocalId)&&(P.current=(0,v.d0)(l.id));const M=!f&&l.groupedId?l.groupedId:void 0,R=y&&!en(y)?y.groupedId:void 0,k=l.id===s,T={isFirstInGroup:0===d,isLastInGroup:d===e.length-1,isFirstInDocumentGroup:Boolean(M&&M!==i),isLastInDocumentGroup:Boolean(M&&M!==R),isLastInList:d===e.length-1&&n===o.length-1&&t===a.length-1};i=M;const N=(0,v.KK)(l),A=(0,v.jM)(l)?`${l.date}_${N}`:N,B=!1===E||!w;return(0,h.oA)([l.id===Z.current&&z,Tt.ZP.createElement(Li,{key:A,message:l,observeIntersectionForBottom:F,observeIntersectionForLoading:D,observeIntersectionForPlaying:j,album:u,noAvatars:b,withAvatar:T.isLastInGroup&&I&&!m&&(!k||!p),withSenderName:T.isFirstInGroup&&I&&!m,threadId:s,messageListType:C,noComments:B,noReplies:!B||s!==r._f||"scheduled"===C,appearanceOrder:K-++J,isJustAdded:T.isLastInList&&Y,isFirstInGroup:T.isFirstInGroup,isLastInGroup:T.isLastInGroup,isFirstInDocumentGroup:T.isFirstInDocumentGroup,isLastInDocumentGroup:T.isLastInDocumentGroup,isLastInList:T.isLastInList,memoFirstUnreadIdRef:S,onPinnedIntersectionChange:U,getIsMessageListReady:_}),l.id===s&&Tt.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},Tt.ZP.createElement("span",null,$(g?p?"NoComments":"NoReplies":"DiscussionStarted")))])})).flat()}));return Tt.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:sn.q,teactFastList:!0},Tt.ZP.createElement("div",{className:(0,xt.Z)("sticky-date",O&&"interactive"),key:"date-header",onMouseDown:sn.q,onClick:O?()=>L({selectedAt:e.datetime}):void 0},Tt.ZP.createElement("span",{dir:"auto"},R&&e.originalDate===n.t4X&&$("MessageScheduledUntilOnline"),R&&e.originalDate!==n.t4X&&$("MessageScheduledOn",(0,ce.j1)($,e.datetime,void 0,!0)),!R&&(0,ce.j1)($,e.datetime))),o.flat())}));return Tt.ZP.createElement("div",{className:"messages-container",teactFastList:!0},q&&Tt.ZP.createElement("div",{ref:G,key:"backwards-trigger",className:"backwards-trigger"}),k&&Tt.ZP.createElement(hn,{isInMessageList:!0,key:`bot_info_${t}`,chatId:t}),X.flat(),!e&&u&&Tt.ZP.createElement(Fi,{key:t,chatId:t,containerRef:y}),q&&Tt.ZP.createElement("div",{ref:H,key:"forwards-trigger",className:"forwards-trigger"}),Tt.ZP.createElement("div",{ref:V,key:"fab-trigger",className:"fab-trigger"}))})),ji=3*M.Gw,qi=(0,Tt.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s,topic:a})=>{const n=(0,Is.Z)();return"scheduled"===t?function(e){return Tt.ZP.createElement("div",{className:"empty"},Tt.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(n):e?function(e){return Tt.ZP.createElement("div",{className:"NoMessages"},Tt.ZP.createElement("div",{className:"wrapper"},Tt.ZP.createElement("i",{className:"icon no-messages-icon icon-cloud-download"}),Tt.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),Tt.ZP.createElement("ul",{className:"description"},Tt.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),Tt.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),Tt.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),Tt.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(n):s?function(e){return Tt.ZP.createElement("div",{className:"NoMessages"},Tt.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},Tt.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),Tt.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),Tt.ZP.createElement("ul",{className:"list-checkmarks"},Tt.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),Tt.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),Tt.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),Tt.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(n):a?function(e,t){return Tt.ZP.createElement("div",{className:"NoMessages"},Tt.ZP.createElement("div",{className:"wrapper"},Tt.ZP.createElement(co.Z,{topic:t,size:ji,className:"no-messages-icon topic-icon"}),Tt.ZP.createElement("h3",{className:"title"},e("Chat.EmptyTopicPlaceholder.Title")),Tt.ZP.createElement("p",{className:"description topic-description"},(0,ga.Z)(e("Chat.EmptyTopicPlaceholder.Text"),["br"]))))}(n,a):Tt.ZP.createElement("div",{className:"empty"},Tt.ZP.createElement("span",null,n("NoMessages")))})),Gi=(0,Tt.X$)((0,a.c$)(((e,{userId:t})=>{const s=(0,y.Puy)(e),{patternColor:a}=e.settings.themes[s]||{},n=(0,y.dyD)(e,t);return{patternColor:a,userName:(0,v.Vl)(n)}}))((function({patternColor:e,userName:t}){const s=(0,Is.Z)(),{openPremiumModal:n}=(0,a.Sv)(),o=(0,qt.Z)((()=>n()));return Tt.ZP.createElement("div",{className:"tFp81o13"},Tt.ZP.createElement("div",{className:"xzZFmIqC"},Tt.ZP.createElement("div",{className:"vyeCoKP3"},Tt.ZP.createElement(Oo.Z,{tgsUrl:_o.l.Unlock,size:54,color:e,className:"YVmR5pRi"}),Tt.ZP.createElement(so.Z,{name:"comments-sticker",className:"ouB5dgHN"})),Tt.ZP.createElement("span",{className:"oEQISdJD"},(0,ga.Z)(s("MessageLockedPremium",t),["simple_markdown"])),Tt.ZP.createElement(vs.Z,{color:"translucent-black",size:"tiny",onClick:o,className:"KJVF1etk"},s("MessagePremiumUnlock"))))}))),Hi=(0,f.Ds)((e=>e()),200,!1),Vi=(0,Tt.X$)((0,a.c$)(((e,{chatId:t,threadId:s,type:a})=>{const o=e.currentUserId,i=(0,y.Z1J)(e,t);if(!i)return{currentUserId:o};const c=(0,y.$Wy)(e,t,s,a),d="scheduled"===a?(0,y.yBV)(e,t):(0,y.Zwk)(e,t),l=(0,v._o)(t,s,o);if(!(s===r._f||l||i?.isForum||d&&s&&d[Number(s)]))return{currentUserId:o};const{isRestricted:u,restrictionReason:m}=i,h=(0,y._If)(e,t,l?"saved":"all"),p=(0,y.G$N)(e,t),g=s===r._f&&!c&&!i.unreadCount&&!p&&h&&!h.groupedId,f=(0,y.kBx)(e,t),I=i.topics?.[s],w=(0,v.YC)(t)?void 0:(0,y.x67)(e,t),b=!(0,y.tZg)(e,t,s)?.messagesCount;return{isCurrentUserPremium:(0,y.wVz)(e),isChatLoaded:!0,isRestricted:u,restrictionReason:m,isChannelChat:(0,v.eA)(i),isGroupChat:(0,v.Bf)(i),isCreator:i.isCreator,isChatWithSelf:(0,y.FM1)(e,t),isRepliesChat:(0,v.pK)(t),isAnonymousForwards:(0,v.wo)(t),isBot:Boolean(f),isSynced:e.isSynced,messageIds:c,messagesById:d,firstUnreadId:(0,y.It8)(e,t,s),isViewportNewest:"thread"!==a||(0,y.b9T)(e,t,s),focusingId:p,isSelectModeActive:(0,y.CAb)(e),hasLinkedChat:w?Boolean(w.linkedChatId):void 0,topic:I,noMessageSendingAnimation:!(0,y.$Yd)(e,"messageSendingAnimations"),isServiceNotificationsChat:t===n.awM,isForum:i.isForum,isEmptyThread:b,currentUserId:o,...g&&{lastMessage:h}}}))((({chatId:e,threadId:t,type:s,hasTools:o,onFabToggle:i,onNotchToggle:d,isCurrentUserPremium:l,isChatLoaded:u,isForum:m,isChannelChat:p,isGroupChat:I,canPost:w,isSynced:b,isReady:P,isChatWithSelf:Z,isRepliesChat:S,isAnonymousForwards:C,isCreator:M,isBot:E,messageIds:R,messagesById:k,firstUnreadId:T,isComments:N,isViewportNewest:A,isRestricted:B,restrictionReason:x,isEmptyThread:U,focusingId:L,isSelectModeActive:_,lastMessage:O,hasLinkedChat:F,withBottomShift:D,withDefaultBg:j,topic:q,noMessageSendingAnimation:G,isServiceNotificationsChat:H,currentUserId:V,getForceNextPinnedInHeader:$,onPinnedIntersectionChange:z,isContactRequirePremium:K})=>{const{loadViewportMessages:J,setScrollOffset:W,loadSponsoredMessages:Y,loadMessageReactions:X,copyMessagesByIds:Q,loadMessageViews:ee,loadPeerStoriesByIds:te}=(0,a.Sv)(),se=(0,Tt.sO)(null),ae=(0,Tt.sO)("thread"===s&&(0,y.Vtl)((0,a.Rd)(),e,t)||(0,y.T6o)((0,a.Rd)(),e,t)||0),ne=(0,Tt.sO)(),oe=(0,Tt.sO)(),ie=(0,Tt.sO)(),re=(0,Tt.sO)(),ce=(0,Tt.sO)(),de=(0,Tt.sO)(),le=(0,Tt.sO)(!1),ue=(0,Tt.sO)(Boolean(O)),me=(0,v._o)(e,t,V),he=me&&t!==n.tKb,pe=Boolean(R);(0,zt.Z)((()=>{pe&&(0,f.R3)((()=>{ue.current=!1}))}),[pe]),(0,zt.Z)((()=>{re.current=T}),[T]),(0,Tt.d4)((()=>{!l&&p&&b&&P&&Y({chatId:e})}),[l,e,b,P,p]),(0,zt.Z)((()=>{pe&&(ce.current=re.current)}),[pe]),(0,zt.Z)((()=>{de.current=L}),[L]),(e=>{(0,us.y)({"Mod+C":function(t){const s=(0,nn.Z)();s&&s.length>1&&(t.preventDefault(),e({messageIds:s}))}})})(Q);const ge=(0,Tt.Ye)((()=>{if(!R?.length||!k)return;const e=R.map((e=>k[e])).filter(Boolean),a="scheduled"===s||H?["date","id"]:["id"];return e.length?tn((0,h.Xo)(e,a),ce.current,m?void 0:Number(t),Z):void 0}),[R,k,s,H,m,t,Z]);(0,Ot.Z)((()=>{if(!R||!k||"scheduled"===s)return;if(!p&&!I)return;const t=R.filter((e=>{const t=k[e];return t&&t.reactions?.results.length&&!t.content.action}));t.length&&X({chatId:e,ids:t})}),2e4,!0),(0,Ot.Z)((()=>{if(!R||!k||"scheduled"===s)return;const e=R.map((e=>k[e]?.content.storyData)).filter(Boolean);if(!e.length)return;const t=e.reduce(((e,t)=>{const{peerId:s,id:a}=t;return e[s]||(e[s]=[]),e[s].push(a),e}),{});Object.entries(t).forEach((([e,t])=>{te({peerId:e,storyIds:t})}))}),3e5),(0,Ot.Z)((()=>{if(!R||!k||t!==r._f||"scheduled"===s)return;const n=(0,a.Rd)(),o=R.filter((t=>(0,y.tZg)(n,e,t)?.isCommentsInfo||void 0!==k[t]?.viewsCount));o.length&&ee({chatId:e,ids:o})}),2e4,!0);const fe=(0,Tt.Ye)((()=>{if("thread"===s)return(0,f.Ds)((()=>J({direction:c.Uq.Around})),1e3,!0,!1)}),[J,R]),{isScrolled:Ie,updateStickyDates:ve}=function(){const[e,t]=(0,xs.Z)(!1),s=(0,rn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,qt.Z)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,Bt.WM)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{const t=function(e,t){const s=e.querySelectorAll(".sticky-date"),a=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:n}=e,o=s-a;return-n<=o&&o<=(t?60:10)}))}(e,a);t&&(0,Bt.WM)((()=>{t.classList.add("stuck")})),(0,Bt.WM)((()=>{const e=document.querySelector(".stuck");e&&e.classList.remove("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}))}}(),we=(0,qt.Z)((()=>{if(le.current)return void(le.current=!1);const n=se.current;n&&(de.current||ve(n,o),Hi((()=>{const o=(0,a.Rd)();$()&&!(0,y.jUK)(o).focusedMessage?.chatId&&z({hasScrolled:!0}),n.parentElement&&(ae.current=n.scrollHeight-n.scrollTop,"thread"===s&&W({chatId:e,threadId:t,scrollOffset:ae.current}))})))})),[be,ye]=function(e,t){const[s,a]=(0,Da.Z)(),n=(0,qt.Z)((e=>{a(e.contentRect.height)}));(0,on.Z)(e,n),(0,Tt.d4)((()=>{const a=Number(e.current.dataset.normalHeight)||0,n=s();n&&n>a&&t&&(e.current.dataset.normalHeight=String(n))}),[t,e,s]);const o=(0,Tt.sO)();return[s,o]}(se,w&&!_);(0,Tt.d4)((()=>{if(!fe||!u||B||L)return;if(R&&(0,g.AJ)(R[R.length-1]))return;const e=se.current;(!R||R.length<n.hT6/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&fe()}),[u,R,fe,L,B]);const Pe=(0,ms.Y)((()=>{if(!R||!ie.current)return;const e=ie.current.filter((e=>R.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(ne.current=t.id,oe.current=t.getBoundingClientRect().top)}));(0,zt.Z)((()=>(0,Bt.yn)((()=>Pe.current()))),[R,A,o,Pe]),(0,Tt.d4)((()=>Pe.current()),[be,Pe]),(0,an.Z)((([e,t])=>{const s=be(),a=ye.current;if(ye.current=s,R===e&&A===t&&s!==a&&void 0===a)return;const i=se.current;ie.current=Array.from(i.querySelectorAll(".message-list-item"));const r=ie.current[ie.current.length-1],c=re.current?i.querySelector(`#${(0,v.d0)(re.current)}`):void 0,d=R&&e&&R[R.length-1]!==e[e.length-1],l=R?.[0]!==e?.[0]&&R?.length===n.hT6/2+1,u=d&&!l;A&&u&&R&&R.length<n.hT6/2&&!i.parentElement.classList.contains("force-messages-scroll")&&(0,Bt.yn)((()=>i.firstElementChild.clientHeight<=2*i.offsetHeight))&&((0,Nt.D_)(i.parentElement,"force-messages-scroll"),i.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{i.parentElement&&(0,Nt.mC)(i.parentElement,"force-messages-scroll")}),500)),(0,Bt.lT)((()=>{const{scrollTop:e,scrollHeight:n,offsetHeight:d}=i,l=ae.current;let m=l-(a||d);u&&(m-=r?r.offsetHeight:0);const h=A&&t&&m<=50,p=R&&de.current===R[R.length-1];u&&h&&!p&&(0,Bt.i$)((()=>{const e=!(0,Kt.q)()||!c;(0,Ja.ZP)(i,e?r:c,e?"end":"start",20,void 0,void 0,G?0:void 0)}));const g=void 0!==a&&a!==s;if(g&&(0,Ja.Ni)())return;const f=ne.current&&i.querySelector(`#${ne.current}`),I=!f&&ce.current&&i.querySelector(".unread-divider");let v;if(h&&g)v=n-d;else if(f){const t=f.getBoundingClientRect().top;v=e+(t-(oe.current||0))}else v=I?Math.min(I.offsetTop-(o?60:10),n-l):n-l;return()=>{(0,Qa.Z)(i,Math.ceil(v)),(0,Ja.wA)(),ae.current=Math.max(Math.ceil(n-v),d),de.current||(le.current=!0,(0,Bt.i$)((()=>{le.current=!1})))}}))}),[R,A,o,be,ye,G]),(0,Js.Z)((([e])=>{void 0!==e&&(0,jt.YW)(200+n.fK3)}),[_]);const Ze=Boolean(e&&(0,v.YC)(e)),Se=Boolean(!Ze&&!p||Z||S||C),Ce=Boolean(!Se||p),Me=(0,v.YC)(e)&&!Z&&!E&&!C&&(!ge&&!O&&R&&(!ie.current||0===ie.current.length)||1===R?.length&&"contactSignUp"===k?.[R[0]]?.content.action?.type||"contactSignUp"===O?.content?.action?.type),Ee=I&&M&&1===R?.length&&"chatCreate"===k?.[R[0]]?.content.action?.type,Re=1===R?.length&&"topicCreate"===k?.[R[0]]?.content.action?.type,ke=(0,xt.Z)("MessageList custom-scroll",Ce&&"no-avatars",!w&&"no-composer","pinned"===s&&"type-pinned",D&&"with-bottom-shift",j&&"with-default-bg",_&&"select-mode-active",Ie&&"scrolled",!P&&"is-animating",he&&"saved-dialog"),Te=R&&ge||O;return Tt.ZP.createElement("div",{ref:se,className:ke,onScroll:we,onMouseDown:sn.q},B?Tt.ZP.createElement("div",{className:"empty"},Tt.ZP.createElement("span",null,x?x.text:"This is a private "+(p?"channel":"chat"))):K?Tt.ZP.createElement(Gi,{userId:e}):E&&!Te?Tt.ZP.createElement(hn,{chatId:e}):Me?Tt.ZP.createElement(dn,{key:e,userId:e}):R&&(!ge||Ee||Re)?Tt.ZP.createElement(qi,{chatId:e,topic:q,type:s,isChatWithSelf:Z,isGroupChatJustCreated:Ee}):Te?Tt.ZP.createElement(Di,{isCurrentUserPremium:l,chatId:e,isComments:N,isChannelChat:p,isSavedDialog:me,messageIds:R||[O.id],messageGroups:ge||tn([O]),getContainerHeight:be,isViewportNewest:Boolean(A),isUnread:Boolean(T),isEmptyThread:U,withUsers:Se,noAvatars:Ce,containerRef:se,anchorIdRef:ne,memoUnreadDividerBeforeIdRef:ce,memoFirstUnreadIdRef:re,threadId:t,type:s,isReady:P,hasLinkedChat:F,isSchedule:!!ge&&"scheduled"===s,shouldRenderBotInfo:E,noAppearanceAnimation:!ge||!ue.current,onFabToggle:i,onNotchToggle:d,onPinnedIntersectionChange:z}):Tt.ZP.createElement(ps.Z,{color:"white",backgroundColor:"dark"}))}))),$i=e=>{const{isActive:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"MessageSelectToolbar",!t);return s?Tt.ZP.createElement(s,e):void 0};var zi=s(18360),Ki=s(86203),Ji=s(4794),Wi=s(98799),Yi=s(6058),Xi=s(14605);const Qi=(0,Tt.X$)((0,a.c$)(((e,{chatId:t})=>({currentUserId:e.currentUserId,chat:(0,y.Z1J)(e,t),user:(0,y.dyD)(e,t)})))((({chatId:e,className:t,chat:s,user:n,settings:o,currentUserId:i})=>{const{openAddContactDialog:r,blockUser:c,reportSpam:d,deleteChat:l,leaveChannel:u,deleteChatUser:m,deleteHistory:h,toggleChatArchived:p,hideChatReportPanel:g}=(0,a.Sv)(),f=(0,Is.Z)(),[I,w,b]=(0,xs.Z)(),[y,P]=(0,Tt.eJ)(!0),[Z,S]=(0,Tt.eJ)(!0),{isAutoArchived:C,canReportSpam:M,canAddContact:E,canBlockContact:R}=o||{},k=s&&(0,v.G9)(s),T=(0,qt.Z)((()=>{r({userId:e}),C&&p({id:e})})),N=(0,qt.Z)((()=>{b(),c({userId:e}),M&&y&&d({chatId:e}),Z&&l({chatId:e})})),A=(0,qt.Z)((()=>{g({chatId:e})})),B=(0,qt.Z)((()=>{b(),d({chatId:e}),k?(m({chatId:e,userId:i}),h({chatId:e,shouldDeleteForAll:!1})):u({chatId:e})}));if(o&&(s||n))return Tt.ZP.createElement("div",{className:(0,xt.Z)("ChatReportPanel",t),dir:f.isRtl?"rtl":void 0},E&&Tt.ZP.createElement(vs.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:T},f("lng_new_contact_add")),R&&Tt.ZP.createElement(vs.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:w},f("lng_new_contact_block")),M&&!R&&Tt.ZP.createElement(vs.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:w},f("lng_report_spam_and_leave")),Tt.ZP.createElement(vs.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:A,ariaLabel:f("Close")},Tt.ZP.createElement("i",{className:"icon icon-close"})),Tt.ZP.createElement(Fo.Z,{isOpen:I,onClose:b,title:f("BlockUserTitle",n?(0,v.Vl)(n):(0,v.U)(f,s)),text:n?f("UserInfo.BlockConfirmationTitle",(0,v.Js)(n)):f("Chat.Confirm.ReportSpam.Channel"),confirmIsDestructive:!0,confirmLabel:f("Block"),confirmHandler:n?N:B},n&&Tt.ZP.createElement(Xi.Z,{label:f("DeleteThisChat"),checked:Z,onCheck:S}),n&&M&&Tt.ZP.createElement(Xi.Z,{label:f("ReportChat"),checked:y,onCheck:P})))})));var er=s(59188),tr=s(2903),sr=s(45370);const ar={"pinned-message-border":"L5TQCriM",pinnedMessageBorder:"L5TQCriM","pinned-message-border-wrapper-1":"v5sJGzfS",pinnedMessageBorderWrapper1:"v5sJGzfS","pinned-message-border-wrapper":"p6PQhvds",pinnedMessageBorderWrapper:"p6PQhvds","pinned-message-border-mark":"M2PQZgBd",pinnedMessageBorderMark:"M2PQZgBd"};function nr(e,t,s,a,n){return`M${e},${t+n}a${n},${n},0,0,1,\n ${s},0v${a-2*n}a${n},${n},0,0,1,${-s},0Z`}const or=(0,Tt.X$)((({count:e,index:t})=>{const s=(0,Tt.sO)(null),a=(0,Tt.Ye)((()=>function(e,t){const s=e-t-1,a=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),n=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),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,a),i=`clipPath${e}`,r=function(e,t,s){let a="";if(3===s)a=nr(0,0,2,t,1)+nr(0,12,2,t+1,1)+nr(0,25,2,t,1);else for(let e=0;e<s;e++)a+=nr(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${a}" />\n </clipPath>`}(i,a,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,a,e),d=function(e,t,s,a){return t<=4||e<=1?0:e>=t-2?a-36:(s+4)/2+(e-2)*(s+2)}(s,e,a,o);return{markHeight:n,clipPath:r,markTranslateY:c,trackTranslateY:d,trackHeight:o,clipPathId:i}}(e,t)),[e,t]);if((0,Tt.bt)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:i,clipPath:r}=a,c=s.current.firstElementChild;if(s?.current){const a=s.current,{style:d}=a;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${i}")`;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=`${n}px`,u.style.transform=`translateY(${o}px)`)}}),[a]),1===e)return Tt.ZP.createElement("div",{className:ar.pinnedMessageBorder},Tt.ZP.createElement("div",{className:ar.pinnedMessageBorderWrapper1,ref:s}));const{trackHeight:n,trackTranslateY:o,markHeight:i,markTranslateY:r,clipPathId:c}=a;return Tt.ZP.createElement("div",{className:(0,xt.Z)(ar.pinnedMessageBorder,e>4&&ar.pinnedMessageBorderMask)},Tt.ZP.createElement("div",{className:ar.pinnedMessageBorderWrapper,ref:s,style:`clip-path: url("#${c}"); width: 2px;\n height: ${n}px; transform: translateY(-${o}px);`},Tt.ZP.createElement("span",null),Tt.ZP.createElement("div",{className:ar.pinnedMessageBorderMark,style:`--height: ${i}px; --translate-y: ${r}px; --translate-track: ${o}px;`})))})),ir="OibpUlOd",rr="_f3hwC8p",cr=1.125*M.Gw,dr=(0,Tt.X$)((({message:e,count:t,index:s,customTitle:n,className:i,onUnpinMessage:r,onClick:c,onAllPinnedClick:d,isLoading:l,isFullWidth:u})=>{const{clickBotInlineButton:m}=(0,a.Sv)(),h=(0,Is.Z)(),p=(0,tr.Z)(e),g=(0,ba.Z)((0,v.Ti)(e,"pictogram")),f=(0,v.NE)(e),I=(0,Co.Z)([l],450)&&l,[w,b,y]=(0,xs.Z)(),P=(0,qt.Z)((()=>{y(),r&&r(e.id)})),Z=(0,v.eH)(e),S=(0,qt.Z)((()=>{Z&&m({messageId:e.id,button:Z})})),[C,E,R]=(0,xs.Z)(),{handleClick:k,handleMouseDown:T}=(0,to.m)(c);return Tt.ZP.createElement("div",{className:(0,xt.Z)("HeaderPinnedMessageWrapper","Guj4V7W_",u&&"full-width",i)},(t>1||I)&&Tt.ZP.createElement(vs.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:h("EventLogFilterPinnedMessages"),onClick:I?void 0:d},l&&Tt.ZP.createElement(js.Z,{color:"blue",className:(0,xt.Z)("clu9vjEC",ir,!I&&rr)}),Tt.ZP.createElement("i",{className:(0,xt.Z)("icon","icon-pin-list",ir,I&&rr)})),r&&Tt.ZP.createElement(vs.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:h("UnpinMessageAlertTitle"),onClick:b},Tt.ZP.createElement("i",{className:"icon icon-close"})),Tt.ZP.createElement(Fo.Z,{isOpen:w,onClose:y,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:P}),Tt.ZP.createElement("div",{className:(0,xt.Z)("GgG7nh8p",C&&"Nki3ifmz"),onClick:k,onMouseDown:T,dir:h.isRtl?"rtl":void 0},Tt.ZP.createElement(or,{count:t,index:s}),Tt.ZP.createElement(hs.ZP,{activeKey:e.id,name:"slideVertical",className:"ud4LJMTI"},function(e,t,s){const{width:a,height:n}=(0,M.W7)(),o=t||e;return Tt.ZP.createElement("div",{className:"_M8tJtJD"},e&&!s&&Tt.ZP.createElement("img",{className:"KKUhI313",src:o,width:a,height:n,alt:"",draggable:!1}),e&&Tt.ZP.createElement(Yo.Z,{thumbDataUri:o,isVisible:Boolean(s),width:a,height:n}))}(p,g,f)),Tt.ZP.createElement("div",{className:(0,xt.Z)("LPdDfCw0",p&&"hRtSF_Ex")},Tt.ZP.createElement("div",{className:"bY9umAoY",dir:"auto"},!n&&Tt.ZP.createElement(Mo.Z,{text:`${h("PinnedMessage")} ${s>0?"#"+(t-s):""}`}),n&&(0,ga.Z)(n)),Tt.ZP.createElement(hs.ZP,{activeKey:e.id,name:"slideVerticalFade",className:"lo853Tki"},Tt.ZP.createElement("p",{dir:"auto",className:"Ko14czNN"},Tt.ZP.createElement(sr.Z,{lang:h,message:e,noEmoji:Boolean(p),emojiSize:cr})))),Tt.ZP.createElement(Ca.Z,null),Z&&Tt.ZP.createElement(vs.Z,{size:"tiny",className:"lfWlkB7k",onClick:S,shouldStopPropagation:!0,onMouseEnter:o.$b?void 0:E,onMouseLeave:o.$b?void 0:R},(0,ga.Z)(Z.text))))})),lr=(0,Tt.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a,isMobile:n})=>{const{isLeftColumnShown:o,shouldSkipHistoryAnimations:i,audioPlayer:c,messageLists:d}=(0,y.jUK)(e),l=(0,y.Z1J)(e,t),{chatId:u,messageId:m}=c,h=u&&m?(0,y.hjO)(e,u,m):void 0;let p;if("pinned"===a){const a=(0,y.KBA)(e,t,s);p=a?.length}else if("scheduled"===a){const a=(0,y.qyA)(e,t,s);p=a?.length}else if("thread"===a&&s!==r._f){const a=(0,y.tZg)(e,t,s);p=a?.messagesCount||0}const g="thread"===a&&s===r._f,f=l&&(0,y.xoo)(e,l),I=Boolean(f&&(0,y.s4q)(e,t)),w=f&&!I&&Boolean((0,y.pkN)(e,t)),b=Boolean(l&&(g||l.isForum)&&((0,v.eA)(l)||(0,v.ZV)(l))&&l.isNotJoined),P=Boolean(l?.isNotJoined&&l.isJoinRequest),Z=(0,y.WPz)(e,t,s,"typingStatus"),S=l?.emojiStatus,C=S&&e.customEmojis.byId[S.documentId],M=(0,v._o)(t,s,e.currentUserId),E={typingStatus:Z,isLeftColumnShown:o,isRightColumnShown:(0,y.Jf5)(e,n),isSelectModeActive:(0,y.CAb)(e),audioMessage:h,chat:l,messagesCount:p,isChatWithSelf:(0,y.FM1)(e,t),shouldSkipHistoryAnimations:i,currentTransitionKey:Math.max(0,d.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing,isSynced:e.isSynced,isFetchingDifference:e.isFetchingDifference,emojiStatusSticker:C,hasButtonInHeader:w||I||b||P,isSavedDialog:M},R=(0,y.Zwk)(e,t);if("thread"!==a||!R)return E;if(s!==r._f&&!M&&!l?.isForum){const a=Number(s),n=a?(0,y.hjO)(e,t,a):void 0,o=n?(0,y.cve)(e,n):void 0;return{...E,pinnedMessageIds:a,messagesById:R,canUnpin:!1,topMessageSender:o}}const k=M?void 0:(0,y.KBA)(e,t,s);if(k?.length){const t=R[k[0]],{canUnpin:a=!1}=t&&1===k.length&&(0,y._kf)(e,t,s)||{};return{...E,pinnedMessageIds:k,messagesById:R,canUnpin:a}}return E}))((({chatId:e,threadId:t,messageListType:s,isReady:o,isMobile:i,pinnedMessageIds:d,messagesById:l,canUnpin:u,topMessageSender:m,typingStatus:h,isSelectModeActive:p,isLeftColumnShown:f,isRightColumnShown:I,audioMessage:w,chat:b,messagesCount:y,isComments:P,isChatWithSelf:Z,hasButtonInHeader:S,shouldSkipHistoryAnimations:C,currentTransitionKey:M,connectionState:E,isSyncing:R,isSynced:k,isFetchingDifference:T,getCurrentPinnedIndexes:N,getLoadingPinnedId:A,emojiStatusSticker:B,isSavedDialog:U,onFocusPinnedMessage:L})=>{const{openThreadWithInfo:_,pinMessage:O,focusMessage:F,openChat:D,openPreviousChat:j,loadPinnedMessages:q,toggleLeftColumn:G,exitMessageSelectMode:H,openPremiumModal:V,openThread:$,openStickerSet:z}=(0,a.Sv)(),K=(0,Is.Z)(),J=(0,Tt.sO)(!0),{isTablet:W}=(0,x.ZP)(),Y=(0,Ki.Z)(N)[`${e}_${t}`]||0,X=(0,Ki.Z)(A),Q=Array.isArray(d)?d[Y]:d,ee=l&&Q?l[Q]:void 0,te=Array.isArray(d)?d.length:d?1:void 0,se=b&&(0,v.U)(K,b).length,ae=m?(0,v.OU)(K,m):void 0,{settings:ne}=b||{},oe=b?.isForum;(0,Tt.d4)((()=>{k&&o&&(t===r._f||oe)&&q({chatId:e,threadId:t})}),[e,t,k,o,oe]),(0,kn.Z)(e,Q,ee);const{width:ie}=(0,_a.Z)(),re=ie<=n.ksF,ce=W&&f,de=(0,Tt.sO)(null),le=(0,Tt.sO)(!0),{handleClick:ue,handleMouseDown:me}=(0,to.m)((s=>{"mousedown"===s.type&&s.target.closest(".title > .custom-emoji")||_({chatId:e,threadId:t})})),he=(0,qt.Z)((e=>{O({messageId:e,isUnpin:!0})})),pe=(0,qt.Z)((s=>{const a=s.shiftKey&&Array.isArray(d)?d[(0,Oa.Z)(d.length,d.indexOf(Q)-2)]:Q;L(a)&&F({chatId:e,threadId:t,messageId:a,noForumTopicPanel:!0})})),ge=(0,qt.Z)((()=>{$({chatId:e,threadId:t,type:"pinned"})})),fe=(0,qt.Z)((()=>{setTimeout((()=>{J.current=!0}),450)})),Ie=(0,qt.Z)((()=>{V({fromUserId:e})})),ve=(0,qt.Z)((()=>{z({stickerSetInfo:B.stickerSetInfo})})),we=(0,qt.Z)((e=>{if(J.current){if(J.current=!1,i){const e=document.querySelector(n.Edp);e?.blur()}if(p)return H(),void fe();if("thread"===s&&0===M)return!W||ce?(e.stopPropagation(),D({id:void 0},{forceOnHeavyAnimation:!0})):G(),void fe();j(),fe()}})),be=ie>=n.ksF&&ie<n.jT7||ie>n.l35&&ie<n.ksF&&(!se||se>30),ye=be||ie>n._mX&&ie<n.QU1,Pe=Boolean(ne?.canAddContact||ne?.canBlockContact||ne?.canReportSpam),{shouldRender:Ze,transitionClassNames:Se}=(0,$t.Z)(Pe),Ce=(0,zi.Z)(Pe?ne:void 0,!0),{shouldRender:Me,transitionClassNames:Ee}=(0,$t.Z)(Boolean(w)),Re=(0,zi.Z)(w,!0),{shouldRender:ke,transitionClassNames:Te}=(0,$t.Z)(Boolean(ee),void 0,!0),Ne=(0,zi.Z)(ee,!0),Ae=(0,zi.Z)(te,!0),Be=(0,zi.Z)(u,!0),xe=(0,zi.Z)(ae),Ue=(0,La.Z)(M),Le=void 0!==Ue&&Ue<M?Ue:void 0,_e=ke&&Ne||Me&ℜ(0,Tt.bt)((()=>{const e=de.current;if(e)return ye&&_e?void(I||be?(le.current&&(e.classList.add("tools-stacked","animated"),le.current=!1),setTimeout((()=>{(0,Bt.WM)((()=>{e.classList.remove("animated")}))}),350)):(e.classList.remove("tools-stacked"),le.current=!0)):(e.classList.remove("tools-stacked","animated"),void(le.current=!0))}),[ye,_e,be,I]);const{connectionStatusText:Oe}=As(K,E,R||T,!0);function Fe(e=!1,t=!1){return Tt.ZP.createElement("div",{className:"back-button"},Tt.ZP.createElement(vs.Z,{round:!0,size:"smaller",color:"translucent",onClick:we,ariaLabel:K(e?"Close":"Back")},Tt.ZP.createElement("div",{className:(0,xt.Z)("animated-close-icon",!e&&"state-back")})),t&&Tt.ZP.createElement(rs,null))}const De=Boolean(Me&&Re),je=De||!i&&S&&ie<n.sgm;return(0,Bs.Z)(de),Tt.ZP.createElement("div",{className:"MiddleHeader",ref:de},Tt.ZP.createElement(hs.ZP,{name:C?"none":"slideFade",activeKey:M,shouldCleanup:!0,cleanupExceptionKey:Le},"thread"===s&&(t===r._f||U||b?.isForum)?function(){const s=U?K("SavedMessages"):void 0,a=U?String(t):e;return Tt.ZP.createElement(Tt.ZP.Fragment,null,(re||M>0)&&Fe(ce,!U),Tt.ZP.createElement("div",{className:"chat-info-wrapper",onClick:ue,onMouseDown:me},(0,v.YC)(a)?Tt.ZP.createElement(Yi.Z,{key:a,userId:a,typingStatus:h,status:Oe||s,withDots:Boolean(Oe),withFullInfo:!0,withMediaViewer:!0,withStory:!Z,withUpdatingStatus:!0,isSavedDialog:U,storyViewerOrigin:c.ze.MiddleHeaderAvatar,emojiStatusSize:22,noRtl:!0,onEmojiStatusClick:Ie}):Tt.ZP.createElement(Wi.Z,{key:a,chatId:a,threadId:U?void 0:t,typingStatus:h,status:Oe||s,withDots:Boolean(Oe),withMediaViewer:t===r._f,withFullInfo:t===r._f,withUpdatingStatus:!0,withStory:!0,isSavedDialog:U,storyViewerOrigin:c.ze.MiddleHeaderAvatar,emojiStatusSize:22,onEmojiStatusClick:ve,noRtl:!0})))}():Tt.ZP.createElement(Tt.ZP.Fragment,null,Fe(),Tt.ZP.createElement("h3",null,void 0!==y?"thread"===s?y?K(P?"Comments":"Replies",y,"i"):K(P?"CommentsTitle":"RepliesTitle"):"pinned"===s?K("PinnedMessagesCount",y,"i"):"scheduled"===s?Z?K("Reminders"):K("messages",y,"i"):void 0:K("Loading")))),t===r._f&&!b?.isForum&&Tt.ZP.createElement(Ji.Z,{hasPinnedOffset:ke&&Boolean(Ne)||Me&&Boolean(Re),chatId:e}),ke&&Ne&&Tt.ZP.createElement(dr,{key:e,message:Ne,count:Ae||0,index:Y,customTitle:xe,className:Te,onUnpinMessage:Be?he:void 0,onClick:pe,onAllPinnedClick:ge,isLoading:void 0!==X,isFullWidth:je}),Ze&&Tt.ZP.createElement(Qi,{key:e,chatId:e,settings:Ce,className:Se}),Tt.ZP.createElement("div",{className:"header-tools"},De&&Tt.ZP.createElement(Ra,{key:(0,g.Tp)(Re),message:Re,className:Ee}),Tt.ZP.createElement(er.Z,{chatId:e,threadId:t,messageListType:s,isMobile:i,canExpandActions:!De})))}))),ur=e=>{const{isActive:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"MobileSearch",!t,!0);return s?Tt.ZP.createElement(s,e):void 0};var mr=s(8337);const hr=(0,Tt.X$)((0,a.c$)(((e,{userId:t})=>{const s=(0,y.dyD)(e,t);return{userName:(0,v.Vl)(s)}}))((function({userName:e}){const t=(0,Is.Z)(),{openPremiumModal:s}=(0,a.Sv)(),n=(0,qt.Z)((()=>s()));return Tt.ZP.createElement("div",null,Tt.ZP.createElement("div",null,t("Chat.MessagingRestrictedPlaceholder",e)),Tt.ZP.createElement(mr.Z,{isPrimary:!0,onClick:n},t("Chat.MessagingRestrictedPlaceholderAction")))}))),pr=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"ReactorListModal",!t);return s?Tt.ZP.createElement(s,e):void 0};function gr(e){return"file"===e.kind&&e.type&&n.oGt.has(e.type)}const fr=450+n.fK3,Ir=(0,Tt.X$)((0,a.c$)(((e,{isMobile:t})=>{const s=(0,y.Puy)(e),{isBlurred:a,background:o,backgroundColor:i,patternColor:c}=e.settings.themes[s]||{},{messageLists:d,isLeftColumnShown:l,activeEmojiInteractions:u,seenByModal:m,giftPremiumModal:h,reactorModal:p,audioPlayer:g,shouldSkipHistoryAnimations:f,chatLanguageModal:I,privacySettingsNoticeModal:w}=(0,y.jUK)(e),b=(0,y.Btg)(e),{leftColumnWidth:P}=e,Z={theme:s,customBackground:o,backgroundColor:i,patternColor:c,isLeftColumnShown:l,isRightColumnShown:(0,y.Jf5)(e,t),isBackgroundBlurred:a,hasCurrentTextSearch:Boolean((0,y.n5x)(e)),isSelectModeActive:(0,y.CAb)(e),isSeenByModalOpen:Boolean(m),isPrivacySettingsNoticeModalOpen:Boolean(w),isReactorListModalOpen:Boolean(p),isGiftPremiumModalOpen:h?.isOpen,isChatLanguageModalOpen:Boolean(I),withInterfaceAnimations:(0,y.FOo)(e),currentTransitionKey:Math.max(0,d.length-1),activeEmojiInteractions:u,leftColumnWidth:P};if(!b)return Z;const{chatId:S,threadId:C,type:M}=b,E=(0,v.YC)(S),R=(0,y.Z1J)(e,S),k=(0,y.kBx)(e,S),T=(0,y.KBA)(e,S,C),{chatId:N,messageId:A}=g,B=S?(0,y.x67)(e,S):void 0,x=(0,y.tZg)(e,S,C),U=Boolean(!x?.isCommentsInfo&&x?.fromChannelId),L=R&&(0,v.Qm)(R,C,U,B),_=(0,y.pkN)(e,S),O="pinned"===M,F="thread"===M&&C===r._f,D=Boolean(R&&(0,v.eA)(R)),j=Boolean(R&&F&&(D||(0,v.ZV)(R))&&R.isNotJoined&&!R.joinRequests),q=Boolean(R?.isNotJoined&&R.isJoinToSend),G=Boolean(R?.isNotJoined&&R.isJoinRequest),H=!!E&&(0,y.s4q)(e,S),V=Boolean(k&&H),$=!V&&_,z=H&&!k,K=Boolean(R&&(0,v.Bf)(R)&&!B),J=(0,y.Mst)(e,S,C)?.replyInfo,W=!!R?.isForum&&C===r._f&&!J&&R.topics?.[n.OxA]?.isClosed,Y=N&&A?(0,y.hjO)(e,N,A):void 0,X=(0,v._o)(S,C,e.currentUserId),Q=X&&C!==n.tKb,ee=C!==r._f&&!X&&!R?.isForum,te=ee?Number(C):void 0,se=R&&(E||R?.isCreator||!D&&!(0,v.Mg)(R,"pinMessages")||(0,v.VE)(R,"pinMessages")),ae=(0,y.ccz)(e,S)?.isContactRequirePremium;return{...Z,chatId:S,threadId:C,messageListType:M,chat:R,draftReplyInfo:J,isPrivate:E,areChatSettingsLoaded:Boolean(R?.settings),isComments:U,canPost:!O&&(!R||L)&&!_&&!(q&&R?.isNotJoined)&&!W&&!X,isPinnedMessageList:O,currentUserBannedRights:R?.currentUserBannedRights,defaultBannedRights:R?.defaultBannedRights,hasPinned:ee||Boolean(!O&&T?.length),hasAudioPlayer:Boolean(Y),hasButtonInHeader:$||V||j||G,pinnedMessagesCount:T?T.length:0,shouldSkipHistoryAnimations:f,isChannel:D,canSubscribe:j,canStartBot:$,canRestartBot:V,shouldJoinToSend:q,shouldSendJoinRequest:G,shouldLoadFullChat:K,pinnedIds:T,topMessageId:te,canUnpin:se,canUnblock:z,isSavedDialog:X,canShowOpenChatButton:Q,isContactRequirePremium:ae}}))((function({leftColumnRef:e,chatId:t,threadId:s,isComments:i,messageListType:r,isMobile:c,chat:d,draftReplyInfo:l,isPrivate:u,isPinnedMessageList:m,canPost:p,currentUserBannedRights:g,defaultBannedRights:f,hasPinned:I,hasAudioPlayer:w,hasButtonInHeader:b,pinnedMessagesCount:P,customBackground:Z,theme:S,backgroundColor:C,patternColor:A,isLeftColumnShown:B,isRightColumnShown:U,isBackgroundBlurred:L,leftColumnWidth:_,hasCurrentTextSearch:O,isSelectModeActive:F,isSeenByModalOpen:D,isPrivacySettingsNoticeModalOpen:j,isReactorListModalOpen:q,isGiftPremiumModalOpen:G,isChatLanguageModalOpen:H,withInterfaceAnimations:V,shouldSkipHistoryAnimations:$,currentTransitionKey:z,isChannel:K,areChatSettingsLoaded:J,canSubscribe:W,canStartBot:Y,canRestartBot:X,activeEmojiInteractions:Q,shouldJoinToSend:ee,shouldSendJoinRequest:te,shouldLoadFullChat:se,pinnedIds:ae,topMessageId:ne,canUnpin:oe,canUnblock:ie,isSavedDialog:re,canShowOpenChatButton:ce,isContactRequirePremium:de}){const{openChat:le,openPreviousChat:ue,unpinAllMessages:me,loadUser:he,loadChatSettings:pe,closeLocalTextSearch:ge,exitMessageSelectMode:fe,joinChannel:Ie,sendBotCommand:ve,restartBot:we,showNotification:be,loadFullChat:ye,setLeftColumnWidth:Pe,resetLeftColumnWidth:Ze,unblockUser:Se}=(0,a.Sv)(),{width:Ce}=(0,_a.Z)(),{isTablet:Me,isDesktop:Ee}=(0,x.ZP)(),Re=(0,Is.Z)(),[ke,Te]=(0,Tt.eJ)(za.t.None),[Ne,Ae]=(0,Tt.eJ)(),[Be,xe]=(0,Tt.eJ)(),[Ue,Le]=(0,Tt.eJ)(!1),{onIntersectionChanged:_e,onFocusPinnedMessage:Oe,getCurrentPinnedIndexes:Fe,getLoadingPinnedId:De,getForceNextPinnedInHeader:je}=function(e,t,s,n){const[o,i]=(0,Da.Z)({}),[r,c]=(0,Da.Z)(),d=(0,Tt.sO)(),[l,u]=(0,Da.Z)(),m=e?`${e}_${t}`:void 0;return(0,Tt.d4)((()=>{c(void 0),d.current=void 0,u(void 0)}),[e,i,c,u,t]),(0,Tt.d4)((()=>{if(!m)return;const e=o()[m],t=s?.length||0;e>=t&&i({...o(),[m]:Math.max(0,t-1)})}),[o,m,s?.length,i]),{onIntersectionChanged:(0,qt.Z)((({viewportPinnedIdsToAdd:n=[],viewportPinnedIdsToRemove:p=[],isReversed:g,hasScrolled:f,isUnmount:I})=>{if(!e||!t||!m)return;const v=(0,a.Rd)();if(!s?.length||!s)return;const w=l();if(w&&!f){const e=s.indexOf(w);i({...o(),[m]:e}),u(void 0)}f&&(c(void 0),u(void 0));const b=r(),P=d.current;if(I&&0===n.length&&1===p.length&&!P?.includes(p[0]))return;const Z=(0,h.Tw)((P?.filter((e=>!p.includes(e)))||[]).concat(n));d.current=Z;const S=(0,y.G$N)(v,e);if(!Z.length&&I&&S&&!s.includes(S)){const e=s.find((e=>e<S));if(e){const t=s.indexOf(e);i({...o(),[m]:t})}}if(b||I)return;const C=Math.max(...Z),M=s.findIndex((e=>e===C)),E=g?0:1,R=Z.length?M:P?.length?(0,Fa.uZ)(s.indexOf(P[0])+E,0,s.length-1):0;i({...o(),[m]:R})})),onFocusPinnedMessage:(0,qt.Z)((r=>{if(!e||!t||!m||l())return!1;const d=(0,a.Rd)();if(!s?.length)return n===r;const h=s.indexOf(r),p=(0,Oa.Z)(s.length,h+1);c(!0);const g=(0,y.gbs)(d,e,t);return g?.includes(r)||(0,y.ofg)(d,e,t,r)?(i({...o(),[m]:p}),!0):(u(s[p]),!0)})),getCurrentPinnedIndexes:o,getLoadingPinnedId:l,getForceNextPinnedInHeader:r}}(t,s,ae,ne),qe=c&&O,Ge=c?fr:void 0,He=I&&(Ce<n.l35||w||U&&Ce>n._mX&&Ce<n.QU1||!c&&b&&Ce<n.sgm),Ve=(0,Ua.Z)(t,Ge),$e=(0,Ua.Z)(s,Ge),ze=(0,Ua.Z)(r,Ge),Ke=(0,Ua.Z)(W,Ge),Je=(0,Ua.Z)(Y,Ge),We=(0,Ua.Z)(X,Ge),Ye=(0,Ua.Z)(ie,Ge),Xe=(0,Ua.Z)(p,Ge)&&!We&&!Je&&!Ke&&!Ye&&t!==n.mzl&&!de,Qe=(0,Ua.Z)(He,Ge),et=(0,Ua.Z)(Ne,Ge)&&t!==n.mzl,tt=(0,Ua.Z)(K,Ge),st=(0,Ua.Z)(ee,Ge),at=(0,Ua.Z)(te,Ge),nt=(0,Ua.Z)(t?_e:void 0,Ge),ot=(0,La.Z)(z),it=void 0!==ot&&ot<z?ot:void 0,{isReady:rt,handleCssTransitionEnd:ct,handleSlideTransitionStop:dt}=function(e,t,s,a,n){const[o,i]=(0,Tt.eJ)(!n),r=(0,Dt.Z)(),c=void 0!==s&&s!==t;return c&&(e?(i(!1),setTimeout((()=>{i(!0)}),fr)):r()),(0,zt.Z)((()=>{e||i(!0)}),[e]),{isReady:o&&!c,handleCssTransitionEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&i(Boolean(a))}:void 0,handleSlideTransitionStop:e?function(){i(!0)}:void 0}}(!$&&V,z,ot,t,c);(0,Tt.d4)((()=>t?(0,cs.Z)((()=>{le({id:void 0})})):void 0),[t,le]),(0,zt.Z)((()=>{Te(za.t.None),xe(void 0)}),[t]),(0,Tt.d4)((()=>{if(!o.cj&&!o.wZ)return;const{visualViewport:e}=window;if(!e)return;const t=()=>{const t=e.height!==document.documentElement.clientHeight;(0,Bt.WM)((()=>{document.body.classList.toggle("keyboard-visible",t),(0,Bt.i$)((()=>{!t&&e.offsetTop&&(0,Bt.WM)((()=>{window.scrollTo({top:0})}))}))}))};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}})),(0,Tt.d4)((()=>{u&&he({userId:t})}),[t,u,he]),(0,Tt.d4)((()=>{J||pe({chatId:t})}),[t,u,J]),(0,Tt.d4)((()=>{t&&se&&rt&&ye({chatId:t})}),[se,t,rt,ye]);const{initResize:lt,resetResize:ut,handleMouseUp:mt}=function(e,t,s,a,n){const[o,i,r]=(0,xs.Z)(),[c,d]=(0,Tt.eJ)(0),[l,u]=(0,Tt.eJ)(0),m=(0,qt.Z)((t=>{(0,Bt.WM)((()=>{if(!e.current)return;const s=t?`${t}px`:"";e.current.style.width=s,n&&e.current.style.setProperty(n,s)}))}));function h(){(0,Bt.WM)((()=>{document.body.classList.remove("cursor-ew-resize")}))}return(0,Tt.bt)((()=>{e.current&&a&&m(a)}),[n,e,a,m]),(0,Tt.d4)((()=>{if(!o)return;const s=e=>{const t=Math.ceil(l+e.clientX-c);m(t)};function a(){n(),t(e.current.offsetWidth)}function n(){h(),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",a,!1),document.removeEventListener("blur",a,!1),r()}return document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",a,!1),document.addEventListener("blur",a,!1),n}),[l,c,e,t,o,r,m]),{initResize:function(t){t.preventDefault(),(0,Bt.WM)((()=>{document.body.classList.add("cursor-ew-resize")})),d(t.clientX),u(e.current.offsetWidth),i()},resetResize:function(e){e.preventDefault(),m(void 0),s()},handleMouseUp:h}}(e,(e=>Pe({leftColumnWidth:e})),Ze,_,"--left-column-width"),ht=(0,qt.Z)((e=>{const{items:t}=e.dataTransfer||{},s=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(gr);Te(s?za.t.QuickFile:za.t.Document)})),pt=(0,qt.Z)((()=>{Te(za.t.None)})),gt=(0,qt.Z)((()=>{Le(!0)})),ft=(0,qt.Z)((()=>{Le(!1)})),It=(0,qt.Z)((()=>{le({id:String(s)})})),vt=(0,qt.Z)((()=>{me({chatId:t,threadId:s}),ft(),ue()})),wt=(0,qt.Z)((()=>{le({id:t})})),bt=(0,qt.Z)((()=>{Ie({chatId:t}),at&&be({message:Re(K?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})})),yt=(0,qt.Z)((()=>{ve({command:"/start"})})),Pt=(0,qt.Z)((()=>{we({chatId:t})})),Zt=(0,qt.Z)((()=>{Se({userId:t})})),St=((e,t)=>{const{setThemeSettings:s}=(0,a.Sv)(),[o,i]=(0,Tt.eJ)(t);return(0,Tt.d4)((()=>{t&&(t.startsWith("#")?i(t):Ba.fetch(n.foQ,e,Ba.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,xa.pt)(t).then((()=>{i(`url(${t})`)}))})).catch((()=>{s({theme:e,background:void 0,backgroundColor:void 0,isBlurred:!0,patternColor:"dark"===e?n.Vvx:n.ga_})})))}),[t,e]),t?o:void 0})(S,Z),Ct=(0,xt.Z)(Qe&&"has-header-tools",o.aZ?"mask-image-disabled":"mask-image-enabled"),Mt=(0,xt.Z)("C6IaXYew","nXhZtCma",Z&&"K1xhz7U5",C&&"CwoXMwaR",Z&&L&&"JBrOVLsX",U&&"Lyw3O8XE",o.D$&&!(Ve&&$e)&&"jMpPshUt"),Et=(0,xt.Z)("messaging-disabled",!F&&"shown"),Rt=(0,v.q8)(Re,g,f),kt=(0,v.mt)(Re,d,s,Boolean(l)),Nt=Rt??kt??(de?Tt.ZP.createElement(hr,{userId:t}):void 0),{composerHiddenScale:At,toolbarHiddenScale:Ut,composerTranslateX:Lt,toolbarTranslateX:_t,unpinHiddenScale:Ot,toolbarForUnpinHiddenScale:Ft}=(0,Tt.Ye)((()=>function(e,t){const s=e<=n.l35?M.Gw:2*M.Gw,a=function(e){if(e>n._mX){const t=Math.min(Math.max(.25*e,T),k),s=Math.min(.25*e,k);return Math.min(e-t-s,R)}if(e>n.ksF){const t=Math.min(Math.max(.4*e,T),k);return Math.min(e-t,R)}return e>R?R:e}(e),o=e<=n.l35?3.375*M.Gw:4*M.Gw,i=t?a-s-o:a-s,r=e>n.l35?Math.min(a-s,E):a-s,c=r/i,d=i/r;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?o/2*d:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:r/N,toolbarForUnpinHiddenScale:N/r}}(Ce,Xe)),[Xe,Ce]),jt=(0,xt.Z)("middle-column-footer",!Xe&&"no-composer",Xe&&Be&&!F&&"with-notch");(0,Ss.Z)({isActive:F,onBack:fe}),(0,Ss.Z)({isActive:qe,onBack:ge});const Gt=Boolean(!m&&!re&&!Xe&&!We&&!Je&&!Ke&&Nt),Ht=Boolean(We||Ke||at||Je||m||ce||Ye),Vt=Boolean(Gt||F||m);return Tt.ZP.createElement("div",{id:"MiddleColumn",className:Ct,onTransitionEnd:ct,style:(0,Aa.Z)(`--composer-hidden-scale: ${At}`,`--toolbar-hidden-scale: ${Ut}`,`--unpin-hidden-scale: ${Ot}`,`--toolbar-unpin-hidden-scale: ${Ft},`,`--composer-translate-x: ${Lt}px`,`--toolbar-translate-x: ${_t}px`,`--pattern-color: ${A}`,C&&`--theme-background-color: ${C}`),onClick:Me&&B?wt:void 0},Ee&&Tt.ZP.createElement("div",{className:"resize-handle",onMouseDown:lt,onMouseUp:mt,onDoubleClick:ut}),Tt.ZP.createElement("div",{className:Mt,style:St?`--custom-background: ${St}`:void 0}),Tt.ZP.createElement("div",{id:"middle-column-portals"}),Boolean(Ve&&$e)&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:"messages-layout",onDragEnter:Xe?ht:void 0},Tt.ZP.createElement(lr,{chatId:Ve,threadId:$e,messageListType:ze,isComments:i,isReady:rt,isMobile:c,getCurrentPinnedIndexes:Fe,getLoadingPinnedId:De,onFocusPinnedMessage:Oe}),Tt.ZP.createElement(hs.ZP,{name:$?"none":V?"slide":"fade",activeKey:z,shouldCleanup:!0,cleanupExceptionKey:it,onStop:dt},Tt.ZP.createElement(Vi,{key:`${Ve}-${$e}-${ze}`,chatId:Ve,threadId:$e,type:ze,isComments:i,canPost:Xe,hasTools:Qe,onFabToggle:Ae,onNotchToggle:xe,isReady:rt,isContactRequirePremium:de,withBottomShift:Ht,withDefaultBg:Boolean(!Z&&!C),onPinnedIntersectionChange:nt,getForceNextPinnedInHeader:je}),Tt.ZP.createElement("div",{className:jt},Xe&&Tt.ZP.createElement(ja.Z,{type:"messageList",chatId:Ve,threadId:$e,messageListType:ze,dropAreaState:ke,onDropHide:pt,isReady:rt,isMobile:c,editableInputId:n.R2F,editableInputCssSelector:n.Edp,inputId:"message-input-text"}),m&&oe&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,color:"secondary",className:"composer-button unpin-all-button",onClick:gt},Tt.ZP.createElement("i",{className:"icon icon-unpin"}),Tt.ZP.createElement("span",null,Re("Chat.Pinned.UnpinAll",P,"i")))),ce&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,color:"secondary",className:"composer-button open-chat-button",onClick:It},Tt.ZP.createElement("span",null,Re("SavedOpenChat")))),Gt&&Tt.ZP.createElement("div",{className:Et},Tt.ZP.createElement("div",{className:"messaging-disabled-inner"},Tt.ZP.createElement("span",null,Nt))),c&&(Ke||st&&!at)&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,ripple:!0,className:"composer-button join-subscribe-button",onClick:bt},Re(tt?"ProfileJoinChannel":"ProfileJoinGroup"))),c&&at&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,ripple:!0,className:"composer-button join-subscribe-button",onClick:bt},Re("ChannelJoinRequest"))),c&&Je&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,ripple:!0,className:"composer-button join-subscribe-button",onClick:yt},Re("BotStart"))),c&&We&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,ripple:!0,className:"composer-button join-subscribe-button",onClick:Pt},Re("BotRestart"))),c&&Ye&&Tt.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Re.isRtl?"rtl":void 0},Tt.ZP.createElement(vs.Z,{size:"tiny",fluid:!0,ripple:!0,className:"composer-button join-subscribe-button",onClick:Zt},Re("Unblock"))),Tt.ZP.createElement($i,{messageListType:ze,isActive:F,canPost:Xe}),Tt.ZP.createElement(Ga,{isOpen:D}),Tt.ZP.createElement(qa,{isOpen:j}),Tt.ZP.createElement(pr,{isOpen:q}),o.SX&&Tt.ZP.createElement($a,{isOpen:H}))),Tt.ZP.createElement(Xa,{isShown:et,canPost:Xe,withExtraShift:Vt})),c&&Tt.ZP.createElement(ur,{isActive:Boolean(qe)})),t&&Tt.ZP.createElement(Ha,{isOpen:Ue,chatId:t,pinnedMessagesCount:P,onClose:ft,onUnpin:vt}),Tt.ZP.createElement("div",{teactFastList:!0},Q?.map(((e,t)=>Tt.ZP.createElement(Ka,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))),Tt.ZP.createElement(Va,{isOpen:G}))}))),vr=e=>{const{bot:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"AttachBotInstallModal",!t);return s?Tt.ZP.createElement(s,e):void 0},wr=e=>{const{info:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"BoostModal",!t);return s?Tt.ZP.createElement(s,e):void 0},br=e=>{const{info:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"ChatlistModal",!t);return s?Tt.ZP.createElement(s,e):void 0},yr=e=>{const{modal:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"GiftCodeModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Pr=e=>{const{geoPoint:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"MapModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Zr=e=>{const{info:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"OneTimeMediaModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Sr=e=>{const{urlAuth:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"UrlAuthModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Cr=e=>{const{webApp:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"WebAppModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Mr=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"PaymentModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Er=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"ReceiptModal",!t);return s?Tt.ZP.createElement(s,e):void 0};var Rr=s(67263),kr=s(11820),Tr=s(41151);const Nr=(0,Tt.X$)((0,a.c$)(((e,{chatId:t})=>{const s=(0,y.Z1J)(e,t),{userIds:a}=e.contactList||{},{newChatMembersProgress:n}=(0,y.jUK)(e),{currentUserId:o}=e,i=s&&(0,v.eA)(s),{query:r,fetchingStatus:d,globalUserIds:l,localUserIds:u}=(0,y.jUK)(e).userSearch;return{isChannel:i,members:(0,y.x67)(e,t)?.members,currentUserId:o,localContactIds:a,searchQuery:r,isSearching:d,isLoading:n===c.WB.Loading,globalUserIds:l,localUserIds:u}}))((({isChannel:e,members:t,onNextStep:s,currentUserId:n,localContactIds:o,isLoading:i,searchQuery:r,isSearching:c,localUserIds:d,globalUserIds:l,onClose:u,isActive:m})=>{const{setUserSearchQuery:p}=(0,a.Sv)(),g=(0,Is.Z)(),[f,I]=(0,Tt.eJ)([]),w=(0,La.Z)(f)===f;(0,Ss.Z)({isActive:m,onBack:u});const b=(0,Tt.Ye)((()=>t?t.map((e=>e.userId)):[]),[t]),y=(0,Tt.I4)((e=>{p({query:e})}),[p]),P=(0,Tt.Ye)((()=>{const t=(0,a.Rd)().users.byId,s=o?(0,v.kK)(o,t,r):[];return(0,Rr.Z)((0,h.Tw)([...s,...d||[],...l||[]]).filter((s=>{const a=t[s];return!b.includes(s)&&s!==n&&(!a||!(0,v.cS)(a)||!e&&a.canBeInvitedToGroup)})))}),[o,r,d,l,n,b,e]),Z=(0,Tt.I4)((()=>{f.length&&(p({query:""}),s(f))}),[f,p,s]);return Tt.ZP.createElement("div",{className:"AddChatMembers"},Tt.ZP.createElement("div",{className:"AddChatMembers-inner"},Tt.ZP.createElement(kr.Z,{itemIds:P,selectedIds:f,filterValue:r,filterPlaceholder:g("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:c,onSelectedIdsChange:I,onFilterChange:y,isSearchable:!0,noScrollRestore:w}),Tt.ZP.createElement(Tr.Z,{isShown:Boolean(f.length),disabled:i,ariaLabel:g("lng_channel_add_users"),onClick:Z},i?Tt.ZP.createElement(js.Z,{color:"white"}):Tt.ZP.createElement("i",{className:"icon icon-arrow-right"}))))}))),Ar=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"CreateTopic");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},Br=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"EditTopic");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},xr=()=>{const e=(0,Yt.Z)(_t.gl.Extra,"GifSearch");return e?Tt.ZP.createElement(e,null):Tt.ZP.createElement(ps.Z,null)},Ur=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"Management");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},Lr=()=>{const e=(0,Yt.Z)(_t.gl.Extra,"PollResults");return e?Tt.ZP.createElement(e,null):Tt.ZP.createElement(ps.Z,null)};var _r=s(91),Or=s(13995);const Fr=(0,f.P2)((e=>e()),250,!1);let Dr=!1;function jr(e){switch(e){case"members":return c.vi.MemberList;case"stories":return c.vi.StoryList;case"dialogs":return c.vi.SavedDialogs;default:return c.vi.SharedMedia}}var qr=s(27407);function Gr(e,t){const[s,a]=(0,qr.Z)(e,t,void 0,n.Vk);return[s,a,!(!s||!t||s[0]===t[0])]}function Hr(e,t,s,a,o,i){const r=(0,Tt.sO)();(0,zt.Z)((()=>{r.current=void 0}),[i]),(0,zt.Z)((()=>{t===e&&a&&o&&(r.current=(0,v.R5)(a,o,e))}),[a,o,t,e]);const[c,d]=(0,qr.Z)(s,r.current,void 0,"media"===e?n.ENB:n.pnA);return[c,d,!(!c||!r.current||c[0]===r.current[0])]}var Vr=s(70180),$r=s(13709),zr=s(47262),Kr=s(16568),Jr=s(45418),Wr=s(12644),Yr=s(42175);const Xr=(0,Tt.X$)((function({story:e,isProtected:t,isArchive:s}){const{openStoryViewer:n,loadPeerSkippedStories:o,toggleStoryPinned:i,showNotification:r}=(0,a.Sv)(),c=(0,Is.Z)(),d=(0,Tt.sO)(null),l=(0,qt.Z)((()=>d.current)),u=(0,qt.Z)((()=>document.body)),m=(0,qt.Z)((()=>document.querySelector("#portals .story-context-menu .bubble"))),h=(0,qt.Z)((()=>({withPortal:!0,isDense:!0}))),p=e&&e.peerId,g=e&&"content"in e,f=g&&e.isOut,I=e&&"isDeleted"in e,w=g?e.content.video:void 0,b=g?(0,v.Cc)(e):void 0,y=(0,ba.Z)(b)||w?.thumbnail?.dataUri;(0,Tt.d4)((()=>{!e||g||I||o({peerId:e.peerId})}),[I,g,e]);const{isContextMenuOpen:P,contextMenuPosition:Z,handleBeforeContextMenu:S,handleContextMenu:C,handleContextMenuClose:M,handleContextMenuHide:E}=(0,Ia.Z)(d,!f),{positionX:R,positionY:k,transformOriginX:T,transformOriginY:N,style:A}=(0,Wr.Z)(Z,l,u,m,h),B=(0,Tt.I4)((()=>{n({peerId:e.peerId,storyId:e.id,isSinglePeer:!0,isPrivate:!0,isArchive:s})}),[s,e.id,e.peerId]),x=(0,qt.Z)((e=>{(0,sn.b)(e),S(e)})),U=(0,qt.Z)((t=>{(0,yn.Z)(t),i({peerId:p,storyId:e.id,isPinned:!0}),r({message:c("Story.ToastSavedToProfileText")}),M()})),L=(0,qt.Z)((t=>{(0,yn.Z)(t),i({peerId:p,storyId:e.id,isPinned:!1}),r({message:c("Story.ToastRemovedFromProfileText")}),M()}));return Tt.ZP.createElement("div",{ref:d,className:(0,xt.Z)("kxMIqtqr","scroll-item"),onMouseDown:x,onClick:B,onContextMenu:C},I&&Tt.ZP.createElement("span",null,Tt.ZP.createElement("i",{className:(0,xt.Z)("cq7jTRkg","icon icon-story-expired"),"aria-hidden":!0}),c("ExpiredStory")),Tt.ZP.createElement("div",{className:"D6Yajvjx"},y&&Tt.ZP.createElement("img",{src:y,alt:"",className:"cV_QL3N5",draggable:!1}),g&&Tt.ZP.createElement(Yr.Z,{story:e}),t&&Tt.ZP.createElement("span",{className:"protector"})),void 0!==Z&&Tt.ZP.createElement(ws.Z,{isOpen:P,transformOriginX:T,transformOriginY:N,positionX:R,positionY:k,style:A,className:(0,xt.Z)("UAfI9izT","story-context-menu"),autoClose:!0,onClose:M,onCloseAnimationEnd:E,withPortal:!0},s&&Tt.ZP.createElement(bs.Z,{icon:"pin",onClick:U},c("StoryList.SaveToProfile")),!s&&Tt.ZP.createElement(bs.Z,{icon:"unpin",onClick:L},c("Story.Context.RemoveFromProfile"))))}));var Qr=s(21273),ec=s(31876),tc=s(22275);const sc=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"}],ac=(0,Tt.X$)((0,a.c$)(((e,{chatId:t,threadId:s,isMobile:a})=>{const n=(0,y.Z1J)(e,t),o=(0,y.x67)(e,t),i=(0,y.Zwk)(e,t),{currentType:c,resultsByType:d}=(0,y.weG)(e)||{},{foundIds:l}=d&&c&&d[c]||{},u=Boolean(n?.isForum&&s&&s!==r._f),{byId:m,statusesById:h}=e.users,{byId:p}=e.chats,g=(0,v._o)(t,s,e.currentUserId),f=n&&(0,v.Bf)(n),I=n&&(0,v.eA)(n),w=!u&&!g&&(f||I&&(0,v.Nl)(n)),b=o?.members,P=o?.adminMembersById,Z=w&&n&&(n.isForbidden||o&&!o.canViewMembers),S=w&&n&&((0,v.VE)(n,"inviteUsers")||!(0,v.Mg)(n,"inviteUsers")||n.isCreator),C=w&&n&&((0,v.VE)(n,"banUsers")||n.isCreator),M=(0,y.f21)(e,t),{similarChannelIds:E}=(0,y.D2x)(e,t)||{},R=(0,y.wVz)(e);let k,T,N;(0,v.YC)(t)&&(T=t,N=(0,y.dyD)(e,T),k=N&&!N.isSelf&&!(0,v.cS)(N)&&!g);const A=N||n,B=(0,y.mZI)(e,t),x=A&&(N?.isSelf||!A.areStoriesHidden&&B?.hasPinnedStories)&&!g,U=x?(0,y.nST)(e,A.id):void 0,L=U?.pinnedIds,_=U?.byId,O=U?.archiveIds;return{theme:(0,y.Puy)(e),isChannel:I,resolvedUserId:T,messagesById:i,foundIds:l,mediaSearchType:c,hasCommonChatsTab:k,hasStoriesTab:x,hasMembersTab:w,areMembersHidden:Z,canAddMembers:S,canDeleteMembers:C,currentUserId:e.currentUserId,isRightColumnShown:(0,y.Jf5)(e,a),isRestricted:n?.isRestricted,activeDownloadIds:M?.ids,usersById:m,userStatusesById:h,chatsById:p,storyIds:L,archiveStoryIds:O,storyByIds:_,isChatProtected:n?.isProtected,nextProfileTab:(0,y.jUK)(e).nextProfileTab,forceScrollProfileTab:(0,y.jUK)(e).forceScrollProfileTab,shouldWarnAboutSvg:e.settings.byKey.shouldWarnAboutSvg,similarChannels:E,isCurrentUserPremium:R,isTopicInfo:u,isSavedDialog:g,limitSimilarChannels:(0,ae.P)(e,"recommendedChannels"),...w&&b&&{members:b,adminMembersById:P},...k&&N&&{commonChatIds:N.commonChats?.ids}}}))((({chatId:e,threadId:t,profileState:s,onProfileStateChange:i,theme:d,isChannel:l,resolvedUserId:u,currentUserId:m,messagesById:h,foundIds:p,storyIds:g,archiveStoryIds:f,storyByIds:I,mediaSearchType:w,hasCommonChatsTab:b,hasStoriesTab:y,hasMembersTab:P,areMembersHidden:Z,canAddMembers:S,canDeleteMembers:C,commonChatIds:M,members:E,adminMembersById:R,usersById:k,userStatusesById:T,chatsById:N,isRightColumnShown:A,isRestricted:B,activeDownloadIds:x,isChatProtected:U,nextProfileTab:L,shouldWarnAboutSvg:_,similarChannels:O,isCurrentUserPremium:F,limitSimilarChannels:D,isTopicInfo:j,isSavedDialog:q,forceScrollProfileTab:G})=>{const{setLocalMediaSearchType:H,loadMoreMembers:V,loadCommonChats:$,openChat:z,searchMediaMessagesLocal:K,openMediaViewer:J,openAudioPlayer:W,focusMessage:Y,loadProfilePhotos:X,setNewChatMembersDialogState:Q,loadPeerPinnedStories:ee,loadStoriesArchive:te,openPremiumModal:se,fetchChannelRecommendations:ae}=(0,a.Sv)(),ne=(0,Tt.sO)(null),oe=(0,Tt.sO)(null),ie=(0,Is.Z)(),[re,ce]=(0,Tt.eJ)(),de=q?String(t):u||e,le=de===m&&!q,ue=(0,Tt.Ye)((()=>[...le&&!q?[{type:"dialogs",title:"SavedDialogsTab"}]:[],...y?[{type:"stories",title:"ProfileStories"}]:[],...y&&le?[{type:"storiesArchive",title:"ProfileStoriesArchive"}]:[],...P?[{type:"members",title:l?"ChannelSubscribers":"GroupMembers"}]:[],...sc,...j?[]:[{type:"voice",title:"SharedVoiceTab2"}],...b?[{type:"commonChats",title:"SharedGroupsTab2"}]:[],...l&&O?.length?[{type:"similarChannels",title:"SimilarChannelsTab"}]:[]]),[b,P,y,l,j,O,le,q]),me=(0,Tt.Ye)((()=>{if(!L)return 0;const e=ue.findIndex((({type:e})=>e===L));return-1===e?0:e}),[L,ue]),[he,pe]=(0,Tt.eJ)(me);(0,Tt.d4)((()=>{if(!L)return;const e=ue.findIndex((({type:e})=>e===L));-1!==e&&pe(e)}),[L,ue]),(0,Tt.d4)((()=>{l&&!O&&ae({chatId:e})}),[e,l,O]);const ge=he>ue.length-1?ue.length-1:he,fe=ue[ge].type,Ie=(0,Tt.I4)((({offsetId:t})=>{ee({peerId:e,offsetId:t})}),[e]),ve=(0,Tt.I4)((({offsetId:e})=>{te({peerId:m,offsetId:e})}),[m]),[we,be,ye,Pe]=function(e,t,s,a,n,o,i,r,c,d,l,u,m,h,p,g,f,I){const w="members"!==o&&i?i:o,b=(0,Tt.Ye)((()=>{if(r&&d&&l)return(0,v.Z0)(r.map((({userId:e})=>e)),d,l)}),[r,d,l]),y=(0,Tt.Ye)((()=>{if(c&&u)return(0,Rr.Z)(c,!0)}),[u,c]),[P,Z,S]=Gr(e,b),[C,M,E]=Hr("media",w,s,m,h,p),[R,k,T]=Hr("documents",w,s,m,h,p),[N,A,B]=Hr("links",w,s,m,h,p),[x,U,L]=Hr("audio",w,s,m,h,p),[_,O,F]=Hr("voice",w,s,m,h,p),[D,j,q]=Gr(t,y),[G,H,V]=Gr(a,g),[$,z,K]=Gr(n,f);let J,W,Y=!1;switch(w){case"members":J=P,W=Z,Y=S;break;case"commonChats":J=D,W=j,Y=q;break;case"media":J=C,W=M,Y=E;break;case"documents":J=R,W=k,Y=T;break;case"links":J=N,W=A,Y=B;break;case"audio":J=x,W=U,Y=L;break;case"voice":J=_,W=O,Y=F;break;case"stories":J=G,W=H,Y=V;break;case"storiesArchive":J=$,W=z,Y=K;break;case"similarChannels":J=I;break;case"dialogs":Y=!0}return[w,J,W,Y]}(V,$,K,Ie,ve,fe,w,E,M,k,T,N,h,p,t,g,f,O),Ze=le&&"dialogs"===we||y&&"stories"===we||"members"===we||!P&&"media"===we,Se=ue.findIndex((({type:e})=>e===we));(0,Or.Z)("members"===we?be:void 0);const{handleScroll:Ce}=function(e,t,s,a,n=!1){(0,Js.Z)((([s])=>{if(s&&s!==t||t&&n){const s=e.current,n=s.querySelector(".TabList");s.scrollTop<n.offsetTop&&(a(jr(t)),Dr=!0,(0,Ja.ZP)(s,n,"start",void 0,void 0,void 0,300),setTimeout((()=>{Dr=!1}),350))}}),[t,a,e,n]),(0,Js.Z)((([t])=>{if(s!==c.vi.Profile||s===t)return;const a=e.current;if(!a)return;const n=a.querySelector(".TabList");!n||n.offsetTop>a.scrollTop||(Dr=!0,(0,Ja.ZP)(a,a.firstElementChild,"start",void 0,2*a.offsetHeight),setTimeout((()=>{Dr=!1}),350))}),[s,e]);const o=(0,qt.Z)((()=>{const s=e.current;if(!s)return;const n=s.querySelector(".TabList");if(!n)return;let o=c.vi.Profile;s.scrollTop>=n.offsetTop&&(o=jr(t)),a(o)}));return(0,Tt.d4)((()=>{Dr||o()}),[o,t]),{handleScroll:(0,qt.Z)((()=>{Dr||Fr(o)}))}}(ne,we,s,i,G),{applyTransitionFix:Me,releaseTransitionFix:Ee}=function(e,t=".Transition.shared-media-transition"){return(0,Tt.d4)((()=>{function s(){const s=e.current,a=s.querySelector(t),n=s.querySelector(".TabList");if(a&&n){const e=s.offsetHeight-n.offsetHeight;(0,Bt.WM)((()=>{a.style.minHeight=`${e}px`}))}}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]),{applyTransitionFix:(0,qt.Z)((()=>{(0,Bt.i$)((()=>{const t=e.current;if("hidden"===t.style.overflowY)return;const s=t.offsetWidth-t.clientWidth;(0,Bt.WM)((()=>{t.style.overflowY="hidden",t.style.paddingRight=`${s}px`}))}))})),releaseTransitionFix:(0,qt.Z)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.paddingRight="0"}))}}(ne),[Re,ke]=(()=>{const[e,t]=(0,Tt.eJ)(0);return[e,(0,Tt.I4)((()=>{t((e=>e+1))}),[])]})(),{observe:Te}=(0,gn.S1)({rootRef:ne,throttleMs:500}),Ne=(0,qt.Z)((()=>{Ee(),ke()})),Ae=(0,qt.Z)((()=>{Q({newChatMembersProgress:c.WB.InProgress})}));(0,Tt.d4)((()=>{H({mediaType:fe})}),[H,fe,t]),(0,Tt.d4)((()=>{X({profileId:de})}),[de]);const Be=(0,qt.Z)((e=>{J({chatId:de,threadId:r._f,mediaId:e,origin:c.bZ.SharedMedia})})),xe=(0,qt.Z)((e=>{W({chatId:de,messageId:e})})),Ue=(0,qt.Z)((e=>{z({id:e})})),Le=(0,qt.Z)((e=>{Y({chatId:de,messageId:e})})),_e=(0,qt.Z)((()=>{ce(void 0)}));let Oe;(0,Js.Z)((([e])=>{if(void 0===e||0===he||e===P)return;const t=he+(P?1:-1);pe(Math.min(t,ue.length-1))}),[P,he,ue]),(0,Tt.d4)((()=>{if(oe.current&&o.$b)return(0,Zs.sf)(oe.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Zs.eM.Left?(pe(Math.min(ge+1,ue.length-1)),!0):t===Zs.eM.Right&&(pe(Math.max(0,ge-1)),!0)})}),[ge,ue.length]),Ze?Oe=A?0:1e3:be||(Oe=n.Yan);const Fe=(0,Co.Z)([e,t,we,ge],Oe);return Tt.ZP.createElement(Qr.Z,{ref:ne,className:"Profile custom-scroll",itemSelector:`.shared-media-transition > .Transition_slide-active.${we}-list > .scroll-item`,items:Fe?be:void 0,cacheBuster:Re,sensitiveArea:n.qUX,preloadBackwards:Fe?"members"===we?n.Vk:n.ENB:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:ye,onScroll:Ce},!Pe&&!le&&function(e,t,s){return Tt.ZP.createElement("div",{className:"profile-info"},Tt.ZP.createElement(Kr.Z,{userId:e,canPlayVideo:t}),Tt.ZP.createElement(Vr.Z,{chatOrUserId:e,isSavedDialog:s}))}(de,A&&Fe,q),!B&&Tt.ZP.createElement("div",{className:"shared-media"},Tt.ZP.createElement(hs.ZP,{ref:oe,name:ie.isRtl?"slideOptimizedRtl":"slideOptimized",activeKey:Se,renderCount:ue.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:Me,onStop:Ne},function(){if("dialogs"===we)return Tt.ZP.createElement(Es.Z,{className:"saved-dialogs",folderType:"saved",isActive:!0});if(!be||!Fe||!h){const e=Ze&&!Fe,t=Boolean("members"===we&&Z);return Tt.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&Tt.ZP.createElement(js.Z,null),t&&Tt.ZP.createElement(zr.Z,{text:"You have no access to group members list."}))}if(!be.length){let e;switch(we){case"members":e=Z?"You have no access to group members list.":"No members found";break;case"commonChats":e=ie("NoGroupsInCommon");break;case"documents":e=ie("lng_media_file_empty");break;case"links":e=ie("lng_media_link_empty");break;case"audio":e=ie("lng_media_song_empty");break;case"voice":e=ie("lng_media_audio_empty");break;case"stories":e=ie("StoryList.SavedEmptyState.Title");break;case"storiesArchive":e=ie("StoryList.ArchivedEmptyState.Title");break;default:e=ie("SharedMedia.EmptyTitle")}return Tt.ZP.createElement("div",{className:"content empty-list"},Tt.ZP.createElement(zr.Z,{text:e}))}return Tt.ZP.createElement("div",{className:`content ${we}-list`,dir:ie.isRtl&&"media"===we?"rtl":void 0,teactFastList:!0},"media"===we?be.map((e=>h[e]&&Tt.ZP.createElement($r.Z,{key:e,message:h[e],isProtected:U||h[e].isProtected,observeIntersection:Te,onClick:Be}))):"stories"===we||"storiesArchive"===we?be.map((e=>I?.[e]&&Tt.ZP.createElement(Xr,{key:`${we}_${e}`,story:I[e],isProtected:U,isArchive:"storiesArchive"===we}))):"documents"===we?be.map((e=>h[e]&&Tt.ZP.createElement(Xn.Z,{key:e,message:h[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:x?.includes(e),observeIntersection:Te,onDateClick:Le,shouldWarnAboutSvg:_}))):"links"===we?be.map((e=>h[e]&&Tt.ZP.createElement(Jr.Z,{key:e,message:h[e],isProtected:U||h[e].isProtected,observeIntersection:Te,onMessageClick:Le}))):"audio"===we?be.map((e=>h[e]&&Tt.ZP.createElement(Wn.ZP,{key:e,theme:d,message:h[e],origin:c.Cr.SharedMedia,date:h[e].date,className:"scroll-item",onPlay:xe,onDateClick:Le,canDownload:!U&&!h[e].isProtected,isDownloading:x?.includes(e)}))):"voice"===we?be.map((e=>h[e]&&Tt.ZP.createElement(Wn.ZP,{key:e,theme:d,message:h[e],senderTitle:(0,_r.F)(ie,h[e],N,k),origin:c.Cr.SharedMedia,date:h[e].date,className:"scroll-item",onPlay:xe,onDateClick:Le,canDownload:!U&&!h[e].isProtected,isDownloading:x?.includes(e)}))):"members"===we?be.map(((e,t)=>{return Tt.ZP.createElement(ec.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable contact-list-item scroll-item small-icon",onClick:()=>Ue(e),contextActions:(s=e,s!==m&&C?[{title:ie("lng_context_remove_from_group"),icon:"stop",handler:()=>{ce(s)}}]:void 0)},Tt.ZP.createElement(Yi.Z,{userId:e,adminMember:R?.[e],forceShowSelf:!0,withStory:!0}));var s})):"commonChats"===we?be.map(((e,t)=>Tt.ZP.createElement(ec.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>z({id:e})},Tt.ZP.createElement(Wi.Z,{chatId:e})))):"similarChannels"===we?Tt.ZP.createElement("div",{key:we},be.map(((e,t)=>Tt.ZP.createElement(ec.Z,{key:e,teactOrderKey:t,className:(0,xt.Z)("chat-item-clickable search-result",!F&&t===O.length-1&&"blured"),onClick:()=>z({id:e})},Tt.ZP.createElement(Wi.Z,{avatarSize:"large",chatId:e,withFullInfo:!0})))),!F&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement(vs.Z,{className:"show-more-channels",size:"smaller",onClick:()=>se()},ie("UnlockSimilar"),Tt.ZP.createElement("i",{className:"icon icon-unlock-badge"})),Tt.ZP.createElement("div",{className:"more-similar"},(0,ga.Z)(ie("MoreSimilarText",D),["simple_markdown"])))):void 0)}()),Tt.ZP.createElement(Ms.Z,{big:!0,activeTab:ge,tabs:ue,onSwitchTab:pe})),S&&Tt.ZP.createElement(Tr.Z,{isShown:"members"===we,onClick:Ae,ariaLabel:ie("lng_channel_add_users")},Tt.ZP.createElement("i",{className:"icon icon-add-user-filled"})),C&&Tt.ZP.createElement(tc.Z,{isOpen:Boolean(re),userId:re,onClose:_e}))}))),nc=450+n.fK3,oc=(0,f.Ds)((e=>e()),200,!1);var ic=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.StoryStatistics=7]="StoryStatistics",e[e.BoostStatistics=8]="BoostStatistics",e[e.Management=9]="Management",e[e.ManageInitial=10]="ManageInitial",e[e.ManageChannelSubscribers=11]="ManageChannelSubscribers",e[e.ManageChatAdministrators=12]="ManageChatAdministrators",e[e.ManageChatPrivacyType=13]="ManageChatPrivacyType",e[e.ManageDiscussion=14]="ManageDiscussion",e[e.ManageGroupPermissions=15]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=16]="ManageGroupRemovedUsers",e[e.ManageChannelRemovedUsers=17]="ManageChannelRemovedUsers",e[e.ManageGroupUserPermissionsCreate=18]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=19]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=20]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=21]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=22]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=23]="ManageGroupMembers",e[e.ManageGroupAddAdmins=24]="ManageGroupAddAdmins",e[e.StickerSearch=25]="StickerSearch",e[e.GifSearch=26]="GifSearch",e[e.PollResults=27]="PollResults",e[e.AddingMembers=28]="AddingMembers",e[e.ManageInvites=29]="ManageInvites",e[e.ManageEditInvite=30]="ManageEditInvite",e[e.ManageReactions=31]="ManageReactions",e[e.ManageInviteInfo=32]="ManageInviteInfo",e[e.ManageJoinRequests=33]="ManageJoinRequests",e[e.CreateTopic=34]="CreateTopic",e[e.EditTopic=35]="EditTopic",e[e.SavedDialogs=36]="SavedDialogs",e}(ic||{});const rc=(0,a.c$)(((e,{chatId:t,isProfile:s,isManagement:a,threadId:n})=>{const o=(0,y.jUK)(e),{query:i}=(0,y.n5x)(e)||{},{query:c}=(0,y.y5E)(e)||{},{query:d}=(0,y.yNS)(e)||{},l=t?(0,y.Z1J)(e,t):void 0,u=s&&t&&(0,v.YC)(t)?(0,y.dyD)(e,t):void 0,m=l&&(0,v.eA)(l),h=l?.isForum&&Boolean(n&&n!==r._f),p=h?l.topics?.[n]:void 0,g=h&&p&&(0,v.GU)(l,p),f=u&&(0,v.cS)(u),I=t?(0,y.FM1)(e,t):void 0,w=f&&u?.canEditBot,b=u&&(0,v.kw)(u),P=Boolean(!a&&s&&t&&(0,y.Yo)(e,t)),Z=Boolean(t&&o.management.byChatId[t]?.editingInvite),S=!h&&t?(0,y.x67)(e,t)?.canViewStatistics:void 0,C=t?o.management.byChatId[t]?.inviteInfo?.invite:void 0;return{canManage:P,canAddContact:b,canViewStatistics:S,isChannel:m,isBot:f,isInsideTopic:h,canEditTopic:g,userId:u?.id,isSelf:u?.isSelf,messageSearchQuery:i,stickerSearchQuery:c,gifSearchQuery:d,isEditingInvite:Z,currentInviteInfo:C,isSavedMessages:I,shouldSkipHistoryAnimations:o.shouldSkipHistoryAnimations,canEditBot:w}}))((({chatId:e,threadId:t,isColumnOpen:s,isProfile:o,isSearch:i,isManagement:r,isStatistics:d,isMessageStatistics:l,isStoryStatistics:u,isBoostStatistics:m,isStickerSearch:h,isGifSearch:p,isPollResults:g,isCreatingTopic:f,isEditingTopic:I,isAddingChatMembers:v,profileState:w,managementScreen:b,canAddContact:y,userId:P,isSelf:Z,canManage:S,isChannel:C,messageSearchQuery:M,stickerSearchQuery:E,gifSearchQuery:R,isEditingInvite:k,canViewStatistics:T,currentInviteInfo:N,shouldSkipHistoryAnimations:A,isBot:B,isInsideTopic:U,canEditTopic:L,isSavedMessages:_,onClose:O,onScreenSelect:F,canEditBot:D})=>{const{setLocalTextSearchQuery:j,setStickerSearchQuery:q,setGifSearchQuery:G,searchTextMessagesLocal:H,toggleManagement:V,openHistoryCalendar:$,openAddContactDialog:z,toggleStatistics:K,setEditingExportedInvite:J,deleteExportedChatInvite:W,openEditTopicPanel:Y}=(0,a.Sv)(),[X,Q,ee]=(0,xs.Z)(),{isMobile:te}=(0,x.ZP)(),se=(0,is.mE)(),ae=(0,qt.Z)((()=>{J({chatId:e,invite:N}),F(c.u1.EditInvite)})),ne=(0,qt.Z)((()=>{W({chatId:e,link:N.link}),F(c.u1.Invites),ee()})),oe=(0,qt.Z)((e=>{j({query:e}),e.length&&oc(H)})),ie=(0,qt.Z)((e=>{q({query:e})})),re=(0,qt.Z)((e=>{G({query:e})})),de=(0,qt.Z)((()=>{z({userId:P})})),le=(0,qt.Z)((()=>{e&&t&&Y({chatId:e,topicId:Number(t)})})),ue=(0,qt.Z)((()=>{V()})),me=(0,qt.Z)((()=>{K()})),he=(0,qt.Z)((()=>{O(!_)})),[pe,ge]=(0,Tt.eJ)(!s);(0,Tt.d4)((()=>{setTimeout((()=>{ge(!s)}),nc)}),[s]);const fe=(0,Is.Z)(),Ie=o?w===c.vi.Profile?ic.Profile:w===c.vi.SharedMedia?ic.SharedMedia:w===c.vi.MemberList?ic.MemberList:w===c.vi.StoryList?ic.StoryList:w===c.vi.SavedDialogs?ic.SavedDialogs:-1:i?ic.Search:g?ic.PollResults:h?ic.StickerSearch:p?ic.GifSearch:v?ic.AddingMembers:r?b===c.u1.Initial?ic.ManageInitial:b===c.u1.ChatPrivacyType?ic.ManageChatPrivacyType:b===c.u1.Discussion?ic.ManageDiscussion:b===c.u1.ChannelSubscribers?ic.ManageChannelSubscribers:b===c.u1.GroupPermissions?ic.ManageGroupPermissions:b===c.u1.ChatAdministrators?ic.ManageChatAdministrators:b===c.u1.GroupRemovedUsers?ic.ManageGroupRemovedUsers:b===c.u1.ChannelRemovedUsers?ic.ManageChannelRemovedUsers:b===c.u1.GroupUserPermissionsCreate?ic.ManageGroupUserPermissionsCreate:b===c.u1.GroupUserPermissions?ic.ManageGroupUserPermissions:b===c.u1.GroupRecentActions?ic.ManageGroupRecentActions:b===c.u1.ChatAdminRights?ic.ManageGroupAdminRights:b===c.u1.ChatNewAdminRights?ic.ManageGroupNewAdminRights:b===c.u1.GroupMembers?ic.ManageGroupMembers:b===c.u1.Invites?ic.ManageInvites:b===c.u1.EditInvite?ic.ManageEditInvite:b===c.u1.GroupAddAdmins?ic.ManageGroupAddAdmins:b===c.u1.Reactions?ic.ManageReactions:b===c.u1.InviteInfo?ic.ManageInviteInfo:b===c.u1.JoinRequests?ic.ManageJoinRequests:void 0:d?ic.Statistics:l?ic.MessageStatistics:u?ic.StoryStatistics:m?ic.BoostStatistics:f?ic.CreateTopic:I?ic.EditTopic:void 0,ve=(0,zi.Z)(Ie,!0)??-1,we=te||!_&&(Ie===ic.SharedMedia||Ie===ic.MemberList||Ie===ic.StoryList||Ie===ic.AddingMembers||Ie===ic.MessageStatistics||Ie===ic.StoryStatistics||r),be=(0,xt.Z)("animated-close-icon",we&&"state-back",(pe||A)&&"no-transition"),ye=(0,Tt.sO)(null);return(0,Bs.Z)(ye),Tt.ZP.createElement("div",{className:"RightHeader",ref:ye},Tt.ZP.createElement(vs.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:he,ariaLabel:fe(we?"Common.Back":"Common.Close")},Tt.ZP.createElement("div",{className:be})),Tt.ZP.createElement(hs.ZP,{name:pe||A?"none":"slideFade",activeKey:ve},function(){if(-1!==ve)switch(ve){case ic.PollResults:return Tt.ZP.createElement("h3",{className:"title"},fe("PollResults"));case ic.Search:return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement(Fs.Z,{parentContainerClassName:"RightSearch",value:M,onChange:oe}),Tt.ZP.createElement(vs.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>$({selectedAt:(0,ce._F)(Date.now())}),ariaLabel:"Search messages by date"},Tt.ZP.createElement("i",{className:"icon icon-calendar"})));case ic.AddingMembers:return Tt.ZP.createElement("h3",{className:"title"},fe(C?"ChannelAddSubscribers":"GroupAddMembers"));case ic.ManageInitial:return Tt.ZP.createElement("h3",{className:"title"},fe("Edit"));case ic.ManageChatPrivacyType:return Tt.ZP.createElement("h3",{className:"title"},fe(C?"ChannelTypeHeader":"GroupTypeHeader"));case ic.ManageDiscussion:return Tt.ZP.createElement("h3",{className:"title"},fe("Discussion"));case ic.ManageChatAdministrators:return Tt.ZP.createElement("h3",{className:"title"},fe("ChannelAdministrators"));case ic.ManageGroupRecentActions:return Tt.ZP.createElement("h3",{className:"title"},fe("Group.Info.AdminLog"));case ic.ManageGroupAdminRights:return Tt.ZP.createElement("h3",{className:"title"},fe("EditAdminRights"));case ic.ManageGroupNewAdminRights:return Tt.ZP.createElement("h3",{className:"title"},fe("SetAsAdmin"));case ic.ManageGroupPermissions:return Tt.ZP.createElement("h3",{className:"title"},fe("ChannelPermissions"));case ic.ManageGroupRemovedUsers:return Tt.ZP.createElement("h3",{className:"title"},fe("BlockedUsers"));case ic.ManageChannelRemovedUsers:return Tt.ZP.createElement("h3",{className:"title"},fe("ChannelBlockedUsers"));case ic.ManageGroupUserPermissionsCreate:return Tt.ZP.createElement("h3",{className:"title"},fe("ChannelAddException"));case ic.ManageGroupUserPermissions:return Tt.ZP.createElement("h3",{className:"title"},fe("UserRestrictions"));case ic.ManageInvites:return Tt.ZP.createElement("h3",{className:"title"},fe("lng_group_invite_title"));case ic.ManageEditInvite:return Tt.ZP.createElement("h3",{className:"title"},fe(k?"EditLink":"NewLink"));case ic.ManageInviteInfo:return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("h3",{className:"title"},fe("InviteLink")),Tt.ZP.createElement("section",{className:"tools"},N&&!N.isRevoked&&Tt.ZP.createElement(vs.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:fe("Edit"),onClick:ae},Tt.ZP.createElement("i",{className:"icon icon-edit"})),N&&N.isRevoked&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement(vs.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:fe("Delete"),onClick:Q},Tt.ZP.createElement("i",{className:"icon icon-delete"})),Tt.ZP.createElement(Fo.Z,{isOpen:X,onClose:ee,title:fe("DeleteLink"),text:fe("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:fe("Delete"),confirmHandler:ne}))));case ic.ManageJoinRequests:return Tt.ZP.createElement("h3",{className:"title"},fe(C?"SubscribeRequests":"MemberRequests"));case ic.ManageGroupAddAdmins:return Tt.ZP.createElement("h3",{className:"title"},fe("Channel.Management.AddModerator"));case ic.StickerSearch:return Tt.ZP.createElement(Fs.Z,{value:E,placeholder:fe("SearchStickersHint"),autoFocusSearch:!0,onChange:ie});case ic.GifSearch:return Tt.ZP.createElement(Fs.Z,{value:R,placeholder:fe("SearchGifsTitle"),autoFocusSearch:!0,onChange:re});case ic.Statistics:return Tt.ZP.createElement("h3",{className:"title"},fe(C?"ChannelStats.Title":"GroupStats.Title"));case ic.MessageStatistics:return Tt.ZP.createElement("h3",{className:"title"},fe("Stats.MessageTitle"));case ic.StoryStatistics:return Tt.ZP.createElement("h3",{className:"title"},fe("Stats.StoryTitle"));case ic.BoostStatistics:return Tt.ZP.createElement("h3",{className:"title"},fe("Boosts"));case ic.SharedMedia:return Tt.ZP.createElement("h3",{className:"title"},fe("SharedMedia"));case ic.ManageChannelSubscribers:return Tt.ZP.createElement("h3",{className:"title"},fe("ChannelSubscribers"));case ic.MemberList:case ic.ManageGroupMembers:return Tt.ZP.createElement("h3",{className:"title"},fe("GroupMembers"));case ic.StoryList:return Tt.ZP.createElement("h3",{className:"title"},fe(Z?"Settings.MyStories":"PeerInfo.PaneStories"));case ic.SavedDialogs:return Tt.ZP.createElement("div",{className:"header"},Tt.ZP.createElement("h3",{className:"title"},fe("SavedMessagesTab")),Tt.ZP.createElement("div",{className:"subtitle"},fe("Chats",se[n.aV7])));case ic.ManageReactions:return Tt.ZP.createElement("h3",{className:"title"},fe("Reactions"));case ic.CreateTopic:return Tt.ZP.createElement("h3",{className:"title"},fe("NewTopic"));case ic.EditTopic:return Tt.ZP.createElement("h3",{className:"title"},fe("EditTopic"));default:return Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("h3",{className:"title"},fe(_?"SavedMessages":U?"AccDescrTopic":C?"Channel.TitleInfo":P?B?"lng_info_bot_title":"lng_info_user_title":"GroupInfo.Title")),Tt.ZP.createElement("section",{className:"tools"},y&&Tt.ZP.createElement(vs.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:fe("AddContact"),onClick:de},Tt.ZP.createElement("i",{className:"icon icon-add-user","aria-hidden":!0})),S&&!U&&Tt.ZP.createElement(vs.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:fe("Edit"),onClick:ue},Tt.ZP.createElement("i",{className:"icon icon-edit"})),D&&Tt.ZP.createElement(vs.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:fe("Edit"),onClick:ue},Tt.ZP.createElement(so.Z,{name:"edit"})),L&&Tt.ZP.createElement(vs.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:fe("EditTopic"),onClick:le},Tt.ZP.createElement("i",{className:"icon icon-edit"})),T&&Tt.ZP.createElement(vs.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:fe("Statistics"),onClick:me},Tt.ZP.createElement("i",{className:"icon icon-stats"}))))}}()))})),cc=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"RightSearch");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)};var dc=s(4830),lc=s(12007),uc=s(66),mc=s(16289);const hc={root:"gk6pIryJ",noResults:"WP4wRUbm","section-header":"LWcgK3OX",sectionHeader:"LWcgK3OX",section:"C8KF95yU",user:"oMy5KOFr",stats:"GOzrl0zF",down:"QuLtxDUV",loadMoreSpinner:"ln5zB7KK"},pc=(0,Tt.X$)((0,a.c$)((e=>({boostStatistics:(0,y.jUK)(e).boostStatistics})))((({boostStatistics:e})=>{const{openChat:t,loadMoreBoosters:s,closeBoostStatistics:n}=(0,a.Sv)(),o=(0,Is.Z)(),i=e?.boostStatus,r=i?e.boostStatus:void 0,{currentLevel:c,hasNextLevel:d,boosts:l,levelProgress:u,remainingBoosts:m}=(0,Tt.Ye)((()=>r?(0,dc.k)(r):{currentLevel:0,hasNextLevel:!1,boosts:0,levelProgress:0,remainingBoosts:0}),[r]),h=(0,Tt.Ye)((()=>{if(r)return{level:c,boosts:l,premiumSubscribers:r.premiumSubscribers,remainingBoosts:m}}),[r,l,c,m]),p=(0,Tt.Ye)((()=>{if(!e?.count)return;const t=e.boosterIds?.length||0;return e.count-t}),[e]),g=(0,qt.Z)((e=>{t({id:e}),n()})),f=(0,qt.Z)((()=>{s()}));return Tt.ZP.createElement("div",{className:(0,xt.Z)(hc.root,"custom-scroll")},!i&&Tt.ZP.createElement(ps.Z,null),i&&h&&Tt.ZP.createElement(Tt.ZP.Fragment,null,Tt.ZP.createElement("div",{className:hc.section},Tt.ZP.createElement(uc.Z,{leftText:o("BoostsLevel",c),rightText:d?o("BoostsLevel",c+1):void 0,progress:u,floatingBadgeText:l.toString(),floatingBadgeIcon:"boost"}),Tt.ZP.createElement(mc.Z,{className:hc.stats,statistics:h,type:"boost"})),Tt.ZP.createElement("div",{className:hc.section},Tt.ZP.createElement("h4",{className:hc.sectionHeader,dir:o.isRtl?"rtl":void 0},o("Boosters")),!e.boosterIds?.length&&Tt.ZP.createElement("div",{className:hc.noResults},o("NoBoostersHint")),e.boosterIds?.map((t=>Tt.ZP.createElement(ec.Z,{key:t,className:"chat-item-clickable",onClick:()=>g(t)},Tt.ZP.createElement(Yi.Z,{className:hc.user,forceShowSelf:!0,userId:t,status:o("BoostExpireOn",(0,ce.$M)(o,1e3*e.boosters[t]))})))),Boolean(p)&&Tt.ZP.createElement(ec.Z,{key:"load-more",className:hc.showMore,disabled:e?.isLoadingBoosters,onClick:f},e?.isLoadingBoosters?Tt.ZP.createElement(js.Z,{className:hc.loadMoreSpinner}):Tt.ZP.createElement(so.Z,{name:"down",className:hc.down}),o("ShowVotes",p))),Tt.ZP.createElement(lc.Z,{className:hc.section,link:r.boostUrl,withShare:!0,title:o("LinkForBoosting")})))}))),gc=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"MessageStatistics");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},fc=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"Statistics");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},Ic=e=>{const t=(0,Yt.Z)(_t.gl.Extra,"StoryStatistics");return t?Tt.ZP.createElement(t,e):Tt.ZP.createElement(ps.Z,null)},vc=()=>{const e=(0,Yt.Z)(_t.gl.Extra,"StickerSearch");return e?Tt.ZP.createElement(e,null):Tt.ZP.createElement(ps.Z,null)},wc=450+n.fK3,bc=Object.keys(c.qt).length/2,yc=Object.keys(c.u1).length/2;function Pc(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Zc=(0,Tt.X$)((0,a.c$)(((e,{isMobile:t})=>{const{chatId:s,threadId:a}=(0,y.Btg)(e)||{},n=(0,y.g4C)(e),{management:o,shouldSkipHistoryAnimations:i,nextProfileTab:r}=(0,y.jUK)(e),c=s?o.byChatId[s]?.nextScreen:void 0,d=s?(0,y.FM1)(e,s):void 0,l=s?(0,v._o)(s,a,e.currentUserId):void 0;return{contentKey:(0,y.WqZ)(e,t),chatId:s,threadId:a,isChatSelected:Boolean(s&&n),shouldSkipHistoryAnimations:i,nextManagementScreen:c,nextProfileTab:r,isSavedMessages:d,isSavedDialog:l}}))((({contentKey:e,chatId:t,threadId:s,isMobile:o,isChatSelected:i,shouldSkipHistoryAnimations:r,nextManagementScreen:d,nextProfileTab:l,isSavedMessages:u,isSavedDialog:m})=>{const{toggleChatInfo:h,toggleManagement:p,closeLocalTextSearch:g,setStickerSearchQuery:f,setGifSearchQuery:I,closePollResults:v,addChatMembers:w,setNewChatMembersDialogState:b,setEditingExportedInvite:y,toggleStatistics:P,toggleMessageStatistics:Z,toggleStoryStatistics:S,setOpenedInviteInfo:C,requestNextManagementScreen:M,resetNextProfileTab:E,closeCreateTopicPanel:R,closeEditTopicPanel:k,closeBoostStatistics:T}=(0,a.Sv)(),{width:N}=(0,_a.Z)(),[A,B]=(0,Tt.eJ)(u&&!m?c.vi.SavedDialogs:c.vi.Profile),[x,U]=(0,Tt.eJ)(c.u1.Initial),[L,_]=(0,Tt.eJ)(),[O,F]=(0,Tt.eJ)(),D=A!==c.vi.Profile,j=void 0!==e,q=e===c.qt.ChatInfo,G=e===c.qt.Search,H=e===c.qt.Management,V=e===c.qt.Statistics,$=e===c.qt.MessageStatistics,z=e===c.qt.StoryStatistics,K=e===c.qt.BoostStatistics,J=e===c.qt.StickerSearch,W=e===c.qt.GifSearch,Y=e===c.qt.PollResults,X=e===c.qt.AddingMembers,Q=e===c.qt.CreateTopic,ee=e===c.qt.EditTopic,te=N<=n._mX,[se,ae]=(0,Tt.eJ)(!j),ne=(0,zi.Z)(e,!0,!i)??-1,oe=(0,qt.Z)(((s=!0)=>{switch(e){case c.qt.AddingMembers:b({newChatMembersProgress:c.WB.Closed});break;case c.qt.ChatInfo:if(D&&s&&!u){B(c.vi.Profile);break}h({force:!1},{forceSyncOnIOs:!0});break;case c.qt.Management:switch(x){case c.u1.Initial:p();break;case c.u1.ChatPrivacyType:case c.u1.Discussion:case c.u1.GroupPermissions:case c.u1.GroupType:case c.u1.ChatAdministrators:case c.u1.ChannelSubscribers:case c.u1.GroupMembers:case c.u1.Invites:case c.u1.Reactions:case c.u1.JoinRequests:case c.u1.ChannelRemovedUsers:U(c.u1.Initial);break;case c.u1.GroupUserPermissionsCreate:case c.u1.GroupRemovedUsers:case c.u1.GroupUserPermissions:U(c.u1.GroupPermissions),_(void 0),F(void 0);break;case c.u1.ChatAdminRights:case c.u1.ChatNewAdminRights:case c.u1.GroupAddAdmins:case c.u1.GroupRecentActions:U(c.u1.ChatAdministrators);break;case c.u1.EditInvite:case c.u1.InviteInfo:U(c.u1.Invites),C({chatId:t,invite:void 0}),y({chatId:t,invite:void 0})}break;case c.qt.MessageStatistics:Z();break;case c.qt.StoryStatistics:S();break;case c.qt.Statistics:P();break;case c.qt.BoostStatistics:T();break;case c.qt.Search:Pc(),g();break;case c.qt.StickerSearch:Pc(),f({query:void 0});break;case c.qt.GifSearch:Pc(),I({query:void 0});break;case c.qt.PollResults:v();break;case c.qt.CreateTopic:R();break;case c.qt.EditTopic:k()}})),ie=(0,qt.Z)(((e,t)=>{_(e),F(t)})),re=(0,qt.Z)((e=>{w({chatId:t,memberIds:e})}));function ce(e){if(-1!==ne)switch(ne){case c.qt.AddingMembers:return Tt.ZP.createElement(Nr,{key:`add_chat_members_${t}`,chatId:t,isActive:j&&e,onNextStep:re,onClose:oe});case c.qt.ChatInfo:return Tt.ZP.createElement(ac,{key:`profile_${t}_${s}`,chatId:t,threadId:s,profileState:A,isMobile:o,onProfileStateChange:B});case c.qt.Search:return Tt.ZP.createElement(cc,{key:`right_search_${t}`,chatId:t,threadId:s,onClose:oe,isActive:j&&e});case c.qt.Management:return Tt.ZP.createElement(Ur,{key:`management_${t}_${x}`,chatId:t,currentScreen:x,isPromotedByCurrentUser:O,selectedChatMemberId:L,isActive:j&&e,onScreenSelect:U,onChatMemberSelect:ie,onClose:oe});case c.qt.Statistics:return Tt.ZP.createElement(fc,{chatId:t});case c.qt.BoostStatistics:return Tt.ZP.createElement(pc,null);case c.qt.MessageStatistics:return Tt.ZP.createElement(gc,{chatId:t,isActive:j&&e});case c.qt.StoryStatistics:return Tt.ZP.createElement(Ic,{chatId:t,isActive:j&&e});case c.qt.StickerSearch:return Tt.ZP.createElement(vc,{onClose:oe,isActive:j&&e});case c.qt.GifSearch:return Tt.ZP.createElement(xr,{onClose:oe,isActive:j&&e});case c.qt.PollResults:return Tt.ZP.createElement(Lr,{onClose:oe,isActive:j&&e});case c.qt.CreateTopic:return Tt.ZP.createElement(Ar,{onClose:oe,isActive:j&&e});case c.qt.EditTopic:return Tt.ZP.createElement(Br,{onClose:oe,isActive:j&&e})}}return(0,Tt.d4)((()=>j&&t?(0,cs.Z)(oe):void 0),[j,oe,t]),(0,Tt.d4)((()=>{setTimeout((()=>{ae(!j)}),wc)}),[j]),(0,Tt.d4)((()=>{d&&(U(d),M(void 0))}),[d]),(0,Tt.d4)((()=>{l&&E()}),[l]),(0,Tt.d4)((()=>{j&&te&&oe()}),[te]),(0,an.Z)((([e,a])=>{e===t&&a===s||(B(u&&!m?c.vi.SavedDialogs:c.vi.Profile),U(c.u1.Initial))}),[t,s,m,u]),(0,Ss.Z)({isActive:i&&(e===c.qt.ChatInfo||e===c.qt.Management||e===c.qt.AddingMembers||e===c.qt.CreateTopic||e===c.qt.EditTopic),onBack:()=>oe(!1)}),Tt.ZP.createElement("div",{id:"RightColumn-wrapper",className:i?void 0:"is-hidden"},te&&Tt.ZP.createElement("div",{className:"overlay-backdrop",onClick:oe}),Tt.ZP.createElement("div",{id:"RightColumn"},Tt.ZP.createElement(rc,{chatId:t,threadId:s,isColumnOpen:j,isProfile:q,isSearch:G,isManagement:H,isStatistics:V,isBoostStatistics:K,isMessageStatistics:$,isStoryStatistics:z,isStickerSearch:J,isGifSearch:W,isPollResults:Y,isCreatingTopic:Q,isEditingTopic:ee,isAddingChatMembers:X,profileState:A,managementScreen:x,onClose:oe,onScreenSelect:U}),Tt.ZP.createElement(hs.ZP,{name:se||r?"none":"zoomFade",renderCount:bc+yc,activeKey:H?bc+x:ne,shouldCleanup:!0,cleanupExceptionKey:ne===c.qt.MessageStatistics||ne===c.qt.StoryStatistics?c.qt.Statistics:void 0},ce)))}))),Sc=(0,Tt.X$)((({isOpen:e})=>{const t=(0,Yt.Z)(_t.gl.Extra,"StoryViewer",!e);return t?Tt.ZP.createElement(t,null):void 0})),Cc=e=>{const{requestedAttachBotInChat:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"AttachBotRecipientPicker",!t);return s?Tt.ZP.createElement(s,e):void 0},Mc=e=>{const{bot:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"BotTrustModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Ec={root:"e0JMk_Kh"},Rc=["#E8BC2C","#D0049E","#02CBFE","#5723FD","#FE8C27","#6CB859"],kc=(0,Tt.X$)((0,a.c$)((e=>(0,h.ei)((0,y.jUK)(e),["confetti"])))((({confetti:e})=>{const t=(0,Tt.sO)(null),s=(0,Tt.sO)([]),a=(0,Tt.sO)(!1),n=(0,_a.Z)(),o=(0,Dt.Z)(),{isMobile:i}=(0,x.ZP)(),r=i?50:100,{lastConfettiTime:c,top:d,width:l,left:u,height:m}=e||{},h=(0,Tt.I4)(((e,t,a=r)=>{for(let n=0;n<a;n++){const a=n%2,o={x:e*(a?-.1:1.1),y:.75*t},i=Math.random()*e*1.5,r={x:a?i:-1*i,y:-t/2-Math.random()*t},c=Rc[Math.floor(Math.random()*Rc.length)],d=10;s.current.push({pos:o,size:d,color:c,velocity:r,flicker:d,flickerFrequency:.2*Math.random(),rotation:0,lastDrawnAt:Date.now(),frameCount:0})}}),[r]),p=(0,Tt.I4)((()=>{if(!t.current||!a.current)return;const e=t.current,n=e.getContext("2d");if(!n)return;const{width:o,height:i}=e;n.clearRect(0,0,o,i);const r=[];s.current.forEach(((e,t)=>{const{pos:a,velocity:o,size:c,color:d,flicker:l,flickerFrequency:u,rotation:m,lastDrawnAt:h,frameCount:p}=e,g=(Date.now()-h)/1e3,f={x:a.x+o.x*g,y:a.y+o.y*g},I={x:.98*o.x,y:o.y+=1e3*g},v=c*Math.abs(Math.sin(p*u)),w=5*p*u*(Math.PI/180),b=p+1,y=Date.now();if(f.y>i+e.size)return void r.push(e);const P={...e,pos:f,velocity:I,flicker:v,rotation:w,lastDrawnAt:y,frameCount:b};s.current[t]=P,n.fillStyle=d,n.beginPath(),n.ellipse(a.x,a.y,c,l,m,0,2*Math.PI),n.fill()})),s.current=s.current.filter((e=>!r.includes(e))),s.current.length?(0,Bt.i$)(p):a.current=!1}),[]);if((0,zt.Z)((([e])=>{let t;return e!==c&&(h(l||n.width,m||n.height),t=setTimeout(o,1e4),a.current||(a.current=!0,(0,Bt.i$)(p))),()=>{clearTimeout(t)}}),[c,o,p]),!c||Date.now()-c>1e4)return;const g=(0,Aa.Z)(Boolean(d)&&`top: ${d}px`,Boolean(u)&&`left: ${u}px`,Boolean(l)&&`width: ${l}px`,Boolean(m)&&`height: ${m}px`);return Tt.ZP.createElement("div",{id:"Confetti",className:Ec.root,style:g},Tt.ZP.createElement("canvas",{ref:t,className:Ec.canvas,width:n.width,height:n.height}))}))),Tc=e=>{const{folder:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"DeleteFolderDialog",!t);return s?Tt.ZP.createElement(s,e):void 0},Nc=({isOpen:e})=>{const t=(0,Yt.Z)(_t.gl.Extra,"Dialogs",!e);return t?Tt.ZP.createElement(t,null):void 0};var Ac=s(6562);const Bc=new Set,xc=new Set,Uc=(0,Tt.X$)((0,a.c$)((e=>({activeDownloads:(0,y.jUK)(e).activeDownloads.byChatId})))((({activeDownloads:e})=>{const{cancelMessagesMediaDownload:t,showNotification:s}=(0,a.Sv)(),n=(0,rn.Z)(1e3,!0),i=(0,qt.Z)((e=>{xc.add(e),n((()=>{xc.size&&(t({messages:Array.from(xc)}),xc.clear())}))}));(0,Tt.d4)((()=>{const t=(0,a.Rd)().messages.byChatId,n=(0,a.Rd)().scheduledMessages.byChatId,c=Object.entries(e).map((([e,s])=>{const a=s.ids?.map((s=>t[e]?.byId[s])),o=s.scheduledIds?.map((t=>n[e]?.byId[t]));return(0,h.oA)([...a||[],...o||[]])})).flat();c.length?c.forEach((e=>{if(Bc.has(e))return;Bc.add(e);const t=(0,v.Ti)(e,"download");if(!t)return void i(e);const a=Ue.UV(t);if(a)return(0,Ac.Z)(a,(0,v.w6)(e)),void i(e);const{document:n,video:c,audio:d}=e.content;if(((n||c||d)?.size||0)>o.l0&&!o.rT&&!o.Mc)return s({message:"Downloading files bigger than 2GB is not supported in your browser."}),void i(e);const l=(0,v.kG)(e,"download");Ue.he(t,l,!0).then((t=>{if(l===r.IU.DownloadUrl){const a=new URL(t,window.document.baseURI),n=(0,v.w6)(e);a.searchParams.set("filename",encodeURIComponent(n));const o=window.open(a.toString());o?.addEventListener("beforeunload",(()=>{s({message:"Download started. Please, do not close the app before it is finished."})}))}else t&&(0,Ac.Z)(t,(0,v.w6)(e));i(e)}))})):Bc.clear()}),[e,t,i,s])}))),Lc=e=>{const{requestedDraft:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"DraftRecipientPicker",!t);return s?Tt.ZP.createElement(s,e):void 0},_c=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"ForwardRecipientPicker",!t);return s?Tt.ZP.createElement(s,e):void 0};var Oc=s(56389),Fc=s(34563);const Dc=(0,Tt.X$)((0,a.c$)(((e,{openedGame:t})=>{const{chatId:s}=t||{},a=s&&(0,y.Z1J)(e,s),n=s?(0,y.x67)(e,s):void 0;return{canPost:Boolean(a)&&(0,v.Qm)(a,r._f,void 0,n)}}))((({openedGame:e,gameTitle:t,canPost:s})=>{const{closeGame:a,openForwardMenu:n}=(0,pe.Sv)(),o=(0,Is.Z)(),{url:i,chatId:r,messageId:c}=e||{},d=Boolean(i),l=(0,Oc.Z)(r);(0,Ot.Z)((()=>{l({type:"playingGame"})}),d&&s?5e3:void 0);const u=(0,Tt.I4)((e=>{try{const t=JSON.parse(e.data);"share_score"===t.eventType&&(n({fromChatId:r,messageIds:[c],withMyScore:!0}),a()),"share_game"===t.eventType&&(n({fromChatId:r,messageIds:[c]}),a())}catch(e){}}),[r,a,c,n]),m=(0,Tt.I4)((e=>{e.currentTarget.focus()}),[]);return(0,Tt.d4)((()=>(window.addEventListener("message",u),()=>window.removeEventListener("message",u))),[u]),Tt.ZP.createElement(Fc.Z,{className:"GameModal",isOpen:d,onClose:a,title:t,hasCloseButton:!0},d&&Tt.ZP.createElement("iframe",{className:"game-frame",onLoad:m,src:i,title:o("AttachGame"),sandbox:"allow-scripts allow-same-origin allow-orientation-lock",allow:"fullscreen"}))}))),jc=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"HistoryCalendar",!t);return s?Tt.ZP.createElement(s,e):void 0},qc=e=>{const{userIds:t,chatId:s}=e,a=(0,Yt.Z)(_t.gl.Extra,"InviteViaLinkModal",!(t&&s));return a?Tt.ZP.createElement(a,e):void 0},Gc=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"NewContactModal",!t);return s?Tt.ZP.createElement(s,e):void 0},Hc=({isOpen:e})=>{const t=(0,Yt.Z)(_t.gl.Extra,"Notifications",!e);return t?Tt.ZP.createElement(t,null):void 0},Vc=e=>{const{limit:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"PremiumLimitReachedModal",!t);return s?Tt.ZP.createElement(s,e):void 0},$c=e=>{const{isOpen:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"PremiumMainModal",!t);return s?Tt.ZP.createElement(s,e):void 0},zc=e=>{const{url:t}=e,s=(0,Yt.Z)(_t.gl.Extra,"SafeLinkModal",!t);return s?Tt.ZP.createElement(s,e):void 0};let Kc=!1;const Jc=(0,Tt.X$)((0,a.c$)(((e,{isMobile:t})=>{const{settings:{byKey:{language:s,wasTimeFormatSetManually:a}},currentUserId:n}=e,{botTrustRequest:o,requestedAttachBotInstall:i,requestedAttachBotInChat:r,requestedDraft:c,urlAuth:d,webApp:l,safeLinkModalUrl:u,mapModal:m,openedStickerSetShortName:h,openedCustomEmojiSetIds:p,shouldSkipHistoryAnimations:g,openedGame:f,audioPlayer:I,isLeftColumnShown:w,historyCalendarSelectedAt:b,notifications:P,dialogs:Z,newContact:S,ratingPhoneCall:C,premiumModal:M,isMasterTab:E,payment:R,limitReachedModal:k,deleteFolderDialogModal:T,chatlistModal:N,boostModal:A,giftCodeModal:B,inviteViaLinkModal:x,oneTimeMediaModal:U}=(0,y.jUK)(e),{chatId:L,messageId:_}=I,O=L&&_?(0,y.hjO)(e,L,_):void 0,F=f&&(0,y.hjO)(e,f.chatId,f.messageId),D=F?.content.game?.title,j=e.currentUserId?(0,y.dyD)(e,e.currentUserId):void 0,{chatId:q}=(0,y.Btg)(e)||{},G=!(0,y.$Yd)(e,"rightColumnAnimations")||!(0,y.FOo)(e),H=T?(0,y.MwT)(e,T):void 0;return{currentUserId:n,isLeftColumnOpen:w,isMiddleColumnOpen:Boolean(q),isRightColumnOpen:(0,y.Jf5)(e,t),isMediaViewerOpen:(0,y.zQd)(e),isStoryViewerOpen:(0,y.TuN)(e),isForwardModalOpen:(0,y.Evo)(e),isReactionPickerOpen:(0,y.Io8)(e),hasNotifications:Boolean(P.length),hasDialogs:Boolean(Z.length),audioMessage:O,safeLinkModalUrl:u,mapModalGeoPoint:m?.point,mapModalZoom:m?.zoom,isHistoryCalendarOpen:Boolean(b),shouldSkipHistoryAnimations:g,openedStickerSetShortName:h,openedCustomEmojiSetIds:p,isServiceChatReady:(0,y.UWV)(e),activeGroupCallId:E?e.groupCalls.activeGroupCallId:void 0,withInterfaceAnimations:(0,y.FOo)(e),language:s,wasTimeFormatSetManually:a,isPhoneCallActive:E?Boolean(e.phoneCall):void 0,addedSetIds:e.stickers.added.setIds,addedCustomEmojiIds:e.customEmojis.added.setIds,newContactUserId:S?.userId,newContactByPhoneNumber:S?.isByPhoneNumber,openedGame:f,gameTitle:D,isRatePhoneCallModalOpen:Boolean(C),botTrustRequest:o,botTrustRequestBot:o&&(0,y.dyD)(e,o.botId),attachBotToInstall:i?.bot,requestedAttachBotInChat:r,webApp:l,currentUserName:(0,v.Js)(j),urlAuth:d,isCurrentUserPremium:(0,y.wVz)(e),isPremiumModalOpen:M?.isOpen,limitReached:k?.limit,isPaymentModalOpen:R.isPaymentModalOpen,isReceiptModalOpen:Boolean(R.receipt),deleteFolderDialog:H,isMasterTab:E,requestedDraft:c,chatlistModal:N,boostModal:A,giftCodeModal:B,noRightColumnAnimation:G,isSynced:e.isSynced,inviteViaLinkModal:x,oneTimeMediaModal:U}}))((({isMobile:e,isLeftColumnOpen:t,isMiddleColumnOpen:s,isRightColumnOpen:i,isMediaViewerOpen:r,isStoryViewerOpen:c,isForwardModalOpen:d,hasNotifications:l,hasDialogs:u,audioMessage:m,activeGroupCallId:h,safeLinkModalUrl:p,mapModalGeoPoint:g,mapModalZoom:f,isHistoryCalendarOpen:I,shouldSkipHistoryAnimations:v,limitReached:w,openedStickerSetShortName:b,openedCustomEmojiSetIds:y,isServiceChatReady:P,withInterfaceAnimations:Z,language:S,wasTimeFormatSetManually:C,addedSetIds:M,addedCustomEmojiIds:E,isPhoneCallActive:R,newContactUserId:k,newContactByPhoneNumber:T,openedGame:N,gameTitle:A,isRatePhoneCallModalOpen:B,botTrustRequest:U,botTrustRequestBot:L,attachBotToInstall:_,requestedAttachBotInChat:O,requestedDraft:F,webApp:D,currentUserName:j,urlAuth:q,isPremiumModalOpen:G,isPaymentModalOpen:H,isReceiptModalOpen:V,isReactionPickerOpen:$,isCurrentUserPremium:z,deleteFolderDialog:K,isMasterTab:J,chatlistModal:W,giftCodeModal:Y,boostModal:X,noRightColumnAnimation:Q,isSynced:ee,inviteViaLinkModal:te,oneTimeMediaModal:se,currentUserId:ae})=>{const{initMain:ne,loadAnimatedEmojis:oe,loadNotificationSettings:ie,loadNotificationExceptions:re,updateIsOnline:ce,onTabFocusChange:de,loadTopInlineBots:le,loadEmojiKeywords:ue,loadCountryList:me,loadAvailableReactions:he,loadStickerSets:pe,loadPremiumGifts:ge,loadDefaultTopicIcons:fe,loadAddedStickers:Ie,loadFavoriteStickers:ve,loadDefaultStatusIcons:we,ensureTimeFormat:be,closeStickerSetModal:ye,closeCustomEmojiSets:Pe,checkVersionNotification:Ze,loadConfig:Se,loadAppConfig:Ce,loadAttachBots:Me,loadContactList:Ee,loadCustomEmojis:Re,loadGenericEmojiEffects:ke,closePaymentModal:Te,clearReceipt:Ne,checkAppVersion:Ae,openThread:Be,toggleLeftColumn:xe,loadRecentEmojiStatuses:Ue,updatePageTitle:Le,loadTopReactions:Oe,loadRecentReactions:Fe,loadDefaultTagReactions:De,loadFeaturedEmojiStickers:je,setIsElectronUpdateAvailable:qe,loadAuthorizations:Ge,loadPeerColors:He,loadSavedReactionTags:Ve}=(0,a.Sv)();n.eMD&&!Kc&&(Kc=!0,console.log(">>> RENDER MAIN")),(0,Ft.Z)((()=>{(0,_t.Pb)(_t.gl.Calls)}),5e3);const $e=(0,Tt.sO)(null),ze=(0,Tt.sO)(null),{isDesktop:Ke}=(0,x.ZP)();(0,Tt.d4)((()=>{t||s||Ke?t&&s&&e&&xe():xe()}),[Ke,t,s,e,xe]),(0,Ot.Z)(Ae,J?3e5:void 0,!0),(0,Tt.d4)((()=>{if(!o.D$)return;const e=window.electron.on(At.I.UPDATE_AVAILABLE,(()=>{qe(!0)})),t=window.electron.on(At.I.UPDATE_ERROR,(()=>{qe(!1),e?.()}));return()=>{t?.(),e?.()}}),[]),(0,Tt.d4)((()=>{J&&ee&&(ce(!0),Se(),Ce(),He(),ne(),he(),oe(),ke(),ie(),re(),le(),ue({language:n.pRL}),Me(),Ee(),ge(),fe(),Ae(),Oe(),Fe(),De(),je(),Ge(),Ve())}),[J,ee]),(0,Tt.d4)((()=>{J&&z&&(we(),Ue())}),[z,J]),(0,Tt.d4)((()=>{J&&(S!==n.pRL&&ue({language:S}),me({langCode:S}))}),[S,J]),(0,Tt.d4)((()=>{J&&Re({ids:Object.keys((0,a.Rd)().customEmojis.byId),ignoreCache:!0})}),[J]),(0,Tt.d4)((()=>{J&&ee&&(M&&E||(pe(),ve()),M&&E&&Ie())}),[M,E,J,ee]),(0,Tt.d4)((()=>{P&&J&&Ze()}),[P,J]),(0,Tt.d4)((()=>{C||be()}),[C]),(0,Tt.d4)((()=>{const e=(0,_e.dx)();e?.tgaddr&&(0,Lt.ou)(decodeURIComponent(e.tgaddr))}),[]),(0,Tt.d4)((()=>window.electron?.on(At.I.DEEPLINK,(e=>{(0,Lt.ou)(decodeURIComponent(e))}))),[]),(0,Tt.d4)((()=>{const e=(0,_e.VX)(ae);e&&Be({chatId:e.chatId,threadId:e.threadId,type:e.type})}),[ae]),(0,Tt.bt)((()=>{const e=$e.current;1===e.parentNode.childElementCount&&(0,Nt.D_)(e,"Transition_slide-active")}),[]);const We=(0,$t.Z)(t,void 0,!0,void 0,v,void 0,!0),Ye=(0,Tt.sO)(!1),Xe=(0,Dt.Z)();(0,zt.Z)((([e])=>{if(void 0===e||t===e||!Z)return;Ye.current=!0,o.wZ&&(0,Bt.Yq)((()=>{document.body.classList.toggle("android-left-blackout-open",!t)}));const s=(0,jt.YW)();(0,Ut.L)(document.getElementById("MiddleColumn"),(()=>{s(),Ye.current=!1,Xe()}))}),[t,Z,Xe]);const Qe=(0,$t.Z)(i,void 0,!0,void 0,v,void 0,!0),et=(0,Tt.sO)(!1),[tt,st]=(0,Tt.eJ)(i),at=(0,Wt.Ar)();(0,zt.Z)((([e,t])=>{if(void 0===t||i===t)return;if(!e||Q)return void st(i);et.current=!0;const s=(0,jt.YW)();(0,Ut.L)(document.getElementById("RightColumn"),(()=>{s(),et.current=!1,Xe(),st(i)}))}),[s,i,Q,Xe]);const nt=(0,xt.Z)(We.hasShownClass&&"left-column-shown",We.hasOpenClass&&"left-column-open",Ye.current&&"left-column-animating",Qe.hasShownClass&&"right-column-shown",Qe.hasOpenClass&&"right-column-open",et.current&&"right-column-animating",tt&&"narrow-message-list",v&&"history-animation-disabled",at&&"is-fullscreen"),ot=(0,qt.Z)((()=>{de({isBlurred:!0})})),it=(0,qt.Z)((()=>{de({isBlurred:!1}),document.title.includes(n.ouc)||Le(),Je(!1)})),rt=(0,qt.Z)((()=>{ye()})),ct=(0,qt.Z)((()=>{Pe()}));return(0,Kt.Z)(ot,it,!!o.D$),(0,Jt.Z)(ot),function(e=!1){(0,Tt.d4)((()=>{if(o.$b){if(!e)return Gt?.setAttribute("content",Ht),o.cj&&!o.fl&&document.addEventListener("gesturestart",Vt),()=>{Gt?.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),o.cj&&!o.fl&&document.removeEventListener("gesturestart",Vt)};Gt?.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover")}}),[e])}(r||c),Tt.ZP.createElement("div",{ref:$e,id:"Main",className:nt},Tt.ZP.createElement(ua,{ref:ze}),Tt.ZP.createElement(Ir,{leftColumnRef:ze,isMobile:e}),Tt.ZP.createElement(Zc,{isMobile:e}),Tt.ZP.createElement(ma,{isOpen:r}),Tt.ZP.createElement(Sc,{isOpen:c}),Tt.ZP.createElement(_c,{isOpen:d}),Tt.ZP.createElement(Lc,{requestedDraft:F}),Tt.ZP.createElement(Hc,{isOpen:l}),Tt.ZP.createElement(Nc,{isOpen:u}),m&&Tt.ZP.createElement(Ra,{key:m.id,message:m,noUi:!0}),Tt.ZP.createElement(zc,{url:p}),Tt.ZP.createElement(Pr,{geoPoint:g,zoom:f}),Tt.ZP.createElement(Sr,{urlAuth:q,currentUserName:j}),Tt.ZP.createElement(jc,{isOpen:I}),Tt.ZP.createElement(as,{isOpen:Boolean(b),onClose:rt,stickerSetShortName:b}),Tt.ZP.createElement(ss,{customEmojiSetIds:y,onClose:ct}),h&&Tt.ZP.createElement(Qt,{groupCallId:h}),Tt.ZP.createElement(Xt,{isActive:Boolean(h||R)}),Tt.ZP.createElement(Gc,{isOpen:Boolean(k||T),userId:k,isByPhoneNumber:T}),Tt.ZP.createElement(wr,{info:X}),Tt.ZP.createElement(yr,{modal:Y}),Tt.ZP.createElement(Zr,{info:se}),Tt.ZP.createElement(br,{info:W}),Tt.ZP.createElement(Dc,{openedGame:N,gameTitle:A}),Tt.ZP.createElement(Cr,{webApp:D}),Tt.ZP.createElement(Uc,null),Tt.ZP.createElement(kc,null),Tt.ZP.createElement(es,{isActive:R}),Tt.ZP.createElement(rs,{isForAppBadge:!0}),Tt.ZP.createElement(ts,{isOpen:B}),Tt.ZP.createElement(Mc,{bot:L,type:U?.type,shouldRequestWriteAccess:U?.shouldRequestWriteAccess}),Tt.ZP.createElement(vr,{bot:_}),Tt.ZP.createElement(Cc,{requestedAttachBotInChat:O}),Tt.ZP.createElement(Na,null),Tt.ZP.createElement($c,{isOpen:G}),Tt.ZP.createElement(Vc,{limit:w}),Tt.ZP.createElement(Mr,{isOpen:H,onClose:Te}),Tt.ZP.createElement(Er,{isOpen:V,onClose:Ne}),Tt.ZP.createElement(Tc,{folder:K}),Tt.ZP.createElement(ka,{isOpen:$}),Tt.ZP.createElement(qc,{userIds:te?.restrictedUserIds,chatId:te?.chatId}))})));var Wc=s(99364);var Yc=s(2092);const Xc=(0,Tt.X$)((0,a.c$)((e=>({passcodeSettings:e.passcode})))((({isLocked:e,passcodeSettings:t})=>{const{unlockScreen:s,signOut:n,logInvalidUnlockAttempt:o,resetInvalidUnlockAttempts:i}=(0,a.Sv)(),{invalidAttemptsCount:r,timeoutUntil:c,isLoading:d}=t,l=(0,Is.Z)(),[u,m]=(0,Tt.eJ)(""),[h,p]=(0,Tt.eJ)(!1),[g,f,I]=(0,xs.Z)(!1),{shouldRender:v}=(0,$t.Z)(e);(0,Ft.Z)(i,c?c-Date.now():void 0);const w=(0,Tt.I4)((()=>{m("")}),[]),b=(0,Tt.I4)((e=>{void 0===c?(m(""),(0,at.so)(e).then(s,(()=>{o(),m(l("lng_passcode_wrong"))}))):m(l("FloodWait"))}),[l,c]);(0,Tt.d4)((()=>{void 0!==c?m(l("FloodWait")):0===r&&m("")}),[c,l,r]);const y=(0,Tt.I4)((()=>{I(),n({forceInitApi:!0})}),[I,n]);if(v)return Tt.ZP.createElement("div",{className:"bdKGCai4"},Tt.ZP.createElement("div",{className:"BIi4Pl4Z",dir:l.isRtl?"rtl":void 0},Tt.ZP.createElement(Oo.Z,{tgsUrl:_o.l.Lock,previewUrl:Yc,size:160,className:"JwlsF2tF"}),Tt.ZP.createElement(Wc.Z,{key:"password-form",shouldShowSubmit:!0,shouldDisablePasswordManager:!0,isLoading:d,error:u,placeholder:l("Passcode.EnterPasscodePlaceholder"),submitLabel:l("Next"),clearError:w,isPasswordVisible:h,noRipple:!0,onChangePasswordVisibility:p,onSubmit:b}),Tt.ZP.createElement("div",{className:"VlXFyC_a"},Tt.ZP.createElement("p",null,Tt.ZP.createElement(mr.Z,{onClick:f},"Log out")," ","if you don't remember your passcode."),Tt.ZP.createElement("p",null,Tt.ZP.createElement(vs.Z,{color:"translucent",size:"tiny",isText:!0,onClick:f},l("AccountSettings.Logout"))))),Tt.ZP.createElement(Fo.Z,{isOpen:g,onClose:I,text:l("lng_sure_logout"),confirmLabel:l("AccountSettings.Logout"),confirmHandler:y,confirmIsDestructive:!0}))})));n.eMD&&console.log(">>> FINISH LOAD MAIN BUNDLE");const{passcode:{isScreenLocked:Qc},connectionState:ed}=(0,a.Rd)();ed||Qc||o.Eo||(0,a.Sv)().initApi()},48960:(e,t,s)=>{var a=s(48764).lW;const{constructors:n}=s(57404),o=a.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00","hex"),i=a.from("ffd9","hex");function r(e,t){throw new Error(`Cannot cast ${e.className} to any kind of ${t}`)}e.exports={getMessageId:function(e){if(void 0!==e){if("number"==typeof e)return e;if(2030045667===e.SUBCLASS_OF_ID)return e.id;throw new Error(`Invalid message type: ${e.constructor.name}`)}},getInputPeer:function e(t,s=!0,a=!0){if(void 0===t.SUBCLASS_OF_ID){if(s&&"inputEntity"in t)return t.inputEntity;if("entity"in t)return e(t.entity);r(t,"InputPeer")}if(3374092470===t.SUBCLASS_OF_ID)return t;if(t instanceof n.User){if(t.isSelf&&s)return new n.InputPeerSelf;if(void 0===t.accessHash&&a)throw new Error("User without accessHash or min info cannot be input");return new n.InputPeerUser({userId:t.id,accessHash:t.accessHash})}if(t instanceof n.Chat||t instanceof n.ChatEmpty||t instanceof n.ChatForbidden)return new n.InputPeerChat({chatId:t.id});if(t instanceof n.Channel){if(void 0===t.accessHash&&a)throw new TypeError("Channel without accessHash or min info cannot be input");return new n.InputPeerChannel({channelId:t.id,accessHash:t.accessHash})}return t instanceof n.ChannelForbidden?new n.InputPeerChannel({channelId:t.id,accessHash:t.accessHash}):t instanceof n.InputUser?new n.InputPeerUser({userId:t.userId,accessHash:t.accessHash}):t instanceof n.InputChannel?new n.InputPeerChannel({channelId:t.channelId,accessHash:t.accessHash}):t instanceof n.UserEmpty?new n.InputPeerEmpty:t instanceof n.UserFull?e(t.user):t instanceof n.ChatFull?new n.InputPeerChat({chatId:t.id}):t instanceof n.PeerChat?new n.InputPeerChat(t.chatId):void r(t,"InputPeer")},getDisplayName:function(e){return e instanceof n.User?e.lastName&&e.firstName?`${e.firstName} ${e.lastName}`:e.firstName?e.firstName:e.lastName?e.lastName:"":e instanceof n.Chat||e instanceof n.Channel?e.title:""},getDownloadPartSize:function(e){if(e<=65536)return 64;if(e<=104857600)return 128;if(e<=786432e3)return 256;if(e<=2097152e3)return 512;if(e<=4194304e3)return 1024;throw new Error("File size too large")},getUploadPartSize:function(e){if(e<=104857600)return 128;if(e<=786432e3)return 256;if(e<=2097152e3)return 512;if(e<=4194304e3)return 512;throw new Error("File size too large")},strippedPhotoToJpg:function(e){if(e.length<3||1!==e[0])return e;const t=a.from(o);return t[164]=e[1],t[166]=e[2],a.concat([t,e.slice(3),i])},getDC:function(e,t=!1){switch(e){case 1:return{id:1,ipAddress:`zws1${t?"-1":""}.web.telegram.org`,port:443};case 2:return{id:2,ipAddress:`zws2${t?"-1":""}.web.telegram.org`,port:443};case 3:return{id:3,ipAddress:`zws3${t?"-1":""}.web.telegram.org`,port:443};case 4:return{id:4,ipAddress:`zws4${t?"-1":""}.web.telegram.org`,port:443};case 5:return{id:5,ipAddress:`zws5${t?"-1":""}.web.telegram.org`,port:443};default:throw new Error(`Cannot find the DC with the ID of ${e}`)}}}}}]);
|
||
//# sourceMappingURL=5769.8fa27eea52a86ed008e9.js.map
|