mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-12 00:59:52 +01:00
2 lines
234 KiB
JavaScript
2 lines
234 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[214],{1214:(e,t,s)=>{s.r(t),s.d(t,{Main:()=>Zo});var n=s(5116),a=s(3716),o=s(4050),r=(s(7895),s(1752)),i=s(8085),c=s(735),d=s(2858);function l(e){const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};return t&&s?(e=(0,r.qr)(e,t,s,!1),e=(0,r.Pb)(e,t,s,void 0)):e}(0,n.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(t&&s)return(0,r.qr)(e,t,s,!0)})),(0,n.Q6)("closeLocalTextSearch",l),(0,n.Q6)("setLocalTextSearchQuery",((e,t,s)=>{const{chatId:n,threadId:a}=(0,i.Bt)(e)||{};if(!n||!a)return;const{query:o}=s,l=(0,d.uw)(n,a),{query:u}=e.localTextSearch.byChatThreadKey[l]||{};return o!==u&&(e=(0,r.Pb)(e,n,a,c.D)),(0,r.qr)(e,n,a,!0,o)})),(0,n.Q6)("setLocalMediaSearchType",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};if(!n)return;const{mediaType:a}=s;return(0,r.z5)(e,n,a)})),(0,n.Q6)("openChat",((e,t,s)=>{const{id:a,threadId:o=-1,type:c="thread",shouldReplaceHistory:d=!1}=s,u=(0,i.Bt)(e);return u&&u.chatId===a&&u.threadId===o&&u.type===c||(e=(0,r.pf)(e,a,o,"replyStack",[]),e=l(e=(0,r.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...a!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,n.R3)(e)),(0,r.Wy)(e,a,o,c,d)})),(0,n.Q6)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,n.Q6)("openChatWithInfo",((e,t,s)=>{(0,n.R3)({...e,isChatInfoShown:!0}),t.openChat(s)})),(0,n.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,n.Q6)("setNewChatMembersDialogState",((e,t,s)=>({...e,newChatMembersProgress:s}))),(0,n.Q6)("openNextChat",((e,t,s)=>{const{targetIndexDelta:n,orderedIds:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return void t.openChat({id:a[0]});const r=a.indexOf(o);if(-1===r)return;const c=a[r+n];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=s(6137),h=s(1713),m=s(7361),g=s(782),f=s(2267),p=s(3099);const I=a.ck+a.fK;let v;(0,n.Q6)("setScrollOffset",((e,t,s)=>{const{chatId:n,threadId:a,scrollOffset:o}=s;return(0,r.pf)(e,n,a,"scrollOffset",o)})),(0,n.Q6)("setReplyingToId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c}=a;return(0,r.pf)(e,o,c,"replyingToId",n)})),(0,n.Q6)("setEditingId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c,type:d}=a,l="scheduled"===d?"editingScheduledId":"editingId";return(0,r.pf)(e,o,c,l,n)})),(0,n.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(!t||!s)return;const n=(0,i.Zw)(e,t),a=(0,i.Cb)(e,t,s);if(!n||!a)return;const o=(0,g.dF)(a,(t=>Boolean(n[t]&&(0,i._k)(e,n[t],s).canEdit)));return o?(0,r.pf)(e,t,s,"editingId",o):void 0})),(0,n.Q6)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:n}=s,{chatId:a,threadId:o}=(0,i.Bt)(e)||{};if(!a||!o)return;const r=(0,i.Zw)(e,a),c=(0,i.Cb)(e,a,o);if(!r||!c)return;const d=(0,i.Yy)(e,a,o);let l;if((0,i.b9)(e,a,o)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+n;l=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){var h;const t=(0,i.Z1)(e,a);l=null==t||null===(h=t.lastMessage)||void 0===h?void 0:h.id}else{const t=(0,i.tZ)(e,a,o);l=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:l}),t.focusMessage({chatId:a,threadId:o,messageId:l})})),(0,n.Q6)("openMediaViewer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c}=s;return{...e,mediaViewer:{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c},forwardMessages:{}}})),(0,n.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,n.Q6)("openAudioPlayer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,origin:r}=s;return{...e,audioPlayer:{chatId:n,threadId:a,messageId:o,origin:r}}})),(0,n.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{}}))),(0,n.Q6)("openPollResults",((e,t,s)=>{const{chatId:a,messageId:o}=s;(0,i.Jf)(e)?a===e.pollResults.chatId&&o===e.pollResults.messageId||(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,n.Rd)();(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}})}),450)})),(0,n.Q6)("closePollResults",(e=>{(0,n.R3)({...e,pollResults:{}})})),(0,n.Q6)("focusLastMessage",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:n,threadId:a}=s;let o;if(a===u._f){var r;const t=(0,i.Z1)(e,n);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,i.tZ)(e,n,a);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:n,threadId:a,messageId:o,noHighlight:!0})})),(0,n.Q6)("focusNextReply",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:a,threadId:o}=s,c=(0,i.p9)(e,a,o);if(c&&0!==c.length){const s=c.pop();e=(0,r.pf)(e,a,o,"replyStack",[...c]),(0,n.R3)(e),t.focusMessage({chatId:a,threadId:o,messageId:s})}else t.focusLastMessage()})),(0,n.Q6)("focusMessage",((e,t,s)=>{const{chatId:a,threadId:o=u._f,messageListType:c="thread",noHighlight:d,groupedId:l,groupedChatId:m,replyMessageId:g,isResizingContainer: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||a!==y.chatId||o!==y.threadId||c!==y.type;if(v&&(clearTimeout(v),v=void 0),v=window.setTimeout((()=>{let e=(0,n.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,n.R3)(e)}),d?I:1500),e=(0,r.cq)(e,a,p,d,f),e=(0,r.wV)(e,void 0),g){const t=(0,i.p9)(e,a,o)||[];e=(0,r.pf)(e,a,o,"replyStack",[...t,g])}C&&(e=(0,r.wV)(e,h.fo.Static));const Z=(0,i.Cb)(e,a,o);if(Z&&Z.includes(p))return(0,n.R3)(e),void t.openChat({id:a,threadId:o});if(C&&(e=(0,r.pf)(e,a,o,"viewportIds",void 0)),e=(0,r.pf)(e,a,o,"outlyingIds",void 0),Z&&!C){const t=p>Z[0]?h.fo.Down:h.fo.Up;e=(0,r.wV)(e,t)}(0,n.R3)(e),t.openChat({id:a,threadId:o}),t.loadViewportMessages()})),(0,n.Q6)("openForwardMenu",((e,t,s)=>{const{fromChatId:n,messageIds:a,groupedId:o}=s;let r;return o&&(r=(0,i.xH)(e,n,o)),{...e,forwardMessages:{fromChatId:n,messageIds:r||a,isModalShown:!0}}})),(0,n.Q6)("exitForwardMode",(e=>{(0,n.R3)({...e,forwardMessages:{}})})),(0,n.Q6)("setForwardChatId",((e,t,s)=>{const{id:a}=s;(0,n.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:a,isModalShown:!1}}),t.openChat({id:a}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,n.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages;t.openForwardMenu({fromChatId:s,messageIds:n})})),(0,n.Q6)("cancelMessageMediaDownload",((e,t,s)=>{const{message:a}=s,o=e.activeDownloads.byChatId[a.chatId];o&&o.length&&(0,n.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:o.filter((e=>e!==a.id))}}})})),(0,n.Q6)("downloadMessageMedia",((e,t,s)=>{const{message:a}=s;a&&(0,n.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:[...e.activeDownloads.byChatId[a.chatId]||[],a.id]}}})})),(0,n.Q6)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages,{threadId:a}=(0,i.Bt)(e)||{},o=(0,i.Zw)(e,s);o&&a&&n.map((e=>o[e])).filter((t=>(0,i._k)(e,t,a).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,n.Q6)("enterMessageSelectMode",((e,t,s)=>{const{messageId:n}=s||{},a=(0,i.jr)(e);return a?(0,r.M6)(e,a.id,n):e})),(0,n.Q6)("toggleMessageSelection",((e,t,s)=>{const{messageId:a,groupedId:o,childMessageIds:c,withShift:d}=s,l=(0,i.Bt)(e);if(!l)return;const{chatId:u,threadId:h,type:g}=l;e=(0,r.Ob)(e,u,h,g,a,o,c,d),(0,n.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${m.$b?"long tap":"right click"} on a message.`}))})),(0,n.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,n.Q6)("exitMessageSelectMode",r.i9),(0,n.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,n.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,n.Q6)("checkVersionNotification",((e,t)=>{const s=a.Ji.split(".").slice(0,2).join("."),{serviceNotifications:n}=e;if(n.find((({version:e})=>e===s)))return;const o={chatId:a.aw,date:(0,f.b)(e.serverTimeOffset),content:{text:(0,p.Z)("**Telegram Web Z was updated to version 1.18**\n\n👏 **Harder**\n· Support downloading for all kinds of media (via context menu).\n· Support downloading multiple selected messages.\n· Group Permissions: Allow to remove/ban users.\n· Privacy and Security: Allow to block users.\n· Add fancy changelogs.\n\n🤩 **Better**\n· Message: Make circle videos and gifs larger.\n· Sticker and GIF Search: Auto-focus when opening.\n\n🚀 **Faster**\n· Optimize animations.\n\n💪 **Stronger**\n· Notifications: Fix missing sound.\n· Left Column: Fix default width on small screens.\n· Message: Prevent showing self-destructing videos.\n· Media Viewer: Fix pinch zoom in iOS PWA (again).\n· Audio: Fix download button in RTL.\n· Various layout fixes.\n")},isOutgoing:!1};t.createServiceNotification({message:o,version:s})})),(0,n.Q6)("createServiceNotification",((e,t,s)=>{var o;const{message:r,version:c}=s,{serviceNotifications:d}=e,l=(0,i.Z1)(e,a.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)/1e4,m=Math.floor(u)+h;r.id=m;const g={id:m,message:r,version:c};(0,n.R3)({...e,serviceNotifications:[...d,g]}),t.apiUpdate({"@type":"newMessage",id:r.id,chatId:r.chatId,message:r})})),(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{query:n}=s,{chatId:a}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...n?{fetchingStatus:{chats:!a,messages:!0}}:{fetchingStatus:void 0},query:n})})),(0,n.Q6)("addRecentlyFoundChatId",((e,t,s)=>{const{id:n}=s,{recentlyFoundChatIds:a}=e.globalSearch;if(!a)return(0,r.No)(e,{recentlyFoundChatIds:[n]});const o=a.filter((e=>e!==n));return o.unshift(n),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,n.Q6)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,n.Q6)("setGlobalSearchContent",((e,t,s)=>{const{content:n}=s;return(0,r.Og)(e,n)})),(0,n.Q6)("setGlobalSearchChatId",((e,t,s)=>{const{id:n}=s;return(0,r.No)(e,{chatId:n,query:void 0,resultsByType:void 0})})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,stickers:{...e.stickers,search:{query:n,resultIds:void 0}}}})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,gifs:{...e.gifs,search:{query:n,offsetId:void 0,results:void 0}}}})),(0,n.Q6)("openUserInfo",((e,t,s)=>{const{id:n}=s;t.openChat({id:n})})),(0,n.Q6)("openChat",(e=>(0,r.x1)(e,void 0))),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:n}=s;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(n),query:n})})),s(3781);var y=s(1947),C=s(6926);(0,n.Q6)("toggleChatInfo",(e=>({...e,isChatInfoShown:!e.isChatInfoShown}))),(0,n.Q6)("setLeftColumnWidth",((e,t,s)=>({...e,leftColumnWidth:s}))),(0,n.Q6)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,n.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,n.Q6)("closeManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,n.Q6)("openChat",(e=>{if(m.wB||m.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,n.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,n.Q6)("addRecentEmoji",((e,t,s)=>{const{emoji:n}=s,{recentEmojis:a}=e;if(!a)return{...e,recentEmojis:[n]};const o=a.filter((e=>e!==n));return o.unshift(n),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,n.Q6)("addRecentSticker",((e,t,s)=>{const{sticker:n}=s,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:0,stickers:[n]}}};const o=a.stickers.filter((e=>e.id!==n.id));return o.unshift(n),{...e,stickers:{...e.stickers,recent:{...a,stickers:o}}}})),(0,n.Q6)("showNotification",((e,t,s)=>{const n=s;n.localId=(0,C.Z)({});const a=[...e.notifications],o=a.findIndex((e=>e.message===n.message));return-1!==o&&a.splice(o,1),a.push(n),{...e,notifications:a}})),(0,n.Q6)("dismissNotification",((e,t,s)=>{const n=e.notifications.filter((({localId:e})=>e!==s.localId));return{...e,notifications:n}})),(0,n.Q6)("showDialog",((e,t,s)=>{const{data:n}=s;if("message"in n&&n.hasErrorKey&&!(0,y.ZP)(n))return e;const a=[...e.dialogs];if("message"in n){const e=a.findIndex((e=>e.message===n.message));-1!==e&&a.splice(e,1)}return a.push(n),{...e,dialogs:a}})),(0,n.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,n.Q6)("toggleSafeLinkModal",((e,t,s)=>{const{url:n}=s;return{...e,safeLinkModalUrl:n}})),(0,n.Q6)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:n}=s;return{...e,historyCalendarSelectedAt:n}})),(0,n.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,n.Q6)("openPaymentModal",((e,t,s)=>{const{chatId:n,messageId:a}=s;return{...e,payment:{...e.payment,chatId:n,messageId:a,isPaymentModalOpen:!0}}})),(0,n.Q6)("closePaymentModal",(e=>{const t=(0,r.bp)(e);return(0,r.WY)(t)})),(0,n.Q6)("addPaymentError",((e,t,s)=>{const{error:n}=s;return{...e,payment:{...e.payment,error:n}}})),s(1363);var Z=s(1226),w=s(9118);const P=e=>{const{protocol:t,searchParams:s,pathname:a}=new URL(e);if("tg:"!==t)return;const{openChatByInvite:o,openChatByUsername:r,openStickerSetShortName:i,focusMessage:c}=(0,n.uC)(),d=a.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,w.P2)((e=>e()),300,!0),M=(0,w.P2)((e=>e()),3e3,!0),S=(0,w.Ds)((e=>e()),500,!1,!0);async function E(e,t,s){var o;let c=(0,n.Rd)();const d=await(0,Z.t9)("fetchChats",{limit:a.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,n.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).map(Number).forEach((e=>{c=(0,r.pf)(c,e,u._f,"draft",d.draftsById[e])})),Object.keys(d.replyingToById).map(Number).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,n.R3)(c)}async function k(e){const t=await(0,Z.t9)("fetchFullChat",e);if(!t)return;const{users:s,fullInfo:a}=t;let o=(0,n.Rd)();s&&(o=(0,r.Sh)(o,(0,g.ee)(s,"id"))),o=(0,r.a4)(o,e.id,{fullInfo:a}),(0,n.R3)(o)}async function R(e){const t=(0,n.Rd)(),s=(0,i.DI)(t,e);if(s&&!s.isMin)return s;const a=await(0,Z.t9)("getChatByUsername",e);return a?((0,n.R3)((0,r.a4)((0,n.Rd)(),a.id,a)),a):void 0}(0,n.Q6)("preloadTopChatMessages",((e,t)=>{(async()=>{const s=[];for(let o=0;o<a.ul;o++){await(0,w.wO)(100);const{byId:a,listIds:{active:o},orderedPinnedIds:{active:r}}=(0,n.Rd)().chats;if(!o)return;const{chatId:c}=(0,i.Bt)(e)||{},{pinnedChats:l,otherChats:h}=(0,d.O)(a,o,r),m=[...l,...h].find((({id:e})=>e!==c&&!s.includes(e)));if(!m)return;s.push(m.id),t.loadViewportMessages({chatId:m.id,threadId:u._f})}})()})),(0,n.Q6)("openChat",((e,t,s)=>{const{id:n,threadId:a}=s,{currentUserId:o}=e,r=(0,i.Z1)(e,n);if(null!=r&&r.hasUnreadMark&&t.toggleChatUnread({id:n}),r&&r.lastMessage&&r.lastMessage.threadInfo&&t.requestThreadInfoUpdate({chatId:r.lastMessage.threadInfo.chatId,threadId:r.lastMessage.threadInfo.threadId}),r)(0,d.Hp)(r)&&!r.isMin&&t.requestChatUpdate({chatId:n});else if(n===o)(0,Z.t9)("fetchChat",{type:"self"});else{const t=(0,i.dy)(e,n);t&&(0,Z.t9)("fetchChat",{type:"user",user:t})}a!==u._f&&((0,i.qS)(e,n,a)||t.requestThreadInfoUpdate({chatId:n,threadId:a}))})),(0,n.Q6)("openLinkedChat",((e,t,s)=>{const{id:n}=s,a=(0,i.Z1)(e,n);a&&(async()=>{var e;const s=await(0,Z.t9)("fetchFullChat",a);null!=s&&null!==(e=s.fullInfo)&&void 0!==e&&e.linkedChatId&&t.openChat({id:s.fullInfo.linkedChatId})})()})),(0,n.Q6)("focusMessageInComments",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o}=s,r=(0,i.Z1)(e,n);r&&(async()=>{await(0,Z.t9)("requestThreadInfoUpdate",{chat:r,threadId:a})&&t.focusMessage({chatId:n,threadId:a,messageId:o})})()})),(0,n.Q6)("openSupportChat",((e,t)=>{const s=(0,i.P_)(e);t.openChat({id:s?s.id:-1}),s||(async()=>{const e=await(0,Z.t9)("fetchChat",{type:"support"});e&&t.openChat({id:e.chatId})})()})),(0,n.Q6)("openTipsChat",((e,t,s)=>{const{langCode:n}=s,o="pt-br"===n?"BR":a.Db.includes(n)?n.toUpperCase():"";t.openChatByUsername({username:`${a.vi}${o}`})})),(0,n.Q6)("loadMoreChats",((e,t,s)=>{const{listType:n="active"}=s,a=e.chats.listIds[n];if(e.chats.isFullyLoaded[n])return;const o=a?a.map((t=>e.chats.byId[t])).filter((t=>Boolean(null==t?void 0:t.lastMessage)&&!(0,i.ep)(e,t.id))).sort(((e,t)=>e.lastMessage.date-t.lastMessage.date))[0]:void 0;b(o?()=>E(n,o.id,o.lastMessage.date):()=>E(n))})),(0,n.Q6)("preloadArchivedChats",(()=>{(async()=>{for(;!(0,n.Rd)().chats.isFullyLoaded.archived;){const e=(0,n.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,w.wO)(300)}})()})),(0,n.Q6)("loadFullChat",((e,t,s)=>{const{chatId:n,force:a}=s,o=(0,i.Z1)(e,n);o&&(a?k(o):S((()=>k(o))))})),(0,n.Q6)("loadTopChats",(()=>{M((()=>E("active")))})),(0,n.Q6)("requestChatUpdate",((e,t,s)=>{var n;const{serverTimeOffset:o}=e,{chatId:r}=s,c=(0,i.Z1)(e,r);c&&(0,Z.t9)("requestChatUpdate",{chat:c,serverTimeOffset:o,...r===a.aw&&{lastLocalMessage:null===(n=(0,i.VF)(e))||void 0===n?void 0:n.message}})})),(0,n.Q6)("updateChatMutedState",((e,t,s)=>{const{serverTimeOffset:a}=e,{chatId:o,isMuted:c}=s,d=(0,i.Z1)(e,o);d&&((0,n.R3)((0,r.a4)(e,o,{isMuted:c})),(0,Z.t9)("updateChatMutedState",{chat:d,isMuted:c,serverTimeOffset:a}))})),(0,n.Q6)("createChannel",((e,t,s)=>{const{title:a,about:o,photo:c,memberIds:d}=s;!async function(e,t,s,a){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const o=await(0,Z.t9)("createChannel",{title:e,about:s,users:t});if(!o)return;const{id:i,accessHash:c}=o;let d=(0,n.Rd)();d=(0,r.a4)(d,i,o),d={...d,chatCreation:{...d.chatCreation,progress:o?h.Nh.Complete:h.Nh.Error}},(0,n.R3)(d),(0,n.uC)().openChat({id:i}),i&&c&&a&&await(0,Z.t9)("editChatPhoto",{chatId:i,accessHash:c,photo:a})}(a,d.map((t=>(0,i.dy)(e,t))).filter(Boolean),o,c)})),(0,n.Q6)("joinChannel",((e,t,s)=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;const{id:o,accessHash:r}=a;o&&r&&(0,Z.t9)("joinChannel",{channelId:o,accessHash:r})})),(0,n.Q6)("deleteChatUser",((e,t,s)=>{(async()=>{const{chatId:n,userId:a}=s,o=(0,i.Z1)(e,n),r=(0,i.dy)(e,a);if(!o||!r)return;await(0,Z.t9)("deleteChatUser",{chat:o,user:r});const c=(0,i.Bt)(e);c&&c.chatId===n&&e.currentUserId===a&&t.openChat({id:void 0})})()})),(0,n.Q6)("deleteChat",((e,t,s)=>{(async()=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;await(0,Z.t9)("deleteChat",{chatId:a.id});const o=(0,i.Bt)(e);o&&o.chatId===n&&t.openChat({id:void 0})})()})),(0,n.Q6)("leaveChannel",((e,t,s)=>{(async()=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;const{id:o,accessHash:r}=a;o&&r&&await(0,Z.t9)("leaveChannel",{channelId:o,accessHash:r});const c=(0,i.Bt)(e);c&&c.chatId===n&&t.openChat({id:void 0})})()})),(0,n.Q6)("deleteChannel",((e,t,s)=>{(async()=>{const{chatId:n}=s,a=(0,i.Z1)(e,n);if(!a)return;const{id:o,accessHash:r}=a;o&&r&&await(0,Z.t9)("deleteChannel",{channelId:o,accessHash:r});const c=(0,i.Bt)(e);c&&c.chatId===n&&t.openChat({id:void 0})})()})),(0,n.Q6)("createGroupChat",((e,t,s)=>{const{title:a,memberIds:o,photo:c}=s;!async function(e,t,s){(0,n.R3)({...(0,n.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const a=await(0,Z.t9)("createGroupChat",{title:e,users:t});if(!a)return;const{id:o}=a;let i=(0,n.Rd)();i=(0,r.a4)(i,o,a),i={...i,chatCreation:{...i.chatCreation,progress:a?h.Nh.Complete:h.Nh.Error}},(0,n.R3)(i),(0,n.uC)().openChat({id:o}),o&&s&&await(0,Z.t9)("editChatPhoto",{chatId:o,photo:s})}(a,o.map((t=>(0,i.dy)(e,t))).filter(Boolean),c)})),(0,n.Q6)("toggleChatPinned",((e,t,s)=>{const{id:n,folderId:o}=s,r=(0,i.Z1)(e,n);if(r)if(o){const t=(0,i.Mw)(e,o);if(t){const s=!(0,i.ep)(e,n,o),{pinnedChatIds:a,includedChatIds:r}=t,c=s?[n,...a||[]]:(a||[]).filter((e=>e!==n)),d=[n,...r];(0,Z.t9)("editChatFolder",{id:o,folderUpdate:{...t,pinnedChatIds:c,includedChatIds:d}})}}else{const t=(0,i.Ek)(e,n),s=(0,i.ep)(e,n,"archived"===t?a.WS:void 0);(0,Z.t9)("toggleChatPinned",{chat:r,shouldBePinned:!s})}})),(0,n.Q6)("toggleChatArchived",((e,t,s)=>{const{id:n}=s,o=(0,i.Z1)(e,n);o&&(0,Z.t9)("toggleChatArchived",{chat:o,folderId:(0,d.pE)(o)?0:a.WS})})),(0,n.Q6)("loadChatFolders",(()=>{!async function(){const e=await(0,Z.t9)("fetchChatFolders");if(e){const t=(0,n.Rd)();(0,n.R3)({...t,chatFolders:{...t.chatFolders,...e}})}}()})),(0,n.Q6)("loadRecommendedChatFolders",(()=>{!async function(){const e=await(0,Z.t9)("fetchRecommendedChatFolders");if(e){const t=(0,n.Rd)();(0,n.R3)({...t,chatFolders:{...t.chatFolders,recommended:e}})}}()})),(0,n.Q6)("editChatFolders",((e,t,s)=>{const{chatId:n,idsToRemove:a,idsToAdd:o}=s;a.forEach((async t=>{const s=(0,i.Mw)(e,t);var a;s&&await(0,Z.t9)("editChatFolder",{id:t,folderUpdate:{...s,pinnedChatIds:null===(a=s.pinnedChatIds)||void 0===a?void 0:a.filter((e=>e!==n)),includedChatIds:s.includedChatIds.filter((e=>e!==n))}})})),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(n)}})}))})),(0,n.Q6)("editChatFolder",((e,t,s)=>{const{id:n,folderUpdate:a}=s,o=(0,i.Mw)(e,n);o&&(0,Z.t9)("editChatFolder",{id:n,folderUpdate:{id:n,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...a}})})),(0,n.Q6)("addChatFolder",((e,t,s)=>{const{folder:o}=s,{orderedIds:r}=e.chatFolders;!async function(e,t){const{id:s,description:a,...o}=e;if(await(0,Z.t9)("editChatFolder",{id:t+1,folderUpdate:{id:t+1,...o}}),!a)return;const r=(0,n.Rd)(),{recommended:i}=r.chatFolders;i&&(0,n.R3)({...r,chatFolders:{...r.chatFolders,recommended:i.filter((({id:e})=>e!==s))}})}(o,null!=r&&r.length?Math.max.apply(Math.max,r):a.WS)})),(0,n.Q6)("deleteChatFolder",((e,t,s)=>{const{id:n}=s;(0,i.Mw)(e,n)&&async function(e){await(0,Z.t9)("deleteChatFolder",e)}(n)})),(0,n.Q6)("toggleChatUnread",((e,t,s)=>{const{id:n}=s,{serverTimeOffset:a}=e,o=(0,i.Z1)(e,n);o&&(o.unreadCount?(0,Z.t9)("markMessageListRead",{serverTimeOffset:a,chat:o,threadId:u._f}):(0,Z.t9)("toggleDialogUnread",{chat:o,hasUnreadMark:!o.hasUnreadMark}))})),(0,n.Q6)("openChatByInvite",((e,t,s)=>{const{hash:n}=s;(async()=>{const e=await(0,Z.t9)("openChatByInvite",n);e&&t.openChat({id:e.chatId})})()})),(0,n.Q6)("openTelegramLink",((e,t,s)=>{const{url:n}=s,o=a.iL.exec(n);if(o)t.openStickerSetShortName({stickerSetShortName:o[1]});else if(n.match(a.g$))P(n.match(a.g$)[0]);else{let e=a.Lj.exec(n);if(e){const s=e[1];t.openChatByInvite({hash:s})}else{e=a.FS.exec(n);const s=e[1],o=e[2]?Number(e[2]):void 0,r=e[3]?Number(e[3]):void 0,i="comment"===e[4]&&e[5]?Number(e[5]):void 0;"c"===s&&o&&r?t.focusMessage({chatId:-o,messageId:r}):t.openChatByUsername({username:s,messageId:r||o,commentId:i})}}})),(0,n.Q6)("acceptInviteConfirmation",((e,t,s)=>{const{hash:n}=s;(async()=>{const e=await(0,Z.t9)("importChatInvite",{hash:n});e&&t.openChat({id:e.id})})()})),(0,n.Q6)("openChatByUsername",((e,t,s)=>{const{username:a,messageId:o,commentId:r}=s;(async()=>{const s=(0,i.jr)(e);if(!r)return s&&s.username===a?void t.focusMessage({chatId:s.id,messageId:o}):void await async function(e,t,s){e.openChat({id:-1});const n=await R(t);if(!n)return e.openPreviousChat(),void e.showNotification({message:"User does not exist"});s?e.focusMessage({chatId:n.id,messageId:s}):e.openChat({id:n.id})}(t,a,o);const{chatId:c,type:d}=(0,i.Bt)(e)||{},l=(0,i.DI)(e,a);if(c&&l&&"thread"===d){const s=(0,i.tZ)(e,c,o);if(s&&s.chatId===c)return void t.focusMessage({chatId:s.chatId,threadId:s.threadId,messageId:r})}o&&await async function(e,t,s,a){e.openChat({id:-1});const o=await R(t);if(!o)return;const r=(0,n.Rd)(),c=(0,i.tZ)(r,o.id,s);let d;if(c)d=c.chatId;else{const e=await(0,Z.t9)("requestThreadInfoUpdate",{chat:o,threadId:s});if(!e)return;d=e.discussionChatId}d&&e.focusMessage({chatId:d,threadId:s,messageId:Number(a)})}(t,a,o,r)})()})),(0,n.Q6)("togglePreHistoryHidden",((e,t,s)=>{const{chatId:n,isEnabled:a}=s;let o=(0,i.Z1)(e,n);o&&(async()=>{if((0,d.G9)(o)){if(o=await(0,Z.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}(0,Z.t9)("togglePreHistoryHidden",{chat:o,isEnabled:a})})()})),(0,n.Q6)("updateChatDefaultBannedRights",((e,t,s)=>{const{chatId:n,bannedRights:a}=s,o=(0,i.Z1)(e,n);o&&(0,Z.t9)("updateChatDefaultBannedRights",{chat:o,bannedRights:a})})),(0,n.Q6)("updateChatMemberBannedRights",((e,t,s)=>{const{chatId:a,userId:o,bannedRights:c}=s;let l=(0,i.Z1)(e,a);const u=(0,i.dy)(e,o);l&&u&&(async()=>{if((0,d.G9)(l)){if(l=await(0,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,n.Rd)(),s=(0,i.Z1)(e,a);if(!s||!s.fullInfo)return;const{members:h,kickedMembers:m}=s.fullInfo,g=!!c.viewMessages,f=!Object.keys(c).length;(0,n.R3)((0,r.a4)(e,a,{fullInfo:{...s.fullInfo,...h&&g&&{members:h.filter((e=>e.userId!==o))},...h&&!g&&{members:h.map((e=>e.userId===o?{...e,bannedRights:c}:e))},...f&&m&&{kickedMembers:m.filter((e=>e.userId!==o))}}}))})()})),(0,n.Q6)("updateChatAdmin",((e,t,s)=>{const{chatId:a,userId:o,adminRights:c,customTitle:l}=s;let u=(0,i.Z1)(e,a);const h=(0,i.dy)(e,o);u&&h&&(async()=>{if((0,d.G9)(u)){if(u=await(0,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,n.Rd)(),s=(0,i.Z1)(e,a);if(!s||!s.fullInfo)return;const{adminMembers:m}=s.fullInfo,g=!Object.keys(c).length;(0,n.R3)((0,r.a4)(e,a,{fullInfo:{...s.fullInfo,...m&&g&&{adminMembers:m.filter((e=>e.userId!==o))},...m&&!g&&{adminMembers:m.map((e=>e.userId===o?{...e,adminRights:c,customTitle:l}:e))}}}))})()})),(0,n.Q6)("updateChat",((e,t,s)=>{const{chatId:a,title:o,about:c,photo:d}=s,l=(0,i.Z1)(e,a);l&&(async()=>{(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.InProgress)),await Promise.all([l.title!==o?(0,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:a,accessHash:l.accessHash,photo:d}):void 0]),(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.Complete))})()})),(0,n.Q6)("toggleSignatures",((e,t,s)=>{const{chatId:n,isEnabled:a}=s,o=(0,i.Z1)(e,n);o&&(0,Z.t9)("toggleSignatures",{chat:o,isEnabled:a})})),(0,n.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,n.Rd)(),t);(0,n.R3)({...s,chats:{...s.chats,forDiscussionIds:Object.keys(t).map(Number)}})})()})),(0,n.Q6)("linkDiscussionGroup",((e,t,s)=>{const{channelId:n,chatId:a}=s,o=(0,i.Z1)(e,n);let r=(0,i.Z1)(e,a);o&&r&&(async()=>{if((0,d.G9)(r)){if(r=await(0,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,n.Q6)("unlinkDiscussionGroup",((e,t,s)=>{var n;const{channelId:a}=s,o=(0,i.Z1)(e,a);if(!o)return;let r;null!==(n=o.fullInfo)&&void 0!==n&&n.linkedChatId&&(r=(0,i.Z1)(e,o.fullInfo.linkedChatId)),(async()=>{await(0,Z.t9)("setDiscussionGroup",{channel:o}),r&&k(r)})()})),(0,n.Q6)("setActiveChatFolder",((e,t,s)=>({...e,chatFolders:{...e.chatFolders,activeChatFolder:s}}))),(0,n.Q6)("loadMoreMembers",(e=>{(async()=>{var t,s;const{chatId:a}=(0,i.Bt)(e)||{},o=a?(0,i.Z1)(e,a):void 0;if(!o||(0,d.G9)(o))return;const c=(null===(t=o.fullInfo)||void 0===t||null===(s=t.members)||void 0===s?void 0:s.length)||void 0,l=await(0,Z.t9)("fetchMembers",o.id,o.accessHash,"recent",c);if(!l)return;const{members:u,users:h}=l;u&&u.length&&(e=(0,n.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(h,"id")),e=(0,r.a4)(e,o.id,{fullInfo:{...o.fullInfo,members:[...(o.fullInfo||{}).members||[],...u||[]]}}),(0,n.R3)(e))})()})),(0,n.Q6)("addChatMembers",((e,t,s)=>{const{chatId:n,memberIds:a}=s,o=(0,i.Z1)(e,n),r=a.map((t=>(0,i.dy)(e,t))).filter(Boolean);o&&r.length&&(t.setNewChatMembersDialogState(h.WB.Loading),(async()=>{await(0,Z.t9)("addChatMembers",o,r),t.setNewChatMembersDialogState(h.WB.Closed),k(o)})())})),(0,n.Q6)("deleteChatMember",((e,t,s)=>{const{chatId:n,userId:a}=s,o=(0,i.Z1)(e,n),r=(0,i.dy)(e,a);o&&r&&(async()=>{await(0,Z.t9)("deleteChatMember",o,r),k(o)})()}));const T=new Map,N=(0,w.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(a.hT/2)+1);break;case h.Uq.Forwards:u=-(a.hT+1)}const m=await(0,Z.t9)("fetchMessages",{chat:(0,i.Cm)((0,n.Rd)(),l,t),offsetId:s,addOffset:u,limit:a.hT,threadId:t});if(!m)return;const{messages:f,users:p,chats:I,threadInfos:v}=m;let y=(0,n.Rd)();const C=l===a.aw?y.serviceNotifications.map((({message:e})=>e)):[],w=[].concat(f,C),P=(0,g.ee)(w,"id"),b=Object.keys(P).map(Number);y=(0,r.c_)(y,l,P),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:n}=x(e,s,o);y=(0,r.y9)(y,l,t,n)}(0,n.R3)(y)}function x(e,t,s){const{length:n}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,n)=>s===t||s<t&&e[n+1]>t))}(e,t):-1,r=s===h.Uq.Backwards?o:o+1||n,i=r-a.hT,c=r+a.hT-1,d=e.slice(Math.max(0,i),c+1);let l,u;switch(s){case h.Uq.Backwards:l=r>0,u=i>=0;break;case h.Uq.Forwards:l=r<n,u=c<=n-1;break;case h.Uq.Around:default:l=d.length>0,u=d.length===a.hT}return{newViewportIds:d,areSomeLocal:l,areAllLocal:u}}async function L(e){let t;const s=e.attachment?(e,a)=>{T.has(a)||(t=a,T.set(a,s));const o=(0,n.Rd)();(0,n.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||m.cj)&&await(0,w.Pn)();const a=(0,n.Rd)();e.serverTimeOffset=a.serverTimeOffset;const o=(0,i.Bt)(a);if(!o)return;const{threadId:r}=o;e.replyingTo||r===u._f||(e.replyingTo=(0,i.qS)(a,e.chat.id,r)),await(0,Z.t9)("sendMessage",e,s),s&&t&&T.delete(t)}(0,n.Q6)("loadViewportMessages",((e,t,s)=>{const{direction:n=h.Uq.Around,isBudgetPreload:o=!1}=s||{};let{chatId:c,threadId:d}=s||{};if(!c){const t=(0,i.Bt)(e);if(!t)return;c=t.chatId,d=t.threadId}const l=(0,i.Z1)(e,c);if(!l||l.isRestricted)return;const u=(0,i.Cb)(e,c,d),m=(0,i.gb)(e,c,d),g=(0,i.qC)(e,c,d);if(u&&u.length&&n!==h.Uq.Around){const s=n===h.Uq.Backwards?u[0]:u[u.length-1],a=Boolean(g),i=a?g:m,{newViewportIds:f,areSomeLocal:p,areAllLocal:I}=x(i,s,n);if(p&&(e=(0,r.y9)(e,c,d,f)),async function(e,t,s,n,a,o,r,i){t||await B(a,o,i,r,s,n),n||(await Promise.resolve(),e.loadViewportMessages({chatId:a.id,threadId:o,direction:r,isBudgetPreload:!0}))}(t,I,a,o,l,d,n,s),o)return}else{const t=(0,i.G$)(e,c)||(0,i.rd)(e,c,d),s=Boolean(t&&m&&!m.includes(t)),n=(s?g:m)||[],{newViewportIds:u,areSomeLocal:f,areAllLocal:p}=x(n,t,h.Uq.Around);f&&u.length>=a.hT&&(e=(0,r.y9)(e,c,d,u)),p||B(l,d,t,h.Uq.Around,s,o)}return e})),(0,n.Q6)("loadMessage",((e,t,s)=>{const{chatId:a,messageId:o,replyOriginForId:c,threadUpdate:d}=s,l=(0,i.Z1)(e,a);l&&(async()=>{const e=await async function(e,t,s){const a=await(0,Z.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===u._Q){if(s){let t=(0,n.Rd)();const a=(0,i.hj)(t,e.id,s);t=(0,r.cY)(t,e.id,s,{...a,replyToMessageId:void 0}),(0,n.R3)(t)}return}let o=(0,n.Rd)();return o=(0,r.cY)(o,e.id,t,a.message),o=(0,r.Sh)(o,(0,g.ee)(a.users,"id")),(0,n.R3)(o),a.message}(l,o,c);if(e&&d){const{lastMessageId:t,isDeleting:s}=d;(0,n.R3)((0,r.lG)((0,n.Rd)(),e,a,t,s))}})()})),(0,n.Q6)("sendMessage",((e,t,s)=>{const n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:r,type:c}=n;if("scheduled"===c&&!s.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:s}};const d=(0,i.Z1)(e,o);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:r,value:!1});const l={...s,chat:d,replyingTo:(0,i.Yy)(e,o,r),noWebPage:(0,i.tV)(e,o,r)},u=!s.attachments||s.attachments.length<=1,h=!u&&s.attachments&&s.attachments.length>1;if(u){const{attachments:e,...t}=l;L({...t,attachment:e?e[0]:void 0})}else if(h){const{text:e,entities:t,attachments:s,...n}=l,o=(0,g.Vl)(s,a.DU);for(let s=0;s<o.length;s++){const[a,...r]=o[s],i=`${Date.now()}${s}`;L({...n,text:0===s?e:void 0,entities:0===s?t:void 0,attachment:a,groupedId:r.length>0?i:void 0}),r.forEach((e=>{L({...n,attachment:e,groupedId:i})}))}}else{const{text:e,entities:t,attachments:s,replyingTo:n,...a}=l;e&&L({...a,text:e,entities:t,replyingTo:n}),s.forEach((e=>{L({...a,attachment:e})}))}})),(0,n.Q6)("editMessage",((e,t,s)=>{const{serverTimeOffset:n}=e,{text:a,entities:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c,threadId:d,type:l}=r,u=(0,i.Z1)(e,c),h=(0,i.kK)(e,c,d,l);u&&h&&((0,Z.t9)("editMessage",{chat:u,message:h,text:a,entities:o,noWebPage:(0,i.tV)(e,c,d),serverTimeOffset:n}),t.setEditingId({messageId:void 0}))})),(0,n.Q6)("cancelSendingMessage",((e,t,s)=>{const{chatId:n,messageId:a}=s,o=(0,i.hj)(e,n,a),r=o&&T.get(o.previousLocalId||o.id);r&&(0,Z.u3)(r),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:n})})),(0,n.Q6)("saveDraft",((e,t,s)=>{const{chatId:n,threadId:a,draft:o}=s;if(!o)return;const{text:c,entities:d}=o,l=(0,i.Z1)(e,n);return a===u._f&&(0,Z.t9)("saveDraft",{chat:l,text:c,entities:d,replyToMsgId:(0,i.Yy)(e,n,a)}),e=(0,r.pf)(e,n,a,"draft",o),(0,r.a4)(e,n,{draftDate:Math.round(Date.now()/1e3)})})),(0,n.Q6)("clearDraft",((e,t,s)=>{const{chatId:n,threadId:a,localOnly:o}=s;if(!(0,i.Ms)(e,n,a))return;const c=(0,i.Z1)(e,n);return o||a!==u._f||(0,Z.t9)("clearDraft",c),e=(0,r.pf)(e,n,a,"draft",void 0),(0,r.a4)(e,n,{draftDate:void 0})})),(0,n.Q6)("toggleMessageWebPage",((e,t,s)=>{const{chatId:n,threadId:a,noWebPage:o}=s;return(0,r.pf)(e,n,a,"noWebPage",o)})),(0,n.Q6)("pinMessage",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageId:a,isUnpin:o,isOneSide:r,isSilent:c}=s;(0,Z.t9)("pinMessage",{chat:n,messageId:a,isUnpin:o,isOneSide:r,isSilent:c})})),(0,n.Q6)("unpinAllMessages",((e,t,s)=>{const a=(0,i.Z1)(e,s.chatId);a&&async function(e){await(0,Z.t9)("unpinAllMessages",{chat:e});let t=(0,n.Rd)();t=(0,r.pf)(t,e.id,u._f,"pinnedIds",[]),(0,n.R3)(t)}(a)})),(0,n.Q6)("deleteMessages",((e,t,s)=>{const{messageIds:n,shouldDeleteForAll:a}=s,o=(0,i.Bt)(e);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);(0,Z.t9)("deleteMessages",{chat:d,messageIds:n,shouldDeleteForAll:a});const l=(0,i._$)(e,r,c);n.includes(l)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o}=a,r=(0,i.Z1)(e,o);(0,Z.t9)("deleteScheduledMessages",{chat:r,messageIds:n});const c=(0,i.wU)(e,o);n.includes(c)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteHistory",((e,t,s)=>{(async()=>{var n;const{chatId:a,shouldDeleteForAll:o}=s,r=(0,i.Z1)(e,a);if(!r)return;const c=null===(n=r.lastMessage)||void 0===n?void 0:n.id;await(0,Z.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o,maxId:c});const d=(0,i.Bt)(e);d&&d.chatId===a&&t.openChat({id:void 0})})()})),(0,n.Q6)("reportMessages",((e,t,s)=>{(async()=>{const{messageIds:n,reason:a,description:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c}=r,d=(0,i.Z1)(e,c),l=await(0,Z.t9)("reportMessages",{peer:d,messageIds:n,reason:a,description:o});t.showNotification({message:l?"Thank you! Your report will be reviewed by our team.":"Error occured while submiting report. Please, try again later."})})()})),(0,n.Q6)("markMessageListRead",((e,t,s)=>{const{serverTimeOffset:n}=e,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c}=a,d=(0,i.Cm)(e,o,c);if(!d)return;const{maxId:l}=s;if(N((()=>{(0,Z.t9)("markMessageListRead",{serverTimeOffset:n,chat:d,threadId:c,maxId:l})})),c!==u._f)return;const h=(0,i.Cb)(e,o,c),m=(0,i.It)(e,o,c);if(!h||!m||!d.unreadCount)return;const g=function(e,t,s){let n=0;for(let a=0,o=e.length;a<o&&(e[a]>=t&&e[a]<=s&&n++,!(e[a]>=s));a++);return n}(h,m,l);return g?(0,r.a4)(e,o,{lastReadInboxMessageId:l,unreadCount:Math.max(0,d.unreadCount-g)}):void 0})),(0,n.Q6)("markMessagesRead",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageIds:a}=s;(0,Z.t9)("markMessagesRead",{chat:n,messageIds:a})})),(0,n.Q6)("loadWebPagePreview",((e,t,s)=>{const{text:a}=s;!async function(e){const t=await(0,Z.t9)("fetchWebPagePreview",{message:e});(0,n.R3)({...(0,n.Rd)(),webPagePreview:t})}(a)})),(0,n.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,n.Q6)("sendPollVote",((e,t,s)=>{const{chatId:n,messageId:a,options:o}=s,r=(0,i.Z1)(e,n);r&&(0,Z.t9)("sendPollVote",{chat:r,messageId:a,options:o})})),(0,n.Q6)("loadPollOptionResults",((e,t,s)=>{const{chat:a,messageId:o,option:i,offset:c,limit:d,shouldResetVoters:l}=s;!async function(e,t,s,a,o,i){const c=await(0,Z.t9)("loadPollOptionResults",{chat:e,messageId:t,option:s,offset:a,limit:o});if(!c)return;let d=(0,n.Rd)();d=(0,r.Sh)(d,(0,g.ee)(c.users,"id"));const{voters:l}=d.pollResults;(0,n.R3)({...d,pollResults:{...d.pollResults,voters:{...l,[s]:[...!i&&l&&l[s]?l[s]:[],...c&&c.users.map((e=>e.id))].filter(((e,t,s)=>s.indexOf(e)===t))},offsets:{...d.pollResults.offsets?d.pollResults.offsets:{},[s]:c.nextOffset||""}}})}(a,o,i,c,d,l)})),(0,n.Q6)("forwardMessages",(e=>{const{fromChatId:t,messageIds:s,toChatId:a}=e.forwardMessages,o=t?(0,i.Z1)(e,t):void 0,r=a?(0,i.Z1)(e,a):void 0,c=t&&s?s.sort(((e,t)=>e-t)).map((s=>(0,i.hj)(e,t,s))).filter(Boolean):void 0;o&&r&&c&&c.length&&function(e,t,s){(0,Z.t9)("forwardMessages",{fromChat:e,toChat:t,messages:s,serverTimeOffset:(0,n.Rd)().serverTimeOffset}),(0,n.R3)({...(0,n.Rd)(),forwardMessages:{}})}(o,r,c)})),(0,n.Q6)("loadScheduledHistory",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);if(!o)return;const{hash:c}=e.scheduledMessages.byChatId[o.id]||{};!async function(e,t){const s=await(0,Z.t9)("fetchScheduledHistory",{chat:e,hash:t});if(!s)return;const{hash:a,messages:o}=s,i=(0,g.ee)(o,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,n.Rd)();d=(0,r.w3)(d,e.id,i,a),d=(0,r.pf)(d,e.id,u._f,"scheduledIds",c),(0,n.R3)(d)}(o,c)})),(0,n.Q6)("sendScheduledMessages",((e,t,s)=>{const{chatId:n,id:a}=s,o=(0,i.Z1)(e,n);o&&(0,Z.t9)("sendScheduledMessages",{chat:o,ids:[a]})})),(0,n.Q6)("rescheduleMessage",((e,t,s)=>{const{chatId:n,messageId:a,scheduledAt:o}=s,r=(0,i.Z1)(e,n),c=r&&(0,i.Tm)(e,r.id,a);r&&c&&(0,Z.t9)("rescheduleMessage",{chat:r,message:c,scheduledAt:o})})),(0,n.Q6)("requestThreadInfoUpdate",((e,t,s)=>{const{chatId:n,threadId:a}=s,o=(0,i.Cm)(e,n,a);o&&(0,Z.t9)("requestThreadInfoUpdate",{chat:o,threadId:a})})),(0,n.Q6)("loadPinnedMessages",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&async function(e){const t=await(0,Z.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:s,chats:a,users:o}=t,i=(0,g.ee)(s,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,n.Rd)();d=(0,r.c_)(d,e.id,i),d=(0,r.pf)(d,e.id,u._f,"pinnedIds",c),d=(0,r.Sh)(d,(0,g.ee)(o,"id")),d=(0,r.fZ)(d,(0,g.ee)(a,"id")),(0,n.R3)(d)}(o)}));var A=s(5765);const O=(0,w.P2)((e=>e()),500,!1);async function F(e,t){const s=await(0,Z.t9)("searchGifs",{query:e,offset:t});s&&(0,n.R3)((0,r.rq)((0,n.Rd)(),!t,s.gifs,s.nextOffset))}(0,n.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e=0){const t=await(0,Z.t9)("fetchStickerSets",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"added",t.hash,t.sets))}(t)})),(0,n.Q6)("loadAddedStickers",((e,t)=>{const{setIds:s}=e.stickers.added;s&&s.length&&(async()=>{for(let e=0;e<s.length;e++)t.loadStickers({stickerSetId:s[e]}),e%50==0&&e>0&&await(0,w.wO)(500)})()})),(0,n.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e=0){const t=await(0,Z.t9)("fetchRecentStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,recent:t}})}(t)})),(0,n.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e=0){const t=await(0,Z.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,favorite:t}})}(t)})),(0,n.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,Z.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,n.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e=0){const t=await(0,Z.t9)("fetchFeaturedStickers",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,n.Q6)("loadStickers",((e,t,s)=>{const{stickerSetId:a,stickerSetShortName:o}=s;let{stickerSetAccessHash:c}=s;if(!c&&!o){const t=(0,i.Ny)(e,a);if(!t)return;c=t.accessHash}!async function(e,t,s){const a=await(0,Z.t9)("fetchStickers",{stickerSetShortName:s,stickerSetId:e,accessHash:t});if(!a)return;const{set:o,stickers:i,packs:c}=a;let d=(0,n.Rd)();d=(0,r.Rg)(d,o.id,{...o,stickers:i,packs:c});const l=d.stickers.forEmoji.emoji;l&&c[l]&&(d=(0,r.vy)(d)),(0,n.R3)(d)}(a,c,o)})),(0,n.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,Z.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:s}=e;(0,n.R3)((0,r.g_)((0,n.Rd)(),{...t,stickers:s}))}()})),(0,n.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e=0){const t=await(0,Z.t9)("fetchSavedGifs",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,gifs:{...s.gifs,saved:t}})}(t)})),(0,n.Q6)("faveSticker",((e,t,s)=>{const{sticker:n}=s;n&&(0,Z.t9)("faveSticker",{sticker:n})})),(0,n.Q6)("unfaveSticker",((e,t,s)=>{const{sticker:a}=s;a&&function(e){const t=(0,n.Rd)();(0,n.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((({id:t})=>t!==e.id))}}}),(0,Z.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,n.Q6)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:n}=s,a=(0,i.Ny)(e,n);if(!a)return;const{accessHash:o,installedDate:r}=a;(0,Z.t9)(r?"uninstallStickerSet":"installStickerSet",{stickerSetId:n,accessHash:o})})),(0,n.Q6)("loadEmojiKeywords",((e,t,s)=>{var a;const{language:o}=s;let r=e.emojiKeywords[o];null!==(a=r)&&void 0!==a&&a.isLoading||((0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}}),(async()=>{var t;const s=await(0,Z.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});e=(0,n.Rd)(),r=e.emojiKeywords[o],s?(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:s.version,keywords:{...null===(t=r)||void 0===t?void 0:t.keywords,...s.keywords}}}}):(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})())})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:a}=s;a&&O((()=>{!async function(e,t=0){const s=await(0,Z.t9)("searchStickers",{query:e,hash:t});if(!s)return;const a=(0,n.Rd)(),{setsById:o,added:i}=a.stickers,c=s.sets.map((({id:e})=>e));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:s}=o[t]||{};s&&(0,A.Z)(s,e)&&c.unshift(t)}})),(0,n.R3)((0,r.z3)(a,"search",s.hash,s.sets,c))}(a)}))})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;"string"==typeof n&&O((()=>{F(n)}))})),(0,n.Q6)("searchMoreGifs",(e=>{const{query:t,offset:s}=e.gifs.search;"string"==typeof t&&O((()=>{F(t,s)}))})),(0,n.Q6)("loadStickersForEmoji",((e,t,s)=>{const{emoji:a}=s,{hash:o}=e.stickers.forEmoji;O((()=>{!async function(e,t=0){let s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,forEmoji:{...s.stickers.forEmoji,emoji:e}}});const a=await(0,Z.t9)("fetchStickersForEmoji",{emoji:e,hash:t});s=(0,n.Rd)(),a&&s.stickers.forEmoji.emoji===e&&(s=(0,r.IM)(s,e,a.stickers,a.hash),(0,n.R3)(s))}(a,o)}))})),(0,n.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,n.Q6)("openStickerSetShortName",((e,t,s)=>{const{stickerSetShortName:n}=s;return{...e,openedStickerSetShortName:n}}));var U=s(790);const D=(0,w.P2)((e=>e()),500,!1);async function $(e="",t,s,o,c,d){let l;if(o){const n=await(0,Z.t9)("searchMessagesLocal",{chatOrUser:o,query:e,type:t,limit:a.Hk,offsetId:s,minDate:d,maxDate:c});if(n){const{messages:e,users:t,totalCount:s,nextOffsetId:a}=n;l={messages:e,users:t,chats:[],totalCount:s,nextRate:a}}}else l=await(0,Z.t9)("searchMessagesGlobal",{query:e,offsetRate:s,limit:a.Hk,type:t,maxDate:c,minDate:d});let u=(0,n.Rd)();const h=(0,i.JX)(u);if(!l||""!==e&&e!==h)return void(0,n.R3)((0,r.xv)(u,{messages:!1}));const{messages:m,users:f,chats:p,totalCount:I,nextRate:v}=l;p.length&&(u=(0,r.fZ)(u,(0,g.ee)(p,"id"))),f.length&&(u=(0,r.Sh)(u,(0,g.ee)(f,"id"))),m.length&&(u=(0,r.m6)(u,m)),u=(0,r.px)(u,m,I,t,v),(0,n.R3)(u)}(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{chatId:a}=e.globalSearch,{query:o}=s;o&&!a&&D((()=>{!async function(e){const t=await(0,Z.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=(0,i.JX)(s);if(!t||!a||e!==a)return void(0,n.R3)((0,r.xv)(s,{chats:!1}));const{localChats:o,localUsers:c,globalChats:d,globalUsers:l}=t;(o.length||d.length)&&(s=(0,r.fZ)(s,(0,g.ee)([...o,...d],"id"))),(c.length||l.length)&&(s=(0,r.Sh)(s,(0,g.ee)([...c,...l],"id"))),s=(0,r.xv)(s,{chats:!1}),s=(0,r.No)(s,{localResults:{chatIds:o.map((({id:e})=>e)),userIds:c.map((({id:e})=>e))},globalResults:{...s.globalSearch.globalResults,chatIds:d.map((({id:e})=>e)),userIds:l.map((({id:e})=>e))}}),(0,n.R3)(s)}(o)}))})),(0,n.Q6)("setGlobalSearchDate",((e,t,s)=>{const{date:a}=s,o=a?(0,U.IS)(a):a,c=(0,r.No)(e,{date:a,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,n.R3)(c);const{chatId:d}=e.globalSearch;$("","text",void 0,d?(0,i.Z1)(e,d):void 0,o,a)})),(0,n.Q6)("searchMessagesGlobal",((e,t,s)=>{var n;const{query:a,resultsByType:o,chatId:r,date:c}=e.globalSearch,d=c?(0,U.IS)(c):c,{type:l}=s;$(a,l,null==o||null===(n=o[l])||void 0===n?void 0:n.nextOffsetId,r?(0,i.Z1)(e,r):void 0,d,c)})),(0,n.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},o=t?(0,i.Z1)(e,t):void 0,c=(0,i.n5)(e);if(!o||!c||!s)return;const{query:d,results:l}=c,h=null==l?void 0:l.nextOffsetId;let m;if(s!==u._f){const n=(0,i.tZ)(e,t,s);m=null==n?void 0:n.topMessageId}!async function(e,t,s,o,c){const d=await(0,Z.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:s,limit:a.pn,offsetId:c});if(!d)return;const{messages:l,users:u,totalCount:h,nextOffsetId:m}=d,f=(0,g.ee)(l,"id"),p=Object.keys(f).map(Number);let I=(0,n.Rd)();const v=(0,i.n5)(I);!v||o&&o!==v.query||(I=(0,r.c_)(I,e.id,f),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.dx)(I,e.id,t,p,h,m),(0,n.R3)(I))}(o,s,m,d,h)})),(0,n.Q6)("searchMediaMessagesLocal",(e=>{const t=(0,i.og)(e),s=t?e.users.byId[t]||e.chats.byId[t]:void 0,o=(0,i.we)(e);if(!s||!o)return;const{currentType:c,resultsByType:d}=o,l=c&&d&&d[c],u=null==l?void 0:l.nextOffsetId;c&&async function(e,t,s){const o=await(0,Z.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:a.EN,offsetId:s});if(!o)return;const{messages:c,users:d,totalCount:l,nextOffsetId:u}=o,h=(0,g.ee)(c,"id"),m=Object.keys(h).map(Number);let f=(0,n.Rd)();(0,i.we)(f)&&(f=(0,r.c_)(f,e.id,h),f=(0,r.Sh)(f,(0,g.ee)(d,"id")),f=(0,r.c1)(f,e.id,t,m,l,u),(0,n.R3)(f))}(s,c,u)})),(0,n.Q6)("searchMessagesByDate",((e,t,s)=>{const{timestamp:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return;const r=(0,i.Z1)(e,o);r&&async function(e,t){const s=await(0,Z.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});s&&(0,n.uC)().focusMessage({chatId:e.id,messageId:s})}(r,a)})),(0,n.Q6)("checkPublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};if(!a)return;if(e.management.progress===h.wv.InProgress)return;const{username:o}=s;(async()=>{e=(0,r.H9)(e,h.wv.InProgress),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e);const t=await(0,Z.t9)("checkChatUsername",{username:o});e=(0,n.Rd)(),e=(0,r.H9)(e,t?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:t}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};let o=a&&(0,i.Z1)(e,a);if(!a||!o)return;const{username:c}=s;(async()=>{if(e=(0,r.H9)(e,h.wv.InProgress),(0,n.R3)(e),(0,d.G9)(o)){if(o=await(0,Z.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const s=await(0,Z.t9)("setChatUsername",{chat:o,username:c});e=(0,n.Rd)(),e=(0,r.H9)(e,s?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t&&(0,i.Z1)(e,t);t&&s&&(0,Z.t9)("updatePrivateLink",{chat:s})}));var Q=s(7358);async function q(){const e=await(0,Z.t9)("fetchChats",{limit:a.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,n.Rd)().serverTimeOffset});if(!e)return;let t=(0,n.Rd)();t=(0,r.eD)(t,(0,g.ee)(e.users,"id")),t=(0,r.GL)(t,(0,g.ee)(e.chats,"id")),t=(0,r.Mg)(t,"archived",e.chatIds),t=(0,r.vv)(t,"archived",e),(0,n.R3)(t)}async function G(){let e=(0,n.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:s}=e.contactList||{};if(!(s&&s.length||t&&t.length))return;const a=[...t||[],...s||[]].map((t=>(0,i.dy)(e,t))).filter(Boolean),o=await(0,Z.t9)("fetchUsers",{users:a});o&&(e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(o,"id")),(0,n.R3)(e))}function H(e){return(0,Z.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,n.Q6)("sync",((e,t)=>{!async function(e){a.eM&&console.log(">>> START SYNC"),await(0,Z.t9)("fetchCurrentUser");const t=await async function(){var e;let t=(0,n.Rd)();const s=await(0,Z.t9)("fetchChats",{limit:a.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,n.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.YA)(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).map(Number).forEach((e=>{t=(0,r.pf)(t,e,u._f,"draft",s.draftsById[e])})),Object.keys(s.replyingToById).map(Number).forEach((e=>{t=(0,r.pf)(t,e,u._f,"replyingToId",s.replyingToById[e])})),(0,n.R3)(t),p&&!t.chats.byId[p]&&(0,n.uC)().openChat({id:void 0}),m}();await async function(e){let t=!1,s=e||[],o=(0,n.Rd)();const{chatId:c,threadId:d}=(0,i.Bt)(o)||{},l=Object.keys(o.messages.byChatId).map(Number).reduce(((e,t)=>{const s=(0,i.Ms)(o,t,u._f);return s?{...e,[t]:s}:e}),{});if(c){const e=await H(o.chats.byId[c]);o=(0,n.Rd)();const{chatId:l}=(0,i.Bt)(o)||{},h=d&&(0,i.tZ)(o,c,d);if(e&&l===c){const n=o.messages.byChatId[c],i=c===a.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 H(o.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),a=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:a,viewportIds:a,outlyingIds:void 0}}},[c]:{...o.messages.byChatId[c],threadsById:{...o.messages.byChatId[c].threadsById,[d]:{...null==n?void 0:n.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).map(Number).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,n.R3)(o);const{chatId:h,messageId:m}=o.audioPlayer;h&&m&&!(0,i.hj)(o,h,m)&&(0,n.uC)().closeAudioPlayer()}(t),(0,n.R3)({...(0,n.Rd)(),lastSyncTime:Date.now()}),a.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,n.Q6)("afterSync",((e,t)=>{!async function(e){a.eM&&console.log(">>> START AFTER-SYNC"),e.loadFavoriteStickers(),await Promise.all([G(),q()]),await(0,Z.t9)("fetchCurrentUser"),(0,Q.w)((0,i.A1)((0,n.Rd)())),a.eM&&console.log(">>> FINISH AFTER-SYNC")}(t)}));const j=(0,w.Ds)((e=>e()),500,!1,!0),_=(0,w.P2)((e=>e()),500,!1);function V(e,t,s){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:s}}}}function W(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,n.Q6)("loadFullUser",((e,t,s)=>{const{userId:n}=s,a=(0,i.dy)(e,n);if(!a)return;const{id:o,accessHash:r}=a;j((()=>(0,Z.t9)("fetchFullUser",{id:o,accessHash:r})))})),(0,n.Q6)("loadUser",((e,t,s)=>{const{userId:a}=s,o=(0,i.dy)(e,a);o&&(async()=>{const t=await(0,Z.t9)("fetchUsers",{users:[o]});t&&(e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(t,"id")),(0,n.R3)(e))})()})),(0,n.Q6)("loadTopUsers",(e=>{const{topPeers:{hash:t,lastRequestedAt:s}}=e;(!s||(0,f.b)(e.serverTimeOffset)-s>60)&&async function(e){const t=await(0,Z.t9)("fetchTopUsers",{hash:e});if(!t)return;const{hash:s,ids:a,users:o}=t;let i=(0,n.Rd)();i=(0,r.Sh)(i,(0,g.ee)(o,"id")),i={...i,topPeers:{...i.topPeers,hash:s,userIds:a,lastRequestedAt:(0,f.b)(i.serverTimeOffset)}},(0,n.R3)(i)}(t)})),(0,n.Q6)("loadContactList",(e=>{const{hash:t}=e.contactList||{};!async function(e){const t=await(0,Z.t9)("fetchContactList",{hash:e});if(!t)return;let s=(0,r.Sh)((0,n.Rd)(),(0,g.ee)(t.users,"id"));s=(0,r.fZ)(s,(0,g.ee)(t.chats,"id"));const a=e=>e.lastName||e.firstName||"",o=new Intl.Collator("en-US"),i=t.users.sort(((e,t)=>o.compare(a(e),a(t)))).filter((e=>!e.isSelf));(0,n.R3)({...s,contactList:{hash:t.hash,userIds:i.map((e=>e.id))}})}(t)})),(0,n.Q6)("loadCurrentUser",(()=>{(0,Z.t9)("fetchCurrentUser")})),(0,n.Q6)("updateContact",((e,t,s)=>{const{userId:a,isMuted:o,firstName:c,lastName:d}=s;!async function(e,t,s,a){const o=(0,n.Rd)(),c=(0,i.dy)(o,e);c&&((0,n.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.InProgress)),await(0,Z.t9)("updateContact",{phone:c.phoneNumber,firstName:s,lastName:a})&&(0,n.R3)((0,r.Nq)((0,n.Rd)(),c.id,{firstName:s,lastName:a})),(0,n.R3)((0,r.H9)((0,n.Rd)(),h.wv.Complete)))}(a,o,c,d)})),(0,n.Q6)("deleteUser",((e,t,s)=>{const{userId:a}=s;!async function(e){const t=(0,n.Rd)(),s=(0,i.dy)(t,e);if(!s)return;const{id:a,accessHash:o}=s;await(0,Z.t9)("deleteUser",{id:a,accessHash:o})}(a)})),(0,n.Q6)("loadProfilePhotos",((e,t,s)=>{const{profileId:a}=s,o=(0,d.YA)(a),c=o?(0,i.dy)(e,a):void 0,l=o?void 0:(0,i.Z1)(e,a);(c||l)&&(async()=>{const e=await(0,Z.t9)("fetchProfilePhotos",c,l);if(!e||!e.photos)return;let t=(0,n.Rd)();o?t=(0,r.Nq)(t,a,{photos:e.photos}):(t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.a4)(t,a,{photos:e.photos})),(0,n.R3)(t)})()})),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:a}=s;a&&_((()=>{!async function(e){const t=await(0,Z.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=s.userSearch.query;if(!t||!a||e!==a)return void(0,n.R3)((0,r.Q3)(s,!1));const{localUsers:o,globalUsers:i}=t;let c,d;o.length&&(s=(0,r.Sh)(s,(0,g.ee)(o,"id")),c=o.map((({id:e})=>e))),i.length&&(s=(0,r.Sh)(s,(0,g.ee)(i,"id")),d=i.map((({id:e})=>e))),s=(0,r.Q3)(s,!1),s=(0,r.Lm)(s,{localUserIds:c,globalUserIds:d}),(0,n.R3)(s)}(a)}))}));const z=(0,w.Ds)((e=>e()),500,!1);async function Y(e,t,s,n){await(0,Z.t9)("sendMessage",{chat:e,text:s,replyingTo:n})}(0,n.Q6)("clickInlineButton",((e,t,s)=>{const{button:o}=s;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(a.Lj)||o.value.match(a.FS)||o.value.match(a.g$)||o.value.match(a.iL)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,i.jr)(e);if(!t)return;!async function(e,t,s){const a=await(0,Z.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:s});if(!a)return;const{showDialog:o,showNotification:r,toggleSafeLinkModal:i}=(0,n.uC)(),{message:c,alert:d,url:l}=a;d?o({data:{message:c||"Error"}}):c?r({message:c}):l&&i({url:l})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"buy":{const s=(0,i.jr)(e),{messageId:n,value:a}=o;if(!s)return;a?t.getReceipt({receiptMessageId:a,chatId:s.id,messageId:n}):(t.getPaymentForm({chat:s,messageId:n}),t.setInvoiceMessageInfo((0,i.hj)(e,s.id,n)),t.openPaymentModal({chatId:s.id,messageId:n}));break}}})),(0,n.Q6)("sendBotCommand",((e,t,s)=>{const{command:n,chatId:a}=s,{currentUserId:o}=e,r=a?(0,i.Z1)(e,a):(0,i.jr)(e),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,n,(0,i.Yy)(e,r.id,d))})),(0,n.Q6)("restartBot",((e,t,s)=>{const{chatId:a}=s,{currentUserId:o}=e,c=(0,i.jr)(e),d=o&&(0,i.IK)(e,a);o&&c&&d&&(async()=>{await(0,Z.t9)("unblockContact",d.id,d.accessHash)&&((0,n.R3)((0,r.rB)((0,n.Rd)(),d.id)),Y(c,0,"/start"))})()})),(0,n.Q6)("loadTopInlineBots",(e=>{const{hash:t,lastRequestedAt:s}=e.topInlineBots;s&&(0,f.b)(e.serverTimeOffset)-s<60||(async()=>{const s=await(0,Z.t9)("fetchTopInlineBots",{hash:t});if(!s)return;const{hash:a,ids:o,users:i}=s;let c=(0,n.Rd)();c=(0,r.Sh)(c,(0,g.ee)(i,"id")),c={...c,topInlineBots:{...c.topInlineBots,hash:a,userIds:o,lastRequestedAt:(0,f.b)(e.serverTimeOffset)}},(0,n.R3)(c)})()})),(0,n.Q6)("queryInlineBot",((e,t,s)=>{const{chatId:a,username:o,query:c,offset:d}=s;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:s,chat:a}=await(0,Z.t9)("fetchInlineBot",{username:o})||{};if(e=(0,n.Rd)(),!s||!a)return void(0,n.R3)(V(e,o,!1));e=(0,r.Sh)(e,{[s.id]:s}),e=(0,r.fZ)(e,{[a.id]:a}),t={id:s.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=V(e,o,t),(0,n.R3)(e)}(c!==t.query||t.canLoadMore)&&z((()=>{!async function({username:e,inlineBotData:t,chatId:s,query:a,offset:o}){let r=(0,n.Rd)();const c=(0,i.dy)(r,t.id),d=(0,i.Z1)(r,s);if(!c||!d)return;const l=t.query!==a;r=W(r,!0),r=V(r,e,{...t,query:a,...l&&{offset:void 0,results:[]}}),(0,n.R3)(r);const u=await(0,Z.t9)("fetchInlineBotResults",{bot:c,chat:d,query:a,offset:l?void 0:o}),h=r.inlineBots.byUsername[e];if(r=W((0,n.Rd)(),!1),!u||!h||a!==h.query)return void(0,n.R3)(r);const m=new Set((h.results||[]).map((e=>e.id))),g=u.results.filter((e=>!m.has(e.id)));r=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,n.R3)(r)}({username:o,inlineBotData:t,chatId:a,query:c,offset:d})}))}})()})),(0,n.Q6)("sendInlineBotResult",((e,t,s)=>{const{id:n,queryId:a}=s,o=(0,i.Bt)(e);if(!o||!n)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r,threadId:c,value:!1}),(0,Z.t9)("sendInlineBotResult",{chat:d,resultId:n,queryId:a,replyingTo:(0,i.Yy)(e,r,c)})})),(0,n.Q6)("resetInlineBot",((e,t,s)=>{const{username:a}=s;let o=e.inlineBots.byUsername[a];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,n.R3)(V(e,a,o)))})),(0,n.Q6)("startBot",((e,t,s)=>{const{botId:n,param:a}=s,o=(0,i.dy)(e,n);o&&(async()=>{await(0,Z.t9)("startBot",{bot:o,startParam:a})})()})),s(9667),(0,n.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,Z.t9)("getPasswordInfo");if(!e)return;let t=(0,n.Rd)();t=(0,r.BI)(t,{hasPassword:e.hasPassword}),t=(0,r.IE)(t,{hint:e.hint}),(0,n.R3)(t)})()})),(0,n.Q6)("checkPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("checkPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("clearPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("clearPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("updatePassword",((e,t,s)=>{const{currentPassword:a,password:o,hint:i,email:c,onSuccess:d}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("updatePassword",a,o,i,c);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&d()})()})),(0,n.Q6)("updateRecoveryEmail",((e,t,s)=>{const{currentPassword:a,email:o,onSuccess:i}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,Z.t9)("updateRecoveryEmail",a,o);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&i()})()})),(0,n.Q6)("provideTwoFaEmailCode",((e,t,s)=>{const{code:n}=s;(0,Z.t9)("provideRecoveryEmailCode",n)})),(0,n.Q6)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,n.Q6)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:a,saveInfo:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e);d&&l&&async function(e,t,s,a){const o=await(0,Z.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:s,shouldSave:a});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let d=(0,r.vT)((0,n.Rd)(),i);c?(d=(0,r.TM)(d,c),d=(0,r.Q$)(d,h.KB.Shipping)):d=(0,r.Q$)(d,h.KB.PaymentInfo),(0,n.R3)(d)}(d,l,a,o)})),(0,n.Q6)("getPaymentForm",((e,t,s)=>{const{chat:a,messageId:o}=s;a&&o&&async function(e,t){const s=await(0,Z.t9)("getPaymentForm",{chat:e,messageId:t});if(!s)return;let a=(0,r._7)((0,n.Rd)(),s),o=h.KB.PaymentInfo;a.payment.invoice&&(a.payment.invoice.shippingAddressRequested||a.payment.invoice.nameRequested||a.payment.invoice.phoneRequested||a.payment.invoice.emailRequested)&&(o=h.KB.ShippingInfo),a=(0,r.Q$)(a,o),(0,n.R3)(a)}(a,o)})),(0,n.Q6)("getReceipt",((e,t,s)=>{const{receiptMessageId:a,chatId:o,messageId:c}=s,d=o&&(0,i.Z1)(e,o);c&&a&&d&&async function(e,t,s){const a=await(0,Z.t9)("getReceipt",e,s);if(!a)return;let o=(0,n.Rd)();const c=(0,i.hj)(o,e.id,t);o=(0,r.Dq)(o,a,c),(0,n.R3)(o)}(d,c,a)})),(0,n.Q6)("clearPaymentError",(e=>{(0,n.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,n.Q6)("clearReceipt",(e=>{(0,n.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,n.Q6)("sendCredentialsInfo",((e,t,s)=>{const a=(0,i.$$)(e);if(!a)return;const{credentials:o}=s,{data:c}=o;!async function(e,t){const s=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvv,"card[address_zip]":e.zip,"card[address_country]":e.country}),a=await fetch(`https://api.stripe.com/v1/tokens${s}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await a.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,n.Rd)();return void(0,n.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,n.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,h.KB.Checkout),(0,n.R3)(i)}(c,a)})),(0,n.Q6)("sendPaymentForm",((e,t,s)=>{const{shippingOptionId:a,saveCredentials:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e),u=(0,i.eh)(e),h=(0,i.sp)(e),m=(0,i.$$)(e),g=(0,i.i3)(e);d&&l&&m&&u&&async function(e,t,s,a,o,i){if(await(0,Z.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:a,requestedInfoId:o,shippingOptionId:i})){const e=(0,r.bp)((0,n.Rd)());(0,n.R3)((0,r.WY)(e))}}(d,l,u,{save:o,data:g},h,a)})),(0,n.Q6)("setPaymentStep",((e,t,s={})=>(0,r.Q$)(e,s.step||h.KB.ShippingInfo))),(0,n.Q6)("setInvoiceMessageInfo",((e,t,s)=>(0,r.nA)(e,s))),s(4907);var X=s(8406);const K=(0,w.P2)((e=>e()),500,!0);(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{s.noTopChatsRequest||(0,i.N)(e,s.id)||t.loadTopChats();const a=(0,r.a4)(e,s.id,s.chat,s.newProfilePhoto);(0,n.R3)(a),K((()=>(0,Q.w)((0,i.A1)((0,n.Rd)())))),s.chat.id&&(0,X.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const a=(0,i.Ek)(e,s.id);if(!a)break;e=(0,r.B1)(e,a,[s.id]),e=(0,r.a4)(e,s.id,{isNotJoined:!1}),(0,n.R3)(e);const o=(0,i.Z1)(e,s.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":{const t=(0,i.Ek)(e,s.id);if(!t)break;const{[t]:a}=e.chats.listIds;a&&(e=(0,r.Mg)(e,t,a.filter((e=>e!==s.id)))),e=(0,r.a4)(e,s.id,{isNotJoined:!0}),(0,n.R3)(e);break}case"updateChatInbox":(0,n.R3)((0,r.a4)(e,s.id,s.chat)),K((()=>(0,Q.w)((0,i.A1)((0,n.Rd)()))));break;case"updateChatTypingStatus":{const{id:t,typingStatus:a}=s;(0,n.R3)((0,r.a4)(e,t,{typingStatus:a})),setTimeout((()=>{const e=(0,n.Rd)(),s=(0,i.Z1)(e,t);s&&a&&s.typingStatus&&s.typingStatus.timestamp===a.timestamp&&(0,n.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:a}=s,{chatId:o,threadId:c,type:d}=(0,i.Bt)(e)||{};if(a.senderId===e.currentUserId&&!a.isFromScheduled)return;const l=(0,i.Z1)(e,s.chatId);if(!l)return;const h="thread"===d&&c===u._f&&s.chatId===o;h?setTimeout((()=>{t.requestChatUpdate({chatId:s.chatId})}),1500):(0,n.R3)((0,r.a4)(e,s.chatId,{unreadCount:l.unreadCount?l.unreadCount+1:1,...s.message.hasUnreadMention&&{unreadMentionsCount:l.unreadMentionsCount?l.unreadMentionsCount+1:1}})),(0,Q.w)((0,i.A1)((0,n.Rd)()));const{hasWebNotifications:m}=(0,i.dZ)(e);m&&(0,X.VL)({chat:l,message:a,isActiveChat:h});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=s;if(!1!==a.hasUnreadMention)return;t.forEach((t=>{const n="channelId"in s?s.channelId:(0,i.X5)(e,t),a=(0,i.Z1)(e,n);null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,n,{unreadMentionsCount:a.unreadMentionsCount-1}))})),(0,n.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=s,a=e.chats.byId[s.id];if(!a)return;(0,n.R3)((0,r.a4)(e,s.id,{fullInfo:{...a.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=s,r=o===a.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:t.length?t:void 0}}},(0,n.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=s,r=(0,i.Ek)(e,t);if(r){const{[r]:s}=e.chats.orderedPinnedIds;let n=s||[];if(o){if(!n.includes(t)){if("active"===r&&n.length>=a.EG){const t=e.chats.listIds.active;n=n.filter((e=>t&&t.includes(e)))}n=[t,...n]}}else n=n.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:n.length?n:void 0}}}}(0,n.R3)(e);break}case"updateChatListType":{const{id:t,folderId:a}=s;(0,n.R3)((0,r.Pi)(e,t,a));break}case"updateChatFolder":{const{id:t,folder:a}=s,{byId:o,orderedIds:r}=e.chatFolders,i=a?{...o,[t]:a}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=a?r&&r.includes(t)?r:[...r||[],t]:r?r.filter((e=>e!==t)):void 0;(0,n.R3)({...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[s.id],{replacedMembers:a,addedMember:i,deletedMemberId:c}=s;if(!t)return;let d=!1,l=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(a)l=a,d=!0;else if(i)l.length&&l.some((e=>e.userId===i.userId))||(l.push(i),d=!0);else if(l.length&&c){const e=l.findIndex((e=>e.userId===c));e>-1&&(l.slice(e,1),d=!0)}if(d){const a=l.filter((({isOwner:e,isAdmin:t})=>e||t));(0,n.R3)((0,r.a4)(e,s.id,{membersCount:l.length,fullInfo:{...t.fullInfo,members:l,adminMembers:a}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:a}=s,o=e.chats.byId[t];null!=o&&o.photos&&(0,n.R3)((0,r.a4)(e,t,{photos:o.photos.filter((e=>!a.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:a,date:o,replyingToId:i}=s;e.chats.byId[t]&&(e=(0,r.pf)(e,t,u._f,"draft",a),e=(0,r.pf)(e,t,u._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:o}),(0,n.R3)(e));break}case"showInvite":{const{data:e}=s;t.showDialog({data:e});break}}}));const J=350;function ee(e,t,s,n,a=!1){const o=a?(0,i.Tm)(e,t,s):(0,i.hj)(e,t,s);if(o&&n.content){const{photo:e,video:t,sticker:s,document:a}=(0,d.qp)(o);e&&n.content.photo?(n.content.photo.blobUrl=e.blobUrl,n.content.photo.thumbnail=e.thumbnail):t&&n.content.video?n.content.video.blobUrl=t.blobUrl:s&&n.content.sticker?n.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:a&&n.content.document&&(n.content.document.previewBlobUrl=a.previewBlobUrl)}return a?(0,r.P4)(e,t,s,n):(0,r.cY)(e,t,s,n)}function te(e,t,s,n){const{chatId:a}=s,{threadInfo:o}=(0,i.Db)(e,a,s)||{};if(!o&&s.replyToMessageId){const o=(0,i.hj)(e,a,s.replyToMessageId);o?e=(0,r.lG)(e,o,a,s.id,n):t.loadMessage({chatId:a,messageId:s.replyToMessageId,threadUpdate:{isDeleting:n,lastMessageId:s.id}})}return e}function se(e,t,s){const{id:n,chatId:a}=s,{threadInfo:o,firstMessageId:c}=(0,i.Db)(e,a,s)||{},l=(0,i.Z1)(e,a),h=(null==l?void 0:l.unreadCount)&&!(0,i.gb)(e,a,u._f);if(e=te(e,t,s),o&&(!c&&(0,d.CI)(s)||(e=(0,r.xj)(e,a,o.threadId,[n]),(0,i.b9)(e,a,o.threadId)&&(e=(0,r.$S)(e,a,o.threadId,n),c||(e=(0,r.pf)(e,a,o.threadId,"firstMessageId",s.id)))),e=(0,r.pf)(e,a,o.threadId,"threadInfo",{...o,lastMessageId:s.id,messagesCount:o.messagesCount+1})),h)return e;if(e=(0,r.xj)(e,a,u._f,[n]),(0,i.b9)(e,a,u._f)){const t=(0,i.It)(e,a,u._f),s=(0,r.$S)(e,a,u._f,n),o=(0,i.Cb)(s,a,u._f);t&&!o.includes(t)||(e=s)}return e}function ne(e,t,s,n=!1){var a;const{chats:o}=e,i=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!i||n||i.id===s.id||i.id===s.previousLocalId||s.id>i.id?(0,r.a4)(e,t,{lastMessage:s}):e}function ae(e,t){const s=(0,i.Zw)(e,t),n=(0,i.gb)(e,t,u._f);if(!s||!n)return;let a=n.length;for(;a--;){const e=s[n[a]];if(!e.isDeleting)return e}}function oe(e,t,s,a){if(e){t.forEach((t=>{const s=ae(a=(0,r.cY)(a,e,t,{isDeleting:!0}),e);s&&(a=ne(a,e,s,!0))})),(0,n.R3)(a),s.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const n=(0,i.hj)(a,e,t);if(!n)return;a=te(a,s,n,!0);const{threadInfo:r}=(0,i.Db)(a,e,n)||{};r&&o.push(r.threadId)})),(0,n.R3)(a),void setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{s.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),J)}const o=[];t.forEach((e=>{const t=(0,i.X5)(a,e);if(t){o.push(t);const s=ae(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);s&&(a=ne(a,t,s,!0)),setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),t,[e]))}),J)}})),(0,n.R3)(a),(0,g.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:o,id:c,message:l,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,n.R3)(e);const m=(0,i.hj)(e,o,c);if((0,i.hg)(e,o,l)){var a;if(l.isOutgoing&&(null===(a=l.content)||void 0===a||!a.action)){const s=(0,i.Bt)(e);s&&t.focusMessage({chatId:o,threadId:s.threadId,messageId:l.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:s}=(0,i.Db)(e,o,l)||{};s&&t.requestThreadInfoUpdate({chatId:o,threadId:s.threadId}),(0,d.CI)(l)||setTimeout((()=>{let e=(0,n.Rd)();h&&(e=(0,r.pf)(e,o,u._f,"replyingToId",c)),(0,n.R3)(ne(e,o,m))}),J)}else(0,n.R3)(ne((0,n.Rd)(),o,m));(0,i.N)(e,o)||t.loadTopChats();break}case"newScheduledMessage":{const{chatId:t,id:a,message:o}=s;e=ee(e,t,a,o,!0);const c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,a])),(0,n.R3)(e);break}case"updateMessage":{var o,c;const{chatId:a,id:d,message:l}=s;if(!(0,i.hj)(e,a,d))return;e=ee(e,a,d,l);const h=(0,i.hj)(e,a,d);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),e=ne(e,a,h),(0,n.R3)(e);const m=(0,i.Z1)(e,a);m&&!l.isOutgoing&&(null===(o=m.lastMessage)||void 0===o?void 0:o.id)===l.id&&(0,i.xo)(e,m)&&(0,i.hg)(e,a,l)&&(0,i.b9)(e,a,(null===(c=l.threadInfo)||void 0===c?void 0:c.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:o}=s;if(!(0,i.Tm)(e,t,a))return;e=ee(e,t,a,o,!0);const c=Object.keys((0,i.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,u._f,"scheduledIds",c),(0,n.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:o,message:c}=s;e=se(e,t,c);const d=(0,i.hj)(e,a,o);e=(0,r.K4)(e,a,[o]),c.isScheduled&&(e=(0,r.bV)(e,a,[o])),e=(0,r.cY)(e,a,c.id,{...d,...c,previousLocalId:o});const l=(0,i.hj)(e,a,c.id);e=ne(e,a,l);const u=(0,i.Db)(e,a,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,n.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:o}=s,c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const d=(0,i.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:a}),(0,n.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:o}=s,c=(0,i.KB)(e,t)||[],d=a?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,n.R3)((0,r.pf)(e,t,u._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:o,firstMessageId:c}=s,d={...(0,i.tZ)(e,t,a),...o};if(!d.threadId)return;e=(0,r.Xg)(e,t,a,d),c&&(e=(0,r.pf)(e,t,a,"firstMessageId",c)),(0,n.R3)(e);break}case"resetMessages":{const{id:a}=s,o=(0,i.Zw)(e,a);o&&!(0,d.YA)(a)&&(e=(0,r.K4)(e,a,Object.keys(o).map(Number)),(0,n.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:n,chatId:a}=s;oe(a,n,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:a}=s;!function(e,t,s,a){e&&(t.forEach((t=>{a=(0,r.P4)(a,e,t,{isDeleting:!0})})),(0,n.R3)(a),setTimeout((()=>{a=(0,r.bV)((0,n.Rd)(),e,t);const s=(0,i.Fn)(a,e);a=(0,r.pf)(a,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,n.R3)(a)}),J))}(a,t,0,e);break}case"deleteHistory":{const{chatId:n}=s,a=e.messages.byChatId[n];a?oe(n,Object.keys(a.byId).map(Number),t,e):t.requestChatUpdate({chatId:n});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=s;t.forEach((t=>{const s=(0,i.X5)(e,t);s&&(e=(0,r.cY)(e,s,t,a))})),(0,n.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:o}=s;a.forEach((s=>{e=(0,r.cY)(e,t,s,o)})),(0,n.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=s,o=(0,i.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...a},{results:s}=t.results||{};if(s&&!s.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,n=e&&e.filter((e=>e.isChosen));n&&n.forEach((e=>{const n=s.findIndex((t=>t.option===e.option));n>=0&&(t.results.results[n].isChosen=!0)}))}(0,n.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:o}=s,c=(0,i.ZB)(e,t);if(!c||!c.content.poll||!c.content.poll.results)break;const{poll:d}=c.content,{recentVoterIds:l,totalVoters:u,results:h}=d.results,m=l?[...l]:[],g=u?u+1:1,f=h?[...h]:[];m.push(a),o.forEach((t=>{const s=f.find((e=>e.option===t)),n=f.findIndex((e=>e.option===t)),o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,a===e.currentUserId&&(o.isChosen=!0),n?f[n]=o:f.push(o)})),(0,n.R3)((0,r.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...d,results:{...d.results,recentVoterIds:m,totalVoters:g,results:f}}}}));break}case"updateServiceNotification":{const{message:n}=s;(0,i.UW)(e)&&t.createServiceNotification({message:n});break}}}));const re=(0,w.P2)((function(){let e=(0,n.Rd)();ie.forEach((([t,s])=>{e=(0,r.Nq)(e,t,{status:s})})),(0,n.R3)(e),ie=[]}),3e3,!0);let ie=[];(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteUser":return(0,r.h8)(e,s.id);case"updateUser":return(0,r.Nq)(e,s.id,s.user);case"updateUserStatus":return n=s.userId,a=s.status,ie.push([n,a]),void re();case"updateUserFullInfo":{const{id:t,fullInfo:n}=s,a=e.users.byId[t];if(!a)return;return(0,r.Nq)(e,t,{fullInfo:{...a.fullInfo,...n}})}}var n,a})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateStickerSet":return(0,r.Rg)(e,s.id,s.stickerSet)}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,r.O4)((0,n.Rd)(),s.id):(0,r.rB)((0,n.Rd)(),s.id);case"updateResetContactList":(0,n.R3)({...(0,n.Rd)(),contactList:{hash:0,userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[s.key]=s.rules}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,r.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:a,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,n.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:o,shouldShowPreviews:i}));break}}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:s.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:s.message}}}}));var ce=s(8674),de=s(6752),le=s(1279),ue=s(1212),he=s(5332);function me(e){(0,o.d4)((()=>(0,w.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),we=s(2255);function Pe(){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,n.c$)((e=>{const{query:t,fetchingStatus:s,chatId:n,date:a}=e.globalSearch,{currentUserId:o}=e,{byId:r}=e.chats,{animationLevel:c}=e.settings.byKey;return{searchQuery:t,isLoading:!!s&&Boolean(s.chats||s.messages),currentUserId:o,chatsById:r,globalSearchChatId:n,searchDate:a,theme:(0,i.Pu)(e),animationLevel:c}}),((e,t)=>(0,g.ei)(t,["openChat","openTipsChat","setGlobalSearchDate","setGlobalSearchChatId","setSettingOption"])))((({content:e,contactsFilter:t,onSearchQuery:s,onSelectSettings:n,onSelectContacts:r,onSelectArchived:i,setGlobalSearchChatId:c,onReset:l,searchQuery:u,isLoading:g,shouldSkipTransition:f,currentUserId:p,globalSearchChatId:I,searchDate:v,theme:y,animationLevel:C,chatsById:Z,openChat:w,openTipsChat:P,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)((()=>{w({id:p,shouldReplaceHistory:!0})}),[p,w]),L=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";M({theme:t}),M({shouldUseSystemTheme:!1}),(0,Me.Z)(t,C===a.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:`${a.iC} alpha ${a.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:n},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:()=>{P({langCode:S.code})}},S("TelegramFeatures")),o.ZP.createElement(Ee.Z,{icon:"bug",href:a.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,n.c$)((e=>{const{chats:{byId:t},users:{byId:s},chatFolders:{byId:n,orderedIds:a,activeChatFolder:o},currentUserId:r,lastSyncTime:c,shouldSkipHistoryAnimations:d}=e;return{chatsById:t,usersById:s,chatFoldersById:n,orderedFolderIds:a,lastSyncTime:c,notifySettings:(0,i.dZ)(e),notifyExceptions:(0,i.NJ)(e),activeChatFolder:o,currentUserId:r,shouldSkipHistoryAnimations:d}}),((e,t)=>(0,g.ei)(t,["loadChatFolders","setActiveChatFolder","openChat"])))((({chatsById:e,usersById:t,chatFoldersById:s,notifySettings:n,notifyExceptions:a,orderedFolderIds:r,activeChatFolder:i,currentUserId:c,lastSyncTime:l,shouldSkipHistoryAnimations:u,foldersDispatch:h,onScreenSelect:f,loadChatFolders:p,setActiveChatFolder:I,openChat:v})=>{const y=(0,o.sO)(null),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]),P=((e,t,s)=>{const n=((e,t=!1)=>(0,o.Ye)((()=>(0,w.P2)((e=>e()),e,!t)),[e,t]))(t,!0),[a,r]=(0,o.eJ)(),[i,c,d]=(0,Ze.Z)();return(0,ce.ZP)(c,d),(0,ge.Z)((()=>{i||n((()=>{r(e())}))}),s.concat([i])),a})((()=>{if(!Z||!Z.length)return;const s=Object.keys(e).map(Number),o=Z.map((o=>{const{unreadDialogsCount:r,hasActiveDialogs:i}=(0,d.Fu)(e,t,o,s,n,a)||{};return{id:o.id,badgeCount:r,isBadgeActive:i}}));return(0,g.ee)(o,"id")}),3e3,[Z,e,t,n,a]),b=(0,o.Ye)((()=>{if(Z&&Z.length)return[{title:"en"===C.code?"All":C("FilterAllChats")},...Z.map((e=>({title:e.title,...null==P?void 0:P[e.id]})))]}),[Z,P,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(we.Z,{ref:y,name:u?"none":C.isRtl?"slide-reversed":"slide",activeKey:i,renderCount:b?b.length:void 0},R))})));var $e=s(9203),Qe=s(8778),qe=s(4288);const Ge=(0,o.X$)((e=>{const t=(0,Qe.Z)($e.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),He=(0,o.X$)((e=>{const t=(0,Qe.Z)($e.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:n})=>{const[a,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{e||r(!1)}),[e]);const i=(0,be.Z)(),c=(0,de.Z)("NewChatButton",e&&"revealed",a&&"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:a?"active":"",onClick:()=>{r(!a)},ariaLabel:i(a?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(je.Z,{isOpen:a,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:n},i("NewGroup")),o.ZP.createElement(Ee.Z,{icon:"user",onClick:t},i("NewMessageTitle"))))}));var We=s(126);const ze=Object.keys(h.du).length/2;let Ye;const Xe=(0,n.c$)((e=>(0,g.ei)(e,["connectionState"])))((({content:e,searchQuery:t,searchDate:s,contactsFilter:n,shouldSkipTransition:a,foldersDispatch:r,onSearchQuery:i,onContentChange:c,onScreenSelect:d,onReset:l,connectionState:u})=>{const[g,f]=(0,o.eJ)(m.$b),p=!Pe()||"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]),w=(0,o.I4)((()=>{c(h.du.Archived)}),[c]),P=(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:n}=(0,ue.Z)(e);return[s,n,()=>{window.location.reload()}]}(),k=(0,be.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:m.$b?void 0:P,onMouseLeave:m.$b?void 0:b},o.ZP.createElement(xe,{content:e,contactsFilter:n,onSearchQuery:i,onSelectSettings:v,onSelectContacts:y,onSelectArchived:w,onReset:l,shouldSkipTransition:a}),o.ZP.createElement(We.Z,{isOpen:p,isCustom:!0,className:"connection-state-wrapper opacity-transition slow"},(()=>o.ZP.createElement(Ae,null))),o.ZP.createElement(we.Z,{name:a?"none":"zoom-fade",renderCount:ze,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:h.du.ChatList,className:p?"pull-down":void 0},(a=>{switch(e){case h.du.ChatList:return o.ZP.createElement(De,{onScreenSelect:d,foldersDispatch:r});case h.du.GlobalSearch:return o.ZP.createElement(Ge,{searchQuery:t,searchDate:s,isActive:a,onReset:l});case h.du.Contacts:return o.ZP.createElement(He,{filter:n,isActive:a,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,Qe.Z)($e.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Je=(0,o.X$)((e=>{const t=(0,Qe.Z)($e.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),et=(0,o.X$)((e=>{const t=(0,Qe.Z)($e.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,nt=(0,o.X$)((0,n.c$)((e=>{const{globalSearch:{query:t,date:s},chatFolders:{activeChatFolder:n},shouldSkipHistoryAnimations:a,leftColumnWidth:o}=e;return{searchQuery:t,searchDate:s,activeChatFolder:n,shouldSkipHistoryAnimations:a,leftColumnWidth:o}}),((e,t)=>(0,g.ei)(t,["setGlobalSearchQuery","setGlobalSearchChatId","resetChatCreation","setGlobalSearchDate","loadPasswordInfo","clearTwoFaError","setLeftColumnWidth","resetLeftColumnWidth"])))((({searchQuery:e,searchDate:t,activeChatFolder:s,shouldSkipHistoryAnimations:n,leftColumnWidth:a,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,w]=(0,o.eJ)(""),[P,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.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),w(""),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})):w(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,n)=>{const[a,r,i]=(0,Ze.Z)(),[c,d]=(0,o.eJ)(),[l,u]=(0,o.eJ)();(0,o.d4)((()=>{e.current&&n&&(e.current.style.width=`${n}px`)}),[e,n]);const h=()=>{document.body.classList.remove("no-selection","cursor-ew-resize")};return(0,o.d4)((()=>{if(!a)return;const s=t=>{const s=Math.ceil(l+t.clientX-c);e.current.style.width=`${s}px`},n=()=>{h(),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",n,!1),document.removeEventListener("blur",n,!1),t(e.current.offsetWidth),i()};document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",n,!1),document.addEventListener("blur",n,!1)}),[l,c,e,t,a,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,a),x=e=>{v(h.du.Settings),C(e)};return o.ZP.createElement("div",{id:"LeftColumn",ref:p},o.ZP.createElement(we.Z,{name:n?"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:P,foldersDispatch:b,onScreenSelect:x,onReset:k,shouldSkipTransition:n});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:n})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:T,onMouseUp:B,onDoubleClick:N}))})));var at=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,w.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,Qe.Z)($e.gl.Extra,"HeaderMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),yt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{const a=(0,i.Z1)(e,t),o=Boolean(a&&(0,d.eA)(a));if(null!=a&&a.isRestricted||(0,i.CA)(e))return{noMenu:!0};const r=(0,i.IK)(e,t),c=(0,i.FM)(e,t),l="thread"===n&&s===u._f,h="thread"===n&&s!==u._f,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&&a&&(o||(0,d.ZV)(a))&&a.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:n,canStartBot:a,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canLeave:l,isRightColumnShown:u,joinChannel:h,sendBotCommand:g,openLocalTextSearch:f,restartBot:p})=>{const I=(0,o.sO)(null),[v,y]=(0,o.eJ)(!1),[C,Z]=(0,o.eJ)(void 0),w=(0,o.I4)((()=>{y(!0);const e=I.current.getBoundingClientRect();Z({x:e.right,y:e.bottom})}),[]),P=(0,o.I4)((()=>{y(!1)}),[]),b=(0,o.I4)((()=>{Z(void 0)}),[]),M=(0,o.I4)((()=>{h({chatId:e})}),[h,e]),S=(0,o.I4)((()=>{g({command:"/start"})}),[g]),E=(0,o.I4)((()=>{p({chatId:e})}),[e,p]),k=(0,o.I4)((()=>{f(),m.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[f]),R=(0,be.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!m.wB&&i&&o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:M},R(n?"Subscribe":"Join Group")),!m.wB&&a&&o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:S},R("BotStart")),!m.wB&&r&&o.ZP.createElement(ke.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:E},R("BotRestart")),!m.wB&&c&&o.ZP.createElement(ke.Z,{round:!0,ripple:u,color:"translucent",size:"smaller",onClick:k,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),o.ZP.createElement(ke.Z,{ref:I,className:v?"active":"",round:!0,ripple:!m.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:w},o.ZP.createElement("i",{className:"icon-more"})),C&&o.ZP.createElement(vt,{chatId:e,threadId:t,isOpen:v,anchor:C,isChannel:n,canStartBot:a,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canLeave:l,onSubscribeChannel:M,onSearchClick:k,onClose:P,onCloseAnimationEnd:b}))})));var Ct=s(4399),Zt=s(2340),wt=s(6202),Pt=s(862);function bt(e){var t;const s=e&&(0,d.DH)(e),n=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,r=s&&n&&!(0,m.on)()&&s.includes("image/webp"),[i,c]=(0,o.eJ)(Pt.Hu),l=null==e?void 0:e.id;return(0,o.bt)((()=>{r&&(0,Pt.p6)(`b64-${l}`,s).then(c).catch((e=>{a.eM&&console.error(e)}))}),[l,r,s]),r?i:s}var Mt=s(7551),St=s(8512);function Et(e,t,s,n,a){return`M${e},${t+a}a${a},${a},0,0,1,\n ${s},0v${n-2*a}a${a},${a},0,0,1,${-s},0Z`}const kt=(0,o.X$)((({count:e,index:t})=>{const s=(0,o.sO)(null),n=(0,o.Ye)((()=>function(e,t){const s=e-t-1,n=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),a=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,n),r=`clipPath${e}`;return{markHeight:a,clipPath:function(e,t,s){let n="";if(3===s)n=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++)n+=Et(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${n}" />\n </clipPath>`}(r,n,e),markTranslateY:function(e,t,s){return 1===s?0:2===s?0===e?0:t+2:3===s?0===e?0:1===e?12:25:(t+2)*e}(s,n,e),trackTranslateY:function(e,t,s,n){return t<=4||e<=1?0:e>=t-2?n-36:(s+4)/2+(e-2)*(s+2)}(s,e,n,o),trackHeight:o,clipPathId:r}}(e,t)),[e,t]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:a,markTranslateY:o,clipPathId:r,clipPath:i}=n,c=s.current.firstElementChild;if(null!=s&&s.current){const n=s.current,{style:d}=n;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${r}")`;const l=n.querySelector("svg"),u=n.querySelector("div"),h=n.querySelector("defs");l||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${i} </defs></svg>`),h&&(h.innerHTML=i),u&&(u.style.height=`${a}px`,u.style.transform=`translateY(${o}px)`)}}),[n]),1===e)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:a,trackTranslateY:r,markHeight:i,markTranslateY:c,clipPathId:d}=n;return o.ZP.createElement("div",{className:(0,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: ${a}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${i}px; transform: translateY(${c}px);`})))})),Rt=(0,o.X$)((({message:e,count:t,index:s,customTitle:n,className:a,onUnpinMessage:r,onClick:i,onAllPinnedClick:c})=>{const l=(0,be.Z)(),u=bt(e),h=(0,wt.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",a)},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:n}=(0,Ct.W7)();return o.ZP.createElement("img",{src:t||e,width:s,height:n,alt:""})}(u,h),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},n||`${l("PinnedMessage")} ${s>0?"#"+(t-s):""}`),o.ZP.createElement("p",{dir:"auto"},(0,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 n=e instanceof Blob?URL.createObjectURL(e):e,a=new Image;return new Promise((o=>{a.onload=()=>{At(a,a.width*t,a.height*t,s).then((e=>URL.createObjectURL(e))).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(n)}))},a.src=n}))}async function At(e,t,s,n="image/png"){if(!("createImageBitmap"in window))return Ot(e,t,s,void 0,n);try{const a=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:s,resizeQuality:"high"});if(a.height!==s||a.width!==t)throw new Error("Image bitmap resize not supported!");return await new Promise((e=>{const t=document.createElement("canvas");t.width=a.width,t.height=a.height;const s=t.getContext("bitmaprenderer");s?s.transferFromImageBitmap(a):t.getContext("2d").drawImage(a,0,0),t.toBlob(e,n)}))}catch(a){return Ot(e,t,s,void 0,n)}}function Ot(e,t,s,n=.5,a="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*n>t){const s=1/n;let a={width:Math.floor(e.width*n),height:Math.floor(e.height*n)};for(i.width=a.width,i.height=a.height,c.drawImage(e,0,0,a.width,a.height);a.width*n>t;)a={width:Math.floor(a.width*n),height:Math.floor(a.height*n)},c.drawImage(i,0,0,a.width*s,a.height*s,0,0,a.width,a.height);r.drawImage(i,0,0,a.width,a.height,0,0,o.width,o.height)}else r.drawImage(e,0,0,o.width,o.height);return new Promise((e=>{o.toBlob(e,a)}))}var Ft=s(4524);const Ut={width:200,height:200},Dt=115,$t=(e,t,s)=>{const{audio:n,voice:a}=(0,d.qp)(e),r=n?n.title||n.fileName:a?"Voice message":"",i=n&&n.performer||t&&(0,d.OU)(Bt.i0,t),c=s&&(0,d.U)(Bt.i0,s)||"Telegram",l=n&&(0,d.MR)(n)&&(0,d.Ti)(e,"pictogram"),u=t&&(0,d.RT)(t,"big"),h=n&&l||a&&u,m=(0,wt.Z)(h),g=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}(n,a,m),{result:f}=((e,t,s)=>{const[n,a]=(0,o.eJ)(!1),[r,i]=(0,o.eJ)(),[c,d]=(0,o.eJ)(s);return(0,o.d4)((()=>{a(!0);let e=!1;return function(e,t){if(!e)return Promise.resolve(Ft);if(!t)return function(e,t,s,n="image/png"){const a=e instanceof Blob?URL.createObjectURL(e):e,o=new Image;return new Promise((r=>{o.onload=()=>{At(o,t,s,n).then((e=>URL.createObjectURL(e))).then(r).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},o.src=a}))}(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||(a(!1),d(t))}),(t=>{e||(a(!1),i(t))})),()=>{e=!0}}),t),{isLoading:n,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 Qt=s(396);const qt=(0,n.c$)(((e,{message:t})=>({sender:(0,i.Ur)(e,t),chat:(0,i.Z1)(e,t.chatId)})),((e,t)=>(0,g.ei)(t,["focusMessage","closeAudioPlayer"])))((({message:e,origin:t=h.Cr.Inline,className:s,noUi:n,sender:a,focusMessage:r,closeAudioPlayer:i,chat:c})=>{const l=(0,be.Z)(),{audio:u,voice:g}=(0,d.qp)(e),f=Boolean(g),p=a?(0,d.OU)(l,a):void 0,I=Tt.UV((0,d.Ti)(e,"inline")),v=$t(e,a,c),{playPause:y,stop:C,isPlaying:Z}=(0,Nt.Z)((0,Qt.An)(e),(0,d.XV)(e),f?"voice":"audio",t,I,void 0,v,void 0,!0,void 0,void 0,!0),w=(0,o.I4)((()=>{r({chatId:e.chatId,messageId:e.id})}),[r,e.chatId,e.id]),P=(0,o.I4)((()=>{Z&&y(),i(),(0,xt.Ay)(),C()}),[i,Z,y,C]);if(!n)return o.ZP.createElement("div",{className:(0,de.Z)("AudioPlayer",s),dir:l.isRtl?"rtl":void 0},o.ZP.createElement(ke.Z,{round:!0,ripple:!m.wB,color:"translucent",size:"smaller",className:(0,de.Z)("toggle-play",Z?"pause":"play"),onClick:y,ariaLabel:Z?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:w},u?function(e){const{title:t,performer:s,fileName:n}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,Zt.Z)(t||n)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Zt.Z)(s)))}(u):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))}(l("AttachAudio"),p),o.ZP.createElement(St.Z,null)),o.ZP.createElement(ke.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:P,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))})),Gt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{const{isLeftColumnShown:a,lastSyncTime:o,shouldSkipHistoryAnimations:r}=e,{byId:c}=e.chats,d=(0,i.Z1)(e,t),{typingStatus:l}=d||{},{chatId:h,messageId:m}=e.audioPlayer,g=h&&m?(0,i.hj)(e,h,m):void 0;let f;if("pinned"===n){const s=(0,i.KB)(e,t);f=null==s?void 0:s.length}else if("scheduled"===n){const s=(0,i.qy)(e,t);f=null==s?void 0:s.length}else if("thread"===n&&s!==u._f){const n=(0,i.tZ)(e,t,s);f=(null==n?void 0:n.messagesCount)||0}const p={typingStatus:l,isLeftColumnShown:a,isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),audioMessage:g,chat:d,chatsById:c,messagesCount:f,isChatWithSelf:(0,i.FM)(e,t),isChatWithBot:d&&(0,i.xo)(e,d),lastSyncTime:o,shouldSkipHistoryAnimations:r,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState},I=(0,i.Zw)(e,t);if("thread"!==n||!I)return p;if(Object.assign(p,{messagesById:I}),s!==u._f){const n=(0,i.qS)(e,t,s),a=n?(0,i.hj)(e,t,n):void 0,o=a?(0,i.cv)(e,a):void 0;return{...p,pinnedMessageIds:n,canUnpin:!1,topMessageSender:o}}const v=(0,i.KB)(e,t);if(null!=v&&v.length){const t=I[v[0]],{canUnpin:n}=t&&(0,i._k)(e,t,s)||{};return{...p,pinnedMessageIds:v,canUnpin:n}}return p}),((e,t)=>(0,g.ei)(t,["openChatWithInfo","pinMessage","focusMessage","openChat","openPreviousChat","loadPinnedMessages","toggleLeftColumn","exitMessageSelectMode"])))((({chatId:e,threadId:t,messageListType:s,isReady:r,pinnedMessageIds:c,messagesById:l,canUnpin:h,topMessageSender:g,typingStatus:f,isSelectModeActive:p,isLeftColumnShown:I,isRightColumnShown:v,audioMessage:y,chat:C,chatsById:Z,messagesCount:w,isChatWithSelf:P,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,$]=(0,o.eJ)(0),Q=Array.isArray(c)?c[D]:c,q=l&&Q?l[Q]:void 0,G=Array.isArray(c)?c.length:c?1:void 0,H=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)((()=>{$(0)}),[c]),(0,mt.Z)(e,Q,q);const{width:_}=ct(),V=_<=a.ks,W=m.p7&&I,z=(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)(G||1,D+1);$(e)}}),[q,N,t,G,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(a.R2);e&&e.blur()}if(p)return O(),void te();if(t===u._f&&"thread"===s&&0===E)return m.wB||W?(e.stopPropagation(),B({id:void 0})):A(),void te();x(),te()}}),[t,s,E,p,x,W,B,A,O,te]),ne=(0,o.Ye)((()=>{if(V&&Z)return(0,i.A1)((0,n.Rd)())||void 0}),[V,Z]),ae=_>=a.ks&&_<a.jT||_>a.l3&&_<a.ks&&(!H||H>30),oe=ae||_>a._m&&_<a.QU,{shouldRender:re,transitionClassNames:ie}=(0,ue.Z)(Boolean(y)),ce=(0,gt.Z)(y),{shouldRender:le,transitionClassNames:he}=(0,ue.Z)(q&&!re),me=(0,gt.Z)(q,!0),ge=(0,gt.Z)(G,!0),fe=(0,gt.Z)(h,!0),pe=(0,gt.Z)(j),Ie=le&&me||re&&ce;(0,o.d4)((()=>{const e=z.current;if(e)return oe&&Ie?void(v||ae?(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,ae,v]);const ve=(!Pe()||"connectionStateConnecting"===k)&&(m.wB||m.p7&&!W);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(W,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:X},(0,d.YA)(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",w,"i"))):"pinned"===s?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",w,"i"))):"scheduled"===s?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,P?F("Reminders"):F("messages",w,"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:e?"Close":"Back"},o.ZP.createElement("div",{className:(0,de.Z)("animated-close-icon",!e&&"state-back")})),t&&ne&&o.ZP.createElement("div",{className:"unread-count active"},(0,ft.bi)(ne)))}return o.ZP.createElement("div",{className:"MiddleHeader",ref:z},o.ZP.createElement(we.Z,{name:S?"none":"slide-fade",activeKey:ve?1/0:E},ye),o.ZP.createElement("div",{className:"header-tools"},le&&me&&!re&&o.ZP.createElement(Rt,{key:e,message:me,count:ge||0,index:D,customTitle:pe,className:he,onUnpinMessage:fe?K:void 0,onClick:J,onAllPinnedClick:ee}),re&&ce&&o.ZP.createElement(qt,{key:(0,d.Tp)(ce),message:ce,className:ie}),o.ZP.createElement(yt,{chatId:e,threadId:t,messageListType:s})))})));var Ht=s(2645),jt=s(274);function _t(e){return"albumId"in e}function Vt(e,t){let s,n=[],a={originalDate:e[0].date,datetime:Number((0,U.$Y)(1e3*e[0].date)),senderGroups:[n]};const o=[a];return e.forEach(((r,i)=>{r.isInAlbum?s?(s.messages.push(r),r.content.text&&(s.mainMessage=r)):s={albumId:r.groupedId,messages:[r],mainMessage:r}:n.push(r);const c=e[i+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(n.push(s),s=void 0),c){const e=Number((0,U.$Y)(1e3*c.date));a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},o.push(a),n=[],a.senderGroups.push(n)):(c.id===t||r.senderId!==c.senderId||r.isOutgoing!==c.isOutgoing||(0,d.Lo)(r)||(0,d.Lo)(c)||r.forwardInfo&&c.forwardInfo&&(r.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||r.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||r.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||r.inlineButtons||c.inlineButtons||c.date-r.date>600)&&(n=[],a.senderGroups.push(n))}})),o}var Wt=s(386);var zt=s(7675),Yt=s(539),Xt=s(3657);const Kt=m.wZ?1e3:350,Jt=m.wB?300:500;var es=s(7240),ts=s(935);function ss(e){return"number"==typeof e}function ns(e,t){return e?t?238:175:t?238:100}function as(e,t){const s=(0,d.B4)(e),n=(0,d.MF)(e),a=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),r=Boolean((0,d.F$)(e)),{width:i,height:c}=a?(0,Ct.Eh)(a,s,n,r,t):(0,Ct.GC)(o,s,n,t),l=ns(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 os(e,t){return e.reduce(((e,t)=>e+t),t)}function rs(e,t,s){return e<t?t:e>s?s:e}function is(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 cs(e,t,s,n){const a=n.messages.map((e=>{const t=as(e);return t.width/t.height})),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),i=a.length,c=a.some((e=>e>2)),d=(0,Ct.kc)(e,t,!1,s)-(t?2.5:0)*Ct.Gw;let l;const u={ratios:a,proportions:o,averageRatio:r,maxWidth:d,minWidth:100,maxHeight:d,spacing:2};return l=i>=5||c?function({ratios:e,averageRatio:t,maxWidth:s,minWidth:n,spacing:a,maxHeight:o=4*s/3}){const r=function(e,t){return e.map((e=>t>1.1?rs(e,1,2.75):rs(e,.6667,1)))}(e,t),i=e.length,c=new Array(i),d=[],l=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=os(r.slice(e,e+t),0);return(s-(t-1)*a)/n})(n,e)),n+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==i;++e){const t=i-e;e<=3&&t<=3&&l([e,t])}for(let e=1;e!==i-1;++e)for(let s=1;s!==i-e;++s){const n=i-e-s;e<=3&&s<=(t<.85?4:3)&&n<=3&&l([e,s,n])}for(let e=1;e!==i-1;++e)for(let t=1;t!==i-e;++t)for(let s=1;s!==i-e-t;++s){const n=i-e-t-s;e<=3&&t<=3&&s<=3&&n<=4&&l([e,t,s,n])}let u,h=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:s}=d[e],r=s.length,i=os(t,0)+a*(r-1),c=Math.min(...t)<n?1.5:1,l=(()=>{for(let e=1;e!==r;++e)if(s[e-1]>s[e])return 1.5;return 1})(),m=Math.abs(i-o)*c*l;(!u||m<h)&&(u=d[e],h=m)}const m=u.lineCounts,g=u.heights,f=m.length;let p=0,I=0;for(let e=0;e!==f;++e){const t=m[e],n=g[e],o=Math.round(n);let i=0;for(let d=0;d!==t;++d){const l=0|(0===e?1:0)|(e===f-1?4:0)|(0===d?8:0)|(d===t-1?2:0),u=r[p],h=d===t-1?s-i:Math.round(u*n);c[p]={dimensions:{x:i,y:I,width:h,height:o},sides:l},i+=h+a,++p}I+=o+a}return c}(u):2===i?function(e){const{ratios:t,proportions:s,averageRatio:n}=e;return"ww"===s&&n>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(a-n)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:11},{dimensions:{x:0,y:o+n,width:s,height:o},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=(s-n)/2,r=Math.round(Math.min(o/t[0],Math.min(o/t[1],a)));return[{dimensions:{x:0,y:0,width:o,height:r},sides:13},{dimensions:{x:o+n,y:0,width:o,height:r},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:n,spacing:a,maxHeight:o}=e,r=Math.round(1.5*s),i=Math.min(Math.round(Math.max(.4*(n-a),(n-a)/t[0]/(1/t[0]+1/t[1]))),n-a-r),c=n-i-a,d=Math.min(o,Math.round(Math.min(c/t[0],i/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:13},{dimensions:{x:c+a,y:0,width:i,height:d},sides:7}]}(e)}(u):3===i?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:n,maxWidth:a,minWidth:o}=e,r=t,i=Math.round(Math.min((t-s)/2,n[1]*(a-s)/(n[2]+n[1]))),c=r-i-s,d=Math.max(o,Math.round(Math.min((a-s)/2,Math.min(i*n[2],c*n[1])))),l=Math.min(Math.round(r*n[0]),a-s-d);return[{dimensions:{x:0,y:0,width:l,height:r},sides:13},{dimensions:{x:l+s,y:0,width:d,height:c},sides:3},{dimensions:{x:l+s,y:c+s,width:d,height:i},sides:6}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:n,spacing:a}=e,o=t,r=Math.round(Math.min(o/s[0],.66*(n-a))),i=(t-a)/2,c=Math.min(n-r-a,Math.round(Math.min(i/s[1],i/s[2])));return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+a,width:i,height:c},sides:12},{dimensions:{x:i+a,y:r+a,width:o-i-a,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:n,minWidth:a}){const o=e,r=Math.round(Math.min(o/t[0],.66*(n-s))),i=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(a,Math.round(Math.min(.4*(e-2*s),i*t[1]))),d=Math.round(Math.max(Math.max(a,.33*(e-2*s)),i*t[3])),l=o-c-d-2*s,u=Math.min(n-r-s,i);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:c,height:u},sides:12},{dimensions:{x:c+s,y:r+s,width:l,height:u},sides:4},{dimensions:{x:c+s+l+s,y:r+s,width:d,height:u},sides:6}]}(e):function({maxHeight:e,ratios:t,maxWidth:s,spacing:n,minWidth:a}){const o=e,r=Math.round(Math.min(o*t[0],.6*(s-n))),i=Math.round((e-2*n)/(1/t[1]+1/t[2]+1/t[3])),c=Math.round(i/t[1]),d=Math.round(i/t[2]),l=o-c-d-2*n,u=Math.max(a,Math.min(s-r-n,i));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+n,y:0,width:u,height:c},sides:3},{dimensions:{x:r+n,y:c+n,width:u,height:d},sides:2},{dimensions:{x:r+n,y:c+d+2*n,width:u,height:l},sides:6}]}(e)}(u),{layout:l,containerStyle:is(l)}}let ds;function ls(e){return ds||(ds=document.createElement("span"),ds.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',ds.style.whiteSpace="nowrap",ds.style.position="absolute",ds.style.left="-999px",ds.style.opacity=".01",document.body.appendChild(ds)),ds.innerHTML=e,ds.offsetWidth}function us(e,t,s,n,a,r){(0,o.bt)((()=>{if(s&&e.current){const t=e.current.closest(".MessageList");(0,Yt.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==n?1e3:void 0,n,void 0,r)}}),[e,t,s,n,a,r])}var hs=s(172),ms=s(2864);const gs=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"ContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),fs=(0,o.X$)((0,n.c$)(((e,{message:t})=>{const{byId:s}=e.users,n=t.senderId,{targetUserIds:a,targetChatId:o}=t.content.action||{},r=t.replyToMessageId,c=r?(0,i.hj)(e,t.chatId,r):void 0,l=(0,i._X)(e,t),{direction:u,noHighlight:h}=l&&e.focusedMessage||{},m=(0,i.Z1)(e,t.chatId);return{usersById:s,sender:m&&((0,d.eA)(m)||n===t.chatId)?m:n?(0,i.dy)(e,n):void 0,targetChatId:o,targetUserIds:a,targetMessage:c,isFocused:l,...l&&{focusDirection:u,noFocusHighlight:h}}}))((({message:e,observeIntersection:t,isEmbedded:s,appearanceOrder:n=0,isLastInList:a,usersById:r,sender:i,targetUserIds:c,targetMessage:d,targetChatId:l,isFocused:u,focusDirection:h,noFocusHighlight:m})=>{const g=(0,o.sO)(null);(0,Xt._N)(g,t),(0,mt.Z)(e.chatId,e.replyToMessageId,d),us(g,e.chatId,u,h,m);const f=(0,be.Z)(),p=n<=0,[I,v]=(0,Ze.Z)(p);(0,o.d4)((()=>{p||setTimeout(v,10*n)}),[n,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,ms.D)(f,e,i,C,d,l,s?{isEmbedded:!0,asPlain:!0}:void 0),{isContextMenuOpen:w,contextMenuPosition:P,handleBeforeContextMenu:b,handleContextMenu:M,handleContextMenuClose:S,handleContextMenuHide:E}=(0,es.Z)(g),k=void 0!==P;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",a&&"last-in-list",y);return o.ZP.createElement("div",{ref:g,id:`message${e.id}`,className:R,"data-message-id":e.id,onMouseDown:e=>{(0,Wt.q)(e),b(e)},onContextMenu:M},o.ZP.createElement("span",null,Z),P&&o.ZP.createElement(gs,{isOpen:w,anchor:P,message:e,messageListType:"thread",onClose:S,onCloseAnimationEnd:E}))}))),ps=({className:e,message:t,sender:s,title:n,customText:a,observeIntersection:r,onClick:i})=>{const c=(0,o.sO)(null),l=(0,Xt.Op)(c,r),u=(0,wt.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,n){const{width:a,height:r}=(0,Ct.W7)();return o.ZP.createElement("img",{id:e,src:s||t,width:a,height:r,alt:"",className:n?"round":""})}(h,m,u,g),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},t?(0,d.Lo)(t)?o.ZP.createElement(fs,{message:t,isEmbedded:!0}):(0,Zt.Z)((0,d.MK)(f,t,Boolean(m))):a||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Zt.Z)(p||n||" "))))};var Is=s(2535),vs=s(4752),ys=s(8018);const Cs=(0,o.X$)((({message:e,outgoingStatus:t,signature:s,onClick:n})=>{const a=(0,be.Z)();return o.ZP.createElement("span",{className:"MessageMeta",dir:a.isRtl?"rtl":"ltr",onClick:n},Boolean(e.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,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&&`${a("EditedMessage")} `,(0,U.mr)(1e3*e.date)),t&&o.ZP.createElement(ys.Z,{status:t}))}));var Zs=s(8835),ws=s(7799),Ps=s(4851);const bs=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:n,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===a.n,p=(0,Xt.Op)(i,t),I=(0,Xt.Op)(i,s),v=h.isPreloadedGlobally?`sticker${h.id}`:(0,d.Ti)(e,"inline"),y=bt(e),C=(0,wt.Z)(v,!p,(0,d.kG)(e,"inline",!0),r),Z=Boolean(C),[w,P]=(0,Ze.Z)(Z),b=m?w:Z,{shouldRenderFullMedia:M,transitionClassNames:S}=(0,Zs.Z)(b,"slow"),{width:E,height:k}=(0,Ct.Wr)(h),R=(0,de.Z)("thumbnail",!y&&"empty"),T=(0,de.Z)("Sticker media-inner",f&&"inactive");return o.ZP.createElement("div",{ref:i,className:T,onClick:f?void 0:l},!b&&o.ZP.createElement("img",{id:`sticker-thumb-${e.id}`,src:y,width:E,height:k,alt:"",className:R}),!m&&M&&o.ZP.createElement("img",{id:`sticker-${e.id}`,src:C,width:E,height:k,alt:"",className:(0,de.Z)("full-media",S)}),m&&Z&&o.ZP.createElement(ws.Z,{key:v,className:(0,de.Z)("full-media",S),id:v,animationData:C,size:E,play:I,noLoop:!n,onLoad:P}),o.ZP.createElement(Ps.Z,{isOpen:c,fromSticker:h,onClose:u}))};var Ms=s(7854),Ss=s(2566),Es=s(5866);function ks(e,t){return(0,Es.Z)((0,d.DH)(e),Boolean(t),m.wB&&!m.vX)}var Rs=s(7204);const Ts={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var Ns=s(9196);const Bs=({id:e,message:t,observeIntersection:s,noAvatars:n,shouldAutoLoad:a,isInSelectMode:r,isSelected:i,uploadProgress:c,size:l="inline",dimensions:u,nonInteractive:h,shouldAffectAppendix:m,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,Xt.Op)(v,s),[Z,w]=(0,o.eJ)(a),P=Z&&C,{mediaData:b,loadProgress:M}=(0,Ss.Z)((0,d.Ti)(t,l),!P),S=y||b,E=ks(t,S),{loadProgress:k}=(0,Ss.Z)((0,d.Ti)(t,"download"),!g),{isUploading:R,isTransferring:T,transferProgress:N}=(0,d.Sc)(t,c||(g?k:M),P&&!S),B=!1===(0,Rs.Z)(Z),{shouldRender:x,transitionClassNames:L}=(0,ue.Z)(T,void 0,B,"slow"),{shouldRenderThumb:A,shouldRenderFullMedia:O,transitionClassNames:F}=(0,Zs.Z)(S,"slow"),U=(0,o.I4)((()=>{R?I&&I(t):S?p&&p(t.id):w((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,n,a){return n?Promise.resolve(Ts[a||"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 n=document.createElement("canvas"),a=n.getContext("2d");n.width=s.width,n.height=s.height,a.drawImage(s,0,0,s.width,s.height);const o=t?s.width-1:0,r=s.height-1;return`rgba(${Array.from(a.getImageData(o,r,1,1).data).join(",")})`}(e,t)}(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:$,height:Q,isSmall:q}=u||as(t,n),G=(0,de.Z)("media-inner",!R&&!h&&"interactive",q&&"small-image",$===Q&&"square-image"),H=u?`width: ${$}px; height: ${Q}px; left: ${u.x}px; top: ${u.y}px;`:"";return o.ZP.createElement("div",{id:e,ref:v,className:G,style:H,onClick:R?void 0:U},A&&o.ZP.createElement("canvas",{ref:E,className:"thumbnail",style:`width: ${$}px; height: ${Q}px`}),O&&o.ZP.createElement("img",{src:S,className:`full-media ${F}`,width:$,height:Q,alt:""}),x&&o.ZP.createElement("div",{className:`media-loading ${L}`},o.ZP.createElement(Ns.Z,{progress:N,onClick:R?U:void 0})),!S&&!Z&&o.ZP.createElement("i",{className:"icon-download"}),T&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*N),"%"))};var xs=s(2019),Ls=s(4753);function As(e,t){const s=(0,o.sO)();s.current=t;const n=(0,o.I4)((()=>{e.current&&e.current.pause()}),[e]),a=(0,o.I4)((()=>{e.current&&s.current&&(0,Ls.Z)(e.current)}),[e]);(0,ce.ZP)(n,a)}var Os=s(6898);const Fs=(e,t=!1)=>{const s=(0,o.sO)(!1),n=(0,o.sO)(!1),a=(0,o.I4)((()=>{n.current=!0,t&&e.current&&(s.current||(s.current=!e.current.paused),e.current.pause())}),[t,e]),r=(0,o.I4)((()=>{t&&e.current&&s.current&&document.body.contains(e.current)&&(0,Ls.Z)(e.current),s.current=!1,n.current=!1}),[t,e]),i=(0,o.I4)((()=>{(0,w.T2)(r)}),[r]);document.hasFocus()||a(),(0,he.Z)(a,i)};function Us(){return(Us=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const Ds=({id:e,message:t,observeIntersection:s,noAvatars:a,shouldAutoLoad:r,shouldAutoPlay: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,Xt.Op)(I,s),[w,P]=(0,o.eJ)(r),b=Boolean(w&&Z&&l),[M,S]=(0,o.eJ)(i),E=(0,wt.Z)((0,d.Ti)(t,"pictogram"),!(Z&&l),(0,d.kG)(t,"pictogram"),l),{mediaData:k,loadProgress:R}=(0,Ss.Z)((0,d.Ti)(t,"inline"),!b,(0,d.kG)(t,"inline"),l),T=C||k,N=Boolean(Z&&T),B=ks(t,E),{loadProgress:x}=(0,Ss.Z)((0,d.Ti)(t,"download"),!f,u.IU.BlobUrl,l),{isBuffered:L,bufferingHandlers:A}=(0,xs.Z)(!r),{isUploading:O,isTransferring:F,transferProgress:D}=(0,d.Sc)(t,c||(f?x:R),b&&!L||f),$=!1===(0,Rs.Z)(w),{shouldRender:Q,transitionClassNames:q}=(0,ue.Z)(F,void 0,$),{transitionClassNames:G}=(0,Zs.Z)(T,"slow"),[H,j]=(0,o.eJ)(0),_=(0,o.I4)((e=>{j(Math.max(0,e.currentTarget.currentTime-1))}),[]),V=(null===(p=v.current)||void 0===p?void 0:p.duration)||y.duration||0,W=(0,d.B4)(t),z=(0,d.MF)(t),{width:Y,height:X}=h||(0,Ct.GC)(y,W,z,a);As(v,Boolean(N&&i)),Fs(v,M),(0,Os.Z)(v,[N]);const K=(0,o.I4)((()=>{O?g&&g(t):f?(0,n.uC)().cancelMessageMediaDownload({message:t}):T?T&&!M?(S(!0),v.current.play()):m&&m(t.id):P((e=>!e))}),[O,f,T,M,m,g,t]),J=(0,de.Z)("media-inner dark",!O&&"interactive"),ee=(0,de.Z)("full-media",G),te=h?`width: ${Y}px; height: ${X}px; left: ${h.x}px; top: ${h.y}px;`:"";return o.ZP.createElement("div",{ref:I,id:e,className:J,style:te,onClick:O?void 0:K},!E&&o.ZP.createElement("canvas",{ref:B,className:"thumbnail",style:`width: ${Y}px; height: ${X}px;`}),E&&o.ZP.createElement("img",{src:E,className:"thumbnail",style:`width: ${Y}px; height: ${X}px;`,alt:""}),N&&o.ZP.createElement("video",Us({ref:v,className:ee,width:Y,height:X,autoPlay:M,muted:!0,loop:!0,playsInline:!0},A,{onTimeUpdate:_}),o.ZP.createElement("source",{src:T})),w&&!M&&!Q&&o.ZP.createElement("i",{className:"icon-large-play"}),Q&&o.ZP.createElement("div",{className:`media-loading ${q}`},o.ZP.createElement(Ns.Z,{progress:D,onClick:K})),!w&&o.ZP.createElement("i",{className:"icon-download"}),F?o.ZP.createElement("span",{className:"message-transfer-progress"},O||f?`${Math.round(100*D)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},y.isGif?"GIF":(0,U.k9)(Math.max(V-H,0))))};var $s=s(6272);const Qs=(0,n.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:n})=>{const{firstName:a,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(hs.Z,{size:"large",user:t,text:a||r}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},a," ",r),o.ZP.createElement("div",{className:"contact-phone"},(0,$s.WZ)(n,i))))}));var qs=s(1218),Gs=s(4434),Hs=s(6937);function js(e,t){return t>0?(e/t*100).toFixed():0}const _s=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:n,correctResults:a,shouldAnimate:r})=>{const i=t&&t.find((t=>t.option===e.option)),c=0===a.length||-1!==a.indexOf(e.option),d=a.length>0&&c||(null==i?void 0:i.isChosen),l=i?js(i.votersCount,s||0):0,[u,h]=(0,o.eJ)(r?0:l),m=(0,o.sO)(null),g=i?js(i.votersCount,n||0):0,f=u<l;if((0,o.d4)((()=>{r&&h(l)}),[r,l]),(0,o.d4)((()=>{const e=m.current;if(e&&r){const t=e.firstElementChild,s=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",s):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${s}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[f,r]),!t||!i)return;const p=`width: ${g}%; transform:scaleX(${f?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===l?"limit-width":"")},l,"%",d&&o.ZP.createElement("span",{className:(0,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}))))},Vs=(0,o.X$)((0,n.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{serverTimeOffset:n,users:{byId:a}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:a,serverTimeOffset:n}:{}}),((e,t)=>(0,g.ei)(t,["loadMessage","openPollResults"])))((({message:e,poll:t,recentVoterIds:s,usersById:n,loadMessage:a,onSendVote:r,openPollResults:i,serverTimeOffset:c})=>{const{id:d,chatId:l}=e,{summary:u,results:h}=t,[m,g]=(0,o.eJ)(!1),[f,p]=(0,o.eJ)([]),[I,v]=(0,o.eJ)(!1),[y,C]=(0,o.eJ)(!1),[Z,w]=(0,o.eJ)(!u.closed&&u.closeDate&&u.closeDate>0?Math.min(u.closeDate-Math.floor(Date.now()/1e3)+c,u.closePeriod):0),P=(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((()=>w(Z-1)),1e3);const e=P.current;if(e){const t=12*Math.PI,s=e.lastElementChild,n=e.firstElementChild;if(Z<=5&&e.classList.add("hurry-up"),s&&n){const e=(u.closePeriod-Z)/u.closePeriod*t;n.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)&&a({chatId:l,messageId:d})}),[l,Z,S,a,d,u.closed,u.quiz]),(0,o.d4)((()=>{let e;return u.quiz&&!u.closed&&u.closePeriod&&u.closePeriod>0&&(e=window.setTimeout((()=>{a({chatId:l,messageId:d})}),1e3*u.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[E,l,a,d,u.closePeriod,u.closed,u.quiz]);const x=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const s=n[t];return s&&e.push(s),e}),[]):[]),[n,s]),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)}),[]),$=(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 Q=(0,be.Z)();return o.ZP.createElement("div",{className:"Poll",dir:Q.isRtl?"auto":"ltr"},I&&t.results.solution&&o.ZP.createElement(Hs.Z,{message:(0,ts.H)(t.results.solution,t.results.solutionEntities),duration:5e3,onDismiss:$,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"},Q(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(hs.Z,{size:"micro",user:e})))),Z>0&&E&&o.ZP.createElement("div",{ref:P,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(qs.Z,{options:B,onChange:A,disabled:e.isScheduled||m,loadingOptions:m?f:void 0,round:!0}):o.ZP.createElement(Gs.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(_s,{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")}(Q,u.quiz,h.totalVoters)),R&&o.ZP.createElement(ke.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:O},Q("PollSubmitVotes")),k&&o.ZP.createElement(ke.Z,{isText:!0,size:"tiny",onClick:F},Q("PollViewResults")))})));var Ws=s(8035),zs=s(88);const Ys=(0,o.X$)((({message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:n,shouldAutoPlay:a,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}=as(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:w}=m,P=(Z||w)&&u&&!g,b=(0,Ws.Z)(C,170),M=(0,de.Z)("WebPage",g&&"with-square-photo",!Z&&!w&&!r&&"without-media",w&&"with-video");return o.ZP.createElement("div",{className:M,"data-initial":(p||v)[0],dir:"auto"},Z&&!w&&o.ZP.createElement(Bs,{message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:n,size:g?"pictogram":"inline",nonInteractive:!P,onClick:P?f:void 0,onCancelUpload:h,isDownloading:c,theme:l}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(zs.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&&w&&o.ZP.createElement(Ds,{message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:n,shouldAutoPlay:a,lastSyncTime:i,onClick:P?f:void 0,onCancelUpload:h,isDownloading:c}))}));var Xs=s(9937);const Ks=(0,o.X$)((({message:e})=>{const t=(0,be.Z)(),s=(0,d.eO)(e),{title:n,text:a,amount:r,currency:i,isTest:c,photoUrl:l}=s;return o.ZP.createElement("div",{className:"Invoice"},n&&o.ZP.createElement("p",{className:"title"},(0,Zt.Z)(n)),a&&o.ZP.createElement("p",null,(0,Zt.Z)(a,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(l?"has-image":"")},l&&o.ZP.createElement("img",{className:"invoice-image",src:l,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,Xs.x)(r,i,t.code),c&&o.ZP.createElement("span",null,t("PaymentTestInvoice")))))}));function Js(e){return(0,o.X$)((0,n.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,i.CA)(e),isSelected:(0,i.vk)(e,s.id)}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection"])))((t=>{const{isInSelectMode:s,isSelected:n,message:a,toggleMessageSelection:r,dimensions:i}=t,c=(0,o.I4)((e=>{e.stopPropagation(),r({messageId:a.id,withShift:null==e?void 0:e.shiftKey})}),[r,a]),d=(0,o.Ye)((()=>({...t,isInSelectMode:s,isSelected:n,dimensions:{...t.dimensions,x:0,y:0},onClick:s?void 0:t.onClick})),[t,s,n]);return o.ZP.createElement("div",{className:(0,de.Z)("album-item-select-wrapper",n&&"is-selected"),style:i?`left: ${i.x}px; top: ${i.y}px;`:"",onClick:s?c:void 0},s&&o.ZP.createElement("div",{className:"message-select-control"},n&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const en=Js(Bs),tn=Js(Ds),sn=(0,n.c$)(((e,{album:t})=>{const{chatId:s}=t.mainMessage,n=(0,i.Pu)(e),a=(0,i.xs)(e,s);return{theme:n,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:a}}),((e,t)=>(0,g.ei)(t,["cancelSendingMessage"])))((({album:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:n,hasCustomAppendix:a,lastSyncTime:r,isOwn:i,albumLayout:c,onMediaClick:l,uploadsById:u,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:w}=c.layout[g];if(I){const n=a&&(i?g===f-1:Boolean(8&w&&4&w));return o.ZP.createElement(en,{id:`album-media-${e.id}`,message:e,observeIntersection:t,shouldAutoLoad:s,shouldAffectAppendix:n,uploadProgress:C,dimensions:Z,onClick:l,onCancelUpload:p,isDownloading:h.includes(e.id),theme:m})}if(v)return o.ZP.createElement(tn,{id:`album-media-${e.id}`,message:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:n,uploadProgress:C,lastSyncTime:r,dimensions:Z,onClick:l,onCancelUpload:p,isDownloading:h.includes(e.id),theme:m})})))}));function nn(){return(nn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}let an;const on=({message:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:a,lastSyncTime:r,isDownloading:i})=>{const c=(0,o.sO)(null),l=(0,o.sO)(null),h=(0,o.sO)(null),m=e.content.video,g=(0,Xt.Op)(c,t),[f,p]=(0,o.eJ)(s&&a),I=Boolean(f&&g&&r),{mediaData:v,loadProgress:y}=(0,Ss.Z)((0,d.Ti)(e,"inline"),!I,(0,d.kG)(e,"inline"),r),{loadProgress:C}=(0,Ss.Z)((0,d.Ti)(e,"download"),!i,u.IU.BlobUrl,r),Z=ks(e,v),{isBuffered:P,bufferingHandlers:b}=(0,xs.Z)(),M=f&&!P||i,S=!1===(0,Rs.Z)(f),{shouldRender:E,transitionClassNames:k}=(0,ue.Z)(M||!P,void 0,S),{shouldRenderThumb:R,transitionClassNames:T}=(0,Zs.Z)(v,"slow"),[N,B]=(0,o.eJ)(!1),[x,L]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!N)return;const e=Ct.Rj/2,t=2*(e-6)*Math.PI,s=t-x*t,n=h.current,a=l.current,o=a.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",s.toString()):a.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>`,L(n.currentTime/n.duration)}),[N,x]);const A=Boolean(v&&g),O=()=>{B(!1),L(0),(0,Ls.Z)(h.current),(0,w.T2)((()=>{l.current.innerHTML=""}))},F=(D=O,()=>{an&&an(),an=D});var D;(0,o.d4)((()=>{h.current&&(A?(0,Ls.Z)(h.current):h.current.pause())}),[A]),As(h,A),Fs(h,Boolean(v)),(0,Os.Z)(h,[v]);const $=(0,o.I4)((()=>{if(!v)return void p((e=>!e));if(i)return void(0,n.uC)().cancelMessageMediaDownload({message:e});const t=h.current;N?t.paused?((0,Ls.Z)(t),(0,Qt.Es)()):t.pause():(F(),t.pause(),t.currentTime=0,(0,Ls.Z)(t),(0,Qt.Es)(),B(!0))}),[F,N,i,v,e]),Q=(0,o.I4)((e=>{const t=e.currentTarget;L(t.currentTime/t.duration)}),[]),q=(0,de.Z)("full-media",T);return o.ZP.createElement("div",{ref:c,className:"RoundVideo media-inner",onClick:$},(R||v)&&o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:Z,className:"thumbnail",style:`width: ${Ct.Rj}px; height: ${Ct.Rj}px`})),v&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",nn({ref:h,className:q,width:Ct.Rj,height:Ct.Rj,autoPlay:!0,muted:!N,loop:!N,playsInline:!0,onEnded:N?O:void 0},b,{onTimeUpdate:N?Q:void 0}),o.ZP.createElement("source",{src:v}))),o.ZP.createElement("div",{className:"progress",ref:l}),E&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(Ns.Z,{progress:i?C:y})),!v&&!f&&o.ZP.createElement("i",{className:"icon-large-play"}),o.ZP.createElement("div",{className:"message-media-duration"},N?(0,U.k9)(h.current.currentTime):(0,U.k9)(m.duration),(!N||h.current.paused)&&o.ZP.createElement("i",{className:"icon-muted-chat"})))},rn=({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(a.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},cn=(0,o.X$)((0,n.c$)(((e,{message:t})=>{const{threadId:s,chatId:n}=t.threadInfo,a=(0,i.tZ)(e,n,s)||t.threadInfo,{byId:o}=e.users,{byId:r}=e.chats;return{threadInfo:a,usersById:o,chatsById:r}}),((e,t)=>(0,g.ei)(t,["openChat"])))((({disabled:e,threadInfo:t,usersById:s,chatsById:n,openChat:a})=>{const r=(0,be.Z)(),{threadId:i,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:h,recentReplierIds:m}=t,g=(0,o.I4)((()=>{a({id:c,threadId:i})}),[a,c,i]);if(void 0===l)return;const f=m&&m.map((e=>(0,d.YA)(e)?s[e]:n[e])).filter(Boolean),p=Boolean(h&&u&&h<u);return o.ZP.createElement("div",{"data-cnt":(0,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(hs.Z,{key:e.id,size:"small",user:(0,d.YA)(e.id)?e:void 0,chat:(0,d.YA)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},l?r("Comments",l,"i"):r("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))}))),dn="data-is-document-group-hover";function ln(e){const t=hn(e.currentTarget);t&&t.setAttribute(dn,"")}function un(e){const t=hn(e.currentTarget);t&&t.removeAttribute(dn)}function hn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}const mn=(0,o.X$)((0,n.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:n,lastSyncTime:a}=e,{message:o,album:r,withSenderName:c,withAvatar:l,threadId:u,messageListType:h}=t,{id:m,chatId:g,viaBotId:f,replyToChatId:p,replyToMessageId:I,isOutgoing:v}=o,y=(0,i.Z1)(e,g),C=(0,i.FM)(e,g),Z=(0,d.pK)(g),w=y&&(0,d.eA)(y),P=null==y?void 0:y.username,b=!C&&(0,d.Ul)(o),M=c||l||b?(0,i.Ur)(e,o):void 0,S=(0,i.cv)(e,o),E=f?(0,i.dy)(e,f):void 0,k=u?(0,i.qS)(e,g,u):void 0,R=o.id===k,T=I===k,N=I&&!T?(0,i.hj)(e,Z&&p?p:g,I):void 0,B=N&&(0,i.Ur)(e,N),x=(0,i.uZ)(e,o),L="thread"===h&&(r?r.messages.some((t=>(0,i._X)(e,t))):(0,i._X)(e,o)),{direction:A,noHighlight:O,isResizingContainer:F}=L&&s||{},U=n.messageIds&&n.messageIds.includes(m),{query:D}=(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:q}="thread"===h&&(0,i._k)(e,o,u)||{},G=(0,i.te)(e,o);return{theme:(0,i.Pu)(e),chatUsername:P,forceSenderName:b,sender:M,originSender:S,botSender:E,shouldHideReply:T,isThreadTop:R,replyMessage:N,replyMessageSender:B,isFocused:L,isForwarding:U,isChatWithSelf:C,isRepliesChat:Z,isChannel:w,canReply:q,lastSyncTime:a,highlight:D,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,shouldAutoLoadMedia:y?(0,i.TD)(e,o,y,M):void 0,shouldAutoPlayMedia:(0,i.pv)(e,o),shouldLoopStickers:(0,i.yB)(e),...v&&{outgoingStatus:(0,i.dT)(e,o,"scheduled"===h)},..."number"==typeof x&&{uploadProgress:x},...L&&{focusDirection:A,noFocusHighlight:O,isResizingContainer:F}}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection","clickInlineButton","disableContextMenuHint"])))((({message:e,chatUsername:t,observeIntersectionForBottom:s,observeIntersectionForMedia:a,observeIntersectionForAnimatedStickers:r,album:i,noAvatars:c,withAvatar:l,withSenderName:g,noComments:f,appearanceOrder:p,isFirstInGroup:I,isLastInGroup:v,isFirstInDocumentGroup:y,isLastInDocumentGroup:C,isLastInList:Z,theme:w,forceSenderName:P,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:$,canReply:Q,lastSyncTime:q,highlight:G,animatedEmoji:H,isInSelectMode:j,isSelected:_,isGroupSelected:V,threadId:W,messageListType:z,isPinnedList:Y,isDownloading:X,shouldAutoLoadMedia:K,shouldAutoPlayMedia:J,shouldLoopStickers:ee,toggleMessageSelection:te,clickInlineButton:se,disableContextMenuHint:ne})=>{const ae=(0,o.sO)(null),oe=(0,o.sO)(null),re=(0,o.sO)(null),ie=(0,be.Z)();(0,Xt._N)(oe,s);const{isContextMenuOpen:ce,contextMenuPosition:le,handleBeforeContextMenu:he,handleContextMenu:me,handleContextMenuClose:ge,handleContextMenuHide:fe}=(0,es.Z)(ae,m.$b&&j,!0,m.wZ);(0,o.d4)((()=>{ce&&ne()}),[ce,ne]);const pe=p<=0,[Ie,ve]=(0,Ze.Z)(pe);(0,o.d4)((()=>{pe||setTimeout(ve,10*p)}),[p,ve,pe]);const{transitionClassNames:ye}=(0,ue.Z)(Ie,void 0,pe,!1),{id:Ce,chatId:we,threadInfo:Pe}=e,Me=(0,d.CI)(e),Se=(0,d.B4)(e),Ee="scheduled"===z||e.isScheduled,Re=(0,d.ss)(e)&&!k,Te=Boolean(Pe)&&"thread"===z,{forwardInfo:Ne,viaBotId:Be}=e,xe=Ne&&!U&&!D&&!Ne.isLinkedChannelPost,Le=Boolean(e.groupedId)&&!e.isInAlbum,Ae=Boolean(i)&&i.messages.length>1,{text:Fe,photo:Ue,video:De,audio:$e,voice:Qe,document:qe,sticker:Ge,contact:He,poll:je,webPage:_e,invoice:Ve}=(0,d.qp)(e),We=(0,d.$D)(e),ze=(0,ts.X)(e,G,ss(We)),Ye=void 0!==le,Xe=$&&e.adminTitle||Ne&&!xe&&Ne.adminTitle||void 0,Ke=(0,o.Ye)((()=>Xe?ls(Xe):void 0),[Xe]),Je=!(Ye||j||F)&&(!Le||C),et=$&&!Ee,tt=Boolean(Y||Ne&&(Ne.isChannelPost||U&&!Se||D)&&Ne.fromMessageId),st=Ne&&(U||D||!b)?M:b,nt=Ne?M:b,at=(0,o.I4)(((e,t)=>{te({messageId:Ce,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...Ae&&{childMessageIds:i.messages.map((({id:e})=>e))}})}),[te,Ce,Ae,i]),{handleMouseDown:ot,handleClick:rt,handleContextMenu:ct,handleDoubleClick:dt,handleContentDoubleClick:lt,isSwiped:ut}=function(e,t,s,a,r,i,c,d){const{setReplyingToId:l}=(0,n.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}}(at,ae,Ce,0,Boolean(j),Boolean(Q),me,he),{handleAvatarClick:ht,handleSenderClick:gt,handleViaBotClick:ft,handleReplyClick:pt,handleMediaClick:It,handleAudioPlay:vt,handleAlbumMediaClick:yt,handleMetaClick:wt,handleReadMedia:Pt,handleCancelUpload:bt,handleVoteSend:Mt,handleGroupForward:St,handleForward:Et,handleFocus:kt,handleFocusForwarded:Rt,handleDocumentGroupSelectAll:Tt}=function(e,t,s,a,r,i,c,l,m,g,f,p){const{openUserInfo:I,openChat:v,showNotification:y,focusMessage:C,openMediaViewer:Z,openAudioPlayer:w,markMessagesRead:P,cancelSendingMessage:b,sendPollVote:M,openForwardMenu:S,focusMessageInComments:E}=(0,n.uC)(),{id:k,forwardInfo:R,replyToMessageId:T,replyToChatId:N,replyToTopMessageId:B,groupedId:x}=s,L=(0,o.I4)((()=>{g&&((0,d.YA)(g.id)?I({id:g.id}):v({id:g.id}))}),[g,I,v]),A=(0,o.I4)((()=>{f?(0,d.YA)(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:a,threadId:r,messageId:T,replyMessageId:l&&N?void 0:k})}),[C,l,N,a,r,T,k]),U=(0,o.I4)((()=>{Z({chatId:a,threadId:r,messageId:k,origin:c?h.bZ.ScheduledInline:h.bZ.Inline})}),[a,r,k,Z,c]),D=(0,o.I4)((()=>{w({chatId:a,messageId:k,origin:h.Cr.Inline})}),[a,k,w]),$=(0,o.I4)((e=>{Z({chatId:a,threadId:r,messageId:e,origin:c?h.bZ.ScheduledAlbum:h.bZ.Album})}),[a,r,Z,c]),Q=(0,o.I4)((()=>{P({messageIds:[k]})}),[k,P]),q=(0,o.I4)((()=>{b({chatId:a,messageId:k})}),[b,a,k]),G=(0,o.I4)((e=>{M({chatId:a,messageId:k,options:e})}),[a,k,M]),H=(0,o.I4)((()=>{S({fromChatId:a,groupedId:x})}),[S,a,x]),j=(0,o.I4)((()=>{if(m&&m.messages){const e=m.messages.map((({id:e})=>e));S({fromChatId:a,messageIds:e})}else S({fromChatId:a,messageIds:[k]})}),[m,S,a,k]),_=(0,o.I4)((()=>{C({chatId:a,threadId:u._f,messageId:k})}),[C,a,k]),V=(0,o.I4)((()=>{i?C({chatId:R.fromChatId,groupedId:x,groupedChatId:a}):l&&N?E({chatId:N,threadId:B,messageId:R.fromMessageId}):C({chatId:R.fromChatId,messageId:R.fromMessageId})}),[i,l,N,C,R,x,a,E,B]),W=(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:$,handleMetaClick:W,handleReadMedia:Q,handleCancelUpload:q,handleVoteSend:G,handleGroupForward:H,handleForward:j,handleFocus:_,handleFocusForwarded:V,handleDocumentGroupSelectAll:W}}(ie,at,e,we,W,Le,Boolean(Ee),D,i,st,nt,S),Nt=(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",Se&&"own",Boolean(e.views)&&"has-views",e.isEdited&&"was-edited",Re&&"has-reply",Ye&&"has-menu-open",x&&!A&&"focused",F&&"is-forwarding",e.isDeleting&&"is-deleting",Le&&"is-in-document-group",Ae&&"is-album",e.hasUnreadMention&&"has-unread-mention",_&&"is-selected",j&&"is-in-selection-mode",E&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",ut&&"is-swiped",ye),Bt=function(e,{hasReply:t,customShape:s,isLastInGroup:n,asForwarded:a,hasThread:o,forceSenderName:r,hasComments:i,hasActionButton:c}={}){const{text:l,photo:u,video:h,audio:m,voice:g,document:f,poll:p,webPage:I,contact:v}=(0,d.qp)(e),y=["message-content"],C=u||h,Z=C&&!l,w=Boolean(e.viaBotId);return ss(s)?y.push(`emoji-only emoji-only-${s}`):l&&y.push("text"),c&&y.push("has-action-button"),s&&(y.push("custom-shape"),null!=h&&h.isRound&&y.push("round"),i&&y.push("has-comments")),u||h?y.push("media"):m?y.push("audio"):g?y.push("voice"):f?y.push("document"):v?y.push("contact"):p?y.push("poll"):I&&(y.push("web-page"),(I.photo||I.video)&&y.push("media")),a&&!s&&y.push("is-forwarded"),t&&y.push("is-reply"),o&&y.push("has-replies"),w&&y.push("is-via-bot"),r&&y.push("force-sender-name"),s||(y.push("has-shadow"),C&&i&&y.push("has-background"),(t||a||!Z||w||r)&&y.push("has-solid-background"),!n||!u&&Z||y.push("has-appendix")),y.join(" ")}(e,{hasReply:Re,customShape:We,isLastInGroup:v,asForwarded:xe,hasThread:Te,forceSenderName:P,hasComments:e.threadInfo&&e.threadInfo.messagesCount>0,hasActionButton:et||tt}),xt=e.threadInfo&&(!Le||C)&&"thread"===z&&!f,Lt=Bt.includes("has-appendix");(0,mt.Z)(D&&e.replyToChatId?e.replyToChatId:we,Re?e.replyToMessageId:void 0,R,e.id),us(ae,we,x,L,A,O),(0,o.bt)((()=>{re.current&&(re.current.innerHTML=Se?'<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>')}),[Se,Lt]);let At,Ot="",Ft=!1;const Ut=(0,o.Ye)((()=>Ae?cs(Se,Boolean(xe),Boolean(c),i):void 0),[Ae,Se,xe,c,i]),Dt=xe?28:0;if(Ae||!Ue&&!De)Ut&&(At=Math.max(ns(Boolean(Fe),xt),Ut.containerStyle.width),At-Ut.containerStyle.width>18&&(Ft=!0));else{let t;Ue?t=as(e,c).width:De&&(t=De.isRound?Ct.Rj:as(e,c).width),t&&(At=Math.max(ns(Boolean(Fe),xt),t),At-t>18&&(Ft=!0))}return At&&(Ot=`width: ${At+Dt}px`),o.ZP.createElement("div",{ref:ae,id:`message${Ce}`,className:Nt,style:Ke?`--meta-safe-author-width: ${Ke}px`:void 0,"data-message-id":Ce,onMouseDown:ot,onClick:rt,onContextMenu:ct,onDoubleClick:dt,onMouseEnter:Le&&!C?ln:void 0,onMouseLeave:Le&&!C?un:void 0},o.ZP.createElement("div",{ref:oe,className:"bottom-marker","data-message-id":Ce,"data-last-message-id":i?i.messages[i.messages.length-1].id:void 0,"data-has-unread-mention":e.hasUnreadMention}),!Le&&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:Tt},V&&o.ZP.createElement("i",{className:"icon-select"})),l&&function(){const e=st&&(0,d.YA)(st.id),t=st&&e?st:void 0,s=st&&!e?st:void 0,n=!st&&Ne?Ne.hiddenUserName:void 0;return o.ZP.createElement(hs.Z,{size:"small",user:t,chat:s,text:n,lastSyncTime:q,onClick:t||s?ht:void 0})}(),o.ZP.createElement("div",{className:(0,de.Z)("message-content-wrapper",Bt.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:Bt,style:Ot,dir:"auto"},xe&&!We&&(!Le||y)&&o.ZP.createElement("div",{className:"message-title"},ie("ForwardedMessage")),function(){const t=(0,de.Z)("content-inner",xe&&!We&&"forwarded-message",Re&&"reply-message",Ft&&"no-media-corners"),s=v&&!ze&&!xe&&!Te,n=!_e&&!H&&ze,l=(0,de.Z)("text-content",n&&"with-meta",N&&"with-outgoing-icon");return o.ZP.createElement("div",{className:t,onDoubleClick:lt,dir:"auto"},function(){if(We&&!Be||!(g&&!Ue&&!De||xe||Be||P)||Le&&!y||Re&&We)return;let t,s;return!nt||We&&Be?null!=Ne&&Ne.hiddenUserName&&(t=Ne.hiddenUserName):(t=(0,d.OU)(ie,nt),xe||(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:gt,dir:"auto"},(0,Zt.Z)(t)):S?void 0:" ",S&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},ie("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:ft},(0,Zt.Z)(`@${S.username}`))),null!=Ne&&Ne.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},ie("DiscussChannel")):e.adminTitle&&!$?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.adminTitle):void 0)}(),Re&&o.ZP.createElement(ps,{message:R,sender:T,observeIntersection:a,onClick:pt}),Ge&&o.ZP.createElement(bs,{message:e,observeIntersection:a,observeIntersectionForPlaying:r,shouldLoop:ee,lastSyncTime:q}),H&&o.ZP.createElement(Ms.Z,{size:"small",sticker:H,observeIntersection:a,lastSyncTime:q,forceLoadPreview:Me}),Ae&&o.ZP.createElement(sn,{album:i,albumLayout:Ut,observeIntersection:a,shouldAutoLoad:K,shouldAutoPlay:J,isOwn:Se,hasCustomAppendix:s,lastSyncTime:q,onMediaClick:yt}),!Ae&&Ue&&o.ZP.createElement(Bs,{message:e,observeIntersection:a,noAvatars:c,shouldAutoLoad:K,uploadProgress:B,shouldAffectAppendix:s,onClick:It,onCancelUpload:bt,isDownloading:X,theme:w}),!Ae&&De&&De.isRound&&o.ZP.createElement(on,{message:e,observeIntersection:a,shouldAutoLoad:K,shouldAutoPlay:J,lastSyncTime:q,isDownloading:X}),!Ae&&De&&!De.isRound&&o.ZP.createElement(Ds,{message:e,observeIntersection:a,noAvatars:c,shouldAutoLoad:K,shouldAutoPlay:J,uploadProgress:B,lastSyncTime:q,onClick:It,onCancelUpload:bt,isDownloading:X}),($e||Qe)&&o.ZP.createElement(vs.Z,{theme:w,message:e,origin:h.Cr.Inline,uploadProgress:B,lastSyncTime:q,isSelectable:Le,isSelected:_,onPlay:vt,onReadMedia:!Qe||Se&&!U?void 0:Pt,onCancelUpload:bt,isDownloading:X}),qe&&o.ZP.createElement(Is.Z,{message:e,observeIntersection:a,uploadProgress:B,isSelectable:Le,isSelected:_,onMediaClick:It,onCancelUpload:bt,isDownloading:X}),He&&o.ZP.createElement(Qs,{contact:He}),je&&o.ZP.createElement(Vs,{message:e,poll:je,onSendVote:Mt}),!H&&ze&&o.ZP.createElement("p",{className:l,dir:"auto"},ze,n&&o.ZP.createElement(Cs,{message:e,outgoingStatus:N,signature:Xe,onClick:wt})),_e&&o.ZP.createElement(Ys,{message:e,observeIntersection:a,noAvatars:c,shouldAutoLoad:K,shouldAutoPlay:J,lastSyncTime:q,onMediaClick:It,onCancelMediaTransfer:bt,isDownloading:X,theme:w}),Ve&&o.ZP.createElement(Ks,{message:e}))}(),(!Le||C)&&!(!_e&&!H&&ze)&&o.ZP.createElement(Cs,{message:e,outgoingStatus:N,signature:Xe,onClick:wt}),Je&&et?o.ZP.createElement(ke.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:ie("lng_context_forward_msg"),onClick:C?St:Et},o.ZP.createElement("i",{className:"icon-share-filled"})):Je&&tt?o.ZP.createElement(ke.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:Y?kt:Rt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,xt&&o.ZP.createElement(cn,{message:e,disabled:f}),Lt&&o.ZP.createElement("div",{className:"svg-appendix",ref:re})),e.inlineButtons&&o.ZP.createElement(rn,{message:e,onClick:se})),le&&o.ZP.createElement(gs,{isOpen:ce,anchor:le,message:e,album:i,chatUsername:t,messageListType:z,onClose:ge,onCloseAnimationEnd:fe}))}))),gn=(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:P,onFabToggle:b,onNotchToggle:M,openHistoryCalendar:S})=>{const{observeIntersectionForMedia:E,observeIntersectionForReading:k,observeIntersectionForAnimatedStickers:R}=function(e,t,s){const{markMessageListRead:a,markMessagesRead:o}=(0,n.uC)(),{observe:r}=(0,Xt.S1)({rootRef:t,throttleMs:Kt,margin:Jt}),{observe:i,freeze:c,unfreeze:d}=(0,Xt.S1)({rootRef:t,throttleMs:150,noAutoFreeze:!0},(t=>{if("thread"!==e)return;let n=0;const r=[];t.forEach((e=>{const{isIntersecting:t,target:s}=e;if(!t)return;const{dataset:a}=s,o=Number(a.lastMessageId||a.messageId);o>n&&(n=o),a.hasUnreadMention&&r.push(o)})),s.current&&n>=s.current&&a({maxId:n}),r.length&&o({messageIds:r})}));(0,he.Z)(c,d);const{observe:l}=(0,Xt.S1)({rootRef:t,throttleMs:Kt});return{observeIntersectionForMedia:r,observeIntersectionForReading:i,observeIntersectionForAnimatedStickers:l}}(I,l,f),{backwardsTriggerRef:T,forwardsTriggerRef:N,fabTriggerRef:B}=function(e,t,s,r,i,c,d,l){const{loadViewportMessages:u}=(0,n.uC)(),[m,g]=(0,o.Ye)((()=>"thread"===e?[(0,w.Ds)((()=>u({direction:h.Uq.Backwards})),1e3,!0,!1),(0,w.Ds)((()=>u({direction:h.Uq.Forwards})),1e3,!0,!1)]:[]),[u,s]),f=(0,o.sO)(null),p=(0,o.sO)(null),I=(0,o.sO)(null);function v(){if(!l)return;if(!s||!s.length)return c(!1),void d(!1);if(!r)return c(!0),void d(!0);const{offsetHeight:e,scrollHeight:n,scrollTop:a}=t.current,o=Math.round(n-a-e),u=o<=0;c(i?!u:!(o<=50)),d(!u)}const{observe:y}=(0,Xt.S1)({rootRef:t,margin:a.gZ},(e=>{if(!g||!m)return;if(s[0]>=a.AE)return;const n=e.find((({isIntersecting:e})=>e));if(!n)return;const{target:o}=n;"backwards-trigger"===o.className?((0,zt.Z)(t.current),m()):"forwards-trigger"===o.className&&((0,zt.Z)(t.current),g())}));(0,Xt._N)(f,y),(0,Xt._N)(p,y);const{observe:C,freeze:Z,unfreeze:P}=(0,Xt.S1)({rootRef:t,margin:50},v);(0,Xt._N)(I,C);const{observe:b,freeze:M,unfreeze:S}=(0,Xt.S1)({rootRef:t},v);return(0,Xt._N)(I,b),(0,ge.Z)((()=>{Z(),M(),setTimeout((()=>{S(),P()}),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=P?0:t.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let O=0;const F=t.map(((e,t,s)=>{const n=e.senderGroups.map(((e,n,a)=>{if(1===e.length&&!_t(e[0])&&(0,d.Lo)(e[0])){const r=e[0],i=n===a.length-1&&t===s.length-1;return(0,g.oA)([r.id===m.current&&L,o.ZP.createElement(fs,{key:r.id,message:r,observeIntersection:k,appearanceOrder:A-++O,isLastInList:i})])}let r;return(0,g.xH)(e.map(((l,h)=>{const f=_t(l)?l.mainMessage:l,v=_t(l)?l:void 0,Z=(0,d.B4)(f),w=_t(l),P=e[h+1];f.previousLocalId&&u.current===`message${f.previousLocalId}`&&(u.current=`message${f.id}`);const b=!w&&f.groupedId?f.groupedId:void 0,M=P&&!_t(P)?P.groupedId:void 0,S={isFirstInGroup:0===h,isLastInGroup:h===e.length-1,isFirstInDocumentGroup:Boolean(b&&b!==r),isLastInDocumentGroup:Boolean(b&&b!==M),isLastInList:h===e.length-1&&n===a.length-1&&t===s.length-1};r=b;const T=(0,d.KK)(f),N="scheduled"!==I?T:`${f.date}_${T}`;return(0,g.oA)([f.id===m.current&&L,o.ZP.createElement(mn,{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===a.t4&&x("MessageScheduledUntilOnline"),Z&&e.originalDate!==a.t4&&x("MessageScheduledOn",(0,U.j1)(x,e.datetime,void 0,!0)),!Z&&(0,U.j1)(x,e.datetime))),(0,g.xH)(n))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:T,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(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 fn=s(3547);const pn=(0,o.X$)((0,n.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,n=null!=s&&s.length?s[t%s.length]:void 0,a=(0,i.Z1)(e,t);return a?{sticker:n,lastUnreadMessageId:a.lastMessage&&a.lastMessage.id!==a.lastReadInboxMessageId?a.lastMessage.id:void 0,connectionState:e.connectionState}:{}}),((e,t)=>(0,g.ei)(t,["loadGreetingStickers","sendMessage","markMessageListRead"])))((({sticker:e,connectionState:t,lastUnreadMessageId:s,loadGreetingStickers:n,sendMessage:a,markMessageListRead:r})=>{const i=(0,be.Z)(),c=(0,o.sO)(null),{observe:d}=(0,Xt.S1)({rootRef:c,debounceMs:200});(0,o.d4)((()=>{e||"connectionStateReady"!==t||n()}),[t,n,e]),(0,o.d4)((()=>{"connectionStateReady"===t&&s&&r({maxId:s})}),[t,r,s]);const l=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},a({sticker:e})}),[a]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:c},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},i("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},i("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},e&&o.ZP.createElement(fn.Z,{sticker:e,onClick:l,clickArg:e,observeIntersection:d,size:160,className:"large"}))))}))),In=(0,o.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s})=>{const n=(0,be.Z)();return"scheduled"===t?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(n):e?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(n):s?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(n):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,n("NoMessages")))})),vn=(0,w.Ds)((e=>e()),200,!1),yn=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,type:n})=>{const a=(0,i.Z1)(e,t);if(!a)return{};const o=(0,i.$W)(e,t,s,n),r="scheduled"===n?(0,i.Fn)(e,t):(0,i.Zw)(e,t),c=(0,i.qS)(e,t,s);if(s!==u._f&&!(r&&c&&r[c]))return{};const{isRestricted:l,restrictionReason:h,lastMessage:m}=a,g=(0,i.G$)(e,t),f=s===u._f&&!o&&!a.unreadCount&&!g&&m&&!m.groupedId,p=(0,i.IK)(e,t);let I;return(0,i.pk)(e,t)&&(I=p.fullInfo?p.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:l,restrictionReason:h,isChannelChat:(0,d.eA)(a),isGroupChat:(0,d.Bf)(a),isCreator:a.isCreator,isChatWithSelf:(0,i.FM)(e,t),isRepliesChat:(0,d.pK)(t),isBot:Boolean(p),messageIds:o,messagesById:r,firstUnreadId:(0,i.It)(e,t,s),isViewportNewest:"thread"!==n||(0,i.b9)(e,t,s),threadFirstMessageId:(0,i.yZ)(e,t,s),focusingId:g,isSelectModeActive:(0,i.CA)(e),botDescription:I,threadTopMessageId:c,hasLinkedChat:a.fullInfo&&"linkedChatId"in a.fullInfo?Boolean(a.fullInfo.linkedChatId):void 0,...f&&{lastMessage:m}}}),((e,t)=>(0,g.ei)(t,["loadViewportMessages","setScrollOffset","openHistoryCalendar"])))((({chatId:e,threadId:t,type:s,hasTools:r,onFabToggle:c,onNotchToggle:l,isChatLoaded:u,isChannelChat:m,isGroupChat:f,canPost:p,isReady:I,isActive:v,isChatWithSelf:y,isRepliesChat:C,isCreator:Z,isBot:P,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,G,H,j;const _=(0,o.sO)(null),V=(0,o.sO)("thread"===s&&(0,i.Vt)((0,n.Rd)(),e,t)||0),W=(0,o.sO)(),z=(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,ne]=(0,o.eJ)(),ae=Boolean(b);(0,ge.Z)((()=>{ae&&(0,w.R3)((()=>{te.current=!1}))}),[ae]),(0,ge.Z)((()=>{X.current=S}),[S]),(0,ge.Z)((()=>{ae&&(K.current=X.current)}),[ae]),(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 Vt((0,g.Xo)(t,["date","id"]),K.current)}),[b,M,k,F]),re=(0,o.Ye)((()=>{if("thread"===s)return(0,w.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,o.Ye)((()=>(0,w.Ds)((e=>e()),1e3,!1,n)),[1e3,!1,n]);var n;return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,n)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,w.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{(0,w.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const s=function(e,t){const s=e.querySelectorAll(".sticky-date"),n=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:a}=e,o=s-n;return-a<=o&&o<=(t?60:10)}))}(e,n);s&&s.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,s])}}(),ue=(0,o.I4)((()=>{if(ee.current)return void(ee.current=!1);const n=_.current;J.current||le(n,r),vn((()=>{(0,w.T2)((()=>{n.parentElement&&(V.current=n.scrollHeight-n.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&&ne(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[0]>=a.AE)return;const e=_.current;(!b||b.length<a.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&&(W.current=t.id,z.current=t.getBoundingClientRect().top)}),[b,E,se,r,I]),(0,Ht.Z)((([e,t,s])=>{const n=_.current;if(Y.current=Array.from(n.querySelectorAll(".message-list-item")),!n.offsetParent)return;const o=E&&b&&b.length<a.hT/2&&!n.parentElement.classList.contains("force-messages-scroll")&&n.firstElementChild.clientHeight<=2*n.offsetHeight;o&&(n.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{n.parentElement&&n.parentElement.classList.remove("force-messages-scroll")}),1e3));const i=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)===a.hT/2+1,d=i&&!c,l=b&&J.current===b[b.length-1],{scrollTop:u,scrollHeight:h,offsetHeight:m}=n,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,w.T2)((()=>{(0,Yt.Z)(n,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=W.current&&document.getElementById(W.current),Z=!C&&K.current&&n.querySelector(".unread-divider");if(I&&y){if((0,Yt.N)())return;v=h-m}else v=C?u+(C.getBoundingClientRect().top-(z.current||0)):Z?Math.min(Z.offsetTop-(r?60:10),h-g):h-g;(0,zt.Z)(n,Math.ceil(v)),J.current||(ee.current=!0,(0,w.T2)((()=>{ee.current=!1}))),V.current=Math.max(Math.ceil(h-v),m)}),[b,E,se,r]),(0,jt.Z)((([e])=>{void 0!==e&&(0,ce.YW)(200+a.fK)}),[B]);const me=(0,be.Z)(),fe=Boolean(e&&(0,d.YA)(e)),pe=Boolean(!fe&&!m||y||C),Ie=Boolean(!pe||m),ve=(0,d.YA)(e)&&!y&&!P&&(!oe&&!A&&b&&(!Y.current||0===Y.current.length)||1===(null==b?void 0:b.length)&&"contactSignUp"===(null==M||null===($=M[b[0]])||void 0===$||null===(Q=$.content.action)||void 0===Q?void 0:Q.type)||"contactSignUp"===(null==A||null===(q=A.content)||void 0===q||null===(G=q.action)||void 0===G?void 0:G.type)),ye=f&&Z&&1===(null==b?void 0:b.length)&&"chatCreate"===(null==M||null===(H=M[b[0]])||void 0===H||null===(j=H.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(pn,{userId:e}):!b||oe&&!ye?b&&oe||A?o.ZP.createElement(gn,{messageIds:b||[A.id],messageGroups:oe||Vt([A]),isViewportNewest:Boolean(E),isUnread:Boolean(S),withUsers:pe,noAvatars:Ie,containerRef:_,anchorIdRef:W,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(In,{chatId:e,type:s,isChatWithSelf:y,isGroupChatJustCreated:ye}))}))),Cn=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Bt)(e);if(!t)return{};const{chatId:s,threadId:n,type:a}=t,o=(0,i.Z1)(e,s);return{messageListType:a,unreadCount:o&&n===u._f&&"thread"===a?o.unreadCount:void 0}}),((e,t)=>(0,g.ei)(t,["focusNextReply"])))((({isShown:e,canPost:t,messageListType:s,unreadCount:n,withExtraShift:a,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,Yt.Z)(e,s,"end",20)}}),[e,s,r]),l=(0,de.Z)("ScrollDownButton",e&&"revealed",!t&&"no-composer",a&&"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(n)&&o.ZP.createElement("div",{className:"unread-count"},(0,ft.bi)(n))))})));var Zn=s(5723);const wn=1280;async function Pn(e,t,s,n){const o=URL.createObjectURL(t),{type:r,size:i}=t;let c,d;if(a.oG.has(r))if(s){const t=await(0,rt.pt)(o),{width:s,height:a}=t;if(s>wn||a>wn||"image/jpeg"!==r){const t=await Lt(o,wn/Math.max(s,a),"image/jpeg");return URL.revokeObjectURL(o),Pn(e,await(0,rt.gm)(t),!0,n)}c={width:s,height:a}}else d=o;else if(a.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,...n}}var bn=s(6391);let Mn;function Sn(e){Mn.focus(),e.focus()}m.cj&&(Mn=document.createElement("input"),Mn.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Mn));const En={encoderPath:s.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},kn={type:"audio/ogg"};let Rn,Tn,Nn;async function Bn(){return Rn||(Rn=s.e(161).then(s.t.bind(s,1161,23)),Tn=(await Rn).default,Nn=new Tn(En)),Rn}async function xn(e){await async function(){await Bn(),await Nn.start()}();const t=Date.now();let s;const n=[],a=[];Nn.ondataavailable=e=>{n.push(e)};const o=function(t,s){const n=t.sourceNode,o=n.context.createAnalyser();o.fftSize=64,n.connect(o);const r=o.frequencyBinCount,i=new Uint8Array(r);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(i);const s=i.reduce(((e,t)=>e+t),0)/r/255;(t=>{a.push(255*t),e(t)})(s<.1?0:s),requestAnimationFrame(t)}(),()=>{c=!0}}(Nn);return{stop:()=>new Promise(((e,r)=>{Nn.onstop=()=>{e({blob:new Blob(n,kn),duration:Math.round(((s||Date.now())-t)/1e3),waveform:a})},Nn.onerror=r;const i=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Nn.stop(),o()}),i)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Nn.pause(),s=Date.now(),o()}),e)}}}const Ln=["image/png","image/jpeg","image/gif"];function An(e){const{text:t,entities:s}=e||{};if(!t)return"";const n=(0,ts.H)(t,s,void 0,void 0,!0);return Array.isArray(n)?n.join(""):n}let On,Fn;var Un=s(4784),Dn=s(2400),$n=s(8353),Qn=s(2365);const qn=document.createElement("div"),Gn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Hn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i;const jn=(0,w.P2)((e=>e()),500,!0),_n=/^[\w@]{1,32}\s?/i,Vn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"DeleteMessageModal",!t);return s?o.ZP.createElement(s,e):void 0}));function Wn(){return(Wn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}let zn,Yn=!0;const Xn=(0,o.X$)((({onActivate:e,...t})=>{const s=(0,o.sO)(!1),n=(0,o.I4)((()=>{if(s.current=!0,Yn)return Yn=!1,void e();zn&&(clearTimeout(zn),zn=void 0),zn=window.setTimeout((()=>{s.current&&e()}),200)}),[e]),a=(0,o.I4)((()=>{s.current=!1}),[]);return o.ZP.createElement(ke.Z,Wn({},t,{onMouseEnter:m.$b?void 0:n,onMouseLeave:m.$b?void 0:a,onClick:m.$b?e:void 0}))})),Kn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"AttachMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Jn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"SymbolMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ea=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"InlineBotTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),ta=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"MentionTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),sa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"CustomSendMenu",!t);return s?o.ZP.createElement(s,e):void 0})),na=e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"StickerTooltip",!t);return s?o.ZP.createElement(s,e):void 0};var aa=s(9830);const oa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"BotCommandTooltip",!t);return s?o.ZP.createElement(s,e):void 0}));var ra=s(6503);const ia=(0,o.X$)((0,n.c$)(((e,{messageId:t})=>{const{chatId:s}=(0,i.Bt)(e)||{};return s?{message:(0,i.hj)(e,s,t)}:{}}),((e,t)=>(0,g.ei)(t,["clickInlineButton"])))((({isOpen:e,message:t,onClose:s,clickInlineButton:n})=>{const[a,r]=(0,ra.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:a,onMouseLeave:m.$b?void 0:r},o.ZP.createElement("div",{className:"content"},t.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(ke.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>n({button:e})},e.text))))))))})));var ca=s(3616),da=s(7891);const la=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s,type:n}=(0,i.Bt)(e)||{};if(!t||!s||!n)return{};const{currentUserId:a,forwardMessages:{fromChatId:o,toChatId:r,messageIds:c}}=e,l=(0,i.Yy)(e,t,s),u="scheduled"===n?(0,i.wU)(e,t):(0,i._$)(e,t,s),h=e.settings.byKey.animationLevel>=1,m=r===t;let g,f;if(l?g=(0,i.hj)(e,t,l):u?g=(0,i.kK)(e,t,s,n):m&&1===c.length&&(g=(0,i.hj)(e,o,c[0])),l&&g){const{forwardInfo:s}=g,n=t===a;s&&(s.isChannelPost||n)&&(f=(0,i.cv)(e,g)),f||(f=(0,i.Ur)(e,g))}else m&&(f=(0,d.YA)(o)?(0,i.dy)(e,o):(0,i.Z1)(e,o));return{replyingToId:l,editingId:u,message:g,sender:f,shouldAnimate:h,forwardedMessagesCount:m?c.length:void 0}}),((e,t)=>(0,g.ei)(t,["setReplyingToId","setEditingId","focusMessage","exitForwardMode"])))((({replyingToId:e,editingId:t,message:s,sender:n,shouldAnimate:a,forwardedMessagesCount:r,setReplyingToId:i,setEditingId:c,focusMessage:d,exitForwardMode:l})=>{const u=Boolean((e||t)&&s||n&&r),h=(0,da.Z)([r],r?300:void 0),{shouldRender:m,transitionClassNames:g}=(0,ue.Z)(h&&u,void 0,!a,void 0,!a),f=(0,o.I4)((()=>{e?i({messageId:void 0}):t?c({messageId:void 0}):r&&l()}),[e,t,r,i,c,l]);(0,o.d4)((()=>u?(0,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(ps,{className:"inside-input",message:s,sender:n,customText:v,title:t?"Edit Message":void 0,onClick:p})))}))),ua=(0,o.X$)((e=>{const{attachments:t}=e,s=(0,Qe.Z)($e.gl.Extra,"AttachmentModal",!t.length);return s?o.ZP.createElement(s,e):void 0})),ha=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"BotCommandMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ma=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"PollModal",!t);return s?o.ZP.createElement(s,e):void 0})),ga=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"DropArea",!t);return s?o.ZP.createElement(s,e):void 0})),fa=new RegExp(a.FM,"i"),pa=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s})=>{const n=(0,i.tV)(e,t,s);return{theme:(0,i.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:n}}),((e,t)=>(0,g.ei)(t,["loadWebPagePreview","clearWebPagePreview","toggleMessageWebPage"])))((({chatId:e,threadId:t,messageText:s,disabled:n,webPagePreview:a,noWebPage:r,theme:i,loadWebPagePreview:c,clearWebPagePreview:d,toggleMessageWebPage:l})=>{const h=(0,o.Ye)((()=>{const{text:e,entities:t}=(0,p.Z)(s),n=t&&t.find((({type:e})=>e===u.Vv.TextUrl));if(n)return n.url;const a=e.match(fa);return a?a[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(a&&s.length&&!r&&!n),{shouldRender:g,transitionClassNames:f}=(0,ue.Z)(m),I=(0,gt.Z)(a,!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(Ys,{message:C,inPreview:!0,theme:i})))})));var Ia=s(2898);const va=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"CalendarModal",!t);return s?o.ZP.createElement(s,e):void 0}));var ya;!function(e){e.Send="send",e.Record="record",e.Edit="edit"}(ya||(ya={}));const Ca=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{var o,r;const c=(0,i.Z1)(e,t),l=c&&(0,i.Dg)(e,c),h=t!==a.FV?(0,i.IK)(e,t):void 0,m=Boolean(h),g=(0,i.FM)(e,t),f=m&&(0,i.FT)(e,t),p=(0,i.qy)(e,t),{language:I}=e.settings.byKey,v=e.emojiKeywords[a.pR],y=I!==a.pR?e.emojiKeywords[I]:void 0,C=f?f.id:void 0,Z=C?(0,i.hj)(e,t,C):void 0;return{editingMessage:(0,i.kK)(e,t,s,n),connectionState:e.connectionState,draft:(0,i.Ms)(e,t,s),chat:c,isChatWithBot:m,isChatWithSelf:g,canScheduleUntilOnline:!g&&!m&&c&&l&&(0,d.YA)(t)&&l.status&&Boolean(l.status.wasOnline),isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),withScheduledButton:s===u._f&&"thread"===n&&Boolean(null==p?void 0:p.length),shouldSchedule:"scheduled"===n,botKeyboardMessageId:C,botKeyboardPlaceholder:null==Z?void 0:Z.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:e.settings.byKey.shouldSuggestStickers,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==v?void 0:v.keywords,emojiKeywords:null==y?void 0:y.keywords,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:c&&c.fullInfo&&c.fullInfo.botCommands,botCommands:h&&h.fullInfo?h.fullInfo.botCommands||!1:void 0}}),((e,t)=>(0,g.ei)(t,["sendMessage","editMessage","saveDraft","clearDraft","showDialog","setStickerSearchQuery","setGifSearchQuery","forwardMessages","openPollModal","closePollModal","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:P,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:$,serverTimeOffset:Q,recentEmojis:q,inlineBots:G,isInlineBotLoading:H,botCommands:j,chatBotCommands:_,sendMessage:V,editMessage:W,saveDraft:z,clearDraft:Y,showDialog:X,setStickerSearchQuery:K,setGifSearchQuery:J,forwardMessages:ee,openPollModal:te,closePollModal:se,loadScheduledHistory:ne,openChat:ae,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,Rs.Z)(e),[pe,Ie,ve]=(0,Ze.Z)(),[Ce,we]=(0,o.eJ)(),{width:Pe}=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&&ne({chatId:l})}),[r,l,ne,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&&(we(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,$e,Qe]=(0,Ze.Z)(),[qe,Ge,He]=(0,Ze.Z)(),[je,_e]=(0,Ze.Z)(),[Ve,We,ze]=(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)(),n=(0,o.sO)(),[a,r]=(0,o.eJ)();(0,o.d4)((()=>{m.s$&&m.mh&&Bn()}),[]);const i=(0,o.I4)((async()=>{try{const{stop:t,pause:a}=await xn((t=>{e.current&&(n.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),r(Date.now()))}));n.current=Date.now(),r(Date.now()),s({stop:t,pause:a})}catch(e){console.error(e)}}),[]),c=(0,o.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),d=(0,o.I4)((()=>{if(t){s(void 0),n.current=void 0,r(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,ye.Z)(d):void 0),[t,d]),{startRecordingVoice:i,pauseRecordingVoice:c,stopRecordingVoice:d,activeVoiceRecording:t,currentRecordTime:a,recordButtonRef:e,startRecordTimeRef:n}})(),nt=c?ya.Edit:!m.mh||Je||le&&!Se.length||M?ya.Send:ya.Record,ot=!t,{isMentionTooltipOpen:rt,closeMentionTooltip:ct,insertMention:dt,mentionFilteredUsers:lt}=(0,Qn.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,a){const[r,i,c]=(0,Ze.Z)(),d=function(e){return qn.innerHTML=e.replace(/<br>/g,"\n"),qn.innerText}(s),{queryInlineBot:l,resetInlineBot:u}=(0,n.uC)(),{username:h,query:m,canShowHelp:g}=function(e){const t=e.match(Gn);return t?{username:t[1],query:t[2],canShowHelp:""===t[2]&&!e.match(Hn)}:{username:"",query:"",canShowHelp:!1}}(d),f=h.toLowerCase(),p=(0,Rs.Z)(m),I=(0,Rs.Z)(h),v=null==a?void 0:a[f],{id:y,switchPm:C,offset:Z,results:w,isGallery:P,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!=w&&w.length)?i():c()}),[y,e,i,w,C,c]),I!==h&&u({username:I}),{isOpen:r,closeTooltip:c,loadMore:M,username:h,id:y,isGallery:P,switchPm:C,results:w,help:g&&b?`@${h} ${b}`:void 0}}(Boolean(!Se.length&&A),l,le,G),{isOpen:yt,close:Ct,filteredBotCommands:wt}=function(e,t,s,n){const[a,r,i]=(0,Ze.Z)(),[c,d]=(0,o.eJ)(),l=(0,o.I4)((e=>{s||n?jn((()=>{const t=(s||n||[]).filter((({command:t})=>!e||t.includes(e)));d(t&&t.length?t:void 0)})):d(void 0)}),[s,n]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,Dn._)(t.substr(1)).match(_n);l(e?e[0]:"")}else i();else i()}),[l,t,e,i]),(0,o.d4)((()=>{c&&c.length?r():i()}),[c,r,i]),{isOpen:a,close:i,filteredBotCommands:c}}(Boolean(j&&j.length||_&&_.length),le,j,_),{isContextMenuOpen:Pt,handleContextMenu:bt,handleContextMenuClose:Mt,handleContextMenuHide:St}=(0,es.Z)(tt,!(nt===ya.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,a=!1){const r=(0,o.Ye)((()=>(0,Dn._)(t).trim()),[t]),{loadStickersForEmoji:i,clearStickersForEmoji:c}=(0,n.uC)(),d=m.op&&1===(0,Un.Z)(r)||!m.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),l=Boolean(s)&&d;return(0,o.d4)((()=>{a||(e&&d?i({emoji:r}):!l&&d||c())}),[t,d,c,i,e,a]),{isStickerTooltipOpen:l,closeStickerTooltip:c}}(Boolean(F&&Et.canSendStickers&&!Se.length),le,T,!r),{isEmojiTooltipOpen:Bt,closeEmojiTooltip:xt,filteredEmojis:Lt,insertEmoji:At}=(0,$n.Z)(Boolean(F&&Et.canSendStickers&&!Se.length),le,q,void 0,ue,D,$,!r),Ot=(0,o.I4)(((e,t=a.R2)=>{const s=window.getSelection(),n=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,bn.R)(e,t))return function(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const s=t.getRangeAt(0);s.deleteContents();const n=s.createContextualFragment(e),a=n.lastChild;s.insertNode(n),a?(s.setStartAfter(a),s.setEndAfter(a)):s.collapse(!1),t.removeAllRanges(),t.addRange(s)}}(o),void n.dispatchEvent(new Event("input",{bubbles:!0}))}ue(`${Me.current}${o}`),requestAnimationFrame((()=>{(0,Zn.Z)(n)}))}),[]),Ft=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,bn.R)(t,a.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 n=s.textContent.length,a=document.createRange(),o=window.getSelection();a.setStart(s,n),a.setEnd(s,n),o.removeAllRanges(),o.addRange(a),document.execCommand("delete",!1);const r=t.innerHTML;return document.body.removeChild(t),r}(Me.current))}),[]),Ut=(0,o.I4)(((e=!1)=>{e||ue(""),Ee([]),Nt(),ve(),we(void 0),ct(),xt(),m.wB?setTimeout((()=>Qe()),350):Qe()}),[Nt,ve,ct,xt,Qe]),Dt=(0,o.sO)();Dt.current=Xe,(0,o.d4)((()=>()=>{Dt.current(),Ut()}),[l,Ut,Dt]);const $t=((e,t,s,n,r,i)=>((0,o.d4)((()=>{s?(t(An(s.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,Zn.Z)(e,!0)}))):t("")}),[s,t]),(0,o.I4)((()=>{const{text:t,entities:a}=(0,p.Z)(e.current);s&&(t||(0,d.u8)(s)?(i({messageId:s.id,text:t,entities:a}),n()):r())}),[i,s,e,r,n])))(Me,ue,c,Ut,Ge,W);((e,t,s,n,r,i,c,d,l)=>{const u=(0,o.I4)(((e,t)=>{r.current.length&&!c?d({chatId:e,threadId:t,draft:(0,p.Z)(r.current)}):l({chatId:e,threadId:t})}),[l,c,r,d]),h=(0,o.Ye)((()=>(0,w.Ds)((e=>e()),a.r_,!1)),[t]),g=(0,Rs.Z)(t),f=(0,Rs.Z)(s);(0,o.d4)((()=>(On=t,Fn=s,()=>{On=void 0,Fn=void 0,u(t,s)})),[t,s,u]),(0,o.d4)((()=>{t===g&&s===f||e&&(i(An(e)),m.$b||requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,Zn.Z)(e,!0)})))}),[t,s,e,i,u,g,f]);const I=(0,Rs.Z)(n);(0,o.d4)((()=>{t&&s&&g===t&&f===s&&I!==n&&(n.length?h((()=>{On===t&&Fn===s&&u(t,s)})):u(t,s))}),[t,n,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,z,Y),((e,t,s)=>{(0,o.d4)((()=>{async function n(n){if(!n.clipboardData)return;const o=document.activeElement;if(o&&![a.R2,a.nY].includes(o.id))return;const{items:r}=n.clipboardData,i=Array.from(r).find((e=>Ln.includes(e.type)&&"file"===e.kind)),c=i&&i.getAsFile(),d=n.clipboardData.getData("text").substring(0,4096);if(n.preventDefault(),c||d){if(c&&!s){const e=await Pn(c.name,c,!0);t((t=>[...t,e]))}d&&e(d,null==o?void 0:o.id)}}return document.addEventListener("paste",n,!1),()=>{document.removeEventListener("paste",n,!1)}}),[e,s,t])})(Ot,Ee,c);const Qt=(0,o.I4)((async(e,t)=>{Ee(await Promise.all(e.map((e=>Pn(e.name,e,t)))))}),[]),qt=(0,o.I4)((async(e,t)=>{Ee([...Se,...await Promise.all(e.map((e=>Pn(e.name,e,t))))])}),[Se]),Gt=(0,o.I4)((()=>{Ee([])}),[]),Ht=(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:n,waveform:a}=e;s=[await Pn("wonderful-voice-message.ogg",t,!1,{voice:{duration:n,waveform:a}})]}}const{text:n,entities:o}=(0,p.Z)(Me.current);if(!s.length&&!n&&!M)return;const r=s.length?1024:4096;if((null==n?void 0:n.length)>r){const e=n.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(a.R2);if(s.length||n){if(Rt&&!kt){const e=(0,f.b)(Q),t=ge.current&&Math.floor(e-ge.current),s=Rt.nextSendDate&&Rt.nextSendDate>e;if(t&&t<Rt.seconds||s){const n=s?Rt.nextSendDate-e:Rt.seconds-t;return X({data:{message:ie("SlowModeHint",(0,U.k9)(n)),isSlowMode:!0,hasErrorKey:!1}}),void i.blur()}}V({text:n,entities:o,attachments:s,scheduledAt:t,isSilent:e})}M&&ee(),ge.current=(0,f.b)(Q),Y({chatId:l,localOnly:!0}),m.cj&&i===document.activeElement&&Sn(i),requestAnimationFrame((()=>{Ut()}))}),[y,Se,Je,M,Y,l,Q,Ut,Xe,X,Rt,kt,V,ee,ie]),jt=(0,o.I4)((()=>{Qe(),xe()}),[Qe,xe]),_t=(0,o.I4)((()=>{Ae(),$e()}),[Ae,$e]),Vt=(0,o.I4)(((e,s=!1)=>{e={...e,isPreloadedGlobally:!0},t?(we({sticker:e}),Ie()):(V({sticker:e}),requestAnimationFrame((()=>{Ut(s)})))}),[t,Ie,V,Ut]),Wt=(0,o.I4)((e=>{t?(we({gif:e}),Ie()):(V({gif:e}),requestAnimationFrame((()=>{Ut(!0)})))}),[t,Ie,V,Ut]),zt=(0,o.I4)((e=>{if("connectionStateReady"!==y)return;re({id:e.id,queryId:e.queryId});const t=document.getElementById(a.R2);m.cj&&t===document.activeElement&&Sn(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?(we({poll:e}),se(),Ie()):(V({poll:e}),se())}),[se,Ie,V,t]),Kt=(0,o.I4)((()=>{t?(we({isSilent:!0}),Ie()):Ht(!0)}),[Ht,Ie,t]),Jt=(0,o.I4)(((e,t=!1)=>{const{isSilent:s,...n}=Ce||{},a=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:Q);Ce&&0!==Object.keys(n).length?(V({...Ce,scheduledAt:a}),requestAnimationFrame((()=>{Ut()}))):Ht(!!s,a),ve()}),[ve,Ht,Ut,Ce,V,Q]),ts=(0,o.I4)((()=>{Jt(new Date(1e3*a.t4),!0)}),[Jt]),ss=(0,o.I4)((()=>{ve(),we(void 0)}),[ve]),ns=(0,o.I4)((e=>{"stickers"===e?(K({query:""}),J({query:void 0})):(J({query:""}),K({query:void 0}))}),[K,J]),as=(0,o.I4)((()=>{const e=document.getElementById(a.R2);m.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Ae(),$e()}),100)):$e()}),[$e,Ae]),os=(0,o.I4)((()=>{ae({id:l,threadId:h,type:"scheduled"})}),[ae,l,h]);(0,o.d4)((()=>{P&&m.wB&&Qe()}),[P,Qe]),(0,o.d4)((()=>{r&&(b?We():setTimeout((()=>{ze()}),200))}),[b,ze,We,r]);const rs=(0,o.I4)((()=>{switch(nt){case ya.Send:t?(Je&&Ke(),Ie()):Ht();break;case ya.Record:Ye();break;case ya.Edit:$t()}}),[nt,t,Ye,$t,Je,Ie,Ke,Ht]),is=nt===ya.Record&&!Et.canAttachMedia,cs=(0,Rs.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(nt){case ya.Edit:hs="Save edited message";break;case ya.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=nt===ya.Edit?$t:t?Ie:Ht;return o.ZP.createElement("div",{className:ms},Et.canAttachMedia&&r&&o.ZP.createElement(Ia.Z,{containerId:"#middle-column-portals"},o.ZP.createElement(ga,{isOpen:e!==at.t.None,withQuick:[e,fe].includes(at.t.QuickFile),onHide:i,onFileSelect:Qt})),o.ZP.createElement(ua,{attachments:Se,caption:Se.length?le:"",groupChatMembers:N,currentUserId:x,usersById:L,recentEmojis:q,isReady:r,onCaptionUpdate:ue,baseEmojiKeywords:D,emojiKeywords:$,addRecentEmoji:oe,onSend:t?Ie:Ht,onFileAppend:qt,onClear:Gt}),o.ZP.createElement(ma,{isOpen:Boolean(S),onClear:se,onSend:Xt}),ds&&o.ZP.createElement(Vn,{isOpen:qe,isSchedule:"scheduled"===g,onClose:He,message:ds}),o.ZP.createElement(ta,{isOpen:rt,onClose:ct,onInsertUserName:dt,filteredUsers:lt,usersById:L}),o.ZP.createElement(ea,{isOpen:ut,botId:ht,allowedAttachmentOptions:Et,isGallery:mt,inlineBotResults:ft,switchPm:gt,onSelectResult:zt,loadMore:vt,onClose:pt}),o.ZP.createElement(oa,{isOpen:yt,withUsername:Boolean(_),botCommands:wt,onClick:Yt,onClose:Ct}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:ce}),o.ZP.createElement(la,null),o.ZP.createElement(pa,{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(Xn,{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?Qe:as,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(Xn,{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(ca.Z,{id:"message-input-text",html:Se.length?"":le,placeholder:Je&&Pe<=600?"":k||ie("Message"),forcedPlaceholder:It,shouldSetFocus:!Se.length,shouldSuppressFocus:m.wB&&De,shouldSuppressTextFormatter:Bt||rt||ut,onUpdate:ue,onSend:fs,onSuppressedFocus:Qe}),H&&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(Xn,{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(Xn,{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(na,{isOpen:Tt,onStickerSelect:Vt}),o.ZP.createElement(aa.Z,{isOpen:Bt,emojis:Lt,onClose:xt,onEmojiSelect:At,addRecentEmoji:oe}),o.ZP.createElement(Kn,{isOpen:Oe,allowedAttachmentOptions:Et,onFileSelect:Qt,onPollCreate:te,onClose:Ue}),E&&o.ZP.createElement(ia,{messageId:E,isOpen:Re,onClose:Ne}),j&&o.ZP.createElement(ha,{isOpen:Be,botCommands:j,onClose:Ae}),o.ZP.createElement(Jn,{isOpen:De,allowedAttachmentOptions:Et,onLoad:_e,onClose:Qe,onEmojiSelect:Ot,onStickerSelect:Vt,onGifSelect:Wt,onRemoveSymbol:Ft,onSearchOpen:ns,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)(nt,!r&&"not-ready",Je&&"recording"),disabled:is,ariaLabel:ie(hs),onClick:rs,onContextMenu:nt===ya.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(sa,{isOpen:Pt,onSilentSend:Z?void 0:Kt,onScheduleSend:t?void 0:Ie,onClose:Mt,onCloseAnimationEnd:St}),o.ZP.createElement(va,{isOpen:pe,withTimePicker:!0,selectedAt:ls.getTime(),maxAt:(0,U._F)(us),isFutureMode:!0,secondButtonLabel:s?ie("Schedule.SendWhenOnline"):void 0,onClose:ss,onSubmit:Jt,onSecondButtonClick:s?ts:void 0}))}))),Za=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,Qe.Z)($e.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0})),wa=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,Qe.Z)($e.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0})),Pa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0})),ba=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0})),Ma=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0})),Sa=m.wB?450+a.fK:void 0;function Ea(e){return"file"===e.kind&&e.type&&a.oG.has(e.type)}const ka=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Pu)(e),{isBlurred:s,background:n,backgroundColor:a,patternColor:o}=e.settings.themes[t]||{},{messageLists:r}=e.messages,c=(0,i.Bt)(e),{isLeftColumnShown:l,chats:{listIds:h}}=e,g={theme:t,customBackground:n,backgroundColor:a,patternColor:o,isLeftColumnShown:l,isRightColumnShown:(0,i.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(m.wB&&(0,i.n5)(e)),isSelectModeActive:(0,i.CA)(e),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,w=v&&(0,d.Qm)(v,p),P=(0,i.pk)(e,f),b="pinned"===I,M="scheduled"===I;return{...g,chatId:f,threadId:p,messageListType:I,isPrivate:(0,d.YA)(f),canPost:!b&&(!v||w)&&!P,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:n,isPinnedMessageList:r,messageLists:i,canPost:c,currentUserBannedRights:l,defaultBannedRights:u,hasPinnedOrAudioMessage:h,pinnedMessagesCount:g,customBackground:f,theme:p,backgroundColor:I,patternColor:v,isLeftColumnShown:y,isRightColumnShown:C,isBackgroundBlurred:Z,isMobileSearchActive:w,isSelectModeActive:P,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)(at.t.None),[$,Q]=(0,o.eJ)(),[q,G]=(0,o.eJ)(),[H,j]=(0,o.eJ)(!1),[_,V]=(0,o.eJ)(!m.wB||S===a.oB),W=h&&(O<a.l3||C&&O>a._m&&O<a.QU||O>=a.ks&&O<a.jT),z=(0,dt.Z)(e,Sa),Y=(0,dt.Z)(t,Sa),X=(0,dt.Z)(s,Sa),K=(0,dt.Z)(c,Sa),J=(0,dt.Z)(W,Sa),ee=(0,dt.Z)($,Sa);(0,o.d4)((()=>e?(0,ye.Z)((()=>{R({id:void 0})})):void 0),[e,R]),(0,o.d4)((()=>{D(at.t.None),Q(void 0),G(void 0)}),[e]),(0,o.d4)((()=>{S===a.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)((()=>{n&&N({userId:e})}),[e,n,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(Ea);D(s?at.t.QuickFile:at.t.Document)}),[]),se=(0,o.I4)((()=>{D(at.t.None)}),[]),ne=(0,o.I4)((()=>{j(!0)}),[]),ae=(0,o.I4)((()=>{j(!1)}),[]),oe=(0,o.I4)((()=>{T({chatId:e}),ae(),R({id:e})}),[T,R,ae,e]),re=(0,o.I4)((()=>{R({id:e})}),[R,e]),ie=((e,t)=>{const[s,n]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?n(t):ot.fetch(a.fo,e,ot.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,rt.pt)(t).then((()=>{n(`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",!P&&"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<=a.l3?16:32,n=function(e){if(e>a._m){const t=Math.min(Math.max(.25*e,288),424),s=Math.min(.25*e,424);return Math.min(e-t-s,lt)}if(e>a.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<=a.l3?54:64,r=t?n-s-o:n-s,i=e>a.l3?Math.min(n-s,512):n-s,c=i/r,d=r/i;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?o/2*d:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:i/258,toolbarForUnpinHiddenScale:258/i}}(O,K)),[K,O]),Ce=(0,de.Z)("middle-column-footer",!K&&"no-composer",K&&q&&!P&&"with-notch");(0,ve.ZP)(z&&Y,(()=>{R({id:void 0},!0)}),void 0,void 0,void 0,i?i.map(ut.q):[]),(0,ve.ZP)(w,B),(0,ve.ZP)(P,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?a.It:a.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"}),z&&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:z,threadId:Y,messageListType:X,isReady:_}),o.ZP.createElement(we.Z,{name:E?"none":S===a.zy?"slide":"fade",activeKey:k,shouldCleanup:!0},(e=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(yn,{key:`${z}-${Y}-${X}`,chatId:z,threadId:Y,type:X,canPost:K,hasTools:J,onFabToggle:Q,onNotchToggle:G,isReady:_,isActive:e}),o.ZP.createElement("div",{className:Ce},K&&o.ZP.createElement(Ca,{chatId:z,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:ne},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(wa,{messageListType:X,isActive:P,canPost:K}),o.ZP.createElement(ba,{isOpen:Boolean(b),onClose:L}),o.ZP.createElement(Ma,{isOpen:Boolean(M),onClose:A}))))),o.ZP.createElement(Cn,{isShown:ee,canPost:K,withExtraShift:Ze||P||r})),m.wB&&o.ZP.createElement(Za,{isActive:Boolean(w)})),e&&o.ZP.createElement(Pa,{isOpen:H,chatId:e,pinnedMessagesCount:g,onClose:ae,onUnpin:oe}))}))),Ra=(0,w.Ds)((e=>e()),200,!1);var Ta;!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"}(Ta||(Ta={}));const Na=(0,o.X$)((0,n.c$)(((e,{chatId:t,isProfile:s,isManagement:n})=>{const{query:a}=(0,i.n5)(e)||{},{query:o}=(0,i.y5)(e)||{},{query:r}=(0,i.yN)(e)||{},c=t?(0,i.Z1)(e,t):void 0,l=c&&(0,d.eA)(c);return{canManage:Boolean(!n&&s&&c&&!(0,i.FM)(e,c.id)&&((0,d.YA)(c.id)||((0,d.Nl)(c)||c.isCreator)&&!c.isNotJoined)),isChannel:l,messageSearchQuery:a,stickerSearchQuery:o,gifSearchQuery:r}}),((e,t)=>(0,g.ei)(t,["setLocalTextSearchQuery","setStickerSearchQuery","setGifSearchQuery","searchTextMessagesLocal","toggleManagement","openHistoryCalendar"])))((({isColumnOpen:e,isProfile:t,isSearch:s,isManagement:n,isStickerSearch:a,isGifSearch:r,isPollResults:i,isAddingChatMembers:c,profileState:d,managementScreen:l,canManage:u,isChannel:g,onClose:f,messageSearchQuery:p,stickerSearchQuery:I,gifSearchQuery:v,setLocalTextSearchQuery:y,setStickerSearchQuery:C,setGifSearchQuery:Z,searchTextMessagesLocal:w,toggleManagement:P,openHistoryCalendar:b,shouldSkipAnimation:M})=>{var S;const E=(0,o.sO)(null),k=(0,o.I4)((e=>{y({query:e}),e.length&&Ra(w)}),[w,y]),R=(0,o.I4)((e=>{C({query:e})}),[C]),T=(0,o.I4)((e=>{Z({query:e})}),[Z]),[N,B]=(0,o.eJ)(!e);(0,o.d4)((()=>{setTimeout((()=>{B(!e)}),300)}),[e]);const x=(0,be.Z)(),L=t?d===h.vi.Profile?Ta.Profile:d===h.vi.SharedMedia?Ta.SharedMedia:d===h.vi.MemberList?Ta.MemberList:-1:s?Ta.Search:i?Ta.PollResults:a?Ta.StickerSearch:r?Ta.GifSearch:c?Ta.AddingMembers:n?l===h.u1.Initial?Ta.ManageInitial:l===h.u1.ChatPrivacyType?Ta.ManageChatPrivacyType:l===h.u1.Discussion?Ta.ManageDiscussion:l===h.u1.ChannelSubscribers?Ta.ManageChannelSubscribers:l===h.u1.GroupPermissions?Ta.ManageGroupPermissions:l===h.u1.ChatAdministrators?Ta.ManageChatAdministrators:l===h.u1.GroupRemovedUsers?Ta.ManageGroupRemovedUsers:l===h.u1.GroupUserPermissionsCreate?Ta.ManageGroupUserPermissionsCreate:l===h.u1.GroupUserPermissions?Ta.ManageGroupUserPermissions:l===h.u1.GroupRecentActions?Ta.ManageGroupRecentActions:l===h.u1.ChatAdminRights?Ta.ManageGroupAdminRights:l===h.u1.GroupMembers?Ta.ManageGroupMembers:void 0:void 0,A=null!==(S=(0,gt.Z)(L,!0))&&void 0!==S?S:-1;function O(){if(-1!==A)switch(A){case Ta.PollResults:return o.ZP.createElement("h3",null,x("PollResults"));case Ta.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Re.Z,{parentContainerClassName:"RightSearch",value:p,onChange:k}),o.ZP.createElement(ke.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>b({selectedAt:(0,U._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case Ta.AddingMembers:return o.ZP.createElement("h3",null,x("GroupAddMembers"));case Ta.ManageInitial:return o.ZP.createElement("h3",null,x("Edit"));case Ta.ManageChatPrivacyType:return o.ZP.createElement("h3",null,x(g?"ChannelTypeHeader":"GroupTypeHeader"));case Ta.ManageDiscussion:return o.ZP.createElement("h3",null,x("Discussion"));case Ta.ManageChatAdministrators:return o.ZP.createElement("h3",null,x("ChannelAdministrators"));case Ta.ManageGroupRecentActions:return o.ZP.createElement("h3",null,x("Group.Info.AdminLog"));case Ta.ManageGroupAdminRights:return o.ZP.createElement("h3",null,x("EditAdminRights"));case Ta.ManageGroupPermissions:return o.ZP.createElement("h3",null,x("ChannelPermissions"));case Ta.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,x("ChannelBlockedUsers"));case Ta.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,x("ChannelAddException"));case Ta.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,x("UserRestrictions"));case Ta.StickerSearch:return o.ZP.createElement(Re.Z,{value:I,placeholder:x("SearchStickersHint"),autoFocusSearch:!0,onChange:R});case Ta.GifSearch:return o.ZP.createElement(Re.Z,{value:v,placeholder:x("SearchGifsTitle"),autoFocusSearch:!0,onChange:T});case Ta.SharedMedia:return o.ZP.createElement("h3",null,x("SharedMedia"));case Ta.ManageChannelSubscribers:return o.ZP.createElement("h3",null,x("ChannelSubscribers"));case Ta.MemberList:case Ta.ManageGroupMembers:return o.ZP.createElement("h3",null,x("GroupMembers"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},u&&o.ZP.createElement(ke.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:x("Edit"),onClick:P},o.ZP.createElement("i",{className:"icon-edit"}))))}}const F=m.wB||L===Ta.SharedMedia||L===Ta.MemberList||L===Ta.AddingMembers||n,D=(0,de.Z)("animated-close-icon",F&&"state-back",(N||M)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(ke.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:f,ariaLabel:x(F?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:E,className:D})),o.ZP.createElement(we.Z,{name:N||M?"none":"slide-fade",activeKey:A},O))})));var Ba=s(91),xa=s(7407);function La(e,t,s,n,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,xa.Z)(n?s:void 0,c.current,void 0,"media"===e?a.EN:a.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const Aa=(0,w.P2)((e=>e()),250,!1);let Oa=!1;var Fa=s(1273),Ua=s(1876),Da=s(787),$a=s(180),Qa=s(3709),qa=s(5418),Ga=s(7262),Ha=s(1151),ja=s(3103);const _a=(0,o.X$)((0,n.c$)(((e,{userId:t})=>{const s=(0,i.jr)(e),n=t&&(0,i.dy)(e,t);return{chat:s,contactName:n?(0,d.Vl)(n):void 0}}),((e,t)=>(0,g.ei)(t,["deleteChatMember"])))((({isOpen:e,chat:t,userId:s,contactName:n,onClose:a,deleteChatMember:r})=>{const i=(0,be.Z)(),c=(0,o.I4)((()=>{r({chatId:t.id,userId:s}),a()}),[t,r,a,s]);if(t&&s)return o.ZP.createElement(ja.Z,{isOpen:e,onClose:a,onEnter:c,className:"delete",title:i("GroupRemoved.Remove")},o.ZP.createElement("p",null,(0,Zt.Z)(i("PeerInfo.Confirm.RemovePeer",n))),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:a},i("Cancel")))}))),Va=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function Wa(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > div.active > .${e}-list > .scroll-item`].join(", ")}const za=(0,o.X$)((0,n.c$)(((e,{chatId:t,userId:s})=>{var n;const a=(0,i.Z1)(e,t),o=(0,i.Zw)(e,s||t),{currentType:r,resultsByType:c}=(0,i.we)(e)||{},{foundIds:l}=c&&r&&c[r]||{},{byId:u}=e.users,{byId:h}=e.chats,m=a&&(0,d.Bf)(a),g=a&&(0,d.eA)(a),f=m||g&&(0,d.Nl)(a),p=null==a||null===(n=a.fullInfo)||void 0===n?void 0:n.members,I=f&&a&&a.fullInfo&&!a.fullInfo.canViewMembers,v=f&&a&&((0,d.VE)(a,"inviteUsers")||a.isCreator),y=f&&a&&((0,d.VE)(a,"banUsers")||a.isCreator),C=(0,i.xs)(e,t);let Z;return s?Z=s:(0,d.YA)(t)&&(Z=t),{theme:(0,i.Pu)(e),isChannel:g,resolvedUserId:Z,chatMessages:o,foundIds:l,mediaSearchType:r,hasMembersTab:f,areMembersHidden:I,canAddMembers:v,canDeleteMembers:y,currentUserId:e.currentUserId,isRightColumnShown:(0,i.Jf)(e),isRestricted:null==a?void 0:a.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:C,usersById:u,chatsById:h,...f&&p&&{members:p}}}),((e,t)=>(0,g.ei)(t,["setLocalMediaSearchType","loadMoreMembers","searchMediaMessagesLocal","openMediaViewer","openAudioPlayer","openUserInfo","focusMessage","loadProfilePhotos","setNewChatMembersDialogState"])))((({chatId:e,profileState:t,onProfileStateChange:s,theme:n,isChannel:r,resolvedUserId:i,currentUserId:c,chatMessages:l,foundIds:g,mediaSearchType:f,hasMembersTab:p,areMembersHidden:I,canAddMembers:v,canDeleteMembers:y,members:C,usersById:Z,chatsById:w,isRightColumnShown:P,isRestricted:b,lastSyncTime:M,activeDownloadIds:S,setLocalMediaSearchType:E,loadMoreMembers:k,searchMediaMessagesLocal:R,openMediaViewer:T,openAudioPlayer:N,openUserInfo:B,focusMessage:x,loadProfilePhotos:L,setNewChatMembersDialogState:A,serverTimeOffset:O})=>{const F=(0,o.sO)(null),U=(0,o.sO)(null),D=(0,be.Z)(),[$,Q]=(0,o.eJ)(0),[q,G]=(0,o.eJ)(),H=(0,o.Ye)((()=>[...p?[{type:"members",title:r?"ChannelSubscribers":"GroupMembers"}]:[],...Va]),[p,r]),j=H[$].type,[_,V,W,z]=function(e,t,s,n,r,i,c,l,u,h,m,g=0){const f="members"!==n&&r?r:n,p=(0,o.Ye)((()=>{if(i&&c)return(0,d.Z0)(i.map((({userId:e})=>e)),c,void 0,g)}),[i,g,c]),[I,v,y]=function(e,t,s,n){const[o,r]=(0,xa.Z)(s?t:void 0,n,void 0,a.Vk);return[o,r,!(!o||!n||o[0]===n[0])]}(0,t,m,p),[C,Z,w]=La("media",f,s,m,l,u),[P,b,M]=La("documents",f,s,m,l,u),[S,E,k]=La("links",f,s,m,l,u),[R,T,N]=La("audio",f,s,m,l,u),[B,x,L]=La("voice",f,s,m,l,u);let A,O,F=!1;switch(f){case"members":A=I,O=v,F=y;break;case"media":A=C,O=Z,F=w;break;case"documents":A=P,O=b,F=M;break;case"links":A=S,O=E,F=k;break;case"audio":A=R,O=T,F=N;break;case"voice":A=B,O=x,F=L}return[f,A,O,F]}(0,k,R,j,f,C,Z,l,g,0,M,O),Y=H.findIndex((({type:e})=>e===_)),{handleScroll:X}=function(e,t,s,n){(0,jt.Z)((([s])=>{if(s&&s!==t){const s=e.current,a=s.querySelector(".TabList");s.scrollTop<a.offsetTop&&(n("members"===t?h.vi.MemberList:h.vi.SharedMedia),Oa=!0,(0,Yt.Z)(s,a,"start",void 0,void 0,void 0,300),setTimeout((()=>{Oa=!1}),350))}}),[t,n]),(0,jt.Z)((([t])=>{if(s!==h.vi.Profile||s===t)return;const a=e.current;a&&a.querySelector(".TabList")&&(Oa=!0,(0,Yt.Z)(a,a.firstElementChild,"start",void 0,2*a.offsetHeight),setTimeout((()=>{Oa=!1}),350),n(s))}),[s]);const a=(0,o.I4)((()=>{const s=e.current;if(!s)return;const a=s.querySelector(".TabList");if(!a)return;let o=h.vi.Profile;s.scrollTop>=a.offsetTop&&(o="members"===t?h.vi.MemberList:h.vi.SharedMedia),n(o)}),[e,n,t]);return(0,o.d4)((()=>{Oa||a()}),[a,t]),{handleScroll:(0,o.I4)((()=>{Oa||Aa(a)}),[a])}}(F,j,t,s),{applyTransitionFix:K,releaseTransitionFix:J}=function(e,t=".Transition.shared-media-transition"){return(0,o.d4)((()=>{function s(){const s=e.current,n=s.querySelector(t),a=s.querySelector(".TabList");n&&a&&(n.style.minHeight=s.offsetHeight-a.offsetHeight+"px")}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]),{applyTransitionFix:(0,o.I4)((()=>{const t=e.current;if("hidden"!==t.style.overflowY){const e=t.offsetWidth-t.clientWidth;t.style.overflowY="hidden",t.style.marginRight=`${e}px`}}),[e]),releaseTransitionFix:(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e])}}(F),[ee,te]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),se=(0,o.I4)((()=>{J(),te()}),[J,te]),ne=(0,o.I4)((()=>{A(h.WB.InProgress)}),[A]);(0,o.d4)((()=>{E({mediaType:j})}),[E,j]);const ae=i||e;(0,o.d4)((()=>{M&&L({profileId:ae})}),[L,ae,M]);const oe=(0,o.I4)((e=>{T({chatId:ae,threadId:u._f,messageId:e,origin:h.bZ.SharedMedia})}),[ae,T]),re=(0,o.I4)((e=>{N({chatId:ae,messageId:e,origin:h.Cr.SharedMedia})}),[ae,N]),ie=(0,o.I4)((e=>{B({id:e})}),[B]),ce=(0,o.I4)((e=>{x({chatId:ae,messageId:e})}),[ae,x]),de=(0,o.I4)((()=>{G(void 0)}),[]);let le;(0,o.d4)((()=>{if(U.current&&m.$b)return(0,Oe.s)(U.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Oe.e.Left?(Q(Math.min($+1,H.length-1)),!0):t===Oe.e.Right&&(Q(Math.max(0,$-1)),!0)})}),[$,H.length]);const ue="members"===_||!p&&"media"===_;ue?le=P?0:1e3:V||(le=a.Y);const he=(0,da.Z)([e,_],le);function me(e){return e!==c&&y?[{title:D("lng_context_remove_from_group"),icon:"stop",handler:()=>{G(e)}}]:void 0}function ge(){if(!V||!he||!l){const e=ue&&V&&!he;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Le.Z,null))}if(!V.length){let e;switch(_){case"members":e=I?"You have no access to group members list.":"No members found";break;case"documents":e=D("lng_media_file_empty");break;case"links":e=D("lng_media_link_empty");break;case"audio":e=D("lng_media_song_empty");break;case"voice":e=D("lng_media_audio_empty");break;default:e=D("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(Ga.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${_}-list`,dir:D.isRtl&&"media"===_?"rtl":void 0,teactFastList:!0},"media"===_?V.map((e=>l[e]&&o.ZP.createElement(Qa.Z,{key:e,message:l[e],onClick:oe}))):"documents"===_?V.map((e=>l[e]&&o.ZP.createElement(Is.Z,{key:e,message:l[e],withDate:!0,smaller:!0,className:"scroll-item",onDateClick:ce,isDownloading:S.includes(e)}))):"links"===_?V.map((e=>l[e]&&o.ZP.createElement(qa.Z,{key:e,message:l[e],onMessageClick:ce}))):"audio"===_?V.map((e=>l[e]&&o.ZP.createElement(vs.Z,{key:e,theme:n,message:l[e],origin:h.Cr.SharedMedia,date:l[e].date,lastSyncTime:M,className:"scroll-item",onPlay:re,onDateClick:ce,isDownloading:S.includes(e)}))):"voice"===_?V.map((e=>l[e]&&o.ZP.createElement(vs.Z,{key:e,theme:n,message:l[e],senderTitle:(0,Ba.F)(D,l[e],w,Z),origin:h.Cr.SharedMedia,date:l[e].date,lastSyncTime:M,className:"scroll-item",onPlay:re,onDateClick:ce,isDownloading:S.includes(e)}))):"members"===_?V.map(((e,t)=>o.ZP.createElement(Ua.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>ie(e),contextActions:me(e)},o.ZP.createElement(pt.Z,{userId:e,forceShowSelf:!0})))):void 0)}return o.ZP.createElement(Fa.Z,{ref:F,className:"Profile custom-scroll",itemSelector:Wa(_),items:he?V:void 0,cacheBuster:ee,sensitiveArea:a.qU,preloadBackwards:he?"members"===_?a.Vk:a.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:W,onScroll:X},!z&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Da.Z,{userId:t||e}),o.ZP.createElement($a.Z,{chatOrUserId:t||e}))}(e,i),!b&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(we.Z,{ref:U,name:D.isRtl?"slide-reversed":"slide",activeKey:Y,renderCount:H.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:K,onStop:se},ge),o.ZP.createElement(Fe.Z,{big:!0,activeTab:$,tabs:H,onSwitchTab:Q})),v&&o.ZP.createElement(Ha.Z,{isShown:"members"===_,onClick:ne,ariaLabel:D("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),y&&o.ZP.createElement(_a,{isOpen:Boolean(q),userId:q,onClose:de}))}))),Ya=(0,o.X$)((e=>{const t=(0,Qe.Z)($e.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Xa=(0,o.X$)((e=>{const t=(0,Qe.Z)($e.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Ka=(0,o.X$)((()=>{const e=(0,Qe.Z)($e.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)})),Ja=(0,o.X$)((()=>{const e=(0,Qe.Z)($e.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)})),eo=(0,o.X$)((()=>{const e=(0,Qe.Z)($e.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)}));var to=s(1820);const so=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{var s;const n=(0,i.Z1)(e,t),{userIds:a}=e.contactList||{},{byId:o}=e.users,{byId:r}=e.chats,{currentUserId:c,newChatMembersProgress:l,connectionState:u}=e,m=n&&(0,d.eA)(n),{query:g,fetchingStatus:f,globalUserIds:p,localUserIds:I}=e.userSearch;return{isChannel:m,members:null==n||null===(s=n.fullInfo)||void 0===s?void 0:s.members,currentUserId:c,usersById:o,chatsById:r,localContactIds:a,searchQuery:g,isSearching:f,isLoading:l===h.WB.Loading,globalUserIds:p,localUserIds:I,connectionState:u}}),((e,t)=>(0,g.ei)(t,["loadContactList","setUserSearchQuery"])))((({isChannel:e,connectionState:t,members:s,onNextStep:n,currentUserId:a,usersById:r,chatsById:i,localContactIds:c,isLoading:l,searchQuery:u,isSearching:h,localUserIds:m,globalUserIds:f,setUserSearchQuery:p,onClose:I,isActive:v,loadContactList:y})=>{const C=(0,be.Z)(),[Z,w]=(0,o.eJ)([]),P=(0,Rs.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!==a)),i):[];if(!u)return t.filter((e=>!b.includes(e)));const s=t.filter((e=>{const t=r[e];if(!t)return!1;const s=(0,d.Js)(t);return s&&(0,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,a,r,b,e]),E=(0,o.I4)((()=>{Z.length&&(p({query:""}),n(Z))}),[Z,p,n]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(to.Z,{itemIds:S,selectedIds:Z,filterValue:u,filterPlaceholder:C("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:w,onFilterChange:M,noScrollRestore:P}),o.ZP.createElement(Ha.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"}))))}))),no=Object.keys(h.qt).length/2,ao=Object.keys(h.u1).length/2;function oo(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const ro=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},n=(0,i.g4)(e);return{contentKey:(0,i.Wq)(e),chatId:t,threadId:s,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(t&&n),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}),((e,t)=>(0,g.ei)(t,["openUserInfo","toggleChatInfo","toggleManagement","closeLocalTextSearch","setStickerSearchQuery","setGifSearchQuery","closePollResults","addChatMembers","setNewChatMembersDialogState"])))((({contentKey:e,chatId:t,threadId:s,currentProfileUserId:n,isChatSelected:r,toggleChatInfo:i,toggleManagement:c,openUserInfo:d,closeLocalTextSearch:l,setStickerSearchQuery:u,setGifSearchQuery:m,closePollResults:g,addChatMembers:f,setNewChatMembersDialogState:p,shouldSkipHistoryAnimations:I})=>{var v;const{width:y}=ct(),[C,Z]=(0,o.eJ)(h.vi.Profile),[w,P]=(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<=a._m,[U,D]=(0,o.eJ)(!R),$=null!==(v=(0,gt.Z)(e,!0,!r))&&void 0!==v?v:-1,Q=(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(w){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:P(h.u1.Initial);break;case h.u1.GroupUserPermissionsCreate:case h.u1.GroupRemovedUsers:case h.u1.GroupUserPermissions:P(h.u1.GroupPermissions),M(void 0),E(void 0);break;case h.u1.ChatAdminRights:case h.u1.GroupRecentActions:P(h.u1.ChatAdministrators)}break;case h.qt.Search:oo(),l();break;case h.qt.StickerSearch:oo(),u({query:void 0});break;case h.qt.GifSearch:oo(),m({query:void 0});break;case h.qt.PollResults:g()}}),[e,k,i,d,g,p,w,c,l,u,m]),q=(0,o.I4)(((e,t)=>{M(e),E(t)}),[]),G=(0,o.I4)((e=>{f({chatId:t,memberIds:e})}),[f,t]);function H(e){if(-1!==$)switch($){case h.qt.AddingMembers:return o.ZP.createElement(so,{chatId:t,onNextStep:G,isActive:R&&e,onClose:Q});case h.qt.ChatInfo:case h.qt.UserInfo:return o.ZP.createElement(za,{key:n||t,chatId:t,userId:n,profileState:C,onProfileStateChange:Z});case h.qt.Search:return o.ZP.createElement(Ya,{chatId:t,threadId:s,onClose:Q,isActive:R&&e});case h.qt.Management:return o.ZP.createElement(Xa,{chatId:t,currentScreen:w,isPromotedByCurrentUser:S,selectedChatMemberId:b,onScreenSelect:P,onChatMemberSelect:q,isActive:R&&e,onClose:Q});case h.qt.StickerSearch:return o.ZP.createElement(Ka,{onClose:Q,isActive:R&&e});case h.qt.GifSearch:return o.ZP.createElement(Ja,{onClose:Q,isActive:R&&e});case h.qt.PollResults:return o.ZP.createElement(eo,{onClose:Q,isActive:R&&e})}}return(0,o.d4)((()=>R?(0,ye.Z)(Q):void 0),[R,Q]),(0,o.d4)((()=>{setTimeout((()=>{D(!R)}),300)}),[R]),(0,o.d4)((()=>{R&&F&&Q()}),[F]),(0,Ht.Z)((([s,n])=>{(s===h.qt.ChatInfo&&e===h.qt.UserInfo||s===h.qt.UserInfo&&e===h.qt.ChatInfo||n!==t)&&(Z(h.vi.Profile),P(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),(()=>Q(!1)),i),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:r?void 0:"is-hidden"},F&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:Q}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(Na,{chatId:t,isColumnOpen:R,isProfile:T,isSearch:N,isManagement:B,isStickerSearch:x,isGifSearch:L,isPollResults:A,isAddingChatMembers:O,profileState:C,managementScreen:w,onClose:Q,shouldSkipAnimation:U||I}),o.ZP.createElement(we.Z,{name:U||I?"none":"zoom-fade",renderCount:no+ao,activeKey:B?no+w:$,shouldCleanup:!0,cleanupExceptionKey:h.qt.ChatInfo},H)))}))),io=(0,o.X$)((({isOpen:e})=>{const t=(0,Qe.Z)($e.gl.Extra,"MediaViewer",!e);return t?o.ZP.createElement(t,null):void 0}));function co(e,t){const s=document.createElement("a");s.href=e,s.download=t;try{s.click()}catch(e){console.error(e)}}const lo=new Set,uo=(0,o.X$)((0,n.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,n])=>{n.map((s=>t[Number(e)].byId[s])).forEach((e=>{const t=(0,d.Ti)(e,"download");if(t){if(!lo.has(t)){const n=Tt.UV(t);if(n)return lo.delete(t),co(n,(0,d.w6)(e)),void s({message:e});Tt.he(t,u.IU.BlobUrl,!0).then((n=>{lo.delete(t),n&&co(n,(0,d.w6)(e)),s({message:e})})),lo.add(t)}}else s({message:e})}))}))}),[s,t,e])}))),ho=(0,o.X$)((({isOpen:e})=>{const t=(0,Qe.Z)($e.gl.Extra,"Notifications",!e);return t?o.ZP.createElement(t,null):void 0})),mo=(0,o.X$)((({isOpen:e})=>{const t=(0,Qe.Z)($e.gl.Extra,"Dialogs",!e);return t?o.ZP.createElement(t,null):void 0})),go=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"ForwardPicker",!t);return s?o.ZP.createElement(s,e):void 0})),fo=(0,o.X$)((e=>{const{url:t}=e,s=(0,Qe.Z)($e.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0})),po=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Qe.Z)($e.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0}));let Io,vo=!1;function yo(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 Co(e){document.title!==e&&(document.title=e)}const Zo=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,messageId:s,origin:n}=e.audioPlayer,a=t&&s?(0,i.hj)(e,t,s):void 0;return{animationLevel:e.settings.byKey.animationLevel,lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,i.Jf)(e),isMediaViewerOpen:(0,i.zQ)(e),isForwardModalOpen:(0,i.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:a,audioOrigin:n,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,language:e.settings.byKey.language,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,i.UW)(e)}}),((e,t)=>(0,g.ei)(t,["loadAnimatedEmojis","loadNotificationSettings","loadNotificationExceptions","updateIsOnline","loadTopInlineBots","loadEmojiKeywords","openStickerSetShortName","loadCountryList","checkVersionNotification"])))((({lastSyncTime:e,isLeftColumnShown:t,isRightColumnShown:s,isMediaViewerOpen:r,isForwardModalOpen:c,animationLevel:d,hasNotifications:l,hasDialogs:u,audioMessage:h,audioOrigin:g,safeLinkModalUrl:f,isHistoryCalendarOpen:p,shouldSkipHistoryAnimations:I,language:v,openedStickerSetShortName:y,isServiceChatReady:C,loadAnimatedEmojis:Z,loadNotificationSettings:b,loadNotificationExceptions:M,updateIsOnline:S,loadTopInlineBots:E,loadEmojiKeywords:k,loadCountryList:R,openStickerSetShortName:T,checkVersionNotification:N})=>{a.eM&&!vo&&(vo=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{e&&(S(!0),Z(),b(),M(),E(),k({language:a.pR}),v!==a.pR&&k({language:v}),R({langCode:v}))}),[e,Z,M,b,S,E,k,R,v]),(0,o.d4)((()=>{e&&C&&N()}),[e,C,N]),(0,o.d4)((()=>{e&&ve.Oy.startsWith("#?tgaddr=")&&P(decodeURIComponent(ve.Oy.substr("#?tgaddr=".length)))}),[e]);const{transitionClassNames:B}=(0,ue.Z)(!t,void 0,!0,void 0,I),{transitionClassNames:x}=(0,ue.Z)(s,void 0,!0,void 0,I),L=(0,de.Z)(B.replace(/([\w-]+)/g,"middle-column-$1"),x.replace(/([\w-]+)/g,"right-column-$1"),I&&"history-animation-disabled");(0,ge.Z)((([e])=>{if(void 0===e||0===d)return;const t=(0,ce.YW)();(0,le.L)(document.getElementById("MiddleColumn"),t)}),[t]),(0,ge.Z)((([e])=>{if(void 0===e||0===d)return;(0,w.T2)((()=>{document.body.classList.add("animating-right-column")}));const t=(0,ce.YW)();(0,le.L)(document.getElementById("RightColumn"),(()=>{t(),(0,w.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[s]);const A=(0,o.I4)((()=>{S(!1);const e=(0,i.A1)((0,n.Rd)());let t=0;clearInterval(Io),Io=window.setInterval((()=>{if(document.title.includes(a.ou))yo(!1);else{if(t%2==0){const t=(0,i.A1)((0,n.Rd)())-e;t>0&&(Co(`${t} notification${t>1?"s":""}`),yo(!0))}else Co(a.Ti),yo(!1);t++}}),1e3)}),[S]),O=(0,o.I4)((()=>{S(!0),clearInterval(Io),Io=void 0,document.title.includes(a.ou)||Co(a.Ti),yo(!1)}),[S]),F=(0,o.I4)((()=>{T({stickerSetShortName:void 0})}),[T]);function U(e){e.preventDefault(),e.stopPropagation()}return(0,he.Z)(A,O),me(A),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:L,onDrop:U,onDragOver:U},o.ZP.createElement(nt,null),o.ZP.createElement(ka,null),o.ZP.createElement(ro,null),o.ZP.createElement(io,{isOpen:r}),o.ZP.createElement(go,{isOpen:c}),o.ZP.createElement(ho,{isOpen:l}),o.ZP.createElement(mo,{isOpen:u}),h&&o.ZP.createElement(qt,{key:h.id,message:h,origin:g,noUi:!0}),o.ZP.createElement(fo,{url:f}),o.ZP.createElement(po,{isOpen:p}),o.ZP.createElement(Ps.Z,{isOpen:Boolean(y),onClose:F,stickerSetShortName:y}),o.ZP.createElement(uo,null))})));a.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,n.Rd)().connectionState||(0,n.uC)().initApi()},4524:(e,t,s)=>{e.exports=s.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg"}}]);
|
||
//# sourceMappingURL=214.47b1b181098daaea7459.js.map
|