TelegramPWA/dist/5769.d2b8af27d159fb4beb9a.js
Alexander Zinchuk 54b5c8c7e4 [Build]
2022-08-07 18:43:53 +02:00

2 lines
325 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

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

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[5769],{73181:(e,t,n)=>{n.r(t),n.d(t,{LockScreen:()=>$r,Main:()=>Ur});var s=n(33555),a=n(83716),i=n(14050),o=(n(89005),n(6137)),r=n(5161),c=n(11192),l=n(70735),d=n(83158);function u(e){const{chatId:t,threadId:n}=(0,c.Bt)(e)||{};return t&&n?(e=(0,r.qr)(e,t,n,!1),e=(0,r.Pb)(e,t,n,void 0)):e}(0,s.iw)("openLocalTextSearch",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{};if(t&&n)return(0,r.qr)(e,t,n,!0)})),(0,s.iw)("closeLocalTextSearch",u),(0,s.iw)("setLocalTextSearchQuery",((e,t,n)=>{const{chatId:s,threadId:a}=(0,c.Bt)(e)||{};if(!s||!a)return;const{query:i}=n,o=(0,d.uw)(s,a),{query:u}=e.localTextSearch.byChatThreadKey[o]||{};return i!==u&&(e=(0,r.Pb)(e,s,a,l.D)),(0,r.qr)(e,s,a,!0,i)})),(0,s.iw)("setLocalMediaSearchType",((e,t,n)=>{const{chatId:s}=(0,c.Bt)(e)||{};if(!s)return;const{mediaType:a}=n;return(0,r.z5)(e,s,a)})),(0,s.iw)("openChat",((e,t,n)=>{var s,a;const{id:i,threadId:l=o._f,type:d="thread",shouldReplaceHistory:m=!1}=n,h=(0,c.Bt)(e);return null!==(s=e.premiumModal)&&void 0!==s&&s.promo&&null!==(a=e.premiumModal)&&void 0!==a&&a.isOpen&&(e={...e,premiumModal:{...e.premiumModal,isOpen:!1}}),h&&h.chatId===i&&h.threadId===l&&h.type===d||(i&&(e=(0,r.pf)(e,i,l,"replyStack",[])),e=u(e=(0,r.i9)(e)),e={...e,isStatisticsShown:!1,messages:{...e.messages,contentToBeScheduled:void 0},...i!==e.forwardMessages.toChatId&&{forwardMessages:{}}}),(0,r.Wy)(e,i,l,d,m)})),(0,s.iw)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,s.iw)("openChatWithInfo",((e,t,n)=>{(0,s.R3)({...e,isChatInfoShown:!0}),t.openChat(n)})),(0,s.iw)("openChatWithText",((e,t,n)=>{const{chatId:s,text:a}=n;return t.openChat({id:s}),{...e,openChatWithText:{chatId:s,text:a}}})),(0,s.iw)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,s.iw)("setNewChatMembersDialogState",((e,t,n)=>({...e,newChatMembersProgress:n}))),(0,s.iw)("openNextChat",((e,t,n)=>{const{targetIndexDelta:s,orderedIds:a}=n,{chatId:i}=(0,c.Bt)(e)||{};if(!i)return void t.openChat({id:a[0]});const o=a.indexOf(i);if(-1===o)return;const r=a[o+s];t.openChat({id:r,shouldReplaceHistory:!0})})),(0,s.iw)("openDeleteChatFolderModal",((e,t,n)=>{const{folderId:s}=n;return{...e,deleteFolderDialogModal:s}})),(0,s.iw)("closeDeleteChatFolderModal",(e=>({...e,deleteFolderDialogModal:void 0})));var m=n(91713),h=n(77361),g=n(60782),p=n(82267),f=n(83099),v=n(50711),I=n(64319);const w=a.ck+a.fK;let y;function Z(e,t,n){const{threadId:s}=(0,c.Bt)(e)||{},a=v.i0,i=(0,c.Zw)(e,t);if(!i||!s)return;const o=n.map((e=>i[e])).filter((t=>(0,c._k)(e,t,s).canCopy)).sort(((e,t)=>e.id-t.id)).reduce(((t,n)=>{const s=(0,c.Ur)(e,n);return t.push(`> ${s?(0,d.OU)(a,s):""}:`),t.push(`${(0,d.MK)(a,n,!1,0,void 0,!0)}\n`),t}),[]);(0,I.TE)(o.join("\n"))}(0,s.iw)("setScrollOffset",((e,t,n)=>{const{chatId:s,threadId:a,scrollOffset:i}=n;return(0,r.pf)(e,s,a,"scrollOffset",i)})),(0,s.iw)("setReplyingToId",((e,t,n)=>{const{messageId:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:i,threadId:o}=a;return(0,r.pf)(e,i,o,"replyingToId",s)})),(0,s.iw)("setEditingId",((e,t,n)=>{const{messageId:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:i,threadId:o,type:l}=a,d="scheduled"===l?"editingScheduledId":"editingId";return(0,r.pf)(e,i,o,d,s)})),(0,s.iw)("setEditingDraft",((e,t,n)=>{const{text:s,chatId:a,threadId:i,type:o}=n,c="scheduled"===o?"editingScheduledDraft":"editingDraft";return(0,r.pf)(e,a,i,c,s)})),(0,s.iw)("editLastMessage",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{};if(!t||!n)return;const s=(0,c.Zw)(e,t),a=(0,c.Cb)(e,t,n);if(!s||!a)return;const i=(0,g.dF)(a,(t=>Boolean(s[t]&&(0,c._k)(e,s[t],n).canEdit)));return i?(0,r.pf)(e,t,n,"editingId",i):void 0})),(0,s.iw)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:s}=n,{chatId:a,threadId:i}=(0,c.Bt)(e)||{};if(!a||!i)return;const r=(0,c.Zw)(e,a),l=(0,c.Cb)(e,a,i);if(!r||!l)return;const d=(0,c.Yy)(e,a,i);let u;if((0,c.b9)(e,a,i)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+s;u=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(i===o._f){var m;const t=(0,c.Z1)(e,a);u=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,c.tZ)(e,a,i);u=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:u}),t.focusMessage({chatId:a,threadId:i,messageId:u})})),(0,s.iw)("openAudioPlayer",((e,t,n)=>{const{chatId:s,threadId:a,messageId:i,origin:o,volume:r,playbackRate:c,isMuted:l}=n;return{...e,audioPlayer:{chatId:s,threadId:a,messageId:i,origin:null!=o?o:e.audioPlayer.origin,volume:null!=r?r:e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:l||e.audioPlayer.isMuted}}})),(0,s.iw)("setAudioPlayerVolume",((e,t,n)=>{const{volume:s}=n;return{...e,audioPlayer:{...e.audioPlayer,volume:s,isMuted:!1}}})),(0,s.iw)("setAudioPlayerPlaybackRate",((e,t,n)=>{const{playbackRate:s}=n;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:s}}})),(0,s.iw)("setAudioPlayerMuted",((e,t,n)=>{const{isMuted:s}=n;return{...e,audioPlayer:{...e.audioPlayer,isMuted:s}}})),(0,s.iw)("setAudioPlayerOrigin",((e,t,n)=>{const{origin:s}=n;return{...e,audioPlayer:{...e.audioPlayer,origin:s}}})),(0,s.iw)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,s.iw)("openPollResults",((e,t,n)=>{const{chatId:a,messageId:i}=n;if((0,c.Jf)(e)){if(a!==e.pollResults.chatId||i!==e.pollResults.messageId)return{...e,pollResults:{chatId:a,messageId:i,voters:{}}}}else window.setTimeout((()=>{e=(0,s.Rd)(),(0,s.R3)({...e,pollResults:{chatId:a,messageId:i,voters:{}}})}),450)})),(0,s.iw)("closePollResults",(e=>({...e,pollResults:{}}))),(0,s.iw)("focusLastMessage",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:s,threadId:a}=n;let i;if(a===o._f){var r;const t=(0,c.Z1)(e,s);i=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,c.tZ)(e,s,a);i=null==t?void 0:t.lastMessageId}i&&t.focusMessage({chatId:s,threadId:a,messageId:i,noHighlight:!0})})),(0,s.iw)("focusNextReply",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:a,threadId:i}=n,o=(0,c.p9)(e,a,i);if(o&&0!==o.length){const n=o.pop();e=(0,r.pf)(e,a,i,"replyStack",[...o]),(0,s.R3)(e),t.focusMessage({chatId:a,threadId:i,messageId:n})}else t.focusLastMessage()})),(0,s.iw)("focusMessage",((e,t,n)=>{const{chatId:a,threadId:i=o._f,messageListType:l="thread",noHighlight:d,groupedId:u,groupedChatId:h,replyMessageId:g,isResizingContainer:p,shouldReplaceHistory:f}=n;let{messageId:v}=n;if(void 0!==u){const t=(0,c.y8)(e,h,u);null!=t&&t.length&&([v]=t)}const I=(0,c.Bt)(e),Z=!I||a!==I.chatId||i!==I.threadId||l!==I.type;if(y&&(clearTimeout(y),y=void 0),y=window.setTimeout((()=>{let e=(0,s.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,s.R3)(e)}),d?w:1500),e=(0,r.cq)(e,a,v,d,p),e=(0,r.wV)(e,void 0),g){const t=(0,c.p9)(e,a,i)||[];e=(0,r.pf)(e,a,i,"replyStack",[...t,g])}Z&&(e=(0,r.wV)(e,m.fo.Static));const P=(0,c.Cb)(e,a,i);if(P&&P.includes(v))return(0,s.R3)(e),void t.openChat({id:a,threadId:i,shouldReplaceHistory:f});if(Z&&(e=(0,r.pf)(e,a,i,"viewportIds",void 0)),e=(0,r.pf)(e,a,i,"outlyingIds",void 0),P&&!Z){const t=v>P[0]?m.fo.Down:m.fo.Up;e=(0,r.wV)(e,t)}(0,s.R3)(e),t.openChat({id:a,threadId:i,shouldReplaceHistory:f}),t.loadViewportMessages()})),(0,s.iw)("openForwardMenu",((e,t,n)=>{const{fromChatId:s,messageIds:a,groupedId:i,withMyScore:o}=n;let r;return i&&(r=(0,c.xH)(e,s,i)),{...e,forwardMessages:{fromChatId:s,messageIds:r||a,isModalShown:!0,withMyScore:o}}})),(0,s.iw)("changeForwardRecipient",(e=>({...e,forwardMessages:{...e.forwardMessages,toChatId:void 0,isModalShown:!0,noAuthors:!1,noCaptions:!1}}))),(0,s.iw)("setForwardNoAuthors",((e,t,n)=>({...e,forwardMessages:{...e.forwardMessages,noAuthors:n,noCaptions:n&&e.forwardMessages.noCaptions}}))),(0,s.iw)("setForwardNoCaptions",((e,t,n)=>({...e,forwardMessages:{...e.forwardMessages,noCaptions:n,noAuthors:n}}))),(0,s.iw)("exitForwardMode",(e=>{(0,s.R3)({...e,forwardMessages:{}})})),(0,s.iw)("setForwardChatId",((e,t,n)=>{const{id:a}=n;(0,s.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:a,isModalShown:!1}}),t.openChat({id:a}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,s.iw)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:s}=e.selectedMessages;t.openForwardMenu({fromChatId:n,messageIds:s})})),(0,s.iw)("cancelMessageMediaDownload",((e,t,n)=>{const{message:a}=n,i=e.activeDownloads.byChatId[a.chatId];i&&i.length&&(0,s.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:i.filter((e=>e!==a.id))}}})})),(0,s.iw)("cancelMessagesMediaDownload",((e,t,n)=>{const{messages:s}=n,a=e.activeDownloads.byChatId,i={};return Object.keys(a).forEach((e=>{i[e]=a[e].filter((e=>!s.find((t=>t.id===e))))})),{...e,activeDownloads:{byChatId:i}}})),(0,s.iw)("downloadMessageMedia",((e,t,n)=>{const{message:a}=n;(0,s.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:[...e.activeDownloads.byChatId[a.chatId]||[],a.id]}}})})),(0,s.iw)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:s}=e.selectedMessages,{threadId:a}=(0,c.Bt)(e)||{},i=(0,c.Zw)(e,n);i&&a&&s.map((e=>i[e])).filter((t=>(0,c._k)(e,t,a).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,s.iw)("enterMessageSelectMode",((e,t,n)=>{const{messageId:s}=n||{},a=(0,c.jr)(e);return a?(0,r.M6)(e,a.id,s):e})),(0,s.iw)("toggleMessageSelection",((e,t,n)=>{const{messageId:a,groupedId:i,childMessageIds:o,withShift:l}=n,d=(0,c.Bt)(e);if(!d)return;const{chatId:u,threadId:m,type:g}=d;e=(0,r.Ob)(e,u,m,g,a,i,o,l),(0,s.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${h.$b?"long tap":"right click"} on a message.`}))})),(0,s.iw)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,s.iw)("exitMessageSelectMode",r.i9),(0,s.iw)("openPollModal",((e,t,n)=>{const{isQuiz:s}=n||{};return{...e,pollModal:{isOpen:!0,isQuiz:s}}})),(0,s.iw)("closePollModal",(e=>({...e,pollModal:{isOpen:!1}}))),(0,s.iw)("checkVersionNotification",((e,t)=>{const n=a.Ji.split(".").slice(0,2).join("."),{serviceNotifications:s}=e;if(s.find((e=>{let{version:t}=e;return t===n})))return;const i={chatId:a.aw,date:(0,p.b)(e.serverTimeOffset),content:{text:(0,f.Z)("**Telegram Web Z was updated to version 1.50**\n\n👏 **Harder**\n• Flexible Forwarding: Forward messages without the sender's name or media captions.\n• Reorder Folders: Change the order of your folders in Settings.\n• Better Drag & Drop: Open a chat in your list by dragging a file to it.\n\n🤩 **Better**\n• Added more emojis.\n• Media Viewer now supports scrolling through profile pictures.\n• Use the hotkey `⌘+0` to open Saved Messages on macOS.\n• Triple click will now select all text in the message field.\n• Large file downloads (2 GB+) are supported in more browsers.\n• Added colored icons for the invite link section in groups and channels.\n• Added support for deleting chats with service notifications.\n• Background color now adapts for better contrast in uploaded transparent images.\n• Added support for SmallTalk highlighting, thanks to LinqLover on GitHub.\n\n💪 **Stronger**\n• Fixed issue with countable text localization in some languages.\n• Removed download button from media in chats with content protection enabled.\n• Various call fixes.\n• Small redesign for code formatting, fixed parsing issues.\n• Fixed video controls on mobile devices, thanks to y0ung3r on GitHub.\n• Fixed duplicated messages in CJK languages.\n• Removed View in Picture-in-Picture button from stickers.\n• Fixed layout issues in Waterfox Classic.\n• Fixed issue with replies in discussions.\n• Small design improvements related to Telegram Premium.\n",!0)},isOutgoing:!1};t.createServiceNotification({message:i,version:n})})),(0,s.iw)("createServiceNotification",((e,t,n)=>{var i;const{message:o,version:r}=n,{serviceNotifications:l}=e,d=(0,c.Z1)(e,a.aw),u=Math.max((null===(i=d.lastMessage)||void 0===i?void 0:i.id)||0,...l.map((e=>{let{id:t}=e;return t}))),m=(l.length+1)/1e3,h=Math.floor(u)+m;o.previousLocalId=o.id,o.id=h;const g={id:h,message:o,version:r,isUnread:!0};(0,s.R3)({...e,serviceNotifications:[...l.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:o.id,chatId:o.chatId,message:o})})),(0,s.iw)("openReactorListModal",((e,t,n)=>{const{chatId:s,messageId:a}=n;return{...e,reactorModal:{chatId:s,messageId:a}}})),(0,s.iw)("closeReactorListModal",(e=>({...e,reactorModal:void 0}))),(0,s.iw)("openSeenByModal",((e,t,n)=>{const{chatId:s,messageId:a}=n;return{...e,seenByModal:{chatId:s,messageId:a}}})),(0,s.iw)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,s.iw)("copySelectedMessages",(e=>{if(!e.selectedMessages)return;const{chatId:t,messageIds:n}=e.selectedMessages;Z(e,t,n)})),(0,s.iw)("copyMessagesByIds",((e,t,n)=>{const{messageIds:s}=n,a=(0,c.jr)(e);s&&0!==s.length&&a&&Z(e,a.id,s)})),(0,s.iw)("setGlobalSearchQuery",((e,t,n)=>{const{query:s}=n,{chatId:a}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...s?{fetchingStatus:{chats:!a,messages:!0}}:{fetchingStatus:void 0},query:s})})),(0,s.iw)("addRecentlyFoundChatId",((e,t,n)=>{const{id:s}=n,{recentlyFoundChatIds:a}=e.globalSearch;if(!a)return(0,r.No)(e,{recentlyFoundChatIds:[s]});const i=a.filter((e=>e!==s));return i.unshift(s),i.length>10&&i.pop(),(0,r.No)(e,{recentlyFoundChatIds:i})})),(0,s.iw)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,s.iw)("setGlobalSearchContent",((e,t,n)=>{const{content:s}=n;return(0,r.Og)(e,s)})),(0,s.iw)("setGlobalSearchChatId",((e,t,n)=>{const{id:s}=n;return(0,r.No)(e,{chatId:s,query:void 0,resultsByType:void 0})})),(0,s.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:s}=n;return{...e,stickers:{...e.stickers,search:{query:s,resultIds:void 0}}}})),(0,s.iw)("setGifSearchQuery",((e,t,n)=>{const{query:s}=n;return{...e,gifs:{...e.gifs,search:{query:s,offsetId:void 0,results:void 0}}}})),(0,s.iw)("setUserSearchQuery",((e,t,n)=>{const{query:s}=n;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(s),query:s})})),(0,s.iw)("openAddContactDialog",((e,t,n)=>{const{userId:s}=n;return{...e,newContact:{userId:s}}})),(0,s.iw)("openNewContactDialog",(e=>({...e,newContact:{isByPhoneNumber:!0}}))),(0,s.iw)("closeNewContactDialog",(e=>(0,r.ft)(e))),n(73456);var P=n(91947),C=n(26926);(0,s.iw)("toggleChatInfo",((e,t,n)=>({...e,isChatInfoShown:void 0!==n?n:!e.isChatInfoShown}))),(0,s.iw)("setLeftColumnWidth",((e,t,n)=>({...e,leftColumnWidth:n}))),(0,s.iw)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,s.iw)("toggleManagement",(e=>{const{chatId:t}=(0,c.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,s.iw)("requestNextManagementScreen",((e,t,n)=>{const{screen:s}=n||{},{chatId:a}=(0,c.Bt)(e)||{};if(a)return{...e,management:{byChatId:{...e.management.byChatId,[a]:{...e.management.byChatId[a],isActive:!0,nextScreen:s}}}}})),(0,s.iw)("closeManagement",(e=>{const{chatId:t}=(0,c.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,s.iw)("openChat",(e=>{if(h.wB||h.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,s.iw)("toggleStatistics",(e=>({...e,isStatisticsShown:!e.isStatisticsShown,statistics:{...e.statistics,currentMessageId:void 0}}))),(0,s.iw)("toggleMessageStatistics",((e,t,n)=>({...e,statistics:{...e.statistics,currentMessageId:null==n?void 0:n.messageId}}))),(0,s.iw)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,s.iw)("addRecentEmoji",((e,t,n)=>{const{emoji:s}=n,{recentEmojis:a}=e;if(!a)return{...e,recentEmojis:[s]};const i=a.filter((e=>e!==s));return i.unshift(s),i.length>18&&i.pop(),{...e,recentEmojis:i}})),(0,s.iw)("addRecentSticker",((e,t,n)=>{const{sticker:s}=n,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[s]}}};const i=a.stickers.filter((e=>e.id!==s.id));return i.unshift(s),{...e,stickers:{...e.stickers,recent:{...a,stickers:i}}}})),(0,s.iw)("reorderStickerSets",((e,t,n)=>{const{order:s}=n;return{...e,stickers:{...e.stickers,added:{setIds:s}}}})),(0,s.iw)("showNotification",((e,t,n)=>{const s=n;s.localId=(0,C.Z)({});const a=[...e.notifications],i=a.findIndex((e=>e.message===s.message));return-1!==i&&a.splice(i,1),a.push(s),{...e,notifications:a}})),(0,s.iw)("dismissNotification",((e,t,n)=>{const s=e.notifications.filter((e=>{let{localId:t}=e;return t!==n.localId}));return{...e,notifications:s}})),(0,s.iw)("showDialog",((e,t,n)=>{const{data:s}=n;if("message"in s&&s.hasErrorKey&&!(0,P.ZP)(s))return e;const a=[...e.dialogs];if("message"in s){const e=a.findIndex((e=>e.message===s.message));-1!==e&&a.splice(e,1)}return a.push(s),{...e,dialogs:a}})),(0,s.iw)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,s.iw)("toggleSafeLinkModal",((e,t,n)=>{const{url:s}=n;return{...e,safeLinkModalUrl:s}})),(0,s.iw)("openHistoryCalendar",((e,t,n)=>{const{selectedAt:s}=n;return{...e,historyCalendarSelectedAt:s}})),(0,s.iw)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,s.iw)("openGame",((e,t,n)=>{const{url:a,chatId:i,messageId:o}=n,r=(0,c.hj)(e,i,o);if(!r)return;const l=r.viaBotId||r.senderId;l&&((0,c.LM)(e,l)?(0,s.R3)({...e,openedGame:{url:a,chatId:i,messageId:o}}):(0,s.R3)({...e,botTrustRequest:{botId:l,type:"game",onConfirm:{action:"openGame",payload:n}}}))})),(0,s.iw)("closeGame",(e=>({...e,openedGame:void 0}))),(0,s.iw)("requestConfetti",((e,t,n)=>{const{top:s,left:a,width:i,height:o}=n||{},{animationLevel:r}=e.settings.byKey;if(0!==r)return{...e,confetti:{lastConfettiTime:Date.now(),top:s,left:a,width:i,height:o}}})),(0,s.iw)("openLimitReachedModal",((e,t,n)=>{const{limit:s}=n;return{...e,limitReachedModal:{limit:s}}})),(0,s.iw)("closeLimitReachedModal",(e=>({...e,limitReachedModal:void 0}))),(0,s.iw)("closePaymentModal",(e=>{const t=e.payment.status;return e=(0,r.bp)(e),e=(0,r.WY)(e),{...e,payment:{...e.payment,status:t}}})),(0,s.iw)("addPaymentError",((e,t,n)=>{const{error:s}=n;return{...e,payment:{...e.payment,status:"failed",error:s}}}));var b=n(88422);(0,s.iw)("openMediaViewer",((e,t,n)=>{const{chatId:s,threadId:a,mediaId:i,avatarOwnerId:o,profilePhotoIndex:r,origin:c,volume:l,playbackRate:d,isMuted:u}=n;return{...e,mediaViewer:{...e.mediaViewer,chatId:s,threadId:a,mediaId:i,avatarOwnerId:o,profilePhotoIndex:r,origin:c,volume:null!=l?l:e.mediaViewer.volume,playbackRate:d||e.mediaViewer.playbackRate,isMuted:u||e.mediaViewer.isMuted},forwardMessages:{}}})),(0,s.iw)("closeMediaViewer",(e=>{const{volume:t,isMuted:n,playbackRate:s}=e.mediaViewer;return{...e,mediaViewer:{volume:t,isMuted:n,playbackRate:s}}})),(0,s.iw)("setMediaViewerVolume",((e,t,n)=>{const{volume:s}=n;return{...e,mediaViewer:{...e.mediaViewer,volume:s,isMuted:!1}}})),(0,s.iw)("setMediaViewerPlaybackRate",((e,t,n)=>{const{playbackRate:s}=n;return{...e,mediaViewer:{...e.mediaViewer,playbackRate:s}}})),(0,s.iw)("setMediaViewerMuted",((e,t,n)=>{const{isMuted:s}=n;return{...e,mediaViewer:{...e.mediaViewer,isMuted:s}}}));var S=n(3100),M=n(95281),E=n(5872),R=n(69118);let k=!1;(0,R.Gq)((()=>{(0,s.Rd)().passcode.hasPasscode&&!k&&(0,S.jv)()})),(0,s.iw)("setPasscode",(async(e,t,n)=>{let{passcode:a}=n;(0,s.R3)((0,r.vu)(e,{isLoading:!0})),await(0,M.AU)(a);const i=JSON.stringify({...(0,S.K8)(),userId:e.currentUserId}),o=(0,E.Uf)((0,r.vu)((0,s.Rd)(),{hasPasscode:!0,error:void 0,isLoading:!1}));await(0,M.H4)(i,o),(0,s.R3)((0,r.vu)((0,s.Rd)(),{hasPasscode:!0,error:void 0,isLoading:!1})),(0,E.jA)(!0)})),(0,s.iw)("clearPasscode",(e=>((0,M.C8)(),(0,r.Kn)(e)))),(0,s.iw)("unlockScreen",((e,t,n)=>{let{sessionJson:a,globalJson:i}=n;const o=JSON.parse(a);(0,S.wX)(o,o.userId),e=JSON.parse(i),(0,s.R3)((0,r.vu)(e,{isScreenLocked:!1,error:void 0,invalidAttemptsCount:0})),t.initApi()})),(0,s.iw)("logInvalidUnlockAttempt",(e=>{var t,n;return(0,r.vu)(e,{invalidAttemptsCount:(null!==(t=null===(n=e.passcode)||void 0===n?void 0:n.invalidAttemptsCount)&&void 0!==t?t:0)+1})})),(0,s.iw)("resetInvalidUnlockAttempts",(e=>(0,r.vu)(e,{invalidAttemptsCount:0}))),(0,s.iw)("setPasscodeError",((e,t,n)=>{const{error:s}=n;return(0,r.vu)(e,{error:s})})),(0,s.iw)("clearPasscodeError",(e=>(0,r.vu)(e,{error:void 0}))),(0,s.iw)("skipLockOnUnload",(()=>{k=!0})),n(65456);var N=n(27225),T=n(71226),A=n(81396);const B=new Map,x=(0,R.Ds)((e=>e()),500,!1);async function L(e,t,n,i){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const d=e.id;let u;switch(i){case m.Uq.Backwards:u=void 0;break;case m.Uq.Around:u=-(Math.round(a.hT/2)+1);break;case m.Uq.Forwards:u=-(a.hT+1)}const h=await(0,T.t9)("fetchMessages",{chat:(0,c.Cm)((0,s.Rd)(),d,t),offsetId:n,addOffset:u,limit:a.hT,threadId:t});if(!h)return;const{messages:p,users:f,chats:v,threadInfos:I}=h;let w=(0,s.Rd)();const y=d===a.aw?w.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],Z=[].concat(p,y),P=(0,g.ee)(Z,"id"),C=Object.keys(P).map(Number);w=(0,r.c_)(w,d,P),w=o?(0,r.ff)(w,d,t,C):(0,r.xj)(w,d,t,C),w=(0,r.Sh)(w,(0,g.ee)(f,"id")),w=(0,r.fZ)(w,(0,g.ee)(v,"id")),w=(0,r.j6)(w,d,I);let b=(0,c.gb)(w,d,t);const S=(0,c.qC)(w,d,t);if(o&&b&&S&&(S.length&&!(0,g.YE)(b,S)||(w=(0,r.xj)(w,d,t,S),b=(0,c.gb)(w,d,t),w=(0,r.pf)(w,d,t,"outlyingIds",void 0),o=!1)),!l){const e=o?S:b,{newViewportIds:s}=O(e,n,i);w=(0,r.y9)(w,d,t,s)}(0,s.R3)(w)}function O(e,t,n){const{length:s}=e,i=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((n,s)=>n===t||n<t&&e[s+1]>t))}(e,t):-1,o=n===m.Uq.Backwards?i:i+1||s,r=o-a.hT,c=o+a.hT-1,l=e.slice(Math.max(0,r),c+1);let d,u;switch(n){case m.Uq.Backwards:d=o>0,u=r>=0;break;case m.Uq.Forwards:d=o<s,u=c<=s-1;break;case m.Uq.Around:default:d=l.length>0,u=l.length===a.hT}return{newViewportIds:l,areSomeLocal:d,areAllLocal:u}}async function U(e){let t;const n=e.attachment?(e,a)=>{B.has(a)||(t=a,B.set(a,n));const i=(0,s.Rd)();(0,s.R3)({...i,fileUploads:{byMessageLocalId:{...i.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,R.Pn)();const a=(0,s.Rd)();e.serverTimeOffset=a.serverTimeOffset;const i=(0,c.Bt)(a);if(!i)return;const{threadId:r}=i;e.replyingTo||r===o._f||(e.replyingTo=(0,c.qS)(a,e.chat.id,r)),e.replyingTo&&!e.replyingToTopId&&r!==o._f&&(e.replyingToTopId=(0,c.qS)(a,e.chat.id,r)),await(0,T.t9)("sendMessage",e,n),n&&t&&B.delete(t)}(0,s.iw)("loadViewportMessages",((e,t,n)=>{const{direction:s=m.Uq.Around,isBudgetPreload:i=!1}=n||{};let{chatId:o,threadId:l}=n||{};if(!o){const t=(0,c.Bt)(e);if(!t)return;o=t.chatId,l=t.threadId}const d=(0,c.Z1)(e,o);if(!d||d.isRestricted)return;const u=(0,c.Cb)(e,o,l),h=(0,c.gb)(e,o,l),g=(0,c.qC)(e,o,l);if(u&&u.length&&s!==m.Uq.Around){const n=s===m.Uq.Backwards?u[0]:u[u.length-1],a=Boolean(g),c=a?g:h,{newViewportIds:p,areSomeLocal:f,areAllLocal:v}=O(c,n,s);if(f&&(e=(0,r.y9)(e,o,l,p)),(0,R.R3)((()=>{!async function(e,t,n,s,a,i,o,r){t||await L(a,i,r,o,n,s),s||e.loadViewportMessages({chatId:a.id,threadId:i,direction:o,isBudgetPreload:!0})}(t,v,a,i,d,l,s,n)})),i)return}else{const t=(0,c.G$)(e,o)||(0,c.rd)(e,o,l),n=Boolean(t&&h&&!h.includes(t)),s=(n?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=O(s,t,m.Uq.Around);p&&u.length>=a.hT&&(e=(0,r.y9)(e,o,l,u)),f||(0,R.R3)((()=>{L(d,l,t,m.Uq.Around,n,i)}))}return e})),(0,s.iw)("loadMessage",(async(e,t,n)=>{const{chatId:a,messageId:i,replyOriginForId:l,threadUpdate:d}=n,u=(0,c.Z1)(e,a);if(!u)return;const m=await async function(e,t,n){const a=await(0,T.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===o._Q){if(n){let t=(0,s.Rd)();const a=(0,c.hj)(t,e.id,n);t=(0,r.cY)(t,e.id,n,{...a,replyToMessageId:void 0}),(0,s.R3)(t)}return}let i=(0,s.Rd)();return i=(0,r.cY)(i,e.id,t,a.message),i=(0,r.Sh)(i,(0,g.ee)(a.users,"id")),(0,s.R3)(i),a.message}(u,i,l);if(m&&d){const{lastMessageId:e,isDeleting:t}=d;(0,s.R3)((0,r.lG)((0,s.Rd)(),m,a,e,t))}})),(0,s.iw)("sendMessage",((e,t,n)=>{const s=(0,c.Bt)(e);if(!s)return;const{chatId:i,threadId:o,type:r}=s;if("scheduled"===r&&!n.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:n}};const l=(0,c.Z1)(e,i),d={...n,chat:l,replyingTo:(0,c.Yy)(e,i,o),noWebPage:(0,c.tV)(e,i,o),sendAs:(0,c._5)(e,i)};t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i,threadId:o,value:!1});const u=!n.attachments||n.attachments.length<=1,m=!u&&n.attachments&&n.attachments.length>1;if(u){const{attachments:e,...t}=d;U({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:n,...s}=d,i=(0,g.Vl)(n,a.DU);for(let n=0;n<i.length;n++){const[a,...o]=i[n],r=`${Date.now()}${n}`;U({...s,text:0===n?e:void 0,entities:0===n?t:void 0,attachment:a,groupedId:o.length>0?r:void 0}),o.forEach((e=>{U({...s,attachment:e,groupedId:r})}))}}else{const{text:e,entities:t,attachments:n,replyingTo:s,...a}=d;e&&U({...a,text:e,entities:t,replyingTo:s}),n.forEach((e=>{U({...a,attachment:e})}))}})),(0,s.iw)("editMessage",((e,t,n)=>{const{serverTimeOffset:s}=e,{text:a,entities:i}=n,o=(0,c.Bt)(e);if(!o)return;const{chatId:r,threadId:l,type:d}=o,u=(0,c.Z1)(e,r),m=(0,c.kK)(e,r,l,d);u&&m&&((0,T.t9)("editMessage",{chat:u,message:m,text:a,entities:i,noWebPage:(0,c.tV)(e,r,l),serverTimeOffset:s}),t.setEditingId({messageId:void 0}))})),(0,s.iw)("cancelSendingMessage",((e,t,n)=>{const{chatId:s,messageId:a}=n,i=(0,c.hj)(e,s,a),o=i&&B.get((0,d.KK)(i));o&&(0,T.u3)(o),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:s})})),(0,s.iw)("saveDraft",((e,t,n)=>{const{chatId:s,threadId:a,draft:i}=n;if(!i)return;const{text:l,entities:d}=i,u=(0,c.Z1)(e,s);return a===o._f&&(0,T.t9)("saveDraft",{chat:u,text:l,entities:d,replyToMsgId:(0,c.Yy)(e,s,a)}),e=(0,r.pf)(e,s,a,"draft",i),(0,r.a4)(e,s,{draftDate:Math.round(Date.now()/1e3)})})),(0,s.iw)("clearDraft",((e,t,n)=>{const{chatId:s,threadId:a,localOnly:i}=n;if(!(0,c.Ms)(e,s,a))return;const l=(0,c.Z1)(e,s);return i||a!==o._f||(0,T.t9)("clearDraft",l),e=(0,r.pf)(e,s,a,"draft",void 0),(0,r.a4)(e,s,{draftDate:void 0})})),(0,s.iw)("toggleMessageWebPage",((e,t,n)=>{const{chatId:s,threadId:a,noWebPage:i}=n;return(0,r.pf)(e,s,a,"noWebPage",i)})),(0,s.iw)("pinMessage",((e,t,n)=>{const s=(0,c.jr)(e);if(!s)return;const{messageId:a,isUnpin:i,isOneSide:o,isSilent:r}=n;(0,T.t9)("pinMessage",{chat:s,messageId:a,isUnpin:i,isOneSide:o,isSilent:r})})),(0,s.iw)("unpinAllMessages",((e,t,n)=>{const a=(0,c.Z1)(e,n.chatId);a&&async function(e){await(0,T.t9)("unpinAllMessages",{chat:e});let t=(0,s.Rd)();t=(0,r.pf)(t,e.id,o._f,"pinnedIds",[]),(0,s.R3)(t)}(a)})),(0,s.iw)("deleteMessages",((e,t,n)=>{const{messageIds:s,shouldDeleteForAll:a}=n,i=(0,c.Bt)(e);if(!i)return;const{chatId:o,threadId:r}=i,l=(0,c.Z1)(e,o);(0,T.t9)("deleteMessages",{chat:l,messageIds:s,shouldDeleteForAll:a});const d=(0,c._$)(e,o,r);s.includes(d)&&t.setEditingId({messageId:void 0})})),(0,s.iw)("deleteScheduledMessages",((e,t,n)=>{const{messageIds:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:i}=a,o=(0,c.Z1)(e,i);(0,T.t9)("deleteScheduledMessages",{chat:o,messageIds:s});const r=(0,c.wU)(e,i);s.includes(r)&&t.setEditingId({messageId:void 0})})),(0,s.iw)("deleteHistory",(async(e,t,n)=>{var s;const{chatId:a,shouldDeleteForAll:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const r=null===(s=o.lastMessage)||void 0===s?void 0:s.id;await(0,T.t9)("deleteHistory",{chat:o,shouldDeleteForAll:i,maxId:r});const l=(0,c.Bt)(e);l&&l.chatId===a&&t.openChat({id:void 0})})),(0,s.iw)("reportMessages",(async(e,t,n)=>{const{messageIds:s,reason:a,description:i}=n,o=(0,c.Bt)(e);if(!o)return;const{chatId:r}=o,l=(0,c.Z1)(e,r),d=await(0,T.t9)("reportMessages",{peer:l,messageIds:s,reason:a,description:i});t.showNotification({message:d?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,s.iw)("sendMessageAction",(async(e,t,n)=>{const{action:s,chatId:a,threadId:i}=n;if(a===e.currentUserId)return;const o=(0,c.Z1)(e,a);o&&await(0,T.t9)("sendMessageAction",{peer:o,threadId:i,action:s})})),(0,s.iw)("markMessageListRead",((e,t,n)=>{const{serverTimeOffset:s}=e,i=(0,c.Bt)(e);if(!i)return;const{chatId:l,threadId:d}=i,u=(0,c.Cm)(e,l,d);if(!u)return;const{maxId:m}=n;if(x((()=>{(0,T.t9)("markMessageListRead",{serverTimeOffset:s,chat:u,threadId:d,maxId:m})})),d!==o._f)return;l===a.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=m?{...e,isUnread:!1}:e))});const h=(0,c.Cb)(e,l,d),g=(0,c.It)(e,l,d);if(!h||!g||!u.unreadCount)return e;const p=function(e,t,n){let s=0;for(let a=0,i=e.length;a<i&&(e[a]>=t&&e[a]<=n&&s++,!(e[a]>=n));a++);return s}(h,g,m);return p?(0,r.a4)(e,l,{lastReadInboxMessageId:m,unreadCount:Math.max(0,u.unreadCount-p)}):e})),(0,s.iw)("markMessagesRead",((e,t,n)=>{const s=(0,c.jr)(e);if(!s)return;const{messageIds:a}=n;(0,T.t9)("markMessagesRead",{chat:s,messageIds:a})})),(0,s.iw)("loadWebPagePreview",((e,t,n)=>{const{text:a}=n;!async function(e){const t=await(0,T.t9)("fetchWebPagePreview",{message:e});(0,s.R3)({...(0,s.Rd)(),webPagePreview:t})}(a)})),(0,s.iw)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,s.iw)("sendPollVote",((e,t,n)=>{const{chatId:s,messageId:a,options:i}=n,o=(0,c.Z1)(e,s);o&&(0,T.t9)("sendPollVote",{chat:o,messageId:a,options:i})})),(0,s.iw)("cancelPollVote",((e,t,n)=>{const{chatId:s,messageId:a}=n,i=(0,c.Z1)(e,s);i&&(0,T.t9)("sendPollVote",{chat:i,messageId:a,options:[]})})),(0,s.iw)("closePoll",((e,t,n)=>{var s;const{chatId:a,messageId:i}=n,o=(0,c.Z1)(e,a),r=null===(s=(0,c.hj)(e,a,i))||void 0===s?void 0:s.content.poll;o&&r&&(0,T.t9)("closePoll",{chat:o,messageId:i,poll:r})})),(0,s.iw)("loadPollOptionResults",((e,t,n)=>{const{chat:a,messageId:i,option:o,offset:c,limit:l,shouldResetVoters:d}=n;!async function(e,t,n,a,i,o){const c=await(0,T.t9)("loadPollOptionResults",{chat:e,messageId:t,option:n,offset:a,limit:i});if(!c)return;let l=(0,s.Rd)();l=(0,r.Sh)(l,(0,g.ee)(c.users,"id"));const{voters:d}=l.pollResults;(0,s.R3)({...l,pollResults:{...l.pollResults,voters:{...d,[n]:(0,g.Tw)([...!o&&d&&d[n]?d[n]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[n]:c.nextOffset||""}}})}(a,i,o,c,l,d)})),(0,s.iw)("forwardMessages",((e,t,n)=>{const{fromChatId:a,messageIds:i,toChatId:o,withMyScore:r,noAuthors:l,noCaptions:u}=e.forwardMessages,m=a?(0,c.Z1)(e,a):void 0,h=o?(0,c.Z1)(e,o):void 0,g=a&&i?i.sort(((e,t)=>e-t)).map((t=>(0,c.hj)(e,a,t))).filter(Boolean):void 0;if(!m||!h||!g)return;const{isSilent:p,scheduledAt:f}=n,v=(0,c._5)(e,o),I=g.filter((e=>!(0,d.jM)(e)));I.length&&(0,T.t9)("forwardMessages",{fromChat:m,toChat:h,messages:I,serverTimeOffset:(0,s.Rd)().serverTimeOffset,isSilent:p,scheduledAt:f,sendAs:v,withMyScore:r,noAuthors:l,noCaptions:u}),g.filter((e=>(0,d.jM)(e))).forEach((e=>{const{text:t,entities:n}=e.content.text||{},{sticker:s,poll:a}=e.content;U({chat:h,text:t,entities:n,sticker:s,poll:a,isSilent:p,scheduledAt:f,sendAs:v})})),(0,s.R3)({...(0,s.Rd)(),forwardMessages:{}})})),(0,s.iw)("loadScheduledHistory",((e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);i&&async function(e){const t=await(0,T.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:n}=t,a=(0,g.ee)(n,"id"),i=Object.keys(a).map(Number).sort(((e,t)=>t-e));let c=(0,s.Rd)();c=(0,r.w3)(c,e.id,a),c=(0,r.pf)(c,e.id,o._f,"scheduledIds",i),(0,s.R3)(c)}(i)})),(0,s.iw)("sendScheduledMessages",((e,t,n)=>{const{chatId:s,id:a}=n,i=(0,c.Z1)(e,s);i&&(0,T.t9)("sendScheduledMessages",{chat:i,ids:[a]})})),(0,s.iw)("rescheduleMessage",((e,t,n)=>{const{chatId:s,messageId:a,scheduledAt:i}=n,o=(0,c.Z1)(e,s),r=o&&(0,c.Tm)(e,o.id,a);o&&r&&(0,T.t9)("rescheduleMessage",{chat:o,message:r,scheduledAt:i})})),(0,s.iw)("requestThreadInfoUpdate",((e,t,n)=>{const{chatId:s,threadId:a}=n,i=(0,c.Cm)(e,s,a);i&&(0,T.t9)("requestThreadInfoUpdate",{chat:i,threadId:a})})),(0,s.iw)("transcribeAudio",(async(e,t,n)=>{const{messageId:a,chatId:i}=n,o=(0,c.Z1)(e,i);if(!o)return;e=(0,r.cY)(e,i,a,{transcriptionId:""}),(0,s.R3)(e);const l=await(0,T.t9)("transcribeAudio",{chat:o,messageId:a});e=(0,r.cY)((0,s.Rd)(),i,a,{transcriptionId:l,isTranscriptionError:!l}),(0,s.R3)(e)})),(0,s.iw)("loadPinnedMessages",((e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);i&&async function(e){const t=await(0,T.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:n,chats:a,users:i}=t,c=(0,g.ee)(n,"id"),l=Object.keys(c).map(Number).sort(((e,t)=>t-e));let d=(0,s.Rd)();d=(0,r.c_)(d,e.id,c),d=(0,r.pf)(d,e.id,o._f,"pinnedIds",l),d=(0,r.Sh)(d,(0,g.ee)(i,"id")),d=(0,r.fZ)(d,(0,g.ee)(a,"id")),(0,s.R3)(d)}(i)})),(0,s.iw)("loadSeenBy",(async(e,t,n)=>{const{chatId:a,messageId:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const l=await(0,T.t9)("fetchSeenBy",{chat:o,messageId:i});l&&(0,s.R3)((0,r.cY)((0,s.Rd)(),a,i,{seenByUserIds:l}))})),(0,s.iw)("saveDefaultSendAs",((e,t,n)=>{const{chatId:s,sendAsId:a}=n,i=(0,c.Z1)(e,s),o=(0,c.Z1)(e,a)||(0,c.dy)(e,a);if(i&&o)return(0,T.t9)("saveDefaultSendAs",{sendAs:o,chat:i}),(0,r.a4)(e,s,{fullInfo:{...i.fullInfo,sendAsId:a}})})),(0,s.iw)("loadSendAs",(async(e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);if(!i)return;const o=await(0,T.t9)("fetchSendAs",{chat:i});o?(e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(o.chats,"id")),e=(0,r.a4)(e,a,{sendAsIds:o.ids}),(0,s.R3)(e)):(0,s.R3)((0,r.a4)((0,s.Rd)(),a,{sendAsIds:[]}))})),(0,s.iw)("loadSponsoredMessages",(async(e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);if(!i)return;const o=await(0,T.t9)("fetchSponsoredMessages",{chat:i});o&&(e=(0,s.Rd)(),e=(0,r.Fn)(e,a,o.messages[0]),e=(0,r.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(o.chats,"id")),(0,s.R3)(e))})),(0,s.iw)("viewSponsoredMessage",((e,t,n)=>{const{chatId:s}=n,a=(0,c.Z1)(e,s),i=(0,c.fS)(e,s);a&&i&&(0,T.t9)("viewSponsoredMessage",{chat:a,random:i.randomId})})),(0,s.iw)("fetchUnreadMentions",(async(e,t,n)=>{const{chatId:a,offsetId:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const l=await(0,T.t9)("fetchUnreadMentions",{chat:o,offsetId:i});if(!l)return;const{messages:d,chats:u,users:m}=l,h=(0,g.ee)(d,"id"),p=Object.keys(h).map(Number);e=(0,s.Rd)(),e=(0,r.c_)(e,o.id,h),e=(0,r.Sh)(e,(0,g.ee)(m,"id")),e=(0,r.fZ)(e,(0,g.ee)(u,"id")),e=(0,r.a4)(e,a,{unreadMentions:[...o.unreadMentions||[],...p]}),(0,s.R3)(e)})),(0,s.iw)("markMentionsRead",((e,t,n)=>{const{messageIds:a}=n,i=(0,c.jr)(e);if(!i)return;if(!i.unreadMentionsCount)return;const o=i.unreadMentionsCount-a.length,l=(i.unreadMentions||[]).filter((e=>!a.includes(e)));e=(0,r.a4)(e,i.id,{unreadMentions:l}),(0,s.R3)(e),!l.length&&o&&t.fetchUnreadMentions({chatId:i.id,offsetId:Math.max(...a)}),t.markMessagesRead({messageIds:a})})),(0,s.iw)("focusNextMention",((e,t)=>{const n=(0,c.jr)(e);null!=n&&n.unreadMentions&&t.focusMessage({chatId:n.id,messageId:n.unreadMentions[0]})})),(0,s.iw)("readAllMentions",(e=>{const t=(0,c.jr)(e);if(t)return(0,T.t9)("readAllMentions",{chat:t}),(0,r.a4)(e,t.id,{unreadMentionsCount:void 0,unreadMentions:void 0})})),(0,s.iw)("openUrl",((e,t,n)=>{const{url:s,shouldSkipModal:i}=n,o=(0,A.X)(s);if(o.match(a.FS)||o.match(a.g$))return void t.openTelegramLink({url:s});const{appConfig:r}=e;if(r){const e=new URL(o);if(r.autologinDomains.includes(e.hostname))return e.searchParams.set("autologin_token",r.autologinToken),void window.open(e.href,"_blank","noopener");if(r.urlAuthDomains.includes(e.hostname))return void t.requestLinkUrlAuth({url:s})}o.match(a.jL)||i?window.open(o,"_blank","noopener"):t.toggleSafeLinkModal({url:o})}));var F=n(85765),q=n(9211);const D=(0,R.P2)((e=>e()),500,!1);async function $(e){const t=await(0,T.t9)("fetchRecentStickers",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,stickers:{...n.stickers,recent:t}})}async function j(e,t,n){const a=await(0,T.t9)("fetchStickers",{stickerSetShortName:n,stickerSetId:e,accessHash:t});let i=(0,s.Rd)();if(!a)return(0,R.R3)((()=>{(0,s.Sv)().showNotification({message:(0,v.i0)("StickerPack.ErrorNotFound")})})),void(i.openedStickerSetShortName===n&&(0,s.R3)({...i,openedStickerSetShortName:void 0}));const{set:o,stickers:c,packs:l}=a;i=(0,r.Rg)(i,o.id,{...o,stickers:c,packs:l});const d=i.stickers.forEmoji.emoji;d&&l[d]&&(i=(0,r.vy)(i)),(0,s.R3)(i)}async function G(e,t){const n=await(0,T.t9)("searchGifs",{query:e,offset:t});n&&(0,s.R3)((0,r.rq)((0,s.Rd)(),!t,n.gifs,n.nextOffset))}(0,s.iw)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,T.t9)("fetchStickerSets",{hash:e});t&&(0,s.R3)((0,r.z3)((0,s.Rd)(),"added",t.hash,t.sets))}(t)})),(0,s.iw)("loadAddedStickers",(async(e,t)=>{const{setIds:n}=e.stickers.added,s=e.stickers.setsById;if(n&&n.length)for(let e=0;e<n.length;e++){var a;const i=n[e];null!==(a=s[i])&&void 0!==a&&a.stickers||(t.loadStickers({stickerSetId:i}),e%10==0&&e>0&&await(0,R.wO)(200))}})),(0,s.iw)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};$(t)})),(0,s.iw)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,T.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,stickers:{...n.stickers,favorite:t}})}(t)})),(0,s.iw)("loadPremiumStickers",(async e=>{const{hash:t}=e.stickers.premium||{},n=await(0,T.t9)("fetchStickersForEmoji",{emoji:"⭐️⭐️",hash:t});n&&(e=(0,s.Rd)(),(0,s.R3)({...e,stickers:{...e.stickers,premium:{hash:n.hash,stickers:n.stickers}}}))})),(0,s.iw)("loadGreetingStickers",(async e=>{const{hash:t}=e.stickers.greeting||{},n=await(0,T.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});n&&(e=(0,s.Rd)(),(0,s.R3)({...e,stickers:{...e.stickers,greeting:{hash:n.hash,stickers:n.stickers.filter((e=>"👋"===e.emoji))}}}))})),(0,s.iw)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,T.t9)("fetchFeaturedStickers",{hash:e});t&&(0,s.R3)((0,r.z3)((0,s.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,s.iw)("loadStickers",((e,t,n)=>{const{stickerSetId:a,stickerSetShortName:i}=n;let{stickerSetAccessHash:o}=n;if(!o&&!i){const t=(0,c.Ny)(e,a);if(!t)return void(e.openedStickerSetShortName===i&&(0,s.R3)({...e,openedStickerSetShortName:void 0}));o=t.accessHash}j(a,o,i)})),(0,s.iw)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,T.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:n}=e;(0,s.R3)((0,r.g_)((0,s.Rd)(),{...t,stickers:n}))}(),async function(){const e=await(0,T.t9)("fetchAnimatedEmojiEffects");if(!e)return;const{set:t,stickers:n}=e;(0,s.R3)({...(0,s.Rd)(),animatedEmojiEffects:{...t,stickers:n}})}()})),(0,s.iw)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,T.t9)("fetchSavedGifs",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,gifs:{...n.gifs,saved:t}})}(t)})),(0,s.iw)("saveGif",(async(e,t,n)=>{var a,i;const{gif:o,shouldUnsave:r}=n,l=null===(a=e.gifs.saved.gifs)||void 0===a?void 0:a.length,d=(0,q.M)(e,"savedGifs"),u=(0,q.P)(e,"savedGifs"),m=(0,c.wV)(e);if(!r&&l&&l>=d&&t.showNotification({title:v.i0("LimitReachedFavoriteGifs",d.toString()),message:m?v.i0("LimitReachedFavoriteGifsSubtitlePremium"):v.i0("LimitReachedFavoriteGifsSubtitle",u.toString()),...!m&&{action:t.openPremiumModal},className:"bold-link"}),!await(0,T.t9)("saveGif",{gif:o,shouldUnsave:r}))return;const h=(null===(i=(e=(0,s.Rd)()).gifs.saved.gifs)||void 0===i?void 0:i.filter((e=>{let{id:t}=e;return t!==o.id})))||[],g=r?h:[o,...h];(0,s.R3)({...e,gifs:{...e.gifs,saved:{...e.gifs.saved,gifs:g}}})})),(0,s.iw)("faveSticker",((e,t,n)=>{const{sticker:s}=n,a=e.stickers.favorite.stickers.length,i=(0,q.M)(e,"stickersFaved"),o=(0,q.P)(e,"stickersFaved"),r=(0,c.wV)(e);a>=i&&t.showNotification({title:v.i0("LimitReachedFavoriteStickers",i.toString()),message:r?v.i0("LimitReachedFavoriteStickersSubtitlePremium"):v.i0("LimitReachedFavoriteStickersSubtitle",o.toString()),...!r&&{action:t.openPremiumModal},className:"bold-link"}),s&&(0,T.t9)("faveSticker",{sticker:s})})),(0,s.iw)("unfaveSticker",((e,t,n)=>{const{sticker:a}=n;a&&function(e){const t=(0,s.Rd)();(0,s.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((t=>{let{id:n}=t;return n!==e.id}))}}}),(0,T.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,s.iw)("removeRecentSticker",(async(e,t,n)=>{const{sticker:s}=n;await(0,T.t9)("removeRecentSticker",{sticker:s})&&$()})),(0,s.iw)("clearRecentStickers",(async e=>{await(0,T.t9)("clearRecentStickers")&&(e=(0,s.Rd)(),(0,s.R3)({...e,stickers:{...e.stickers,recent:{stickers:[]}}}))})),(0,s.iw)("toggleStickerSet",((e,t,n)=>{const{stickerSetId:s}=n,a=(0,c.Ny)(e,s);if(!a)return;const{accessHash:i,installedDate:o}=a;(0,T.t9)(o?"uninstallStickerSet":"installStickerSet",{stickerSetId:s,accessHash:i})})),(0,s.iw)("loadEmojiKeywords",(async(e,t,n)=>{var a,i;const{language:o}=n;let r=e.emojiKeywords[o];if(null!==(a=r)&&void 0!==a&&a.isLoading)return;(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}});const c=await(0,T.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});r=(e=(0,s.Rd)()).emojiKeywords[o],c?(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:c.version,keywords:{...null===(i=r)||void 0===i?void 0:i.keywords,...c.keywords}}}}):(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})),(0,s.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:a}=n;a&&D((()=>{!async function(e,t){const n=await(0,T.t9)("searchStickers",{query:e,hash:void 0});if(!n)return;const a=(0,s.Rd)(),{setsById:i,added:o}=a.stickers,c=n.sets.map((e=>{let{id:t}=e;return t}));o.setIds&&o.setIds.forEach((t=>{if(!c.includes(t)){const{title:n}=i[t]||{};n&&(0,F.Z)(n,e)&&c.unshift(t)}})),(0,s.R3)((0,r.z3)(a,"search",n.hash,n.sets,c))}(a)}))})),(0,s.iw)("setGifSearchQuery",((e,t,n)=>{const{query:s}=n;"string"==typeof s&&D((()=>{G(s)}))})),(0,s.iw)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&D((()=>{G(t,n)}))})),(0,s.iw)("loadStickersForEmoji",((e,t,n)=>{const{emoji:a}=n,{hash:i}=e.stickers.forEmoji;D((()=>{!async function(e,t){let n=(0,s.Rd)();(0,s.R3)({...n,stickers:{...n.stickers,forEmoji:{...n.stickers.forEmoji,emoji:e}}});const a=await(0,T.t9)("fetchStickersForEmoji",{emoji:e,hash:t});n=(0,s.Rd)(),a&&n.stickers.forEmoji.emoji===e&&(n=(0,r.IM)(n,e,a.stickers,a.hash),(0,s.R3)(n))}(a,i)}))})),(0,s.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,s.iw)("openStickerSetShortName",((e,t,n)=>{const{stickerSetShortName:s}=n;return{...e,openedStickerSetShortName:s}})),(0,s.iw)("openStickerSet",(async(e,t,n)=>{const{sticker:a}=n;if(!(0,c.Ny)(e,a.stickerSetId)){if(!a.stickerSetAccessHash)return void t.showNotification({message:(0,v.i0)("StickerPack.ErrorNotFound")});await j(a.stickerSetId,a.stickerSetAccessHash)}e=(0,s.Rd)();const i=(0,c.Ny)(e,a.stickerSetId);null!=i&&i.shortName&&(0,s.R3)({...e,openedStickerSetShortName:i.shortName})}));var H=n(790);const _=(0,R.P2)((e=>e()),500,!1);async function z(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0;if(o){const s=await(0,T.t9)("searchMessagesLocal",{chat:o,query:t,type:n,limit:a.Hk,offsetId:i,minDate:d,maxDate:l});if(s){const{messages:t,users:n,totalCount:a,nextOffsetId:i}=s;e={messages:t,users:n,chats:[],totalCount:a,nextRate:i}}}else e=await(0,T.t9)("searchMessagesGlobal",{query:t,offsetRate:i,limit:a.Hk,type:n,maxDate:l,minDate:d});let u=(0,s.Rd)();const m=(0,c.JX)(u);if(!e||""!==t&&t!==m)return void(0,s.R3)((0,r.xv)(u,{messages:!1}));const{messages:h,users:p,chats:f,totalCount:v,nextRate:I}=e;f.length&&(u=(0,r.fZ)(u,(0,g.ee)(f,"id"))),p.length&&(u=(0,r.Sh)(u,(0,g.ee)(p,"id"))),h.length&&(u=(0,r.m6)(u,h)),u=(0,r.px)(u,h,v,n,I),(0,s.R3)(u)}async function V(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const o=await(0,T.t9)("searchMessagesLocal",{chat:e,type:t,limit:2*a.EN,offsetId:n});if(!o)return;const{chats:l,users:d,messages:u,totalCount:m,nextOffsetId:h}=o,p=(0,g.ee)(u,"id"),f=Object.keys(p).map(Number);let v=(0,s.Rd)();const I=(0,c.we)(v);I&&(v=(0,r.fZ)(v,(0,g.ee)(l,"id")),v=(0,r.Sh)(v,(0,g.ee)(d,"id")),v=(0,r.c_)(v,e.id,p),v=(0,r.c1)(v,e.id,t,f,m,h),(0,s.R3)(v),i||V(e,t,h,!0))}(0,s.iw)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:a}=e.globalSearch,{query:i}=n;i&&!a&&_((()=>{!async function(e){const t=await(0,T.t9)("searchChats",{query:e});let n=(0,s.Rd)();const a=(0,c.JX)(n);if(!t||!a||e!==a)return void(0,s.R3)((0,r.xv)(n,{chats:!1}));const{localChats:i,localUsers:o,globalChats:l,globalUsers:d}=t;(i.length||l.length)&&(n=(0,r.fZ)(n,(0,g.ee)([...i,...l],"id"))),(o.length||d.length)&&(n=(0,r.Sh)(n,(0,g.ee)([...o,...d],"id"))),n=(0,r.xv)(n,{chats:!1}),n=(0,r.No)(n,{localResults:{chatIds:i.map((e=>{let{id:t}=e;return t})),userIds:o.map((e=>{let{id:t}=e;return t}))},globalResults:{...n.globalSearch.globalResults,chatIds:l.map((e=>{let{id:t}=e;return t})),userIds:d.map((e=>{let{id:t}=e;return t}))}}),(0,s.R3)(n)}(i)}))})),(0,s.iw)("setGlobalSearchDate",((e,t,n)=>{const{date:a}=n,i=a?(0,H.IS)(a):a;e=(0,r.No)(e,{date:a,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}}),(0,s.R3)(e);const{chatId:o}=e.globalSearch;z("","text",void 0,o?(0,c.Z1)(e,o):void 0,i,a)})),(0,s.iw)("searchMessagesGlobal",((e,t,n)=>{var s;const{query:a,resultsByType:i,chatId:o,date:r}=e.globalSearch,l=r?(0,H.IS)(r):r,{type:d}=n;z(a,d,null==i||null===(s=i[d])||void 0===s?void 0:s.nextOffsetId,o?(0,c.Z1)(e,o):void 0,l,r)})),(0,s.iw)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{},i=t?(0,c.Z1)(e,t):void 0,l=(0,c.n5)(e);if(!i||!l||!n)return;const{query:d,results:u}=l,m=null==u?void 0:u.nextOffsetId;let h;if(n!==o._f){const s=(0,c.tZ)(e,t,n);h=null==s?void 0:s.topMessageId}!async function(e,t,n,i,o){if(!i)return;const l=await(0,T.t9)("searchMessagesLocal",{chat:e,type:"text",query:i,topMessageId:n,limit:a.pn,offsetId:o});if(!l)return;const{chats:d,users:u,messages:m,totalCount:h,nextOffsetId:p}=l,f=(0,g.ee)(m,"id"),v=Object.keys(f).map(Number);let I=(0,s.Rd)();const w=(0,c.n5)(I);w&&i===w.query&&(I=(0,r.fZ)(I,(0,g.ee)(d,"id")),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.c_)(I,e.id,f),I=(0,r.dx)(I,e.id,t,v,h,p),(0,s.R3)(I))}(i,n,h,d,m)})),(0,s.iw)("searchMediaMessagesLocal",(e=>{const{chatId:t}=(0,c.Bt)(e)||{};if(!t)return;const n=(0,c.Z1)(e,t),s=(0,c.we)(e);if(!n||!s)return;const{currentType:a,resultsByType:i}=s,o=a&&i&&i[a],r=null==o?void 0:o.nextOffsetId;a&&V(n,a,r)})),(0,s.iw)("searchMessagesByDate",((e,t,n)=>{const{timestamp:a}=n,{chatId:i}=(0,c.Bt)(e)||{};if(!i)return;const o=(0,c.Z1)(e,i);o&&async function(e,t){const n=await(0,T.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});n&&(0,s.Sv)().focusMessage({chatId:e.id,messageId:n})}(o,a)})),(0,s.iw)("checkPublicLink",(async(e,t,n)=>{const{chatId:a}=(0,c.Bt)(e)||{};if(!a)return;if(e.management.progress===m.wv.InProgress)return;const{username:i}=n;e=(0,r.H9)(e,m.wv.InProgress),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,s.R3)(e);const o=await(0,T.t9)("checkChatUsername",{username:i});e=(0,s.Rd)(),e=(0,r.H9)(e,o?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:o}),(0,s.R3)(e),void 0===o&&t.openLimitReachedModal({limit:"channelsPublic"})})),(0,s.iw)("updatePublicLink",(async(e,t,n)=>{const{chatId:a}=(0,c.Bt)(e)||{};let i=a&&(0,c.Z1)(e,a);if(!a||!i)return;const{username:o}=n;if(e=(0,r.H9)(e,m.wv.InProgress),(0,s.R3)(e),(0,d.G9)(i)){if(i=await(0,N.bZ)(i),!i)return;t.openChat({id:i.id})}const l=await(0,T.t9)("setChatUsername",{chat:i,username:o});e=(0,s.Rd)(),e=(0,r.H9)(e,l?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,s.R3)(e)})),(0,s.iw)("updatePrivateLink",(e=>{const{chatId:t}=(0,c.Bt)(e)||{},n=t&&(0,c.Z1)(e,t);t&&n&&(0,T.t9)("updatePrivateLink",{chat:n})})),(0,s.iw)("setEditingExportedInvite",((e,t,n)=>{const{chatId:a,invite:i}=n;(0,s.R3)((0,r.fw)(e,a,{editingInvite:i}))})),(0,s.iw)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:a,invite:i}=n,o=i?{inviteInfo:{invite:i}}:{inviteInfo:void 0};(0,s.R3)((0,r.fw)(e,a,o))})),(0,s.iw)("loadExportedChatInvites",(async(e,t,n)=>{const{chatId:a,adminId:i,isRevoked:o,limit:l}=n,d=(0,c.Z1)(e,a),u=(0,c.dy)(e,i||e.currentUserId);if(!d||!u)return;const m=await(0,T.t9)("fetchExportedChatInvites",{peer:d,admin:u,isRevoked:o,limit:l});if(!m)return;const h=o?{revokedInvites:m}:{invites:m};(0,s.R3)((0,r.fw)((0,s.Rd)(),a,h))})),(0,s.iw)("editExportedChatInvite",(async(e,t,n)=>{const{chatId:a,link:i,isRevoked:o,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m}=n,h=(0,c.Z1)(e,a);if(!h)return;const g=await(0,T.t9)("editExportedChatInvite",{peer:h,link:i,isRevoked:o,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m});if(!g)return;const{oldInvite:p,newInvite:f}=g,v=((e=(0,s.Rd)()).management.byChatId[a].invites||[]).filter((e=>e.link!==p.link)),I=[...e.management.byChatId[a].revokedInvites||[]];f.isRevoked?I.unshift(f):v.push(f),(0,s.R3)((0,r.fw)(e,a,{invites:v,revokedInvites:I}))})),(0,s.iw)("exportChatInvite",(async(e,t,n)=>{const{chatId:a,expireDate:i,usageLimit:o,isRequestNeeded:l,title:d}=n,u=(0,c.Z1)(e,a);if(!u)return;const m=await(0,T.t9)("exportChatInvite",{peer:u,expireDate:i,usageLimit:o,isRequestNeeded:l,title:d});if(!m)return;const h=(e=(0,s.Rd)()).management.byChatId[a].invites||[];(0,s.R3)((0,r.fw)(e,a,{invites:[...h,m]}))})),(0,s.iw)("deleteExportedChatInvite",(async(e,t,n)=>{var a,i;const{chatId:o,link:l}=n,d=(0,c.Z1)(e,o);if(!d)return;if(!await(0,T.t9)("deleteExportedChatInvite",{peer:d,link:l}))return;const u=(e=(0,s.Rd)()).management.byChatId[o];(0,s.R3)((0,r.fw)(e,o,{invites:null==u||null===(a=u.invites)||void 0===a?void 0:a.filter((e=>e.link!==l)),revokedInvites:null==u||null===(i=u.revokedInvites)||void 0===i?void 0:i.filter((e=>e.link!==l))}))})),(0,s.iw)("deleteRevokedExportedChatInvites",(async(e,t,n)=>{const{chatId:a,adminId:i}=n,o=(0,c.Z1)(e,a),l=(0,c.dy)(e,i||e.currentUserId);o&&l&&await(0,T.t9)("deleteRevokedExportedChatInvites",{peer:o,admin:l})&&(e=(0,s.Rd)(),(0,s.R3)((0,r.fw)(e,a,{revokedInvites:[]})))})),(0,s.iw)("loadChatInviteImporters",(async(e,t,n)=>{var a;const{chatId:i,link:o,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,i),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,T.t9)("fetchChatInviteImporters",{peer:m,link:o,offsetDate:l,offsetUser:h,limit:u});if(!g)return;const{importers:p,users:f}=g,v=null===(a=(e=(0,s.Rd)()).management.byChatId[i])||void 0===a?void 0:a.inviteInfo;null!=v&&v.invite&&v.invite.link===o&&(e=(0,r.fw)(e,i,{inviteInfo:{...v,importers:p}}),e=(0,r.Sh)(e,f),(0,s.R3)(e))})),(0,s.iw)("loadChatInviteRequesters",(async(e,t,n)=>{var a;const{chatId:i,link:o,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,i),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,T.t9)("fetchChatInviteImporters",{peer:m,link:o,offsetDate:l,offsetUser:h,limit:u,isRequested:!0});if(!g)return;const{importers:p,users:f}=g,v=null===(a=(e=(0,s.Rd)()).management.byChatId[i])||void 0===a?void 0:a.inviteInfo;null!=v&&v.invite&&v.invite.link===o&&(e=(0,r.fw)(e,i,{inviteInfo:{...v,requesters:p}}),e=(0,r.Sh)(e,f),(0,s.R3)(e))})),(0,s.iw)("loadChatJoinRequests",(async(e,t,n)=>{const{chatId:a,offsetDate:i,offsetUserId:o,limit:l}=n,d=(0,c.Z1)(e,a),u=(0,c.dy)(e,o);if(!d||o&&!u)return;const m=await(0,T.t9)("fetchChatInviteImporters",{peer:d,offsetDate:i,offsetUser:u,limit:l,isRequested:!0});if(!m)return;const{importers:h,users:g}=m;e=(0,s.Rd)(),e=(0,r.a4)(e,a,{joinRequests:h}),e=(0,r.Sh)(e,g),(0,s.R3)(e)})),(0,s.iw)("hideChatJoinRequest",(async(e,t,n)=>{var a;const{chatId:i,userId:o,isApproved:l}=n,d=(0,c.Z1)(e,i),u=(0,c.dy)(e,o);if(!d||!u)return;if(!await(0,T.t9)("hideChatJoinRequest",{peer:d,user:u,isApproved:l}))return;e=(0,s.Rd)();const m=(0,c.Z1)(e,i);m&&(0,s.R3)((0,r.a4)(e,i,{joinRequests:null===(a=m.joinRequests)||void 0===a?void 0:a.filter((e=>e.userId!==o))}))})),(0,s.iw)("hideAllChatJoinRequests",(async(e,t,n)=>{const{chatId:a,isApproved:i,link:o}=n,l=(0,c.Z1)(e,a);if(!l)return;if(!await(0,T.t9)("hideAllChatJoinRequests",{peer:l,isApproved:i,link:o}))return;e=(0,s.Rd)();const d=(0,c.Z1)(e,a);d&&(0,s.R3)((0,r.a4)(e,a,{joinRequests:[],fullInfo:{...d.fullInfo,recentRequesterIds:[],requestsPending:0}}))})),(0,s.iw)("hideChatReportPanel",(async(e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);i&&await(0,T.t9)("hideChatReportPanel",i)&&(0,s.R3)((0,r.a4)((0,s.Rd)(),a,{settings:void 0}))}));var W=n(16974);let J;function X(e){return(0,T.t9)("fetchMessages",{chat:e,threadId:o._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,s.iw)("sync",(()=>{a.eM&&console.log(">>> START SYNC"),J&&clearTimeout(J),(0,s.R3)({...(0,s.Rd)(),isSyncing:!0}),J=window.setTimeout((()=>{(0,s.R3)({...(0,s.Rd)(),isSyncing:!1}),J=void 0}),15e3);const{loadAllChats:e,preloadTopChatMessages:t}=(0,s.Sv)();e({listType:"active",shouldReplace:!0,onReplace:async()=>{await async function(){let e=!1,t=(0,s.Rd)();const n=Object.keys(t.messages.byChatId).reduce(((e,n)=>(e[n]={},e[n].draft=(0,c.Ms)(t,n,o._f),e[n].editingId=(0,c._$)(t,n,o._f),e[n].editingDraft=(0,c.s)(t,n,o._f),e)),{}),{chatId:i,threadId:l}=(0,c.Bt)(t)||{},d=i?t.chats.byId[i]:void 0;if(i&&d){const n=await X(d);t=(0,s.Rd)();const{chatId:u}=(0,c.Bt)(t)||{},m=l&&(0,c.tZ)(t,i,l);if(n&&u===i){const s=t.messages.byChatId[i],c=i===a.aw?t.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],d=[].concat(n.messages,c),u=(0,g.ee)(d,"id"),h=Object.keys(u).map(Number);if(t={...t,messages:{...t.messages,byChatId:{}}},t=(0,r.c_)(t,i,u),t=(0,r.xj)(t,i,o._f,h),t=(0,r.y9)(t,i,o._f,h),l&&m&&m.originChannelId){const{originChannelId:e}=m,n=t.messages.byChatId[e],a=await X(t.chats.byId[e]);if(a){const e=(0,g.ee)(a.messages,"id"),r=Object.keys(e).map(Number);t={...t,messages:{...t.messages,byChatId:{...t.messages.byChatId,[m.originChannelId]:{byId:e,threadsById:{[o._f]:{...null==n?void 0:n.threadsById[o._f],listedIds:r,viewportIds:r,outlyingIds:void 0}}},[i]:{...t.messages.byChatId[i],threadsById:{...t.messages.byChatId[i].threadsById,[l]:{...null==s?void 0:s.threadsById[l],outlyingIds:void 0}}}}}}}}t=(0,r.GL)(t,(0,g.ee)(n.chats,"id")),t=(0,r.eD)(t,(0,g.ee)(n.users,"id")),t=(0,r.j6)(t,i,n.threadInfos),e=!0}}e||(t={...t,messages:{...t.messages,byChatId:{}}}),Object.keys(n).forEach((e=>{t=(0,r.sN)(t,e,o._f,n[e])})),(0,s.R3)(t);const{chatId:u,messageId:m}=t.audioPlayer;u&&m&&!(0,c.hj)(t,u,m)&&(0,s.Sv)().closeAudioPlayer()}(),(0,s.R3)({...(0,s.Rd)(),lastSyncTime:Date.now(),isSyncing:!1}),a.eM&&console.log(">>> FINISH SYNC"),(0,W.S1)(),e({listType:"archived",shouldReplace:!0}),(0,T.t9)("fetchCurrentUser"),t()}})})),(0,s.iw)("reportPeer",(async(e,t,n)=>{const{chatId:s,reason:a,description:i}=n;if(!s)return;const o=(0,c.Z1)(e,s);if(!o)return;const r=await(0,T.t9)("reportPeer",{peer:o,reason:a,description:i});t.showNotification({message:r?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,s.iw)("reportProfilePhoto",(async(e,t,n)=>{const{chatId:s,reason:a,description:i,photo:o}=n;if(!s)return;const r=(0,c.Z1)(e,s);if(!r||!o)return;const l=await(0,T.t9)("reportProfilePhoto",{peer:r,photo:o,reason:a,description:i});t.showNotification({message:l?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,s.iw)("loadAuthorizations",(async()=>{const e=await(0,T.t9)("fetchAuthorizations");e&&(0,s.R3)({...(0,s.Rd)(),activeSessions:{byHash:e.authorizations,orderedHashes:Object.keys(e.authorizations),ttlDays:e.ttlDays}})})),(0,s.iw)("terminateAuthorization",(async(e,t,n)=>{const{hash:a}=n;if(!await(0,T.t9)("terminateAuthorization",a))return;e=(0,s.Rd)();const{[a]:i,...o}=e.activeSessions.byHash;(0,s.R3)({...e,activeSessions:{byHash:o,orderedHashes:e.activeSessions.orderedHashes.filter((e=>e!==a))}})})),(0,s.iw)("terminateAllAuthorizations",(async e=>{if(!await(0,T.t9)("terminateAllAuthorizations"))return;const t=(e=(0,s.Rd)()).activeSessions.orderedHashes.find((t=>e.activeSessions.byHash[t].isCurrent));if(!t)return;const n=e.activeSessions.byHash[t];(0,s.R3)({...e,activeSessions:{byHash:{[t]:n},orderedHashes:[t]}})})),(0,s.iw)("changeSessionSettings",(async(e,t,n)=>{const{hash:a,areCallsEnabled:i,areSecretChatsEnabled:o}=n;await(0,T.t9)("changeSessionSettings",{hash:a,areCallsEnabled:i,areSecretChatsEnabled:o})&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeSessions:{...e.activeSessions,byHash:{...e.activeSessions.byHash,[a]:{...e.activeSessions.byHash[a],...void 0!==i?{areCallsEnabled:i}:void 0,...void 0!==o?{areSecretChatsEnabled:o}:void 0}}}}))})),(0,s.iw)("changeSessionTtl",(async(e,t,n)=>{const{days:a}=n;await(0,T.t9)("changeSessionTtl",{days:a})&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeSessions:{...e.activeSessions,ttlDays:a}}))})),(0,s.iw)("loadWebAuthorizations",(async()=>{const e=await(0,T.t9)("fetchWebAuthorizations");e&&(0,s.R3)({...(0,s.Rd)(),activeWebSessions:{byHash:e,orderedHashes:Object.keys(e)}})})),(0,s.iw)("terminateWebAuthorization",(async(e,t,n)=>{const{hash:a}=n;if(!await(0,T.t9)("terminateWebAuthorization",a))return;e=(0,s.Rd)();const{[a]:i,...o}=e.activeWebSessions.byHash;(0,s.R3)({...e,activeWebSessions:{byHash:o,orderedHashes:e.activeWebSessions.orderedHashes.filter((e=>e!==a))}})})),(0,s.iw)("terminateAllWebAuthorizations",(async e=>{await(0,T.t9)("terminateAllWebAuthorizations")&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeWebSessions:{byHash:{},orderedHashes:[]}}))}));const Y=(0,R.P2)((e=>e()),500,!1);function K(e,t,n){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:n}}}}function Q(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,s.iw)("loadFullUser",((e,t,n)=>{const{userId:s}=n,a=(0,c.dy)(e,s);if(!a)return;const{id:i,accessHash:o}=a;(0,T.t9)("fetchFullUser",{id:i,accessHash:o})})),(0,s.iw)("loadUser",(async(e,t,n)=>{const{userId:a}=n,i=(0,c.dy)(e,a);if(!i)return;const o=await(0,T.t9)("fetchUsers",{users:[i]});if(!o)return;const{users:l,userStatusesById:d}=o;e=(0,s.Rd)(),e=(0,r.eD)(e,(0,g.ee)(l,"id")),e=(0,r.ps)(e,{...e.users.statusesById,...d}),(0,s.R3)(e)})),(0,s.iw)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,p.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,T.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:n}=e;let a=(0,s.Rd)();a=(0,r.Sh)(a,(0,g.ee)(n,"id")),a={...a,topPeers:{...a.topPeers,userIds:t,lastRequestedAt:(0,p.b)(a.serverTimeOffset)}},(0,s.R3)(a)}()})),(0,s.iw)("loadContactList",(()=>{!async function(){const e=await(0,T.t9)("fetchContactList");if(!e)return;let t=(0,r.Sh)((0,s.Rd)(),(0,g.ee)(e.users,"id"));t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id")),t=(0,r.zn)(t,e.userStatusesById);const n=e=>e.lastName||e.firstName||"",a=new Intl.Collator("en-US"),i=e.users.sort(((e,t)=>a.compare(n(e),n(t)))).filter((e=>!e.isSelf));(0,s.R3)({...t,contactList:{userIds:i.map((e=>e.id))}})}()})),(0,s.iw)("loadCurrentUser",(()=>{(0,T.t9)("fetchCurrentUser")})),(0,s.iw)("loadCommonChats",(async e=>{var t,n,a;const{chatId:i}=(0,c.Bt)(e)||{},o=i?(0,c.dy)(e,i):void 0;if(!o||(0,d.cS)(o)||null!==(t=o.commonChats)&&void 0!==t&&t.isFullyLoaded)return;const l=null===(n=o.commonChats)||void 0===n?void 0:n.maxId,u=await(0,T.t9)("fetchCommonChats",o.id,o.accessHash,l);if(!u)return;const{chats:m,chatIds:h,isFullyLoaded:p}=u;e=(0,s.Rd)(),m.length&&(e=(0,r.fZ)(e,(0,g.ee)(m,"id"))),e=(0,r.Nq)(e,o.id,{commonChats:{maxId:h.length?h[h.length-1]:"0",ids:(0,g.Tw)(((null===(a=o.commonChats)||void 0===a?void 0:a.ids)||[]).concat(h)),isFullyLoaded:p}}),(0,s.R3)(e)})),(0,s.iw)("updateContact",((e,t,n)=>{const{userId:a,isMuted:i=!1,firstName:o,lastName:l,shouldSharePhoneNumber:d}=n;!async function(e,t,n,a,i){let o=(0,s.Rd)();const l=(0,c.dy)(o,e);if(!l)return;let d;if((0,s.Sv)().updateChatMutedState({chatId:e,isMuted:t}),(0,s.R3)((0,r.H9)((0,s.Rd)(),m.wv.InProgress)),!l.isContact&&l.phoneNumber)d=await(0,T.t9)("importContact",{phone:l.phoneNumber,firstName:n,lastName:a});else{const{id:e,accessHash:t}=l;d=await(0,T.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:n,lastName:a,shouldSharePhoneNumber:i})}d&&((0,s.Sv)().loadChatSettings({chatId:e}),(0,s.R3)((0,r.Nq)((0,s.Rd)(),l.id,{firstName:n,lastName:a}))),o=(0,s.Rd)(),o=(0,r.H9)(o,m.wv.Complete),o=(0,r.ft)(o),(0,s.R3)(o)}(a,i,o,l,d)})),(0,s.iw)("deleteContact",((e,t,n)=>{const{userId:a}=n;!async function(e){const t=(0,s.Rd)(),n=(0,c.dy)(t,e);if(!n)return;const{id:a,accessHash:i}=n;await(0,T.t9)("deleteContact",{id:a,accessHash:i})}(a)})),(0,s.iw)("loadProfilePhotos",(async(e,t,n)=>{const{profileId:a}=n,i=(0,d.YC)(a),o=i?(0,c.dy)(e,a):void 0,l=i?void 0:(0,c.Z1)(e,a);if(!o&&!l)return;const u=await(0,T.t9)("fetchProfilePhotos",o,l);u&&u.photos&&(e=(0,s.Rd)(),i?e=(0,r.Nq)(e,a,{photos:u.photos}):(e=(0,r.Sh)(e,(0,g.ee)(u.users,"id")),e=(0,r.a4)(e,a,{photos:u.photos})),(0,s.R3)(e))})),(0,s.iw)("setUserSearchQuery",((e,t,n)=>{const{query:a}=n;a&&Y((()=>{!async function(e){const t=await(0,T.t9)("searchChats",{query:e});let n=(0,s.Rd)();const a=n.userSearch.query;if(!t||!a||e!==a)return void(0,s.R3)((0,r.Q3)(n,!1));const{localUsers:i,globalUsers:o}=t;let c,l;i.length&&(n=(0,r.Sh)(n,(0,g.ee)(i,"id")),c=i.map((e=>{let{id:t}=e;return t}))),o.length&&(n=(0,r.Sh)(n,(0,g.ee)(o,"id")),l=o.map((e=>{let{id:t}=e;return t}))),n=(0,r.Q3)(n,!1),n=(0,r.Lm)(n,{localUserIds:c,globalUserIds:l}),(0,s.R3)(n)}(a)}))})),(0,s.iw)("importContact",(async(e,t,n)=>{const{phoneNumber:a,firstName:i,lastName:o}=n,c=await(0,T.t9)("importContact",{phone:a,firstName:i,lastName:o});c?(t.openChat({id:c}),(0,s.R3)((0,r.ft)((0,s.Rd)()))):t.showNotification({message:v.i0("Contacts.PhoneNumber.NotRegistred")})})),(0,s.iw)("reportSpam",((e,t,n)=>{const{chatId:s}=n,a=(0,d.YC)(s)?(0,c.dy)(e,s):(0,c.Z1)(e,s);a&&(0,T.t9)("reportSpam",a)}));var ee=n(18629);const te=h.cj||h.wZ;class ne{constructor(e,t){var n,s;this.features=e,this.onFail=t,s=void 0,(n="preOpened")in this?Object.defineProperty(this,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):this[n]=s}preOpenIfNeeded(){var e;te&&(this.preOpened=window.open("about:blank",void 0,this.features),this.preOpened?this.preOpened.blur():null===(e=this.onFail)||void 0===e||e.call(this))}open(e){if(this.preOpened)return this.preOpened.location.href=e,this.preOpened.focus(),void(this.preOpened=void 0);if(!te){const n=window.open(e,void 0,this.features);var t;n?n.focus():null===(t=this.onFail)||void 0===t||t.call(this)}}cancelPreOpen(){var e;null===(e=this.preOpened)||void 0===e||e.close(),this.preOpened=void 0}}const se="https://prizes.gamee.com/",ae=(0,R.Ds)((e=>e()),500,!1);async function ie(e,t){await(0,T.t9)("toggleBotInAttachMenu",{bot:e,isEnabled:t}),await oe()}async function oe(e){const t=await(0,T.t9)("loadAttachMenuBots",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,attachMenu:{hash:t.hash,bots:t.bots}})}function re(e,t){if("request"===t.type){const e=(0,s.Rd)();if(!e.urlAuth)return;const{domain:n,bot:a,shouldRequestWriteAccess:i}=t;return void(0,s.R3)({...e,urlAuth:{...e.urlAuth,request:{domain:n,botId:a.id,shouldRequestWriteAccess:i}}})}const n="accepted"===t.type?t.url:e;window.open(n,"_blank","noopener"),(0,s.Sv)().closeUrlAuthModal()}async function ce(e,t,n,s,a){await(0,T.t9)("sendMessage",{chat:e,text:n,replyingTo:s,sendAs:a})}let le;async function de(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{showDialog:i,showNotification:o,openUrl:r,openGame:c}=(0,s.Sv)();a&&(le||(le=new ne("popup,width=800,height=600",(()=>{o({message:"Allow browser to open popup window"})}))),le.preOpenIfNeeded());const l=await(0,T.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:n,isGame:a});if(!l)return;const{message:d,alert:u,url:m}=l;u?i({data:{message:d||"Error"}}):d?o({message:d}):m&&(a?m.includes(se)?le.open(m):(le.cancelPreOpen(),c({url:m,chatId:e.id,messageId:t})):r({url:m}))}async function ue(e,t,n){const a=await(0,T.t9)("validateRequestedInfo",{inputInvoice:e,requestInfo:t,shouldSave:n});if(!a)return;const{id:i,shippingOptions:o}=a;if(!i)return;let c=(0,r.vT)((0,s.Rd)(),i);o?(c=(0,r.TM)(c,o),c=(0,r.Q$)(c,m.KB.Shipping)):c=(0,r.Q$)(c,m.KB.PaymentInfo),(0,s.R3)(c)}async function me(e){const t=await(0,T.t9)("getPaymentForm",e);if(!t)return;const{form:n,invoice:a}=t;let i=(0,r._7)((0,s.Rd)(),n),o=m.KB.PaymentInfo;const{shippingAddressRequested:c,nameRequested:l,phoneRequested:d,emailRequested:u}=i.payment.invoice||{};return(c||l||d||u)&&(o=m.KB.ShippingInfo),i=(0,r.Q$)(i,o),(0,s.R3)(i),a}(0,s.iw)("clickBotInlineButton",((e,t,n)=>{const{messageId:s,button:a}=n;switch(a.type){case"command":t.sendBotCommand({command:a.text});break;case"url":{const{url:e}=a;t.openUrl({url:e});break}case"callback":{const t=(0,c.jr)(e);if(!t)return;de(t,s,a.data);break}case"requestPoll":t.openPollModal({isQuiz:a.isQuiz});break;case"requestPhone":{const n=e.currentUserId?(0,c.dy)(e,e.currentUserId):void 0;if(!n)return;t.showDialog({data:{phoneNumber:n.phoneNumber,firstName:n.firstName,lastName:n.lastName,userId:n.id}});break}case"receipt":{const n=(0,c.jr)(e);if(!n)return;const{receiptMessageId:i}=a;t.getReceipt({receiptMessageId:i,chatId:n.id,messageId:s});break}case"buy":{const n=(0,c.jr)(e);if(!n)return;t.openInvoice({chatId:n.id,messageId:s});break}case"game":{const t=(0,c.jr)(e);if(!t)return;de(t,s,void 0,!0);break}case"switchBotInline":{const{query:e,isSamePeer:n}=a;t.switchBotInline({query:e,isSamePeer:n,messageId:s});break}case"userProfile":{const{userId:e}=a;t.openChatWithInfo({id:e});break}case"simpleWebView":{const{url:n}=a,{chatId:i}=(0,c.Bt)(e)||{};if(!i)return;const o=(0,c.hj)(e,i,s);if(null==o||!o.senderId)return;const r=(0,ee.B)();t.requestSimpleWebView({url:n,botId:null==o?void 0:o.senderId,theme:r,buttonText:a.text});break}case"webView":{const{url:n}=a,i=(0,c.jr)(e);if(!i)return;const o=(0,c.hj)(e,i.id,s);if(!o)return;const r=o.viaBotId||o.senderId;if(!r)return;const l=(0,ee.B)();t.requestWebView({url:n,botId:r,peerId:i.id,theme:l,buttonText:a.text});break}case"urlAuth":{const{url:n}=a,i=(0,c.jr)(e);if(!i)return;t.requestBotUrlAuth({chatId:i.id,messageId:s,buttonId:a.buttonId,url:n});break}}})),(0,s.iw)("sendBotCommand",((e,t,n)=>{const{command:s,chatId:a}=n,{currentUserId:i}=e,o=a?(0,c.Z1)(e,a):(0,c.jr)(e),r=(0,c.Bt)(e);if(!i||!o||!r)return;const{threadId:l}=r;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o.id,threadId:l,value:!1}),ce(o,0,s,(0,c.Yy)(e,o.id,l),(0,c._5)(e,a))})),(0,s.iw)("restartBot",(async(e,t,n)=>{const{chatId:a}=n,{currentUserId:i}=e,o=(0,c.jr)(e),l=i&&(0,c.IK)(e,a);i&&o&&l&&await(0,T.t9)("unblockContact",l.id,l.accessHash)&&((0,s.R3)((0,r.rB)((0,s.Rd)(),l.id)),ce(o,0,"/start",void 0,(0,c._5)(e,a)))})),(0,s.iw)("loadTopInlineBots",(async e=>{const{lastRequestedAt:t}=e.topInlineBots;if(t&&(0,p.b)(e.serverTimeOffset)-t<60)return;const n=await(0,T.t9)("fetchTopInlineBots");if(!n)return;const{ids:a,users:i}=n;e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(i,"id")),e={...e,topInlineBots:{...e.topInlineBots,userIds:a,lastRequestedAt:(0,p.b)(e.serverTimeOffset)}},(0,s.R3)(e)})),(0,s.iw)("queryInlineBot",(async(e,t,n)=>{const{chatId:a,username:i,query:o,offset:l}=n;let d=e.inlineBots.byUsername[i];if(!1!==d){if(void 0===d){const{user:t,chat:n}=await(0,T.t9)("fetchInlineBot",{username:i})||{};if(e=(0,s.Rd)(),!t||!n)return void(0,s.R3)(K(e,i,!1));e=(0,r.Sh)(e,{[t.id]:t}),e=(0,r.fZ)(e,{[n.id]:n}),d={id:t.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=K(e,i,d),(0,s.R3)(e)}(o!==d.query||d.canLoadMore)&&ae((()=>{!async function(e){let{username:t,inlineBotData:n,chatId:a,query:i,offset:o}=e,r=(0,s.Rd)();const l=(0,c.dy)(r,n.id),d=(0,c.Z1)(r,a);if(!l||!d)return;const u=n.query!==i;r=Q(r,!0),r=K(r,t,{...n,query:i,...u&&{offset:void 0,results:[]}}),(0,s.R3)(r);const m=await(0,T.t9)("fetchInlineBotResults",{bot:l,chat:d,query:i,offset:u?void 0:o}),h=r.inlineBots.byUsername[t];if(r=Q((0,s.Rd)(),!1),!m||!h||i!==h.query)return void(0,s.R3)(r);const g=new Set((h.results||[]).map((e=>e.id))),p=m.results.filter((e=>!g.has(e.id)));r=K(r,t,{...h,help:m.help,...p.length&&{isGallery:m.isGallery},...m.switchPm&&{switchPm:m.switchPm},canLoadMore:m.results.length>0&&Boolean(m.nextOffset),results:""===h.offset||h.offset===m.nextOffset?m.results:(h.results||[]).concat(p),offset:p.length?m.nextOffset:""}),(0,s.R3)(r)}({username:i,inlineBotData:d,chatId:a,query:o,offset:l})}))}})),(0,s.iw)("switchBotInline",((e,t,n)=>{const{query:s,isSamePeer:a,messageId:i}=n,o=(0,c.jr)(e);if(!o)return;const r=(0,c.hj)(e,o.id,i);if(!r)return;const l=(0,c.IK)(e,r.senderId);if(!l)return;const d=`@${l.username} ${s}`;if(!a)return{...e,switchBotInline:{query:s,botUsername:l.username}};t.openChatWithText({chatId:o.id,text:d})})),(0,s.iw)("resetSwitchBotInline",(e=>({...e,switchBotInline:void 0}))),(0,s.iw)("sendInlineBotResult",((e,t,n)=>{const{id:s,queryId:a,isSilent:i,scheduledAt:o}=n,r=(0,c.Bt)(e);if(!r||!s)return;const{chatId:l,threadId:d}=r,u=(0,c.Z1)(e,l);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:l,threadId:d,value:!1}),(0,T.t9)("sendInlineBotResult",{chat:u,resultId:s,queryId:a,replyingTo:(0,c.Yy)(e,l,d),sendAs:(0,c._5)(e,l),isSilent:i,scheduleDate:o})})),(0,s.iw)("resetInlineBot",((e,t,n)=>{const{username:a}=n;let i=e.inlineBots.byUsername[a];i&&(i={id:i.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,s.R3)(K(e,a,i)))})),(0,s.iw)("startBot",(async(e,t,n)=>{var a;const{botId:i,param:o}=n;let r=(0,c.dy)(e,i);r&&(r.fullInfo||await(0,T.t9)("fetchFullUser",{id:r.id,accessHash:r.accessHash}),r=(0,c.dy)((0,s.Rd)(),i),null!==(a=r.fullInfo)&&void 0!==a&&a.isBlocked&&await(0,T.t9)("unblockContact",r.id,r.accessHash),await(0,T.t9)("startBot",{bot:r,startParam:o}))})),(0,s.iw)("requestSimpleWebView",(async(e,t,n)=>{const{url:a,botId:i,theme:o,buttonText:r}=n,l=(0,c.dy)(e,i);if(!l)return;if(!(0,c.LM)(e,i))return void(0,s.R3)({...e,botTrustRequest:{botId:i,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:n}}});const d=await(0,T.t9)("requestSimpleWebView",{url:a,bot:l,theme:o});d&&(e=(0,s.Rd)(),(0,s.R3)({...e,webApp:{url:d,botId:i,buttonText:r}}))})),(0,s.iw)("requestWebView",(async(e,t,n)=>{const{url:a,botId:i,peerId:o,theme:r,isSilent:l,buttonText:d,isFromBotMenu:u,startParam:m}=n,h=(0,c.dy)(e,i);if(!h)return;const g=(0,c.Z1)(e,o);if(!g)return;if(!(0,c.LM)(e,i))return void(0,s.R3)({...e,botTrustRequest:{botId:i,type:"webApp",onConfirm:{action:"requestWebView",payload:n}}});const p=(0,c.Bt)(e);if(!p)return;const{chatId:f,threadId:v}=p,I=f&&(0,c.Yy)(e,f,v),w=(0,c._5)(e,f),y=await(0,T.t9)("requestWebView",{url:a,bot:h,peer:g,theme:r,isSilent:l,replyToMessageId:I||void 0,isFromBotMenu:u,startParam:m,sendAs:w});if(!y)return;const{url:Z,queryId:P}=y;e=(0,s.Rd)(),(0,s.R3)({...e,webApp:{url:Z,botId:i,queryId:P,buttonText:d}})})),(0,s.iw)("prolongWebView",(async(e,t,n)=>{const{botId:s,peerId:a,isSilent:i,replyToMessageId:o,queryId:r}=n,l=(0,c.dy)(e,s);if(!l)return;const d=(0,c.Z1)(e,a);if(!d)return;const u=(0,c._5)(e,a);await(0,T.t9)("prolongWebView",{bot:l,peer:d,isSilent:i,replyToMessageId:o,queryId:r,sendAs:u})||t.closeWebApp()})),(0,s.iw)("sendWebViewData",((e,t,n)=>{const{bot:s,data:a,buttonText:i}=n;(0,T.t9)("sendWebViewData",{bot:s,data:a,buttonText:i})})),(0,s.iw)("closeWebApp",(e=>({...e,webApp:void 0}))),(0,s.iw)("setWebAppPaymentSlug",((e,t,n)=>{var s;if(null!==(s=e.webApp)&&void 0!==s&&s.url)return{...e,webApp:{...e.webApp,slug:n.slug}}})),(0,s.iw)("cancelBotTrustRequest",(e=>({...e,botTrustRequest:void 0}))),(0,s.iw)("markBotTrusted",((e,t,n)=>{var a;const{botId:i}=n,{trustedBotIds:o}=e,r=new Set(o);if(r.add(i),(0,s.R3)({...e,botTrustRequest:void 0,trustedBotIds:Array.from(r)}),null!==(a=e.botTrustRequest)&&void 0!==a&&a.onConfirm){const{action:n,payload:s}=e.botTrustRequest.onConfirm;t[n](s)}})),(0,s.iw)("loadAttachMenuBots",(async(e,t,n)=>{const{hash:s}=n||{};await oe(s)})),(0,s.iw)("toggleBotInAttachMenu",(async(e,t,n)=>{const{botId:s,isEnabled:a}=n,i=(0,c.dy)(e,s);i&&await ie(i,a)})),(0,s.iw)("callAttachMenuBot",((e,t,n)=>{const{chatId:s,botId:a,isFromBotMenu:i,url:o,startParam:r}=n,{attachMenu:{bots:c}}=e;if(!i&&!c[a])return{...e,botAttachRequest:{botId:a,chatId:s,startParam:r}};const l=(0,ee.B)();t.requestWebView({url:o,peerId:s,botId:a,theme:l,buttonText:"",isFromBotMenu:i,startParam:r})})),(0,s.iw)("confirmBotAttachRequest",(async(e,t)=>{const{botAttachRequest:n}=e;if(!n)return;const{botId:a,chatId:i,startParam:o}=n;(0,s.R3)({...e,botAttachRequest:void 0});const r=(0,c.dy)(e,a);r&&(await ie(r,!0),t.callAttachMenuBot({chatId:i,botId:a,startParam:o}))})),(0,s.iw)("closeBotAttachRequestModal",(e=>({...e,botAttachRequest:void 0}))),(0,s.iw)("requestBotUrlAuth",(async(e,t,n)=>{const{chatId:a,buttonId:i,messageId:o,url:r}=n,l=(0,c.Z1)(e,a);if(!l)return;const d=await(0,T.t9)("requestBotUrlAuth",{chat:l,buttonId:i,messageId:o});d&&(e=(0,s.Rd)(),(0,s.R3)({...e,urlAuth:{url:r,button:{buttonId:i,messageId:o,chatId:l.id}}}),re(r,d))})),(0,s.iw)("acceptBotUrlAuth",(async(e,t,n)=>{var s;const{isWriteAllowed:a}=n;if(null===(s=e.urlAuth)||void 0===s||!s.button)return;const{button:i,url:o}=e.urlAuth,{chatId:r,messageId:l,buttonId:d}=i,u=(0,c.Z1)(e,r);if(!u)return;const m=await(0,T.t9)("acceptBotUrlAuth",{chat:u,messageId:l,buttonId:d,isWriteAllowed:a});m&&re(o,m)})),(0,s.iw)("requestLinkUrlAuth",(async(e,t,n)=>{const{url:a}=n,i=await(0,T.t9)("requestLinkUrlAuth",{url:a});i&&(e=(0,s.Rd)(),(0,s.R3)({...e,urlAuth:{url:a}}),re(a,i))})),(0,s.iw)("acceptLinkUrlAuth",(async(e,t,n)=>{var s;const{isWriteAllowed:a}=n;if(null===(s=e.urlAuth)||void 0===s||!s.url)return;const{url:i}=e.urlAuth,o=await(0,T.t9)("acceptLinkUrlAuth",{url:i,isWriteAllowed:a});o&&re(i,o)})),(0,s.iw)("closeUrlAuthModal",(e=>({...e,urlAuth:void 0}))),n(51371),(0,s.iw)("loadPasswordInfo",(async e=>{const t=await(0,T.t9)("getPasswordInfo");t&&(e=(0,s.Rd)(),e=(0,r.BI)(e,{hasPassword:t.hasPassword}),e=(0,r.IE)(e,{hint:t.hint}),(0,s.R3)(e))})),(0,s.iw)("checkPassword",(async(e,t,n)=>{const{currentPassword:a,onSuccess:i}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const o=await(0,T.t9)("checkPassword",a);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),o&&i()})),(0,s.iw)("clearPassword",(async(e,t,n)=>{const{currentPassword:a,onSuccess:i}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const o=await(0,T.t9)("clearPassword",a);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),o&&i()})),(0,s.iw)("updatePassword",(async(e,t,n)=>{const{currentPassword:a,password:i,hint:o,email:c,onSuccess:l}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const d=await(0,T.t9)("updatePassword",a,i,o,c);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),d&&l()})),(0,s.iw)("updateRecoveryEmail",(async(e,t,n)=>{const{currentPassword:a,email:i,onSuccess:o}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const c=await(0,T.t9)("updateRecoveryEmail",a,i);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),c&&o()})),(0,s.iw)("provideTwoFaEmailCode",((e,t,n)=>{const{code:s}=n;(0,T.t9)("provideRecoveryEmailCode",s)})),(0,s.iw)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,s.iw)("validateRequestedInfo",((e,t,n)=>{const{requestInfo:s,saveInfo:a}=n,i=(0,c.kb)(e);if(i)if("slug"in i)ue(i,s,a);else{const t=(0,c.Z1)(e,i.chatId);if(!t)return;ue({chat:t,messageId:i.messageId},s,a)}})),(0,s.iw)("openInvoice",(async(e,t,n)=>{let a;if("slug"in n)a=await me({slug:n.slug});else{const t=(0,c.Z1)(e,n.chatId);if(!t)return;a=await me({chat:t,messageId:n.messageId})}a&&(e=(0,s.Rd)(),e=(0,r.bs)(e,a),(0,s.R3)({...e,payment:{...e.payment,inputInvoice:n,isPaymentModalOpen:!0,status:"cancelled"}}))})),(0,s.iw)("getReceipt",((e,t,n)=>{const{receiptMessageId:a,chatId:i,messageId:o}=n,l=i&&(0,c.Z1)(e,i);o&&a&&l&&async function(e,t,n){const a=await(0,T.t9)("getReceipt",e,n);if(!a)return;let i=(0,s.Rd)();const o=(0,c.hj)(i,e.id,t);i=(0,r.Dq)(i,a,o),(0,s.R3)(i)}(l,o,a)})),(0,s.iw)("clearPaymentError",(e=>{(0,s.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,s.iw)("clearReceipt",(e=>{(0,s.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,s.iw)("sendCredentialsInfo",((e,t,n)=>{const{nativeProvider:i}=e.payment,{credentials:o}=n,{data:l}=o;if("stripe"===i){const t=(0,c.$$)(e);if(!t)return;!async function(e,t){const n=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${n}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),i=await a.json();if(i.error){const e=(0,d.Ow)(i.error),t=(0,s.Rd)();return void(0,s.R3)({...t,payment:{...t.payment,status:"failed",error:{...e}}})}let o=(0,r.QH)((0,s.Rd)(),{type:i.type,id:i.id});o=(0,r.Q$)(o,m.KB.Checkout),(0,s.R3)(o)}(l,t)}else if("smartglocal"===i){const t=(0,c.EB)(e);if(!t)return;!async function(e,t){const n={card:{number:e.cardNumber.replace(/[^\d]+/g,""),expiration_month:e.expiryMonth,expiration_year:e.expiryYear,security_code:e.cvv.replace(/[^\d]+/g,"")}},i=a.eA?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",o=await fetch(i,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":t},body:JSON.stringify(n)}),c=await o.json();if("ok"!==c.status){const e={description:"payment error"},t=(0,s.Rd)();return void(0,s.R3)({...t,payment:{...t.payment,status:"failed",error:{...e}}})}let l=(0,r.QD)((0,s.Rd)(),{type:"card",token:c.data.token});l=(0,r.Q$)(l,m.KB.Checkout),(0,s.R3)(l)}(l,t)}})),(0,s.iw)("sendPaymentForm",((e,t,n)=>{const{shippingOptionId:a,saveCredentials:i}=n,o=(0,c.kb)(e),l=(0,c.eh)(e),d=(0,c.sp)(e),{nativeProvider:u}=e.payment,m="stripe"===u?(0,c.$$)(e):(0,c.EB)(e);if(!(o&&m&&l&&u))return;let h;if("slug"in o)h={slug:o.slug};else{const t=(0,c.Z1)(e,o.chatId);if(!t)return;h={chat:t,messageId:o.messageId}}return async function(e,t,n,a,i){if(!0===await(0,T.t9)("sendPaymentForm",{inputInvoice:e,formId:t,credentials:n,requestedInfoId:a,shippingOptionId:i})){let e=(0,r.bp)((0,s.Rd)());e={...e,payment:{...e.payment,status:"paid"}},(0,s.R3)((0,r.WY)(e))}}(h,l,{save:i,data:"stripe"===u?(0,c.i3)(e):(0,c.Jg)(e)},d,a),{...e,payment:{...e.payment,status:"pending"}}})),(0,s.iw)("setPaymentStep",(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,r.Q$)(e,n.step||m.KB.ShippingInfo)})),(0,s.iw)("closePremiumModal",((e,t,n)=>{if(!e.premiumModal)return;const{isClosed:s}=n||{};return{...e,premiumModal:{...e.premiumModal,...s&&{isOpen:!1},isClosing:!s}}})),(0,s.iw)("openPremiumModal",(async(e,t,n)=>{const{initialSection:a,fromUserId:i,isSuccess:o}=n||{};t.loadPremiumStickers();const c=await(0,T.t9)("fetchPremiumPromo");c&&(e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(c.users,"id")),(0,s.R3)({...e,premiumModal:{promo:c.promo,initialSection:a,isOpen:!0,fromUserId:i,isSuccess:o}}))}));var he=n(40647),ge=n(4907);const pe=728,fe=424,ve=288;var Ie=n(43858),we=n(53475);function ye(e,t){return t-(e.isLeftColumnShown&&!h.wB?e.leftColumnWidth||((n=Ie.Z.get().width)>a._m?Math.min(Math.max(.25*n,ve),.33*n):n>a.ks?Math.min(Math.max(.33*n,ve),.4*n):fe):0);var n}function Ze(e,t,n){return(0,we.a4)(e,t,n,void 0,!0)}let Pe=0;(0,s.iw)("loadAvailableReactions",(async()=>{const e=await(0,T.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&he.he(`sticker${e.aroundAnimation.id}`,o.IU.BlobUrl),e.centerIcon&&he.he(`sticker${e.centerIcon.id}`,o.IU.BlobUrl)})),(0,s.R3)({...(0,s.Rd)(),availableReactions:e}))})),(0,s.iw)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:s,x:a,y:i,localEffect:o,startSize:r,isReversed:c}=n,l={id:Pe++,animatedEffect:s||o,x:ye(e,a)+40*Math.random()-20,y:i+40*Math.random()-20,startSize:r,isReversed:c};return{...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],l]}})),(0,s.iw)("sendEmojiInteraction",((e,t,n)=>{const{messageId:s,chatId:a,emoji:i,interactions:o,localEffect:r}=n,l=(0,c.Z1)(e,a);l&&(i||r)&&a!==e.currentUserId&&(0,T.t9)("sendEmojiInteraction",{chat:l,messageId:s,emoticon:i||(0,c.ji)(r),timestamps:o})})),(0,s.iw)("sendDefaultReaction",((e,t,n)=>{const{chatId:s,messageId:a,x:i,y:o}=n,r=(0,c.q6)(e,s),l=(0,c.hj)(e,s,a);r&&l&&!(0,d.CI)(l)&&t.sendReaction({chatId:s,messageId:a,reaction:r,x:i,y:o})})),(0,s.iw)("sendReaction",((e,t,n)=>{var s,i,o;const{chatId:r}=n;let{messageId:l}=n,{reaction:d}=n;const u=(0,c.Z1)(e,r);let m=(0,c.hj)(e,r,l);if(!u||!m)return;const h=Boolean(m.groupedId)&&!m.isInAlbum,p=h?(0,c.xH)(e,r,m.groupedId)[0]:void 0;m=h&&(0,c.hj)(e,r,p)||m,l=(null===(s=m)||void 0===s?void 0:s.id)||l,null!==(i=m.reactions)&&void 0!==i&&null!==(o=i.results)&&void 0!==o&&o.some((e=>e.reaction===d&&e.isChosen))&&(d=void 0),(0,T.t9)("sendReaction",{chat:u,messageId:l,reaction:d});const{animationLevel:f}=e.settings.byKey;return f===a.zy&&(e={...e,activeReactions:{...d?e.activeReactions:(0,g.CE)(e.activeReactions,[l]),...d&&{[l]:{reaction:d,messageId:l}}}}),function(e,t,n,s){const{reactions:a}=(0,c.hj)(e,t,n)||{};if(!a)return e;let i=a.results.map((e=>e.reaction===s?{...e,count:e.isChosen?e.count:e.count+1,isChosen:!0}:e.isChosen?{...e,isChosen:!1,count:e.count-1}:e)).filter((e=>e.count>0)),{recentReactions:o}=a;if(s&&!i.some((e=>e.reaction===s))){const{currentUserId:t}=e;i=[...i,{reaction:s,isChosen:!0,count:1}],a.canSeeList&&(o=[...o||[],{userId:t,reaction:s}])}return(0,ge.cY)(e,t,n,{reactions:{...a,results:i,recentReactions:o}})}(e,r,l,d)})),(0,s.iw)("openChat",(e=>({...e,activeReactions:{}}))),(0,s.iw)("stopActiveReaction",((e,t,n)=>{var s;const{messageId:a,reaction:i}=n;return(null===(s=e.activeReactions[a])||void 0===s?void 0:s.reaction)!==i?e:{...e,activeReactions:(0,g.CE)(e.activeReactions,[a])}})),(0,s.iw)("setDefaultReaction",(async(e,t,n)=>{const{reaction:a}=n;await(0,T.t9)("setDefaultReaction",{reaction:a})&&(0,s.R3)({...(0,s.Rd)(),appConfig:{...e.appConfig,defaultReaction:a}})})),(0,s.iw)("stopActiveEmojiInteraction",((e,t,n)=>{var s;const{id:a}=n;return{...e,activeEmojiInteractions:null===(s=e.activeEmojiInteractions)||void 0===s?void 0:s.filter((e=>e.id!==a))}})),(0,s.iw)("loadReactors",(async(e,t,n)=>{var a,i,o;const{chatId:l,messageId:d,reaction:u}=n,m=(0,c.Z1)(e,l),h=(0,c.hj)(e,l,d);if(!m||!h)return;const p=null===(a=h.reactors)||void 0===a?void 0:a.nextOffset,f=await(0,T.t9)("fetchMessageReactionsList",{reaction:u,chat:m,messageId:d,offset:p});if(!f)return;e=(0,s.Rd)(),null!==(i=f.users)&&void 0!==i&&i.length&&(e=(0,r.Sh)(e,(0,g.ee)(f.users,"id")));const{nextOffset:v,count:I,reactions:w}=f;(0,s.R3)((0,r.cY)(e,l,d,{reactors:{nextOffset:v,count:I,reactions:[...(null===(o=h.reactors)||void 0===o?void 0:o.reactions)||[],...w]}}))})),(0,s.iw)("loadMessageReactions",((e,t,n)=>{const{ids:s,chatId:a}=n,i=(0,c.Z1)(e,a);i&&(0,T.t9)("fetchMessageReactions",{ids:s,chat:i})})),(0,s.iw)("sendWatchingEmojiInteraction",((e,t,n)=>{var s;const{chatId:a,emoticon:i,x:o,y:r,startSize:l,isReversed:d,id:u}=n,m=(0,c.Z1)(e,a);if(m&&null!==(s=e.activeEmojiInteractions)&&void 0!==s&&s.some((e=>e.id===u))&&a!==e.currentUserId)return(0,T.t9)("sendWatchingEmojiInteraction",{chat:m,emoticon:i}),{...e,activeEmojiInteractions:e.activeEmojiInteractions.map((t=>t.id===u?{...t,x:ye(e,o),y:r,startSize:l,isReversed:d}:t))}})),(0,s.iw)("fetchUnreadReactions",(async(e,t,n)=>{const{chatId:a,offsetId:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const l=await(0,T.t9)("fetchUnreadReactions",{chat:o,offsetId:i,addOffset:i?-1:void 0});if(!l||!l.messages.length)return e=Ze(e=(0,s.Rd)(),a,{unreadReactionsCount:0}),void(0,s.R3)(e);const{messages:d,chats:u,users:m}=l,h=(0,g.ee)(d,"id"),p=Object.keys(h).map(Number);e=(0,s.Rd)(),e=(0,r.c_)(e,o.id,h),e=(0,r.Sh)(e,(0,g.ee)(m,"id")),e=Ze(e=(0,r.fZ)(e,(0,g.ee)(u,"id")),a,{unreadReactions:[...o.unreadReactions||[],...p]}),(0,s.R3)(e)})),(0,s.iw)("animateUnreadReaction",((e,t,n)=>{const{messageIds:i}=n,{animationLevel:o}=e.settings.byKey,r=(0,c.jr)(e);if(r){if(r.unreadReactionsCount){const n=r.unreadReactionsCount-i.length,a=(r.unreadReactions||[]).filter((e=>!i.includes(e)));e=Ze(e,r.id,{unreadReactions:a}),(0,s.R3)(e),!a.length&&n&&t.fetchUnreadReactions({chatId:r.id,offsetId:Math.min(...i)})}if(t.markMessagesRead({messageIds:i}),o===a.zy)return e=(0,s.Rd)(),{...e,activeReactions:{...e.activeReactions,...Object.fromEntries(i.map((t=>{var n,s;const a=(0,c.hj)(e,r.id,t);if(!a)return;const i=null===(n=a.reactions)||void 0===n||null===(s=n.recentReactions)||void 0===s?void 0:s.find((e=>e.isUnread));return i?[t,{messageId:t,reaction:null==i?void 0:i.reaction}]:void 0})).filter(Boolean))}}}})),(0,s.iw)("focusNextReaction",((e,t)=>{const n=(0,c.jr)(e);null!=n&&n.unreadReactions&&t.focusMessage({chatId:n.id,messageId:n.unreadReactions[0]})})),(0,s.iw)("readAllReactions",(e=>{const t=(0,c.jr)(e);if(t)return(0,T.t9)("readAllReactions",{chat:t}),Ze(e,t.id,{unreadReactionsCount:void 0,unreadReactions:void 0})})),(0,s.iw)("loadStatistics",(async(e,t,n)=>{var a;const{chatId:i,isGroup:o}=n,l=(0,c.Z1)(e,i);if(null==l||!l.fullInfo)return;const d=await(0,T.t9)(o?"fetchGroupStatistics":"fetchChannelStatistics",{chat:l});if(d){if(e=(0,s.Rd)(),null!==(a=d.recentTopMessages)&&void 0!==a&&a.length){const t=(0,c.Zw)(e,i);d.recentTopMessages=d.recentTopMessages.map((e=>({...e,...t[e.msgId]})))}(0,s.R3)((0,r.ze)(e,i,d))}})),(0,s.iw)("loadMessageStatistics",(async(e,t,n)=>{const{chatId:a,messageId:i}=n,o=(0,c.Z1)(e,a);if(null==o||!o.fullInfo)return;let l=await(0,T.t9)("fetchMessageStatistics",{chat:o,messageId:i});l||(l={}),e=(0,s.Rd)();const{views:d,forwards:u}=(0,c.Zw)(e,a)[i];l.views=d,l.forwards=u;const m=o.fullInfo.statisticsDcId,h=await(0,T.t9)("fetchMessagePublicForwards",{chat:o,messageId:i,dcId:m});l.publicForwards=null==h?void 0:h.length,l.publicForwardsData=h,e=(0,s.Rd)(),(0,s.R3)((0,r.kM)(e,l))})),(0,s.iw)("loadStatisticsAsyncGraph",(async(e,t,n)=>{const{chatId:a,token:i,name:o,isPercentage:l}=n,d=(0,c.Z1)(e,a);if(null==d||!d.fullInfo)return;const u=d.fullInfo.statisticsDcId,m=await(0,T.t9)("fetchStatisticsAsyncGraph",{token:i,dcId:u,isPercentage:l});m&&(0,s.R3)((0,r.yC)((0,s.Rd)(),a,o,m))})),n(28304);var Ce=n(28406);function be(e,t){const n=typeof e;if(n!==typeof t)return!1;if("object"!==n)return e===t;const s=Array.isArray(e);if(s!==Array.isArray(t))return!1;if(s){const n=e,s=t;return n.length===s.length&&n.every(((e,t)=>be(e,s[t])))}const a=e,i=t;return Object.keys(a).every((e=>be(a[e],i[e])))}(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":return(0,s.R3)((0,r.a4)(e,n.id,n.chat,n.newProfilePhoto)),n.noTopChatsRequest||(0,c.N)(e,n.id)||t.loadTopChats(),void(n.chat.id&&(0,Ce.Vr)({chatId:n.chat.id,lastReadInboxMessageId:n.chat.lastReadInboxMessageId}));case"updateChatJoin":{const a=(0,c.Ek)(e,n.id);if(!a)return;e=(0,r.B1)(e,a,[n.id]),e=(0,r.a4)(e,n.id,{isNotJoined:!1}),(0,s.R3)(e);const i=(0,c.Z1)(e,n.id);return void(i&&t.requestChatUpdate({chatId:i.id}))}case"updateChatLeave":return(0,r.Dd)(e,n.id);case"updateChatInbox":return(0,r.a4)(e,n.id,n.chat);case"updateChatTypingStatus":{const{id:t,typingStatus:a}=n;return(0,s.R3)((0,r.a4)(e,t,{typingStatus:a})),void setTimeout((()=>{e=(0,s.Rd)();const n=(0,c.Z1)(e,t);n&&a&&n.typingStatus&&n.typingStatus.timestamp===a.timestamp&&(0,s.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3)}case"newMessage":{const{message:a}=n,{chatId:i,threadId:l,type:d}=(0,c.Bt)(e)||{};if(a.senderId===e.currentUserId&&!a.isFromScheduled)return;const u=(0,c.Z1)(e,n.chatId);if(!u)return;return"thread"===d&&l===o._f&&n.chatId===i&&setTimeout((()=>{t.requestChatUpdate({chatId:n.chatId})}),1500),(0,s.R3)((0,r.a4)(e,n.chatId,{unreadCount:u.unreadCount?u.unreadCount+1:1,...n.message.id&&n.message.hasUnreadMention&&{unreadMentionsCount:(u.unreadMentionsCount||0)+1,unreadMentions:[...u.unreadMentions||[],n.message.id]}})),void(0,Ce.rh)({chat:u,message:a})}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:s}=n;if(!1!==s.hasUnreadMention)return;return t.forEach((t=>{const s="channelId"in n?n.channelId:(0,c.X5)(e,t),a=(0,c.Z1)(e,s);var i,o;null!=a&&a.unreadReactionsCount&&(e=Ze(e,s,{unreadReactionsCount:a.unreadReactionsCount-1||void 0,unreadReactions:null===(i=a.unreadReactions)||void 0===i?void 0:i.filter((e=>e!==t))})),null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,s,{unreadMentionsCount:a.unreadMentionsCount-1||void 0,unreadMentions:null===(o=a.unreadMentions)||void 0===o?void 0:o.filter((e=>e!==t))}))})),e}case"updateChatFullInfo":{const{fullInfo:t}=n,s=e.chats.byId[n.id];if(!s)return;return(0,r.a4)(e,n.id,{fullInfo:{...s.fullInfo,...t}})}case"updatePinnedChatIds":{const{ids:t,folderId:s}=n,i=s===a.WS?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:s}=n,i=(0,c.Ek)(e,t);if(!i)return;const{[i]:o}=e.chats.orderedPinnedIds;let r=o||[];if(s){if(!r.includes(t)){if("active"===i&&r.length>=a.EG){const t=e.chats.listIds.active;r=r.filter((e=>t&&t.includes(e)))}r=[t,...r]}}else r=r.filter((e=>e!==t));return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:r.length?r:void 0}}}}case"updateChatListType":{const{id:t,folderId:s}=n;return(0,r.Pi)(e,t,s)}case"updateChatFolder":{const{id:t,folder:s}=n,{byId:a,orderedIds:i}=e.chatFolders,o=s?{...a,[t]:s}:(0,g.ei)(a,Object.keys(a).map(Number).filter((e=>e!==t))),r=s?i&&i.includes(t)?i:[...i||[],t]:i?i.filter((e=>e!==t)):void 0;return{...e,chatFolders:{...e.chatFolders,byId:o,orderedIds:r}}}case"updateChatFoldersOrder":{const{orderedIds:t}=n;return{...e,chatFolders:{...e.chatFolders,orderedIds:t}}}case"updateRecommendedChatFolders":{const{folders:t}=n;return{...e,chatFolders:{...e.chatFolders,recommended:t}}}case"updateChatMembers":{var i;const t=e.chats.byId[n.id],{replacedMembers:s,addedMember:a,deletedMemberId:o}=n;if(!t)return;let c=!1,l=null!==(i=t.fullInfo)&&void 0!==i&&i.members?[...t.fullInfo.members]:[];if(s)l=s,c=!0;else if(a)l.length&&l.some((e=>e.userId===a.userId))||(l.push(a),c=!0);else if(l.length&&o){const e=l.findIndex((e=>e.userId===o));e>-1&&(l.slice(e,1),c=!0)}if(c){const s=l.filter((e=>{let{isOwner:t,isAdmin:n}=e;return t||n}));return(0,r.a4)(e,n.id,{membersCount:l.length,fullInfo:{...t.fullInfo,members:l,adminMembers:s}})}return}case"deleteProfilePhotos":{const{chatId:t,ids:s}=n,a=e.chats.byId[t];return null!=a&&a.photos?(0,r.a4)(e,t,{photos:a.photos.filter((e=>!s.includes(e.id)))}):void 0}case"draftMessage":{const{chatId:t,formattedText:s,date:a,replyingToId:i}=n;if(!e.chats.byId[t])return;return e=(0,r.pf)(e,t,o._f,"draft",s),e=(0,r.pf)(e,t,o._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:a})}case"showInvite":{const{data:e}=n;return void t.showDialog({data:e})}case"updatePendingJoinRequests":{const{chatId:a,requestsPending:i,recentRequesterIds:o}=n,c=e.chats.byId[a];if(!c)return;e=(0,r.a4)(e,a,{fullInfo:{...c.fullInfo,requestsPending:i,recentRequesterIds:o}}),(0,s.R3)(e),t.loadChatJoinRequests({chatId:a})}}}));const Se=350;function Me(e,t,n,s,a,i,o){var l;const u=null==o?void 0:o.reactions;if(u&&be(s,u))return e;if(e=(0,r.cY)(e,t,n,{reactions:s}),!i)return e;const m=null===(l=a.unreadReactions)||void 0===l?void 0:l.includes(n);if((0,d.yL)(e,s)&&!m){e=Ze(e,t,{unreadReactionsCount:((null==a?void 0:a.unreadReactionsCount)||0)+1,unreadReactions:[...(null==a?void 0:a.unreadReactions)||[],n]});const s=(0,c.hj)(e,t,n);if(!a||!s)return e;(0,R.R3)((()=>{(0,Ce.rh)({chat:a,message:s,isReaction:!0})}))}else if(m){var h;e=Ze(e,t,{unreadReactionsCount:((null==a?void 0:a.unreadReactionsCount)||1)-1,unreadReactions:null==a||null===(h=a.unreadReactions)||void 0===h?void 0:h.filter((e=>e!==n))})}return e}function Ee(e,t,n,s){let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const i=a?(0,c.Tm)(e,t,n):(0,c.hj)(e,t,n);if(i&&s.content){const{photo:e,video:t,sticker:n,document:a}=(0,d.qp)(i);e&&s.content.photo?(s.content.photo.blobUrl=e.blobUrl,s.content.photo.thumbnail=e.thumbnail):t&&s.content.video?s.content.video.blobUrl=t.blobUrl:n&&s.content.sticker?s.content.sticker.isPreloadedGlobally=n.isPreloadedGlobally:a&&s.content.document&&(s.content.document.previewBlobUrl=a.previewBlobUrl)}return a?(0,r.P4)(e,t,n,s):(0,r.cY)(e,t,n,s)}function Re(e,t,n,s){const{chatId:a}=n,{threadInfo:i}=(0,c.Db)(e,a,n)||{};if(!i&&n.replyToMessageId){const i=(0,c.hj)(e,a,n.replyToMessageId);i?e=(0,r.lG)(e,i,a,n.id,s):t.loadMessage({chatId:a,messageId:n.replyToMessageId,threadUpdate:{isDeleting:s,lastMessageId:n.id}})}return e}function ke(e,t,n){const{id:s,chatId:a}=n,{threadInfo:i,firstMessageId:l}=(0,c.Db)(e,a,n)||{},u=(0,c.Z1)(e,a),m=(null==u?void 0:u.unreadCount)&&!(0,c.gb)(e,a,o._f);if(e=Re(e,t,n),i&&(!l&&(0,d.CI)(n)||(e=(0,r.xj)(e,a,i.threadId,[s]),(0,c.b9)(e,a,i.threadId)&&(e=(0,r.$S)(e,a,i.threadId,s),l||(e=(0,r.pf)(e,a,i.threadId,"firstMessageId",n.id)))),e=(0,r.pf)(e,a,i.threadId,"threadInfo",{...i,lastMessageId:n.id,messagesCount:i.messagesCount+1})),m)return e;if(e=(0,r.xj)(e,a,o._f,[s]),(0,c.b9)(e,a,o._f)){const t=(0,c.It)(e,a,o._f),n=(0,r.$S)(e,a,o._f,s),i=(0,c.Cb)(n,a,o._f);t&&!i.includes(t)||(e=n)}return e}function Ne(e,t,n){var s;let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:i}=e,o=null===(s=i.byId[t])||void 0===s?void 0:s.lastMessage;return!o||a||o.id===n.id||o.id===n.previousLocalId||n.id>o.id?(0,r.a4)(e,t,{lastMessage:n}):e}function Te(e,t){const n=(0,c.Zw)(e,t),s=(0,c.gb)(e,t,o._f);if(!n||!s)return;let a=s.length;for(;a--;){const e=n[s[a]];if(!e.isDeleting)return e}}function Ae(e,t,n,a){if(e){t.forEach((t=>{const n=Te(a=(0,r.cY)(a,e,t,{isDeleting:!0}),e);n&&(a=Ne(a,e,n,!0))})),n.requestChatUpdate({chatId:e});const i=[];return t.forEach((t=>{const s=(0,c.hj)(a,e,t);if(!s)return;a=Re(a,n,s,!0);const{threadInfo:o}=(0,c.Db)(a,e,s)||{};o&&i.push(o.threadId)})),(0,s.R3)(a),void setTimeout((()=>{(0,s.R3)((0,r.K4)((0,s.Rd)(),e,t)),(0,g.Tw)(i).forEach((t=>{n.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),Se)}const i=[];t.forEach((e=>{const t=(0,c.X5)(a,e);if(t){i.push(t);const n=Te(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);n&&(a=Ne(a,t,n,!0)),setTimeout((()=>{(0,s.R3)((0,r.K4)((0,s.Rd)(),t,[e]))}),Se)}})),(0,s.R3)(a),(0,g.Tw)(i).forEach((e=>{n.requestChatUpdate({chatId:e})}))}(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"newMessage":{const{chatId:a,id:l,message:u,shouldForceReply:m}=n;e=ke(e=Ee(e,a,l,u),t,u),u.threadInfo&&(e=(0,r.Xg)(e,u.threadInfo.chatId,u.threadInfo.threadId,u.threadInfo));const h=(0,c.hj)(e,a,l);if((0,c.KA)(e,a,u)){var i;if(u.isOutgoing&&(null===(i=u.content)||void 0===i||!i.action)){const n=(0,c.Bt)(e);n&&t.focusMessage({chatId:a,threadId:n.threadId,messageId:u.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:n}=(0,c.Db)(e,a,u)||{};n&&t.requestThreadInfoUpdate({chatId:a,threadId:n.threadId}),(0,d.CI)(u)||setTimeout((()=>{let e=(0,s.Rd)();m&&(e=(0,r.pf)(e,a,o._f,"replyingToId",l)),(0,s.R3)(Ne(e,a,h))}),Se)}else e=Ne(e,a,h);(0,s.R3)(e),(0,c.N)(e,a)||t.loadTopChats();break}case"updateStartEmojiInteraction":{var l;const{chatId:t}=(0,c.Bt)(e)||{};if(t!==n.id)return;const a=(0,c.hj)(e,t,n.messageId);if(!a)return;if((0,d.UD)(a)!==n.emoji)return;const i=(0,c.CP)(e,n.emoji);e={...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],{id:(null===(l=e.activeEmojiInteractions)||void 0===l?void 0:l.length)||0,animatedEffect:i?(0,c.cu)(i):n.emoji,messageId:n.messageId}]},(0,s.R3)(e);break}case"newScheduledMessage":{const{chatId:t,id:a,message:i}=n;e=Ee(e,t,a,i,!0);const l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,o._f,"scheduledIds",(0,g.Tw)([...l,a])),(0,s.R3)(e);break}case"updateMessage":{var u,m;const{chatId:a,id:i,message:l}=n,d=(0,c.hj)(e,a,i),h=(0,c.Z1)(e,a);e=Ee(e,a,i,l);const g=(0,c.hj)(e,a,i);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),d&&(e=Ne(e,a,g)),l.reactions&&h&&(e=Me(e,a,i,l.reactions,h,l.isOutgoing,d)),(0,s.R3)(e),d&&h&&!l.isOutgoing&&(null===(u=h.lastMessage)||void 0===u?void 0:u.id)===l.id&&(0,c.xo)(e,h)&&(0,c.KA)(e,a,l)&&(0,c.b9)(e,a,(null===(m=l.threadInfo)||void 0===m?void 0:m.threadId)||o._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:i}=n;if(!(0,c.Tm)(e,t,a))return;e=Ee(e,t,a,i,!0);const l=Object.keys((0,c.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,o._f,"scheduledIds",l),(0,s.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:i,message:o}=n;e=ke(e,t,o);const l=(0,c.hj)(e,a,i);e=(0,r.K4)(e,a,[i]),o.isScheduled&&(e=(0,r.bV)(e,a,[i])),e=(0,r.cY)(e,a,o.id,{...l,...o,previousLocalId:i});const d=(0,c.hj)(e,a,o.id);e=Ne(e,a,d);const u=(0,c.Db)(e,a,o);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:o.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:o.id,lastReadInboxMessageId:o.id})),(0,s.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:i}=n,l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,o._f,"scheduledIds",[...l,i.id]);const d=(0,c.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,i.id,{...d,...i,previousLocalId:a}),(0,s.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:i}=n,l=(0,c.KB)(e,t)||[],d=a?[...l,...i].sort(((e,t)=>t-e)):l.filter((e=>!i.includes(e)));(0,s.R3)((0,r.pf)(e,t,o._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:i,firstMessageId:o}=n,l={...(0,c.tZ)(e,t,a),...i};if(!l.threadId)return;e=(0,r.Xg)(e,t,a,l),o&&(e=(0,r.pf)(e,t,a,"firstMessageId",o)),(0,s.R3)(e);break}case"resetMessages":{const{id:a}=n,i=(0,c.Zw)(e,a);i&&!(0,d.YC)(a)&&(e=(0,r.K4)(e,a,Object.keys(i).map(Number)),(0,s.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:s,chatId:a}=n;Ae(a,s,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:a}=n;!function(e,t,n,a){e&&(t.forEach((t=>{a=(0,r.P4)(a,e,t,{isDeleting:!0})})),(0,s.R3)(a),setTimeout((()=>{a=(0,r.bV)((0,s.Rd)(),e,t);const n=(0,c.Fn)(a,e);a=(0,r.pf)(a,e,o._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,s.R3)(a)}),Se))}(a,t,0,e);break}case"deleteHistory":{const{chatId:i}=n,o=e.messages.byChatId[i];if(i===a.aw){var h;const t=null===(h=e.serviceNotifications.sort(((e,t)=>t.id-e.id)))||void 0===h?void 0:h[0],n=t?[{...t,isHidden:!0}]:[];(0,s.R3)({...e,serviceNotifications:n})}o?Ae(i,Object.keys(o.byId).map(Number),t,(0,s.Rd)()):t.requestChatUpdate({chatId:i});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=n;t.forEach((t=>{const n=(0,c.X5)(e,t);n&&(e=(0,r.cY)(e,n,t,a))})),(0,s.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:i}=n;a.forEach((n=>{e=(0,r.cY)(e,t,n,i)})),(0,s.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=n,i=(0,c.ZB)(e,t);if(null!=i&&i.content.poll){var p;const t=i.content.poll.results;let n=t;null!==(p=a.results)&&void 0!==p&&p.results&&(t.results&&a.results.isMin?t.results&&(n={...a.results,results:a.results.results.map((e=>{var n;return{...e,isChosen:null===(n=t.results.find((t=>t.option===e.option)))||void 0===n?void 0:n.isChosen}})),isMin:void 0}):n=a.results);const o={...i.content.poll,...a,results:n};(0,s.R3)((0,r.cY)(e,i.chatId,i.id,{content:{...i.content,poll:o}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:i}=n,o=(0,c.ZB)(e,t);if(!o||!o.content.poll||!o.content.poll.results)break;const{poll:l}=o.content,{recentVoterIds:d,totalVoters:u,results:m}=l.results,h=d?[...d]:[],g=u?u+1:1,p=m?[...m]:[];h.push(a),i.forEach((t=>{const n=p.findIndex((e=>e.option===t)),s=p[n],i=s?{...s}:{option:t,votersCount:0};i.votersCount+=1,a===e.currentUserId&&(i.isChosen=!0),n?p[n]=i:p.push(i)})),(0,s.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:{...l,results:{...l.results,recentVoterIds:h,totalVoters:g,results:p}}}}));break}case"updateServiceNotification":{const{message:s}=n;(0,c.UW)(e)&&t.createServiceNotification({message:s});break}case"updateMessageReactions":{const{chatId:t,id:a,reactions:i}=n,o=(0,c.hj)(e,t,a),r=(0,c.Z1)(e,n.chatId);if(!r||!o)return;(0,s.R3)(Me(e,t,a,i,r,o.isOutgoing,o));break}case"updateTranscribedAudio":{const{transcriptionId:t,text:a,isPending:i}=n;(0,s.R3)({...e,transcriptions:{...e.transcriptions,[t]:{...e.transcriptions[t]||{},transcriptionId:t,text:a,isPending:i}}});break}}}));const Be=(0,R.P2)((function(){const e=(0,s.Rd)();(0,s.R3)((0,r.ps)(e,{...e.users.statusesById,...xe})),xe={}}),3e3,!0);let xe={};(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"deleteContact":return(0,r.GK)(e,n.id);case"updateUser":return n.id===e.currentUserId&&n.user.isPremium&&!(0,c.wV)(e)&&t.openPremiumModal({isSuccess:!0}),(0,r.Nq)(e,n.id,n.user);case"updateUserStatus":return a=n.userId,i=n.status,xe[a]=i,void Be();case"updateUserFullInfo":{const{id:t,fullInfo:s}=n,a=e.users.byId[t];if(!a)return;return(0,r.Nq)(e,t,{fullInfo:{...a.fullInfo,...s}})}case"updateBotMenuButton":{var s;const{botId:t,button:a}=n,i=(0,c.dy)(e,t);if(null==i||null===(s=i.fullInfo)||void 0===s||!s.botInfo)return;return(0,r.Nq)(e,t,{fullInfo:{...i.fullInfo,botInfo:{...i.fullInfo.botInfo,menuButton:a}}})}}var a,i})),(0,s.iw)("apiUpdate",((e,t,n)=>{if("updateStickerSet"===n["@type"])return(0,r.Rg)(e,n.id,n.stickerSet)})),(0,s.iw)("apiUpdate",((e,t,n)=>{var a;switch(n["@type"]){case"updatePeerBlocked":return n.isBlocked?(0,r.O4)((0,s.Rd)(),n.id):(0,r.rB)((0,s.Rd)(),n.id);case"updateResetContactList":(0,s.R3)({...(0,s.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updateRecentStickers":t.loadRecentStickers();break;case"updateStickerSets":t.loadStickerSets();break;case"updateStickerSetsOrder":t.reorderStickerSets({order:n.order});break;case"updateSavedGifs":t.loadSavedGifs();break;case"updatePrivacy":(0,s.R3)({...e,settings:{...e.settings,privacy:{...e.settings.privacy,[n.key]:n.rules}}});break;case"updatePaymentVerificationNeeded":e=(0,r.fS)((0,s.Rd)(),n.url),e=(0,r.Q$)(e,m.KB.ConfirmPayment),(0,s.R3)(e);break;case"updateWebViewResultSent":(null===(a=e.webApp)||void 0===a?void 0:a.queryId)===n.queryId&&(t.setReplyingToId({messageId:void 0}),t.closeWebApp())}})),(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateNotifySettings":return(0,r.HN)(e,n.peerType,n.isSilent,n.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:a,isSilent:i,shouldShowPreviews:o}=n;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,s.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:i,shouldShowPreviews:o}));break}}})),(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:n.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:n.message}}}}));var Le=n(78958),Oe=n(42431);(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateGroupCall":return"discarded"===n.call.connectionState?e.groupCalls.activeGroupCallId?void t.leaveGroupCall({shouldRemove:!0}):(0,Le.dc)(e,n.call.id):(0,Le.AH)(e,n.call.id,(0,g.CE)(n.call,["connectionState"]),void 0,n.call.participantsCount);case"updateGroupCallChatId":{const t=(0,c.Z1)(e,n.chatId);return t&&(e=(0,r.a4)(e,n.chatId,{fullInfo:{...t.fullInfo,groupCallId:n.call.id}})),e}case"updateGroupCallParticipants":{const{groupCallId:t,participants:a,nextOffset:i}=n,{currentUserId:o}=e;return e=(0,s.Rd)(),a.forEach((n=>{n.id&&(e=(0,Le.B6)(e,t,n.id,n,Boolean(i)||o===n.id))})),i&&(e=(0,Le.AH)(e,t,{nextOffset:i})),e}case"updatePhoneCall":{if(!h.Bi)return;const{phoneCall:a,currentUserId:i}=e,{call:o}=n;if(a)return"discarded"===o.state?(t.playGroupCallSound({sound:"end"}),{...e,...o.needRating&&{ratingPhoneCall:o},isCallPanelVisible:void 0,phoneCall:void 0}):void 0;if((null==o?void 0:o.adminId)!==i&&"requested"===o.state)return(0,R.R3)((()=>{(0,Ce.TO)({call:o,user:(0,Oe.fu)((0,s.Rd)())})})),(0,b.o5)(),{...e,phoneCall:o,isCallPanelVisible:!1}}}})),(0,s.iw)("apiUpdate",((e,t,n)=>{if("updatePaymentStateCompleted"===n["@type"]){const{inputInvoice:t}=e.payment;if(n.slug&&t&&"slug"in t&&t.slug!==n.slug)return;return h.Xp||(e=(0,r.bp)(e)),{...e,payment:{...e.payment,status:"paid"}}}}));var Ue=n(18674),Fe=n(46752),qe=n(1279),De=n(53551),$e=n(45332);function je(e){(0,i.d4)((()=>(0,R.Gq)(e)),[e])}var Ge=n(29290);const He=document.querySelector('meta[name="viewport"]'),_e=(null==He?void 0:He.getAttribute("content"))||"",ze="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function Ve(e){e.preventDefault()}var We=n(65326),Je=n(46590),Xe=n(31212),Ye=n(94851),Ke=n(2155),Qe=n(95616),et=n(17358);const tt=(0,i.X$)((e=>{let{isForAppBadge:t}=e;(0,Qe.yi)();const n=(0,W.xW)();if((0,i.d4)((()=>{t&&(0,et.w)(n)}),[t,n]),!t&&n)return i.ZP.createElement("div",{className:"unread-count active"},(0,Ke.bi)(n))}));var nt=n(23989),st=n(53455),at=n(60706),it=n(73541),ot=n(2255),rt=n(59107),ct=n(27370),lt=n(706);let dt;function ut(e,t,n,s,a,o){let r,c,l;return r=function(){const[e,t]=(0,i.eJ)(window.navigator.onLine);return(0,i.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}()&&"connectionStateConnecting"!==t?n?dt.syncing:dt.online:dt.waitingForNetwork,c=r===dt.online||o?"none":s?"middleHeader":a?"minimized":"overlay",r===dt.waitingForNetwork?l=e("WaitingForNetwork"):r===dt.syncing&&(l=e("Updating")),"middleHeader"===c&&(l=l.toLowerCase().replace(/\.+$/,"")),{connectionStatus:r,connectionStatusPosition:c,connectionStatusText:l}}!function(e){e[e.waitingForNetwork=0]="waitingForNetwork",e[e.syncing=1]="syncing",e[e.online=2]="online"}(dt||(dt={}));var mt=n(36046),ht=n(53106),gt=n(58964),pt=n(231),ft=n(69589),vt=n(49187),It=n(4863),wt=n(83321),yt=n(40126),Zt=n(49204);const Pt=(0,i.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:s}=e;const a=(0,rt.Z)();return i.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:a.isRtl?"rtl":void 0,onClick:s},i.ZP.createElement(Zt.Z,{color:"black"}),i.ZP.createElement("div",{className:"state-text"},i.ZP.createElement(ot.Z,{activeKey:t,name:"slide-fade"},n)),i.ZP.createElement(pt.Z,{round:!0,size:"tiny",color:"translucent-black"},i.ZP.createElement("span",{className:"icon-close"})))})),Ct=(0,i.X$)((0,s.c$)((e=>{const{query:t,fetchingStatus:n,chatId:s,date:a}=e.globalSearch,{currentUserId:i,connectionState:o,isSyncing:r}=e,{byId:l}=e.chats,{isConnectionStatusMinimized:d,animationLevel:u}=e.settings.byKey;return{searchQuery:t,isLoading:!!n&&Boolean(n.chats||n.messages),currentUserId:i,chatsById:l,globalSearchChatId:s,searchDate:a,theme:(0,c.Pu)(e),animationLevel:u,connectionState:o,isSyncing:r,isMessageListOpen:Boolean((0,c.Bt)(e)),isConnectionStatusMinimized:d,areChatsLoaded:Boolean(e.chats.listIds.active),hasPasscode:Boolean(e.passcode.hasPasscode),canInstall:Boolean(e.canInstall),isPremiumPurchaseBlocked:(0,c.oe)(e)}}))((e=>{let{content:t,contactsFilter:n,onSearchQuery:o,onSelectSettings:r,onSelectContacts:c,onSelectArchived:l,onReset:u,searchQuery:g,isLoading:p,shouldSkipTransition:f,currentUserId:v,globalSearchChatId:I,searchDate:w,theme:y,animationLevel:Z,chatsById:P,connectionState:C,isSyncing:b,isMessageListOpen:S,isConnectionStatusMinimized:M,areChatsLoaded:E,hasPasscode:R,canInstall:k,isPremiumPurchaseBlocked:N}=e;const{openChat:T,setGlobalSearchDate:A,setSettingOption:B,setGlobalSearchChatId:x,openChatByUsername:L,lockScreen:O,requestNextSettingsScreen:U,skipLockOnUnload:F,openPremiumModal:q}=(0,s.Sv)(),D=(0,rt.Z)(),$=t===m.du.ChatList,j=(0,i.Ye)((()=>w?(0,H.xH)(new Date(1e3*w)):void 0),[w]),G=(0,i.Ye)((()=>$&&P?Object.values(P).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[$,P]),{connectionStatus:_,connectionStatusText:z,connectionStatusPosition:V}=ut(D,C,b,S,M,!E),W=(0,i.I4)((e=>{e.preventDefault(),e.stopPropagation(),R?O():U(m.MT.PasscodeDisabled)}),[R,O,U]);(0,it.y)({"Ctrl+Shift+L":W,"Alt+Shift+L":W,"Meta+Shift+L":W,...h.fl&&{"Mod+L":W}});const J=window.location.hostname===a.xH||a.Cg,X=(0,i.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return i.ZP.createElement(pt.Z,{round:!0,ripple:$&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:$?t:()=>u(),ariaLabel:$?D("AccDescrOpenMenu2"):"Return to chat list"},i.ZP.createElement("div",{className:(0,Fe.Z)("animated-menu-icon",!$&&"state-back",f&&"no-animation")}))}),[$,D,u,f]),Y=(0,i.I4)((()=>{g||o("")}),[g,o]),K=(0,i.I4)((()=>{B({isConnectionStatusMinimized:!M})}),[M,B]),Q=(0,i.I4)((()=>{T({id:v,shouldReplaceHistory:!0})}),[v,T]),ee=(0,i.I4)((()=>{q()}),[q]),te=(0,i.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";B({theme:t}),B({shouldUseSystemTheme:!1}),(0,ct.Z)(t,Z===a.zy)}),[Z,B,y]),ne=(0,i.I4)((()=>{window.open(a.ul,"_blank","noopener")}),[]),se=(0,i.I4)((()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,lt.W8)(),F()}),[F]),ae=(0,i.I4)((()=>{F()}),[F]),ie=(0,i.I4)((()=>{L({username:D("Settings.TipsUsername")})}),[D,L]),oe=(0,i.I4)((()=>{O()}),[O]),re=Boolean(I)||t===m.du.GlobalSearch||t===m.du.Contacts;(0,i.d4)((()=>re?(0,nt.Z)((()=>u())):void 0),[re,u]);const ce=t===m.du.Contacts?D("SearchFriends"):D("Search"),le=a.Tj?`${a.Ji} Beta (master)`:a.eM?"master":a.Ji;return i.ZP.createElement("div",{className:"LeftMainHeader"},i.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},i.ZP.createElement(ht.Z,{trigger:X,footer:`${a.iC} ${le}`},i.ZP.createElement(gt.Z,{icon:"saved-messages",onClick:Q},D("SavedMessages")),i.ZP.createElement(gt.Z,{icon:"archive",onClick:l},i.ZP.createElement("span",{className:"menu-item-name"},D("ArchivedChats")),G>0&&i.ZP.createElement("div",{className:"archived-badge"},G)),i.ZP.createElement(gt.Z,{icon:"user",onClick:c},D("Contacts")),i.ZP.createElement(gt.Z,{icon:"settings",onClick:r},D("Settings")),i.ZP.createElement(gt.Z,{icon:"darkmode",onClick:te},i.ZP.createElement("span",{className:"menu-item-name"},D("lng_menu_night_mode")),i.ZP.createElement(wt.Z,{id:"darkmode",label:D("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),!N&&i.ZP.createElement(gt.Z,{customIcon:i.ZP.createElement(It.Z,{withGradient:!0,big:!0}),onClick:ee},D("TelegramPremium"),i.ZP.createElement("span",{className:"menu-item-badge"},D("New"))),i.ZP.createElement(gt.Z,{icon:"help",onClick:ie},D("TelegramFeatures")),i.ZP.createElement(gt.Z,{icon:"bug",href:a.mU},"Report Bug"),a.Tj&&i.ZP.createElement(gt.Z,{icon:"permissions",onClick:ne},"Beta Changelog"),J&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(gt.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:se},"Switch to K Version"),i.ZP.createElement(gt.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:ae},"Switch to Old Version")),k&&i.ZP.createElement(gt.Z,{icon:"install",onClick:(0,mt.G)()},"Install App")),i.ZP.createElement(ft.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||w?"with-picker-item":"",value:n||g,focused:re,isLoading:p||"minimized"===V,spinnerColor:"minimized"===V?"yellow":void 0,spinnerBackgroundColor:"minimized"===V&&"light"===y?"light":void 0,placeholder:ce,autoComplete:"off",canClose:Boolean(I||w),onChange:o,onReset:u,onFocus:Y,onSpinnerClick:"minimized"===V?K:void 0},j&&i.ZP.createElement(vt.Z,{icon:"calendar",title:j,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:A,clickArg:{date:void 0}}),I&&i.ZP.createElement(vt.Z,{chatOrUserId:I,onClick:x,canClose:!0,clickArg:{id:void 0}})),R&&i.ZP.createElement(pt.Z,{round:!0,ripple:!h.wB,size:"smaller",color:"translucent",ariaLabel:`${D("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:oe,className:"passcode-lock"},i.ZP.createElement("i",{className:"icon-lock"})),i.ZP.createElement(yt.Z,{isOpen:"overlay"===V,isCustom:!0,className:"connection-state-wrapper"},i.ZP.createElement(Pt,{connectionStatus:_,connectionStatusText:z,onClick:K}))))})));var bt=n(64963),St=n(93133),Mt=n(1080);const Et=(0,i.X$)((0,s.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n,activeChatFolder:s},currentUserId:a,lastSyncTime:i,shouldSkipHistoryAnimations:o}=e;return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:s,currentUserId:a,lastSyncTime:i,shouldSkipHistoryAnimations:o,maxFolders:(0,q.M)(e,"dialogFilters")}}))((e=>{let{foldersDispatch:t,onScreenSelect:n,chatFoldersById:o,orderedFolderIds:r,activeChatFolder:c,currentUserId:l,lastSyncTime:d,shouldSkipHistoryAnimations:u,maxFolders:m}=e;const{loadChatFolders:g,setActiveChatFolder:p,openChat:f}=(0,s.Sv)(),v=(0,i.sO)(null),I=(0,rt.Z)();(0,i.d4)((()=>{d&&g()}),[d,g]);const w=(0,i.Ye)((()=>({id:a.Nf,title:(null==r?void 0:r[0])===a.Nf?I("FilterAllChatsShort"):I("FilterAllChats")})),[r,I]),y=(0,i.Ye)((()=>r?r.map((e=>e===a.Nf?w:o[e]||{})).filter(Boolean):void 0),[o,w,r]),Z=(null==y?void 0:y.findIndex((e=>e.id===a.Nf)))===c,P=0===c,C=(0,Qe.yi)(),b=(0,i.Ye)((()=>{if(y&&y.length)return y.map(((e,t)=>{var n,s;let{id:i,title:o}=e;const r=i!==a.Nf&&t>m-1;return{id:i,title:o,badgeCount:null===(n=C[i])||void 0===n?void 0:n.chatsCount,isBadgeActive:Boolean(null===(s=C[i])||void 0===s?void 0:s.notificationsCount),isBlocked:r}}))}),[y,C,m]),S=(0,i.I4)((e=>{p(e,{forceOnHeavyAnimation:!0})}),[p]);(0,i.d4)((()=>{b&&b.length&&c>=b.length&&p(0)}),[c,b,p]),(0,i.d4)((()=>{if(v.current&&h.$b&&b&&b.length)return(0,bt.sf)(v.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===bt.eM.Left?(p(Math.min(c+1,b.length-1),{forceOnHeavyAnimation:!0}),!0):t===bt.eM.Right&&(p(Math.max(0,c-1),{forceOnHeavyAnimation:!0}),!0)})}),[c,b,p]);const M=(0,i.sO)();M.current=!P,(0,i.d4)((()=>M.current?(0,nt.Z)((()=>{M.current&&p(0)})):void 0),[c,p]),(0,Je.Z)({isActive:!P,onBack:()=>p(0,{forceOnHeavyAnimation:!0})}),(0,i.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 f({id:l,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>b.length-1)return;p(n,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}),[l,b,f,p]);const{shouldRender:E,transitionClassNames:R}=(0,Xe.Z)(!r,void 0,!0);function k(e){const s=Object.values(o).find((e=>{let{id:t}=e;return t===b[c].id}));return!s||Z?i.ZP.createElement(Mt.Z,{folderType:"all",isActive:e,lastSyncTime:d,foldersDispatch:t,onScreenSelect:n}):i.ZP.createElement(Mt.Z,{folderType:"folder",folderId:s.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t})}const N=b&&b.length>1;return i.ZP.createElement("div",{className:"ChatFolders"},N?i.ZP.createElement(St.Z,{tabs:b,activeTab:c,onSwitchTab:S}):E?i.ZP.createElement("div",{className:(0,Fe.Z)("tabs-placeholder",R)}):void 0,i.ZP.createElement(ot.Z,{ref:v,name:u?"none":I.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:N?b.length:void 0},k))})));var Rt=n(99203),kt=n(48778),Nt=n(34288);const Tt=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"LeftSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)})),At=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"ContactList");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)}));var Bt=n(52328);const xt=(0,i.X$)((e=>{let{isShown:t,onNewPrivateChat:n,onNewChannel:s,onNewGroup:a}=e;const[o,r]=(0,i.eJ)(!1);(0,i.d4)((()=>{t||r(!1)}),[t]);const c=(0,rt.Z)(),l=(0,Fe.Z)("NewChatButton",t&&"revealed",o&&"menu-is-open"),d=(0,i.I4)((()=>{r(!o)}),[o]),u=(0,i.I4)((()=>{r(!1)}),[]);return i.ZP.createElement("div",{className:l},i.ZP.createElement(pt.Z,{round:!0,color:"primary",className:o?"active":"",onClick:d,ariaLabel:c(o?"Close":"NewMessageTitle"),tabIndex:-1},i.ZP.createElement("i",{className:"icon-new-chat-filled"}),i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(Bt.Z,{isOpen:o,positionX:"right",positionY:"bottom",autoClose:!0,onClose:u},i.ZP.createElement(gt.Z,{icon:"channel",onClick:s},c("NewChannel")),i.ZP.createElement(gt.Z,{icon:"group",onClick:a},c("NewGroup")),i.ZP.createElement(gt.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),Lt=Object.keys(m.du).length/2;let Ot;const Ut=(0,i.X$)((e=>{let{content:t,searchQuery:n,searchDate:s,contactsFilter:a,shouldSkipTransition:o,foldersDispatch:r,onSearchQuery:c,onContentChange:l,onScreenSelect:d,onReset:u}=e;const[g,p]=(0,i.eJ)(h.$b),f=(0,i.sO)(!1),v=(0,i.I4)((()=>{l(m.du.Settings)}),[l]),I=(0,i.I4)((()=>{l(m.du.Contacts)}),[l]),w=(0,i.I4)((()=>{l(m.du.NewChannelStep1)}),[l]),y=(0,i.I4)((()=>{l(m.du.NewGroupStep1)}),[l]),Z=(0,i.I4)((()=>{l(m.du.Archived)}),[l]),P=(0,i.I4)((()=>{t===m.du.ChatList&&(f.current=!0,p(!0))}),[t]),C=(0,i.I4)((()=>{f.current=!1,Ot&&(clearTimeout(Ot),Ot=void 0),Ot=window.setTimeout((()=>{f.current||p(!1)}),250)}),[]);(0,i.d4)((()=>{let e;return t!==m.du.ChatList?e=window.setTimeout((()=>{p(!1)}),250):(f.current||h.$b)&&p(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const[b,S,M]=function(){const[e,t]=(0,at.Z)(!1);(0,i.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:n,transitionClassNames:s}=(0,Xe.Z)(e);return[n,s,()=>{window.location.reload()}]}(),E=(0,rt.Z)();return i.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:P,onMouseLeave:h.$b?void 0:C},i.ZP.createElement(Ct,{content:t,contactsFilter:a,onSearchQuery:c,onSelectSettings:v,onSelectContacts:I,onSelectArchived:Z,onReset:u,shouldSkipTransition:o}),i.ZP.createElement(ot.Z,{name:o?"none":"zoom-fade",renderCount:Lt,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return i.ZP.createElement(Et,{onScreenSelect:d,foldersDispatch:r});case m.du.GlobalSearch:return i.ZP.createElement(Tt,{searchQuery:n,searchDate:s,isActive:e,onReset:u});case m.du.Contacts:return i.ZP.createElement(At,{filter:a,isActive:e,onReset:u});default:return}})),b&&i.ZP.createElement(pt.Z,{fluid:!0,pill:!0,className:(0,Fe.Z)("btn-update",S),onClick:M},E("lng_update_telegram")),i.ZP.createElement(xt,{isShown:g,onNewPrivateChat:I,onNewChannel:w,onNewGroup:y}))})),Ft=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"Settings");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)})),qt=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"NewChat");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)})),Dt=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"ArchivedChats");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)}));var $t;!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"}($t||($t={}));const jt=Object.keys($t).length/2,Gt=(0,i.X$)((0,s.c$)((e=>{var t;const{globalSearch:{query:n,date:s},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:i,leftColumnWidth:o,currentUserId:r,passcode:{hasPasscode:l},settings:{nextScreen:d}}=e;return{searchQuery:n,searchDate:s,isFirstChatFolderActive:0===a,shouldSkipHistoryAnimations:i,leftColumnWidth:o,currentUserId:r,hasPasscode:l,nextSettingsScreen:d,isChatOpen:Boolean(null===(t=(0,c.jr)(e))||void 0===t?void 0:t.id)}}))((e=>{let{searchQuery:t,searchDate:n,isFirstChatFolderActive:a,shouldSkipHistoryAnimations:o,leftColumnWidth:r,currentUserId:c,hasPasscode:l,nextSettingsScreen:d,isChatOpen:u}=e;const{setGlobalSearchQuery:g,setGlobalSearchChatId:p,resetChatCreation:f,setGlobalSearchDate:v,loadPasswordInfo:I,clearTwoFaError:w,setLeftColumnWidth:y,resetLeftColumnWidth:Z,openChat:P,requestNextSettingsScreen:C}=(0,s.Sv)(),b=(0,i.sO)(null),[S,M]=(0,i.eJ)(m.du.ChatList),[E,R]=(0,i.eJ)(m.MT.Main),[k,N]=(0,i.eJ)(""),[T,A]=(0,st.ZP)(),[B,x]=(0,i.eJ)(0);let L=$t.Main;switch(S){case m.du.Archived:L=$t.Archived;break;case m.du.Settings:L=$t.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:L=$t.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:L=$t.NewGroup}const O=(0,i.I4)((e=>{function t(){M(m.du.ChatList),N(""),g({query:""}),v({date:void 0}),p({id:void 0}),f(),setTimeout((()=>{x(Date.now())}),250)}if(!0!==e)if(S!==m.du.NewGroupStep2)if(S!==m.du.NewChannelStep2){if(S===m.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(S===m.du.Settings)switch(E){case m.MT.EditProfile:case m.MT.Folders:case m.MT.General:case m.MT.Notifications:case m.MT.DataStorage:case m.MT.Privacy:case m.MT.ActiveSessions:case m.MT.Language:case m.MT.Experimental:return void R(m.MT.Main);case m.MT.GeneralChatBackground:case m.MT.QuickReaction:return void R(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void R(m.MT.GeneralChatBackground);case m.MT.PrivacyPhoneNumber:case m.MT.PrivacyLastSeen:case m.MT.PrivacyProfilePhoto:case m.MT.PrivacyPhoneCall:case m.MT.PrivacyPhoneP2P:case m.MT.PrivacyForwarding:case m.MT.PrivacyGroupChats:case m.MT.PrivacyBlockedUsers:case m.MT.ActiveWebsites:case m.MT.TwoFaDisabled:case m.MT.TwoFaEnabled:case m.MT.TwoFaCongratulations:case m.MT.PasscodeDisabled:case m.MT.PasscodeEnabled:case m.MT.PasscodeCongratulations:return void R(m.MT.Privacy);case m.MT.PasscodeNewPasscode:return void R(l?m.MT.PasscodeEnabled:m.MT.PasscodeDisabled);case m.MT.PasscodeChangePasscodeCurrent:case m.MT.PasscodeTurnOff:return void R(m.MT.PasscodeEnabled);case m.MT.PasscodeNewPasscodeConfirm:return void R(m.MT.PasscodeNewPasscode);case m.MT.PasscodeChangePasscodeNew:return void R(m.MT.PasscodeChangePasscodeCurrent);case m.MT.PasscodeChangePasscodeConfirm:return void R(m.MT.PasscodeChangePasscodeNew);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void R(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void R(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void R(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyPhoneCallAllowedContacts:case m.MT.PrivacyPhoneCallDeniedContacts:return void R(m.MT.PrivacyPhoneCall);case m.MT.PrivacyPhoneP2PAllowedContacts:case m.MT.PrivacyPhoneP2PDeniedContacts:return void R(m.MT.PrivacyPhoneP2P);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void R(m.MT.PrivacyForwarding);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void R(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void R(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void R(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void R(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void R(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void R(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void R(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void R(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void R(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void R(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void R(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void R(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void R(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void R(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return M(m.du.ChatList),void R(m.MT.Main)}S===m.du.ChatList&&a?M(m.du.GlobalSearch):t()}else M(m.du.NewChannelStep1);else M(m.du.NewGroupStep1);else t()}),[S,a,E,g,v,p,f,l]),U=(0,i.I4)((e=>{S!==m.du.Contacts?(M(m.du.GlobalSearch),e!==t&&g({query:e})):N(e)}),[S,t,g]);(0,i.d4)((()=>S!==m.du.ChatList||a&&!u?(0,nt.Z)((()=>O())):void 0),[a,S,O,u]);const F=(0,i.I4)((e=>{S!==m.du.GlobalSearch&&(e.preventDefault(),M(m.du.GlobalSearch))}),[S]),q=(0,i.I4)((e=>{e.preventDefault(),P({id:c,shouldReplaceHistory:!0})}),[c,P]),D=(0,i.I4)((e=>{e.preventDefault(),M(m.du.Settings)}),[]);(0,it.y)({"Mod+Shift+F":F,"Mod+Shift+S":q,"Mod+0":q,...h.jm&&h.fl&&{"Mod+,":D}}),(0,i.d4)((()=>{w(),E===m.MT.Privacy&&I()}),[w,I,E]),(0,Ge.Z)((()=>{d&&(M(m.du.Settings),R(d),C(void 0))}),[d,C]);const{initResize:$,resetResize:j,handleMouseUp:G}=function(e,t,n,s){const[a,o,r]=(0,at.Z)(),[c,l]=(0,i.eJ)(),[d,u]=(0,i.eJ)();function m(){document.body.classList.remove("cursor-ew-resize")}return(0,i.d4)((()=>{e.current&&s&&(e.current.style.width=`${s}px`)}),[e,s]),(0,i.d4)((()=>{if(!a)return;const n=t=>{const n=Math.ceil(d+t.clientX-c);e.current.style.width=`${n}px`};function s(){i(),t(e.current.offsetWidth)}function i(){m(),document.removeEventListener("mousemove",n,!1),document.removeEventListener("mouseup",s,!1),document.removeEventListener("blur",s,!1),r()}return document.addEventListener("mousemove",n,!1),document.addEventListener("mouseup",s,!1),document.addEventListener("blur",s,!1),i}),[d,c,e,t,a,r]),{initResize:function(t){t.preventDefault(),document.body.classList.add("cursor-ew-resize"),l(t.clientX),u(e.current.offsetWidth),o()},resetResize:function(t){t.preventDefault(),e.current.style.width="",n()},handleMouseUp:m}}(b,y,Z,r),H=(0,i.I4)((e=>{M(m.du.Settings),R(e)}),[]);return i.ZP.createElement("div",{id:"LeftColumn",ref:b},i.ZP.createElement(ot.Z,{name:o?"none":h.s0,renderCount:jt,activeKey:L,shouldCleanup:!0,cleanupExceptionKey:$t.Main},(e=>{switch(L){case $t.Archived:return i.ZP.createElement(Dt,{isActive:e,onReset:O,onContentChange:M});case $t.Settings:return i.ZP.createElement(Ft,{isActive:e,currentScreen:E,foldersState:T,foldersDispatch:A,onScreenSelect:H,onReset:O,shouldSkipTransition:o});case $t.NewChannel:return i.ZP.createElement(qt,{key:B,isActive:e,isChannel:!0,content:S,onContentChange:M,onReset:O});case $t.NewGroup:return i.ZP.createElement(qt,{key:B,isActive:e,content:S,onContentChange:M,onReset:O});default:return i.ZP.createElement(Ut,{content:S,searchQuery:t,searchDate:n,contactsFilter:k,foldersDispatch:A,onContentChange:M,onSearchQuery:U,onScreenSelect:H,onReset:O,shouldSkipTransition:o})}})),i.ZP.createElement("div",{className:"resize-handle",onMouseDown:$,onMouseUp:G,onDoubleClick:j}))})));var Ht=n(12420),_t=n(49524),zt=n(71394);var Vt=n(12255),Wt=n(52678),Jt=n(87204),Xt=n(3570),Yt=n(75790),Kt=n(18360),Qt=n(6058),en=n(98799);const tn=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"HeaderMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),nn=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s,a;let{chatId:i,threadId:r,messageListType:l}=t;const u=(0,c.Z1)(e,i),m=Boolean(u&&(0,d.eA)(u));if(!u||u.isRestricted||(0,c.CA)(e))return{noMenu:!0};const g=(0,c.IK)(e,i),p=(0,c.FM)(e,i),f="thread"===l&&r===o._f,v="thread"===l&&r!==o._f,I=(0,c.Jf)(e),w=Boolean(g&&(0,c.s4)(e,g.id)),y=!w&&Boolean((0,c.pk)(e,i)),Z=Boolean(f&&(m||(0,d.ZV)(u))&&u.isNotJoined),P=f||v,C=h.Bi&&(0,d.YC)(u.id)&&!p&&!g,b=f&&!p&&!Z,S=f&&!Z,M=h.Bi&&u.isCallActive,E=h.Bi&&!u.isCallActive&&((null===(n=u.adminRights)||void 0===n?void 0:n.manageCall)||u.isCreator&&(0,d.G9)(u));return{noMenu:!1,isChannel:m,isRightColumnShown:I,canStartBot:y,canRestartBot:w,canSubscribe:Z,canSearch:P,canCall:C,canMute:b,canViewStatistics:null===(s=u.fullInfo)||void 0===s?void 0:s.canViewStatistics,canLeave:S,canEnterVoiceChat:M,canCreateVoiceChat:E,pendingJoinRequests:null===(a=u.fullInfo)||void 0===a?void 0:a.requestsPending,shouldJoinToSend:Boolean((null==u?void 0:u.isNotJoined)&&u.isJoinToSend),shouldSendJoinRequest:Boolean((null==u?void 0:u.isNotJoined)&&u.isJoinRequest)}}))((e=>{let{chatId:t,threadId:n,noMenu:a,isChannel:o,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,pendingJoinRequests:w,isRightColumnShown:y,canExpandActions:Z,shouldJoinToSend:P,shouldSendJoinRequest:C}=e;const{joinChannel:b,sendBotCommand:S,openLocalTextSearch:M,restartBot:E,requestCall:R,requestNextManagementScreen:k,showNotification:N}=(0,s.Sv)(),T=(0,i.sO)(null),A=(0,rt.Z)(),[B,x]=(0,i.eJ)(!1),[L,O]=(0,i.eJ)(void 0),U=(0,i.I4)((()=>{x(!0);const e=T.current.getBoundingClientRect();O({x:e.right,y:e.bottom})}),[]),F=(0,i.I4)((()=>{x(!1)}),[]),q=(0,i.I4)((()=>{O(void 0)}),[]),D=(0,i.I4)((()=>{b({chatId:t}),C&&N({message:A(o?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[b,t,C,N,o,A]),$=(0,i.I4)((()=>{S({command:"/start"})}),[S]),j=(0,i.I4)((()=>{E({chatId:t})}),[t,E]),G=(0,i.I4)((()=>{k({screen:m.u1.JoinRequests})}),[k]),H=(0,i.I4)((()=>{M(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[M]),_=(0,i.I4)((e=>{d&&h.fl&&!e.shiftKey&&(e.preventDefault(),H())}),[d,H]);return(0,it.y)({"Mod+F":_}),i.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&i.ZP.createElement(i.ZP.Fragment,null,Z&&!C&&(l||P)&&i.ZP.createElement(pt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:D},A(o?"ProfileJoinChannel":"ProfileJoinGroup")),Z&&C&&i.ZP.createElement(pt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:D},A("ChannelJoinRequest")),Z&&r&&i.ZP.createElement(pt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:$},A("BotStart")),Z&&c&&i.ZP.createElement(pt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:j},A("BotRestart")),d&&i.ZP.createElement(pt.Z,{round:!0,ripple:y,color:"translucent",size:"smaller",onClick:H,ariaLabel:"Search in this chat"},i.ZP.createElement("i",{className:"icon-search"})),u&&i.ZP.createElement(pt.Z,{round:!0,color:"translucent",size:"smaller",onClick:function(){R({userId:t})},ariaLabel:"Call"},i.ZP.createElement("i",{className:"icon-phone"}))),Boolean(w)&&i.ZP.createElement(pt.Z,{round:!0,className:"badge-button",ripple:y,color:"translucent",size:"smaller",onClick:G,ariaLabel:A(o?"SubscribeRequests":"MemberRequests")},i.ZP.createElement("i",{className:"icon-user"}),i.ZP.createElement("div",{className:"badge"},w)),i.ZP.createElement(pt.Z,{ref:T,className:B?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:a,ariaLabel:"More actions",onClick:U},i.ZP.createElement("i",{className:"icon-more"})),L&&i.ZP.createElement(tn,{chatId:t,threadId:n,isOpen:B,anchor:L,withExtraActions:h.wB||!Z,isChannel:o,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,onSubscribeChannel:D,onSearchClick:H,onClose:F,onCloseAnimationEnd:q}))})));var sn=n(74399),an=n(996),on=n(6202),rn=n(10862);function cn(e){var t;const n=e&&(0,d.DH)(e),s=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,o=n&&s&&!(0,h.on)()&&n.includes("image/webp"),[r,c]=(0,i.eJ)(rn.Hu),l=null==e?void 0:e.id;return(0,i.bt)((()=>{o&&(0,rn.p6)(`b64-${l}`,n).then(c).catch((e=>{a.eM&&console.error(e)}))}),[l,o,n]),o?r:n}var ln=n(68512),dn=n(17551);function un(e,t,n,s,a){return`M${e},${t+a}a${a},${a},0,0,1,\n ${n},0v${s-2*a}a${a},${a},0,0,1,${-n},0Z`}const mn=(0,i.X$)((e=>{let{count:t,index:n}=e;const s=(0,i.sO)(null),a=(0,i.Ye)((()=>function(e,t){const n=e-t-1,s=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 n=36;return 1===e?n=36:2===e?n=17:3===e?n=1===t?12:11:(4===e||e>3)&&(n=7.5),n}(e,n),i=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,s),o=`clipPath${e}`,r=function(e,t,n){let s="";if(3===n)s=un(0,0,2,t,1)+un(0,12,2,t+1,1)+un(0,25,2,t,1);else for(let e=0;e<n;e++)s+=un(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${s}" />\n </clipPath>`}(o,s,e),c=function(e,t,n){return 1===n?0:2===n?0===e?0:t+2:3===n?0===e?0:1===e?12:25:(t+2)*e}(n,s,e),l=function(e,t,n,s){return t<=4||e<=1?0:e>=t-2?s-36:(n+4)/2+(e-2)*(n+2)}(n,e,s,i);return{markHeight:a,clipPath:r,markTranslateY:c,trackTranslateY:l,trackHeight:i,clipPathId:o}}(t,n)),[t,n]);if((0,i.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:i,clipPathId:o,clipPath:r}=a,c=s.current.firstElementChild;if(null!=s&&s.current){const a=s.current,{style:l}=a;l.height=`${e}px`,l.transform=`translateY(-${t}px)`,l.clipPath=`url("#${o}")`;const d=a.querySelector("svg"),u=a.querySelector("div"),m=a.querySelector("defs");d||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${r} </defs></svg>`),m&&(m.innerHTML=r),u&&(u.style.height=`${n}px`,u.style.transform=`translateY(${i}px)`)}}),[a]),1===t)return i.ZP.createElement("div",{className:"pinned-message-border"},i.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:o,trackTranslateY:r,markHeight:c,markTranslateY:l,clipPathId:d}=a;return i.ZP.createElement("div",{className:(0,Fe.Z)("pinned-message-border",t>4&&"pinned-message-border-mask")},i.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${d}"); width: 2px;\n height: ${o}px; transform: translateY(-${r}px);`},i.ZP.createElement("span",null),i.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${c}px; transform: translateY(${l}px);`})))})),hn=(0,i.X$)((e=>{let{message:t,count:n,index:a,customTitle:o,className:r,onUnpinMessage:c,onClick:l,onAllPinnedClick:u}=e;const{clickBotInlineButton:m}=(0,s.Sv)(),g=(0,rt.Z)(),p=cn(t),f=(0,on.Z)((0,d.Ti)(t,"pictogram")),v=(0,an.e)(g,t,Boolean(p)),[I,w,y]=(0,at.Z)(),Z=(0,i.I4)((()=>{y(),c&&c(t.id)}),[y,c,t.id]),P=(0,d.eH)(t),C=(0,i.I4)((()=>{P&&m({messageId:t.id,button:P})}),[m,P,t.id]),[b,S,M]=(0,at.Z)();return i.ZP.createElement("div",{className:(0,Fe.Z)("HeaderPinnedMessage-wrapper",r)},n>1&&i.ZP.createElement(pt.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:g("EventLogFilterPinnedMessages"),onClick:u},i.ZP.createElement("i",{className:"icon-pin-list"})),c&&i.ZP.createElement(pt.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:g("UnpinMessageAlertTitle"),className:"unpin-button",onClick:w},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(dn.Z,{isOpen:I,onClose:y,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:Z}),i.ZP.createElement("div",{className:(0,Fe.Z)("HeaderPinnedMessage",b&&"no-hover"),onClick:l,dir:g.isRtl?"rtl":void 0},i.ZP.createElement(mn,{count:n,index:a}),p&&function(e,t){const{width:n,height:s}=(0,sn.W7)();return i.ZP.createElement("img",{src:t||e,width:n,height:s,alt:""})}(p,f),i.ZP.createElement("div",{className:"message-text"},i.ZP.createElement("div",{className:"title",dir:"auto"},o||`${g("PinnedMessage")} ${a>0?"#"+(n-a):""}`),i.ZP.createElement("p",{dir:"auto"},v),i.ZP.createElement(ln.Z,null)),P&&i.ZP.createElement(pt.Z,{size:"tiny",className:"inline-button",onClick:C,shouldStopPropagation:!0,onMouseEnter:h.$b?void 0:S,onMouseLeave:h.$b?void 0:M},P.text)))}));var gn=n(10396),pn=n(64532),fn=n(23186),vn=n(75851);const In=240;function wn(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/png";const s=e instanceof Blob?URL.createObjectURL(e):e,a=new Image;return new Promise((i=>{a.onload=()=>{yn(a,a.width*t,a.height*t,n).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(i).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(s)}))},a.src=s}))}async function yn(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Zn(e,t,n,void 0,s);try{const a=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:n,resizeQuality:"high"});if(a.height!==n||a.width!==t)throw new Error("Image bitmap resize not supported!");const i=await(0,vn.ix)(e.src),o=(0,vn.rZ)(i)<In?"#fff":"#000";return await new Promise((e=>{const t=document.createElement("canvas");t.width=a.width,t.height=a.height;const n=t.getContext("2d");n.fillStyle=o,n.fillRect(0,0,t.width,t.height);const i=t.getContext("bitmaprenderer");i?i.transferFromImageBitmap(a):n.drawImage(a,0,0),t.toBlob(e,s)}))}catch(a){return Zn(e,t,n,void 0,s)}}async function Zn(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"image/png";const i=document.createElement("canvas"),o=i.getContext("2d"),r=document.createElement("canvas"),c=r.getContext("2d");if(i.width=t,i.height=n,e.width*s>t){const n=1/s;let a={width:Math.floor(e.width*s),height:Math.floor(e.height*s)};for(r.width=a.width,r.height=a.height,c.drawImage(e,0,0,a.width,a.height);a.width*s>t;)a={width:Math.floor(a.width*s),height:Math.floor(a.height*s)},c.drawImage(r,0,0,a.width*n,a.height*n,0,0,a.width,a.height);o.drawImage(r,0,0,a.width,a.height,0,0,i.width,i.height)}else o.drawImage(e,0,0,i.width,i.height);const l=await(0,vn.ix)(e.src),d=(0,vn.rZ)(l)<In?"#fff":"#000";return o.fillStyle=d,o.globalCompositeOperation="destination-over",o.fillRect(0,0,i.width,i.height),new Promise((e=>{i.toBlob(e,a)}))}var Pn=n(77510);const Cn=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",bn={width:200,height:200},Sn=115;var Mn=n(32340),En=n(18051);const Rn=(0,s.c$)(((e,t)=>{let{message:n}=t;const s=(0,c.Ur)(e,n),a=(0,c.Z1)(e,n.chatId),{volume:i,playbackRate:o,isMuted:r}=e.audioPlayer;return{sender:s,chat:a,volume:i,playbackRate:o,isMuted:r}}))((e=>{let{message:t,className:n,noUi:o,sender:r,chat:c,volume:l,playbackRate:u,isMuted:m}=e;const{setAudioPlayerVolume:g,setAudioPlayerPlaybackRate:p,setAudioPlayerMuted:f,focusMessage:v,closeAudioPlayer:I}=(0,s.Sv)(),w=(0,rt.Z)(),{audio:y,voice:Z,video:P}=(0,d.qp)(t),C=Boolean(Z||P),b=C||((null==y?void 0:y.duration)||0)>a.J0,S=r?(0,d.OU)(w,r):void 0,M=he.UV((0,d.Ti)(t,"inline")),E=((e,t,n)=>{const s=(0,rt.Z)(),{audio:a,voice:o}=(0,d.qp)(e),r=a?a.title||a.fileName:o?"Voice message":"",c=(null==a?void 0:a.performer)||t&&(0,d.OU)(s,t),l=n&&(0,d.U)(s,n)||"Telegram",u=a&&(0,d.MR)(a)&&(0,d.Ti)(e,"pictogram"),m=t&&(0,d.RT)(t,"big"),h=a&&u||o&&m,g=(0,on.Z)(h),p=(0,i.Ye)((()=>function(e,t,n){if(!n)return bn;if(e){var s;if(null===(s=e.thumbnailSizes)||void 0===s||!s.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?sn.vY:void 0}(a,o,g)),[a,g,o]),{result:f}=(0,Pn.Z)((()=>function(e,t){if(!e)return Promise.resolve(Cn);if(!t)return function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";const a=e instanceof Blob?URL.createObjectURL(e):e,i=new Image;return new Promise((o=>{i.onload=()=>{yn(i,t,n,s).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},i.src=a}))}(e,Sn,Sn);const n=Math.min(t.width,t.height);return n<Sn?wn(e,Sn/n):Promise.resolve(e)}(g,p)),[g,p],Cn);return(0,i.Ye)((()=>(0,pn.Of)({title:r,artist:c,album:l,artwork:[{src:f}]})),[l,c,r,f])})(t,r,c),{playPause:R,stop:k,isPlaying:N,requestNextTrack:T,requestPreviousTrack:A,isFirst:B,isLast:x,setVolume:L,toggleMuted:O,setPlaybackRate:U}=(0,fn.Z)((0,gn.An)(t),(0,d.XV)(t),C?"voice":"audio",M,void 0,E,void 0,!0,void 0,void 0,(0,d.CI)(t),!0),F=C&&N;(0,i.d4)((()=>{if(F)return Ie.Z.disableRefresh(),()=>{Ie.Z.enableRefresh()}}),[F]);const q=(0,i.I4)((()=>{v({chatId:t.chatId,messageId:t.id})}),[v,t.chatId,t.id]),D=(0,i.I4)((()=>{N&&R(),I(),(0,pn.Ay)(),k()}),[I,N,R,k]),$=(0,i.I4)((e=>{g({volume:e/100}),L(e/100)}),[g,L]),j=(0,i.I4)((()=>{h.$b&&!h.cj||(O(),f({isMuted:!m}))}),[m,f,O]),G=(0,i.I4)((()=>{1===u?(U(1.8),p({playbackRate:1.8})):(U(1),p({playbackRate:1}))}),[u,p,U]),H=(0,i.Ye)((()=>0===l||m?"icon-muted":l<.3?"icon-volume-1":l<.6?"icon-volume-2":"icon-volume-3"),[l,m]);if(!o)return i.ZP.createElement("div",{className:(0,Fe.Z)("AudioPlayer",n),dir:w.isRtl?"rtl":void 0},i.ZP.createElement("div",{className:"AudioPlayer-content",onClick:q},y?function(e){const{title:t,performer:n,fileName:s}=e;return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},(0,Mn.Z)(t||s)),n&&i.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Mn.Z)(n)))}(y):function(e,t){return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,Mn.Z)(t)),i.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(w("AttachAudio"),S),i.ZP.createElement(ln.Z,null)),i.ZP.createElement(pt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:B(),onClick:A,ariaLabel:"Previous track"},i.ZP.createElement("i",{className:"icon-skip-previous"})),i.ZP.createElement(pt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,Fe.Z)("toggle-play","player-button",N?"pause":"play"),onClick:R,ariaLabel:N?"Pause audio":"Play audio"},i.ZP.createElement("i",{className:"icon-play"}),i.ZP.createElement("i",{className:"icon-pause"})),i.ZP.createElement(pt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:x(),onClick:T,ariaLabel:"Next track"},i.ZP.createElement("i",{className:"icon-skip-next"})),i.ZP.createElement(pt.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",noPreventDefault:!0},i.ZP.createElement("i",{className:H,onClick:j}),!h.cj&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"volume-slider-spacer"}),i.ZP.createElement("div",{className:"volume-slider"},i.ZP.createElement(En.Z,{bold:!0,value:m?0:100*l,onChange:$})))),b&&i.ZP.createElement(pt.Z,{round:!0,className:(0,Fe.Z)("playback-button",1!==u&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:G},i.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),i.ZP.createElement(pt.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:D,ariaLabel:"Close player"},i.ZP.createElement("i",{className:"icon-close"})))}));var kn=n(70172);const Nn=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;const s=(0,c.Z1)(e,n),a=(0,Oe.Bj)(e,n);return{groupCall:a,usersById:e.users.byId,chatsById:e.chats.byId,activeGroupCallId:e.groupCalls.activeGroupCallId,isActive:(a?a.participantsCount>0&&a.isLoaded:s&&s.isCallNotEmpty&&s.isCallActive)&&e.groupCalls.activeGroupCallId!==(null==a?void 0:a.id)}}))((e=>{let{chatId:t,isActive:n,groupCall:a,hasPinnedOffset:o,usersById:r,chatsById:c}=e;const{joinGroupCall:l,subscribeToGroupCallUpdates:d}=(0,s.Sv)(),u=(0,rt.Z)(),m=(0,i.I4)((()=>{l({chatId:t})}),[l,t]),h=null==a?void 0:a.participants,g=(0,i.Ye)((()=>h?Object.values(h).filter(((e,t)=>t<3)).map((e=>{let{id:t,isUser:n}=e;if(n){if(!r[t])return;return{user:r[t]}}if(c[t])return{chat:c[t]}})).filter(Boolean):[]),[c,h,r]);if((0,i.d4)((()=>{if(null!=a&&a.id&&(n||!a.isLoaded))return d({id:a.id,subscribed:!0}),()=>{d({id:a.id,subscribed:!1})}}),[null==a?void 0:a.id,null==a?void 0:a.isLoaded,n,d]),a)return i.ZP.createElement("div",{className:(0,Fe.Z)("GroupCallTopPane",o&&"has-pinned-offset",!n&&"is-hidden"),onClick:m},i.ZP.createElement("div",{className:"info"},i.ZP.createElement("span",{className:"title"},u("VoipGroupVoiceChat")),i.ZP.createElement("span",{className:"participants"},u("Participants",a.participantsCount||0,"i"))),i.ZP.createElement("div",{className:"avatars"},g.map((e=>{if(e)return e.user?i.ZP.createElement(kn.Z,{key:e.user.id,user:e.user}):i.ZP.createElement(kn.Z,{key:e.chat.id,chat:e.chat})}))),i.ZP.createElement(pt.Z,{round:!0,className:"join"},u("VoipChatJoin")))})));var Tn=n(14605);const An=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;return{currentUserId:e.currentUserId,chat:(0,c.Z1)(e,n),user:(0,d.YC)(n)?(0,c.dy)(e,n):void 0}}))((e=>{let{chatId:t,className:n,chat:a,user:o,settings:r,currentUserId:c}=e;const{openAddContactDialog:l,blockContact:u,reportSpam:m,deleteChat:h,leaveChannel:g,deleteChatUser:p,deleteHistory:f,toggleChatArchived:v,hideChatReportPanel:I}=(0,s.Sv)(),w=(0,rt.Z)(),[y,Z,P]=(0,at.Z)(),[C,b]=(0,i.eJ)(!0),[S,M]=(0,i.eJ)(!0),{accessHash:E}=a||{},{isAutoArchived:R,canReportSpam:k,canAddContact:N,canBlockContact:T}=r||{},A=a&&(0,d.G9)(a),B=(0,i.I4)((()=>{l({userId:t}),R&&v({chatId:t})}),[l,R,v,t]),x=(0,i.I4)((()=>{P(),u({contactId:t,accessHash:E}),k&&C&&m({chatId:t}),S&&h({chatId:t})}),[E,u,P,h,m,k,S,C,t]),L=(0,i.I4)((()=>{I({chatId:t})}),[t,I]),O=(0,i.I4)((()=>{P(),m({chatId:t}),A?(p({chatId:t,userId:c}),f({chatId:t,shouldDeleteForAll:!1})):g({chatId:t})}),[t,P,c,p,f,A,g,m]);if(r)return i.ZP.createElement("div",{className:(0,Fe.Z)("ChatReportPanel",n),dir:w.isRtl?"rtl":void 0},N&&i.ZP.createElement(pt.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:B},w("lng_new_contact_add")),T&&i.ZP.createElement(pt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:Z},w("lng_new_contact_block")),k&&!T&&i.ZP.createElement(pt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:Z},w("lng_report_spam_and_leave")),i.ZP.createElement(pt.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:L,ariaLabel:w("Close")},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(dn.Z,{isOpen:y,onClose:P,title:w("BlockUserTitle",o?(0,d.Vl)(o):(0,d.U)(w,a)),text:o?w("UserInfo.BlockConfirmationTitle",(0,d.Js)(o)):w("Chat.Confirm.ReportSpam.Channel"),isButtonsInOneRow:!0,confirmIsDestructive:!0,confirmLabel:w("Block"),confirmHandler:o?x:O},o&&i.ZP.createElement(Tn.Z,{label:w("DeleteThisChat"),checked:S,onCheck:M}),o&&k&&i.ZP.createElement(Tn.Z,{label:w("ReportChat"),checked:C,onCheck:b})))}))),Bn=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s,messageListType:a}=t;const{isLeftColumnShown:i,lastSyncTime:r,shouldSkipHistoryAnimations:l}=e,u=(0,c.Z1)(e,n),{typingStatus:m}=u||{},{chatId:h,messageId:g}=e.audioPlayer,p=h&&g?(0,c.hj)(e,h,g):void 0;let f;if("pinned"===a){const t=(0,c.KB)(e,n);f=null==t?void 0:t.length}else if("scheduled"===a){const t=(0,c.qy)(e,n);f=null==t?void 0:t.length}else if("thread"===a&&s!==o._f){const t=(0,c.tZ)(e,n,s);f=(null==t?void 0:t.messagesCount)||0}const v="thread"===a&&s===o._f,I=u&&(0,c.xo)(e,u),w=Boolean(I&&(0,c.s4)(e,n)),y=I&&!w&&Boolean((0,c.pk)(e,n)),Z=Boolean(v&&u&&((0,d.eA)(u)||(0,d.ZV)(u))&&u.isNotJoined),P=Boolean((null==u?void 0:u.isNotJoined)&&u.isJoinRequest),C={typingStatus:m,isLeftColumnShown:i,isRightColumnShown:(0,c.Jf)(e),isSelectModeActive:(0,c.CA)(e),audioMessage:p,chat:u,messagesCount:f,isChatWithSelf:(0,c.FM)(e,n),isChatWithBot:I,lastSyncTime:r,shouldSkipHistoryAnimations:l,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing,hasButtonInHeader:y||w||Z||P},b=(0,c.Zw)(e,n);if("thread"!==a||!b)return C;if(Object.assign(C,{messagesById:b}),s!==o._f){const t=(0,c.qS)(e,n,s),a=t?(0,c.hj)(e,n,t):void 0,i=a?(0,c.cv)(e,a):void 0;return{...C,pinnedMessageIds:t,canUnpin:!1,topMessageSender:i}}const S=(0,c.KB)(e,n);if(null!=S&&S.length){const t=b[S[0]],{canUnpin:n}=t&&(0,c._k)(e,t,s)||{};return{...C,pinnedMessageIds:S,canUnpin:n}}return C}))((e=>{let{chatId:t,threadId:n,messageListType:r,isReady:c,pinnedMessageIds:l,messagesById:u,canUnpin:m,topMessageSender:g,typingStatus:p,isSelectModeActive:f,isLeftColumnShown:v,isRightColumnShown:I,audioMessage:w,chat:y,messagesCount:Z,isChatWithSelf:P,isChatWithBot:C,lastSyncTime:b,hasButtonInHeader:S,shouldSkipHistoryAnimations:M,currentTransitionKey:E,connectionState:R,isSyncing:k}=e;const{openChatWithInfo:N,pinMessage:T,focusMessage:A,openChat:B,openPreviousChat:x,loadPinnedMessages:L,toggleLeftColumn:O,exitMessageSelectMode:U}=(0,s.Sv)(),F=(0,rt.Z)(),q=(0,i.sO)(!0),[D,$]=(0,i.eJ)(0),j=Array.isArray(l)?l[D]:l,G=u&&j?u[j]:void 0,H=Array.isArray(l)?l.length:l?1:void 0,_=y&&(0,d.U)(F,y).length,z=g?(0,d.OU)(F,g):void 0,{settings:V}=y||{};(0,i.d4)((()=>{n===o._f&&b&&c&&L({chatId:t})}),[t,L,b,n,c]),(0,i.d4)((()=>{$(0)}),[l]),(0,Yt.Z)(t,j,G);const{width:W}=(0,Vt.Z)(),J=W<=a.ks,X=h.p7&&v,Y=(0,i.sO)(null),K=(0,i.sO)(!0),Q=(0,i.I4)((()=>{N({id:t})}),[N,t]),ee=(0,i.I4)((e=>{T({chatId:t,messageId:e,isUnpin:!0})}),[T,t]),te=(0,i.I4)((()=>{if(G){A({chatId:G.chatId,threadId:n,messageId:G.id});const e=(0,Xt.Z)(H||1,D+1);$(e)}}),[G,A,n,H,D]),ne=(0,i.I4)((()=>{B({id:t,threadId:o._f,type:"pinned"})}),[B,t]),se=(0,i.I4)((()=>{setTimeout((()=>{q.current=!0}),450)}),[]),ae=(0,i.I4)((e=>{if(q.current){if(q.current=!1,h.wB){const e=document.querySelector(a.Ed);null==e||e.blur()}if(f)return U(),void se();if(n===o._f&&"thread"===r&&0===E)return h.wB||X?(e.stopPropagation(),B({id:void 0})):O(),void se();x(),se()}}),[n,r,E,f,x,X,B,O,U,se]),ie=W>=a.ks&&W<a.jT||W>a.l3&&W<a.ks&&(!_||_>30),oe=ie||W>a._m&&W<a.QU,re=Boolean((null==V?void 0:V.canAddContact)||(null==V?void 0:V.canBlockContact)||(null==V?void 0:V.canReportSpam)),{shouldRender:ce,transitionClassNames:le}=(0,Xe.Z)(re),de=(0,Kt.Z)(re?V:void 0,!0),{shouldRender:ue,transitionClassNames:me}=(0,Xe.Z)(Boolean(w)),he=(0,Kt.Z)(w,!0),{shouldRender:ge,transitionClassNames:pe}=(0,Xe.Z)(Boolean(G)),fe=(0,Kt.Z)(G,!0),ve=(0,Kt.Z)(H,!0),Ie=(0,Kt.Z)(m,!0),we=(0,Kt.Z)(z),ye=ge&&fe||ue&&he;(0,i.d4)((()=>{const e=Y.current;if(e)return oe&&ye?void(I||ie?(K.current&&(e.classList.add("tools-stacked","animated"),K.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),K.current=!0)):(e.classList.remove("tools-stacked","animated"),void(K.current=!0))}),[oe,ye,ie,I]);const{connectionStatusText:Ze}=ut(F,R,k,!0);function Pe(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i.ZP.createElement("div",{className:"back-button"},i.ZP.createElement(pt.Z,{round:!0,size:"smaller",color:"translucent",onClick:ae,ariaLabel:F(e?"Close":"Back")},i.ZP.createElement("div",{className:(0,Fe.Z)("animated-close-icon",!e&&"state-back")})),t&&i.ZP.createElement(tt,null))}const Ce=Boolean(ue&&he),be=Ce||!h.wB&&S&&W<a.sg;return i.ZP.createElement("div",{className:"MiddleHeader",ref:Y},i.ZP.createElement(ot.Z,{name:M?"none":"slide-fade",activeKey:E},"thread"===r&&n===o._f?i.ZP.createElement(i.ZP.Fragment,null,(J||E>0)&&Pe(X,!0),i.ZP.createElement("div",{className:"chat-info-wrapper",onClick:Q},(0,d.YC)(t)?i.ZP.createElement(Qt.Z,{userId:t,typingStatus:p,status:Ze,withDots:Boolean(Ze),withFullInfo:C,withMediaViewer:!0,withUpdatingStatus:!0,withVideoAvatar:!0,noRtl:!0}):i.ZP.createElement(en.Z,{chatId:t,typingStatus:p,status:Ze,withDots:Boolean(Ze),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,withVideoAvatar:!0,noRtl:!0}))):"thread"===r?i.ZP.createElement(i.ZP.Fragment,null,Pe(),i.ZP.createElement("h3",null,F("CommentsCount",Z,"i"))):"pinned"===r?i.ZP.createElement(i.ZP.Fragment,null,Pe(),i.ZP.createElement("h3",null,F("PinnedMessagesCount",Z,"i"))):"scheduled"===r?i.ZP.createElement(i.ZP.Fragment,null,Pe(),i.ZP.createElement("h3",null,P?F("Reminders"):F("messages",Z,"i"))):void 0),i.ZP.createElement(Nn,{hasPinnedOffset:ge&&Boolean(fe)||ue&&Boolean(he),chatId:t}),ge&&fe&&i.ZP.createElement(hn,{key:t,message:fe,count:ve||0,index:D,customTitle:we,className:(0,Fe.Z)(pe,be&&"full-width"),onUnpinMessage:Ie?ee:void 0,onClick:te,onAllPinnedClick:ne}),ce&&i.ZP.createElement(An,{key:t,chatId:t,settings:de,className:le}),i.ZP.createElement("div",{className:"header-tools"},Ce&&i.ZP.createElement(Rn,{key:(0,d.Tp)(he),message:he,className:me}),i.ZP.createElement(nn,{chatId:t,threadId:n,messageListType:r,canExpandActions:!Ce})))})));function xn(e){return"albumId"in e}function Ln(e,t){let n,s=[],a={originalDate:e[0].date,datetime:(0,H._F)(1e3*e[0].date),senderGroups:[s]};const i=[a];return e.forEach(((o,r)=>{o.isInAlbum?n?(n.messages.push(o),o.content.text&&(n.mainMessage=o)):n={albumId:o.groupedId,messages:[o],mainMessage:o}:s.push(o);const c=e[r+1];if(!n||c&&c.groupedId&&c.groupedId===n.albumId||(s.push(n),n=void 0),c){const e=(0,H._F)(1e3*c.date);a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},i.push(a),s=[],a.senderGroups.push(s)):(c.id===t||o.senderId!==c.senderId||o.isOutgoing!==c.isOutgoing||(0,d.Lo)(o)||(0,d.Lo)(c)||o.forwardInfo&&c.forwardInfo&&(o.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||o.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||o.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||o.inlineButtons||c.inlineButtons||c.date-o.date>600)&&(s=[],a.senderGroups.push(s))}})),i}var On=n(30386),Un=n(87675),Fn=n(60539),qn=n(88957);var Dn=n(62357),$n=n(60998);var jn=n(72645),Gn=n(274),Hn=n(3657);const _n=h.wZ?1e3:350,zn=h.wB?300:500;var Vn=n(17240);function Wn(e){return"number"==typeof e}function Jn(e,t){return e?t?238:175:t?238:100}function Xn(e,t){const n=(0,d.B4)(e),s=(0,d.MF)(e),a=(0,d.O$)(e)||(0,d.F$)(e),i=(0,d.b7)(e),o=Boolean((0,d.F$)(e)),{width:r,height:c}=a?(0,sn.Eh)(a,n,s,o,t):(0,sn.GC)(i,n,s,t),l=Jn(Boolean((0,d.UD)(e)));let u=1;r<l&&l-r<12&&(u=l/r),c*u<90&&90-c*u<12&&(u=90/c);const m=Math.round(r*u),h=Math.round(c*u);return{width:m,height:h,isSmall:m<l||h<90}}var Yn=n(28712);function Kn(e,t){return e.reduce(((e,t)=>e+t),t)}function Qn(e){const t={width:0,height:0};return e.forEach((e=>{let{dimensions:n,sides:s}=e;2&s&&(t.width=n.width+n.x),4&s&&(t.height=n.height+n.y)})),t}function es(e,t,n,s){const a=function(e){return e.map((e=>{const t=Xn(e);return t.width/t.height}))}(s.messages),i=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),o=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),r=a.length,c=a.some((e=>e>2)),l=(0,sn.kc)(e,t,!1,n)-(t?2.5:0)*sn.Gw;let d;const u={ratios:a,proportions:i,averageRatio:o,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return d=r>=5||c?function(e){let{ratios:t,averageRatio:n,maxWidth:s,minWidth:a,spacing:i,maxHeight:o=4*s/3}=e;const r=function(e,t){return e.map((e=>t>1.1?(0,Yn.uZ)(e,1,2.75):(0,Yn.uZ)(e,.6667,1)))}(t,n),c=t.length,l=new Array(c),d=[],u=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=Kn(r.slice(e,e+t),0);return(s-(t-1)*i)/n})(n,e)),n+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==c;++e){const t=c-e;e<=3&&t<=3&&u([e,t])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t){const s=c-e-t;e<=3&&t<=(n<.85?4:3)&&s<=3&&u([e,t,s])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t)for(let n=1;n!==c-e-t;++n){const s=c-e-t-n;e<=3&&t<=3&&n<=3&&s<=4&&u([e,t,n,s])}let m,h=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:n}=d[e],s=n.length,r=Kn(t,0)+i*(s-1),c=Math.min(...t)<a?1.5:1,l=(()=>{for(let e=1;e!==s;++e)if(n[e-1]>n[e])return 1.5;return 1})(),u=Math.abs(r-o)*c*l;(!m||u<h)&&(m=d[e],h=u)}const g=m.lineCounts,p=m.heights,f=g.length;let v=0,I=0;for(let e=0;e!==f;++e){const t=g[e],n=p[e],a=Math.round(n);let o=0;for(let c=0;c!==t;++c){const d=0|(0===e?1:0)|(e===f-1?4:0)|(0===c?8:0)|(c===t-1?2:0),u=r[v],m=c===t-1?s-o:Math.round(u*n);l[v]={dimensions:{x:o,y:I,width:m,height:a},sides:d},o+=m+i,++v}I+=a+i}return l}(u):2===r?function(e){const{ratios:t,proportions:n,averageRatio:s}=e;return"ww"===n&&s>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:n,spacing:s,maxHeight:a}=e,i=Math.round(Math.min(n/t[0],Math.min(n/t[1],(a-s)/2)));return[{dimensions:{x:0,y:0,width:n,height:i},sides:11},{dimensions:{x:0,y:i+s,width:n,height:i},sides:14}]}(e):"ww"===n||"qq"===n?function(e){const{ratios:t,maxWidth:n,spacing:s,maxHeight:a}=e,i=(n-s)/2,o=Math.round(Math.min(i/t[0],Math.min(i/t[1],a)));return[{dimensions:{x:0,y:0,width:i,height:o},sides:13},{dimensions:{x:i+s,y:0,width:i,height:o},sides:7}]}(e):function(e){const{ratios:t,minWidth:n,maxWidth:s,spacing:a,maxHeight:i}=e,o=Math.round(1.5*n),r=Math.min(Math.round(Math.max(.4*(s-a),(s-a)/t[0]/(1/t[0]+1/t[1]))),s-a-o),c=s-r-a,l=Math.min(i,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:l},sides:13},{dimensions:{x:c+a,y:0,width:r,height:l},sides:7}]}(e)}(u):3===r?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:n,ratios:s,maxWidth:a,minWidth:i}=e,o=t,r=Math.round(Math.min((t-n)/2,s[1]*(a-n)/(s[2]+s[1]))),c=o-r-n,l=Math.max(i,Math.round(Math.min((a-n)/2,Math.min(r*s[2],c*s[1])))),d=Math.min(Math.round(o*s[0]),a-n-l);return[{dimensions:{x:0,y:0,width:d,height:o},sides:13},{dimensions:{x:d+n,y:0,width:l,height:c},sides:3},{dimensions:{x:d+n,y:c+n,width:l,height:r},sides:6}]}(e):function(e){const{maxWidth:t,ratios:n,maxHeight:s,spacing:a}=e,i=t,o=Math.round(Math.min(i/n[0],.66*(s-a))),r=(t-a)/2,c=Math.min(s-o-a,Math.round(Math.min(r/n[1],r/n[2])));return[{dimensions:{x:0,y:0,width:i,height:o},sides:11},{dimensions:{x:0,y:o+a,width:r,height:c},sides:12},{dimensions:{x:r+a,y:o+a,width:i-r-a,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function(e){let{maxWidth:t,ratios:n,spacing:s,maxHeight:a,minWidth:i}=e;const o=t,r=Math.round(Math.min(o/n[0],.66*(a-s))),c=Math.round((t-2*s)/(n[1]+n[2]+n[3])),l=Math.max(i,Math.round(Math.min(.4*(t-2*s),c*n[1]))),d=Math.round(Math.max(Math.max(i,.33*(t-2*s)),c*n[3])),u=o-l-d-2*s,m=Math.min(a-r-s,c);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:l,height:m},sides:12},{dimensions:{x:l+s,y:r+s,width:u,height:m},sides:4},{dimensions:{x:l+s+u+s,y:r+s,width:d,height:m},sides:6}]}(e):function(e){let{maxHeight:t,ratios:n,maxWidth:s,spacing:a,minWidth:i}=e;const o=t,r=Math.round(Math.min(o*n[0],.6*(s-a))),c=Math.round((t-2*a)/(1/n[1]+1/n[2]+1/n[3])),l=Math.round(c/n[1]),d=Math.round(c/n[2]),u=o-l-d-2*a,m=Math.max(i,Math.min(s-r-a,c));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+a,y:0,width:m,height:l},sides:3},{dimensions:{x:r+a,y:l+a,width:m,height:d},sides:2},{dimensions:{x:r+a,y:l+d+2*a,width:m,height:u},sides:6}]}(e)}(u),{layout:d,containerStyle:Qn(d)}}let ts,ns;function ss(e){return ns||(ns=getComputedStyle(document.documentElement).getPropertyValue("--font-family")),ts||(ts=document.createElement("span"),ts.style.font=`400 12px ${ns}`,ts.style.whiteSpace="nowrap",ts.style.position="absolute",ts.style.left="-999px",ts.style.opacity=".01",document.body.appendChild(ts)),ts.innerHTML=e,ts.offsetWidth}function as(e,t,n,s,a,o){(0,i.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,Fn.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==s?1e3:void 0,s,void 0,o)}}),[e,t,n,s,a,o])}var is=n(3858);const os=3*sn.Gw,rs=Number(sn.Gw),cs="data-is-document-group-hover";function ls(e,t,n,a,o,r,c,l,d,u,m,g,p,f){const{setReplyingToId:v,sendDefaultReaction:I}=(0,s.Sv)(),[w,y,Z]=(0,at.Z)(),[P,C,b]=(0,at.Z)(),S=(0,i.sO)();return(0,i.d4)((()=>{if(!h.$b||o||!r||m)return;let e;return(0,bt.sf)(t.current,{selectorToPreventScroll:".MessageList",excludedClosestSelector:".no-word-wrap",onSwipe:(t,n)=>n===bt.eM.Left&&(e||(e=Date.now()),C(),!0),onRelease:()=>{e&&(v({messageId:n}),setTimeout(b,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,o,n,v,C,b,r,m]),{handleMouseDown:o?void 0:function(e){(0,On.q)(e),d(e)},handleClick:function(t){if(o)e(t);else if(h.$b)return S.current?(clearInterval(S.current),S.current=void 0,void function(e){const{pageX:t,pageY:s}=e;I({chatId:u,messageId:n,x:t,y:s})}(t)):void(S.current=setTimeout((()=>{S.current=void 0,function(e){if(h.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;Ie.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:o?c?is.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]")||m)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:o?void 0:function(){h.$b||v({messageId:n})},handleContentDoubleClick:h.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:function(e){const t=g.current;if(!t)return;const{clientX:n,clientY:s}=e,{x:a,width:i,y:o,height:r}=t.getBoundingClientRect(),c=Math.abs(p?n-a:a+i-n)<os,l=Math.abs(o+r-s)<rs;c&&l?y():Z()},handleSendQuickReaction:function(e){const{x:t,y:s}=e.currentTarget.getBoundingClientRect();I({chatId:u,messageId:n,x:t,y:s})},handleMouseLeave:function(e){Z(),f&&function(e){const t=us(e.currentTarget);t&&t.removeAttribute(cs)}(e)},isSwiped:P,isQuickReactionVisible:w,handleDocumentGroupMouseEnter:ds}}function ds(e){const t=us(e.currentTarget);t&&t.setAttribute(cs,"")}function us(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var ms=n(55254),hs=n(18005);const gs=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"ContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),ps=(0,i.X$)((0,s.c$)(((e,t)=>{let{message:n}=t;const{byId:s}=e.users,a=n.senderId,{targetUserIds:i,targetChatId:o}=n.content.action||{},r=n.replyToMessageId,l=r?(0,c.hj)(e,n.chatId,r):void 0,u=(0,c._X)(e,n),{direction:m,noHighlight:h}=u&&e.focusedMessage||{},g=(0,c.Z1)(e,n.chatId),p=g&&((0,d.eA)(g)||a===n.chatId);return{usersById:s,senderUser:!p&&a?(0,c.dy)(e,a):void 0,senderChat:p?g:void 0,targetChatId:o,targetUserIds:i,targetMessage:l,isFocused:u,...u&&{focusDirection:m,noFocusHighlight:h}}}))((e=>{let{message:t,observeIntersection:n,isEmbedded:s,appearanceOrder:a=0,isLastInList:o,usersById:r,senderUser:c,senderChat:l,targetUserIds:u,targetMessage:m,targetChatId:h,isFocused:g,focusDirection:p,noFocusHighlight:f}=e;const v=(0,i.sO)(null);(0,Hn._N)(v,n),(0,Yt.Z)(t.chatId,t.replyToMessageId,m),as(v,t.chatId,g,p,f);const I=(0,rt.Z)(),w=a<=0,[y,Z]=(0,at.Z)(w);(0,i.d4)((()=>{w||setTimeout(Z,10*a)}),[a,Z,w]);const{transitionClassNames:P}=(0,Xe.Z)(y,void 0,w,!1),C=(0,i.Ye)((()=>u?u.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[u,r]),b=(0,hs.D)(I,t,c,l,C,m,h,{asTextWithSpoilers:s}),{isContextMenuOpen:S,contextMenuPosition:M,handleBeforeContextMenu:E,handleContextMenu:R,handleContextMenuClose:k,handleContextMenuHide:N}=(0,Vn.Z)(v),T=void 0!==M;if(s)return i.ZP.createElement("span",{className:"embedded-action-message"},b);const A=(0,Fe.Z)("ActionMessage message-list-item",g&&!f&&"focused",T&&"has-menu-open",o&&"last-in-list",P);return i.ZP.createElement("div",{ref:v,id:(0,d.d0)(t.id),className:A,"data-message-id":t.id,onMouseDown:e=>{(0,On.q)(e),E(e)},onContextMenu:R},i.ZP.createElement("span",null,b),M&&i.ZP.createElement(gs,{isOpen:S,anchor:M,message:t,messageListType:"thread",onClose:k,onCloseAnimationEnd:N}))}))),fs=e=>{var t;let{className:n,message:s,sender:a,title:o,customText:r,isProtected:c,noUserColors:l,hasContextMenu:u,observeIntersection:m,onClick:h}=e;const g=(0,i.sO)(null),p=(0,Hn.Op)(g,m),f=(0,on.Z)(s&&(0,d.Ti)(s,"pictogram"),!p),v=cn(s),I=Boolean(s&&(0,d.Y5)(s)),w=(0,rt.Z)(),y=a?(0,d.OU)(w,a):null==s||null===(t=s.forwardInfo)||void 0===t?void 0:t.hiddenUserName;return i.ZP.createElement("div",{ref:g,className:(0,Fe.Z)("EmbeddedMessage",n,a&&!l&&`color-${(0,d.Rs)(a)}`),onClick:s?h:void 0},v&&function(e,t,n,s){const{width:a,height:o}=(0,sn.W7)();return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("img",{src:t||e,width:a,height:o,alt:"",className:n?"round":"",draggable:!s}),s&&i.ZP.createElement("span",{className:"protector"}))}(v,f,I,c),i.ZP.createElement("div",{className:"message-text"},i.ZP.createElement("p",{dir:"auto"},s?(0,d.Lo)(s)?i.ZP.createElement(ps,{message:s,isEmbedded:!0}):(0,an.e)(w,s,Boolean(v)):r||" "),i.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Mn.Z)(y||o||" "))),u&&i.ZP.createElement("i",{className:"embedded-more icon-more"}))};var vs=n(82535),Is=n(54752),ws=n(8018),ys=n(48198),Zs=n(97799);const Ps=(0,i.X$)((e=>{var t,n;let{reaction:a,activeReaction:o,isInMeta:r,availableReactions:c}=e;const{stopActiveReaction:l}=(0,s.Sv)(),d=null==c?void 0:c.find((e=>e.reaction===a)),u=null==d||null===(t=d.centerIcon)||void 0===t?void 0:t.id,m=null==d||null===(n=d.aroundAnimation)||void 0===n?void 0:n.id,h=(0,on.Z)(`sticker${u}`,!u),g=(0,on.Z)(`sticker${m}`,!m),p=Boolean((null==o?void 0:o.reaction)===a&&h&&g),{shouldRender:f,transitionClassNames:v}=(0,Xe.Z)(p,void 0,!0,"slow"),I=(0,i.I4)((()=>{l({messageId:null==o?void 0:o.messageId,reaction:a})}),[null==o?void 0:o.messageId,a,l]),[w,y,Z]=(0,at.Z)(),P=!p||!w,C=(0,Fe.Z)("ReactionAnimatedEmoji",r&&"in-meta",f&&"is-animating");return i.ZP.createElement("div",{className:C},P&&i.ZP.createElement(ys.Z,{reaction:a}),f&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Zs.Z,{key:u,className:v,size:30,tgsUrl:h,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:y,onEnded:Z}),i.ZP.createElement(Zs.Z,{key:m,className:(0,Fe.Z)("effect",v),size:100,tgsUrl:g,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:I})))})),Cs=(0,i.X$)((e=>{var t;let{message:n,outgoingStatus:s,signature:a,onClick:o,withReactions:r,activeReaction:c,withReactionOffset:l,availableReactions:d,reactionMessage:u}=e;const m=(0,rt.Z)(),[h,g]=(0,at.Z)(),p=r&&(null==u||null===(t=u.reactions)||void 0===t?void 0:t.results.filter((e=>e.count>0))),f=(0,i.Ye)((()=>{if(!h)return;const e=(0,H.SA)(1e3*n.date,m.code),t=n.isEdited&&(0,H.SA)(1e3*n.editDate,m.code),s=n.forwardInfo&&(0,H.SA)(1e3*n.forwardInfo.date,m.code);let a=e;return t&&(a+="\n",a+=m("lng_edited_date").replace("{date}",t)),s&&(a+="\n",a+=m("lng_forwarded_date").replace("{date}",s)),a}),[h,m,n]);return i.ZP.createElement("span",{className:(0,Fe.Z)("MessageMeta",l&&"reactions-offset"),dir:m.isRtl?"rtl":"ltr",onClick:o},p&&p.map((e=>i.ZP.createElement(Ps,{activeReaction:c,reaction:e.reaction,isInMeta:!0,availableReactions:d}))),Boolean(n.views)&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"message-views"},(0,Ke.bi)(n.views)),i.ZP.createElement("i",{className:"icon-channelviews"})),a&&i.ZP.createElement("span",{className:"message-signature"},(0,Mn.Z)(a)),i.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:g},n.isEdited&&`${m("EditedMessage")} `,(0,H.mr)(m,1e3*n.date)),s&&i.ZP.createElement(ws.Z,{status:s}))}));var bs=n(70692),Ss=n(74753);const Ms=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:r,shouldLoop:c,lastSyncTime:l,shouldPlayEffect:u,onPlayEffect:m,onStopEffect:g}=e;const{showNotification:p}=(0,s.Sv)(),f=(0,rt.Z)(),v=(0,i.sO)(null),[I,w,y]=(0,at.Z)(),Z=t.content.sticker,{isLottie:P,stickerSetId:C,isVideo:b,hasEffect:S}=Z,M=h.Hh,E=C===a.$E,[R,k,N]=(0,at.Z)(),T=(0,Hn.Op)(v,n),A=(0,Hn.Op)(v,r),B=Z.isPreloadedGlobally?`sticker${Z.id}`:(0,d.Ti)(t,"inline"),x=`sticker${Z.id}?size=f`,L=b&&!M&&(Z.isPreloadedGlobally?`sticker${Z.id}?size=m`:(0,d.Ti)(t,"pictogram")),O=(0,on.Z)(L),U=cn(t),F=O||U,q=(0,on.Z)(B,!T,(0,d.kG)(t,"inline"),l),D=(0,on.Z)(x,!T||!S,o.IU.BlobUrl,l),$=Boolean(q),[j,G]=(0,at.Z)($),H=P?j:$,_=(0,bs.Z)(H),{width:z,height:V}=(0,sn.Wr)(Z),W=(0,Fe.Z)("thumbnail",!U&&"empty"),J=(0,Fe.Z)("Sticker media-inner",E&&"inactive",S&&!t.isOutgoing&&"reversed"),X=(0,i.I4)((()=>{N(),null==g||g()}),[g,N]);(0,i.d4)((()=>{if(!b||!v.current)return;const e=v.current.querySelector("video");e&&(A?(0,Ss.Z)(e):e.pause())}),[b,A]),(0,i.d4)((()=>{S&&A&&u&&(k(),null==m||m())}),[S,u,m,A,k]);const Y=(0,i.I4)((()=>{if(S)return R?void p({message:f("PremiumStickerTooltip"),action:w,actionText:f("ViewAction")}):(k(),void(null==m||m()));w()}),[S,R,f,m,w,p,k]);return i.ZP.createElement("div",{ref:v,className:J,onClick:E?void 0:Y},(!H||b&&!M)&&i.ZP.createElement("img",{src:F,width:z,height:V,alt:"",className:W}),!P&&!b&&i.ZP.createElement("img",{src:q,width:z,height:V,alt:"",className:(0,Fe.Z)("full-media",_)}),b&&M&&H&&i.ZP.createElement("video",{src:q,width:z,height:V,autoPlay:A,playsInline:!0,disablePictureInPicture:!0,loop:c,muted:!0}),P&&$&&i.ZP.createElement(Zs.Z,{key:B,className:(0,Fe.Z)("full-media",_),tgsUrl:q,size:z,play:A,noLoop:!c,onLoad:G}),S&&T&&R&&i.ZP.createElement(Zs.Z,{key:x,className:"effect-sticker",tgsUrl:D,size:1.49*z,play:!0,isLowPriority:!0,noLoop:!0,onEnded:X}),i.ZP.createElement(Ye.Z,{isOpen:I,fromSticker:Z,onClose:y}))};var Es=n(13365);var Rs=n(45601),ks=n(21179);const Ns=(0,i.X$)((0,s.c$)(((e,t)=>{let{emoji:n,withEffects:s}=t;const a=(0,c.CP)(e,n);return{sticker:(0,c.zB)(e,n),effect:s?(0,c.tH)(e,n):void 0,soundId:(0,c.Oh)(e,n),localSticker:a,localEffect:a&&s?(0,c.cu)(a):void 0}}))((e=>{let{isOwn:t,observeIntersection:n,lastSyncTime:a,forceLoadPreview:o,messageId:r,chatId:l,activeEmojiInteractions:d,sticker:u,effect:m,localSticker:h,localEffect:g,soundId:p}=e;const{ref:f,size:v,style:I,handleClick:w}=function(e,t,n,a,o,r,l){const{interactWithAnimatedEmoji:d,sendEmojiInteraction:u,sendWatchingEmojiInteraction:m}=(0,s.Sv)(),h=r||l,g=(0,i.sO)(null),p=(0,i.sO)(null),f=(0,on.Z)(n?`document${n}`:void 0,!n),v=(0,i.sO)(void 0),I=(0,i.sO)(void 0),w=(0,i.I4)((()=>{g.current&&(u({chatId:e,messageId:t,localEffect:r,emoji:l,interactions:v.current}),I.current=void 0,v.current=void 0)}),[u,e,t,r,l]),y=(0,i.I4)((()=>{const e=p.current;f&&(e&&(e.pause(),e.remove()),p.current=new Audio,p.current.src=f,(0,Ss.Z)(p.current),p.current.addEventListener("ended",(()=>{p.current=void 0}),{once:!0}))}),[f]),Z=(0,i.I4)((()=>{y();const n=g.current;if(!(h&&n&&t&&e))return;const{x:s,y:a}=n.getBoundingClientRect();d({localEffect:r,emoji:l,x:s,y:a,startSize:104,isReversed:!o}),v.current||(v.current=[],I.current=performance.now(),setTimeout(w,1e3)),v.current.push(I.current?(performance.now()-I.current)/1e3:0)}),[e,l,h,d,o,r,t,y,w]);return(0,i.d4)((()=>{const n=g.current;n&&a&&a.forEach((s=>{let{id:a,startSize:i,messageId:d}=s;if(i||t!==d)return;const{x:u,y:h}=n.getBoundingClientRect();m({id:a,chatId:e,emoticon:r?(0,c.ji)(r):l,startSize:104,x:u,y:h,isReversed:!o}),y()}))}),[a,e,l,o,r,t,y,m]),{ref:g,size:104,style:"width: 104px; height: 104px;",handleClick:Z}}(l,r,p,d,t,g,null==m?void 0:m.emoji),y=(0,Hn.Op)(f,n);return h?i.ZP.createElement(ks.Z,{tgsUrl:Es.l[h],size:v,quality:1,play:y,forceOnHeavyAnimation:!0,ref:f,className:"AnimatedEmoji media-inner",style:I,onClick:w}):i.ZP.createElement(Rs.Z,{sticker:u,size:v,quality:1,noLoad:!y,forcePreview:o,lastSyncTime:a,play:y,forceOnHeavyAnimation:!0,ref:f,className:(0,Fe.Z)("AnimatedEmoji media-inner",(null==u?void 0:u.id)===sn.wB&&"like-sticker-thumb"),style:I,onClick:w})})));var Ts=n(92566),As=n(15866);function Bs(e,t){return(0,As.Z)((0,d.DH)(e),Boolean(t),h.wB&&!h.vX)}const xs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function Ls(e,t,n,s,a){return s?Promise.resolve(xs[a||"light"][t?"outgoing":"incoming"]):async function(e,t){const n=new Image;n.src=e,n.crossOrigin="anonymous",n.width||await new Promise((e=>{n.onload=e}));const s=document.createElement("canvas"),a=s.getContext("2d");s.width=n.width,s.height=n.height,a.drawImage(n,0,0,n.width,n.height);const i=t?n.width-1:0,o=n.height-1;return`rgba(${Array.from(a.getImageData(i,o,1,1).data).join(",")})`}(e,t)}var Os=n(39196);const Us=e=>{let{id:t,message:n,observeIntersection:s,noAvatars:o,canAutoLoad:r,isInSelectMode:c,isSelected:l,uploadProgress:u,size:m="inline",dimensions:h,nonInteractive:g,shouldAffectAppendix:p,isDownloading:f,isProtected:v,withAspectRatio:I,theme:w,onClick:y,onCancelUpload:Z}=e;const P=(0,i.sO)(null),C=((0,d.O$)(n)||(0,d.F$)(n)).blobUrl,b=(0,Hn.Op)(P,s),[S,M]=(0,i.eJ)(r),E=S&&b,{mediaData:R,loadProgress:k}=(0,Ts.Z)((0,d.Ti)(n,m),!E),N=C||R,T=Bs(n,N),{loadProgress:A}=(0,Ts.Z)((0,d.Ti)(n,"download"),!f,(0,d.kG)(n,"download")),{isUploading:B,isTransferring:x,transferProgress:L}=(0,d.Sc)(n,u||(f?A:k),E&&!N),O=!1===(0,Jt.Z)(S),U=(0,bs.Z)(N),{shouldRender:F,transitionClassNames:q}=(0,Xe.Z)(x,void 0,O,"slow"),{shouldRender:D,transitionClassNames:$}=(0,Xe.Z)(!N&&!S),j=(0,i.I4)((()=>{B?Z&&Z(n):N?y&&y(n.id):M((e=>!e))}),[N,B,n,Z,y]),G=(0,d.B4)(n);(0,i.bt)((()=>{if(!p)return;const e=P.current.closest(".message-content");N?Ls(N,G,0,l,w).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(a.s2,"")})):e.classList.add("has-appendix-thumb")}),[N,G,p,c,l,w]);const{width:H,height:_,isSmall:z}=h||Xn(n,o),V=(0,Fe.Z)("media-inner",!B&&!g&&"interactive",z&&"small-image",H===_&&"square-image"),W=I?`aspect-ratio: ${(H/_).toFixed(3)}/ 1`:"",J=h?`width: ${H}px; height: ${_}px; left: ${h.x}px; top: ${h.y}px;${W}`:"";return i.ZP.createElement("div",{id:t,ref:P,className:V,style:J,onClick:B?void 0:j},i.ZP.createElement("canvas",{ref:T,className:"thumbnail",style:`width: ${H}px; height: ${_}px;${W}`}),i.ZP.createElement("img",{src:N,className:`full-media ${U}`,width:H,height:_,alt:"",draggable:!v}),v&&i.ZP.createElement("span",{className:"protector"}),F&&!D&&i.ZP.createElement("div",{className:`media-loading ${q}`},i.ZP.createElement(Os.Z,{progress:L,onClick:B?j:void 0})),D&&i.ZP.createElement("i",{className:(0,Fe.Z)("icon-download",$)}),x&&i.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*L),"%"))};var Fs=n(12019),qs=n(46898),Ds=n(21747);function $s(){return $s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},$s.apply(this,arguments)}const js=e=>{var t;let{id:n,message:a,observeIntersection:o,noAvatars:r,canAutoLoad:c,canAutoPlay:l,uploadProgress:u,lastSyncTime:m,dimensions:h,onClick:g,onCancelUpload:p,isDownloading:f,isProtected:v,withAspectRatio:I}=e;const w=(0,i.sO)(null),y=(0,i.sO)(null),Z=(0,d.b7)(a)||(0,d.Cg)(a),P=Z.blobUrl,C=(0,Hn.Op)(w,o),[b,S]=(0,i.eJ)(c),M=Boolean(b&&C&&m),[E,R]=(0,i.eJ)(l),k=(0,on.Z)((0,d.Ti)(a,"pictogram"),!(C&&m),(0,d.kG)(a,"pictogram"),m),N=(0,bs.Z)(k),{mediaData:T,loadProgress:A}=(0,Ts.Z)((0,d.Ti)(a,"inline"),!M,(0,d.kG)(a,"inline"),m),B=P||T,x=Boolean(C&&B),L=Bs(a,k),{loadProgress:O}=(0,Ts.Z)((0,d.Ti)(a,"download"),!f,(0,d.kG)(a,"download"),m),{isBuffered:U,bufferingHandlers:F}=(0,Fs.Z)(!c),{isUploading:q,isTransferring:D,transferProgress:$}=(0,d.Sc)(a,u||(f?O:A),M&&!U||f),j=!1===(0,Jt.Z)(b),{shouldRender:G,transitionClassNames:_}=(0,Xe.Z)(D,void 0,j),{shouldRender:z,transitionClassNames:V}=(0,Xe.Z)(b&&!E&&!G),[W,J]=(0,i.eJ)(0),X=(0,i.I4)((e=>{J(Math.max(0,e.currentTarget.currentTime-1))}),[]),Y=(null===(t=y.current)||void 0===t?void 0:t.duration)||Z.duration||0,K=(0,d.B4)(a),Q=(0,d.MF)(a),{width:ee,height:te}=h||(0,sn.GC)(Z,K,Q,r);(0,Ds.Z)(y,x),(0,qs.Z)(y,[x]);const ne=(0,i.I4)((()=>{q?p&&p(a):f?(0,s.Sv)().cancelMessageMediaDownload({message:a}):B?B&&!E?(R(!0),y.current.play()):g&&g(a.id):S((e=>!e))}),[q,f,B,E,g,p,a]),se=(0,Fe.Z)("media-inner dark",!q&&"interactive"),ae=I?`aspect-ratio: ${(ee/te).toFixed(3)}/ 1`:"",ie=h?`width: ${ee}px; height: ${te}px; left: ${h.x}px; top: ${h.y}px;${ae}`:"";return i.ZP.createElement("div",{ref:w,id:n,className:se,style:ie,onClick:q?void 0:ne},i.ZP.createElement("canvas",{ref:L,className:"thumbnail",style:`width: ${ee}px; height: ${te}px;${ae}`}),i.ZP.createElement("img",{src:k,className:(0,Fe.Z)("thumbnail",N),style:`width: ${ee}px; height: ${te}px;${ae}`,alt:"",draggable:!v}),x&&i.ZP.createElement("video",$s({ref:y,className:"full-media",width:ee,height:te,autoPlay:E,muted:!0,loop:!0,playsInline:!0},F,{draggable:!v,onTimeUpdate:X,style:ae}),i.ZP.createElement("source",{src:B})),v&&i.ZP.createElement("span",{className:"protector"}),z&&i.ZP.createElement("i",{className:(0,Fe.Z)("icon-large-play",V)}),G&&i.ZP.createElement("div",{className:(0,Fe.Z)("media-loading",_)},i.ZP.createElement(Os.Z,{progress:$,onClick:ne})),!b&&i.ZP.createElement("i",{className:"icon-download"}),D?i.ZP.createElement("span",{className:"message-transfer-progress"},q||f?`${Math.round(100*$)}%`:"..."):i.ZP.createElement("div",{className:"message-media-duration"},Z.isGif?"GIF":(0,H.k9)(Math.max(Y-W,0))))};var Gs=n(6272);const Hs=(0,s.c$)(((e,t)=>{let{contact:n}=t;const{countryList:{phoneCodes:s}}=e;return{user:(0,c.dy)(e,n.userId),phoneCodeList:s}}))((e=>{let{contact:t,user:n,phoneCodeList:a}=e;const{openChat:o}=(0,s.Sv)(),{firstName:r,lastName:c,phoneNumber:l,userId:d}=t,u="0"!==d,m=(0,i.I4)((()=>{o({id:d})}),[o,d]);return i.ZP.createElement("div",{className:(0,Fe.Z)("Contact",u&&"interactive"),onClick:u?m:void 0},i.ZP.createElement(kn.Z,{size:"large",user:n,text:r||c}),i.ZP.createElement("div",{className:"contact-info"},i.ZP.createElement("div",{className:"contact-name"},r," ",c),i.ZP.createElement("div",{className:"contact-phone"},(0,Gs.WZ)(a,l))))}));var _s=n(20230),zs=n(51218),Vs=n(14434),Ws=n(96937);function Js(e,t){return t>0?(e/t*100).toFixed():0}const Xs=e=>{let{answer:t,voteResults:n,totalVoters:s,maxVotersCount:a,correctResults:o,shouldAnimate:r}=e;const c=n&&n.find((e=>e.option===t.option)),l=0===o.length||-1!==o.indexOf(t.option),d=o.length>0&&l||(null==c?void 0:c.isChosen),u=c?Js(c.votersCount,s||0):0,[m,h]=(0,i.eJ)(r?0:u),g=(0,i.sO)(null),p=c?Js(c.votersCount,a||0):0,f=m!==u;if((0,i.d4)((()=>{r&&h(u)}),[r,u]),(0,i.d4)((()=>{const e=g.current;if(e&&r){const t=e.firstElementChild,n=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",n):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${n}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[f,r]),!n||!c)return;const v=`width: ${p}%; transform:scaleX(${f?0:1})`;return i.ZP.createElement("div",{className:"PollOption",dir:"ltr"},i.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",d&&i.ZP.createElement("span",{className:(0,Fe.Z)("poll-option-chosen",!l&&"wrong",r&&"animate")},i.ZP.createElement("i",{className:l?"icon-check":"icon-close"}))),i.ZP.createElement("div",{className:"poll-option-right"},i.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,Mn.Z)(t.text)),i.ZP.createElement("div",{className:(0,Fe.Z)("poll-option-answer",d&&!l&&"wrong")},i.ZP.createElement("div",{className:"poll-option-corner",ref:g}),i.ZP.createElement("div",{className:"poll-option-line",style:v}))))},Ys=(0,i.X$)((0,s.c$)(((e,t)=>{let{poll:n}=t;const{recentVoterIds:s}=n.results,{serverTimeOffset:a,users:{byId:i}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:i,serverTimeOffset:a}:{}}))((e=>{let{message:t,poll:n,recentVoterIds:a,usersById:o,onSendVote:r,serverTimeOffset:c}=e;const{loadMessage:l,openPollResults:d,requestConfetti:u}=(0,s.Sv)(),{id:m,chatId:h}=t,{summary:g,results:p}=n,[f,v]=(0,i.eJ)(!1),[I,w]=(0,i.eJ)([]),[y,Z]=(0,i.eJ)(!1),[P,C]=(0,i.eJ)(!1),[b,S]=(0,i.eJ)(!g.closed&&g.closeDate&&g.closeDate>0?Math.min(g.closeDate-Math.floor(Date.now()/1e3)+c,g.closePeriod):0),M=(0,i.sO)(null),{results:E,totalVoters:R}=p,k=E&&E.some((e=>e.isChosen)),N=!g.closed&&!k,T=!N&&g.isPublic&&Number(p.totalVoters)>0,A=N&&g.multipleChoice,B=E?Math.max(...E.map((e=>e.votersCount))):R,x=E?E.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],L=g.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(g.quiz&&g.closePeriod&&b<=0)})));(0,i.d4)((()=>{var e;const t=null===(e=n.results.results)||void 0===e?void 0:e.find((e=>e.isChosen));f&&t&&(t.isCorrect&&u(),v(!1))}),[f,n.results.results,u]),(0,i.d4)((()=>{b>0&&setTimeout((()=>S(b-1)),1e3);const e=M.current;if(e){const t=12*Math.PI,n=e.lastElementChild,s=e.firstElementChild;if(b<=5&&e.classList.add("hurry-up"),n&&s){const e=(g.closePeriod-b)/g.closePeriod*t;s.textContent=(0,H.k9)(b),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,H.k9)(b)}</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>`}}),[b,g.closePeriod]),(0,i.d4)((()=>{g.quiz&&(b<=0||k&&!g.closed)&&l({chatId:h,messageId:m})}),[h,b,k,l,m,g.closed,g.quiz]),(0,i.d4)((()=>{let e;return g.quiz&&!g.closed&&g.closePeriod&&g.closePeriod>0&&(e=window.setTimeout((()=>{l({chatId:h,messageId:m})}),1e3*g.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[N,h,l,m,g.closePeriod,g.closed,g.quiz]);const O=(0,i.Ye)((()=>a?a.reduce(((e,t)=>{const n=o[t];return n&&e.push(n),e}),[]):[]),[o,a]),U=(0,i.I4)((e=>{w([e]),v(!0),C(!0),r([e])}),[r]),F=(0,i.I4)((e=>{w(e)}),[]),q=(0,i.I4)((()=>{v(!0),C(!0),r(I)}),[r,I]),D=(0,i.I4)((()=>{d({chatId:h,messageId:m})}),[h,m,d]),$=(0,i.I4)((()=>{Z(!0)}),[]),j=(0,i.I4)((()=>{Z(!1),C(!1)}),[]);(0,i.d4)((()=>{P&&k&&g.quiz&&p.results&&n.results.solution&&(p.results.find((e=>e.isChosen&&e.isCorrect))||Z(!0))}),[k,P,p.results,g.quiz,n.results.solution]);const G=(0,rt.Z)();return i.ZP.createElement("div",{className:"Poll",dir:G.isRtl?"auto":"ltr"},y&&n.results.solution&&i.ZP.createElement(Ws.Z,{message:(0,_s.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:j,containerId:"#middle-column-portals"}),i.ZP.createElement("div",{className:"poll-question"},(0,Mn.Z)(g.question,["emoji","br"])),i.ZP.createElement("div",{className:"poll-type"},G(function(e){return void 0===e.isPublic?" ":e.closed?"FinalResults":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.isPublic?"PublicPoll":"AnonymousPoll"}(g)),O.length>0&&i.ZP.createElement("div",{className:"poll-recent-voters"},O.map((e=>i.ZP.createElement(kn.Z,{size:"micro",user:e,noVideo:!0})))),b>0&&N&&i.ZP.createElement("div",{ref:M,className:"poll-countdown"}),g.quiz&&n.results.solution&&!N&&i.ZP.createElement(pt.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:y,onClick:$,ariaLabel:"Show Solution"},i.ZP.createElement("i",{className:"icon-lamp"}))),N&&i.ZP.createElement("div",{className:"poll-answers"},A?i.ZP.createElement(zs.Z,{options:L,onChange:F,disabled:t.isScheduled||f,loadingOptions:f?I:void 0,round:!0}):i.ZP.createElement(Vs.Z,{name:`poll-${m}`,options:L,onChange:U,disabled:t.isScheduled||f,loadingOption:f?I[0]:void 0})),!N&&i.ZP.createElement("div",{className:"poll-results"},g.answers.map((function(e){return i.ZP.createElement(Xs,{key:e.option,shouldAnimate:P||!N,answer:e,voteResults:E,totalVoters:R,maxVotersCount:B,correctResults:x})}))),!T&&!A&&i.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,n){return n?e(t?"Answer":"Vote",n,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(G,g.quiz,p.totalVoters)),A&&i.ZP.createElement(pt.Z,{isText:!0,disabled:0===I.length,size:"tiny",onClick:q},G("PollSubmitVotes")),T&&i.ZP.createElement(pt.Z,{isText:!0,size:"tiny",onClick:D},G("PollViewResults")))})));var Ks=n(48035),Qs=n(10088);const ea=(0,i.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,canAutoPlay:o,inPreview:r,lastSyncTime:c,isDownloading:l=!1,isProtected:u,theme:m,onMediaClick:h,onCancelMediaTransfer:g}=e;const p=(0,d.s1)(t);let f=!1;if(null!=p&&p.photo&&!p.video){const{width:e,height:n}=Xn(t);f=e===n}const v=(0,i.I4)((()=>{h()}),[h]);if(!p)return;const{siteName:I,url:w,displayUrl:y,title:Z,description:P,photo:C,video:b}=p,S=(C||b)&&h&&!f,M=(0,Ks.Z)(P,170),E=(0,Fe.Z)("WebPage",r&&"in-preview",f&&"with-square-photo",!C&&!b&&!r&&"without-media",b&&"with-video");return i.ZP.createElement("div",{className:E,"data-initial":(I||y)[0],dir:"auto"},C&&!b&&i.ZP.createElement(Us,{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,size:f?"pictogram":"inline",nonInteractive:!S,onClick:S?v:void 0,onCancelUpload:g,isDownloading:l,isProtected:u,withAspectRatio:!0,theme:m}),i.ZP.createElement("div",{className:"WebPage-text"},i.ZP.createElement(Qs.Z,{className:"site-name",url:w,text:I||y}),!r&&Z&&i.ZP.createElement("p",{className:"site-title"},(0,Mn.Z)(Z)),M&&i.ZP.createElement("p",{className:"site-description"},(0,Mn.Z)(M,["emoji","br"]))),!r&&b&&i.ZP.createElement(js,{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,canAutoPlay:o,lastSyncTime:c,onClick:S?v:void 0,onCancelUpload:g,isDownloading:l,isProtected:u,withAspectRatio:!0}))}));var ta=n(9937),na=n(17921);const sa=(0,i.X$)((e=>{var t,n;let{message:s,shouldAffectAppendix:o,isInSelectMode:r,isSelected:c,theme:l}=e;const u=(0,i.sO)(null),m=(0,rt.Z)(),h=(0,d.eO)(s),{title:g,text:p,amount:f,currency:v,isTest:I,photo:w}=h,y=(0,on.Z)((0,d.O9)(w));return(0,i.bt)((()=>{if(!o)return;const e=u.current.closest(".message-content");y&&Ls(y,!1,0,c,l).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(a.s2,"")}))}),[o,y,r,c,l]),i.ZP.createElement("div",{ref:u,className:"Invoice"},g&&i.ZP.createElement("p",{className:"title"},(0,Mn.Z)(g)),p&&i.ZP.createElement("div",null,(0,Mn.Z)(p,["emoji","br"])),i.ZP.createElement("div",{className:"description "+(w?"has-image":"")},y&&i.ZP.createElement("img",{className:"invoice-image",src:y,alt:"",crossOrigin:"anonymous"}),!y&&w&&i.ZP.createElement(na.Z,{width:null===(t=w.dimensions)||void 0===t?void 0:t.width,height:null===(n=w.dimensions)||void 0===n?void 0:n.height,forceAspectRatio:!0}),i.ZP.createElement("p",{className:"description-text"},(0,ta.x)(f,v,m.code),I&&i.ZP.createElement("span",null,m("PaymentTestInvoice")))))}));var aa=n(28183);const ia=new Map(Object.entries({"building/medical":"#43b3f4","building/gym":"#43b3f4","education/cafeteria":"#f7943f","travel/bedandbreakfast":"#9987ff","travel/hotel":"#9987ff","travel/hostel":"#9987ff","travel/resort":"#9987ff","travel/hotel_bar":"#e56dd6",arts_entertainment:"#e56dd6",building:"#6e81b2",education:"#a57348",event:"#959595",food:"#f7943f",home:"#00aeef",nightlife:"#e56dd6",parks_outdoors:"#6cc039",shops:"#ffb300",travel:"#1c9fff",work:"#ad7854"})),oa=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"],ra=n.p+"map-pin.7b3c3e60ee24795e4bd2.svg",ca=1e-4,la={width:400,height:300,zoom:16,scale:2},da={__html:'<svg version="1.1" class="round-pin" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve"><g><circle cx="32" cy="32" r="24.5"/><path d="M32,8c13.23,0,24,10.77,24,24S45.23,56,32,56S8,45.23,8,32S18.77,8,32,8 M32,7C18.19,7,7,18.19,7,32s11.19,25,25,25 s25-11.19,25-25S45.81,7,32,7L32,7z"/></g><g><polygon points="29.38,57.67 27.4,56.08 30.42,54.42 32,51.54 33.58,54.42 36.6,56.08 34.69,57.61 32,60.73"/><path d="M32,52.58l1.07,1.95l0.14,0.26l0.26,0.14l2.24,1.22l-1.33,1.06l-0.07,0.06l-0.06,0.07L32,59.96l-2.24-2.61l-0.06-0.07 l-0.07-0.06l-1.33-1.06l2.24-1.22l0.26-0.14l0.14-0.26L32,52.58 M32,50.5l-1.94,3.56L26.5,56l2.5,2l3,3.5l3-3.5l2.5-2l-3.56-1.94 L32,50.5L32,50.5z"/></g></svg>'},ua=(0,i.X$)((e=>{let{message:t,peer:n,lastSyncTime:s,isInSelectMode:o,isSelected:r,theme:c,serverTimeOffset:l}=e;const u=(0,i.sO)(null),m=(0,i.sO)(null),h=(0,rt.Z)(),g=(0,We.Z)(),f=(0,d.nf)(t),{type:v,geo:I}=f,w=(0,p.b)(l),y=(0,d.$R)(t,w),Z="geoLive"!==v||y?void 0:t.date+f.period-w,[P,C]=(0,i.eJ)(I),b="venue"===v||"geoLive"===v&&!y,{width:S,height:M,zoom:E,scale:R}=la,k=Boolean(s)&&(0,d.k6)(P,S,M,E,R),N=(0,on.Z)(k),T=(0,Jt.Z)(N),A=N||T,B=n&&(0,d.YC)(n.id),x=n&&B?n:void 0,L=n&&!B?n:void 0,O=(0,d.B4)(t),U=(0,i.Ye)((()=>{if("geoLive"!==v||!P.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=P;return t/function(e,t){return 156543.03392*Math.cos(e*(Math.PI/180))/2**t}(e,E)}),[v,P,E]),F=(0,i.I4)((e=>{if("geoLive"!==v)return;const n=24*Math.PI,s=e.lastElementChild,a=e.firstElementChild,i=t.date+f.period-(0,p.b)(l),o=(1-i/f.period)*n,r=(0,H.mB)(h,1e3*i);s&&a?(a.textContent=r,s.firstElementChild.setAttribute("stroke-dashoffset",`-${o}`)):e.innerHTML=`\n <span class="geo-countdown-text">${r}</span>\n <svg width="32px" height="32px">\n <circle cx="16" cy="16" r="12" class="geo-countdown-progress" transform="rotate(-90, 16, 16)"\n stroke-dasharray="${n} ${n}"\n stroke-dashoffset="-${o}"\n />\n </svg>`}),[v,t.date,f,l,h]);return(0,i.bt)((()=>{m.current&&F(m.current)}),[F]),(0,i.bt)((()=>{if(b)return;const e=u.current.closest(".message-content");A&&Ls(A,O,0,r,c).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(a.s2,"")}))}),[O,o,r,c,A,b]),(0,i.d4)((()=>{Math.abs(I.lat-P.lat)<ca&&Math.abs(I.long-P.long)<ca?P.accuracyRadius!==I.accuracyRadius&&C({...P,accuracyRadius:I.accuracyRadius}):C(I)}),[I,P]),(0,aa.Z)((()=>{g()}),y?void 0:1e3*(Z||0)),(0,Dn.Z)((()=>{const e=m.current;e&&F(e)}),Z?1e3:void 0),i.ZP.createElement("div",{ref:u,className:"Location media-inner interactive",onClick:()=>{var e;const t=function(e,t,n){return`http://maps.google.com/maps/place/${e}+${t}/@${e},${t},${n}z`}(P.lat,P.long,E);null===(e=window.open(t,"_blank","noopener"))||void 0===e||e.focus()}},i.ZP.createElement("div",{className:"map-wrapper"},A?i.ZP.createElement("img",{className:"full-media map",src:A,alt:"Location on a map",width:la.width,height:la.height}):i.ZP.createElement(na.Z,{width:S,height:M}),function(){if(A)return i.ZP.createElement(i.ZP.Fragment,null,Boolean(U)&&!y&&i.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*U}px; height: ${2*U}px`}),function(){const e=(0,Fe.Z)("pin",v,y&&"expired");if("geoLive"===v)return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:da},i.ZP.createElement(kn.Z,{chat:L,user:x,className:"location-avatar"}),void 0!==f.heading&&i.ZP.createElement("div",{className:"direction",style:`--direction: ${f.heading}deg`}));if("venue"===v){const t=function(e){return e?ia.get(e)||ia.get(e.split("/")[0])||oa[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%oa.length)]:"#008df2";var t}(f.venueType),n=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(f.venueType);return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:da,style:`--pin-color: ${t}`},i.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return i.ZP.createElement("img",{className:e,src:ra,alt:""})}())}()),function(){if(b)return"venue"===v?i.ZP.createElement("div",{className:"location-info"},i.ZP.createElement("div",{className:"location-info-title"},f.title),i.ZP.createElement("div",{className:"location-info-subtitle"},f.address)):"geoLive"===v?i.ZP.createElement("div",{className:"location-info"},i.ZP.createElement("div",{className:"location-info-title"},h("AttachLiveLocation")),i.ZP.createElement("div",{className:"location-info-subtitle"},(0,H.dJ)(h,w,t.editDate)),!y&&i.ZP.createElement("div",{className:"geo-countdown",ref:m})):void 0}())})),ma=(0,i.X$)((e=>{let{message:t,canAutoLoadMedia:n,lastSyncTime:a}=e;const{clickBotInlineButton:o}=(0,s.Sv)(),r=t.content.game,{title:c,description:l}=r,u=Boolean(a)&&(0,d.N)(r),m=Boolean(a)&&(0,d.Wc)(r),h=(0,on.Z)(u,!n),g=(0,on.Z)(m,!n);return i.ZP.createElement("div",{className:"Game"},i.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{o({messageId:t.id,button:t.inlineButtons[0][0]})}},!h&&!g&&i.ZP.createElement(na.Z,{className:"skeleton preview-content"}),h&&i.ZP.createElement("img",{className:"preview-content",src:h,alt:c}),g&&i.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,disablePictureInPicture:!0,autoPlay:!0,loop:!0,src:g})),i.ZP.createElement("div",{className:"title"},c),!(0,d.UD)(t)&&i.ZP.createElement("div",{className:"description"},l))}));function ha(e){return(0,i.X$)((0,s.c$)(((e,t)=>{const{message:n}=t;return{isInSelectMode:(0,c.CA)(e),isSelected:(0,c.vk)(e,n.id)}}))((t=>{const{isInSelectMode:n,isSelected:a,message:o,dimensions:r}=t,{toggleMessageSelection:c}=(0,s.Sv)(),l=(0,i.I4)((e=>{e.stopPropagation(),c({messageId:o.id,withShift:null==e?void 0:e.shiftKey})}),[c,o]),d=(0,i.Ye)((()=>{const{dimensions:e,onClick:s}=t;return{...t,isInSelectMode:n,isSelected:a,dimensions:{...e,x:0,y:0},onClick:n?void 0:s}}),[t,n,a]);return i.ZP.createElement("div",{className:(0,Fe.Z)("album-item-select-wrapper",a&&"is-selected"),style:r?`left: ${r.x}px; top: ${r.y}px;`:"",onClick:n?l:void 0},n&&i.ZP.createElement("div",{className:"message-select-control"},a&&i.ZP.createElement("i",{className:"icon-select"})),i.ZP.createElement(e,d))})))}const ga=ha(Us),pa=ha(js),fa=(0,s.c$)(((e,t)=>{let{album:n}=t;const{chatId:s}=n.mainMessage,a=(0,c.Pu)(e),i=(0,c.xs)(e,s);return{theme:a,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:i}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:a,lastSyncTime:o,isOwn:r,isProtected:l,albumLayout:u,onMediaClick:m,uploadsById:h,activeDownloadIds:g,theme:p}=e;const{cancelSendingMessage:f}=(0,s.Sv)(),v=t.messages.length,I=(0,i.I4)((e=>{f({chatId:e.chatId,messageId:e.id})}),[f]),{width:w,height:y}=u.containerStyle;return i.ZP.createElement("div",{className:"Album",style:`width: ${w}px; height: ${y}px;`},t.messages.map((function(e,t){const{photo:f,video:w}=(0,d.qp)(e),y=h[(0,d.KK)(e)],Z=null==y?void 0:y.progress,{dimensions:P,sides:C}=u.layout[t],b=(0,c.bH)((0,s.Rd)(),e),S=(0,c.__)((0,s.Rd)(),e);if(f){const s=a&&(r?t===v-1:Boolean(8&C&&4&C));return i.ZP.createElement(ga,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersection:n,canAutoLoad:b,shouldAffectAppendix:s,uploadProgress:Z,dimensions:P,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})}if(w)return i.ZP.createElement(pa,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersection:n,canAutoLoad:b,canAutoPlay:S,uploadProgress:Z,lastSyncTime:o,dimensions:P,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})})))}));function va(){return va=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},va.apply(this,arguments)}let Ia;const wa=e=>{let{message:t,observeIntersection:n,canAutoLoad:a,lastSyncTime:r,isDownloading:c}=e;const l=(0,i.sO)(null),u=(0,i.sO)(null),m=(0,i.sO)(null),h=t.content.video,g=(0,Hn.Op)(l,n),[p,f]=(0,i.eJ)(a),v=Boolean(p&&g&&r),{mediaData:I,loadProgress:w}=(0,Ts.Z)((0,d.Ti)(t,"inline"),!v,(0,d.kG)(t,"inline"),r),{loadProgress:y}=(0,Ts.Z)((0,d.Ti)(t,"download"),!c,o.IU.BlobUrl,r),Z=Bs(t,I),{isBuffered:P,bufferingHandlers:C}=(0,Fs.Z)(),b=p&&!P||c,S=!1===(0,Jt.Z)(p),M=(0,bs.Z)(I),{shouldRender:E,transitionClassNames:k}=(0,Xe.Z)(b||!P,void 0,S),[N,T]=(0,i.eJ)(!1),[A,B]=(0,i.eJ)(0);(0,i.d4)((()=>{if(!N)return;const e=sn.Rj/2,t=2*(e-6)*Math.PI,n=t-A*t,s=m.current,a=u.current,i=a.firstElementChild;i?i.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):a.innerHTML=`\n <svg width="${sn.Rj}px" height="${sn.Rj}px">\n <circle cx="${e}" cy="${e}" r="${e-6}" class="progress-circle"\n transform="rotate(-90, ${e}, ${e})"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="${t}"\n />\n </svg>`,B(s.currentTime/s.duration)}),[N,A]);const x=Boolean(I&&g),L=(0,i.I4)((()=>{m.current&&(T(!1),B(0),(0,Ss.Z)(m.current),(0,R.T2)((()=>{u.current.innerHTML=""})))}),[]),O=(0,i.I4)((()=>{var e;null===(e=Ia)||void 0===e||e(),Ia=L}),[L]);(0,i.d4)((()=>{m.current&&(x?(0,Ss.Z)(m.current):m.current.pause())}),[x]),(0,Ds.Z)(m,x),(0,qs.Z)(m,[I]);const U=(0,i.I4)((()=>{if(!I)return void f((e=>!e));if(c)return void(0,s.Sv)().cancelMessageMediaDownload({message:t});const e=m.current;N?e.paused?((0,Ss.Z)(e),(0,gn.Es)()):e.pause():(O(),e.pause(),e.currentTime=0,(0,Ss.Z)(e),(0,gn.Es)(),T(!0))}),[O,N,c,I,t]),F=(0,i.I4)((e=>{const t=e.currentTarget;B(t.currentTime/t.duration)}),[]),q=(0,Fe.Z)("full-media",M);return i.ZP.createElement("div",{ref:l,className:"RoundVideo media-inner",onClick:U},i.ZP.createElement("div",{className:"thumbnail-wrapper"},i.ZP.createElement("canvas",{ref:Z,className:"thumbnail",style:`width: ${sn.Rj}px; height: ${sn.Rj}px`})),I&&i.ZP.createElement("div",{className:"video-wrapper"},i.ZP.createElement("video",va({ref:m,className:q,width:sn.Rj,height:sn.Rj,autoPlay:!0,disablePictureInPicture:!0,muted:!N,loop:!N,playsInline:!0,onEnded:N?L:void 0},C,{onTimeUpdate:N?F:void 0}),i.ZP.createElement("source",{src:I}))),i.ZP.createElement("div",{className:"progress",ref:u}),E&&i.ZP.createElement("div",{className:`media-loading ${k}`},i.ZP.createElement(Os.Z,{progress:c?y:w})),!I&&!p&&i.ZP.createElement("i",{className:"icon-download"}),i.ZP.createElement("div",{className:"message-media-duration"},N?(0,H.k9)(m.current.currentTime):(0,H.k9)(h.duration),(!N||m.current.paused)&&i.ZP.createElement("i",{className:"icon-muted"})))},ya=e=>{let{message:t,onClick:n}=e;const s=(0,rt.Z)();return i.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>i.ZP.createElement("div",{className:"row"},e.map((e=>i.ZP.createElement(pt.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===e.type,onClick:()=>n({messageId:t.id,button:e})},i.ZP.createElement("span",{className:"inline-button-text"},(0,Mn.Z)(s(e.text))),(e=>{const{type:t}=e;switch(t){case"url":if(!a.FS.test(e.url))return i.ZP.createElement("i",{className:"icon-arrow-right"});break;case"urlAuth":return i.ZP.createElement("i",{className:"icon-arrow-right"});case"buy":case"receipt":return i.ZP.createElement("i",{className:"icon-cart"});case"switchBotInline":return i.ZP.createElement("i",{className:"icon-share-filled"});case"webView":case"simpleWebView":return i.ZP.createElement("i",{className:"icon-webapp"})}})(e))))))))},Za=(0,i.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:a}=(0,s.Sv)(),o=(0,rt.Z)(),{threadId:r,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h}=t,g=(0,i.I4)((()=>{a({id:c,threadId:r})}),[a,c,r]),p=(0,i.Ye)((()=>{if(null==h||!h.length)return;const{users:{byId:e},chats:{byId:t}}=(0,s.Rd)();return h.map((n=>(0,d.YC)(n)?e[n]:t[n])).filter(Boolean)}),[h]);if(void 0===l)return;const f=Boolean(m&&u&&m<u);return i.ZP.createElement("div",{"data-cnt":(0,Ke.bi)(l),className:(0,Fe.Z)("CommentButton",f&&"has-unread",n&&"disabled"),dir:o.isRtl?"rtl":"ltr",onClick:g},i.ZP.createElement("i",{className:"icon-comments-sticker"}),(!p||0===p.length)&&i.ZP.createElement("i",{className:"icon-comments"}),p&&p.length>0&&i.ZP.createElement("div",{className:"recent-repliers",dir:o.isRtl?"rtl":"ltr"},p.map((e=>i.ZP.createElement(kn.Z,{key:e.id,size:"small",user:(0,d.YC)(e.id)?e:void 0,chat:(0,d.YC)(e.id)?void 0:e,noVideo:!0})))),i.ZP.createElement("div",{className:"label",dir:"auto"},l?o("Comments",l,"i"):o("LeaveAComment")),i.ZP.createElement("i",{className:"icon-next"}))})),Pa=(0,i.X$)((e=>{let{reaction:t,message:n,activeReaction:a,availableReactions:o}=e;const{sendReaction:r}=(0,s.Sv)(),{recentReactions:c}=n.reactions,l=(0,i.Ye)((()=>{if(!c||t.count>3)return;const e=(0,s.Rd)().users.byId;return c.filter((e=>e.reaction===t.reaction)).map((t=>e[t.userId])).filter(Boolean)}),[t,c]),d=(0,i.I4)((()=>{r({reaction:t.isChosen?void 0:t.reaction,chatId:n.chatId,messageId:n.id})}),[n,t,r]);return i.ZP.createElement(pt.Z,{className:(0,Fe.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},i.ZP.createElement(Ps,{activeReaction:a,reaction:t.reaction,availableReactions:o}),null!=l&&l.length?i.ZP.createElement("div",{className:"avatars"},l.map((e=>i.ZP.createElement(kn.Z,{user:e,size:"micro",noVideo:!0})))):(0,Ke.bi)(t.count))})),Ca=(0,i.X$)((e=>{let{message:t,isOutside:n,activeReaction:s,availableReactions:a,metaChildren:o}=e;return i.ZP.createElement("div",{className:(0,Fe.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>i.ZP.createElement(Pa,{key:e.reaction,reaction:e,message:t,activeReaction:s,availableReactions:a}))),o)})),ba=(0,i.X$)((e=>{let{phoneCall:t,message:n,chatId:a}=e;const{requestCall:o}=(0,s.Sv)(),r=(0,rt.Z)(),{isOutgoing:c,isVideo:l,reason:d}=t,u="missed"===d,m="busy"===d&&!c,g=(0,i.I4)((()=>{o({isVideo:l,userId:a})}),[a,l,o]),p=(0,i.Ye)((()=>l?m?"CallMessageVideoIncomingDeclined":u?c?"CallMessageVideoOutgoingMissed":"CallMessageVideoIncomingMissed":c?"CallMessageVideoOutgoing":"CallMessageVideoIncoming":m?"CallMessageIncomingDeclined":u?c?"CallMessageOutgoingMissed":"CallMessageIncomingMissed":c?"CallMessageOutgoing":"CallMessageIncoming"),[m,u,c,l]),f=(0,i.Ye)((()=>t.duration?(0,H.J_)(r,t.duration):void 0),[r,t.duration]),v=(0,H.mr)(r,1e3*n.date);return i.ZP.createElement("div",{className:"vDeypQzM845_JE14qGId"},i.ZP.createElement(pt.Z,{size:"smaller",color:"translucent",round:!0,ripple:!0,onClick:g,className:"OtJi45yywgt1n_y6VPkE",disabled:!h.Bi,ariaLabel:r(c?"CallAgain":"CallBack")},i.ZP.createElement("i",{className:l?"icon-video-outlined":"icon-phone"})),i.ZP.createElement("div",{className:"_0BG8sziTJQ_NYrsspMg"},i.ZP.createElement("div",{className:"LWVSvxVjeEyHPBrCb2sD"},r(p)),i.ZP.createElement("div",{className:"nuIsoCP15iD4ETadJ44R"},i.ZP.createElement("i",{className:(0,Fe.Z)("icon-arrow-right","wrUkWet7enyh9L1iPKvA",u&&"V5tKkKZpcY5yq_f5nO8l",!c&&"e0Vhbj8gfzQn1zJQoFLK")}),i.ZP.createElement("span",{className:"TJ2lYkLxYUie3A0JqtMR"},f?r("CallMessageWithDuration",[v,f]):v))))}));var Sa=n(78780);const Ma={__html:'<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>'},Ea={__html:'<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>'},Ra=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s,a;const{focusedMessage:i,forwardMessages:o,lastSyncTime:r,serverTimeOffset:l}=e,{message:u,album:m,withSenderName:h,withAvatar:g,threadId:p,messageListType:f,isLastInDocumentGroup:v}=t,{id:I,chatId:w,viaBotId:y,replyToChatId:Z,replyToMessageId:P,isOutgoing:C,threadInfo:b,forwardInfo:S,transcriptionId:M}=u,E=(0,c.Z1)(e,w),R=(0,c.FM)(e,w),k=(0,d.pK)(w),N=E&&(0,d.eA)(E),T=null==E?void 0:E.username,A=!R&&(0,d.Ul)(u),B=h||g||A,x=(0,c.Ur)(e,u),L=(0,c.cv)(e,u),O=y?(0,c.dy)(e,y):void 0,U=p?(0,c.qS)(e,w,p):void 0,F=u.id===U,q=P===U,D=P&&!q?(0,c.hj)(e,k&&Z?Z:w,P):void 0,$=D&&(0,c.Bz)(e,D,Boolean(S)),j=(0,c.uZ)(e,u),G="thread"===f&&(m?m.messages.some((t=>(0,c._X)(e,t))):(0,c._X)(e,u)),{direction:H,noHighlight:_,isResizingContainer:z}=G&&i||{},V=o.messageIds&&o.messageIds.includes(I),{query:W}=(0,c.n5)(e)||{},J=(0,d._O)(u),X=J&&((0,c.zB)(e,J)||(0,c.CP)(e,J))?J:void 0;let Y;Y=null!=m&&m.messages?m.messages.every((t=>{let{id:n}=t;return(0,c.vk)(e,n)})):(0,c.vk)(e,I);const{canReply:K}="thread"===f&&(0,c._k)(e,u,p)||{},Q=(0,c.te)(e,u),ee=b?(0,c.tZ)(e,b.chatId,b.threadId)||b:void 0,te=Boolean(u.groupedId)&&!u.isInAlbum,ne=te?(0,c.xH)(e,w,u.groupedId)[0]:void 0,se=te?v?(0,c.hj)(e,w,ne):void 0:u,ae=null==E||null===(n=E.unreadReactions)||void 0===n?void 0:n.includes(u.id);return{theme:(0,c.Pu)(e),chatUsername:T,forceSenderName:A,sender:x,canShowSender:B,originSender:L,botSender:O,shouldHideReply:q,isThreadTop:F,replyMessage:D,replyMessageSender:$,isInDocumentGroup:te,isProtected:(0,c.EV)(e,u),isFocused:G,isForwarding:V,reactionMessage:se,isChatWithSelf:R,isRepliesChat:k,isChannel:N,canReply:K,lastSyncTime:r,serverTimeOffset:l,highlight:W,animatedEmoji:X,isInSelectMode:(0,c.CA)(e),isSelected:Y,isGroupSelected:Boolean(u.groupedId)&&!u.isInAlbum&&(0,c.a6)(e,w,u.groupedId),threadId:p,isDownloading:Q,isPinnedList:"pinned"===f,canAutoLoadMedia:(0,c.bH)(e,u),canAutoPlayMedia:(0,c.__)(e,u),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,c.yB)(e),threadInfo:ee,availableReactions:e.availableReactions,defaultReaction:(0,d.CI)(u)?void 0:(0,c.q6)(e,w),activeReaction:se&&e.activeReactions[se.id],activeEmojiInteractions:e.activeEmojiInteractions,...C&&{outgoingStatus:(0,c.dT)(e,u,"scheduled"===f)},..."number"==typeof j&&{uploadProgress:j},...G&&{focusDirection:H,noFocusHighlight:_,isResizingContainer:z},hasUnreadReaction:ae,isTranscribing:void 0!==M&&(null===(s=e.transcriptions[M])||void 0===s?void 0:s.isPending),transcribedText:void 0!==M?null===(a=e.transcriptions[M])||void 0===a?void 0:a.text:void 0,isPremium:(0,c.wV)(e)}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:a,observeIntersectionForMedia:r,observeIntersectionForAnimatedStickers:c,album:l,noAvatars:u,withAvatar:g,withSenderName:f,areReactionsInMeta:v,noComments:I,appearanceOrder:w,isFirstInGroup:y,isPremium:Z,isLastInGroup:P,isFirstInDocumentGroup:C,isLastInDocumentGroup:b,isTranscribing:S,transcribedText:M,isLastInList:E,theme:R,forceSenderName:k,sender:N,canShowSender:T,originSender:A,botSender:B,isThreadTop:x,shouldHideReply:L,replyMessage:O,replyMessageSender:U,outgoingStatus:F,uploadProgress:q,isInDocumentGroup:D,isProtected:$,isFocused:j,focusDirection:G,noFocusHighlight:H,isResizingContainer:_,isForwarding:z,isChatWithSelf:V,isRepliesChat:W,isChannel:J,canReply:X,lastSyncTime:Y,serverTimeOffset:K,highlight:Q,animatedEmoji:ee,isInSelectMode:te,isSelected:ne,isGroupSelected:se,threadId:ae,reactionMessage:ie,availableReactions:oe,defaultReaction:re,activeReaction:ce,activeEmojiInteractions:le,messageListType:de,isPinnedList:ue,isDownloading:me,canAutoLoadMedia:he,canAutoPlayMedia:ge,shouldLoopStickers:pe,autoLoadFileMaxSizeMb:fe,threadInfo:ve,hasUnreadReaction:Ie,memoFirstUnreadIdRef:we}=e;const{toggleMessageSelection:ye,clickBotInlineButton:Ze,disableContextMenuHint:Pe,animateUnreadReaction:Ce,focusLastMessage:be}=(0,s.Sv)(),Se=(0,i.sO)(null),Me=(0,i.sO)(null),Ee=(0,i.sO)(null),Re=(0,rt.Z)(),[ke,Ne]=(0,i.eJ)(!1),[Te,Ae,Be]=(0,at.Z)();(0,Hn._N)(Me,a);const{isContextMenuOpen:xe,contextMenuPosition:Le,handleBeforeContextMenu:Oe,handleContextMenu:Ue,handleContextMenuClose:qe,handleContextMenuHide:De}=(0,Vn.Z)(Se,h.$b&&te,!0,h.wZ);(0,i.d4)((()=>{xe&&Pe()}),[xe,Pe]);const $e=w<=0,[je,Ge]=(0,at.Z)($e);(0,i.d4)((()=>{$e||setTimeout(Ge,10*w)}),[w,Ge,$e]);const{transitionClassNames:He}=(0,Xe.Z)(je,void 0,$e,!1),{id:_e,chatId:ze,forwardInfo:Ve,viaBotId:We,isTranscriptionError:Je}=t,Ye=(0,d.CI)(t),Ke=(0,d.B4)(t),Qe="scheduled"===de||t.isScheduled,et=(0,d.ss)(t)&&!L,tt=Boolean(ve)&&"thread"===de,nt=(0,d.$D)(t),st=ee,it=(null==ie?void 0:ie.reactions)&&!(0,d.JE)(ie.reactions),ot=Ve&&(!V||Qe)&&!W&&!Ve.isLinkedChannelPost&&!nt,ct=Boolean(l)&&l.messages.length>1,lt=D&&!C,dt=D&&!b,ut=void 0!==Le,mt=!(ut||te||z||dt),ht=J&&!Qe&&!$,gt=Boolean(ue||Ve&&(Ve.isChannelPost||V&&!Ke||W)&&Ve.fromMessageId),ft=(0,i.I4)(((e,t)=>{ye({messageId:_e,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...ct&&{childMessageIds:l.messages.map((e=>{let{id:t}=e;return t}))}})}),[ye,_e,ct,l]),vt=T?N:void 0,It=Boolean(!ke&&(Je||M)),wt=Ve&&(V||W||!vt)?A:vt,yt=Ve?A:vt,{handleMouseDown:Zt,handleClick:Pt,handleContextMenu:Ct,handleDoubleClick:bt,handleContentDoubleClick:St,handleMouseMove:Mt,handleSendQuickReaction:Et,handleMouseLeave:Rt,isSwiped:kt,isQuickReactionVisible:Nt,handleDocumentGroupMouseEnter:Tt}=ls(ft,Se,_e,0,Boolean(te),Boolean(X),Boolean($),Ue,Oe,ze,ut,Ee,Ke,dt),{handleAvatarClick:At,handleSenderClick:Bt,handleViaBotClick:xt,handleReplyClick:Lt,handleMediaClick:Ot,handleAudioPlay:Ut,handleAlbumMediaClick:Ft,handleMetaClick:qt,handleReadMedia:Dt,handleCancelUpload:$t,handleVoteSend:jt,handleGroupForward:Gt,handleForward:Ht,handleFocus:_t,handleFocusForwarded:zt,handleDocumentGroupSelectAll:Vt}=function(e,t,n,a,r,c,l,d,u,h,g,p,f){const{openChat:v,showNotification:I,focusMessage:w,openMediaViewer:y,openAudioPlayer:Z,markMessagesRead:P,cancelSendingMessage:C,sendPollVote:b,openForwardMenu:S,focusMessageInComments:M}=(0,s.Sv)(),{id:E,forwardInfo:R,replyToMessageId:k,replyToChatId:N,replyToTopMessageId:T,groupedId:A}=n,B=(0,i.I4)((()=>{g&&v({id:g.id})}),[g,v]),x=(0,i.I4)((()=>{p?l&&null!=R&&R.channelPostId?w({chatId:p.id,messageId:R.channelPostId}):v({id:p.id}):I({message:e("HidAccount")})}),[l,w,R,e,v,p,I]),L=(0,i.I4)((()=>{f&&v({id:f.id})}),[f,v]),O=(0,i.I4)((()=>{w({chatId:u&&N?N:a,threadId:r,messageId:k,replyMessageId:u&&N?void 0:E})}),[w,u,N,a,r,k,E]),U=(0,i.I4)((()=>{y({chatId:a,threadId:r,mediaId:E,origin:d?m.bZ.ScheduledInline:m.bZ.Inline})}),[a,r,E,y,d]),F=(0,i.I4)((()=>{Z({chatId:a,messageId:E})}),[a,E,Z]),q=(0,i.I4)((e=>{y({chatId:a,threadId:r,mediaId:e,origin:d?m.bZ.ScheduledAlbum:m.bZ.Album})}),[a,r,y,d]),D=(0,i.I4)((()=>{P({messageIds:[E]})}),[E,P]),$=(0,i.I4)((()=>{C({chatId:a,messageId:E})}),[C,a,E]),j=(0,i.I4)((e=>{b({chatId:a,messageId:E,options:e})}),[a,E,b]),G=(0,i.I4)((()=>{S({fromChatId:a,groupedId:A})}),[S,a,A]),H=(0,i.I4)((()=>{if(h&&h.messages){const e=h.messages.map((e=>{let{id:t}=e;return t}));S({fromChatId:a,messageIds:e})}else S({fromChatId:a,messageIds:[E]})}),[h,S,a,E]),_=(0,i.I4)((()=>{w({chatId:a,threadId:o._f,messageId:E})}),[w,a,E]),z=(0,i.I4)((()=>{c?w({chatId:R.fromChatId,groupedId:A,groupedChatId:a}):u&&N?M({chatId:N,threadId:T,messageId:R.fromMessageId}):w({chatId:R.fromChatId,messageId:R.fromMessageId})}),[c,u,N,w,R,A,a,M,T]),V=(0,i.I4)((e=>{e.stopPropagation(),t(e,A)}),[t,A]);return{handleAvatarClick:B,handleSenderClick:x,handleViaBotClick:L,handleReplyClick:O,handleMediaClick:U,handleAudioPlay:F,handleAlbumMediaClick:q,handleMetaClick:V,handleReadMedia:D,handleCancelUpload:$,handleVoteSend:j,handleGroupForward:G,handleForward:H,handleFocus:_,handleFocusForwarded:z,handleDocumentGroupSelectAll:V}}(Re,ft,t,ze,ae,D,ot,Qe,W,l,wt,yt,B);(0,i.d4)((()=>{E&&It&&M&&be()}),[be,E,M,It]);const Wt=(0,Fe.Z)("Message message-list-item",y&&"first-in-group",$&&"is-protected",P&&"last-in-group",C&&"first-in-document-group",b&&"last-in-document-group",E&&"last-in-list",Ke&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",et&&"has-reply",ut&&"has-menu-open",j&&!H&&"focused",z&&"is-forwarding",t.isDeleting&&"is-deleting",D&&"is-in-document-group",ct&&"is-album",t.hasUnreadMention&&"has-unread-mention",ne&&"is-selected",te&&"is-in-selection-mode",x&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",kt&&"is-swiped",He,(Boolean(ce)||Te)&&"has-active-reaction"),{text:Jt,photo:Xt,video:Kt,audio:Qt,voice:en,document:tn,sticker:nn,contact:on,poll:rn,webPage:cn,invoice:ln,location:dn,action:un,game:mn}=(0,d.qp)(t),{phoneCall:hn}=un||{},gn=ve&&!dt&&"thread"===de&&!I,pn=!h.$b&&!hn&&!te&&re&&!dt,fn=function(e){let{hasReply:t,customShape:n,isLastInGroup:s,asForwarded:a,hasThread:i,forceSenderName:o,hasComments:r,hasActionButton:c,hasReactions:l,isGeoLiveActive:u,withVoiceTranscription:m}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:h,photo:g,video:p,audio:f,voice:v,document:I,poll:w,webPage:y,contact:Z,location:P,invoice:C}=(0,d.qp)(e),b=["message-content"],S=g||p||P,M=h||"venue"===(null==P?void 0:P.type)||u,E=S&&!M,R=Boolean(e.viaBotId);return Wn(n)?b.push(`emoji-only emoji-only-${n}`):M&&b.push("text"),c&&b.push("has-action-button"),n&&(b.push("custom-shape"),null!=p&&p.isRound&&b.push("round"),r&&b.push("has-comments")),S?b.push("media"):f?b.push("audio"):v?(b.push("voice"),m&&b.push("with-voice-transcription")):I?b.push("document"):Z?b.push("contact"):w?b.push("poll"):y&&(b.push("web-page"),(y.photo||y.video)&&b.push("media")),C&&b.push("invoice"),a&&b.push("is-forwarded"),t&&b.push("is-reply"),i&&b.push("has-replies"),l&&b.push("has-reactions"),R&&b.push("is-via-bot"),o&&b.push("force-sender-name"),n||(b.push("has-shadow"),S&&r&&b.push("has-background"),(t||a||!E||R||o)&&b.push("has-solid-background"),s&&(g||P&&!M||!E)&&b.push("has-appendix")),b.join(" ")}(t,{hasReply:et,customShape:nt,isLastInGroup:P,asForwarded:ot,hasThread:tt,forceSenderName:k,hasComments:ve&&(null==ve?void 0:ve.messagesCount)>0,hasActionButton:ht||gt,hasReactions:it,isGeoLiveActive:"geoLive"===(null==dn?void 0:dn.type)&&!(0,d.$R)(t,(0,p.b)(K)),withVoiceTranscription:It}),vn=fn.includes("has-appendix"),In=(0,an.X)(t,Q,Wn(nt),void 0,void 0,$);let wn,yn;wn=hn||dt?"none":!In||st||cn?"standalone":"in-text",v?yn="in-meta":it?nt||(Xt||Kt||st)&&!In?yn="outside":ot?(wn="standalone",yn="inside"):yn="inside":yn="none",(0,Yt.Z)(W&&t.replyToChatId?t.replyToChatId:ze,et?t.replyToMessageId:void 0,O,t.id),as(Se,ze,j,G,H,_),(0,i.d4)((()=>{const e=Me.current;Ie&&e&&(0,ms.P)(e)&&Ce({messageIds:[_e]})}),[Ie,_e,Ce]);let Zn,Pn="",Cn=!1;const bn=(0,i.Ye)((()=>ct?es(Ke,Boolean(ot),Boolean(u),l):void 0),[ct,Ke,ot,u,l]),Sn=ot?28:0;if(ct||!Xt&&!Kt)bn&&(Zn=Math.max(Jn(Boolean(Jt),gn),bn.containerStyle.width),Zn-bn.containerStyle.width>18&&(Cn=!0));else{let e;Xt?e=Xn(t,u).width:Kt&&(e=Kt.isRound?sn.Rj:Xn(t,u).width),e&&(Zn=Math.max(Jn(Boolean(Jt),gn),e),Zn-e>18&&(Cn=!0))}Zn&&(Pn=`width: ${Zn+Sn}px`);const En=J&&t.adminTitle||!ot&&(null==Ve?void 0:Ve.adminTitle)||void 0,Rn=(0,i.Ye)((()=>En?ss(En):void 0),[En]);function Nn(){const e=i.ZP.createElement(Cs,{message:t,reactionMessage:ie,outgoingStatus:F,signature:En,withReactions:"in-meta"===yn,withReactionOffset:"inside"===yn,availableReactions:oe,activeReaction:ce,onClick:qt});return"inside"!==yn?e:i.ZP.createElement(Ca,{activeReaction:ce,message:ie,metaChildren:e,availableReactions:oe})}return i.ZP.createElement("div",{ref:Se,id:(0,d.d0)(t.id),className:Wt,style:Rn?`--meta-safe-author-width: ${Rn}px`:void 0,"data-message-id":_e,onMouseDown:Zt,onClick:Pt,onContextMenu:Ct,onDoubleClick:bt,onMouseEnter:dt?Tt:void 0,onMouseMove:pn?Mt:void 0,onMouseLeave:pn||dt?Rt:void 0},i.ZP.createElement("div",{ref:Me,className:"bottom-marker","data-message-id":_e,"data-last-message-id":l?l.messages[l.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention||void 0,"data-has-unread-reaction":Ie||void 0}),!D&&i.ZP.createElement("div",{className:"message-select-control"},ne&&i.ZP.createElement("i",{className:"icon-select"})),b&&i.ZP.createElement("div",{className:(0,Fe.Z)("message-select-control group-select",se&&"is-selected"),onClick:Vt},se&&i.ZP.createElement("i",{className:"icon-select"})),g&&function(){const e=wt&&(0,d.YC)(wt.id),t=wt&&e?wt:void 0,n=wt&&!e?wt:void 0,s=!wt&&Ve?Ve.hiddenUserName:void 0;return i.ZP.createElement(kn.Z,{size:"small",user:t,chat:n,text:s,lastSyncTime:Y,onClick:t||n?At:void 0,observeIntersection:r})}(),i.ZP.createElement("div",{className:(0,Fe.Z)("message-content-wrapper",fn.includes("text")&&"can-select-text")},i.ZP.createElement("div",{ref:Ee,className:fn,style:Pn,dir:"auto"},ot&&!lt&&i.ZP.createElement("div",{className:"message-title"},Re("ForwardedMessage")),function(){const e=(0,Fe.Z)("content-inner",ot&&"forwarded-message",et&&"reply-message",Cn&&"no-media-corners"),n=P&&!In&&!ot&&!tt,s=(0,Fe.Z)("text-content","in-text"===wn&&"with-meta",F&&"with-outgoing-icon");return i.ZP.createElement("div",{className:e,onDoubleClick:St,dir:"auto"},function(){if(nt&&!We||!(f&&!(Xt||Kt||dn)||ot||We||k)||lt||et&&nt)return;let e,n;return!yt||nt&&We?null!=Ve&&Ve.hiddenUserName&&(e=Ve.hiddenUserName):(e=(0,d.OU)(Re,yt),ot||(n=`color-${(0,d.Rs)(yt)}`)),i.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?i.ZP.createElement("span",{className:(0,Fe.Z)("interactive",n),onClick:Bt,dir:"auto"},(0,Mn.Z)(e)):B?void 0:" ",B&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"via"},Re("ViaBot")),i.ZP.createElement("span",{className:"interactive",onClick:xt},(0,Mn.Z)(`@${B.username}`))),null!=Ve&&Ve.isLinkedChannelPost?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},Re("DiscussChannel")):t.adminTitle&&!J?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.adminTitle):void 0)}(),et&&i.ZP.createElement(fs,{message:O,noUserColors:Ke,isProtected:$,sender:U,observeIntersection:r,onClick:Lt}),nn&&i.ZP.createElement(Ms,{message:t,observeIntersection:r,observeIntersectionForPlaying:c,shouldLoop:pe,lastSyncTime:Y,shouldPlayEffect:nn.hasEffect&&(we.current&&_e>=we.current||Ye)||void 0,onPlayEffect:Ae,onStopEffect:Be}),ee&&i.ZP.createElement(Ns,{emoji:ee,withEffects:(0,d.YC)(ze),isOwn:Ke,observeIntersection:r,lastSyncTime:Y,forceLoadPreview:Ye,messageId:_e,chatId:ze,activeEmojiInteractions:le}),ct&&i.ZP.createElement(fa,{album:l,albumLayout:bn,observeIntersection:r,isOwn:Ke,isProtected:$,hasCustomAppendix:n,lastSyncTime:Y,onMediaClick:Ft}),hn&&i.ZP.createElement(ba,{message:t,phoneCall:hn,chatId:ze}),!ct&&Xt&&i.ZP.createElement(Us,{message:t,observeIntersection:r,noAvatars:u,canAutoLoad:he,uploadProgress:q,shouldAffectAppendix:n,onClick:Ot,onCancelUpload:$t,isDownloading:me,isProtected:$,theme:R}),!ct&&Kt&&Kt.isRound&&i.ZP.createElement(wa,{message:t,observeIntersection:r,canAutoLoad:he,lastSyncTime:Y,isDownloading:me}),!ct&&Kt&&!Kt.isRound&&i.ZP.createElement(js,{message:t,observeIntersection:r,noAvatars:u,canAutoLoad:he,canAutoPlay:ge,uploadProgress:q,lastSyncTime:Y,onClick:Ot,onCancelUpload:$t,isDownloading:me,isProtected:$}),(Qt||en)&&i.ZP.createElement(Is.ZP,{theme:R,message:t,origin:m.Cr.Inline,uploadProgress:q,lastSyncTime:Y,isSelectable:D,isSelected:ne,noAvatars:u,onPlay:Ut,onReadMedia:!en||Ke&&!V?void 0:Dt,onCancelUpload:$t,isDownloading:me,isTranscribing:S,isTranscriptionHidden:ke,isTranscribed:Boolean(M),isTranscriptionError:Je,canDownload:!$,onHideTranscription:Ne,canTranscribe:Z}),tn&&i.ZP.createElement(vs.Z,{message:t,observeIntersection:r,canAutoLoad:he,autoLoadFileMaxSizeMb:fe,uploadProgress:q,isSelectable:D,isSelected:ne,onMediaClick:Ot,onCancelUpload:$t,isDownloading:me}),on&&i.ZP.createElement(Hs,{contact:on}),rn&&i.ZP.createElement(Ys,{message:t,poll:rn,onSendVote:jt}),mn&&i.ZP.createElement(ma,{message:t,canAutoLoadMedia:he,lastSyncTime:Y}),It&&i.ZP.createElement("p",{className:(0,Fe.Z)("transcription",!ke&&Je&&"transcription-error"),dir:"auto"},Je?Re("NoWordsRecognized"):S&&M?i.ZP.createElement(Sa.Z,{content:M}):M),!st&&In&&i.ZP.createElement("p",{className:s,dir:"auto"},In,"in-text"===wn&&Nn()),cn&&i.ZP.createElement(ea,{message:t,observeIntersection:r,noAvatars:u,canAutoLoad:he,canAutoPlay:ge,lastSyncTime:Y,onMediaClick:Ot,onCancelMediaTransfer:$t,isDownloading:me,isProtected:$,theme:R}),ln&&i.ZP.createElement(sa,{message:t,shouldAffectAppendix:n,isInSelectMode:te,isSelected:ne,theme:R}),dn&&i.ZP.createElement(ua,{message:t,lastSyncTime:Y,isInSelectMode:te,isSelected:ne,theme:R,peer:N,serverTimeOffset:K}))}(),!dt&&"standalone"===wn&&Nn(),mt&&ht?i.ZP.createElement(pt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:Re("lng_context_forward_msg"),onClick:b?Gt:Ht},i.ZP.createElement("i",{className:"icon-share-filled"})):mt&&gt?i.ZP.createElement(pt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:ue?_t:zt},i.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,gn&&i.ZP.createElement(Za,{threadInfo:ve,disabled:I}),vn&&i.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:Ke?Ma:Ea}),pn&&i.ZP.createElement("div",{className:(0,Fe.Z)("quick-reaction",Nt&&!ce&&"visible"),onClick:Et},i.ZP.createElement(ys.Z,{reaction:re}))),t.inlineButtons&&i.ZP.createElement(ya,{message:t,onClick:Ze}),"outside"===yn&&i.ZP.createElement(Ca,{message:ie,isOutside:!0,activeReaction:ce,availableReactions:oe})),Le&&i.ZP.createElement(gs,{isOpen:xe,anchor:Le,message:t,album:l,chatUsername:n,messageListType:de,onClose:qe,onCloseAnimationEnd:De}))}))),ka=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"AboutAdsModal",!t);return n?i.ZP.createElement(n,e):void 0})),Na=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),Ta=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;const s=(0,c.fS)(e,n),{chatId:a,isBot:i}=s||{};return{message:s,bot:a&&i?(0,c.dy)(e,a):void 0,channel:!i&&a?(0,c.Z1)(e,a):void 0}}))((e=>{let{chatId:t,message:n,containerRef:a,bot:o,channel:r}=e;const{viewSponsoredMessage:c,openChat:l,openChatByInvite:u,startBot:m,focusMessage:g}=(0,s.Sv)(),p=(0,rt.Z)(),f=(0,i.sO)(null),v=(0,i.sO)(null),I=Boolean(n),{observe:w}=(0,Hn.S1)({rootRef:a,debounceMs:200,threshold:1}),{isContextMenuOpen:y,contextMenuPosition:Z,handleBeforeContextMenu:P,handleContextMenu:C,handleContextMenuClose:b,handleContextMenuHide:S}=(0,Vn.Z)(f,h.$b,!0,h.wZ),[M,E,R]=(0,at.Z)(!1);(0,i.d4)((()=>I?w(v.current,(e=>{e.isIntersecting&&c({chatId:t})})):void 0),[t,I,w,c]);const k=(0,i.I4)((()=>{n&&(n.chatInviteHash?u({hash:n.chatInviteHash}):n.channelPostId?g({chatId:n.chatId,messageId:n.channelPostId}):(l({id:n.chatId}),n.startParam&&m({botId:n.chatId,param:n.startParam})))}),[g,n,l,u,m]);if(n)return i.ZP.createElement("div",{ref:f,key:"sponsored-message",className:"SponsoredMessage Message open",onMouseDown:e=>{(0,On.q)(e),P(e)},onContextMenu:C},i.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},i.ZP.createElement("div",{className:"content-inner",dir:"auto"},i.ZP.createElement("div",{className:"message-title",dir:"ltr"},o&&(0,Mn.Z)((0,d.Js)(o)||""),r&&(0,Mn.Z)(n.chatInviteTitle||(0,d.U)(p,r,o)||"")),i.ZP.createElement("p",{className:"text-content with-meta",dir:"auto",ref:v},i.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,_s.H)(n.text.text,n.text.entities)),i.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},i.ZP.createElement("span",{className:"message-signature"},n.isRecommended?p("Message.RecommendedLabel"):p("SponsoredMessage")))),i.ZP.createElement(pt.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:k,className:"SponsoredMessage__button"},p(n.isBot?"Conversation.ViewBot":n.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))),Z&&i.ZP.createElement(Na,{isOpen:y,anchor:Z,message:n,onAboutAds:E,onClose:b,onCloseAnimationEnd:S}),i.ZP.createElement(ka,{isOpen:M,onClose:R}))}))),Aa=(0,i.X$)((e=>{let{isCurrentUserPremium:t,chatId:n,messageIds:o,messageGroups:r,isViewportNewest:c,isUnread:l,withUsers:u,areReactionsInMeta:p,noAvatars:f,containerRef:v,anchorIdRef:I,memoUnreadDividerBeforeIdRef:w,memoFirstUnreadIdRef:y,threadId:Z,type:P,isReady:C,isScrollingRef:b,isScrollPatchNeededRef:S,threadTopMessageId:M,hasLinkedChat:E,isSchedule:k,noAppearanceAnimation:N,onFabToggle:T,onNotchToggle:A}=e;const{openHistoryCalendar:B}=(0,s.Sv)(),{observeIntersectionForMedia:x,observeIntersectionForReading:L,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:a,markMentionsRead:i,animateUnreadReaction:o}=(0,s.Sv)(),{observe:r}=(0,Hn.S1)({rootRef:t,throttleMs:_n,margin:zn}),{observe:c,freeze:l,unfreeze:d}=(0,Hn.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let s=0;const r=[],c=[];t.forEach((e=>{const{isIntersecting:t,target:n}=e;if(!t)return;const{dataset:a}=n,i=Number(a.lastMessageId||a.messageId);i>s&&(s=i),a.hasUnreadMention&&r.push(i),a.hasUnreadReaction&&c.push(i)})),n.current&&s>=n.current&&a({maxId:s}),r.length&&i({messageIds:r}),c.length&&o({messageIds:c})}));(0,$e.Z)(l,d);const{observe:u}=(0,Hn.S1)({rootRef:t,throttleMs:_n});return{observeIntersectionForMedia:r,observeIntersectionForReading:c,observeIntersectionForAnimatedStickers:u}}(P,v,y),{backwardsTriggerRef:U,forwardsTriggerRef:F,fabTriggerRef:q}=function(e,t,n,o,r,c,l,d,u,g){const{loadViewportMessages:p}=(0,s.Sv)(),[f,v]=(0,i.Ye)((()=>"thread"===e?[(0,R.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,R.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,n]),I=(0,i.sO)(null),w=(0,i.sO)(null),y=(0,i.sO)(null);function Z(){if(!d)return;if(!n||!n.length)return c(!1),void l(!1);if(!o)return c(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:s,scrollTop:a}=t.current,i=Math.round(s-a-e),u=i<=1;c(r?!u:!(i<=50)),l(!u)}const{observe:P}=(0,Hn.S1)({rootRef:t,margin:h.gZ},(e=>{if(!v||!f)return;if(n[0]>a.MP)return;const t=e.find((e=>{let{isIntersecting:t}=e;return t}));if(!t)return;const{target:s}=t;"backwards-trigger"===s.className?(h.i4&&u.current&&n.length<=a.hT&&(g.current=!0),f()):"forwards-trigger"===s.className&&v()}));(0,Hn._N)(I,P),(0,Hn._N)(w,P);const{observe:C,freeze:b,unfreeze:S}=(0,Hn.S1)({rootRef:t,margin:100},Z);(0,Hn._N)(y,C);const{observe:M,freeze:E,unfreeze:k}=(0,Hn.S1)({rootRef:t,margin:1},Z);return(0,Hn._N)(y,M),(0,Ge.Z)((()=>{d&&Z()}),[d]),(0,Ge.Z)((()=>{b(),E(),setTimeout((()=>{k(),S()}),250)}),[n]),{backwardsTriggerRef:I,forwardsTriggerRef:w,fabTriggerRef:y}}(P,v,o,c,l,T,A,C,b,S),D=(0,rt.Z)(),$=i.ZP.createElement("div",{className:(0,Fe.Z)("unread-divider","local-action-message"),key:"unread-messages"},i.ZP.createElement("span",null,D("UnreadMessages"))),j=N?0:r.reduce(((e,t)=>e+t.senderGroups.flat().length),0);let G=0;const _=r.map(((e,t,n)=>{const s=e.senderGroups.map(((e,s,a)=>{var o;if(1===e.length&&!xn(e[0])&&(0,d.Lo)(e[0])&&(null===(o=e[0].content.action)||void 0===o||!o.phoneCall)){const o=e[0],r=s===a.length-1&&t===n.length-1;return(0,g.oA)([o.id===w.current&&$,i.ZP.createElement(ps,{key:o.id,message:o,observeIntersection:L,appearanceOrder:j-++G,isLastInList:r})])}let r;return e.map(((o,c)=>{const l=xn(o)?o.mainMessage:o,m=xn(o)?o:void 0,h=(0,d.B4)(l),v=xn(o),C=e[c+1];l.previousLocalId&&I.current===(0,d.d0)(l.previousLocalId)&&(I.current=(0,d.d0)(l.id));const b=!v&&l.groupedId?l.groupedId:void 0,S=C&&!xn(C)?C.groupedId:void 0,R={isFirstInGroup:0===c,isLastInGroup:c===e.length-1,isFirstInDocumentGroup:Boolean(b&&b!==r),isLastInDocumentGroup:Boolean(b&&b!==S),isLastInList:c===e.length-1&&s===a.length-1&&t===n.length-1};r=b;const k=(0,d.KK)(l),N=(0,d.jM)(l)?`${l.date}_${k}`:k;return(0,g.oA)([l.id===w.current&&$,i.ZP.createElement(Ra,{key:N,message:l,observeIntersectionForBottom:L,observeIntersectionForMedia:x,observeIntersectionForAnimatedStickers:O,album:m,noAvatars:f,withAvatar:R.isLastInGroup&&u&&!h&&!(l.id===M),withSenderName:R.isFirstInGroup&&u&&!h,areReactionsInMeta:p,threadId:Z,messageListType:P,noComments:!1===E,appearanceOrder:j-++G,isFirstInGroup:R.isFirstInGroup,isLastInGroup:R.isLastInGroup,isFirstInDocumentGroup:R.isFirstInDocumentGroup,isLastInDocumentGroup:R.isLastInDocumentGroup,isLastInList:R.isLastInList,memoFirstUnreadIdRef:y}),l.id===M&&i.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},i.ZP.createElement("span",null,D("DiscussionStarted")))])})).flat()}));return i.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:On.q,teactFastList:!0},i.ZP.createElement("div",{className:(0,Fe.Z)("sticky-date",!k&&"interactive"),key:"date-header",onMouseDown:On.q,onClick:k?void 0:()=>B({selectedAt:e.datetime})},i.ZP.createElement("span",{dir:"auto"},k&&e.originalDate===a.t4&&D("MessageScheduledUntilOnline"),k&&e.originalDate!==a.t4&&D("MessageScheduledOn",(0,H.j1)(D,e.datetime,void 0,!0)),!k&&(0,H.j1)(D,e.datetime))),s.flat())}));return i.ZP.createElement("div",{className:"messages-container",teactFastList:!0},i.ZP.createElement("div",{ref:U,key:"backwards-trigger",className:"backwards-trigger"}),_.flat(),!t&&c&&i.ZP.createElement(Ta,{key:n,chatId:n,containerRef:v}),i.ZP.createElement("div",{ref:F,key:"forwards-trigger",className:"forwards-trigger"}),i.ZP.createElement("div",{ref:q,key:"fab-trigger",className:"fab-trigger"}))}));var Ba=n(73547);const xa=(0,i.X$)((0,s.c$)(((e,t)=>{let{userId:n}=t;const{stickers:s}=e.stickers.greeting,a=(0,d.db)(n)+(0,d.db)(e.currentUserId),i=null!=s&&s.length?s[a%s.length]:void 0,o=(0,c.Z1)(e,n);return o?{sticker:i,lastUnreadMessageId:o.lastMessage&&o.lastMessage.id!==o.lastReadInboxMessageId?o.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((e=>{let{sticker:t,connectionState:n,lastUnreadMessageId:a}=e;const{loadGreetingStickers:o,sendMessage:r,markMessageListRead:c}=(0,s.Sv)(),l=(0,rt.Z)(),d=(0,i.sO)(null),{observe:u}=(0,Hn.S1)({rootRef:d,debounceMs:200});(0,i.d4)((()=>{t||"connectionStateReady"!==n||o()}),[n,o,t]),(0,i.d4)((()=>{"connectionStateReady"===n&&a&&c({maxId:a})}),[n,c,a]);const m=(0,i.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return i.ZP.createElement("div",{className:"ContactGreeting",ref:d},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement("p",{className:"title",dir:"auto"},l("Conversation.EmptyPlaceholder")),i.ZP.createElement("p",{className:"description",dir:"auto"},l("Conversation.GreetingText")),i.ZP.createElement("div",{className:"sticker"},t&&i.ZP.createElement(Ba.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large",noContextMenu:!0,isCurrentUserPremium:!0}))))}))),La=(0,i.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:s}=e;const a=(0,rt.Z)();return"scheduled"===n?function(e){return i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(a):t?function(e){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement("i",{className:"icon icon-cloud-download"}),i.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),i.ZP.createElement("ul",{className:"description"},i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(a):s?function(e){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},i.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),i.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),i.ZP.createElement("ul",{className:"list-checkmarks"},i.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(a):i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,a("NoMessages")))})),Oa=(0,R.Ds)((e=>e()),200,!1),Ua=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s,type:a}=t;const i=(0,c.Z1)(e,n);if(!i)return{};const r=(0,c.$W)(e,n,s,a),l="scheduled"===a?(0,c.Fn)(e,n):(0,c.Zw)(e,n),u=(0,c.qS)(e,n,s);if(s!==o._f&&!(l&&u&&l[u]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=i,p=(0,c.G$)(e,n),f=s===o._f&&!r&&!i.unreadCount&&!p&&g&&!g.groupedId,v=(0,c.IK)(e,n);let I,w=!1;return(0,c.pk)(e,n)&&(v.fullInfo?I=v.fullInfo.botInfo:w=!0),{isCurrentUserPremium:(0,c.wV)(e),isChatLoaded:!0,isRestricted:m,restrictionReason:h,isChannelChat:(0,d.eA)(i),isGroupChat:(0,d.Bf)(i),isCreator:i.isCreator,isChatWithSelf:(0,c.FM)(e,n),isRepliesChat:(0,d.pK)(n),isBot:Boolean(v),messageIds:r,messagesById:l,firstUnreadId:(0,c.It)(e,n,s),isViewportNewest:"thread"!==a||(0,c.b9)(e,n,s),threadFirstMessageId:(0,c.yZ)(e,n,s),focusingId:p,isSelectModeActive:(0,c.CA)(e),isLoadingBotInfo:w,botInfo:I,threadTopMessageId:u,hasLinkedChat:i.fullInfo&&"linkedChatId"in i.fullInfo?Boolean(i.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...f&&{lastMessage:g}}}))((e=>{var t,n,o,r,l,u;let{chatId:p,threadId:f,type:v,hasTools:I,onFabToggle:w,onNotchToggle:y,isCurrentUserPremium:Z,isChatLoaded:P,isChannelChat:C,isGroupChat:b,canPost:S,isReady:M,isChatWithSelf:E,isRepliesChat:k,isCreator:N,isBot:T,messageIds:A,messagesById:B,firstUnreadId:x,isViewportNewest:L,threadFirstMessageId:O,isRestricted:U,restrictionReason:F,focusingId:q,isSelectModeActive:D,lastMessage:$,isLoadingBotInfo:j,botInfo:G,threadTopMessageId:H,hasLinkedChat:_,lastSyncTime:z,withBottomShift:V}=e;const{loadViewportMessages:W,setScrollOffset:J,loadSponsoredMessages:X,loadMessageReactions:Y,copyMessagesByIds:K}=(0,s.Sv)(),Q=(0,i.sO)(null),ee=(0,i.sO)("thread"===v&&(0,c.Vt)((0,s.Rd)(),p,f)||0),te=(0,i.sO)(),ne=(0,i.sO)(),se=(0,i.sO)(),ae=(0,i.sO)(),ie=(0,i.sO)(),oe=(0,i.sO)(),re=(0,i.sO)(!1),ce=(0,i.sO)(Boolean($)),[le,de]=(0,i.eJ)(),ue=(0,on.Z)(null!=G&&G.photo?(0,d.NF)(G.photo):void 0),me=(0,on.Z)(null!=G&&G.gif?(0,d.ym)(G.gif):void 0),he=null!=G&&G.photo?(0,d.bV)(G.photo):null!=G&&G.gif?(0,d.jC)(G.gif):void 0,ge=he&&{width:he.width/h.cL,height:he.height/h.cL},pe=Boolean(A);(0,Ge.Z)((()=>{pe&&(0,R.R3)((()=>{ce.current=!1}))}),[pe]),(0,Ge.Z)((()=>{ae.current=x}),[x]),(0,Ge.Z)((()=>{!Z&&C&&M&&z&&X({chatId:p})}),[Z,p,M,C,z]),(0,Ge.Z)((()=>{pe&&(ie.current=ae.current)}),[pe]),(0,Ge.Z)((()=>{oe.current=q}),[q]),(e=>{(0,it.y)({"Mod+C":function(t){const n=(0,$n.Z)();n&&n.length>0&&(t.preventDefault(),e({messageIds:n}))}})})(K);const fe=(0,i.Ye)((()=>{if(!A||!B)return;const e=!H||A[0]&&O!==A[0]?A:[H,...A];if(!e.length)return;const t=e.map((e=>B[e])).filter(Boolean);return Ln((0,g.Xo)(t,["date","id"]),ie.current)}),[A,B,O,H]);(0,Dn.Z)((()=>{if(!A||!B)return;const e=A.filter((e=>{var t;return null===(t=B[e])||void 0===t?void 0:t.reactions}));e.length&&Y({chatId:p,ids:e})}),15e3);const ve=(0,i.Ye)((()=>{if("thread"===v)return(0,R.Ds)((()=>W({direction:m.Uq.Around})),1e3,!0,!1)}),[W,A]),{isScrolled:Ie,updateStickyDates:we}=function(){const[e,t]=(0,at.Z)(!1),n=(0,qn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,i.I4)(((e,s)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,R.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,R.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const n=function(e,t){const n=e.querySelectorAll(".sticky-date"),s=e.scrollTop;return Array.from(n).find((e=>{const{offsetTop:n,offsetHeight:a}=e,i=n-s;return-a<=i&&i<=(t?60:10)}))}(e,s);n&&n.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,n])}}(),ye=(0,i.sO)(),Ze=(0,i.sO)(),Pe=(0,i.I4)((()=>{if(re.current)return void(re.current=!1);ye.current=!0;const e=Q.current;oe.current||we(e,I),Oa((()=>{ye.current=!1,(0,R.T2)((()=>{e.parentElement&&(ee.current=e.scrollHeight-e.scrollTop,"thread"===v&&J({chatId:p,threadId:f,scrollOffset:ee.current}))}))}))}),[we,I,v,J,p,f]);(0,i.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((e=>{let[t]=e;t.target.offsetParent&&de(t.contentRect.height)}));return e.observe(Q.current),()=>{e.disconnect()}}),[]);const{height:Ce}=(0,Vt.Z)();(0,i.d4)((()=>{Q.current.dataset.normalHeight=String(Q.current.offsetHeight)}),[Ce,S]),(0,i.d4)((()=>{if(!ve||!P||U||q)return;if(A&&A[A.length-1]>a.MP)return;const e=Q.current;(!A||A.length<a.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&ve()}),[P,A,ve,q,U]),(0,Ge.Z)((()=>{if(!A||!se.current)return;const e=se.current.filter((e=>A.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(te.current=t.id,ne.current=t.getBoundingClientRect().top)}),[A,L,le,I]),(0,jn.Z)((e=>{let[t,n,s]=e;const i=Q.current;se.current=Array.from(i.querySelectorAll(".message-list-item"));const o=A&&t&&A[A.length-1]!==t[t.length-1],r=(null==A?void 0:A[0])!==(null==t?void 0:t[0])&&(null==A?void 0:A.length)===a.hT/2+1,c=o&&!r,l=A&&oe.current===A[A.length-1],d=L&&c&&A&&A.length<a.hT/2&&!i.parentElement.classList.contains("force-messages-scroll")&&i.firstElementChild.clientHeight<=2*i.offsetHeight;d&&(i.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{i.parentElement&&i.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=i,g=ee.current,p=se.current[se.current.length-1];let f=g-(s||h);c&&(f-=p?p.offsetHeight:0);const v=L&&n&&f<=50;let w;if(c&&v&&!l&&(p&&(0,R.T2)((()=>{(0,Fn.Z)(i,p,"end",20)})),w=m-h,ee.current=Math.max(Math.ceil(m-w),h),!d))return;const y=void 0!==s&&s!==le,Z=te.current&&i.querySelector(`#${te.current}`),P=!Z&&ie.current&&i.querySelector(".unread-divider");if(v&&y){if((0,Fn.N)())return;w=m-h}else Z?(Ze.current&&(Ze.current=!1,(0,Un.z)(i)),w=u+(Z.getBoundingClientRect().top-(ne.current||0))):w=P?Math.min(P.offsetTop-(I?60:10),m-g):m-g;(0,Un.Z)(i,Math.ceil(w)),oe.current||(re.current=!0,(0,R.T2)((()=>{re.current=!1}))),ee.current=Math.max(Math.ceil(m-w),h)}),[A,L,le,I]),(0,Gn.Z)((e=>{let[t]=e;void 0!==t&&(0,Ue.YW)(200+a.fK)}),[D]);const be=(0,rt.Z)(),Se=Boolean(p&&(0,d.YC)(p)),Me=Boolean(!Se&&!C||E||k),Ee=Boolean(!Me||C),Re=(0,d.YC)(p)&&!E&&!T&&(!fe&&!$&&A&&(!se.current||0===se.current.length)||1===(null==A?void 0:A.length)&&"contactSignUp"===(null==B||null===(t=B[A[0]])||void 0===t||null===(n=t.content.action)||void 0===n?void 0:n.type)||"contactSignUp"===(null==$||null===(o=$.content)||void 0===o||null===(r=o.action)||void 0===r?void 0:r.type)),ke=b&&N&&1===(null==A?void 0:A.length)&&"chatCreate"===(null==B||null===(l=B[A[0]])||void 0===l||null===(u=l.content.action)||void 0===u?void 0:u.type),Ne=G&&!G.description,Te=(0,Fe.Z)("MessageList custom-scroll",Ee&&"no-avatars",!S&&"no-composer","pinned"===v&&"type-pinned",V&&"with-bottom-shift",D&&"select-mode-active",Ie&&"scrolled",!M&&"is-animating");return i.ZP.createElement("div",{ref:Q,className:Te,onScroll:Pe,onMouseDown:On.q},U?i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,F?F.text:"This is a private "+(C?"channel":"chat"))):G?i.ZP.createElement("div",{className:"empty"},j&&i.ZP.createElement("span",null,be("Loading")),Ne&&i.ZP.createElement("span",null,be("NoMessages")),G&&i.ZP.createElement("div",{className:"bot-info",style:ge&&`width: ${ge.width}px`},ue&&i.ZP.createElement("img",{src:ue,width:null==ge?void 0:ge.width,height:null==ge?void 0:ge.height,alt:"Bot info"}),me&&i.ZP.createElement("video",{src:me,loop:!0,autoPlay:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0}),he&&!ue&&!me&&i.ZP.createElement(na.Z,{width:null==ge?void 0:ge.width,height:null==ge?void 0:ge.height}),G.description&&i.ZP.createElement("div",{className:"bot-info-description"},i.ZP.createElement("p",{className:"bot-info-title"},be("BotInfoTitle")),(0,Mn.Z)(G.description,["br","emoji","links"])))):Re?i.ZP.createElement(xa,{userId:p}):!A||fe&&!ke?A&&fe||$?i.ZP.createElement(Aa,{isCurrentUserPremium:Z,chatId:p,messageIds:A||[$.id],messageGroups:fe||Ln([$]),isViewportNewest:Boolean(L),isUnread:Boolean(x),withUsers:Me,areReactionsInMeta:Se,noAvatars:Ee,containerRef:Q,anchorIdRef:te,memoUnreadDividerBeforeIdRef:ie,memoFirstUnreadIdRef:ae,threadId:f,type:v,isReady:M,isScrollingRef:ye,isScrollPatchNeededRef:Ze,threadTopMessageId:H,hasLinkedChat:_,isSchedule:!!fe&&"scheduled"===v,noAppearanceAnimation:!fe||!ce.current,onFabToggle:w,onNotchToggle:y}):i.ZP.createElement(Nt.Z,{color:"white",backgroundColor:"dark"}):i.ZP.createElement(La,{chatId:p,type:v,isChatWithSelf:E,isGroupChatJustCreated:ke}))}))),Fa=(0,i.X$)((e=>{let{icon:t,ariaLabelLang:n,unreadCount:s,onClick:a,onReadAll:o,className:r}=e;const c=(0,rt.Z)(),l=(0,i.sO)(null),{isContextMenuOpen:d,handleContextMenu:u,handleContextMenuClose:m,handleContextMenuHide:h}=(0,Vn.Z)(l,!o);return i.ZP.createElement("div",{className:(0,Fe.Z)("KboxtoWkfx23zfklH_Zg",r),ref:l},i.ZP.createElement(pt.Z,{color:"secondary",round:!0,className:"sgkkv3bmIMAZS9G9BHUz",onClick:a,onContextMenu:u,ariaLabel:c(n)},i.ZP.createElement("i",{className:(0,Fe.Z)("AafG9_xBi_2eJ_bFNnNg",`icon-${t}`)})),Boolean(s)&&i.ZP.createElement("div",{className:"yKN1kQ3YXf4SHHIBcotS"},(0,Ke.bi)(s)),o&&i.ZP.createElement(Bt.Z,{isOpen:d,onClose:m,onCloseAnimationEnd:h,autoClose:!0,positionX:"right",positionY:"bottom"},i.ZP.createElement(gt.Z,{icon:"readchats",onClick:o},c("MarkAllAsRead"))))})),qa=(0,i.X$)((0,s.c$)((e=>{const t=(0,c.Bt)(e);if(!t)return{};const{chatId:n,threadId:s,type:a}=t,i=(0,c.Z1)(e,n),r=i&&s===o._f&&"thread"===a;return{messageListType:a,chatId:n,reactionsCount:r?i.unreadReactionsCount:void 0,mentionsCount:r?i.unreadMentionsCount:void 0,unreadCount:r?i.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:n,messageListType:a,chatId:o,unreadCount:r,reactionsCount:c,mentionsCount:l,withExtraShift:d}=e;const{focusNextReply:u,focusNextReaction:m,focusNextMention:h,fetchUnreadReactions:g,readAllMentions:p,readAllReactions:f,fetchUnreadMentions:v}=(0,s.Sv)(),I=(0,i.sO)(null),w=Boolean(c),y=Boolean(l);(0,i.d4)((()=>{w&&o&&g({chatId:o})}),[o,g,w]),(0,i.d4)((()=>{y&&o&&v({chatId:o})}),[o,v,y]);const Z=(0,i.I4)((()=>{if(t)if("thread"===a)u();else{const e=I.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),n=t[t.length-1];if(!n)return;(0,Fn.Z)(e,n,"end",20)}}),[t,a,u]),P=(0,Fe.Z)("quM3aP53TOfurCEOYgOE",(t||Boolean(c)||Boolean(l))&&"Gutr8PrNAFFTnrIdgK_l",(Boolean(c)||Boolean(l))&&!t&&"bHOz3QboabL0RvHuj3ku",!n&&"r7RXnwv5TF4Cf2V0d5Mf",!d&&"S98OqutuQVCNVHgTrKv4");return i.ZP.createElement("div",{ref:I,className:P},w&&i.ZP.createElement(Fa,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:m,onReadAll:f,unreadCount:c}),y&&i.ZP.createElement(Fa,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:h,onReadAll:p,unreadCount:l}),i.ZP.createElement(Fa,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:Z,unreadCount:r,className:"Hoi4yrJrfBHTmvB8TPce"}))})));var Da=n(65723);const $a=1280,ja=/\.[^/.]+$/;async function Ga(e,t,s,i){const o=URL.createObjectURL(t),{type:r,size:c}=t;let l,d,u;if(a.oG.has(r))if(s){const t=await(0,zt.pt)(o),{width:n,height:s}=t,a=n>$a||s>$a;if(a||"image/jpeg"!==r){const t=await wn(o,a?$a/Math.max(n,s):1,"image/jpeg");return URL.revokeObjectURL(o),Ga(e,await(0,zt.gm)(t),!0,i)}"image/jpeg"===r&&(e=e.replace(ja,".jpg")),l={width:n,height:s}}else u=o;else if(a.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,zt.jj)(o);l={width:e,height:t,duration:n},u=await(0,zt.ud)(o)}else if(a.e7.has(r)){const{duration:e,title:t,performer:s,coverUrl:a}=await async function(e){const{fetchFromUrl:t,selectCover:s}=await n.e(8505).then(n.t.bind(n,38505,23)),a=await t(e),{common:{title:i,artist:o,picture:r},format:{duration:c}}=a,l=s(r);return{title:i,performer:o,duration:c,coverUrl:l?`data:${l.format};base64,${l.data.toString("base64")}`:void 0}}(o);d={duration:e||0,title:t,performer:s},u=a}return{blobUrl:o,filename:e,mimeType:r,size:c,quick:l,audio:d,previewBlobUrl:u,...i}}function Ha(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const n=t.getRangeAt(0);n.deleteContents();const s=n.createContextualFragment(e),a=s.lastChild;n.insertNode(s),a?(n.setStartAfter(a),n.setEndAfter(a)):n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}var _a=n(96391);let za;function Va(e){za.focus(),e.focus()}h.cj&&(za=document.createElement("input"),za.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(za));var Wa=n(64784),Ja=n(52400),Xa=n(56389),Ya=n(70971);const Ka={encoderPath:new URL(n(68973),n.b).href,reuseWorker:!0},Qa={type:"audio/ogg"};let ei,ti,ni;async function si(){return ei||(ei=n.e(1161).then(n.t.bind(n,1161,23)),ti=(await ei).default,ni=new ti(Ka)),ei}async function ai(e){await async function(){await si(),await ni.start()}();const t=Date.now();let n;const s=[],a=[];ni.ondataavailable=e=>{s.push(e)};const i=function(t,n){const s=t.sourceNode,i=s.context.createAnalyser();i.fftSize=64,s.connect(i);const o=i.frequencyBinCount,r=new Uint8Array(o);let c=!1;return function t(){if(c)return;i.getByteFrequencyData(r);const n=r.reduce(((e,t)=>e+t),0)/o/255;(t=>{a.push(255*t),e(t)})(n<.1?0:n),requestAnimationFrame(t)}(),()=>{c=!0}}(ni);return{stop:()=>new Promise(((e,o)=>{ni.onstop=()=>{e({blob:new Blob(s,Qa),duration:Math.round(((n||Date.now())-t)/1e3),waveform:a})},ni.onerror=o;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{ni.stop(),i()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{ni.pause(),n=Date.now(),i()}),e)}}}var ii=n(21262);const oi=["image/png","image/jpeg","image/gif"];let ri,ci;var li=n(72162),di=n(29295);function ui(e,t,n){const[s,a]=(0,i.eJ)(),{isFrozen:o,updateWhenUnfrozen:r}=function(){const e=(0,i.sO)(!1),t=(0,i.I4)((()=>{e.current=!0}),[]),n=(0,We.Z)(),s=(0,i.I4)((()=>{e.current&&(e.current=!1,n())}),[n]);return(0,Ue.ZP)(mi,s),{isFrozen:(0,Ue.zG)(),updateWhenUnfrozen:t}}(),c=(0,qn.Z)(t,!0);return(0,Ge.Z)((()=>{o?r():c((()=>{a(e())}))}),[...n,o]),s}function mi(){}const hi=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,gi=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,pi={username:"",query:"",canShowHelp:!1,usernameLowered:""},fi=document.createElement("div");const vi=(0,R.P2)((e=>e()),500,!0),Ii=/^[\w@]{1,32}\s?/i;var wi=n(33057);const yi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"DeleteMessageModal",!t);return n?i.ZP.createElement(n,e):void 0}));function Zi(){return Zi=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Zi.apply(this,arguments)}let Pi,Ci=!0;const bi=(0,i.X$)((e=>{let{onActivate:t,...n}=e;const s=(0,i.sO)(!1),a=(0,i.I4)((()=>{if(s.current=!0,Ci)return Ci=!1,void t();Pi&&(clearTimeout(Pi),Pi=void 0),Pi=window.setTimeout((()=>{s.current&&t()}),200)}),[t]),o=(0,i.I4)((()=>{s.current=!1}),[]);return i.ZP.createElement(pt.Z,Zi({},n,{onMouseEnter:h.$b?void 0:a,onMouseLeave:h.$b?void 0:o,onClick:t}))}));var Si=n(85655),Mi=n(56503),Ei=n(62898);const Ri="kq_1N12wqP7sbQ3EhVqO",ki=/#fff/gi,Ni=(0,i.X$)((e=>{let{icon:t,theme:n}=e;const s=(0,on.Z)((0,d.ym)(t),!1,o.IU.Text),a=(0,i.Ye)((()=>{if(!s)return"";const e="dark"===n?"rgb(170, 170, 170)":"rgb(112, 117, 121)",t=s.replace(ki,e),a=(new DOMParser).parseFromString(t,"image/svg+xml");return a.querySelectorAll("path").forEach((t=>{t.style.stroke=e,t.style.strokeWidth="0.5px"})),`data:image/svg+xml;utf8,${a.documentElement.outerHTML}`}),[s,n]);return i.ZP.createElement("i",{className:(0,Fe.Z)("JDpb9xn3FmOzR6pVNK6n",h.FW&&Ri)},i.ZP.createElement("img",{src:a,alt:"",className:(0,Fe.Z)("Bo8mxv82IZ6uf0lrclLq",h.FW&&Ri)}))})),Ti=(0,i.X$)((e=>{let{bot:t,theme:n,chatId:a,onMenuOpened:o,onMenuClosed:r}=e;const{callAttachMenuBot:c,toggleBotInAttachMenu:l}=(0,s.Sv)(),d=(0,rt.Z)(),u=(0,i.Ye)((()=>{var e;return null===(e=t.icons.find((e=>{let{name:t}=e;return"default_static"===t})))||void 0===e?void 0:e.document}),[t.icons]),[m,h,g]=(0,at.Z)(),[p,f]=(0,i.eJ)(void 0),v=(0,i.I4)((e=>{e.preventDefault();const t=e.currentTarget.getBoundingClientRect();f({x:t.right,y:t.bottom}),o(),h()}),[o,h]),I=(0,i.I4)((()=>{g(),r()}),[g,r]),w=(0,i.I4)((()=>{f(void 0)}),[]),y=(0,i.I4)((()=>{l({botId:t.id,isEnabled:!1})}),[t.id,l]);return i.ZP.createElement(gt.Z,{key:t.id,customIcon:u&&i.ZP.createElement(Ni,{icon:u,theme:n}),icon:u?void 0:"bots",onClick:()=>c({botId:t.id,chatId:a}),onContextMenu:v},t.shortName,p&&i.ZP.createElement(Ei.Z,null,i.ZP.createElement(Bt.Z,{isOpen:m,positionX:"right",style:`left: ${p.x}px;top: ${p.y}px;`,className:"bot-attach-context-menu",autoClose:!0,onClose:I,onCloseAnimationEnd:w},i.ZP.createElement(gt.Z,{icon:"stop",destructive:!0,onClick:y},d("WebApp.RemoveBot")))))})),Ai=(0,i.X$)((e=>{let{chatId:t,isButtonVisible:n,canAttachMedia:s,canAttachPolls:o,attachMenuBots:r,peerType:c,isScheduled:l,onFileSelect:d,onPollCreate:u,theme:m}=e;const[g,p,f]=(0,at.Z)(),[v,I,w]=(0,Mi.Z)(g,f),[y,Z,P]=(0,at.Z)();(0,i.d4)((()=>{g&&w()}),[g,w]);const C=(0,i.I4)((()=>{g?f():p()}),[g,p,f]),b=(0,i.I4)(((e,t)=>{const{files:n}=e.target;n&&n.length>0&&d(Array.from(n),t)}),[d]),S=(0,i.I4)((()=>{(0,Si.g)(Array.from(a.dI).join(","),(e=>b(e,!0)))}),[b]),M=(0,i.I4)((()=>{(0,Si.g)("*",(e=>b(e,!1)))}),[b]),E=(0,i.Ye)((()=>Object.values(r).filter((e=>!!c&&(!("bot"!==c||e.id!==t||!e.peerTypes.includes("self"))||e.peerTypes.includes(c))))),[r,t,c]),R=(0,rt.Z)();if(n)return i.ZP.createElement("div",{className:"AttachMenu"},i.ZP.createElement(bi,{id:"attach-menu-button",className:g?"AttachMenu--button activated":"AttachMenu--button",round:!0,color:"translucent",onActivate:C,ariaLabel:"Add an attachment",ariaControls:"attach-menu-controls",hasPopup:!0},i.ZP.createElement("i",{className:"icon-attach"})),i.ZP.createElement(Bt.Z,{id:"attach-menu-controls",isOpen:g||y,autoClose:!0,positionX:"right",positionY:"bottom",onClose:f,className:"AttachMenu--menu fluid",onCloseAnimationEnd:f,onMouseEnter:h.$b?void 0:v,onMouseLeave:h.$b?void 0:I,noCloseOnBackdrop:!h.$b,ariaLabelledBy:"attach-menu-button"},!s&&i.ZP.createElement(gt.Z,{className:"media-disabled",disabled:!0},"Posting media content is not allowed in this group."),s&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(gt.Z,{icon:"photo",onClick:S},R("AttachmentMenu.PhotoOrVideo")),i.ZP.createElement(gt.Z,{icon:"document",onClick:M},R("AttachDocument"))),o&&i.ZP.createElement(gt.Z,{icon:"poll",onClick:u},R("Poll")),s&&!l&&E.map((e=>i.ZP.createElement(Ti,{bot:e,chatId:t,theme:m,onMenuOpened:Z,onMenuClosed:P})))))})),Bi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"SymbolMenu",!t);return n?i.ZP.createElement(n,e):void 0})),xi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"InlineBotTooltip",!t);return n?i.ZP.createElement(n,e):void 0})),Li=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"MentionTooltip",!t);return n?i.ZP.createElement(n,e):void 0}));var Oi=n(67146);const Ui=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"StickerTooltip",!t);return n?i.ZP.createElement(n,e):void 0}));var Fi=n(19830);const qi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"BotCommandTooltip",!t);return n?i.ZP.createElement(n,e):void 0})),Di=(0,i.X$)((0,s.c$)(((e,t)=>{let{messageId:n}=t;const{chatId:s}=(0,c.Bt)(e)||{};return s?{message:(0,c.hj)(e,s,n)}:{}}))((e=>{let{isOpen:t,message:n,onClose:a}=e;const{clickBotInlineButton:o}=(0,s.Sv)(),[r,c]=(0,Mi.Z)(t,a),{isKeyboardSingleUse:l}=n||{},[d,u,m]=(0,at.Z)(!0),g=(0,i.I4)((()=>{m(),a()}),[a,m]);if((0,i.d4)((()=>{u()}),[u,null==n?void 0:n.keyboardButtons]),n&&n.keyboardButtons)return i.ZP.createElement(Bt.Z,{isOpen:t||d,autoClose:l,positionX:"right",positionY:"bottom",onClose:g,className:"BotKeyboardMenu",onCloseAnimationEnd:g,onMouseEnter:h.$b?void 0:r,onMouseLeave:h.$b?void 0:c,noCompact:!0},i.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>i.ZP.createElement("div",{className:"row"},e.map((e=>i.ZP.createElement(pt.Z,{ripple:!0,disabled:"unsupported"===e.type,onClick:()=>o({messageId:n.id,button:e})},e.text))))))))})));var $i=n(13616),ji=n(17891),Gi=n(63394);const Hi=e=>{let{className:t}=e;return i.ZP.createElement("div",{className:(0,Fe.Z)("GC8g9Q16IaK76g6rcU78",t)})},_i=(0,i.X$)((0,s.c$)((e=>{const{chatId:t,threadId:n,type:s}=(0,c.Bt)(e)||{};if(!t||!n||!s)return{};const{forwardMessages:{fromChatId:a,toChatId:i,messageIds:o,noAuthors:r,noCaptions:l}}=e,u=(0,c.Yy)(e,t,n),m="scheduled"===s?(0,c.wU)(e,t):(0,c._$)(e,t,n),h=e.settings.byKey.animationLevel>=1,g=i===t,p=null==o?void 0:o.map((t=>(0,c.hj)(e,a,t)));let f,v;if(u?f=(0,c.hj)(e,t,u):m?f=(0,c.kK)(e,t,n,s):g&&1===o.length&&(f=null==p?void 0:p[0]),u&&f){const{forwardInfo:n}=f,s=(0,c.FM)(e,t);n&&(n.isChannelPost||s)&&(v=(0,c.cv)(e,f)),v||null!=n&&n.hiddenUserName||(v=(0,c.Ur)(e,f))}else g&&(f&&(v=(0,c.cv)(e,f),v||(v=(0,c.Ur)(e,f))),v||(v=(0,d.YC)(a)?(0,c.dy)(e,a):(0,c.Z1)(e,a)));const I=null==p?void 0:p.some((e=>(null==e?void 0:e.content.text)&&Object.keys(e.content).length>1));return{replyingToId:u,editingId:m,message:f,sender:v,shouldAnimate:h,forwardedMessagesCount:g?o.length:void 0,noAuthors:r,noCaptions:l,forwardsHaveCaptions:I}}))((e=>{let{replyingToId:t,editingId:n,message:a,sender:o,shouldAnimate:r,forwardedMessagesCount:c,noAuthors:l,noCaptions:d,forwardsHaveCaptions:u,onClear:m}=e;const{setReplyingToId:h,setEditingId:g,focusMessage:p,changeForwardRecipient:f,setForwardNoAuthors:v,setForwardNoCaptions:I,exitForwardMode:w}=(0,s.Sv)(),y=(0,i.sO)(null),Z=(0,rt.Z)(),P=Boolean(c),C=Boolean((t||n)&&a||o&&c),b=(0,ji.Z)([c],c?300:void 0),{shouldRender:S,transitionClassNames:M}=(0,Xe.Z)(b&&C,void 0,!r,void 0,!r),E=(0,i.I4)((()=>{t?h({messageId:void 0}):n?g({messageId:void 0}):c&&w(),null==m||m()}),[t,n,c,m,h,g,w]);(0,i.d4)((()=>C?(0,nt.Z)(E):void 0),[C,E]);const R=(0,i.I4)((()=>{P||p({chatId:a.chatId,messageId:a.id})}),[p,P,a]),k=(0,i.I4)((e=>{e.stopPropagation(),E()}),[E]),N=(0,i.I4)((()=>{f()}),[f]),{isContextMenuOpen:T,contextMenuPosition:A,handleContextMenu:B,handleContextMenuClose:x,handleContextMenuHide:L}=(0,Vn.Z)(y),O=(0,i.I4)((()=>y.current),[]),U=(0,i.I4)((()=>y.current),[]),F=(0,i.I4)((()=>y.current.querySelector(".forward-context-menu .bubble")),[]),{positionX:q,positionY:D,transformOriginX:$,transformOriginY:j,style:G}=(0,Gi.Z)(A,O,U,F),H=(0,Fe.Z)("ComposerEmbeddedMessage",M),_=(0,i.Ye)((()=>t?"icon-reply":n?"icon-edit":P?"icon-forward":void 0),[n,P,t]),z=c&&c>1?Z("ForwardedMessageCount",c):void 0;if(S)return i.ZP.createElement("div",{className:H,ref:y,onContextMenu:B,onClick:B},i.ZP.createElement("div",null,i.ZP.createElement("div",{className:"embedded-left-icon"},i.ZP.createElement("i",{className:_})),i.ZP.createElement(fs,{className:"inside-input",message:a,sender:l?void 0:o,customText:z,title:n?Z("EditMessage"):l?Z("HiddenSendersNameDescription"):void 0,onClick:R,hasContextMenu:P}),i.ZP.createElement(pt.Z,{className:"embedded-cancel",round:!0,faded:!0,color:"translucent",ariaLabel:Z("Cancel"),onClick:k},i.ZP.createElement("i",{className:"icon-close"})),P&&i.ZP.createElement(Bt.Z,{isOpen:T,transformOriginX:$,transformOriginY:j,positionX:q,positionY:D,style:G,className:"forward-context-menu",onClose:x,onCloseAnimationEnd:L},i.ZP.createElement(gt.Z,{icon:l?void 0:"message-succeeded",customIcon:l?i.ZP.createElement("i",{className:"icon-placeholder"}):void 0,onClick:()=>v(!1)},Z(c>1?"ShowSenderNames":"ShowSendersName")),i.ZP.createElement(gt.Z,{icon:l?"message-succeeded":void 0,customIcon:l?void 0:i.ZP.createElement("i",{className:"icon-placeholder"}),onClick:()=>v(!0)},Z(c>1?"HideSenderNames":"HideSendersName")),u&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Hi,null),i.ZP.createElement(gt.Z,{icon:d?void 0:"message-succeeded",customIcon:d?i.ZP.createElement("i",{className:"icon-placeholder"}):void 0,onClick:()=>I(!1)},Z(c>1?"Conversation.ForwardOptions.ShowCaption":"ShowCaption")),i.ZP.createElement(gt.Z,{icon:d?"message-succeeded":void 0,customIcon:d?void 0:i.ZP.createElement("i",{className:"icon-placeholder"}),onClick:()=>I(!0)},Z(c>1?"Conversation.ForwardOptions.HideCaption":"HideCaption"))),i.ZP.createElement(Hi,null),i.ZP.createElement(gt.Z,{icon:"replace",onClick:N},Z("ChangeRecipient")))))}))),zi=(0,i.X$)((e=>{const{attachments:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"AttachmentModal",!t.length);return n?i.ZP.createElement(n,e):void 0})),Vi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"BotCommandMenu",!t);return n?i.ZP.createElement(n,e):void 0})),Wi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"PollModal",!t);return n?i.ZP.createElement(n,e):void 0})),Ji=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"DropArea",!t);return n?i.ZP.createElement(n,e):void 0})),Xi=new RegExp(a.FM,"i"),Yi=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s}=t;const a=(0,c.tV)(e,n,s);return{theme:(0,c.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:a}}))((e=>{let{chatId:t,threadId:n,messageText:a,disabled:r,webPagePreview:c,noWebPage:l,theme:d}=e;const{loadWebPagePreview:u,clearWebPagePreview:m,toggleMessageWebPage:h}=(0,s.Sv)(),g=ui((()=>{const{text:e,entities:t}=(0,f.Z)(a),n=t&&t.find((e=>{let{type:t}=e;return t===o.Vv.TextUrl}));if(n)return n.url;const s=e.match(Xi);return s?s[0]:void 0}),300,[a]);(0,i.d4)((()=>{g?u({text:g}):(m(),h({chatId:t,threadId:n}))}),[t,h,m,g,u,n]),(0,Ge.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t]);const p=Boolean(c&&a.length&&!l&&!r),{shouldRender:v,transitionClassNames:I}=(0,Xe.Z)(p),w=(0,Kt.Z)(c,!0),y=(0,i.I4)((()=>{h({chatId:t,threadId:n,noWebPage:!0})}),[t,n,h]);if(!v||!w)return;const{photo:Z,...P}=w,C={content:{webPage:P}};return i.ZP.createElement("div",{className:(0,Fe.Z)("WebPagePreview",I)},i.ZP.createElement("div",null,i.ZP.createElement("div",{className:"WebPagePreview-left-icon"},i.ZP.createElement("i",{className:"icon-link"})),i.ZP.createElement(ea,{message:C,inPreview:!0,theme:d}),i.ZP.createElement(pt.Z,{className:"WebPagePreview-clear",round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:y},i.ZP.createElement("i",{className:"icon-close"}))))}))),Ki=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"SendAsMenu",!t);return n?i.ZP.createElement(n,e):void 0})),Qi=(0,i.X$)((e=>{let{isOpen:t,onClick:n,text:s,isDisabled:a}=e;const o=(0,i.sO)(null);return(0,i.d4)((()=>{const e=o.current;if(!e)return;const t=e.scrollWidth+1;e.closest(".Composer").style.setProperty("--bot-menu-text-width",`${t}px`)}),[t,s]),(0,i.d4)((()=>{const e=o.current;if(!e)return;const t=e.closest(".Composer");return()=>{t.style.removeProperty("--bot-menu-text-width")}}),[]),i.ZP.createElement(pt.Z,{className:(0,Fe.Z)("bot-menu",t&&"open"),round:!0,color:"translucent",disabled:a,onClick:n,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:(0,Fe.Z)("bot-menu-icon","icon-webapp",t&&"open")}),i.ZP.createElement("span",{ref:o,className:"bot-menu-text"},s))}));var eo;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(eo||(eo={}));const to="wonderful-voice-message.ogg",no=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s,i,r,l,u,m;let{chatId:h,threadId:g,messageListType:p}=t;const f=(0,c.Z1)(e,h),v=h!==a.FV?(0,c.IK)(e,h):void 0,I=Boolean(v),w=(0,c.FM)(e,h),y=I&&(0,c.FT)(e,h),Z=(0,c.qy)(e,h),{language:P,shouldSuggestStickers:C}=e.settings.byKey,b=e.emojiKeywords[a.pR],S=P!==a.pR?e.emojiKeywords[P]:void 0,M=y?y.id:void 0,E=M?(0,c.hj)(e,h,M):void 0,{currentUserId:R}=e,k=null!=f&&f.fullInfo?(null==f||null===(n=f.fullInfo)||void 0===n?void 0:n.sendAsId)||R:void 0,N=null!=f&&f.sendAsIds&&k&&f.sendAsIds.includes(k)?k:null!=f&&null!==(s=f.adminRights)&&void 0!==s&&s.anonymous?null==f?void 0:f.id:void 0,T=N?(0,c.dy)(e,N):void 0,A=!T&&N?(0,c.Z1)(e,N):void 0,B=(0,c.QV)(e,h),x=(0,c.Bt)(e),L=h===(null==x?void 0:x.chatId)&&g===(null==x?void 0:x.threadId)&&p===(null==x?void 0:x.type),O="scheduled"===p?(0,c.hI)(e,h):(0,c.s)(e,h,g);return{editingMessage:(0,c.kK)(e,h,g,p),connectionState:e.connectionState,draft:(0,c.Ms)(e,h,g),chat:f,isChatWithBot:I,isChatWithSelf:w,isForCurrentMessageList:L,canScheduleUntilOnline:(0,c.Eh)(e,h),isChannel:f?(0,d.eA)(f):void 0,isRightColumnShown:(0,c.Jf)(e),isSelectModeActive:(0,c.CA)(e),withScheduledButton:g===o._f&&"thread"===p&&Boolean(null==Z?void 0:Z.length),shouldSchedule:"scheduled"===p,botKeyboardMessageId:M,botKeyboardPlaceholder:null==E?void 0:E.keyboardPlaceholder,isForwarding:h===e.forwardMessages.toChatId,pollModal:e.pollModal,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==f||null===(i=f.fullInfo)||void 0===i?void 0:i.members,topInlineBotIds:null===(r=e.topInlineBots)||void 0===r?void 0:r.userIds,currentUserId:R,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:C,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==b?void 0:b.keywords,emojiKeywords:null==S?void 0:S.keywords,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:(null==f?void 0:f.fullInfo)&&f.fullInfo.botCommands,botCommands:null!=v&&v.fullInfo?(null===(l=v.fullInfo.botInfo)||void 0===l?void 0:l.commands)||!1:void 0,botMenuButton:null==v||null===(u=v.fullInfo)||void 0===u||null===(m=u.botInfo)||void 0===m?void 0:m.menuButton,sendAsUser:T,sendAsChat:A,sendAsId:N,editingDraft:O,requestedText:B,attachMenuBots:e.attachMenu.bots,attachMenuPeerType:(0,c.x$)(e,h),theme:(0,c.Pu)(e),fileSizeLimit:(0,q.M)(e,"uploadMaxFileparts")*a.pJ,captionLimit:(0,q.M)(e,"captionLength"),isCurrentUserPremium:(0,c.wV)(e)}}))((e=>{let{dropAreaState:t,shouldSchedule:n,canScheduleUntilOnline:r,isReady:c,onDropHide:u,editingMessage:m,chatId:g,threadId:v,messageListType:I,draft:w,chat:y,isForCurrentMessageList:Z,isCurrentUserPremium:P,connectionState:C,isChatWithBot:b,isChatWithSelf:S,isChannel:M,fileSizeLimit:E,isRightColumnShown:k,isSelectModeActive:N,isForwarding:T,pollModal:A,botKeyboardMessageId:B,botKeyboardPlaceholder:x,withScheduledButton:L,stickersForEmoji:O,groupChatMembers:U,topInlineBotIds:F,currentUserId:q,captionLimit:D,lastSyncTime:$,contentToBeScheduled:j,shouldSuggestStickers:G,baseEmojiKeywords:_,emojiKeywords:z,recentEmojis:V,inlineBots:W,isInlineBotLoading:J,botCommands:X,chatBotCommands:Y,sendAsUser:K,sendAsChat:Q,sendAsId:ee,editingDraft:te,requestedText:ne,botMenuButton:se,attachMenuBots:ae,attachMenuPeerType:ie,theme:oe}=e;const{sendMessage:re,clearDraft:ce,showDialog:le,setStickerSearchQuery:de,setGifSearchQuery:ue,forwardMessages:me,openPollModal:he,closePollModal:ge,loadScheduledHistory:pe,openChat:fe,addRecentEmoji:ve,sendInlineBotResult:we,loadSendAs:ye,loadFullChat:Ze,resetOpenChatWithText:Pe,callAttachMenuBot:Ce,openLimitReachedModal:be}=(0,s.Sv)(),Se=(0,rt.Z)(),Me=(0,i.sO)(null),[Ee,Re]=(0,i.eJ)(""),ke=(0,Ya.Y)(Ee),Ne=(0,i.sO)(),Te=(0,Jt.Z)(t),{width:Ae}=Ie.Z.get(),Be=null==y?void 0:y.sendAsIds,xe=Be&&(Be.length>1||!Be.includes(q)),[Le,Oe,Ue]=(0,at.Z)(),qe=(0,Xa.Z)(g,v),De=(0,i.I4)((()=>{Ue()}),[Ue]),[He,_e]=(0,wi.Z)(r,De);(0,i.d4)((()=>{Ne.current=void 0}),[g]),(0,i.d4)((()=>{g&&$&&v===o._f&&c&&pe({chatId:g})}),[c,g,pe,$,v]),(0,i.d4)((()=>{g&&y&&$&&!Be&&c&&(0,d.ZV)(y)&&ye({chatId:g})}),[y,g,c,$,ye,Be]),(0,i.d4)((()=>{g&&y&&$&&!y.fullInfo&&c&&(0,d.ZV)(y)&&Ze({chatId:g})}),[y,g,c,$,Ze]);const ze=(0,i.sO)(!1);(0,Ge.Z)((e=>{let[t,n]=e;ze.current=Boolean(g===t&&Be&&!n)}),[g,Be]),(0,i.bt)((()=>{Me.current&&(Me.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>')}),[]);const[Ve,We]=(0,i.eJ)([]),[Je,Xe,Ye]=(0,at.Z)(),[Ke,Qe,et]=(0,at.Z)(),[tt,st,it]=(0,at.Z)(),[ot,ct,lt]=(0,at.Z)(),[dt,ut,mt]=(0,at.Z)(),[ht,gt]=(0,at.Z)(),[ft,vt,It]=(0,at.Z)(),wt=(0,i.I4)((e=>{const t="function"==typeof e?e(Ve):e;t&&t.some((e=>e.size>E))?be({limit:"uploadMaxFileparts"}):We(t)}),[Ve,E,be]),{startRecordingVoice:yt,stopRecordingVoice:Pt,pauseRecordingVoice:Ct,activeVoiceRecording:bt,currentRecordTime:St,recordButtonRef:Mt,startRecordTimeRef:Et}=(()=>{const e=(0,i.sO)(null),[t,n]=(0,i.eJ)(),s=(0,i.sO)(),[a,o]=(0,i.eJ)();(0,i.d4)((()=>{h.s$&&h.mh&&si()}),[]);const r=(0,i.I4)((async()=>{try{const{stop:t,pause:a}=await ai((t=>{e.current&&(s.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),o(Date.now()))}));s.current=Date.now(),o(Date.now()),n({stop:t,pause:a})}catch(e){console.error(e)}}),[]),c=(0,i.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),l=(0,i.I4)((()=>{if(t){n(void 0),s.current=void 0,o(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,i.d4)((()=>t?(0,nt.Z)(l):void 0),[t,l]),{startRecordingVoice:r,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:a,recordButtonRef:e,startRecordTimeRef:s}})();(0,Dn.Z)((()=>{qe({type:"recordAudio"})}),bt&&a.o_),(0,i.d4)((()=>{bt||qe({type:"cancel"})}),[bt,qe]);const Rt=m?eo.Edit:!h.mh||bt||Ee&&!Ve.length||T?n?eo.Schedule:eo.Send:eo.Record,kt=!n,{isMentionTooltipOpen:Nt,closeMentionTooltip:Tt,insertMention:At,mentionFilteredUsers:Bt}=(0,di.Z)(!Ve.length,ke,Re,void 0,U,F,q),{isOpen:xt,id:Lt,isGallery:Ot,switchPm:Ut,results:Ft,closeTooltip:qt,help:Dt,loadMore:$t}=function(e,t,n,a){const{queryInlineBot:o,resetInlineBot:r}=(0,s.Sv)(),[c,l,d]=(0,at.Z)(),{username:u,query:m,canShowHelp:h,usernameLowered:g}=ui((()=>function(e){const t=function(e){return fi.innerHTML=e.replace(/<br>/g,"\n"),fi.innerText}(e),n=t.match(hi);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(gi),usernameLowered:n[1].toLowerCase()}:pi}(n)),300,[n])||{},p=(0,Jt.Z)(m),f=(0,Jt.Z)(u),v=g?null==a?void 0:a[g]:void 0,{id:I,switchPm:w,offset:y,results:Z,isGallery:P,help:C}=v||{};(0,i.d4)((()=>{p!==m&&d()}),[p,m,d]),(0,i.d4)((()=>{e&&g&&t&&o({chatId:t,username:g,query:m})}),[m,e,o,t,g]);const b=(0,i.I4)((()=>{o({chatId:t,username:g,query:m,offset:y})}),[y,t,m,o,g]);return(0,i.d4)((()=>{e&&I&&(w||null!=Z&&Z.length)?l():d()}),[I,e,l,Z,w,d]),f!==u&&r({username:f}),{isOpen:c,id:I,isGallery:P,switchPm:w,results:Z,closeTooltip:d,help:h&&C?`@${u} ${C}`:void 0,loadMore:b}}(Boolean(!Ve.length&&$),g,Ee,W),{isOpen:jt,close:Gt,filteredBotCommands:_t}=function(e,t,n,s){const[a,o,r]=(0,at.Z)(),[c,l]=(0,i.eJ)(),d=(0,i.I4)((e=>{n||s?vi((()=>{const t=(n||s||[]).filter((t=>{let{command:n}=t;return!e||n.includes(e)}));l(t&&t.length?t:void 0)})):l(void 0)}),[n,s]);return(0,i.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,Ja._)(t.substr(1)).match(Ii);d(e?e[0]:"")}else l(void 0);else l(void 0)}),[d,t,e,r]),(0,i.d4)((()=>{c&&c.length&&t.length>0?o():r()}),[c,t.length,o,r]),{isOpen:a,close:r,filteredBotCommands:c}}(Boolean(X&&X.length||Y&&Y.length),Ee,X,Y),{isContextMenuOpen:zt,handleContextMenu:Vt,handleContextMenuClose:Wt,handleContextMenuHide:Xt}=(0,Vn.Z)(Mt,!(Rt===eo.Send&&kt)),{canSendStickers:Yt,canSendGifs:Kt,canAttachMedia:Qt,canAttachPolls:en,canAttachEmbedLinks:tn}=(0,i.Ye)((()=>(0,d.H5)(y,b)),[y,b]),nn=y&&(0,d.Nl)(y),sn=(0,d.Hd)(y),{isStickerTooltipOpen:an,closeStickerTooltip:on}=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const o=(0,i.Ye)((()=>(0,Ja._)(t).trim()),[t]),{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,s.Sv)(),l=h.op&&1===(0,Wa.Z)(o)||!h.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),d=Boolean(n)&&l;return(0,i.d4)((()=>{var t;a||(e&&l?r({emoji:h.op?o:null===(t=o.match(/alt="(.+)"/))||void 0===t?void 0:t[1]}):!d&&l||c())}),[t,l,c,r,e,a]),{isStickerTooltipOpen:d,closeStickerTooltip:c}}(Boolean(G&&Yt&&!Ve.length),Ee,O,!c),{isEmojiTooltipOpen:rn,closeEmojiTooltip:cn,filteredEmojis:ln,insertEmoji:dn}=(0,li.Z)(Boolean(G&&Yt&&!Ve.length),ke,V,void 0,Re,_,z,!c),un=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.R2;const n=window.getSelection();let s;s=t===a.R2?document.querySelector(a.Ed):document.getElementById(t);const i=(0,Mn.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(n.rangeCount){const e=n.getRangeAt(0);if((0,_a.R)(e,t))return Ha(i),void s.dispatchEvent(new Event("input",{bubbles:!0}))}Re(`${ke.current}${i}`),requestAnimationFrame((()=>{(0,Da.Z)(s)}))}),[ke]),mn=(0,i.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,_a.R)(t,a.R2))return void document.execCommand("delete",!1)}Re(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 n=t.lastChild;if(n.lastChild)for(;n.lastChild;)n=n.lastChild;const s=n.textContent.length,a=document.createRange(),i=window.getSelection();a.setStart(n,s),a.setEnd(n,s),i.removeAllRanges(),i.addRange(a),document.execCommand("delete",!1);const o=t.innerHTML;return document.body.removeChild(t),o}(ke.current))}),[ke]),hn=(0,i.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||Re(""),We(l.D),on(),Tt(),cn(),h.wB?setTimeout((()=>it()),350):it()}),[on,Tt,cn,it]),gn=(0,i.sO)();gn.current=Pt,(0,i.d4)((()=>()=>{gn.current(),hn()}),[g,hn,gn]);const[pn,fn]=((e,t,n,o,r,c,l,u,m,h)=>{const{editMessage:g,setEditingDraft:p}=(0,s.Sv)();(0,Gn.Z)((e=>{let[s]=e;if(!n)return;if((null==s?void 0:s.id)===n.id)return;const i=(0,_s.z)(null!=h&&h.text.length?h:n.content.text);t(i),requestAnimationFrame((()=>{const e=document.querySelector(a.Ed);e&&(0,Da.Z)(e,!0)}))}),[n,t]),(0,i.d4)((()=>{if(n)return()=>{const t=(0,f.Z)(e.current),n=t.text.length?t:void 0;p({chatId:c,threadId:l,type:u,text:n})}}),[c,n,e,p,l,u]);const v=(0,i.I4)((()=>{m&&(0,R.T2)((()=>{t((0,_s.z)(m));const e=document.querySelector(a.Ed);e&&requestAnimationFrame((()=>{(0,Da.Z)(e,!0)}))}))}),[m,t]),I=(0,i.I4)((()=>{o(),v()}),[o,v]),w=(0,i.I4)((()=>{const{text:t,entities:s}=(0,f.Z)(e.current);n&&(t||(0,d.u8)(n)?(g({messageId:n.id,text:t,entities:s}),o(),v()):r())}),[g,n,e,r,o,v]),y=(0,i.I4)((()=>{if(!n)return;const t=(0,f.Z)(e.current),s=t.text.length?t:void 0;p({chatId:c,threadId:l,type:u,text:s})}),[c,n,e,p,l,u]);return(0,$e.Z)(y),je(y),[w,I]})(ke,Re,m,hn,ut,g,v,I,w,te);((e,t,n,o,r,c)=>{const{saveDraft:l,clearDraft:d}=(0,s.Sv)(),u=(0,i.I4)(((e,t)=>{const n=o.current;void 0===n||c||(n.length?l({chatId:e,threadId:t,draft:(0,f.Z)(n)}):d({chatId:e,threadId:t}))}),[d,c,o,l]),m=(0,i.Ye)((()=>(0,R.Ds)((e=>e()),a.r_,!1)),[t]),g=(0,Jt.Z)(t),p=(0,Jt.Z)(n);(0,i.d4)((()=>(ri=t,ci=n,()=>{ri=void 0,ci=void 0,u(t,n)})),[t,n,u]),(0,i.d4)((()=>{t===g&&n===p||!c&&e&&(r((0,_s.z)(e)),h.$b||requestAnimationFrame((()=>{const e=document.querySelector(a.Ed);e&&(0,Da.Z)(e,!0)})))}),[t,n,e,r,u,g,p,c]);const v=o.current,I=(0,Jt.Z)(v);(0,i.d4)((()=>{t&&n&&g===t&&p===n&&I!==v&&(v.length?m((()=>{ri===t&&ci===n&&u(t,n)})):u(t,n))}),[t,v,g,I,p,m,n,u]);const w=(0,i.I4)((()=>{t&&n&&u(t,n)}),[t,n,u]);(0,$e.Z)(w),je(w)})(w,g,v,ke,Re,m),((e,t,n,s)=>{(0,i.d4)((()=>{if(e)return document.addEventListener("paste",i,!1),()=>{document.removeEventListener("paste",i,!1)};async function i(e){if(!e.clipboardData)return;const i=document.activeElement;if(i&&![a.R2,a.nY].includes(i.id))return;const o=e.clipboardData.getData("text").substring(0,4096),{items:r}=e.clipboardData;let c=[];if(e.preventDefault(),r.length>0&&(c=await(0,ii.Z)(r)),0!==c.length||o){if(c.length>0&&!s){const e=await Promise.all(c.map((e=>Ga(e.name,e,1===c.length&&oi.includes(e.type)))));n((t=>t.concat(e)))}o&&t(o,null==i?void 0:i.id)}}}),[t,s,n,e])})(Z,un,wt,m);const vn=(0,i.I4)((()=>{m&&fn()}),[m,fn]),In=(0,i.I4)((async(e,t)=>{wt(await Promise.all(e.map((e=>Ga(e.name,e,t)))))}),[wt]),wn=(0,i.I4)((async(e,t)=>{wt([...Ve,...await Promise.all(e.map((e=>Ga(e.name,e,t))))])}),[Ve,wt]),yn=(0,i.I4)((()=>{We(l.D)}),[]),Zn=(0,i.I4)((async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;if("connectionStateReady"!==C)return;let n=Ve;if(bt){const e=await Pt();if(e){const{blob:t,duration:s,waveform:a}=e;n=[await Ga(to,t,!1,{voice:{duration:s,waveform:a}})]}}const{text:i,entities:o}=(0,f.Z)(ke.current);if(!n.length&&!i&&!T)return;const{serverTimeOffset:r}=(0,s.Rd)(),c=n.length?D:4096;if((null==i?void 0:i.length)>c){const e=i.length-c;return void le({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const l=document.querySelector(a.Ed);if(n.length||i){if(sn&&!nn){const e=(0,p.b)(r),t=Ne.current&&Math.floor(e-Ne.current),n=sn.nextSendDate&&sn.nextSendDate>e;if(t&&t<sn.seconds||n){const s=n?sn.nextSendDate-e:sn.seconds-t;return le({data:{message:Se("SlowModeHint",(0,H.k9)(s)),isSlowMode:!0,hasErrorKey:!1}}),void(null==l||l.blur())}}re({text:i,entities:o,attachments:n,scheduledAt:t,isSilent:e})}T&&me({scheduledAt:t,isSilent:e}),Ne.current=(0,p.b)(r),ce({chatId:g,localOnly:!0}),h.cj&&l&&l===document.activeElement&&Va(l),requestAnimationFrame((()=>{hn()}))}),[C,Ve,bt,T,ce,g,D,hn,Pt,le,sn,nn,re,me,Se,ke]),Pn=(0,i.I4)((()=>{"webApp"===(null==se?void 0:se.type)&&Ce({botId:g,chatId:g,isFromBotMenu:!0,url:se.url})}),[se,Ce,g]),Cn=(0,i.I4)((()=>{it(),Qe()}),[it,Qe]),bn=(0,i.I4)((()=>{et(),lt(),st()}),[et,lt,st]),Sn=(0,i.I4)(((e,t)=>{if(e&&"queryId"in e){const{id:n,queryId:s,isSilent:a}=e;return void we({id:n,queryId:s,scheduledAt:t,isSilent:a})}const{isSilent:n,...s}=e||{};e&&0!==Object.keys(s).length?re({...e,scheduledAt:t}):Zn(Boolean(n),t)}),[Zn,we,re]);(0,i.d4)((()=>{j&&He((e=>{Sn(j,e)}))}),[j,Sn,He]),(0,i.d4)((()=>{ne&&(Re(ne),Pe(),requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,Da.Z)(e,!0)})))}),[ne,Pe]);const En=(0,i.I4)((function(e,t,s){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e={...e,isPreloadedGlobally:!0},n||s?(Oe(),He((n=>{Ue(),Sn({sticker:e,isSilent:t},n),requestAnimationFrame((()=>{hn(a)}))}))):(re({sticker:e,isSilent:t}),requestAnimationFrame((()=>{hn(a)})))}),[n,Oe,He,Ue,Sn,hn,re]),Rn=(0,i.I4)(((e,t,s)=>{n||s?(Oe(),He((n=>{Ue(),Sn({gif:e,isSilent:t},n),requestAnimationFrame((()=>{hn(!0)}))}))):(re({gif:e,isSilent:t}),requestAnimationFrame((()=>{hn(!0)})))}),[n,Oe,He,Ue,Sn,hn,re]),Nn=(0,i.I4)(((e,t,s)=>{if("connectionStateReady"!==C)return;n||s?He((n=>{Sn({id:e.id,queryId:e.queryId,isSilent:t},n)})):we({id:e.id,queryId:e.queryId,isSilent:t});const i=document.querySelector(a.Ed);h.cj&&i&&i===document.activeElement&&Va(i),ce({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{hn()}))}),[g,ce,C,Sn,He,hn,we,n]),Tn=(0,i.I4)((()=>{ce({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{hn()}))}),[g,ce,hn]),An=(0,i.I4)((e=>{n?(He((t=>{Sn({poll:e},t)})),ge()):(re({poll:e}),ge())}),[ge,Sn,He,re,n]),Bn=(0,i.I4)((()=>{n?He((e=>{Sn({isSilent:!0},e)})):Zn(!0)}),[Sn,Zn,He,n]),xn=(0,i.I4)((e=>{"stickers"===e?(de({query:""}),ue({query:void 0})):(ue({query:""}),de({query:void 0}))}),[de,ue]),Ln=(0,i.I4)((()=>{const e=document.querySelector(a.Ed);h.wB&&e===document.activeElement?(null==e||e.blur(),setTimeout((()=>{et(),st()}),100)):st()}),[st,et]),On=(0,i.I4)((()=>{const e=document.querySelector(a.Ed);if(!h.wB||e!==document.activeElement)return et(),it(),void ct();null==e||e.blur(),setTimeout((()=>{et(),it(),ct()}),100)}),[et,it,ct]),Un=(0,i.I4)((()=>{fe({id:g,threadId:v,type:"scheduled"})}),[fe,g,v]);(0,i.d4)((()=>{k&&h.wB&&it()}),[k,it]),(0,i.d4)((()=>{c&&(N?vt():setTimeout((()=>{It()}),200))}),[N,It,vt,c]);const Fn=(0,i.I4)((()=>{switch(Rt){case eo.Send:Zn();break;case eo.Record:yt();break;case eo.Edit:pn();break;case eo.Schedule:bt&&Ct(),He((e=>{Sn({},e)}))}}),[Rt,Zn,yt,pn,bt,He,Ct,Sn]),qn=Rt===eo.Record&&!Qt,$n=(0,Jt.Z)(m,!0),jn=m||$n,Hn=new Date;Hn.setSeconds(0),Hn.setMilliseconds(0);const _n=new Date;_n.setFullYear(_n.getFullYear()+1);let zn="SendMessage";switch(Rt){case eo.Edit:zn="Save edited message";break;case eo.Record:zn=qn?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const Wn=(0,Fe.Z)("Composer",!N&&"shown",ft&&"hover-disabled"),Jn=(0,Fe.Z)("mobile-symbol-menu-button",!c&&"not-ready",ht?tt&&"menu-opened":tt&&"is-loading"),Xn=(0,i.I4)((()=>{He((e=>{Sn({},e)}))}),[Sn,He]),Yn=Rt===eo.Edit?pn:Rt===eo.Schedule?Xn:Zn,Kn=se&&"commands"===(null==se?void 0:se.type);return i.ZP.createElement("div",{className:Wn},Qt&&c&&i.ZP.createElement(Ji,{isOpen:t!==Ht.t.None,withQuick:t===Ht.t.QuickFile||Te===Ht.t.QuickFile,onHide:u,onFileSelect:In}),i.ZP.createElement(zi,{chatId:g,threadId:v,canShowCustomSendMenu:kt,attachments:Ve,captionLimit:D,caption:Ve.length?Ee:"",groupChatMembers:U,currentUserId:q,recentEmojis:V,isReady:c,isChatWithSelf:S,onCaptionUpdate:Re,baseEmojiKeywords:_,emojiKeywords:z,addRecentEmoji:ve,shouldSchedule:n,onSendSilent:Bn,onSend:Zn,onSendScheduled:Xn,onFileAppend:wn,onClear:yn}),i.ZP.createElement(Wi,{isOpen:A.isOpen,isQuiz:A.isQuiz,shouldBeAnonymous:M,onClear:ge,onSend:An}),jn&&i.ZP.createElement(yi,{isOpen:dt,isSchedule:"scheduled"===I,onClose:mt,message:jn}),i.ZP.createElement(Ki,{isOpen:ot,onClose:lt,chatId:g,selectedSendAsId:ee,sendAsIds:Be}),i.ZP.createElement(Li,{isOpen:Nt,onClose:Tt,onInsertUserName:At,filteredUsers:Bt}),i.ZP.createElement(xi,{isOpen:xt,botId:Lt,isGallery:Ot,inlineBotResults:Ft,switchPm:Ut,onSelectResult:Nn,loadMore:$t,onClose:qt,isSavedMessages:S,canSendGifs:Kt,isCurrentUserPremium:P}),i.ZP.createElement(qi,{isOpen:jt,withUsername:Boolean(Y),botCommands:_t,onClick:Tn,onClose:Gt}),i.ZP.createElement("div",{id:"message-compose"},i.ZP.createElement("div",{className:"svg-appendix",ref:Me}),i.ZP.createElement(_i,{onClear:vn}),i.ZP.createElement(Yi,{chatId:g,threadId:v,messageText:Ve.length?"":Ee,disabled:!tn}),i.ZP.createElement("div",{className:"message-input-wrapper"},b&&se&&"webApp"===se.type&&!m&&i.ZP.createElement(Qi,{isOpen:!Ee&&!bt,onClick:Pn,text:se.text,isDisabled:Boolean(bt)}),b&&Kn&&!1!==X&&!bt&&!m&&i.ZP.createElement(bi,{className:(0,Fe.Z)("bot-commands",Ke&&"activated"),round:!0,disabled:void 0===X,color:"translucent",onActivate:Cn,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:"icon-bot-commands-filled"})),xe&&(K||Q)&&i.ZP.createElement(pt.Z,{round:!0,color:"translucent",onClick:ot?lt:On,ariaLabel:Se("SendMessageAsTitle"),className:(0,Fe.Z)("send-as-button",ze.current&&"appear-animation")},i.ZP.createElement(kn.Z,{user:K,chat:Q,size:"tiny",noVideo:!0})),h.wB?i.ZP.createElement(pt.Z,{className:Jn,round:!0,color:"translucent",onClick:tt?it:Ln,ariaLabel:"Choose emoji, sticker or GIF"},i.ZP.createElement("i",{className:"icon-smile"}),i.ZP.createElement("i",{className:"icon-keyboard"}),tt&&!ht&&i.ZP.createElement(Zt.Z,{color:"gray"})):i.ZP.createElement(bi,{className:tt?"activated":"",round:!0,color:"translucent",onActivate:bn,ariaLabel:"Choose emoji, sticker or GIF"},i.ZP.createElement("i",{className:"icon-smile"})),i.ZP.createElement($i.Z,{id:"message-input-text",chatId:g,threadId:v,html:Ve.length?"":Ee,placeholder:bt&&Ae<=600?"":x||Se("Message"),forcedPlaceholder:Dt,canAutoFocus:c&&!Ve.length,shouldSuppressFocus:h.wB&&tt,shouldSuppressTextFormatter:rn||Nt||xt,onUpdate:Re,onSend:Yn,onSuppressedFocus:it}),J&&Boolean(Lt)&&i.ZP.createElement(Zt.Z,{color:"gray"}),L&&i.ZP.createElement(pt.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:Un,ariaLabel:"Open scheduled messages"},i.ZP.createElement("i",{className:"icon-schedule"})),B&&!bt&&!m&&i.ZP.createElement(bi,{className:Je?"activated":"",round:!0,color:"translucent",onActivate:Xe,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:"icon-bot-command"})),bt&&St&&i.ZP.createElement("span",{className:"recording-state"},(0,H.rM)(St-Et.current)),i.ZP.createElement(Ai,{chatId:g,isButtonVisible:!bt&&!m,canAttachMedia:Qt,canAttachPolls:en,onFileSelect:In,onPollCreate:he,isScheduled:n,attachMenuBots:ae,peerType:ie,theme:oe}),B&&i.ZP.createElement(Di,{messageId:B,isOpen:Je,onClose:Ye}),X&&i.ZP.createElement(Vi,{isOpen:Ke,botCommands:X,onClose:et}),i.ZP.createElement(Ui,{chatId:g,threadId:v,isOpen:an,onStickerSelect:En}),i.ZP.createElement(Fi.Z,{isOpen:rn,emojis:ln,onClose:cn,onEmojiSelect:dn,addRecentEmoji:ve}),i.ZP.createElement(Bi,{chatId:g,threadId:v,isOpen:tt||Le,canSendGifs:Kt,canSendStickers:Yt,onLoad:gt,onClose:it,onEmojiSelect:un,onStickerSelect:En,onGifSelect:Rn,onRemoveSymbol:mn,onSearchOpen:xn,addRecentEmoji:ve}))),bt&&i.ZP.createElement(pt.Z,{round:!0,color:"danger",className:"cancel",onClick:Pt,ariaLabel:"Cancel voice recording"},i.ZP.createElement("i",{className:"icon-delete"})),i.ZP.createElement(pt.Z,{ref:Mt,round:!0,color:"secondary",className:(0,Fe.Z)(Rt,!c&&"not-ready",bt&&"recording"),disabled:qn,ariaLabel:Se(zn),onClick:Fn,onContextMenu:Rt===eo.Send&&kt?Vt:void 0},i.ZP.createElement("i",{className:"icon-send"}),i.ZP.createElement("i",{className:"icon-schedule"}),i.ZP.createElement("i",{className:"icon-microphone-alt"}),i.ZP.createElement("i",{className:"icon-check"})),kt&&i.ZP.createElement(Oi.Z,{isOpen:zt,onSendSilent:S?void 0:Bn,onSendSchedule:n?void 0:Xn,onClose:Wt,onCloseAnimationEnd:Xt,isSavedMessages:S}),_e)}))),so=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"MobileSearch",!t,!0);return n?i.ZP.createElement(n,e):void 0})),ao=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"MessageSelectToolbar",!t);return n?i.ZP.createElement(n,e):void 0})),io=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"UnpinAllMessagesModal",!t);return n?i.ZP.createElement(n,e):void 0})),oo=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"SeenByModal",!t);return n?i.ZP.createElement(n,e):void 0})),ro=(0,i.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"EmojiInteractionAnimation",!t);return n?i.ZP.createElement(n,e):void 0})),co=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"ReactorListModal",!t);return n?i.ZP.createElement(n,e):void 0})),lo=h.wB?450+a.fK:void 0;function uo(e){return"file"===e.kind&&e.type&&a.oG.has(e.type)}const mo=(0,i.X$)((0,s.c$)((e=>{const t=(0,c.Pu)(e),{isBlurred:n,background:s,backgroundColor:a,patternColor:i}=e.settings.themes[t]||{},{messageLists:r}=e.messages,l=(0,c.Bt)(e),{isLeftColumnShown:u,chats:{listIds:m},activeEmojiInteractions:g,lastSyncTime:p}=e,f={theme:t,customBackground:s,backgroundColor:a,patternColor:i,isLeftColumnShown:u,isRightColumnShown:(0,c.Jf)(e),isBackgroundBlurred:n,isMobileSearchActive:Boolean(h.wB&&(0,c.n5)(e)),isSelectModeActive:(0,c.CA)(e),isSeenByModalOpen:Boolean(e.seenByModal),isReactorListModalOpen:Boolean(e.reactorModal),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,r.length-1),activeEmojiInteractions:g,lastSyncTime:p};if(!l||!m.active)return f;const{chatId:v,threadId:I,type:w}=l,y=(0,d.YC)(v),Z=(0,c.Z1)(e,v),P=(0,c.IK)(e,v),C=(0,c.KB)(e,v),{chatId:b,messageId:S}=e.audioPlayer,M=Z&&(0,d.Qm)(Z,I),E=(0,c.pk)(e,v),R="pinned"===w,k="scheduled"===w,N="thread"===w&&I===o._f,T=Boolean(Z&&(0,d.eA)(Z)),A=Boolean(Z&&N&&(T||(0,d.ZV)(Z))&&Z.isNotJoined&&!Z.joinRequests),B=Boolean((null==Z?void 0:Z.isNotJoined)&&Z.isJoinToSend),x=Boolean((null==Z?void 0:Z.isNotJoined)&&Z.isJoinRequest),L=Boolean(P&&(0,c.s4)(e,P.id)),O=!L&&E;return{...f,chatId:v,threadId:I,messageListType:w,isPrivate:y,areChatSettingsLoaded:Boolean(null==Z?void 0:Z.settings),canPost:!R&&(!Z||M)&&!E&&!(B&&null!=Z&&Z.isNotJoined),isPinnedMessageList:R,isScheduledMessageList:k,currentUserBannedRights:null==Z?void 0:Z.currentUserBannedRights,defaultBannedRights:null==Z?void 0:Z.defaultBannedRights,hasPinnedOrAudioPlayer:I!==o._f||Boolean(!R&&(null==C?void 0:C.length))||Boolean(b&&S),pinnedMessagesCount:C?C.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,isChannel:T,canSubscribe:A,canStartBot:O,canRestartBot:L,shouldJoinToSend:B,shouldSendJoinRequest:x}}))((e=>{let{chatId:t,threadId:n,messageListType:o,isPrivate:r,isPinnedMessageList:c,canPost:l,currentUserBannedRights:u,defaultBannedRights:m,hasPinnedOrAudioPlayer:g,pinnedMessagesCount:p,customBackground:f,theme:v,backgroundColor:I,patternColor:w,isLeftColumnShown:y,isRightColumnShown:Z,isBackgroundBlurred:P,isMobileSearchActive:C,isSelectModeActive:b,isSeenByModalOpen:S,isReactorListModalOpen:M,animationLevel:E,shouldSkipHistoryAnimations:R,currentTransitionKey:k,isChannel:N,areChatSettingsLoaded:T,canSubscribe:A,canStartBot:B,canRestartBot:x,activeEmojiInteractions:L,shouldJoinToSend:O,shouldSendJoinRequest:U,lastSyncTime:F}=e;const{openChat:q,openPreviousChat:D,unpinAllMessages:$,loadUser:j,loadChatSettings:G,closeLocalTextSearch:H,exitMessageSelectMode:_,joinChannel:z,sendBotCommand:V,restartBot:W,showNotification:J}=(0,s.Sv)(),{width:X}=(0,Vt.Z)(),Y=(0,rt.Z)(),[K,Q]=(0,i.eJ)(Ht.t.None),[ee,te]=(0,i.eJ)(),[ne,se]=(0,i.eJ)(),[ae,ie]=(0,i.eJ)(!1),oe=g&&(X<a.l3||Z&&X>a._m&&X<a.QU||X>=a.ks&&X<a.jT),re=(0,Wt.Z)(t,lo),ce=(0,Wt.Z)(n,lo),le=(0,Wt.Z)(o,lo),de=(0,Wt.Z)(A,lo),ue=(0,Wt.Z)(B,lo),me=(0,Wt.Z)(x,lo),he=(0,Wt.Z)(l,lo)&&!me&&!ue&&!de,ge=(0,Wt.Z)(oe,lo),Ie=(0,Wt.Z)(ee,lo),we=(0,Wt.Z)(N,lo),ye=(0,Wt.Z)(O,lo),Ze=(0,Wt.Z)(U,lo),Pe=(0,Jt.Z)(k),Ce=void 0!==Pe&&Pe<k?Pe:void 0,{isReady:be,handleOpenEnd:Se,handleSlideStop:Me}=function(e,t,n,s){const[a,o]=(0,i.eJ)(!h.wB),r=(0,We.Z)(),c=void 0!==n&&n!==t;return c&&(e?o(!1):r()),(0,Ge.Z)((()=>{e||o(!0)}),[e]),{isReady:a&&!c,handleOpenEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&o(Boolean(s))}:void 0,handleSlideStop:e?function(){o(!0)}:void 0}}(!R&&E!==a.oB,k,Pe,t);(0,i.d4)((()=>t?(0,nt.Z)((()=>{q({id:void 0})})):void 0),[t,q]),(0,Ge.Z)((()=>{Q(Ht.t.None),te(void 0),se(void 0)}),[t]),(0,i.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,i.d4)((()=>{r&&j({userId:t})}),[t,r,j]),(0,i.d4)((()=>{!T&&F&&G({chatId:t})}),[t,r,T,F,G]);const Ee=(0,i.I4)((e=>{if(h.$b)return;const{items:t}=e.dataTransfer||{},n=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(uo);Q(n?Ht.t.QuickFile:Ht.t.Document)}),[]),Re=(0,i.I4)((()=>{Q(Ht.t.None)}),[]),ke=(0,i.I4)((()=>{ie(!0)}),[]),Ne=(0,i.I4)((()=>{ie(!1)}),[]),Te=(0,i.I4)((()=>{$({chatId:t}),Ne(),D()}),[$,t,Ne,D]),Ae=(0,i.I4)((()=>{q({id:t})}),[q,t]),Be=(0,i.I4)((()=>{z({chatId:t}),Ze&&J({message:Y(N?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[z,t,Ze,J,N,Y]),xe=(0,i.I4)((()=>{V({command:"/start"})}),[V]),Le=(0,i.I4)((()=>{W({chatId:t})}),[t,W]),Oe=((e,t)=>{const[n,s]=(0,i.eJ)(t);return(0,i.d4)((()=>{t&&(t.startsWith("#")?s(t):_t.fetch(a.fo,e,_t.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,zt.pt)(t).then((()=>{s(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(v,f),Ue=(0,Fe.Z)(ge&&"has-header-tools",h.aZ?"mask-image-disabled":"mask-image-enabled"),qe=(0,Fe.Z)("ON5E8MkEVA1mAlkuIxhG","OWFg9Wf1uioPWDz_IgS8",f&&"Ik9ZZlj3eKtKXRrUZKVk",I&&"avVozLQe3SaWcSkIt6pG",f&&P&&"Tipa66fYcSvl6w0587Xz",Z&&"vhOr8s3T_LCKSt2BF7fs"),De=(0,Fe.Z)("messaging-disabled",!b&&"shown"),$e=(0,d.q8)(Y,u,m),{composerHiddenScale:je,toolbarHiddenScale:He,composerTranslateX:_e,toolbarTranslateX:ze,unpinHiddenScale:Ve,toolbarForUnpinHiddenScale:Xe}=(0,i.Ye)((()=>function(e,t){const n=e<=a.l3?16:32,s=function(e){if(e>a._m){const t=Math.min(Math.max(.25*e,ve),fe),n=Math.min(.25*e,fe);return Math.min(e-t-n,pe)}if(e>a.ks){const t=Math.min(Math.max(.4*e,ve),fe);return Math.min(e-t,pe)}return e>pe?pe:e}(e),i=e<=a.l3?54:64,o=t?s-n-i:s-n,r=e>a.l3?Math.min(s-n,512):s-n,c=r/o,l=o/r;return{composerHiddenScale:c,toolbarHiddenScale:l,composerTranslateX:t?i/2*l:0,toolbarTranslateX:t?i/2*-1*c:0,unpinHiddenScale:r/258,toolbarForUnpinHiddenScale:258/r}}(X,he)),[he,X]),Ye=(0,Fe.Z)("middle-column-footer",!he&&"no-composer",he&&ne&&!b&&"with-notch");(0,Je.Z)({isActive:b,onBack:_}),(0,Je.Z)({isActive:C,onBack:H});const Ke=Boolean(!c&&!he&&!me&&!ue&&!de&&$e),Qe=Boolean(me||de||ue||c),et=Boolean(Ke||b||c);return i.ZP.createElement("div",{id:"MiddleColumn",className:Ue,onTransitionEnd:Se,style:`\n --composer-hidden-scale: ${je};\n --toolbar-hidden-scale: ${He};\n --unpin-hidden-scale: ${Ve};\n --toolbar-unpin-hidden-scale: ${Xe};\n --composer-translate-x: ${_e}px;\n --toolbar-translate-x: ${ze}px;\n --pattern-color: ${w};\n --theme-background-color:\n ${I||("dark"===v?a.It:a.p3)};\n `,onClick:h.p7&&y?Ae:void 0},i.ZP.createElement("div",{className:qe,style:Oe?`--custom-background: ${Oe}`:void 0}),i.ZP.createElement("div",{id:"middle-column-portals"}),re&&ce&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"messages-layout",onDragEnter:he?Ee:void 0},i.ZP.createElement(Bn,{chatId:re,threadId:ce,messageListType:le,isReady:be}),i.ZP.createElement(ot.Z,{name:R?"none":E===a.zy?"slide":"fade",activeKey:k,shouldCleanup:!0,cleanupExceptionKey:Ce,onStop:Me},i.ZP.createElement(Ua,{key:`${re}-${ce}-${le}`,chatId:re,threadId:ce,type:le,canPost:he,hasTools:ge,onFabToggle:te,onNotchToggle:se,isReady:be,withBottomShift:Qe}),i.ZP.createElement("div",{className:Ye},he&&i.ZP.createElement(no,{chatId:re,threadId:ce,messageListType:le,dropAreaState:K,onDropHide:Re,isReady:be}),c&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},i.ZP.createElement(pt.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:ke},i.ZP.createElement("i",{className:"icon-unpin"}),i.ZP.createElement("span",null,Y("Chat.Pinned.UnpinAll",p,"i")))),Ke&&i.ZP.createElement("div",{className:De},i.ZP.createElement("div",{className:"messaging-disabled-inner"},i.ZP.createElement("span",null,$e))),h.wB&&(de||ye&&!Ze)&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},i.ZP.createElement(pt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Be},Y(we?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&Ze&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},i.ZP.createElement(pt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Be},Y("ChannelJoinRequest"))),h.wB&&ue&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},i.ZP.createElement(pt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:xe},Y("BotStart"))),h.wB&&me&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},i.ZP.createElement(pt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Le},Y("BotRestart"))),i.ZP.createElement(ao,{messageListType:le,isActive:b,canPost:he}),i.ZP.createElement(oo,{isOpen:S}),i.ZP.createElement(co,{isOpen:M}))),i.ZP.createElement(qa,{isShown:Ie,canPost:he,withExtraShift:et})),h.wB&&i.ZP.createElement(so,{isActive:Boolean(C)})),t&&i.ZP.createElement(io,{isOpen:ae,chatId:t,pinnedMessagesCount:p,onClose:Ne,onUnpin:Te}),i.ZP.createElement("div",{teactFastList:!0},null==L?void 0:L.map(((e,t)=>i.ZP.createElement(ro,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))))}))),ho=450+a.fK,go=(0,R.Ds)((e=>e()),200,!1);var po;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Statistics=4]="Statistics",e[e.MessageStatistics=5]="MessageStatistics",e[e.Management=6]="Management",e[e.ManageInitial=7]="ManageInitial",e[e.ManageChannelSubscribers=8]="ManageChannelSubscribers",e[e.ManageChatAdministrators=9]="ManageChatAdministrators",e[e.ManageChatPrivacyType=10]="ManageChatPrivacyType",e[e.ManageDiscussion=11]="ManageDiscussion",e[e.ManageGroupPermissions=12]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=13]="ManageGroupRemovedUsers",e[e.ManageChannelRemovedUsers=14]="ManageChannelRemovedUsers",e[e.ManageGroupUserPermissionsCreate=15]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=16]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=17]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=18]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=19]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=20]="ManageGroupMembers",e[e.ManageGroupAddAdmins=21]="ManageGroupAddAdmins",e[e.StickerSearch=22]="StickerSearch",e[e.GifSearch=23]="GifSearch",e[e.PollResults=24]="PollResults",e[e.AddingMembers=25]="AddingMembers",e[e.ManageInvites=26]="ManageInvites",e[e.ManageEditInvite=27]="ManageEditInvite",e[e.ManageReactions=28]="ManageReactions",e[e.ManageInviteInfo=29]="ManageInviteInfo",e[e.ManageJoinRequests=30]="ManageJoinRequests"}(po||(po={}));const fo=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s,a,i;let{chatId:o,isProfile:r,isManagement:l}=t;const{query:u}=(0,c.n5)(e)||{},{query:m}=(0,c.y5)(e)||{},{query:h}=(0,c.yN)(e)||{},g=o?(0,c.Z1)(e,o):void 0,p=g&&(0,d.eA)(g),f=r&&o&&(0,d.YC)(o)?(0,c.dy)(e,o):void 0,v=f&&(0,d.kw)(f),I=Boolean(!l&&r&&!v&&g&&!(0,c.FM)(e,g.id)&&((0,d.YC)(g.id)||((0,d.Nl)(g)||g.isCreator)&&!g.isNotJoined)),w=Boolean(o&&(null===(n=e.management.byChatId[o])||void 0===n?void 0:n.editingInvite)),y=null==g||null===(s=g.fullInfo)||void 0===s?void 0:s.canViewStatistics,Z=o?null===(a=e.management.byChatId[o])||void 0===a||null===(i=a.inviteInfo)||void 0===i?void 0:i.invite:void 0;return{canManage:I,canAddContact:v,canViewStatistics:y,isChannel:p,userId:null==f?void 0:f.id,messageSearchQuery:u,stickerSearchQuery:m,gifSearchQuery:h,isEditingInvite:w,currentInviteInfo:Z,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}))((e=>{var t;let{chatId:n,isColumnOpen:a,isProfile:o,isSearch:r,isManagement:c,isStatistics:l,isMessageStatistics:d,isStickerSearch:u,isGifSearch:g,isPollResults:p,isAddingChatMembers:f,profileState:v,managementScreen:I,canAddContact:w,userId:y,canManage:Z,isChannel:P,onClose:C,onScreenSelect:b,messageSearchQuery:S,stickerSearchQuery:M,gifSearchQuery:E,isEditingInvite:R,canViewStatistics:k,currentInviteInfo:N,shouldSkipHistoryAnimations:T}=e;const{setLocalTextSearchQuery:A,setStickerSearchQuery:B,setGifSearchQuery:x,searchTextMessagesLocal:L,toggleManagement:O,openHistoryCalendar:U,openAddContactDialog:F,toggleStatistics:q,setEditingExportedInvite:D,deleteExportedChatInvite:$}=(0,s.Sv)(),[j,G,_]=(0,at.Z)(),z=(0,i.I4)((()=>{D({chatId:n,invite:N}),b(m.u1.EditInvite)}),[n,N,b,D]),V=(0,i.I4)((()=>{$({chatId:n,link:N.link}),b(m.u1.Invites),_()}),[n,_,N,$,b]),W=(0,i.I4)((e=>{A({query:e}),e.length&&go(L)}),[L,A]),J=(0,i.I4)((e=>{B({query:e})}),[B]),X=(0,i.I4)((e=>{x({query:e})}),[x]),Y=(0,i.I4)((()=>{F({userId:y})}),[F,y]),[K,Q]=(0,i.eJ)(!a);(0,i.d4)((()=>{setTimeout((()=>{Q(!a)}),ho)}),[a]);const ee=(0,rt.Z)(),te=o?v===m.vi.Profile?po.Profile:v===m.vi.SharedMedia?po.SharedMedia:v===m.vi.MemberList?po.MemberList:-1:r?po.Search:p?po.PollResults:u?po.StickerSearch:g?po.GifSearch:f?po.AddingMembers:c?I===m.u1.Initial?po.ManageInitial:I===m.u1.ChatPrivacyType?po.ManageChatPrivacyType:I===m.u1.Discussion?po.ManageDiscussion:I===m.u1.ChannelSubscribers?po.ManageChannelSubscribers:I===m.u1.GroupPermissions?po.ManageGroupPermissions:I===m.u1.ChatAdministrators?po.ManageChatAdministrators:I===m.u1.GroupRemovedUsers?po.ManageGroupRemovedUsers:I===m.u1.ChannelRemovedUsers?po.ManageChannelRemovedUsers:I===m.u1.GroupUserPermissionsCreate?po.ManageGroupUserPermissionsCreate:I===m.u1.GroupUserPermissions?po.ManageGroupUserPermissions:I===m.u1.GroupRecentActions?po.ManageGroupRecentActions:I===m.u1.ChatAdminRights?po.ManageGroupAdminRights:I===m.u1.ChatNewAdminRights?po.ManageGroupNewAdminRights:I===m.u1.GroupMembers?po.ManageGroupMembers:I===m.u1.Invites?po.ManageInvites:I===m.u1.EditInvite?po.ManageEditInvite:I===m.u1.GroupAddAdmins?po.ManageGroupAddAdmins:I===m.u1.Reactions?po.ManageReactions:I===m.u1.InviteInfo?po.ManageInviteInfo:I===m.u1.JoinRequests?po.ManageJoinRequests:void 0:l?po.Statistics:d?po.MessageStatistics:void 0,ne=null!==(t=(0,Kt.Z)(te,!0))&&void 0!==t?t:-1,se=h.wB||te===po.SharedMedia||te===po.MemberList||te===po.AddingMembers||te===po.MessageStatistics||c,ae=(0,Fe.Z)("animated-close-icon",se&&"state-back",(K||T)&&"no-transition");return i.ZP.createElement("div",{className:"RightHeader"},i.ZP.createElement(pt.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:C,ariaLabel:ee(se?"Common.Back":"Common.Close")},i.ZP.createElement("div",{className:ae})),i.ZP.createElement(ot.Z,{name:K||T?"none":"slide-fade",activeKey:ne},function(){if(-1!==ne)switch(ne){case po.PollResults:return i.ZP.createElement("h3",null,ee("PollResults"));case po.Search:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(ft.Z,{parentContainerClassName:"RightSearch",value:S,onChange:W}),i.ZP.createElement(pt.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>U({selectedAt:(0,H._F)(Date.now())}),ariaLabel:"Search messages by date"},i.ZP.createElement("i",{className:"icon-calendar"})));case po.AddingMembers:return i.ZP.createElement("h3",null,ee(P?"ChannelAddSubscribers":"GroupAddMembers"));case po.ManageInitial:return i.ZP.createElement("h3",null,ee("Edit"));case po.ManageChatPrivacyType:return i.ZP.createElement("h3",null,ee(P?"ChannelTypeHeader":"GroupTypeHeader"));case po.ManageDiscussion:return i.ZP.createElement("h3",null,ee("Discussion"));case po.ManageChatAdministrators:return i.ZP.createElement("h3",null,ee("ChannelAdministrators"));case po.ManageGroupRecentActions:return i.ZP.createElement("h3",null,ee("Group.Info.AdminLog"));case po.ManageGroupAdminRights:return i.ZP.createElement("h3",null,ee("EditAdminRights"));case po.ManageGroupNewAdminRights:return i.ZP.createElement("h3",null,ee("SetAsAdmin"));case po.ManageGroupPermissions:return i.ZP.createElement("h3",null,ee("ChannelPermissions"));case po.ManageGroupRemovedUsers:return i.ZP.createElement("h3",null,ee("BlockedUsers"));case po.ManageChannelRemovedUsers:return i.ZP.createElement("h3",null,ee("ChannelBlockedUsers"));case po.ManageGroupUserPermissionsCreate:return i.ZP.createElement("h3",null,ee("ChannelAddException"));case po.ManageGroupUserPermissions:return i.ZP.createElement("h3",null,ee("UserRestrictions"));case po.ManageInvites:return i.ZP.createElement("h3",null,ee("lng_group_invite_title"));case po.ManageEditInvite:return i.ZP.createElement("h3",null,ee(R?"EditLink":"NewLink"));case po.ManageInviteInfo:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("h3",null,ee("InviteLink")),i.ZP.createElement("section",{className:"tools"},N&&!N.isRevoked&&i.ZP.createElement(pt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("Edit"),onClick:z},i.ZP.createElement("i",{className:"icon-edit"})),N&&N.isRevoked&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(pt.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:ee("Delete"),onClick:G},i.ZP.createElement("i",{className:"icon-delete"})),i.ZP.createElement(dn.Z,{isOpen:j,onClose:_,title:ee("DeleteLink"),text:ee("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:ee("Delete"),confirmHandler:V}))));case po.ManageJoinRequests:return i.ZP.createElement("h3",null,ee(P?"SubscribeRequests":"MemberRequests"));case po.ManageGroupAddAdmins:return i.ZP.createElement("h3",null,ee("Channel.Management.AddModerator"));case po.StickerSearch:return i.ZP.createElement(ft.Z,{value:M,placeholder:ee("SearchStickersHint"),autoFocusSearch:!0,onChange:J});case po.GifSearch:return i.ZP.createElement(ft.Z,{value:E,placeholder:ee("SearchGifsTitle"),autoFocusSearch:!0,onChange:X});case po.Statistics:return i.ZP.createElement("h3",null,ee(P?"ChannelStats.Title":"GroupStats.Title"));case po.MessageStatistics:return i.ZP.createElement("h3",null,ee("Stats.MessageTitle"));case po.SharedMedia:return i.ZP.createElement("h3",null,ee("SharedMedia"));case po.ManageChannelSubscribers:return i.ZP.createElement("h3",null,ee("ChannelSubscribers"));case po.MemberList:case po.ManageGroupMembers:return i.ZP.createElement("h3",null,ee("GroupMembers"));case po.ManageReactions:return i.ZP.createElement("h3",null,ee("Reactions"));default:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("h3",null,"Profile"),i.ZP.createElement("section",{className:"tools"},w&&i.ZP.createElement(pt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("AddContact"),onClick:Y},i.ZP.createElement("i",{className:"icon-add-user"})),Z&&i.ZP.createElement(pt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("Edit"),onClick:O},i.ZP.createElement("i",{className:"icon-edit"})),k&&i.ZP.createElement(pt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("Statistics"),onClick:q},i.ZP.createElement("i",{className:"icon-stats"}))))}}()))})));var vo=n(91);var Io=n(27407);function wo(e,t,n,s){const[i,o]=(0,Io.Z)(n?t:void 0,s,void 0,a.Vk);return[i,o,!(!i||!s||i[0]===s[0])]}function yo(e,t,n,s,o,r){const c=(0,i.sO)();(0,Ge.Z)((()=>{t===e&&o&&r&&(c.current=(0,d.R5)(o,r,e))}),[o,r,t,e]);const[l,u]=(0,Io.Z)(s?n:void 0,c.current,void 0,"media"===e?a.EN:a.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const Zo=(0,R.P2)((e=>e()),250,!1);let Po=!1;var Co=n(21273),bo=n(31876),So=n(20787),Mo=n(70180),Eo=n(13709),Ro=n(45418),ko=n(47262),No=n(41151),To=n(22275);const Ao=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function Bo(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const xo=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s;let{chatId:a}=t;const i=(0,c.Z1)(e,a),o=(0,c.Zw)(e,a),{currentType:r,resultsByType:l}=(0,c.we)(e)||{},{foundIds:u}=l&&r&&l[r]||{},{byId:m,statusesById:h}=e.users,{byId:g}=e.chats,p=i&&(0,d.Bf)(i),f=i&&(0,d.eA)(i),v=p||f&&(0,d.Nl)(i),I=null==i||null===(n=i.fullInfo)||void 0===n?void 0:n.members,w=v&&i&&(i.isForbidden||i.fullInfo&&!i.fullInfo.canViewMembers),y=v&&i&&((0,d.VE)(i,"inviteUsers")||!(0,d.Mg)(i,"inviteUsers")||i.isCreator),Z=v&&i&&((0,d.VE)(i,"banUsers")||i.isCreator),P=(0,c.xs)(e,a);let C,b,S;return(0,d.YC)(a)&&(b=a,S=(0,c.dy)(e,b),C=S&&!S.isSelf&&!(0,d.cS)(S)),{theme:(0,c.Pu)(e),isChannel:f,resolvedUserId:b,chatMessages:o,foundIds:u,mediaSearchType:r,hasCommonChatsTab:C,hasMembersTab:v,areMembersHidden:w,canAddMembers:y,canDeleteMembers:Z,currentUserId:e.currentUserId,isRightColumnShown:(0,c.Jf)(e),isRestricted:null==i?void 0:i.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:P,usersById:m,userStatusesById:h,chatsById:g,isChatProtected:null==i?void 0:i.isProtected,...v&&I&&{members:I},...C&&S&&{commonChatIds:null===(s=S.commonChats)||void 0===s?void 0:s.ids}}}))((e=>{let{chatId:t,profileState:n,onProfileStateChange:r,theme:c,isChannel:l,resolvedUserId:u,currentUserId:g,chatMessages:p,foundIds:f,mediaSearchType:v,hasCommonChatsTab:I,hasMembersTab:w,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,commonChatIds:C,members:b,usersById:S,userStatusesById:M,chatsById:E,isRightColumnShown:R,isRestricted:k,lastSyncTime:N,activeDownloadIds:T,serverTimeOffset:A,isChatProtected:B}=e;const{setLocalMediaSearchType:x,loadMoreMembers:L,loadCommonChats:O,openChat:U,searchMediaMessagesLocal:F,openMediaViewer:q,openAudioPlayer:D,focusMessage:$,loadProfilePhotos:j,setNewChatMembersDialogState:G}=(0,s.Sv)(),H=(0,i.sO)(null),_=(0,i.sO)(null),z=(0,rt.Z)(),[V,W]=(0,i.eJ)(0),[J,X]=(0,i.eJ)(),Y=(0,i.Ye)((()=>[...w?[{type:"members",title:l?"ChannelSubscribers":"GroupMembers"}]:[],...Ao,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,w,l]),K=Y[V].type,[Q,ee,te,ne]=function(e,t,n,s,a,o,r,c,l,u,m,h,g,p,f){let v=arguments.length>15&&void 0!==arguments[15]?arguments[15]:0;const I="members"!==a&&o?o:a,w=(0,i.Ye)((()=>{if(r&&l&&u)return(0,d.Z0)(r.map((e=>{let{userId:t}=e;return t})),l,u,void 0,v)}),[r,v,l,u]),y=(0,i.Ye)((()=>{if(c&&m)return(0,d.ih)(c,m,!0)}),[m,c]),[Z,P,C]=wo(0,t,f,w),[b,S,M]=yo("media",I,s,f,h,g),[E,R,k]=yo("documents",I,s,f,h,g),[N,T,A]=yo("links",I,s,f,h,g),[B,x,L]=yo("audio",I,s,f,h,g),[O,U,F]=yo("voice",I,s,f,h,g),[q,D,$]=wo(0,n,f,y);let j,G,H=!1;switch(I){case"members":j=Z,G=P,H=C;break;case"commonChats":j=q,G=D,H=$;break;case"media":j=b,G=S,H=M;break;case"documents":j=E,G=R,H=k;break;case"links":j=N,G=T,H=A;break;case"audio":j=B,G=x,H=L;break;case"voice":j=O,G=U,H=F}return[I,j,G,H]}(R,L,O,F,K,v,b,C,S,M,E,p,f,t,N,A),se=Y.findIndex((e=>{let{type:t}=e;return t===Q})),{handleScroll:ae}=function(e,t,n,s){(0,Gn.Z)((n=>{let[a]=n;if(a&&a!==t){const n=e.current,a=n.querySelector(".TabList");n.scrollTop<a.offsetTop&&(s("members"===t?m.vi.MemberList:m.vi.SharedMedia),Po=!0,(0,Fn.Z)(n,a,"start",void 0,void 0,void 0,300),setTimeout((()=>{Po=!1}),350))}}),[t,s]),(0,Gn.Z)((t=>{let[a]=t;if(n!==m.vi.Profile||n===a)return;const i=e.current;if(!i)return;const o=i.querySelector(".TabList");!o||o.offsetTop>i.scrollTop||(Po=!0,(0,Fn.Z)(i,i.firstElementChild,"start",void 0,2*i.offsetHeight),setTimeout((()=>{Po=!1}),350),s(n))}),[n]);const a=(0,i.I4)((()=>{const n=e.current;if(!n)return;const a=n.querySelector(".TabList");if(!a)return;let i=m.vi.Profile;n.scrollTop>=a.offsetTop&&(i="members"===t?m.vi.MemberList:m.vi.SharedMedia),s(i)}),[e,s,t]);return(0,i.d4)((()=>{Po||a()}),[a,t]),{handleScroll:(0,i.I4)((()=>{Po||Zo(a)}),[a])}}(H,K,n,r),{applyTransitionFix:ie,releaseTransitionFix:oe}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,i.d4)((()=>{function n(){const n=e.current,s=n.querySelector(t),a=n.querySelector(".TabList");s&&a&&(s.style.minHeight=n.offsetHeight-a.offsetHeight+"px")}return n(),window.addEventListener("resize",n,!1),()=>{window.removeEventListener("resize",n,!1)}}),[e,t]);const n=(0,i.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]),s=(0,i.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e]);return{applyTransitionFix:n,releaseTransitionFix:s}}(H),[re,ce]=(()=>{const[e,t]=(0,i.eJ)(!1);return[e,(0,i.I4)((()=>{t((e=>!e))}),[])]})(),{observe:le}=(0,Hn.S1)({rootRef:H,throttleMs:500}),de=(0,i.I4)((()=>{oe(),ce()}),[oe,ce]),ue=(0,i.I4)((()=>{G(m.WB.InProgress)}),[G]);(0,i.d4)((()=>{x({mediaType:K})}),[x,K]);const me=u||t;(0,i.d4)((()=>{N&&j({profileId:me})}),[j,me,N]);const he=(0,i.I4)((e=>{q({chatId:me,threadId:o._f,mediaId:e,origin:m.bZ.SharedMedia})}),[me,q]),ge=(0,i.I4)((e=>{D({chatId:me,messageId:e})}),[me,D]),pe=(0,i.I4)((e=>{U({id:e})}),[U]),fe=(0,i.I4)((e=>{$({chatId:me,messageId:e})}),[me,$]),ve=(0,i.I4)((()=>{X(void 0)}),[]);let Ie;(0,i.d4)((()=>{if(_.current&&h.$b)return(0,bt.sf)(_.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===bt.eM.Left?(W(Math.min(V+1,Y.length-1)),!0):t===bt.eM.Right&&(W(Math.max(0,V-1)),!0)})}),[V,Y.length]);const we="members"===Q||!w&&"media"===Q;we?Ie=R?0:1e3:ee||(Ie=a.Y);const ye=(0,ji.Z)([t,Q],Ie);return i.ZP.createElement(Co.Z,{ref:H,className:"Profile custom-scroll",itemSelector:Bo(Q),items:ye?ee:void 0,cacheBuster:re,sensitiveArea:a.qU,preloadBackwards:ye?"members"===Q?a.Vk:a.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:te,onScroll:ae},!ne&&function(e,t){return i.ZP.createElement("div",{className:"profile-info"},i.ZP.createElement(So.Z,{userId:t||e}),i.ZP.createElement(Mo.Z,{chatOrUserId:t||e}))}(t,u),!k&&i.ZP.createElement("div",{className:"shared-media"},i.ZP.createElement(ot.Z,{ref:_,name:z.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:se,renderCount:Y.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:ie,onStop:de},function(){if(!ee||!ye||!p){const e=we&&!ye,t=Boolean("members"===Q&&y);return i.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&i.ZP.createElement(Zt.Z,null),t&&i.ZP.createElement(ko.Z,{text:"You have no access to group members list."}))}if(!ee.length){let e;switch(Q){case"members":e=y?"You have no access to group members list.":"No members found";break;case"commonChats":e=z("NoGroupsInCommon");break;case"documents":e=z("lng_media_file_empty");break;case"links":e=z("lng_media_link_empty");break;case"audio":e=z("lng_media_song_empty");break;case"voice":e=z("lng_media_audio_empty");break;default:e=z("SharedMedia.EmptyTitle")}return i.ZP.createElement("div",{className:"content empty-list"},i.ZP.createElement(ko.Z,{text:e}))}return i.ZP.createElement("div",{className:`content ${Q}-list`,dir:z.isRtl&&"media"===Q?"rtl":void 0,teactFastList:!0},"media"===Q?ee.map((e=>p[e]&&i.ZP.createElement(Eo.Z,{key:e,message:p[e],isProtected:B||p[e].isProtected,observeIntersection:le,onClick:he}))):"documents"===Q?ee.map((e=>p[e]&&i.ZP.createElement(vs.Z,{key:e,message:p[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:T.includes(e),observeIntersection:le,onDateClick:fe}))):"links"===Q?ee.map((e=>p[e]&&i.ZP.createElement(Ro.Z,{key:e,message:p[e],isProtected:B||p[e].isProtected,observeIntersection:le,onMessageClick:fe}))):"audio"===Q?ee.map((e=>p[e]&&i.ZP.createElement(Is.ZP,{key:e,theme:c,message:p[e],origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:N,className:"scroll-item",onPlay:ge,onDateClick:fe,canDownload:!B&&!p[e].isProtected,isDownloading:T.includes(e)}))):"voice"===Q?ee.map((e=>p[e]&&i.ZP.createElement(Is.ZP,{key:e,theme:c,message:p[e],senderTitle:(0,vo.F)(z,p[e],E,S),origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:N,className:"scroll-item",onPlay:ge,onDateClick:fe,canDownload:!B&&!p[e].isProtected,isDownloading:T.includes(e)}))):"members"===Q?ee.map(((e,t)=>{return i.ZP.createElement(bo.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>pe(e),contextActions:(n=e,n!==g&&P?[{title:z("lng_context_remove_from_group"),icon:"stop",handler:()=>{X(n)}}]:void 0)},i.ZP.createElement(Qt.Z,{userId:e,forceShowSelf:!0}));var n})):"commonChats"===Q?ee.map(((e,t)=>i.ZP.createElement(bo.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>U({id:e})},i.ZP.createElement(en.Z,{chatId:e})))):void 0)}()),i.ZP.createElement(St.Z,{big:!0,activeTab:V,tabs:Y,onSwitchTab:W})),Z&&i.ZP.createElement(No.Z,{isShown:"members"===Q,onClick:ue,ariaLabel:z("lng_channel_add_users")},i.ZP.createElement("i",{className:"icon-add-user-filled"})),P&&i.ZP.createElement(To.Z,{isOpen:Boolean(J),userId:J,onClose:ve}))}))),Lo=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"RightSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)})),Oo=(0,i.X$)((e=>{const t=(0,kt.Z)(Rt.gl.Extra,"Management");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)})),Uo=e=>{const t=(0,kt.Z)(Rt.gl.Extra,"Statistics");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)},Fo=e=>{const t=(0,kt.Z)(Rt.gl.Extra,"MessageStatistics");return t?i.ZP.createElement(t,e):i.ZP.createElement(Nt.Z,null)},qo=(0,i.X$)((()=>{const e=(0,kt.Z)(Rt.gl.Extra,"StickerSearch");return e?i.ZP.createElement(e,null):i.ZP.createElement(Nt.Z,null)})),Do=(0,i.X$)((()=>{const e=(0,kt.Z)(Rt.gl.Extra,"GifSearch");return e?i.ZP.createElement(e,null):i.ZP.createElement(Nt.Z,null)})),$o=(0,i.X$)((()=>{const e=(0,kt.Z)(Rt.gl.Extra,"PollResults");return e?i.ZP.createElement(e,null):i.ZP.createElement(Nt.Z,null)}));var jo=n(11820);const Go=(0,i.X$)((0,s.c$)(((e,t)=>{var n;let{chatId:s}=t;const a=(0,c.Z1)(e,s),{userIds:i}=e.contactList||{},{byId:o}=e.chats,{currentUserId:r,newChatMembersProgress:l}=e,u=a&&(0,d.eA)(a),{query:h,fetchingStatus:g,globalUserIds:p,localUserIds:f}=e.userSearch;return{isChannel:u,members:null==a||null===(n=a.fullInfo)||void 0===n?void 0:n.members,currentUserId:r,chatsById:o,localContactIds:i,searchQuery:h,isSearching:g,isLoading:l===m.WB.Loading,globalUserIds:p,localUserIds:f}}))((e=>{let{isChannel:t,members:n,onNextStep:a,currentUserId:o,chatsById:r,localContactIds:c,isLoading:l,searchQuery:u,isSearching:m,localUserIds:h,globalUserIds:p,onClose:f,isActive:v}=e;const{setUserSearchQuery:I}=(0,s.Sv)(),w=(0,rt.Z)(),[y,Z]=(0,i.eJ)([]),P=(0,Jt.Z)(y)===y;(0,Je.Z)({isActive:v,onBack:f});const C=(0,i.Ye)((()=>n?n.map((e=>e.userId)):[]),[n]),b=(0,i.I4)((e=>{I({query:e})}),[I]),S=(0,i.Ye)((()=>{const e=(0,s.Rd)().users.byId,n=c?(0,d.kK)(c,e,u):[];return(0,d.ih)((0,g.Tw)([...n,...h||[],...p||[]]).filter((n=>{const s=e[n];return!C.includes(n)&&n!==o&&(!s||!(0,d.cS)(s)||!t&&s.canBeInvitedToGroup)})),r)}),[c,r,u,h,p,o,C,t]),M=(0,i.I4)((()=>{y.length&&(I({query:""}),a(y))}),[y,I,a]);return i.ZP.createElement("div",{className:"AddChatMembers"},i.ZP.createElement("div",{className:"AddChatMembers-inner"},i.ZP.createElement(jo.Z,{itemIds:S,selectedIds:y,filterValue:u,filterPlaceholder:w("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:m,onSelectedIdsChange:Z,onFilterChange:b,noScrollRestore:P}),i.ZP.createElement(No.Z,{isShown:Boolean(y.length),disabled:l,ariaLabel:w("lng_channel_add_users"),onClick:M},l?i.ZP.createElement(Zt.Z,{color:"white"}):i.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),Ho=450+a.fK,_o=Object.keys(m.qt).length/2,zo=Object.keys(m.u1).length/2;function Vo(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Wo=(0,i.X$)((0,s.c$)((e=>{var t;const{chatId:n,threadId:s}=(0,c.Bt)(e)||{},a=(0,c.g4)(e),i=n?null===(t=e.management.byChatId[n])||void 0===t?void 0:t.nextScreen:void 0;return{contentKey:(0,c.Wq)(e),chatId:n,threadId:s,isChatSelected:Boolean(n&&a),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,nextManagementScreen:i}}))((e=>{var t;let{contentKey:n,chatId:o,threadId:r,isChatSelected:c,shouldSkipHistoryAnimations:l,nextManagementScreen:d}=e;const{toggleChatInfo:u,toggleManagement:h,closeLocalTextSearch:g,setStickerSearchQuery:p,setGifSearchQuery:f,closePollResults:v,addChatMembers:I,setNewChatMembersDialogState:w,setEditingExportedInvite:y,toggleStatistics:Z,toggleMessageStatistics:P,setOpenedInviteInfo:C,requestNextManagementScreen:b}=(0,s.Sv)(),{width:S}=(0,Vt.Z)(),[M,E]=(0,i.eJ)(m.vi.Profile),[R,k]=(0,i.eJ)(m.u1.Initial),[N,T]=(0,i.eJ)(),[A,B]=(0,i.eJ)(),x=M!==m.vi.Profile,L=void 0!==n,O=n===m.qt.ChatInfo,U=n===m.qt.Search,F=n===m.qt.Management,q=n===m.qt.Statistics,D=n===m.qt.MessageStatistics,$=n===m.qt.StickerSearch,j=n===m.qt.GifSearch,G=n===m.qt.PollResults,H=n===m.qt.AddingMembers,_=S<=a._m,[z,V]=(0,i.eJ)(!L),W=null!==(t=(0,Kt.Z)(n,!0,!c))&&void 0!==t?t:-1,J=(0,i.I4)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];switch(n){case m.qt.AddingMembers:w(m.WB.Closed);break;case m.qt.ChatInfo:if(x&&e){E(m.vi.Profile);break}u(void 0,{forceSyncOnIOs:!0});break;case m.qt.Management:switch(R){case m.u1.Initial:h();break;case m.u1.ChatPrivacyType:case m.u1.Discussion:case m.u1.GroupPermissions:case m.u1.GroupType:case m.u1.ChatAdministrators:case m.u1.ChannelSubscribers:case m.u1.GroupMembers:case m.u1.Invites:case m.u1.Reactions:case m.u1.JoinRequests:case m.u1.ChannelRemovedUsers:k(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:k(m.u1.GroupPermissions),T(void 0),B(void 0);break;case m.u1.ChatAdminRights:case m.u1.ChatNewAdminRights:case m.u1.GroupAddAdmins:case m.u1.GroupRecentActions:k(m.u1.ChatAdministrators);break;case m.u1.EditInvite:case m.u1.InviteInfo:k(m.u1.Invites),C({invite:void 0}),y({chatId:o,invite:void 0})}break;case m.qt.MessageStatistics:P();break;case m.qt.Statistics:Z();break;case m.qt.Search:Vo(),g();break;case m.qt.StickerSearch:Vo(),p({query:void 0});break;case m.qt.GifSearch:Vo(),f({query:void 0});break;case m.qt.PollResults:v()}}),[n,x,u,v,w,R,h,g,p,f,y,o,C,Z,P]),X=(0,i.I4)(((e,t)=>{T(e),B(t)}),[]),Y=(0,i.I4)((e=>{I({chatId:o,memberIds:e})}),[I,o]);function K(e){if(-1!==W)switch(W){case m.qt.AddingMembers:return i.ZP.createElement(Go,{key:o,chatId:o,isActive:L&&e,onNextStep:Y,onClose:J});case m.qt.ChatInfo:return i.ZP.createElement(xo,{key:o,chatId:o,profileState:M,onProfileStateChange:E});case m.qt.Search:return i.ZP.createElement(Lo,{chatId:o,threadId:r,onClose:J,isActive:L&&e});case m.qt.Management:return i.ZP.createElement(Oo,{key:o,chatId:o,currentScreen:R,isPromotedByCurrentUser:A,selectedChatMemberId:N,isActive:L&&e,onScreenSelect:k,onChatMemberSelect:X,onClose:J});case m.qt.Statistics:return i.ZP.createElement(Uo,{chatId:o});case m.qt.MessageStatistics:return i.ZP.createElement(Fo,{chatId:o,isActive:L&&e});case m.qt.StickerSearch:return i.ZP.createElement(qo,{onClose:J,isActive:L&&e});case m.qt.GifSearch:return i.ZP.createElement(Do,{onClose:J,isActive:L&&e});case m.qt.PollResults:return i.ZP.createElement($o,{onClose:J,isActive:L&&e})}}return(0,i.d4)((()=>L?(0,nt.Z)(J):void 0),[L,J]),(0,i.d4)((()=>{setTimeout((()=>{V(!L)}),Ho)}),[L]),(0,i.d4)((()=>{d&&(k(d),b(void 0))}),[d,b]),(0,i.d4)((()=>{L&&_&&J()}),[_]),(0,jn.Z)((e=>{let[t]=e;t!==o&&(E(m.vi.Profile),k(m.u1.Initial))}),[o]),(0,Je.Z)({isActive:c&&(n===m.qt.ChatInfo||n===m.qt.Management||n===m.qt.AddingMembers),onBack:()=>J(!1)}),i.ZP.createElement("div",{id:"RightColumn-wrapper",className:c?void 0:"is-hidden"},_&&i.ZP.createElement("div",{className:"overlay-backdrop",onClick:J}),i.ZP.createElement("div",{id:"RightColumn"},i.ZP.createElement(fo,{chatId:o,isColumnOpen:L,isProfile:O,isSearch:U,isManagement:F,isStatistics:q,isMessageStatistics:D,isStickerSearch:$,isGifSearch:j,isPollResults:G,isAddingChatMembers:H,profileState:M,managementScreen:R,onClose:J,onScreenSelect:k}),i.ZP.createElement(ot.Z,{name:z||l?"none":"zoom-fade",renderCount:_o+zo,activeKey:F?_o+R:W,shouldCleanup:!0,cleanupExceptionKey:W===m.qt.MessageStatistics?m.qt.Statistics:void 0},K)))}))),Jo=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,kt.Z)(Rt.gl.Extra,"MediaViewer",!t);return n?i.ZP.createElement(n,null):void 0}));let Xo=[],Yo=!1;function Ko(e,t){Xo.push({url:e,filename:t}),Yo||(Yo=!0,setTimeout((async()=>{await async function(){let e=0;for(const t of Xo)Qo(t),e++,10===e&&(await(0,R.wO)(1e3),e=0);Xo=[]}(),Yo=!1}),1e3))}function Qo(e){let{url:t,filename:n}=e;const s=document.createElement("a");s.href=t,s.download=n;try{s.click()}catch(e){console.error(e)}}const er=new Set,tr=new Set,nr=(0,i.X$)((0,s.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})))((e=>{let{activeDownloads:t,messages:n}=e;const{cancelMessagesMediaDownload:a,showNotification:r}=(0,s.Sv)(),c=(0,qn.Z)(1e3,!0),l=(0,i.I4)((e=>{tr.add(e),c((()=>{tr.size&&(a({messages:Array.from(tr)}),tr.clear())}))}),[a,c]);(0,i.d4)((()=>{const e=Object.entries(t).map((e=>{let[t,s]=e;return s.map((e=>n[t].byId[e]))})).flat();e.length?e.forEach((e=>{var t;if(er.has(e))return;er.add(e);const n=(0,d.Ti)(e,"download");if(!n)return void l(e);const s=he.UV(n);if(s)return Ko(s,(0,d.w6)(e)),void l(e);const{document:a,video:i,audio:c}=e.content;if(((null===(t=a||i||c)||void 0===t?void 0:t.size)||0)>h.l0&&!h.rT&&!h.Mc)return r({message:"Downloading files bigger than 2GB is not supported in your browser."}),void l(e);const u=(0,d.kG)(e,"download");he.he(n,u,!0).then((t=>{if(u===o.IU.DownloadUrl){const n=new URL(t,window.document.baseURI),s=(0,d.w6)(e);n.searchParams.set("filename",encodeURIComponent(s));const a=window.open(n.toString());null==a||a.addEventListener("beforeunload",(()=>{r({message:"Download started. Please, do not close the app before it is finished."})}))}else t&&Ko(t,(0,d.w6)(e));l(e)}))})):er.clear()}),[n,t,a,l,r])})));var sr=n(65116),ar=n(13103);const ir=(0,i.X$)((e=>{let{openedGame:t,gameTitle:n}=e;const{closeGame:s,showNotification:a,openForwardMenu:o}=(0,sr.Sv)(),r=(0,rt.Z)(),{url:c,chatId:l,messageId:d}=t||{},u=Boolean(c),m=(0,Xa.Z)(l);(0,Dn.Z)((()=>{m({type:"playingGame"})}),u?5e3:void 0);const h=(0,i.I4)((e=>{try{const t=JSON.parse(e.data);"share_score"===t.eventType&&(o({fromChatId:l,messageIds:[d],withMyScore:!0}),s()),"share_game"===t.eventType&&a({message:"Unsupported game action"})}catch(e){}}),[l,s,d,o,a]),g=(0,i.I4)((e=>{e.currentTarget.focus()}),[]);return(0,i.d4)((()=>(window.addEventListener("message",h),()=>window.removeEventListener("message",h))),[h]),(0,i.d4)((()=>{if(u)return Ie.Z.disableRefresh(),()=>{Ie.Z.enableRefresh()}}),[u]),i.ZP.createElement(ar.Z,{className:"GameModal",isOpen:u,onClose:s,title:n,hasCloseButton:!0},u&&i.ZP.createElement("iframe",{className:"game-frame",onLoad:g,src:c,title:r("AttachGame"),sandbox:"allow-scripts allow-same-origin allow-orientation-lock",allow:"fullscreen"}))})),or=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,kt.Z)(Rt.gl.Extra,"Notifications",!t);return n?i.ZP.createElement(n,null):void 0})),rr=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,kt.Z)(Rt.gl.Extra,"Dialogs",!t);return n?i.ZP.createElement(n,null):void 0})),cr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"ForwardPicker",!t);return n?i.ZP.createElement(n,e):void 0})),lr=(0,i.X$)((e=>{const{url:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"SafeLinkModal",!t);return n?i.ZP.createElement(n,e):void 0})),dr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"HistoryCalendar",!t);return n?i.ZP.createElement(n,e):void 0})),ur=(0,i.X$)((e=>{const{groupCallId:t}=e,n=(0,kt.Z)(Rt.gl.Calls,"GroupCall",!t);return n?i.ZP.createElement(n,e):void 0})),mr=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,kt.Z)(Rt.gl.Calls,"ActiveCallHeader",!t);return n?i.ZP.createElement(n,null):void 0})),hr=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,kt.Z)(Rt.gl.Calls,"PhoneCall",!t);return n?i.ZP.createElement(n,null):void 0}));var gr=n(15780);function pr(){return pr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},pr.apply(this,arguments)}const fr=(0,i.X$)((0,sr.c$)((e=>({messageLists:e.messages.messageLists})))((e=>{let{messageLists:t}=e;const{openChat:n}=(0,sr.Sv)(),s=()=>{n({id:void 0},{forceSyncOnIOs:!0})},a=e=>{let{chatId:t,type:n,threadId:a}=e;(0,Je.Z)({isActive:!0,hash:(0,gr.q)(t,n,a),onBack:s})};return i.ZP.createElement("div",null,null==t?void 0:t.map(((e,t)=>i.ZP.createElement(a,pr({key:`${e.chatId}_${e.threadId}_${e.type}_${t}`},e)))))}))),vr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"NewContactModal",!t);return n?i.ZP.createElement(n,e):void 0})),Ir=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Calls,"RatePhoneCallModal",!t);return n?i.ZP.createElement(n,e):void 0})),wr=(0,i.X$)((e=>{const{webApp:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"WebAppModal",!t);return n?i.ZP.createElement(n,e):void 0})),yr=(0,i.X$)((e=>{const{bot:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"BotTrustModal",!t);return n?i.ZP.createElement(n,e):void 0})),Zr=(0,i.X$)((e=>{const{bot:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"BotAttachModal",!t);return n?i.ZP.createElement(n,e):void 0}));var Pr=n(80036);const Cr={root:"vfd0Bo1X6k19aaxQ577t"},br=h.wB?50:100,Sr=["#E8BC2C","#D0049E","#02CBFE","#5723FD","#FE8C27","#6CB859"],Mr=(0,i.X$)((0,s.c$)((e=>(0,g.ei)(e,["confetti"])))((e=>{let{confetti:t}=e;const n=(0,i.sO)(null),s=(0,i.sO)([]),a=(0,i.sO)(!1),o=(0,Vt.Z)(),r=(0,We.Z)(),{lastConfettiTime:c,top:l,width:d,left:u,height:m}=t||{},h=()=>{if(!n.current||!a.current)return;const e=n.current,t=e.getContext("2d");if(!t)return;const{width:i,height:o}=e;t.clearRect(0,0,i,o);const r=[];s.current.forEach(((e,n)=>{const{pos:a,velocity:i,size:c,color:l,flicker:d,flickerFrequency:u,rotation:m,lastDrawnAt:h,frameCount:g}=e,p=(Date.now()-h)/1e3,f={x:a.x+i.x*p,y:a.y+i.y*p},v={x:.98*i.x,y:i.y+=1e3*p},I=c*Math.abs(Math.sin(g*u)),w=5*g*u*(Math.PI/180),y=g+1,Z=Date.now();if(f.y>o+e.size)return void r.push(e);const P={...e,pos:f,velocity:v,flicker:I,rotation:w,lastDrawnAt:Z,frameCount:y};s.current[n]=P,t.fillStyle=l,t.beginPath(),t.ellipse(a.x,a.y,c,d,m,0,2*Math.PI),t.fill()})),s.current=s.current.filter((e=>!r.includes(e))),s.current.length?requestAnimationFrame(h):a.current=!1};if((0,Ge.Z)((e=>{let t,[n]=e;return n!==c&&(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:br;for(let a=0;a<n;a++){const n=a%2,i={x:e*(n?-.1:1.1),y:.75*t},o=Math.random()*e*1.5,r={x:n?o:-1*o,y:-t/2-Math.random()*t},c=Sr[Math.floor(Math.random()*Sr.length)],l=10;s.current.push({pos:i,size:l,color:c,velocity:r,flicker:l,flickerFrequency:.2*Math.random(),rotation:0,lastDrawnAt:Date.now(),frameCount:0})}}(d||o.width,m||o.height),t=setTimeout(r,1e4),a.current||(a.current=!0,requestAnimationFrame(h))),()=>{t&&clearTimeout(t)}}),[c,h]),!c||Date.now()-c>1e4)return;const g=(0,Pr.Z)(Boolean(l)&&`top: ${l}px`,Boolean(u)&&`left: ${u}px`,Boolean(d)&&`width: ${d}px`,Boolean(m)&&`height: ${m}px`);return i.ZP.createElement("div",{id:"Confetti",className:Cr.root,style:g},i.ZP.createElement("canvas",{ref:n,className:Cr.canvas,width:o.width,height:o.height}))}))),Er=(0,i.X$)((e=>{const{urlAuth:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"UrlAuthModal",!t);return n?i.ZP.createElement(n,e):void 0})),Rr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"PremiumMainModal",!t);return n?i.ZP.createElement(n,e):void 0})),kr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"PaymentModal",!t);return n?i.ZP.createElement(n,e):void 0})),Nr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"ReceiptModal",!t);return n?i.ZP.createElement(n,e):void 0})),Tr=(0,i.X$)((e=>{const{limit:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"PremiumLimitReachedModal",!t);return n?i.ZP.createElement(n,e):void 0})),Ar=(0,i.X$)((e=>{const{deleteFolderDialogId:t}=e,n=(0,kt.Z)(Rt.gl.Extra,"DeleteFolderDialog",!t);return n?i.ZP.createElement(n,e):void 0}));let Br,xr=!1;function Lr(e){document.querySelectorAll('link[rel="icon"], link[rel="alternate icon"]').forEach((t=>{e?t.href.includes("favicon-unread")||(t.href=t.href.replace("favicon","favicon-unread")):t.href=t.href.replace("favicon-unread","favicon")}))}function Or(e){document.title!==e&&(document.title=e)}const Ur=(0,i.X$)((0,s.c$)((e=>{var t,n,s,a,i;const{settings:{byKey:{animationLevel:o,language:r,wasTimeFormatSetManually:l}},botTrustRequest:d,botAttachRequest:u}=e,{chatId:m,messageId:h}=e.audioPlayer,g=m&&h?(0,c.hj)(e,m,h):void 0,p=e.openedGame,f=p&&(0,c.hj)(e,p.chatId,p.messageId),v=null==f||null===(t=f.content.game)||void 0===t?void 0:t.title,I=e.currentUserId?(0,c.dy)(e,e.currentUserId):void 0;return{connectionState:e.connectionState,authState:e.authState,lastSyncTime:e.lastSyncTime,isLeftColumnOpen:e.isLeftColumnShown,isRightColumnOpen:(0,c.Jf)(e),isMediaViewerOpen:(0,c.zQ)(e),isForwardModalOpen:(0,c.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:g,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,c.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:o,language:r,wasTimeFormatSetManually:l,isPhoneCallActive:Boolean(e.phoneCall),addedSetIds:e.stickers.added.setIds,newContactUserId:null===(n=e.newContact)||void 0===n?void 0:n.userId,newContactByPhoneNumber:null===(s=e.newContact)||void 0===s?void 0:s.isByPhoneNumber,openedGame:p,gameTitle:v,isRatePhoneCallModalOpen:Boolean(e.ratingPhoneCall),botTrustRequest:d,botTrustRequestBot:d&&(0,c.dy)(e,d.botId),botAttachRequestBot:u&&(0,c.dy)(e,u.botId),webApp:e.webApp,currentUser:I,urlAuth:e.urlAuth,isPremiumModalOpen:null===(a=e.premiumModal)||void 0===a?void 0:a.isOpen,limitReached:null===(i=e.limitReachedModal)||void 0===i?void 0:i.limit,isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),deleteFolderDialogId:e.deleteFolderDialogModal}}))((e=>{let{connectionState:t,authState:n,lastSyncTime:o,isLeftColumnOpen:r,isRightColumnOpen:c,isMediaViewerOpen:l,isForwardModalOpen:d,hasNotifications:u,hasDialogs:m,audioMessage:g,activeGroupCallId:p,safeLinkModalUrl:f,isHistoryCalendarOpen:v,shouldSkipHistoryAnimations:I,limitReached:w,openedStickerSetShortName:y,isServiceChatReady:Z,animationLevel:P,language:C,wasTimeFormatSetManually:b,addedSetIds:S,isPhoneCallActive:M,newContactUserId:E,newContactByPhoneNumber:k,openedGame:N,gameTitle:T,isRatePhoneCallModalOpen:A,botTrustRequest:B,botTrustRequestBot:x,botAttachRequestBot:L,webApp:O,currentUser:U,urlAuth:F,isPremiumModalOpen:q,isPaymentModalOpen:D,isReceiptModalOpen:$,deleteFolderDialogId:j}=e;const{sync:G,loadAnimatedEmojis:H,loadNotificationSettings:_,loadNotificationExceptions:z,updateIsOnline:V,loadTopInlineBots:J,loadEmojiKeywords:X,loadCountryList:Y,loadAvailableReactions:K,loadStickerSets:Q,loadAddedStickers:ee,loadFavoriteStickers:te,ensureTimeFormat:ne,openStickerSetShortName:se,checkVersionNotification:ae,loadAppConfig:ie,loadAttachMenuBots:oe,loadContactList:re,closePaymentModal:ce,clearReceipt:le}=(0,s.Sv)();a.eM&&!xr&&(xr=!0,console.log(">>> RENDER MAIN")),(0,i.d4)((()=>{"connectionStateReady"===t&&"authorizationStateReady"===n&&G()}),[t,n,G]),(0,i.d4)((()=>{o&&(V(!0),ie(),K(),H(),_(),z(),J(),X({language:a.pR}),oe(),re())}),[o,H,X,z,_,J,V,K,ie,oe,re]),(0,i.d4)((()=>{o&&(C!==a.pR&&X({language:C}),Y({langCode:C}))}),[C,o,Y,X]),(0,i.d4)((()=>{o&&(S?ee():(Q(),te()))}),[o,S,Q,te,ee]),(0,i.d4)((()=>{o&&Z&&ae()}),[o,Z,ae]),(0,i.d4)((()=>{o&&!b&&ne()}),[o,b,ne]),(0,i.d4)((()=>{o&&Je.O.startsWith("#?tgaddr=")&&(0,De.o)(decodeURIComponent(Je.O.substr("#?tgaddr=".length)))}),[o]),(0,i.d4)((()=>{if(p)return Ie.Z.disableRefresh(),()=>{Ie.Z.enableRefresh()}}),[p]);const de=(0,Xe.Z)(r,void 0,!0,void 0,I),ue=(0,i.sO)(!1),me=(0,We.Z)();(0,Ge.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;ue.current=!0,h.wZ&&(0,R.T2)((()=>{document.body.classList.toggle("android-left-blackout-open",!r)}));const n=(0,Ue.YW)();(0,qe.L)(document.getElementById("MiddleColumn"),(()=>{n(),ue.current=!1,me()}))}),[r]);const he=(0,Xe.Z)(c,void 0,!0,void 0,I),ge=(0,i.sO)(!1),[pe,fe]=(0,i.eJ)(c);(0,Ge.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;ge.current=!0;const n=(0,Ue.YW)();(0,qe.L)(document.getElementById("RightColumn"),(()=>{n(),ge.current=!1,me(),fe(c)}))}),[c]);const ve=(0,Fe.Z)(de.hasShownClass&&"left-column-shown",de.hasOpenClass&&"left-column-open",ue.current&&"left-column-animating",he.hasShownClass&&"right-column-shown",he.hasOpenClass&&"right-column-open",ge.current&&"right-column-animating",pe&&"narrow-message-list",I&&"history-animation-disabled"),we=(0,i.I4)((()=>{V(!1);const e=(0,W.xW)();let t=0;clearInterval(Br),Br=window.setInterval((()=>{if(document.title.includes(a.ou))Lr(!1);else{if(t%2==0){const t=(0,W.xW)()-e;t>0&&(Or(`${t} notification${t>1?"s":""}`),Lr(!0))}else Or(a.Ti),Lr(!1);t++}}),1e3)}),[V]),ye=(0,i.I4)((()=>{V(!0),clearInterval(Br),Br=void 0,document.title.includes(a.ou)||Or(a.Ti),Lr(!1)}),[V]),Ze=(0,i.I4)((()=>{se({stickerSetShortName:void 0})}),[se]);return(0,$e.Z)(we,ye),je(we),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,i.d4)((()=>{if(h.$b){if(!e)return null==He||He.setAttribute("content",_e),h.cj&&!h.fl&&document.addEventListener("gesturestart",Ve),()=>{null==He||He.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",Ve)};null==He||He.setAttribute("content",ze)}}),[e])}(l),i.ZP.createElement("div",{id:"Main",className:ve},i.ZP.createElement(Gt,null),i.ZP.createElement(mo,null),i.ZP.createElement(Wo,null),i.ZP.createElement(Jo,{isOpen:l}),i.ZP.createElement(cr,{isOpen:d}),i.ZP.createElement(or,{isOpen:u}),i.ZP.createElement(rr,{isOpen:m}),g&&i.ZP.createElement(Rn,{key:g.id,message:g,noUi:!0}),i.ZP.createElement(lr,{url:f}),i.ZP.createElement(Er,{urlAuth:F,currentUser:U}),i.ZP.createElement(dr,{isOpen:v}),i.ZP.createElement(Ye.Z,{isOpen:Boolean(y),onClose:Ze,stickerSetShortName:y}),p&&i.ZP.createElement(ur,{groupCallId:p}),i.ZP.createElement(mr,{isActive:Boolean(p||M)}),i.ZP.createElement(vr,{isOpen:Boolean(E||k),userId:E,isByPhoneNumber:k}),i.ZP.createElement(ir,{openedGame:N,gameTitle:T}),i.ZP.createElement(wr,{webApp:O}),i.ZP.createElement(nr,null),i.ZP.createElement(Mr,null),i.ZP.createElement(hr,{isActive:M}),i.ZP.createElement(tt,{isForAppBadge:!0}),i.ZP.createElement(Ir,{isOpen:A}),i.ZP.createElement(yr,{bot:x,type:null==B?void 0:B.type}),i.ZP.createElement(Zr,{bot:L}),i.ZP.createElement(fr,null),q&&i.ZP.createElement(Rr,{isOpen:q}),i.ZP.createElement(Tr,{limit:w}),i.ZP.createElement(kr,{isOpen:D,onClose:ce}),i.ZP.createElement(Nr,{isOpen:$,onClose:le}),i.ZP.createElement(Ar,{deleteFolderDialogId:j}))})));var Fr=n(99364),qr=n(88033);var Dr=n(2092);const $r=(0,i.X$)((0,s.c$)((e=>({passcodeSettings:e.passcode})))((e=>{let{isLocked:t,passcodeSettings:n}=e;const{unlockScreen:a,signOut:o,logInvalidUnlockAttempt:r,resetInvalidUnlockAttempts:c}=(0,s.Sv)(),{invalidAttemptsCount:l,isLoading:d}=n,u=(0,rt.Z)(),[m,h]=(0,i.eJ)(""),[g,p]=(0,i.eJ)(!1),[f,v,I]=(0,at.Z)(!1),{transitionClassNames:w,shouldRender:y}=(0,Xe.Z)(t);(0,aa.Z)(c,l&&l>=5?18e4:void 0);const Z=(0,i.I4)((()=>{h("")}),[]),P=(0,i.I4)((e=>{l&&l>=5?h(u("FloodWait")):(h(""),(0,M.so)(e).then(a,(()=>{r(),h(u("lng_passcode_wrong"))})))}),[l,u,r,a]);(0,i.d4)((()=>{l&&l>=5?h(u("FloodWait")):0===l&&h("")}),[l,u]);const C=(0,i.I4)((()=>{I(),o()}),[I,o]);if(y)return i.ZP.createElement("div",{className:(0,Fe.Z)("sY59IPNwkaRsrfYPhEJc",w)},i.ZP.createElement("div",{className:"DlErQEIDwmZ0duQgO_2b",dir:u.isRtl?"rtl":void 0},i.ZP.createElement(ks.Z,{tgsUrl:Es.l.Lock,previewUrl:Dr,size:160,className:"ar9YdQbWJreREHmnZa9m"}),i.ZP.createElement(Fr.Z,{key:"password-form",shouldShowSubmit:!0,shouldDisablePasswordManager:!0,isLoading:d,error:m,placeholder:u("Passcode.EnterPasscodePlaceholder"),submitLabel:u("Next"),clearError:Z,isPasswordVisible:g,noRipple:!0,onChangePasswordVisibility:p,onSubmit:P}),i.ZP.createElement("div",{className:"uOmdTQr_cJEvuTkQipx7"},i.ZP.createElement("p",null,i.ZP.createElement(qr.Z,{onClick:v},"Log out")," ","if you don't remember your passcode."),i.ZP.createElement("p",null,i.ZP.createElement(pt.Z,{color:"translucent",size:"tiny",isText:!0,onClick:v},u("AccountSettings.Logout"))))),i.ZP.createElement(dn.Z,{isOpen:f,onClose:I,text:u("lng_sure_logout"),confirmLabel:u("AccountSettings.Logout"),confirmHandler:C,confirmIsDestructive:!0}))})));a.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE");const{connectionState:jr,passcode:{isScreenLocked:Gr}}=(0,s.Rd)();jr||Gr||(0,s.Sv)().initApi()},68973:(e,t,n)=>{e.exports=n.p+"encoderWorker.min.8ea62f6317fbac7d4558.js"}}]);
//# sourceMappingURL=5769.d2b8af27d159fb4beb9a.js.map