mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-16 03:07:07 +01:00
2 lines
239 KiB
JavaScript
2 lines
239 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[325],{325:(e,t,s)=>{s.r(t),s.d(t,{Main:()=>Mo});var a=s(5116),n=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,a.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(t&&s)return(0,r.qr)(e,t,s,!0)})),(0,a.Q6)("closeLocalTextSearch",l),(0,a.Q6)("setLocalTextSearchQuery",((e,t,s)=>{const{chatId:a,threadId:n}=(0,i.Bt)(e)||{};if(!a||!n)return;const{query:o}=s,l=(0,d.uw)(a,n),{query:u}=e.localTextSearch.byChatThreadKey[l]||{};return o!==u&&(e=(0,r.Pb)(e,a,n,c.D)),(0,r.qr)(e,a,n,!0,o)})),(0,a.Q6)("setLocalMediaSearchType",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};if(!a)return;const{mediaType:n}=s;return(0,r.z5)(e,a,n)})),(0,a.Q6)("openChat",((e,t,s)=>{const{id:n,threadId:o=-1,type:c="thread",shouldReplaceHistory:d=!1}=s,u=(0,i.Bt)(e);return u&&u.chatId===n&&u.threadId===o&&u.type===c||(e=(0,r.pf)(e,n,o,"replyStack",[]),e=l(e=(0,r.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...n!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,a.R3)(e)),(0,r.Wy)(e,n,o,c,d)})),(0,a.Q6)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,a.Q6)("openChatWithInfo",((e,t,s)=>{(0,a.R3)({...e,isChatInfoShown:!0}),t.openChat(s)})),(0,a.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,a.Q6)("setNewChatMembersDialogState",((e,t,s)=>({...e,newChatMembersProgress:s}))),(0,a.Q6)("openNextChat",((e,t,s)=>{const{targetIndexDelta:a,orderedIds:n}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return void t.openChat({id:n[0]});const r=n.indexOf(o);if(-1===r)return;const c=n[r+a];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=s(6137),h=s(1713),m=s(7361),g=s(782),f=s(2267),p=s(3099);const I=n.ck+n.fK;let v;(0,a.Q6)("setScrollOffset",((e,t,s)=>{const{chatId:a,threadId:n,scrollOffset:o}=s;return(0,r.pf)(e,a,n,"scrollOffset",o)})),(0,a.Q6)("setReplyingToId",((e,t,s)=>{const{messageId:a}=s,n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:c}=n;return(0,r.pf)(e,o,c,"replyingToId",a)})),(0,a.Q6)("setEditingId",((e,t,s)=>{const{messageId:a}=s,n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:c,type:d}=n,l="scheduled"===d?"editingScheduledId":"editingId";return(0,r.pf)(e,o,c,l,a)})),(0,a.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(!t||!s)return;const a=(0,i.Zw)(e,t),n=(0,i.Cb)(e,t,s);if(!a||!n)return;const o=(0,g.dF)(n,(t=>Boolean(a[t]&&(0,i._k)(e,a[t],s).canEdit)));return o?(0,r.pf)(e,t,s,"editingId",o):void 0})),(0,a.Q6)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:a}=s,{chatId:n,threadId:o}=(0,i.Bt)(e)||{};if(!n||!o)return;const r=(0,i.Zw)(e,n),c=(0,i.Cb)(e,n,o);if(!r||!c)return;const d=(0,i.Yy)(e,n,o);let l;if((0,i.b9)(e,n,o)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+a;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,n);l=null==t||null===(h=t.lastMessage)||void 0===h?void 0:h.id}else{const t=(0,i.tZ)(e,n,o);l=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:l}),t.focusMessage({chatId:n,threadId:o,messageId:l})})),(0,a.Q6)("openMediaViewer",((e,t,s)=>{const{chatId:a,threadId:n,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c}=s;return{...e,mediaViewer:{chatId:a,threadId:n,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c},forwardMessages:{}}})),(0,a.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,a.Q6)("openAudioPlayer",((e,t,s)=>{const{chatId:a,threadId:n,messageId:o,origin:r,volume:i,playbackRate:c,isMuted:d}=s;return{...e,audioPlayer:{chatId:a,threadId:n,messageId:o,origin:r,volume:i||e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:d||e.audioPlayer.isMuted}}})),(0,a.Q6)("setAudioPlayerVolume",((e,t,s)=>{const{volume:a}=s;return{...e,audioPlayer:{...e.audioPlayer,volume:a}}})),(0,a.Q6)("setAudioPlayerPlaybackRate",((e,t,s)=>{const{playbackRate:a}=s;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:a}}})),(0,a.Q6)("setAudioPlayerMuted",((e,t,s)=>{const{isMuted:a}=s;return{...e,audioPlayer:{...e.audioPlayer,isMuted:a}}})),(0,a.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,a.Q6)("openPollResults",((e,t,s)=>{const{chatId:n,messageId:o}=s;(0,i.Jf)(e)?n===e.pollResults.chatId&&o===e.pollResults.messageId||(0,a.R3)({...e,pollResults:{chatId:n,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,a.Rd)();(0,a.R3)({...e,pollResults:{chatId:n,messageId:o,voters:{}}})}),450)})),(0,a.Q6)("closePollResults",(e=>{(0,a.R3)({...e,pollResults:{}})})),(0,a.Q6)("focusLastMessage",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:a,threadId:n}=s;let o;if(n===u._f){var r;const t=(0,i.Z1)(e,a);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,i.tZ)(e,a,n);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:a,threadId:n,messageId:o,noHighlight:!0})})),(0,a.Q6)("focusNextReply",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:n,threadId:o}=s,c=(0,i.p9)(e,n,o);if(c&&0!==c.length){const s=c.pop();e=(0,r.pf)(e,n,o,"replyStack",[...c]),(0,a.R3)(e),t.focusMessage({chatId:n,threadId:o,messageId:s})}else t.focusLastMessage()})),(0,a.Q6)("focusMessage",((e,t,s)=>{const{chatId:n,threadId:o=u._f,messageListType:c="thread",noHighlight:d,groupedId:l,groupedChatId:m,replyMessageId:g,isResizingContainer:f}=s;let{messageId:p}=s;if(void 0!==l){const t=(0,i.y8)(e,m,l);null!=t&&t.length&&([p]=t)}const y=(0,i.Bt)(e),C=!y||n!==y.chatId||o!==y.threadId||c!==y.type;if(v&&(clearTimeout(v),v=void 0),v=window.setTimeout((()=>{let e=(0,a.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,a.R3)(e)}),d?I:1500),e=(0,r.cq)(e,n,p,d,f),e=(0,r.wV)(e,void 0),g){const t=(0,i.p9)(e,n,o)||[];e=(0,r.pf)(e,n,o,"replyStack",[...t,g])}C&&(e=(0,r.wV)(e,h.fo.Static));const Z=(0,i.Cb)(e,n,o);if(Z&&Z.includes(p))return(0,a.R3)(e),void t.openChat({id:n,threadId:o});if(C&&(e=(0,r.pf)(e,n,o,"viewportIds",void 0)),e=(0,r.pf)(e,n,o,"outlyingIds",void 0),Z&&!C){const t=p>Z[0]?h.fo.Down:h.fo.Up;e=(0,r.wV)(e,t)}(0,a.R3)(e),t.openChat({id:n,threadId:o}),t.loadViewportMessages()})),(0,a.Q6)("openForwardMenu",((e,t,s)=>{const{fromChatId:a,messageIds:n,groupedId:o}=s;let r;return o&&(r=(0,i.xH)(e,a,o)),{...e,forwardMessages:{fromChatId:a,messageIds:r||n,isModalShown:!0}}})),(0,a.Q6)("exitForwardMode",(e=>{(0,a.R3)({...e,forwardMessages:{}})})),(0,a.Q6)("setForwardChatId",((e,t,s)=>{const{id:n}=s;(0,a.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:n,isModalShown:!1}}),t.openChat({id:n}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,a.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:a}=e.selectedMessages;t.openForwardMenu({fromChatId:s,messageIds:a})})),(0,a.Q6)("cancelMessageMediaDownload",((e,t,s)=>{const{message:n}=s,o=e.activeDownloads.byChatId[n.chatId];o&&o.length&&(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[n.chatId]:o.filter((e=>e!==n.id))}}})})),(0,a.Q6)("downloadMessageMedia",((e,t,s)=>{const{message:n}=s;n&&(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[n.chatId]:[...e.activeDownloads.byChatId[n.chatId]||[],n.id]}}})})),(0,a.Q6)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:a}=e.selectedMessages,{threadId:n}=(0,i.Bt)(e)||{},o=(0,i.Zw)(e,s);o&&n&&a.map((e=>o[e])).filter((t=>(0,i._k)(e,t,n).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,a.Q6)("enterMessageSelectMode",((e,t,s)=>{const{messageId:a}=s||{},n=(0,i.jr)(e);return n?(0,r.M6)(e,n.id,a):e})),(0,a.Q6)("toggleMessageSelection",((e,t,s)=>{const{messageId:n,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,n,o,c,d),(0,a.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,a.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,a.Q6)("exitMessageSelectMode",r.i9),(0,a.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,a.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,a.Q6)("checkVersionNotification",((e,t)=>{const s=n.Ji.split(".").slice(0,2).join("."),{serviceNotifications:a}=e;if(a.find((({version:e})=>e===s)))return;const o={chatId:n.aw,date:(0,f.b)(e.serverTimeOffset),content:{text:(0,p.Z)("**Telegram Web Z was updated to version alpha 1.21**\n\n👏 **Harder**\n· Specify auto-download settings for media by chat type in Settings > Data & Storage.\n· The ‘Choosing a Sticker’ user status now appears in chats and the chat list.\n\n🤩 **Better**\n· Various UI fixes.\n\n🚀 **Faster**\n· Optimized animations for voice message playback.\n· Faster rendering of chats and messages with optimized time formatting.\n\n💪 **Stronger**\n· Fixed scrolling jumps in message list.\n· Fixed leaving/deleting groups and channels.\n· Fixed marking service notifications as read.\n· Fixed time display issues for both 12 and 24-hour formats.\n")},isOutgoing:!1};t.createServiceNotification({message:o,version:s})})),(0,a.Q6)("createServiceNotification",((e,t,s)=>{var o;const{message:r,version:c}=s,{serviceNotifications:d}=e,l=(0,i.Z1)(e,n.aw),u=Math.max((null===(o=l.lastMessage)||void 0===o?void 0:o.id)||0,...d.map((({id:e})=>e))),h=(d.length+1)/1e3,m=Math.floor(u)+h;r.id=m;const g={id:m,message:r,version:c,isUnread:!0};(0,a.R3)({...e,serviceNotifications:[...d.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:r.id,chatId:r.chatId,message:r})})),(0,a.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{query:a}=s,{chatId:n}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!n,messages:!0}}:{fetchingStatus:void 0},query:a})})),(0,a.Q6)("addRecentlyFoundChatId",((e,t,s)=>{const{id:a}=s,{recentlyFoundChatIds:n}=e.globalSearch;if(!n)return(0,r.No)(e,{recentlyFoundChatIds:[a]});const o=n.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,a.Q6)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,a.Q6)("setGlobalSearchContent",((e,t,s)=>{const{content:a}=s;return(0,r.Og)(e,a)})),(0,a.Q6)("setGlobalSearchChatId",((e,t,s)=>{const{id:a}=s;return(0,r.No)(e,{chatId:a,query:void 0,resultsByType:void 0})})),(0,a.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:a}=s;return{...e,stickers:{...e.stickers,search:{query:a,resultIds:void 0}}}})),(0,a.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:a}=s;return{...e,gifs:{...e.gifs,search:{query:a,offsetId:void 0,results:void 0}}}})),(0,a.Q6)("openUserInfo",((e,t,s)=>{const{id:a}=s;t.openChat({id:a})})),(0,a.Q6)("openChat",(e=>(0,r.x1)(e,void 0))),(0,a.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:a}=s;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a})})),s(3781);var y=s(1947),C=s(6926);(0,a.Q6)("toggleChatInfo",(e=>({...e,isChatInfoShown:!e.isChatInfoShown}))),(0,a.Q6)("setLeftColumnWidth",((e,t,s)=>({...e,leftColumnWidth:s}))),(0,a.Q6)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,a.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,a.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,a.Q6)("openChat",(e=>{if(m.wB||m.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,a.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,a.Q6)("addRecentEmoji",((e,t,s)=>{const{emoji:a}=s,{recentEmojis:n}=e;if(!n)return{...e,recentEmojis:[a]};const o=n.filter((e=>e!==a));return o.unshift(a),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,a.Q6)("addRecentSticker",((e,t,s)=>{const{sticker:a}=s,{recent:n}=e.stickers;if(!n)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[a]}}};const o=n.stickers.filter((e=>e.id!==a.id));return o.unshift(a),{...e,stickers:{...e.stickers,recent:{...n,stickers:o}}}})),(0,a.Q6)("showNotification",((e,t,s)=>{const a=s;a.localId=(0,C.Z)({});const n=[...e.notifications],o=n.findIndex((e=>e.message===a.message));return-1!==o&&n.splice(o,1),n.push(a),{...e,notifications:n}})),(0,a.Q6)("dismissNotification",((e,t,s)=>{const a=e.notifications.filter((({localId:e})=>e!==s.localId));return{...e,notifications:a}})),(0,a.Q6)("showDialog",((e,t,s)=>{const{data:a}=s;if("message"in a&&a.hasErrorKey&&!(0,y.ZP)(a))return e;const n=[...e.dialogs];if("message"in a){const e=n.findIndex((e=>e.message===a.message));-1!==e&&n.splice(e,1)}return n.push(a),{...e,dialogs:n}})),(0,a.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,a.Q6)("toggleSafeLinkModal",((e,t,s)=>{const{url:a}=s;return{...e,safeLinkModalUrl:a}})),(0,a.Q6)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:a}=s;return{...e,historyCalendarSelectedAt:a}})),(0,a.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,a.Q6)("openPaymentModal",((e,t,s)=>{const{chatId:a,messageId:n}=s;return{...e,payment:{...e.payment,chatId:a,messageId:n,isPaymentModalOpen:!0}}})),(0,a.Q6)("closePaymentModal",(e=>{const t=(0,r.bp)(e);return(0,r.WY)(t)})),(0,a.Q6)("addPaymentError",((e,t,s)=>{const{error:a}=s;return{...e,payment:{...e.payment,error:a}}})),s(1363);var Z=s(1226),P=s(9118);const w=e=>{const{protocol:t,searchParams:s,pathname:n}=new URL(e);if("tg:"!==t)return;const{openChatByInvite:o,openChatByUsername:r,openStickerSetShortName:i,focusMessage:c}=(0,a.uC)(),d=n.replace(/^\/\//,""),l={};switch(s.forEach(((e,t)=>{l[t]=e})),d){case"resolve":{const{domain:e,post:t,comment:s}=l;"telegrampassport"!==e&&r({username:e,messageId:Number(t),commentId:Number(s)});break}case"privatepost":{const{post:e,channel:t}=l;c({chatId:-Number(t),id:e});break}case"bg":break;case"join":{const{invite:e}=l;o({hash:e});break}case"addstickers":{const{set:e}=l;i({stickerSetShortName:e});break}}},b=(0,P.P2)((e=>e()),300,!0),M=(0,P.P2)((e=>e()),3e3,!0),S=(0,P.Ds)((e=>e()),500,!1,!0);async function E(e,t,s){var o;let c=(0,a.Rd)();const d=await(0,Z.t9)("fetchChats",{limit:n.Ov,offsetDate:s,archived:"archived"===e,withPinned:void 0===c.chats.orderedPinnedIds[e],serverTimeOffset:c.serverTimeOffset,lastLocalServiceMessage:null===(o=(0,i.VF)(c))||void 0===o?void 0:o.message});if(!d)return;const{chatIds:l}=d;l.length>0&&l[0]===t&&l.shift(),c=(0,a.Rd)(),c=(0,r.Sh)(c,(0,g.ee)(d.users,"id")),c=(0,r.GL)(c,(0,g.ee)(d.chats,"id")),c=(0,r.B1)(c,e,l),c=(0,r.vv)(c,e,d),Object.keys(d.draftsById).forEach((e=>{c=(0,r.pf)(c,e,u._f,"draft",d.draftsById[e])})),Object.keys(d.replyingToById).forEach((e=>{c=(0,r.pf)(c,e,u._f,"replyingToId",d.replyingToById[e])})),0!==l.length||c.chats.isFullyLoaded[e]||(c={...c,chats:{...c.chats,isFullyLoaded:{...c.chats.isFullyLoaded,[e]:!0}}}),(0,a.R3)(c)}async function k(e){const t=await(0,Z.t9)("fetchFullChat",e);if(!t)return;const{users:s,fullInfo:n}=t;let o=(0,a.Rd)();s&&(o=(0,r.Sh)(o,(0,g.ee)(s,"id"))),o=(0,r.a4)(o,e.id,{fullInfo:n}),(0,a.R3)(o)}async function R(e){const t=(0,a.Rd)(),s=(0,i.DI)(t,e);if(s&&!s.isMin)return s;const n=await(0,Z.t9)("getChatByUsername",e);return n?((0,a.R3)((0,r.a4)((0,a.Rd)(),n.id,n)),n):void 0}(0,a.Q6)("preloadTopChatMessages",((e,t)=>{(async()=>{const s=[];for(let o=0;o<n.ul;o++){await(0,P.wO)(100);const{byId:n,listIds:{active:o},orderedPinnedIds:{active:r}}=(0,a.Rd)().chats;if(!o)return;const{chatId:c}=(0,i.Bt)(e)||{},{pinnedChats:l,otherChats:h}=(0,d.O)(n,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,a.Q6)("openChat",((e,t,s)=>{const{id:a,threadId:n}=s,{currentUserId:o}=e,r=(0,i.Z1)(e,a);if(null!=r&&r.hasUnreadMark&&t.toggleChatUnread({id:a}),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:a});else if(a===o)(0,Z.t9)("fetchChat",{type:"self"});else{const t=(0,i.dy)(e,a);t&&(0,Z.t9)("fetchChat",{type:"user",user:t})}n!==u._f&&((0,i.qS)(e,a,n)||t.requestThreadInfoUpdate({chatId:a,threadId:n}))})),(0,a.Q6)("openLinkedChat",((e,t,s)=>{const{id:a}=s,n=(0,i.Z1)(e,a);n&&(async()=>{var e;const s=await(0,Z.t9)("fetchFullChat",n);null!=s&&null!==(e=s.fullInfo)&&void 0!==e&&e.linkedChatId&&t.openChat({id:s.fullInfo.linkedChatId})})()})),(0,a.Q6)("focusMessageInComments",((e,t,s)=>{const{chatId:a,threadId:n,messageId:o}=s,r=(0,i.Z1)(e,a);r&&(async()=>{await(0,Z.t9)("requestThreadInfoUpdate",{chat:r,threadId:n})&&t.focusMessage({chatId:a,threadId:n,messageId:o})})()})),(0,a.Q6)("openSupportChat",((e,t)=>{const s=(0,i.P_)(e);s?t.openChat({id:s.id,shouldReplaceHistory:!0}):(t.openChat({id:n.AJ,shouldReplaceHistory:!0}),(async()=>{const e=await(0,Z.t9)("fetchChat",{type:"support"});e&&t.openChat({id:e.chatId,shouldReplaceHistory:!0})})())})),(0,a.Q6)("openTipsChat",((e,t,s)=>{const{langCode:a}=s,o="pt-br"===a?"BR":n.Db.includes(a)?a.toUpperCase():"";t.openChatByUsername({username:`${n.vi}${o}`})})),(0,a.Q6)("loadMoreChats",((e,t,s)=>{const{listType:a="active"}=s,n=e.chats.listIds[a];if(e.chats.isFullyLoaded[a])return;const o=n?n.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;b(o?()=>E(a,o.id,o.lastMessage.date):()=>E(a))})),(0,a.Q6)("preloadArchivedChats",(()=>{(async()=>{for(;!(0,a.Rd)().chats.isFullyLoaded.archived;){const e=(0,a.Rd)(),t=e.chats.listIds.archived,s=t?t.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;await E("archived",null==s?void 0:s.id,null==s?void 0:s.lastMessage.date),await(0,P.wO)(300)}})()})),(0,a.Q6)("loadFullChat",((e,t,s)=>{const{chatId:a,force:n}=s,o=(0,i.Z1)(e,a);o&&(n?k(o):S((()=>k(o))))})),(0,a.Q6)("loadTopChats",(()=>{M((()=>E("active")))})),(0,a.Q6)("requestChatUpdate",((e,t,s)=>{var a;const{serverTimeOffset:o}=e,{chatId:r}=s,c=(0,i.Z1)(e,r);c&&(0,Z.t9)("requestChatUpdate",{chat:c,serverTimeOffset:o,...r===n.aw&&{lastLocalMessage:null===(a=(0,i.VF)(e))||void 0===a?void 0:a.message}})})),(0,a.Q6)("updateChatMutedState",((e,t,s)=>{const{serverTimeOffset:n}=e,{chatId:o,isMuted:c}=s,d=(0,i.Z1)(e,o);d&&((0,a.R3)((0,r.a4)(e,o,{isMuted:c})),(0,Z.t9)("updateChatMutedState",{chat:d,isMuted:c,serverTimeOffset:n}))})),(0,a.Q6)("createChannel",((e,t,s)=>{const{title:n,about:o,photo:c,memberIds:d}=s;!async function(e,t,s,n){(0,a.R3)({...(0,a.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const o=await(0,Z.t9)("createChannel",{title:e,about:s,users:t});if(!o)return;const{id:i,accessHash:c}=o;let d=(0,a.Rd)();d=(0,r.a4)(d,i,o),d={...d,chatCreation:{...d.chatCreation,progress:o?h.Nh.Complete:h.Nh.Error}},(0,a.R3)(d),(0,a.uC)().openChat({id:i,shouldReplaceHistory:!0}),i&&c&&n&&await(0,Z.t9)("editChatPhoto",{chatId:i,accessHash:c,photo:n})}(n,d.map((t=>(0,i.dy)(e,t))).filter(Boolean),o,c)})),(0,a.Q6)("joinChannel",((e,t,s)=>{const{chatId:a}=s,n=(0,i.Z1)(e,a);if(!n)return;const{id:o,accessHash:r}=n;o&&r&&(0,Z.t9)("joinChannel",{channelId:o,accessHash:r})})),(0,a.Q6)("deleteChatUser",((e,t,s)=>{var n;const{chatId:o,userId:c}=s,d=(0,i.Z1)(e,o),l=(0,i.dy)(e,c);d&&l&&(e=(0,r.Dd)(e,o),(0,a.R3)(e),(null===(n=(0,i.Bt)(e))||void 0===n?void 0:n.chatId)===o&&t.openChat({id:void 0}),(0,Z.t9)("deleteChatUser",{chat:d,user:l}))})),(0,a.Q6)("deleteChat",((e,t,s)=>{var n;const{chatId:o}=s,c=(0,i.Z1)(e,o);c&&(e=(0,r.Dd)(e,o),(0,a.R3)(e),(null===(n=(0,i.Bt)(e))||void 0===n?void 0:n.chatId)===o&&t.openChat({id:void 0}),(0,Z.t9)("deleteChat",{chatId:c.id}))})),(0,a.Q6)("leaveChannel",((e,t,s)=>{var n;const{chatId:o}=s,c=(0,i.Z1)(e,o);if(!c)return;e=(0,r.Dd)(e,o),(0,a.R3)(e),(null===(n=(0,i.Bt)(e))||void 0===n?void 0:n.chatId)===o&&t.openChat({id:void 0});const{id:d,accessHash:l}=c;d&&l&&(0,Z.t9)("leaveChannel",{channelId:d,accessHash:l})})),(0,a.Q6)("deleteChannel",((e,t,s)=>{var n;const{chatId:o}=s,c=(0,i.Z1)(e,o);if(!c)return;e=(0,r.Dd)(e,o),(0,a.R3)(e),(null===(n=(0,i.Bt)(e))||void 0===n?void 0:n.chatId)===o&&t.openChat({id:void 0});const{id:d,accessHash:l}=c;d&&l&&(0,Z.t9)("deleteChannel",{channelId:d,accessHash:l})})),(0,a.Q6)("createGroupChat",((e,t,s)=>{const{title:n,memberIds:o,photo:c}=s;!async function(e,t,s){(0,a.R3)({...(0,a.Rd)(),chatCreation:{progress:h.Nh.InProgress}});try{const n=await(0,Z.t9)("createGroupChat",{title:e,users:t});if(!n)return;const{id:o}=n;let i=(0,a.Rd)();i=(0,r.a4)(i,o,n),i={...i,chatCreation:{...i.chatCreation,progress:n?h.Nh.Complete:h.Nh.Error}},(0,a.R3)(i),(0,a.uC)().openChat({id:o,shouldReplaceHistory:!0}),o&&s&&await(0,Z.t9)("editChatPhoto",{chatId:o,photo:s})}catch(e){if("USERS_TOO_FEW"===e.message){const e=(0,a.Rd)();(0,a.R3)({...e,chatCreation:{...e.chatCreation,progress:h.Nh.Error,error:"CreateGroupError"}})}}}(n,o.map((t=>(0,i.dy)(e,t))).filter(Boolean),c)})),(0,a.Q6)("toggleChatPinned",((e,t,s)=>{const{id:a,folderId:o}=s,r=(0,i.Z1)(e,a);if(r)if(o){const t=(0,i.Mw)(e,o);if(t){const s=!(0,i.ep)(e,a,o),{pinnedChatIds:n,includedChatIds:r}=t,c=s?[a,...n||[]]:(n||[]).filter((e=>e!==a)),d=[a,...r];(0,Z.t9)("editChatFolder",{id:o,folderUpdate:{...t,pinnedChatIds:c,includedChatIds:d}})}}else{const t=(0,i.Ek)(e,a),s=(0,i.ep)(e,a,"archived"===t?n.WS:void 0);(0,Z.t9)("toggleChatPinned",{chat:r,shouldBePinned:!s})}})),(0,a.Q6)("toggleChatArchived",((e,t,s)=>{const{id:a}=s,o=(0,i.Z1)(e,a);o&&(0,Z.t9)("toggleChatArchived",{chat:o,folderId:(0,d.pE)(o)?0:n.WS})})),(0,a.Q6)("loadChatFolders",(()=>{!async function(){const e=await(0,Z.t9)("fetchChatFolders");if(e){const t=(0,a.Rd)();(0,a.R3)({...t,chatFolders:{...t.chatFolders,...e}})}}()})),(0,a.Q6)("loadRecommendedChatFolders",(()=>{!async function(){const e=await(0,Z.t9)("fetchRecommendedChatFolders");if(e){const t=(0,a.Rd)();(0,a.R3)({...t,chatFolders:{...t.chatFolders,recommended:e}})}}()})),(0,a.Q6)("editChatFolders",((e,t,s)=>{const{chatId:a,idsToRemove:n,idsToAdd:o}=s;n.forEach((async t=>{const s=(0,i.Mw)(e,t);var n;s&&await(0,Z.t9)("editChatFolder",{id:t,folderUpdate:{...s,pinnedChatIds:null===(n=s.pinnedChatIds)||void 0===n?void 0:n.filter((e=>e!==a)),includedChatIds:s.includedChatIds.filter((e=>e!==a))}})})),o.forEach((async t=>{const s=(0,i.Mw)(e,t);s&&await(0,Z.t9)("editChatFolder",{id:t,folderUpdate:{...s,includedChatIds:s.includedChatIds.concat(a)}})}))})),(0,a.Q6)("editChatFolder",((e,t,s)=>{const{id:a,folderUpdate:n}=s,o=(0,i.Mw)(e,a);o&&(0,Z.t9)("editChatFolder",{id:a,folderUpdate:{id:a,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...n}})})),(0,a.Q6)("addChatFolder",((e,t,s)=>{const{folder:o}=s,{orderedIds:r}=e.chatFolders;!async function(e,t){const{id:s,description:n,...o}=e;if(await(0,Z.t9)("editChatFolder",{id:t+1,folderUpdate:{id:t+1,...o}}),!n)return;const r=(0,a.Rd)(),{recommended:i}=r.chatFolders;i&&(0,a.R3)({...r,chatFolders:{...r.chatFolders,recommended:i.filter((({id:e})=>e!==s))}})}(o,null!=r&&r.length?Math.max.apply(Math.max,r):n.WS)})),(0,a.Q6)("deleteChatFolder",((e,t,s)=>{const{id:a}=s;(0,i.Mw)(e,a)&&async function(e){await(0,Z.t9)("deleteChatFolder",e)}(a)})),(0,a.Q6)("toggleChatUnread",((e,t,s)=>{const{id:a}=s,{serverTimeOffset:n}=e,o=(0,i.Z1)(e,a);o&&(o.unreadCount?(0,Z.t9)("markMessageListRead",{serverTimeOffset:n,chat:o,threadId:u._f}):(0,Z.t9)("toggleDialogUnread",{chat:o,hasUnreadMark:!o.hasUnreadMark}))})),(0,a.Q6)("openChatByInvite",((e,t,s)=>{const{hash:a}=s;(async()=>{const e=await(0,Z.t9)("openChatByInvite",a);e&&t.openChat({id:e.chatId})})()})),(0,a.Q6)("openTelegramLink",((e,t,s)=>{const{url:a}=s;if(a.match(n.g$))return void w(a.match(n.g$)[0]);const o=new URL(a.startsWith("http")?a:`https://${a}`),[r,i,c]=o.pathname.split("/").filter(Boolean).map((e=>decodeURI(e))),d=Object.fromEntries(o.searchParams);let l;if("joinchat"===r&&(l=i),(r.startsWith(" ")||r.startsWith("+"))&&(l=r.substr(1,r.length-1)),l)return void t.openChatByInvite({hash:l});if("addstickers"===r)return void t.openStickerSetShortName({stickerSetShortName:i});const u=i?Number(i):void 0,h=c?Number(c):void 0,m=d.comment?Number(d.comment):void 0;"c"===r&&u&&h?t.focusMessage({chatId:-u,messageId:h}):t.openChatByUsername({username:r,messageId:h||u,commentId:m})})),(0,a.Q6)("acceptInviteConfirmation",((e,t,s)=>{const{hash:a}=s;(async()=>{const e=await(0,Z.t9)("importChatInvite",{hash:a});e&&t.openChat({id:e.id})})()})),(0,a.Q6)("openChatByUsername",((e,t,s)=>{const{username:o,messageId:r,commentId:c}=s;(async()=>{const s=(0,i.jr)(e);if(!c)return s&&s.username===o?void t.focusMessage({chatId:s.id,messageId:r}):void await async function(e,t,s){e.openChat({id:n.AJ});const a=await R(t);if(!a)return e.openPreviousChat(),void e.showNotification({message:"User does not exist"});s?e.focusMessage({chatId:a.id,messageId:s}):e.openChat({id:a.id})}(t,o,r);const{chatId:d,type:l}=(0,i.Bt)(e)||{},u=(0,i.DI)(e,o);if(d&&u&&"thread"===l){const s=(0,i.tZ)(e,d,r);if(s&&s.chatId===d)return void t.focusMessage({chatId:s.chatId,threadId:s.threadId,messageId:c})}r&&await async function(e,t,s,o){e.openChat({id:n.AJ});const r=await R(t);if(!r)return;const c=(0,a.Rd)(),d=(0,i.tZ)(c,r.id,s);let l;if(d)l=d.chatId;else{const e=await(0,Z.t9)("requestThreadInfoUpdate",{chat:r,threadId:s});if(!e)return;l=e.discussionChatId}l&&e.focusMessage({chatId:l,threadId:s,messageId:Number(o)})}(t,o,r,c)})()})),(0,a.Q6)("togglePreHistoryHidden",((e,t,s)=>{const{chatId:a,isEnabled:n}=s;let o=(0,i.Z1)(e,a);o&&(async()=>{if((0,d.G9)(o)){if(o=await(0,Z.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}(0,Z.t9)("togglePreHistoryHidden",{chat:o,isEnabled:n})})()})),(0,a.Q6)("updateChatDefaultBannedRights",((e,t,s)=>{const{chatId:a,bannedRights:n}=s,o=(0,i.Z1)(e,a);o&&(0,Z.t9)("updateChatDefaultBannedRights",{chat:o,bannedRights:n})})),(0,a.Q6)("updateChatMemberBannedRights",((e,t,s)=>{const{chatId:n,userId:o,bannedRights:c}=s;let l=(0,i.Z1)(e,n);const u=(0,i.dy)(e,o);l&&u&&(async()=>{if((0,d.G9)(l)){if(l=await(0,Z.t9)("migrateChat",l),!l)return;t.openChat({id:l.id})}await(0,Z.t9)("updateChatMemberBannedRights",{chat:l,user:u,bannedRights:c});const e=(0,a.Rd)(),s=(0,i.Z1)(e,n);if(!s||!s.fullInfo)return;const{members:h,kickedMembers:m}=s.fullInfo,g=!!c.viewMessages,f=!Object.keys(c).length;(0,a.R3)((0,r.a4)(e,n,{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,a.Q6)("updateChatAdmin",((e,t,s)=>{const{chatId:n,userId:o,adminRights:c,customTitle:l}=s;let u=(0,i.Z1)(e,n);const h=(0,i.dy)(e,o);u&&h&&(async()=>{if((0,d.G9)(u)){if(u=await(0,Z.t9)("migrateChat",u),!u)return;t.openChat({id:u.id})}await(0,Z.t9)("updateChatAdmin",{chat:u,user:h,adminRights:c,customTitle:l});const e=(0,a.Rd)(),s=(0,i.Z1)(e,n);if(!s||!s.fullInfo)return;const{adminMembers:m}=s.fullInfo,g=!Object.keys(c).length;(0,a.R3)((0,r.a4)(e,n,{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,a.Q6)("updateChat",((e,t,s)=>{const{chatId:n,title:o,about:c,photo:d}=s,l=(0,i.Z1)(e,n);l&&(async()=>{(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.InProgress)),await Promise.all([l.title!==o?(0,Z.t9)("updateChatTitle",l,o):void 0,l.fullInfo&&l.fullInfo.about!==c?(0,Z.t9)("updateChatAbout",l,c):void 0,d?(0,Z.t9)("editChatPhoto",{chatId:n,accessHash:l.accessHash,photo:d}):void 0]),(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.Complete))})()})),(0,a.Q6)("toggleSignatures",((e,t,s)=>{const{chatId:a,isEnabled:n}=s,o=(0,i.Z1)(e,a);o&&(0,Z.t9)("toggleSignatures",{chat:o,isEnabled:n})})),(0,a.Q6)("loadGroupsForDiscussion",(()=>{(async()=>{const e=await(0,Z.t9)("fetchGroupsForDiscussion");if(!e)return;const t=e.reduce(((e,t)=>(t&&(e[t.id]=t),e)),{}),s=(0,r.fZ)((0,a.Rd)(),t);(0,a.R3)({...s,chats:{...s.chats,forDiscussionIds:Object.keys(t)}})})()})),(0,a.Q6)("linkDiscussionGroup",((e,t,s)=>{const{channelId:a,chatId:n}=s,o=(0,i.Z1)(e,a);let r=(0,i.Z1)(e,n);o&&r&&(async()=>{if((0,d.G9)(r)){if(r=await(0,Z.t9)("migrateChat",r),!r)return;t.openChat({id:r.id})}let{fullInfo:e}=r;if(!e){const t=await(0,Z.t9)("fetchFullChat",r);if(!t)return;e=t.fullInfo}e.isPreHistoryHidden&&await(0,Z.t9)("togglePreHistoryHidden",{chat:r,isEnabled:!1}),(0,Z.t9)("setDiscussionGroup",{channel:o,chat:r})})()})),(0,a.Q6)("unlinkDiscussionGroup",((e,t,s)=>{var a;const{channelId:n}=s,o=(0,i.Z1)(e,n);if(!o)return;let r;null!==(a=o.fullInfo)&&void 0!==a&&a.linkedChatId&&(r=(0,i.Z1)(e,o.fullInfo.linkedChatId)),(async()=>{await(0,Z.t9)("setDiscussionGroup",{channel:o}),r&&k(r)})()})),(0,a.Q6)("setActiveChatFolder",((e,t,s)=>({...e,chatFolders:{...e.chatFolders,activeChatFolder:s}}))),(0,a.Q6)("loadMoreMembers",(e=>{(async()=>{var t,s;const{chatId:n}=(0,i.Bt)(e)||{},o=n?(0,i.Z1)(e,n):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,Z.t9)("fetchMembers",o.id,o.accessHash,"recent",c);if(!l)return;const{members:u,users:h}=l;u&&u.length&&(e=(0,a.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,a.R3)(e))})()})),(0,a.Q6)("addChatMembers",((e,t,s)=>{const{chatId:a,memberIds:n}=s,o=(0,i.Z1)(e,a),r=n.map((t=>(0,i.dy)(e,t))).filter(Boolean);o&&r.length&&(t.setNewChatMembersDialogState(h.WB.Loading),(async()=>{await(0,Z.t9)("addChatMembers",o,r),t.setNewChatMembersDialogState(h.WB.Closed),k(o)})())})),(0,a.Q6)("deleteChatMember",((e,t,s)=>{const{chatId:a,userId:n}=s,o=(0,i.Z1)(e,a),r=(0,i.dy)(e,n);o&&r&&(async()=>{await(0,Z.t9)("deleteChatMember",o,r),k(o)})()}));const T=new Map,N=(0,P.Ds)((e=>e()),500,!1);async function B(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(n.hT/2)+1);break;case h.Uq.Forwards:u=-(n.hT+1)}const m=await(0,Z.t9)("fetchMessages",{chat:(0,i.Cm)((0,a.Rd)(),l,t),offsetId:s,addOffset:u,limit:n.hT,threadId:t});if(!m)return;const{messages:f,users:p,chats:I,threadInfos:v}=m;let y=(0,a.Rd)();const C=l===n.aw?y.serviceNotifications.map((({message:e})=>e)):[],P=[].concat(f,C),w=(0,g.ee)(P,"id"),b=Object.keys(w).map(Number);y=(0,r.c_)(y,l,w),y=c?(0,r.ff)(y,l,t,b):(0,r.xj)(y,l,t,b),y=(0,r.Sh)(y,(0,g.ee)(p,"id")),y=(0,r.fZ)(y,(0,g.ee)(I,"id")),y=(0,r.j6)(y,l,v);let M=(0,i.gb)(y,l,t);const S=(0,i.qC)(y,l,t);if(c&&M&&S&&(S.length&&!(0,g.YE)(M,S)||(y=(0,r.xj)(y,l,t,S),M=(0,i.gb)(y,l,t),y=(0,r.pf)(y,l,t,"outlyingIds",void 0),c=!1)),!d){const e=c?S:M,{newViewportIds:a}=x(e,s,o);y=(0,r.y9)(y,l,t,a)}(0,a.R3)(y)}function x(e,t,s){const{length:a}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,a)=>s===t||s<t&&e[a+1]>t))}(e,t):-1,r=s===h.Uq.Backwards?o:o+1||a,i=r-n.hT,c=r+n.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<a,u=c<=a-1;break;case h.Uq.Around:default:l=d.length>0,u=d.length===n.hT}return{newViewportIds:d,areSomeLocal:l,areAllLocal:u}}async function L(e){let t;const s=e.attachment?(e,n)=>{T.has(n)||(t=n,T.set(n,s));const o=(0,a.Rd)();(0,a.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[n]:{progress:e}}}})}:void 0;(e.replyingTo||m.cj)&&await(0,P.Pn)();const n=(0,a.Rd)();e.serverTimeOffset=n.serverTimeOffset;const o=(0,i.Bt)(n);if(!o)return;const{threadId:r}=o;e.replyingTo||r===u._f||(e.replyingTo=(0,i.qS)(n,e.chat.id,r)),await(0,Z.t9)("sendMessage",e,s),s&&t&&T.delete(t)}(0,a.Q6)("loadViewportMessages",((e,t,s)=>{const{direction:a=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&&a!==h.Uq.Around){const s=a===h.Uq.Backwards?u[0]:u[u.length-1],n=Boolean(g),i=n?g:m,{newViewportIds:f,areSomeLocal:p,areAllLocal:I}=x(i,s,a);if(p&&(e=(0,r.y9)(e,c,d,f)),async function(e,t,s,a,n,o,r,i){t||await B(n,o,i,r,s,a),a||(await Promise.resolve(),e.loadViewportMessages({chatId:n.id,threadId:o,direction:r,isBudgetPreload:!0}))}(t,I,n,o,l,d,a,s),o)return}else{const t=(0,i.G$)(e,c)||(0,i.rd)(e,c,d),s=Boolean(t&&m&&!m.includes(t)),a=(s?g:m)||[],{newViewportIds:u,areSomeLocal:f,areAllLocal:p}=x(a,t,h.Uq.Around);f&&u.length>=n.hT&&(e=(0,r.y9)(e,c,d,u)),p||B(l,d,t,h.Uq.Around,s,o)}return e})),(0,a.Q6)("loadMessage",((e,t,s)=>{const{chatId:n,messageId:o,replyOriginForId:c,threadUpdate:d}=s,l=(0,i.Z1)(e,n);l&&(async()=>{const e=await async function(e,t,s){const n=await(0,Z.t9)("fetchMessage",{chat:e,messageId:t});if(!n)return;if(n===u._Q){if(s){let t=(0,a.Rd)();const n=(0,i.hj)(t,e.id,s);t=(0,r.cY)(t,e.id,s,{...n,replyToMessageId:void 0}),(0,a.R3)(t)}return}let o=(0,a.Rd)();return o=(0,r.cY)(o,e.id,t,n.message),o=(0,r.Sh)(o,(0,g.ee)(n.users,"id")),(0,a.R3)(o),n.message}(l,o,c);if(e&&d){const{lastMessageId:t,isDeleting:s}=d;(0,a.R3)((0,r.lG)((0,a.Rd)(),e,n,t,s))}})()})),(0,a.Q6)("sendMessage",((e,t,s)=>{const a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:r,type:c}=a;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;L({...t,attachment:e?e[0]:void 0})}else if(h){const{text:e,entities:t,attachments:s,...a}=l,o=(0,g.Vl)(s,n.DU);for(let s=0;s<o.length;s++){const[n,...r]=o[s],i=`${Date.now()}${s}`;L({...a,text:0===s?e:void 0,entities:0===s?t:void 0,attachment:n,groupedId:r.length>0?i:void 0}),r.forEach((e=>{L({...a,attachment:e,groupedId:i})}))}}else{const{text:e,entities:t,attachments:s,replyingTo:a,...n}=l;e&&L({...n,text:e,entities:t,replyingTo:a}),s.forEach((e=>{L({...n,attachment:e})}))}})),(0,a.Q6)("editMessage",((e,t,s)=>{const{serverTimeOffset:a}=e,{text:n,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,Z.t9)("editMessage",{chat:u,message:h,text:n,entities:o,noWebPage:(0,i.tV)(e,c,d),serverTimeOffset:a}),t.setEditingId({messageId:void 0}))})),(0,a.Q6)("cancelSendingMessage",((e,t,s)=>{const{chatId:a,messageId:n}=s,o=(0,i.hj)(e,a,n),r=o&&T.get(o.previousLocalId||o.id);r&&(0,Z.u3)(r),t.apiUpdate({"@type":"deleteMessages",ids:[n],chatId:a})})),(0,a.Q6)("saveDraft",((e,t,s)=>{const{chatId:a,threadId:n,draft:o}=s;if(!o)return;const{text:c,entities:d}=o,l=(0,i.Z1)(e,a);return n===u._f&&(0,Z.t9)("saveDraft",{chat:l,text:c,entities:d,replyToMsgId:(0,i.Yy)(e,a,n)}),e=(0,r.pf)(e,a,n,"draft",o),(0,r.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)})})),(0,a.Q6)("clearDraft",((e,t,s)=>{const{chatId:a,threadId:n,localOnly:o}=s;if(!(0,i.Ms)(e,a,n))return;const c=(0,i.Z1)(e,a);return o||n!==u._f||(0,Z.t9)("clearDraft",c),e=(0,r.pf)(e,a,n,"draft",void 0),(0,r.a4)(e,a,{draftDate:void 0})})),(0,a.Q6)("toggleMessageWebPage",((e,t,s)=>{const{chatId:a,threadId:n,noWebPage:o}=s;return(0,r.pf)(e,a,n,"noWebPage",o)})),(0,a.Q6)("pinMessage",((e,t,s)=>{const a=(0,i.jr)(e);if(!a)return;const{messageId:n,isUnpin:o,isOneSide:r,isSilent:c}=s;(0,Z.t9)("pinMessage",{chat:a,messageId:n,isUnpin:o,isOneSide:r,isSilent:c})})),(0,a.Q6)("unpinAllMessages",((e,t,s)=>{const n=(0,i.Z1)(e,s.chatId);n&&async function(e){await(0,Z.t9)("unpinAllMessages",{chat:e});let t=(0,a.Rd)();t=(0,r.pf)(t,e.id,u._f,"pinnedIds",[]),(0,a.R3)(t)}(n)})),(0,a.Q6)("deleteMessages",((e,t,s)=>{const{messageIds:a,shouldDeleteForAll:n}=s,o=(0,i.Bt)(e);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);(0,Z.t9)("deleteMessages",{chat:d,messageIds:a,shouldDeleteForAll:n});const l=(0,i._$)(e,r,c);a.includes(l)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:a}=s,n=(0,i.Bt)(e);if(!n)return;const{chatId:o}=n,r=(0,i.Z1)(e,o);(0,Z.t9)("deleteScheduledMessages",{chat:r,messageIds:a});const c=(0,i.wU)(e,o);a.includes(c)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteHistory",((e,t,s)=>{(async()=>{var a;const{chatId:n,shouldDeleteForAll:o}=s,r=(0,i.Z1)(e,n);if(!r)return;const c=null===(a=r.lastMessage)||void 0===a?void 0:a.id;await(0,Z.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o,maxId:c});const d=(0,i.Bt)(e);d&&d.chatId===n&&t.openChat({id:void 0})})()})),(0,a.Q6)("reportMessages",((e,t,s)=>{(async()=>{const{messageIds:a,reason:n,description:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c}=r,d=(0,i.Z1)(e,c),l=await(0,Z.t9)("reportMessages",{peer:d,messageIds:a,reason:n,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,a.Q6)("markMessageListRead",((e,t,s)=>{const{serverTimeOffset:a}=e,o=(0,i.Bt)(e);if(!o)return;const{chatId:c,threadId:d}=o,l=(0,i.Cm)(e,c,d);if(!l)return;const{maxId:h}=s;if(N((()=>{(0,Z.t9)("markMessageListRead",{serverTimeOffset:a,chat:l,threadId:d,maxId:h})})),d!==u._f)return;c===n.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=h?{...e,isUnread:!1}:e))});const m=(0,i.Cb)(e,c,d),g=(0,i.It)(e,c,d);if(!m||!g||!l.unreadCount)return e;const f=function(e,t,s){let a=0;for(let n=0,o=e.length;n<o&&(e[n]>=t&&e[n]<=s&&a++,!(e[n]>=s));n++);return a}(m,g,h);return f?(0,r.a4)(e,c,{lastReadInboxMessageId:h,unreadCount:Math.max(0,l.unreadCount-f)}):e})),(0,a.Q6)("markMessagesRead",((e,t,s)=>{const a=(0,i.jr)(e);if(!a)return;const{messageIds:n}=s;(0,Z.t9)("markMessagesRead",{chat:a,messageIds:n})})),(0,a.Q6)("loadWebPagePreview",((e,t,s)=>{const{text:n}=s;!async function(e){const t=await(0,Z.t9)("fetchWebPagePreview",{message:e});(0,a.R3)({...(0,a.Rd)(),webPagePreview:t})}(n)})),(0,a.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,a.Q6)("sendPollVote",((e,t,s)=>{const{chatId:a,messageId:n,options:o}=s,r=(0,i.Z1)(e,a);r&&(0,Z.t9)("sendPollVote",{chat:r,messageId:n,options:o})})),(0,a.Q6)("loadPollOptionResults",((e,t,s)=>{const{chat:n,messageId:o,option:i,offset:c,limit:d,shouldResetVoters:l}=s;!async function(e,t,s,n,o,i){const c=await(0,Z.t9)("loadPollOptionResults",{chat:e,messageId:t,option:s,offset:n,limit:o});if(!c)return;let d=(0,a.Rd)();d=(0,r.Sh)(d,(0,g.ee)(c.users,"id"));const{voters:l}=d.pollResults;(0,a.R3)({...d,pollResults:{...d.pollResults,voters:{...l,[s]:(0,g.Tw)([...!i&&l&&l[s]?l[s]:[],...c&&c.users.map((e=>e.id))])},offsets:{...d.pollResults.offsets?d.pollResults.offsets:{},[s]:c.nextOffset||""}}})}(n,o,i,c,d,l)})),(0,a.Q6)("forwardMessages",((e,t,s)=>{const{fromChatId:n,messageIds:o,toChatId:r}=e.forwardMessages,c=n?(0,i.Z1)(e,n):void 0,l=r?(0,i.Z1)(e,r):void 0,u=n&&o?o.sort(((e,t)=>e-t)).map((t=>(0,i.hj)(e,n,t))).filter(Boolean):void 0;if(!c||!l||!u)return;const{isSilent:h,scheduledAt:m}=s,g=u.filter((e=>!(0,d.jM)(e)));g.length&&(0,Z.t9)("forwardMessages",{fromChat:c,toChat:l,messages:g,serverTimeOffset:(0,a.Rd)().serverTimeOffset,isSilent:h,scheduledAt:m}),u.filter((e=>(0,d.jM)(e))).forEach((e=>{const{text:t,entities:s}=e.content.text||{},{sticker:a,poll:n}=e.content;L({chat:l,text:t,entities:s,sticker:a,poll:n,isSilent:h,scheduledAt:m})})),(0,a.R3)({...(0,a.Rd)(),forwardMessages:{}})})),(0,a.Q6)("loadScheduledHistory",((e,t,s)=>{const{chatId:n}=s,o=(0,i.Z1)(e,n);o&&async function(e){const t=await(0,Z.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:s}=t,n=(0,g.ee)(s,"id"),o=Object.keys(n).map(Number).sort(((e,t)=>t-e));let i=(0,a.Rd)();i=(0,r.w3)(i,e.id,n),i=(0,r.pf)(i,e.id,u._f,"scheduledIds",o),(0,a.R3)(i)}(o)})),(0,a.Q6)("sendScheduledMessages",((e,t,s)=>{const{chatId:a,id:n}=s,o=(0,i.Z1)(e,a);o&&(0,Z.t9)("sendScheduledMessages",{chat:o,ids:[n]})})),(0,a.Q6)("rescheduleMessage",((e,t,s)=>{const{chatId:a,messageId:n,scheduledAt:o}=s,r=(0,i.Z1)(e,a),c=r&&(0,i.Tm)(e,r.id,n);r&&c&&(0,Z.t9)("rescheduleMessage",{chat:r,message:c,scheduledAt:o})})),(0,a.Q6)("requestThreadInfoUpdate",((e,t,s)=>{const{chatId:a,threadId:n}=s,o=(0,i.Cm)(e,a,n);o&&(0,Z.t9)("requestThreadInfoUpdate",{chat:o,threadId:n})})),(0,a.Q6)("loadPinnedMessages",((e,t,s)=>{const{chatId:n}=s,o=(0,i.Z1)(e,n);o&&async function(e){const t=await(0,Z.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:s,chats:n,users:o}=t,i=(0,g.ee)(s,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,a.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)(n,"id")),(0,a.R3)(d)}(o)}));var A=s(5765);const O=(0,P.P2)((e=>e()),500,!1);async function F(e,t){const s=await(0,Z.t9)("searchGifs",{query:e,offset:t});s&&(0,a.R3)((0,r.rq)((0,a.Rd)(),!t,s.gifs,s.nextOffset))}(0,a.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,Z.t9)("fetchStickerSets",{hash:e});t&&(0,a.R3)((0,r.z3)((0,a.Rd)(),"added",t.hash,t.sets))}(t)})),(0,a.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,P.wO)(500)})()})),(0,a.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,Z.t9)("fetchRecentStickers",{hash:e});if(!t)return;const s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,recent:t}})}(t)})),(0,a.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,Z.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,favorite:t}})}(t)})),(0,a.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,Z.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,a.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,Z.t9)("fetchFeaturedStickers",{hash:e});t&&(0,a.R3)((0,r.z3)((0,a.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,a.Q6)("loadStickers",((e,t,s)=>{const{stickerSetId:n,stickerSetShortName:o}=s;let{stickerSetAccessHash:c}=s;if(!c&&!o){const t=(0,i.Ny)(e,n);if(!t)return;c=t.accessHash}!async function(e,t,s){const n=await(0,Z.t9)("fetchStickers",{stickerSetShortName:s,stickerSetId:e,accessHash:t});if(!n)return;const{set:o,stickers:i,packs:c}=n;let d=(0,a.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,a.R3)(d)}(n,c,o)})),(0,a.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,Z.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:s}=e;(0,a.R3)((0,r.g_)((0,a.Rd)(),{...t,stickers:s}))}()})),(0,a.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,Z.t9)("fetchSavedGifs",{hash:e});if(!t)return;const s=(0,a.Rd)();(0,a.R3)({...s,gifs:{...s.gifs,saved:t}})}(t)})),(0,a.Q6)("faveSticker",((e,t,s)=>{const{sticker:a}=s;a&&(0,Z.t9)("faveSticker",{sticker:a})})),(0,a.Q6)("unfaveSticker",((e,t,s)=>{const{sticker:n}=s;n&&function(e){const t=(0,a.Rd)();(0,a.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((({id:t})=>t!==e.id))}}}),(0,Z.t9)("faveSticker",{sticker:e,unfave:!0})}(n)})),(0,a.Q6)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:a}=s,n=(0,i.Ny)(e,a);if(!n)return;const{accessHash:o,installedDate:r}=n;(0,Z.t9)(r?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.Q6)("loadEmojiKeywords",((e,t,s)=>{var n;const{language:o}=s;let r=e.emojiKeywords[o];null!==(n=r)&&void 0!==n&&n.isLoading||((0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}}),(async()=>{var t;const s=await(0,Z.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});e=(0,a.Rd)(),r=e.emojiKeywords[o],s?(0,a.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,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})())})),(0,a.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:n}=s;n&&O((()=>{!async function(e,t){const s=await(0,Z.t9)("searchStickers",{query:e,hash:void 0});if(!s)return;const n=(0,a.Rd)(),{setsById:o,added:i}=n.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,A.Z)(s,e)&&c.unshift(t)}})),(0,a.R3)((0,r.z3)(n,"search",s.hash,s.sets,c))}(n)}))})),(0,a.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:a}=s;"string"==typeof a&&O((()=>{F(a)}))})),(0,a.Q6)("searchMoreGifs",(e=>{const{query:t,offset:s}=e.gifs.search;"string"==typeof t&&O((()=>{F(t,s)}))})),(0,a.Q6)("loadStickersForEmoji",((e,t,s)=>{const{emoji:n}=s,{hash:o}=e.stickers.forEmoji;O((()=>{!async function(e,t){let s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,forEmoji:{...s.stickers.forEmoji,emoji:e}}});const n=await(0,Z.t9)("fetchStickersForEmoji",{emoji:e,hash:t});s=(0,a.Rd)(),n&&s.stickers.forEmoji.emoji===e&&(s=(0,r.IM)(s,e,n.stickers,n.hash),(0,a.R3)(s))}(n,o)}))})),(0,a.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.Q6)("openStickerSetShortName",((e,t,s)=>{const{stickerSetShortName:a}=s;return{...e,openedStickerSetShortName:a}}));var U=s(790);const D=(0,P.P2)((e=>e()),500,!1);async function Q(e="",t,s,o,c,d){let l;if(o){const a=await(0,Z.t9)("searchMessagesLocal",{chatOrUser:o,query:e,type:t,limit:n.Hk,offsetId:s,minDate:d,maxDate:c});if(a){const{messages:e,users:t,totalCount:s,nextOffsetId:n}=a;l={messages:e,users:t,chats:[],totalCount:s,nextRate:n}}}else l=await(0,Z.t9)("searchMessagesGlobal",{query:e,offsetRate:s,limit:n.Hk,type:t,maxDate:c,minDate:d});let u=(0,a.Rd)();const h=(0,i.JX)(u);if(!l||""!==e&&e!==h)return void(0,a.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,a.R3)(u)}(0,a.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{chatId:n}=e.globalSearch,{query:o}=s;o&&!n&&D((()=>{!async function(e){const t=await(0,Z.t9)("searchChats",{query:e});let s=(0,a.Rd)();const n=(0,i.JX)(s);if(!t||!n||e!==n)return void(0,a.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:d.map((({id:e})=>e)),userIds:l.map((({id:e})=>e))}}),(0,a.R3)(s)}(o)}))})),(0,a.Q6)("setGlobalSearchDate",((e,t,s)=>{const{date:n}=s,o=n?(0,U.IS)(n):n,c=(0,r.No)(e,{date:n,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,a.R3)(c);const{chatId:d}=e.globalSearch;Q("","text",void 0,d?(0,i.Z1)(e,d):void 0,o,n)})),(0,a.Q6)("searchMessagesGlobal",((e,t,s)=>{var a;const{query:n,resultsByType:o,chatId:r,date:c}=e.globalSearch,d=c?(0,U.IS)(c):c,{type:l}=s;Q(n,l,null==o||null===(a=o[l])||void 0===a?void 0:a.nextOffsetId,r?(0,i.Z1)(e,r):void 0,d,c)})),(0,a.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 a=(0,i.tZ)(e,t,s);m=null==a?void 0:a.topMessageId}!async function(e,t,s,o,c){const d=await(0,Z.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:s,limit:n.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,a.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,a.R3)(I))}(o,s,m,d,h)})),(0,a.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,Z.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:n.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,a.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,a.R3)(f))}(s,c,u)})),(0,a.Q6)("searchMessagesByDate",((e,t,s)=>{const{timestamp:n}=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,Z.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});s&&(0,a.uC)().focusMessage({chatId:e.id,messageId:s})}(r,n)})),(0,a.Q6)("checkPublicLink",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};if(!n)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,n,{isUsernameAvailable:void 0}),(0,a.R3)(e);const t=await(0,Z.t9)("checkChatUsername",{username:o});e=(0,a.Rd)(),e=(0,r.H9)(e,t?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,n,{isUsernameAvailable:t}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePublicLink",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};let o=n&&(0,i.Z1)(e,n);if(!n||!o)return;const{username:c}=s;(async()=>{if(e=(0,r.H9)(e,h.wv.InProgress),(0,a.R3)(e),(0,d.G9)(o)){if(o=await(0,Z.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const s=await(0,Z.t9)("setChatUsername",{chat:o,username:c});e=(0,a.Rd)(),e=(0,r.H9)(e,s?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,n,{isUsernameAvailable:void 0}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t&&(0,i.Z1)(e,t);t&&s&&(0,Z.t9)("updatePrivateLink",{chat:s})}));var $=s(7358);async function q(){const e=await(0,Z.t9)("fetchChats",{limit:n.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,a.Rd)().serverTimeOffset});if(!e)return;let t=(0,a.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,a.R3)(t)}async function H(){let e=(0,a.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:s}=e.contactList||{};if(!(s&&s.length||t&&t.length))return;const n=[...t||[],...s||[]].map((t=>(0,i.dy)(e,t))).filter(Boolean),o=await(0,Z.t9)("fetchUsers",{users:n});o&&(e=(0,a.Rd)(),e=(0,r.eD)(e,(0,g.ee)(o,"id")),(0,a.R3)(e))}function G(e){return(0,Z.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(n.hT/2)+1),limit:n.hT})}(0,a.Q6)("sync",((e,t)=>{!async function(e){n.eM&&console.log(">>> START SYNC"),await(0,Z.t9)("fetchCurrentUser");const t=await async function(){var e;let t=(0,a.Rd)();const s=await(0,Z.t9)("fetchChats",{limit:n.Ov,withPinned:!0,serverTimeOffset:t.serverTimeOffset,lastLocalServiceMessage:null===(e=(0,i.VF)(t))||void 0===e?void 0:e.message});if(!s)return;t=(0,a.Rd)();const{recentlyFoundChatIds:o}=t.globalSearch,{userIds:c}=t.contactList||{},{currentUserId:l}=t,h=[...o||[],...c||[],...l?[l]:[]],m=h.map((e=>(0,i.dy)(t,e))).filter(Boolean),f=h.map((e=>(0,i.Z1)(t,e))).filter(Boolean),{chatId:p}=(0,i.Bt)(t)||{};if(p){const e=(0,i.Z1)(t,p);if(e&&!h.includes(p)&&f.push(e),(0,d.YC)(p)){const e=(0,i.dy)(t,p);e&&!h.includes(p)&&m.push(e)}}return m.push(...s.users),f.push(...s.chats),t=(0,r.SL)(t,(0,g.ee)(f,"id")),t=(0,r.Mg)(t,"active",s.chatIds),t={...t,chats:{...t.chats}},t=(0,r.vv)(t,"active",s),Object.keys(s.draftsById).forEach((e=>{t=(0,r.pf)(t,e,u._f,"draft",s.draftsById[e])})),Object.keys(s.replyingToById).forEach((e=>{t=(0,r.pf)(t,e,u._f,"replyingToId",s.replyingToById[e])})),(0,a.R3)(t),p&&!t.chats.byId[p]&&(0,a.uC)().openChat({id:void 0}),m}();await async function(e){let t=!1,s=e||[],o=(0,a.Rd)();const{chatId:c,threadId:d}=(0,i.Bt)(o)||{},l=Object.keys(o.messages.byChatId).reduce(((e,t)=>{const s=(0,i.Ms)(o,t,u._f);return s&&(e[t]=s),e}),{});if(c){const e=await G(o.chats.byId[c]);o=(0,a.Rd)();const{chatId:l}=(0,i.Bt)(o)||{},h=d&&(0,i.tZ)(o,c,d);if(e&&l===c){const a=o.messages.byChatId[c],i=c===n.aw?o.serviceNotifications.map((({message:e})=>e)):[],l=[].concat(e.messages,i),m=(0,g.ee)(l,"id"),f=Object.keys(m).map(Number);if(o={...o,messages:{...o.messages,byChatId:{}}},o=(0,r.c_)(o,c,m),o=(0,r.xj)(o,c,u._f,f),o=(0,r.y9)(o,c,u._f,f),d&&h&&h.originChannelId){const{originChannelId:e}=h,t=o.messages.byChatId[e],s=await G(o.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),n=Object.keys(e).map(Number);o={...o,messages:{...o.messages,byChatId:{...o.messages.byChatId,[h.originChannelId]:{byId:e,threadsById:{[u._f]:{...null==t?void 0:t.threadsById[u._f],listedIds:n,viewportIds:n,outlyingIds:void 0}}},[c]:{...o.messages.byChatId[c],threadsById:{...o.messages.byChatId[c].threadsById,[d]:{...null==a?void 0:a.threadsById[d],outlyingIds:void 0}}}}}}}}o=(0,r.GL)(o,(0,g.ee)(e.chats,"id")),o=(0,r.j6)(o,c,e.threadInfos),t=!0,s=Array.prototype.concat(s,e.users)}}t||(o={...o,messages:{...o.messages,byChatId:{}}}),Object.keys(l).forEach((e=>{o=(0,r.pf)(o,e,u._f,"draft",l[e])})),e?o=(0,r.s5)(o,(0,g.ee)(s,"id")):s&&(o=(0,r.eD)(o,(0,g.ee)(s,"id"))),(0,a.R3)(o);const{chatId:h,messageId:m}=o.audioPlayer;h&&m&&!(0,i.hj)(o,h,m)&&(0,a.uC)().closeAudioPlayer()}(t),(0,a.R3)({...(0,a.Rd)(),lastSyncTime:Date.now()}),n.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,a.Q6)("afterSync",((e,t)=>{!async function(e){n.eM&&console.log(">>> START AFTER-SYNC"),e.loadFavoriteStickers(),await Promise.all([H(),q()]),await(0,Z.t9)("fetchCurrentUser"),(0,$.w)((0,i.A1)((0,a.Rd)())),n.eM&&console.log(">>> FINISH AFTER-SYNC")}(t)}));const j=(0,P.Ds)((e=>e()),500,!1,!0),_=(0,P.P2)((e=>e()),500,!1);function V(e,t,s){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:s}}}}function z(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,a.Q6)("loadFullUser",((e,t,s)=>{const{userId:a}=s,n=(0,i.dy)(e,a);if(!n)return;const{id:o,accessHash:r}=n;j((()=>(0,Z.t9)("fetchFullUser",{id:o,accessHash:r})))})),(0,a.Q6)("loadUser",((e,t,s)=>{const{userId:n}=s,o=(0,i.dy)(e,n);o&&(async()=>{const t=await(0,Z.t9)("fetchUsers",{users:[o]});t&&(e=(0,a.Rd)(),e=(0,r.eD)(e,(0,g.ee)(t,"id")),(0,a.R3)(e))})()})),(0,a.Q6)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,f.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,Z.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:s}=e;let n=(0,a.Rd)();n=(0,r.Sh)(n,(0,g.ee)(s,"id")),n={...n,topPeers:{...n.topPeers,userIds:t,lastRequestedAt:(0,f.b)(n.serverTimeOffset)}},(0,a.R3)(n)}()})),(0,a.Q6)("loadContactList",(()=>{!async function(){const e=await(0,Z.t9)("fetchContactList");if(!e)return;let t=(0,r.Sh)((0,a.Rd)(),(0,g.ee)(e.users,"id"));t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id"));const s=e=>e.lastName||e.firstName||"",n=new Intl.Collator("en-US"),o=e.users.sort(((e,t)=>n.compare(s(e),s(t)))).filter((e=>!e.isSelf));(0,a.R3)({...t,contactList:{userIds:o.map((e=>e.id))}})}()})),(0,a.Q6)("loadCurrentUser",(()=>{(0,Z.t9)("fetchCurrentUser")})),(0,a.Q6)("loadCommonChats",(e=>{var t;const{chatId:s}=(0,i.Bt)(e)||{},n=s?(0,i.dy)(e,s):void 0;!n||(0,d.cS)(n)||null!==(t=n.commonChats)&&void 0!==t&&t.isFullyLoaded||(async()=>{var t,s;const o=null===(t=n.commonChats)||void 0===t?void 0:t.maxId,i=await(0,Z.t9)("fetchCommonChats",n.id,n.accessHash,o);if(!i)return;const{chats:c,chatIds:d,isFullyLoaded:l}=i;e=(0,a.Rd)(),c.length&&(e=(0,r.fZ)(e,(0,g.ee)(c,"id"))),e=(0,r.Nq)(e,n.id,{commonChats:{maxId:d.length?d[d.length-1]:"0",ids:(0,g.Tw)(((null===(s=n.commonChats)||void 0===s?void 0:s.ids)||[]).concat(d)),isFullyLoaded:l}}),(0,a.R3)(e)})()})),(0,a.Q6)("updateContact",((e,t,s)=>{const{userId:n,isMuted:o,firstName:c,lastName:d}=s;!async function(e,t,s,n){const o=(0,a.Rd)(),c=(0,i.dy)(o,e);if(!c)return;let d;if((0,a.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.InProgress)),c.phoneNumber)d=await(0,Z.t9)("updateContact",{phone:c.phoneNumber,firstName:s,lastName:n});else{const{id:e,accessHash:t}=c;d=await(0,Z.t9)("addContact",{id:e,accessHash:t,phoneNumber:"",firstName:s,lastName:n})}d&&(0,a.R3)((0,r.Nq)((0,a.Rd)(),c.id,{firstName:s,lastName:n})),(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.Complete))}(n,o,c,d)})),(0,a.Q6)("deleteUser",((e,t,s)=>{const{userId:n}=s;!async function(e){const t=(0,a.Rd)(),s=(0,i.dy)(t,e);if(!s)return;const{id:n,accessHash:o}=s;await(0,Z.t9)("deleteUser",{id:n,accessHash:o})}(n)})),(0,a.Q6)("loadProfilePhotos",((e,t,s)=>{const{profileId:n}=s,o=(0,d.YC)(n),c=o?(0,i.dy)(e,n):void 0,l=o?void 0:(0,i.Z1)(e,n);(c||l)&&(async()=>{const e=await(0,Z.t9)("fetchProfilePhotos",c,l);if(!e||!e.photos)return;let t=(0,a.Rd)();o?t=(0,r.Nq)(t,n,{photos:e.photos}):(t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.a4)(t,n,{photos:e.photos})),(0,a.R3)(t)})()})),(0,a.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:n}=s;n&&_((()=>{!async function(e){const t=await(0,Z.t9)("searchChats",{query:e});let s=(0,a.Rd)();const n=s.userSearch.query;if(!t||!n||e!==n)return void(0,a.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,a.R3)(s)}(n)}))})),(0,a.Q6)("addContact",((e,t,s)=>{const{userId:a}=s,n=(0,i.dy)(e,a);n&&(0,Z.t9)("addContact",(0,g.ei)(n,["id","accessHash","firstName","lastName","phoneNumber"]))}));const W=(0,P.Ds)((e=>e()),500,!1);async function Y(e,t,s,a){await(0,Z.t9)("sendMessage",{chat:e,text:s,replyingTo:a})}(0,a.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(n.FS)||o.value.match(n.g$)?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 n=await(0,Z.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:s});if(!n)return;const{showDialog:o,showNotification:r,toggleSafeLinkModal:i}=(0,a.uC)(),{message:c,alert:d,url:l}=n;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:a,value:n}=o;if(!s)return;n?t.getReceipt({receiptMessageId:n,chatId:s.id,messageId:a}):(t.getPaymentForm({chat:s,messageId:a}),t.setInvoiceMessageInfo((0,i.hj)(e,s.id,a)),t.openPaymentModal({chatId:s.id,messageId:a}));break}}})),(0,a.Q6)("sendBotCommand",((e,t,s)=>{const{command:a,chatId:n}=s,{currentUserId:o}=e,r=n?(0,i.Z1)(e,n):(0,i.jr)(e),c=(0,i.Bt)(e);if(!o||!r||!c)return;const{threadId:d}=c;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r.id,threadId:d,value:!1}),Y(r,0,a,(0,i.Yy)(e,r.id,d))})),(0,a.Q6)("restartBot",((e,t,s)=>{const{chatId:n}=s,{currentUserId:o}=e,c=(0,i.jr)(e),d=o&&(0,i.IK)(e,n);o&&c&&d&&(async()=>{await(0,Z.t9)("unblockContact",d.id,d.accessHash)&&((0,a.R3)((0,r.rB)((0,a.Rd)(),d.id)),Y(c,0,"/start"))})()})),(0,a.Q6)("loadTopInlineBots",(e=>{const{lastRequestedAt:t}=e.topInlineBots;t&&(0,f.b)(e.serverTimeOffset)-t<60||(async()=>{const t=await(0,Z.t9)("fetchTopInlineBots");if(!t)return;const{ids:s,users:n}=t;let o=(0,a.Rd)();o=(0,r.Sh)(o,(0,g.ee)(n,"id")),o={...o,topInlineBots:{...o.topInlineBots,userIds:s,lastRequestedAt:(0,f.b)(e.serverTimeOffset)}},(0,a.R3)(o)})()})),(0,a.Q6)("queryInlineBot",((e,t,s)=>{const{chatId:n,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:n}=await(0,Z.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!s||!n)return void(0,a.R3)(V(e,o,!1));e=(0,r.Sh)(e,{[s.id]:s}),e=(0,r.fZ)(e,{[n.id]:n}),t={id:s.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=V(e,o,t),(0,a.R3)(e)}(c!==t.query||t.canLoadMore)&&W((()=>{!async function({username:e,inlineBotData:t,chatId:s,query:n,offset:o}){let r=(0,a.Rd)();const c=(0,i.dy)(r,t.id),d=(0,i.Z1)(r,s);if(!c||!d)return;const l=t.query!==n;r=z(r,!0),r=V(r,e,{...t,query:n,...l&&{offset:void 0,results:[]}}),(0,a.R3)(r);const u=await(0,Z.t9)("fetchInlineBotResults",{bot:c,chat:d,query:n,offset:l?void 0:o}),h=r.inlineBots.byUsername[e];if(r=z((0,a.Rd)(),!1),!u||!h||n!==h.query)return void(0,a.R3)(r);const m=new Set((h.results||[]).map((e=>e.id))),g=u.results.filter((e=>!m.has(e.id)));r=V(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,a.R3)(r)}({username:o,inlineBotData:t,chatId:n,query:c,offset:d})}))}})()})),(0,a.Q6)("sendInlineBotResult",((e,t,s)=>{const{id:a,queryId:n}=s,o=(0,i.Bt)(e);if(!o||!a)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,Z.t9)("sendInlineBotResult",{chat:d,resultId:a,queryId:n,replyingTo:(0,i.Yy)(e,r,c)})})),(0,a.Q6)("resetInlineBot",((e,t,s)=>{const{username:n}=s;let o=e.inlineBots.byUsername[n];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,a.R3)(V(e,n,o)))})),(0,a.Q6)("startBot",((e,t,s)=>{const{botId:a,param:n}=s,o=(0,i.dy)(e,a);o&&(async()=>{await(0,Z.t9)("startBot",{bot:o,startParam:n})})()})),s(9667),(0,a.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,Z.t9)("getPasswordInfo");if(!e)return;let t=(0,a.Rd)();t=(0,r.BI)(t,{hasPassword:e.hasPassword}),t=(0,r.IE)(t,{hint:e.hint}),(0,a.R3)(t)})()})),(0,a.Q6)("checkPassword",((e,t,s)=>{const{currentPassword:n,onSuccess:o}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("checkPassword",n);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("clearPassword",((e,t,s)=>{const{currentPassword:n,onSuccess:o}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("clearPassword",n);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("updatePassword",((e,t,s)=>{const{currentPassword:n,password:o,hint:i,email:c,onSuccess:d}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("updatePassword",n,o,i,c);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),e&&d()})()})),(0,a.Q6)("updateRecoveryEmail",((e,t,s)=>{const{currentPassword:n,email:o,onSuccess:i}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("updateRecoveryEmail",n,o);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&i()})()})),(0,a.Q6)("provideTwoFaEmailCode",((e,t,s)=>{const{code:a}=s;(0,Z.t9)("provideRecoveryEmailCode",a)})),(0,a.Q6)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,a.Q6)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:n,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,n){const o=await(0,Z.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:s,shouldSave:n});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let d=(0,r.vT)((0,a.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,a.R3)(d)}(d,l,n,o)})),(0,a.Q6)("getPaymentForm",((e,t,s)=>{const{chat:n,messageId:o}=s;n&&o&&async function(e,t){const s=await(0,Z.t9)("getPaymentForm",{chat:e,messageId:t});if(!s)return;let n=(0,r._7)((0,a.Rd)(),s),o=h.KB.PaymentInfo;n.payment.invoice&&(n.payment.invoice.shippingAddressRequested||n.payment.invoice.nameRequested||n.payment.invoice.phoneRequested||n.payment.invoice.emailRequested)&&(o=h.KB.ShippingInfo),n=(0,r.Q$)(n,o),(0,a.R3)(n)}(n,o)})),(0,a.Q6)("getReceipt",((e,t,s)=>{const{receiptMessageId:n,chatId:o,messageId:c}=s,d=o&&(0,i.Z1)(e,o);c&&n&&d&&async function(e,t,s){const n=await(0,Z.t9)("getReceipt",e,s);if(!n)return;let o=(0,a.Rd)();const c=(0,i.hj)(o,e.id,t);o=(0,r.Dq)(o,n,c),(0,a.R3)(o)}(d,c,n)})),(0,a.Q6)("clearPaymentError",(e=>{(0,a.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,a.Q6)("clearReceipt",(e=>{(0,a.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,a.Q6)("sendCredentialsInfo",((e,t,s)=>{const n=(0,i.$$)(e);if(!n)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}),n=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 n.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,a.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,h.KB.Checkout),(0,a.R3)(i)}(c,n)})),(0,a.Q6)("sendPaymentForm",((e,t,s)=>{const{shippingOptionId:n,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,n,o,i){if(await(0,Z.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:n,requestedInfoId:o,shippingOptionId:i})){const e=(0,r.bp)((0,a.Rd)());(0,a.R3)((0,r.WY)(e))}}(d,l,u,{save:o,data:g},h,n)})),(0,a.Q6)("setPaymentStep",((e,t,s={})=>(0,r.Q$)(e,s.step||h.KB.ShippingInfo))),(0,a.Q6)("setInvoiceMessageInfo",((e,t,s)=>(0,r.nA)(e,s))),s(4907);var X=s(8406);const K=(0,P.P2)((e=>e()),500,!0);(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{s.noTopChatsRequest||(0,i.N)(e,s.id)||t.loadTopChats();const n=(0,r.a4)(e,s.id,s.chat,s.newProfilePhoto);(0,a.R3)(n),K((()=>(0,$.w)((0,i.A1)((0,a.Rd)())))),s.chat.id&&(0,X.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const n=(0,i.Ek)(e,s.id);if(!n)break;e=(0,r.B1)(e,n,[s.id]),e=(0,r.a4)(e,s.id,{isNotJoined:!1}),(0,a.R3)(e);const o=(0,i.Z1)(e,s.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":(0,a.R3)((0,r.Dd)(e,s.id));break;case"updateChatInbox":(0,a.R3)((0,r.a4)(e,s.id,s.chat)),K((()=>(0,$.w)((0,i.A1)((0,a.Rd)()))));break;case"updateChatTypingStatus":{const{id:t,typingStatus:n}=s;(0,a.R3)((0,r.a4)(e,t,{typingStatus:n})),setTimeout((()=>{const e=(0,a.Rd)(),s=(0,i.Z1)(e,t);s&&n&&s.typingStatus&&s.typingStatus.timestamp===n.timestamp&&(0,a.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:n}=s,{chatId:o,threadId:c,type:d}=(0,i.Bt)(e)||{};if(n.senderId===e.currentUserId&&!n.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,a.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,$.w)((0,i.A1)((0,a.Rd)())),(0,X.zP)({chat:l,message:n,isActiveChat:h});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:n}=s;if(!1!==n.hasUnreadMention)return;t.forEach((t=>{const a="channelId"in s?s.channelId:(0,i.X5)(e,t),n=(0,i.Z1)(e,a);null!=n&&n.unreadMentionsCount&&(e=(0,r.a4)(e,a,{unreadMentionsCount:n.unreadMentionsCount-1}))})),(0,a.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=s,n=e.chats.byId[s.id];if(!n)return;(0,a.R3)((0,r.a4)(e,s.id,{fullInfo:{...n.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=s,r=o===n.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:t.length?t:void 0}}},(0,a.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 a=s||[];if(o){if(!a.includes(t)){if("active"===r&&a.length>=n.EG){const t=e.chats.listIds.active;a=a.filter((e=>t&&t.includes(e)))}a=[t,...a]}}else a=a.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:a.length?a:void 0}}}}(0,a.R3)(e);break}case"updateChatListType":{const{id:t,folderId:n}=s;(0,a.R3)((0,r.Pi)(e,t,n));break}case"updateChatFolder":{const{id:t,folder:n}=s,{byId:o,orderedIds:r}=e.chatFolders,i=n?{...o,[t]:n}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=n?r&&r.includes(t)?r:[...r||[],t]:r?r.filter((e=>e!==t)):void 0;(0,a.R3)({...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=s;(0,a.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=s;(0,a.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[s.id],{replacedMembers:n,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(n)l=n,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 n=l.filter((({isOwner:e,isAdmin:t})=>e||t));(0,a.R3)((0,r.a4)(e,s.id,{membersCount:l.length,fullInfo:{...t.fullInfo,members:l,adminMembers:n}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:n}=s,o=e.chats.byId[t];null!=o&&o.photos&&(0,a.R3)((0,r.a4)(e,t,{photos:o.photos.filter((e=>!n.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:n,date:o,replyingToId:i}=s;e.chats.byId[t]&&(e=(0,r.pf)(e,t,u._f,"draft",n),e=(0,r.pf)(e,t,u._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:o}),(0,a.R3)(e));break}case"showInvite":{const{data:e}=s;t.showDialog({data:e});break}}}));const J=350;function ee(e,t,s,a,n=!1){const o=n?(0,i.Tm)(e,t,s):(0,i.hj)(e,t,s);if(o&&a.content){const{photo:e,video:t,sticker:s,document:n}=(0,d.qp)(o);e&&a.content.photo?(a.content.photo.blobUrl=e.blobUrl,a.content.photo.thumbnail=e.thumbnail):t&&a.content.video?a.content.video.blobUrl=t.blobUrl:s&&a.content.sticker?a.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:n&&a.content.document&&(a.content.document.previewBlobUrl=n.previewBlobUrl)}return n?(0,r.P4)(e,t,s,a):(0,r.cY)(e,t,s,a)}function te(e,t,s,a){const{chatId:n}=s,{threadInfo:o}=(0,i.Db)(e,n,s)||{};if(!o&&s.replyToMessageId){const o=(0,i.hj)(e,n,s.replyToMessageId);o?e=(0,r.lG)(e,o,n,s.id,a):t.loadMessage({chatId:n,messageId:s.replyToMessageId,threadUpdate:{isDeleting:a,lastMessageId:s.id}})}return e}function se(e,t,s){const{id:a,chatId:n}=s,{threadInfo:o,firstMessageId:c}=(0,i.Db)(e,n,s)||{},l=(0,i.Z1)(e,n),h=(null==l?void 0:l.unreadCount)&&!(0,i.gb)(e,n,u._f);if(e=te(e,t,s),o&&(!c&&(0,d.CI)(s)||(e=(0,r.xj)(e,n,o.threadId,[a]),(0,i.b9)(e,n,o.threadId)&&(e=(0,r.$S)(e,n,o.threadId,a),c||(e=(0,r.pf)(e,n,o.threadId,"firstMessageId",s.id)))),e=(0,r.pf)(e,n,o.threadId,"threadInfo",{...o,lastMessageId:s.id,messagesCount:o.messagesCount+1})),h)return e;if(e=(0,r.xj)(e,n,u._f,[a]),(0,i.b9)(e,n,u._f)){const t=(0,i.It)(e,n,u._f),s=(0,r.$S)(e,n,u._f,a),o=(0,i.Cb)(s,n,u._f);t&&!o.includes(t)||(e=s)}return e}function ae(e,t,s,a=!1){var n;const{chats:o}=e,i=null===(n=o.byId[t])||void 0===n?void 0:n.lastMessage;return!i||a||i.id===s.id||i.id===s.previousLocalId||s.id>i.id?(0,r.a4)(e,t,{lastMessage:s}):e}function ne(e,t){const s=(0,i.Zw)(e,t),a=(0,i.gb)(e,t,u._f);if(!s||!a)return;let n=a.length;for(;n--;){const e=s[a[n]];if(!e.isDeleting)return e}}function oe(e,t,s,n){if(e){t.forEach((t=>{const s=ne(n=(0,r.cY)(n,e,t,{isDeleting:!0}),e);s&&(n=ae(n,e,s,!0))})),(0,a.R3)(n),s.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const a=(0,i.hj)(n,e,t);if(!a)return;n=te(n,s,a,!0);const{threadInfo:r}=(0,i.Db)(n,e,a)||{};r&&o.push(r.threadId)})),(0,a.R3)(n),void setTimeout((()=>{(0,a.R3)((0,r.K4)((0,a.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{s.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),J)}const o=[];t.forEach((e=>{const t=(0,i.X5)(n,e);if(t){o.push(t);const s=ne(n=(0,r.cY)(n,t,e,{isDeleting:!0}),t);s&&(n=ae(n,t,s,!0)),setTimeout((()=>{(0,a.R3)((0,r.K4)((0,a.Rd)(),t,[e]))}),J)}})),(0,a.R3)(n),(0,g.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:o,id:c,message:l,shouldForceReply:h}=s;e=se(e=ee(e,o,c,l),t,l),l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),(0,a.R3)(e);const m=(0,i.hj)(e,o,c);if((0,i.hg)(e,o,l)){var n;if(l.isOutgoing&&(null===(n=l.content)||void 0===n||!n.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((()=>{let e=(0,a.Rd)();h&&(e=(0,r.pf)(e,o,u._f,"replyingToId",c)),(0,a.R3)(ae(e,o,m))}),J)}else(0,a.R3)(ae((0,a.Rd)(),o,m));(0,i.N)(e,o)||t.loadTopChats();break}case"newScheduledMessage":{const{chatId:t,id:n,message:o}=s;e=ee(e,t,n,o,!0);const c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,n])),(0,a.R3)(e);break}case"updateMessage":{var o,c;const{chatId:n,id:d,message:l}=s;if(!(0,i.hj)(e,n,d))return;e=ee(e,n,d,l);const h=(0,i.hj)(e,n,d);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),e=ae(e,n,h),(0,a.R3)(e);const m=(0,i.Z1)(e,n);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,n,l)&&(0,i.b9)(e,n,(null===(c=l.threadInfo)||void 0===c?void 0:c.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:n,message:o}=s;if(!(0,i.Tm)(e,t,n))return;e=ee(e,t,n,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,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:n,localId:o,message:c}=s;e=se(e,t,c);const d=(0,i.hj)(e,n,o);e=(0,r.K4)(e,n,[o]),c.isScheduled&&(e=(0,r.bV)(e,n,[o])),e=(0,r.cY)(e,n,c.id,{...d,...c,previousLocalId:o});const l=(0,i.hj)(e,n,c.id);e=ae(e,n,l);const u=(0,i.Db)(e,n,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,r.pf)(e,n,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:n,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,n);e=(0,r.bV)(e,t,[n]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:n}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:n,messageIds:o}=s,c=(0,i.KB)(e,t)||[],d=n?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,a.R3)((0,r.pf)(e,t,u._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:n,threadInfo:o,firstMessageId:c}=s,d={...(0,i.tZ)(e,t,n),...o};if(!d.threadId)return;e=(0,r.Xg)(e,t,n,d),c&&(e=(0,r.pf)(e,t,n,"firstMessageId",c)),(0,a.R3)(e);break}case"resetMessages":{const{id:n}=s,o=(0,i.Zw)(e,n);o&&!(0,d.YC)(n)&&(e=(0,r.K4)(e,n,Object.keys(o).map(Number)),(0,a.R3)(e),t.loadFullChat({chatId:n,force:!0}));break}case"deleteMessages":{const{ids:a,chatId:n}=s;oe(n,a,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:n}=s;!function(e,t,s,n){e&&(t.forEach((t=>{n=(0,r.P4)(n,e,t,{isDeleting:!0})})),(0,a.R3)(n),setTimeout((()=>{n=(0,r.bV)((0,a.Rd)(),e,t);const s=(0,i.Fn)(n,e);n=(0,r.pf)(n,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,a.R3)(n)}),J))}(n,t,0,e);break}case"deleteHistory":{const{chatId:a}=s,n=e.messages.byChatId[a];n?oe(a,Object.keys(n.byId).map(Number),t,e):t.requestChatUpdate({chatId:a});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:n}=s;t.forEach((t=>{const s=(0,i.X5)(e,t);s&&(e=(0,r.cY)(e,s,t,n))})),(0,a.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:n,messageUpdate:o}=s;n.forEach((s=>{e=(0,r.cY)(e,t,s,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:n}=s,o=(0,i.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...n},{results:s}=t.results||{};if(s&&!s.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,a=e&&e.filter((e=>e.isChosen));a&&a.forEach((e=>{const a=s.findIndex((t=>t.option===e.option));a>=0&&(t.results.results[a].isChosen=!0)}))}(0,a.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:n,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(n),o.forEach((t=>{const s=f.find((e=>e.option===t)),a=f.findIndex((e=>e.option===t)),o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,n===e.currentUserId&&(o.isChosen=!0),a?f[a]=o:f.push(o)})),(0,a.R3)((0,r.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...d,results:{...d.results,recentVoterIds:m,totalVoters:g,results:f}}}}));break}case"updateServiceNotification":{const{message:a}=s;(0,i.UW)(e)&&t.createServiceNotification({message:a});break}}}));const re=(0,P.P2)((function(){let e=(0,a.Rd)();ie.forEach((([t,s])=>{e=(0,r.Nq)(e,t,{status:s})})),(0,a.R3)(e),ie=[]}),3e3,!0);let ie=[];(0,a.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 a=s.userId,n=s.status,ie.push([a,n]),void re();case"updateUserFullInfo":{const{id:t,fullInfo:a}=s,n=e.users.byId[t];if(!n)return;return(0,r.Nq)(e,t,{fullInfo:{...n.fullInfo,...a}})}}var a,n})),(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateStickerSet":return(0,r.Rg)(e,s.id,s.stickerSet)}})),(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,r.O4)((0,a.Rd)(),s.id):(0,r.rB)((0,a.Rd)(),s.id);case"updateResetContactList":(0,a.R3)({...(0,a.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[s.key]=s.rules}})),(0,a.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:n,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:n})),(0,a.R3)((0,r.aK)(e,t,{isMuted:n,isSilent:o,shouldShowPreviews:i}));break}}})),(0,a.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 ce=s(8674),de=s(6752),le=s(1279),ue=s(1212),he=s(5332);function me(e){(0,o.d4)((()=>(0,P.Gq)(e)),[e])}var ge=s(9290);const fe=document.querySelector('meta[name="viewport"]'),pe=(null==fe?void 0:fe.getAttribute("content"))||"";function Ie(e){e.preventDefault()}var ve=s(6590),ye=s(3989),Ce=s(3455),Ze=s(706),Pe=s(2255);function we(){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 be=s(9107),Me=s(6917),Se=s(3106),Ee=s(8964),ke=s(231),Re=s(9589),Te=s(9187),Ne=s(3321);const Be=[0,1,2],xe=(0,o.X$)((0,a.c$)((e=>{const{query:t,fetchingStatus:s,chatId:a,date:n}=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:a,searchDate:n,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:a,onSelectContacts:r,onSelectArchived:i,setGlobalSearchChatId:c,onReset:l,searchQuery:u,isLoading:g,shouldSkipTransition:f,currentUserId:p,globalSearchChatId:I,searchDate:v,theme:y,animationLevel:C,chatsById:Z,openChat:P,openTipsChat:w,setGlobalSearchDate:b,setSettingOption:M})=>{const S=(0,be.Z)(),E=e===h.du.ChatList,k=(0,o.Ye)((()=>v?(0,U.xH)(new Date(1e3*v)):void 0),[v]),R=(0,o.Ye)((()=>E&&Z?Object.values(Z).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[E,Z]),T="web.telegram.org"===window.location.hostname,N=(0,o.Ye)((()=>({onTrigger:e,isOpen:t})=>o.ZP.createElement(ke.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,de.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)((()=>{P({id:p,shouldReplaceHistory:!0})}),[p,P]),L=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";M({theme:t}),M({shouldUseSystemTheme:!1}),(0,Me.Z)(t,C===n.zy)}),[C,M,y]),A=(0,o.I4)((e=>{e.stopPropagation();const t=0===C?2:0;Be.forEach(((e,s)=>{document.body.classList.toggle(`animation-level-${s}`,t===s)})),M({animationLevel:t})}),[C,M]),O=Boolean(I)||e===h.du.GlobalSearch||e===h.du.Contacts,F=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(Se.Z,{trigger:N,footer:`${n.iC} alpha ${n.Ji}`},o.ZP.createElement(Ee.Z,{icon:"saved-messages",onClick:x},S("SavedMessages")),o.ZP.createElement(Ee.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(Ee.Z,{icon:"user",onClick:r},S("Contacts")),o.ZP.createElement(Ee.Z,{icon:"settings",onClick:a},S("Settings")),o.ZP.createElement(Ee.Z,{icon:"darkmode",onClick:L},o.ZP.createElement("span",{className:"menu-item-name"},S("lng_menu_night_mode")),o.ZP.createElement(Ne.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(Ee.Z,{icon:"animations",onClick:A},o.ZP.createElement("span",{className:"menu-item-name capitalize"},S("Appearance.Animations").toLowerCase()),o.ZP.createElement(Ne.Z,{id:"animations",label:"Toggle Animations",checked:C>0})),o.ZP.createElement(Ee.Z,{icon:"help",onClick:()=>{w({langCode:S.code})}},S("TelegramFeatures")),o.ZP.createElement(Ee.Z,{icon:"bug",href:n.mU},"Report Bug"),T&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ee.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,ve.Wv)()}},"Switch to K Version"),o.ZP.createElement(Ee.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:ve.Wv},"Switch to Old Version"))),o.ZP.createElement(Re.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||v?"with-picker-item":"",value:t||u,focused:O,isLoading:g,placeholder:F,autoComplete:"off",canClose:Boolean(I||v),onChange:s,onReset:l,onFocus:B},k&&o.ZP.createElement(Te.Z,{icon:"calendar",title:k,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:b,clickArg:{date:void 0}}),I&&o.ZP.createElement(Te.Z,{chatOrUserId:I,onClick:c,canClose:!0,clickArg:{id:void 0}}))))})));var Le=s(9204);const Ae=(0,o.X$)((()=>{const e=(0,be.Z)();return o.ZP.createElement("div",{id:"ConnectionState",dir:e.isRtl?"rtl":void 0},o.ZP.createElement(Le.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},e("WaitingForNetwork")))}));var Oe=s(1174);var Fe=s(3133),Ue=s(9359);const De=(0,o.X$)((0,a.c$)((e=>{const{chats:{byId:t},users:{byId:s},chatFolders:{byId:a,orderedIds:n,activeChatFolder:o},currentUserId:r,lastSyncTime:c,shouldSkipHistoryAnimations:d}=e;return{chatsById:t,usersById:s,chatFoldersById:a,orderedFolderIds:n,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:a,notifyExceptions:n,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),C=(0,be.Z)();(0,o.d4)((()=>{l&&p()}),[l,p]);const Z=(0,o.Ye)((()=>r?r.map((e=>s[e]||{})).filter(Boolean):void 0),[s,r]),w=((e,t,s)=>{const a=((e,t=!1)=>(0,o.Ye)((()=>(0,P.P2)((e=>e()),e,!t)),[e,t]))(t,!0),[n,r]=(0,o.eJ)(),[i,c,d]=(0,Ze.Z)();return(0,ce.ZP)(c,d),(0,ge.Z)((()=>{i||a((()=>{r(e())}))}),s.concat([i])),n})((()=>{if(!Z||!Z.length)return;const s=Object.keys(e),o=Z.map((o=>{const{unreadDialogsCount:r,hasActiveDialogs:i}=(0,d.Fu)(e,t,o,s,a,n)||{};return{id:o.id,badgeCount:r,isBadgeActive:i}}));return(0,g.ee)(o,"id")}),3e3,[Z,e,t,a,n]),b=(0,o.Ye)((()=>{if(Z&&Z.length)return[{title:"en"===C.code?"All":C("FilterAllChats")},...Z.map((e=>({title:e.title,...null==w?void 0:w[e.id]})))]}),[Z,w,C]),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,Oe.s)(y.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Oe.e.Left?(I(Math.min(i+1,b.length-1)),!0):t===Oe.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,ye.Z)((()=>{S.current&&I(0)})):void 0),[i,I]),(0,ve.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,ue.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(Ue.Z,{folderType:"folder",folderId:t.id,isActive:e,onScreenSelect:f,foldersDispatch:h}):o.ZP.createElement(Ue.Z,{folderType:"all",isActive:e,foldersDispatch:h,onScreenSelect:f})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=b&&b.length?o.ZP.createElement(Fe.Z,{tabs:b,activeTab:i,onSwitchTab:M}):E?o.ZP.createElement("div",{className:(0,de.Z)("tabs-placeholder",k)}):void 0,o.ZP.createElement(Pe.Z,{ref:y,name:u?"none":C.isRtl?"slide-reversed":"slide",activeKey:i,renderCount:b?b.length:void 0},R))})));var Qe=s(9203),$e=s(8778),qe=s(4288);const He=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Ge=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)}));var je=s(2328);let _e;const Ve=(0,o.X$)((({isShown:e,onNewPrivateChat:t,onNewChannel:s,onNewGroup:a})=>{const[n,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{e||r(!1)}),[e]);const i=(0,be.Z)(),c=(0,de.Z)("NewChatButton",e&&"revealed",n&&"menu-is-open"),d=(0,o.I4)((()=>{_e&&(clearTimeout(_e),_e=void 0)}),[]),l=(0,o.I4)((()=>{_e&&(clearTimeout(_e),_e=void 0),_e=window.setTimeout((()=>{r(!1)}),750)}),[]);return o.ZP.createElement("div",{className:c,onMouseEnter:d,onMouseLeave:l},o.ZP.createElement(ke.Z,{round:!0,color:"primary",className:n?"active":"",onClick:()=>{r(!n)},ariaLabel:i(n?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(je.Z,{isOpen:n,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(Ee.Z,{icon:"channel",onClick:s},i("NewChannel")),o.ZP.createElement(Ee.Z,{icon:"group",onClick:a},i("NewGroup")),o.ZP.createElement(Ee.Z,{icon:"user",onClick:t},i("NewMessageTitle"))))}));var ze=s(126);const We=Object.keys(h.du).length/2;let Ye;const Xe=(0,a.c$)((e=>(0,g.ei)(e,["connectionState"])))((({content:e,searchQuery:t,searchDate:s,contactsFilter:a,shouldSkipTransition:n,foldersDispatch:r,onSearchQuery:i,onContentChange:c,onScreenSelect:d,onReset:l,connectionState:u})=>{const[g,f]=(0,o.eJ)(m.$b),p=!we()||"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]),C=(0,o.I4)((()=>{c(h.du.NewChannelStep1)}),[c]),Z=(0,o.I4)((()=>{c(h.du.NewGroupStep1)}),[c]),P=(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,Ye&&(clearTimeout(Ye),Ye=void 0),Ye=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,Ze.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:s,transitionClassNames:a}=(0,ue.Z)(e);return[s,a,()=>{window.location.reload()}]}(),k=(0,be.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:m.$b?void 0:w,onMouseLeave:m.$b?void 0:b},o.ZP.createElement(xe,{content:e,contactsFilter:a,onSearchQuery:i,onSelectSettings:v,onSelectContacts:y,onSelectArchived:P,onReset:l,shouldSkipTransition:n}),o.ZP.createElement(ze.Z,{isOpen:p,isCustom:!0,className:"connection-state-wrapper opacity-transition slow"},(()=>o.ZP.createElement(Ae,null))),o.ZP.createElement(Pe.Z,{name:n?"none":"zoom-fade",renderCount:We,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:h.du.ChatList,className:p?"pull-down":void 0},(n=>{switch(e){case h.du.ChatList:return o.ZP.createElement(De,{onScreenSelect:d,foldersDispatch:r});case h.du.GlobalSearch:return o.ZP.createElement(He,{searchQuery:t,searchDate:s,isActive:n,onReset:l});case h.du.Contacts:return o.ZP.createElement(Ge,{filter:a,isActive:n,onReset:l});default:return}})),M&&o.ZP.createElement(ke.Z,{fluid:!0,pill:!0,className:(0,de.Z)("btn-update",S),onClick:E},k("lng_update_telegram")),o.ZP.createElement(Ve,{isShown:g,onNewPrivateChat:y,onNewChannel:C,onNewGroup:Z}))})),Ke=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Je=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),et=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)}));var tt;!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"}(tt||(tt={}));const st=Object.keys(tt).length/2,at=(0,o.X$)((0,a.c$)((e=>{const{globalSearch:{query:t,date:s},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:n,leftColumnWidth:o}=e;return{searchQuery:t,searchDate:s,activeChatFolder:a,shouldSkipHistoryAnimations:n,leftColumnWidth:o}}),((e,t)=>(0,g.ei)(t,["setGlobalSearchQuery","setGlobalSearchChatId","resetChatCreation","setGlobalSearchDate","loadPasswordInfo","clearTwoFaError","setLeftColumnWidth","resetLeftColumnWidth"])))((({searchQuery:e,searchDate:t,activeChatFolder:s,shouldSkipHistoryAnimations:a,leftColumnWidth:n,setGlobalSearchQuery:r,setGlobalSearchChatId:i,resetChatCreation:c,setGlobalSearchDate:d,loadPasswordInfo:l,clearTwoFaError:u,setLeftColumnWidth:g,resetLeftColumnWidth:f})=>{const p=(0,o.sO)(null),[I,v]=(0,o.eJ)(h.du.ChatList),[y,C]=(0,o.eJ)(h.MT.Main),[Z,P]=(0,o.eJ)(""),[w,b]=(0,Ce.ZP)(),[M,S]=(0,o.eJ)(0);let E=tt.Main;switch(I){case h.du.Archived:E=tt.Archived;break;case h.du.Settings:E=tt.Settings;break;case h.du.NewChannelStep1:case h.du.NewChannelStep2:E=tt.NewChannel;break;case h.du.NewGroupStep1:case h.du.NewGroupStep2:E=tt.NewGroup}const k=(0,o.I4)((e=>{if(I!==h.du.NewGroupStep2||e)if(I!==h.du.NewChannelStep2||e){if(I===h.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(I===h.du.Settings)switch(y){case h.MT.EditProfile:case h.MT.Folders:case h.MT.General:case h.MT.Notifications:case h.MT.DataStorage:case h.MT.Privacy:case h.MT.Language:return void C(h.MT.Main);case h.MT.GeneralChatBackground:return void C(h.MT.General);case h.MT.GeneralChatBackgroundColor:return void C(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 C(h.MT.Privacy);case h.MT.PrivacyPhoneNumberAllowedContacts:case h.MT.PrivacyPhoneNumberDeniedContacts:return void C(h.MT.PrivacyPhoneNumber);case h.MT.PrivacyLastSeenAllowedContacts:case h.MT.PrivacyLastSeenDeniedContacts:return void C(h.MT.PrivacyLastSeen);case h.MT.PrivacyProfilePhotoAllowedContacts:case h.MT.PrivacyProfilePhotoDeniedContacts:return void C(h.MT.PrivacyProfilePhoto);case h.MT.PrivacyForwardingAllowedContacts:case h.MT.PrivacyForwardingDeniedContacts:return void C(h.MT.PrivacyForwarding);case h.MT.PrivacyGroupChatsAllowedContacts:case h.MT.PrivacyGroupChatsDeniedContacts:return void C(h.MT.PrivacyGroupChats);case h.MT.TwoFaNewPassword:return void C(h.MT.TwoFaDisabled);case h.MT.TwoFaNewPasswordConfirm:return void C(h.MT.TwoFaNewPassword);case h.MT.TwoFaNewPasswordHint:return void C(h.MT.TwoFaNewPasswordConfirm);case h.MT.TwoFaNewPasswordEmail:return void C(h.MT.TwoFaNewPasswordHint);case h.MT.TwoFaNewPasswordEmailCode:return void C(h.MT.TwoFaNewPasswordEmail);case h.MT.TwoFaChangePasswordCurrent:case h.MT.TwoFaTurnOff:case h.MT.TwoFaRecoveryEmailCurrentPassword:return void C(h.MT.TwoFaEnabled);case h.MT.TwoFaChangePasswordNew:return void C(h.MT.TwoFaChangePasswordCurrent);case h.MT.TwoFaChangePasswordConfirm:return void C(h.MT.TwoFaChangePasswordNew);case h.MT.TwoFaChangePasswordHint:return void C(h.MT.TwoFaChangePasswordConfirm);case h.MT.TwoFaRecoveryEmail:return void C(h.MT.TwoFaRecoveryEmailCurrentPassword);case h.MT.TwoFaRecoveryEmailCode:return void C(h.MT.TwoFaRecoveryEmail);case h.MT.FoldersCreateFolder:case h.MT.FoldersEditFolder:return void C(h.MT.Folders);case h.MT.FoldersIncludedChatsFromChatList:case h.MT.FoldersExcludedChatsFromChatList:return void C(h.MT.FoldersEditFolderFromChatList);case h.MT.FoldersEditFolderFromChatList:return v(h.du.ChatList),void C(h.MT.Main)}I!==h.du.ChatList||0!==s?(v(h.du.ChatList),P(""),r({query:""}),d({date:void 0}),i({id:void 0}),c(),setTimeout((()=>{S(Date.now())}),250)):v(h.du.GlobalSearch)}else v(h.du.NewChannelStep1);else v(h.du.NewGroupStep1)}),[I,s,y,r,d,i,c]),R=(0,o.I4)((t=>{I!==h.du.Contacts?(v(h.du.GlobalSearch),t!==e&&r({query:t})):P(t)}),[I,e,r]);(0,o.d4)((()=>I!==h.du.ChatList||0===s?(0,ye.Z)((()=>k())):void 0),[s,I,k]),(0,o.d4)((()=>{u(),y===h.MT.Privacy&&l()}),[u,l,y]);const{initResize:T,resetResize:N,handleMouseUp:B}=((e,t,s,a)=>{const[n,r,i]=(0,Ze.Z)(),[c,d]=(0,o.eJ)(),[l,u]=(0,o.eJ)();(0,o.d4)((()=>{e.current&&a&&(e.current.style.width=`${a}px`)}),[e,a]);const h=()=>{document.body.classList.remove("no-selection","cursor-ew-resize")};return(0,o.d4)((()=>{if(!n)return;const s=t=>{const s=Math.ceil(l+t.clientX-c);e.current.style.width=`${s}px`},a=()=>{h(),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",a,!1),document.removeEventListener("blur",a,!1),t(e.current.offsetWidth),i()};document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",a,!1),document.addEventListener("blur",a,!1)}),[l,c,e,t,n,i]),{initResize:t=>{document.body.classList.add("no-selection","cursor-ew-resize"),d(t.clientX),u(e.current.offsetWidth),r()},resetResize:t=>{t.preventDefault(),e.current.style.width="",s()},handleMouseUp:h}})(p,g,f,n),x=e=>{v(h.du.Settings),C(e)};return o.ZP.createElement("div",{id:"LeftColumn",ref:p},o.ZP.createElement(Pe.Z,{name:a?"none":m.s0,renderCount:st,activeKey:E,shouldCleanup:!0,cleanupExceptionKey:tt.Main},(s=>{switch(E){case tt.Archived:return o.ZP.createElement(et,{isActive:s,onReset:k,onContentChange:v});case tt.Settings:return o.ZP.createElement(Ke,{isActive:s,currentScreen:y,foldersState:w,foldersDispatch:b,onScreenSelect:x,onReset:k,shouldSkipTransition:a});case tt.NewChannel:return o.ZP.createElement(Je,{key:M,isActive:s,isChannel:!0,content:I,onContentChange:v,onReset:k});case tt.NewGroup:return o.ZP.createElement(Je,{key:M,isActive:s,content:I,onContentChange:v,onReset:k});default:return o.ZP.createElement(Xe,{content:I,searchQuery:e,searchDate:t,contactsFilter:Z,foldersDispatch:b,onContentChange:v,onSearchQuery:R,onScreenSelect:x,onReset:k,shouldSkipTransition:a})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:T,onMouseUp:B,onDoubleClick:N}))})));var nt=s(2420),ot=s(9524),rt=s(1394),it=s(3858);const ct=()=>{const[e,t]=(0,o.eJ)(it.Z.get());return(0,o.d4)((()=>{const e=(0,P.P2)((()=>{t(it.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var dt=s(2678);const lt=728;var ut=s(5780),ht=s(3570),mt=s(5790),gt=s(8360),ft=s(2155),pt=s(6058),It=s(8799);const vt=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"HeaderMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),yt=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a})=>{const n=(0,i.Z1)(e,t),o=Boolean(n&&(0,d.eA)(n));if(null!=n&&n.isRestricted||(0,i.CA)(e))return{noMenu:!0};const r=(0,i.IK)(e,t),c=(0,i.FM)(e,t),l="thread"===a&&s===u._f,h="thread"===a&&s!==u._f,m=(0,i.Jf)(e),g=Boolean(r&&(0,i.s4)(e,r.id)),f=!g&&Boolean((0,i.pk)(e,t)),p=Boolean(l&&n&&(o||(0,d.ZV)(n))&&n.isNotJoined);return{noMenu:!1,isChannel:o,isRightColumnShown:m,canStartBot:f,canRestartBot:g,canSubscribe:p,canSearch:l||h,canMute:l&&!c&&!p,canLeave:l&&!p}}),((e,t)=>(0,g.ei)(t,["joinChannel","sendBotCommand","openLocalTextSearch","restartBot"])))((({chatId:e,threadId:t,noMenu:s,isChannel:a,canStartBot:n,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canLeave:l,isRightColumnShown:u,canExpandActions:h,joinChannel:g,sendBotCommand:f,openLocalTextSearch:p,restartBot:I})=>{const v=(0,o.sO)(null),[y,C]=(0,o.eJ)(!1),[Z,P]=(0,o.eJ)(void 0),w=(0,o.I4)((()=>{C(!0);const e=v.current.getBoundingClientRect();P({x:e.right,y:e.bottom})}),[]),b=(0,o.I4)((()=>{C(!1)}),[]),M=(0,o.I4)((()=>{P(void 0)}),[]),S=(0,o.I4)((()=>{g({chatId:e})}),[g,e]),E=(0,o.I4)((()=>{f({command:"/start"})}),[f]),k=(0,o.I4)((()=>{I({chatId:e})}),[e,I]),R=(0,o.I4)((()=>{p(),m.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[p]),T=(0,be.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!m.wB&&h&&i&&o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:S},T(a?"ProfileJoinChannel":"ProfileJoinGroup")),!m.wB&&h&&n&&o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:E},T("BotStart")),!m.wB&&h&&r&&o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:k},T("BotRestart")),!m.wB&&c&&o.ZP.createElement(ke.Z,{round:!0,ripple:u,color:"translucent",size:"smaller",onClick:R,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),o.ZP.createElement(ke.Z,{ref:v,className:y?"active":"",round:!0,ripple:!m.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:w},o.ZP.createElement("i",{className:"icon-more"})),Z&&o.ZP.createElement(vt,{chatId:e,threadId:t,isOpen:y,anchor:Z,withExtraActions:m.wB||!h,isChannel:a,canStartBot:n,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canLeave:l,onSubscribeChannel:S,onSearchClick:R,onClose:b,onCloseAnimationEnd:M}))})));var Ct=s(4399),Zt=s(2340),Pt=s(6202),wt=s(862);function bt(e){var t;const s=e&&(0,d.DH)(e),a=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,r=s&&a&&!(0,m.on)()&&s.includes("image/webp"),[i,c]=(0,o.eJ)(wt.Hu),l=null==e?void 0:e.id;return(0,o.bt)((()=>{r&&(0,wt.p6)(`b64-${l}`,s).then(c).catch((e=>{n.eM&&console.error(e)}))}),[l,r,s]),r?i:s}var Mt=s(7551),St=s(8512);function Et(e,t,s,a,n){return`M${e},${t+n}a${n},${n},0,0,1,\n ${s},0v${a-2*n}a${n},${n},0,0,1,${-s},0Z`}const kt=(0,o.X$)((({count:e,index:t})=>{const s=(0,o.sO)(null),a=(0,o.Ye)((()=>function(e,t){const s=e-t-1,a=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),n=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,a),r=`clipPath${e}`;return{markHeight:n,clipPath:function(e,t,s){let a="";if(3===s)a=Et(0,0,2,t,1)+Et(0,12,2,t+1,1)+Et(0,25,2,t,1);else for(let e=0;e<s;e++)a+=Et(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${a}" />\n </clipPath>`}(r,a,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,a,e),trackTranslateY:function(e,t,s,a){return t<=4||e<=1?0:e>=t-2?a-36:(s+4)/2+(e-2)*(s+2)}(s,e,a,o),trackHeight:o,clipPathId:r}}(e,t)),[e,t]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:r,clipPath:i}=a,c=s.current.firstElementChild;if(null!=s&&s.current){const a=s.current,{style:d}=a;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${r}")`;const l=a.querySelector("svg"),u=a.querySelector("div"),h=a.querySelector("defs");l||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${i} </defs></svg>`),h&&(h.innerHTML=i),u&&(u.style.height=`${n}px`,u.style.transform=`translateY(${o}px)`)}}),[a]),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:n,trackTranslateY:r,markHeight:i,markTranslateY:c,clipPathId:d}=a;return o.ZP.createElement("div",{className:(0,de.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: ${n}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);`})))})),Rt=(0,o.X$)((({message:e,count:t,index:s,customTitle:a,className:n,onUnpinMessage:r,onClick:i,onAllPinnedClick:c})=>{const l=(0,be.Z)(),u=bt(e),h=(0,Pt.Z)((0,d.Ti)(e,"pictogram")),m=(0,d.MK)(l,e,Boolean(u)),[g,f,p]=(0,Ze.Z)(),I=(0,o.I4)((()=>{p(),r&&r(e.id)}),[p,r,e.id]);return o.ZP.createElement("div",{className:(0,de.Z)("HeaderPinnedMessage-wrapper",n)},t>1&&o.ZP.createElement(ke.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(ke.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(Mt.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(kt,{count:t,index:s}),u&&function(e,t){const{width:s,height:a}=(0,Ct.W7)();return o.ZP.createElement("img",{src:t||e,width:s,height:a,alt:""})}(u,h),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},a||`${l("PinnedMessage")} ${s>0?"#"+(t-s):""}`),o.ZP.createElement("p",{dir:"auto"},(0,Zt.Z)(m))),o.ZP.createElement(St.Z,null)))}));var Tt=s(647),Nt=s(3186),Bt=s(663),xt=s(4532);function Lt(e,t,s="image/png"){const a=e instanceof Blob?URL.createObjectURL(e):e,n=new Image;return new Promise((o=>{n.onload=()=>{At(n,n.width*t,n.height*t,s).then((e=>URL.createObjectURL(e))).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},n.src=a}))}async function At(e,t,s,a="image/png"){if(!("createImageBitmap"in window))return Ot(e,t,s,void 0,a);try{const n=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:s,resizeQuality:"high"});if(n.height!==s||n.width!==t)throw new Error("Image bitmap resize not supported!");return await new Promise((e=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const s=t.getContext("bitmaprenderer");s?s.transferFromImageBitmap(n):t.getContext("2d").drawImage(n,0,0),t.toBlob(e,a)}))}catch(n){return Ot(e,t,s,void 0,a)}}function Ot(e,t,s,a=.5,n="image/png"){const o=document.createElement("canvas"),r=o.getContext("2d"),i=document.createElement("canvas"),c=i.getContext("2d");if(o.width=t,o.height=s,e.width*a>t){const s=1/a;let n={width:Math.floor(e.width*a),height:Math.floor(e.height*a)};for(i.width=n.width,i.height=n.height,c.drawImage(e,0,0,n.width,n.height);n.width*a>t;)n={width:Math.floor(n.width*a),height:Math.floor(n.height*a)},c.drawImage(i,0,0,n.width*s,n.height*s,0,0,n.width,n.height);r.drawImage(i,0,0,n.width,n.height,0,0,o.width,o.height)}else r.drawImage(e,0,0,o.width,o.height);return new Promise((e=>{o.toBlob(e,n)}))}var Ft=s(4524);const Ut={width:200,height:200},Dt=115,Qt=(e,t,s)=>{const{audio:a,voice:n}=(0,d.qp)(e),r=a?a.title||a.fileName:n?"Voice message":"",i=a&&a.performer||t&&(0,d.OU)(Bt.i0,t),c=s&&(0,d.U)(Bt.i0,s)||"Telegram",l=a&&(0,d.MR)(a)&&(0,d.Ti)(e,"pictogram"),u=t&&(0,d.RT)(t,"big"),h=a&&l||n&&u,m=(0,Pt.Z)(h),g=(0,o.Ye)((()=>function(e,t,s){if(!s)return Ut;if(e){if(!e.thumbnailSizes||0===e.thumbnailSizes.length)return;return e.thumbnailSizes.find((e=>"m"===e.type))||e.thumbnailSizes[0]}return t?Ct.vY:void 0}(a,n,m)),[a,m,n]),{result:f}=((e,t,s)=>{const[a,n]=(0,o.eJ)(!1),[r,i]=(0,o.eJ)(),[c,d]=(0,o.eJ)(s);return(0,o.d4)((()=>{n(!0);let e=!1;return function(e,t){if(!e)return Promise.resolve(Ft);if(!t)return function(e,t,s,a="image/png"){const n=e instanceof Blob?URL.createObjectURL(e):e,o=new Image;return new Promise((r=>{o.onload=()=>{At(o,t,s,a).then((e=>URL.createObjectURL(e))).then(r).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(n)}))},o.src=n}))}(e,Dt,Dt);const s=Math.min(t.width,t.height);return s<Dt?Lt(e,Dt/s):Promise.resolve(e)}(m,g).then((t=>{e||(n(!1),d(t))}),(t=>{e||(n(!1),i(t))})),()=>{e=!0}}),t),{isLoading:a,error:r,result:c}})(0,[m,g],Ft);return(0,o.Ye)((()=>(0,xt.Of)({title:r,artist:i,album:c,artwork:[{src:f}]})),[c,i,r,f])};var $t=s(396),qt=s(8051);const Ht=(0,a.c$)(((e,{message:t})=>{const s=(0,i.Ur)(e,t),a=(0,i.Z1)(e,t.chatId),{volume:n,playbackRate:o,isMuted:r}=e.audioPlayer;return{sender:s,chat:a,volume:n,playbackRate:o,isMuted:r}}),((e,t)=>(0,g.ei)(t,["focusMessage","closeAudioPlayer","setAudioPlayerVolume","setAudioPlayerPlaybackRate","setAudioPlayerMuted"])))((({message:e,origin:t=h.Cr.Inline,className:s,noUi:a,sender:n,chat:r,volume:i,playbackRate:c,isMuted:l,setAudioPlayerVolume:u,setAudioPlayerPlaybackRate:g,setAudioPlayerMuted:f,focusMessage:p,closeAudioPlayer:I})=>{const v=(0,be.Z)(),{audio:y,voice:C,video:Z}=(0,d.qp)(e),P=Boolean(C||Z),w=n?(0,d.OU)(v,n):void 0,b=Tt.UV((0,d.Ti)(e,"inline")),M=Qt(e,n,r),{playPause:S,stop:E,isPlaying:k,requestNextTrack:R,requestPreviousTrack:T,isFirst:N,isLast:B,setVolume:x,toggleMuted:L,setPlaybackRate:A}=(0,Nt.Z)((0,$t.An)(e),(0,d.XV)(e),P?"voice":"audio",t,b,void 0,M,void 0,!0,void 0,void 0,!0,!0),O=(0,o.I4)((()=>{p({chatId:e.chatId,messageId:e.id})}),[p,e.chatId,e.id]),F=(0,o.I4)((()=>{k&&S(),I(),(0,xt.Ay)(),E()}),[I,k,S,E]),U=(0,o.I4)((e=>{u({volume:e/100}),f({isMuted:!1}),x(e/100)}),[f,u,x]),D=(0,o.I4)((()=>{m.$b&&!m.cj||(L(),f({isMuted:!l}))}),[l,f,L]),Q=(0,o.I4)((()=>{1===c?(A(1.8),g({playbackRate:1.8})):(A(1),g({playbackRate:1}))}),[c,g,A]),$=(0,o.Ye)((()=>0===i||l?"icon-muted":i<.3?"icon-volume-1":i<.6?"icon-volume-2":"icon-volume-3"),[i,l]);if(!a)return o.ZP.createElement("div",{className:(0,de.Z)("AudioPlayer",s),dir:v.isRtl?"rtl":void 0},o.ZP.createElement(ke.Z,{round:!0,ripple:!m.wB,color:"translucent",size:"smaller",className:"player-button",disabled:N,onClick:T,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(ke.Z,{round:!0,ripple:!m.wB,color:"translucent",size:"smaller",className:(0,de.Z)("toggle-play","player-button",k?"pause":"play"),onClick:S,ariaLabel:k?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(ke.Z,{round:!0,ripple:!m.wB,color:"translucent",size:"smaller",className:"player-button",disabled:B,onClick:R,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon-skip-next"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:O},y?function(e){const{title:t,performer:s,fileName:a}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,Zt.Z)(t||a)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Zt.Z)(s)))}(y):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,Zt.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(v("AttachAudio"),w),o.ZP.createElement(St.Z,null)),o.ZP.createElement(ke.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",withClickPropagation:!0},o.ZP.createElement("i",{className:$,onClick:D}),!m.cj&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"volume-slider-spacer"}),o.ZP.createElement("div",{className:"volume-slider"},o.ZP.createElement(qt.Z,{value:l?0:100*i,onChange:U})))),P&&o.ZP.createElement(ke.Z,{round:!0,className:(0,de.Z)("playback-button",1!==c&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!m.wB,onClick:Q},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(ke.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:F,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))})),Gt=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a})=>{const{isLeftColumnShown:n,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"===a){const s=(0,i.KB)(e,t);f=null==s?void 0:s.length}else if("scheduled"===a){const s=(0,i.qy)(e,t);f=null==s?void 0:s.length}else if("thread"===a&&s!==u._f){const a=(0,i.tZ)(e,t,s);f=(null==a?void 0:a.messagesCount)||0}const p={typingStatus:l,isLeftColumnShown:n,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"!==a||!I)return p;if(Object.assign(p,{messagesById:I}),s!==u._f){const a=(0,i.qS)(e,t,s),n=a?(0,i.hj)(e,t,a):void 0,o=n?(0,i.cv)(e,n):void 0;return{...p,pinnedMessageIds:a,canUnpin:!1,topMessageSender:o}}const v=(0,i.KB)(e,t);if(null!=v&&v.length){const t=I[v[0]],{canUnpin:a}=t&&(0,i._k)(e,t,s)||{};return{...p,pinnedMessageIds:v,canUnpin:a}}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:C,chatsById:Z,messagesCount:P,isChatWithSelf:w,isChatWithBot:b,lastSyncTime:M,shouldSkipHistoryAnimations:S,currentTransitionKey:E,connectionState:k,openChatWithInfo:R,pinMessage:T,focusMessage:N,openChat:B,openPreviousChat:x,loadPinnedMessages:L,toggleLeftColumn:A,exitMessageSelectMode:O})=>{const F=(0,be.Z)(),U=(0,o.sO)(!0),[D,Q]=(0,o.eJ)(0),$=Array.isArray(c)?c[D]:c,q=l&&$?l[$]:void 0,H=Array.isArray(c)?c.length:c?1:void 0,G=C&&(0,d.U)(F,C).length,j=g?(0,d.OU)(F,g):void 0;(0,o.d4)((()=>{t===u._f&&M&&r&&L({chatId:e})}),[e,L,M,t,r]),(0,o.d4)((()=>{Q(0)}),[c]),(0,mt.Z)(e,$,q);const{width:_}=ct(),V=_<=n.ks,z=m.p7&&I,W=(0,o.sO)(null),Y=(0,o.sO)(!0),X=(0,o.I4)((()=>{R({id:e})}),[R,e]),K=(0,o.I4)((t=>{T({chatId:e,messageId:t,isUnpin:!0})}),[T,e]),J=(0,o.I4)((()=>{if(q){N({chatId:q.chatId,threadId:t,messageId:q.id});const e=(0,ht.Z)(H||1,D+1);Q(e)}}),[q,N,t,H,D]),ee=(0,o.I4)((()=>{B({id:e,threadId:u._f,type:"pinned"})}),[B,e]),te=(0,o.I4)((()=>{setTimeout((()=>{U.current=!0}),450)}),[]),se=(0,o.I4)((e=>{if(U.current){if(U.current=!1,m.wB){const e=document.getElementById(n.R2);e&&e.blur()}if(p)return O(),void te();if(t===u._f&&"thread"===s&&0===E)return m.wB||z?(e.stopPropagation(),B({id:void 0})):A(),void te();x(),te()}}),[t,s,E,p,x,z,B,A,O,te]),ae=(0,o.Ye)((()=>{if(V&&Z)return(0,i.A1)((0,a.Rd)())||void 0}),[V,Z]),ne=_>=n.ks&&_<n.jT||_>n.l3&&_<n.ks&&(!G||G>30),oe=ne||_>n._m&&_<n.QU,{shouldRender:re,transitionClassNames:ie}=(0,ue.Z)(Boolean(y)),ce=(0,gt.Z)(y),{shouldRender:le,transitionClassNames:he}=(0,ue.Z)(Boolean(q)),me=(0,gt.Z)(q,!0),ge=(0,gt.Z)(H,!0),fe=(0,gt.Z)(h,!0),pe=(0,gt.Z)(j),Ie=le&&me||re&&ce;(0,o.d4)((()=>{const e=W.current;if(e)return oe&&Ie?void(v||ne?(Y.current&&(e.classList.add("tools-stacked","animated"),Y.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),Y.current=!0)):(e.classList.remove("tools-stacked","animated"),void(Y.current=!0))}),[oe,Ie,ne,v]);const ve=(!we()||"connectionStateConnecting"===k)&&(m.wB||m.p7&&!z);function ye(){return ve?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,F("WaitingForNetwork"))):"thread"===s&&t===u._f?o.ZP.createElement(o.ZP.Fragment,null,(V||E>0)&&Ce(z,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:X},(0,d.YC)(e)?o.ZP.createElement(pt.Z,{userId:e,typingStatus:f,withFullInfo:b,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(It.Z,{chatId:e,typingStatus:f,noRtl:!0,withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0}))):"thread"===s?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,F("CommentsCount",P,"i"))):"pinned"===s?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",P,"i"))):"scheduled"===s?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,w?F("Reminders"):F("messages",P,"i"))):void 0}function Ce(e=!1,t=!1){return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(ke.Z,{round:!0,size:"smaller",color:"translucent",onClick:se,ariaLabel:F(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,de.Z)("animated-close-icon",!e&&"state-back")})),t&&ae&&o.ZP.createElement("div",{className:"unread-count active"},(0,ft.bi)(ae)))}const Ze=Boolean(re&&ce);return o.ZP.createElement("div",{className:"MiddleHeader",ref:W},o.ZP.createElement(Pe.Z,{name:S?"none":"slide-fade",activeKey:ve?1/0:E},ye),le&&me&&o.ZP.createElement(Rt,{key:e,message:me,count:ge||0,index:D,customTitle:pe,className:(0,de.Z)(he,Ze&&"full-width"),onUnpinMessage:fe?K:void 0,onClick:J,onAllPinnedClick:ee}),o.ZP.createElement("div",{className:"header-tools"},Ze&&o.ZP.createElement(Ht,{key:(0,d.Tp)(ce),message:ce,className:ie}),o.ZP.createElement(yt,{chatId:e,threadId:t,messageListType:s,canExpandActions:!Ze})))})));var jt=s(2645),_t=s(274);function Vt(e){return"albumId"in e}function zt(e,t){let s,a=[],n={originalDate:e[0].date,datetime:Number((0,U.$Y)(1e3*e[0].date)),senderGroups:[a]};const o=[n];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}:a.push(r);const c=e[i+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(a.push(s),s=void 0),c){const e=Number((0,U.$Y)(1e3*c.date));n.datetime!==e?(n={originalDate:c.date,datetime:e,senderGroups:[]},o.push(n),a=[],n.senderGroups.push(a)):(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)&&(a=[],n.senderGroups.push(a))}})),o}var Wt=s(386),Yt=s(2202);var Xt=s(7675),Kt=s(539),Jt=s(3657);const es=m.wZ?1e3:350,ts=m.wB?300:500;var ss=s(7240),as=s(935);function ns(e){return"number"==typeof e}function os(e,t){return e?t?238:175:t?238:100}function rs(e,t){const s=(0,d.B4)(e),a=(0,d.MF)(e),n=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),r=Boolean((0,d.F$)(e)),{width:i,height:c}=n?(0,Ct.Eh)(n,s,a,r,t):(0,Ct.GC)(o,s,a,t),l=os(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 is(e,t){return e.reduce(((e,t)=>e+t),t)}function cs(e,t,s){return e<t?t:e>s?s:e}function ds(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 ls(e,t,s,a){const n=a.messages.map((e=>{const t=rs(e);return t.width/t.height})),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(n),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(n),i=n.length,c=n.some((e=>e>2)),d=(0,Ct.kc)(e,t,!1,s)-(t?2.5:0)*Ct.Gw;let l;const u={ratios:n,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:a,spacing:n,maxHeight:o=4*s/3}){const r=function(e,t){return e.map((e=>t>1.1?cs(e,1,2.75):cs(e,.6667,1)))}(e,t),i=e.length,c=new Array(i),d=[],l=e=>{const t=[];let a=0;e.forEach((e=>{t.push(((e,t)=>{const a=is(r.slice(e,e+t),0);return(s-(t-1)*n)/a})(a,e)),a+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==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 a=i-e-s;e<=3&&s<=(t<.85?4:3)&&a<=3&&l([e,s,a])}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 a=i-e-t-s;e<=3&&t<=3&&s<=3&&a<=4&&l([e,t,s,a])}let u,h=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:s}=d[e],r=s.length,i=is(t,0)+n*(r-1),c=Math.min(...t)<a?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],a=g[e],o=Math.round(a);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*a);c[p]={dimensions:{x:i,y:I,width:h,height:o},sides:l},i+=h+n,++p}I+=o+n}return c}(u):2===i?function(e){const{ratios:t,proportions:s,averageRatio:a}=e;return"ww"===s&&a>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:a,maxHeight:n}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(n-a)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:11},{dimensions:{x:0,y:o+a,width:s,height:o},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:a,maxHeight:n}=e,o=(s-a)/2,r=Math.round(Math.min(o/t[0],Math.min(o/t[1],n)));return[{dimensions:{x:0,y:0,width:o,height:r},sides:13},{dimensions:{x:o+a,y:0,width:o,height:r},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:a,spacing:n,maxHeight:o}=e,r=Math.round(1.5*s),i=Math.min(Math.round(Math.max(.4*(a-n),(a-n)/t[0]/(1/t[0]+1/t[1]))),a-n-r),c=a-i-n,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+n,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:a,maxWidth:n,minWidth:o}=e,r=t,i=Math.round(Math.min((t-s)/2,a[1]*(n-s)/(a[2]+a[1]))),c=r-i-s,d=Math.max(o,Math.round(Math.min((n-s)/2,Math.min(i*a[2],c*a[1])))),l=Math.min(Math.round(r*a[0]),n-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:a,spacing:n}=e,o=t,r=Math.round(Math.min(o/s[0],.66*(a-n))),i=(t-n)/2,c=Math.min(a-r-n,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+n,width:i,height:c},sides:12},{dimensions:{x:i+n,y:r+n,width:o-i-n,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:a,minWidth:n}){const o=e,r=Math.round(Math.min(o/t[0],.66*(a-s))),i=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(n,Math.round(Math.min(.4*(e-2*s),i*t[1]))),d=Math.round(Math.max(Math.max(n,.33*(e-2*s)),i*t[3])),l=o-c-d-2*s,u=Math.min(a-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:a,minWidth:n}){const o=e,r=Math.round(Math.min(o*t[0],.6*(s-a))),i=Math.round((e-2*a)/(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*a,u=Math.max(n,Math.min(s-r-a,i));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+a,y:0,width:u,height:c},sides:3},{dimensions:{x:r+a,y:c+a,width:u,height:d},sides:2},{dimensions:{x:r+a,y:c+d+2*a,width:u,height:l},sides:6}]}(e)}(u),{layout:l,containerStyle:ds(l)}}let us;function hs(e){return us||(us=document.createElement("span"),us.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',us.style.whiteSpace="nowrap",us.style.position="absolute",us.style.left="-999px",us.style.opacity=".01",document.body.appendChild(us)),us.innerHTML=e,us.offsetWidth}function ms(e,t,s,a,n,r){(0,o.bt)((()=>{if(s&&e.current){const t=e.current.closest(".MessageList");(0,Kt.Z)(t,e.current,n?"end":"centerOrTop",20,void 0!==a?1e3:void 0,a,void 0,r)}}),[e,t,s,a,n,r])}var gs=s(172),fs=s(2864);const ps=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"ContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),Is=(0,o.X$)((0,a.c$)(((e,{message:t})=>{const{byId:s}=e.users,a=t.senderId,{targetUserIds:n,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)||a===t.chatId)?m:a?(0,i.dy)(e,a):void 0,targetChatId:o,targetUserIds:n,targetMessage:c,isFocused:l,...l&&{focusDirection:u,noFocusHighlight:h}}}))((({message:e,observeIntersection:t,isEmbedded:s,appearanceOrder:a=0,isLastInList:n,usersById:r,sender:i,targetUserIds:c,targetMessage:d,targetChatId:l,isFocused:u,focusDirection:h,noFocusHighlight:m})=>{const g=(0,o.sO)(null);(0,Jt._N)(g,t),(0,mt.Z)(e.chatId,e.replyToMessageId,d),ms(g,e.chatId,u,h,m);const f=(0,be.Z)(),p=a<=0,[I,v]=(0,Ze.Z)(p);(0,o.d4)((()=>{p||setTimeout(v,10*a)}),[a,v,p]);const{transitionClassNames:y}=(0,ue.Z)(I,void 0,p,!1),C=(0,o.Ye)((()=>c?c.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[c,r]),Z=(0,fs.D)(f,e,i,C,d,l,s?{isEmbedded:!0,asPlain:!0}:void 0),{isContextMenuOpen:P,contextMenuPosition:w,handleBeforeContextMenu:b,handleContextMenu:M,handleContextMenuClose:S,handleContextMenuHide:E}=(0,ss.Z)(g),k=void 0!==w;if(s)return o.ZP.createElement("span",{className:"embedded-action-message"},(0,Zt.Z)(Z));const R=(0,de.Z)("ActionMessage message-list-item",u&&!m&&"focused",k&&"has-menu-open",n&&"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,Wt.q)(e),b(e)},onContextMenu:M},o.ZP.createElement("span",null,Z),w&&o.ZP.createElement(ps,{isOpen:P,anchor:w,message:e,messageListType:"thread",onClose:S,onCloseAnimationEnd:E}))}))),vs=({className:e,message:t,sender:s,title:a,customText:n,observeIntersection:r,onClick:i})=>{const c=(0,o.sO)(null),l=(0,Jt.Op)(c,r),u=(0,Pt.Z)(t&&(0,d.Ti)(t,"pictogram"),!l),h=t&&`sticker-reply-thumb${t.id}`,m=bt(t),g=Boolean(t&&(0,d.Y5)(t)),f=(0,be.Z)(),p=s&&(0,d.OU)(f,s);return o.ZP.createElement("div",{ref:c,className:(0,de.Z)("EmbeddedMessage",e),onClick:t?i:void 0},m&&function(e,t,s,a){const{width:n,height:r}=(0,Ct.W7)();return o.ZP.createElement("img",{id:e,src:s||t,width:n,height:r,alt:"",className:a?"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(Is,{message:t,isEmbedded:!0}):(0,Zt.Z)((0,d.MK)(f,t,Boolean(m))):n||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Zt.Z)(p||a||" "))))};var ys=s(2535),Cs=s(4752),Zs=s(8018);const Ps=(0,o.X$)((({message:e,outgoingStatus:t,signature:s,onClick:a})=>{const n=(0,be.Z)();return o.ZP.createElement("span",{className:"MessageMeta",dir:n.isRtl?"rtl":"ltr",onClick:a},Boolean(e.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,ft.bi)(e.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,Zt.Z)(s)),o.ZP.createElement("span",{className:"message-time"},e.isEdited&&`${n("EditedMessage")} `,(0,U.mr)(1e3*e.date,n)),t&&o.ZP.createElement(Zs.Z,{status:t}))}));var ws=s(692),bs=s(7799),Ms=s(4851);const Ss=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:a,lastSyncTime:r})=>{const i=(0,o.sO)(null),[c,l,u]=(0,Ze.Z)(),h=e.content.sticker,{isAnimated:m,stickerSetId:g}=h,f=g===n.n,p=(0,Jt.Op)(i,t),I=(0,Jt.Op)(i,s),v=h.isPreloadedGlobally?`sticker${h.id}`:(0,d.Ti)(e,"inline"),y=bt(e),C=(0,Pt.Z)(v,!p,(0,d.kG)(e,"inline",!0),r),Z=Boolean(C),[P,w]=(0,Ze.Z)(Z),b=m?P:Z,M=(0,ws.Z)(b),{width:S,height:E}=(0,Ct.Wr)(h),k=(0,de.Z)("thumbnail",!y&&"empty"),R=(0,de.Z)("Sticker media-inner",f&&"inactive");return o.ZP.createElement("div",{ref:i,className:R,onClick:f?void 0:l},!b&&o.ZP.createElement("img",{id:`sticker-thumb-${e.id}`,src:y,width:S,height:E,alt:"",className:k}),!m&&o.ZP.createElement("img",{id:`sticker-${e.id}`,src:C,width:S,height:E,alt:"",className:(0,de.Z)("full-media",M)}),m&&Z&&o.ZP.createElement(bs.Z,{key:v,className:(0,de.Z)("full-media",M),id:v,animationData:C,size:S,play:I,noLoop:!a,onLoad:w}),o.ZP.createElement(Ms.Z,{isOpen:c,fromSticker:h,onClose:u}))};var Es=s(7854),ks=s(2566),Rs=s(5866);function Ts(e,t){return(0,Rs.Z)((0,d.DH)(e),Boolean(t),m.wB&&!m.vX)}var Ns=s(7204);const Bs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var xs=s(9196);const Ls=({id:e,message:t,observeIntersection:s,noAvatars:a,canAutoLoad:n,isInSelectMode:r,isSelected:i,uploadProgress:c,size:l="inline",dimensions:u,nonInteractive:h,shouldAffectAppendix:m,isDownloading:g,theme:f,onClick:p,onCancelUpload:I})=>{const v=(0,o.sO)(null),y=((0,d.O$)(t)||(0,d.F$)(t)).blobUrl,C=(0,Jt.Op)(v,s),[Z,P]=(0,o.eJ)(n),w=Z&&C,{mediaData:b,loadProgress:M}=(0,ks.Z)((0,d.Ti)(t,l),!w),S=y||b,E=Ts(t,S),{loadProgress:k}=(0,ks.Z)((0,d.Ti)(t,"download"),!g),{isUploading:R,isTransferring:T,transferProgress:N}=(0,d.Sc)(t,c||(g?k:M),w&&!S),B=!1===(0,Ns.Z)(Z),x=(0,ws.Z)(S),{shouldRender:L,transitionClassNames:A}=(0,ue.Z)(T,void 0,B,"slow"),{shouldRender:O,transitionClassNames:F}=(0,ue.Z)(!S&&!Z),U=(0,o.I4)((()=>{R?I&&I(t):S?p&&p(t.id):P((e=>!e))}),[S,R,t,I,p]),D=(0,d.B4)(t);(0,o.bt)((()=>{if(!m)return;const e=v.current.closest(".message-content");S?function(e,t,s,a,n){return a?Promise.resolve(Bs[n||"light"][t?"outgoing":"incoming"]):async function(e,t){const s=new Image;s.src=e,s.width||await new Promise((e=>{s.onload=e}));const a=document.createElement("canvas"),n=a.getContext("2d");a.width=s.width,a.height=s.height,n.drawImage(s,0,0,s.width,s.height);const o=t?s.width-1:0,r=s.height-1;return`rgba(${Array.from(n.getImageData(o,r,1,1).data).join(",")})`}(e,t)}(S,D,0,i,f).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[S,D,m,r,i,f]);const{width:Q,height:$,isSmall:q}=u||rs(t,a),H=(0,de.Z)("media-inner",!R&&!h&&"interactive",q&&"small-image",Q===$&&"square-image"),G=u?`width: ${Q}px; height: ${$}px; left: ${u.x}px; top: ${u.y}px;`:"";return o.ZP.createElement("div",{id:e,ref:v,className:H,style:G,onClick:R?void 0:U},o.ZP.createElement("canvas",{ref:E,className:"thumbnail",style:`width: ${Q}px; height: ${$}px`}),o.ZP.createElement("img",{src:S,className:`full-media ${x}`,width:Q,height:$,alt:""}),L&&!O&&o.ZP.createElement("div",{className:`media-loading ${A}`},o.ZP.createElement(xs.Z,{progress:N,onClick:R?U:void 0})),O&&o.ZP.createElement("i",{className:(0,de.Z)("icon-download",F)}),T&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*N),"%"))};var As=s(2019),Os=s(4753);function Fs(e,t){const s=(0,o.sO)();s.current=t;const a=(0,o.I4)((()=>{e.current&&e.current.pause()}),[e]),n=(0,o.I4)((()=>{e.current&&s.current&&(0,Os.Z)(e.current)}),[e]);(0,ce.ZP)(a,n)}var Us=s(6898);const Ds=(e,t=!1)=>{const s=(0,o.sO)(!1),a=(0,o.sO)(!1),n=(0,o.I4)((()=>{a.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,Os.Z)(e.current),s.current=!1,a.current=!1}),[t,e]),i=(0,o.I4)((()=>{(0,P.T2)(r)}),[r]);document.hasFocus()||n(),(0,he.Z)(n,i)};function Qs(){return(Qs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}const $s=({id:e,message:t,observeIntersection:s,noAvatars:n,canAutoLoad:r,canAutoPlay:i,uploadProgress:c,lastSyncTime:l,dimensions:h,onClick:m,onCancelUpload:g,isDownloading:f})=>{var p;const I=(0,o.sO)(null),v=(0,o.sO)(null),y=(0,d.b7)(t)||(0,d.Cg)(t),C=y.blobUrl,Z=(0,Jt.Op)(I,s),[P,w]=(0,o.eJ)(r),b=Boolean(P&&Z&&l),[M,S]=(0,o.eJ)(i),E=(0,Pt.Z)((0,d.Ti)(t,"pictogram"),!(Z&&l),(0,d.kG)(t,"pictogram"),l),{transitionClassNames:k}=(0,ue.Z)(Boolean(E),void 0,void 0,"slow"),{mediaData:R,loadProgress:T}=(0,ks.Z)((0,d.Ti)(t,"inline"),!b,(0,d.kG)(t,"inline"),l),N=C||R,B=Boolean(Z&&N),x=Ts(t,E),{loadProgress:L}=(0,ks.Z)((0,d.Ti)(t,"download"),!f,u.IU.BlobUrl,l),{isBuffered:A,bufferingHandlers:O}=(0,As.Z)(!r),{isUploading:F,isTransferring:D,transferProgress:Q}=(0,d.Sc)(t,c||(f?L:T),b&&!A||f),$=!1===(0,Ns.Z)(P),{shouldRender:q,transitionClassNames:H}=(0,ue.Z)(D,void 0,$),{shouldRender:G,transitionClassNames:j}=(0,ue.Z)(P&&!M&&!q),[_,V]=(0,o.eJ)(0),z=(0,o.I4)((e=>{V(Math.max(0,e.currentTarget.currentTime-1))}),[]),W=(null===(p=v.current)||void 0===p?void 0:p.duration)||y.duration||0,Y=(0,d.B4)(t),X=(0,d.MF)(t),{width:K,height:J}=h||(0,Ct.GC)(y,Y,X,n);Fs(v,Boolean(B&&i)),Ds(v,M),(0,Us.Z)(v,[B]);const ee=(0,o.I4)((()=>{F?g&&g(t):f?(0,a.uC)().cancelMessageMediaDownload({message:t}):N?N&&!M?(S(!0),v.current.play()):m&&m(t.id):w((e=>!e))}),[F,f,N,M,m,g,t]),te=(0,de.Z)("media-inner dark",!F&&"interactive"),se=h?`width: ${K}px; height: ${J}px; left: ${h.x}px; top: ${h.y}px;`:"";return o.ZP.createElement("div",{ref:I,id:e,className:te,style:se,onClick:F?void 0:ee},o.ZP.createElement("canvas",{ref:x,className:"thumbnail",style:`width: ${K}px; height: ${J}px;`}),o.ZP.createElement("img",{src:E,className:(0,de.Z)("thumbnail",k),style:`width: ${K}px; height: ${J}px;`,alt:""}),B&&o.ZP.createElement("video",Qs({ref:v,className:"full-media",width:K,height:J,autoPlay:M,muted:!0,loop:!0,playsInline:!0},O,{onTimeUpdate:z}),o.ZP.createElement("source",{src:N})),G&&o.ZP.createElement("i",{className:(0,de.Z)("icon-large-play",j)}),q&&o.ZP.createElement("div",{className:(0,de.Z)("media-loading",H)},o.ZP.createElement(xs.Z,{progress:Q,onClick:ee})),!P&&o.ZP.createElement("i",{className:"icon-download"}),D?o.ZP.createElement("span",{className:"message-transfer-progress"},F||f?`${Math.round(100*Q)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},y.isGif?"GIF":(0,U.k9)(Math.max(W-_,0))))};var qs=s(6272);const Hs=(0,a.c$)(((e,{contact:t})=>{const{countryList:{phoneCodes:s}}=e;return{user:(0,i.dy)(e,t.userId),phoneCodeList:s}}),((e,t)=>(0,g.ei)(t,["openUserInfo"])))((({contact:e,user:t,openUserInfo:s,phoneCodeList:a})=>{const{firstName:n,lastName:r,phoneNumber:i,userId:c}=e,d=(0,o.I4)((()=>{s({id:c})}),[s,c]);return o.ZP.createElement("div",{className:(0,de.Z)("Contact",Boolean(c)&&"interactive"),onClick:c?d:void 0},o.ZP.createElement(gs.Z,{size:"large",user:t,text:n||r}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},n," ",r),o.ZP.createElement("div",{className:"contact-phone"},(0,qs.WZ)(a,i))))}));var Gs=s(1218),js=s(4434),_s=s(6937);function Vs(e,t){return t>0?(e/t*100).toFixed():0}const zs=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:a,correctResults:n,shouldAnimate:r})=>{const i=t&&t.find((t=>t.option===e.option)),c=0===n.length||-1!==n.indexOf(e.option),d=n.length>0&&c||(null==i?void 0:i.isChosen),l=i?Vs(i.votersCount,s||0):0,[u,h]=(0,o.eJ)(r?0:l),m=(0,o.sO)(null),g=i?Vs(i.votersCount,a||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,de.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,Zt.Z)(e.text)),o.ZP.createElement("div",{className:(0,de.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}))))},Ws=(0,o.X$)((0,a.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{serverTimeOffset:a,users:{byId:n}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:n,serverTimeOffset:a}:{}}),((e,t)=>(0,g.ei)(t,["loadMessage","openPollResults"])))((({message:e,poll:t,recentVoterIds:s,usersById:a,loadMessage:n,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,C]=(0,o.eJ)(!1),[Z,P]=(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&&Z<=0)})));(0,o.d4)((()=>{m&&t.results.results&&t.results.results.some((e=>e.isChosen))&&g(!1)}),[m,t.results.results]),(0,o.d4)((()=>{Z>0&&setTimeout((()=>P(Z-1)),1e3);const e=w.current;if(e){const t=12*Math.PI,s=e.lastElementChild,a=e.firstElementChild;if(Z<=5&&e.classList.add("hurry-up"),s&&a){const e=(u.closePeriod-Z)/u.closePeriod*t;a.textContent=(0,U.k9)(Z),s.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,U.k9)(Z)}</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>`}}),[Z,u.closePeriod]),(0,o.d4)((()=>{u.quiz&&(Z<=0||S&&!u.closed)&&n({chatId:l,messageId:d})}),[l,Z,S,n,d,u.closed,u.quiz]),(0,o.d4)((()=>{let e;return u.quiz&&!u.closed&&u.closePeriod&&u.closePeriod>0&&(e=window.setTimeout((()=>{n({chatId:l,messageId:d})}),1e3*u.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[E,l,n,d,u.closePeriod,u.closed,u.quiz]);const x=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const s=a[t];return s&&e.push(s),e}),[]):[]),[a,s]),L=(0,o.I4)((e=>{p([e]),g(!0),C(!0),r([e])}),[r]),A=(0,o.I4)((e=>{p(e)}),[]),O=(0,o.I4)((()=>{g(!0),C(!0),r(f)}),[r,f]),F=(0,o.I4)((()=>{i({chatId:l,messageId:d})}),[l,d,i]),D=(0,o.I4)((()=>{v(!0)}),[]),Q=(0,o.I4)((()=>{v(!1),C(!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 $=(0,be.Z)();return o.ZP.createElement("div",{className:"Poll",dir:$.isRtl?"auto":"ltr"},I&&t.results.solution&&o.ZP.createElement(_s.Z,{message:(0,as.H)(t.results.solution,t.results.solutionEntities),duration:5e3,onDismiss:Q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,Zt.Z)(u.question,["emoji","br"])),o.ZP.createElement("div",{className:"poll-type"},$(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(gs.Z,{size:"micro",user:e})))),Z>0&&E&&o.ZP.createElement("div",{ref:w,className:"poll-countdown"}),u.quiz&&t.results.solution&&!E&&o.ZP.createElement(ke.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:I,onClick:D,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),E&&o.ZP.createElement("div",{className:"poll-answers"},R?o.ZP.createElement(Gs.Z,{options:B,onChange:A,disabled:e.isScheduled||m,loadingOptions:m?f:void 0,round:!0}):o.ZP.createElement(js.Z,{name:`poll-${d}`,options:B,onChange:L,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(zs,{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")}($,u.quiz,h.totalVoters)),R&&o.ZP.createElement(ke.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:O},$("PollSubmitVotes")),k&&o.ZP.createElement(ke.Z,{isText:!0,size:"tiny",onClick:F},$("PollViewResults")))})));var Ys=s(8035),Xs=s(88);const Ks=(0,o.X$)((({message:e,observeIntersection:t,noAvatars:s,canAutoLoad:a,canAutoPlay:n,inPreview:r,lastSyncTime:i,isDownloading:c=!1,theme:l,onMediaClick:u,onCancelMediaTransfer:h})=>{const m=(0,d.s1)(e);let g=!1;if(null!=m&&m.photo&&!m.video){const{width:t,height:s}=rs(e);g=t===s}const f=(0,o.I4)((()=>{u()}),[u]);if(!m)return;const{siteName:p,url:I,displayUrl:v,title:y,description:C,photo:Z,video:P}=m,w=(Z||P)&&u&&!g,b=(0,Ys.Z)(C,170),M=(0,de.Z)("WebPage",g&&"with-square-photo",!Z&&!P&&!r&&"without-media",P&&"with-video");return o.ZP.createElement("div",{className:M,"data-initial":(p||v)[0],dir:"auto"},Z&&!P&&o.ZP.createElement(Ls,{message:e,observeIntersection:t,noAvatars:s,canAutoLoad:a,size:g?"pictogram":"inline",nonInteractive:!w,onClick:w?f:void 0,onCancelUpload:h,isDownloading:c,theme:l}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Xs.Z,{className:"site-name",url:I,text:p||v}),!r&&y&&o.ZP.createElement("p",{className:"site-title"},(0,Zt.Z)(y)),b&&o.ZP.createElement("p",{className:"site-description"},(0,Zt.Z)(b,["emoji","br"]))),!r&&P&&o.ZP.createElement($s,{message:e,observeIntersection:t,noAvatars:s,canAutoLoad:a,canAutoPlay:n,lastSyncTime:i,onClick:w?f:void 0,onCancelUpload:h,isDownloading:c}))}));var Js=s(9937);const ea=(0,o.X$)((({message:e})=>{const t=(0,be.Z)(),s=(0,d.eO)(e),{title:a,text:n,amount:r,currency:i,isTest:c,photoUrl:l}=s;return o.ZP.createElement("div",{className:"Invoice"},a&&o.ZP.createElement("p",{className:"title"},(0,Zt.Z)(a)),n&&o.ZP.createElement("p",null,(0,Zt.Z)(n,["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,Js.x)(r,i,t.code),c&&o.ZP.createElement("span",null,t("PaymentTestInvoice")))))}));function ta(e){return(0,o.X$)((0,a.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:a,message:n,toggleMessageSelection:r,dimensions:i}=t,c=(0,o.I4)((e=>{e.stopPropagation(),r({messageId:n.id,withShift:null==e?void 0:e.shiftKey})}),[r,n]),d=(0,o.Ye)((()=>({...t,isInSelectMode:s,isSelected:a,dimensions:{...t.dimensions,x:0,y:0},onClick:s?void 0:t.onClick})),[t,s,a]);return o.ZP.createElement("div",{className:(0,de.Z)("album-item-select-wrapper",a&&"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"},a&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const sa=ta(Ls),aa=ta($s),na=(0,a.c$)(((e,{album:t})=>{const{chatId:s}=t.mainMessage,a=(0,i.Pu)(e),n=(0,i.xs)(e,s);return{theme:a,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:n}}),((e,t)=>(0,g.ei)(t,["cancelSendingMessage"])))((({album:e,observeIntersection:t,canAutoLoad:s,canAutoPlay:a,hasCustomAppendix:n,lastSyncTime:r,isOwn:i,albumLayout:c,onMediaClick:l,uploadsById:u,activeDownloadIds:h,theme:m,cancelSendingMessage:g})=>{const f=e.messages.length,p=(0,o.I4)((e=>{g({chatId:e.chatId,messageId:e.id})}),[g]),{width:I,height:v}=c.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${I}px; height: ${v}px;`},e.messages.map((function(e,g){const{photo:I,video:v}=(0,d.qp)(e),y=u[e.previousLocalId||e.id],C=null==y?void 0:y.progress,{dimensions:Z,sides:P}=c.layout[g];if(I){const a=n&&(i?g===f-1:Boolean(8&P&&4&P));return o.ZP.createElement(sa,{id:`album-media-${e.id}`,message:e,observeIntersection:t,canAutoLoad:s,shouldAffectAppendix:a,uploadProgress:C,dimensions:Z,onClick:l,onCancelUpload:p,isDownloading:h.includes(e.id),theme:m})}if(v)return o.ZP.createElement(aa,{id:`album-media-${e.id}`,message:e,observeIntersection:t,canAutoLoad:s,canAutoPlay:a,uploadProgress:C,lastSyncTime:r,dimensions:Z,onClick:l,onCancelUpload:p,isDownloading:h.includes(e.id),theme:m})})))}));function oa(){return(oa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}let ra;const ia=({message:e,observeIntersection:t,canAutoLoad:s,lastSyncTime:n,isDownloading:r})=>{const i=(0,o.sO)(null),c=(0,o.sO)(null),l=(0,o.sO)(null),h=e.content.video,m=(0,Jt.Op)(i,t),[g,f]=(0,o.eJ)(s),p=Boolean(g&&m&&n),{mediaData:I,loadProgress:v}=(0,ks.Z)((0,d.Ti)(e,"inline"),!p,(0,d.kG)(e,"inline"),n),{loadProgress:y}=(0,ks.Z)((0,d.Ti)(e,"download"),!r,u.IU.BlobUrl,n),C=Ts(e,I),{isBuffered:Z,bufferingHandlers:w}=(0,As.Z)(),b=g&&!Z||r,M=!1===(0,Ns.Z)(g),S=(0,ws.Z)(I),{shouldRender:E,transitionClassNames:k}=(0,ue.Z)(b||!Z,void 0,M),[R,T]=(0,o.eJ)(!1),[N,B]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!R)return;const e=Ct.Rj/2,t=2*(e-6)*Math.PI,s=t-N*t,a=l.current,n=c.current,o=n.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",s.toString()):n.innerHTML=`\n <svg width="${Ct.Rj}px" height="${Ct.Rj}px">\n <circle cx="${e}" cy="${e}" r="${e-6}" class="progress-circle"\n transform="rotate(-90, ${e}, ${e})"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="${t}"\n />\n </svg>`,B(a.currentTime/a.duration)}),[R,N]);const x=Boolean(I&&m),L=()=>{T(!1),B(0),(0,Os.Z)(l.current),(0,P.T2)((()=>{c.current.innerHTML=""}))},A=(O=L,()=>{ra&&ra(),ra=O});var O;(0,o.d4)((()=>{l.current&&(x?(0,Os.Z)(l.current):l.current.pause())}),[x]),Fs(l,x),Ds(l,Boolean(I)),(0,Us.Z)(l,[I]);const F=(0,o.I4)((()=>{if(!I)return void f((e=>!e));if(r)return void(0,a.uC)().cancelMessageMediaDownload({message:e});const t=l.current;R?t.paused?((0,Os.Z)(t),(0,$t.Es)()):t.pause():(A(),t.pause(),t.currentTime=0,(0,Os.Z)(t),(0,$t.Es)(),T(!0))}),[A,R,r,I,e]),D=(0,o.I4)((e=>{const t=e.currentTarget;B(t.currentTime/t.duration)}),[]),Q=(0,de.Z)("full-media",S);return o.ZP.createElement("div",{ref:i,className:"RoundVideo media-inner",onClick:F},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:C,className:"thumbnail",style:`width: ${Ct.Rj}px; height: ${Ct.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",oa({ref:l,className:Q,width:Ct.Rj,height:Ct.Rj,autoPlay:!0,muted:!R,loop:!R,playsInline:!0,onEnded:R?L:void 0},w,{onTimeUpdate:R?D:void 0}),o.ZP.createElement("source",{src:I}))),o.ZP.createElement("div",{className:"progress",ref:c}),E&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(xs.Z,{progress:r?y:v})),!I&&!g&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},R?(0,U.k9)(l.current.currentTime):(0,U.k9)(h.duration),(!R||l.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},ca=({message:e,onClick:t})=>{const s=(0,be.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},e.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>t({button:e})},(0,Zt.Z)(s(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(n.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},da=(0,o.X$)((0,a.c$)(((e,{message:t})=>{const{threadId:s,chatId:a}=t.threadInfo,n=(0,i.tZ)(e,a,s)||t.threadInfo,{byId:o}=e.users,{byId:r}=e.chats;return{threadInfo:n,usersById:o,chatsById:r}}),((e,t)=>(0,g.ei)(t,["openChat"])))((({disabled:e,threadInfo:t,usersById:s,chatsById:a,openChat:n})=>{const r=(0,be.Z)(),{threadId:i,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:h,recentReplierIds:m}=t,g=(0,o.I4)((()=>{n({id:c,threadId:i})}),[n,c,i]);if(void 0===l)return;const f=m&&m.map((e=>(0,d.YC)(e)?s[e]:a[e])).filter(Boolean),p=Boolean(h&&u&&h<u);return o.ZP.createElement("div",{"data-cnt":(0,ft.bi)(l),className:(0,de.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(gs.Z,{key:e.id,size:"small",user:(0,d.YC)(e.id)?e:void 0,chat:(0,d.YC)(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"}))}))),la="data-is-document-group-hover";function ua(e){const t=ma(e.currentTarget);t&&t.setAttribute(la,"")}function ha(e){const t=ma(e.currentTarget);t&&t.removeAttribute(la)}function ma(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}const ga=(0,o.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:a,lastSyncTime:n}=e,{message:o,album:r,withSenderName:c,withAvatar:l,threadId:u,messageListType:h}=t,{id:m,chatId:g,viaBotId:f,replyToChatId:p,replyToMessageId:I,isOutgoing:v}=o,y=(0,i.Z1)(e,g),C=(0,i.FM)(e,g),Z=(0,d.pK)(g),P=y&&(0,d.eA)(y),w=null==y?void 0:y.username,b=!C&&(0,d.Ul)(o),M=c||l||b,S=(0,i.Ur)(e,o),E=(0,i.cv)(e,o),k=f?(0,i.dy)(e,f):void 0,R=u?(0,i.qS)(e,g,u):void 0,T=o.id===R,N=I===R,B=I&&!N?(0,i.hj)(e,Z&&p?p:g,I):void 0,x=B&&(0,i.Ur)(e,B),L=(0,i.uZ)(e,o),A="thread"===h&&(r?r.messages.some((t=>(0,i._X)(e,t))):(0,i._X)(e,o)),{direction:O,noHighlight:F,isResizingContainer:U}=A&&s||{},D=a.messageIds&&a.messageIds.includes(m),{query:Q}=(0,i.n5)(e)||{},$=(0,d._O)(o);let q;q=null!=r&&r.messages?r.messages.every((({id:t})=>(0,i.vk)(e,t))):(0,i.vk)(e,m);const{canReply:H}="thread"===h&&(0,i._k)(e,o,u)||{},G=(0,i.te)(e,o);return{theme:(0,i.Pu)(e),chatUsername:w,forceSenderName:b,sender:M?S:void 0,originSender:E,botSender:k,shouldHideReply:N,isThreadTop:T,replyMessage:B,replyMessageSender:x,isFocused:A,isForwarding:D,isChatWithSelf:C,isRepliesChat:Z,isChannel:P,canReply:H,lastSyncTime:n,highlight:Q,isSingleEmoji:Boolean($),animatedEmoji:$?(0,i.zB)(e,$):void 0,isInSelectMode:(0,i.CA)(e),isSelected:q,isGroupSelected:!!o.groupedId&&!o.isInAlbum&&(0,i.a6)(e,g,o.groupedId),threadId:u,isDownloading:G,isPinnedList:"pinned"===h,canAutoLoadMedia:y?(0,i.bH)(e,o,y,S):void 0,canAutoPlayMedia:(0,i.__)(e,o),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,i.yB)(e),...v&&{outgoingStatus:(0,i.dT)(e,o,"scheduled"===h)},..."number"==typeof L&&{uploadProgress:L},...A&&{focusDirection:O,noFocusHighlight:F,isResizingContainer:U}}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection","clickInlineButton","disableContextMenuHint"])))((({message:e,chatUsername:t,observeIntersectionForBottom:s,observeIntersectionForMedia:n,observeIntersectionForAnimatedStickers:r,album:i,noAvatars:c,withAvatar:l,withSenderName:g,noComments:f,appearanceOrder:p,isFirstInGroup:I,isLastInGroup:v,isFirstInDocumentGroup:y,isLastInDocumentGroup:C,isLastInList:Z,theme:P,forceSenderName:w,sender:b,originSender:M,botSender:S,isThreadTop:E,shouldHideReply:k,replyMessage:R,replyMessageSender:T,outgoingStatus:N,uploadProgress:B,isFocused:x,focusDirection:L,noFocusHighlight:A,isResizingContainer:O,isForwarding:F,isChatWithSelf:U,isRepliesChat:D,isChannel:Q,canReply:$,lastSyncTime:q,highlight:H,animatedEmoji:G,isInSelectMode:j,isSelected:_,isGroupSelected:V,threadId:z,messageListType:W,isPinnedList:Y,isDownloading:X,canAutoLoadMedia:K,canAutoPlayMedia:J,shouldLoopStickers:ee,autoLoadFileMaxSizeMb:te,toggleMessageSelection:se,clickInlineButton:ae,disableContextMenuHint:ne})=>{const oe=(0,o.sO)(null),re=(0,o.sO)(null),ie=(0,o.sO)(null),ce=(0,be.Z)();(0,Jt._N)(re,s);const{isContextMenuOpen:le,contextMenuPosition:he,handleBeforeContextMenu:me,handleContextMenu:ge,handleContextMenuClose:fe,handleContextMenuHide:pe}=(0,ss.Z)(oe,m.$b&&j,!0,m.wZ);(0,o.d4)((()=>{le&&ne()}),[le,ne]);const Ie=p<=0,[ve,ye]=(0,Ze.Z)(Ie);(0,o.d4)((()=>{Ie||setTimeout(ye,10*p)}),[p,ye,Ie]);const{transitionClassNames:Ce}=(0,ue.Z)(ve,void 0,Ie,!1),{id:Pe,chatId:we,threadInfo:Me}=e,Se=(0,d.CI)(e),Ee=(0,d.B4)(e),Re="scheduled"===W||e.isScheduled,Te=(0,d.ss)(e)&&!k,Ne=Boolean(Me)&&"thread"===W,{forwardInfo:Be,viaBotId:xe}=e,Le=Be&&(!U||Re)&&!D&&!Be.isLinkedChannelPost,Ae=Boolean(e.groupedId)&&!e.isInAlbum,Fe=Boolean(i)&&i.messages.length>1,{text:Ue,photo:De,video:Qe,audio:$e,voice:qe,document:He,sticker:Ge,contact:je,poll:_e,webPage:Ve,invoice:ze}=(0,d.qp)(e),We=(0,d.$D)(e),Ye=(0,as.X)(e,H,ns(We)),Xe=void 0!==he,Ke=Q&&e.adminTitle||Be&&!Le&&Be.adminTitle||void 0,Je=(0,o.Ye)((()=>Ke?hs(Ke):void 0),[Ke]),et=!(Xe||j||F)&&(!Ae||C),tt=Q&&!Re,st=Boolean(Y||Be&&(Be.isChannelPost||U&&!Ee||D)&&Be.fromMessageId),at=Be&&(U||D||!b)?M:b,nt=Be?M:b,ot=(0,o.I4)(((e,t)=>{se({messageId:Pe,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...Fe&&{childMessageIds:i.messages.map((({id:e})=>e))}})}),[se,Pe,Fe,i]),{handleMouseDown:rt,handleClick:ct,handleContextMenu:dt,handleDoubleClick:lt,handleContentDoubleClick:ut,isSwiped:ht}=function(e,t,s,n,r,i,c,d){const{setReplyingToId:l}=(0,a.uC)(),[u,h,g]=(0,Ze.Z)();return(0,o.d4)((()=>{if(!m.$b||r||!i)return;let e;return(0,Oe.s)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,s)=>s===Oe.e.Left&&(e||(e=Date.now()),h(),!0),onRelease:()=>{e&&(l({messageId:s}),setTimeout(g,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,r,s,l,h,g,i]),{handleMouseDown:r?void 0:function(e){(0,Wt.q)(e),d(e)},handleClick:function(t){if(r)e(t);else if(m.wZ){const e=t.target;if(!e.classList.contains("text-content")&&!e.classList.contains("Message"))return;it.Z.getIsKeyboardVisible()?setTimeout((()=>{c(t)}),350):c(t)}},handleContextMenu:r?void 0:function(t){if(m.wZ){if(t.target.matches("a[href]"))return;t.preventDefault(),e()}else c(t)},handleDoubleClick:r?void 0:function(){l({messageId:s})},handleContentDoubleClick:m.$b?void 0:function(e){e.stopPropagation()},isSwiped:u}}(ot,oe,Pe,0,Boolean(j),Boolean($),ge,me),{handleAvatarClick:gt,handleSenderClick:ft,handleViaBotClick:pt,handleReplyClick:It,handleMediaClick:vt,handleAudioPlay:yt,handleAlbumMediaClick:Pt,handleMetaClick:wt,handleReadMedia:bt,handleCancelUpload:Mt,handleVoteSend:St,handleGroupForward:Et,handleForward:kt,handleFocus:Rt,handleFocusForwarded:Tt,handleDocumentGroupSelectAll:Nt}=function(e,t,s,n,r,i,c,l,m,g,f,p){const{openUserInfo:I,openChat:v,showNotification:y,focusMessage:C,openMediaViewer:Z,openAudioPlayer:P,markMessagesRead:w,cancelSendingMessage:b,sendPollVote:M,openForwardMenu:S,focusMessageInComments:E}=(0,a.uC)(),{id:k,forwardInfo:R,replyToMessageId:T,replyToChatId:N,replyToTopMessageId:B,groupedId:x}=s,L=(0,o.I4)((()=>{g&&((0,d.YC)(g.id)?I({id:g.id}):v({id:g.id}))}),[g,I,v]),A=(0,o.I4)((()=>{f?(0,d.YC)(f.id)?I({id:f.id}):v({id:f.id}):y({message:e("HidAccount")})}),[f,y,e,I,v]),O=(0,o.I4)((()=>{p&&I({id:p.id})}),[p,I]),F=(0,o.I4)((()=>{C({chatId:l&&N?N:n,threadId:r,messageId:T,replyMessageId:l&&N?void 0:k})}),[C,l,N,n,r,T,k]),U=(0,o.I4)((()=>{Z({chatId:n,threadId:r,messageId:k,origin:c?h.bZ.ScheduledInline:h.bZ.Inline})}),[n,r,k,Z,c]),D=(0,o.I4)((()=>{P({chatId:n,messageId:k,origin:h.Cr.Inline})}),[n,k,P]),Q=(0,o.I4)((e=>{Z({chatId:n,threadId:r,messageId:e,origin:c?h.bZ.ScheduledAlbum:h.bZ.Album})}),[n,r,Z,c]),$=(0,o.I4)((()=>{w({messageIds:[k]})}),[k,w]),q=(0,o.I4)((()=>{b({chatId:n,messageId:k})}),[b,n,k]),H=(0,o.I4)((e=>{M({chatId:n,messageId:k,options:e})}),[n,k,M]),G=(0,o.I4)((()=>{S({fromChatId:n,groupedId:x})}),[S,n,x]),j=(0,o.I4)((()=>{if(m&&m.messages){const e=m.messages.map((({id:e})=>e));S({fromChatId:n,messageIds:e})}else S({fromChatId:n,messageIds:[k]})}),[m,S,n,k]),_=(0,o.I4)((()=>{C({chatId:n,threadId:u._f,messageId:k})}),[C,n,k]),V=(0,o.I4)((()=>{i?C({chatId:R.fromChatId,groupedId:x,groupedChatId:n}):l&&N?E({chatId:N,threadId:B,messageId:R.fromMessageId}):C({chatId:R.fromChatId,messageId:R.fromMessageId})}),[i,l,N,C,R,x,n,E,B]),z=(0,o.I4)((e=>{e.stopPropagation(),t(e,x)}),[t,x]);return{handleAvatarClick:L,handleSenderClick:A,handleViaBotClick:O,handleReplyClick:F,handleMediaClick:U,handleAudioPlay:D,handleAlbumMediaClick:Q,handleMetaClick:z,handleReadMedia:$,handleCancelUpload:q,handleVoteSend:H,handleGroupForward:G,handleForward:j,handleFocus:_,handleFocusForwarded:V,handleDocumentGroupSelectAll:z}}(ce,ot,e,we,z,Ae,Boolean(Re),D,i,at,nt,S),Bt=(0,de.Z)("Message message-list-item",I&&"first-in-group",v&&"last-in-group",y&&"first-in-document-group",C&&"last-in-document-group",Z&&"last-in-list",Ee&&"own",Boolean(e.views)&&"has-views",e.isEdited&&"was-edited",Te&&"has-reply",Xe&&"has-menu-open",x&&!A&&"focused",F&&"is-forwarding",e.isDeleting&&"is-deleting",Ae&&"is-in-document-group",Fe&&"is-album",e.hasUnreadMention&&"has-unread-mention",_&&"is-selected",j&&"is-in-selection-mode",E&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",ht&&"is-swiped",Ce),xt=function(e,{hasReply:t,customShape:s,isLastInGroup:a,asForwarded:n,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"],C=u||h,Z=C&&!l,P=Boolean(e.viaBotId);return ns(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")),n&&!s&&y.push("is-forwarded"),t&&y.push("is-reply"),o&&y.push("has-replies"),P&&y.push("is-via-bot"),r&&y.push("force-sender-name"),s||(y.push("has-shadow"),C&&i&&y.push("has-background"),(t||n||!Z||P||r)&&y.push("has-solid-background"),!a||!u&&Z||y.push("has-appendix")),y.join(" ")}(e,{hasReply:Te,customShape:We,isLastInGroup:v,asForwarded:Le,hasThread:Ne,forceSenderName:w,hasComments:e.threadInfo&&e.threadInfo.messagesCount>0,hasActionButton:tt||st}),Lt=e.threadInfo&&(!Ae||C)&&"thread"===W&&!f,At=xt.includes("has-appendix");(0,mt.Z)(D&&e.replyToChatId?e.replyToChatId:we,Te?e.replyToMessageId:void 0,R,e.id),ms(oe,we,x,L,A,O),(0,o.bt)((()=>{ie.current&&(ie.current.innerHTML=Ee?'<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>')}),[Ee,At]);let Ot,Ft="",Ut=!1;const Dt=(0,o.Ye)((()=>Fe?ls(Ee,Boolean(Le),Boolean(c),i):void 0),[Fe,Ee,Le,c,i]),Qt=Le?28:0;if(Fe||!De&&!Qe)Dt&&(Ot=Math.max(os(Boolean(Ue),Lt),Dt.containerStyle.width),Ot-Dt.containerStyle.width>18&&(Ut=!0));else{let t;De?t=rs(e,c).width:Qe&&(t=Qe.isRound?Ct.Rj:rs(e,c).width),t&&(Ot=Math.max(os(Boolean(Ue),Lt),t),Ot-t>18&&(Ut=!0))}return Ot&&(Ft=`width: ${Ot+Qt}px`),o.ZP.createElement("div",{ref:oe,id:`message${Pe}`,className:Bt,style:Je?`--meta-safe-author-width: ${Je}px`:void 0,"data-message-id":Pe,onMouseDown:rt,onClick:ct,onContextMenu:dt,onDoubleClick:lt,onMouseEnter:Ae&&!C?ua:void 0,onMouseLeave:Ae&&!C?ha:void 0},o.ZP.createElement("div",{ref:re,className:"bottom-marker","data-message-id":Pe,"data-last-message-id":i?i.messages[i.messages.length-1].id:void 0,"data-has-unread-mention":e.hasUnreadMention}),!Ae&&o.ZP.createElement("div",{className:"message-select-control"},_&&o.ZP.createElement("i",{className:"icon-select"})),C&&o.ZP.createElement("div",{className:(0,de.Z)("message-select-control group-select",V&&"is-selected"),onClick:Nt},V&&o.ZP.createElement("i",{className:"icon-select"})),l&&function(){const e=at&&(0,d.YC)(at.id),t=at&&e?at:void 0,s=at&&!e?at:void 0,a=!at&&Be?Be.hiddenUserName:void 0;return o.ZP.createElement(gs.Z,{size:"small",user:t,chat:s,text:a,lastSyncTime:q,onClick:t||s?gt:void 0})}(),o.ZP.createElement("div",{className:(0,de.Z)("message-content-wrapper",xt.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:xt,style:Ft,dir:"auto"},Le&&!We&&(!Ae||y)&&o.ZP.createElement("div",{className:"message-title"},ce("ForwardedMessage")),function(){const t=(0,de.Z)("content-inner",Le&&!We&&"forwarded-message",Te&&"reply-message",Ut&&"no-media-corners"),s=v&&!Ye&&!Le&&!Ne,a=!Ve&&!G&&Ye,l=(0,de.Z)("text-content",a&&"with-meta",N&&"with-outgoing-icon");return o.ZP.createElement("div",{className:t,onDoubleClick:ut,dir:"auto"},function(){if(We&&!xe||!(g&&!De&&!Qe||Le||xe||w)||Ae&&!y||Te&&We)return;let t,s;return!nt||We&&xe?null!=Be&&Be.hiddenUserName&&(t=Be.hiddenUserName):(t=(0,d.OU)(ce,nt),Le||(s=`color-${(0,d.Rs)(nt)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},t?o.ZP.createElement("span",{className:(0,de.Z)("interactive",s),onClick:ft,dir:"auto"},(0,Zt.Z)(t)):S?void 0:" ",S&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},ce("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:pt},(0,Zt.Z)(`@${S.username}`))),null!=Be&&Be.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},ce("DiscussChannel")):e.adminTitle&&!Q?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.adminTitle):void 0)}(),Te&&o.ZP.createElement(vs,{message:R,sender:T,observeIntersection:n,onClick:It}),Ge&&o.ZP.createElement(Ss,{message:e,observeIntersection:n,observeIntersectionForPlaying:r,shouldLoop:ee,lastSyncTime:q}),G&&o.ZP.createElement(Es.Z,{size:"small",sticker:G,observeIntersection:n,lastSyncTime:q,forceLoadPreview:Se}),Fe&&o.ZP.createElement(na,{album:i,albumLayout:Dt,observeIntersection:n,canAutoLoad:K,canAutoPlay:J,isOwn:Ee,hasCustomAppendix:s,lastSyncTime:q,onMediaClick:Pt}),!Fe&&De&&o.ZP.createElement(Ls,{message:e,observeIntersection:n,noAvatars:c,canAutoLoad:K,uploadProgress:B,shouldAffectAppendix:s,onClick:vt,onCancelUpload:Mt,isDownloading:X,theme:P}),!Fe&&Qe&&Qe.isRound&&o.ZP.createElement(ia,{message:e,observeIntersection:n,canAutoLoad:K,lastSyncTime:q,isDownloading:X}),!Fe&&Qe&&!Qe.isRound&&o.ZP.createElement($s,{message:e,observeIntersection:n,noAvatars:c,canAutoLoad:K,canAutoPlay:J,uploadProgress:B,lastSyncTime:q,onClick:vt,onCancelUpload:Mt,isDownloading:X}),($e||qe)&&o.ZP.createElement(Cs.Z,{theme:P,message:e,origin:h.Cr.Inline,uploadProgress:B,lastSyncTime:q,isSelectable:Ae,isSelected:_,onPlay:yt,onReadMedia:!qe||Ee&&!U?void 0:bt,onCancelUpload:Mt,isDownloading:X}),He&&o.ZP.createElement(ys.Z,{message:e,observeIntersection:n,canAutoLoad:K,autoLoadFileMaxSizeMb:te,uploadProgress:B,isSelectable:Ae,isSelected:_,onMediaClick:vt,onCancelUpload:Mt,isDownloading:X}),je&&o.ZP.createElement(Hs,{contact:je}),_e&&o.ZP.createElement(Ws,{message:e,poll:_e,onSendVote:St}),!G&&Ye&&o.ZP.createElement("p",{className:l,dir:"auto"},Ye,a&&o.ZP.createElement(Ps,{message:e,outgoingStatus:N,signature:Ke,onClick:wt})),Ve&&o.ZP.createElement(Ks,{message:e,observeIntersection:n,noAvatars:c,canAutoLoad:K,canAutoPlay:J,lastSyncTime:q,onMediaClick:vt,onCancelMediaTransfer:Mt,isDownloading:X,theme:P}),ze&&o.ZP.createElement(ea,{message:e}))}(),(!Ae||C)&&!(!Ve&&!G&&Ye)&&o.ZP.createElement(Ps,{message:e,outgoingStatus:N,signature:Ke,onClick:wt}),et&&tt?o.ZP.createElement(ke.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:ce("lng_context_forward_msg"),onClick:C?Et:kt},o.ZP.createElement("i",{className:"icon-share-filled"})):et&&st?o.ZP.createElement(ke.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:Y?Rt:Tt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Lt&&o.ZP.createElement(da,{message:e,disabled:f}),At&&o.ZP.createElement("div",{className:"svg-appendix",ref:ie})),e.inlineButtons&&o.ZP.createElement(ca,{message:e,onClick:ae})),he&&o.ZP.createElement(ps,{isOpen:le,anchor:he,message:e,album:i,chatUsername:t,messageListType:W,onClose:fe,onCloseAnimationEnd:pe}))}))),fa=(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:C,isSchedule:Z,noAppearanceAnimation:w,onFabToggle:b,onNotchToggle:M,openHistoryCalendar:S})=>{const{observeIntersectionForMedia:E,observeIntersectionForReading:k,observeIntersectionForAnimatedStickers:R}=function(e,t,s){const{markMessageListRead:n,markMessagesRead:o}=(0,a.uC)(),{observe:r}=(0,Jt.S1)({rootRef:t,throttleMs:es,margin:ts}),{observe:i,freeze:c,unfreeze:d}=(0,Jt.S1)({rootRef:t,throttleMs:150,noAutoFreeze:!0},(t=>{if("thread"!==e)return;let a=0;const r=[];t.forEach((e=>{const{isIntersecting:t,target:s}=e;if(!t)return;const{dataset:n}=s,o=Number(n.lastMessageId||n.messageId);o>a&&(a=o),n.hasUnreadMention&&r.push(o)})),s.current&&a>=s.current&&n({maxId:a}),r.length&&o({messageIds:r})}));(0,he.Z)(c,d);const{observe:l}=(0,Jt.S1)({rootRef:t,throttleMs:es});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,a.uC)(),[m,g]=(0,o.Ye)((()=>"thread"===e?[(0,P.Ds)((()=>u({direction:h.Uq.Backwards})),1e3,!0,!1),(0,P.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:a,scrollTop:n}=t.current,o=Math.round(a-n-e),u=o<=0;c(i?!u:!(o<=50)),d(!u)}const{observe:y}=(0,Jt.S1)({rootRef:t,margin:n.gZ},(e=>{if(!g||!m)return;if(s[0]>=n.AE)return;const a=e.find((({isIntersecting:e})=>e));if(!a)return;const{target:o}=a;"backwards-trigger"===o.className?((0,Xt.Z)(t.current),m()):"forwards-trigger"===o.className&&((0,Xt.Z)(t.current),g())}));(0,Jt._N)(f,y),(0,Jt._N)(p,y);const{observe:C,freeze:Z,unfreeze:w}=(0,Jt.S1)({rootRef:t,margin:50},v);(0,Jt._N)(I,C);const{observe:b,freeze:M,unfreeze:S}=(0,Jt.S1)({rootRef:t},v);return(0,Jt._N)(I,b),(0,ge.Z)((()=>{Z(),M(),setTimeout((()=>{S(),w()}),100)}),[s]),{backwardsTriggerRef:f,forwardsTriggerRef:p,fabTriggerRef:I}}(I,l,e,s,r,b,M,v),x=(0,be.Z)(),L=o.ZP.createElement("div",{className:(0,de.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,x("UnreadMessages"))),A=w?0:t.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let O=0;const F=t.map(((e,t,s)=>{const a=e.senderGroups.map(((e,a,n)=>{if(1===e.length&&!Vt(e[0])&&(0,d.Lo)(e[0])){const r=e[0],i=a===n.length-1&&t===s.length-1;return(0,g.oA)([r.id===m.current&&L,o.ZP.createElement(Is,{key:r.id,message:r,observeIntersection:k,appearanceOrder:A-++O,isLastInList:i})])}let r;return(0,g.xH)(e.map(((l,h)=>{const f=Vt(l)?l.mainMessage:l,v=Vt(l)?l:void 0,Z=(0,d.B4)(f),P=Vt(l),w=e[h+1];f.previousLocalId&&u.current===`message${f.previousLocalId}`&&(u.current=`message${f.id}`);const b=!P&&f.groupedId?f.groupedId:void 0,M=w&&!Vt(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&&a===n.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&&L,o.ZP.createElement(ga,{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===C,appearanceOrder:A-++O,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:Wt.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,de.Z)("sticky-date",!Z&&"interactive"),key:"date-header",onMouseDown:Wt.q,onClick:Z?void 0:()=>S({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},Z&&e.originalDate===n.t4&&x("MessageScheduledUntilOnline"),Z&&e.originalDate!==n.t4&&x("MessageScheduledOn",(0,U.j1)(x,e.datetime,void 0,!0)),!Z&&(0,U.j1)(x,e.datetime))),(0,g.xH)(a))}));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)(F),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 pa=s(3547);const Ia=(0,o.X$)((0,a.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,a=(0,d.db)(t)+(0,d.db)(e.currentUserId),n=null!=s&&s.length?s[a%s.length]:void 0,o=(0,i.Z1)(e,t);return o?{sticker:n,lastUnreadMessageId:o.lastMessage&&o.lastMessage.id!==o.lastReadInboxMessageId?o.lastMessage.id:void 0,connectionState:e.connectionState}:{}}),((e,t)=>(0,g.ei)(t,["loadGreetingStickers","sendMessage","markMessageListRead"])))((({sticker:e,connectionState:t,lastUnreadMessageId:s,loadGreetingStickers:a,sendMessage:n,markMessageListRead:r})=>{const i=(0,be.Z)(),c=(0,o.sO)(null),{observe:d}=(0,Jt.S1)({rootRef:c,debounceMs:200});(0,o.d4)((()=>{e||"connectionStateReady"!==t||a()}),[t,a,e]),(0,o.d4)((()=>{"connectionStateReady"===t&&s&&r({maxId:s})}),[t,r,s]);const l=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},n({sticker:e})}),[n]);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(pa.Z,{sticker:e,onClick:l,clickArg:e,observeIntersection:d,size:160,className:"large"}))))}))),va=(0,o.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s})=>{const a=(0,be.Z)();return"scheduled"===t?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(a):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")))))}(a):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")))))}(a):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,a("NoMessages")))})),ya=(0,P.Ds)((e=>e()),200,!1),Ca=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,type:a})=>{const n=(0,i.Z1)(e,t);if(!n)return{};const o=(0,i.$W)(e,t,s,a),r="scheduled"===a?(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}=n,g=(0,i.G$)(e,t),f=s===u._f&&!o&&!n.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)(n),isGroupChat:(0,d.Bf)(n),isCreator:n.isCreator,isChatWithSelf:(0,i.FM)(e,t),isRepliesChat:(0,d.pK)(t),isBot:Boolean(p),messageIds:o,messagesById:r,firstUnreadId:(0,i.It)(e,t,s),isViewportNewest:"thread"!==a||(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:n.fullInfo&&"linkedChatId"in n.fullInfo?Boolean(n.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,isRepliesChat:C,isCreator:Z,isBot:w,messageIds:b,messagesById:M,firstUnreadId:S,isViewportNewest:E,threadFirstMessageId:k,isRestricted:R,restrictionReason:T,focusingId:N,isSelectModeActive:B,loadViewportMessages:x,setScrollOffset:L,lastMessage:A,botDescription:O,threadTopMessageId:F,hasLinkedChat:U,openHistoryCalendar:D})=>{var Q,$,q,H,G,j;const _=(0,o.sO)(null),V=(0,o.sO)("thread"===s&&(0,i.Vt)((0,a.Rd)(),e,t)||0),z=(0,o.sO)(),W=(0,o.sO)(),Y=(0,o.sO)(),X=(0,o.sO)(),K=(0,o.sO)(),J=(0,o.sO)(),ee=(0,o.sO)(!1),te=(0,o.sO)(Boolean(A)),[se,ae]=(0,o.eJ)(),ne=Boolean(b);(0,ge.Z)((()=>{ne&&(0,P.R3)((()=>{te.current=!1}))}),[ne]),(0,ge.Z)((()=>{X.current=S}),[S]),(0,ge.Z)((()=>{ne&&(K.current=X.current)}),[ne]),(0,ge.Z)((()=>{J.current=N}),[N]);const oe=(0,o.Ye)((()=>{if(!b||!M)return;const e=!F||b[0]&&k!==b[0]?b:[F,...b];if(!e.length)return;const t=e.map((e=>M[e])).filter(Boolean);return zt((0,g.Xo)(t,["date","id"]),K.current)}),[b,M,k,F]),re=(0,o.Ye)((()=>{if("thread"===s)return(0,P.Ds)((()=>x({direction:h.Uq.Around})),1e3,!0,!1)}),[x,b]),{isScrolled:ie,updateStickyDates:le}=function(){const[e,t]=(0,Ze.Z)(!1),s=(0,Yt.Z)(1e3,!1);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,P.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{(0,P.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const s=function(e,t){const s=e.querySelectorAll(".sticky-date"),a=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:n}=e,o=s-a;return-n<=o&&o<=(t?60:10)}))}(e,a);s&&s.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,s])}}(),ue=(0,o.I4)((()=>{if(ee.current)return void(ee.current=!1);const a=_.current;J.current||le(a,r),ya((()=>{(0,P.T2)((()=>{a.parentElement&&(V.current=a.scrollHeight-a.scrollTop,"thread"===s&&L({chatId:e,threadId:t,scrollOffset:V.current}))}))}))}),[le,r,s,L,e,t]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{e.target.offsetParent&&ae(e.contentRect.height)}));return e.observe(_.current),()=>{e.disconnect()}}),[]);const{height:he}=ct();(0,o.d4)((()=>{I&&(_.current.dataset.normalHeight=String(_.current.offsetHeight))}),[he,I,p]),(0,o.d4)((()=>{if(!re||!u||R||N)return;if(b&&b[b.length-1]>=n.AE)return;const e=_.current;(!b||b.length<n.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&re()}),[u,b,re,N,R]),(0,ge.Z)((()=>{if(!b||!Y.current||!I)return;const e=Y.current.filter((e=>b.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(z.current=t.id,W.current=t.getBoundingClientRect().top)}),[b,E,se,r,I]),(0,jt.Z)((([e,t,s])=>{const a=_.current;if(Y.current=Array.from(a.querySelectorAll(".message-list-item")),!a.offsetParent)return;const o=E&&b&&b.length<n.hT/2&&!a.parentElement.classList.contains("force-messages-scroll")&&a.firstElementChild.clientHeight<=2*a.offsetHeight;o&&(a.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{a.parentElement&&a.parentElement.classList.remove("force-messages-scroll")}),1e3));const i=b&&e&&b[b.length-1]!==e[e.length-1],c=(null==b?void 0:b[0])!==(null==e?void 0:e[0])&&(null==b?void 0:b.length)===n.hT/2+1,d=i&&!c,l=b&&J.current===b[b.length-1],{scrollTop:u,scrollHeight:h,offsetHeight:m}=a,g=V.current,f=Y.current[Y.current.length-1];let p=g-(s||m);d&&(p-=f?f.offsetHeight:0);const I=E&&t&&p<=20;let v;if(d&&I&&!l&&(f&&(0,P.T2)((()=>{(0,Kt.Z)(a,f,"end",20)})),v=h-m,V.current=Math.max(Math.ceil(h-v),m),!o))return;const y=void 0!==s&&s!==se,C=z.current&&document.getElementById(z.current),Z=!C&&K.current&&a.querySelector(".unread-divider");if(I&&y){if((0,Kt.N)())return;v=h-m}else v=C?u+(C.getBoundingClientRect().top-(W.current||0)):Z?Math.min(Z.offsetTop-(r?60:10),h-g):h-g;(0,Xt.Z)(a,Math.ceil(v)),J.current||(ee.current=!0,(0,P.T2)((()=>{ee.current=!1}))),V.current=Math.max(Math.ceil(h-v),m)}),[b,E,se,r]),(0,_t.Z)((([e])=>{void 0!==e&&(0,ce.YW)(200+n.fK)}),[B]);const me=(0,be.Z)(),fe=Boolean(e&&(0,d.YC)(e)),pe=Boolean(!fe&&!m||y||C),Ie=Boolean(!pe||m),ve=(0,d.YC)(e)&&!y&&!w&&(!oe&&!A&&b&&(!Y.current||0===Y.current.length)||1===(null==b?void 0:b.length)&&"contactSignUp"===(null==M||null===(Q=M[b[0]])||void 0===Q||null===($=Q.content.action)||void 0===$?void 0:$.type)||"contactSignUp"===(null==A||null===(q=A.content)||void 0===q||null===(H=q.action)||void 0===H?void 0:H.type)),ye=f&&Z&&1===(null==b?void 0:b.length)&&"chatCreate"===(null==M||null===(G=M[b[0]])||void 0===G||null===(j=G.content.action)||void 0===j?void 0:j.type),Ce=(0,de.Z)("MessageList custom-scroll",Ie&&"no-avatars",!p&&"no-composer","pinned"===s&&"type-pinned",B&&"select-mode-active",ie&&"scrolled",!I&&"is-animating");return o.ZP.createElement("div",{ref:_,className:Ce,onScroll:ue,onMouseDown:Wt.q},R?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,T?T.text:"This is a private "+(m?"channel":"chat"))):O?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,Zt.Z)(me(O),["br","emoji","links"]))):ve?o.ZP.createElement(Ia,{userId:e}):!b||oe&&!ye?b&&oe||A?o.ZP.createElement(fa,{messageIds:b||[A.id],messageGroups:oe||zt([A]),isViewportNewest:Boolean(E),isUnread:Boolean(S),withUsers:pe,noAvatars:Ie,containerRef:_,anchorIdRef:z,memoUnreadDividerBeforeIdRef:K,memoFirstUnreadIdRef:X,threadId:t,type:s,isActive:v,threadTopMessageId:F,hasLinkedChat:U,isSchedule:!!oe&&"scheduled"===s,noAppearanceAnimation:!oe||!te.current,onFabToggle:c,onNotchToggle:l,openHistoryCalendar:D}):o.ZP.createElement(qe.Z,{color:"white"}):o.ZP.createElement(va,{chatId:e,type:s,isChatWithSelf:y,isGroupChatJustCreated:ye}))}))),Za=(0,o.X$)((0,a.c$)((e=>{const t=(0,i.Bt)(e);if(!t)return{};const{chatId:s,threadId:a,type:n}=t,o=(0,i.Z1)(e,s);return{messageListType:n,unreadCount:o&&a===u._f&&"thread"===n?o.unreadCount:void 0}}),((e,t)=>(0,g.ei)(t,["focusNextReply"])))((({isShown:e,canPost:t,messageListType:s,unreadCount:a,withExtraShift:n,focusNextReply:r})=>{const i=(0,be.Z)(),c=(0,o.sO)(null),d=(0,o.I4)((()=>{if(e)if("thread"===s)r();else{const e=c.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,Kt.Z)(e,s,"end",20)}}),[e,s,r]),l=(0,de.Z)("ScrollDownButton",e&&"revealed",!t&&"no-composer",n&&"with-extra-shift");return o.ZP.createElement("div",{ref:c,className:l},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(ke.Z,{color:"secondary",round:!0,onClick:d,ariaLabel:i("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(a)&&o.ZP.createElement("div",{className:"unread-count"},(0,ft.bi)(a))))})));var Pa=s(5723);const wa=1280,ba=/\.[^/.]+$/;async function Ma(e,t,s,a){const o=URL.createObjectURL(t),{type:r,size:i}=t;let c,d;if(n.oG.has(r))if(s){const t=await(0,rt.pt)(o),{width:s,height:n}=t;if(s>wa||n>wa||"image/jpeg"!==r){const t=await Lt(o,wa/Math.max(s,n),"image/jpeg");return URL.revokeObjectURL(o),Ma(e,await(0,rt.gm)(t),!0,a)}"image/jpeg"===r&&(e=e.replace(ba,".jpg")),c={width:s,height:n}}else d=o;else if(n.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:s}=await(0,rt.jj)(o);c={width:e,height:t,duration:s},d=await(0,rt.ud)(o)}return{blobUrl:o,filename:e,mimeType:r,size:i,quick:c,previewBlobUrl:d,...a}}var Sa=s(6391);let Ea;function ka(e){Ea.focus(),e.focus()}m.cj&&(Ea=document.createElement("input"),Ea.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Ea));const Ra={encoderPath:s.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},Ta={type:"audio/ogg"};let Na,Ba,xa;async function La(){return Na||(Na=s.e(161).then(s.t.bind(s,1161,23)),Ba=(await Na).default,xa=new Ba(Ra)),Na}async function Aa(e){await async function(){await La(),await xa.start()}();const t=Date.now();let s;const a=[],n=[];xa.ondataavailable=e=>{a.push(e)};const o=function(t,s){const a=t.sourceNode,o=a.context.createAnalyser();o.fftSize=64,a.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=>{n.push(255*t),e(t)})(s<.1?0:s),requestAnimationFrame(t)}(),()=>{c=!0}}(xa);return{stop:()=>new Promise(((e,r)=>{xa.onstop=()=>{e({blob:new Blob(a,Ta),duration:Math.round(((s||Date.now())-t)/1e3),waveform:n})},xa.onerror=r;const i=Math.max(0,t+1e3-Date.now());setTimeout((()=>{xa.stop(),o()}),i)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{xa.pause(),s=Date.now(),o()}),e)}}}const Oa=["image/png","image/jpeg","image/gif"];function Fa(e){const{text:t,entities:s}=e||{};if(!t)return"";const a=(0,as.H)(t,s,void 0,void 0,!0);return Array.isArray(a)?a.join(""):a}let Ua,Da;var Qa=s(4784),$a=s(2400),qa=s(8353),Ha=s(2365);const Ga=document.createElement("div"),ja=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,_a=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i;const Va=(0,P.P2)((e=>e()),500,!0),za=/^[\w@]{1,32}\s?/i,Wa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"DeleteMessageModal",!t);return s?o.ZP.createElement(s,e):void 0}));function Ya(){return(Ya=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}let Xa,Ka=!0;const Ja=(0,o.X$)((({onActivate:e,...t})=>{const s=(0,o.sO)(!1),a=(0,o.I4)((()=>{if(s.current=!0,Ka)return Ka=!1,void e();Xa&&(clearTimeout(Xa),Xa=void 0),Xa=window.setTimeout((()=>{s.current&&e()}),200)}),[e]),n=(0,o.I4)((()=>{s.current=!1}),[]);return o.ZP.createElement(ke.Z,Ya({},t,{onMouseEnter:m.$b?void 0:a,onMouseLeave:m.$b?void 0:n,onClick:m.$b?e:void 0}))})),en=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"AttachMenu",!t);return s?o.ZP.createElement(s,e):void 0})),tn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"SymbolMenu",!t);return s?o.ZP.createElement(s,e):void 0})),sn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"InlineBotTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),an=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"MentionTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),nn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"CustomSendMenu",!t);return s?o.ZP.createElement(s,e):void 0})),on=e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"StickerTooltip",!t);return s?o.ZP.createElement(s,e):void 0};var rn=s(9830);const cn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"BotCommandTooltip",!t);return s?o.ZP.createElement(s,e):void 0}));var dn=s(6503);const ln=(0,o.X$)((0,a.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:a})=>{const[n,r]=(0,dn.Z)(e,s),{isKeyboardSingleUse:i}=t||{},[c,d,l]=(0,Ze.Z)(!0),u=()=>{l(),s()};if((0,o.d4)((()=>{d()}),[d,t]),t&&t.keyboardButtons)return o.ZP.createElement(je.Z,{isOpen:e||c,autoClose:i,positionX:"right",positionY:"bottom",onClose:u,className:"BotKeyboardMenu",onCloseAnimationEnd:u,onMouseEnter:m.$b?void 0:n,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(ke.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>a({button:e})},e.text))))))))})));var un=s(3616),hn=s(7891);const mn=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:s,type:a}=(0,i.Bt)(e)||{};if(!t||!s||!a)return{};const{currentUserId:n,forwardMessages:{fromChatId:o,toChatId:r,messageIds:c}}=e,l=(0,i.Yy)(e,t,s),u="scheduled"===a?(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,a):m&&1===c.length&&(g=(0,i.hj)(e,o,c[0])),l&&g){const{forwardInfo:s}=g,a=t===n;s&&(s.isChannelPost||a)&&(f=(0,i.cv)(e,g)),f||(f=(0,i.Ur)(e,g))}else m&&(f=(0,d.YC)(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:a,shouldAnimate:n,forwardedMessagesCount:r,setReplyingToId:i,setEditingId:c,focusMessage:d,exitForwardMode:l})=>{const u=Boolean((e||t)&&s||a&&r),h=(0,hn.Z)([r],r?300:void 0),{shouldRender:m,transitionClassNames:g}=(0,ue.Z)(h&&u,void 0,!n,void 0,!n),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,ye.Z)(f):void 0),[u,f]);const p=(0,o.I4)((()=>{d({chatId:s.chatId,messageId:s.id})}),[d,s]),I=(0,de.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(ke.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(vs,{className:"inside-input",message:s,sender:a,customText:v,title:t?"Edit Message":void 0,onClick:p})))}))),gn=(0,o.X$)((e=>{const{attachments:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"AttachmentModal",!t.length);return s?o.ZP.createElement(s,e):void 0})),fn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"BotCommandMenu",!t);return s?o.ZP.createElement(s,e):void 0})),pn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"PollModal",!t);return s?o.ZP.createElement(s,e):void 0})),In=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"DropArea",!t);return s?o.ZP.createElement(s,e):void 0})),vn=new RegExp(n.FM,"i"),yn=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s})=>{const a=(0,i.tV)(e,t,s);return{theme:(0,i.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:a}}),((e,t)=>(0,g.ei)(t,["loadWebPagePreview","clearWebPagePreview","toggleMessageWebPage"])))((({chatId:e,threadId:t,messageText:s,disabled:a,webPagePreview:n,noWebPage:r,theme:i,loadWebPagePreview:c,clearWebPagePreview:d,toggleMessageWebPage:l})=>{const h=(0,o.Ye)((()=>{const{text:e,entities:t}=(0,p.Z)(s),a=t&&t.find((({type:e})=>e===u.Vv.TextUrl));if(a)return a.url;const n=e.match(vn);return n?n[0]:void 0}),[s]);(0,o.d4)((()=>{h?c({text:h}):(d(),l({chatId:e,threadId:t}))}),[e,l,d,h,c,t]),(0,ge.Z)((()=>{d(),l({chatId:e,threadId:t})}),[e]);const m=Boolean(n&&s.length&&!r&&!a),{shouldRender:g,transitionClassNames:f}=(0,ue.Z)(m),I=(0,gt.Z)(n,!0);if(!g||!I)return;const{photo:v,...y}=I,C={content:{webPage:y}};return o.ZP.createElement("div",{className:(0,de.Z)("WebPagePreview",f)},o.ZP.createElement("div",null,o.ZP.createElement(ke.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{l({chatId:e,threadId:t,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Ks,{message:C,inPreview:!0,theme:i})))})));var Cn=s(2898);const Zn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"CalendarModal",!t);return s?o.ZP.createElement(s,e):void 0}));var Pn;!function(e){e.Send="send",e.Record="record",e.Edit="edit"}(Pn||(Pn={}));const wn=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a})=>{var o,r;const c=(0,i.Z1)(e,t),l=c&&(0,i.Dg)(e,c),h=t!==n.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,shouldSuggestStickers:v}=e.settings.byKey,y=e.emojiKeywords[n.pR],C=I!==n.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,a),connectionState:e.connectionState,draft:(0,i.Ms)(e,t,s),chat:c,isChatWithBot:m,isChatWithSelf:g,canScheduleUntilOnline:!g&&!m&&c&&l&&(0,d.YC)(t)&&l.status&&Boolean(l.status.wasOnline),isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),withScheduledButton:s===u._f&&"thread"===a&&Boolean(null==p?void 0:p.length),shouldSchedule:"scheduled"===a,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,shouldSuggestStickers:v,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==y?void 0:y.keywords,emojiKeywords:null==C?void 0:C.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","loadScheduledHistory","openChat","addRecentEmoji","sendInlineBotResult"])))((({dropAreaState:e,shouldSchedule:t,canScheduleUntilOnline:s,isReady:r,onDropHide:i,editingMessage:c,chatId:l,threadId:h,messageListType:g,draft:I,chat:v,connectionState:y,isChatWithBot:C,isChatWithSelf:Z,isRightColumnShown:w,isSelectModeActive:b,isForwarding:M,isPollModalOpen:S,botKeyboardMessageId:E,botKeyboardPlaceholder:k,withScheduledButton:R,stickersForEmoji:T,groupChatMembers:N,topInlineBotIds:B,currentUserId:x,usersById:L,lastSyncTime:A,contentToBeScheduled:O,shouldSuggestStickers:F,baseEmojiKeywords:D,emojiKeywords:Q,serverTimeOffset:$,recentEmojis:q,inlineBots:H,isInlineBotLoading:G,botCommands:j,chatBotCommands:_,sendMessage:V,editMessage:z,saveDraft:W,clearDraft:Y,showDialog:X,setStickerSearchQuery:K,setGifSearchQuery:J,forwardMessages:ee,openPollModal:te,closePollModal:se,loadScheduledHistory:ae,openChat:ne,addRecentEmoji:oe,sendInlineBotResult:re})=>{const ie=(0,be.Z)(),ce=(0,o.sO)(null),[le,ue]=(0,o.eJ)(""),ge=(0,o.sO)(),fe=(0,Ns.Z)(e),[pe,Ie,ve]=(0,Ze.Z)(),[Ce,Pe]=(0,o.eJ)(),{width:we}=it.Z.get(),Me=(0,o.sO)(le);(0,o.d4)((()=>{Me.current=le}),[le]),(0,o.d4)((()=>{ge.current=void 0}),[l]),(0,o.d4)((()=>{l&&A&&h===u._f&&r&&ae({chatId:l})}),[r,l,ae,A,h]),(0,o.bt)((()=>{ce.current&&(ce.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)((()=>{O&&(Pe(O),Ie())}),[O,Ie]);const[Se,Ee]=(0,o.eJ)([]),[Re,Te,Ne]=(0,Ze.Z)(),[Be,xe,Ae]=(0,Ze.Z)(),[Oe,Fe,Ue]=(0,Ze.Z)(),[De,Qe,$e]=(0,Ze.Z)(),[qe,He,Ge]=(0,Ze.Z)(),[je,_e]=(0,Ze.Z)(),[Ve,ze,We]=(0,Ze.Z)(),{startRecordingVoice:Ye,stopRecordingVoice:Xe,pauseRecordingVoice:Ke,activeVoiceRecording:Je,currentRecordTime:et,recordButtonRef:tt,startRecordTimeRef:st}=(()=>{const e=(0,o.sO)(null),[t,s]=(0,o.eJ)(),a=(0,o.sO)(),[n,r]=(0,o.eJ)();(0,o.d4)((()=>{m.s$&&m.mh&&La()}),[]);const i=(0,o.I4)((async()=>{try{const{stop:t,pause:n}=await Aa((t=>{e.current&&(a.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),r(Date.now()))}));a.current=Date.now(),r(Date.now()),s({stop:t,pause:n})}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),a.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,ye.Z)(d):void 0),[t,d]),{startRecordingVoice:i,pauseRecordingVoice:c,stopRecordingVoice:d,activeVoiceRecording:t,currentRecordTime:n,recordButtonRef:e,startRecordTimeRef:a}})(),at=c?Pn.Edit:!m.mh||Je||le&&!Se.length||M?Pn.Send:Pn.Record,ot=!t,{isMentionTooltipOpen:rt,closeMentionTooltip:ct,insertMention:dt,mentionFilteredUsers:lt}=(0,Ha.Z)(!Se.length,le,ue,void 0,N,B,x,L),{isOpen:ut,id:ht,isGallery:mt,switchPm:gt,results:ft,closeTooltip:pt,help:It,loadMore:vt}=function(e,t,s,n){const[r,i,c]=(0,Ze.Z)(),d=function(e){return Ga.innerHTML=e.replace(/<br>/g,"\n"),Ga.innerText}(s),{queryInlineBot:l,resetInlineBot:u}=(0,a.uC)(),{username:h,query:m,canShowHelp:g}=function(e){const t=e.match(ja);return t?{username:t[1],query:t[2],canShowHelp:""===t[2]&&!e.match(_a)}:{username:"",query:"",canShowHelp:!1}}(d),f=h.toLowerCase(),p=(0,Ns.Z)(m),I=(0,Ns.Z)(h),v=null==n?void 0:n[f],{id:y,switchPm:C,offset:Z,results:P,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:Z})}),[Z,t,m,l,f]);return(0,o.d4)((()=>{e&&y&&(C||null!=P&&P.length)?i():c()}),[y,e,i,P,C,c]),I!==h&&u({username:I}),{isOpen:r,closeTooltip:c,loadMore:M,username:h,id:y,isGallery:w,switchPm:C,results:P,help:g&&b?`@${h} ${b}`:void 0}}(Boolean(!Se.length&&A),l,le,H),{isOpen:yt,close:Ct,filteredBotCommands:Pt}=function(e,t,s,a){const[n,r,i]=(0,Ze.Z)(),[c,d]=(0,o.eJ)(),l=(0,o.I4)((e=>{s||a?Va((()=>{const t=(s||a||[]).filter((({command:t})=>!e||t.includes(e)));d(t&&t.length?t:void 0)})):d(void 0)}),[s,a]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,$a._)(t.substr(1)).match(za);l(e?e[0]:"")}else i();else i()}),[l,t,e,i]),(0,o.d4)((()=>{c&&c.length?r():i()}),[c,r,i]),{isOpen:n,close:i,filteredBotCommands:c}}(Boolean(j&&j.length||_&&_.length),le,j,_),{isContextMenuOpen:wt,handleContextMenu:bt,handleContextMenuClose:Mt,handleContextMenuHide:St}=(0,ss.Z)(tt,!(at===Pn.Send&&ot)),Et=(0,o.Ye)((()=>(0,d.H5)(v,C)),[v,C]),kt=v&&(0,d.Nl)(v),Rt=(0,d.Hd)(v),{isStickerTooltipOpen:Tt,closeStickerTooltip:Nt}=function(e,t,s,n=!1){const r=(0,o.Ye)((()=>(0,$a._)(t).trim()),[t]),{loadStickersForEmoji:i,clearStickersForEmoji:c}=(0,a.uC)(),d=m.op&&1===(0,Qa.Z)(r)||!m.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),l=Boolean(s)&&d;return(0,o.d4)((()=>{n||(e&&d?i({emoji:r}):!l&&d||c())}),[t,d,c,i,e,n]),{isStickerTooltipOpen:l,closeStickerTooltip:c}}(Boolean(F&&Et.canSendStickers&&!Se.length),le,T,!r),{isEmojiTooltipOpen:Bt,closeEmojiTooltip:xt,filteredEmojis:Lt,insertEmoji:At}=(0,qa.Z)(Boolean(F&&Et.canSendStickers&&!Se.length),le,q,void 0,ue,D,Q,!r),Ot=(0,o.I4)(((e,t=n.R2)=>{const s=window.getSelection(),a=document.getElementById(t),o=(0,Zt.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(s.rangeCount){const e=s.getRangeAt(0);if((0,Sa.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 a=s.createContextualFragment(e),n=a.lastChild;s.insertNode(a),n?(s.setStartAfter(n),s.setEndAfter(n)):s.collapse(!1),t.removeAllRanges(),t.addRange(s)}}(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}ue(`${Me.current}${o}`),requestAnimationFrame((()=>{(0,Pa.Z)(a)}))}),[]),Ft=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,Sa.R)(t,n.R2))return void document.execCommand("delete",!1)}ue(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 a=s.textContent.length,n=document.createRange(),o=window.getSelection();n.setStart(s,a),n.setEnd(s,a),o.removeAllRanges(),o.addRange(n),document.execCommand("delete",!1);const r=t.innerHTML;return document.body.removeChild(t),r}(Me.current))}),[]),Ut=(0,o.I4)(((e=!1)=>{e||ue(""),Ee([]),Nt(),ve(),Pe(void 0),ct(),xt(),m.wB?setTimeout((()=>$e()),350):$e()}),[Nt,ve,ct,xt,$e]),Dt=(0,o.sO)();Dt.current=Xe,(0,o.d4)((()=>()=>{Dt.current(),Ut()}),[l,Ut,Dt]);const Qt=((e,t,s,a,r,i)=>((0,o.d4)((()=>{s?(t(Fa(s.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(n.R2);(0,Pa.Z)(e,!0)}))):t("")}),[s,t]),(0,o.I4)((()=>{const{text:t,entities:n}=(0,p.Z)(e.current);s&&(t||(0,d.u8)(s)?(i({messageId:s.id,text:t,entities:n}),a()):r())}),[i,s,e,r,a])))(Me,ue,c,Ut,He,z);((e,t,s,a,r,i,c,d,l)=>{const u=(0,o.I4)(((e,t)=>{r.current.length&&!c?d({chatId:e,threadId:t,draft:(0,p.Z)(r.current)}):l({chatId:e,threadId:t})}),[l,c,r,d]),h=(0,o.Ye)((()=>(0,P.Ds)((e=>e()),n.r_,!1)),[t]),g=(0,Ns.Z)(t),f=(0,Ns.Z)(s);(0,o.d4)((()=>(Ua=t,Da=s,()=>{Ua=void 0,Da=void 0,u(t,s)})),[t,s,u]),(0,o.d4)((()=>{t===g&&s===f||e&&(i(Fa(e)),m.$b||requestAnimationFrame((()=>{const e=document.getElementById(n.R2);(0,Pa.Z)(e,!0)})))}),[t,s,e,i,u,g,f]);const I=(0,Ns.Z)(a);(0,o.d4)((()=>{t&&s&&g===t&&f===s&&I!==a&&(a.length?h((()=>{Ua===t&&Da===s&&u(t,s)})):u(t,s))}),[t,a,g,I,f,h,s,u]);const v=(0,o.I4)((()=>{t&&s&&u(t,s)}),[t,s,u]);(0,he.Z)(v),me(v)})(I,l,h,le,Me,ue,c,W,Y),((e,t,s)=>{(0,o.d4)((()=>{async function a(a){if(!a.clipboardData)return;const o=document.activeElement;if(o&&![n.R2,n.nY].includes(o.id))return;const{items:r}=a.clipboardData,i=Array.from(r).find((e=>Oa.includes(e.type)&&"file"===e.kind)),c=i&&i.getAsFile(),d=a.clipboardData.getData("text").substring(0,4096);if(a.preventDefault(),c||d){if(c&&!s){const e=await Ma(c.name,c,!0);t((t=>[...t,e]))}d&&e(d,null==o?void 0:o.id)}}return document.addEventListener("paste",a,!1),()=>{document.removeEventListener("paste",a,!1)}}),[e,s,t])})(Ot,Ee,c);const $t=(0,o.I4)((async(e,t)=>{Ee(await Promise.all(e.map((e=>Ma(e.name,e,t)))))}),[]),qt=(0,o.I4)((async(e,t)=>{Ee([...Se,...await Promise.all(e.map((e=>Ma(e.name,e,t))))])}),[Se]),Ht=(0,o.I4)((()=>{Ee([])}),[]),Gt=(0,o.I4)((async(e=!1,t)=>{if("connectionStateReady"!==y)return;let s=Se;if(Je){const e=await Xe();if(e){const{blob:t,duration:a,waveform:n}=e;s=[await Ma("wonderful-voice-message.ogg",t,!1,{voice:{duration:a,waveform:n}})]}}const{text:a,entities:o}=(0,p.Z)(Me.current);if(!s.length&&!a&&!M)return;const r=s.length?1024:4096;if((null==a?void 0:a.length)>r){const e=a.length-r;return void X({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const i=document.getElementById(n.R2);if(s.length||a){if(Rt&&!kt){const e=(0,f.b)($),t=ge.current&&Math.floor(e-ge.current),s=Rt.nextSendDate&&Rt.nextSendDate>e;if(t&&t<Rt.seconds||s){const a=s?Rt.nextSendDate-e:Rt.seconds-t;return X({data:{message:ie("SlowModeHint",(0,U.k9)(a)),isSlowMode:!0,hasErrorKey:!1}}),void i.blur()}}V({text:a,entities:o,attachments:s,scheduledAt:t,isSilent:e})}M&&ee({scheduledAt:t,isSilent:e}),ge.current=(0,f.b)($),Y({chatId:l,localOnly:!0}),m.cj&&i===document.activeElement&&ka(i),requestAnimationFrame((()=>{Ut()}))}),[y,Se,Je,M,Y,l,$,Ut,Xe,X,Rt,kt,V,ee,ie]),jt=(0,o.I4)((()=>{$e(),xe()}),[$e,xe]),_t=(0,o.I4)((()=>{Ae(),Qe()}),[Ae,Qe]),Vt=(0,o.I4)(((e,s=!1)=>{e={...e,isPreloadedGlobally:!0},t?(Pe({sticker:e}),Ie()):(V({sticker:e}),requestAnimationFrame((()=>{Ut(s)})))}),[t,Ie,V,Ut]),zt=(0,o.I4)((e=>{t?(Pe({gif:e}),Ie()):(V({gif:e}),requestAnimationFrame((()=>{Ut(!0)})))}),[t,Ie,V,Ut]),Wt=(0,o.I4)((e=>{if("connectionStateReady"!==y)return;re({id:e.id,queryId:e.queryId});const t=document.getElementById(n.R2);m.cj&&t===document.activeElement&&ka(t),Y({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{Ut()}))}),[l,Y,y,Ut,re]),Yt=(0,o.I4)((()=>{Y({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{Ut()}))}),[l,Y,Ut]),Xt=(0,o.I4)((e=>{t?(Pe({poll:e}),se(),Ie()):(V({poll:e}),se())}),[se,Ie,V,t]),Kt=(0,o.I4)((()=>{t?(Pe({isSilent:!0}),Ie()):Gt(!0)}),[Gt,Ie,t]),Jt=(0,o.I4)(((e,t=!1)=>{const{isSilent:s,...a}=Ce||{},n=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:$);Ce&&0!==Object.keys(a).length?(V({...Ce,scheduledAt:n}),requestAnimationFrame((()=>{Ut()}))):Gt(!!s,n),ve()}),[ve,Gt,Ut,Ce,V,$]),es=(0,o.I4)((()=>{Jt(new Date(1e3*n.t4),!0)}),[Jt]),ts=(0,o.I4)((()=>{ve(),Pe(void 0)}),[ve]),as=(0,o.I4)((e=>{"stickers"===e?(K({query:""}),J({query:void 0})):(J({query:""}),K({query:void 0}))}),[K,J]),ns=(0,o.I4)((()=>{const e=document.getElementById(n.R2);m.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Ae(),Qe()}),100)):Qe()}),[Qe,Ae]),os=(0,o.I4)((()=>{ne({id:l,threadId:h,type:"scheduled"})}),[ne,l,h]);(0,o.d4)((()=>{w&&m.wB&&$e()}),[w,$e]),(0,o.d4)((()=>{r&&(b?ze():setTimeout((()=>{We()}),200))}),[b,We,ze,r]);const rs=(0,o.I4)((()=>{switch(at){case Pn.Send:t?(Je&&Ke(),Ie()):Gt();break;case Pn.Record:Ye();break;case Pn.Edit:Qt()}}),[at,t,Ye,Qt,Je,Ie,Ke,Gt]),is=at===Pn.Record&&!Et.canAttachMedia,cs=(0,Ns.Z)(c,!0),ds=c||cs,ls=new Date;ls.setSeconds(0),ls.setMilliseconds(0);const us=new Date;us.setFullYear(us.getFullYear()+1);let hs="SendMessage";switch(at){case Pn.Edit:hs="Save edited message";break;case Pn.Record:hs=is?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const ms=(0,de.Z)("Composer",!b&&"shown",Ve&&"hover-disabled"),gs=(0,de.Z)("mobile-symbol-menu-button",!r&&"not-ready",je?De&&"menu-opened":De&&"is-loading"),fs=at===Pn.Edit?Qt:t?Ie:Gt;return o.ZP.createElement("div",{className:ms},Et.canAttachMedia&&r&&o.ZP.createElement(Cn.Z,{containerId:"#middle-column-portals"},o.ZP.createElement(In,{isOpen:e!==nt.t.None,withQuick:[e,fe].includes(nt.t.QuickFile),onHide:i,onFileSelect:$t})),o.ZP.createElement(gn,{attachments:Se,caption:Se.length?le:"",groupChatMembers:N,currentUserId:x,usersById:L,recentEmojis:q,isReady:r,onCaptionUpdate:ue,baseEmojiKeywords:D,emojiKeywords:Q,addRecentEmoji:oe,onSend:t?Ie:Gt,onFileAppend:qt,onClear:Ht}),o.ZP.createElement(pn,{isOpen:Boolean(S),onClear:se,onSend:Xt}),ds&&o.ZP.createElement(Wa,{isOpen:qe,isSchedule:"scheduled"===g,onClose:Ge,message:ds}),o.ZP.createElement(an,{isOpen:rt,onClose:ct,onInsertUserName:dt,filteredUsers:lt,usersById:L}),o.ZP.createElement(sn,{isOpen:ut,botId:ht,allowedAttachmentOptions:Et,isGallery:mt,inlineBotResults:ft,switchPm:gt,onSelectResult:Wt,loadMore:vt,onClose:pt}),o.ZP.createElement(cn,{isOpen:yt,withUsername:Boolean(_),botCommands:Pt,onClick:Yt,onClose:Ct}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:ce}),o.ZP.createElement(mn,null),o.ZP.createElement(yn,{chatId:l,threadId:h,messageText:Se.length?"":le,disabled:!Et.canAttachEmbedLinks}),o.ZP.createElement("div",{className:"message-input-wrapper"},C&&!1!==j&&!Je&&!c&&o.ZP.createElement(Ja,{className:(0,de.Z)("bot-commands",Be&&"activated"),round:!0,disabled:void 0===j,color:"translucent",onActivate:jt,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),m.wB?o.ZP.createElement(ke.Z,{className:gs,round:!0,color:"translucent",onClick:De?$e:ns,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),De&&!je&&o.ZP.createElement(Le.Z,{color:"gray"})):o.ZP.createElement(Ja,{className:De?"activated":"",round:!0,color:"translucent",onActivate:_t,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(un.Z,{id:"message-input-text",html:Se.length?"":le,placeholder:Je&&we<=600?"":k||ie("Message"),forcedPlaceholder:It,shouldSetFocus:!Se.length,shouldSuppressFocus:m.wB&&De,shouldSuppressTextFormatter:Bt||rt||ut,onUpdate:ue,onSend:fs,onSuppressedFocus:$e}),G&&Boolean(ht)&&o.ZP.createElement(Le.Z,{color:"gray"}),R&&o.ZP.createElement(ke.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:os,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),E&&!Je&&!c&&o.ZP.createElement(Ja,{className:Re?"activated":"",round:!0,color:"translucent",onActivate:Te,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!Je&&!c&&o.ZP.createElement(Ja,{className:Oe?"activated":"",round:!0,color:"translucent",onActivate:Fe,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),Je&&et&&o.ZP.createElement("span",{className:"recording-state"},(0,U.rM)(et-st.current)),o.ZP.createElement(on,{isOpen:Tt,onStickerSelect:Vt}),o.ZP.createElement(rn.Z,{isOpen:Bt,emojis:Lt,onClose:xt,onEmojiSelect:At,addRecentEmoji:oe}),o.ZP.createElement(en,{isOpen:Oe,allowedAttachmentOptions:Et,onFileSelect:$t,onPollCreate:te,onClose:Ue}),E&&o.ZP.createElement(ln,{messageId:E,isOpen:Re,onClose:Ne}),j&&o.ZP.createElement(fn,{isOpen:Be,botCommands:j,onClose:Ae}),o.ZP.createElement(tn,{isOpen:De,allowedAttachmentOptions:Et,onLoad:_e,onClose:$e,onEmojiSelect:Ot,onStickerSelect:Vt,onGifSelect:zt,onRemoveSymbol:Ft,onSearchOpen:as,addRecentEmoji:oe}))),Je&&o.ZP.createElement(ke.Z,{round:!0,color:"danger",className:"cancel",onClick:Xe,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(ke.Z,{ref:tt,round:!0,color:"secondary",className:(0,de.Z)(at,!r&&"not-ready",Je&&"recording"),disabled:is,ariaLabel:ie(hs),onClick:rs,onContextMenu:at===Pn.Send&&ot?bt:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),ot&&o.ZP.createElement(nn,{isOpen:wt,onSilentSend:Z?void 0:Kt,onScheduleSend:t?void 0:Ie,onClose:Mt,onCloseAnimationEnd:St}),o.ZP.createElement(Zn,{isOpen:pe,withTimePicker:!0,selectedAt:ls.getTime(),maxAt:(0,U._F)(us),isFutureMode:!0,secondButtonLabel:s?ie("Schedule.SendWhenOnline"):void 0,onClose:ts,onSubmit:Jt,onSecondButtonClick:s?es:void 0}))}))),bn=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0})),Mn=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0})),Sn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0})),En=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0})),kn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0})),Rn=m.wB?450+n.fK:void 0;function Tn(e){return"file"===e.kind&&e.type&&n.oG.has(e.type)}const Nn=(0,o.X$)((0,a.c$)((e=>{const t=(0,i.Pu)(e),{isBlurred:s,background:a,backgroundColor:n,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:a,backgroundColor:n,patternColor:o,isLeftColumnShown:l,isRightColumnShown:(0,i.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(m.wB&&(0,i.n5)(e)),isSelectModeActive:(0,i.CA)(e),isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),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:C,messageId:Z}=e.audioPlayer,P=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.YC)(f),canPost:!b&&(!v||P)&&!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(C&&Z),pinnedMessagesCount:y?y.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:r}}),((e,t)=>(0,g.ei)(t,["openChat","unpinAllMessages","loadUser","closeLocalTextSearch","exitMessageSelectMode","closePaymentModal","clearReceipt"])))((({chatId:e,threadId:t,messageListType:s,isPrivate:a,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:C,isBackgroundBlurred:Z,isMobileSearchActive:P,isSelectModeActive:w,isPaymentModalOpen:b,isReceiptModalOpen:M,animationLevel:S,shouldSkipHistoryAnimations:E,currentTransitionKey:k,openChat:R,unpinAllMessages:T,loadUser:N,closeLocalTextSearch:B,exitMessageSelectMode:x,closePaymentModal:L,clearReceipt:A})=>{const{width:O}=ct(),F=(0,be.Z)(),[U,D]=(0,o.eJ)(nt.t.None),[Q,$]=(0,o.eJ)(),[q,H]=(0,o.eJ)(),[G,j]=(0,o.eJ)(!1),[_,V]=(0,o.eJ)(!m.wB||S===n.oB),z=h&&(O<n.l3||C&&O>n._m&&O<n.QU||O>=n.ks&&O<n.jT),W=(0,dt.Z)(e,Rn),Y=(0,dt.Z)(t,Rn),X=(0,dt.Z)(s,Rn),K=(0,dt.Z)(c,Rn),J=(0,dt.Z)(z,Rn),ee=(0,dt.Z)(Q,Rn);(0,o.d4)((()=>e?(0,ye.Z)((()=>{R({id:void 0})})):void 0),[e,R]),(0,o.d4)((()=>{D(nt.t.None),$(void 0),H(void 0)}),[e]),(0,o.d4)((()=>{S===n.oB&&V(!0)}),[S]),(0,o.d4)((()=>{const{visualViewport:e}=window;if(!e)return;const t=()=>{window.visualViewport.height!==document.documentElement.clientHeight?document.body.classList.add("keyboard-visible"):document.body.classList.remove("keyboard-visible")};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}}),[]),(0,o.d4)((()=>{a&&N({userId:e})}),[e,a,N]);const te=(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(Tn);D(s?nt.t.QuickFile:nt.t.Document)}),[]),se=(0,o.I4)((()=>{D(nt.t.None)}),[]),ae=(0,o.I4)((()=>{j(!0)}),[]),ne=(0,o.I4)((()=>{j(!1)}),[]),oe=(0,o.I4)((()=>{T({chatId:e}),ne(),R({id:e})}),[T,R,ne,e]),re=(0,o.I4)((()=>{R({id:e})}),[R,e]),ie=((e,t)=>{const[s,a]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?a(t):ot.fetch(n.fo,e,ot.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,rt.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?s:void 0})(p,f),ce=(0,de.Z)(J&&"has-header-tools",f&&"custom-bg-image",I&&"custom-bg-color",f&&Z&&"blurred",m.aZ?"mask-image-disabled":"mask-image-enabled"),le=(0,de.Z)("messaging-disabled",!w&&"shown"),ue=(0,d.q8)(F,l,u),{composerHiddenScale:he,toolbarHiddenScale:me,composerTranslateX:ge,toolbarTranslateX:fe,unpinHiddenScale:pe,toolbarForUnpinHiddenScale:Ie}=(0,o.Ye)((()=>function(e,t){const s=e<=n.l3?16:32,a=function(e){if(e>n._m){const t=Math.min(Math.max(.25*e,288),424),s=Math.min(.25*e,424);return Math.min(e-t-s,lt)}if(e>n.ks){const t=Math.min(Math.max(.4*e,288),424);return Math.min(e-t,lt)}return e>lt?lt:e}(e),o=e<=n.l3?54:64,r=t?a-s-o:a-s,i=e>n.l3?Math.min(a-s,512):a-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}}(O,K)),[K,O]),Ce=(0,de.Z)("middle-column-footer",!K&&"no-composer",K&&q&&!w&&"with-notch");(0,ve.ZP)(W&&Y,(()=>{R({id:void 0},!0)}),void 0,void 0,void 0,i?i.map(ut.q):[]),(0,ve.ZP)(P,B),(0,ve.ZP)(w,x);const Ze=Boolean(!r&&!K&&ue);return o.ZP.createElement("div",{id:"MiddleColumn",className:ce,onTransitionEnd:t=>{"transform"===t.propertyName&&t.target===t.currentTarget&&V(Boolean(e))},style:`\n --composer-hidden-scale: ${he};\n --toolbar-hidden-scale: ${me};\n --unpin-hidden-scale: ${pe};\n --toolbar-unpin-hidden-scale: ${Ie};\n --composer-translate-x: ${ge}px;\n --toolbar-translate-x: ${fe}px;\n --pattern-color: ${v};\n --theme-background-color:\n ${I||("dark"===p?n.It:n.p3)};\n `,onClick:m.p7&&y?re:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:ie?`--custom-background: ${ie}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),W&&Y&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:K?te:void 0},o.ZP.createElement(Gt,{chatId:W,threadId:Y,messageListType:X,isReady:_}),o.ZP.createElement(Pe.Z,{name:E?"none":S===n.zy?"slide":"fade",activeKey:k,shouldCleanup:!0},(e=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ca,{key:`${W}-${Y}-${X}`,chatId:W,threadId:Y,type:X,canPost:K,hasTools:J,onFabToggle:$,onNotchToggle:H,isReady:_,isActive:e}),o.ZP.createElement("div",{className:Ce},K&&o.ZP.createElement(wn,{chatId:W,threadId:Y,messageListType:X,dropAreaState:U,onDropHide:se,isReady:_}),r&&o.ZP.createElement("div",{className:"unpin-button-container",dir:F.isRtl?"rtl":void 0},o.ZP.createElement(ke.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:ae},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,F("Chat.Pinned.UnpinAll",g,"i")))),Ze&&o.ZP.createElement("div",{className:le},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,ue))),o.ZP.createElement(Mn,{messageListType:X,isActive:w,canPost:K}),o.ZP.createElement(En,{isOpen:Boolean(b),onClose:L}),o.ZP.createElement(kn,{isOpen:Boolean(M),onClose:A}))))),o.ZP.createElement(Za,{isShown:ee,canPost:K,withExtraShift:Ze||w||r})),m.wB&&o.ZP.createElement(bn,{isActive:Boolean(P)})),e&&o.ZP.createElement(Sn,{isOpen:G,chatId:e,pinnedMessagesCount:g,onClose:ne,onUnpin:oe}))}))),Bn=(0,P.Ds)((e=>e()),200,!1);var xn;!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"}(xn||(xn={}));const Ln=(0,o.X$)((0,a.c$)(((e,{chatId:t,isProfile:s,isManagement:a})=>{const{query:n}=(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),u=s&&t&&(0,d.YC)(t)?(0,i.dy)(e,t):void 0,h=u&&(0,d.kw)(u);return{canManage:Boolean(!a&&s&&!h&&c&&!(0,i.FM)(e,c.id)&&((0,d.YC)(c.id)||((0,d.Nl)(c)||c.isCreator)&&!c.isNotJoined)),canAddContact:h,isChannel:l,userId:null==u?void 0:u.id,messageSearchQuery:n,stickerSearchQuery:o,gifSearchQuery:r}}),((e,t)=>(0,g.ei)(t,["setLocalTextSearchQuery","setStickerSearchQuery","setGifSearchQuery","searchTextMessagesLocal","toggleManagement","openHistoryCalendar","addContact"])))((({isColumnOpen:e,isProfile:t,isSearch:s,isManagement:a,isStickerSearch:n,isGifSearch:r,isPollResults:i,isAddingChatMembers:c,profileState:d,managementScreen:l,canAddContact:u,userId:g,canManage:f,isChannel:p,onClose:I,messageSearchQuery:v,stickerSearchQuery:y,gifSearchQuery:C,setLocalTextSearchQuery:Z,setStickerSearchQuery:P,setGifSearchQuery:w,searchTextMessagesLocal:b,toggleManagement:M,openHistoryCalendar:S,shouldSkipAnimation:E,addContact:k})=>{var R;const T=(0,o.sO)(null),N=(0,o.I4)((e=>{Z({query:e}),e.length&&Bn(b)}),[b,Z]),B=(0,o.I4)((e=>{P({query:e})}),[P]),x=(0,o.I4)((e=>{w({query:e})}),[w]),L=(0,o.I4)((()=>{k({userId:g})}),[k,g]),[A,O]=(0,o.eJ)(!e);(0,o.d4)((()=>{setTimeout((()=>{O(!e)}),300)}),[e]);const F=(0,be.Z)(),D=t?d===h.vi.Profile?xn.Profile:d===h.vi.SharedMedia?xn.SharedMedia:d===h.vi.MemberList?xn.MemberList:-1:s?xn.Search:i?xn.PollResults:n?xn.StickerSearch:r?xn.GifSearch:c?xn.AddingMembers:a?l===h.u1.Initial?xn.ManageInitial:l===h.u1.ChatPrivacyType?xn.ManageChatPrivacyType:l===h.u1.Discussion?xn.ManageDiscussion:l===h.u1.ChannelSubscribers?xn.ManageChannelSubscribers:l===h.u1.GroupPermissions?xn.ManageGroupPermissions:l===h.u1.ChatAdministrators?xn.ManageChatAdministrators:l===h.u1.GroupRemovedUsers?xn.ManageGroupRemovedUsers:l===h.u1.GroupUserPermissionsCreate?xn.ManageGroupUserPermissionsCreate:l===h.u1.GroupUserPermissions?xn.ManageGroupUserPermissions:l===h.u1.GroupRecentActions?xn.ManageGroupRecentActions:l===h.u1.ChatAdminRights?xn.ManageGroupAdminRights:l===h.u1.GroupMembers?xn.ManageGroupMembers:void 0:void 0,Q=null!==(R=(0,gt.Z)(D,!0))&&void 0!==R?R:-1;function $(){if(-1!==Q)switch(Q){case xn.PollResults:return o.ZP.createElement("h3",null,F("PollResults"));case xn.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Re.Z,{parentContainerClassName:"RightSearch",value:v,onChange:N}),o.ZP.createElement(ke.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>S({selectedAt:(0,U._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case xn.AddingMembers:return o.ZP.createElement("h3",null,F("GroupAddMembers"));case xn.ManageInitial:return o.ZP.createElement("h3",null,F("Edit"));case xn.ManageChatPrivacyType:return o.ZP.createElement("h3",null,F(p?"ChannelTypeHeader":"GroupTypeHeader"));case xn.ManageDiscussion:return o.ZP.createElement("h3",null,F("Discussion"));case xn.ManageChatAdministrators:return o.ZP.createElement("h3",null,F("ChannelAdministrators"));case xn.ManageGroupRecentActions:return o.ZP.createElement("h3",null,F("Group.Info.AdminLog"));case xn.ManageGroupAdminRights:return o.ZP.createElement("h3",null,F("EditAdminRights"));case xn.ManageGroupPermissions:return o.ZP.createElement("h3",null,F("ChannelPermissions"));case xn.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,F("ChannelBlockedUsers"));case xn.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,F("ChannelAddException"));case xn.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,F("UserRestrictions"));case xn.StickerSearch:return o.ZP.createElement(Re.Z,{value:y,placeholder:F("SearchStickersHint"),autoFocusSearch:!0,onChange:B});case xn.GifSearch:return o.ZP.createElement(Re.Z,{value:C,placeholder:F("SearchGifsTitle"),autoFocusSearch:!0,onChange:x});case xn.SharedMedia:return o.ZP.createElement("h3",null,F("SharedMedia"));case xn.ManageChannelSubscribers:return o.ZP.createElement("h3",null,F("ChannelSubscribers"));case xn.MemberList:case xn.ManageGroupMembers:return o.ZP.createElement("h3",null,F("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(ke.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:F("AddContact"),onClick:L},o.ZP.createElement("i",{className:"icon-add-user"})),f&&o.ZP.createElement(ke.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:F("Edit"),onClick:M},o.ZP.createElement("i",{className:"icon-edit"}))))}}const q=m.wB||D===xn.SharedMedia||D===xn.MemberList||D===xn.AddingMembers||a,H=(0,de.Z)("animated-close-icon",q&&"state-back",(A||E)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(ke.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:I,ariaLabel:F(q?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:T,className:H})),o.ZP.createElement(Pe.Z,{name:A||E?"none":"slide-fade",activeKey:Q},$))})));var An=s(91),On=s(7407);function Fn(e,t,s,a){const[o,r]=(0,On.Z)(s?t:void 0,a,void 0,n.Vk);return[o,r,!(!o||!a||o[0]===a[0])]}function Un(e,t,s,a,r,i){const c=(0,o.sO)();(0,ge.Z)((()=>{t===e&&r&&i&&(c.current=(0,d.R5)(r,i,e).reverse())}),[r,i,t,e]);const[l,u]=(0,On.Z)(a?s:void 0,c.current,void 0,"media"===e?n.EN:n.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const Dn=(0,P.P2)((e=>e()),250,!1);let Qn=!1;var $n=s(1273),qn=s(1876),Hn=s(787),Gn=s(180),jn=s(3709),_n=s(5418),Vn=s(7262),zn=s(1151),Wn=s(3103);const Yn=(0,o.X$)((0,a.c$)(((e,{userId:t})=>{const s=(0,i.jr)(e),a=t&&(0,i.dy)(e,t);return{chat:s,contactName:a?(0,d.Vl)(a):void 0}}),((e,t)=>(0,g.ei)(t,["deleteChatMember"])))((({isOpen:e,chat:t,userId:s,contactName:a,onClose:n,deleteChatMember:r})=>{const i=(0,be.Z)(),c=(0,o.I4)((()=>{r({chatId:t.id,userId:s}),n()}),[t,r,n,s]);if(t&&s)return o.ZP.createElement(Wn.Z,{isOpen:e,onClose:n,onEnter:c,className:"delete",title:i("GroupRemoved.Remove")},o.ZP.createElement("p",null,(0,Zt.Z)(i("PeerInfo.Confirm.RemovePeer",a))),o.ZP.createElement(ke.Z,{color:"danger",className:"confirm-dialog-button",isText:!0,onClick:c},i("lng_box_remove")),o.ZP.createElement(ke.Z,{className:"confirm-dialog-button",isText:!0,onClick:n},i("Cancel")))}))),Xn=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function Kn(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > div.active > .${e}-list > .scroll-item`].join(", ")}const Jn=(0,o.X$)((0,a.c$)(((e,{chatId:t,userId:s})=>{var a,n;const o=(0,i.Z1)(e,t),r=(0,i.Zw)(e,s||t),{currentType:c,resultsByType:l}=(0,i.we)(e)||{},{foundIds:u}=l&&c&&l[c]||{},{byId:h}=e.users,{byId:m}=e.chats,g=o&&(0,d.Bf)(o),f=o&&(0,d.eA)(o),p=g||f&&(0,d.Nl)(o),I=null==o||null===(a=o.fullInfo)||void 0===a?void 0:a.members,v=p&&o&&o.fullInfo&&!o.fullInfo.canViewMembers,y=p&&o&&((0,d.VE)(o,"inviteUsers")||o.isCreator),C=p&&o&&((0,d.VE)(o,"banUsers")||o.isCreator),Z=(0,i.xs)(e,t);let P,w,b;return s?w=s:(0,d.YC)(t)&&(w=t),w&&(b=(0,i.dy)(e,w),P=b&&!b.isSelf&&!(0,d.cS)(b)),{theme:(0,i.Pu)(e),isChannel:f,resolvedUserId:w,chatMessages:r,foundIds:u,mediaSearchType:c,hasCommonChatsTab:P,hasMembersTab:p,areMembersHidden:v,canAddMembers:y,canDeleteMembers:C,currentUserId:e.currentUserId,isRightColumnShown:(0,i.Jf)(e),isRestricted:null==o?void 0:o.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:Z,usersById:h,chatsById:m,...p&&I&&{members:I},...P&&b&&{commonChatIds:null===(n=b.commonChats)||void 0===n?void 0:n.ids}}}),((e,t)=>(0,g.ei)(t,["setLocalMediaSearchType","loadMoreMembers","searchMediaMessagesLocal","openMediaViewer","openAudioPlayer","openUserInfo","focusMessage","loadProfilePhotos","setNewChatMembersDialogState","loadCommonChats","openChat"])))((({chatId:e,profileState:t,onProfileStateChange:s,theme:a,isChannel:r,resolvedUserId:i,currentUserId:c,chatMessages:l,foundIds:g,mediaSearchType:f,hasCommonChatsTab:p,hasMembersTab:I,areMembersHidden:v,canAddMembers:y,canDeleteMembers:C,commonChatIds:Z,members:P,usersById:w,chatsById:b,isRightColumnShown:M,isRestricted:S,lastSyncTime:E,activeDownloadIds:k,serverTimeOffset:R,setLocalMediaSearchType:T,loadMoreMembers:N,loadCommonChats:B,openChat:x,searchMediaMessagesLocal:L,openMediaViewer:A,openAudioPlayer:O,openUserInfo:F,focusMessage:U,loadProfilePhotos:D,setNewChatMembersDialogState:Q})=>{const $=(0,o.sO)(null),q=(0,o.sO)(null),H=(0,be.Z)(),[G,j]=(0,o.eJ)(0),[_,V]=(0,o.eJ)(),z=(0,o.Ye)((()=>[...I?[{type:"members",title:r?"ChannelSubscribers":"GroupMembers"}]:[],...Xn,...p?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[p,I,r]),W=z[G].type,[Y,X,K,J]=function(e,t,s,a,n,r,i,c,l,u,h,m,g,f,p=0){const I="members"!==n&&r?r:n,v=(0,o.Ye)((()=>{if(i&&l)return(0,d.Z0)(i.map((({userId:e})=>e)),l,void 0,p)}),[i,p,l]),y=(0,o.Ye)((()=>{if(c&&u)return(0,d.ih)(c,u,!0)}),[u,c]),[C,Z,P]=Fn(0,t,f,v),[w,b,M]=Fn(0,s,f,y),[S,E,k]=Un("media",I,a,f,h,m),[R,T,N]=Un("documents",I,a,f,h,m),[B,x,L]=Un("links",I,a,f,h,m),[A,O,F]=Un("audio",I,a,f,h,m),[U,D,Q]=Un("voice",I,a,f,h,m);let $,q,H=!1;switch(I){case"members":$=C,q=Z,H=P;break;case"commonChats":$=w,q=b,H=M;break;case"media":$=S,q=E,H=k;break;case"documents":$=R,q=T,H=N;break;case"links":$=B,q=x,H=L;break;case"audio":$=A,q=O,H=F;break;case"voice":$=U,q=D,H=Q}return[I,$,q,H]}(0,N,B,L,W,f,P,Z,w,b,l,g,0,E,R),ee=z.findIndex((({type:e})=>e===Y)),{handleScroll:te}=function(e,t,s,a){(0,_t.Z)((([s])=>{if(s&&s!==t){const s=e.current,n=s.querySelector(".TabList");s.scrollTop<n.offsetTop&&(a("members"===t?h.vi.MemberList:h.vi.SharedMedia),Qn=!0,(0,Kt.Z)(s,n,"start",void 0,void 0,void 0,300),setTimeout((()=>{Qn=!1}),350))}}),[t,a]),(0,_t.Z)((([t])=>{if(s!==h.vi.Profile||s===t)return;const n=e.current;n&&n.querySelector(".TabList")&&(Qn=!0,(0,Kt.Z)(n,n.firstElementChild,"start",void 0,2*n.offsetHeight),setTimeout((()=>{Qn=!1}),350),a(s))}),[s]);const n=(0,o.I4)((()=>{const s=e.current;if(!s)return;const n=s.querySelector(".TabList");if(!n)return;let o=h.vi.Profile;s.scrollTop>=n.offsetTop&&(o="members"===t?h.vi.MemberList:h.vi.SharedMedia),a(o)}),[e,a,t]);return(0,o.d4)((()=>{Qn||n()}),[n,t]),{handleScroll:(0,o.I4)((()=>{Qn||Dn(n)}),[n])}}($,W,t,s),{applyTransitionFix:se,releaseTransitionFix:ae}=function(e,t=".Transition.shared-media-transition"){return(0,o.d4)((()=>{function s(){const s=e.current,a=s.querySelector(t),n=s.querySelector(".TabList");a&&n&&(a.style.minHeight=s.offsetHeight-n.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])}}($),[ne,oe]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),re=(0,o.I4)((()=>{ae(),oe()}),[ae,oe]),ie=(0,o.I4)((()=>{Q(h.WB.InProgress)}),[Q]);(0,o.d4)((()=>{T({mediaType:W})}),[T,W]);const ce=i||e;(0,o.d4)((()=>{E&&D({profileId:ce})}),[D,ce,E]);const de=(0,o.I4)((e=>{A({chatId:ce,threadId:u._f,messageId:e,origin:h.bZ.SharedMedia})}),[ce,A]),le=(0,o.I4)((e=>{O({chatId:ce,messageId:e,origin:h.Cr.SharedMedia})}),[ce,O]),ue=(0,o.I4)((e=>{F({id:e})}),[F]),he=(0,o.I4)((e=>{U({chatId:ce,messageId:e})}),[ce,U]),me=(0,o.I4)((()=>{V(void 0)}),[]);let ge;(0,o.d4)((()=>{if(q.current&&m.$b)return(0,Oe.s)(q.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Oe.e.Left?(j(Math.min(G+1,z.length-1)),!0):t===Oe.e.Right&&(j(Math.max(0,G-1)),!0)})}),[G,z.length]);const fe="members"===Y||!I&&"media"===Y;fe?ge=M?0:1e3:X||(ge=n.Y);const pe=(0,hn.Z)([e,Y],ge);function Ie(){if(!X||!pe||!l){const e=fe&&X&&!pe;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Le.Z,null))}if(!X.length){let e;switch(Y){case"members":e=v?"You have no access to group members list.":"No members found";break;case"commonChats":e=H("NoGroupsInCommon");break;case"documents":e=H("lng_media_file_empty");break;case"links":e=H("lng_media_link_empty");break;case"audio":e=H("lng_media_song_empty");break;case"voice":e=H("lng_media_audio_empty");break;default:e=H("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(Vn.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${Y}-list`,dir:H.isRtl&&"media"===Y?"rtl":void 0,teactFastList:!0},"media"===Y?X.map((e=>l[e]&&o.ZP.createElement(jn.Z,{key:e,message:l[e],onClick:de}))):"documents"===Y?X.map((e=>l[e]&&o.ZP.createElement(ys.Z,{key:e,message:l[e],withDate:!0,smaller:!0,className:"scroll-item",onDateClick:he,isDownloading:k.includes(e)}))):"links"===Y?X.map((e=>l[e]&&o.ZP.createElement(_n.Z,{key:e,message:l[e],onMessageClick:he}))):"audio"===Y?X.map((e=>l[e]&&o.ZP.createElement(Cs.Z,{key:e,theme:a,message:l[e],origin:h.Cr.SharedMedia,date:l[e].date,lastSyncTime:E,className:"scroll-item",onPlay:le,onDateClick:he,isDownloading:k.includes(e)}))):"voice"===Y?X.map((e=>l[e]&&o.ZP.createElement(Cs.Z,{key:e,theme:a,message:l[e],senderTitle:(0,An.F)(H,l[e],b,w),origin:h.Cr.SharedMedia,date:l[e].date,lastSyncTime:E,className:"scroll-item",onPlay:le,onDateClick:he,isDownloading:k.includes(e)}))):"members"===Y?X.map(((e,t)=>{return o.ZP.createElement(qn.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>ue(e),contextActions:(s=e,s!==c&&C?[{title:H("lng_context_remove_from_group"),icon:"stop",handler:()=>{V(s)}}]:void 0)},o.ZP.createElement(pt.Z,{userId:e,forceShowSelf:!0}));var s})):"commonChats"===Y?X.map(((e,t)=>o.ZP.createElement(qn.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>x({id:e})},o.ZP.createElement(It.Z,{chatId:e})))):void 0)}return o.ZP.createElement($n.Z,{ref:$,className:"Profile custom-scroll",itemSelector:Kn(Y),items:pe?X:void 0,cacheBuster:ne,sensitiveArea:n.qU,preloadBackwards:pe?"members"===Y?n.Vk:n.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:K,onScroll:te},!J&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Hn.Z,{userId:t||e}),o.ZP.createElement(Gn.Z,{chatOrUserId:t||e}))}(e,i),!S&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Pe.Z,{ref:q,name:H.isRtl?"slide-reversed":"slide",activeKey:ee,renderCount:z.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:se,onStop:re},Ie),o.ZP.createElement(Fe.Z,{big:!0,activeTab:G,tabs:z,onSwitchTab:j})),y&&o.ZP.createElement(zn.Z,{isShown:"members"===Y,onClick:ie,ariaLabel:H("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),C&&o.ZP.createElement(Yn,{isOpen:Boolean(_),userId:_,onClose:me}))}))),eo=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),to=(0,o.X$)((e=>{const t=(0,$e.Z)(Qe.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),so=(0,o.X$)((()=>{const e=(0,$e.Z)(Qe.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)})),ao=(0,o.X$)((()=>{const e=(0,$e.Z)(Qe.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)})),no=(0,o.X$)((()=>{const e=(0,$e.Z)(Qe.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)}));var oo=s(1820);const ro=(0,o.X$)((0,a.c$)(((e,{chatId:t})=>{var s;const a=(0,i.Z1)(e,t),{userIds:n}=e.contactList||{},{byId:o}=e.users,{byId:r}=e.chats,{currentUserId:c,newChatMembersProgress:l,connectionState:u}=e,m=a&&(0,d.eA)(a),{query:g,fetchingStatus:f,globalUserIds:p,localUserIds:I}=e.userSearch;return{isChannel:m,members:null==a||null===(s=a.fullInfo)||void 0===s?void 0:s.members,currentUserId:c,usersById:o,chatsById:r,localContactIds:n,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:a,currentUserId:n,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 C=(0,be.Z)(),[Z,P]=(0,o.eJ)([]),w=(0,Ns.Z)(Z)===Z;(0,o.d4)((()=>{v&&"connectionStateReady"===t&&y()}),[t,v,y]),(0,ve.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!==n)),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,A.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,n,r,b,e]),E=(0,o.I4)((()=>{Z.length&&(p({query:""}),a(Z))}),[Z,p,a]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(oo.Z,{itemIds:S,selectedIds:Z,filterValue:u,filterPlaceholder:C("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:P,onFilterChange:M,noScrollRestore:w}),o.ZP.createElement(zn.Z,{isShown:Boolean(Z.length),disabled:l,ariaLabel:C("lng_channel_add_users"),onClick:E},l?o.ZP.createElement(Le.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),io=Object.keys(h.qt).length/2,co=Object.keys(h.u1).length/2;function lo(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const uo=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},a=(0,i.g4)(e);return{contentKey:(0,i.Wq)(e),chatId:t,threadId:s,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(t&&a),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:a,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}=ct(),[C,Z]=(0,o.eJ)(h.vi.Profile),[P,w]=(0,o.eJ)(h.u1.Initial),[b,M]=(0,o.eJ)(),[S,E]=(0,o.eJ)(),k=C!==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,L=e===h.qt.GifSearch,A=e===h.qt.PollResults,O=e===h.qt.AddingMembers,F=y<=n._m,[U,D]=(0,o.eJ)(!R),Q=null!==(v=(0,gt.Z)(e,!0,!r))&&void 0!==v?v:-1,$=(0,o.I4)(((t=!0)=>{switch(e){case h.qt.AddingMembers:p(h.WB.Closed);break;case h.qt.ChatInfo:if(k&&t){Z(h.vi.Profile);break}i(void 0,!0);break;case h.qt.UserInfo:if(k&&t){Z(h.vi.Profile);break}d({id:void 0},!0);break;case h.qt.Management:switch(P){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:lo(),l();break;case h.qt.StickerSearch:lo(),u({query:void 0});break;case h.qt.GifSearch:lo(),m({query:void 0});break;case h.qt.PollResults:g()}}),[e,k,i,d,g,p,P,c,l,u,m]),q=(0,o.I4)(((e,t)=>{M(e),E(t)}),[]),H=(0,o.I4)((e=>{f({chatId:t,memberIds:e})}),[f,t]);function G(e){if(-1!==Q)switch(Q){case h.qt.AddingMembers:return o.ZP.createElement(ro,{chatId:t,onNextStep:H,isActive:R&&e,onClose:$});case h.qt.ChatInfo:case h.qt.UserInfo:return o.ZP.createElement(Jn,{key:a||t,chatId:t,userId:a,profileState:C,onProfileStateChange:Z});case h.qt.Search:return o.ZP.createElement(eo,{chatId:t,threadId:s,onClose:$,isActive:R&&e});case h.qt.Management:return o.ZP.createElement(to,{chatId:t,currentScreen:P,isPromotedByCurrentUser:S,selectedChatMemberId:b,onScreenSelect:w,onChatMemberSelect:q,isActive:R&&e,onClose:$});case h.qt.StickerSearch:return o.ZP.createElement(so,{onClose:$,isActive:R&&e});case h.qt.GifSearch:return o.ZP.createElement(ao,{onClose:$,isActive:R&&e});case h.qt.PollResults:return o.ZP.createElement(no,{onClose:$,isActive:R&&e})}}return(0,o.d4)((()=>R?(0,ye.Z)($):void 0),[R,$]),(0,o.d4)((()=>{setTimeout((()=>{D(!R)}),300)}),[R]),(0,o.d4)((()=>{R&&F&&$()}),[F]),(0,jt.Z)((([s,a])=>{(s===h.qt.ChatInfo&&e===h.qt.UserInfo||s===h.qt.UserInfo&&e===h.qt.ChatInfo||a!==t)&&(Z(h.vi.Profile),w(h.u1.Initial))}),[e,t]),(0,ve.ZP)(r&&(e===h.qt.ChatInfo||e===h.qt.UserInfo||e===h.qt.Management||e===h.qt.AddingMembers),(()=>$(!1)),i),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:r?void 0:"is-hidden"},F&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:$}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(Ln,{chatId:t,isColumnOpen:R,isProfile:T,isSearch:N,isManagement:B,isStickerSearch:x,isGifSearch:L,isPollResults:A,isAddingChatMembers:O,profileState:C,managementScreen:P,onClose:$,shouldSkipAnimation:U||I}),o.ZP.createElement(Pe.Z,{name:U||I?"none":"zoom-fade",renderCount:io+co,activeKey:B?io+P:Q,shouldCleanup:!0,cleanupExceptionKey:h.qt.ChatInfo},G)))}))),ho=(0,o.X$)((({isOpen:e})=>{const t=(0,$e.Z)(Qe.gl.Extra,"MediaViewer",!e);return t?o.ZP.createElement(t,null):void 0}));function mo(e,t){const s=document.createElement("a");s.href=e,s.download=t;try{s.click()}catch(e){console.error(e)}}const go=new Set,fo=(0,o.X$)((0,a.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})),((e,t)=>(0,g.ei)(t,["cancelMessageMediaDownload"])))((({activeDownloads:e,messages:t,cancelMessageMediaDownload:s})=>{(0,o.d4)((()=>{Object.entries(e).forEach((([e,a])=>{a.map((s=>t[Number(e)].byId[s])).forEach((e=>{const t=(0,d.Ti)(e,"download");if(t){if(!go.has(t)){const a=Tt.UV(t);if(a)return go.delete(t),mo(a,(0,d.w6)(e)),void s({message:e});Tt.he(t,u.IU.BlobUrl,!0).then((a=>{go.delete(t),a&&mo(a,(0,d.w6)(e)),s({message:e})})),go.add(t)}}else s({message:e})}))}))}),[s,t,e])}))),po=(0,o.X$)((({isOpen:e})=>{const t=(0,$e.Z)(Qe.gl.Extra,"Notifications",!e);return t?o.ZP.createElement(t,null):void 0})),Io=(0,o.X$)((({isOpen:e})=>{const t=(0,$e.Z)(Qe.gl.Extra,"Dialogs",!e);return t?o.ZP.createElement(t,null):void 0})),vo=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"ForwardPicker",!t);return s?o.ZP.createElement(s,e):void 0})),yo=(0,o.X$)((e=>{const{url:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0})),Co=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,$e.Z)(Qe.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0}));let Zo,Po=!1;function wo(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 bo(e){document.title!==e&&(document.title=e)}const Mo=(0,o.X$)((0,a.c$)((e=>{const{settings:{byKey:{animationLevel:t,language:s,wasTimeFormatSetManually:a}}}=e,{chatId:n,messageId:o,origin:r}=e.audioPlayer,c=n&&o?(0,i.hj)(e,n,o):void 0;return{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:c,audioOrigin:r,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,i.UW)(e),animationLevel:t,language:s,wasTimeFormatSetManually:a}}),((e,t)=>(0,g.ei)(t,["loadAnimatedEmojis","loadNotificationSettings","loadNotificationExceptions","updateIsOnline","loadTopInlineBots","loadEmojiKeywords","openStickerSetShortName","loadCountryList","ensureTimeFormat","checkVersionNotification"])))((({lastSyncTime:e,isLeftColumnShown:t,isRightColumnShown:s,isMediaViewerOpen:r,isForwardModalOpen:c,hasNotifications:d,hasDialogs:l,audioMessage:u,audioOrigin:h,safeLinkModalUrl:g,isHistoryCalendarOpen:f,shouldSkipHistoryAnimations:p,openedStickerSetShortName:I,isServiceChatReady:v,animationLevel:y,language:C,wasTimeFormatSetManually:Z,loadAnimatedEmojis:b,loadNotificationSettings:M,loadNotificationExceptions:S,updateIsOnline:E,loadTopInlineBots:k,loadEmojiKeywords:R,loadCountryList:T,ensureTimeFormat:N,openStickerSetShortName:B,checkVersionNotification:x})=>{n.eM&&!Po&&(Po=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{e&&(E(!0),b(),M(),S(),k(),R({language:n.pR}),C!==n.pR&&R({language:C}),T({langCode:C}))}),[e,b,S,M,E,k,R,T,C]),(0,o.d4)((()=>{e&&v&&x()}),[e,v,x]),(0,o.d4)((()=>{e&&!Z&&N()}),[e,Z,N]),(0,o.d4)((()=>{e&&ve.Oy.startsWith("#?tgaddr=")&&w(decodeURIComponent(ve.Oy.substr("#?tgaddr=".length)))}),[e]);const{transitionClassNames:L}=(0,ue.Z)(!t,void 0,!0,void 0,p),{transitionClassNames:A}=(0,ue.Z)(s,void 0,!0,void 0,p),O=(0,de.Z)(L.replace(/([\w-]+)/g,"middle-column-$1"),A.replace(/([\w-]+)/g,"right-column-$1"),p&&"history-animation-disabled");(0,ge.Z)((([e])=>{if(void 0===e||0===y)return;const t=(0,ce.YW)();(0,le.L)(document.getElementById("MiddleColumn"),t)}),[t]),(0,ge.Z)((([e])=>{if(void 0===e||0===y)return;(0,P.T2)((()=>{document.body.classList.add("animating-right-column")}));const t=(0,ce.YW)();(0,le.L)(document.getElementById("RightColumn"),(()=>{t(),(0,P.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[s]);const F=(0,o.I4)((()=>{E(!1);const e=(0,i.A1)((0,a.Rd)());let t=0;clearInterval(Zo),Zo=window.setInterval((()=>{if(document.title.includes(n.ou))wo(!1);else{if(t%2==0){const t=(0,i.A1)((0,a.Rd)())-e;t>0&&(bo(`${t} notification${t>1?"s":""}`),wo(!0))}else bo(n.Ti),wo(!1);t++}}),1e3)}),[E]),U=(0,o.I4)((()=>{E(!0),clearInterval(Zo),Zo=void 0,document.title.includes(n.ou)||bo(n.Ti),wo(!1)}),[E]),D=(0,o.I4)((()=>{B({stickerSetShortName:void 0})}),[B]);function Q(e){e.preventDefault(),e.stopPropagation()}return(0,he.Z)(F,U),me(F),function(e=!1){(0,o.d4)((()=>{if(m.$b){if(!e)return null==fe||fe.setAttribute("content",pe),m.cj&&!m.fl&&document.addEventListener("gesturestart",Ie),()=>{null==fe||fe.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),m.cj&&!m.fl&&document.removeEventListener("gesturestart",Ie)};null==fe||fe.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover")}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:O,onDrop:Q,onDragOver:Q},o.ZP.createElement(at,null),o.ZP.createElement(Nn,null),o.ZP.createElement(uo,null),o.ZP.createElement(ho,{isOpen:r}),o.ZP.createElement(vo,{isOpen:c}),o.ZP.createElement(po,{isOpen:d}),o.ZP.createElement(Io,{isOpen:l}),u&&o.ZP.createElement(Ht,{key:u.id,message:u,origin:h,noUi:!0}),o.ZP.createElement(yo,{url:g}),o.ZP.createElement(Co,{isOpen:f}),o.ZP.createElement(Ms.Z,{isOpen:Boolean(I),onClose:D,stickerSetShortName:I}),o.ZP.createElement(fo,null))})));n.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,a.Rd)().connectionState||(0,a.uC)().initApi()},4524:(e,t,s)=>{e.exports=s.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg"}}]);
|
||
//# sourceMappingURL=325.54c42e796aa36eb09c60.js.map
|