telegram-tt/dist/433.29f542772c88e944d938.js
Alexander Zinchuk 2c612766d9 [Build]
2021-08-27 21:10:47 +03:00

2 lines
221 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[433],{8065:(e,t,s)=>{s.r(t),s.d(t,{Main:()=>no});var n=s(5116),a=s(3716),o=s(4050),r=(s(7895),s(1752)),i=s(8085),c=s(735),d=s(2858);function l(e){const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};return t&&s?(e=(0,r.qr)(e,t,s,!1),e=(0,r.Pb)(e,t,s,void 0)):e}(0,n.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(t&&s)return(0,r.qr)(e,t,s,!0)})),(0,n.Q6)("closeLocalTextSearch",l),(0,n.Q6)("setLocalTextSearchQuery",((e,t,s)=>{const{chatId:n,threadId:a}=(0,i.Bt)(e)||{};if(!n||!a)return;const{query:o}=s,l=(0,d.uw)(n,a),{query:u}=e.localTextSearch.byChatThreadKey[l]||{};return o!==u&&(e=(0,r.Pb)(e,n,a,c.D)),(0,r.qr)(e,n,a,!0,o)})),(0,n.Q6)("setLocalMediaSearchType",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};if(!n)return;const{mediaType:a}=s;return(0,r.z5)(e,n,a)})),(0,n.Q6)("openChat",((e,t,s)=>{const{id:a,threadId:o=-1,type:c="thread",shouldReplaceHistory:d=!1}=s,u=(0,i.Bt)(e);return u&&u.chatId===a&&u.threadId===o&&u.type===c||(e=(0,r.pf)(e,a,o,"replyStack",[]),e=l(e=(0,r.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...a!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,n.R3)(e)),(0,r.Wy)(e,a,o,c,d)})),(0,n.Q6)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,n.Q6)("openChatWithInfo",((e,t,s)=>{(0,n.R3)({...e,isChatInfoShown:!0}),t.openChat(s)})),(0,n.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,n.Q6)("setNewChatMembersDialogState",((e,t,s)=>({...e,newChatMembersProgress:s}))),(0,n.Q6)("openNextChat",((e,t,s)=>{const{targetIndexDelta:n,orderedIds:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return void t.openChat({id:a[0]});const r=a.indexOf(o);if(-1===r)return;const c=a[r+n];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=s(6137),h=s(1713),m=s(7361),g=s(782);const f=a.ck+a.fK;let p;(0,n.Q6)("setScrollOffset",((e,t,s)=>{const{chatId:n,threadId:a,scrollOffset:o}=s;return(0,r.pf)(e,n,a,"scrollOffset",o)})),(0,n.Q6)("setReplyingToId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c}=a;return(0,r.pf)(e,o,c,"replyingToId",n)})),(0,n.Q6)("setEditingId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c,type:d}=a,l="scheduled"===d?"editingScheduledId":"editingId";return(0,r.pf)(e,o,c,l,n)})),(0,n.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(!t||!s)return;const n=(0,i.Zw)(e,t),a=(0,i.Cb)(e,t,s);if(!n||!a)return;const o=(0,g.dF)(a,(t=>Boolean(n[t]&&(0,i._k)(e,n[t],s).canEdit)));return o?(0,r.pf)(e,t,s,"editingId",o):void 0})),(0,n.Q6)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:n}=s,{chatId:a,threadId:o}=(0,i.Bt)(e)||{};if(!a||!o)return;const r=(0,i.Zw)(e,a),c=(0,i.Cb)(e,a,o);if(!r||!c)return;const d=(0,i.Yy)(e,a,o);let l;if((0,i.b9)(e,a,o)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+n;l=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){var h;const t=(0,i.Z1)(e,a);l=null==t||null===(h=t.lastMessage)||void 0===h?void 0:h.id}else{const t=(0,i.tZ)(e,a,o);l=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:l}),t.focusMessage({chatId:a,threadId:o,messageId:l})})),(0,n.Q6)("openMediaViewer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c}=s;return{...e,mediaViewer:{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c},forwardMessages:{}}})),(0,n.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,n.Q6)("openAudioPlayer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o}=s;return{...e,audioPlayer:{chatId:n,threadId:a,messageId:o}}})),(0,n.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{}}))),(0,n.Q6)("openPollResults",((e,t,s)=>{const{chatId:a,messageId:o}=s;(0,i.Jf)(e)?a===e.pollResults.chatId&&o===e.pollResults.messageId||(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,n.Rd)();(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}})}),450)})),(0,n.Q6)("closePollResults",(e=>{(0,n.R3)({...e,pollResults:{}})})),(0,n.Q6)("focusLastMessage",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:n,threadId:a}=s;let o;if(a===u._f){var r;const t=(0,i.Z1)(e,n);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,i.tZ)(e,n,a);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:n,threadId:a,messageId:o,noHighlight:!0})})),(0,n.Q6)("focusNextReply",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:a,threadId:o}=s,c=(0,i.p9)(e,a,o);if(c&&0!==c.length){const s=c.pop();e=(0,r.pf)(e,a,o,"replyStack",[...c]),(0,n.R3)(e),t.focusMessage({chatId:a,threadId:o,messageId:s})}else t.focusLastMessage()})),(0,n.Q6)("focusMessage",((e,t,s)=>{const{chatId:a,threadId:o=u._f,messageListType:c="thread",noHighlight:d,groupedId:l,groupedChatId:m,replyMessageId:g,isResizingContainer:I}=s;let{messageId:v}=s;if(void 0!==l){const t=(0,i.y8)(e,m,l);null!=t&&t.length&&([v]=t)}const y=(0,i.Bt)(e),Z=!y||a!==y.chatId||o!==y.threadId||c!==y.type;if(p&&(clearTimeout(p),p=void 0),p=window.setTimeout((()=>{let e=(0,n.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,n.R3)(e)}),d?f:1500),e=(0,r.cq)(e,a,v,d,I),e=(0,r.wV)(e,void 0),g){const t=(0,i.p9)(e,a,o)||[];e=(0,r.pf)(e,a,o,"replyStack",[...t,g])}Z&&(e=(0,r.wV)(e,h.fo.Static));const P=(0,i.Cb)(e,a,o);if(P&&P.includes(v))return(0,n.R3)(e),void t.openChat({id:a,threadId:o});if(Z&&(e=(0,r.pf)(e,a,o,"viewportIds",void 0)),e=(0,r.pf)(e,a,o,"outlyingIds",void 0),P&&!Z){const t=v>P[0]?h.fo.Down:h.fo.Up;e=(0,r.wV)(e,t)}(0,n.R3)(e),t.openChat({id:a,threadId:o}),t.loadViewportMessages()})),(0,n.Q6)("openForwardMenu",((e,t,s)=>{const{fromChatId:n,messageIds:a,groupedId:o}=s;let r;return o&&(r=(0,i.xH)(e,n,o)),{...e,forwardMessages:{fromChatId:n,messageIds:r||a,isModalShown:!0}}})),(0,n.Q6)("exitForwardMode",(e=>{(0,n.R3)({...e,forwardMessages:{}})})),(0,n.Q6)("setForwardChatId",((e,t,s)=>{const{id:a}=s;(0,n.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:a,isModalShown:!1}}),t.openChat({id:a}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,n.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages;t.openForwardMenu({fromChatId:s,messageIds:n})})),(0,n.Q6)("enterMessageSelectMode",((e,t,s)=>{const{messageId:n}=s||{},a=(0,i.jr)(e);return a?(0,r.M6)(e,a.id,n):e})),(0,n.Q6)("toggleMessageSelection",((e,t,s)=>{const{messageId:a,groupedId:o,childMessageIds:c,withShift:d}=s,l=(0,i.Bt)(e);if(!l)return;const{chatId:u,threadId:h,type:g}=l;e=(0,r.Ob)(e,u,h,g,a,o,c,d),(0,n.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${m.$b?"long tap":"right click"} on a message.`}))})),(0,n.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,n.Q6)("exitMessageSelectMode",r.i9),(0,n.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,n.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{query:n}=s,{chatId:a}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...n?{fetchingStatus:{chats:!a,messages:!0}}:{fetchingStatus:void 0},query:n})})),(0,n.Q6)("addRecentlyFoundChatId",((e,t,s)=>{const{id:n}=s,{recentlyFoundChatIds:a}=e.globalSearch;if(!a)return(0,r.No)(e,{recentlyFoundChatIds:[n]});const o=a.filter((e=>e!==n));return o.unshift(n),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,n.Q6)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,n.Q6)("setGlobalSearchContent",((e,t,s)=>{const{content:n}=s;return(0,r.Og)(e,n)})),(0,n.Q6)("setGlobalSearchChatId",((e,t,s)=>{const{id:n}=s;return(0,r.No)(e,{chatId:n,query:void 0,resultsByType:void 0})})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,stickers:{...e.stickers,search:{query:n,resultIds:void 0}}}})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,gifs:{...e.gifs,search:{query:n,offsetId:void 0,results:void 0}}}})),(0,n.Q6)("openUserInfo",((e,t,s)=>{const{id:n}=s;t.openChat({id:n})})),(0,n.Q6)("openChat",(e=>(0,r.x1)(e,void 0))),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:n}=s;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(n),query:n})})),s(3781);var I=s(1947),v=s(6926);(0,n.Q6)("toggleChatInfo",(e=>({...e,isChatInfoShown:!e.isChatInfoShown}))),(0,n.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,n.Q6)("closeManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,n.Q6)("openChat",(e=>{if(m.wB||m.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,n.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,n.Q6)("addRecentEmoji",((e,t,s)=>{const{emoji:n}=s,{recentEmojis:a}=e;if(!a)return{...e,recentEmojis:[n]};const o=a.filter((e=>e!==n));return o.unshift(n),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,n.Q6)("addRecentSticker",((e,t,s)=>{const{sticker:n}=s,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:0,stickers:[n]}}};const o=a.stickers.filter((e=>e.id!==n.id));return o.unshift(n),{...e,stickers:{...e.stickers,recent:{...a,stickers:o}}}})),(0,n.Q6)("showNotification",((e,t,s)=>{const n=s;n.localId=(0,v.Z)({});const a=[...e.notifications],o=a.findIndex((e=>e.message===n.message));return-1!==o&&a.splice(o,1),a.push(n),{...e,notifications:a}})),(0,n.Q6)("dismissNotification",((e,t,s)=>{const n=e.notifications.filter((({localId:e})=>e!==s.localId));return{...e,notifications:n}})),(0,n.Q6)("showDialog",((e,t,s)=>{const{data:n}=s;if("message"in n&&n.hasErrorKey&&!(0,I.ZP)(n))return e;const a=[...e.dialogs];if("message"in n){const e=a.findIndex((e=>e.message===n.message));-1!==e&&a.splice(e,1)}return a.push(n),{...e,dialogs:a}})),(0,n.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,n.Q6)("toggleSafeLinkModal",((e,t,s)=>{const{url:n}=s;return{...e,safeLinkModalUrl:n}})),(0,n.Q6)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:n}=s;return{...e,historyCalendarSelectedAt:n}})),(0,n.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,n.Q6)("openPaymentModal",((e,t,s)=>{const{chatId:n,messageId:a}=s;return{...e,payment:{...e.payment,chatId:n,messageId:a,isPaymentModalOpen:!0}}})),(0,n.Q6)("closePaymentModal",(e=>{const t=(0,r.bp)(e);return(0,r.WY)(t)})),(0,n.Q6)("addPaymentError",((e,t,s)=>{const{error:n}=s;return{...e,payment:{...e.payment,error:n}}})),s(1363);var y=s(1226),Z=s(9118);const P=(0,Z.P2)((e=>e()),1e3,!0),C=(0,Z.P2)((e=>e()),3e3,!0),w=(0,Z.Ds)((e=>e()),500,!1,!0);async function b(e,t,s){const o=await(0,y.t9)("fetchChats",{limit:a.Ov,offsetDate:s,archived:"archived"===e,withPinned:void 0===(0,n.Rd)().chats.orderedPinnedIds[e],serverTimeOffset:(0,n.Rd)().serverTimeOffset});if(!o)return;const{chatIds:i}=o;i.length>0&&i[0]===t&&i.shift();let c=(0,n.Rd)();c=(0,r.Sh)(c,(0,g.ee)(o.users,"id")),c=(0,r.GL)(c,(0,g.ee)(o.chats,"id")),c=(0,r.B1)(c,e,i),c=(0,r.vv)(c,e,o),Object.keys(o.draftsById).map(Number).forEach((e=>{c=(0,r.pf)(c,e,u._f,"draft",o.draftsById[e])})),Object.keys(o.replyingToById).map(Number).forEach((e=>{c=(0,r.pf)(c,e,u._f,"replyingToId",o.replyingToById[e])})),0!==i.length||c.chats.isFullyLoaded[e]||(c={...c,chats:{...c.chats,isFullyLoaded:{...c.chats.isFullyLoaded,[e]:!0}}}),(0,n.R3)(c)}async function M(e){const t=await(0,y.t9)("fetchFullChat",e);if(!t)return;const{users:s,fullInfo:a}=t;let o=(0,n.Rd)();s&&(o=(0,r.Sh)(o,(0,g.ee)(s,"id"))),o=(0,r.a4)(o,e.id,{fullInfo:a}),(0,n.R3)(o)}async function S(e,t,s){const a=(0,n.Rd)(),o=(0,i.DI)(a,t);if(o&&!o.isMin)return void(s?e.focusMessage({chatId:o.id,messageId:s}):e.openChat({id:o.id}));const c=(0,i.jr)(a);e.openChat({id:-1});const d=await(0,y.t9)("getChatByUsername",t);if(!d)return c&&e.openChat({id:c.id}),void e.showNotification({message:"User does not exist"});(0,n.R3)((0,r.a4)((0,n.Rd)(),d.id,d)),s?e.focusMessage({chatId:d.id,messageId:s}):e.openChat({id:d.id})}(0,n.Q6)("preloadTopChatMessages",((e,t)=>{(async()=>{const s=[];for(let o=0;o<a.ul;o++){await(0,Z.wO)(100);const{byId:a,listIds:{active:o},orderedPinnedIds:{active:r}}=(0,n.Rd)().chats;if(!o)return;const{chatId:c}=(0,i.Bt)(e)||{},{pinnedChats:l,otherChats:h}=(0,d.O)(a,o,r),m=[...l,...h].find((({id:e})=>e!==c&&!s.includes(e)));if(!m)return;s.push(m.id),t.loadViewportMessages({chatId:m.id,threadId:u._f})}})()})),(0,n.Q6)("openChat",((e,t,s)=>{const{id:n,threadId:a}=s,{currentUserId:o}=e,r=(0,i.Z1)(e,n);if(null!=r&&r.hasUnreadMark&&t.toggleChatUnread({id:n}),r&&r.lastMessage&&r.lastMessage.threadInfo&&t.requestThreadInfoUpdate({chatId:r.lastMessage.threadInfo.chatId,threadId:r.lastMessage.threadInfo.threadId}),r)(0,d.Hp)(r)&&!r.isMin&&t.requestChatUpdate({chatId:n});else if(n===o)(0,y.t9)("fetchChat",{type:"self"});else{const t=(0,i.dy)(e,n);t&&(0,y.t9)("fetchChat",{type:"user",user:t})}a!==u._f&&((0,i.qS)(e,n,a)||t.requestThreadInfoUpdate({chatId:n,threadId:a}))})),(0,n.Q6)("openSupportChat",((e,t)=>{const s=(0,i.P_)(e);t.openChat({id:s?s.id:-1}),s||(async()=>{const e=await(0,y.t9)("fetchChat",{type:"support"});e&&t.openChat({id:e.chatId})})()})),(0,n.Q6)("openTipsChat",((e,t,s)=>{const{langCode:n}=s,o="pt-br"===n?"BR":a.Db.includes(n)?n.toUpperCase():"";t.openChatByUsername({username:`${a.vi}${o}`})})),(0,n.Q6)("loadMoreChats",((e,t,s)=>{const{listType:n="active"}=s,a=e.chats.listIds[n];if(e.chats.isFullyLoaded[n])return;const o=a?a.map((t=>e.chats.byId[t])).filter((t=>Boolean(null==t?void 0:t.lastMessage)&&!(0,i.ep)(e,t.id))).sort(((e,t)=>e.lastMessage.date-t.lastMessage.date))[0]:void 0;P(o?()=>b(n,o.id,o.lastMessage.date):()=>b(n))})),(0,n.Q6)("loadFullChat",((e,t,s)=>{const{chatId:n,force:a}=s,o=(0,i.Z1)(e,n);o&&(a?M(o):w((()=>M(o))))})),(0,n.Q6)("loadTopChats",(()=>{C((()=>b("active")))})),(0,n.Q6)("requestChatUpdate",((e,t,s)=>{const{serverTimeOffset:n}=e,{chatId:a}=s,o=(0,i.Z1)(e,a);o&&(0,y.t9)("requestChatUpdate",{chat:o,serverTimeOffset:n})})),(0,n.Q6)("updateChatMutedState",((e,t,s)=>{const{serverTimeOffset:a}=e,{chatId:o,isMuted:c}=s,d=(0,i.Z1)(e,o);d&&((0,n.R3)((0,r.a4)(e,o,{isMuted:c})),(0,y.t9)("updateChatMutedState",{chat:d,isMuted:c,serverTimeOffset:a}))})),(0,n.Q6)("createChannel",((e,t,s)=>{const{title:a,about:o,photo:c,memberIds:d}=s;!async function(e,t,s,a){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const o=await(0,y.t9)("createChannel",{title:e,about:s,users:t});if(!o)return;const{id:i,accessHash:c}=o;let d=(0,n.Rd)();d=(0,r.a4)(d,i,o),d={...d,chatCreation:{...d.chatCreation,progress:o?h.Nh.Complete:h.Nh.Error}},(0,n.R3)(d),(0,n.uC)().openChat({id:i}),i&&c&&a&&await(0,y.t9)("editChatPhoto",{chatId:i,accessHash:c,photo:a})}(a,d.map((t=>(0,i.dy)(e,t))).filter(Boolean),o,c)})),(0,n.Q6)("joinChannel",((e,t,s)=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;const{id:o,accessHash:r}=a;o&&r&&(0,y.t9)("joinChannel",{channelId:o,accessHash:r})})),(0,n.Q6)("deleteChatUser",((e,t,s)=>{(async()=>{const{chatId:n,userId:a}=s,o=(0,i.Z1)(e,n),r=(0,i.dy)(e,a);if(!o||!r)return;await(0,y.t9)("deleteChatUser",{chat:o,user:r});const c=(0,i.Bt)(e);c&&c.chatId===n&&e.currentUserId===a&&t.openChat({id:void 0})})()})),(0,n.Q6)("deleteChat",((e,t,s)=>{(async()=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;await(0,y.t9)("deleteChat",{chatId:a.id});const o=(0,i.Bt)(e);o&&o.chatId===n&&t.openChat({id:void 0})})()})),(0,n.Q6)("leaveChannel",((e,t,s)=>{(async()=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;const{id:o,accessHash:r}=a;o&&r&&await(0,y.t9)("leaveChannel",{channelId:o,accessHash:r});const c=(0,i.Bt)(e);c&&c.chatId===n&&t.openChat({id:void 0})})()})),(0,n.Q6)("deleteChannel",((e,t,s)=>{(async()=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;const{id:o,accessHash:r}=a;o&&r&&await(0,y.t9)("deleteChannel",{channelId:o,accessHash:r});const c=(0,i.Bt)(e);c&&c.chatId===n&&t.openChat({id:void 0})})()})),(0,n.Q6)("createGroupChat",((e,t,s)=>{const{title:a,memberIds:o,photo:c}=s;!async function(e,t,s){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const a=await(0,y.t9)("createGroupChat",{title:e,users:t});if(!a)return;const{id:o}=a;let i=(0,n.Rd)();i=(0,r.a4)(i,o,a),i={...i,chatCreation:{...i.chatCreation,progress:a?h.Nh.Complete:h.Nh.Error}},(0,n.R3)(i),(0,n.uC)().openChat({id:o}),o&&s&&await(0,y.t9)("editChatPhoto",{chatId:o,photo:s})}(a,o.map((t=>(0,i.dy)(e,t))).filter(Boolean),c)})),(0,n.Q6)("toggleChatPinned",((e,t,s)=>{const{id:n,folderId:o}=s,r=(0,i.Z1)(e,n);if(r)if(o){const t=(0,i.Mw)(e,o);if(t){const s=!(0,i.ep)(e,n,o),{pinnedChatIds:a,includedChatIds:r}=t,c=s?[n,...a||[]]:(a||[]).filter((e=>e!==n)),d=[n,...r];(0,y.t9)("editChatFolder",{id:o,folderUpdate:{...t,pinnedChatIds:c,includedChatIds:d}})}}else{const t=(0,i.Ek)(e,n),s=(0,i.ep)(e,n,"archived"===t?a.WS:void 0);(0,y.t9)("toggleChatPinned",{chat:r,shouldBePinned:!s})}})),(0,n.Q6)("toggleChatArchived",((e,t,s)=>{const{id:n}=s,o=(0,i.Z1)(e,n);o&&(0,y.t9)("toggleChatArchived",{chat:o,folderId:(0,d.pE)(o)?0:a.WS})})),(0,n.Q6)("loadChatFolders",(()=>{!async function(){const e=await(0,y.t9)("fetchChatFolders");if(e){const t=(0,n.Rd)();(0,n.R3)({...t,chatFolders:{...t.chatFolders,...e}})}}()})),(0,n.Q6)("loadRecommendedChatFolders",(()=>{!async function(){const e=await(0,y.t9)("fetchRecommendedChatFolders");if(e){const t=(0,n.Rd)();(0,n.R3)({...t,chatFolders:{...t.chatFolders,recommended:e}})}}()})),(0,n.Q6)("editChatFolder",((e,t,s)=>{const{id:n,folderUpdate:a}=s,o=(0,i.Mw)(e,n);o&&(0,y.t9)("editChatFolder",{id:n,folderUpdate:{id:n,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...a}})})),(0,n.Q6)("addChatFolder",((e,t,s)=>{const{folder:o}=s,{orderedIds:r}=e.chatFolders;!async function(e,t){const{id:s,description:a,...o}=e;if(await(0,y.t9)("editChatFolder",{id:t+1,folderUpdate:{id:t+1,...o}}),!a)return;const r=(0,n.Rd)(),{recommended:i}=r.chatFolders;i&&(0,n.R3)({...r,chatFolders:{...r.chatFolders,recommended:i.filter((({id:e})=>e!==s))}})}(o,null!=r&&r.length?Math.max.apply(Math.max,r):a.WS)})),(0,n.Q6)("deleteChatFolder",((e,t,s)=>{const{id:n}=s;(0,i.Mw)(e,n)&&async function(e){await(0,y.t9)("deleteChatFolder",e)}(n)})),(0,n.Q6)("toggleChatUnread",((e,t,s)=>{const{id:n}=s,{serverTimeOffset:a}=e,o=(0,i.Z1)(e,n);o&&(o.unreadCount?(0,y.t9)("markMessageListRead",{serverTimeOffset:a,chat:o,threadId:u._f}):(0,y.t9)("toggleDialogUnread",{chat:o,hasUnreadMark:!o.hasUnreadMark}))})),(0,n.Q6)("openTelegramLink",((e,t,s)=>{const{url:n}=s;let o=a.Lj.exec(n);if(o){const e=o[1];(async()=>{const s=await(0,y.t9)("openChatByInvite",e);s&&t.openChat({id:s.chatId})})()}else{o=a.FS.exec(n);const e=o[1],s=o[2]?Number(o[2]):void 0,r=o[3]?Number(o[3]):void 0;"c"===e&&s&&r?t.focusMessage({chatId:-s,messageId:r}):S(t,e,s)}})),(0,n.Q6)("acceptInviteConfirmation",((e,t,s)=>{const{hash:n}=s;(async()=>{const e=await(0,y.t9)("importChatInvite",{hash:n});e&&t.openChat({id:e.id})})()})),(0,n.Q6)("openChatByUsername",((e,t,s)=>{const{username:n}=s;S(t,n)})),(0,n.Q6)("togglePreHistoryHidden",((e,t,s)=>{const{chatId:n,isEnabled:a}=s;let o=(0,i.Z1)(e,n);o&&(async()=>{if((0,d.G9)(o)){if(o=await(0,y.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}(0,y.t9)("togglePreHistoryHidden",{chat:o,isEnabled:a})})()})),(0,n.Q6)("updateChatDefaultBannedRights",((e,t,s)=>{const{chatId:n,bannedRights:a}=s,o=(0,i.Z1)(e,n);o&&(0,y.t9)("updateChatDefaultBannedRights",{chat:o,bannedRights:a})})),(0,n.Q6)("updateChatMemberBannedRights",((e,t,s)=>{const{chatId:a,userId:o,bannedRights:c}=s;let l=(0,i.Z1)(e,a);const u=(0,i.dy)(e,o);l&&u&&(async()=>{if((0,d.G9)(l)){if(l=await(0,y.t9)("migrateChat",l),!l)return;t.openChat({id:l.id})}await(0,y.t9)("updateChatMemberBannedRights",{chat:l,user:u,bannedRights:c});const e=(0,n.Rd)(),s=(0,i.Z1)(e,a);if(!s||!s.fullInfo)return;const{members:h,kickedMembers:m}=s.fullInfo,g=!!c.viewMessages,f=!Object.keys(c).length;(0,n.R3)((0,r.a4)(e,a,{fullInfo:{...s.fullInfo,...h&&g&&{members:h.filter((e=>e.userId!==o))},...h&&!g&&{members:h.map((e=>e.userId===o?{...e,bannedRights:c}:e))},...f&&m&&{kickedMembers:m.filter((e=>e.userId!==o))}}}))})()})),(0,n.Q6)("updateChatAdmin",((e,t,s)=>{const{chatId:a,userId:o,adminRights:c,customTitle:l}=s;let u=(0,i.Z1)(e,a);const h=(0,i.dy)(e,o);u&&h&&(async()=>{if((0,d.G9)(u)){if(u=await(0,y.t9)("migrateChat",u),!u)return;t.openChat({id:u.id})}await(0,y.t9)("updateChatAdmin",{chat:u,user:h,adminRights:c,customTitle:l});const e=(0,n.Rd)(),s=(0,i.Z1)(e,a);if(!s||!s.fullInfo)return;const{adminMembers:m}=s.fullInfo,g=!Object.keys(c).length;(0,n.R3)((0,r.a4)(e,a,{fullInfo:{...s.fullInfo,...m&&g&&{adminMembers:m.filter((e=>e.userId!==o))},...m&&!g&&{adminMembers:m.map((e=>e.userId===o?{...e,adminRights:c,customTitle:l}:e))}}}))})()})),(0,n.Q6)("updateChat",((e,t,s)=>{const{chatId:a,title:o,about:c,photo:d}=s,l=(0,i.Z1)(e,a);l&&(async()=>{(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.InProgress)),await Promise.all([l.title!==o?(0,y.t9)("updateChatTitle",l,o):void 0,l.fullInfo&&l.fullInfo.about!==c?(0,y.t9)("updateChatAbout",l,c):void 0,d?(0,y.t9)("editChatPhoto",{chatId:a,accessHash:l.accessHash,photo:d}):void 0]),(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.Complete))})()})),(0,n.Q6)("toggleSignatures",((e,t,s)=>{const{chatId:n,isEnabled:a}=s,o=(0,i.Z1)(e,n);o&&(0,y.t9)("toggleSignatures",{chat:o,isEnabled:a})})),(0,n.Q6)("loadGroupsForDiscussion",(()=>{(async()=>{const e=await(0,y.t9)("fetchGroupsForDiscussion");if(!e)return;const t=e.reduce(((e,t)=>(t&&(e[t.id]=t),e)),{}),s=(0,r.fZ)((0,n.Rd)(),t);(0,n.R3)({...s,chats:{...s.chats,forDiscussionIds:Object.keys(t).map(Number)}})})()})),(0,n.Q6)("linkDiscussionGroup",((e,t,s)=>{const{channelId:n,chatId:a}=s,o=(0,i.Z1)(e,n);let r=(0,i.Z1)(e,a);o&&r&&(async()=>{if((0,d.G9)(r)){if(r=await(0,y.t9)("migrateChat",r),!r)return;t.openChat({id:r.id})}let{fullInfo:e}=r;if(!e){const t=await(0,y.t9)("fetchFullChat",r);if(!t)return;e=t.fullInfo}e.isPreHistoryHidden&&await(0,y.t9)("togglePreHistoryHidden",{chat:r,isEnabled:!1}),(0,y.t9)("setDiscussionGroup",{channel:o,chat:r})})()})),(0,n.Q6)("unlinkDiscussionGroup",((e,t,s)=>{var n;const{channelId:a}=s,o=(0,i.Z1)(e,a);if(!o)return;let r;null!==(n=o.fullInfo)&&void 0!==n&&n.linkedChatId&&(r=(0,i.Z1)(e,o.fullInfo.linkedChatId)),(async()=>{await(0,y.t9)("setDiscussionGroup",{channel:o}),r&&M(r)})()})),(0,n.Q6)("setActiveChatFolder",((e,t,s)=>({...e,chatFolders:{...e.chatFolders,activeChatFolder:s}}))),(0,n.Q6)("loadMoreMembers",(e=>{(async()=>{var t,s;const{chatId:a}=(0,i.Bt)(e)||{},o=a?(0,i.Z1)(e,a):void 0;if(!o||(0,d.G9)(o))return;const c=(null===(t=o.fullInfo)||void 0===t||null===(s=t.members)||void 0===s?void 0:s.length)||void 0,l=await(0,y.t9)("fetchMembers",o.id,o.accessHash,"recent",c);if(!l)return;const{members:u,users:h}=l;u&&u.length&&(e=(0,n.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(h,"id")),e=(0,r.a4)(e,o.id,{fullInfo:{...o.fullInfo,members:[...(o.fullInfo||{}).members||[],...u||[]]}}),(0,n.R3)(e))})()})),(0,n.Q6)("addChatMembers",((e,t,s)=>{const{chatId:n,memberIds:a}=s,o=(0,i.Z1)(e,n),r=a.map((t=>(0,i.dy)(e,t))).filter(Boolean);o&&r.length&&(t.setNewChatMembersDialogState(h.WB.Loading),(async()=>{await(0,y.t9)("addChatMembers",o,r),t.setNewChatMembersDialogState(h.WB.Closed),M(o)})())})),(0,n.Q6)("deleteChatMember",((e,t,s)=>{const{chatId:n,userId:a}=s,o=(0,i.Z1)(e,n),r=(0,i.dy)(e,a);o&&r&&(async()=>{await(0,y.t9)("deleteChatMember",o,r),M(o)})()}));const E=new Map,k=(0,Z.Ds)((e=>e()),500,!1);async function R(e,t,s,o,c=!1,d=!1){const l=e.id;let u;switch(o){case h.Uq.Backwards:u=void 0;break;case h.Uq.Around:u=-(Math.round(a.hT/2)+1);break;case h.Uq.Forwards:u=-(a.hT+1)}const m=await(0,y.t9)("fetchMessages",{chat:(0,i.Cm)((0,n.Rd)(),l,t),offsetId:s,addOffset:u,limit:a.hT,threadId:t});if(!m)return;const{messages:f,users:p,chats:I,threadInfos:v}=m,Z=(0,g.ee)(f,"id"),P=Object.keys(Z).map(Number);let C=(0,n.Rd)();C=(0,r.c_)(C,l,Z),C=c?(0,r.ff)(C,l,t,P):(0,r.xj)(C,l,t,P),C=(0,r.Sh)(C,(0,g.ee)(p,"id")),C=(0,r.fZ)(C,(0,g.ee)(I,"id")),C=(0,r.j6)(C,l,v);let w=(0,i.gb)(C,l,t);const b=(0,i.qC)(C,l,t);if(c&&w&&b&&(b.length&&!(0,g.YE)(w,b)||(C=(0,r.xj)(C,l,t,b),w=(0,i.gb)(C,l,t),C=(0,r.pf)(C,l,t,"outlyingIds",void 0),c=!1)),!d){const e=c?b:w,{newViewportIds:n}=T(e,s,o);C=(0,r.y9)(C,l,t,n)}(0,n.R3)(C)}function T(e,t,s){const{length:n}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,n)=>s===t||s<t&&e[n+1]>t))}(e,t):-1,r=s===h.Uq.Backwards?o:o+1||n,i=r-a.hT,c=r+a.hT-1,d=e.slice(Math.max(0,i),c+1);let l,u;switch(s){case h.Uq.Backwards:l=r>0,u=i>=0;break;case h.Uq.Forwards:l=r<n,u=c<=n-1;break;case h.Uq.Around:default:l=d.length>0,u=d.length===a.hT}return{newViewportIds:d,areSomeLocal:l,areAllLocal:u}}async function N(e){let t;const s=e.attachment?(e,a)=>{E.has(a)||(t=a,E.set(a,s));const o=(0,n.Rd)();(0,n.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||m.cj)&&await(0,Z.Pn)();const a=(0,n.Rd)();e.serverTimeOffset=a.serverTimeOffset;const o=(0,i.Bt)(a);if(!o)return;const{threadId:r}=o;e.replyingTo||r===u._f||(e.replyingTo=(0,i.qS)(a,e.chat.id,r)),await(0,y.t9)("sendMessage",e,s),s&&t&&E.delete(t)}(0,n.Q6)("loadViewportMessages",((e,t,s)=>{const{direction:n=h.Uq.Around,isBudgetPreload:o=!1}=s||{};let{chatId:c,threadId:d}=s||{};if(!c){const t=(0,i.Bt)(e);if(!t)return;c=t.chatId,d=t.threadId}const l=(0,i.Z1)(e,c);if(!l||l.isRestricted)return;const u=(0,i.Cb)(e,c,d),m=(0,i.gb)(e,c,d),g=(0,i.qC)(e,c,d);if(u&&u.length&&n!==h.Uq.Around){const s=n===h.Uq.Backwards?u[0]:u[u.length-1],a=Boolean(g),i=a?g:m,{newViewportIds:f,areSomeLocal:p,areAllLocal:I}=T(i,s,n);if(p&&(e=(0,r.y9)(e,c,d,f)),async function(e,t,s,n,a,o,r,i){t||await R(a,o,i,r,s,n),n||(await Promise.resolve(),e.loadViewportMessages({chatId:a.id,threadId:o,direction:r,isBudgetPreload:!0}))}(t,I,a,o,l,d,n,s),o)return}else{const t=(0,i.G$)(e,c)||(0,i.rd)(e,c,d),s=Boolean(t&&m&&!m.includes(t)),n=(s?g:m)||[],{newViewportIds:u,areSomeLocal:f,areAllLocal:p}=T(n,t,h.Uq.Around);f&&u.length>=a.hT&&(e=(0,r.y9)(e,c,d,u)),p||R(l,d,t,h.Uq.Around,s,o)}return e})),(0,n.Q6)("loadMessage",((e,t,s)=>{const{chatId:a,messageId:o,replyOriginForId:c,threadUpdate:d}=s,l=(0,i.Z1)(e,a);l&&(async()=>{const e=await async function(e,t,s){const a=await(0,y.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===u._Q){if(s){let t=(0,n.Rd)();const a=(0,i.hj)(t,e.id,s);t=(0,r.cY)(t,e.id,s,{...a,replyToMessageId:void 0}),(0,n.R3)(t)}return}let o=(0,n.Rd)();return o=(0,r.cY)(o,e.id,t,a.message),o=(0,r.Sh)(o,(0,g.ee)(a.users,"id")),(0,n.R3)(o),a.message}(l,o,c);if(e&&d){const{lastMessageId:t,isDeleting:s}=d;(0,n.R3)((0,r.lG)((0,n.Rd)(),e,a,t,s))}})()})),(0,n.Q6)("sendMessage",((e,t,s)=>{const n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:r,type:c}=n;if("scheduled"===c&&!s.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:s}};const d=(0,i.Z1)(e,o);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:r,value:!1});const l={...s,chat:d,replyingTo:(0,i.Yy)(e,o,r),noWebPage:(0,i.tV)(e,o,r)},u=!s.attachments||s.attachments.length<=1,h=!u&&s.attachments&&s.attachments.length>1;if(u){const{attachments:e,...t}=l;N({...t,attachment:e?e[0]:void 0})}else if(h){const{text:e,entities:t,attachments:s,...n}=l,o=(0,g.Vl)(s,a.DU);for(let s=0;s<o.length;s++){const[a,...r]=o[s],i=`${Date.now()}${s}`;N({...n,text:0===s?e:void 0,entities:0===s?t:void 0,attachment:a,groupedId:r.length>0?i:void 0}),r.forEach((e=>{N({...n,attachment:e,groupedId:i})}))}}else{const{text:e,entities:t,attachments:s,replyingTo:n,...a}=l;e&&N({...a,text:e,entities:t,replyingTo:n}),s.forEach((e=>{N({...a,attachment:e})}))}})),(0,n.Q6)("editMessage",((e,t,s)=>{const{serverTimeOffset:n}=e,{text:a,entities:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c,threadId:d,type:l}=r,u=(0,i.Z1)(e,c),h=(0,i.kK)(e,c,d,l);u&&h&&((0,y.t9)("editMessage",{chat:u,message:h,text:a,entities:o,noWebPage:(0,i.tV)(e,c,d),serverTimeOffset:n}),t.setEditingId({messageId:void 0}))})),(0,n.Q6)("cancelSendingMessage",((e,t,s)=>{const{chatId:n,messageId:a}=s,o=(0,i.hj)(e,n,a),r=o&&E.get(o.previousLocalId||o.id);r&&(0,y.u3)(r),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:n})})),(0,n.Q6)("saveDraft",((e,t,s)=>{const{chatId:n,threadId:a,draft:o}=s;if(!o)return;const{text:c,entities:d}=o,l=(0,i.Z1)(e,n);return a===u._f&&(0,y.t9)("saveDraft",{chat:l,text:c,entities:d,replyToMsgId:(0,i.Yy)(e,n,a)}),e=(0,r.pf)(e,n,a,"draft",o),(0,r.a4)(e,n,{draftDate:Math.round(Date.now()/1e3)})})),(0,n.Q6)("clearDraft",((e,t,s)=>{const{chatId:n,threadId:a,localOnly:o}=s;if(!(0,i.Ms)(e,n,a))return;const c=(0,i.Z1)(e,n);return o||a!==u._f||(0,y.t9)("clearDraft",c),e=(0,r.pf)(e,n,a,"draft",void 0),(0,r.a4)(e,n,{draftDate:void 0})})),(0,n.Q6)("toggleMessageWebPage",((e,t,s)=>{const{chatId:n,threadId:a,noWebPage:o}=s;return(0,r.pf)(e,n,a,"noWebPage",o)})),(0,n.Q6)("pinMessage",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageId:a,isUnpin:o,isOneSide:r,isSilent:c}=s;(0,y.t9)("pinMessage",{chat:n,messageId:a,isUnpin:o,isOneSide:r,isSilent:c})})),(0,n.Q6)("unpinAllMessages",((e,t,s)=>{const a=(0,i.Z1)(e,s.chatId);a&&async function(e){await(0,y.t9)("unpinAllMessages",{chat:e});let t=(0,n.Rd)();t=(0,r.pf)(t,e.id,u._f,"pinnedIds",[]),(0,n.R3)(t)}(a)})),(0,n.Q6)("deleteMessages",((e,t,s)=>{const{messageIds:n,shouldDeleteForAll:a}=s,o=(0,i.Bt)(e);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);(0,y.t9)("deleteMessages",{chat:d,messageIds:n,shouldDeleteForAll:a});const l=(0,i._$)(e,r,c);n.includes(l)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o}=a,r=(0,i.Z1)(e,o);(0,y.t9)("deleteScheduledMessages",{chat:r,messageIds:n});const c=(0,i.wU)(e,o);n.includes(c)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteHistory",((e,t,s)=>{(async()=>{var n;const{chatId:a,shouldDeleteForAll:o}=s,r=(0,i.Z1)(e,a);if(!r)return;const c=null===(n=r.lastMessage)||void 0===n?void 0:n.id;await(0,y.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o,maxId:c});const d=(0,i.Bt)(e);d&&d.chatId===a&&t.openChat({id:void 0})})()})),(0,n.Q6)("reportMessages",((e,t,s)=>{(async()=>{const{messageIds:n,reason:a,description:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c}=r,d=(0,i.Z1)(e,c),l=await(0,y.t9)("reportMessages",{peer:d,messageIds:n,reason:a,description:o});t.showNotification({message:l?"Thank you! Your report will be reviewed by our team.":"Error occured while submiting report. Please, try again later."})})()})),(0,n.Q6)("markMessageListRead",((e,t,s)=>{const{serverTimeOffset:n}=e,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c}=a,d=(0,i.Cm)(e,o,c);if(!d)return;const{maxId:l}=s;if(k((()=>{(0,y.t9)("markMessageListRead",{serverTimeOffset:n,chat:d,threadId:c,maxId:l})})),c!==u._f)return;const h=(0,i.Cb)(e,o,c),m=(0,i.It)(e,o,c);if(!h||!m||!d.unreadCount)return;const g=function(e,t,s){let n=0;for(let a=0,o=e.length;a<o&&(e[a]>=t&&e[a]<=s&&n++,!(e[a]>=s));a++);return n}(h,m,l);return g?(0,r.a4)(e,o,{lastReadInboxMessageId:l,unreadCount:Math.max(0,d.unreadCount-g)}):void 0})),(0,n.Q6)("markMessagesRead",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageIds:a}=s;(0,y.t9)("markMessagesRead",{chat:n,messageIds:a})})),(0,n.Q6)("loadWebPagePreview",((e,t,s)=>{const{text:a}=s;!async function(e){const t=await(0,y.t9)("fetchWebPagePreview",{message:e});(0,n.R3)({...(0,n.Rd)(),webPagePreview:t})}(a)})),(0,n.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,n.Q6)("sendPollVote",((e,t,s)=>{const{chatId:n,messageId:a,options:o}=s,r=(0,i.Z1)(e,n);r&&(0,y.t9)("sendPollVote",{chat:r,messageId:a,options:o})})),(0,n.Q6)("loadPollOptionResults",((e,t,s)=>{const{chat:a,messageId:o,option:i,offset:c,limit:d,shouldResetVoters:l}=s;!async function(e,t,s,a,o,i){const c=await(0,y.t9)("loadPollOptionResults",{chat:e,messageId:t,option:s,offset:a,limit:o});if(!c)return;let d=(0,n.Rd)();d=(0,r.Sh)(d,(0,g.ee)(c.users,"id"));const{voters:l}=d.pollResults;(0,n.R3)({...d,pollResults:{...d.pollResults,voters:{...l,[s]:[...!i&&l&&l[s]?l[s]:[],...c&&c.users.map((e=>e.id))].filter(((e,t,s)=>s.indexOf(e)===t))},offsets:{...d.pollResults.offsets?d.pollResults.offsets:{},[s]:c.nextOffset||""}}})}(a,o,i,c,d,l)})),(0,n.Q6)("forwardMessages",(e=>{const{fromChatId:t,messageIds:s,toChatId:a}=e.forwardMessages,o=t?(0,i.Z1)(e,t):void 0,r=a?(0,i.Z1)(e,a):void 0,c=t&&s?s.sort(((e,t)=>e-t)).map((s=>(0,i.hj)(e,t,s))).filter(Boolean):void 0;o&&r&&c&&c.length&&function(e,t,s){(0,y.t9)("forwardMessages",{fromChat:e,toChat:t,messages:s,serverTimeOffset:(0,n.Rd)().serverTimeOffset}),(0,n.R3)({...(0,n.Rd)(),forwardMessages:{}})}(o,r,c)})),(0,n.Q6)("loadScheduledHistory",(e=>{const t=(0,i.jr)(e);if(!t)return;const{hash:s}=e.scheduledMessages.byChatId[t.id]||{};!async function(e,t){const s=await(0,y.t9)("fetchScheduledHistory",{chat:e,hash:t});if(!s)return;const{hash:a,messages:o}=s,i=(0,g.ee)(o,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,n.Rd)();d=(0,r.w3)(d,e.id,i,a),d=(0,r.pf)(d,e.id,u._f,"scheduledIds",c),(0,n.R3)(d)}(t,s)})),(0,n.Q6)("sendScheduledMessages",((e,t,s)=>{const{chatId:n,id:a}=s,o=(0,i.Z1)(e,n);o&&(0,y.t9)("sendScheduledMessages",{chat:o,ids:[a]})})),(0,n.Q6)("rescheduleMessage",((e,t,s)=>{const{chatId:n,messageId:a,scheduledAt:o}=s,r=(0,i.Z1)(e,n),c=r&&(0,i.Tm)(e,r.id,a);r&&c&&(0,y.t9)("rescheduleMessage",{chat:r,message:c,scheduledAt:o})})),(0,n.Q6)("requestThreadInfoUpdate",((e,t,s)=>{const{chatId:n,threadId:a}=s,o=(0,i.Cm)(e,n,a);o&&(0,y.t9)("requestThreadInfoUpdate",{chat:o,threadId:a})})),(0,n.Q6)("loadPinnedMessages",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&async function(e){const t=await(0,y.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:s,chats:a,users:o}=t,i=(0,g.ee)(s,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,n.Rd)();d=(0,r.c_)(d,e.id,i),d=(0,r.pf)(d,e.id,u._f,"pinnedIds",c),d=(0,r.Sh)(d,(0,g.ee)(o,"id")),d=(0,r.fZ)(d,(0,g.ee)(a,"id")),(0,n.R3)(d)}(o)}));var B=s(5765);const x=(0,Z.P2)((e=>e()),500,!1);async function A(e,t){const s=await(0,y.t9)("searchGifs",{query:e,offset:t});s&&(0,n.R3)((0,r.rq)((0,n.Rd)(),!t,s.gifs,s.nextOffset))}(0,n.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e=0){const t=await(0,y.t9)("fetchStickerSets",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"added",t.hash,t.sets))}(t)})),(0,n.Q6)("loadAddedStickers",((e,t)=>{const{setIds:s}=e.stickers.added;s&&s.length&&(async()=>{for(let e=0;e<s.length;e++)t.loadStickers({stickerSetId:s[e]}),e%50==0&&e>0&&await(0,Z.wO)(500)})()})),(0,n.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e=0){const t=await(0,y.t9)("fetchRecentStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,recent:t}})}(t)})),(0,n.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e=0){const t=await(0,y.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,favorite:t}})}(t)})),(0,n.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,y.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,n.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e=0){const t=await(0,y.t9)("fetchFeaturedStickers",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,n.Q6)("loadStickers",((e,t,s)=>{const{stickerSetId:a,stickerSetShortName:o}=s;let{stickerSetAccessHash:c}=s;if(!c&&!o){const t=(0,i.Ny)(e,a);if(!t)return;c=t.accessHash}!async function(e,t,s){const a=await(0,y.t9)("fetchStickers",{stickerSetShortName:s,stickerSetId:e,accessHash:t});if(!a)return;const{set:o,stickers:i,packs:c}=a;let d=(0,n.Rd)();d=(0,r.Rg)(d,o.id,{...o,stickers:i,packs:c});const l=d.stickers.forEmoji.emoji;l&&c[l]&&(d=(0,r.vy)(d)),(0,n.R3)(d)}(a,c,o)})),(0,n.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,y.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:s}=e;(0,n.R3)((0,r.g_)((0,n.Rd)(),{...t,stickers:s}))}()})),(0,n.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e=0){const t=await(0,y.t9)("fetchSavedGifs",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,gifs:{...s.gifs,saved:t}})}(t)})),(0,n.Q6)("faveSticker",((e,t,s)=>{const{sticker:n}=s;n&&(0,y.t9)("faveSticker",{sticker:n})})),(0,n.Q6)("unfaveSticker",((e,t,s)=>{const{sticker:a}=s;a&&function(e){const t=(0,n.Rd)();(0,n.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((({id:t})=>t!==e.id))}}}),(0,y.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,n.Q6)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:n}=s,a=(0,i.Ny)(e,n);if(!a)return;const{accessHash:o,installedDate:r}=a;(0,y.t9)(r?"uninstallStickerSet":"installStickerSet",{stickerSetId:n,accessHash:o})})),(0,n.Q6)("loadEmojiKeywords",((e,t,s)=>{var a;const{language:o}=s;let r=e.emojiKeywords[o];null!==(a=r)&&void 0!==a&&a.isLoading||((0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}}),(async()=>{var t;const s=await(0,y.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});e=(0,n.Rd)(),r=e.emojiKeywords[o],s?(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:s.version,keywords:{...null===(t=r)||void 0===t?void 0:t.keywords,...s.keywords}}}}):(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})())})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:a}=s;a&&x((()=>{!async function(e,t=0){const s=await(0,y.t9)("searchStickers",{query:e,hash:t});if(!s)return;const a=(0,n.Rd)(),{setsById:o,added:i}=a.stickers,c=s.sets.map((({id:e})=>e));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:s}=o[t]||{};s&&(0,B.Z)(s,e)&&c.unshift(t)}})),(0,n.R3)((0,r.z3)(a,"search",s.hash,s.sets,c))}(a)}))})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;"string"==typeof n&&x((()=>{A(n)}))})),(0,n.Q6)("searchMoreGifs",(e=>{const{query:t,offset:s}=e.gifs.search;"string"==typeof t&&x((()=>{A(t,s)}))})),(0,n.Q6)("loadStickersForEmoji",((e,t,s)=>{const{emoji:a}=s,{hash:o}=e.stickers.forEmoji;x((()=>{!async function(e,t=0){let s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,forEmoji:{...s.stickers.forEmoji,emoji:e}}});const a=await(0,y.t9)("fetchStickersForEmoji",{emoji:e,hash:t});s=(0,n.Rd)(),a&&s.stickers.forEmoji.emoji===e&&(s=(0,r.IM)(s,e,a.stickers,a.hash),(0,n.R3)(s))}(a,o)}))})),(0,n.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,n.Q6)("openStickerSetShortName",((e,t,s)=>{const{stickerSetShortName:n}=s;return{...e,openedStickerSetShortName:n}}));var L=s(790);const O=(0,Z.P2)((e=>e()),500,!1);async function F(e="",t,s,o,c,d){let l;if(o){const n=await(0,y.t9)("searchMessagesLocal",{chatOrUser:o,query:e,type:t,limit:a.Hk,offsetId:s,minDate:d,maxDate:c});if(n){const{messages:e,users:t,totalCount:s,nextOffsetId:a}=n;l={messages:e,users:t,chats:[],totalCount:s,nextRate:a}}}else l=await(0,y.t9)("searchMessagesGlobal",{query:e,offsetRate:s,limit:a.Hk,type:t,maxDate:c,minDate:d});let u=(0,n.Rd)();const h=(0,i.JX)(u);if(!l||""!==e&&e!==h)return void(0,n.R3)((0,r.xv)(u,{messages:!1}));const{messages:m,users:f,chats:p,totalCount:I,nextRate:v}=l;p.length&&(u=(0,r.fZ)(u,(0,g.ee)(p,"id"))),f.length&&(u=(0,r.Sh)(u,(0,g.ee)(f,"id"))),m.length&&(u=(0,r.m6)(u,m)),u=(0,r.px)(u,m,I,t,v),(0,n.R3)(u)}async function U(){const e=await(0,y.t9)("fetchChats",{limit:a.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,n.Rd)().serverTimeOffset});if(!e)return;let t=(0,n.Rd)();t=(0,r.eD)(t,(0,g.ee)(e.users,"id")),t=(0,r.GL)(t,(0,g.ee)(e.chats,"id")),t=(0,r.Mg)(t,"archived",e.chatIds),t=(0,r.vv)(t,"archived",e),(0,n.R3)(t)}async function $(){let e=(0,n.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:s}=e.contactList||{};if(!(s&&s.length||t&&t.length))return;const a=[...t||[],...s||[]].map((t=>(0,i.dy)(e,t))).filter(Boolean),o=await(0,y.t9)("fetchUsers",{users:a});o&&(e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(o,"id")),(0,n.R3)(e))}function Q(e){return(0,y.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{chatId:a}=e.globalSearch,{query:o}=s;o&&!a&&O((()=>{!async function(e){const t=await(0,y.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=(0,i.JX)(s);if(!t||!a||e!==a)return void(0,n.R3)((0,r.xv)(s,{chats:!1}));const{localChats:o,localUsers:c,globalChats:d,globalUsers:l}=t;(o.length||d.length)&&(s=(0,r.fZ)(s,(0,g.ee)([...o,...d],"id"))),(c.length||l.length)&&(s=(0,r.Sh)(s,(0,g.ee)([...c,...l],"id"))),s=(0,r.xv)(s,{chats:!1}),s=(0,r.No)(s,{localResults:{chatIds:o.map((({id:e})=>e)),userIds:c.map((({id:e})=>e))},globalResults:{...s.globalSearch.globalResults,chatIds:l.map((({id:e})=>e)),userIds:d.map((({id:e})=>e))}}),(0,n.R3)(s)}(o)}))})),(0,n.Q6)("setGlobalSearchDate",((e,t,s)=>{const{date:a}=s,o=a?(0,L.IS)(a):a,c=(0,r.No)(e,{date:a,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,n.R3)(c);const{chatId:d}=e.globalSearch;F("","text",void 0,d?(0,i.Z1)(e,d):void 0,o,a)})),(0,n.Q6)("searchMessagesGlobal",((e,t,s)=>{var n;const{query:a,resultsByType:o,chatId:r,date:c}=e.globalSearch,d=c?(0,L.IS)(c):c,{type:l}=s;F(a,l,null==o||null===(n=o[l])||void 0===n?void 0:n.nextOffsetId,r?(0,i.Z1)(e,r):void 0,d,c)})),(0,n.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},o=t?(0,i.Z1)(e,t):void 0,c=(0,i.n5)(e);if(!o||!c||!s)return;const{query:d,results:l}=c,h=null==l?void 0:l.nextOffsetId;let m;if(s!==u._f){const n=(0,i.tZ)(e,t,s);m=null==n?void 0:n.topMessageId}!async function(e,t,s,o,c){const d=await(0,y.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:s,limit:a.pn,offsetId:c});if(!d)return;const{messages:l,users:u,totalCount:h,nextOffsetId:m}=d,f=(0,g.ee)(l,"id"),p=Object.keys(f).map(Number);let I=(0,n.Rd)();const v=(0,i.n5)(I);!v||o&&o!==v.query||(I=(0,r.c_)(I,e.id,f),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.dx)(I,e.id,t,p,h,m),(0,n.R3)(I))}(o,s,m,d,h)})),(0,n.Q6)("searchMediaMessagesLocal",(e=>{const t=(0,i.og)(e),s=t?e.users.byId[t]||e.chats.byId[t]:void 0,o=(0,i.we)(e);if(!s||!o)return;const{currentType:c,resultsByType:d}=o,l=c&&d&&d[c],u=null==l?void 0:l.nextOffsetId;c&&async function(e,t,s){const o=await(0,y.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:a.EN,offsetId:s});if(!o)return;const{messages:c,users:d,totalCount:l,nextOffsetId:u}=o,h=(0,g.ee)(c,"id"),m=Object.keys(h).map(Number);let f=(0,n.Rd)();(0,i.we)(f)&&(f=(0,r.c_)(f,e.id,h),f=(0,r.Sh)(f,(0,g.ee)(d,"id")),f=(0,r.c1)(f,e.id,t,m,l,u),(0,n.R3)(f))}(s,c,u)})),(0,n.Q6)("searchMessagesByDate",((e,t,s)=>{const{timestamp:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return;const r=(0,i.Z1)(e,o);r&&async function(e,t){const s=await(0,y.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});s&&(0,n.uC)().focusMessage({chatId:e.id,messageId:s})}(r,a)})),(0,n.Q6)("checkPublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};if(!a)return;if(e.management.progress===h.wv.InProgress)return;const{username:o}=s;(async()=>{e=(0,r.H9)(e,h.wv.InProgress),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e);const t=await(0,y.t9)("checkChatUsername",{username:o});e=(0,n.Rd)(),e=(0,r.H9)(e,t?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:t}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};let o=a&&(0,i.Z1)(e,a);if(!a||!o)return;const{username:c}=s;(async()=>{if(e=(0,r.H9)(e,h.wv.InProgress),(0,n.R3)(e),(0,d.G9)(o)){if(o=await(0,y.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const s=await(0,y.t9)("setChatUsername",{chat:o,username:c});e=(0,n.Rd)(),e=(0,r.H9)(e,s?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t&&(0,i.Z1)(e,t);t&&s&&(0,y.t9)("updatePrivateLink",{chat:s})})),(0,n.Q6)("sync",((e,t)=>{!async function(e){a.eM&&console.log(">>> START SYNC"),await(0,y.t9)("fetchCurrentUser");const t=await async function(){const e=await(0,y.t9)("fetchChats",{limit:a.Ov,withPinned:!0,serverTimeOffset:(0,n.Rd)().serverTimeOffset});if(!e)return;let t=(0,n.Rd)();const{recentlyFoundChatIds:s}=t.globalSearch,{userIds:o}=t.contactList||{},{currentUserId:c}=t,l=[...s||[],...o||[],...c?[c]:[]],h=l.map((e=>(0,i.dy)(t,e))).filter(Boolean),m=l.map((e=>(0,i.Z1)(t,e))).filter(Boolean),{chatId:f}=(0,i.Bt)(t)||{};if(f){const e=(0,i.Z1)(t,f);if(e&&!l.includes(f)&&m.push(e),(0,d.YA)(f)){const e=(0,i.dy)(t,f);e&&!l.includes(f)&&h.push(e)}}return h.push(...e.users),m.push(...e.chats),t=(0,r.SL)(t,(0,g.ee)(m,"id")),t=(0,r.Mg)(t,"active",e.chatIds),t={...t,chats:{...t.chats}},t=(0,r.vv)(t,"active",e),Object.keys(e.draftsById).map(Number).forEach((s=>{t=(0,r.pf)(t,s,u._f,"draft",e.draftsById[s])})),Object.keys(e.replyingToById).map(Number).forEach((s=>{t=(0,r.pf)(t,s,u._f,"replyingToId",e.replyingToById[s])})),(0,n.R3)(t),f&&!t.chats.byId[f]&&(0,n.uC)().openChat({id:void 0}),h}();await async function(e){let t=!1,s=e||[],a=(0,n.Rd)();const{chatId:o,threadId:c}=(0,i.Bt)(a)||{},d=Object.keys(a.messages.byChatId).map(Number).reduce(((e,t)=>{const s=(0,i.Ms)(a,t,u._f);return s?{...e,[t]:s}:e}),{});if(o){const e=await Q(a.chats.byId[o]);a=(0,n.Rd)();const{chatId:d}=(0,i.Bt)(a)||{},l=c&&(0,i.tZ)(a,o,c);if(e&&d===o){const n=a.messages.byChatId[o],i=(0,g.ee)(e.messages,"id"),d=Object.keys(i).map(Number);if(a={...a,messages:{...a.messages,byChatId:{[o]:{byId:i,threadsById:{[u._f]:{...null==n?void 0:n.threadsById[u._f],listedIds:d,viewportIds:d,outlyingIds:void 0}}}}}},c&&l&&l.originChannelId){const{originChannelId:e}=l,t=a.messages.byChatId[e],s=await Q(a.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),r=Object.keys(e).map(Number);a={...a,messages:{...a.messages,byChatId:{...a.messages.byChatId,[l.originChannelId]:{byId:e,threadsById:{[u._f]:{...null==t?void 0:t.threadsById[u._f],listedIds:r,viewportIds:r,outlyingIds:void 0}}},[o]:{...a.messages.byChatId[o],threadsById:{...a.messages.byChatId[o].threadsById,[c]:{...null==n?void 0:n.threadsById[c],outlyingIds:void 0}}}}}}}}a=(0,r.GL)(a,(0,g.ee)(e.chats,"id")),a=(0,r.j6)(a,o,e.threadInfos),t=!0,s=Array.prototype.concat(s,e.users)}}t||(a={...a,messages:{...a.messages,byChatId:{}}}),Object.keys(d).map(Number).forEach((e=>{a=(0,r.pf)(a,e,u._f,"draft",d[e])})),e?a=(0,r.s5)(a,(0,g.ee)(s,"id")):s&&(a=(0,r.eD)(a,(0,g.ee)(s,"id"))),(0,n.R3)(a);const{chatId:l,messageId:h}=a.audioPlayer;l&&h&&!(0,i.hj)(a,l,h)&&(0,n.uC)().closeAudioPlayer()}(t),(0,n.R3)({...(0,n.Rd)(),lastSyncTime:Date.now()}),a.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,n.Q6)("afterSync",((e,t)=>{!async function(e){a.eM&&console.log(">>> START AFTER-SYNC"),e.loadFavoriteStickers(),await Promise.all([$(),U()]),await(0,y.t9)("fetchCurrentUser"),a.eM&&console.log(">>> FINISH AFTER-SYNC")}(t)}));var D=s(2267);const q=(0,Z.Ds)((e=>e()),500,!1,!0),G=(0,Z.P2)((e=>e()),500,!1);function H(e,t,s){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:s}}}}function j(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,n.Q6)("loadFullUser",((e,t,s)=>{const{userId:n}=s,a=(0,i.dy)(e,n);if(!a)return;const{id:o,accessHash:r}=a;q((()=>(0,y.t9)("fetchFullUser",{id:o,accessHash:r})))})),(0,n.Q6)("loadUser",((e,t,s)=>{const{userId:a}=s,o=(0,i.dy)(e,a);o&&(async()=>{const t=await(0,y.t9)("fetchUsers",{users:[o]});t&&(e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(t,"id")),(0,n.R3)(e))})()})),(0,n.Q6)("loadTopUsers",(e=>{const{topPeers:{hash:t,lastRequestedAt:s}}=e;(!s||(0,D.b)(e.serverTimeOffset)-s>60)&&async function(e){const t=await(0,y.t9)("fetchTopUsers",{hash:e});if(!t)return;const{hash:s,ids:a,users:o}=t;let i=(0,n.Rd)();i=(0,r.Sh)(i,(0,g.ee)(o,"id")),i={...i,topPeers:{...i.topPeers,hash:s,userIds:a,lastRequestedAt:(0,D.b)(i.serverTimeOffset)}},(0,n.R3)(i)}(t)})),(0,n.Q6)("loadContactList",(e=>{const{hash:t}=e.contactList||{};!async function(e){const t=await(0,y.t9)("fetchContactList",{hash:e});if(!t)return;let s=(0,r.Sh)((0,n.Rd)(),(0,g.ee)(t.users,"id"));s=(0,r.fZ)(s,(0,g.ee)(t.chats,"id"));const a=e=>e.lastName||e.firstName||"",o=new Intl.Collator("en-US"),i=t.users.sort(((e,t)=>o.compare(a(e),a(t)))).filter((e=>!e.isSelf));(0,n.R3)({...s,contactList:{hash:t.hash,userIds:i.map((e=>e.id))}})}(t)})),(0,n.Q6)("loadCurrentUser",(()=>{(0,y.t9)("fetchCurrentUser")})),(0,n.Q6)("updateContact",((e,t,s)=>{const{userId:a,isMuted:o,firstName:c,lastName:d}=s;!async function(e,t,s,a){const o=(0,n.Rd)(),c=(0,i.dy)(o,e);c&&((0,n.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.InProgress)),await(0,y.t9)("updateContact",{phone:c.phoneNumber,firstName:s,lastName:a})&&(0,n.R3)((0,r.Nq)((0,n.Rd)(),c.id,{firstName:s,lastName:a})),(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.Complete)))}(a,o,c,d)})),(0,n.Q6)("deleteUser",((e,t,s)=>{const{userId:a}=s;!async function(e){const t=(0,n.Rd)(),s=(0,i.dy)(t,e);if(!s)return;const{id:a,accessHash:o}=s;await(0,y.t9)("deleteUser",{id:a,accessHash:o})}(a)})),(0,n.Q6)("loadProfilePhotos",((e,t,s)=>{const{profileId:a}=s,o=(0,d.YA)(a),c=o?(0,i.dy)(e,a):void 0,l=o?void 0:(0,i.Z1)(e,a);(async()=>{const e=await(0,y.t9)("fetchProfilePhotos",c,l);if(!e||!e.photos)return;let t=(0,n.Rd)();o?t=(0,r.Nq)(t,a,{photos:e.photos}):(t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.a4)(t,a,{photos:e.photos})),(0,n.R3)(t)})()})),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:a}=s;a&&G((()=>{!async function(e){const t=await(0,y.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=s.userSearch.query;if(!t||!a||e!==a)return void(0,n.R3)((0,r.Q3)(s,!1));const{localUsers:o,globalUsers:i}=t;let c,d;o.length&&(s=(0,r.Sh)(s,(0,g.ee)(o,"id")),c=o.map((({id:e})=>e))),i.length&&(s=(0,r.Sh)(s,(0,g.ee)(i,"id")),d=i.map((({id:e})=>e))),s=(0,r.Q3)(s,!1),s=(0,r.Lm)(s,{localUserIds:c,globalUserIds:d}),(0,n.R3)(s)}(a)}))}));const _=(0,Z.Ds)((e=>e()),500,!1);async function V(e,t,s){await(0,y.t9)("sendMessage",{chat:e,text:s})}(0,n.Q6)("clickInlineButton",((e,t,s)=>{const{button:o}=s;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(a.Lj)||o.value.match(a.FS)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,i.jr)(e);if(!t)return;!async function(e,t,s){const a=await(0,y.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:s});if(!a)return;const{showDialog:o,showNotification:r,toggleSafeLinkModal:i}=(0,n.uC)(),{message:c,alert:d,url:l}=a;d?o({data:{message:c||"Error"}}):c?r({message:c}):l&&i({url:l})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"buy":{const s=(0,i.jr)(e),{messageId:n,value:a}=o;if(!s)return;a?t.getReceipt({receiptMessageId:a,chatId:s.id,messageId:n}):(t.getPaymentForm({chat:s,messageId:n}),t.setInvoiceMessageInfo((0,i.hj)(e,s.id,n)),t.openPaymentModal({chatId:s.id,messageId:n}));break}}})),(0,n.Q6)("sendBotCommand",((e,t,s)=>{const{command:n,chatId:a}=s,{currentUserId:o}=e,r=a?(0,i.Z1)(e,a):(0,i.jr)(e);o&&r&&V(r,0,n)})),(0,n.Q6)("restartBot",((e,t,s)=>{const{chatId:a}=s,{currentUserId:o}=e,c=(0,i.jr)(e),d=o&&(0,i.IK)(e,a);o&&c&&d&&(async()=>{await(0,y.t9)("unblockContact",d.id,d.accessHash)&&((0,n.R3)((0,r.rB)((0,n.Rd)(),d.id)),V(c,0,"/start"))})()})),(0,n.Q6)("loadTopInlineBots",(e=>{const{hash:t,lastRequestedAt:s}=e.topInlineBots;s&&(0,D.b)(e.serverTimeOffset)-s<60||(async()=>{const s=await(0,y.t9)("fetchTopInlineBots",{hash:t});if(!s)return;const{hash:a,ids:o,users:i}=s;let c=(0,n.Rd)();c=(0,r.Sh)(c,(0,g.ee)(i,"id")),c={...c,topInlineBots:{...c.topInlineBots,hash:a,userIds:o,lastRequestedAt:(0,D.b)(e.serverTimeOffset)}},(0,n.R3)(c)})()})),(0,n.Q6)("queryInlineBot",((e,t,s)=>{const{chatId:a,username:o,query:c,offset:d}=s;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:s,chat:a}=await(0,y.t9)("fetchInlineBot",{username:o})||{};if(e=(0,n.Rd)(),!s||!a)return void(0,n.R3)(H(e,o,!1));e=(0,r.Sh)(e,{[s.id]:s}),e=(0,r.fZ)(e,{[a.id]:a}),t={id:s.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=H(e,o,t),(0,n.R3)(e)}(c!==t.query||t.canLoadMore)&&_((()=>{!async function({username:e,inlineBotData:t,chatId:s,query:a,offset:o}){let r=(0,n.Rd)();const c=(0,i.dy)(r,t.id),d=(0,i.Z1)(r,s);if(!c||!d)return;const l=t.query!==a;r=j(r,!0),r=H(r,e,{...t,query:a,...l&&{offset:void 0,results:[]}}),(0,n.R3)(r);const u=await(0,y.t9)("fetchInlineBotResults",{bot:c,chat:d,query:a,offset:l?void 0:o}),h=r.inlineBots.byUsername[e];if(r=j((0,n.Rd)(),!1),!u||!h||a!==h.query)return void(0,n.R3)(r);const m=new Set((h.results||[]).map((e=>e.id))),g=u.results.filter((e=>!m.has(e.id)));r=H(r,e,{...h,help:u.help,...g.length&&{isGallery:u.isGallery},...u.switchPm&&{switchPm:u.switchPm},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:""}),(0,n.R3)(r)}({username:o,inlineBotData:t,chatId:a,query:c,offset:d})}))}})()})),(0,n.Q6)("sendInlineBotResult",((e,t,s)=>{const{id:n,queryId:a}=s,o=(0,i.Bt)(e);if(!o||!n)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r,threadId:c,value:!1}),(0,y.t9)("sendInlineBotResult",{chat:d,resultId:n,queryId:a,replyingTo:(0,i.Yy)(e,r,c)})})),(0,n.Q6)("resetInlineBot",((e,t,s)=>{const{username:a}=s;let o=e.inlineBots.byUsername[a];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,n.R3)(H(e,a,o)))})),(0,n.Q6)("startBot",((e,t,s)=>{const{botId:n,param:a}=s,o=(0,i.dy)(e,n);o&&(async()=>{await(0,y.t9)("startBot",{bot:o,startParam:a})})()})),s(9667),(0,n.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,y.t9)("getPasswordInfo");if(!e)return;let t=(0,n.Rd)();t=(0,r.BI)(t,{hasPassword:e.hasPassword}),t=(0,r.IE)(t,{hint:e.hint}),(0,n.R3)(t)})()})),(0,n.Q6)("checkPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("checkPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("clearPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("clearPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("updatePassword",((e,t,s)=>{const{currentPassword:a,password:o,hint:i,email:c,onSuccess:d}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("updatePassword",a,o,i,c);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&d()})()})),(0,n.Q6)("updateRecoveryEmail",((e,t,s)=>{const{currentPassword:a,email:o,onSuccess:i}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("updateRecoveryEmail",a,o);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&i()})()})),(0,n.Q6)("provideTwoFaEmailCode",((e,t,s)=>{const{code:n}=s;(0,y.t9)("provideRecoveryEmailCode",n)})),(0,n.Q6)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,n.Q6)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:a,saveInfo:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e);d&&l&&async function(e,t,s,a){const o=await(0,y.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:s,shouldSave:a});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let d=(0,r.vT)((0,n.Rd)(),i);c?(d=(0,r.TM)(d,c),d=(0,r.Q$)(d,h.KB.Shipping)):d=(0,r.Q$)(d,h.KB.PaymentInfo),(0,n.R3)(d)}(d,l,a,o)})),(0,n.Q6)("getPaymentForm",((e,t,s)=>{const{chat:a,messageId:o}=s;a&&o&&async function(e,t){const s=await(0,y.t9)("getPaymentForm",{chat:e,messageId:t});if(!s)return;let a=(0,r._7)((0,n.Rd)(),s),o=h.KB.PaymentInfo;a.payment.invoice&&(a.payment.invoice.shippingAddressRequested||a.payment.invoice.nameRequested||a.payment.invoice.phoneRequested||a.payment.invoice.emailRequested)&&(o=h.KB.ShippingInfo),a=(0,r.Q$)(a,o),(0,n.R3)(a)}(a,o)})),(0,n.Q6)("getReceipt",((e,t,s)=>{const{receiptMessageId:a,chatId:o,messageId:c}=s,d=o&&(0,i.Z1)(e,o);c&&a&&d&&async function(e,t,s){const a=await(0,y.t9)("getReceipt",e,s);if(!a)return;let o=(0,n.Rd)();const c=(0,i.hj)(o,e.id,t);o=(0,r.Dq)(o,a,c),(0,n.R3)(o)}(d,c,a)})),(0,n.Q6)("clearPaymentError",(e=>{(0,n.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,n.Q6)("clearReceipt",(e=>{(0,n.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,n.Q6)("sendCredentialsInfo",((e,t,s)=>{const a=(0,i.$$)(e);if(!a)return;const{credentials:o}=s,{data:c}=o;!async function(e,t){const s=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvv,"card[address_zip]":e.zip,"card[address_country]":e.country}),a=await fetch(`https://api.stripe.com/v1/tokens${s}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await a.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,n.Rd)();return void(0,n.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,n.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,h.KB.Checkout),(0,n.R3)(i)}(c,a)})),(0,n.Q6)("sendPaymentForm",((e,t,s)=>{const{shippingOptionId:a,saveCredentials:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e),u=(0,i.eh)(e),h=(0,i.sp)(e),m=(0,i.$$)(e),g=(0,i.i3)(e);d&&l&&m&&u&&async function(e,t,s,a,o,i){if(await(0,y.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:a,requestedInfoId:o,shippingOptionId:i})){const e=(0,r.bp)((0,n.Rd)());(0,n.R3)((0,r.WY)(e))}}(d,l,u,{save:o,data:g},h,a)})),(0,n.Q6)("setPaymentStep",((e,t,s={})=>(0,r.Q$)(e,s.step||h.KB.ShippingInfo))),(0,n.Q6)("setInvoiceMessageInfo",((e,t,s)=>(0,r.nA)(e,s))),s(4907);var W=s(8406),K=s(7358);const X=(0,Z.P2)((e=>e()),500,!0);(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{s.noTopChatsRequest||(0,i.N)(e,s.id)||t.loadTopChats();const a=(0,r.a4)(e,s.id,s.chat,s.newProfilePhoto);(0,n.R3)(a),X((()=>(0,K.w)((0,i.A1)((0,n.Rd)())))),s.chat.id&&(0,W.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const a=(0,i.Ek)(e,s.id);if(!a)break;e=(0,r.B1)(e,a,[s.id]),e=(0,r.a4)(e,s.id,{isNotJoined:!1}),(0,n.R3)(e);const o=(0,i.Z1)(e,s.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":{const t=(0,i.Ek)(e,s.id);if(!t)break;const{[t]:a}=e.chats.listIds;a&&(e=(0,r.Mg)(e,t,a.filter((e=>e!==s.id)))),e=(0,r.a4)(e,s.id,{isNotJoined:!0}),(0,n.R3)(e);break}case"updateChatInbox":(0,n.R3)((0,r.a4)(e,s.id,s.chat)),X((()=>(0,K.w)((0,i.A1)((0,n.Rd)()))));break;case"updateChatTypingStatus":{const{id:t,typingStatus:a}=s;(0,n.R3)((0,r.a4)(e,t,{typingStatus:a})),setTimeout((()=>{const e=(0,n.Rd)(),s=(0,i.Z1)(e,t);s&&a&&s.typingStatus&&s.typingStatus.timestamp===a.timestamp&&(0,n.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:a}=s,{chatId:o,threadId:c,type:d}=(0,i.Bt)(e)||{};if(a.senderId===e.currentUserId&&!a.isFromScheduled)return;const l=(0,i.Z1)(e,s.chatId);if(!l)return;const h="thread"===d&&c===u._f&&s.chatId===o;h?setTimeout((()=>{t.requestChatUpdate({chatId:s.chatId})}),1500):(0,n.R3)((0,r.a4)(e,s.chatId,{unreadCount:l.unreadCount?l.unreadCount+1:1,...s.message.hasUnreadMention&&{unreadMentionsCount:l.unreadMentionsCount?l.unreadMentionsCount+1:1}})),(0,K.w)((0,i.A1)((0,n.Rd)()));const{hasWebNotifications:m}=(0,i.dZ)(e);m&&(0,W.VL)({chat:l,message:a,isActiveChat:h});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=s;if(!1!==a.hasUnreadMention)return;t.forEach((t=>{const n="channelId"in s?s.channelId:(0,i.X5)(e,t),a=(0,i.Z1)(e,n);null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,n,{unreadMentionsCount:a.unreadMentionsCount-1}))})),(0,n.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=s,a=e.chats.byId[s.id];if(!a)return;(0,n.R3)((0,r.a4)(e,s.id,{fullInfo:{...a.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=s,r=o===a.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:t.length?t:void 0}}},(0,n.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=s,r=(0,i.Ek)(e,t);if(r){const{[r]:s}=e.chats.orderedPinnedIds;let n=s||[];if(o){if(!n.includes(t)){if("active"===r&&n.length>=a.EG){const t=e.chats.listIds.active;n=n.filter((e=>t&&t.includes(e)))}n=[t,...n]}}else n=n.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:n.length?n:void 0}}}}(0,n.R3)(e);break}case"updateChatListType":{const{id:t,folderId:a}=s;(0,n.R3)((0,r.Pi)(e,t,a));break}case"updateChatFolder":{const{id:t,folder:a}=s,{byId:o,orderedIds:r}=e.chatFolders,i=a?{...o,[t]:a}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=a?r&&r.includes(t)?r:[...r||[],t]:r?r.filter((e=>e!==t)):void 0;(0,n.R3)({...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[s.id],{replacedMembers:a,addedMember:i,deletedMemberId:c}=s;if(!t)return;let d=!1,l=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(a)l=a,d=!0;else if(i)l.length&&l.some((e=>e.userId===i.userId))||(l.push(i),d=!0);else if(l.length&&c){const e=l.findIndex((e=>e.userId===c));e>-1&&(l.slice(e,1),d=!0)}if(d){const a=l.filter((({isOwner:e,isAdmin:t})=>e||t));(0,n.R3)((0,r.a4)(e,s.id,{membersCount:l.length,fullInfo:{...t.fullInfo,members:l,adminMembers:a}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:a}=s,o=e.chats.byId[t];null!=o&&o.photos&&(0,n.R3)((0,r.a4)(e,t,{photos:o.photos.filter((e=>!a.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:a,date:o,replyingToId:i}=s;e.chats.byId[t]&&(e=(0,r.pf)(e,t,u._f,"draft",a),e=(0,r.pf)(e,t,u._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:o}),(0,n.R3)(e));break}case"showInvite":{const{data:e}=s;t.showDialog({data:e});break}}}));const Y=350;function z(e,t,s,n,a=!1){const o=a?(0,i.Tm)(e,t,s):(0,i.hj)(e,t,s);if(o&&n.content){const{photo:e,video:t,sticker:s,document:a}=(0,d.qp)(o);e&&n.content.photo?(n.content.photo.blobUrl=e.blobUrl,n.content.photo.thumbnail=e.thumbnail):t&&n.content.video?n.content.video.blobUrl=t.blobUrl:s&&n.content.sticker?n.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:a&&n.content.document&&(n.content.document.previewBlobUrl=a.previewBlobUrl)}return a?(0,r.P4)(e,t,s,n):(0,r.cY)(e,t,s,n)}function J(e,t,s,n){const{chatId:a}=s,{threadInfo:o}=(0,i.Db)(e,a,s)||{};if(!o&&s.replyToMessageId){const o=(0,i.hj)(e,a,s.replyToMessageId);o?e=(0,r.lG)(e,o,a,s.id,n):t.loadMessage({chatId:a,messageId:s.replyToMessageId,threadUpdate:{isDeleting:n,lastMessageId:s.id}})}return e}function ee(e,t,s){const{id:n,chatId:a}=s,{threadInfo:o,firstMessageId:c}=(0,i.Db)(e,a,s)||{},l=(0,i.Z1)(e,a),h=(null==l?void 0:l.unreadCount)&&!(0,i.gb)(e,a,u._f);if(e=J(e,t,s),o&&(!c&&(0,d.CI)(s)||(e=(0,r.xj)(e,a,o.threadId,[n]),(0,i.b9)(e,a,o.threadId)&&(e=(0,r.$S)(e,a,o.threadId,n),c||(e=(0,r.pf)(e,a,o.threadId,"firstMessageId",s.id)))),e=(0,r.pf)(e,a,o.threadId,"threadInfo",{...o,lastMessageId:s.id,messagesCount:o.messagesCount+1})),h)return e;if(e=(0,r.xj)(e,a,u._f,[n]),(0,i.b9)(e,a,u._f)){const t=(0,i.It)(e,a,u._f),s=(0,r.$S)(e,a,u._f,n),o=(0,i.Cb)(s,a,u._f);t&&!o.includes(t)||(e=s)}return e}function te(e,t,s,n=!1){var a;const{chats:o}=e,i=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!i||n||i.id===s.id||i.id===s.previousLocalId||s.id>i.id?(0,r.a4)(e,t,{lastMessage:s}):e}function se(e,t){const s=(0,i.Zw)(e,t),n=(0,i.gb)(e,t,u._f);if(!s||!n)return;let a=n.length;for(;a--;){const e=s[n[a]];if(!e.isDeleting)return e}}function ne(e,t,s,a){if(e){t.forEach((t=>{const s=se(a=(0,r.cY)(a,e,t,{isDeleting:!0}),e);s&&(a=te(a,e,s,!0))})),(0,n.R3)(a),s.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const n=(0,i.hj)(a,e,t);if(!n)return;a=J(a,s,n,!0);const{threadInfo:r}=(0,i.Db)(a,e,n)||{};r&&o.push(r.threadId)})),(0,n.R3)(a),void setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{s.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),Y)}const o=[];t.forEach((e=>{const t=(0,i.X5)(a,e);if(t){o.push(t);const s=se(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);s&&(a=te(a,t,s,!0)),setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),t,[e]))}),Y)}})),(0,n.R3)(a),(0,g.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:o,id:c,message:l}=s;e=ee(e=z(e,o,c,l),t,l),l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),(0,n.R3)(e);const u=(0,i.hj)(e,o,c);if((0,i.hg)(e,o,l)){var a;if(l.isOutgoing&&(null===(a=l.content)||void 0===a||!a.action)){const s=(0,i.Bt)(e);s&&t.focusMessage({chatId:o,threadId:s.threadId,messageId:l.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:s}=(0,i.Db)(e,o,l)||{};s&&t.requestThreadInfoUpdate({chatId:o,threadId:s.threadId}),(0,d.CI)(l)||setTimeout((()=>{(0,n.R3)(te((0,n.Rd)(),o,u))}),Y)}else(0,n.R3)(te((0,n.Rd)(),o,u));(0,i.N)(e,o)||t.loadTopChats();break}case"newScheduledMessage":{const{chatId:t,id:a,message:o}=s;e=z(e,t,a,o,!0);const c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,a])),(0,n.R3)(e);break}case"updateMessage":{var o,c;const{chatId:a,id:d,message:l}=s;if(!(0,i.hj)(e,a,d))return;e=z(e,a,d,l);const h=(0,i.hj)(e,a,d);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),e=te(e,a,h),(0,n.R3)(e);const m=(0,i.Z1)(e,a);m&&!l.isOutgoing&&(null===(o=m.lastMessage)||void 0===o?void 0:o.id)===l.id&&(0,i.xo)(e,m)&&(0,i.hg)(e,a,l)&&(0,i.b9)(e,a,(null===(c=l.threadInfo)||void 0===c?void 0:c.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:o}=s;if(!(0,i.Tm)(e,t,a))return;e=z(e,t,a,o,!0);const c=Object.keys((0,i.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,u._f,"scheduledIds",c),(0,n.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:o,message:c}=s;e=ee(e,t,c);const d=(0,i.hj)(e,a,o);e=(0,r.K4)(e,a,[o]),c.isScheduled&&(e=(0,r.bV)(e,a,[o])),e=(0,r.cY)(e,a,c.id,{...d,...c,previousLocalId:o});const l=(0,i.hj)(e,a,c.id);e=te(e,a,l);const u=(0,i.Db)(e,a,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,n.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:o}=s,c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const d=(0,i.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:a}),(0,n.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:o}=s,c=(0,i.KB)(e,t)||[],d=a?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,n.R3)((0,r.pf)(e,t,u._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:o,firstMessageId:c}=s,d={...(0,i.tZ)(e,t,a),...o};if(!d.threadId)return;e=(0,r.Xg)(e,t,a,d),c&&(e=(0,r.pf)(e,t,a,"firstMessageId",c)),(0,n.R3)(e);break}case"resetMessages":{const{id:a}=s,o=(0,i.Zw)(e,a);o&&!(0,d.YA)(a)&&(e=(0,r.K4)(e,a,Object.keys(o).map(Number)),(0,n.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:n,chatId:a}=s;ne(a,n,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:a}=s;!function(e,t,s,a){e&&(t.forEach((t=>{a=(0,r.P4)(a,e,t,{isDeleting:!0})})),(0,n.R3)(a),setTimeout((()=>{a=(0,r.bV)((0,n.Rd)(),e,t);const s=(0,i.Fn)(a,e);a=(0,r.pf)(a,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,n.R3)(a)}),Y))}(a,t,0,e);break}case"deleteHistory":{const{chatId:n}=s,a=e.messages.byChatId[n];a?ne(n,Object.keys(a.byId).map(Number),t,e):t.requestChatUpdate({chatId:n});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=s;t.forEach((t=>{const s=(0,i.X5)(e,t);s&&(e=(0,r.cY)(e,s,t,a))})),(0,n.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:o}=s;a.forEach((s=>{e=(0,r.cY)(e,t,s,o)})),(0,n.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=s,o=(0,i.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...a},{results:s}=t.results||{};if(s&&!s.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,n=e&&e.filter((e=>e.isChosen));n&&n.forEach((e=>{const n=s.findIndex((t=>t.option===e.option));n>=0&&(t.results.results[n].isChosen=!0)}))}(0,n.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:o}=s,c=(0,i.ZB)(e,t);if(!c||!c.content.poll||!c.content.poll.results)break;const{poll:d}=c.content,{recentVoterIds:l,totalVoters:u,results:h}=d.results,m=l?[...l]:[],g=u?u+1:1,f=h?[...h]:[];m.push(a),o.forEach((t=>{const s=f.find((e=>e.option===t)),n=f.findIndex((e=>e.option===t)),o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,a===e.currentUserId&&(o.isChosen=!0),n?f[n]=o:f.push(o)})),(0,n.R3)((0,r.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...d,results:{...d.results,recentVoterIds:m,totalVoters:g,results:f}}}}));break}}}));const ae=(0,Z.P2)((function(){let e=(0,n.Rd)();oe.forEach((([t,s])=>{e=(0,r.Nq)(e,t,{status:s})})),(0,n.R3)(e),oe=[]}),3e3,!0);let oe=[];(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteUser":return(0,r.h8)(e,s.id);case"updateUser":return(0,r.Nq)(e,s.id,s.user);case"updateUserStatus":return n=s.userId,a=s.status,oe.push([n,a]),void ae();case"updateUserFullInfo":{const{id:t,fullInfo:n}=s,a=e.users.byId[t];if(!a)return;return(0,r.Nq)(e,t,{fullInfo:{...a.fullInfo,...n}})}}var n,a})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateStickerSet":return(0,r.Rg)(e,s.id,s.stickerSet)}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,r.O4)((0,n.Rd)(),s.id):(0,r.rB)((0,n.Rd)(),s.id);case"updateResetContactList":(0,n.R3)({...(0,n.Rd)(),contactList:{hash:0,userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[s.key]=s.rules}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,r.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:a,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,n.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:o,shouldShowPreviews:i}));break}}})),(0,n.Q6)("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 re=s(8674),ie=s(6752),ce=s(1279),de=s(1212),le=s(5332);function ue(e){(0,o.d4)((()=>(0,Z.Gq)(e)),[e])}var he=s(9290);function me(e){e.preventDefault()}var ge=s(6590),fe=s(3989),pe=s(3455),Ie=s(2255);function ve(){const[e,t]=(0,o.eJ)(window.navigator.onLine);return(0,o.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}var ye=s(706),Ze=s(9107),Pe=s(6917),Ce=s(3106),we=s(8964),be=s(231),Me=s(9589),Se=s(9187),Ee=s(3321);const ke=[0,1,2],Re=(0,o.X$)((0,n.c$)((e=>{const{query:t,fetchingStatus:s,chatId:n,date:a}=e.globalSearch,{currentUserId:o}=e,{byId:r}=e.chats,{animationLevel:c}=e.settings.byKey;return{searchQuery:t,isLoading:!!s&&Boolean(s.chats||s.messages),currentUserId:o,chatsById:r,globalSearchChatId:n,searchDate:a,theme:(0,i.Pu)(e),animationLevel:c}}),((e,t)=>(0,g.ei)(t,["openChat","openTipsChat","setGlobalSearchDate","setGlobalSearchChatId","setSettingOption"])))((({content:e,contactsFilter:t,onSearchQuery:s,onSelectSettings:n,onSelectContacts:r,onSelectArchived:i,setGlobalSearchChatId:c,onReset:l,searchQuery:u,isLoading:g,shouldSkipTransition:f,currentUserId:p,globalSearchChatId:I,searchDate:v,theme:y,animationLevel:Z,chatsById:P,openChat:C,openTipsChat:w,setGlobalSearchDate:b,setSettingOption:M})=>{const S=(0,Ze.Z)(),E=e===h.du.ChatList,k=(0,o.Ye)((()=>v?(0,L.xH)(new Date(1e3*v)):void 0),[v]),R=(0,o.Ye)((()=>E&&P?Object.values(P).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[E,P]),T="web.telegram.org"===window.location.hostname,N=(0,o.Ye)((()=>({onTrigger:e,isOpen:t})=>o.ZP.createElement(be.Z,{round:!0,ripple:E&&!m.wB,size:"smaller",color:"translucent",className:t?"active":"",onClick:E?e:()=>l(),ariaLabel:E?S("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,ie.Z)("animated-menu-icon",!E&&"state-back",f&&"no-animation")}))),[E,S,l,f]),B=(0,o.I4)((()=>{u||s("")}),[u,s]),x=(0,o.I4)((()=>{C({id:p,shouldReplaceHistory:!0})}),[p,C]),A=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";M({theme:t}),M({shouldUseSystemTheme:!1}),(0,Pe.Z)(t,Z===a.zy)}),[Z,M,y]),O=(0,o.I4)((e=>{e.stopPropagation();const t=0===Z?2:0;ke.forEach(((e,s)=>{document.body.classList.toggle(`animation-level-${s}`,t===s)})),M({animationLevel:t})}),[Z,M]),F=Boolean(I)||e===h.du.GlobalSearch||e===h.du.Contacts,U=e===h.du.Contacts?S("SearchFriends"):S("Search");return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(Ce.Z,{trigger:N,footer:`${a.iC} alpha ${a.Ji}`},o.ZP.createElement(we.Z,{icon:"saved-messages",onClick:x},S("SavedMessages")),o.ZP.createElement(we.Z,{icon:"archive",onClick:i},o.ZP.createElement("span",{className:"menu-item-name"},S("ArchivedChats")),R>0&&o.ZP.createElement("div",{className:"archived-badge"},R)),o.ZP.createElement(we.Z,{icon:"user",onClick:r},S("Contacts")),o.ZP.createElement(we.Z,{icon:"settings",onClick:n},S("Settings")),o.ZP.createElement(we.Z,{icon:"darkmode",onClick:A},o.ZP.createElement("span",{className:"menu-item-name"},S("lng_menu_night_mode")),o.ZP.createElement(Ee.Z,{id:"darkmode",label:S("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),o.ZP.createElement(we.Z,{icon:"animations",onClick:O},o.ZP.createElement("span",{className:"menu-item-name capitalize"},S("Appearance.Animations").toLowerCase()),o.ZP.createElement(Ee.Z,{id:"animations",label:"Toggle Animations",checked:Z>0})),o.ZP.createElement(we.Z,{icon:"help",onClick:()=>{w({langCode:S.code})}},S("TelegramFeatures")),o.ZP.createElement(we.Z,{icon:"bug",href:a.mU},"Report Bug"),T&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(we.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,ge.Wv)()}},"Switch to K Version"),o.ZP.createElement(we.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:ge.Wv},"Switch to Old Version"))),o.ZP.createElement(Me.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||v?"with-picker-item":"",value:t||u,focused:F,isLoading:g,placeholder:U,autoComplete:"off",canClose:Boolean(I||v),onChange:s,onReset:l,onFocus:B},k&&o.ZP.createElement(Se.Z,{icon:"calendar",title:k,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:b,clickArg:{date:void 0}}),I&&o.ZP.createElement(Se.Z,{chatOrUserId:I,onClick:c,canClose:!0,clickArg:{id:void 0}}))))})));var Te=s(9204);const Ne=(0,o.X$)((()=>{const e=(0,Ze.Z)();return o.ZP.createElement("div",{id:"ConnectionState",dir:e.isRtl?"rtl":void 0},o.ZP.createElement(Te.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},e("WaitingForNetwork")))}));var Be=s(1174);var xe=s(3133),Ae=s(9359);const Le=(0,o.X$)((0,n.c$)((e=>{const{chats:{byId:t},users:{byId:s},chatFolders:{byId:n,orderedIds:a,activeChatFolder:o},currentUserId:r,lastSyncTime:c,shouldSkipHistoryAnimations:d}=e;return{chatsById:t,usersById:s,chatFoldersById:n,orderedFolderIds:a,lastSyncTime:c,notifySettings:(0,i.dZ)(e),notifyExceptions:(0,i.NJ)(e),activeChatFolder:o,currentUserId:r,shouldSkipHistoryAnimations:d}}),((e,t)=>(0,g.ei)(t,["loadChatFolders","setActiveChatFolder","openChat"])))((({chatsById:e,usersById:t,chatFoldersById:s,notifySettings:n,notifyExceptions:a,orderedFolderIds:r,activeChatFolder:i,currentUserId:c,lastSyncTime:l,shouldSkipHistoryAnimations:u,foldersDispatch:h,onScreenSelect:f,loadChatFolders:p,setActiveChatFolder:I,openChat:v})=>{const y=(0,o.sO)(null),P=(0,Ze.Z)();(0,o.d4)((()=>{l&&p()}),[l,p]);const C=(0,o.Ye)((()=>r?r.map((e=>s[e]||{})).filter(Boolean):void 0),[s,r]),w=((e,t,s)=>{const n=((e,t=!1)=>(0,o.Ye)((()=>(0,Z.P2)((e=>e()),e,!t)),[e,t]))(t,!0),[a,r]=(0,o.eJ)(),[i,c,d]=(0,ye.Z)();return(0,re.ZP)(c,d),(0,he.Z)((()=>{i||n((()=>{r(e())}))}),s.concat([i])),a})((()=>{if(!C||!C.length)return;const s=Object.keys(e).map(Number),o=C.map((o=>{const{unreadDialogsCount:r,hasActiveDialogs:i}=(0,d.Fu)(e,t,o,s,n,a)||{};return{id:o.id,badgeCount:r,isBadgeActive:i}}));return(0,g.ee)(o,"id")}),3e3,[C,e,t,n,a]),b=(0,o.Ye)((()=>{if(C&&C.length)return[{title:"en"===P.code?"All":P("FilterAllChats")},...C.map((e=>({title:e.title,...null==w?void 0:w[e.id]})))]}),[C,w,P]),M=(0,o.I4)((e=>{I(e)}),[I]);(0,o.d4)((()=>{b&&b.length&&i>=b.length&&I(0)}),[i,b,I]),(0,o.d4)((()=>{if(y.current&&m.$b&&b&&b.length)return(0,Be.s)(y.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Be.e.Left?(I(Math.min(i+1,b.length-1)),!0):t===Be.e.Right&&(I(Math.max(0,i-1)),!0)})}),[i,b,I]);const S=(0,o.sO)();S.current=0!==i,(0,o.d4)((()=>S.current?(0,fe.Z)((()=>{S.current&&I(0)})):void 0),[i,I]),(0,ge.ZP)(0!==i,(()=>I(0))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&b){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void v({id:c,shouldReplaceHistory:!0});const s=Number(t)-1;if(s>b.length-1)return;I(s),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:E,transitionClassNames:k}=(0,de.Z)(!r,void 0,!0);function R(e){const t=Object.values(s).find((({title:e})=>e===b[i].title));return t&&0!==i?o.ZP.createElement(Ae.Z,{folderType:"folder",folderId:t.id,isActive:e,onScreenSelect:f,foldersDispatch:h}):o.ZP.createElement(Ae.Z,{folderType:"all",isActive:e,foldersDispatch:h,onScreenSelect:f})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=b&&b.length?o.ZP.createElement(xe.Z,{tabs:b,activeTab:i,onSwitchTab:M}):E?o.ZP.createElement("div",{className:(0,ie.Z)("tabs-placeholder",k)}):void 0,o.ZP.createElement(Ie.Z,{ref:y,name:u?"none":P.isRtl?"slide-reversed":"slide",activeKey:i,renderCount:b?b.length:void 0},R))})));var Oe=s(9203),Fe=s(8778),Ue=s(4288);const $e=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)})),Qe=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)}));var De=s(2328);let qe;const Ge=(0,o.X$)((({isShown:e,onNewPrivateChat:t,onNewChannel:s,onNewGroup:n})=>{const[a,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{e||r(!1)}),[e]);const i=(0,Ze.Z)(),c=(0,ie.Z)("NewChatButton",e&&"revealed",a&&"menu-is-open"),d=(0,o.I4)((()=>{qe&&(clearTimeout(qe),qe=void 0)}),[]),l=(0,o.I4)((()=>{qe&&(clearTimeout(qe),qe=void 0),qe=window.setTimeout((()=>{r(!1)}),750)}),[]);return o.ZP.createElement("div",{className:c,onMouseEnter:d,onMouseLeave:l},o.ZP.createElement(be.Z,{round:!0,color:"primary",className:a?"active":"",onClick:()=>{r(!a)},ariaLabel:i(a?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(De.Z,{isOpen:a,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(we.Z,{icon:"channel",onClick:s},i("NewChannel")),o.ZP.createElement(we.Z,{icon:"group",onClick:n},i("NewGroup")),o.ZP.createElement(we.Z,{icon:"user",onClick:t},i("NewMessageTitle"))))}));var He=s(126);const je=Object.keys(h.du).length/2;let _e;const Ve=(0,n.c$)((e=>(0,g.ei)(e,["connectionState"])))((({content:e,searchQuery:t,searchDate:s,contactsFilter:n,shouldSkipTransition:a,foldersDispatch:r,onSearchQuery:i,onContentChange:c,onScreenSelect:d,onReset:l,connectionState:u})=>{const[g,f]=(0,o.eJ)(m.$b),p=!ve()||"connectionStateConnecting"===u,I=(0,o.sO)(!1),v=(0,o.I4)((()=>{c(h.du.Settings)}),[c]),y=(0,o.I4)((()=>{c(h.du.Contacts)}),[c]),Z=(0,o.I4)((()=>{c(h.du.NewChannelStep1)}),[c]),P=(0,o.I4)((()=>{c(h.du.NewGroupStep1)}),[c]),C=(0,o.I4)((()=>{c(h.du.Archived)}),[c]),w=(0,o.I4)((()=>{e===h.du.ChatList&&(I.current=!0,f(!0))}),[e]),b=(0,o.I4)((()=>{I.current=!1,_e&&(clearTimeout(_e),_e=void 0),_e=window.setTimeout((()=>{I.current||f(!1)}),250)}),[]);(0,o.d4)((()=>{let t;return e!==h.du.ChatList?t=window.setTimeout((()=>{f(!1)}),250):(I.current||m.$b)&&f(!0),()=>{t&&(clearTimeout(t),t=void 0)}}),[e]);const[M,S,E]=function(){const[e,t]=(0,ye.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:s,transitionClassNames:n}=(0,de.Z)(e);return[s,n,()=>{window.location.reload()}]}(),k=(0,Ze.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:m.$b?void 0:w,onMouseLeave:m.$b?void 0:b},o.ZP.createElement(Re,{content:e,contactsFilter:n,onSearchQuery:i,onSelectSettings:v,onSelectContacts:y,onSelectArchived:C,onReset:l,shouldSkipTransition:a}),o.ZP.createElement(He.Z,{isOpen:p,isCustom:!0,className:"connection-state-wrapper opacity-transition slow"},(()=>o.ZP.createElement(Ne,null))),o.ZP.createElement(Ie.Z,{name:a?"none":"zoom-fade",renderCount:je,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:h.du.ChatList,className:p?"pull-down":void 0},(a=>{switch(e){case h.du.ChatList:return o.ZP.createElement(Le,{onScreenSelect:d,foldersDispatch:r});case h.du.GlobalSearch:return o.ZP.createElement($e,{searchQuery:t,searchDate:s,isActive:a,onReset:l});case h.du.Contacts:return o.ZP.createElement(Qe,{filter:n,isActive:a,onReset:l});default:return}})),M&&o.ZP.createElement(be.Z,{fluid:!0,pill:!0,className:(0,ie.Z)("btn-update",S),onClick:E},k("lng_update_telegram")),o.ZP.createElement(Ge,{isShown:g,onNewPrivateChat:y,onNewChannel:Z,onNewGroup:P}))})),We=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)})),Ke=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)})),Xe=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)}));var Ye;!function(e){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"}(Ye||(Ye={}));const ze=Object.keys(Ye).length/2,Je=(0,o.X$)((0,n.c$)((e=>{const{globalSearch:{query:t,date:s},chatFolders:{activeChatFolder:n},shouldSkipHistoryAnimations:a}=e;return{searchQuery:t,searchDate:s,activeChatFolder:n,shouldSkipHistoryAnimations:a}}),((e,t)=>(0,g.ei)(t,["setGlobalSearchQuery","setGlobalSearchChatId","resetChatCreation","setGlobalSearchDate","loadPasswordInfo","clearTwoFaError"])))((({searchQuery:e,searchDate:t,activeChatFolder:s,shouldSkipHistoryAnimations:n,setGlobalSearchQuery:a,setGlobalSearchChatId:r,resetChatCreation:i,setGlobalSearchDate:c,loadPasswordInfo:d,clearTwoFaError:l})=>{const[u,g]=(0,o.eJ)(h.du.ChatList),[f,p]=(0,o.eJ)(h.MT.Main),[I,v]=(0,o.eJ)(""),[y,Z]=(0,pe.ZP)(),[P,C]=(0,o.eJ)(0);let w=Ye.Main;switch(u){case h.du.Archived:w=Ye.Archived;break;case h.du.Settings:w=Ye.Settings;break;case h.du.NewChannelStep1:case h.du.NewChannelStep2:w=Ye.NewChannel;break;case h.du.NewGroupStep1:case h.du.NewGroupStep2:w=Ye.NewGroup}const b=(0,o.I4)((e=>{if(u!==h.du.NewGroupStep2||e)if(u!==h.du.NewChannelStep2||e){if(u===h.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(u===h.du.Settings)switch(f){case h.MT.EditProfile:case h.MT.Folders:case h.MT.General:case h.MT.Notifications:case h.MT.Privacy:case h.MT.Language:return void p(h.MT.Main);case h.MT.GeneralChatBackground:return void p(h.MT.General);case h.MT.GeneralChatBackgroundColor:return void p(h.MT.GeneralChatBackground);case h.MT.PrivacyPhoneNumber:case h.MT.PrivacyLastSeen:case h.MT.PrivacyProfilePhoto:case h.MT.PrivacyForwarding:case h.MT.PrivacyGroupChats:case h.MT.PrivacyActiveSessions:case h.MT.PrivacyBlockedUsers:case h.MT.TwoFaDisabled:case h.MT.TwoFaEnabled:case h.MT.TwoFaCongratulations:return void p(h.MT.Privacy);case h.MT.PrivacyPhoneNumberAllowedContacts:case h.MT.PrivacyPhoneNumberDeniedContacts:return void p(h.MT.PrivacyPhoneNumber);case h.MT.PrivacyLastSeenAllowedContacts:case h.MT.PrivacyLastSeenDeniedContacts:return void p(h.MT.PrivacyLastSeen);case h.MT.PrivacyProfilePhotoAllowedContacts:case h.MT.PrivacyProfilePhotoDeniedContacts:return void p(h.MT.PrivacyProfilePhoto);case h.MT.PrivacyForwardingAllowedContacts:case h.MT.PrivacyForwardingDeniedContacts:return void p(h.MT.PrivacyForwarding);case h.MT.PrivacyGroupChatsAllowedContacts:case h.MT.PrivacyGroupChatsDeniedContacts:return void p(h.MT.PrivacyGroupChats);case h.MT.TwoFaNewPassword:return void p(h.MT.TwoFaDisabled);case h.MT.TwoFaNewPasswordConfirm:return void p(h.MT.TwoFaNewPassword);case h.MT.TwoFaNewPasswordHint:return void p(h.MT.TwoFaNewPasswordConfirm);case h.MT.TwoFaNewPasswordEmail:return void p(h.MT.TwoFaNewPasswordHint);case h.MT.TwoFaNewPasswordEmailCode:return void p(h.MT.TwoFaNewPasswordEmail);case h.MT.TwoFaChangePasswordCurrent:case h.MT.TwoFaTurnOff:case h.MT.TwoFaRecoveryEmailCurrentPassword:return void p(h.MT.TwoFaEnabled);case h.MT.TwoFaChangePasswordNew:return void p(h.MT.TwoFaChangePasswordCurrent);case h.MT.TwoFaChangePasswordConfirm:return void p(h.MT.TwoFaChangePasswordNew);case h.MT.TwoFaChangePasswordHint:return void p(h.MT.TwoFaChangePasswordConfirm);case h.MT.TwoFaRecoveryEmail:return void p(h.MT.TwoFaRecoveryEmailCurrentPassword);case h.MT.TwoFaRecoveryEmailCode:return void p(h.MT.TwoFaRecoveryEmail);case h.MT.FoldersCreateFolder:case h.MT.FoldersEditFolder:return void p(h.MT.Folders);case h.MT.FoldersIncludedChatsFromChatList:case h.MT.FoldersExcludedChatsFromChatList:return void p(h.MT.FoldersEditFolderFromChatList);case h.MT.FoldersEditFolderFromChatList:return g(h.du.ChatList),void p(h.MT.Main)}u!==h.du.ChatList||0!==s?(g(h.du.ChatList),v(""),a({query:""}),c({date:void 0}),r({id:void 0}),i(),setTimeout((()=>{C(Date.now())}),250)):g(h.du.GlobalSearch)}else g(h.du.NewChannelStep1);else g(h.du.NewGroupStep1)}),[u,s,f,a,c,r,i]),M=(0,o.I4)((t=>{u!==h.du.Contacts?(g(h.du.GlobalSearch),t!==e&&a({query:t})):v(t)}),[u,e,a]);(0,o.d4)((()=>u!==h.du.ChatList||0===s?(0,fe.Z)((()=>b())):void 0),[s,u,b]),(0,o.d4)((()=>{l(),f===h.MT.Privacy&&d()}),[l,d,f]);const S=e=>{g(h.du.Settings),p(e)};return o.ZP.createElement(Ie.Z,{id:"LeftColumn",name:n?"none":m.s0,renderCount:ze,activeKey:w,shouldCleanup:!0,cleanupExceptionKey:Ye.Main},(s=>{switch(w){case Ye.Archived:return o.ZP.createElement(Xe,{isActive:s,onReset:b,onContentChange:g});case Ye.Settings:return o.ZP.createElement(We,{isActive:s,currentScreen:f,foldersState:y,foldersDispatch:Z,onScreenSelect:S,onReset:b,shouldSkipTransition:n});case Ye.NewChannel:return o.ZP.createElement(Ke,{key:P,isActive:s,isChannel:!0,content:u,onContentChange:g,onReset:b});case Ye.NewGroup:return o.ZP.createElement(Ke,{key:P,isActive:s,content:u,onContentChange:g,onReset:b});default:return o.ZP.createElement(Ve,{content:u,searchQuery:e,searchDate:t,contactsFilter:I,foldersDispatch:Z,onContentChange:g,onSearchQuery:M,onScreenSelect:S,onReset:b,shouldSkipTransition:n})}}))})));var et=s(2420),tt=s(9524),st=s(1394),nt=s(3858);const at=()=>{const[e,t]=(0,o.eJ)(nt.Z.get());return(0,o.d4)((()=>{const e=(0,Z.P2)((()=>{t(nt.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var ot=s(2678);const rt=728;const it=e=>e.chatId.toString()+("thread"!==e.type?`_${e.type}`:-1!==e.threadId?`_${e.threadId}`:"");var ct=s(3570),dt=s(5790),lt=s(8360),ut=s(2155),ht=s(6058),mt=s(8799);const gt=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"HeaderMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),ft=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{const a=(0,i.Z1)(e,t),o=Boolean(a&&(0,d.eA)(a));if(null!=a&&a.isRestricted||(0,i.CA)(e))return{noMenu:!0};const r=(0,i.IK)(e,t),c=(0,i.FM)(e,t),l="thread"===n&&s===u._f,h="thread"===n&&s!==u._f,g=(0,i.Jf)(e),f=Boolean(r&&(0,i.s4)(e,r.id)),p=!f&&Boolean((0,i.pk)(e,t)),I=Boolean(l&&a&&(o||(0,d.ZV)(a))&&a.isNotJoined),v=l||h,y=l&&!c&&!I,Z=l&&!I;return{noMenu:!(m.wB&&I||m.wB&&v||y||Z),isChannel:o,isRightColumnShown:g,canStartBot:p,canRestartBot:f,canSubscribe:I,canSearch:v,canMute:y,canLeave:Z}}),((e,t)=>(0,g.ei)(t,["joinChannel","sendBotCommand","openLocalTextSearch","restartBot"])))((({chatId:e,threadId:t,noMenu:s,isChannel:n,canStartBot:a,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canLeave:l,isRightColumnShown:u,joinChannel:h,sendBotCommand:g,openLocalTextSearch:f,restartBot:p})=>{const I=(0,o.sO)(null),[v,y]=(0,o.eJ)(!1),[Z,P]=(0,o.eJ)(void 0),C=(0,o.I4)((()=>{y(!0);const e=I.current.getBoundingClientRect();P({x:e.right,y:e.bottom})}),[]),w=(0,o.I4)((()=>{y(!1)}),[]),b=(0,o.I4)((()=>{P(void 0)}),[]),M=(0,o.I4)((()=>{h({chatId:e})}),[h,e]),S=(0,o.I4)((()=>{g({command:"/start"})}),[g]),E=(0,o.I4)((()=>{p({chatId:e})}),[e,p]),k=(0,o.I4)((()=>{f(),m.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[f]),R=(0,Ze.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!m.wB&&i&&o.ZP.createElement(be.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:M},R(n?"Subscribe":"Join Group")),!m.wB&&a&&o.ZP.createElement(be.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:S},R("BotStart")),!m.wB&&r&&o.ZP.createElement(be.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:E},R("BotRestart")),!m.wB&&c&&o.ZP.createElement(be.Z,{round:!0,ripple:u,color:"translucent",size:"smaller",onClick:k,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),(m.wB||!i)&&o.ZP.createElement(be.Z,{ref:I,className:v?"active":"",round:!0,ripple:!m.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:C},o.ZP.createElement("i",{className:"icon-more"})),Z&&o.ZP.createElement(gt,{chatId:e,threadId:t,isOpen:v,anchor:Z,isChannel:n,canStartBot:a,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canLeave:l,onSubscribeChannel:M,onSearchClick:k,onClose:w,onCloseAnimationEnd:b}))})));var pt=s(4399),It=s(2340),vt=s(6202),yt=s(862);function Zt(e){var t;const s=e&&(0,d.DH)(e),n=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,r=s&&n&&!(0,m.on)()&&s.includes("image/webp"),[i,c]=(0,o.eJ)(yt.Hu),l=null==e?void 0:e.id;return(0,o.bt)((()=>{r&&(0,yt.p6)(`b64-${l}`,s).then(c).catch((e=>{a.eM&&console.error(e)}))}),[l,r,s]),r?i:s}var Pt=s(7551),Ct=s(8512);function wt(e,t,s,n,a){return`M${e},${t+a}a${a},${a},0,0,1,\n ${s},0v${n-2*a}a${a},${a},0,0,1,${-s},0Z`}const bt=(0,o.X$)((({count:e,index:t})=>{const s=(0,o.sO)(null),n=(0,o.Ye)((()=>function(e,t){const s=e-t-1,n=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),a=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,n),r=`clipPath${e}`;return{markHeight:a,clipPath:function(e,t,s){let n="";if(3===s)n=wt(0,0,2,t,1)+wt(0,12,2,t+1,1)+wt(0,25,2,t,1);else for(let e=0;e<s;e++)n+=wt(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${n}" />\n </clipPath>`}(r,n,e),markTranslateY:function(e,t,s){return 1===s?0:2===s?0===e?0:t+2:3===s?0===e?0:1===e?12:25:(t+2)*e}(s,n,e),trackTranslateY:function(e,t,s,n){return t<=4||e<=1?0:e>=t-2?n-36:(s+4)/2+(e-2)*(s+2)}(s,e,n,o),trackHeight:o,clipPathId:r}}(e,t)),[e,t]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:a,markTranslateY:o,clipPathId:r,clipPath:i}=n,c=s.current.firstElementChild;if(null!=s&&s.current){const n=s.current,{style:d}=n;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${r}")`;const l=n.querySelector("svg"),u=n.querySelector("div"),h=n.querySelector("defs");l||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${i} </defs></svg>`),h&&(h.innerHTML=i),u&&(u.style.height=`${a}px`,u.style.transform=`translateY(${o}px)`)}}),[n]),1===e)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:a,trackTranslateY:r,markHeight:i,markTranslateY:c,clipPathId:d}=n;return o.ZP.createElement("div",{className:(0,ie.Z)("pinned-message-border",e>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${d}"); width: 2px;\n height: ${a}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${i}px; transform: translateY(${c}px);`})))})),Mt=(0,o.X$)((({message:e,count:t,index:s,customTitle:n,className:a,onUnpinMessage:r,onClick:i,onAllPinnedClick:c})=>{const l=(0,Ze.Z)(),u=Zt(e),h=(0,vt.Z)((0,d.Ti)(e,"pictogram")),m=(0,d.MK)(l,e,Boolean(u)),[g,f,p]=(0,ye.Z)(),I=(0,o.I4)((()=>{p(),r&&r(e.id)}),[p,r,e.id]);return o.ZP.createElement("div",{className:(0,ie.Z)("HeaderPinnedMessage-wrapper",a)},t>1&&o.ZP.createElement(be.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:l("EventLogFilterPinnedMessages"),onClick:c},o.ZP.createElement("i",{className:"icon-pin-list"})),r&&o.ZP.createElement(be.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:l("UnpinMessageAlertTitle"),className:"unpin-button",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Pt.Z,{isOpen:g,onClose:p,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:I}),o.ZP.createElement("div",{className:"HeaderPinnedMessage",onClick:i,dir:l.isRtl?"rtl":void 0},o.ZP.createElement(bt,{count:t,index:s}),u&&function(e,t){const{width:s,height:n}=(0,pt.W7)();return o.ZP.createElement("img",{src:t||e,width:s,height:n,alt:""})}(u,h),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},n||`${l("PinnedMessage")} ${s>0?"#"+(t-s):""}`),o.ZP.createElement("p",{dir:"auto"},(0,It.Z)(m))),o.ZP.createElement(Ct.Z,null)))}));var St=s(647),Et=s(3186);const kt=(0,n.c$)(((e,{message:t})=>({sender:(0,i.Ur)(e,t)})),((e,t)=>(0,g.ei)(t,["focusMessage","closeAudioPlayer"])))((({message:e,className:t,noUi:s,sender:n,focusMessage:a,closeAudioPlayer:r})=>{const i=(0,Ze.Z)(),c=n?(0,d.OU)(i,n):void 0,l=St.UV((0,d.Ti)(e,"inline")),{playPause:u,isPlaying:h}=(0,Et.Z)((0,d.Tp)(e),(0,d.XV)(e),l,void 0,void 0,!0),g=(0,o.I4)((()=>{a({chatId:e.chatId,messageId:e.id})}),[a,e.chatId,e.id]),f=(0,o.I4)((()=>{h&&u(),r()}),[r,h,u]);if(s)return;const p=(0,d.oP)(e);return o.ZP.createElement("div",{className:(0,ie.Z)("AudioPlayer",t),dir:i.isRtl?"rtl":void 0},o.ZP.createElement(be.Z,{round:!0,ripple:!m.wB,color:"translucent",size:"smaller",className:(0,ie.Z)("toggle-play",h?"pause":"play"),onClick:u,ariaLabel:h?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:g},p?function(e){const{title:t,performer:s,fileName:n}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,It.Z)(t||n)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,It.Z)(s)))}(p):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,It.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(i("AttachAudio"),c),o.ZP.createElement(Ct.Z,null)),o.ZP.createElement(be.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:f,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))})),Rt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{const{isLeftColumnShown:a,lastSyncTime:o,shouldSkipHistoryAnimations:r}=e,{byId:c}=e.chats,d=(0,i.Z1)(e,t),{typingStatus:l}=d||{},{chatId:h,messageId:m}=e.audioPlayer,g=h&&m?(0,i.hj)(e,h,m):void 0;let f;if("pinned"===n){const s=(0,i.KB)(e,t);f=null==s?void 0:s.length}else if("scheduled"===n){const s=(0,i.qy)(e,t);f=null==s?void 0:s.length}else if("thread"===n&&s!==u._f){const n=(0,i.tZ)(e,t,s);n&&(f=n.messagesCount)}const p={typingStatus:l,isLeftColumnShown:a,isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),audioMessage:g,chat:d,chatsById:c,messagesCount:f,isChatWithSelf:(0,i.FM)(e,t),isChatWithBot:d&&(0,i.xo)(e,d),lastSyncTime:o,shouldSkipHistoryAnimations:r,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState},I=(0,i.Zw)(e,t);if("thread"!==n||!I)return p;if(Object.assign(p,{messagesById:I}),s!==u._f){const n=(0,i.qS)(e,t,s),a=n?(0,i.hj)(e,t,n):void 0,o=a?(0,i.cv)(e,a):void 0;return{...p,pinnedMessageIds:n,canUnpin:!1,topMessageSender:o}}const v=(0,i.KB)(e,t);if(null!=v&&v.length){const t=I[v[0]],{canUnpin:n}=t&&(0,i._k)(e,t,s)||{};return{...p,pinnedMessageIds:v,canUnpin:n}}return p}),((e,t)=>(0,g.ei)(t,["openChatWithInfo","pinMessage","focusMessage","openChat","openPreviousChat","loadPinnedMessages","toggleLeftColumn","exitMessageSelectMode"])))((({chatId:e,threadId:t,messageListType:s,isReady:r,pinnedMessageIds:c,messagesById:l,canUnpin:h,topMessageSender:g,typingStatus:f,isSelectModeActive:p,isLeftColumnShown:I,isRightColumnShown:v,audioMessage:y,chat:Z,chatsById:P,messagesCount:C,isChatWithSelf:w,isChatWithBot:b,lastSyncTime:M,shouldSkipHistoryAnimations:S,currentTransitionKey:E,connectionState:k,openChatWithInfo:R,pinMessage:T,focusMessage:N,openChat:B,openPreviousChat:x,loadPinnedMessages:A,toggleLeftColumn:L,exitMessageSelectMode:O})=>{const F=(0,Ze.Z)(),[U,$]=(0,o.eJ)(0),Q=Array.isArray(c)?c[U]:c,D=l&&Q?l[Q]:void 0,q=Array.isArray(c)?c.length:c?1:0,G=Z&&(0,d.U)(F,Z).length,H=g?(0,d.OU)(F,g):void 0;(0,o.d4)((()=>{t===u._f&&M&&r&&A({chatId:e})}),[e,A,M,t,r]),(0,o.d4)((()=>{$(0)}),[c]),(0,dt.Z)(e,Q,D);const{width:j}=at(),_=j<=a.ks,V=m.p7&&I,W=(0,o.sO)(null),K=(0,o.sO)(!0),X=(0,o.I4)((()=>{R({id:e})}),[R,e]),Y=(0,o.I4)((t=>{T({chatId:e,messageId:t,isUnpin:!0})}),[T,e]),z=(0,o.I4)((()=>{if(D){N({chatId:D.chatId,threadId:t,messageId:D.id});const e=(0,ct.Z)(q,U+1);$(e)}}),[D,N,t,q,U]),J=(0,o.I4)((()=>{B({id:e,threadId:u._f,type:"pinned"})}),[B,e]),ee=(0,o.I4)((e=>{if(m.wB){const e=document.getElementById(a.R2);e&&e.blur()}p?O():t!==u._f||"thread"!==s||0!==E?x():m.wB||V?(e.stopPropagation(),B({id:void 0})):L()}),[t,s,E,p,x,V,B,L,O]),te=(0,o.Ye)((()=>{if(_&&P)return(0,i.A1)((0,n.Rd)())||void 0}),[_,P]),se=j>=a.ks&&j<a.jT||j>a.l3&&j<a.ks&&(!G||G>30),ne=se||j>a._m&&j<a.QU,{shouldRender:ae,transitionClassNames:oe}=(0,de.Z)(Boolean(y)),re=(0,lt.Z)(y),{shouldRender:ce,transitionClassNames:le}=(0,de.Z)(D&&!ae),ue=(0,lt.Z)(D),he=(0,lt.Z)(H),me=ce&&ue||ae&&re;(0,o.d4)((()=>{const e=W.current;if(e)return ne&&me?void(v||se?(K.current&&(e.classList.add("tools-stacked","animated"),K.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),K.current=!0)):(e.classList.remove("tools-stacked","animated"),void(K.current=!0))}),[ne,me,se,v]);const ge=(!ve()||"connectionStateConnecting"===k)&&(m.wB||m.p7&&!V);function fe(){return ge?o.ZP.createElement(o.ZP.Fragment,null,pe(),o.ZP.createElement("h3",null,F("WaitingForNetwork"))):"thread"===s&&t===u._f?o.ZP.createElement(o.ZP.Fragment,null,(_||E>0)&&pe(V,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:X},(0,d.YA)(e)?o.ZP.createElement(ht.Z,{userId:e,typingStatus:f,withFullInfo:b,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(mt.Z,{chatId:e,typingStatus:f,noRtl:!0,withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0}))):"thread"===s?o.ZP.createElement(o.ZP.Fragment,null,pe(),o.ZP.createElement("h3",null,F("CommentsCount",C))):"pinned"===s?o.ZP.createElement(o.ZP.Fragment,null,pe(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",C))):"scheduled"===s?o.ZP.createElement(o.ZP.Fragment,null,pe(),o.ZP.createElement("h3",null,w?F("Reminders"):F("messages",C,"i"))):void 0}function pe(e=!1,t=!1){return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(be.Z,{round:!0,size:"smaller",color:"translucent",onClick:ee,ariaLabel:e?"Close":"Back"},o.ZP.createElement("div",{className:(0,ie.Z)("animated-close-icon",!e&&"state-back")})),t&&te&&o.ZP.createElement("div",{className:"unread-count active"},(0,ut.bi)(te)))}return o.ZP.createElement("div",{className:"MiddleHeader",ref:W},o.ZP.createElement(Ie.Z,{name:S?"none":"slide-fade",activeKey:ge?1/0:E},fe),o.ZP.createElement("div",{className:"header-tools"},ce&&ue&&!ae&&o.ZP.createElement(Mt,{key:e,message:ue,count:q,index:U,customTitle:he,className:le,onUnpinMessage:h?Y:void 0,onClick:z,onAllPinnedClick:J}),ae&&re&&o.ZP.createElement(kt,{key:(0,d.Tp)(re),message:re,className:oe}),o.ZP.createElement(ft,{chatId:e,threadId:t,messageListType:s})))})));var Tt=s(2645),Nt=s(274);function Bt(e){return"albumId"in e}function xt(e,t){let s,n=[],a={originalDate:e[0].date,datetime:Number((0,L.$Y)(1e3*e[0].date)),senderGroups:[n]};const o=[a];return e.forEach(((r,i)=>{r.isInAlbum?s?(s.messages.push(r),r.content.text&&(s.mainMessage=r)):s={albumId:r.groupedId,messages:[r],mainMessage:r}:n.push(r);const c=e[i+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(n.push(s),s=void 0),c){const e=Number((0,L.$Y)(1e3*c.date));a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},o.push(a),n=[],a.senderGroups.push(n)):(c.id===t||r.senderId!==c.senderId||r.isOutgoing!==c.isOutgoing||(0,d.Lo)(r)||(0,d.Lo)(c)||r.forwardInfo&&c.forwardInfo&&(r.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||r.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||r.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||r.inlineButtons||c.inlineButtons||c.date-r.date>600)&&(n=[],a.senderGroups.push(n))}})),o}var At=s(386);var Lt=s(7675),Ot=s(539),Ft=s(3657);const Ut=m.wZ?1e3:350,$t=m.wB?300:500;var Qt=s(7240),Dt=s(935);function qt(e){return"number"==typeof e}function Gt(e,t){return e?t?238:175:t?238:100}function Ht(e,t){const s=(0,d.B4)(e),n=(0,d.MF)(e),a=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),r=Boolean((0,d.F$)(e)),{width:i,height:c}=a?(0,pt.Eh)(a,s,n,r,t):(0,pt.GC)(o,s,n,t),l=Gt(Boolean((0,d.UD)(e)));let u=1;i<l&&l-i<12&&(u=l/i),c*u<90&&90-c*u<12&&(u=90/c);const h=Math.round(i*u),m=Math.round(c*u);return{width:h,height:m,isSmall:h<l||m<90}}function jt(e,t){return e.reduce(((e,t)=>e+t),t)}function _t(e,t,s){return e<t?t:e>s?s:e}function Vt(e){const t={width:0,height:0};return e.forEach((({dimensions:e,sides:s})=>{2&s&&(t.width=e.width+e.x),4&s&&(t.height=e.height+e.y)})),t}function Wt(e,t,s,n){const a=n.messages.map((e=>{const t=Ht(e);return t.width/t.height})),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),i=a.length,c=a.some((e=>e>2)),d=(0,pt.kc)(e,t,!1,s)-(t?2.5:0)*pt.Gw;let l;const u={ratios:a,proportions:o,averageRatio:r,maxWidth:d,minWidth:100,maxHeight:d,spacing:2};return l=i>=5||c?function({ratios:e,averageRatio:t,maxWidth:s,minWidth:n,spacing:a,maxHeight:o=4*s/3}){const r=function(e,t){return e.map((e=>t>1.1?_t(e,1,2.75):_t(e,.6667,1)))}(e,t),i=e.length,c=new Array(i),d=[],l=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=jt(r.slice(e,e+t),0);return(s-(t-1)*a)/n})(n,e)),n+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==i;++e){const t=i-e;e<=3&&t<=3&&l([e,t])}for(let e=1;e!==i-1;++e)for(let s=1;s!==i-e;++s){const n=i-e-s;e<=3&&s<=(t<.85?4:3)&&n<=3&&l([e,s,n])}for(let e=1;e!==i-1;++e)for(let t=1;t!==i-e;++t)for(let s=1;s!==i-e-t;++s){const n=i-e-t-s;e<=3&&t<=3&&s<=3&&n<=4&&l([e,t,s,n])}let u,h=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:s}=d[e],r=s.length,i=jt(t,0)+a*(r-1),c=Math.min(...t)<n?1.5:1,l=(()=>{for(let e=1;e!==r;++e)if(s[e-1]>s[e])return 1.5;return 1})(),m=Math.abs(i-o)*c*l;(!u||m<h)&&(u=d[e],h=m)}const m=u.lineCounts,g=u.heights,f=m.length;let p=0,I=0;for(let e=0;e!==f;++e){const t=m[e],n=g[e],o=Math.round(n);let i=0;for(let d=0;d!==t;++d){const l=0|(0===e?1:0)|(e===f-1?4:0)|(0===d?8:0)|(d===t-1?2:0),u=r[p],h=d===t-1?s-i:Math.round(u*n);c[p]={dimensions:{x:i,y:I,width:h,height:o},sides:l},i+=h+a,++p}I+=o+a}return c}(u):2===i?function(e){const{ratios:t,proportions:s,averageRatio:n}=e;return"ww"===s&&n>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(a-n)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:11},{dimensions:{x:0,y:o+n,width:s,height:o},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=(s-n)/2,r=Math.round(Math.min(o/t[0],Math.min(o/t[1],a)));return[{dimensions:{x:0,y:0,width:o,height:r},sides:13},{dimensions:{x:o+n,y:0,width:o,height:r},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:n,spacing:a,maxHeight:o}=e,r=Math.round(1.5*s),i=Math.min(Math.round(Math.max(.4*(n-a),(n-a)/t[0]/(1/t[0]+1/t[1]))),n-a-r),c=n-i-a,d=Math.min(o,Math.round(Math.min(c/t[0],i/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:13},{dimensions:{x:c+a,y:0,width:i,height:d},sides:7}]}(e)}(u):3===i?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:n,maxWidth:a,minWidth:o}=e,r=t,i=Math.round(Math.min((t-s)/2,n[1]*(a-s)/(n[2]+n[1]))),c=r-i-s,d=Math.max(o,Math.round(Math.min((a-s)/2,Math.min(i*n[2],c*n[1])))),l=Math.min(Math.round(r*n[0]),a-s-d);return[{dimensions:{x:0,y:0,width:l,height:r},sides:13},{dimensions:{x:l+s,y:0,width:d,height:c},sides:3},{dimensions:{x:l+s,y:c+s,width:d,height:i},sides:6}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:n,spacing:a}=e,o=t,r=Math.round(Math.min(o/s[0],.66*(n-a))),i=(t-a)/2,c=Math.min(n-r-a,Math.round(Math.min(i/s[1],i/s[2])));return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+a,width:i,height:c},sides:12},{dimensions:{x:i+a,y:r+a,width:o-i-a,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:n,minWidth:a}){const o=e,r=Math.round(Math.min(o/t[0],.66*(n-s))),i=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(a,Math.round(Math.min(.4*(e-2*s),i*t[1]))),d=Math.round(Math.max(Math.max(a,.33*(e-2*s)),i*t[3])),l=o-c-d-2*s,u=Math.min(n-r-s,i);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:c,height:u},sides:12},{dimensions:{x:c+s,y:r+s,width:l,height:u},sides:4},{dimensions:{x:c+s+l+s,y:r+s,width:d,height:u},sides:6}]}(e):function({maxHeight:e,ratios:t,maxWidth:s,spacing:n,minWidth:a}){const o=e,r=Math.round(Math.min(o*t[0],.6*(s-n))),i=Math.round((e-2*n)/(1/t[1]+1/t[2]+1/t[3])),c=Math.round(i/t[1]),d=Math.round(i/t[2]),l=o-c-d-2*n,u=Math.max(a,Math.min(s-r-n,i));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+n,y:0,width:u,height:c},sides:3},{dimensions:{x:r+n,y:c+n,width:u,height:d},sides:2},{dimensions:{x:r+n,y:c+d+2*n,width:u,height:l},sides:6}]}(e)}(u),{layout:l,containerStyle:Vt(l)}}let Kt;function Xt(e){return Kt||(Kt=document.createElement("span"),Kt.style.font=m.cj?'400 12px system-ui, -apple-system, BlinkMacSystemFont, "Roboto", "Apple Color Emoji", "Helvetica Neue", sans-serif':'400 12px "Roboto", -apple-system, "Apple Color Emoji", BlinkMacSystemFont, "Helvetica Neue", sans-serif',Kt.style.whiteSpace="nowrap",Kt.style.position="absolute",Kt.style.left="-999px",Kt.style.opacity=".01",document.body.appendChild(Kt)),Kt.innerHTML=e,Kt.offsetWidth}function Yt(e,t,s,n,a,r){(0,o.bt)((()=>{if(s&&e.current){const t=e.current.closest(".MessageList");(0,Ot.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==n?1e3:void 0,n,void 0,r)}}),[e,t,s,n,a,r])}var zt=s(172),Jt=s(2864);const es=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"ContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),ts=(0,o.X$)((0,n.c$)(((e,{message:t})=>{const{byId:s}=e.users,n=t.senderId,{targetUserIds:a,targetChatId:o}=t.content.action||{},r=t.replyToMessageId,c=r?(0,i.hj)(e,t.chatId,r):void 0,l=(0,i._X)(e,t),{direction:u,noHighlight:h}=l&&e.focusedMessage||{},m=(0,i.Z1)(e,t.chatId);return{usersById:s,sender:m&&((0,d.eA)(m)||n===t.chatId)?m:n?(0,i.dy)(e,n):void 0,targetChatId:o,targetUserIds:a,targetMessage:c,isFocused:l,...l&&{focusDirection:u,noFocusHighlight:h}}}))((({message:e,observeIntersection:t,isEmbedded:s,appearanceOrder:n=0,isLastInList:a,usersById:r,sender:i,targetUserIds:c,targetMessage:d,targetChatId:l,isFocused:u,focusDirection:h,noFocusHighlight:m})=>{const g=(0,o.sO)(null);(0,Ft._N)(g,t),(0,dt.Z)(e.chatId,e.replyToMessageId,d),Yt(g,e.chatId,u,h,m);const f=(0,Ze.Z)(),p=n<=0,[I,v]=(0,ye.Z)(p);(0,o.d4)((()=>{p||setTimeout(v,10*n)}),[n,v,p]);const{transitionClassNames:y}=(0,de.Z)(I,void 0,p,!1),Z=(0,o.Ye)((()=>c?c.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[c,r]),P=(0,Jt.D)(f,e,i,Z,d,l,s?{isEmbedded:!0,asPlain:!0}:void 0),{isContextMenuOpen:C,contextMenuPosition:w,handleBeforeContextMenu:b,handleContextMenu:M,handleContextMenuClose:S,handleContextMenuHide:E}=(0,Qt.Z)(g),k=void 0!==w;if(s)return o.ZP.createElement("span",{className:"embedded-action-message"},(0,It.Z)(P));const R=(0,ie.Z)("ActionMessage message-list-item",u&&!m&&"focused",k&&"has-menu-open",a&&"last-in-list",y);return o.ZP.createElement("div",{ref:g,id:`message${e.id}`,className:R,"data-message-id":e.id,onMouseDown:e=>{(0,At.q)(e),b(e)},onContextMenu:M},o.ZP.createElement("span",null,P),w&&o.ZP.createElement(es,{isOpen:C,anchor:w,message:e,messageListType:"thread",onClose:S,onCloseAnimationEnd:E}))}))),ss=({className:e,message:t,sender:s,title:n,customText:a,observeIntersection:r,onClick:i})=>{const c=(0,o.sO)(null),l=(0,Ft.Op)(c,r),u=(0,vt.Z)(t&&(0,d.Ti)(t,"pictogram"),!l),h=t&&`sticker-reply-thumb${t.id}`,m=Zt(t),g=Boolean(t&&(0,d.Y5)(t)),f=(0,Ze.Z)(),p=s&&(0,d.OU)(f,s);return o.ZP.createElement("div",{ref:c,className:(0,ie.Z)("EmbeddedMessage",e),onClick:t?i:void 0},m&&function(e,t,s,n){const{width:a,height:r}=(0,pt.W7)();return o.ZP.createElement("img",{id:e,src:s||t,width:a,height:r,alt:"",className:n?"round":""})}(h,m,u,g),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},t?(0,d.Lo)(t)?o.ZP.createElement(ts,{message:t,isEmbedded:!0}):(0,It.Z)((0,d.MK)(f,t,Boolean(m))):a||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,It.Z)(p||n||" "))))};var ns=s(2535),as=s(4752),os=s(8018);const rs=(0,o.X$)((({message:e,outgoingStatus:t,signature:s,onClick:n})=>{const a=(0,Ze.Z)();return o.ZP.createElement("span",{className:"MessageMeta",dir:a.isRtl?"rtl":"ltr",onClick:n},Boolean(e.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,ut.bi)(e.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,It.Z)(s)),o.ZP.createElement("span",{className:"message-time"},e.isEdited&&`${a("EditedMessage")} `,(0,L.mr)(1e3*e.date)),t&&o.ZP.createElement(os.Z,{status:t}))}));var is=s(8835),cs=s(7799),ds=s(4851);const ls=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:n,lastSyncTime:r})=>{const i=(0,o.sO)(null),[c,l,u]=(0,ye.Z)(),h=e.content.sticker,{isAnimated:m,stickerSetId:g}=h,f=g===a.n,p=(0,Ft.Op)(i,t),I=(0,Ft.Op)(i,s),v=h.isPreloadedGlobally?`sticker${h.id}`:(0,d.Ti)(e,"inline"),y=Zt(e),Z=(0,vt.Z)(v,!p,(0,d.kG)(e,"inline",!0),r),P=Boolean(Z),[C,w]=(0,ye.Z)(P),b=m?C:P,{shouldRenderFullMedia:M,transitionClassNames:S}=(0,is.Z)(b,"slow"),{width:E,height:k}=(0,pt.Wr)(h),R=(0,ie.Z)("thumbnail",!y&&"empty"),T=(0,ie.Z)("Sticker media-inner",f&&"inactive");return o.ZP.createElement("div",{ref:i,className:T,onClick:f?void 0:l},!b&&o.ZP.createElement("img",{id:`sticker-thumb-${e.id}`,src:y,width:E,height:k,alt:"",className:R}),!m&&M&&o.ZP.createElement("img",{id:`sticker-${e.id}`,src:Z,width:E,height:k,alt:"",className:(0,ie.Z)("full-media",S)}),m&&P&&o.ZP.createElement(cs.Z,{key:v,className:(0,ie.Z)("full-media",S),id:v,animationData:Z,size:E,play:I,noLoop:!n,onLoad:w}),o.ZP.createElement(ds.Z,{isOpen:c,fromSticker:h,onClose:u}))};var us=s(7854),hs=s(2761),ms=s(5866);function gs(e,t){return(0,ms.Z)((0,d.DH)(e),Boolean(t),m.wB&&!m.vX)}var fs=s(7204);const ps=Promise.resolve("rgba(255,255,255,1)");var Is=s(9196);const vs=({id:e,message:t,observeIntersection:s,noAvatars:n,shouldAutoLoad:a,isInSelectMode:r,isSelected:i,uploadProgress:c,size:l="inline",dimensions:u,nonInteractive:h,shouldAffectAppendix:m,onClick:g,onCancelUpload:f})=>{const p=(0,o.sO)(null),I=((0,d.O$)(t)||(0,d.F$)(t)).blobUrl,v=(0,Ft.Op)(p,s),[y,Z]=(0,o.eJ)(a),P=y&&v,{mediaData:C,downloadProgress:w}=(0,hs.Z)((0,d.Ti)(t,l),!P),b=I||C,M=gs(t,b),{isUploading:S,isTransferring:E,transferProgress:k}=(0,d.Sc)(t,c||w,P&&!b),R=!1===(0,fs.Z)(y),{shouldRender:T,transitionClassNames:N}=(0,de.Z)(E,void 0,R,"slow"),{shouldRenderThumb:B,shouldRenderFullMedia:x,transitionClassNames:A}=(0,is.Z)(b,"slow"),L=(0,o.I4)((()=>{S?f&&f(t):b?g&&g(t.id):Z((e=>!e))}),[b,S,t,f,g]),O=(0,d.B4)(t);(0,o.bt)((()=>{if(!m)return;const e=p.current.closest(".message-content");b?function(e,t,s,n){return n?ps:async function(e,t){const s=new Image;s.src=e,s.width||await new Promise((e=>{s.onload=e}));const n=document.createElement("canvas"),a=n.getContext("2d");n.width=s.width,n.height=s.height,a.drawImage(s,0,0,s.width,s.height);const o=t?s.width-1:0,r=s.height-1;return`rgba(${Array.from(a.getImageData(o,r,1,1).data).join(",")})`}(e,t)}(b,O,0,i).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[b,O,m,r,i]);const{width:F,height:U,isSmall:$}=u||Ht(t,n),Q=(0,ie.Z)("media-inner",!S&&!h&&"interactive",$&&"small-image",F===U&&"square-image"),D=u?`width: ${F}px; height: ${U}px; left: ${u.x}px; top: ${u.y}px;`:"";return o.ZP.createElement("div",{id:e,ref:p,className:Q,style:D,onClick:S?void 0:L},B&&o.ZP.createElement("canvas",{ref:M,className:"thumbnail",style:`width: ${F}px; height: ${U}px`}),x&&o.ZP.createElement("img",{src:b,className:`full-media ${A}`,width:F,height:U,alt:""}),T&&o.ZP.createElement("div",{className:`media-loading ${N}`},o.ZP.createElement(Is.Z,{progress:k,onClick:S?L:void 0})),!b&&!y&&o.ZP.createElement("i",{className:"icon-download"}),E&&o.ZP.createElement("span",{className:"message-upload-progress"},Math.round(100*k),"%"))};var ys=s(2019),Zs=s(4753);function Ps(e,t){const s=(0,o.sO)();s.current=t;const n=(0,o.I4)((()=>{e.current&&e.current.pause()}),[e]),a=(0,o.I4)((()=>{e.current&&s.current&&(0,Zs.Z)(e.current)}),[e]);(0,re.ZP)(n,a)}var Cs=s(6898);const ws=(e,t=!1)=>{const s=(0,o.sO)(!1),n=(0,o.sO)(!1),a=(0,o.I4)((()=>{n.current=!0,t&&e.current&&(s.current||(s.current=!e.current.paused),e.current.pause())}),[t,e]),r=(0,o.I4)((()=>{t&&e.current&&s.current&&document.body.contains(e.current)&&(0,Zs.Z)(e.current),s.current=!1,n.current=!1}),[t,e]),i=(0,o.I4)((()=>{(0,Z.T2)(r)}),[r]);document.hasFocus()||a(),(0,le.Z)(a,i)};function bs(){return(bs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const Ms=({id:e,message:t,observeIntersection:s,noAvatars:n,shouldAutoLoad:a,shouldAutoPlay:r,uploadProgress:i,lastSyncTime:c,dimensions:l,onClick:u,onCancelUpload:h})=>{var m;const g=(0,o.sO)(null),f=(0,o.sO)(null),p=(0,d.b7)(t)||(0,d.Cg)(t),I=p.blobUrl,v=(0,Ft.Op)(g,s),[y,Z]=(0,o.eJ)(a),P=Boolean(y&&v&&c),[C,w]=(0,o.eJ)(r),b=(0,vt.Z)((0,d.Ti)(t,"pictogram"),!(v&&c),(0,d.kG)(t,"pictogram"),c),{mediaData:M,downloadProgress:S}=(0,hs.Z)((0,d.Ti)(t,"inline"),!P,(0,d.kG)(t,"inline"),c),E=I||M,k=Boolean(v&&E),R=gs(t,b),{isBuffered:T,bufferingHandlers:N}=(0,ys.Z)(!a),{isUploading:B,isTransferring:x,transferProgress:A}=(0,d.Sc)(t,i||S,P&&!T),O=!1===(0,fs.Z)(y),{shouldRender:F,transitionClassNames:U}=(0,de.Z)(x,void 0,O),{transitionClassNames:$}=(0,is.Z)(E,"slow"),[Q,D]=(0,o.eJ)(0),q=(0,o.I4)((e=>{D(Math.max(0,e.currentTarget.currentTime-1))}),[]),G=(null===(m=f.current)||void 0===m?void 0:m.duration)||p.duration||0,H=(0,d.B4)(t),j=(0,d.MF)(t),{width:_,height:V}=l||(0,pt.GC)(p,H,j,n);Ps(f,Boolean(k&&r)),ws(f,C),(0,Cs.Z)(f,[k]);const W=(0,o.I4)((()=>{B?h&&h(t):E?E&&!C?(w(!0),f.current.play()):u&&u(t.id):Z((e=>!e))}),[B,E,C,u,h,t]),K=(0,ie.Z)("media-inner dark",!B&&"interactive"),X=(0,ie.Z)("full-media",$),Y=l?`width: ${_}px; height: ${V}px; left: ${l.x}px; top: ${l.y}px;`:"";return o.ZP.createElement("div",{ref:g,id:e,className:K,style:Y,onClick:B?void 0:W},!b&&o.ZP.createElement("canvas",{ref:R,className:"thumbnail",style:`width: ${_}px; height: ${V}px;`}),b&&o.ZP.createElement("img",{src:b,className:"thumbnail",style:`width: ${_}px; height: ${V}px;`,alt:""}),k&&o.ZP.createElement("video",bs({ref:f,className:X,width:_,height:V,autoPlay:C,muted:!0,loop:!0,playsInline:!0},N,{onTimeUpdate:q}),o.ZP.createElement("source",{src:E})),y&&!C&&!F&&o.ZP.createElement("i",{className:"icon-large-play"}),F&&o.ZP.createElement("div",{className:`media-loading ${U}`},o.ZP.createElement(Is.Z,{progress:A,onClick:B?W:void 0})),!y&&o.ZP.createElement("i",{className:"icon-download"}),x?o.ZP.createElement("span",{className:"message-upload-progress"},"..."):o.ZP.createElement("div",{className:"message-media-duration"},p.isGif?"GIF":(0,L.k9)(Math.max(G-Q,0))))};var Ss=s(2969);const Es=(0,n.c$)(((e,{contact:t})=>({user:(0,i.dy)(e,t.userId)})),((e,t)=>(0,g.ei)(t,["openUserInfo"])))((({contact:e,user:t,openUserInfo:s})=>{const{firstName:n,lastName:a,phoneNumber:r,userId:i}=e,c=(0,o.I4)((()=>{s({id:i})}),[s,i]);return o.ZP.createElement("div",{className:(0,ie.Z)("Contact",Boolean(i)&&"interactive"),onClick:i?c:void 0},o.ZP.createElement(zt.Z,{size:"large",user:t,text:n||a}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},n," ",a),o.ZP.createElement("div",{className:"contact-phone"},(0,Ss.WZ)(r))))}));var ks=s(4605);const Rs=(0,o.X$)((({id:e,options:t,selected:s=[],disabled:n,round:a,loadingOptions:r,onChange:i})=>{const[c,d]=(0,o.eJ)([]),l=(0,o.I4)((e=>{const{value:t,checked:s}=e.currentTarget;let n;n=s?[...c,t]:c.filter((e=>e!==t)),d(n),i(n)}),[i,c]);return o.ZP.createElement("div",{id:e,className:"radio-group"},t.map((e=>o.ZP.createElement(ks.Z,{label:e.label,subLabel:e.subLabel,value:e.value,checked:-1!==s.indexOf(e.value),disabled:n,round:a,isLoading:r?-1!==r.indexOf(e.value):void 0,onChange:l}))))}));var Ts=s(4434),Ns=s(6937);function Bs(e,t){return t>0?(e/t*100).toFixed():0}const xs=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:n,correctResults:a,shouldAnimate:r})=>{const i=t&&t.find((t=>t.option===e.option)),c=0===a.length||-1!==a.indexOf(e.option),d=a.length>0&&c||(null==i?void 0:i.isChosen),l=i?Bs(i.votersCount,s||0):0,[u,h]=(0,o.eJ)(r?0:l),m=(0,o.sO)(null),g=i?Bs(i.votersCount,n||0):0,f=u<l;if((0,o.d4)((()=>{r&&h(l)}),[r,l]),(0,o.d4)((()=>{const e=m.current;if(e&&r){const t=e.firstElementChild,s=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",s):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${s}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[f,r]),!t||!i)return;const p=`width: ${g}%; transform:scaleX(${f?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===l?"limit-width":"")},l,"%",d&&o.ZP.createElement("span",{className:(0,ie.Z)("poll-option-chosen",!c&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:c?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,It.Z)(e.text)),o.ZP.createElement("div",{className:(0,ie.Z)("poll-option-answer",d&&!c&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:m}),o.ZP.createElement("div",{className:"poll-option-line",style:p}))))},As=(0,o.X$)((0,n.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{serverTimeOffset:n,users:{byId:a}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:a,serverTimeOffset:n}:{}}),((e,t)=>(0,g.ei)(t,["loadMessage","openPollResults"])))((({message:e,poll:t,recentVoterIds:s,usersById:n,loadMessage:a,onSendVote:r,openPollResults:i,serverTimeOffset:c})=>{const{id:d,chatId:l}=e,{summary:u,results:h}=t,[m,g]=(0,o.eJ)(!1),[f,p]=(0,o.eJ)([]),[I,v]=(0,o.eJ)(!1),[y,Z]=(0,o.eJ)(!1),[P,C]=(0,o.eJ)(!u.closed&&u.closeDate&&u.closeDate>0?Math.min(u.closeDate-Math.floor(Date.now()/1e3)+c,u.closePeriod):0),w=(0,o.sO)(null),{results:b,totalVoters:M}=h,S=b&&b.some((e=>e.isChosen)),E=!u.closed&&!S,k=!E&&u.isPublic&&Number(h.totalVoters)>0,R=E&&u.multipleChoice,T=b?Math.max(...b.map((e=>e.votersCount))):M,N=b?b.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],B=u.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(u.quiz&&u.closePeriod&&P<=0)})));(0,o.d4)((()=>{m&&t.results.results&&t.results.results.some((e=>e.isChosen))&&g(!1)}),[m,t.results.results]),(0,o.d4)((()=>{P>0&&setTimeout((()=>C(P-1)),1e3);const e=w.current;if(e){const t=12*Math.PI,s=e.lastElementChild,n=e.firstElementChild;if(P<=5&&e.classList.add("hurry-up"),s&&n){const e=(u.closePeriod-P)/u.closePeriod*t;n.textContent=(0,L.k9)(P),s.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,L.k9)(P)}</span>\n <svg width="16px" height="16px">\n <circle cx="8" cy="8" r="6" class="poll-countdown-progress" transform="rotate(-90, 8, 8)"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="0"\n />\n </svg>`}}),[P,u.closePeriod]),(0,o.d4)((()=>{u.quiz&&(P<=0||S&&!u.closed)&&a({chatId:l,messageId:d})}),[l,P,S,a,d,u.closed,u.quiz]),(0,o.d4)((()=>{let e;return u.quiz&&!u.closed&&u.closePeriod&&u.closePeriod>0&&(e=window.setTimeout((()=>{a({chatId:l,messageId:d})}),1e3*u.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[E,l,a,d,u.closePeriod,u.closed,u.quiz]);const x=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const s=n[t];return s&&e.push(s),e}),[]):[]),[n,s]),A=(0,o.I4)((e=>{p([e]),g(!0),Z(!0),r([e])}),[r]),O=(0,o.I4)((e=>{p(e)}),[]),F=(0,o.I4)((()=>{g(!0),Z(!0),r(f)}),[r,f]),U=(0,o.I4)((()=>{i({chatId:l,messageId:d})}),[l,d,i]),$=(0,o.I4)((()=>{v(!0)}),[]),Q=(0,o.I4)((()=>{v(!1),Z(!1)}),[]);(0,o.d4)((()=>{y&&S&&u.quiz&&h.results&&t.results.solution&&(h.results.find((e=>e.isChosen&&e.isCorrect))||v(!0))}),[S,y,h.results,u.quiz,t.results.solution]);const D=(0,Ze.Z)();return o.ZP.createElement("div",{className:"Poll",dir:D.isRtl?"auto":"ltr"},I&&t.results.solution&&o.ZP.createElement(Ns.Z,{message:(0,Dt.H)(t.results.solution,t.results.solutionEntities),duration:5e3,onDismiss:Q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,It.Z)(u.question)),o.ZP.createElement("div",{className:"poll-type"},D(function(e){return void 0===e.isPublic?" ":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.closed?"FinalResults":e.isPublic?"PublicPoll":"AnonymousPoll"}(u)),x.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},x.map((e=>o.ZP.createElement(zt.Z,{size:"micro",user:e})))),P>0&&E&&o.ZP.createElement("div",{ref:w,className:"poll-countdown"}),u.quiz&&t.results.solution&&!E&&o.ZP.createElement(be.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:I,onClick:$,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),E&&o.ZP.createElement("div",{className:"poll-answers"},R?o.ZP.createElement(Rs,{options:B,onChange:O,disabled:e.isScheduled||m,loadingOptions:m?f:void 0,round:!0}):o.ZP.createElement(Ts.Z,{name:`poll-${d}`,options:B,onChange:A,disabled:e.isScheduled||m,loadingOption:m?f[0]:void 0})),!E&&o.ZP.createElement("div",{className:"poll-results"},u.answers.map((function(e){return o.ZP.createElement(xs,{key:e.option,shouldAnimate:y,answer:e,voteResults:b,totalVoters:M,maxVotersCount:T,correctResults:N})}))),!k&&!R&&o.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,s){return s?e(t?"Answer":"Vote",s,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(D,u.quiz,h.totalVoters)),R&&o.ZP.createElement(be.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:F},D("PollSubmitVotes")),k&&o.ZP.createElement(be.Z,{isText:!0,size:"tiny",onClick:U},D("PollViewResults")))})));var Ls=s(8035),Os=s(88);const Fs=(0,o.X$)((({message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:n,shouldAutoPlay:a,inPreview:r,lastSyncTime:i,onMediaClick:c,onCancelMediaTransfer:l})=>{const u=(0,d.s1)(e);let h=!1;if(null!=u&&u.photo&&!u.video){const{width:t,height:s}=Ht(e);h=t===s}const m=(0,o.I4)((()=>{c()}),[c]);if(!u)return;const{siteName:g,url:f,displayUrl:p,title:I,description:v,photo:y,video:Z}=u,P=(y||Z)&&c&&!h,C=(0,Ls.Z)(v,170),w=(0,ie.Z)("WebPage",h&&"with-square-photo",!y&&!Z&&!r&&"without-media",Z&&"with-video");return o.ZP.createElement("div",{className:w,"data-initial":(g||p)[0],dir:"auto"},y&&!Z&&o.ZP.createElement(vs,{message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:n,size:h?"pictogram":"inline",nonInteractive:!P,onClick:P?m:void 0,onCancelUpload:l}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Os.Z,{className:"site-name",url:f,text:g||p}),!r&&I&&o.ZP.createElement("p",{className:"site-title"},(0,It.Z)(I)),C&&o.ZP.createElement("p",{className:"site-description"},(0,It.Z)(C,["emoji","br"]))),!r&&Z&&o.ZP.createElement(Ms,{message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:n,shouldAutoPlay:a,lastSyncTime:i,onClick:P?m:void 0,onCancelUpload:l}))}));var Us=s(9937);const $s=(0,o.X$)((({message:e})=>{const t=(0,Ze.Z)(),s=(0,d.eO)(e),{title:n,text:a,amount:r,currency:i,isTest:c,photoUrl:l}=s;return o.ZP.createElement("div",{className:"Invoice"},n&&o.ZP.createElement("p",{className:"title"},(0,It.Z)(n)),a&&o.ZP.createElement("p",null,(0,It.Z)(a,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(l?"has-image":"")},l&&o.ZP.createElement("img",{className:"invoice-image",src:l,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,Us.x)(r,i,t.code),c&&o.ZP.createElement("span",null,t("PaymentTestInvoice")))))}));function Qs(e){return(0,o.X$)((0,n.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,i.CA)(e),isSelected:(0,i.vk)(e,s.id)}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection"])))((t=>{const{isInSelectMode:s,isSelected:n,message:a,toggleMessageSelection:r,dimensions:i}=t,c=(0,o.I4)((e=>{e.stopPropagation(),r({messageId:a.id,withShift:null==e?void 0:e.shiftKey})}),[r,a]),d=(0,o.Ye)((()=>({...t,isInSelectMode:s,isSelected:n,dimensions:{...t.dimensions,x:0,y:0},onClick:s?void 0:t.onClick})),[t,s,n]);return o.ZP.createElement("div",{className:(0,ie.Z)("album-item-select-wrapper",n&&"is-selected"),style:i?`left: ${i.x}px; top: ${i.y}px;`:"",onClick:s?c:void 0},s&&o.ZP.createElement("div",{className:"message-select-control"},n&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const Ds=Qs(vs),qs=Qs(Ms),Gs=(0,n.c$)((e=>({uploadsById:e.fileUploads.byMessageLocalId})),((e,t)=>(0,g.ei)(t,["cancelSendingMessage"])))((({album:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:n,hasCustomAppendix:a,lastSyncTime:r,isOwn:i,albumLayout:c,onMediaClick:l,uploadsById:u,cancelSendingMessage:h})=>{const m=e.messages.length,g=(0,o.I4)((e=>{h({chatId:e.chatId,messageId:e.id})}),[h]),{width:f,height:p}=c.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${f}px; height: ${p}px;`},e.messages.map((function(e,h){const{photo:f,video:p}=(0,d.qp)(e),I=u[e.previousLocalId||e.id],v=null==I?void 0:I.progress,{dimensions:y,sides:Z}=c.layout[h];if(f){const n=a&&(i?h===m-1:Boolean(8&Z&&4&Z));return o.ZP.createElement(Ds,{id:`album-media-${e.id}`,message:e,observeIntersection:t,shouldAutoLoad:s,shouldAffectAppendix:n,uploadProgress:v,dimensions:y,onClick:l,onCancelUpload:g})}if(p)return o.ZP.createElement(qs,{id:`album-media-${e.id}`,message:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:n,uploadProgress:v,lastSyncTime:r,dimensions:y,onClick:l,onCancelUpload:g})})))}));function Hs(){return(Hs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}let js;const _s=({message:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:n,lastSyncTime:a})=>{const r=(0,o.sO)(null),i=(0,o.sO)(null),c=(0,o.sO)(null),l=e.content.video,u=(0,Ft.Op)(r,t),[h,m]=(0,o.eJ)(s&&n),g=Boolean(h&&u&&a),{mediaData:f,downloadProgress:p}=(0,hs.Z)((0,d.Ti)(e,"inline"),!g,(0,d.kG)(e,"inline"),a),I=gs(e,f),{isBuffered:v,bufferingHandlers:y}=(0,ys.Z)(),P=h&&!v,C=!1===(0,fs.Z)(h),{shouldRender:w,transitionClassNames:b}=(0,de.Z)(P||!v,void 0,C),{shouldRenderThumb:M,transitionClassNames:S}=(0,is.Z)(f,"slow"),[E,k]=(0,o.eJ)(!1),[R,T]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!E)return;const e=188*Math.PI,t=e-R*e,s=c.current,n=i.current,a=n.firstElementChild;a?a.firstElementChild.setAttribute("stroke-dashoffset",t.toString()):n.innerHTML=`<svg width="200px" height="200px">\n <circle cx="100" cy="100" r="94" class="progress-circle" transform="rotate(-90, 100, 100)"\n stroke-dasharray="${e} ${e}"\n stroke-dashoffset="${e}"\n />\n </svg>`,T(s.currentTime/s.duration)}),[E,R]);const N=Boolean(f&&u),B=()=>{k(!1),T(0),(0,Zs.Z)(c.current),(0,Z.T2)((()=>{i.current.innerHTML=""}))},x=(A=B,()=>{js&&js(),js=A});var A;(0,o.d4)((()=>{c.current&&(N?(0,Zs.Z)(c.current):c.current.pause())}),[N]),Ps(c,N),ws(c,Boolean(f)),(0,Cs.Z)(c,[f]);const O=(0,o.I4)((()=>{if(!f)return void m((e=>!e));const e=c.current;E?e.paused?(0,Zs.Z)(e):e.pause():(x(),e.pause(),e.currentTime=0,(0,Zs.Z)(e),k(!0))}),[x,E,f]),F=(0,o.I4)((e=>{const t=e.currentTarget;T(t.currentTime/t.duration)}),[]),U=(0,ie.Z)("full-media",S);return o.ZP.createElement("div",{ref:r,className:"RoundVideo media-inner",onClick:O},(M||f)&&o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:I,className:"thumbnail",style:`width: ${pt.vw}px; height: ${pt.vw}px`})),f&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",Hs({ref:c,className:U,width:pt.vw,height:pt.vw,autoPlay:!0,muted:!E,loop:!E,playsInline:!0,onEnded:E?B:void 0},y,{onTimeUpdate:E?F:void 0}),o.ZP.createElement("source",{src:f}))),o.ZP.createElement("div",{className:"progress",ref:i}),w&&o.ZP.createElement("div",{className:`media-loading ${b}`},o.ZP.createElement(Is.Z,{progress:p})),!f&&!h&&o.ZP.createElement("i",{className:"icon-large-play"}),o.ZP.createElement("div",{className:"message-media-duration"},E?(0,L.k9)(c.current.currentTime):(0,L.k9)(l.duration),(!E||c.current.paused)&&o.ZP.createElement("i",{className:"icon-muted-chat"})))},Vs=({message:e,onClick:t})=>{const s=(0,Ze.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},e.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(be.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>t({button:e})},(0,It.Z)(s(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(a.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},Ws=(0,o.X$)((0,n.c$)(((e,{message:t})=>{const{threadId:s,chatId:n}=t.threadInfo,a=(0,i.tZ)(e,n,s)||t.threadInfo,{byId:o}=e.users,{byId:r}=e.chats;return{threadInfo:a,usersById:o,chatsById:r}}),((e,t)=>(0,g.ei)(t,["openChat"])))((({disabled:e,threadInfo:t,usersById:s,chatsById:n,openChat:a})=>{const r=(0,Ze.Z)(),{threadId:i,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:h,recentReplierIds:m}=t,g=(0,o.I4)((()=>{a({id:c,threadId:i})}),[a,c,i]);if(void 0===l)return;const f=m&&m.map((e=>(0,d.YA)(e)?s[e]:n[e])).filter(Boolean),p=Boolean(h&&u&&h<u);return o.ZP.createElement("div",{"data-cnt":(0,ut.bi)(l),className:(0,ie.Z)("CommentButton",p&&"has-unread",e&&"disabled"),dir:r.isRtl?"rtl":"ltr",onClick:g},o.ZP.createElement("i",{className:"icon-comments-sticker"}),(!f||0===f.length)&&o.ZP.createElement("i",{className:"icon-comments"}),f&&f.length>0&&o.ZP.createElement("div",{className:"recent-repliers",dir:r.isRtl?"rtl":"ltr"},f.map((e=>o.ZP.createElement(zt.Z,{key:e.id,size:"small",user:(0,d.YA)(e.id)?e:void 0,chat:(0,d.YA)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},l?r("Comments",l,"i"):r("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))}))),Ks="data-is-document-group-hover";function Xs(e){const t=zs(e.currentTarget);t&&t.setAttribute(Ks,"")}function Ys(e){const t=zs(e.currentTarget);t&&t.removeAttribute(Ks)}function zs(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}const Js=(0,o.X$)((0,n.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:n,lastSyncTime:a}=e,{message:o,album:r,withSenderName:c,withAvatar:l,threadId:u,messageListType:h}=t,{id:m,chatId:g,viaBotId:f,replyToMessageId:p,isOutgoing:I}=o,v=(0,i.Z1)(e,g),y=(0,i.FM)(e,g),Z=v&&(0,d.eA)(v),P=null==v?void 0:v.username,C=!y&&(0,d.Ul)(o),w=c||l||C?(0,i.Ur)(e,o):void 0,b=(0,i.cv)(e,o),M=f?(0,i.dy)(e,f):void 0,S=u?(0,i.qS)(e,g,u):void 0,E=o.id===S,k=p===S,R=p&&!k?(0,i.hj)(e,g,p):void 0,T=R&&(0,i.Ur)(e,R),N=(0,i.uZ)(e,o),B="thread"===h&&(r?r.messages.some((t=>(0,i._X)(e,t))):(0,i._X)(e,o)),{direction:x,noHighlight:A,isResizingContainer:L}=B&&s||{},O=n.messageIds&&n.messageIds.includes(m),{query:F}=(0,i.n5)(e)||{},U=(0,d._O)(o);let $;$=null!=r&&r.messages?r.messages.every((({id:t})=>(0,i.vk)(e,t))):(0,i.vk)(e,m);const{canReply:Q}="thread"===h&&(0,i._k)(e,o,u)||{};return{theme:(0,i.Pu)(e),chatUsername:P,forceSenderName:C,sender:w,originSender:b,botSender:M,shouldHideReply:k,isThreadTop:E,replyMessage:R,replyMessageSender:T,isFocused:B,isForwarding:O,isChatWithSelf:y,isChannel:Z,canReply:Q,lastSyncTime:a,highlight:F,isSingleEmoji:Boolean(U),animatedEmoji:U?(0,i.zB)(e,U):void 0,isInSelectMode:(0,i.CA)(e),isSelected:$,isGroupSelected:!!o.groupedId&&!o.isInAlbum&&(0,i.a6)(e,g,o.groupedId),threadId:u,isPinnedList:"pinned"===h,shouldAutoLoadMedia:v?(0,i.TD)(e,o,v,w):void 0,shouldAutoPlayMedia:(0,i.pv)(e,o),shouldLoopStickers:(0,i.yB)(e),...I&&{outgoingStatus:(0,i.dT)(e,o,"scheduled"===h)},..."number"==typeof N&&{uploadProgress:N},...B&&{focusDirection:x,noFocusHighlight:A,isResizingContainer:L}}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection","clickInlineButton","disableContextMenuHint"])))((({message:e,chatUsername:t,observeIntersectionForBottom:s,observeIntersectionForMedia:a,observeIntersectionForAnimatedStickers:r,album:i,noAvatars:c,withAvatar:l,withSenderName:g,noComments:f,appearanceOrder:p,isFirstInGroup:I,isLastInGroup:v,isFirstInDocumentGroup:y,isLastInDocumentGroup:Z,isLastInList:P,theme:C,forceSenderName:w,sender:b,originSender:M,botSender:S,isThreadTop:E,shouldHideReply:k,replyMessage:R,replyMessageSender:T,outgoingStatus:N,uploadProgress:B,isFocused:x,focusDirection:A,noFocusHighlight:L,isResizingContainer:O,isForwarding:F,isChatWithSelf:U,isChannel:$,canReply:Q,lastSyncTime:D,highlight:q,animatedEmoji:G,isInSelectMode:H,isSelected:j,isGroupSelected:_,threadId:V,messageListType:W,isPinnedList:K,shouldAutoLoadMedia:X,shouldAutoPlayMedia:Y,shouldLoopStickers:z,toggleMessageSelection:J,clickInlineButton:ee,disableContextMenuHint:te})=>{const se=(0,o.sO)(null),ne=(0,o.sO)(null),ae=(0,o.sO)(null),oe=(0,Ze.Z)();(0,Ft._N)(ne,s);const{isContextMenuOpen:re,contextMenuPosition:ce,handleBeforeContextMenu:le,handleContextMenu:ue,handleContextMenuClose:he,handleContextMenuHide:me}=(0,Qt.Z)(se,m.$b&&H,!0,m.wZ);(0,o.d4)((()=>{re&&te()}),[re,te]);const ge=p<=0,[fe,pe]=(0,ye.Z)(ge);(0,o.d4)((()=>{ge||setTimeout(pe,10*p)}),[p,pe,ge]);const{transitionClassNames:Ie}=(0,de.Z)(fe,void 0,ge,!1),{id:ve,chatId:Pe,threadInfo:Ce}=e,we=(0,d.CI)(e),Me=(0,d.B4)(e),Se="scheduled"===W||e.isScheduled,Ee=(0,d.ss)(e)&&!k,ke=Boolean(Ce)&&"thread"===W,{forwardInfo:Re,viaBotId:Te}=e,Ne=Re&&!U&&!Re.isLinkedChannelPost,xe=Boolean(e.groupedId)&&!e.isInAlbum,Ae=Boolean(i)&&i.messages.length>1,{text:Le,photo:Oe,video:Fe,audio:Ue,voice:$e,document:Qe,sticker:De,contact:qe,poll:Ge,webPage:He,invoice:je}=(0,d.qp)(e),_e=(0,d.$D)(e),Ve=(0,Dt.X)(e,q,qt(_e)),We=void 0!==ce,Ke=$&&e.adminTitle||Re&&!Ne&&Re.adminTitle||void 0,Xe=(0,o.Ye)((()=>Ke?Xt(Ke):void 0),[Ke]),Ye=!(We||H||F)&&(!xe||Z),ze=$&&!Se,Je=Boolean(K||Re&&(Re.isChannelPost||U&&!Me)&&Re.fromMessageId),et=!Re||!U&&b?b:M,tt=Re?M:b,st=(0,o.I4)(((e,t)=>{we||J({messageId:ve,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...Ae&&{childMessageIds:i.messages.map((({id:e})=>e))}})}),[we,J,ve,Ae,i]),{handleMouseDown:at,handleClick:ot,handleContextMenu:rt,handleDoubleClick:it,handleContentDoubleClick:ct,isSwiped:lt}=function(e,t,s,a,r,i,c,d,l){const{setReplyingToId:u}=(0,n.uC)(),[h,g,f]=(0,ye.Z)();return(0,o.d4)((()=>{if(!m.$b||i||!c)return;let e;return(0,Be.s)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,s)=>s===Be.e.Left&&(e||(e=Date.now()),g(),!0),onRelease:()=>{e&&(u({messageId:s}),setTimeout(f,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,i,s,u,g,f,c]),{handleMouseDown:i?void 0:function(e){(0,At.q)(e),a||l(e)},handleClick:function(t){if(i&&!a)e(t);else if(m.wZ){const e=t.target;if(!e.classList.contains("text-content")&&!e.classList.contains("Message"))return;nt.Z.getIsKeyboardVisible()?setTimeout((()=>{d(t)}),350):d(t)}},handleContextMenu:i||a?void 0:function(t){if(m.wZ){if(t.target.matches("a[href]"))return;t.preventDefault(),e()}else d(t)},handleDoubleClick:i?void 0:function(){u({messageId:s})},handleContentDoubleClick:m.$b?void 0:function(e){e.stopPropagation()},isSwiped:h}}(st,se,ve,we,0,Boolean(H),Boolean(Q),ue,le),{handleAvatarClick:ut,handleSenderClick:ht,handleViaBotClick:mt,handleReplyClick:gt,handleMediaClick:ft,handleAudioPlay:vt,handleAlbumMediaClick:yt,handleMetaClick:Zt,handleReadMedia:Pt,handleCancelUpload:Ct,handleVoteSend:wt,handleGroupForward:bt,handleForward:Mt,handleFocus:St,handleFocusForwarded:Et,handleDocumentGroupSelectAll:kt}=function(e,t,s,a,r,i,c,l,m,g,f){const{openUserInfo:p,openChat:I,showNotification:v,focusMessage:y,openMediaViewer:Z,openAudioPlayer:P,markMessagesRead:C,cancelSendingMessage:w,sendPollVote:b,openForwardMenu:M}=(0,n.uC)(),{id:S,forwardInfo:E,replyToMessageId:k,groupedId:R}=s,T=(0,o.I4)((()=>{m&&((0,d.YA)(m.id)?p({id:m.id}):I({id:m.id}))}),[m,p,I]),N=(0,o.I4)((()=>{g?(0,d.YA)(g.id)?p({id:g.id}):I({id:g.id}):v({message:e("HidAccount")})}),[g,v,e,p,I]),B=(0,o.I4)((()=>{f&&p({id:f.id})}),[f,p]),x=(0,o.I4)((()=>{y({chatId:a,threadId:r,messageId:k,replyMessageId:S})}),[y,a,r,k,S]),A=(0,o.I4)((()=>{Z({chatId:a,threadId:r,messageId:S,origin:c?h.bZ.ScheduledInline:h.bZ.Inline})}),[a,r,S,Z,c]),L=(0,o.I4)((()=>{P({chatId:a,messageId:S})}),[a,S,P]),O=(0,o.I4)((e=>{Z({chatId:a,threadId:r,messageId:e,origin:c?h.bZ.ScheduledAlbum:h.bZ.Album})}),[a,r,Z,c]),F=(0,o.I4)((()=>{C({messageIds:[S]})}),[S,C]),U=(0,o.I4)((()=>{w({chatId:a,messageId:S})}),[w,a,S]),$=(0,o.I4)((e=>{b({chatId:a,messageId:S,options:e})}),[a,S,b]),Q=(0,o.I4)((()=>{M({fromChatId:a,groupedId:R})}),[M,a,R]),D=(0,o.I4)((()=>{if(l&&l.messages){const e=l.messages.map((({id:e})=>e));M({fromChatId:a,messageIds:e})}else M({fromChatId:a,messageIds:[S]})}),[l,M,a,S]),q=(0,o.I4)((()=>{y({chatId:a,threadId:u._f,messageId:S})}),[y,a,S]),G=(0,o.I4)((()=>{y(i?{chatId:E.fromChatId,groupedId:R,groupedChatId:a}:{chatId:E.fromChatId,messageId:E.fromMessageId})}),[i,y,E,R,a]),H=(0,o.I4)((e=>{e.stopPropagation(),t(e,R)}),[t,R]);return{handleAvatarClick:T,handleSenderClick:N,handleViaBotClick:B,handleReplyClick:x,handleMediaClick:A,handleAudioPlay:L,handleAlbumMediaClick:O,handleMetaClick:H,handleReadMedia:F,handleCancelUpload:U,handleVoteSend:$,handleGroupForward:Q,handleForward:D,handleFocus:q,handleFocusForwarded:G,handleDocumentGroupSelectAll:H}}(oe,st,e,Pe,V,xe,Boolean(Se),i,et,tt,S),Rt=(0,ie.Z)("Message message-list-item",I&&"first-in-group",v&&"last-in-group",y&&"first-in-document-group",Z&&"last-in-document-group",P&&"last-in-list",Me&&"own",Boolean(e.views)&&"has-views",e.isEdited&&"was-edited",Ee&&"has-reply",We&&"has-menu-open",x&&!L&&"focused",F&&"is-forwarding",e.isDeleting&&"is-deleting",xe&&"is-in-document-group",Ae&&"is-album",e.hasUnreadMention&&"has-unread-mention",j&&"is-selected",H&&"is-in-selection-mode",E&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",lt&&"is-swiped",Ie),Tt=function(e,{hasReply:t,customShape:s,isLastInGroup:n,asForwarded:a,hasThread:o,forceSenderName:r,hasComments:i,hasActionButton:c}={}){const{text:l,photo:u,video:h,audio:m,voice:g,document:f,poll:p,webPage:I,contact:v}=(0,d.qp)(e),y=["message-content"],Z=u||h,P=Z&&!l,C=Boolean(e.viaBotId);return qt(s)?y.push(`emoji-only emoji-only-${s}`):l&&y.push("text"),c&&y.push("has-action-button"),s&&(y.push("custom-shape"),null!=h&&h.isRound&&y.push("round"),i&&y.push("has-comments")),u||h?y.push("media"):m?y.push("audio"):g?y.push("voice"):f?y.push("document"):v?y.push("contact"):p?y.push("poll"):I&&(y.push("web-page"),(I.photo||I.video)&&y.push("media")),a&&!s&&y.push("is-forwarded"),t&&y.push("is-reply"),o&&y.push("has-replies"),C&&y.push("is-via-bot"),r&&y.push("force-sender-name"),s||(y.push("has-shadow"),Z&&i&&y.push("has-background"),(t||a||!P||C||r)&&y.push("has-solid-background"),!n||!u&&P||y.push("has-appendix")),y.join(" ")}(e,{hasReply:Ee,customShape:_e,isLastInGroup:v,asForwarded:Ne,hasThread:ke,forceSenderName:w,hasComments:e.threadInfo&&e.threadInfo.messagesCount>0,hasActionButton:ze||Je}),Nt=e.threadInfo&&(!xe||Z)&&"thread"===W&&!f,Bt=Tt.includes("has-appendix");(0,dt.Z)(Pe,Ee?e.replyToMessageId:void 0,R,e.id),Yt(se,Pe,x,A,L,O),(0,o.bt)((()=>{ae.current&&(ae.current.innerHTML=Me?'<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><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"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="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" fill="#000" filter="url(#a)"/><path d="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" fill="#EEFFDE" class="corner"/></g></svg>':'<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><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"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="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" fill="#000" filter="url(#a)"/><path d="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" fill="#FFF" class="corner"/></g></svg>')}),[Me,Bt]);let xt,Lt="",Ot=!1;const Ut=(0,o.Ye)((()=>Ae?Wt(Me,Boolean(Ne),Boolean(c),i):void 0),[Ae,Me,Ne,c,i]),$t=Ne?28:0;if(Ae||!Oe&&!Fe)Ut&&(xt=Math.max(Gt(Boolean(Le),Nt),Ut.containerStyle.width),xt-Ut.containerStyle.width>18&&(Ot=!0));else{let t;Oe?t=Ht(e,c).width:Fe&&(t=Fe.isRound?pt.vw:Ht(e,c).width),t&&(xt=Math.max(Gt(Boolean(Le),Nt),t),xt-t>18&&(Ot=!0))}return xt&&(Lt=`width: ${xt+$t}px`),o.ZP.createElement("div",{ref:se,id:`message${ve}`,className:Rt,style:Xe?`--meta-safe-author-width: ${Xe}px`:void 0,"data-message-id":ve,onMouseDown:at,onClick:ot,onContextMenu:rt,onDoubleClick:it,onMouseEnter:xe&&!Z?Xs:void 0,onMouseLeave:xe&&!Z?Ys:void 0},o.ZP.createElement("div",{ref:ne,className:"bottom-marker","data-message-id":ve,"data-last-message-id":i?i.messages[i.messages.length-1].id:void 0,"data-has-unread-mention":e.hasUnreadMention}),!we&&!xe&&o.ZP.createElement("div",{className:"message-select-control"},j&&o.ZP.createElement("i",{className:"icon-select"})),!we&&Z&&o.ZP.createElement("div",{className:(0,ie.Z)("message-select-control group-select",_&&"is-selected"),onClick:kt},_&&o.ZP.createElement("i",{className:"icon-select"})),l&&function(){const e=et&&(0,d.YA)(et.id),t=et&&e?et:void 0,s=et&&!e?et:void 0,n=!et&&Re?Re.hiddenUserName:void 0;return o.ZP.createElement(zt.Z,{size:"small",user:t,chat:s,text:n,lastSyncTime:D,onClick:t||s?ut:void 0})}(),o.ZP.createElement("div",{className:(0,ie.Z)("message-content-wrapper",Tt.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:Tt,style:Lt,dir:"auto"},Ne&&!_e&&(!xe||y)&&o.ZP.createElement("div",{className:"message-title"},oe("ForwardedMessage")),function(){const t=(0,ie.Z)("content-inner",Ne&&!_e&&"forwarded-message",Ee&&"reply-message",Ot&&"no-media-corners"),s=v&&!Ve&&!Ne&&!ke,n=!He&&!G&&Ve,l=(0,ie.Z)("text-content",n&&"with-meta",N&&"with-outgoing-icon");return o.ZP.createElement("div",{className:t,onDoubleClick:ct,dir:"auto"},function(){if(_e&&!Te||!(g&&!Oe&&!Fe||Ne||Te||w)||xe&&!y)return;let t,s;return!tt||_e&&Te?null!=Re&&Re.hiddenUserName&&(t=Re.hiddenUserName):(t=(0,d.OU)(oe,tt),Ne||(s=`color-${(0,d.Rs)(tt)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},t?o.ZP.createElement("span",{className:(0,ie.Z)("interactive",s),onClick:ht,dir:"auto"},(0,It.Z)(t)):S?void 0:" ",S&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},oe("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:mt},(0,It.Z)(`@${S.username}`))),null!=Re&&Re.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},oe("DiscussChannel")):e.adminTitle&&!$?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.adminTitle):void 0)}(),Ee&&o.ZP.createElement(ss,{message:R,sender:T,observeIntersection:a,onClick:gt}),De&&o.ZP.createElement(ls,{message:e,observeIntersection:a,observeIntersectionForPlaying:r,shouldLoop:z,lastSyncTime:D}),G&&o.ZP.createElement(us.Z,{size:"small",sticker:G,observeIntersection:a,lastSyncTime:D,forceLoadPreview:we}),Ae&&o.ZP.createElement(Gs,{album:i,albumLayout:Ut,observeIntersection:a,shouldAutoLoad:X,shouldAutoPlay:Y,isOwn:Me,hasCustomAppendix:s,lastSyncTime:D,onMediaClick:yt}),!Ae&&Oe&&o.ZP.createElement(vs,{message:e,observeIntersection:a,noAvatars:c,shouldAutoLoad:X,uploadProgress:B,shouldAffectAppendix:s,onClick:ft,onCancelUpload:Ct}),!Ae&&Fe&&Fe.isRound&&o.ZP.createElement(_s,{message:e,observeIntersection:a,shouldAutoLoad:X,shouldAutoPlay:Y,lastSyncTime:D}),!Ae&&Fe&&!Fe.isRound&&o.ZP.createElement(Ms,{message:e,observeIntersection:a,noAvatars:c,shouldAutoLoad:X,shouldAutoPlay:Y,uploadProgress:B,lastSyncTime:D,onClick:ft,onCancelUpload:Ct}),(Ue||$e)&&o.ZP.createElement(as.Z,{theme:C,message:e,uploadProgress:B,lastSyncTime:D,isSelectable:xe,isSelected:j,onPlay:vt,onReadMedia:!$e||Me&&!U?void 0:Pt,onCancelUpload:Ct}),Qe&&o.ZP.createElement(ns.Z,{message:e,observeIntersection:a,uploadProgress:B,isSelectable:xe,isSelected:j,onMediaClick:ft,onCancelUpload:Ct}),qe&&o.ZP.createElement(Es,{contact:qe}),Ge&&o.ZP.createElement(As,{message:e,poll:Ge,onSendVote:wt}),!G&&Ve&&o.ZP.createElement("p",{className:l,dir:"auto"},Ve,n&&o.ZP.createElement(rs,{message:e,outgoingStatus:N,signature:Ke,onClick:Zt})),He&&o.ZP.createElement(Fs,{message:e,observeIntersection:a,noAvatars:c,shouldAutoLoad:X,shouldAutoPlay:Y,lastSyncTime:D,onMediaClick:ft,onCancelMediaTransfer:Ct}),je&&o.ZP.createElement($s,{message:e}))}(),(!xe||Z)&&!(!He&&!G&&Ve)&&o.ZP.createElement(rs,{message:e,outgoingStatus:N,signature:Ke,onClick:Zt}),Ye&&ze?o.ZP.createElement(be.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:oe("lng_context_forward_msg"),onClick:Z?bt:Mt},o.ZP.createElement("i",{className:"icon-share-filled"})):Ye&&Je?o.ZP.createElement(be.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:K?St:Et},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Nt&&o.ZP.createElement(Ws,{message:e,disabled:f}),Bt&&o.ZP.createElement("div",{className:"svg-appendix",ref:ae})),e.inlineButtons&&o.ZP.createElement(Vs,{message:e,onClick:ee})),ce&&o.ZP.createElement(es,{isOpen:re,anchor:ce,message:e,album:i,chatUsername:t,messageListType:W,onClose:he,onCloseAnimationEnd:me}))}))),en=(0,o.X$)((({messageIds:e,messageGroups:t,isViewportNewest:s,isUnread:r,withUsers:i,noAvatars:c,containerRef:l,anchorIdRef:u,memoUnreadDividerBeforeIdRef:m,memoFirstUnreadIdRef:f,threadId:p,type:I,isActive:v,threadTopMessageId:y,hasLinkedChat:P,isSchedule:C,noAppearanceAnimation:w,onFabToggle:b,onNotchToggle:M,openHistoryCalendar:S})=>{const{observeIntersectionForMedia:E,observeIntersectionForReading:k,observeIntersectionForAnimatedStickers:R}=function(e,t,s){const{markMessageListRead:a,markMessagesRead:o}=(0,n.uC)(),{observe:r}=(0,Ft.S1)({rootRef:t,throttleMs:Ut,margin:$t}),{observe:i,freeze:c,unfreeze:d}=(0,Ft.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let n=0;const r=[];t.forEach((e=>{const{isIntersecting:t,target:s}=e;if(!t)return;const{dataset:a}=s,o=Number(a.lastMessageId||a.messageId);o>n&&(n=o),a.hasUnreadMention&&r.push(o)})),s.current&&n>=s.current&&a({maxId:n}),r.length&&o({messageIds:r})}));(0,le.Z)(c,d);const{observe:l}=(0,Ft.S1)({rootRef:t,throttleMs:Ut});return{observeIntersectionForMedia:r,observeIntersectionForReading:i,observeIntersectionForAnimatedStickers:l}}(I,l,f),{backwardsTriggerRef:T,forwardsTriggerRef:N,fabTriggerRef:B}=function(e,t,s,r,i,c,d,l){const{loadViewportMessages:u}=(0,n.uC)(),[m,g]=(0,o.Ye)((()=>"thread"===e?[(0,Z.Ds)((()=>u({direction:h.Uq.Backwards})),1e3,!0,!1),(0,Z.Ds)((()=>u({direction:h.Uq.Forwards})),1e3,!0,!1)]:[]),[u,s]),f=(0,o.sO)(null),p=(0,o.sO)(null),I=(0,o.sO)(null);function v(){if(!l)return;if(!s||!s.length)return c(!1),void d(!1);if(!r)return c(!0),void d(!0);const{offsetHeight:e,scrollHeight:n,scrollTop:a}=t.current,o=Math.round(n-a-e),u=o<=0;c(i?!u:!(o<=50)),d(!u)}const{observe:y}=(0,Ft.S1)({rootRef:t,margin:a.gZ},(e=>{if(!g||!m)return;if(s[0]>=a.AE)return;const n=e.find((({isIntersecting:e})=>e));if(!n)return;const{target:o}=n;"backwards-trigger"===o.className?((0,Lt.Z)(t.current),m()):"forwards-trigger"===o.className&&((0,Lt.Z)(t.current),g())}));(0,Ft._N)(f,y),(0,Ft._N)(p,y);const{observe:P,freeze:C,unfreeze:w}=(0,Ft.S1)({rootRef:t,margin:50},v);(0,Ft._N)(I,P);const{observe:b,freeze:M,unfreeze:S}=(0,Ft.S1)({rootRef:t},v);return(0,Ft._N)(I,b),(0,he.Z)((()=>{C(),M(),setTimeout((()=>{S(),w()}),100)}),[s]),{backwardsTriggerRef:f,forwardsTriggerRef:p,fabTriggerRef:I}}(I,l,e,s,r,b,M,v),x=(0,Ze.Z)(),A=o.ZP.createElement("div",{className:(0,ie.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,x("UnreadMessages"))),O=w?0:t.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let F=0;const U=t.map(((e,t,s)=>{const n=e.senderGroups.map(((e,n,a)=>{if(1===e.length&&!Bt(e[0])&&(0,d.Lo)(e[0])){const r=e[0],i=n===a.length-1&&t===s.length-1;return(0,g.oA)([r.id===m.current&&A,o.ZP.createElement(ts,{key:r.id,message:r,observeIntersection:k,appearanceOrder:O-++F,isLastInList:i})])}let r;return(0,g.xH)(e.map(((l,h)=>{const f=Bt(l)?l.mainMessage:l,v=Bt(l)?l:void 0,Z=(0,d.B4)(f),C=Bt(l),w=e[h+1];f.previousLocalId&&u.current===`message${f.previousLocalId}`&&(u.current=`message${f.id}`);const b=!C&&f.groupedId?f.groupedId:void 0,M=w&&!Bt(w)?w.groupedId:void 0,S={isFirstInGroup:0===h,isLastInGroup:h===e.length-1,isFirstInDocumentGroup:Boolean(b&&b!==r),isLastInDocumentGroup:Boolean(b&&b!==M),isLastInList:h===e.length-1&&n===a.length-1&&t===s.length-1};r=b;const T=(0,d.KK)(f),N="scheduled"!==I?T:`${f.date}_${T}`;return(0,g.oA)([f.id===m.current&&A,o.ZP.createElement(Js,{key:N,message:f,observeIntersectionForBottom:k,observeIntersectionForMedia:E,observeIntersectionForAnimatedStickers:R,album:v,noAvatars:c,withAvatar:S.isLastInGroup&&i&&!Z&&!(f.id===y),withSenderName:S.isFirstInGroup&&i&&!Z,threadId:p,messageListType:I,noComments:!1===P,appearanceOrder:O-++F,isFirstInGroup:S.isFirstInGroup,isLastInGroup:S.isLastInGroup,isFirstInDocumentGroup:S.isFirstInDocumentGroup,isLastInDocumentGroup:S.isLastInDocumentGroup,isLastInList:S.isLastInList}),f.id===y&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,x("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:At.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,ie.Z)("sticky-date",!C&&"interactive"),key:"date-header",onMouseDown:At.q,onClick:C?void 0:()=>S({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},C&&e.originalDate===a.t4&&x("MessageScheduledUntilOnline"),C&&e.originalDate!==a.t4&&x("MessageScheduledOn",(0,L.j1)(x,e.datetime,void 0,!0)),!C&&(0,L.j1)(x,e.datetime))),(0,g.xH)(n))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:T,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(U),o.ZP.createElement("div",{ref:N,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:B,key:"fab-trigger",className:"fab-trigger"}))}));var tn=s(3547);const sn=(0,o.X$)((0,n.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,n=null!=s&&s.length?s[t%s.length]:void 0,a=(0,i.Z1)(e,t);return a?{sticker:n,lastUnreadMessageId:a.lastMessage&&a.lastMessage.id!==a.lastReadInboxMessageId?a.lastMessage.id:void 0,connectionState:e.connectionState}:{}}),((e,t)=>(0,g.ei)(t,["loadGreetingStickers","sendMessage","markMessageListRead"])))((({sticker:e,connectionState:t,lastUnreadMessageId:s,loadGreetingStickers:n,sendMessage:a,markMessageListRead:r})=>{const i=(0,Ze.Z)(),c=(0,o.sO)(null),{observe:d}=(0,Ft.S1)({rootRef:c,debounceMs:200});(0,o.d4)((()=>{e||"connectionStateReady"!==t||n()}),[t,n,e]),(0,o.d4)((()=>{"connectionStateReady"===t&&s&&r({maxId:s})}),[t,r,s]);const l=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},a({sticker:e})}),[a]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:c},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},i("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},i("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},e&&o.ZP.createElement(tn.Z,{sticker:e,onClick:l,clickArg:e,observeIntersection:d,size:160,className:"large"}))))}))),nn=(0,o.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s})=>{const n=(0,Ze.Z)();return"scheduled"===t?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(n):e?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(n):s?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(n):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,n("NoMessages")))})),an=(0,Z.Ds)((e=>e()),200,!1),on=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,type:n})=>{const a=(0,i.Z1)(e,t);if(!a)return{};const o=(0,i.$W)(e,t,s,n),r="scheduled"===n?(0,i.Fn)(e,t):(0,i.Zw)(e,t),c=(0,i.qS)(e,t,s);if(s!==u._f&&!(r&&c&&r[c]))return{};const{isRestricted:l,restrictionReason:h,lastMessage:m}=a,g=(0,i.G$)(e,t),f=s===u._f&&!o&&!a.unreadCount&&!g&&m&&!m.groupedId,p=(0,i.IK)(e,t);let I;return(0,i.pk)(e,t)&&(I=p.fullInfo?p.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:l,restrictionReason:h,isChannelChat:(0,d.eA)(a),isGroupChat:(0,d.Bf)(a),isCreator:a.isCreator,isChatWithSelf:(0,i.FM)(e,t),isBot:Boolean(p),messageIds:o,messagesById:r,firstUnreadId:(0,i.It)(e,t,s),isViewportNewest:"thread"!==n||(0,i.b9)(e,t,s),threadFirstMessageId:(0,i.yZ)(e,t,s),focusingId:g,isSelectModeActive:(0,i.CA)(e),botDescription:I,threadTopMessageId:c,hasLinkedChat:a.fullInfo&&"linkedChatId"in a.fullInfo?Boolean(a.fullInfo.linkedChatId):void 0,...f&&{lastMessage:m}}}),((e,t)=>(0,g.ei)(t,["loadViewportMessages","setScrollOffset","openHistoryCalendar"])))((({chatId:e,threadId:t,type:s,hasTools:r,onFabToggle:c,onNotchToggle:l,isChatLoaded:u,isChannelChat:m,isGroupChat:f,canPost:p,isReady:I,isActive:v,isChatWithSelf:y,isCreator:P,isBot:C,messageIds:w,messagesById:b,firstUnreadId:M,isViewportNewest:S,threadFirstMessageId:E,isRestricted:k,restrictionReason:R,focusingId:T,isSelectModeActive:N,loadViewportMessages:B,setScrollOffset:x,lastMessage:A,botDescription:L,threadTopMessageId:O,hasLinkedChat:F,openHistoryCalendar:U})=>{var $,Q,D,q,G,H;const j=(0,o.sO)(null),_=(0,o.sO)("thread"===s&&(0,i.Vt)((0,n.Rd)(),e,t)||0),V=(0,o.sO)(),W=(0,o.sO)(),K=(0,o.sO)(),X=(0,o.sO)(),Y=(0,o.sO)(),z=(0,o.sO)(),J=(0,o.sO)(!1),ee=(0,o.sO)(Boolean(A)),[te,se]=(0,o.eJ)(),ne=Boolean(w);(0,he.Z)((()=>{ne&&(0,Z.R3)((()=>{ee.current=!1}))}),[ne]),(0,he.Z)((()=>{X.current=M}),[M]),(0,he.Z)((()=>{ne&&(Y.current=X.current)}),[ne]),(0,he.Z)((()=>{z.current=T}),[T]);const ae=(0,o.Ye)((()=>{if(!w||!b)return;const e=!O||w[0]&&E!==w[0]?w:[O,...w];if(!e.length)return;const t=e.map((e=>b[e])).filter(Boolean);return xt((0,g.Xo)(t,["date","id"]),Y.current)}),[w,b,E,O]),oe=(0,o.Ye)((()=>{if("thread"===s)return(0,Z.Ds)((()=>B({direction:h.Uq.Around})),1e3,!0,!1)}),[B,w]),{isScrolled:ce,updateStickyDates:de}=function(){const[e,t]=(0,ye.Z)(!1),s=(0,o.Ye)((()=>(0,Z.Ds)((e=>e()),1e3,!1,n)),[1e3,!1,n]);var n;return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,n)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,Z.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{(0,Z.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const s=function(e,t){const s=e.querySelectorAll(".sticky-date"),n=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:a}=e,o=s-n;return-a<=o&&o<=(t?60:10)}))}(e,n);s&&s.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,s])}}(),le=(0,o.I4)((()=>{if(J.current)return void(J.current=!1);const n=j.current;z.current||de(n,r),an((()=>{(0,Z.T2)((()=>{n.parentElement&&(_.current=n.scrollHeight-n.scrollTop,"thread"===s&&x({chatId:e,threadId:t,scrollOffset:_.current}))}))}))}),[de,r,s,x,e,t]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{e.target.offsetParent&&se(e.contentRect.height)}));return e.observe(j.current),()=>{e.disconnect()}}),[]);const{height:ue}=at();(0,o.d4)((()=>{I&&(j.current.dataset.normalHeight=String(j.current.offsetHeight))}),[ue,I,p]),(0,o.d4)((()=>{if(!oe||!u||k||T)return;if(w&&w[0]>=a.AE)return;const e=j.current;(!w||w.length<a.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&oe()}),[u,w,oe,T,k]),(0,he.Z)((()=>{if(!w||!K.current||!I)return;const e=K.current.filter((e=>w.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(V.current=t.id,W.current=t.getBoundingClientRect().top)}),[w,S,te,r,I]),(0,Tt.Z)((([e,t,s])=>{const n=j.current;if(K.current=Array.from(n.querySelectorAll(".message-list-item")),!n.offsetParent)return;const o=S&&w&&w.length<a.hT/2&&!n.parentElement.classList.contains("force-messages-scroll")&&n.firstElementChild.clientHeight<=2*n.offsetHeight;o&&(n.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{n.parentElement&&n.parentElement.classList.remove("force-messages-scroll")}),1e3));const i=w&&e&&w[w.length-1]!==e[e.length-1],c=(null==w?void 0:w[0])!==(null==e?void 0:e[0])&&(null==w?void 0:w.length)===a.hT/2+1,d=i&&!c,l=w&&z.current===w[w.length-1],{scrollTop:u,scrollHeight:h,offsetHeight:m}=n,g=_.current,f=K.current[K.current.length-1];let p=g-(s||m);d&&(p-=f?f.offsetHeight:0);const I=S&&t&&p<=20;let v;if(d&&I&&!l&&(f&&(0,Z.T2)((()=>{(0,Ot.Z)(n,f,"end",20)})),v=h-m,_.current=Math.max(h-v,m),!o))return;const y=void 0!==s&&s!==te,P=V.current&&n.querySelector(`#${V.current}`),C=!P&&Y.current&&n.querySelector(".unread-divider");if(I&&y){if((0,Ot.N)())return;v=h-m}else v=P?u+(P.getBoundingClientRect().top-(W.current||0)):C?Math.min(C.offsetTop-(r?60:10),h-g):h-g;(0,Lt.Z)(n,v),z.current||(J.current=!0,(0,Z.T2)((()=>{J.current=!1}))),_.current=Math.max(h-v,m)}),[w,S,te,r]),(0,Nt.Z)((([e])=>{void 0!==e&&(0,re.YW)(200+a.fK)}),[N]);const me=(0,Ze.Z)(),ge=Boolean(e&&(0,d.YA)(e)),fe=Boolean(!ge&&!m||y),pe=Boolean(!fe||m),Ie=(0,d.YA)(e)&&!y&&!C&&(!ae&&!A&&w&&(!K.current||0===K.current.length)||1===(null==w?void 0:w.length)&&"contactSignUp"===(null==b||null===($=b[w[0]])||void 0===$||null===(Q=$.content.action)||void 0===Q?void 0:Q.type)||"contactSignUp"===(null==A||null===(D=A.content)||void 0===D||null===(q=D.action)||void 0===q?void 0:q.type)),ve=f&&P&&1===(null==w?void 0:w.length)&&"chatCreate"===(null==b||null===(G=b[w[0]])||void 0===G||null===(H=G.content.action)||void 0===H?void 0:H.type),Pe=(0,ie.Z)("MessageList custom-scroll",pe&&"no-avatars",!p&&"no-composer","pinned"===s&&"type-pinned",N&&"select-mode-active",ce&&"scrolled",!I&&"is-animating");return o.ZP.createElement("div",{ref:j,className:Pe,onScroll:le,onMouseDown:At.q},k?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,R?R.text:"This is a private "+(m?"channel":"chat"))):L?o.ZP.createElement("div",{className:"empty rich"},o.ZP.createElement("span",null,(0,It.Z)(me(L),["br","emoji","links"]))):Ie?o.ZP.createElement(sn,{userId:e}):!w||ae&&!ve?w&&ae||A?o.ZP.createElement(en,{messageIds:w||[A.id],messageGroups:ae||xt([A]),isViewportNewest:Boolean(S),isUnread:Boolean(M),withUsers:fe,noAvatars:pe,containerRef:j,anchorIdRef:V,memoUnreadDividerBeforeIdRef:Y,memoFirstUnreadIdRef:X,threadId:t,type:s,isActive:v,threadTopMessageId:O,hasLinkedChat:F,isSchedule:!!ae&&"scheduled"===s,noAppearanceAnimation:!ae||!ee.current,onFabToggle:c,onNotchToggle:l,openHistoryCalendar:U}):o.ZP.createElement(Ue.Z,{color:"white"}):o.ZP.createElement(nn,{chatId:e,type:s,isChatWithSelf:y,isGroupChatJustCreated:ve}))}))),rn=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Bt)(e);if(!t)return{};const{chatId:s,threadId:n,type:a}=t,o=(0,i.Z1)(e,s);return{messageListType:a,unreadCount:o&&n===u._f&&"thread"===a?o.unreadCount:void 0}}),((e,t)=>(0,g.ei)(t,["focusNextReply"])))((({isShown:e,canPost:t,messageListType:s,unreadCount:n,focusNextReply:a})=>{const r=(0,Ze.Z)(),i=(0,o.sO)(null),c=(0,o.I4)((()=>{if(e)if("thread"===s)a();else{const e=i.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,Ot.Z)(e,s,"end",20)}}),[e,s,a]),d=(0,ie.Z)("ScrollDownButton",e&&"revealed",!t&&"no-composer");return o.ZP.createElement("div",{ref:i,className:d},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(be.Z,{color:"secondary",round:!0,onClick:c,ariaLabel:r("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(n)&&o.ZP.createElement("div",{className:"unread-count"},(0,ut.bi)(n))))})));var cn=s(5723),dn=s(6980);const ln=1280;async function un(e,t,s,n){const a=URL.createObjectURL(t),{type:o,size:r}=t;let i,c;if(o.startsWith("image/"))if(s){const s=await(0,st.pt)(a),{width:r,height:c}=s;if(r>ln||c>ln||"image/jpeg"!==o){const o=await function(e){return new Promise((t=>{const s=document.createElement("canvas"),n=s.getContext("2d");let{width:a,height:o}=e;(a>ln||o>ln)&&(a>=o?(o*=ln/a,a=ln):(a*=ln/o,o=ln)),s.width=a,s.height=o,n.drawImage(e,0,0,e.width,e.height,0,0,a,o),s.toBlob(t,"image/jpeg",100)}))}(s);return o?(URL.revokeObjectURL(a),un(e,o,!0,n)):un(e,t,!1,n)}i={width:r,height:c}}else c=a;else if(o.startsWith("video/")){if(r<10485760){const{videoWidth:e,videoHeight:t,duration:s}=await(0,st.jj)(a);i={width:e,height:t,duration:s}}c=await(0,st.ud)(a)}return{blobUrl:a,filename:e,mimeType:o,size:r,quick:i,previewBlobUrl:c,...n}}var hn=s(6391);let mn;function gn(e){mn.focus(),e.focus()}m.cj&&(mn=document.createElement("input"),mn.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(mn));const fn={encoderPath:s.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},pn={type:"audio/ogg"};let In,vn,yn;async function Zn(){return In||(In=s.e(161).then(s.t.bind(s,1161,23)),vn=(await In).default,yn=new vn(fn)),In}async function Pn(e){await async function(){await Zn(),await yn.start()}();const t=Date.now();let s;const n=[],a=[];yn.ondataavailable=e=>{n.push(e)};const o=function(t,s){const n=t.sourceNode,o=n.context.createAnalyser();o.fftSize=64,n.connect(o);const r=o.frequencyBinCount,i=new Uint8Array(r);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(i);const s=i.reduce(((e,t)=>e+t),0)/r/255;(t=>{a.push(255*t),e(t)})(s<.1?0:s),requestAnimationFrame(t)}(),()=>{c=!0}}(yn);return{stop:()=>new Promise(((e,r)=>{yn.onstop=()=>{e({blob:new Blob(n,pn),duration:Math.round(((s||Date.now())-t)/1e3),waveform:a})},yn.onerror=r;const i=Math.max(0,t+1e3-Date.now());setTimeout((()=>{yn.stop(),o()}),i)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{yn.pause(),s=Date.now(),o()}),e)}}}const Cn=["image/png","image/jpeg","image/gif"];function wn(e){const{text:t,entities:s}=e||{};if(!t)return"";const n=(0,Dt.H)(t,s,void 0,void 0,!0);return Array.isArray(n)?n.join(""):n}let bn,Mn;var Sn=s(4784),En=s(8353),kn=s(2365);const Rn=document.createElement("div"),Tn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Nn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i;const Bn=(0,Z.P2)((e=>e()),500,!0),xn=/[\w\d_-]*/i,An=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"DeleteMessageModal",!t);return s?o.ZP.createElement(s,e):void 0}));function Ln(){return(Ln=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}let On,Fn=!0;const Un=(0,o.X$)((({onActivate:e,...t})=>{const s=(0,o.sO)(!1),n=(0,o.I4)((()=>{if(s.current=!0,Fn)return Fn=!1,void e();On&&(clearTimeout(On),On=void 0),On=window.setTimeout((()=>{s.current&&e()}),200)}),[e]),a=(0,o.I4)((()=>{s.current=!1}),[]);return o.ZP.createElement(be.Z,Ln({},t,{onMouseEnter:m.$b?void 0:n,onMouseLeave:m.$b?void 0:a,onClick:m.$b?e:void 0}))})),$n=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"AttachMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Qn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"SymbolMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Dn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"InlineBotTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),qn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"MentionTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),Gn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"CustomSendMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Hn=e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"StickerTooltip",!t);return s?o.ZP.createElement(s,e):void 0};var jn=s(9830);const _n=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"BotCommandTooltip",!t);return s?o.ZP.createElement(s,e):void 0}));var Vn=s(6503);const Wn=(0,o.X$)((0,n.c$)(((e,{messageId:t})=>{const{chatId:s}=(0,i.Bt)(e)||{};return s?{message:(0,i.hj)(e,s,t)}:{}}),((e,t)=>(0,g.ei)(t,["clickInlineButton"])))((({isOpen:e,message:t,onClose:s,clickInlineButton:n})=>{const[a,r]=(0,Vn.Z)(e,s),{isKeyboardSingleUse:i}=t||{},[c,d,l]=(0,ye.Z)(!0),u=()=>{l(),s()};if((0,o.d4)((()=>{d()}),[d,t]),t&&t.keyboardButtons)return o.ZP.createElement(De.Z,{isOpen:e||c,autoClose:i,positionX:"right",positionY:"bottom",onClose:u,className:"BotKeyboardMenu",onCloseAnimationEnd:u,onMouseEnter:m.$b?void 0:a,onMouseLeave:m.$b?void 0:r},o.ZP.createElement("div",{className:"content"},t.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(be.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>n({button:e})},e.text))))))))})));var Kn=s(3616),Xn=s(7891);const Yn=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s,type:n}=(0,i.Bt)(e)||{};if(!t||!s||!n)return{};const{currentUserId:a,forwardMessages:{fromChatId:o,toChatId:r,messageIds:c}}=e,l=(0,i.Yy)(e,t,s),u="scheduled"===n?(0,i.wU)(e,t):(0,i._$)(e,t,s),h=e.settings.byKey.animationLevel>=1,m=r===t;let g,f;if(l?g=(0,i.hj)(e,t,l):u?g=(0,i.kK)(e,t,s,n):m&&1===c.length&&(g=(0,i.hj)(e,o,c[0])),l&&g){const{forwardInfo:s}=g,n=t===a;s&&(s.isChannelPost||n)&&(f=(0,i.cv)(e,g)),f||(f=(0,i.Ur)(e,g))}else m&&(f=(0,d.YA)(o)?(0,i.dy)(e,o):(0,i.Z1)(e,o));return{replyingToId:l,editingId:u,message:g,sender:f,shouldAnimate:h,forwardedMessagesCount:m?c.length:void 0}}),((e,t)=>(0,g.ei)(t,["setReplyingToId","setEditingId","focusMessage","exitForwardMode"])))((({replyingToId:e,editingId:t,message:s,sender:n,shouldAnimate:a,forwardedMessagesCount:r,setReplyingToId:i,setEditingId:c,focusMessage:d,exitForwardMode:l})=>{const u=Boolean((e||t)&&s||n&&r),h=(0,Xn.Z)([r],r?300:void 0),{shouldRender:m,transitionClassNames:g}=(0,de.Z)(h&&u,void 0,!a,void 0,!a),f=(0,o.I4)((()=>{e?i({messageId:void 0}):t?c({messageId:void 0}):r&&l()}),[e,t,r,i,c,l]);(0,o.d4)((()=>u?(0,fe.Z)(f):void 0),[u,f]);const p=(0,o.I4)((()=>{d({chatId:s.chatId,messageId:s.id})}),[d,s]),I=(0,ie.Z)("ComposerEmbeddedMessage",g),v=r&&r>1?`${r} forwarded messages`:void 0;if(m)return o.ZP.createElement("div",{className:I},o.ZP.createElement("div",null,o.ZP.createElement(be.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(ss,{className:"inside-input",message:s,sender:n,customText:v,title:t?"Edit Message":void 0,onClick:p})))}))),zn=(0,o.X$)((e=>{const{attachments:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"AttachmentModal",!t.length);return s?o.ZP.createElement(s,e):void 0})),Jn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"BotCommandMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ea=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"PollModal",!t);return s?o.ZP.createElement(s,e):void 0})),ta=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"DropArea",!t);return s?o.ZP.createElement(s,e):void 0})),sa=new RegExp(a.FM,"i"),na=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s})=>{const n=(0,i.tV)(e,t,s);return{webPagePreview:e.webPagePreview,noWebPage:n}}),((e,t)=>(0,g.ei)(t,["loadWebPagePreview","clearWebPagePreview","toggleMessageWebPage"])))((({chatId:e,threadId:t,messageText:s,disabled:n,webPagePreview:a,noWebPage:r,loadWebPagePreview:i,clearWebPagePreview:c,toggleMessageWebPage:d})=>{const l=(0,o.Ye)((()=>{const{text:e,entities:t}=(0,dn.Z)(s),n=t&&t.find((({type:e})=>e===u.Vv.TextUrl));if(n)return n.url;const a=e.match(sa);return a?a[0]:void 0}),[s]);(0,o.d4)((()=>{l?i({text:l}):(c(),d({chatId:e,threadId:t}))}),[e,d,c,l,i,t]),(0,he.Z)((()=>{c(),d({chatId:e,threadId:t})}),[e]);const h=Boolean(a&&s.length&&!r&&!n),{shouldRender:m,transitionClassNames:g}=(0,de.Z)(h),f=(0,lt.Z)(a);if(!m||!f)return;const{photo:p,...I}=f,v={content:{webPage:I}};return o.ZP.createElement("div",{className:(0,ie.Z)("WebPagePreview",g)},o.ZP.createElement("div",null,o.ZP.createElement(be.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{d({chatId:e,threadId:t,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Fs,{message:v,inPreview:!0})))})));var aa=s(2898);const oa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"CalendarModal",!t);return s?o.ZP.createElement(s,e):void 0})),ra=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0})),ia=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0}));var ca;!function(e){e.Send="send",e.Record="record",e.Edit="edit"}(ca||(ca={}));const da=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{var o,r;const c=(0,i.Z1)(e,t),l=c&&(0,i.Dg)(e,c),h=t!==a.FV?(0,i.IK)(e,t):void 0,m=Boolean(h),g=(0,i.FM)(e,t),f=m&&(0,i.FT)(e,t),p=(0,i.qy)(e,t),{language:I}=e.settings.byKey,v=e.emojiKeywords[a.pR],y=I!==a.pR?e.emojiKeywords[I]:void 0,Z=f?f.id:void 0,P=Z?(0,i.hj)(e,t,Z):void 0;return{editingMessage:(0,i.kK)(e,t,s,n),connectionState:e.connectionState,draft:(0,i.Ms)(e,t,s),chat:c,isChatWithBot:m,isChatWithSelf:g,canScheduleUntilOnline:!g&&!m&&c&&l&&(0,d.YA)(t)&&l.status&&Boolean(l.status.wasOnline),isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),withScheduledButton:s===u._f&&"thread"===n&&Boolean(null==p?void 0:p.length),shouldSchedule:"scheduled"===n,botKeyboardMessageId:Z,botKeyboardPlaceholder:null==P?void 0:P.keyboardPlaceholder,isForwarding:t===e.forwardMessages.toChatId,isPollModalOpen:e.isPollModalOpen,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==c||null===(o=c.fullInfo)||void 0===o?void 0:o.members,topInlineBotIds:null===(r=e.topInlineBots)||void 0===r?void 0:r.userIds,currentUserId:e.currentUserId,usersById:e.users.byId,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),shouldSuggestStickers:e.settings.byKey.shouldSuggestStickers,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==v?void 0:v.keywords,emojiKeywords:null==y?void 0:y.keywords,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:c&&c.fullInfo&&c.fullInfo.botCommands,botCommands:h&&h.fullInfo?h.fullInfo.botCommands||!1:void 0}}),((e,t)=>(0,g.ei)(t,["sendMessage","editMessage","saveDraft","clearDraft","showDialog","setStickerSearchQuery","setGifSearchQuery","forwardMessages","openPollModal","closePollModal","closePaymentModal","clearReceipt","loadScheduledHistory","openChat","addRecentEmoji","sendInlineBotResult"])))((({dropAreaState:e,shouldSchedule:t,canScheduleUntilOnline:s,isReady:r,onDropHide:i,editingMessage:c,chatId:l,threadId:h,messageListType:g,draft:f,chat:p,connectionState:I,isChatWithBot:v,isChatWithSelf:y,isRightColumnShown:P,isSelectModeActive:C,isForwarding:w,isPollModalOpen:b,isPaymentModalOpen:M,isReceiptModalOpen:S,botKeyboardMessageId:E,botKeyboardPlaceholder:k,withScheduledButton:R,stickersForEmoji:T,groupChatMembers:N,topInlineBotIds:B,currentUserId:x,usersById:A,lastSyncTime:O,contentToBeScheduled:F,shouldSuggestStickers:U,baseEmojiKeywords:$,emojiKeywords:Q,serverTimeOffset:q,recentEmojis:G,inlineBots:H,isInlineBotLoading:j,botCommands:_,chatBotCommands:V,sendMessage:W,editMessage:K,saveDraft:X,clearDraft:Y,showDialog:z,setStickerSearchQuery:J,setGifSearchQuery:ee,forwardMessages:te,openPollModal:se,closePollModal:ne,loadScheduledHistory:ae,closePaymentModal:oe,openChat:re,clearReceipt:ce,addRecentEmoji:de,sendInlineBotResult:he})=>{const me=(0,Ze.Z)(),ge=(0,o.sO)(null),[pe,Ie]=(0,o.eJ)(""),ve=(0,o.sO)(),Pe=(0,fs.Z)(e),[Ce,we,Me]=(0,ye.Z)(),[Se,Ee]=(0,o.eJ)(),{width:ke}=nt.Z.get(),Re=(0,o.sO)(pe);(0,o.d4)((()=>{Re.current=pe}),[pe]),(0,o.d4)((()=>{ve.current=void 0}),[l]),(0,o.d4)((()=>{l&&O&&h===u._f&&r&&ae()}),[r,l,ae,O,h]),(0,o.bt)((()=>{ge.current&&(ge.current.innerHTML='<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><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"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="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" fill="#000" filter="url(#a)"/><path d="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" fill="#FFF" class="corner"/></g></svg>')}),[]),(0,o.d4)((()=>{F&&(Ee(F),we())}),[F,we]);const[Ne,Be]=(0,o.eJ)([]),[xe,Ae,Le]=(0,ye.Z)(),[Oe,Fe,Ue]=(0,ye.Z)(),[$e,Qe,De]=(0,ye.Z)(),[qe,Ge,He]=(0,ye.Z)(),[je,_e,Ve]=(0,ye.Z)(),[We,Ke]=(0,ye.Z)(),[Xe,Ye,ze]=(0,ye.Z)(),{startRecordingVoice:Je,stopRecordingVoice:tt,pauseRecordingVoice:st,activeVoiceRecording:at,currentRecordTime:ot,recordButtonRef:rt,startRecordTimeRef:it}=(()=>{const e=(0,o.sO)(null),[t,s]=(0,o.eJ)(),n=(0,o.sO)(),[a,r]=(0,o.eJ)();(0,o.d4)((()=>{m.cj&&m.mh&&Zn()}),[]);const i=(0,o.I4)((async()=>{try{const{stop:t,pause:a}=await Pn((t=>{e.current&&(n.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),r(Date.now()))}));n.current=Date.now(),r(Date.now()),s({stop:t,pause:a})}catch(e){console.error(e)}}),[]),c=(0,o.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),d=(0,o.I4)((()=>{if(t){s(void 0),n.current=void 0,r(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,fe.Z)(d):void 0),[t,d]),{startRecordingVoice:i,pauseRecordingVoice:c,stopRecordingVoice:d,activeVoiceRecording:t,currentRecordTime:a,recordButtonRef:e,startRecordTimeRef:n}})(),ct=c?ca.Edit:!m.mh||at||pe&&!Ne.length||w?ca.Send:ca.Record,dt=!t,{isMentionTooltipOpen:lt,closeMentionTooltip:ut,insertMention:ht,mentionFilteredUsers:mt}=(0,kn.Z)(!Ne.length,pe,Ie,void 0,N,B,x,A),{isOpen:gt,id:ft,isGallery:pt,switchPm:vt,results:yt,closeTooltip:Zt,help:Pt,loadMore:Ct}=function(e,t,s,a){const[r,i,c]=(0,ye.Z)(),d=function(e){return Rn.innerHTML=e.replace(/<br>/g,"\n"),Rn.innerText}(s),{queryInlineBot:l,resetInlineBot:u}=(0,n.uC)(),{username:h,query:m,canShowHelp:g}=function(e){const t=e.match(Tn);return t?{username:t[1],query:t[2],canShowHelp:""===t[2]&&!e.match(Nn)}:{username:"",query:"",canShowHelp:!1}}(d),f=h.toLowerCase(),p=(0,fs.Z)(m),I=(0,fs.Z)(h),v=null==a?void 0:a[f],{id:y,switchPm:Z,offset:P,results:C,isGallery:w,help:b}=v||{};(0,o.d4)((()=>{p!==m&&c()}),[p,m,c]),(0,o.d4)((()=>{e&&f&&t&&l({chatId:t,username:f,query:m})}),[m,e,l,t,f]);const M=(0,o.I4)((()=>{l({chatId:t,username:f,query:m,offset:P})}),[P,t,m,l,f]);return(0,o.d4)((()=>{e&&y&&(Z||null!=C&&C.length)?i():c()}),[y,e,i,C,Z,c]),I!==h&&u({username:I}),{isOpen:r,closeTooltip:c,loadMore:M,username:h,id:y,isGallery:w,switchPm:Z,results:C,help:g&&b?`@${h} ${b}`:void 0}}(Boolean(!Ne.length&&O),l,pe,H),{isOpen:wt,close:bt,filteredBotCommands:Mt}=function(e,t,s,n){const[a,r,i]=(0,ye.Z)(),[c,d]=(0,o.eJ)(),l=(0,o.I4)((e=>{s||n?Bn((()=>{const t=(s||n||[]).filter((({command:t})=>!e||t.includes(e)));d(t&&t.length?t:void 0)})):d(void 0)}),[s,n]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=t.substr(1).match(xn);l(e?e[0]:"")}else i();else i()}),[l,t,e,i]),(0,o.d4)((()=>{c&&c.length?r():i()}),[c,r,i]),{isOpen:a,close:i,filteredBotCommands:c}}(Boolean(_&&_.length||V&&V.length),pe,_,V),{isContextMenuOpen:St,handleContextMenu:Et,handleContextMenuClose:kt,handleContextMenuHide:Rt}=(0,Qt.Z)(rt,!(ct===ca.Send&&dt)),Tt=(0,o.Ye)((()=>(0,d.H5)(p,v)),[p,v]),Nt=p&&(0,d.Nl)(p),Bt=(0,d.Hd)(p),{isStickerTooltipOpen:xt,closeStickerTooltip:At}=function(e,t,s,a=!1){const{loadStickersForEmoji:r,clearStickersForEmoji:i}=(0,n.uC)(),c=m.op&&1===(0,Sn.Z)(t)||!m.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),d=Boolean(s)&&c;return(0,o.d4)((()=>{a||(e&&c?r({emoji:t}):!d&&c||i())}),[t,c,i,r,e,a]),{isStickerTooltipOpen:d,closeStickerTooltip:i}}(Boolean(U&&Tt.canSendStickers&&!Ne.length),pe,T,!r),{isEmojiTooltipOpen:Lt,closeEmojiTooltip:Ot,filteredEmojis:Ft,insertEmoji:Ut}=(0,En.Z)(Boolean(U&&Tt.canSendStickers&&!Ne.length),pe,G,void 0,Ie,$,Q,!r),$t=(0,o.I4)(((e,t=a.R2)=>{const s=window.getSelection(),n=document.getElementById(t),o=(0,It.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(s.rangeCount){const e=s.getRangeAt(0);if((0,hn.R)(e,t))return function(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const s=t.getRangeAt(0);s.deleteContents();const n=s.createContextualFragment(e),a=n.lastChild;s.insertNode(n),a?(s.setStartAfter(a),s.setEndAfter(a)):s.collapse(!1),t.removeAllRanges(),t.addRange(s)}}(o),void n.dispatchEvent(new Event("input",{bubbles:!0}))}Ie(`${Re.current}${o}`),requestAnimationFrame((()=>{(0,cn.Z)(n)}))}),[]),Dt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,hn.R)(t,a.R2))return void document.execCommand("delete",!1)}Ie(function(e){const t=document.createElement("div");t.contentEditable="true",t.style.position="absolute",t.style.left="-10000px",t.style.top="-10000px",t.innerHTML=e,document.body.appendChild(t);let s=t.lastChild;if(s.lastChild)for(;s.lastChild;)s=s.lastChild;const n=s.textContent.length,a=document.createRange(),o=window.getSelection();a.setStart(s,n),a.setEnd(s,n),o.removeAllRanges(),o.addRange(a),document.execCommand("delete",!1);const r=t.innerHTML;return document.body.removeChild(t),r}(Re.current))}),[]),qt=(0,o.I4)(((e=!1)=>{e||Ie(""),Be([]),At(),Me(),Ee(void 0),ut(),Ot(),m.wB?setTimeout((()=>He()),350):He()}),[At,Me,ut,Ot,He]),Gt=(0,o.sO)();Gt.current=tt,(0,o.d4)((()=>()=>{Gt.current(),qt()}),[l,qt,Gt]);const Ht=((e,t,s,n,r,i)=>((0,o.d4)((()=>{s?(t(wn(s.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,cn.Z)(e,!0)}))):t("")}),[s,t]),(0,o.I4)((()=>{const{text:t,entities:a}=(0,dn.Z)(e.current);s&&(t||(0,d.u8)(s)?(i({messageId:s.id,text:t,entities:a}),n()):r())}),[i,s,e,r,n])))(Re,Ie,c,qt,_e,K);((e,t,s,n,r,i,c,d,l)=>{const u=(0,o.I4)(((e,t)=>{r.current.length&&!c?d({chatId:e,threadId:t,draft:(0,dn.Z)(r.current)}):l({chatId:e,threadId:t})}),[l,c,r,d]),h=(0,o.Ye)((()=>(0,Z.Ds)((e=>e()),a.r_,!1)),[t]),g=(0,fs.Z)(t),f=(0,fs.Z)(s);(0,o.d4)((()=>(bn=t,Mn=s,()=>{bn=void 0,Mn=void 0,u(t,s)})),[t,s,u]),(0,o.d4)((()=>{t===g&&s===f||e&&(i(wn(e)),m.$b||requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,cn.Z)(e,!0)})))}),[t,s,e,i,u,g,f]);const p=(0,fs.Z)(n);(0,o.d4)((()=>{t&&s&&g===t&&f===s&&p!==n&&(n.length?h((()=>{bn===t&&Mn===s&&u(t,s)})):u(t,s))}),[t,n,g,p,f,h,s,u]);const I=(0,o.I4)((()=>{t&&s&&u(t,s)}),[t,s,u]);(0,le.Z)(I),ue(I)})(f,l,h,pe,Re,Ie,c,X,Y),((e,t,s)=>{(0,o.d4)((()=>{async function n(n){if(!n.clipboardData)return;const o=document.activeElement;if(o&&![a.R2,a.nY].includes(o.id))return;const{items:r}=n.clipboardData,i=Array.from(r).find((e=>Cn.includes(e.type))),c=i&&i.getAsFile(),d=n.clipboardData.getData("text").substring(0,4096);if(c||d){if(n.preventDefault(),c&&!s){const e=await un(c.name,c,!0);t((t=>[...t,e]))}d&&e(d,null==o?void 0:o.id)}}return document.addEventListener("paste",n,!1),()=>{document.removeEventListener("paste",n,!1)}}),[e,s,t])})($t,Be,c);const jt=(0,o.I4)((async(e,t)=>{Be(await Promise.all(e.map((e=>un(e.name,e,t)))))}),[]),_t=(0,o.I4)((async(e,t)=>{Be([...Ne,...await Promise.all(e.map((e=>un(e.name,e,t))))])}),[Ne]),Vt=(0,o.I4)((()=>{Be([])}),[]),Wt=(0,o.I4)((async(e=!1,t)=>{if("connectionStateReady"!==I)return;let s=Ne;if(at){const e=await tt();if(e){const{blob:t,duration:n,waveform:a}=e;s=[await un("wonderful-voice-message.ogg",t,!1,{voice:{duration:n,waveform:a}})]}}const{text:n,entities:o}=(0,dn.Z)(Re.current);if(!s.length&&!n&&!w)return;const r=s.length?1024:4096;if((null==n?void 0:n.length)>r){const e=n.length-r;return void z({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const i=document.getElementById(a.R2);if(s.length||n){if(Bt&&!Nt){const e=(0,D.b)(q),t=ve.current&&Math.floor(e-ve.current),s=Bt.nextSendDate&&Bt.nextSendDate>e;if(t&&t<Bt.seconds||s){const n=s?Bt.nextSendDate-e:Bt.seconds-t;return z({data:{message:me("SlowModeHint",(0,L.k9)(n)),isSlowMode:!0,hasErrorKey:!1}}),void i.blur()}}W({text:n,entities:o,attachments:s,scheduledAt:t,isSilent:e})}w&&te(),ve.current=(0,D.b)(q),Y({chatId:l,localOnly:!0}),m.cj&&i===document.activeElement&&gn(i),requestAnimationFrame((()=>{qt()}))}),[I,Ne,at,w,Y,l,q,qt,tt,z,Bt,Nt,W,te,me]),Kt=(0,o.I4)((()=>{He(),Fe()}),[He,Fe]),Xt=(0,o.I4)((()=>{Ue(),Ge()}),[Ue,Ge]),Yt=(0,o.I4)(((e,s=!1)=>{e={...e,isPreloadedGlobally:!0},t?(Ee({sticker:e}),we()):(W({sticker:e}),requestAnimationFrame((()=>{qt(s)})))}),[t,we,W,qt]),zt=(0,o.I4)((e=>{t?(Ee({gif:e}),we()):(W({gif:e}),requestAnimationFrame((()=>{qt(!0)})))}),[t,we,W,qt]),Jt=(0,o.I4)((e=>{if("connectionStateReady"!==I)return;he({id:e.id,queryId:e.queryId});const t=document.getElementById(a.R2);m.cj&&t===document.activeElement&&gn(t),Y({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{qt()}))}),[l,Y,I,qt,he]),es=(0,o.I4)((()=>{Y({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{qt()}))}),[l,Y,qt]),ts=(0,o.I4)((e=>{t?(Ee({poll:e}),ne(),we()):(W({poll:e}),ne())}),[ne,we,W,t]),ss=(0,o.I4)((()=>{t?(Ee({isSilent:!0}),we()):Wt(!0)}),[Wt,we,t]),ns=(0,o.I4)(((e,t=!1)=>{const{isSilent:s,...n}=Se||{},a=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:q);Se&&0!==Object.keys(n).length?(W({...Se,scheduledAt:a}),requestAnimationFrame((()=>{qt()}))):Wt(!!s,a),Me()}),[Me,Wt,qt,Se,W,q]),as=(0,o.I4)((()=>{ns(new Date(1e3*a.t4),!0)}),[ns]),os=(0,o.I4)((()=>{Me(),Ee(void 0)}),[Me]),rs=(0,o.I4)((e=>{"stickers"===e?(J({query:""}),ee({query:void 0})):(ee({query:""}),J({query:void 0}))}),[J,ee]),is=(0,o.I4)((()=>{const e=document.getElementById(a.R2);m.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Ue(),Ge()}),100)):Ge()}),[Ge,Ue]),cs=(0,o.I4)((()=>{re({id:l,threadId:h,type:"scheduled"})}),[re,l,h]);(0,o.d4)((()=>{P&&m.wB&&He()}),[P,He]),(0,o.d4)((()=>{r&&(C?Ye():setTimeout((()=>{ze()}),200))}),[C,ze,Ye,r]);const ds=(0,o.I4)((()=>{switch(ct){case ca.Send:t?(at&&st(),we()):Wt();break;case ca.Record:Je();break;case ca.Edit:Ht()}}),[ct,t,Je,Ht,at,we,st,Wt]),ls=ct===ca.Record&&!Tt.canAttachMedia,us=(0,fs.Z)(c,!0),hs=c||us,ms=new Date;ms.setSeconds(0),ms.setMilliseconds(0);const gs=new Date;gs.setFullYear(gs.getFullYear()+1);let ps="SendMessage";switch(ct){case ca.Edit:ps="Save edited message";break;case ca.Record:ps=ls?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const Is=(0,ie.Z)("Composer",!C&&"shown",Xe&&"hover-disabled"),vs=(0,ie.Z)("mobile-symbol-menu-button",!r&&"not-ready",We?qe&&"menu-opened":qe&&"is-loading"),ys=ct===ca.Edit?Ht:t?we:Wt;return o.ZP.createElement("div",{className:Is},Tt.canAttachMedia&&r&&o.ZP.createElement(aa.Z,{containerId:"#middle-column-portals"},o.ZP.createElement(ta,{isOpen:e!==et.t.None,withQuick:[e,Pe].includes(et.t.QuickFile),onHide:i,onFileSelect:jt})),o.ZP.createElement(zn,{attachments:Ne,caption:Ne.length?pe:"",groupChatMembers:N,currentUserId:x,usersById:A,recentEmojis:G,isReady:r,onCaptionUpdate:Ie,baseEmojiKeywords:$,emojiKeywords:Q,addRecentEmoji:de,onSend:t?we:Wt,onFileAppend:_t,onClear:Vt}),o.ZP.createElement(ea,{isOpen:Boolean(b),onClear:ne,onSend:ts}),o.ZP.createElement(ra,{isOpen:Boolean(M),onClose:oe}),o.ZP.createElement(ia,{isOpen:Boolean(S),onClose:ce}),hs&&o.ZP.createElement(An,{isOpen:je,isSchedule:"scheduled"===g,onClose:Ve,message:hs}),o.ZP.createElement(qn,{isOpen:lt,onClose:ut,onInsertUserName:ht,filteredUsers:mt,usersById:A}),o.ZP.createElement(Dn,{isOpen:gt,botId:ft,allowedAttachmentOptions:Tt,isGallery:pt,inlineBotResults:yt,switchPm:vt,onSelectResult:Jt,loadMore:Ct,onClose:Zt}),o.ZP.createElement(_n,{isOpen:wt,withUsername:Boolean(V),botCommands:Mt,onClick:es,onClose:bt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:ge}),o.ZP.createElement(Yn,null),o.ZP.createElement(na,{chatId:l,threadId:h,messageText:Ne.length?"":pe,disabled:!Tt.canAttachEmbedLinks}),o.ZP.createElement("div",{className:"message-input-wrapper"},v&&!1!==_&&!at&&!c&&o.ZP.createElement(Un,{className:(0,ie.Z)("bot-commands",Oe&&"activated"),round:!0,faded:!0,disabled:void 0===_,color:"translucent",onActivate:Kt,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),m.wB?o.ZP.createElement(be.Z,{className:vs,round:!0,faded:!0,color:"translucent",onClick:qe?He:is,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),qe&&!We&&o.ZP.createElement(Te.Z,{color:"gray"})):o.ZP.createElement(Un,{className:qe?"activated":"",round:!0,faded:!0,color:"translucent",onActivate:Xt,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(Kn.Z,{id:"message-input-text",html:Ne.length?"":pe,placeholder:at&&ke<=600?"":k||me("Message"),forcedPlaceholder:Pt,shouldSetFocus:!Ne.length,shouldSuppressFocus:m.wB&&qe,shouldSuppressTextFormatter:Lt||lt||gt,onUpdate:Ie,onSend:ys,onSuppressedFocus:He}),j&&Boolean(ft)&&o.ZP.createElement(Te.Z,{color:"gray"}),R&&o.ZP.createElement(be.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:cs,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),E&&!at&&!c&&o.ZP.createElement(Un,{className:xe?"activated":"",round:!0,faded:!0,color:"translucent",onActivate:Ae,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!at&&!c&&o.ZP.createElement(Un,{className:$e?"activated":"",round:!0,faded:!0,color:"translucent",onActivate:Qe,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),at&&ot&&o.ZP.createElement("span",{className:"recording-state"},(0,L.rM)(ot-it.current)),o.ZP.createElement(Hn,{isOpen:xt,onStickerSelect:Yt}),o.ZP.createElement(jn.Z,{isOpen:Lt,emojis:Ft,onClose:Ot,onEmojiSelect:Ut,addRecentEmoji:de}),o.ZP.createElement($n,{isOpen:$e,allowedAttachmentOptions:Tt,onFileSelect:jt,onPollCreate:se,onClose:De}),E&&o.ZP.createElement(Wn,{messageId:E,isOpen:xe,onClose:Le}),_&&o.ZP.createElement(Jn,{isOpen:Oe,botCommands:_,onClose:Ue}),o.ZP.createElement(Qn,{isOpen:qe,allowedAttachmentOptions:Tt,onLoad:Ke,onClose:He,onEmojiSelect:$t,onStickerSelect:Yt,onGifSelect:zt,onRemoveSymbol:Dt,onSearchOpen:rs,addRecentEmoji:de}))),at&&o.ZP.createElement(be.Z,{round:!0,color:"danger",className:"cancel",onClick:tt,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(be.Z,{ref:rt,round:!0,color:"secondary",className:(0,ie.Z)(ct,!r&&"not-ready",at&&"recording"),disabled:ls,ariaLabel:me(ps),onClick:ds,onContextMenu:ct===ca.Send&&dt?Et:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),dt&&o.ZP.createElement(Gn,{isOpen:St,onSilentSend:y?void 0:ss,onScheduleSend:t?void 0:we,onClose:kt,onCloseAnimationEnd:Rt}),o.ZP.createElement(oa,{isOpen:Ce,withTimePicker:!0,selectedAt:ms.getTime(),maxAt:(0,L._F)(gs),isFutureMode:!0,secondButtonLabel:s?"Send When Online":void 0,onClose:os,onSubmit:ns,onSecondButtonClick:s?as:void 0}))}))),la=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0})),ua=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0})),ha=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0})),ma=m.wB?450+a.fK:void 0;function ga(e){return"file"===e.kind&&e.type&&a.AK.has(e.type)}const fa=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Pu)(e),{isBlurred:s,background:n,backgroundColor:a,patternColor:o}=e.settings.themes[t]||{},{messageLists:r}=e.messages,c=(0,i.Bt)(e),{isLeftColumnShown:l,chats:{listIds:h}}=e,g={theme:t,customBackground:n,backgroundColor:a,patternColor:o,isLeftColumnShown:l,isRightColumnShown:(0,i.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(m.wB&&(0,i.n5)(e)),isSelectModeActive:(0,i.CA)(e),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1)};if(!c||!h.active)return g;const{chatId:f,threadId:p,type:I}=c,v=(0,i.Z1)(e,f),y=(0,i.KB)(e,f),{chatId:Z,messageId:P}=e.audioPlayer,C=v&&(0,d.Qm)(v,p),w=(0,i.pk)(e,f),b="pinned"===I,M="scheduled"===I;return{...g,chatId:f,threadId:p,messageListType:I,isPrivate:(0,d.YA)(f),canPost:!b&&(!v||C)&&!w,isPinnedMessageList:b,isScheduledMessageList:M,currentUserBannedRights:null==v?void 0:v.currentUserBannedRights,defaultBannedRights:null==v?void 0:v.defaultBannedRights,hasPinnedOrAudioMessage:p!==u._f||Boolean(null==y?void 0:y.length)||Boolean(Z&&P),pinnedMessagesCount:y?y.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:r}}),((e,t)=>(0,g.ei)(t,["openChat","unpinAllMessages","loadUser","closeLocalTextSearch","exitMessageSelectMode"])))((({chatId:e,threadId:t,messageListType:s,isPrivate:n,isPinnedMessageList:r,messageLists:i,canPost:c,currentUserBannedRights:l,defaultBannedRights:u,hasPinnedOrAudioMessage:h,pinnedMessagesCount:g,customBackground:f,theme:p,backgroundColor:I,patternColor:v,isLeftColumnShown:y,isRightColumnShown:Z,isBackgroundBlurred:P,isMobileSearchActive:C,isSelectModeActive:w,animationLevel:b,shouldSkipHistoryAnimations:M,currentTransitionKey:S,openChat:E,unpinAllMessages:k,loadUser:R,closeLocalTextSearch:T,exitMessageSelectMode:N})=>{const{width:B}=at(),x=(0,Ze.Z)(),[A,L]=(0,o.eJ)(et.t.None),[O,F]=(0,o.eJ)(),[U,$]=(0,o.eJ)(),[Q,D]=(0,o.eJ)(!1),[q,G]=(0,o.eJ)(!m.wB||b===a.oB),H=h&&(B<a.l3||Z&&B>a._m&&B<a.QU||B>=a.ks&&B<a.jT),j=(0,ot.Z)(e,ma),_=(0,ot.Z)(t,ma),V=(0,ot.Z)(s,ma),W=(0,ot.Z)(c,ma),K=(0,ot.Z)(H,ma),X=(0,ot.Z)(O,ma);(0,o.d4)((()=>e?(0,fe.Z)((()=>{E({id:void 0})})):void 0),[e,E]),(0,o.d4)((()=>{L(et.t.None),F(void 0),$(void 0)}),[e]),(0,o.d4)((()=>{b===a.oB&&G(!0)}),[b]),(0,o.d4)((()=>{n&&R({userId:e})}),[e,n,R]);const Y=(0,o.I4)((e=>{if(m.$b)return;const{items:t}=e.dataTransfer||{},s=t&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(ga);L(s?et.t.QuickFile:et.t.Document)}),[]),z=(0,o.I4)((()=>{L(et.t.None)}),[]),J=(0,o.I4)((()=>{D(!0)}),[]),ee=(0,o.I4)((()=>{D(!1)}),[]),te=(0,o.I4)((()=>{k({chatId:e}),ee(),E({id:e})}),[k,E,ee,e]),se=(0,o.I4)((()=>{E({id:e})}),[E,e]),ne=((e,t)=>{const[s,n]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?n(t):tt.fetch(a.fo,e,tt.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,st.pt)(t).then((()=>{n(`url(${t})`)}))})))}),[t,e]),t?s:void 0})(p,f),ae=(0,ie.Z)(K&&"has-header-tools",f&&"custom-bg-image",I&&"custom-bg-color",f&&P&&"blurred",m.aZ?"mask-image-disabled":"mask-image-enabled"),oe=(0,ie.Z)("messaging-disabled",!w&&"shown"),re=(0,d.q8)(x,l,u),{composerHiddenScale:ce,toolbarHiddenScale:de,composerTranslateX:le,toolbarTranslateX:ue,unpinHiddenScale:he,toolbarForUnpinHiddenScale:me}=(0,o.Ye)((()=>function(e,t){const s=e<=a.l3?16:32,n=function(e){if(e>a._m){const t=Math.min(Math.max(.25*e,288),424),s=Math.min(.25*e,424);return Math.min(e-t-s,rt)}if(e>a.ks){const t=Math.min(Math.max(.4*e,288),424);return Math.min(e-t,rt)}return e>rt?rt:e}(e),o=e<=a.l3?54:64,r=t?n-s-o:n-s,i=e>a.l3?Math.min(n-s,512):n-s,c=i/r,d=r/i;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?o/2*d:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:i/258,toolbarForUnpinHiddenScale:258/i}}(B,W)),[W,B]),pe=(0,ie.Z)("middle-column-footer",!W&&"no-composer",W&&U&&!w&&"with-notch");return(0,ge.ZP)(j&&_,(()=>{E({id:void 0},!0)}),void 0,void 0,void 0,i?i.map(it):[]),(0,ge.ZP)(C,T),(0,ge.ZP)(w,N),o.ZP.createElement("div",{id:"MiddleColumn",className:ae,onTransitionEnd:t=>{"transform"===t.propertyName&&t.target===t.currentTarget&&G(Boolean(e))},style:`\n --composer-hidden-scale: ${ce};\n --toolbar-hidden-scale: ${de};\n --unpin-hidden-scale: ${he};\n --toolbar-unpin-hidden-scale: ${me};\n --composer-translate-x: ${le}px;\n --toolbar-translate-x: ${ue}px;\n --pattern-color: ${v};\n --theme-background-color:\n ${I||("dark"===p?a.It:a.p3)};\n `,onClick:m.p7&&y?se:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:ne?`--custom-background: ${ne}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),j&&_&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:W?Y:void 0},o.ZP.createElement(Rt,{chatId:j,threadId:_,messageListType:V,isReady:q}),o.ZP.createElement(Ie.Z,{name:M?"none":b===a.zy?"slide":"fade",activeKey:S,shouldCleanup:!0},(e=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(on,{key:`${j}-${_}-${V}`,chatId:j,threadId:_,type:V,canPost:W,hasTools:K,onFabToggle:F,onNotchToggle:$,isReady:q,isActive:e}),o.ZP.createElement("div",{className:pe},W&&o.ZP.createElement(da,{chatId:j,threadId:_,messageListType:V,dropAreaState:A,onDropHide:z,isReady:q}),r&&o.ZP.createElement("div",{className:"unpin-button-container",dir:x.isRtl?"rtl":void 0},o.ZP.createElement(be.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:J},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,x("Chat.Pinned.UnpinAll",g,"i")))),!r&&!W&&re&&o.ZP.createElement("div",{className:oe},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,re))),o.ZP.createElement(ua,{messageListType:V,isActive:w,canPost:W}))))),o.ZP.createElement(rn,{isShown:X,canPost:W})),m.wB&&o.ZP.createElement(la,{isActive:Boolean(C)})),e&&o.ZP.createElement(ha,{isOpen:Q,chatId:e,pinnedMessagesCount:g,onClose:ee,onUnpin:te}))}))),pa=(0,Z.Ds)((e=>e()),200,!1);var Ia;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Management=4]="Management",e[e.ManageInitial=5]="ManageInitial",e[e.ManageChannelSubscribers=6]="ManageChannelSubscribers",e[e.ManageChatAdministrators=7]="ManageChatAdministrators",e[e.ManageChatPrivacyType=8]="ManageChatPrivacyType",e[e.ManageDiscussion=9]="ManageDiscussion",e[e.ManageGroupPermissions=10]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=11]="ManageGroupRemovedUsers",e[e.ManageGroupUserPermissionsCreate=12]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=13]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=14]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=15]="ManageGroupAdminRights",e[e.ManageGroupMembers=16]="ManageGroupMembers",e[e.StickerSearch=17]="StickerSearch",e[e.GifSearch=18]="GifSearch",e[e.PollResults=19]="PollResults",e[e.AddingMembers=20]="AddingMembers"}(Ia||(Ia={}));const va=(0,o.X$)((0,n.c$)(((e,{chatId:t,isProfile:s,isManagement:n})=>{const{query:a}=(0,i.n5)(e)||{},{query:o}=(0,i.y5)(e)||{},{query:r}=(0,i.yN)(e)||{},c=t?(0,i.Z1)(e,t):void 0,l=c&&(0,d.eA)(c);return{canManage:Boolean(!n&&s&&c&&!(0,i.FM)(e,c.id)&&((0,d.YA)(c.id)||((0,d.Nl)(c)||c.isCreator)&&!c.isNotJoined)),isChannel:l,messageSearchQuery:a,stickerSearchQuery:o,gifSearchQuery:r}}),((e,t)=>(0,g.ei)(t,["setLocalTextSearchQuery","setStickerSearchQuery","setGifSearchQuery","searchTextMessagesLocal","toggleManagement","openHistoryCalendar"])))((({isColumnOpen:e,isProfile:t,isSearch:s,isManagement:n,isStickerSearch:a,isGifSearch:r,isPollResults:i,isAddingChatMembers:c,profileState:d,managementScreen:l,canManage:u,isChannel:g,onClose:f,messageSearchQuery:p,stickerSearchQuery:I,gifSearchQuery:v,setLocalTextSearchQuery:y,setStickerSearchQuery:Z,setGifSearchQuery:P,searchTextMessagesLocal:C,toggleManagement:w,openHistoryCalendar:b,shouldSkipAnimation:M})=>{var S;const E=(0,o.sO)(null),k=(0,o.I4)((e=>{y({query:e}),e.length&&pa(C)}),[C,y]),R=(0,o.I4)((e=>{Z({query:e})}),[Z]),T=(0,o.I4)((e=>{P({query:e})}),[P]),[N,B]=(0,o.eJ)(!e);(0,o.d4)((()=>{setTimeout((()=>{B(!e)}),300)}),[e]);const x=(0,Ze.Z)(),A=t?d===h.vi.Profile?Ia.Profile:d===h.vi.SharedMedia?Ia.SharedMedia:d===h.vi.MemberList?Ia.MemberList:-1:s?Ia.Search:i?Ia.PollResults:a?Ia.StickerSearch:r?Ia.GifSearch:c?Ia.AddingMembers:n?l===h.u1.Initial?Ia.ManageInitial:l===h.u1.ChatPrivacyType?Ia.ManageChatPrivacyType:l===h.u1.Discussion?Ia.ManageDiscussion:l===h.u1.ChannelSubscribers?Ia.ManageChannelSubscribers:l===h.u1.GroupPermissions?Ia.ManageGroupPermissions:l===h.u1.ChatAdministrators?Ia.ManageChatAdministrators:l===h.u1.GroupRemovedUsers?Ia.ManageGroupRemovedUsers:l===h.u1.GroupUserPermissionsCreate?Ia.ManageGroupUserPermissionsCreate:l===h.u1.GroupUserPermissions?Ia.ManageGroupUserPermissions:l===h.u1.GroupRecentActions?Ia.ManageGroupRecentActions:l===h.u1.ChatAdminRights?Ia.ManageGroupAdminRights:l===h.u1.GroupMembers?Ia.ManageGroupMembers:void 0:void 0,O=null!==(S=(0,lt.Z)(A,!0))&&void 0!==S?S:-1;function F(){if(-1!==O)switch(O){case Ia.PollResults:return o.ZP.createElement("h3",null,x("PollResults"));case Ia.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Me.Z,{parentContainerClassName:"RightSearch",value:p,onChange:k}),o.ZP.createElement(be.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>b({selectedAt:(0,L._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case Ia.AddingMembers:return o.ZP.createElement("h3",null,x("GroupAddMembers"));case Ia.ManageInitial:return o.ZP.createElement("h3",null,x("Edit"));case Ia.ManageChatPrivacyType:return o.ZP.createElement("h3",null,x(g?"ChannelTypeHeader":"GroupTypeHeader"));case Ia.ManageDiscussion:return o.ZP.createElement("h3",null,x("Discussion"));case Ia.ManageChatAdministrators:return o.ZP.createElement("h3",null,x("ChannelAdministrators"));case Ia.ManageGroupRecentActions:return o.ZP.createElement("h3",null,x("Group.Info.AdminLog"));case Ia.ManageGroupAdminRights:return o.ZP.createElement("h3",null,x("EditAdminRights"));case Ia.ManageGroupPermissions:return o.ZP.createElement("h3",null,x("ChannelPermissions"));case Ia.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,x("ChannelBlockedUsers"));case Ia.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,x("ChannelAddException"));case Ia.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,x("UserRestrictions"));case Ia.StickerSearch:return o.ZP.createElement(Me.Z,{value:I,placeholder:x("SearchStickersHint"),onChange:R});case Ia.GifSearch:return o.ZP.createElement(Me.Z,{value:v,placeholder:x("SearchGifsTitle"),onChange:T});case Ia.SharedMedia:return o.ZP.createElement("h3",null,x("SharedMedia"));case Ia.ManageChannelSubscribers:return o.ZP.createElement("h3",null,x("ChannelSubscribers"));case Ia.MemberList:case Ia.ManageGroupMembers:return o.ZP.createElement("h3",null,x("GroupMembers"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},u&&o.ZP.createElement(be.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:x("Edit"),onClick:w},o.ZP.createElement("i",{className:"icon-edit"}))))}}const U=m.wB||A===Ia.SharedMedia||A===Ia.MemberList||A===Ia.AddingMembers||n,$=(0,ie.Z)("animated-close-icon",U&&"state-back",(N||M)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(be.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:f,ariaLabel:x(U?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:E,className:$})),o.ZP.createElement(Ie.Z,{name:N||M?"none":"slide-fade",activeKey:O},F))})));var ya=s(7407);function Za(e,t,s,n,r,i){const c=(0,o.sO)();(0,he.Z)((()=>{t===e&&r&&i&&(c.current=(0,d.R5)(r,i,e).reverse())}),[r,i,t,e]);const[l,u]=(0,ya.Z)(n?s:void 0,c.current,void 0,"media"===e?a.EN:a.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const Pa=(0,Z.P2)((e=>e()),250,!1);let Ca=!1;var wa=s(1273),ba=s(1876),Ma=s(787),Sa=s(180),Ea=s(3709),ka=s(5418),Ra=s(7262),Ta=s(1151),Na=s(3103);const Ba=(0,o.X$)((0,n.c$)(((e,{userId:t})=>{const s=(0,i.jr)(e),n=t&&(0,i.dy)(e,t);return{chat:s,contactName:n?(0,d.Vl)(n):void 0}}),((e,t)=>(0,g.ei)(t,["deleteChatMember"])))((({isOpen:e,chat:t,userId:s,contactName:n,onClose:a,deleteChatMember:r})=>{const i=(0,Ze.Z)(),c=(0,o.I4)((()=>{r({chatId:t.id,userId:s}),a()}),[t,r,a,s]);if(t&&s)return o.ZP.createElement(Na.Z,{isOpen:e,onClose:a,onEnter:c,className:"delete",title:i("GroupRemoved.Remove")},o.ZP.createElement("p",null,(0,It.Z)(i("PeerInfo.Confirm.RemovePeer",n))),o.ZP.createElement(be.Z,{color:"danger",className:"confirm-dialog-button",isText:!0,onClick:c},i("lng_box_remove")),o.ZP.createElement(be.Z,{className:"confirm-dialog-button",isText:!0,onClick:a},i("Cancel")))}))),xa=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"}];function Aa(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > div.active > .${e}-list > .scroll-item`].join(", ")}const La=(0,o.X$)((0,n.c$)(((e,{chatId:t,userId:s})=>{var n;const a=(0,i.Z1)(e,t),o=(0,i.Zw)(e,s||t),{currentType:r,resultsByType:c}=(0,i.we)(e)||{},{foundIds:l}=c&&r&&c[r]||{},{byId:u}=e.users,h=a&&(0,d.Bf)(a),m=a&&(0,d.eA)(a),g=h||m&&(0,d.Nl)(a),f=null==a||null===(n=a.fullInfo)||void 0===n?void 0:n.members,p=g&&a&&a.fullInfo&&!a.fullInfo.canViewMembers,I=g&&a&&((0,d.VE)(a,"inviteUsers")||a.isCreator),v=g&&a&&((0,d.VE)(a,"banUsers")||a.isCreator);let y;return s?y=s:(0,d.YA)(t)&&(y=t),{theme:(0,i.Pu)(e),isChannel:m,resolvedUserId:y,chatMessages:o,foundIds:l,mediaSearchType:r,hasMembersTab:g,areMembersHidden:p,canAddMembers:I,canDeleteMembers:v,currentUserId:e.currentUserId,isRightColumnShown:(0,i.Jf)(e),isRestricted:null==a?void 0:a.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,...g&&f&&{members:f,usersById:u}}}),((e,t)=>(0,g.ei)(t,["setLocalMediaSearchType","loadMoreMembers","searchMediaMessagesLocal","openMediaViewer","openAudioPlayer","openUserInfo","focusMessage","loadProfilePhotos","setNewChatMembersDialogState"])))((({chatId:e,profileState:t,onProfileStateChange:s,theme:n,isChannel:r,resolvedUserId:i,currentUserId:c,chatMessages:l,foundIds:g,mediaSearchType:f,hasMembersTab:p,areMembersHidden:I,canAddMembers:v,canDeleteMembers:y,members:Z,usersById:P,isRightColumnShown:C,isRestricted:w,lastSyncTime:b,setLocalMediaSearchType:M,loadMoreMembers:S,searchMediaMessagesLocal:E,openMediaViewer:k,openAudioPlayer:R,openUserInfo:T,focusMessage:N,loadProfilePhotos:B,setNewChatMembersDialogState:x,serverTimeOffset:A})=>{const L=(0,o.sO)(null),O=(0,o.sO)(null),F=(0,Ze.Z)(),[U,$]=(0,o.eJ)(0),[Q,D]=(0,o.eJ)(),q=(0,o.Ye)((()=>[...p?[{type:"members",title:r?"ChannelSubscribers":"GroupMembers"}]:[],...xa]),[p,r]),G=q[U].type,[H,j,_,V]=function(e,t,s,n,r,i,c,l,u,h,m,g=0){const f="members"!==n&&r?r:n,p=(0,o.Ye)((()=>{if(i&&c)return(0,d.Z0)(i.map((({userId:e})=>e)),c,void 0,g)}),[i,g,c]),[I,v,y]=function(e,t,s,n){const[o,r]=(0,ya.Z)(s?t:void 0,n,void 0,a.Vk);return[o,r,!(!o||!n||o[0]===n[0])]}(0,t,m,p),[Z,P,C]=Za("media",f,s,m,l,u),[w,b,M]=Za("documents",f,s,m,l,u),[S,E,k]=Za("links",f,s,m,l,u),[R,T,N]=Za("audio",f,s,m,l,u);let B,x,A=!1;switch(f){case"members":B=I,x=v,A=y;break;case"media":B=Z,x=P,A=C;break;case"documents":B=w,x=b,A=M;break;case"links":B=S,x=E,A=k;break;case"audio":B=R,x=T,A=N}return[f,B,x,A]}(0,S,E,G,f,Z,P,l,g,0,b,A),W=q.findIndex((({type:e})=>e===H)),{handleScroll:K}=function(e,t,s,n){(0,Nt.Z)((([s])=>{if(s&&s!==t){const s=e.current,a=s.querySelector(".TabList");s.scrollTop<a.offsetTop&&(n("members"===t?h.vi.MemberList:h.vi.SharedMedia),Ca=!0,(0,Ot.Z)(s,a,"start",void 0,void 0,void 0,300),setTimeout((()=>{Ca=!1}),350))}}),[t,n]),(0,Nt.Z)((([t])=>{if(s!==h.vi.Profile||s===t)return;const a=e.current;a&&a.querySelector(".TabList")&&(Ca=!0,(0,Ot.Z)(a,a.firstElementChild,"start",void 0,2*a.offsetHeight),setTimeout((()=>{Ca=!1}),350),n(s))}),[s]);const a=(0,o.I4)((()=>{const s=e.current;if(!s)return;const a=s.querySelector(".TabList");if(!a)return;let o=h.vi.Profile;s.scrollTop>=a.offsetTop&&(o="members"===t?h.vi.MemberList:h.vi.SharedMedia),n(o)}),[e,n,t]);return(0,o.d4)((()=>{Ca||a()}),[a,t]),{handleScroll:(0,o.I4)((()=>{Ca||Pa(a)}),[a])}}(L,G,t,s),{applyTransitionFix:X,releaseTransitionFix:Y}=function(e,t=".Transition.shared-media-transition"){return(0,o.d4)((()=>{function s(){const s=e.current,n=s.querySelector(t),a=s.querySelector(".TabList");n&&a&&(n.style.minHeight=s.offsetHeight-a.offsetHeight+"px")}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]),{applyTransitionFix:(0,o.I4)((()=>{const t=e.current;if("hidden"!==t.style.overflowY){const e=t.offsetWidth-t.clientWidth;t.style.overflowY="hidden",t.style.marginRight=`${e}px`}}),[e]),releaseTransitionFix:(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e])}}(L),[z,J]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),ee=(0,o.I4)((()=>{Y(),J()}),[Y,J]),te=(0,o.I4)((()=>{x(h.WB.InProgress)}),[x]);(0,o.d4)((()=>{M({mediaType:G})}),[M,G]);const se=i||e;(0,o.d4)((()=>{b&&B({profileId:se})}),[B,se,b]);const ne=(0,o.I4)((e=>{k({chatId:se,threadId:u._f,messageId:e,origin:h.bZ.SharedMedia})}),[se,k]),ae=(0,o.I4)((e=>{R({chatId:se,messageId:e})}),[se,R]),oe=(0,o.I4)((e=>{T({id:e})}),[T]),re=(0,o.I4)((e=>{N({chatId:se,messageId:e})}),[se,N]),ie=(0,o.I4)((()=>{D(void 0)}),[]);let ce;(0,o.d4)((()=>{if(O.current&&m.$b)return(0,Be.s)(O.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Be.e.Left?($(Math.min(U+1,q.length-1)),!0):t===Be.e.Right&&($(Math.max(0,U-1)),!0)})}),[U,q.length]);const de="members"===H||!p&&"media"===H;de?ce=C?0:1e3:j||(ce=a.Y);const le=(0,Xn.Z)([e,H],ce);function ue(e){return e!==c&&y?[{title:F("lng_context_remove_from_group"),icon:"stop",handler:()=>{D(e)}}]:void 0}function he(){if(!j||!le||!l){const e=de&&j&&!le;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Te.Z,null))}if(!j.length){let e;switch(H){case"members":e=I?"You have no access to group members list.":"No members found";break;case"documents":e=F("lng_media_file_empty_search");break;case"links":e=F("lng_media_link_empty_search");break;case"audio":e=F("lng_media_song_empty_search");break;default:e=F("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(Ra.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${H}-list`,dir:F.isRtl&&"media"===H?"rtl":void 0,teactFastList:!0},"media"===H?j.map((e=>l[e]&&o.ZP.createElement(Ea.Z,{key:e,message:l[e],onClick:ne}))):"documents"===H?j.map((e=>l[e]&&o.ZP.createElement(ns.Z,{key:e,message:l[e],withDate:!0,smaller:!0,className:"scroll-item",onDateClick:re}))):"links"===H?j.map((e=>l[e]&&o.ZP.createElement(ka.Z,{key:e,message:l[e],onMessageClick:re}))):"audio"===H?j.map((e=>l[e]&&o.ZP.createElement(as.Z,{key:e,theme:n,message:l[e],target:"sharedMedia",date:l[e].date,lastSyncTime:b,className:"scroll-item",onPlay:ae,onDateClick:re}))):"members"===H?j.map(((e,t)=>o.ZP.createElement(ba.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>oe(e),contextActions:ue(e)},o.ZP.createElement(ht.Z,{userId:e,forceShowSelf:!0})))):void 0)}return o.ZP.createElement(wa.Z,{ref:L,className:"Profile custom-scroll",itemSelector:Aa(H),items:le?j:void 0,cacheBuster:z,sensitiveArea:a.qU,preloadBackwards:le?"members"===H?a.Vk:a.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:_,onScroll:K},!V&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Ma.Z,{userId:t||e}),o.ZP.createElement(Sa.Z,{chatOrUserId:t||e}))}(e,i),!w&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Ie.Z,{ref:O,name:F.isRtl?"slide-reversed":"slide",activeKey:W,renderCount:q.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:X,onStop:ee},he),o.ZP.createElement(xe.Z,{big:!0,activeTab:U,tabs:q,onSwitchTab:$})),v&&o.ZP.createElement(Ta.Z,{isShown:"members"===H,onClick:te,ariaLabel:F("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),y&&o.ZP.createElement(Ba,{isOpen:Boolean(Q),userId:Q,onClose:ie}))}))),Oa=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)})),Fa=(0,o.X$)((e=>{const t=(0,Fe.Z)(Oe.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(Ue.Z,null)})),Ua=(0,o.X$)((()=>{const e=(0,Fe.Z)(Oe.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Ue.Z,null)})),$a=(0,o.X$)((()=>{const e=(0,Fe.Z)(Oe.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Ue.Z,null)})),Qa=(0,o.X$)((()=>{const e=(0,Fe.Z)(Oe.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(Ue.Z,null)}));var Da=s(1820);const qa=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{var s;const n=(0,i.Z1)(e,t),{userIds:a}=e.contactList||{},{byId:o}=e.users,{byId:r}=e.chats,{currentUserId:c,newChatMembersProgress:l,connectionState:u}=e,m=n&&(0,d.eA)(n),{query:g,fetchingStatus:f,globalUserIds:p,localUserIds:I}=e.userSearch;return{isChannel:m,members:null==n||null===(s=n.fullInfo)||void 0===s?void 0:s.members,currentUserId:c,usersById:o,chatsById:r,localContactIds:a,searchQuery:g,isSearching:f,isLoading:l===h.WB.Loading,globalUserIds:p,localUserIds:I,connectionState:u}}),((e,t)=>(0,g.ei)(t,["loadContactList","setUserSearchQuery"])))((({isChannel:e,connectionState:t,members:s,onNextStep:n,currentUserId:a,usersById:r,chatsById:i,localContactIds:c,isLoading:l,searchQuery:u,isSearching:h,localUserIds:m,globalUserIds:f,setUserSearchQuery:p,onClose:I,isActive:v,loadContactList:y})=>{const Z=(0,Ze.Z)(),[P,C]=(0,o.eJ)([]),w=(0,fs.Z)(P)===P;(0,o.d4)((()=>{v&&"connectionStateReady"===t&&y()}),[t,v,y]),(0,ge.ZP)(v,I);const b=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),M=(0,o.I4)((e=>{p({query:e})}),[p]),S=(0,o.Ye)((()=>{const t=c?(0,d.ih)(c.filter((e=>e!==a)),i):[];if(!u)return t.filter((e=>!b.includes(e)));const s=t.filter((e=>{const t=r[e];if(!t)return!1;const s=(0,d.Js)(t);return s&&(0,B.Z)(s,u)}));return(0,d.ih)((0,g.Tw)([...s,...m||[],...f||[]]).filter((t=>{const s=r[t];return!b.includes(t)&&(!s||!(0,d.cS)(s)||!e&&s.canBeInvitedToGroup)})),i)}),[c,i,u,m,f,a,r,b,e]),E=(0,o.I4)((()=>{P.length&&(p({query:""}),n(P))}),[P,p,n]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(Da.Z,{itemIds:S,selectedIds:P,filterValue:u,filterPlaceholder:Z("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:C,onFilterChange:M,noScrollRestore:w}),o.ZP.createElement(Ta.Z,{isShown:Boolean(P.length),disabled:l,ariaLabel:Z("lng_channel_add_users"),onClick:E},l?o.ZP.createElement(Te.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),Ga=Object.keys(h.qt).length/2,Ha=Object.keys(h.u1).length/2;function ja(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const _a=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},n=(0,i.g4)(e);return{contentKey:(0,i.Wq)(e),chatId:t,threadId:s,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(t&&n),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}),((e,t)=>(0,g.ei)(t,["openUserInfo","toggleChatInfo","toggleManagement","closeLocalTextSearch","setStickerSearchQuery","setGifSearchQuery","closePollResults","addChatMembers","setNewChatMembersDialogState"])))((({contentKey:e,chatId:t,threadId:s,currentProfileUserId:n,isChatSelected:r,toggleChatInfo:i,toggleManagement:c,openUserInfo:d,closeLocalTextSearch:l,setStickerSearchQuery:u,setGifSearchQuery:m,closePollResults:g,addChatMembers:f,setNewChatMembersDialogState:p,shouldSkipHistoryAnimations:I})=>{var v;const{width:y}=at(),[Z,P]=(0,o.eJ)(h.vi.Profile),[C,w]=(0,o.eJ)(h.u1.Initial),[b,M]=(0,o.eJ)(),[S,E]=(0,o.eJ)(),k=Z!==h.vi.Profile,R=void 0!==e,T=e===h.qt.ChatInfo||e===h.qt.UserInfo,N=e===h.qt.Search,B=e===h.qt.Management,x=e===h.qt.StickerSearch,A=e===h.qt.GifSearch,L=e===h.qt.PollResults,O=e===h.qt.AddingMembers,F=y<=a._m,[U,$]=(0,o.eJ)(!R),Q=null!==(v=(0,lt.Z)(e,!0,!r))&&void 0!==v?v:-1,D=(0,o.I4)(((t=!0)=>{switch(e){case h.qt.AddingMembers:p(h.WB.Closed);break;case h.qt.ChatInfo:if(k&&t){P(h.vi.Profile);break}i(void 0,!0);break;case h.qt.UserInfo:if(k&&t){P(h.vi.Profile);break}d({id:void 0},!0);break;case h.qt.Management:switch(C){case h.u1.Initial:c();break;case h.u1.ChatPrivacyType:case h.u1.Discussion:case h.u1.GroupPermissions:case h.u1.GroupType:case h.u1.ChatAdministrators:case h.u1.ChannelSubscribers:case h.u1.GroupMembers:w(h.u1.Initial);break;case h.u1.GroupUserPermissionsCreate:case h.u1.GroupRemovedUsers:case h.u1.GroupUserPermissions:w(h.u1.GroupPermissions),M(void 0),E(void 0);break;case h.u1.ChatAdminRights:case h.u1.GroupRecentActions:w(h.u1.ChatAdministrators)}break;case h.qt.Search:ja(),l();break;case h.qt.StickerSearch:ja(),u({query:void 0});break;case h.qt.GifSearch:ja(),m({query:void 0});break;case h.qt.PollResults:g()}}),[e,k,i,d,g,p,C,c,l,u,m]),q=(0,o.I4)(((e,t)=>{M(e),E(t)}),[]),G=(0,o.I4)((e=>{f({chatId:t,memberIds:e})}),[f,t]);function H(e){if(-1!==Q)switch(Q){case h.qt.AddingMembers:return o.ZP.createElement(qa,{chatId:t,onNextStep:G,isActive:R&&e,onClose:D});case h.qt.ChatInfo:case h.qt.UserInfo:return o.ZP.createElement(La,{key:n||t,chatId:t,userId:n,profileState:Z,onProfileStateChange:P});case h.qt.Search:return o.ZP.createElement(Oa,{chatId:t,threadId:s,onClose:D,isActive:R&&e});case h.qt.Management:return o.ZP.createElement(Fa,{chatId:t,currentScreen:C,isPromotedByCurrentUser:S,selectedChatMemberId:b,onScreenSelect:w,onChatMemberSelect:q,isActive:R&&e,onClose:D});case h.qt.StickerSearch:return o.ZP.createElement(Ua,{onClose:D,isActive:R&&e});case h.qt.GifSearch:return o.ZP.createElement($a,{onClose:D,isActive:R&&e});case h.qt.PollResults:return o.ZP.createElement(Qa,{onClose:D,isActive:R&&e})}}return(0,o.d4)((()=>R?(0,fe.Z)(D):void 0),[R,D]),(0,o.d4)((()=>{setTimeout((()=>{$(!R)}),300)}),[R]),(0,o.d4)((()=>{R&&F&&D()}),[F]),(0,Tt.Z)((([s,n])=>{(s===h.qt.ChatInfo&&e===h.qt.UserInfo||s===h.qt.UserInfo&&e===h.qt.ChatInfo||n!==t)&&(P(h.vi.Profile),w(h.u1.Initial))}),[e,t]),(0,ge.ZP)(r&&(e===h.qt.ChatInfo||e===h.qt.UserInfo||e===h.qt.Management||e===h.qt.AddingMembers),(()=>D(!1)),i),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:r?void 0:"is-hidden"},F&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:D}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(va,{chatId:t,isColumnOpen:R,isProfile:T,isSearch:N,isManagement:B,isStickerSearch:x,isGifSearch:A,isPollResults:L,isAddingChatMembers:O,profileState:Z,managementScreen:C,onClose:D,shouldSkipAnimation:U||I}),o.ZP.createElement(Ie.Z,{name:U||I?"none":"zoom-fade",renderCount:Ga+Ha,activeKey:B?Ga+C:Q,shouldCleanup:!0,cleanupExceptionKey:h.qt.ChatInfo},H)))}))),Va=(0,o.X$)((({isOpen:e})=>{const t=(0,Fe.Z)(Oe.gl.Extra,"MediaViewer",!e);return t?o.ZP.createElement(t,null):void 0})),Wa=(0,o.X$)((({isOpen:e})=>{const t=(0,Fe.Z)(Oe.gl.Extra,"Notifications",!e);return t?o.ZP.createElement(t,null):void 0})),Ka=(0,o.X$)((({isOpen:e})=>{const t=(0,Fe.Z)(Oe.gl.Extra,"Dialogs",!e);return t?o.ZP.createElement(t,null):void 0})),Xa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"ForwardPicker",!t);return s?o.ZP.createElement(s,e):void 0})),Ya=(0,o.X$)((e=>{const{url:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0})),za=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Fe.Z)(Oe.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0}));let Ja,eo=!1;function to(e){document.querySelectorAll('link[rel="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 so(e){document.title!==e&&(document.title=e)}const no=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,messageId:s}=e.audioPlayer,n=t&&s?(0,i.hj)(e,t,s):void 0;return{animationLevel:e.settings.byKey.animationLevel,lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,i.Jf)(e),isMediaViewerOpen:(0,i.zQ)(e),isForwardModalOpen:(0,i.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:n,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,language:e.settings.byKey.language,openedStickerSetShortName:e.openedStickerSetShortName}}),((e,t)=>(0,g.ei)(t,["loadAnimatedEmojis","loadNotificationSettings","loadNotificationExceptions","updateIsOnline","loadTopInlineBots","loadEmojiKeywords","openStickerSetShortName"])))((({lastSyncTime:e,isLeftColumnShown:t,isRightColumnShown:s,isMediaViewerOpen:r,isForwardModalOpen:c,animationLevel:d,hasNotifications:l,hasDialogs:u,audioMessage:h,safeLinkModalUrl:g,isHistoryCalendarOpen:f,shouldSkipHistoryAnimations:p,language:I,openedStickerSetShortName:v,loadAnimatedEmojis:y,loadNotificationSettings:P,loadNotificationExceptions:C,updateIsOnline:w,loadTopInlineBots:b,loadEmojiKeywords:M,openStickerSetShortName:S})=>{a.eM&&!eo&&(eo=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{e&&(w(!0),y(),P(),C(),b(),M({language:a.pR}),I!==a.pR&&M({language:I}))}),[e,y,C,P,w,b,M,I]),(0,o.d4)((()=>{e&&ge.Oy.startsWith("#?tgaddr=")&&(e=>{const{protocol:t,searchParams:s,pathname:a}=new URL(e);if("tg:"!==t)return;const{openChatByUsername:o,openStickerSetShortName:r}=(0,n.uC)(),i=a.replace(/^\/\//,""),c={};switch(s.forEach(((e,t)=>{c[t]=e})),i){case"resolve":{const{domain:e}=c;"telegrampassport"!==e&&o({username:e});break}case"privatepost":case"bg":case"join":break;case"addstickers":{const{set:e}=c;r({stickerSetShortName:e});break}}})(decodeURIComponent(ge.Oy.substr("#?tgaddr=".length)))}),[e]);const{transitionClassNames:E}=(0,de.Z)(!t,void 0,!0,void 0,p),{transitionClassNames:k}=(0,de.Z)(s,void 0,!0,void 0,p),R=(0,ie.Z)(E.replace(/([\w-]+)/g,"middle-column-$1"),k.replace(/([\w-]+)/g,"right-column-$1"),p&&"history-animation-disabled");(0,he.Z)((([e])=>{if(void 0===e||0===d)return;const t=(0,re.YW)();(0,ce.L)(document.getElementById("MiddleColumn"),t)}),[t]),(0,he.Z)((([e])=>{if(void 0===e||0===d)return;(0,Z.T2)((()=>{document.body.classList.add("animating-right-column")}));const t=(0,re.YW)();(0,ce.L)(document.getElementById("RightColumn"),(()=>{t(),(0,Z.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[s]);const T=(0,o.I4)((()=>{w(!1);const e=(0,i.A1)((0,n.Rd)());let t=0;clearInterval(Ja),Ja=window.setInterval((()=>{if(document.title.includes(a.ou))to(!1);else{if(t%2==0){const t=(0,i.A1)((0,n.Rd)())-e;t>0&&(so(`${t} notification${t>1?"s":""}`),to(!0))}else so(a.Ti),to(!1);t++}}),1e3)}),[w]),N=(0,o.I4)((()=>{w(!0),clearInterval(Ja),Ja=void 0,document.title.includes(a.ou)||so(a.Ti),to(!1)}),[w]),B=(0,o.I4)((()=>{S({stickerSetShortName:void 0})}),[S]);function x(e){e.preventDefault(),e.stopPropagation()}return(0,le.Z)(T,N),ue(T),function(e=!1){(0,o.d4)((()=>{if(m.cj&&!e)return document.addEventListener("gesturestart",me),()=>{document.removeEventListener("gesturestart",me)}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:R,onDrop:x,onDragOver:x},o.ZP.createElement(Je,null),o.ZP.createElement(fa,null),o.ZP.createElement(_a,null),o.ZP.createElement(Va,{isOpen:r}),o.ZP.createElement(Xa,{isOpen:c}),o.ZP.createElement(Wa,{isOpen:l}),o.ZP.createElement(Ka,{isOpen:u}),h&&o.ZP.createElement(kt,{key:h.id,message:h,noUi:!0}),o.ZP.createElement(Ya,{url:g}),o.ZP.createElement(za,{isOpen:f}),o.ZP.createElement(ds.Z,{isOpen:Boolean(v),onClose:B,stickerSetShortName:v}))})));a.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,n.Rd)().connectionState||(0,n.uC)().initApi()}}]);
//# sourceMappingURL=433.29f542772c88e944d938.js.map