2 lines
341 KiB
JavaScript
2 lines
341 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[5769],{86475:(e,t,n)=>{n.r(t),n.d(t,{LockScreen:()=>mc,Main:()=>cc});var s=n(33555),a=n(83716),o=n(14050),i=(n(89005),n(6137)),r=n(5161),c=n(11192),l=n(70735),d=n(56112);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:o}=n,i=(0,d.uw)(s,a),{query:u}=e.localTextSearch.byChatThreadKey[i]||{};return o!==u&&(e=(0,r.Pb)(e,s,a,l.D)),(0,r.qr)(e,s,a,!0,o)})),(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:o,threadId:l=i._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===o&&h.threadId===l&&h.type===d||(o&&(e=(0,r.pf)(e,o,l,"replyStack",[])),e=u(e=(0,r.i9)(e)),e={...e,isStatisticsShown:!1,messages:{...e.messages,contentToBeScheduled:void 0},...o!==e.forwardMessages.toChatId&&{forwardMessages:{}}}),(0,r.Wy)(e,o,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)("openChatWithDraft",((e,t,n)=>{const{chatId:s,text:a,files:o}=n;return s&&t.openChat({id:s}),{...e,requestedDraft:{chatId:s,text:a,files:o}}})),(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:o}=(0,c.Bt)(e)||{};if(!o)return void t.openChat({id:a[0]});const i=a.indexOf(o);if(-1===i)return;const r=a[i+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),w=n(996),y=n(42986);const P=a.ck+a.fK;let Z;function C(e,t,n){const{type:s,threadId:a}=(0,c.Bt)(e)||{},o=v.i0,i="scheduled"===s?(0,c.Fn)(e,t):(0,c.Zw)(e,t);if(!i||!a)return;const r=n.map((e=>i[e])).filter((t=>(0,c._k)(e,t,a).canCopy)).sort(((e,t)=>e.id-t.id)),l=r.reduce(((t,n)=>{const s=(0,c.Ur)(e,n);return t.push(`> ${s?(0,d.OU)(o,s):""}:`),t.push(`${function(e,t){var n;const s=(0,y.Eb)(t),a=s?`${s} `:"",o=null===(n=(0,w.X)(t,void 0,void 0,void 0,void 0,void 0,!0))||void 0===n?void 0:n.join("");return`${a}${(0,y.Kk)(e,t,o,!0,!0)}`}(o,n)}\n`),t}),[]),u=r.reduce(((t,n)=>{const s=(0,c.Ur)(e,n);return t.push(`> ${s?(0,d.OU)(o,s):""}:`),t.push(`${(0,d.MK)(o,n,!1,0,void 0,!0)}\n`),t}),[]);(0,I.qN)(l.join("\n"),u.join("\n"))}(0,s.iw)("setScrollOffset",((e,t,n)=>{const{chatId:s,threadId:a,scrollOffset:o}=n;return(0,r.pf)(e,s,a,"scrollOffset",o)})),(0,s.iw)("setReplyingToId",((e,t,n)=>{const{messageId:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:o,threadId:i}=a;return(0,r.pf)(e,o,i,"replyingToId",s)})),(0,s.iw)("setEditingId",((e,t,n)=>{const{messageId:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:o,threadId:i,type:l}=a,d="scheduled"===l?"editingScheduledId":"editingId";return(0,r.pf)(e,o,i,d,s)})),(0,s.iw)("setEditingDraft",((e,t,n)=>{const{text:s,chatId:a,threadId:o,type:i}=n,c="scheduled"===i?"editingScheduledDraft":"editingDraft";return(0,r.pf)(e,a,o,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 o=(0,g.dF)(a,(t=>Boolean(s[t]&&(0,c._k)(e,s[t],n).canEdit)));return o?(0,r.pf)(e,t,n,"editingId",o):void 0})),(0,s.iw)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:s}=n,{chatId:a,threadId:o}=(0,c.Bt)(e)||{};if(!a||!o)return;const r=(0,c.Zw)(e,a),l=(0,c.Cb)(e,a,o);if(!r||!l)return;const d=(0,c.Yy)(e,a,o);let u;if((0,c.b9)(e,a,o)&&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(o===i._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,o);u=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:u}),t.focusMessage({chatId:a,threadId:o,messageId:u})})),(0,s.iw)("openAudioPlayer",((e,t,n)=>{const{chatId:s,threadId:a,messageId:o,origin:i,volume:r,playbackRate:c,isMuted:l}=n;return{...e,audioPlayer:{chatId:s,threadId:a,messageId:o,origin:null!=i?i: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:o}=n;if((0,c.Jf)(e)){if(a!==e.pollResults.chatId||o!==e.pollResults.messageId)return{...e,pollResults:{chatId:a,messageId:o,voters:{}}}}else window.setTimeout((()=>{e=(0,s.Rd)(),(0,s.R3)({...e,pollResults:{chatId:a,messageId:o,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 o;if(a===i._f){var r;const t=(0,c.Z1)(e,s);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,c.tZ)(e,s,a);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:s,threadId:a,messageId:o,noHighlight:!0})})),(0,s.iw)("focusNextReply",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:a,threadId:o}=n,i=(0,c.p9)(e,a,o);if(i&&0!==i.length){const n=i.pop();e=(0,r.pf)(e,a,o,"replyStack",[...i]),(0,s.R3)(e),t.focusMessage({chatId:a,threadId:o,messageId:n})}else t.focusLastMessage()})),(0,s.iw)("focusMessage",((e,t,n)=>{const{chatId:a,threadId:o=i._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),w=!I||a!==I.chatId||o!==I.threadId||l!==I.type;if(Z&&(clearTimeout(Z),Z=void 0),Z=window.setTimeout((()=>{let e=(0,s.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,s.R3)(e)}),d?P: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,o)||[];e=(0,r.pf)(e,a,o,"replyStack",[...t,g])}w&&(e=(0,r.wV)(e,m.fo.Static));const y=(0,c.Cb)(e,a,o);if(y&&y.includes(v))return(0,s.R3)(e),void t.openChat({id:a,threadId:o,shouldReplaceHistory:f});if(w&&(e=(0,r.pf)(e,a,o,"viewportIds",void 0)),e=(0,r.pf)(e,a,o,"outlyingIds",void 0),y&&!w){const t=v>y[0]?m.fo.Down:m.fo.Up;e=(0,r.wV)(e,t)}(0,s.R3)(e),t.openChat({id:a,threadId:o,shouldReplaceHistory:f}),t.loadViewportMessages()})),(0,s.iw)("openForwardMenu",((e,t,n)=>{const{fromChatId:s,messageIds:a,groupedId:o,withMyScore:i}=n;let r;return o&&(r=(0,c.xH)(e,s,o)),{...e,forwardMessages:{fromChatId:s,messageIds:r||a,isModalShown:!0,withMyScore:i}}})),(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)("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,o=e.activeDownloads.byChatId[a.chatId];o&&o.length&&(0,s.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:o.filter((e=>e!==a.id))}}})})),(0,s.iw)("cancelMessagesMediaDownload",((e,t,n)=>{const{messages:s}=n,a=e.activeDownloads.byChatId,o={};return Object.keys(a).forEach((e=>{o[e]=a[e].filter((e=>!s.find((t=>t.id===e))))})),{...e,activeDownloads:{byChatId:o}}})),(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)||{},o=(0,c.Zw)(e,n);o&&a&&s.map((e=>o[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:o,childMessageIds:i,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,o,i,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)=>{if(a.V6&&Date.now()>Number(a.V6)+2592e5)return;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 o={chatId:a.aw,date:(0,p.b)(e.serverTimeOffset),content:{text:(0,f.Z)("**Telegram Web Z was updated to version 1.56**\n\n[👏](customEmoji:5471921242866981303) **Harder**\n• Formatting is now preserved when pasting text from websites or Telegram messages.\n• The input field is automatically highlighted when you open a chat – so you can start typing right away.\n• Your account's profile pictures can now be deleted by clicking your profile picture in Settings.\n• Native system sharing is available when running the app as a PWA.\n\n[🤩](customEmoji:5373026167722876724) **Better**\n• A list of group members now appears when typing @ to help mention users even faster.\n\n[🚀](customEmoji:5445284980978621387) **Faster**\n• Plenty of improvements and optimizations for stickers and custom emoji rendering – adding a noticeable performance increase.\n\n[💪](customEmoji:5471883477219549006) **Stronger**\n• Various fixes for copying text from messages.\n• Various fixes for custom emoji.\n• Fixed opening the symbol menu on certain touchscreen devices.\n• Fixed the quoted header disappearing when typing a reply.\n• Various layout improvements.\n",!0)},isOutgoing:!1};t.createServiceNotification({message:o,version:n})})),(0,s.iw)("createServiceNotification",((e,t,n)=>{var o;const{message:i,version:r}=n,{serviceNotifications:l}=e,d=(0,c.Z1)(e,a.aw),u=Math.max((null===(o=d.lastMessage)||void 0===o?void 0:o.id)||0,...l.map((e=>{let{id:t}=e;return t}))),m=(l.length+1)/1e3,h=Math.floor(u)+m;i.previousLocalId=i.id,i.id=h;const g={id:h,message:i,version:r,isUnread:!0};(0,s.R3)({...e,serviceNotifications:[...l.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:i.id,chatId:i.chatId,message:i})})),(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;C(e,t,n)})),(0,s.iw)("copyMessagesByIds",((e,t,n)=>{const{messageIds:s}=n,a=(0,c.jr)(e);s&&0!==s.length&&a&&C(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 o=a.filter((e=>e!==s));return o.unshift(s),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(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 b=n(91947),E=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 o=a.filter((e=>e!==s));return o.unshift(s),o.length>32&&o.pop(),{...e,recentEmojis:o}})),(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 o=a.stickers.filter((e=>e.id!==s.id));return o.unshift(s),{...e,stickers:{...e.stickers,recent:{...a,stickers:o}}}})),(0,s.iw)("addRecentCustomEmoji",((e,t,n)=>{const{documentId:s}=n,{recentCustomEmojis:a}=e;if(!a)return{...e,recentCustomEmojis:[s]};const o=a.filter((e=>e!==s));return o.unshift(s),o.length>32&&o.pop(),{...e,recentCustomEmojis:o}})),(0,s.iw)("clearRecentCustomEmoji",(e=>({...e,recentCustomEmojis:[]}))),(0,s.iw)("reorderStickerSets",((e,t,n)=>{const{order:s,isCustomEmoji:a}=n;return{...e,stickers:{...e.stickers,[a?"customEmoji":"added"]:{setIds:s}}}})),(0,s.iw)("showNotification",((e,t,n)=>{const s=n;s.localId=(0,E.Z)({});const a=[...e.notifications],o=a.findIndex((e=>e.message===s.message));return-1!==o&&a.splice(o,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,b.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:o,messageId:i}=n,r=(0,c.hj)(e,o,i);if(!r)return;const l=r.viaBotId||r.senderId;l&&((0,c.LM)(e,l)?(0,s.R3)({...e,openedGame:{url:a,chatId:o,messageId:i}}):(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:o,height:i}=n||{},{animationLevel:r}=e.settings.byKey;if(0!==r)return{...e,confetti:{lastConfettiTime:Date.now(),top:s,left:a,width:o,height:i}}})),(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)("closeStickerSetModal",(e=>({...e,openedStickerSetShortName:void 0}))),(0,s.iw)("openCustomEmojiSets",((e,t,n)=>{const{setIds:s}=n;return{...e,openedCustomEmojiSetIds:s}})),(0,s.iw)("closeCustomEmojiSets",(e=>({...e,openedCustomEmojiSetIds:void 0}))),(0,s.iw)("updateLastRenderedCustomEmojis",((e,t,n)=>{const{ids:s}=n,{lastRendered:o}=e.customEmojis;return{...e,customEmojis:{...e.customEmojis,lastRendered:(0,g.Tw)([...o,...s]).slice(0,a.j7)}}})),(0,s.iw)("checkAppVersion",(()=>{const e=/^\d+\.\d+(\.\d+)?$/;fetch(`version.txt?${Date.now()}`).then((e=>e.text())).then((t=>{t=t.trim(),e.test(t)&&t!==a.Ji&&(0,s.R3)({...(0,s.Rd)(),isUpdateAvailable:!0})})).catch((e=>{a.eM&&console.error("[checkAppVersion failed] ",e)}))})),(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 S=n(88422);(0,s.iw)("openMediaViewer",((e,t,n)=>{const{chatId:s,threadId:a,mediaId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c,volume:l,playbackRate:d,isMuted:u}=n;return{...e,mediaViewer:{...e.mediaViewer,chatId:s,threadId:a,mediaId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c,isHidden:!1,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,isHidden:a}=e.mediaViewer;return{...e,mediaViewer:{volume:t,isMuted:n,isHidden:a,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}}})),(0,s.iw)("setMediaViewerHidden",((e,t,n)=>{const s=n;return{...e,mediaViewer:{...e.mediaViewer,isHidden:s}}}));var M=n(3100),R=n(95281),k=n(5872),T=n(69118),A=n(35369);let N=!1;(0,T.Gq)((()=>{(0,s.Rd)().passcode.hasPasscode&&!N&&(0,M.jv)()})),(0,s.iw)("setPasscode",(async(e,t,n)=>{let{passcode:a}=n;(0,s.R3)((0,r.vu)(e,{isLoading:!0})),await(0,R.AU)(a);const o=JSON.stringify({...(0,M.K8)(),userId:e.currentUserId}),i=(0,k.Uf)((0,r.vu)((0,s.Rd)(),{hasPasscode:!0,error:void 0,isLoading:!1}));await(0,R.H4)(o,i),(0,s.R3)((0,r.vu)((0,s.Rd)(),{hasPasscode:!0,error:void 0,isLoading:!1})),(0,k.jA)(!0)})),(0,s.iw)("clearPasscode",(e=>((0,R.C8)(),(0,r.Kn)(e)))),(0,s.iw)("unlockScreen",((e,t,n)=>{let{sessionJson:a,globalJson:o}=n;const i=JSON.parse(a);(0,M.wX)(i,i.userId),e=JSON.parse(o),(0,k.nE)(e,(0,g.Xh)(A.Y)),(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",(()=>{N=!0})),n(65456);var B=n(27225),x=n(71226),L=n(81396);const O=new Map,F=(0,T.Ds)((e=>e()),500,!1);async function U(e,t,n,o){let i=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(o){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,x.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.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],P=[].concat(p,y),Z=(0,g.ee)(P,"id"),C=Object.keys(Z).map(Number);w=(0,r.c_)(w,d,Z),w=i?(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 E=(0,c.qC)(w,d,t);if(i&&b&&E&&(E.length&&!(0,g.YE)(b,E)||(w=(0,r.xj)(w,d,t,E),b=(0,c.gb)(w,d,t),w=(0,r.pf)(w,d,t,"outlyingIds",void 0),i=!1)),!l){const e=i?E:b,{newViewportIds:s}=j(e,n,o);w=(0,r.y9)(w,d,t,s)}(0,s.R3)(w)}function j(e,t,n){const{length:s}=e,o=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,i=n===m.Uq.Backwards?o:o+1||s,r=i-a.hT,c=i+a.hT-1,l=e.slice(Math.max(0,r),c+1);let d,u;switch(n){case m.Uq.Backwards:d=i>0,u=r>=0;break;case m.Uq.Forwards:d=i<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 D(e){let t;const n=e.attachment?(e,a)=>{O.has(a)||(t=a,O.set(a,n));const o=(0,s.Rd)();(0,s.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,T.Pn)();const a=(0,s.Rd)();e.serverTimeOffset=a.serverTimeOffset;const o=(0,c.Bt)(a);if(!o)return;const{threadId:r}=o;e.replyingTo||r===i._f||(e.replyingTo=(0,c.qS)(a,e.chat.id,r)),e.replyingTo&&!e.replyingToTopId&&r!==i._f&&(e.replyingToTopId=(0,c.qS)(a,e.chat.id,r)),await(0,x.t9)("sendMessage",e,n),n&&t&&O.delete(t)}(0,s.iw)("loadViewportMessages",((e,t,n)=>{const{direction:s=m.Uq.Around,isBudgetPreload:o=!1}=n||{};let{chatId:i,threadId:l}=n||{};if(!i){const t=(0,c.Bt)(e);if(!t)return;i=t.chatId,l=t.threadId}const d=(0,c.Z1)(e,i);if(!d||d.isRestricted)return;const u=(0,c.Cb)(e,i,l),h=(0,c.gb)(e,i,l),g=(0,c.qC)(e,i,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}=j(c,n,s);if(f&&(e=(0,r.y9)(e,i,l,p)),(0,T.R3)((()=>{!async function(e,t,n,s,a,o,i,r){t||await U(a,o,r,i,n,s),s||e.loadViewportMessages({chatId:a.id,threadId:o,direction:i,isBudgetPreload:!0})}(t,v,a,o,d,l,s,n)})),o)return}else{const t=(0,c.G$)(e,i)||(0,c.rd)(e,i,l),n=Boolean(t&&h&&!h.includes(t)),s=(n?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=j(s,t,m.Uq.Around);p&&u.length>=a.hT&&(e=(0,r.y9)(e,i,l,u)),f||(0,T.R3)((()=>{U(d,l,t,m.Uq.Around,n,o)}))}return e})),(0,s.iw)("loadMessage",(async(e,t,n)=>{const{chatId:a,messageId:o,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,x.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===i._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 o=(0,s.Rd)();return o=(0,r.cY)(o,e.id,t,a.message),o=(0,r.Sh)(o,(0,g.ee)(a.users,"id")),(0,s.R3)(o),a.message}(u,o,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:o,threadId:i,type:r}=s;if("scheduled"===r&&!n.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:n}};const l=(0,c.Z1)(e,o),d={...n,chat:l,replyingTo:(0,c.Yy)(e,o,i),noWebPage:(0,c.tV)(e,o,i),sendAs:(0,c._5)(e,o)};t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:i,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;D({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:n,...s}=d,o=(0,g.Vl)(n,a.DU);for(let n=0;n<o.length;n++){const[a,...i]=o[n],r=`${Date.now()}${n}`;D({...s,text:0===n?e:void 0,entities:0===n?t:void 0,attachment:a,groupedId:i.length>0?r:void 0}),i.forEach((e=>{D({...s,attachment:e,groupedId:r})}))}}else{const{text:e,entities:t,attachments:n,replyingTo:s,...a}=d;e&&D({...a,text:e,entities:t,replyingTo:s}),n.forEach((e=>{D({...a,attachment:e})}))}})),(0,s.iw)("editMessage",((e,t,n)=>{const{serverTimeOffset:s}=e,{text:a,entities:o}=n,i=(0,c.Bt)(e);if(!i)return;const{chatId:r,threadId:l,type:d}=i,u=(0,c.Z1)(e,r),m=(0,c.kK)(e,r,l,d);u&&m&&((0,x.t9)("editMessage",{chat:u,message:m,text:a,entities:o,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,o=(0,c.hj)(e,s,a),i=o&&O.get((0,d.KK)(o));i&&(0,x.u3)(i),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:s})})),(0,s.iw)("saveDraft",(async(e,t,n)=>{const{chatId:a,threadId:o,draft:l}=n;if(!l)return;const{text:u,entities:m}=l,h=(0,c.Z1)(e,a),g=(0,c.dy)(e,a);g&&(0,d.NB)(g)||(o===i._f&&(await(0,x.t9)("saveDraft",{chat:h,text:u,entities:m,replyToMsgId:(0,c.Yy)(e,a,o)})||(l.isLocal=!0)),e=(0,s.Rd)(),e=(0,r.pf)(e,a,o,"draft",l),e=(0,r.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)}),(0,s.R3)(e))})),(0,s.iw)("clearDraft",((e,t,n)=>{const{chatId:s,threadId:a,localOnly:o}=n;if(!(0,c.Ms)(e,s,a))return;const l=(0,c.Z1)(e,s);return o||a!==i._f||(0,x.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:o}=n;return(0,r.pf)(e,s,a,"noWebPage",o)})),(0,s.iw)("pinMessage",((e,t,n)=>{const s=(0,c.jr)(e);if(!s)return;const{messageId:a,isUnpin:o,isOneSide:i,isSilent:r}=n;(0,x.t9)("pinMessage",{chat:s,messageId:a,isUnpin:o,isOneSide:i,isSilent:r})})),(0,s.iw)("unpinAllMessages",((e,t,n)=>{const a=(0,c.Z1)(e,n.chatId);a&&async function(e){await(0,x.t9)("unpinAllMessages",{chat:e});let t=(0,s.Rd)();t=(0,r.pf)(t,e.id,i._f,"pinnedIds",[]),(0,s.R3)(t)}(a)})),(0,s.iw)("deleteMessages",((e,t,n)=>{const{messageIds:s,shouldDeleteForAll:a}=n,o=(0,c.Bt)(e);if(!o)return;const{chatId:i,threadId:r}=o,l=(0,c.Z1)(e,i);(0,x.t9)("deleteMessages",{chat:l,messageIds:s,shouldDeleteForAll:a});const d=(0,c._$)(e,i,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:o}=a,i=(0,c.Z1)(e,o);(0,x.t9)("deleteScheduledMessages",{chat:i,messageIds:s});const r=(0,c.wU)(e,o);s.includes(r)&&t.setEditingId({messageId:void 0})})),(0,s.iw)("deleteHistory",(async(e,t,n)=>{const{chatId:s,shouldDeleteForAll:a}=n,o=(0,c.Z1)(e,s);if(!o)return;await(0,x.t9)("deleteHistory",{chat:o,shouldDeleteForAll:a});const i=(0,c.Bt)(e);i&&i.chatId===s&&t.openChat({id:void 0})})),(0,s.iw)("reportMessages",(async(e,t,n)=>{const{messageIds:s,reason:a,description:o}=n,i=(0,c.Bt)(e);if(!i)return;const{chatId:r}=i,l=(0,c.Z1)(e,r),d=await(0,x.t9)("reportMessages",{peer:l,messageIds:s,reason:a,description:o});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:o}=n;if(a===e.currentUserId)return;const i=(0,c.Z1)(e,a);if(!i)return;const r=(0,c.dy)(e,a);r&&((0,d.cS)(r)||(0,d.NB)(r))||await(0,x.t9)("sendMessageAction",{peer:i,threadId:o,action:s})})),(0,s.iw)("markMessageListRead",((e,t,n)=>{const{serverTimeOffset:s}=e,o=(0,c.Bt)(e);if(!o)return;const{chatId:l,threadId:d}=o,u=(0,c.Cm)(e,l,d);if(!u)return;const{maxId:m}=n;if(F((()=>{(0,x.t9)("markMessageListRead",{serverTimeOffset:s,chat:u,threadId:d,maxId:m})})),d!==i._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,o=e.length;a<o&&(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,x.t9)("markMessagesRead",{chat:s,messageIds:a})})),(0,s.iw)("loadWebPagePreview",((e,t,n)=>{const{text:a}=n;!async function(e){const t=await(0,x.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:o}=n,i=(0,c.Z1)(e,s);i&&(0,x.t9)("sendPollVote",{chat:i,messageId:a,options:o})})),(0,s.iw)("cancelPollVote",((e,t,n)=>{const{chatId:s,messageId:a}=n,o=(0,c.Z1)(e,s);o&&(0,x.t9)("sendPollVote",{chat:o,messageId:a,options:[]})})),(0,s.iw)("closePoll",((e,t,n)=>{var s;const{chatId:a,messageId:o}=n,i=(0,c.Z1)(e,a),r=null===(s=(0,c.hj)(e,a,o))||void 0===s?void 0:s.content.poll;i&&r&&(0,x.t9)("closePoll",{chat:i,messageId:o,poll:r})})),(0,s.iw)("loadPollOptionResults",((e,t,n)=>{const{chat:a,messageId:o,option:i,offset:c,limit:l,shouldResetVoters:d}=n;!async function(e,t,n,a,o,i){const c=await(0,x.t9)("loadPollOptionResults",{chat:e,messageId:t,option:n,offset:a,limit:o});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)([...!i&&d&&d[n]?d[n]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[n]:c.nextOffset||""}}})}(a,o,i,c,l,d)})),(0,s.iw)("loadExtendedMedia",((e,t,n)=>{const{chatId:s,ids:a}=n,o=(0,c.Z1)(e,s);o&&(0,x.t9)("fetchExtendedMedia",{chat:o,ids:a})})),(0,s.iw)("forwardMessages",((e,t,n)=>{const{fromChatId:a,messageIds:o,toChatId:i,withMyScore:r,noAuthors:l,noCaptions:u}=e.forwardMessages,m=(0,c.wV)(e),h=a?(0,c.Z1)(e,a):void 0,g=i?(0,c.Z1)(e,i):void 0,p=a&&o?o.sort(((e,t)=>e-t)).map((t=>(0,c.hj)(e,a,t))).filter(Boolean):void 0;if(!h||!g||!p)return;const{isSilent:f,scheduledAt:v}=n,I=(0,c._5)(e,i),w=p.filter((e=>!(0,d.jM)(e)));w.length&&(0,x.t9)("forwardMessages",{fromChat:h,toChat:g,messages:w,serverTimeOffset:(0,s.Rd)().serverTimeOffset,isSilent:f,scheduledAt:v,sendAs:I,withMyScore:r,noAuthors:l,noCaptions:u,isCurrentUserPremium:m}),p.filter((e=>(0,d.jM)(e))).forEach((e=>{const{text:t,entities:n}=e.content.text||{},{sticker:s,poll:a}=e.content;D({chat:g,text:t,entities:n,sticker:s,poll:a,isSilent:f,scheduledAt:v,sendAs:I})})),(0,s.R3)({...(0,s.Rd)(),forwardMessages:{}})})),(0,s.iw)("loadScheduledHistory",((e,t,n)=>{const{chatId:a}=n,o=(0,c.Z1)(e,a);o&&async function(e){const t=await(0,x.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:n}=t,a=(0,g.ee)(n,"id"),o=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,i._f,"scheduledIds",o),(0,s.R3)(c)}(o)})),(0,s.iw)("sendScheduledMessages",((e,t,n)=>{const{chatId:s,id:a}=n,o=(0,c.Z1)(e,s);o&&(0,x.t9)("sendScheduledMessages",{chat:o,ids:[a]})})),(0,s.iw)("rescheduleMessage",((e,t,n)=>{const{chatId:s,messageId:a,scheduledAt:o}=n,i=(0,c.Z1)(e,s),r=i&&(0,c.Tm)(e,i.id,a);i&&r&&(0,x.t9)("rescheduleMessage",{chat:i,message:r,scheduledAt:o})})),(0,s.iw)("requestThreadInfoUpdate",((e,t,n)=>{const{chatId:s,threadId:a}=n,o=(0,c.Cm)(e,s,a);o&&(0,x.t9)("requestThreadInfoUpdate",{chat:o,threadId:a})})),(0,s.iw)("transcribeAudio",(async(e,t,n)=>{const{messageId:a,chatId:o}=n,i=(0,c.Z1)(e,o);if(!i)return;e=(0,r.cY)(e,o,a,{transcriptionId:""}),(0,s.R3)(e);const l=await(0,x.t9)("transcribeAudio",{chat:i,messageId:a});e=(0,r.cY)((0,s.Rd)(),o,a,{transcriptionId:l,isTranscriptionError:!l}),(0,s.R3)(e)})),(0,s.iw)("loadCustomEmojis",(async(e,t,n)=>{const{ids:a,ignoreCache:o}=n,i=o?a:(0,g.Tw)(a.filter((t=>!e.customEmojis.byId[t]))),r=await(0,x.t9)("fetchCustomEmoji",{documentId:i});r&&(e=(0,s.Rd)(),(0,s.R3)({...e,customEmojis:{...e.customEmojis,byId:{...e.customEmojis.byId,...(0,g.ee)(r,"id")}}}))})),(0,s.iw)("loadPinnedMessages",((e,t,n)=>{const{chatId:a}=n,o=(0,c.Z1)(e,a);o&&async function(e){const t=await(0,x.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:n,chats:a,users:o}=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,i._f,"pinnedIds",l),d=(0,r.Sh)(d,(0,g.ee)(o,"id")),d=(0,r.fZ)(d,(0,g.ee)(a,"id")),(0,s.R3)(d)}(o)})),(0,s.iw)("loadSeenBy",(async(e,t,n)=>{const{chatId:a,messageId:o}=n,i=(0,c.Z1)(e,a);if(!i)return;const l=await(0,x.t9)("fetchSeenBy",{chat:i,messageId:o});l&&(0,s.R3)((0,r.cY)((0,s.Rd)(),a,o,{seenByUserIds:l}))})),(0,s.iw)("saveDefaultSendAs",((e,t,n)=>{const{chatId:s,sendAsId:a}=n,o=(0,c.Z1)(e,s),i=(0,c.Z1)(e,a)||(0,c.dy)(e,a);if(o&&i)return(0,x.t9)("saveDefaultSendAs",{sendAs:i,chat:o}),(0,r.a4)(e,s,{fullInfo:{...o.fullInfo,sendAsId:a}})})),(0,s.iw)("loadSendAs",(async(e,t,n)=>{const{chatId:a}=n,o=(0,c.Z1)(e,a);if(!o)return;const i=await(0,x.t9)("fetchSendAs",{chat:o});i?(e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(i.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(i.chats,"id")),e=(0,r.a4)(e,a,{sendAsPeerIds:i.sendAs}),(0,s.R3)(e)):(0,s.R3)((0,r.a4)((0,s.Rd)(),a,{sendAsPeerIds:[]}))})),(0,s.iw)("loadSponsoredMessages",(async(e,t,n)=>{const{chatId:a}=n,o=(0,c.Z1)(e,a);if(!o)return;const i=await(0,x.t9)("fetchSponsoredMessages",{chat:o});i&&(e=(0,s.Rd)(),e=(0,r.Fn)(e,a,i.messages[0]),e=(0,r.Sh)(e,(0,g.ee)(i.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(i.chats,"id")),(0,s.R3)(e))})),(0,s.iw)("viewSponsoredMessage",((e,t,n)=>{const{chatId:s}=n,a=(0,c.Z1)(e,s),o=(0,c.fS)(e,s);a&&o&&(0,x.t9)("viewSponsoredMessage",{chat:a,random:o.randomId})})),(0,s.iw)("fetchUnreadMentions",(async(e,t,n)=>{const{chatId:a,offsetId:o}=n,i=(0,c.Z1)(e,a);if(!i)return;const l=await(0,x.t9)("fetchUnreadMentions",{chat:i,offsetId:o});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,i.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:[...i.unreadMentions||[],...p]}),(0,s.R3)(e)})),(0,s.iw)("markMentionsRead",((e,t,n)=>{const{messageIds:a}=n,o=(0,c.jr)(e);if(!o)return;const i=(o.unreadMentions||[]).filter((e=>!a.includes(e)));e=(0,r.a4)(e,o.id,{unreadMentions:i}),(0,s.R3)(e),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,x.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:o}=n,i=(0,L.X)(s);if(i.match(a.FS)||i.match(a.g$))return void t.openTelegramLink({url:s});const{appConfig:r}=e;if(r){const e=new URL(i);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})}i.match(a.jL)||o?window.open(i,"_blank","noopener"):t.toggleSafeLinkModal({url:i})})),(0,s.iw)("setForwardChatId",(async(e,t,n)=>{const{id:a}=n;let o=(0,c.dy)(e,a);if(o&&(0,c.Nm)(e)){var i;if(!o.fullInfo){const{accessHash:e}=o;o=await(0,x.t9)("fetchFullUser",{id:a,accessHash:e})}if(null!==(i=o)&&void 0!==i&&i.fullInfo.noVoiceMessages)return void t.showDialog({data:{message:(0,v.i0)("VoiceMessagesRestrictedByPrivacy",(0,d.Js)(o))}})}(0,s.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:a,isModalShown:!1}}),t.openChat({id:a}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,s.iw)("forwardToSavedMessages",((e,t)=>{(0,s.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:e.currentUserId}}),t.exitMessageSelectMode(),t.forwardMessages({isSilent:!0})}));var q=n(85765),$=n(9211);const G=(0,T.P2)((e=>e()),500,!1);async function H(e){const t=await(0,x.t9)("fetchRecentStickers",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,stickers:{...n.stickers,recent:t}})}async function V(e){const t=await(0,x.t9)("fetchStickers",{stickerSetInfo:e});let n=(0,s.Rd)();if(!t)return(0,T.R3)((()=>{(0,s.Sv)().showNotification({message:(0,v.i0)("StickerPack.ErrorNotFound")})})),void("shortName"in e&&n.openedStickerSetShortName===e.shortName&&(0,s.R3)({...n,openedStickerSetShortName:void 0}));const{set:a,stickers:o,packs:i}=t;n=(0,r.Rg)(n,a.id,{...a,stickers:o,packs:i});const c=n.stickers.forEmoji.emoji;c&&i[c]&&(n=(0,r.vy)(n)),(0,s.R3)(n)}async function _(e,t){const n=await(0,x.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,t)=>{!async function(e){const t=await(0,x.t9)("fetchStickerSets",{hash:e});t&&(0,s.R3)((0,r.z3)((0,s.Rd)(),"added",t.hash,t.sets))}(e.stickers.added.hash),async function(e){const t=await(0,x.t9)("fetchCustomEmojiSets",{hash:e});t&&(0,s.R3)((0,r.z3)((0,s.Rd)(),"added",t.hash,t.sets))}(e.customEmojis.added.hash),t.loadCustomEmojis({ids:e.recentCustomEmojis})})),(0,s.iw)("loadAddedStickers",(async(e,t)=>{const{added:{setIds:n=[]},setsById:s}=e.stickers,{added:{setIds:a=[]}}=e.customEmojis,o=[...n,...a];if(o.length)for(let e=0;e<o.length;e++){var i;const n=o[e];null!==(i=s[n])&&void 0!==i&&i.stickers||(t.loadStickers({stickerSetInfo:{id:n,accessHash:s[n].accessHash}}),e%10==0&&e>0&&await(0,T.wO)(200))}})),(0,s.iw)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};H(t)})),(0,s.iw)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,x.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,x.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)("loadPremiumSetStickers",(async e=>{const{hash:t}=e.stickers.premium||{},n=await(0,x.t9)("fetchStickersForEmoji",{emoji:"📂⭐️",hash:t});n&&(e=(0,s.Rd)(),(0,s.R3)({...e,stickers:{...e.stickers,premiumSet:{hash:n.hash,stickers:n.stickers}}}))})),(0,s.iw)("loadGreetingStickers",(async e=>{const{hash:t}=e.stickers.greeting||{},n=await(0,x.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,x.t9)("fetchFeaturedStickers",{hash:e});t&&(0,s.R3)((0,r.z3)((0,s.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,s.iw)("loadPremiumGifts",(async()=>{const e=await(0,x.t9)("fetchPremiumGifts");if(!e)return;const{set:t,stickers:n}=e;(0,s.R3)({...(0,s.Rd)(),premiumGifts:{...t,stickers:n}})})),(0,s.iw)("loadStickers",((e,t,n)=>{var s;const{stickerSetInfo:a}=n,o=(0,c.Ny)(e,a);o&&o.count===(null==o||null===(s=o.stickers)||void 0===s?void 0:s.length)||V(a)})),(0,s.iw)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,x.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,x.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,x.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,o;const{gif:i,shouldUnsave:r}=n,l=null===(a=e.gifs.saved.gifs)||void 0===a?void 0:a.length,d=(0,$.M)(e,"savedGifs"),u=(0,$.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,x.t9)("saveGif",{gif:i,shouldUnsave:r}))return;const h=(null===(o=(e=(0,s.Rd)()).gifs.saved.gifs)||void 0===o?void 0:o.filter((e=>{let{id:t}=e;return t!==i.id})))||[],g=r?h:[i,...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,o=(0,$.M)(e,"stickersFaved"),i=(0,$.P)(e,"stickersFaved"),r=(0,c.wV)(e);a>=o&&t.showNotification({title:v.i0("LimitReachedFavoriteStickers",o.toString()),message:r?v.i0("LimitReachedFavoriteStickersSubtitlePremium"):v.i0("LimitReachedFavoriteStickersSubtitle",i.toString()),...!r&&{action:t.openPremiumModal},className:"bold-link"}),s&&(0,x.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,x.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,s.iw)("removeRecentSticker",(async(e,t,n)=>{const{sticker:s}=n;await(0,x.t9)("removeRecentSticker",{sticker:s})&&H()})),(0,s.iw)("clearRecentStickers",(async e=>{await(0,x.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:o,installedDate:i}=a;(0,x.t9)(i?"uninstallStickerSet":"installStickerSet",{stickerSetId:s,accessHash:o})})),(0,s.iw)("loadEmojiKeywords",(async(e,t,n)=>{var a,o;const{language:i}=n;let r=e.emojiKeywords[i];if(null!==(a=r)&&void 0!==a&&a.isLoading)return;(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[i]:{...r,isLoading:!0}}});const c=await(0,x.t9)("fetchEmojiKeywords",{language:i,fromVersion:r?r.version:0});r=(e=(0,s.Rd)()).emojiKeywords[i],c?(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[i]:{isLoading:!1,version:c.version,keywords:{...null===(o=r)||void 0===o?void 0:o.keywords,...c.keywords}}}}):(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[i]:{...r,isLoading:!1}}})})),(0,s.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:a}=n;a&&G((()=>{!async function(e,t){const n=await(0,x.t9)("searchStickers",{query:e,hash:void 0});if(!n)return;const a=(0,s.Rd)(),{setsById:o,added:i}=a.stickers,c=n.sets.map((e=>{let{id:t}=e;return t}));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:n}=o[t]||{};n&&(0,q.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&&G((()=>{_(s)}))})),(0,s.iw)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&G((()=>{_(t,n)}))})),(0,s.iw)("loadStickersForEmoji",((e,t,n)=>{const{emoji:a}=n,{hash:o}=e.stickers.forEmoji;G((()=>{!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,x.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,o)}))})),(0,s.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,s.iw)("loadCustomEmojiForEmoji",((e,t,n)=>{const{emoji:s}=n;return(0,r.AA)(e,s)})),(0,s.iw)("clearCustomEmojiForEmoji",(e=>({...e,customEmojis:{...e.customEmojis,forEmoji:{}}}))),(0,s.iw)("loadFeaturedEmojiStickers",(async e=>{const t=await(0,x.t9)("fetchFeaturedEmojiStickers");t&&(e=(0,s.Rd)(),(0,s.R3)({...e,customEmojis:{...e.customEmojis,featuredIds:t.sets.map((e=>{let{id:t}=e;return t})),byId:{...e.customEmojis.byId,...(0,g.ee)(t.sets.flatMap((e=>e.stickers||[])),"id")}},stickers:{...e.stickers,setsById:{...e.stickers.setsById,...(0,g.ee)(t.sets,"id")}}}))})),(0,s.iw)("openStickerSet",(async(e,t,n)=>{const{stickerSetInfo:a}=n;(0,c.Ny)(e,a)||await V(a),e=(0,s.Rd)();const o=(0,c.Ny)(e,a);null!=o&&o.shortName?(0,s.R3)({...e,openedStickerSetShortName:o.shortName}):t.showNotification({message:(0,v.i0)("StickerPack.ErrorNotFound")})}));var z=n(790);const W=(0,T.P2)((e=>e()),500,!1);async function X(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0;if(i){const s=await(0,x.t9)("searchMessagesLocal",{chat:i,query:t,type:n,limit:a.Hk,offsetId:o,minDate:d,maxDate:l});if(s){const{messages:t,users:n,totalCount:a,nextOffsetId:o}=s;e={messages:t,users:n,chats:[],totalCount:a,nextRate:o}}}else e=await(0,x.t9)("searchMessagesGlobal",{query:t,offsetRate:o,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 J(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=await(0,x.t9)("searchMessagesLocal",{chat:e,type:t,limit:2*a.EN,offsetId:n});if(!i)return;const{chats:l,users:d,messages:u,totalCount:m,nextOffsetId:h}=i,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),o||J(e,t,h,!0))}(0,s.iw)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:a}=e.globalSearch,{query:o}=n;o&&!a&&W((()=>{!async function(e){const t=await(0,x.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:o,localUsers:i,globalChats:l,globalUsers:d}=t;(o.length||l.length)&&(n=(0,r.fZ)(n,(0,g.ee)([...o,...l],"id"))),(i.length||d.length)&&(n=(0,r.Sh)(n,(0,g.ee)([...i,...d],"id"))),n=(0,r.xv)(n,{chats:!1}),n=(0,r.No)(n,{localResults:{chatIds:o.map((e=>{let{id:t}=e;return t})),userIds:i.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)}(o)}))})),(0,s.iw)("setGlobalSearchDate",((e,t,n)=>{const{date:a}=n,o=a?(0,z.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:i}=e.globalSearch;X("","text",void 0,i?(0,c.Z1)(e,i):void 0,o,a)})),(0,s.iw)("searchMessagesGlobal",((e,t,n)=>{var s;const{query:a,resultsByType:o,chatId:i,date:r}=e.globalSearch,l=r?(0,z.IS)(r):r,{type:d}=n;X(a,d,null==o||null===(s=o[d])||void 0===s?void 0:s.nextOffsetId,i?(0,c.Z1)(e,i):void 0,l,r)})),(0,s.iw)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{},o=t?(0,c.Z1)(e,t):void 0,l=(0,c.n5)(e);if(!o||!l||!n)return;const{query:d,results:u}=l,m=null==u?void 0:u.nextOffsetId;let h;if(n!==i._f){const s=(0,c.tZ)(e,t,n);h=null==s?void 0:s.topMessageId}!async function(e,t,n,o,i){if(!o)return;const l=await(0,x.t9)("searchMessagesLocal",{chat:e,type:"text",query:o,topMessageId:n,limit:a.pn,offsetId:i});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&&o===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))}(o,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:o}=s,i=a&&o&&o[a],r=null==i?void 0:i.nextOffsetId;a&&J(n,a,r)})),(0,s.iw)("searchMessagesByDate",((e,t,n)=>{const{timestamp:a}=n,{chatId:o}=(0,c.Bt)(e)||{};if(!o)return;const i=(0,c.Z1)(e,o);i&&async function(e,t){const n=await(0,x.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});n&&(0,s.Sv)().focusMessage({chatId:e.id,messageId:n})}(i,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:o}=n;e=(0,r.fw)(e,a,{isUsernameAvailable:void 0,checkedUsername:void 0}),(0,s.R3)(e);const i=await(0,x.t9)("checkChatUsername",{username:o});e=(0,s.Rd)(),e=(0,r.H9)(e,i?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:i,checkedUsername:o}),(0,s.R3)(e),void 0===i&&t.openLimitReachedModal({limit:"channelsPublic"})})),(0,s.iw)("updatePublicLink",(async(e,t,n)=>{const{chatId:a}=(0,c.Bt)(e)||{};let o=a&&(0,c.Z1)(e,a);if(!a||!o)return;const{username:i}=n;if(e=(0,r.H9)(e,m.wv.InProgress),(0,s.R3)(e),(0,d.G9)(o)){if(o=await(0,B.bZ)(o),!o)return;t.openChat({id:o.id})}const l=await(0,x.t9)("setChatUsername",{chat:o,username:i});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,checkedUsername: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,x.t9)("updatePrivateLink",{chat:n})})),(0,s.iw)("setEditingExportedInvite",((e,t,n)=>{const{chatId:a,invite:o}=n;(0,s.R3)((0,r.fw)(e,a,{editingInvite:o}))})),(0,s.iw)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:a,invite:o}=n,i=o?{inviteInfo:{invite:o}}:{inviteInfo:void 0};(0,s.R3)((0,r.fw)(e,a,i))})),(0,s.iw)("loadExportedChatInvites",(async(e,t,n)=>{const{chatId:a,adminId:o,isRevoked:i,limit:l}=n,d=(0,c.Z1)(e,a),u=(0,c.dy)(e,o||e.currentUserId);if(!d||!u)return;const m=await(0,x.t9)("fetchExportedChatInvites",{peer:d,admin:u,isRevoked:i,limit:l});if(!m)return;const h=i?{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:o,isRevoked:i,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m}=n,h=(0,c.Z1)(e,a);if(!h)return;const g=await(0,x.t9)("editExportedChatInvite",{peer:h,link:o,isRevoked:i,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:o,usageLimit:i,isRequestNeeded:l,title:d}=n,u=(0,c.Z1)(e,a);if(!u)return;const m=await(0,x.t9)("exportChatInvite",{peer:u,expireDate:o,usageLimit:i,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,o;const{chatId:i,link:l}=n,d=(0,c.Z1)(e,i);if(!d)return;if(!await(0,x.t9)("deleteExportedChatInvite",{peer:d,link:l}))return;const u=(e=(0,s.Rd)()).management.byChatId[i];(0,s.R3)((0,r.fw)(e,i,{invites:null==u||null===(a=u.invites)||void 0===a?void 0:a.filter((e=>e.link!==l)),revokedInvites:null==u||null===(o=u.revokedInvites)||void 0===o?void 0:o.filter((e=>e.link!==l))}))})),(0,s.iw)("deleteRevokedExportedChatInvites",(async(e,t,n)=>{const{chatId:a,adminId:o}=n,i=(0,c.Z1)(e,a),l=(0,c.dy)(e,o||e.currentUserId);i&&l&&await(0,x.t9)("deleteRevokedExportedChatInvites",{peer:i,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:o,link:i,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,o),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,x.t9)("fetchChatInviteImporters",{peer:m,link:i,offsetDate:l,offsetUser:h,limit:u});if(!g)return;const{importers:p,users:f}=g,v=null===(a=(e=(0,s.Rd)()).management.byChatId[o])||void 0===a?void 0:a.inviteInfo;null!=v&&v.invite&&v.invite.link===i&&(e=(0,r.fw)(e,o,{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:o,link:i,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,o),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,x.t9)("fetchChatInviteImporters",{peer:m,link:i,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[o])||void 0===a?void 0:a.inviteInfo;null!=v&&v.invite&&v.invite.link===i&&(e=(0,r.fw)(e,o,{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:o,offsetUserId:i,limit:l}=n,d=(0,c.Z1)(e,a),u=(0,c.dy)(e,i);if(!d||i&&!u)return;const m=await(0,x.t9)("fetchChatInviteImporters",{peer:d,offsetDate:o,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:o,userId:i,isApproved:l}=n,d=(0,c.Z1)(e,o),u=(0,c.dy)(e,i);if(!d||!u)return;if(!await(0,x.t9)("hideChatJoinRequest",{peer:d,user:u,isApproved:l}))return;e=(0,s.Rd)();const m=(0,c.Z1)(e,o);m&&(0,s.R3)((0,r.a4)(e,o,{joinRequests:null===(a=m.joinRequests)||void 0===a?void 0:a.filter((e=>e.userId!==i))}))})),(0,s.iw)("hideAllChatJoinRequests",(async(e,t,n)=>{const{chatId:a,isApproved:o,link:i}=n,l=(0,c.Z1)(e,a);if(!l)return;if(!await(0,x.t9)("hideAllChatJoinRequests",{peer:l,isApproved:o,link:i}))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,o=(0,c.Z1)(e,a);o&&await(0,x.t9)("hideChatReportPanel",o)&&(0,s.R3)((0,r.a4)((0,s.Rd)(),a,{settings:void 0}))}));var Y=n(65116),K=n(16974);let Q,ee;function te(e){return(0,x.t9)("fetchMessages",{chat:e,threadId:i._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,s.iw)("sync",(()=>{a.eM&&console.log(">>> START SYNC"),Q&&clearTimeout(Q),(0,s.R3)({...(0,s.Rd)(),isSyncing:!0}),Q=window.setTimeout((()=>{(0,s.R3)({...(0,s.Rd)(),isSyncing:!1}),Q=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,i._f),e[n].editingId=(0,c._$)(t,n,i._f),e[n].editingDraft=(0,c.s)(t,n,i._f),e)),{}),{chatId:o,threadId:l}=(0,c.Bt)(t)||{},d=o?t.chats.byId[o]:void 0;if(o&&d){const n=await te(d);t=(0,s.Rd)();const{chatId:u}=(0,c.Bt)(t)||{},m=l&&(0,c.tZ)(t,o,l);if(n&&u===o){const s=t.messages.byChatId[o],c=o===a.aw?t.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).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,o,u),t=(0,r.xj)(t,o,i._f,h),t=(0,r.y9)(t,o,i._f,h),l&&m&&m.originChannelId){const{originChannelId:e}=m,n=t.messages.byChatId[e],a=await te(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:{[i._f]:{...null==n?void 0:n.threadsById[i._f],listedIds:r,viewportIds:r,outlyingIds:void 0}}},[o]:{...t.messages.byChatId[o],threadsById:{...t.messages.byChatId[o].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,o,n.threadInfos),e=!0}}e||(t={...t,messages:{...t.messages,byChatId:{}}}),Object.keys(n).forEach((e=>{t=(0,r.sN)(t,e,i._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,K.S1)(),e({listType:"archived",shouldReplace:!0}),(0,x.t9)("fetchCurrentUser"),t()}})})),(0,Y.ll)((e=>{var t,n;const{connectionState:a,authState:o}=e;(null===(t=ee)||void 0===t?void 0:t.connectionState)===a&&(null===(n=ee)||void 0===n?void 0:n.authState)===o||("connectionStateReady"===a&&"authorizationStateReady"===o&&(0,s.Sv)().sync(),ee=e)})),(0,s.iw)("reportPeer",(async(e,t,n)=>{const{chatId:s,reason:a,description:o}=n;if(!s)return;const i=(0,c.Z1)(e,s);if(!i)return;const r=await(0,x.t9)("reportPeer",{peer:i,reason:a,description:o});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:o,photo:i}=n;if(!s)return;const r=(0,c.Z1)(e,s);if(!r||!i)return;const l=await(0,x.t9)("reportProfilePhoto",{peer:r,photo:i,reason:a,description:o});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,x.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,x.t9)("terminateAuthorization",a))return;e=(0,s.Rd)();const{[a]:o,...i}=e.activeSessions.byHash;(0,s.R3)({...e,activeSessions:{byHash:i,orderedHashes:e.activeSessions.orderedHashes.filter((e=>e!==a))}})})),(0,s.iw)("terminateAllAuthorizations",(async e=>{if(!await(0,x.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:o,areSecretChatsEnabled:i}=n;await(0,x.t9)("changeSessionSettings",{hash:a,areCallsEnabled:o,areSecretChatsEnabled:i})&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeSessions:{...e.activeSessions,byHash:{...e.activeSessions.byHash,[a]:{...e.activeSessions.byHash[a],...void 0!==o?{areCallsEnabled:o}:void 0,...void 0!==i?{areSecretChatsEnabled:i}:void 0}}}}))})),(0,s.iw)("changeSessionTtl",(async(e,t,n)=>{const{days:a}=n;await(0,x.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,x.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,x.t9)("terminateWebAuthorization",a))return;e=(0,s.Rd)();const{[a]:o,...i}=e.activeWebSessions.byHash;(0,s.R3)({...e,activeWebSessions:{byHash:i,orderedHashes:e.activeWebSessions.orderedHashes.filter((e=>e!==a))}})})),(0,s.iw)("terminateAllWebAuthorizations",(async e=>{await(0,x.t9)("terminateAllWebAuthorizations")&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeWebSessions:{byHash:{},orderedHashes:[]}}))}));const ne=(0,T.P2)((e=>e()),500,!1);function se(e,t,n){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:n}}}}function ae(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:o,accessHash:i}=a;(0,x.t9)("fetchFullUser",{id:o,accessHash:i})})),(0,s.iw)("loadUser",(async(e,t,n)=>{const{userId:a}=n,o=(0,c.dy)(e,a);if(!o)return;const i=await(0,x.t9)("fetchUsers",{users:[o]});if(!i)return;const{users:l,userStatusesById:d}=i;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,x.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,x.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"),o=e.users.sort(((e,t)=>a.compare(n(e),n(t)))).filter((e=>!e.isSelf));(0,s.R3)({...t,contactList:{userIds:o.map((e=>e.id))}})}()})),(0,s.iw)("loadCurrentUser",(()=>{(0,x.t9)("fetchCurrentUser")})),(0,s.iw)("loadCommonChats",(async e=>{var t,n,a;const{chatId:o}=(0,c.Bt)(e)||{},i=o?(0,c.dy)(e,o):void 0;if(!i||(0,d.cS)(i)||null!==(t=i.commonChats)&&void 0!==t&&t.isFullyLoaded)return;const l=null===(n=i.commonChats)||void 0===n?void 0:n.maxId,u=await(0,x.t9)("fetchCommonChats",i.id,i.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,i.id,{commonChats:{maxId:h.length?h[h.length-1]:"0",ids:(0,g.Tw)(((null===(a=i.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:o=!1,firstName:i,lastName:l,shouldSharePhoneNumber:d}=n;!async function(e,t,n,a,o){let i=(0,s.Rd)();const l=(0,c.dy)(i,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,x.t9)("importContact",{phone:l.phoneNumber,firstName:n,lastName:a});else{const{id:e,accessHash:t}=l;d=await(0,x.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:n,lastName:a,shouldSharePhoneNumber:o})}d&&((0,s.Sv)().loadChatSettings({chatId:e}),(0,s.R3)((0,r.Nq)((0,s.Rd)(),l.id,{firstName:n,lastName:a}))),i=(0,s.Rd)(),i=(0,r.H9)(i,m.wv.Complete),i=(0,r.ft)(i),(0,s.R3)(i)}(a,o,i,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:o}=n;await(0,x.t9)("deleteContact",{id:a,accessHash:o})}(a)})),(0,s.iw)("loadProfilePhotos",(async(e,t,n)=>{const{profileId:a}=n,o=(0,d.YC)(a),i=o?(0,c.dy)(e,a):void 0,l=o?void 0:(0,c.Z1)(e,a);if(!i&&!l)return;const u=await(0,x.t9)("fetchProfilePhotos",i,l);u&&u.photos&&(e=(0,s.Rd)(),o?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&&ne((()=>{!async function(e){const t=await(0,x.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:o,globalUsers:i}=t;let c,l;o.length&&(n=(0,r.Sh)(n,(0,g.ee)(o,"id")),c=o.map((e=>{let{id:t}=e;return t}))),i.length&&(n=(0,r.Sh)(n,(0,g.ee)(i,"id")),l=i.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:o,lastName:i}=n,c=await(0,x.t9)("importContact",{phone:a,firstName:o,lastName:i});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,x.t9)("reportSpam",a)}));var oe=n(18629);const ie=h.cj||h.wZ;class re{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;ie&&(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(!ie){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 ce="https://prizes.gamee.com/",le=(0,T.Ds)((e=>e()),500,!1);async function de(e,t){await(0,x.t9)("toggleAttachBot",{bot:e,isEnabled:t}),await ue()}async function ue(e){const t=await(0,x.t9)("loadAttachBots",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,attachMenu:{hash:t.hash,bots:t.bots}})}function me(e,t){if("request"===t.type){const e=(0,s.Rd)();if(!e.urlAuth)return;const{domain:n,bot:a,shouldRequestWriteAccess:o}=t;return void(0,s.R3)({...e,urlAuth:{...e.urlAuth,request:{domain:n,botId:a.id,shouldRequestWriteAccess:o}}})}const n="accepted"===t.type?t.url:e;window.open(n,"_blank","noopener"),(0,s.Sv)().closeUrlAuthModal()}async function he(e,t,n,s,a){await(0,x.t9)("sendMessage",{chat:e,text:n,replyingTo:s,sendAs:a})}let ge;async function pe(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{showDialog:o,showNotification:i,openUrl:r,openGame:c}=(0,s.Sv)();a&&(ge||(ge=new re("popup,width=800,height=600",(()=>{i({message:"Allow browser to open popup window"})}))),ge.preOpenIfNeeded());const l=await(0,x.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?o({data:{message:d||"Error"}}):d?i({message:d}):m&&(a?m.includes(ce)?ge.open(m):(ge.cancelPreOpen(),c({url:m,chatId:e.id,messageId:t})):r({url:m}))}async function fe(e){const t=await(0,x.t9)("getPaymentForm",e);if(!t)return;const{form:n,invoice:a}=t;let o=(0,r._7)((0,s.Rd)(),n);return o=(0,r.Q$)(o,m.KB.Checkout),(0,s.R3)(o),a}async function ve(e,t,n){const a=await(0,x.t9)("validateRequestedInfo",{inputInvoice:e,requestInfo:t,shouldSave:n});if(!a)return;const{id:o,shippingOptions:i}=a;let c=(0,r.vT)((0,s.Rd)(),o);i?(c=(0,r.TM)(c,i),c=(0,r.Q$)(c,m.KB.Shipping)):c=(0,r.Q$)(c,m.KB.Checkout),(0,s.R3)(c)}(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;pe(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:o}=a;t.getReceipt({receiptMessageId:o,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;pe(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:o}=(0,c.Bt)(e)||{};if(!o)return;const i=(0,c.hj)(e,o,s);if(null==i||!i.senderId)return;const r=(0,oe.BS)();t.requestSimpleWebView({url:n,botId:null==i?void 0:i.senderId,theme:r,buttonText:a.text});break}case"webView":{const{url:n}=a,o=(0,c.jr)(e);if(!o)return;const i=(0,c.hj)(e,o.id,s);if(!i)return;const r=i.viaBotId||i.senderId;if(!r)return;const l=(0,oe.BS)();t.requestWebView({url:n,botId:r,peerId:o.id,theme:l,buttonText:a.text});break}case"urlAuth":{const{url:n}=a,o=(0,c.jr)(e);if(!o)return;t.requestBotUrlAuth({chatId:o.id,messageId:s,buttonId:a.buttonId,url:n});break}}})),(0,s.iw)("sendBotCommand",((e,t,n)=>{const{command:s,chatId:a}=n,{currentUserId:o}=e,i=a?(0,c.Z1)(e,a):(0,c.jr)(e),r=(0,c.Bt)(e);if(!o||!i||!r)return;const{threadId:l}=r;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i.id,threadId:l,value:!1}),he(i,0,s,(0,c.Yy)(e,i.id,l),(0,c._5)(e,a))})),(0,s.iw)("restartBot",(async(e,t,n)=>{const{chatId:a}=n,{currentUserId:o}=e,i=(0,c.jr)(e),l=o&&(0,c.IK)(e,a);o&&i&&l&&await(0,x.t9)("unblockContact",l.id,l.accessHash)&&((0,s.R3)((0,r.rB)((0,s.Rd)(),l.id)),he(i,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,x.t9)("fetchTopInlineBots");if(!n)return;const{ids:a,users:o}=n;e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(o,"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:o,query:i,offset:l}=n;let d=e.inlineBots.byUsername[o];if(!1!==d){if(void 0===d){const{user:t,chat:n}=await(0,x.t9)("fetchInlineBot",{username:o})||{};if(e=(0,s.Rd)(),!t||!n)return void(0,s.R3)(se(e,o,!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=se(e,o,d),(0,s.R3)(e)}(i!==d.query||d.canLoadMore)&&le((()=>{!async function(e){let{username:t,inlineBotData:n,chatId:a,query:o,offset:i}=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!==o;r=ae(r,!0),r=se(r,t,{...n,query:o,...u&&{offset:void 0,results:[]}}),(0,s.R3)(r);const m=await(0,x.t9)("fetchInlineBotResults",{bot:l,chat:d,query:o,offset:u?void 0:i}),h=r.inlineBots.byUsername[t];if(r=ae((0,s.Rd)(),!1),!m||!h||o!==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=se(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:o,inlineBotData:d,chatId:a,query:i,offset:l})}))}})),(0,s.iw)("switchBotInline",((e,t,n)=>{const{query:s,isSamePeer:a,messageId:o}=n,i=(0,c.jr)(e);if(!i)return;const r=(0,c.hj)(e,i.id,o);if(!r)return;const l=(0,c.dy)(e,r.viaBotId||r.senderId);l&&t.openChatWithDraft({text:`@${l.username} ${s}`,chatId:a?i.id:void 0})})),(0,s.iw)("sendInlineBotResult",((e,t,n)=>{const{id:s,queryId:a,isSilent:o,scheduledAt:i}=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,x.t9)("sendInlineBotResult",{chat:u,resultId:s,queryId:a,replyingTo:(0,c.Yy)(e,l,d),sendAs:(0,c._5)(e,l),isSilent:o,scheduleDate:i})})),(0,s.iw)("resetInlineBot",((e,t,n)=>{const{username:a}=n;let o=e.inlineBots.byUsername[a];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,s.R3)(se(e,a,o)))})),(0,s.iw)("startBot",(async(e,t,n)=>{var a;const{botId:o,param:i}=n;let r=(0,c.dy)(e,o);r&&(r.fullInfo||await(0,x.t9)("fetchFullUser",{id:r.id,accessHash:r.accessHash}),r=(0,c.dy)((0,s.Rd)(),o),null!==(a=r.fullInfo)&&void 0!==a&&a.isBlocked&&await(0,x.t9)("unblockContact",r.id,r.accessHash),await(0,x.t9)("startBot",{bot:r,startParam:i}))})),(0,s.iw)("requestSimpleWebView",(async(e,t,n)=>{const{url:a,botId:o,theme:i,buttonText:r}=n,l=(0,c.dy)(e,o);if(!l)return;if(!(0,c.LM)(e,o))return void(0,s.R3)({...e,botTrustRequest:{botId:o,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:n}}});const d=await(0,x.t9)("requestSimpleWebView",{url:a,bot:l,theme:i});d&&(e=(0,s.Rd)(),(0,s.R3)({...e,webApp:{url:d,botId:o,buttonText:r}}))})),(0,s.iw)("requestWebView",(async(e,t,n)=>{const{url:a,botId:o,peerId:i,theme:r,isSilent:l,buttonText:d,isFromBotMenu:u,startParam:m}=n,h=(0,c.dy)(e,o);if(!h)return;const g=(0,c.Z1)(e,i);if(!g)return;if(!(0,c.LM)(e,o))return void(0,s.R3)({...e,botTrustRequest:{botId:o,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,x.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:P,queryId:Z}=y;e=(0,s.Rd)(),(0,s.R3)({...e,webApp:{url:P,botId:o,queryId:Z,buttonText:d}})})),(0,s.iw)("prolongWebView",(async(e,t,n)=>{const{botId:s,peerId:a,isSilent:o,replyToMessageId:i,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,x.t9)("prolongWebView",{bot:l,peer:d,isSilent:o,replyToMessageId:i,queryId:r,sendAs:u})||t.closeWebApp()})),(0,s.iw)("sendWebViewData",((e,t,n)=>{const{bot:s,data:a,buttonText:o}=n;(0,x.t9)("sendWebViewData",{bot:s,data:a,buttonText:o})})),(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:o}=n,{trustedBotIds:i}=e,r=new Set(i);if(r.add(o),(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)("loadAttachBots",(async(e,t,n)=>{const{hash:s}=n||{};await ue(s)})),(0,s.iw)("toggleAttachBot",(async(e,t,n)=>{const{botId:s,isEnabled:a}=n,o=(0,c.dy)(e,s);o&&await de(o,a)})),(0,s.iw)("callAttachBot",((e,t,n)=>{const{chatId:s,botId:a,isFromBotMenu:o,url:i,startParam:r}=n,{attachMenu:{bots:c}}=e;if(!o&&!c[a])return{...e,requestedAttachBotInstall:{botId:a,onConfirm:{action:"callAttachBot",payload:{chatId:s,botId:a,startParam:r}}}};const l=(0,oe.BS)();t.openChat({id:s}),t.requestWebView({url:i,peerId:s,botId:a,theme:l,buttonText:"",isFromBotMenu:o,startParam:r})})),(0,s.iw)("confirmAttachBotInstall",(async e=>{const{requestedAttachBotInstall:t}=e,{botId:n,onConfirm:a}=t;(0,s.R3)({...e,requestedAttachBotInstall:void 0});const o=(0,c.dy)(e,n);if(o&&(await de(o,!0),a)){const{action:e,payload:t}=a;(0,s.Sv)()[e](t)}})),(0,s.iw)("cancelAttachBotInstall",(e=>({...e,requestedAttachBotInstall:void 0}))),(0,s.iw)("requestAttachBotInChat",((e,t,n)=>{var a;const{botId:o,filter:i,startParam:r}=n,l=null===(a=(0,c.Bt)(e))||void 0===a?void 0:a.chatId,{attachMenu:{bots:d}}=e,u=d[o];if(!u)return;const m=u.peerTypes.filter((e=>"self"!==e&&i.includes(e)));m.length?(0,s.R3)({...e,requestedAttachBotInChat:{botId:o,filter:m,startParam:r}}):t.callAttachBot({chatId:l||o,botId:o,startParam:r})})),(0,s.iw)("cancelAttachBotInChat",(e=>({...e,requestedAttachBotInChat:void 0}))),(0,s.iw)("requestBotUrlAuth",(async(e,t,n)=>{const{chatId:a,buttonId:o,messageId:i,url:r}=n,l=(0,c.Z1)(e,a);if(!l)return;const d=await(0,x.t9)("requestBotUrlAuth",{chat:l,buttonId:o,messageId:i});d&&(e=(0,s.Rd)(),(0,s.R3)({...e,urlAuth:{url:r,button:{buttonId:o,messageId:i,chatId:l.id}}}),me(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:o,url:i}=e.urlAuth,{chatId:r,messageId:l,buttonId:d}=o,u=(0,c.Z1)(e,r);if(!u)return;const m=await(0,x.t9)("acceptBotUrlAuth",{chat:u,messageId:l,buttonId:d,isWriteAllowed:a});m&&me(i,m)})),(0,s.iw)("requestLinkUrlAuth",(async(e,t,n)=>{const{url:a}=n,o=await(0,x.t9)("requestLinkUrlAuth",{url:a});o&&(e=(0,s.Rd)(),(0,s.R3)({...e,urlAuth:{url:a}}),me(a,o))})),(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:o}=e.urlAuth,i=await(0,x.t9)("acceptLinkUrlAuth",{url:o,isWriteAllowed:a});i&&me(o,i)})),(0,s.iw)("closeUrlAuthModal",(e=>({...e,urlAuth:void 0}))),n(51371),(0,s.iw)("loadPasswordInfo",(async e=>{const t=await(0,x.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:o}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const i=await(0,x.t9)("checkPassword",a);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),i&&o()})),(0,s.iw)("clearPassword",(async(e,t,n)=>{const{currentPassword:a,onSuccess:o}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const i=await(0,x.t9)("clearPassword",a);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),i&&o()})),(0,s.iw)("updatePassword",(async(e,t,n)=>{const{currentPassword:a,password:o,hint:i,email:c,onSuccess:l}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const d=await(0,x.t9)("updatePassword",a,o,i,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:o,onSuccess:i}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const c=await(0,x.t9)("updateRecoveryEmail",a,o);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),c&&i()})),(0,s.iw)("provideTwoFaEmailCode",((e,t,n)=>{const{code:s}=n;(0,x.t9)("provideRecoveryEmailCode",s)})),(0,s.iw)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,s.iw)("validateRequestedInfo",((e,t,n)=>{const s=(0,c.kb)(e);if(!s)return;const{requestInfo:a,saveInfo:o}=n;if("slug"in s)ve(s,a,o);else{const t=(0,c.Z1)(e,s.chatId);if(!t)return;ve({chat:t,messageId:s.messageId},a,o)}})),(0,s.iw)("openInvoice",(async(e,t,n)=>{let a;if("slug"in n)a=await fe({slug:n.slug});else{const t=(0,c.Z1)(e,n.chatId);if(!t)return;a=await fe({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",isExtendedMedia:n.isExtendedMedia}}))})),(0,s.iw)("getReceipt",((e,t,n)=>{const{receiptMessageId:a,chatId:o,messageId:i}=n,l=o&&(0,c.Z1)(e,o);i&&a&&l&&async function(e,t,n){const a=await(0,x.t9)("getReceipt",e,n);if(!a)return;let o=(0,s.Rd)();const i=(0,c.hj)(o,e.id,t);o=(0,r.Dq)(o,a,i),(0,s.R3)(o)}(l,i,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:o}=e.payment,{credentials:i}=n,{data:l}=i;if("stripe"===o){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}`}}),o=await a.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,s.Rd)();return void(0,s.R3)({...t,payment:{...t.payment,status:"failed",error:{...e}}})}let i=(0,r.QH)((0,s.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,m.KB.Checkout),(0,s.R3)(i)}(l,t)}else if("smartglocal"===o){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,"")}},o=a.eA?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",i=await fetch(o,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":t},body:JSON.stringify(n)}),c=await i.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",(async(e,t,n)=>{const{shippingOptionId:a,saveCredentials:o,savedCredentialId:i,tipAmount:l}=n,d=(0,c.kb)(e),u=(0,c.eh)(e),m=(0,c.sp)(e),{nativeProvider:h,temporaryPassword:g}=e.payment,p="stripe"===h?(0,c.$$)(e):(0,c.EB)(e);if(!(d&&p&&u&&h))return;let f;if("slug"in d)f={slug:d.slug};else{const t=(0,c.Z1)(e,d.chatId);if(!t)return;f={chat:t,messageId:d.messageId}}(0,s.R3)((0,r.cQ)(e,{status:"pending"}));const v={save:o,data:"stripe"===h?(0,c.i3)(e):(0,c.Jg)(e)};await(0,x.t9)("sendPaymentForm",{inputInvoice:f,formId:u,credentials:v,requestedInfoId:m,shippingOptionId:a,savedCredentialId:i,temporaryPassword:null==g?void 0:g.value,tipAmount:l})&&(e=(0,s.Rd)(),e=(0,r.cQ)(e,{status:"paid"}),e=(0,r.WY)(e),(0,s.R3)(e))})),(0,s.iw)("setPaymentStep",(function(e,t){var n;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,r.Q$)(e,null!==(n=s.step)&&void 0!==n?n:m.KB.Checkout)})),(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:o,isSuccess:i,isGift:c,monthsAmount:l,toUserId:d}=n||{};t.loadPremiumStickers();const u=await(0,x.t9)("fetchPremiumPromo");u&&(e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(u.users,"id")),(0,s.R3)({...e,premiumModal:{promo:u.promo,initialSection:a,isOpen:!0,fromUserId:o,toUserId:d,isGift:c,monthsAmount:l,isSuccess:i}}))})),(0,s.iw)("openGiftPremiumModal",(async(e,t,n)=>{const{forUserId:a}=n||{},o=await(0,x.t9)("fetchPremiumPromo");if(!o)return;e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(o.users,"id"));const i=o.promo.options.find((e=>1===e.months));(0,s.R3)({...e,giftPremiumModal:{isOpen:!0,forUserId:a,monthlyCurrency:i.currency,monthlyAmount:i.amount}})})),(0,s.iw)("closeGiftPremiumModal",(e=>{(0,s.R3)({...e,giftPremiumModal:{isOpen:!1}})})),(0,s.iw)("validatePaymentPassword",(async(e,t,n)=>{let{password:a}=n;const o=await(0,x.t9)("fetchTemporaryPaymentPassword",a);e=(0,s.Rd)(),e=o?"error"in o?(0,r.cQ)(e,{error:{message:o.error,field:"password"}}):(0,r.cQ)(e,{temporaryPassword:o,step:m.KB.Checkout}):(0,r.cQ)(e,{error:{message:"Unknown Error",field:"password"}}),(0,s.R3)(e)}));var Ie=n(40647),we=n(4907),ye=n(74399);const Pe=32*ye.Gw,Ze=45.5*ye.Gw,Ce=26.5*ye.Gw,be=18*ye.Gw,Ee=16.125*ye.Gw;var Se=n(43858),Me=n(53475);function Re(e,t){return t-(e.isLeftColumnShown&&!h.wB?e.leftColumnWidth||((n=Se.Z.get().width)>a._m?Math.min(Math.max(.25*n,be),.33*n):n>a.ks?Math.min(Math.max(.33*n,be),.4*n):Ce):0);var n}function ke(e,t,n){return(0,Me.a4)(e,t,n,void 0,!0)}let Te=0;(0,s.iw)("loadAvailableReactions",(async()=>{const e=await(0,x.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&Ie.he(`sticker${e.aroundAnimation.id}`,i.IU.BlobUrl),e.centerIcon&&Ie.he(`sticker${e.centerIcon.id}`,i.IU.BlobUrl)})),(0,s.R3)({...(0,s.Rd)(),availableReactions:e}))})),(0,s.iw)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:s,x:a,y:o,localEffect:i,startSize:r,isReversed:c}=n,l={id:Te++,animatedEffect:s||i,x:Re(e,a)+40*Math.random()-20,y:o+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:o,interactions:i,localEffect:r}=n,l=(0,c.Z1)(e,a);l&&(o||r)&&a!==e.currentUserId&&(0,x.t9)("sendEmojiInteraction",{chat:l,messageId:s,emoticon:o||(0,c.ji)(r),timestamps:i})})),(0,s.iw)("sendDefaultReaction",((e,t,n)=>{const{chatId:s,messageId:a,x:o,y:i}=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:o,y:i})})),(0,s.iw)("sendReaction",((e,t,n)=>{var s,o,i;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!==(o=m.reactions)&&void 0!==o&&null!==(i=o.results)&&void 0!==i&&i.some((e=>e.reaction===d&&e.isChosen))&&(d=void 0),(0,x.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 o=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:i}=a;if(s&&!o.some((e=>e.reaction===s))){const{currentUserId:t}=e;o=[...o,{reaction:s,isChosen:!0,count:1}],a.canSeeList&&(i=[...i||[],{userId:t,reaction:s}])}return(0,we.cY)(e,t,n,{reactions:{...a,results:o,recentReactions:i}})}(e,r,l,d)})),(0,s.iw)("openChat",(e=>({...e,activeReactions:{}}))),(0,s.iw)("stopActiveReaction",((e,t,n)=>{var s;const{messageId:a,reaction:o}=n;return(null===(s=e.activeReactions[a])||void 0===s?void 0:s.reaction)!==o?e:{...e,activeReactions:(0,g.CE)(e.activeReactions,[a])}})),(0,s.iw)("setDefaultReaction",(async(e,t,n)=>{const{reaction:a}=n;await(0,x.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,o,i;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,x.t9)("fetchMessageReactionsList",{reaction:u,chat:m,messageId:d,offset:p});if(!f)return;e=(0,s.Rd)(),null!==(o=f.users)&&void 0!==o&&o.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===(i=h.reactors)||void 0===i?void 0:i.reactions)||[],...w]}}))})),(0,s.iw)("loadMessageReactions",((e,t,n)=>{const{ids:s,chatId:a}=n,o=(0,c.Z1)(e,a);o&&(0,x.t9)("fetchMessageReactions",{ids:s,chat:o})})),(0,s.iw)("sendWatchingEmojiInteraction",((e,t,n)=>{var s;const{chatId:a,emoticon:o,x:i,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,x.t9)("sendWatchingEmojiInteraction",{chat:m,emoticon:o}),{...e,activeEmojiInteractions:e.activeEmojiInteractions.map((t=>t.id===u?{...t,x:Re(e,i),y:r,startSize:l,isReversed:d}:t))}})),(0,s.iw)("fetchUnreadReactions",(async(e,t,n)=>{const{chatId:a,offsetId:o}=n,i=(0,c.Z1)(e,a);if(!i)return;const l=await(0,x.t9)("fetchUnreadReactions",{chat:i,offsetId:o,addOffset:o?-1:void 0});if(!l||!l.messages.length)return e=ke(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,i.id,h),e=(0,r.Sh)(e,(0,g.ee)(m,"id")),e=ke(e=(0,r.fZ)(e,(0,g.ee)(u,"id")),a,{unreadReactions:[...i.unreadReactions||[],...p]}),(0,s.R3)(e)})),(0,s.iw)("animateUnreadReaction",((e,t,n)=>{const{messageIds:o}=n,{animationLevel:i}=e.settings.byKey,r=(0,c.jr)(e);if(r){if(r.unreadReactionsCount){const n=r.unreadReactionsCount-o.length,a=(r.unreadReactions||[]).filter((e=>!o.includes(e)));e=ke(e,r.id,{unreadReactions:a}),(0,s.R3)(e),!a.length&&n&&t.fetchUnreadReactions({chatId:r.id,offsetId:Math.min(...o)})}if(t.markMessagesRead({messageIds:o}),i===a.zy)return e=(0,s.Rd)(),{...e,activeReactions:{...e.activeReactions,...Object.fromEntries(o.map((t=>{var n,s;const a=(0,c.hj)(e,r.id,t);if(!a)return;const o=null===(n=a.reactions)||void 0===n||null===(s=n.recentReactions)||void 0===s?void 0:s.find((e=>e.isUnread));return o?[t,{messageId:t,reaction:null==o?void 0:o.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,x.t9)("readAllReactions",{chat:t}),ke(e,t.id,{unreadReactionsCount:void 0,unreadReactions:void 0})})),(0,s.iw)("loadStatistics",(async(e,t,n)=>{var a;const{chatId:o,isGroup:i}=n,l=(0,c.Z1)(e,o);if(null==l||!l.fullInfo)return;const d=await(0,x.t9)(i?"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,o);d.recentTopMessages=d.recentTopMessages.map((e=>({...e,...t[e.msgId]})))}(0,s.R3)((0,r.ze)(e,o,d))}})),(0,s.iw)("loadMessageStatistics",(async(e,t,n)=>{const{chatId:a,messageId:o}=n,i=(0,c.Z1)(e,a);if(null==i||!i.fullInfo)return;let l=await(0,x.t9)("fetchMessageStatistics",{chat:i,messageId:o});l||(l={}),e=(0,s.Rd)();const{views:d,forwards:u}=(0,c.Zw)(e,a)[o];l.views=d,l.forwards=u;const m=i.fullInfo.statisticsDcId,h=await(0,x.t9)("fetchMessagePublicForwards",{chat:i,messageId:o,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:o,name:i,isPercentage:l}=n,d=(0,c.Z1)(e,a);if(null==d||!d.fullInfo)return;const u=d.fullInfo.statisticsDcId,m=await(0,x.t9)("fetchStatisticsAsyncGraph",{token:o,dcId:u,isPercentage:l});m&&(0,s.R3)((0,r.yC)((0,s.Rd)(),a,i,m))})),n(28304);var Ae=n(28406);function Ne(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)=>Ne(e,s[t])))}const a=e,o=t;return Object.keys(a).every((e=>Ne(a[e],o[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,Ae.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 o=(0,c.Z1)(e,n.id);return void(o&&t.requestChatUpdate({chatId:o.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:o,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;const m="thread"===d&&l===i._f&&n.chatId===o,h=Boolean(n.message.id&&n.message.hasUnreadMention);return m?setTimeout((()=>{t.requestChatUpdate({chatId:n.chatId})}),1500):e=(0,r.a4)(e,n.chatId,{unreadCount:(u.unreadCount||0)+1,...h&&{unreadMentionsCount:(u.unreadMentionsCount||0)+1}}),h&&(e=(0,r.a4)(e,n.chatId,{unreadMentions:[...u.unreadMentions||[],n.message.id]})),(0,s.R3)(e),void(0,Ae.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 o,i;null!=a&&a.unreadReactionsCount&&(e=ke(e,s,{unreadReactionsCount:a.unreadReactionsCount-1||void 0,unreadReactions:null===(o=a.unreadReactions)||void 0===o?void 0:o.filter((e=>e!==t))})),null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,s,{unreadMentionsCount:a.unreadMentionsCount-1||void 0,unreadMentions:null===(i=a.unreadMentions)||void 0===i?void 0:i.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,o=s===a.WS?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[o]:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:s}=n,o=(0,c.Ek)(e,t);if(!o)return;const{[o]:i}=e.chats.orderedPinnedIds;let r=i||[];if(s){if(!r.includes(t)){if("active"===o&&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,[o]: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:o}=e.chatFolders,i=s?{...a,[t]:s}:(0,g.ei)(a,Object.keys(a).map(Number).filter((e=>e!==t))),r=s?o&&o.includes(t)?o:[...o||[],t]:o?o.filter((e=>e!==t)):void 0;return{...e,chatFolders:{...e.chatFolders,byId:i,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 o;const t=e.chats.byId[n.id],{replacedMembers:s,addedMember:a,deletedMemberId:i}=n;if(!t)return;let c=!1,l=null!==(o=t.fullInfo)&&void 0!==o&&o.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&&i){const e=l.findIndex((e=>e.userId===i));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,adminMembersById:(0,g.ee)(s,"userId")}})}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:o}=n;if(!e.chats.byId[t])return;return e=(0,r.pf)(e,t,i._f,"draft",s),e=(0,r.pf)(e,t,i._f,"replyingToId",o),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:o,recentRequesterIds:i}=n,c=e.chats.byId[a];if(!c)return;e=(0,r.a4)(e,a,{fullInfo:{...c.fullInfo,requestsPending:o,recentRequesterIds:i}}),(0,s.R3)(e),t.loadChatJoinRequests({chatId:a})}}}));const Be=350;function xe(e,t,n,s,a,o,i){var l;const u=null==i?void 0:i.reactions;if(u&&Ne(s,u))return e;if(e=(0,r.cY)(e,t,n,{reactions:s}),!o)return e;const m=null===(l=a.unreadReactions)||void 0===l?void 0:l.includes(n);if((0,d.yL)(e,s)&&!m){e=ke(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,T.R3)((()=>{(0,Ae.rh)({chat:a,message:s,isReaction:!0})}))}else if(m){var h;e=ke(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 Le(e,t,n,s){let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=a?(0,c.Tm)(e,t,n):(0,c.hj)(e,t,n);if(o&&s.content){const{photo:e,video:t,sticker:n,document:a}=(0,d.qp)(o);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 Oe(e,t,n,s){const{chatId:a}=n,{threadInfo:o}=(0,c.Db)(e,a,n)||{};if(!o&&n.replyToMessageId){const o=(0,c.hj)(e,a,n.replyToMessageId);o?e=(0,r.lG)(e,o,a,n.id,s):t.loadMessage({chatId:a,messageId:n.replyToMessageId,threadUpdate:{isDeleting:s,lastMessageId:n.id}})}return e}function Fe(e,t,n){const{id:s,chatId:a}=n,{threadInfo:o,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,i._f);if(e=Oe(e,t,n),o&&(!l&&(0,d.CI)(n)||(e=(0,r.xj)(e,a,o.threadId,[s]),(0,c.b9)(e,a,o.threadId)&&(e=(0,r.$S)(e,a,o.threadId,s),l||(e=(0,r.pf)(e,a,o.threadId,"firstMessageId",n.id)))),e=(0,r.pf)(e,a,o.threadId,"threadInfo",{...o,lastMessageId:n.id,messagesCount:o.messagesCount+1})),m)return e;if(e=(0,r.xj)(e,a,i._f,[s]),(0,c.b9)(e,a,i._f)){const t=(0,c.It)(e,a,i._f),n=(0,r.$S)(e,a,i._f,s),o=(0,c.Cb)(n,a,i._f);t&&!o.includes(t)||(e=n)}return e}function Ue(e,t,n){var s;let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:o}=e,i=null===(s=o.byId[t])||void 0===s?void 0:s.lastMessage;return!i||a||i.id===n.id||i.id===n.previousLocalId||n.id>i.id?(0,r.a4)(e,t,{lastMessage:n}):e}function je(e,t){const n=(0,c.Zw)(e,t),s=(0,c.gb)(e,t,i._f);if(!n||!s)return;let a=s.length;for(;a--;){const e=n[s[a]];if(!e.isDeleting)return e}}function De(e,t,n,a){if(e){t.forEach((t=>{const n=je(a=(0,r.cY)(a,e,t,{isDeleting:!0}),e);n&&(a=Ue(a,e,n,!0))})),n.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const s=(0,c.hj)(a,e,t);if(!s)return;a=Oe(a,n,s,!0);const{threadInfo:i}=(0,c.Db)(a,e,s)||{};i&&o.push(i.threadId)})),(0,s.R3)(a),void setTimeout((()=>{(0,s.R3)((0,r.K4)((0,s.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{n.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),Be)}const o=[];t.forEach((e=>{const t=(0,c.X5)(a,e);if(t){o.push(t);const n=je(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);n&&(a=Ue(a,t,n,!0)),setTimeout((()=>{(0,s.R3)((0,r.K4)((0,s.Rd)(),t,[e]))}),Be)}})),(0,s.R3)(a),(0,g.Tw)(o).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=Fe(e=Le(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),g=(0,d.CI)(u);if((0,c.KA)(e,a,u)){var o;if(g&&u.isOutgoing&&(null===(o=u.content)||void 0===o||!o.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}),g||setTimeout((()=>{let e=(0,s.Rd)();m&&(e=(0,r.pf)(e,a,i._f,"replyingToId",l)),(0,s.R3)(Ue(e,a,h))}),Be)}else e=Ue(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 o=(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:o?(0,c.cu)(o):n.emoji,messageId:n.messageId}]},(0,s.R3)(e);break}case"newScheduledMessage":{const{chatId:t,id:a,message:o}=n;e=Le(e,t,a,o,!0);const l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,i._f,"scheduledIds",(0,g.Tw)([...l,a])),(0,s.R3)(e);break}case"updateMessage":{var u,m;const{chatId:a,id:o,message:l}=n,d=(0,c.hj)(e,a,o),h=(0,c.Z1)(e,a);e=Le(e,a,o,l);const g=(0,c.hj)(e,a,o);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),d&&(e=Ue(e,a,g)),l.reactions&&h&&(e=xe(e,a,o,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)||i._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:o}=n;if(!(0,c.Tm)(e,t,a))return;e=Le(e,t,a,o,!0);const l=Object.keys((0,c.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,i._f,"scheduledIds",l),(0,s.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:o,message:i}=n;e=Fe(e,t,i);const l=(0,c.hj)(e,a,o);e=(0,r.K4)(e,a,[o]),i.isScheduled&&(e=(0,r.bV)(e,a,[o])),e=(0,r.cY)(e,a,i.id,{...l,...i,previousLocalId:o});const d=(0,c.hj)(e,a,i.id);e=Ue(e,a,d);const u=(0,c.Db)(e,a,i);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:i.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:i.id,lastReadInboxMessageId:i.id})),(0,s.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:o}=n,l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,i._f,"scheduledIds",[...l,o.id]);const d=(0,c.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:a}),(0,s.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:o}=n,l=(0,c.KB)(e,t)||[],d=a?[...l,...o].sort(((e,t)=>t-e)):l.filter((e=>!o.includes(e)));(0,s.R3)((0,r.pf)(e,t,i._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:o,firstMessageId:i}=n,l={...(0,c.tZ)(e,t,a),...o};if(!l.threadId)return;e=(0,r.Xg)(e,t,a,l),i&&(e=(0,r.pf)(e,t,a,"firstMessageId",i)),(0,s.R3)(e);break}case"resetMessages":{const{id:a}=n,o=(0,c.Zw)(e,a);o&&!(0,d.YC)(a)&&(e=(0,r.K4)(e,a,Object.keys(o).map(Number)),(0,s.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:s,chatId:a}=n;De(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,i._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,s.R3)(a)}),Be))}(a,t,0,e);break}case"deleteHistory":{const{chatId:o}=n,i=e.messages.byChatId[o];o===a.aw&&(0,s.R3)({...e,serviceNotifications:e.serviceNotifications.map((e=>({...e,isDeleted:!0})))}),i?De(o,Object.keys(i.byId).map(Number),t,(0,s.Rd)()):t.requestChatUpdate({chatId:o});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:o}=n;a.forEach((n=>{e=(0,r.cY)(e,t,n,o)})),(0,s.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=n,o=(0,c.ZB)(e,t);if(null!=o&&o.content.poll){var h;const t=o.content.poll.results;let n=t;null!==(h=a.results)&&void 0!==h&&h.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 i={...o.content.poll,...a,results:n};(0,s.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:i}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:o}=n,i=(0,c.ZB)(e,t);if(!i||!i.content.poll||!i.content.poll.results)break;const{poll:l}=i.content,{recentVoterIds:d,totalVoters:u,results:m}=l.results,h=d?[...d]:[],g=u?u+1:1,p=m?[...m]:[];h.push(a),o.forEach((t=>{const n=p.findIndex((e=>e.option===t)),s=p[n],o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,a===e.currentUserId&&(o.isChosen=!0),n?p[n]=o:p.push(o)})),(0,s.R3)((0,r.cY)(e,i.chatId,i.id,{content:{...i.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:o}=n,i=(0,c.hj)(e,t,a),r=(0,c.Z1)(e,n.chatId);if(!r||!i)return;(0,s.R3)(xe(e,t,a,o,r,i.isOutgoing,i));break}case"updateMessageExtendedMedia":{const{chatId:t,id:a,media:o,preview:i}=n,l=(0,c.hj)(e,t,a);if(!(0,c.Z1)(e,n.chatId)||!l)return;if(i){if(!l.content.invoice)return;(0,s.R3)((0,r.cY)(e,t,a,{content:{...l.content,invoice:{...l.content.invoice,extendedMedia:i}}}))}else o&&(0,s.R3)((0,r.cY)(e,t,a,{content:{...o}}));break}case"updateTranscribedAudio":{const{transcriptionId:t,text:a,isPending:o}=n;(0,s.R3)({...e,transcriptions:{...e.transcriptions,[t]:{...e.transcriptions[t]||{},transcriptionId:t,text:a,isPending:o}}});break}}}));const qe=(0,T.P2)((function(){const e=(0,s.Rd)();(0,s.R3)((0,r.ps)(e,{...e.users.statusesById,...$e})),$e={}}),3e3,!0);let $e={};(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"updateUserEmojiStatus":return(0,r.Nq)(e,n.userId,{emojiStatus:n.emojiStatus});case"updateUserStatus":return a=n.userId,o=n.status,$e[a]=o,void qe();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,o=(0,c.dy)(e,t);if(null==o||null===(s=o.fullInfo)||void 0===s||!s.botInfo)return;return(0,r.Nq)(e,t,{fullInfo:{...o.fullInfo,botInfo:{...o.fullInfo.botInfo,menuButton:a}}})}}var a,o})),(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,isCustomEmoji:n.isCustomEmoji});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:o,shouldShowPreviews:i}=n;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,s.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:o,shouldShowPreviews:i}));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 Ge=n(78958),He=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,Ge.dc)(e,n.call.id):(0,Ge.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:o}=n,{currentUserId:i}=e;return e=(0,s.Rd)(),a.forEach((n=>{n.id&&(e=(0,Ge.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,Ge.AH)(e,t,{nextOffset:o})),e}case"updatePhoneCall":{if(!h.Bi)return;const{phoneCall:a,currentUserId:o}=e,{call:i}=n;if(a)return"discarded"===i.state?(t.playGroupCallSound({sound:"end"}),{...e,...i.needRating&&{ratingPhoneCall:i},isCallPanelVisible:void 0,phoneCall:void 0}):void 0;if((null==i?void 0:i.adminId)!==o&&"requested"===i.state)return(0,T.R3)((()=>{(0,Ae.TO)({call:i,user:(0,He.fu)((0,s.Rd)())})})),(0,S.o5)(),{...e,phoneCall:i,isCallPanelVisible:!1}}}}));var Ve=n(9937);(0,s.iw)("apiUpdate",((e,t,n)=>{if("updatePaymentStateCompleted"===n["@type"]){const{inputInvoice:s}=e.payment;if(s&&"chatId"in s&&"messageId"in s){const n=(0,c.hj)(e,s.chatId,s.messageId);if(n&&n.content.invoice){const{amount:e,currency:s,title:a}=n.content.invoice;t.showNotification({message:v.i0("PaymentInfoHint",[(0,Ve.x)(e,s,v.i0.code),a])})}}return h.Xp||(e=(0,r.WY)(e)),n.slug&&s&&"slug"in s&&s.slug!==n.slug?h.Xp?void 0:e:{...e,payment:{...e.payment,status:"paid"}}}}));var _e=n(46752),ze=n(1279),We=n(53551),Xe=n(274),Je=n(45332);function Ye(e){(0,o.d4)((()=>(0,T.Gq)(e)),[e])}var Ke=n(29290);const Qe=document.querySelector('meta[name="viewport"]'),et=(null==Qe?void 0:Qe.getAttribute("content"))||"",tt="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function nt(e){e.preventDefault()}var st=n(65326),at=n(31212),ot=n(18674),it=n(62357),rt=n(15780),ct=n(99203),lt=n(48778);const dt=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"StickerSetModal",!t);return n?o.ZP.createElement(n,e):void 0}));var ut=n(2155),mt=n(95616),ht=n(17358);const gt=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,mt.yi)();const n=(0,K.xW)();if((0,o.d4)((()=>{t&&(0,ht.w)(n)}),[t,n]),!t&&n)return o.ZP.createElement("div",{className:"unread-count active"},(0,ut.bi)(n))}));var pt=n(23989),ft=n(53455),vt=n(60706),It=n(73541),wt=n(2255),yt=n(59107),Pt=n(27370),Zt=n(706);let Ct;function bt(e,t,n,s,a,i){let r,c,l;return r=function(){const[e,t]=(0,o.eJ)(window.navigator.onLine);return(0,o.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}()&&"connectionStateConnecting"!==t?n?Ct.syncing:Ct.online:Ct.waitingForNetwork,c=r===Ct.online||i?"none":s?"middleHeader":a?"minimized":"overlay",r===Ct.waitingForNetwork?l=e("WaitingForNetwork"):r===Ct.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"}(Ct||(Ct={}));var Et=n(36046),St=n(53106),Mt=n(58964),Rt=n(231),kt=n(69589),Tt=n(49187),At=n(83321),Nt=n(40126),Bt=n(49204);const xt=(0,o.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:s}=e;const a=(0,yt.Z)();return o.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:a.isRtl?"rtl":void 0,onClick:s},o.ZP.createElement(Bt.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},o.ZP.createElement(wt.Z,{activeKey:t,name:"slide-fade"},n)),o.ZP.createElement(Rt.Z,{round:!0,size:"tiny",color:"translucent-black"},o.ZP.createElement("span",{className:"icon-close"})))})),Lt=(0,o.X$)((0,s.c$)((e=>{const{query:t,fetchingStatus:n,chatId:s,date:a}=e.globalSearch,{currentUserId:o,connectionState:i,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:o,chatsById:l,globalSearchChatId:s,searchDate:a,theme:(0,c.Pu)(e),animationLevel:u,connectionState:i,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)}}))((e=>{let{content:t,contactsFilter:n,onSearchQuery:i,onSelectSettings:r,onSelectContacts:c,onSelectArchived:l,onReset:u,searchQuery:g,isLoading:p,shouldSkipTransition:f,currentUserId:v,globalSearchChatId:I,searchDate:w,theme:y,animationLevel:P,chatsById:Z,connectionState:C,isSyncing:b,isMessageListOpen:E,isConnectionStatusMinimized:S,areChatsLoaded:M,hasPasscode:R,canInstall:k}=e;const{openChat:T,setGlobalSearchDate:A,setSettingOption:N,setGlobalSearchChatId:B,openChatByUsername:x,lockScreen:L,requestNextSettingsScreen:O,skipLockOnUnload:F}=(0,s.Sv)(),U=(0,yt.Z)(),j=t===m.du.ChatList,D=(0,o.Ye)((()=>w?(0,z.xH)(new Date(1e3*w)):void 0),[w]),q=(0,o.Ye)((()=>j&&Z?Object.values(Z).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[j,Z]),{connectionStatus:$,connectionStatusText:G,connectionStatusPosition:H}=bt(U,C,b,E,S,!M),V=(0,o.I4)((e=>{e.preventDefault(),e.stopPropagation(),R?L():O(m.MT.PasscodeDisabled)}),[R,L,O]);(0,It.y)({"Ctrl+Shift+L":V,"Alt+Shift+L":V,"Meta+Shift+L":V,...h.fl&&{"Mod+L":V}});const _=window.location.hostname===a.xH||a.Cg,W=(0,o.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return o.ZP.createElement(Rt.Z,{round:!0,ripple:j&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:j?t:()=>u(),ariaLabel:j?U("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,_e.Z)("animated-menu-icon",!j&&"state-back",f&&"no-animation")}))}),[j,U,u,f]),X=(0,o.I4)((()=>{g||i("")}),[g,i]),J=(0,o.I4)((()=>{N({isConnectionStatusMinimized:!S})}),[S,N]),Y=(0,o.I4)((()=>{T({id:v,shouldReplaceHistory:!0})}),[v,T]),K=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";N({theme:t}),N({shouldUseSystemTheme:!1}),(0,Pt.Z)(t,P===a.zy)}),[P,N,y]),Q=(0,o.I4)((()=>{window.open(a.ul,"_blank","noopener")}),[]),ee=(0,o.I4)((()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,Zt.W8)(),F()}),[F]),te=(0,o.I4)((()=>{F()}),[F]),ne=(0,o.I4)((()=>{x({username:U("Settings.TipsUsername")})}),[U,x]),se=(0,o.I4)((()=>{L()}),[L]),ae=Boolean(I)||t===m.du.GlobalSearch||t===m.du.Contacts;(0,o.d4)((()=>ae?(0,pt.Z)((()=>u())):void 0),[ae,u]);const oe=t===m.du.Contacts?U("SearchFriends"):U("Search"),ie=a.Tj?`${a.Ji} Beta (master)`:a.eM?"master":a.Ji;return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(St.Z,{trigger:W,footer:`${a.iC} ${ie}`},o.ZP.createElement(Mt.Z,{icon:"saved-messages",onClick:Y},U("SavedMessages")),o.ZP.createElement(Mt.Z,{icon:"archive",onClick:l},o.ZP.createElement("span",{className:"menu-item-name"},U("ArchivedChats")),q>0&&o.ZP.createElement("div",{className:"archived-badge"},q)),o.ZP.createElement(Mt.Z,{icon:"user",onClick:c},U("Contacts")),o.ZP.createElement(Mt.Z,{icon:"settings",onClick:r},U("Settings")),o.ZP.createElement(Mt.Z,{icon:"darkmode",onClick:K},o.ZP.createElement("span",{className:"menu-item-name"},U("lng_menu_night_mode")),o.ZP.createElement(At.Z,{id:"darkmode",label:U("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),o.ZP.createElement(Mt.Z,{icon:"help",onClick:ne},U("TelegramFeatures")),o.ZP.createElement(Mt.Z,{icon:"bug",href:a.mU},"Report Bug"),a.Tj&&o.ZP.createElement(Mt.Z,{icon:"permissions",onClick:Q},"Beta Changelog"),_&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Mt.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:ee},"Switch to K Version"),o.ZP.createElement(Mt.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:te},"Switch to Old Version")),k&&o.ZP.createElement(Mt.Z,{icon:"install",onClick:(0,Et.G)()},"Install App")),o.ZP.createElement(kt.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||w?"with-picker-item":"",value:n||g,focused:ae,isLoading:p||"minimized"===H,spinnerColor:"minimized"===H?"yellow":void 0,spinnerBackgroundColor:"minimized"===H&&"light"===y?"light":void 0,placeholder:oe,autoComplete:"off",canClose:Boolean(I||w),onChange:i,onReset:u,onFocus:X,onSpinnerClick:"minimized"===H?J:void 0},D&&o.ZP.createElement(Tt.Z,{icon:"calendar",title:D,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:A,clickArg:{date:void 0}}),I&&o.ZP.createElement(Tt.Z,{chatOrUserId:I,onClick:B,canClose:!0,clickArg:{id:void 0}})),R&&o.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,size:"smaller",color:"translucent",ariaLabel:`${U("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:se,className:"passcode-lock"},o.ZP.createElement("i",{className:"icon-lock"})),o.ZP.createElement(Nt.Z,{isOpen:"overlay"===H,isCustom:!0,className:"connection-state-wrapper"},o.ZP.createElement(xt,{connectionStatus:$,connectionStatusText:G,onClick:J}))))})));var Ot=n(64963),Ft=n(46590),Ut=n(93133),jt=n(1080);const Dt=(0,o.X$)((0,s.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n,activeChatFolder:s},currentUserId:a,lastSyncTime:o,shouldSkipHistoryAnimations:i}=e;return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:s,currentUserId:a,lastSyncTime:o,shouldSkipHistoryAnimations:i,maxFolders:(0,$.M)(e,"dialogFilters")}}))((e=>{let{foldersDispatch:t,onScreenSelect:n,chatFoldersById:i,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,o.sO)(null),I=(0,yt.Z)();(0,o.d4)((()=>{d&&g()}),[d,g]);const w=(0,o.Ye)((()=>({id:a.Nf,title:(null==r?void 0:r[0])===a.Nf?I("FilterAllChatsShort"):I("FilterAllChats")})),[r,I]),y=(0,o.Ye)((()=>r?r.map((e=>e===a.Nf?w:i[e]||{})).filter(Boolean):void 0),[i,w,r]),P=(null==y?void 0:y.findIndex((e=>e.id===a.Nf)))===c,Z=0===c,C=(0,mt.yi)(),b=(0,o.Ye)((()=>{if(y&&y.length)return y.map(((e,t)=>{var n,s;let{id:o,title:i}=e;const r=o!==a.Nf&&t>m-1;return{id:o,title:i,badgeCount:null===(n=C[o])||void 0===n?void 0:n.chatsCount,isBadgeActive:Boolean(null===(s=C[o])||void 0===s?void 0:s.notificationsCount),isBlocked:r}}))}),[y,C,m]),E=(0,o.I4)((e=>{p(e,{forceOnHeavyAnimation:!0})}),[p]);(0,o.d4)((()=>{b&&b.length&&c>=b.length&&p(0)}),[c,b,p]),(0,o.d4)((()=>{if(v.current&&h.$b&&b&&b.length)return(0,Ot.sf)(v.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Ot.eM.Left?(p(Math.min(c+1,b.length-1),{forceOnHeavyAnimation:!0}),!0):t===Ot.eM.Right&&(p(Math.max(0,c-1),{forceOnHeavyAnimation:!0}),!0)})}),[c,b,p]);const S=(0,o.sO)();S.current=!Z,(0,o.d4)((()=>S.current?(0,pt.Z)((()=>{S.current&&p(0)})):void 0),[c,p]),(0,Ft.Z)({isActive:!Z,onBack:()=>p(0,{forceOnHeavyAnimation:!0})}),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&b){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void 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:M,transitionClassNames:R}=(0,at.Z)(!r,void 0,!0);function k(e){const s=Object.values(i).find((e=>{let{id:t}=e;return t===b[c].id}));return!s||P?o.ZP.createElement(jt.Z,{folderType:"all",isActive:e,lastSyncTime:d,foldersDispatch:t,onScreenSelect:n}):o.ZP.createElement(jt.Z,{folderType:"folder",folderId:s.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t})}const T=b&&b.length>1;return o.ZP.createElement("div",{className:"ChatFolders"},T?o.ZP.createElement(Ut.Z,{tabs:b,activeTab:c,onSwitchTab:E,areFolders:!0}):M?o.ZP.createElement("div",{className:(0,_e.Z)("tabs-placeholder",R)}):void 0,o.ZP.createElement(wt.Z,{ref:v,name:u?"none":I.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:T?b.length:void 0},k))})));var qt=n(34288);const $t=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)})),Gt=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)}));var Ht=n(52328);const Vt=(0,o.X$)((e=>{let{isShown:t,onNewPrivateChat:n,onNewChannel:s,onNewGroup:a}=e;const[i,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{t||r(!1)}),[t]);const c=(0,yt.Z)(),l=(0,_e.Z)("NewChatButton",t&&"revealed",i&&"menu-is-open"),d=(0,o.I4)((()=>{r(!i)}),[i]),u=(0,o.I4)((()=>{r(!1)}),[]);return o.ZP.createElement("div",{className:l,dir:c.isRtl?"rtl":void 0},o.ZP.createElement(Rt.Z,{round:!0,color:"primary",className:i?"active":"",onClick:d,ariaLabel:c(i?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Ht.Z,{isOpen:i,positionX:c.isRtl?"left":"right",positionY:"bottom",autoClose:!0,onClose:u},o.ZP.createElement(Mt.Z,{icon:"channel",onClick:s},c("NewChannel")),o.ZP.createElement(Mt.Z,{icon:"group",onClick:a},c("NewGroup")),o.ZP.createElement(Mt.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),_t=Object.keys(m.du).length/2;let zt;const Wt=(0,o.X$)((e=>{let{content:t,searchQuery:n,searchDate:s,contactsFilter:a,shouldSkipTransition:i,foldersDispatch:r,isUpdateAvailable:c,onSearchQuery:l,onContentChange:d,onScreenSelect:u,onReset:g}=e;const[p,f]=(0,o.eJ)(h.$b),{shouldRender:v,transitionClassNames:I}=(0,at.Z)(c),w=(0,o.sO)(!1),y=(0,o.I4)((()=>{t===m.du.ChatList&&(w.current=!0,f(!0))}),[t]),P=(0,o.I4)((()=>{w.current=!1,zt&&(clearTimeout(zt),zt=void 0),zt=window.setTimeout((()=>{w.current||f(!1)}),250)}),[]),Z=(0,o.I4)((()=>{d(m.du.Settings)}),[d]),C=(0,o.I4)((()=>{d(m.du.Contacts)}),[d]),b=(0,o.I4)((()=>{d(m.du.Archived)}),[d]),E=(0,o.I4)((()=>{window.location.reload()}),[]),S=(0,o.I4)((()=>{d(m.du.NewChannelStep1)}),[d]),M=(0,o.I4)((()=>{d(m.du.NewGroupStep1)}),[d]);(0,o.d4)((()=>{let e;return t!==m.du.ChatList?e=window.setTimeout((()=>{f(!1)}),250):(w.current||h.$b)&&f(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const R=(0,yt.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:y,onMouseLeave:h.$b?void 0:P},o.ZP.createElement(Lt,{content:t,contactsFilter:a,onSearchQuery:l,onSelectSettings:Z,onSelectContacts:C,onSelectArchived:b,onReset:g,shouldSkipTransition:i}),o.ZP.createElement(wt.Z,{name:i?"none":"zoom-fade",renderCount:_t,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return o.ZP.createElement(Dt,{onScreenSelect:u,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement($t,{searchQuery:n,searchDate:s,isActive:e,onReset:g});case m.du.Contacts:return o.ZP.createElement(Gt,{filter:a,isActive:e,onReset:g});default:return}})),v&&o.ZP.createElement(Rt.Z,{fluid:!0,pill:!0,className:(0,_e.Z)("btn-update",I),onClick:E},R("lng_update_telegram")),o.ZP.createElement(Vt,{isShown:p,onNewPrivateChat:C,onNewChannel:S,onNewGroup:M}))})),Xt=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)})),Jt=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)})),Yt=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)}));var Kt;!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"}(Kt||(Kt={}));const Qt=Object.keys(Kt).length/2,en=(0,o.X$)((0,s.c$)((e=>{var t;const{globalSearch:{query:n,date:s},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:o,leftColumnWidth:i,currentUserId:r,passcode:{hasPasscode:l},settings:{nextScreen:d},isUpdateAvailable:u}=e;return{searchQuery:n,searchDate:s,isFirstChatFolderActive:0===a,shouldSkipHistoryAnimations:o,leftColumnWidth:i,currentUserId:r,hasPasscode:l,nextSettingsScreen:d,isChatOpen:Boolean(null===(t=(0,c.jr)(e))||void 0===t?void 0:t.id),isUpdateAvailable:u}}))((e=>{let{searchQuery:t,searchDate:n,isFirstChatFolderActive:a,shouldSkipHistoryAnimations:i,leftColumnWidth:r,currentUserId:c,hasPasscode:l,nextSettingsScreen:d,isChatOpen:u,isUpdateAvailable:g}=e;const{setGlobalSearchQuery:p,setGlobalSearchChatId:f,resetChatCreation:v,setGlobalSearchDate:I,loadPasswordInfo:w,clearTwoFaError:y,setLeftColumnWidth:P,resetLeftColumnWidth:Z,openChat:C,requestNextSettingsScreen:b}=(0,s.Sv)(),E=(0,o.sO)(null),[S,M]=(0,o.eJ)(m.du.ChatList),[R,k]=(0,o.eJ)(m.MT.Main),[T,A]=(0,o.eJ)(""),[N,B]=(0,ft.ZP)(),[x,L]=(0,o.eJ)(0);let O=Kt.Main;switch(S){case m.du.Archived:O=Kt.Archived;break;case m.du.Settings:O=Kt.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:O=Kt.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:O=Kt.NewGroup}const F=(0,o.I4)((e=>{function t(){M(m.du.ChatList),A(""),p({query:""}),I({date:void 0}),f({id:void 0}),v(),setTimeout((()=>{L(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(R){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.Stickers:case m.MT.Experimental:return void k(m.MT.Main);case m.MT.GeneralChatBackground:return void k(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void k(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.PrivacyVoiceMessages: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 k(m.MT.Privacy);case m.MT.PasscodeNewPasscode:return void k(l?m.MT.PasscodeEnabled:m.MT.PasscodeDisabled);case m.MT.PasscodeChangePasscodeCurrent:case m.MT.PasscodeTurnOff:return void k(m.MT.PasscodeEnabled);case m.MT.PasscodeNewPasscodeConfirm:return void k(m.MT.PasscodeNewPasscode);case m.MT.PasscodeChangePasscodeNew:return void k(m.MT.PasscodeChangePasscodeCurrent);case m.MT.PasscodeChangePasscodeConfirm:return void k(m.MT.PasscodeChangePasscodeNew);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void k(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void k(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void k(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyPhoneCallAllowedContacts:case m.MT.PrivacyPhoneCallDeniedContacts:return void k(m.MT.PrivacyPhoneCall);case m.MT.PrivacyPhoneP2PAllowedContacts:case m.MT.PrivacyPhoneP2PDeniedContacts:return void k(m.MT.PrivacyPhoneP2P);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void k(m.MT.PrivacyForwarding);case m.MT.PrivacyVoiceMessagesAllowedContacts:case m.MT.PrivacyVoiceMessagesDeniedContacts:return void k(m.MT.PrivacyVoiceMessages);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void k(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void k(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void k(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void k(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void k(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void k(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void k(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void k(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void k(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void k(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void k(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void k(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void k(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void k(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return M(m.du.ChatList),void k(m.MT.Main);case m.MT.QuickReaction:case m.MT.CustomEmoji:return void k(m.MT.Stickers)}S===m.du.ChatList&&a?M(m.du.GlobalSearch):t()}else M(m.du.NewChannelStep1);else M(m.du.NewGroupStep1);else t()}),[S,a,R,p,I,f,v,l]),U=(0,o.I4)((e=>{S!==m.du.Contacts?(M(m.du.GlobalSearch),e!==t&&p({query:e})):A(e)}),[S,t,p]);(0,o.d4)((()=>S!==m.du.ChatList||a&&!u?(0,pt.Z)((()=>F())):void 0),[a,S,F,u]);const j=(0,o.I4)((e=>{S!==m.du.GlobalSearch&&(e.preventDefault(),M(m.du.GlobalSearch))}),[S]),D=(0,o.I4)((e=>{e.preventDefault(),C({id:c,shouldReplaceHistory:!0})}),[c,C]),q=(0,o.I4)((e=>{e.preventDefault(),M(m.du.Settings)}),[]);(0,It.y)({"Mod+Shift+F":j,"Mod+Shift+S":D,"Mod+0":D,...h.jm&&h.fl&&{"Mod+,":q}}),(0,o.d4)((()=>{y(),R===m.MT.Privacy&&w()}),[y,w,R]),(0,Ke.Z)((()=>{d&&(M(m.du.Settings),k(d),b(void 0))}),[d,b]);const{initResize:$,resetResize:G,handleMouseUp:H}=function(e,t,n,s){const[a,i,r]=(0,vt.Z)(),[c,l]=(0,o.eJ)(),[d,u]=(0,o.eJ)();function m(){document.body.classList.remove("cursor-ew-resize")}return(0,o.bt)((()=>{e.current&&s&&(e.current.style.width=`${s}px`)}),[e,s]),(0,o.d4)((()=>{if(!a)return;const n=t=>{const n=Math.ceil(d+t.clientX-c);e.current.style.width=`${n}px`};function s(){o(),t(e.current.offsetWidth)}function o(){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),o}),[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),i()},resetResize:function(t){t.preventDefault(),e.current.style.width="",n()},handleMouseUp:m}}(E,P,Z,r),V=(0,o.I4)((e=>{M(m.du.Settings),k(e)}),[]);return o.ZP.createElement("div",{id:"LeftColumn",ref:E},o.ZP.createElement(wt.Z,{name:i?"none":h.s0,renderCount:Qt,activeKey:O,shouldCleanup:!0,cleanupExceptionKey:Kt.Main},(e=>{switch(O){case Kt.Archived:return o.ZP.createElement(Yt,{isActive:e,onReset:F,onContentChange:M});case Kt.Settings:return o.ZP.createElement(Xt,{isActive:e,currentScreen:R,foldersState:N,foldersDispatch:B,onScreenSelect:V,onReset:F,shouldSkipTransition:i});case Kt.NewChannel:return o.ZP.createElement(Jt,{key:x,isActive:e,isChannel:!0,content:S,onContentChange:M,onReset:F});case Kt.NewGroup:return o.ZP.createElement(Jt,{key:x,isActive:e,content:S,onContentChange:M,onReset:F});default:return o.ZP.createElement(Wt,{content:S,searchQuery:t,searchDate:n,contactsFilter:T,foldersDispatch:B,onContentChange:M,onSearchQuery:U,onScreenSelect:V,onReset:F,shouldSkipTransition:i,isUpdateAvailable:g})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:$,onMouseUp:H,onDoubleClick:G}))})));var tn=n(12420),nn=n(49524),sn=n(71394);var an=n(12255),on=n(52678),rn=n(87204),cn=n(3570),ln=n(75790),dn=n(18360),un=n(6058),mn=n(98799);const hn=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"HeaderMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),gn=(0,o.X$)((0,s.c$)(((e,t)=>{var n,s,o;let{chatId:r,threadId:l,messageListType:u}=t;const m=(0,c.Z1)(e,r),g=Boolean(m&&(0,d.eA)(m));if(!m||m.isRestricted||(0,c.CA)(e))return{noMenu:!0};const p=(0,c.IK)(e,r),f=(0,c.FM)(e,r),v="thread"===u&&l===i._f,I="thread"===u&&l!==i._f,w=(0,c.Jf)(e),y=Boolean(p&&(0,c.s4)(e,p.id)),P=!y&&Boolean((0,c.pk)(e,r)),Z=Boolean(v&&(g||(0,d.ZV)(m))&&m.isNotJoined),C=v||I,b=h.Bi&&(0,d.YC)(m.id)&&!f&&!p,E=v&&!f&&!Z,S=v&&!Z,M=h.Bi&&m.isCallActive,R=h.Bi&&!m.isCallActive&&((null===(n=m.adminRights)||void 0===n?void 0:n.manageCall)||m.isCreator&&(0,d.G9)(m));return{noMenu:!1,isChannel:g,isRightColumnShown:w,canStartBot:P,canRestartBot:y,canSubscribe:Z,canSearch:C,canCall:b,canMute:E,canViewStatistics:null===(s=m.fullInfo)||void 0===s?void 0:s.canViewStatistics,canLeave:S,canEnterVoiceChat:M,canCreateVoiceChat:R,pendingJoinRequests:null===(o=m.fullInfo)||void 0===o?void 0:o.requestsPending,shouldJoinToSend:Boolean((null==m?void 0:m.isNotJoined)&&m.isJoinToSend),shouldSendJoinRequest:Boolean((null==m?void 0:m.isNotJoined)&&m.isJoinRequest),noAnimation:e.settings.byKey.animationLevel===a.oB}}))((e=>{let{chatId:t,threadId:n,noMenu:a,isChannel:i,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:P,shouldJoinToSend:Z,shouldSendJoinRequest:C,noAnimation:b}=e;const{joinChannel:E,sendBotCommand:S,openLocalTextSearch:M,restartBot:R,requestCall:k,requestNextManagementScreen:T,showNotification:A}=(0,s.Sv)(),N=(0,o.sO)(null),B=(0,yt.Z)(),[x,L]=(0,o.eJ)(!1),[O,F]=(0,o.eJ)(void 0),U=(0,o.I4)((()=>{L(!0);const e=N.current.getBoundingClientRect();F({x:e.right,y:e.bottom})}),[]),j=(0,o.I4)((()=>{L(!1)}),[]),D=(0,o.I4)((()=>{F(void 0)}),[]),q=(0,o.I4)((()=>{E({chatId:t}),C&&A({message:B(i?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[E,t,C,A,i,B]),$=(0,o.I4)((()=>{S({command:"/start"})}),[S]),G=(0,o.I4)((()=>{R({chatId:t})}),[t,R]),H=(0,o.I4)((()=>{T({screen:m.u1.JoinRequests})}),[T]),V=(0,o.I4)((()=>{M(),h.wB?document.querySelector("#MobileSearch input").focus():b?requestAnimationFrame((()=>{requestAnimationFrame(pn)})):setTimeout(pn,320)}),[b,M]),_=(0,o.I4)((e=>{d&&h.fl&&!e.shiftKey&&(e.preventDefault(),V())}),[d,V]);return(0,It.y)({"Mod+F":_}),o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,P&&!C&&(l||Z)&&o.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:q},B(i?"ProfileJoinChannel":"ProfileJoinGroup")),P&&C&&o.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:q},B("ChannelJoinRequest")),P&&r&&o.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:$},B("BotStart")),P&&c&&o.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:G},B("BotRestart")),d&&o.ZP.createElement(Rt.Z,{round:!0,ripple:y,color:"translucent",size:"smaller",onClick:V,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),u&&o.ZP.createElement(Rt.Z,{round:!0,color:"translucent",size:"smaller",onClick:function(){k({userId:t})},ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),Boolean(w)&&o.ZP.createElement(Rt.Z,{round:!0,className:"badge-button",ripple:y,color:"translucent",size:"smaller",onClick:H,ariaLabel:B(i?"SubscribeRequests":"MemberRequests")},o.ZP.createElement("i",{className:"icon-user"}),o.ZP.createElement("div",{className:"badge"},w)),o.ZP.createElement(Rt.Z,{ref:N,className:x?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:a,ariaLabel:"More actions",onClick:U},o.ZP.createElement("i",{className:"icon-more"})),O&&o.ZP.createElement(hn,{chatId:t,threadId:n,isOpen:x,anchor:O,withExtraActions:h.wB||!P,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,onSubscribeChannel:q,onSearchClick:V,onClose:j,onCloseAnimationEnd:D}))})));function pn(){const e=document.querySelector(".RightHeader .SearchInput input");null==e||e.focus()}var fn=n(6202),vn=n(2903),In=n(68512),wn=n(17551);function yn(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 Pn=(0,o.X$)((e=>{let{count:t,index:n}=e;const s=(0,o.sO)(null),a=(0,o.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),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,s),i=`clipPath${e}`,r=function(e,t,n){let s="";if(3===n)s=yn(0,0,2,t,1)+yn(0,12,2,t+1,1)+yn(0,25,2,t,1);else for(let e=0;e<n;e++)s+=yn(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${s}" />\n </clipPath>`}(i,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,o);return{markHeight:a,clipPath:r,markTranslateY:c,trackTranslateY:l,trackHeight:o,clipPathId:i}}(t,n)),[t,n]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:i,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("#${i}")`;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(${o}px)`)}}),[a]),1===t)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:i,trackTranslateY:r,markHeight:c,markTranslateY:l,clipPathId:d}=a;return o.ZP.createElement("div",{className:(0,_e.Z)("pinned-message-border",t>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${d}"); width: 2px;\n height: ${i}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${c}px; transform: translateY(${l}px);`})))}));var Zn=n(45370);const Cn=(0,o.X$)((e=>{let{message:t,count:n,index:a,customTitle:i,className:r,onUnpinMessage:c,onClick:l,onAllPinnedClick:u}=e;const{clickBotInlineButton:m}=(0,s.Sv)(),g=(0,yt.Z)(),p=(0,vn.Z)(t),f=(0,fn.Z)((0,d.Ti)(t,"pictogram")),[v,I,w]=(0,vt.Z)(),y=(0,o.I4)((()=>{w(),c&&c(t.id)}),[w,c,t.id]),P=(0,d.eH)(t),Z=(0,o.I4)((()=>{P&&m({messageId:t.id,button:P})}),[m,P,t.id]),[C,b,E]=(0,vt.Z)();return o.ZP.createElement("div",{className:(0,_e.Z)("HeaderPinnedMessage-wrapper",r)},n>1&&o.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:g("EventLogFilterPinnedMessages"),onClick:u},o.ZP.createElement("i",{className:"icon-pin-list"})),c&&o.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:g("UnpinMessageAlertTitle"),className:"unpin-button",onClick:I},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(wn.Z,{isOpen:v,onClose:w,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:y}),o.ZP.createElement("div",{className:(0,_e.Z)("HeaderPinnedMessage",C&&"no-hover"),onClick:l,dir:g.isRtl?"rtl":void 0},o.ZP.createElement(Pn,{count:n,index:a}),p&&function(e,t){const{width:n,height:s}=(0,ye.W7)();return o.ZP.createElement("img",{src:t||e,width:n,height:s,alt:""})}(p,f),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},i||`${g("PinnedMessage")} ${a>0?"#"+(n-a):""}`),o.ZP.createElement("p",{dir:"auto"},o.ZP.createElement(Zn.Z,{lang:g,message:t,noEmoji:Boolean(p)})),o.ZP.createElement(In.Z,null)),P&&o.ZP.createElement(Rt.Z,{size:"tiny",className:"inline-button",onClick:Z,shouldStopPropagation:!0,onMouseEnter:h.$b?void 0:b,onMouseLeave:h.$b?void 0:E},P.text)))}));var bn=n(10396),En=n(64532),Sn=n(23186),Mn=n(75851);const Rn=240;function kn(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((o=>{a.onload=()=>{Tn(a,a.width*t,a.height*t,n).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(s)}))},a.src=s}))}async function Tn(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return An(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 o=await(0,Mn.ix)(e.src),i=(0,Mn.rZ)(o)<Rn?"#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=i,n.fillRect(0,0,t.width,t.height);const o=t.getContext("bitmaprenderer");o?o.transferFromImageBitmap(a):n.drawImage(a,0,0),t.toBlob(e,s)}))}catch(a){return An(e,t,n,void 0,s)}}async function An(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 o=document.createElement("canvas"),i=o.getContext("2d"),r=document.createElement("canvas"),c=r.getContext("2d");if(o.width=t,o.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);i.drawImage(r,0,0,a.width,a.height,0,0,o.width,o.height)}else i.drawImage(e,0,0,o.width,o.height);const l=await(0,Mn.ix)(e.src),d=(0,Mn.rZ)(l)<Rn?"#fff":"#000";return i.fillStyle=d,i.globalCompositeOperation="destination-over",i.fillRect(0,0,o.width,o.height),new Promise((e=>{o.toBlob(e,a)}))}var Nn=n(77510);const Bn=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",xn={width:200,height:200},Ln=115;var On=n(32340),Fn=n(18051);const Un=(0,s.c$)(((e,t)=>{let{message:n}=t;const s=(0,c.Ur)(e,n),a=(0,c.Z1)(e,n.chatId),{volume:o,playbackRate:i,isMuted:r}=e.audioPlayer;return{sender:s,chat:a,volume:o,playbackRate:i,isMuted:r}}))((e=>{let{message:t,className:n,noUi:i,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,yt.Z)(),{audio:y,voice:P,video:Z}=(0,d.qp)(t),C=Boolean(P||Z),b=C||((null==y?void 0:y.duration)||0)>a.J0,E=r?(0,d.OU)(w,r):void 0,S=Ie.UV((0,d.Ti)(t,"inline")),M=((e,t,n)=>{const s=(0,yt.Z)(),{audio:a,voice:i}=(0,d.qp)(e),r=a?a.title||a.fileName:i?"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||i&&m,g=(0,fn.Z)(h),p=(0,o.Ye)((()=>function(e,t,n){if(!n)return xn;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?ye.vY:void 0}(a,i,g)),[a,g,i]),{result:f}=(0,Nn.Z)((()=>function(e,t){if(!e)return Promise.resolve(Bn);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,o=new Image;return new Promise((i=>{o.onload=()=>{Tn(o,t,n,s).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(i).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},o.src=a}))}(e,Ln,Ln);const n=Math.min(t.width,t.height);return n<Ln?kn(e,Ln/n):Promise.resolve(e)}(g,p)),[g,p],Bn);return(0,o.Ye)((()=>(0,En.Of)({title:r,artist:c,album:l,artwork:[{src:f}]})),[l,c,r,f])})(t,r,c),{playPause:R,stop:k,isPlaying:T,requestNextTrack:A,requestPreviousTrack:N,isFirst:B,isLast:x,setVolume:L,toggleMuted:O,setPlaybackRate:F}=(0,Sn.Z)((0,bn.An)(t),(0,d.XV)(t),C?"voice":"audio",S,void 0,M,void 0,!0,void 0,void 0,(0,d.CI)(t),!0),U=C&&T;(0,o.d4)((()=>{if(U)return Se.Z.disableRefresh(),()=>{Se.Z.enableRefresh()}}),[U]);const j=(0,o.I4)((()=>{v({chatId:t.chatId,messageId:t.id})}),[v,t.chatId,t.id]),D=(0,o.I4)((()=>{T&&R(),I(),(0,En.Ay)(),k()}),[I,T,R,k]),q=(0,o.I4)((e=>{g({volume:e/100}),L(e/100)}),[g,L]),$=(0,o.I4)((()=>{h.$b&&!h.cj||(O(),f({isMuted:!m}))}),[m,f,O]),G=(0,o.I4)((()=>{1===u?(F(1.8),p({playbackRate:1.8})):(F(1),p({playbackRate:1}))}),[u,p,F]),H=(0,o.Ye)((()=>0===l||m?"icon-muted":l<.3?"icon-volume-1":l<.6?"icon-volume-2":"icon-volume-3"),[l,m]);if(!i)return o.ZP.createElement("div",{className:(0,_e.Z)("AudioPlayer",n),dir:w.isRtl?"rtl":void 0},o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:j},y?function(e){const{title:t,performer:n,fileName:s}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,On.Z)(t||s)),n&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,On.Z)(n)))}(y):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,On.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(w("AttachAudio"),E),o.ZP.createElement(In.Z,null)),o.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:B(),onClick:N,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,_e.Z)("toggle-play","player-button",T?"pause":"play"),onClick:R,ariaLabel:T?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:x(),onClick:A,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon-skip-next"})),o.ZP.createElement(Rt.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",noPreventDefault:!0},o.ZP.createElement("i",{className:H,onClick:$}),!h.cj&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"volume-slider-spacer"}),o.ZP.createElement("div",{className:"volume-slider"},o.ZP.createElement(Fn.Z,{bold:!0,value:m?0:100*l,onChange:q})))),b&&o.ZP.createElement(Rt.Z,{round:!0,className:(0,_e.Z)("playback-button",1!==u&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:G},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(Rt.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:D,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var jn=n(70172);const Dn=(0,o.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;const s=(0,c.Z1)(e,n),a=(0,He.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),animationLevel:e.settings.byKey.animationLevel}}))((e=>{let{chatId:t,isActive:n,groupCall:a,hasPinnedOffset:i,usersById:r,chatsById:c,animationLevel:l}=e;const{joinGroupCall:d,subscribeToGroupCallUpdates:u}=(0,s.Sv)(),m=(0,yt.Z)(),h=(0,o.I4)((()=>{d({chatId:t})}),[d,t]),g=null==a?void 0:a.participants,p=(0,o.Ye)((()=>g?Object.values(g).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,g,r]);if((0,o.d4)((()=>{if(null!=a&&a.id&&(n||!a.isLoaded))return u({id:a.id,subscribed:!0}),()=>{u({id:a.id,subscribed:!1})}}),[null==a?void 0:a.id,null==a?void 0:a.isLoaded,n,u]),a)return o.ZP.createElement("div",{className:(0,_e.Z)("GroupCallTopPane",i&&"has-pinned-offset",!n&&"is-hidden"),onClick:h},o.ZP.createElement("div",{className:"info"},o.ZP.createElement("span",{className:"title"},m("VoipGroupVoiceChat")),o.ZP.createElement("span",{className:"participants"},m("Participants",a.participantsCount||0,"i"))),o.ZP.createElement("div",{className:"avatars"},p.map((e=>{if(e)return e.user?o.ZP.createElement(jn.Z,{key:e.user.id,user:e.user,animationLevel:l}):o.ZP.createElement(jn.Z,{key:e.chat.id,chat:e.chat,animationLevel:l})}))),o.ZP.createElement(Rt.Z,{round:!0,className:"join"},m("VoipChatJoin")))})));var qn=n(14605);const $n=(0,o.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:i,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,yt.Z)(),[y,P,Z]=(0,vt.Z)(),[C,b]=(0,o.eJ)(!0),[E,S]=(0,o.eJ)(!0),{accessHash:M}=a||{},{isAutoArchived:R,canReportSpam:k,canAddContact:T,canBlockContact:A}=r||{},N=a&&(0,d.G9)(a),B=(0,o.I4)((()=>{l({userId:t}),R&&v({chatId:t})}),[l,R,v,t]),x=(0,o.I4)((()=>{Z(),u({contactId:t,accessHash:M}),k&&C&&m({chatId:t}),E&&h({chatId:t})}),[M,u,Z,h,m,k,E,C,t]),L=(0,o.I4)((()=>{I({chatId:t})}),[t,I]),O=(0,o.I4)((()=>{Z(),m({chatId:t}),N?(p({chatId:t,userId:c}),f({chatId:t,shouldDeleteForAll:!1})):g({chatId:t})}),[t,Z,c,p,f,N,g,m]);if(r)return o.ZP.createElement("div",{className:(0,_e.Z)("ChatReportPanel",n),dir:w.isRtl?"rtl":void 0},T&&o.ZP.createElement(Rt.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:B},w("lng_new_contact_add")),A&&o.ZP.createElement(Rt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:P},w("lng_new_contact_block")),k&&!A&&o.ZP.createElement(Rt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:P},w("lng_report_spam_and_leave")),o.ZP.createElement(Rt.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:L,ariaLabel:w("Close")},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(wn.Z,{isOpen:y,onClose:Z,title:w("BlockUserTitle",i?(0,d.Vl)(i):(0,d.U)(w,a)),text:i?w("UserInfo.BlockConfirmationTitle",(0,d.Js)(i)):w("Chat.Confirm.ReportSpam.Channel"),isButtonsInOneRow:!0,confirmIsDestructive:!0,confirmLabel:w("Block"),confirmHandler:i?x:O},i&&o.ZP.createElement(qn.Z,{label:w("DeleteThisChat"),checked:E,onCheck:S}),i&&k&&o.ZP.createElement(qn.Z,{label:w("ReportChat"),checked:C,onCheck:b})))}))),Gn=(0,o.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s,messageListType:a}=t;const{isLeftColumnShown:o,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!==i._f){const t=(0,c.tZ)(e,n,s);f=(null==t?void 0:t.messagesCount)||0}const v="thread"===a&&s===i._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)),P=Boolean(v&&u&&((0,d.eA)(u)||(0,d.ZV)(u))&&u.isNotJoined),Z=Boolean((null==u?void 0:u.isNotJoined)&&u.isJoinRequest),C={typingStatus:m,isLeftColumnShown:o,isRightColumnShown:(0,c.Jf)(e),isSelectModeActive:(0,c.CA)(e),audioMessage:p,chat:u,messagesCount:f,isChatWithSelf:(0,c.FM)(e,n),lastSyncTime:r,shouldSkipHistoryAnimations:l,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing,hasButtonInHeader:y||w||P||Z},b=(0,c.Zw)(e,n);if("thread"!==a||!b)return C;if(Object.assign(C,{messagesById:b}),s!==i._f){const t=(0,c.qS)(e,n,s),a=t?(0,c.hj)(e,n,t):void 0,o=a?(0,c.cv)(e,a):void 0;return{...C,pinnedMessageIds:t,canUnpin:!1,topMessageSender:o}}const E=(0,c.KB)(e,n);if(null!=E&&E.length){const t=b[E[0]],{canUnpin:n}=t&&(0,c._k)(e,t,s)||{};return{...C,pinnedMessageIds:E,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:P,isChatWithSelf:Z,lastSyncTime:C,hasButtonInHeader:b,shouldSkipHistoryAnimations:E,currentTransitionKey:S,connectionState:M,isSyncing:R}=e;const{openChatWithInfo:k,pinMessage:T,focusMessage:A,openChat:N,openPreviousChat:B,loadPinnedMessages:x,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,s.Sv)(),F=(0,yt.Z)(),U=(0,o.sO)(!0),[j,D]=(0,o.eJ)(0),q=Array.isArray(l)?l[j]:l,$=u&&q?u[q]:void 0,G=Array.isArray(l)?l.length:l?1:void 0,H=y&&(0,d.U)(F,y).length,V=g?(0,d.OU)(F,g):void 0,{settings:_}=y||{};(0,o.d4)((()=>{n===i._f&&C&&c&&x({chatId:t})}),[t,x,C,n,c]),(0,o.d4)((()=>{D(0)}),[l]),(0,ln.Z)(t,q,$);const{width:z}=(0,an.Z)(),W=z<=a.ks,X=h.p7&&v,J=(0,o.sO)(null),Y=(0,o.sO)(!0),K=(0,o.I4)((()=>{k({id:t})}),[k,t]),Q=(0,o.I4)((e=>{T({chatId:t,messageId:e,isUnpin:!0})}),[T,t]),ee=(0,o.I4)((()=>{if($){A({chatId:$.chatId,threadId:n,messageId:$.id});const e=(0,cn.Z)(G||1,j+1);D(e)}}),[$,A,n,G,j]),te=(0,o.I4)((()=>{N({id:t,threadId:i._f,type:"pinned"})}),[N,t]),ne=(0,o.I4)((()=>{setTimeout((()=>{U.current=!0}),450)}),[]),se=(0,o.I4)((e=>{if(U.current){if(U.current=!1,h.wB){const e=document.querySelector(a.Ed);null==e||e.blur()}if(f)return O(),void ne();if(n===i._f&&"thread"===r&&0===S)return h.wB||X?(e.stopPropagation(),N({id:void 0},{forceOnHeavyAnimation:!0})):L(),void ne();B(),ne()}}),[n,r,S,f,B,X,N,L,O,ne]),ae=z>=a.ks&&z<a.jT||z>a.l3&&z<a.ks&&(!H||H>30),oe=ae||z>a._m&&z<a.QU,ie=Boolean((null==_?void 0:_.canAddContact)||(null==_?void 0:_.canBlockContact)||(null==_?void 0:_.canReportSpam)),{shouldRender:re,transitionClassNames:ce}=(0,at.Z)(ie),le=(0,dn.Z)(ie?_:void 0,!0),{shouldRender:de,transitionClassNames:ue}=(0,at.Z)(Boolean(w)),me=(0,dn.Z)(w,!0),{shouldRender:he,transitionClassNames:ge}=(0,at.Z)(Boolean($)),pe=(0,dn.Z)($,!0),fe=(0,dn.Z)(G,!0),ve=(0,dn.Z)(m,!0),Ie=(0,dn.Z)(V),we=(0,rn.Z)(S),ye=void 0!==we&&we<S?we:void 0,Pe=he&&pe||de&&me;(0,o.d4)((()=>{const e=J.current;if(e)return oe&&Pe?void(I||ae?(Y.current&&(e.classList.add("tools-stacked","animated"),Y.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),Y.current=!0)):(e.classList.remove("tools-stacked","animated"),void(Y.current=!0))}),[oe,Pe,ae,I]);const{connectionStatusText:Ze}=bt(F,M,R,!0);function Ce(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",onClick:se,ariaLabel:F(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,_e.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(gt,null))}const be=Boolean(de&&me),Ee=be||!h.wB&&b&&z<a.sg;return o.ZP.createElement("div",{className:"MiddleHeader",ref:J},o.ZP.createElement(wt.Z,{name:E?"none":"slide-fade",activeKey:S,shouldCleanup:!0,cleanupExceptionKey:ye},"thread"===r&&n===i._f?o.ZP.createElement(o.ZP.Fragment,null,(W||S>0)&&Ce(X,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:K},(0,d.YC)(t)?o.ZP.createElement(un.Z,{key:t,userId:t,typingStatus:p,status:Ze,withDots:Boolean(Ze),withFullInfo:!0,withMediaViewer:!0,withUpdatingStatus:!0,withVideoAvatar:c,emojiStatusSize:22,noRtl:!0}):o.ZP.createElement(mn.Z,{key:t,chatId:t,typingStatus:p,status:Ze,withDots:Boolean(Ze),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,withVideoAvatar:c,noRtl:!0}))):"thread"===r?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,F("CommentsCount",P,"i"))):"pinned"===r?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",P,"i"))):"scheduled"===r?o.ZP.createElement(o.ZP.Fragment,null,Ce(),o.ZP.createElement("h3",null,Z?F("Reminders"):F("messages",P,"i"))):void 0),o.ZP.createElement(Dn,{hasPinnedOffset:he&&Boolean(pe)||de&&Boolean(me),chatId:t}),he&&pe&&o.ZP.createElement(Cn,{key:t,message:pe,count:fe||0,index:j,customTitle:Ie,className:(0,_e.Z)(ge,Ee&&"full-width"),onUnpinMessage:ve?Q:void 0,onClick:ee,onAllPinnedClick:te}),re&&o.ZP.createElement($n,{key:t,chatId:t,settings:le,className:ce}),o.ZP.createElement("div",{className:"header-tools"},be&&o.ZP.createElement(Un,{key:(0,d.Tp)(me),message:me,className:ue}),o.ZP.createElement(gn,{chatId:t,threadId:n,messageListType:r,canExpandActions:!be})))})));function Hn(e){return"albumId"in e}function Vn(e,t){let n,s=[],a={originalDate:e[0].date,datetime:(0,z._F)(1e3*e[0].date),senderGroups:[s]};const o=[a];return e.forEach(((i,r)=>{i.isInAlbum?n?(n.messages.push(i),i.content.text&&(n.mainMessage=i)):n={albumId:i.groupedId,messages:[i],mainMessage:i}:s.push(i);const c=e[r+1];if(!n||c&&c.groupedId&&c.groupedId===n.albumId||(s.push(n),n=void 0),c){const e=(0,z._F)(1e3*c.date);a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},o.push(a),s=[],a.senderGroups.push(s)):(c.id===t||i.senderId!==c.senderId||i.isOutgoing!==c.isOutgoing||(0,d.FT)(i)||(0,d.FT)(c)||i.forwardInfo&&c.forwardInfo&&(i.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||i.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||i.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||i.inlineButtons||c.inlineButtons||c.date-i.date>600)&&(s=[],a.senderGroups.push(s))}})),o}var _n=n(30386),zn=n(87675),Wn=n(60539),Xn=n(88957);var Jn=n(60998);var Yn=n(72645),Kn=n(3657);const Qn=h.wZ?1e3:350,es=h.wB?300:500;var ts=n(17240);function ns(e,t){return e?t?238:175:t?238:100}function ss(e,t,n){const s=(0,d.B4)(e),a=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),i=Boolean((0,d.F$)(e)),r=Boolean((0,d.Cg)(e)),{width:c,height:l}=a?(0,ye.Eh)(a,s,t,i,n):(0,ye.GC)(o,s,t,r,n),u=ns(Boolean((0,d.UD)(e)));let m=1;c<u&&u-c<12&&(m=u/c),l*m<90&&90-l*m<12&&(m=90/l);const h=Math.round(c*m),g=Math.round(l*m);return{width:h,height:g,isSmall:h<u||g<90}}var as=n(28712);function os(e,t){return e.reduce(((e,t)=>e+t),t)}function is(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 rs(e,t,n,s){const a=function(e){return e.map((e=>{const t=ss(e);return t.width/t.height}))}(s.messages),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),i=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),r=a.length,c=a.some((e=>e>2)),l=(0,ye.kc)(e,t,!1,n)-(t?2.5:0)*ye.Gw;let d;const u={ratios:a,proportions:o,averageRatio:i,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:o,maxHeight:i=4*s/3}=e;const r=function(e,t){return e.map((e=>t>1.1?(0,as.uZ)(e,1,2.75):(0,as.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=os(r.slice(e,e+t),0);return(s-(t-1)*o)/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=os(t,0)+o*(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-i)*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 i=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-i:Math.round(u*n);l[v]={dimensions:{x:i,y:I,width:m,height:a},sides:d},i+=m+o,++v}I+=a+o}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,o=Math.round(Math.min(n/t[0],Math.min(n/t[1],(a-s)/2)));return[{dimensions:{x:0,y:0,width:n,height:o},sides:11},{dimensions:{x:0,y:o+s,width:n,height:o},sides:14}]}(e):"ww"===n||"qq"===n?function(e){const{ratios:t,maxWidth:n,spacing:s,maxHeight:a}=e,o=(n-s)/2,i=Math.round(Math.min(o/t[0],Math.min(o/t[1],a)));return[{dimensions:{x:0,y:0,width:o,height:i},sides:13},{dimensions:{x:o+s,y:0,width:o,height:i},sides:7}]}(e):function(e){const{ratios:t,minWidth:n,maxWidth:s,spacing:a,maxHeight:o}=e,i=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-i),c=s-r-a,l=Math.min(o,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:o}=e,i=t,r=Math.round(Math.min((t-n)/2,s[1]*(a-n)/(s[2]+s[1]))),c=i-r-n,l=Math.max(o,Math.round(Math.min((a-n)/2,Math.min(r*s[2],c*s[1])))),d=Math.min(Math.round(i*s[0]),a-n-l);return[{dimensions:{x:0,y:0,width:d,height:i},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,o=t,i=Math.round(Math.min(o/n[0],.66*(s-a))),r=(t-a)/2,c=Math.min(s-i-a,Math.round(Math.min(r/n[1],r/n[2])));return[{dimensions:{x:0,y:0,width:o,height:i},sides:11},{dimensions:{x:0,y:i+a,width:r,height:c},sides:12},{dimensions:{x:r+a,y:i+a,width:o-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:o}=e;const i=t,r=Math.round(Math.min(i/n[0],.66*(a-s))),c=Math.round((t-2*s)/(n[1]+n[2]+n[3])),l=Math.max(o,Math.round(Math.min(.4*(t-2*s),c*n[1]))),d=Math.round(Math.max(Math.max(o,.33*(t-2*s)),c*n[3])),u=i-l-d-2*s,m=Math.min(a-r-s,c);return[{dimensions:{x:0,y:0,width:i,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:o}=e;const i=t,r=Math.round(Math.min(i*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=i-l-d-2*a,m=Math.max(o,Math.min(s-r-a,c));return[{dimensions:{x:0,y:0,width:r,height:i},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:is(d)}}let cs,ls;function ds(e){return ls||(ls=getComputedStyle(document.documentElement).getPropertyValue("--font-family")),cs||(cs=document.createElement("span"),cs.style.font=`400 12px ${ls}`,cs.style.whiteSpace="nowrap",cs.style.position="absolute",cs.style.left="-999px",cs.style.opacity=".01",document.body.appendChild(cs)),cs.innerHTML=e,cs.offsetWidth}function us(e,t,n,s,a,i){(0,o.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,Wn.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==s?1e3:void 0,s,void 0,i)}}),[e,t,n,s,a,i])}var ms=n(3858);const hs=3*ye.Gw,gs=Number(ye.Gw),ps="data-is-document-group-hover";function fs(e,t,n,a,i,r,c,l,d,u,m,g,p,f){const{setReplyingToId:v,sendDefaultReaction:I}=(0,s.Sv)(),[w,y,P]=(0,vt.Z)(),[Z,C,b]=(0,vt.Z)(),E=(0,o.sO)();return(0,o.d4)((()=>{if(!h.$b||i||!r||m)return;let e;return(0,Ot.sf)(t.current,{selectorToPreventScroll:".MessageList",excludedClosestSelector:".no-word-wrap",onSwipe:(t,n)=>n===Ot.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,i,n,v,C,b,r,m]),{handleMouseDown:i?void 0:function(e){(0,_n.q)(e),d(e)},handleClick:function(t){if(i)e(t);else if(h.$b)return E.current?(clearInterval(E.current),E.current=void 0,void function(e){const{pageX:t,pageY:s}=e;I({chatId:u,messageId:n,x:t,y:s})}(t)):void(E.current=setTimeout((()=>{E.current=void 0,function(e){if(h.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;Se.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:i?c?ms.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]")||m)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:i?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:o,y:i,height:r}=t.getBoundingClientRect(),c=Math.abs(p?n-a:a+o-n)<hs,l=Math.abs(i+r-s)<gs;c&&l?y():P()},handleSendQuickReaction:function(e){const{x:t,y:s}=e.currentTarget.getBoundingClientRect();I({chatId:u,messageId:n,x:t,y:s})},handleMouseLeave:function(e){P(),f&&function(e){const t=Is(e.currentTarget);t&&t.removeAttribute(ps)}(e)},isSwiped:Z,isQuickReactionVisible:w,handleDocumentGroupMouseEnter:vs}}function vs(e){const t=Is(e.currentTarget);t&&t.setAttribute(ps,"")}function Is(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var ws=n(55254),ys=n(44139),Ps=n(18005);const Zs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"ContextMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0}));var Cs=n(45601);const bs=(0,o.X$)((0,s.c$)(((e,t)=>{var n,s;let{message:a}=t;const{byId:o}=e.users,i=a.senderId,{targetUserIds:r,targetChatId:l}=a.content.action||{},u=a.replyToMessageId,m=u?(0,c.hj)(e,a.chatId,u):void 0,h=(0,c._X)(e,a),{direction:g,noHighlight:p}=h&&e.focusedMessage||{},f=(0,c.Z1)(e,a.chatId),v=f&&((0,d.eA)(f)||i===a.chatId);return{usersById:o,senderUser:!v&&i?(0,c.dy)(e,i):void 0,senderChat:v?f:void 0,targetChatId:l,targetUserIds:r,targetMessage:m,isFocused:h,premiumGiftSticker:null===(n=e.premiumGifts)||void 0===n||null===(s=n.stickers)||void 0===s?void 0:s[0],...h&&{focusDirection:g,noFocusHighlight:p}}}))((e=>{var t;let{message:n,observeIntersectionForReading:a,observeIntersectionForLoading:i,observeIntersectionForPlaying:r,isEmbedded:c,appearanceOrder:l=0,isLastInList:u,usersById:m,senderUser:h,senderChat:g,targetUserIds:p,targetMessage:f,targetChatId:v,isFocused:I,focusDirection:w,noFocusHighlight:y,premiumGiftSticker:P,memoFirstUnreadIdRef:Z}=e;const{openPremiumModal:C,requestConfetti:b}=(0,s.Sv)(),E=(0,yt.Z)(),S=(0,o.sO)(null);(0,Kn._N)(S,a),(0,ln.Z)(n.chatId,n.replyToMessageId,f),us(S,n.chatId,I,w,y);const M=l<=0,[R,k]=(0,vt.Z)(M),T=Boolean(null===(t=n.content.action)||void 0===t?void 0:t.text.startsWith("ActionGift"));(0,o.d4)((()=>{M||setTimeout(k,10*l)}),[l,k,M]);const A=(0,Kn.Op)(S,r),N=(0,o.sO)((()=>{const e=(null==Z?void 0:Z.current)&&n.id>=Z.current;return T&&!n.isOutgoing&&e})());(0,o.d4)((()=>{A&&N.current&&(N.current=!1,b())}),[A,b]);const{transitionClassNames:B}=(0,at.Z)(R,void 0,M,!1),x=(0,o.Ye)((()=>p?p.map((e=>null==m?void 0:m[e])).filter(Boolean):void 0),[p,m]),L=(0,Ps.D)(E,n,h,g,x,f,v,{isEmbedded:c},i,r),{isContextMenuOpen:O,contextMenuPosition:F,handleBeforeContextMenu:U,handleContextMenu:j,handleContextMenuClose:D,handleContextMenuHide:q}=(0,ts.Z)(S),$=void 0!==F;if(c)return o.ZP.createElement("span",{ref:S,className:"embedded-action-message"},L);const G=(0,_e.Z)("ActionMessage message-list-item",I&&!y&&"focused",T&&"premium-gift",$&&"has-menu-open",u&&"last-in-list",B);return o.ZP.createElement("div",{ref:S,id:(0,d.d0)(n.id),className:G,"data-message-id":n.id,onMouseDown:e=>{(0,_n.q)(e),U(e)},onContextMenu:j},o.ZP.createElement("span",null,L),T&&o.ZP.createElement("span",{className:"action-message-gift",tabIndex:0,role:"button",onClick:()=>{var e;C({isGift:!0,fromUserId:null==h?void 0:h.id,toUserId:null==p?void 0:p[0],monthsAmount:(null===(e=n.content.action)||void 0===e?void 0:e.months)||0})}},o.ZP.createElement(Cs.Z,{key:n.id,sticker:P,play:!0,noLoop:!0,nonInteractive:!0}),o.ZP.createElement("strong",null,E("ActionGiftPremiumTitle")),o.ZP.createElement("span",null,E("ActionGiftPremiumSubtitle",E("Months",null===(H=n.content.action)||void 0===H?void 0:H.months,"i"))),o.ZP.createElement("span",{className:"action-message-button"},E("ActionGiftPremiumView"))),F&&o.ZP.createElement(Zs,{isOpen:O,anchor:F,message:n,messageListType:"thread",onClose:D,onCloseAnimationEnd:q}));var H}))),Es=e=>{var t;let{className:n,message:s,sender:a,title:i,customText:r,isProtected:c,noUserColors:l,hasContextMenu:u,observeIntersectionForLoading:m,observeIntersectionForPlaying:h,onClick:g}=e;const p=(0,o.sO)(null),f=(0,Kn.Op)(p,m),v=(0,fn.Z)(s&&(0,d.Ti)(s,"pictogram"),!f),I=(0,vn.Z)(s),w=Boolean(s&&(0,d.Y5)(s)),y=(0,yt.Z)(),P=a?(0,d.OU)(y,a):null==s||null===(t=s.forwardInfo)||void 0===t?void 0:t.hiddenUserName;return o.ZP.createElement("div",{ref:p,className:(0,_e.Z)("EmbeddedMessage",n,a&&!l&&`color-${(0,d.Rs)(a)}`),onClick:s?g:void 0},I&&function(e,t,n,s){const{width:a,height:i}=(0,ye.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{src:t||e,width:a,height:i,alt:"",className:(0,_e.Z)("pictogram",n&&"round"),draggable:!s}),s&&o.ZP.createElement("span",{className:"protector"}))}(I,v,w,c),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},s?(0,d.FT)(s)?o.ZP.createElement(bs,{message:s,isEmbedded:!0,observeIntersectionForLoading:m,observeIntersectionForPlaying:h}):o.ZP.createElement(Zn.Z,{lang:y,message:s,noEmoji:Boolean(I),observeIntersectionForLoading:m,observeIntersectionForPlaying:h}):r||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,On.Z)(P||i||" "))),u&&o.ZP.createElement("i",{className:"embedded-more icon-more"}))};var Ss=n(82535),Ms=n(54752),Rs=n(8018),ks=n(48198),Ts=n(97799);const As=(0,o.X$)((e=>{var t,n;let{reaction:a,activeReaction:i,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=u&&`sticker${u}`,g=m&&`sticker${m}`,p=(0,fn.Z)(h,!u),f=(0,fn.Z)(g,!m),v=Boolean((null==i?void 0:i.reaction)===a&&p&&f),{shouldRender:I,transitionClassNames:w}=(0,at.Z)(v,void 0,!0,"slow"),y=(0,o.I4)((()=>{l({messageId:null==i?void 0:i.messageId,reaction:a})}),[null==i?void 0:i.messageId,a,l]),[P,Z,C]=(0,vt.Z)(),b=!v||!P,E=(0,_e.Z)("ReactionAnimatedEmoji",r&&"in-meta",I&&"is-animating");return o.ZP.createElement("div",{className:E},b&&o.ZP.createElement(ks.Z,{reaction:a}),I&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ts.Z,{key:u,className:w,size:30,tgsUrl:p,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:Z,onEnded:C}),o.ZP.createElement(Ts.Z,{key:m,className:(0,_e.Z)("effect",w),size:100,tgsUrl:f,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:y})))})),Ns=(0,o.X$)((e=>{var t;let{message:n,outgoingStatus:s,signature:a,onClick:i,withReactions:r,activeReaction:c,withReactionOffset:l,availableReactions:d,reactionMessage:u}=e;const m=(0,yt.Z)(),[h,g]=(0,vt.Z)(),p=r&&(null==u||null===(t=u.reactions)||void 0===t?void 0:t.results.filter((e=>e.count>0))),f=(0,o.Ye)((()=>{if(!h)return;const e=(0,z.SA)(1e3*n.date,m.code),t=n.isEdited&&(0,z.SA)(1e3*n.editDate,m.code),s=n.forwardInfo&&(0,z.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 o.ZP.createElement("span",{className:(0,_e.Z)("MessageMeta",l&&"reactions-offset"),dir:m.isRtl?"rtl":"ltr",onClick:i,"data-ignore-on-paste":!0},p&&p.map((e=>o.ZP.createElement(As,{activeReaction:c,reaction:e.reaction,isInMeta:!0,availableReactions:d}))),Boolean(n.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,ut.bi)(n.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),a&&o.ZP.createElement("span",{className:"message-signature"},(0,On.Z)(a)),o.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:g},n.isEdited&&`${m("EditedMessage")} `,(0,z.mr)(m,1e3*n.date)),s&&o.ZP.createElement(Rs.Z,{status:s}))}));var Bs=n(36765);const xs=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:a,shouldLoop:r,lastSyncTime:c,shouldPlayEffect:l,onPlayEffect:u,onStopEffect:m}=e;const{showNotification:g,openStickerSet:p}=(0,s.Sv)(),f=(0,yt.Z)(),v=(0,o.sO)(null),I=t.content.sticker,{stickerSetInfo:w,isVideo:y,hasEffect:P}=I,Z=I.isPreloadedGlobally?void 0:(0,d.Ti)(t,y&&!h.Hh?"pictogram":"inline"),C=(0,Kn.Op)(v,n),b=(0,Kn.Op)(v,a),E=`sticker${I.id}?size=f`,S=(0,fn.Z)(E,!C||!P,i.IU.BlobUrl,c),[M,R,k]=(0,vt.Z)(),T=(0,o.I4)((()=>{k(),null==m||m()}),[m,k]);(0,o.d4)((()=>{P&&b&&l&&(R(),null==u||u())}),[P,b,u,l,R]);const A=(0,o.I4)((()=>{p({stickerSetInfo:I.stickerSetInfo})}),[p,I]),N=(0,o.I4)((()=>{if(P)return M?void g({message:f("PremiumStickerTooltip"),action:A,actionText:f("ViewAction")}):(R(),void(null==u||u()));A()}),[P,M,f,u,A,g,R]),B="isMissing"in w,{width:x,height:L}=(0,ye.Wr)(I),O=(0,_e.Z)("Sticker media-inner",B&&"inactive",P&&!t.isOutgoing&&"reversed");return o.ZP.createElement("div",{ref:v,className:O,style:`width: ${x}px; height: ${L}px;`,onClick:B?void 0:N},o.ZP.createElement(Bs.Z,{containerRef:v,sticker:I,fullMediaHash:Z,fullMediaClassName:"full-media",size:x,shouldLoop:r,noLoad:!C,noPlay:!b,withSharedAnimation:!0,cacheBuster:c}),P&&C&&M&&o.ZP.createElement(Ts.Z,{key:E,className:"effect-sticker",tgsUrl:S,size:1.49*x,play:!0,isLowPriority:!0,noLoop:!0,onEnded:T}))};var Ls=n(13365),Os=n(74753),Fs=n(80036);const Us=7*ye.Gw;function js(e,t,n,a,i,r,l,d){const{interactWithAnimatedEmoji:u,sendEmojiInteraction:m,sendWatchingEmojiInteraction:h}=(0,s.Sv)(),g=r||l,p=(0,o.sO)(null),f=(0,o.sO)(null),v=(0,fn.Z)(n?`document${n}`:void 0,!n),I=d||Us,w=(0,Fs.Z)(`width: ${I}px`,`height: ${I}px`,(l||r)&&"cursor: pointer"),y=(0,o.sO)(void 0),P=(0,o.sO)(void 0),Z=(0,o.I4)((()=>{p.current&&(m({chatId:e,messageId:t,localEffect:r,emoji:l,interactions:y.current}),P.current=void 0,y.current=void 0)}),[m,e,t,r,l]),C=(0,o.I4)((()=>{const e=f.current;v&&(e&&(e.pause(),e.remove()),f.current=new Audio,f.current.src=v,(0,Os.Z)(f.current),f.current.addEventListener("ended",(()=>{f.current=void 0}),{once:!0}))}),[v]),b=(0,o.I4)((()=>{C();const n=p.current;if(!(g&&n&&t&&e))return;const{x:s,y:a}=n.getBoundingClientRect();u({localEffect:r,emoji:l,x:s,y:a,startSize:I,isReversed:!i}),y.current||(y.current=[],P.current=performance.now(),setTimeout(Z,1e3)),y.current.push(P.current?(performance.now()-P.current)/1e3:0)}),[e,l,g,u,i,r,t,C,Z,I]);return(0,o.d4)((()=>{const n=p.current;n&&a&&a.forEach((s=>{let{id:a,startSize:o,messageId:d}=s;if(o||t!==d)return;const{x:u,y:m}=n.getBoundingClientRect();h({id:a,chatId:e,emoticon:r?(0,c.ji)(r):l,startSize:I,x:u,y:m,isReversed:!i}),C()}))}),[a,e,l,i,r,t,C,h,I]),{ref:p,size:I,style:w,handleClick:b}}var Ds=n(21179);const qs=(0,o.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:s,forceLoadPreview:a,messageId:i,chatId:r,activeEmojiInteractions:c,sticker:l,effect:d,localSticker:u,localEffect:m,soundId:h}=e;const{ref:g,size:p,style:f,handleClick:v}=js(r,i,h,c,t,m,null==d?void 0:d.emoji),I=(0,Kn.Op)(g,n);return u?o.ZP.createElement(Ds.Z,{tgsUrl:Ls.l[u],size:p,quality:1,play:I,forceOnHeavyAnimation:!0,ref:g,className:"AnimatedEmoji media-inner",style:f,onClick:v}):o.ZP.createElement(Cs.Z,{sticker:l,size:p,quality:1,noLoad:!I,forcePreview:a,lastSyncTime:s,play:I,forceOnHeavyAnimation:!0,ref:g,className:(0,_e.Z)("AnimatedEmoji media-inner",(null==l?void 0:l.id)===ye.wB&&"like-sticker-thumb"),style:f,onClick:v})})));var $s=n(41012);const Gs=(0,o.X$)((0,s.c$)(((e,t)=>{let{customEmojiId:n,withEffects:s}=t;const a=e.customEmojis.byId[n];return{sticker:a,effect:null!=a&&a.emoji&&s?(0,c.tH)(e,a.emoji):void 0,soundId:(null==a?void 0:a.emoji)&&(0,c.Oh)(e,a.emoji)}}))((e=>{let{isOwn:t,customEmojiId:n,messageId:s,chatId:a,activeEmojiInteractions:i,sticker:r,effect:c,soundId:l,observeIntersection:d}=e;const{ref:u,size:m,style:h,handleClick:g}=js(a,s,l,i,t,void 0,null==c?void 0:c.emoji,(0,ys.qo)(1));return o.ZP.createElement($s.Z,{ref:u,documentId:n,className:(0,_e.Z)("AnimatedEmoji media-inner",(null==r?void 0:r.id)===ye.wB&&"like-sticker-thumb"),style:h,size:m,withSharedAnimation:!0,forceOnHeavyAnimation:!0,observeIntersectionForLoading:d,onClick:g})}))),Hs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function Vs(e,t,n,s,a){return s?Promise.resolve(Hs[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 o=t?n.width-1:0,i=n.height-1;return`rgba(${Array.from(a.getImageData(o,i,1,1).data).join(",")})`}(e,t)}var _s=n(92566),zs=n(15866);function Ws(e,t){return(0,zs.Z)((0,d.DH)(e),Boolean(t),h.wB&&!h.vX)}var Xs=n(70692),Js=n(39196);const Ys=e=>{let{id:t,message:n,observeIntersection:s,noAvatars:i,canAutoLoad:r,isInSelectMode:c,isSelected:l,uploadProgress:u,size:m="inline",dimensions:h,asForwarded:g,nonInteractive:p,shouldAffectAppendix:f,isDownloading:v,isProtected:I,theme:w,onClick:y,onCancelUpload:P}=e;const Z=(0,o.sO)(null),C=((0,d.O$)(n)||(0,d.F$)(n)).blobUrl,b=(0,Kn.Op)(Z,s),[E,S]=(0,o.eJ)(r),M=E&&b,{mediaData:R,loadProgress:k}=(0,_s.Z)((0,d.Ti)(n,m),!M),T=C||R,[A]=(0,o.eJ)(!T),N=Boolean(T),B=Ws(n,N),x=(0,Xs.Z)(!N),{loadProgress:L}=(0,_s.Z)((0,d.Ti)(n,"download"),!v,(0,d.kG)(n,"download")),{isUploading:O,isTransferring:F,transferProgress:U}=(0,d.Sc)(n,u||(v?L:k),M&&!T),j=!1===(0,rn.Z)(E),{shouldRender:D,transitionClassNames:q}=(0,at.Z)(F,void 0,j,"slow"),{shouldRender:$,transitionClassNames:G}=(0,at.Z)(!T&&!E),H=(0,o.I4)((()=>{O?P&&P(n):T?y&&y(n.id):S((e=>!e))}),[T,O,n,P,y]),V=(0,d.B4)(n);(0,Yn.Z)((e=>{let[t]=e;if(!f)return void(t&&Z.current.closest(".message-content").removeAttribute(a.s2));const n=Z.current.closest(".message-content");T?Vs(T,V,0,l,w).then((e=>{n.style.setProperty("--appendix-bg",e),n.setAttribute(a.s2,"")})):n.classList.add("has-appendix-thumb")}),[f,T,V,c,l,w]);const{width:_,height:z,isSmall:W}=h||ss(n,g,i),X=(0,_e.Z)("media-inner",!O&&!p&&"interactive",W&&"small-image",_===z&&"square-image"),J=h?` width: ${_}px; left: ${h.x}px; top: ${h.y}px;`:"",Y="inline"===m?`height: ${z}px;${J}`:void 0;return o.ZP.createElement("div",{id:t,ref:Z,className:X,style:Y,onClick:O?void 0:H},o.ZP.createElement("img",{src:T,className:"full-media",alt:"",draggable:!I}),A&&o.ZP.createElement("canvas",{ref:B,className:(0,_e.Z)("thumbnail",x)}),I&&o.ZP.createElement("span",{className:"protector"}),D&&!$&&o.ZP.createElement("div",{className:`media-loading ${q}`},o.ZP.createElement(Js.Z,{progress:U,onClick:O?H:void 0})),$&&o.ZP.createElement("i",{className:(0,_e.Z)("icon-download",G)}),F&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*U),"%"))};var Ks=n(35148);const Qs=e=>{var t;let{id:n,message:a,observeIntersectionForLoading:i,observeIntersectionForPlaying:r,noAvatars:c,canAutoLoad:l,canAutoPlay:u,uploadProgress:m,lastSyncTime:h,dimensions:g,asForwarded:p,isDownloading:f,isProtected:v,onClick:I,onCancelUpload:w}=e;const y=(0,o.sO)(null),P=(0,o.sO)(null),Z=(0,d.b7)(a)||(0,d.Cg)(a),C=Z.blobUrl,b=(0,Kn.Op)(y,i),E=(0,Kn.Op)(y,r)&&b,S=(0,o.sO)(b);E&&!S.current&&(S.current=!0);const[M,R]=(0,o.eJ)(l),k=Boolean(M&&b&&h),[T,A]=(0,o.eJ)(u),N=(0,d.Ti)(a,"inline"),[B]=(0,o.eJ)(Boolean(N&&Ie.UV(N))),{mediaData:x,loadProgress:L}=(0,_s.Z)(N,!k,(0,d.kG)(a,"inline"),h),O=C||x,[F,U]=(0,vt.Z)(),j=Boolean((0,d.DH)(a)),D=(0,d.Ti)(a,"preview"),[q]=(0,o.eJ)(Boolean(D&&Ie.UV(D))),$=b&&h,G=(0,fn.Z)(D,!$,void 0,h),H=(0,Xs.Z)((j||G)&&!F),V=!j||G||F,_=Ws(a,V),W=(0,Xs.Z)(!V),X=O&&S.current,{loadProgress:J}=(0,_s.Z)((0,d.Ti)(a,"download"),!f,(0,d.kG)(a,"download"),h),{isUploading:Y,isTransferring:K,transferProgress:Q}=(0,d.Sc)(a,m||(f?J:L),k&&!F&&!B||f),ee=!1===(0,rn.Z)(M),{shouldRender:te,transitionClassNames:ne}=(0,at.Z)(K,void 0,ee),{transitionClassNames:se}=(0,at.Z)(Boolean((M||O)&&!T&&!te)),[ae,oe]=(0,o.eJ)(0),ie=(0,o.I4)((e=>{oe(Math.max(0,e.currentTarget.currentTime-1))}),[]),re=(null===(t=P.current)||void 0===t?void 0:t.duration)||Z.duration||0,ce=(0,d.B4)(a),le=Boolean((0,d.Cg)(a)),{width:de,height:ue}=g||(0,ye.GC)(Z,ce,p,le,c),me=(0,o.I4)((()=>{Y?w&&w(a):f?(0,s.Sv)().cancelMessageMediaDownload({message:a}):O?O&&!T?A(!0):I&&I(a.id):R((e=>!e))}),[Y,f,O,T,I,w,a]),he=(0,_e.Z)("media-inner dark",!Y&&"interactive"),ge=`height: ${ue}px;${g?` width: ${de}px; left: ${g.x}px; top: ${g.y}px;`:""}`;return o.ZP.createElement("div",{ref:y,id:n,className:he,style:ge,onClick:Y?void 0:me},X&&o.ZP.createElement(Ks.Z,{ref:P,src:O,className:"full-media",canPlay:T&&E,muted:!0,loop:!0,playsInline:!0,draggable:!v,onTimeUpdate:ie,onReady:U}),o.ZP.createElement("img",{src:G,className:(0,_e.Z)("thumbnail",H),alt:"",draggable:!v}),j&&!q&&o.ZP.createElement("canvas",{ref:_,className:(0,_e.Z)("thumbnail",W)}),v&&o.ZP.createElement("span",{className:"protector"}),o.ZP.createElement("i",{className:(0,_e.Z)("icon-large-play",se)}),te&&o.ZP.createElement("div",{className:(0,_e.Z)("media-loading",ne)},o.ZP.createElement(Js.Z,{progress:Q,onClick:me})),!M&&!O&&o.ZP.createElement("i",{className:"icon-download"}),K?o.ZP.createElement("span",{className:"message-transfer-progress"},Y||f?`${Math.round(100*Q)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},Z.isGif?"GIF":(0,z.k9)(Math.max(re-ae,0))))};var ea=n(6272);const ta=(0,s.c$)(((e,t)=>{let{contact:n}=t;const{countryList:{phoneCodes:s}}=e;return{user:(0,c.dy)(e,n.userId),phoneCodeList:s,animationLevel:e.settings.byKey.animationLevel}}))((e=>{let{contact:t,user:n,phoneCodeList:a,animationLevel:i}=e;const{openChat:r}=(0,s.Sv)(),{firstName:c,lastName:l,phoneNumber:d,userId:u}=t,m="0"!==u,h=(0,o.I4)((()=>{r({id:u})}),[r,u]);return o.ZP.createElement("div",{className:(0,_e.Z)("Contact",m&&"interactive"),onClick:m?h:void 0},o.ZP.createElement(jn.Z,{size:"large",user:n,text:c||l,animationLevel:i,withVideo:!0}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},c," ",l),o.ZP.createElement("div",{className:"contact-phone"},(0,ea.WZ)(a,d))))}));var na=n(20230),sa=n(51218),aa=n(14434),oa=n(96937);function ia(e,t){return t>0?(e/t*100).toFixed():0}const ra=e=>{let{answer:t,voteResults:n,totalVoters:s,maxVotersCount:a,correctResults:i,shouldAnimate:r}=e;const c=n&&n.find((e=>e.option===t.option)),l=0===i.length||-1!==i.indexOf(t.option),d=i.length>0&&l||(null==c?void 0:c.isChosen),u=c?ia(c.votersCount,s||0):0,[m,h]=(0,o.eJ)(r?0:u),g=(0,o.sO)(null),p=c?ia(c.votersCount,a||0):0,f=m!==u;if((0,o.d4)((()=>{r&&h(u)}),[r,u]),(0,o.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 o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",d&&o.ZP.createElement("span",{className:(0,_e.Z)("poll-option-chosen",!l&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:l?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,On.Z)(t.text)),o.ZP.createElement("div",{className:(0,_e.Z)("poll-option-answer",d&&!l&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:g}),o.ZP.createElement("div",{className:"poll-option-line",style:v}))))};function ca(e){e.stopPropagation()}const la=(0,o.X$)((0,s.c$)(((e,t)=>{let{poll:n}=t;const{recentVoterIds:s}=n.results,{serverTimeOffset:a,users:{byId:o}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:o,serverTimeOffset:a}:{}}))((e=>{let{message:t,poll:n,recentVoterIds:a,usersById:i,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,o.eJ)(!1),[I,w]=(0,o.eJ)([]),[y,P]=(0,o.eJ)(!1),[Z,C]=(0,o.eJ)(!1),[b,E]=(0,o.eJ)(!g.closed&&g.closeDate&&g.closeDate>0?Math.min(g.closeDate-Math.floor(Date.now()/1e3)+c,g.closePeriod):0),S=(0,o.sO)(null),{results:M,totalVoters:R}=p,k=M&&M.some((e=>e.isChosen)),T=!g.closed&&!k,A=!T&&g.isPublic&&Number(p.totalVoters)>0,N=T&&g.multipleChoice,B=M?Math.max(...M.map((e=>e.votersCount))):R,x=M?M.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,o.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,o.d4)((()=>{b>0&&setTimeout((()=>E(b-1)),1e3);const e=S.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,z.k9)(b),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,z.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,o.d4)((()=>{g.quiz&&(b<=0||k&&!g.closed)&&l({chatId:h,messageId:m})}),[h,b,k,l,m,g.closed,g.quiz]),(0,o.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)}}),[T,h,l,m,g.closePeriod,g.closed,g.quiz]);const O=(0,o.Ye)((()=>a?a.reduce(((e,t)=>{const n=i[t];return n&&e.push(n),e}),[]):[]),[i,a]),F=(0,o.I4)((e=>{w([e]),v(!0),C(!0),r([e])}),[r]),U=(0,o.I4)((e=>{w(e)}),[]),j=(0,o.I4)((()=>{v(!0),C(!0),r(I)}),[r,I]),D=(0,o.I4)((()=>{d({chatId:h,messageId:m})}),[h,m,d]),q=(0,o.I4)((()=>{P(!0)}),[]),$=(0,o.I4)((()=>{P(!1),C(!1)}),[]);(0,o.d4)((()=>{Z&&k&&g.quiz&&p.results&&n.results.solution&&(p.results.find((e=>e.isChosen&&e.isCorrect))||P(!0))}),[k,Z,p.results,g.quiz,n.results.solution]);const G=(0,yt.Z)();return o.ZP.createElement("div",{className:"Poll",dir:G.isRtl?"auto":"ltr"},y&&n.results.solution&&o.ZP.createElement(oa.Z,{message:(0,na.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:$,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,On.Z)(g.question,["emoji","br"])),o.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&&o.ZP.createElement("div",{className:"poll-recent-voters"},O.map((e=>o.ZP.createElement(jn.Z,{size:"micro",user:e})))),b>0&&T&&o.ZP.createElement("div",{ref:S,className:"poll-countdown"}),g.quiz&&n.results.solution&&!T&&o.ZP.createElement(Rt.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:y,onClick:q,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),T&&o.ZP.createElement("div",{className:"poll-answers",onClick:ca},N?o.ZP.createElement(sa.Z,{options:L,onChange:U,disabled:t.isScheduled||f,loadingOptions:f?I:void 0,round:!0}):o.ZP.createElement(aa.Z,{name:`poll-${m}`,options:L,onChange:F,disabled:t.isScheduled||f,loadingOption:f?I[0]:void 0})),!T&&o.ZP.createElement("div",{className:"poll-results"},g.answers.map((function(e){return o.ZP.createElement(ra,{key:e.option,shouldAnimate:Z||!T,answer:e,voteResults:M,totalVoters:R,maxVotersCount:B,correctResults:x})}))),!A&&!N&&o.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)),N&&o.ZP.createElement(Rt.Z,{isText:!0,disabled:0===I.length,size:"tiny",onClick:j},G("PollSubmitVotes")),A&&o.ZP.createElement(Rt.Z,{isText:!0,size:"tiny",onClick:D},G("PollViewResults")))})));var da=n(48035),ua=n(10088);const ma=(0,o.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,canAutoPlay:i,inPreview:r,asForwarded:c,lastSyncTime:l,isDownloading:u=!1,isProtected:m,theme:h,onMediaClick:g,onCancelMediaTransfer:p}=e;const f=(0,d.s1)(t),v=(0,o.I4)((()=>{g()}),[g]);if(!f)return;const{siteName:I,url:w,displayUrl:y,title:P,description:Z,photo:C,video:b}=f,E=(0,da.Z)(Z,170),S=Boolean(E||P||I);let M=!1;if(S&&null!=f&&f.photo&&!f.video){const{width:e,height:n}=ss(t);M=e===n}const R=(C||b)&&g&&!M,k=(0,_e.Z)("WebPage",r&&"in-preview",M&&"with-square-photo",!C&&!b&&!r&&"without-media",b&&"with-video",!S&&"no-article");return o.ZP.createElement("div",{className:k,"data-initial":(I||y)[0],dir:"auto"},C&&!b&&o.ZP.createElement(Ys,{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,size:M?"pictogram":"inline",asForwarded:c,nonInteractive:!R,isDownloading:u,isProtected:m,theme:h,onClick:R?v:void 0,onCancelUpload:p}),S&&o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(ua.Z,{className:"site-name",url:w,text:I||y}),!r&&P&&o.ZP.createElement("p",{className:"site-title"},(0,On.Z)(P)),E&&o.ZP.createElement("p",{className:"site-description"},(0,On.Z)(E,["emoji","br"]))),!r&&b&&o.ZP.createElement(Qs,{message:t,observeIntersectionForLoading:n,noAvatars:s,canAutoLoad:a,canAutoPlay:i,lastSyncTime:l,asForwarded:c,isDownloading:u,isProtected:m,onClick:R?v:void 0,onCancelUpload:p}))}));var ha=n(17921);const ga=(0,o.X$)((e=>{var t,n;let{message:s,shouldAffectAppendix:i,isInSelectMode:r,isSelected:c,theme:l}=e;const u=(0,o.sO)(null),m=(0,yt.Z)(),h=(0,d.eO)(s),{title:g,text:p,amount:f,currency:v,isTest:I,photo:w}=h,y=(0,fn.Z)((0,d.O9)(w));return(0,Yn.Z)((e=>{let[t]=e;if(i){if(y){const e=u.current.closest(".message-content");Vs(y,!1,0,c,l).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(a.s2,"")}))}}else t&&u.current.closest(".message-content").removeAttribute(a.s2)}),[i,y,r,c,l]),o.ZP.createElement("div",{ref:u,className:"Invoice"},g&&o.ZP.createElement("p",{className:"title"},(0,On.Z)(g)),p&&o.ZP.createElement("div",null,(0,On.Z)(p,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(w?"has-image":"")},y&&o.ZP.createElement("img",{className:"invoice-image",src:y,alt:"",crossOrigin:"anonymous"}),!y&&w&&o.ZP.createElement(ha.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}),o.ZP.createElement("p",{className:"description-text"},(0,Ve.x)(f,v,m.code),I&&o.ZP.createElement("span",null,m("PaymentTestInvoice")))))})),pa={root:"rwnm0xOh31c2MY4kK2No",dots:"Nlcnrzv_f5cSxFsPOGt2",duration:"lKSp02aI8WDGX3393nkh",buy:"gxQfWp0jp0_2Z4qWiXKN",canvas:"a_WnxsI6X0B4j7QRRoOA"},fa=(0,o.X$)((e=>{let{message:t,lastSyncTime:n}=e;const{openInvoice:a,loadExtendedMedia:i}=(0,s.Sv)(),r=(0,yt.Z)(),c=(0,d.eO)(t),{chatId:l,id:u}=t,m=(0,o.I4)((()=>{i({chatId:l,ids:[u]})}),[l,u,i]);(0,it.Z)(m,n?3e4:void 0);const{amount:h,currency:g,extendedMedia:p}=c,{width:f,height:v,thumbnail:I,duration:w}=p,y=(0,zs.Z)(null==I?void 0:I.dataUri,!1,void 0,25,f,v),P=(0,o.I4)((()=>{a({chatId:l,messageId:u,isExtendedMedia:!0})}),[l,u,a]);return o.ZP.createElement("div",{className:(0,_e.Z)(pa.root,"media-inner"),onClick:P},o.ZP.createElement("canvas",{ref:y,className:pa.canvas,width:f,height:v}),o.ZP.createElement("div",{className:pa.dots}),Boolean(w)&&o.ZP.createElement("div",{className:pa.duration},(0,z.k9)(w)),o.ZP.createElement("div",{className:pa.buy},o.ZP.createElement("i",{className:(0,_e.Z)("icon-lock",pa.lock)}),r("Checkout.PayPrice",(0,Ve.x)(h,g))))})),va=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"})),Ia=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"];var wa=n(28183);const ya=n.p+"map-pin.7b3c3e60ee24795e4bd2.svg",Pa=1e-4,Za={width:400,height:300,zoom:16,scale:2},Ca={__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>'},ba=(0,o.X$)((e=>{let{message:t,peer:n,lastSyncTime:s,isInSelectMode:i,isSelected:r,theme:c,serverTimeOffset:l}=e;const u=(0,o.sO)(null),m=(0,o.sO)(null),h=(0,yt.Z)(),g=(0,st.Z)(),f=(0,d.nf)(t),{type:v,geo:I}=f,w=(0,p.b)(l),y=(0,d.$R)(t,w),P="geoLive"!==v||y?void 0:t.date+f.period-w,[Z,C]=(0,o.eJ)(I),b="venue"===v||"geoLive"===v&&!y,{width:E,height:S,zoom:M,scale:R}=Za,k=Boolean(s)&&(0,d.k6)(Z,E,S,M,R),T=(0,fn.Z)(k),A=(0,rn.Z)(T),N=T||A,B=n&&(0,d.YC)(n.id),x=n&&B?n:void 0,L=n&&!B?n:void 0,O=(0,d.B4)(t),F=(0,o.Ye)((()=>{if("geoLive"!==v||!Z.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=Z;return t/function(e,t){return 156543.03392*Math.cos(e*(Math.PI/180))/2**t}(e,M)}),[v,Z,M]),U=(0,o.I4)((e=>{if("geoLive"!==v)return;const n=24*Math.PI,s=e.lastElementChild,a=e.firstElementChild,o=t.date+f.period-(0,p.b)(l),i=(1-o/f.period)*n,r=(0,z.mB)(h,1e3*o);s&&a?(a.textContent=r,s.firstElementChild.setAttribute("stroke-dashoffset",`-${i}`)):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="-${i}"\n />\n </svg>`}),[v,t.date,f,l,h]);return(0,o.bt)((()=>{m.current&&U(m.current)}),[U]),(0,Yn.Z)((e=>{let[t]=e;if(b)t||u.current.closest(".message-content").removeAttribute(a.s2);else if(N){const e=u.current.closest(".message-content");Vs(N,O,0,r,c).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(a.s2,"")}))}}),[b,O,i,r,c,N]),(0,o.d4)((()=>{Math.abs(I.lat-Z.lat)<Pa&&Math.abs(I.long-Z.long)<Pa?Z.accuracyRadius!==I.accuracyRadius&&C({...Z,accuracyRadius:I.accuracyRadius}):C(I)}),[I,Z]),(0,wa.Z)((()=>{g()}),y?void 0:1e3*(P||0)),(0,it.Z)((()=>{const e=m.current;e&&U(e)}),P?1e3:void 0),o.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`}(Z.lat,Z.long,M);null===(e=window.open(t,"_blank","noopener"))||void 0===e||e.focus()}},o.ZP.createElement("div",{className:"map-wrapper"},N?o.ZP.createElement("img",{className:"full-media map",src:N,alt:"Location on a map",width:Za.width,height:Za.height}):o.ZP.createElement(ha.Z,{width:E,height:S}),function(){if(N)return o.ZP.createElement(o.ZP.Fragment,null,Boolean(F)&&!y&&o.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*F}px; height: ${2*F}px`}),function(){const e=(0,_e.Z)("pin",v,y&&"expired");if("geoLive"===v)return o.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Ca},o.ZP.createElement(jn.Z,{chat:L,user:x,className:"location-avatar"}),void 0!==f.heading&&o.ZP.createElement("div",{className:"direction",style:`--direction: ${f.heading}deg`}));if("venue"===v){const t=function(e){return e?va.get(e)||va.get(e.split("/")[0])||Ia[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%Ia.length)]:"#008df2";var t}(f.venueType),n=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(f.venueType);return o.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Ca,style:`--pin-color: ${t}`},o.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return o.ZP.createElement("img",{className:e,src:ya,alt:""})}())}()),function(){if(b)return"venue"===v?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},f.title),o.ZP.createElement("div",{className:"location-info-subtitle"},f.address)):"geoLive"===v?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},h("AttachLiveLocation")),o.ZP.createElement("div",{className:"location-info-subtitle"},(0,z.dJ)(h,w,t.editDate)),!y&&o.ZP.createElement("div",{className:"geo-countdown",ref:m})):void 0}())})),Ea=(0,o.X$)((e=>{let{message:t,canAutoLoadMedia:n,lastSyncTime:a}=e;const{clickBotInlineButton:i}=(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,fn.Z)(u,!n),g=(0,fn.Z)(m,!n);return o.ZP.createElement("div",{className:"Game"},o.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{i({messageId:t.id,button:t.inlineButtons[0][0]})}},!h&&!g&&o.ZP.createElement(ha.Z,{className:"skeleton preview-content"}),h&&o.ZP.createElement("img",{className:"preview-content",src:h,alt:c}),g&&o.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,disablePictureInPicture:!0,autoPlay:!0,loop:!0,src:g})),o.ZP.createElement("div",{className:"title"},c),!(0,d.UD)(t)&&o.ZP.createElement("div",{className:"description"},l))}));function Sa(e){return(0,o.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:i,dimensions:r}=t,{toggleMessageSelection:c}=(0,s.Sv)(),l=(0,o.I4)((e=>{e.stopPropagation(),c({messageId:i.id,withShift:null==e?void 0:e.shiftKey})}),[c,i]),d=(0,o.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 o.ZP.createElement("div",{className:(0,_e.Z)("album-item-select-wrapper",a&&"is-selected"),style:r?`left: ${r.x}px; top: ${r.y}px;`:"",onClick:n?l:void 0},n&&o.ZP.createElement("div",{className:"message-select-control"},a&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const Ma=Sa(Ys),Ra=Sa(Qs),ka=(0,s.c$)(((e,t)=>{let{album:n}=t;const{chatId:s}=n.mainMessage,a=(0,c.Pu)(e),o=(0,c.xs)(e,s);return{theme:a,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:o}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:a,lastSyncTime:i,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,o.I4)((e=>{f({chatId:e.chatId,messageId:e.id})}),[f]),{width:w,height:y}=u.containerStyle;return o.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)],P=null==y?void 0:y.progress,{dimensions:Z,sides:C}=u.layout[t],b=(0,c.bH)((0,s.Rd)(),e),E=(0,c.__)((0,s.Rd)(),e);if(f){const s=a&&(r?t===v-1:Boolean(8&C&&4&C));return o.ZP.createElement(Ma,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersectionForLoading:n,canAutoLoad:b,shouldAffectAppendix:s,uploadProgress:P,dimensions:Z,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})}if(w)return o.ZP.createElement(Ra,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersectionForLoading:n,canAutoLoad:b,canAutoPlay:E,uploadProgress:P,lastSyncTime:i,dimensions:Z,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})})))}));var Ta=n(12019);function Aa(){return Aa=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},Aa.apply(this,arguments)}let Na;const Ba=e=>{let{message:t,observeIntersection:n,canAutoLoad:a,lastSyncTime:r,isDownloading:c}=e;const l=(0,o.sO)(null),u=(0,o.sO)(null),m=(0,o.sO)(null),h=t.content.video,g=(0,Kn.Op)(l,n),[p,f]=(0,o.eJ)(a),v=Boolean(p&&g&&r),{mediaData:I,loadProgress:w}=(0,_s.Z)((0,d.Ti)(t,"inline"),!v,(0,d.kG)(t,"inline"),r),{loadProgress:y}=(0,_s.Z)((0,d.Ti)(t,"download"),!c,i.IU.BlobUrl,r),[P]=(0,o.eJ)(!I),Z=Ws(t,I),{isBuffered:C,bufferingHandlers:b}=(0,Ta.Z)(),E=p&&!C||c,S=!1===(0,rn.Z)(p),M=(0,Xs.Z)(!I),{shouldRender:R,transitionClassNames:k}=(0,at.Z)(E||!C,void 0,S),[A,N]=(0,o.eJ)(!1),[B,x]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!A)return;const e=ye.Rj/2,t=2*(e-6)*Math.PI,n=t-B*t,s=m.current,a=u.current,o=a.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):a.innerHTML=`\n <svg width="${ye.Rj}px" height="${ye.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>`,x(s.currentTime/s.duration)}),[A,B]);const L=Boolean(I&&g),O=(0,o.I4)((()=>{m.current&&(N(!1),x(0),(0,Os.Z)(m.current),(0,T.T2)((()=>{u.current.innerHTML=""})))}),[]),F=(0,o.I4)((()=>{var e;null===(e=Na)||void 0===e||e(),Na=O}),[O]),U=(0,o.I4)((()=>{if(!I)return void f((e=>!e));if(c)return void(0,s.Sv)().cancelMessageMediaDownload({message:t});const e=m.current;A?e.paused?((0,Os.Z)(e),(0,bn.Es)()):e.pause():(F(),e.pause(),e.currentTime=0,(0,Os.Z)(e),(0,bn.Es)(),N(!0))}),[F,A,c,I,t]),j=(0,o.I4)((e=>{const t=e.currentTarget;x(t.currentTime/t.duration)}),[]);return o.ZP.createElement("div",{ref:l,className:"RoundVideo media-inner",onClick:U},I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement(Ks.Z,Aa({canPlay:L,ref:m,src:I,className:"full-media",width:ye.Rj,height:ye.Rj,autoPlay:!0,disablePictureInPicture:!0,muted:!A,loop:!A,playsInline:!0,onEnded:A?O:void 0},b,{onTimeUpdate:A?j:void 0}))),P&&o.ZP.createElement("canvas",{ref:Z,className:(0,_e.Z)("thumbnail",M),style:`width: ${ye.Rj}px; height: ${ye.Rj}px`}),o.ZP.createElement("div",{className:"progress",ref:u}),R&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(Js.Z,{progress:c?y:w})),!I&&!p&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},A?(0,z.k9)(m.current.currentTime):(0,z.k9)(h.duration),(!A||m.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},xa=e=>{let{message:t,onClick:n}=e;const s=(0,yt.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===e.type,onClick:()=>n({messageId:t.id,button:e})},o.ZP.createElement("span",{className:"inline-button-text"},(0,On.Z)(s(e.text))),(e=>{const{type:t}=e;switch(t){case"url":if(!a.FS.test(e.url))return o.ZP.createElement("i",{className:"icon-arrow-right"});break;case"urlAuth":return o.ZP.createElement("i",{className:"icon-arrow-right"});case"buy":case"receipt":return o.ZP.createElement("i",{className:"icon-cart"});case"switchBotInline":return o.ZP.createElement("i",{className:"icon-share-filled"});case"webView":case"simpleWebView":return o.ZP.createElement("i",{className:"icon-webapp"})}})(e))))))))},La=(0,o.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:a}=(0,s.Sv)(),i=(0,yt.Z)(),{threadId:r,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h}=t,g=(0,o.I4)((()=>{a({id:c,threadId:r})}),[a,c,r]),p=(0,o.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 o.ZP.createElement("div",{"data-cnt":(0,ut.bi)(l),className:(0,_e.Z)("CommentButton",f&&"has-unread",n&&"disabled"),dir:i.isRtl?"rtl":"ltr",onClick:g},o.ZP.createElement("i",{className:"icon-comments-sticker"}),(!p||0===p.length)&&o.ZP.createElement("i",{className:"icon-comments"}),p&&p.length>0&&o.ZP.createElement("div",{className:"recent-repliers",dir:i.isRtl?"rtl":"ltr"},p.map((e=>o.ZP.createElement(jn.Z,{key:e.id,size:"small",user:(0,d.YC)(e.id)?e:void 0,chat:(0,d.YC)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},l?i("Comments",l,"i"):i("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))})),Oa=(0,o.X$)((e=>{let{reaction:t,message:n,activeReaction:a,availableReactions:i}=e;const{sendReaction:r}=(0,s.Sv)(),{recentReactions:c}=n.reactions,l=(0,o.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,o.I4)((()=>{r({reaction:t.isChosen?void 0:t.reaction,chatId:n.chatId,messageId:n.id})}),[n,t,r]);return o.ZP.createElement(Rt.Z,{className:(0,_e.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},o.ZP.createElement(As,{activeReaction:a,reaction:t.reaction,availableReactions:i}),null!=l&&l.length?o.ZP.createElement("div",{className:"avatars"},l.map((e=>o.ZP.createElement(jn.Z,{user:e,size:"micro"})))):(0,ut.bi)(t.count))})),Fa=(0,o.X$)((e=>{let{message:t,isOutside:n,activeReaction:s,availableReactions:a,metaChildren:i}=e;return o.ZP.createElement("div",{className:(0,_e.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>o.ZP.createElement(Oa,{key:e.reaction,reaction:e,message:t,activeReaction:s,availableReactions:a}))),i)})),Ua=(0,o.X$)((e=>{let{phoneCall:t,message:n,chatId:a}=e;const{requestCall:i}=(0,s.Sv)(),r=(0,yt.Z)(),{isOutgoing:c,isVideo:l,reason:d}=t,u="missed"===d,m="busy"===d&&!c,g=(0,o.I4)((()=>{i({isVideo:l,userId:a})}),[a,l,i]),p=(0,o.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,o.Ye)((()=>t.duration?(0,z.J_)(r,t.duration):void 0),[r,t.duration]),v=(0,z.mr)(r,1e3*n.date);return o.ZP.createElement("div",{className:"vDeypQzM845_JE14qGId"},o.ZP.createElement(Rt.Z,{size:"smaller",color:"translucent",round:!0,ripple:!0,onClick:g,className:"OtJi45yywgt1n_y6VPkE",disabled:!h.Bi,ariaLabel:r(c?"CallAgain":"CallBack")},o.ZP.createElement("i",{className:l?"icon-video-outlined":"icon-phone"})),o.ZP.createElement("div",{className:"_0BG8sziTJQ_NYrsspMg"},o.ZP.createElement("div",{className:"LWVSvxVjeEyHPBrCb2sD"},r(p)),o.ZP.createElement("div",{className:"nuIsoCP15iD4ETadJ44R"},o.ZP.createElement("i",{className:(0,_e.Z)("icon-arrow-right","wrUkWet7enyh9L1iPKvA",u&&"V5tKkKZpcY5yq_f5nO8l",!c&&"e0Vhbj8gfzQn1zJQoFLK")}),o.ZP.createElement("span",{className:"TJ2lYkLxYUie3A0JqtMR"},f?r("CallMessageWithDuration",[v,f]):v))))}));var ja=n(78780),Da=n(4863),qa=n(50685),$a=n(14612);const Ga={__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>'},Ha={__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>'},Va=(0,o.X$)((0,s.c$)(((e,t)=>{var n,s,a,o,i;const{focusedMessage:r,forwardMessages:l,lastSyncTime:u,serverTimeOffset:m}=e,{message:h,album:g,withSenderName:p,withAvatar:f,threadId:v,messageListType:I,isLastInDocumentGroup:w}=t,{id:y,chatId:P,viaBotId:Z,replyToChatId:C,replyToMessageId:b,isOutgoing:E,threadInfo:S,forwardInfo:M,transcriptionId:R}=h,k=(0,c.Z1)(e,P),T=(0,c.FM)(e,P),A=(0,d.pK)(P),N=k&&(0,d.eA)(k),B=k&&(0,d.Bf)(k),x=null==k?void 0:k.username,L=l.messageIds&&l.messageIds.includes(y),O=!T&&(0,d.Ul)(h),F=p||f||O,U=(0,c.Ur)(e,h),j=(0,c.cv)(e,h),D=Z?(0,c.dy)(e,Z):void 0,q=null!=U&&U.id&&B?null===(n=k.fullInfo)||void 0===n||null===(s=n.adminMembersById)||void 0===s?void 0:s[null==U?void 0:U.id]:void 0,$=v?(0,c.qS)(e,P,v):void 0,G=h.id===$,H=b===$,V=b&&!H?(0,c.hj)(e,A&&C?C:P,b):void 0,_=V&&(0,c.Bz)(e,V,Boolean(M)),z=(0,c.uZ)(e,h),W="thread"===I&&(g?g.messages.some((t=>(0,c._X)(e,t))):(0,c._X)(e,h)),{direction:X,noHighlight:J,isResizingContainer:Y}=W&&r||{},{query:K}=(0,c.n5)(e)||{},Q=(0,d.h_)(h),ee=Q&&((0,c.zB)(e,Q)||(0,c.CP)(e,Q))?Q:void 0,te=(0,d.HW)(h);let ne;ne=null!=g&&g.messages?g.messages.every((t=>{let{id:n}=t;return(0,c.vk)(e,n)})):(0,c.vk)(e,y);const{canReply:se}="thread"===I&&(0,c._k)(e,h,v)||{},ae=(0,c.te)(e,h),oe=S?(0,c.tZ)(e,S.chatId,S.threadId)||S:void 0,ie=Boolean(h.groupedId)&&!h.isInAlbum,re=ie?(0,c.xH)(e,P,h.groupedId)[0]:void 0,ce=ie?w?(0,c.hj)(e,P,re):void 0:h,le=null==k||null===(a=k.unreadReactions)||void 0===a?void 0:a.includes(h.id);return{theme:(0,c.Pu)(e),chatUsername:x,forceSenderName:O,sender:U,canShowSender:F,originSender:j,botSender:D,shouldHideReply:H,isThreadTop:G,replyMessage:V,replyMessageSender:_,isInDocumentGroup:ie,isProtected:(0,c.EV)(e,h),isChatProtected:(0,c.Am)(e,P),isFocused:W,isForwarding:L,reactionMessage:ce,isChatWithSelf:T,isRepliesChat:A,isChannel:N,isGroup:B,canReply:se,lastSyncTime:u,serverTimeOffset:m,highlight:K,animatedEmoji:ee,animatedCustomEmoji:te,isInSelectMode:(0,c.CA)(e),isSelected:ne,isGroupSelected:Boolean(h.groupedId)&&!h.isInAlbum&&(0,c.a6)(e,P,h.groupedId),threadId:v,isDownloading:ae,isPinnedList:"pinned"===I,canAutoLoadMedia:(0,c.bH)(e,h),canAutoPlayMedia:(0,c.__)(e,h),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,c.yB)(e),threadInfo:oe,availableReactions:e.availableReactions,defaultReaction:(0,d.CI)(h)?void 0:(0,c.q6)(e,P),activeReaction:ce&&e.activeReactions[ce.id],activeEmojiInteractions:e.activeEmojiInteractions,...E&&{outgoingStatus:(0,c.dT)(e,h,"scheduled"===I)},..."number"==typeof z&&{uploadProgress:z},...W&&{focusDirection:X,noFocusHighlight:J,isResizingContainer:Y},hasUnreadReaction:le,isTranscribing:void 0!==R&&(null===(o=e.transcriptions[R])||void 0===o?void 0:o.isPending),transcribedText:void 0!==R?null===(i=e.transcriptions[R])||void 0===i?void 0:i.text:void 0,isPremium:(0,c.wV)(e),animationLevel:e.settings.byKey.animationLevel,senderAdminMember:q}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:r,observeIntersectionForLoading:c,observeIntersectionForPlaying:l,album:u,noAvatars:g,withAvatar:f,withSenderName:v,areReactionsInMeta:I,noComments:w,appearanceOrder:y,isFirstInGroup:P,isPremium:Z,isLastInGroup:C,isFirstInDocumentGroup:b,isLastInDocumentGroup:E,isTranscribing:S,transcribedText:M,isLastInList:R,theme:k,forceSenderName:T,sender:A,canShowSender:N,originSender:B,botSender:x,isThreadTop:L,shouldHideReply:O,replyMessage:F,replyMessageSender:U,outgoingStatus:j,uploadProgress:D,isInDocumentGroup:q,isProtected:$,isChatProtected:G,isFocused:H,focusDirection:V,noFocusHighlight:_,isResizingContainer:z,isForwarding:W,isChatWithSelf:X,isRepliesChat:J,isChannel:Y,isGroup:K,canReply:Q,lastSyncTime:ee,serverTimeOffset:te,highlight:ne,animatedEmoji:se,animatedCustomEmoji:ae,isInSelectMode:oe,isSelected:ie,isGroupSelected:re,threadId:ce,reactionMessage:le,availableReactions:de,defaultReaction:ue,activeReaction:me,activeEmojiInteractions:he,messageListType:ge,isPinnedList:pe,isDownloading:fe,canAutoLoadMedia:ve,canAutoPlayMedia:Ie,shouldLoopStickers:we,autoLoadFileMaxSizeMb:Pe,threadInfo:Ze,hasUnreadReaction:Ce,memoFirstUnreadIdRef:be,animationLevel:Ee,senderAdminMember:Se}=e;const{toggleMessageSelection:Me,clickBotInlineButton:Re,disableContextMenuHint:ke,animateUnreadReaction:Te,focusLastMessage:Ae}=(0,s.Sv)(),Ne=(0,o.sO)(null),Be=(0,o.sO)(null),xe=(0,o.sO)(null),Le=(0,yt.Z)(),[Oe,Fe]=(0,o.eJ)(!1),[Ue,je,De]=(0,vt.Z)();(0,Kn._N)(Be,r);const{isContextMenuOpen:qe,contextMenuPosition:$e,handleBeforeContextMenu:Ge,handleContextMenu:He,handleContextMenuClose:Ve,handleContextMenuHide:ze}=(0,ts.Z)(Ne,h.$b&&oe,!0,h.wZ);(0,o.d4)((()=>{qe&&ke()}),[qe,ke]);const We=y<=0,[Xe,Je]=(0,vt.Z)(We);(0,o.d4)((()=>{We||setTimeout(Je,10*y)}),[y,Je,We]);const{transitionClassNames:Ye}=(0,at.Z)(Xe,void 0,We,!1),{id:Ke,chatId:Qe,forwardInfo:et,viaBotId:tt,isTranscriptionError:nt}=t,st=(0,d.CI)(t),ot=(0,d.B4)(t),it="scheduled"===ge||t.isScheduled,rt=(0,d.ss)(t)&&!O,ct=Boolean(Ze)&&"thread"===ge,lt=(0,d.$D)(t),dt=lt&&(se||ae),ut=(null==le?void 0:le.reactions)&&!(0,d.JE)(le.reactions),mt=et&&(!X||it)&&!J&&!et.isLinkedChannelPost&&!lt,ht=Boolean(u)&&u.messages.length>1&&!(null!=u&&u.messages.some((e=>0===Object.keys(e.content).length))),gt=q&&!b,pt=q&&!E,ft=void 0!==$e,It=!(ft||oe||W||pt),wt=Y&&!it&&t.isForwardingAllowed&&!G,Pt=Boolean(pe||et&&(et.isChannelPost||X&&!ot||J)&&et.fromMessageId),Zt=(0,o.I4)(((e,t)=>{Me({messageId:Ke,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...ht&&{childMessageIds:u.messages.map((e=>{let{id:t}=e;return t}))}})}),[Me,Ke,ht,u]),Ct=N?A:void 0,bt=Boolean(!Oe&&(nt||M)),Et=et&&(X||J||!Ct)?B:Ct,St=et?B:Ct,{handleMouseDown:Mt,handleClick:kt,handleContextMenu:Tt,handleDoubleClick:At,handleContentDoubleClick:Nt,handleMouseMove:Bt,handleSendQuickReaction:xt,handleMouseLeave:Lt,isSwiped:Ot,isQuickReactionVisible:Ft,handleDocumentGroupMouseEnter:Ut}=fs(Zt,Ne,Ke,0,Boolean(oe),Boolean(Q),Boolean($),He,Ge,Qe,ft,xe,ot,pt),{handleAvatarClick:jt,handleSenderClick:Dt,handleViaBotClick:qt,handleReplyClick:$t,handleMediaClick:Gt,handleAudioPlay:Ht,handleAlbumMediaClick:Vt,handleMetaClick:_t,handleReadMedia:zt,handleCancelUpload:Wt,handleVoteSend:Xt,handleGroupForward:Jt,handleForward:Yt,handleFocus:Kt,handleFocusForwarded:Qt,handleDocumentGroupSelectAll:en}=function(e,t,n,a,r,c,l,d,u,h,g,p,f){const{openChat:v,showNotification:I,focusMessage:w,openMediaViewer:y,openAudioPlayer:P,markMessagesRead:Z,cancelSendingMessage:C,sendPollVote:b,openForwardMenu:E,focusMessageInComments:S}=(0,s.Sv)(),{id:M,forwardInfo:R,replyToMessageId:k,replyToChatId:T,replyToTopMessageId:A,groupedId:N}=n,B=(0,o.I4)((()=>{g&&v({id:g.id})}),[g,v]),x=(0,o.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,o.I4)((()=>{f&&v({id:f.id})}),[f,v]),O=(0,o.I4)((()=>{w({chatId:u&&T?T:a,threadId:r,messageId:k,replyMessageId:u&&T?void 0:M})}),[w,u,T,a,r,k,M]),F=(0,o.I4)((()=>{y({chatId:a,threadId:r,mediaId:M,origin:d?m.bZ.ScheduledInline:m.bZ.Inline})}),[a,r,M,y,d]),U=(0,o.I4)((()=>{P({chatId:a,messageId:M})}),[a,M,P]),j=(0,o.I4)((e=>{y({chatId:a,threadId:r,mediaId:e,origin:d?m.bZ.ScheduledAlbum:m.bZ.Album})}),[a,r,y,d]),D=(0,o.I4)((()=>{Z({messageIds:[M]})}),[M,Z]),q=(0,o.I4)((()=>{C({chatId:a,messageId:M})}),[C,a,M]),$=(0,o.I4)((e=>{b({chatId:a,messageId:M,options:e})}),[a,M,b]),G=(0,o.I4)((()=>{E({fromChatId:a,groupedId:N})}),[E,a,N]),H=(0,o.I4)((()=>{if(h&&h.messages){const e=h.messages.map((e=>{let{id:t}=e;return t}));E({fromChatId:a,messageIds:e})}else E({fromChatId:a,messageIds:[M]})}),[h,E,a,M]),V=(0,o.I4)((()=>{w({chatId:a,threadId:i._f,messageId:M})}),[w,a,M]),_=(0,o.I4)((()=>{c?w({chatId:R.fromChatId,groupedId:N,groupedChatId:a}):u&&T?S({chatId:T,threadId:A,messageId:R.fromMessageId}):w({chatId:R.fromChatId,messageId:R.fromMessageId})}),[c,u,T,w,R,N,a,S,A]),z=(0,o.I4)((e=>{e.stopPropagation(),t(e,N)}),[t,N]);return{handleAvatarClick:B,handleSenderClick:x,handleViaBotClick:L,handleReplyClick:O,handleMediaClick:F,handleAudioPlay:U,handleAlbumMediaClick:j,handleMetaClick:z,handleReadMedia:D,handleCancelUpload:q,handleVoteSend:$,handleGroupForward:G,handleForward:H,handleFocus:V,handleFocusForwarded:_,handleDocumentGroupSelectAll:z}}(Le,Zt,t,Qe,ce,q,mt,it,J,u,Et,St,x);(0,o.d4)((()=>{R&&bt&&M&&Ae()}),[Ae,R,M,bt]);const tn=(0,_e.Z)("Message message-list-item",P&&"first-in-group",$&&"is-protected",C&&"last-in-group",b&&"first-in-document-group",E&&"last-in-document-group",R&&"last-in-list",ot&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",rt&&"has-reply",ft&&"has-menu-open",H&&!_&&"focused",W&&"is-forwarding",t.isDeleting&&"is-deleting",q&&"is-in-document-group",ht&&"is-album",t.hasUnreadMention&&"has-unread-mention",ie&&"is-selected",oe&&"is-in-selection-mode",L&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",Ot&&"is-swiped",Ye,(Boolean(me)||Ue)&&"has-active-reaction"),{text:nn,photo:sn,video:an,audio:on,voice:rn,document:cn,sticker:dn,contact:un,poll:mn,webPage:hn,invoice:gn,location:pn,action:fn,game:vn}=(0,d.qp)(t),{phoneCall:In}=fn||{},wn=Ze&&!pt&&"thread"===ge&&!w,yn=!h.$b&&!In&&!oe&&ue&&!pt,Pn=function(e){let{hasReply:t,isCustomShape:n,isLastInGroup:s,asForwarded:o,hasThread:i,forceSenderName:r,hasComments:c,hasActionButton:l,hasReactions:u,isGeoLiveActive:m,withVoiceTranscription:h}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:g,photo:p,video:f,audio:v,voice:I,document:w,poll:y,webPage:P,contact:Z,location:C,invoice:b}=(0,d.qp)(e),E=["message-content"],S=p||f||C||(null==b?void 0:b.extendedMedia),M=g||"venue"===(null==C?void 0:C.type)||m,R=S&&!M,k=Boolean(e.viaBotId);return!S&&e.emojiOnlyCount?(E.push("emoji-only"),e.emojiOnlyCount<=a.L5&&E.push(`emoji-only-${e.emojiOnlyCount}`)):M&&E.push("text"),l&&E.push("has-action-button"),n&&(E.push("custom-shape"),null!=f&&f.isRound&&E.push("round"),c&&E.push("has-comments")),S?E.push("media"):v?E.push("audio"):I?(E.push("voice"),h&&E.push("with-voice-transcription")):w?E.push("document"):Z?E.push("contact"):y?E.push("poll"):P&&(E.push("web-page"),(P.photo||P.video)&&E.push("media")),b&&!b.extendedMedia&&E.push("invoice"),o&&E.push("is-forwarded"),t&&E.push("is-reply"),i&&E.push("has-replies"),u&&E.push("has-reactions"),k&&E.push("is-via-bot"),r&&E.push("force-sender-name"),n||(E.push("has-shadow"),S&&c&&E.push("has-background"),(t||o||k||!R||r)&&E.push("has-solid-background"),s&&(p||C&&!M||!R)&&E.push("has-appendix")),E.join(" ")}(t,{hasReply:rt,isCustomShape:lt,isLastInGroup:C,asForwarded:mt,hasThread:ct,forceSenderName:T,hasComments:Ze&&(null==Ze?void 0:Ze.messagesCount)>0,hasActionButton:wt||Pt,hasReactions:ut,isGeoLiveActive:"geoLive"===(null==pn?void 0:pn.type)&&!(0,d.$R)(t,(0,p.b)(te)),withVoiceTranscription:bt}),Zn=Pn.includes("has-appendix"),Cn=(0,d.fY)(t),bn=(0,ys.qo)(t.emojiOnlyCount);let En,Sn;En=In||pt?"none":!Cn||hn||dt?"standalone":"in-text",I?Sn="in-meta":ut?lt||(sn||an)&&!Cn?Sn="outside":mt?(En="standalone",Sn="inside"):Sn="inside":Sn="none",(0,ln.Z)(J&&t.replyToChatId?t.replyToChatId:Qe,rt?t.replyToMessageId:void 0,F,t.id),us(Ne,Qe,H,V,_,z),(0,o.d4)((()=>{const e=Be.current;Ce&&e&&(0,ws.P)(e)&&Te({messageIds:[Ke]})}),[Ce,Ke,Te]);let Mn,Rn="",kn=!1;const Tn=(0,o.Ye)((()=>ht?rs(ot,Boolean(mt),Boolean(g),u):void 0),[ht,ot,mt,g,u]),An=mt?28:0;if(!ht&&(sn||an||null!=gn&&gn.extendedMedia)){let e;if(sn)e=ss(t,mt,g).width;else if(an)e=an.isRound?ye.Rj:ss(t,mt,g).width;else if(null!=gn&&gn.extendedMedia&&gn.extendedMedia.width&&gn.extendedMedia.height){const{width:t,height:n}=gn.extendedMedia;e=(0,ye.Kf)({width:t,height:n,fromOwnMessage:ot,asForwarded:mt,noAvatars:g}).width}e&&(Mn=Math.max(ns(Boolean(nn),wn),e),Mn-e>18&&(kn=!0))}else Tn&&(Mn=Math.max(ns(Boolean(nn),wn),Tn.containerStyle.width),Mn-Tn.containerStyle.width>18&&(kn=!0));Mn&&(Rn=`width: ${Mn+An}px`);const Nn=Y&&t.postAuthorTitle||!mt&&(null==et?void 0:et.postAuthorTitle)||void 0,Bn=(0,o.Ye)((()=>Nn?ds(Nn):void 0),[Nn]);function xn(){const e=o.ZP.createElement(Ns,{message:t,reactionMessage:le,outgoingStatus:j,signature:Nn,withReactions:"in-meta"===Sn,withReactionOffset:"inside"===Sn,availableReactions:de,activeReaction:me,onClick:_t});return"inside"!==Sn?e:o.ZP.createElement(Fa,{activeReaction:me,message:le,metaChildren:e,availableReactions:de})}const Ln=K&&mt?t.postAuthorTitle:void 0;return o.ZP.createElement("div",{ref:Ne,id:(0,d.d0)(t.id),className:tn,style:Bn?`--meta-safe-author-width: ${Bn}px`:void 0,"data-message-id":Ke,onMouseDown:Mt,onClick:kt,onContextMenu:Tt,onDoubleClick:At,onMouseEnter:pt?Ut:void 0,onMouseMove:yn?Bt:void 0,onMouseLeave:yn||pt?Lt:void 0},o.ZP.createElement("div",{ref:Be,className:"bottom-marker","data-message-id":Ke,"data-last-message-id":u?u.messages[u.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention||void 0,"data-has-unread-reaction":Ce||void 0}),!q&&o.ZP.createElement("div",{className:"message-select-control"},ie&&o.ZP.createElement("i",{className:"icon-select"})),E&&o.ZP.createElement("div",{className:(0,_e.Z)("message-select-control group-select",re&&"is-selected"),onClick:en},re&&o.ZP.createElement("i",{className:"icon-select"})),f&&function(){const e=Et&&(0,d.YC)(Et.id),t=Et&&e?Et:void 0,n=Et&&!e?Et:void 0,s=!Et&&et?et.hiddenUserName:void 0;return o.ZP.createElement(jn.Z,{size:"small",user:t,chat:n,text:s,lastSyncTime:ee,onClick:t||n?jt:void 0,observeIntersection:c,animationLevel:Ee,withVideo:!0})}(),o.ZP.createElement("div",{className:(0,_e.Z)("message-content-wrapper",Pn.includes("text")&&"can-select-text")},o.ZP.createElement("div",{ref:xe,className:Pn,style:Rn,dir:"auto"},mt&&!gt&&o.ZP.createElement("div",{className:"message-title"},Le("ForwardedMessage"),Ln&&o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Ln)),function(){const e=(0,_e.Z)("content-inner",mt&&"forwarded-message",rt&&"reply-message",kn&&"no-media-corners"),n=C&&!Cn&&!mt&&!ct,s=(0,_e.Z)("text-content","in-text"===En&&"with-meta",j&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:Nt,dir:"auto"},function(){var e,n;if(lt&&!tt||!(v&&!(sn||an||pn)||mt||tt||T)||gt||rt&<)return;let s,i;!St||lt&&tt?null!=et&&et.hiddenUserName&&(s=et.hiddenUserName):(s=(0,d.OU)(Le,St),mt||(i=`color-${(0,d.Rs)(St)}`));const r=St&&"emojiStatus"in St&&St.emojiStatus,u=St&&"isPremium"in St&&St.isPremium;return o.ZP.createElement("div",{className:"message-title",dir:"ltr"},s?o.ZP.createElement("span",{className:(0,_e.Z)("message-title-name interactive",i),onClick:Dt,dir:"ltr"},(0,On.Z)(s),!mt&&r&&o.ZP.createElement($s.Z,{documentId:r.documentId,loopLimit:a.y3,observeIntersectionForLoading:c,observeIntersectionForPlaying:l}),!mt&&!r&&u&&o.ZP.createElement(Da.Z,null),(null==St?void 0:St.fakeType)&&o.ZP.createElement(qa.Z,{fakeType:St.fakeType})):x?void 0:" ",x&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},Le("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:qt},(0,On.Z)(`@${x.username}`))),null!=et&&et.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Le("DiscussChannel")):null!==(e=t.forwardInfo)&&void 0!==e&&e.postAuthorTitle&&K&&mt?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},null===(n=t.forwardInfo)||void 0===n?void 0:n.postAuthorTitle):t.postAuthorTitle&&K&&!mt?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.postAuthorTitle):Se&&!mt?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Se.customTitle||Le(Se.isOwner?"GroupInfo.LabelOwner":"GroupInfo.LabelAdmin")):void 0)}(),rt&&o.ZP.createElement(Es,{message:F,noUserColors:ot,isProtected:$,sender:U,observeIntersectionForLoading:c,observeIntersectionForPlaying:l,onClick:$t}),dn&&o.ZP.createElement(xs,{message:t,observeIntersection:c,observeIntersectionForPlaying:l,shouldLoop:we,lastSyncTime:ee,shouldPlayEffect:dn.hasEffect&&(be.current&&Ke>=be.current||st)||void 0,onPlayEffect:je,onStopEffect:De}),dt&&ae&&o.ZP.createElement(Gs,{customEmojiId:ae,withEffects:(0,d.YC)(Qe),isOwn:ot,observeIntersection:c,lastSyncTime:ee,forceLoadPreview:st,messageId:Ke,chatId:Qe,activeEmojiInteractions:he}),dt&&se&&o.ZP.createElement(qs,{emoji:se,withEffects:(0,d.YC)(Qe),isOwn:ot,observeIntersection:c,lastSyncTime:ee,forceLoadPreview:st,messageId:Ke,chatId:Qe,activeEmojiInteractions:he}),ht&&o.ZP.createElement(ka,{album:u,albumLayout:Tn,observeIntersection:c,isOwn:ot,isProtected:$,hasCustomAppendix:n,lastSyncTime:ee,onMediaClick:Vt}),In&&o.ZP.createElement(Ua,{message:t,phoneCall:In,chatId:Qe}),!ht&&sn&&o.ZP.createElement(Ys,{message:t,observeIntersection:c,noAvatars:g,canAutoLoad:ve,uploadProgress:D,shouldAffectAppendix:n,isDownloading:fe,isProtected:$,asForwarded:mt,theme:k,onClick:Gt,onCancelUpload:Wt}),!ht&&an&&an.isRound&&o.ZP.createElement(Ba,{message:t,observeIntersection:c,canAutoLoad:ve,lastSyncTime:ee,isDownloading:fe}),!ht&&an&&!an.isRound&&o.ZP.createElement(Qs,{message:t,observeIntersectionForLoading:c,observeIntersectionForPlaying:l,noAvatars:g,canAutoLoad:ve,canAutoPlay:Ie,uploadProgress:D,lastSyncTime:ee,isDownloading:fe,isProtected:$,asForwarded:mt,onClick:Gt,onCancelUpload:Wt}),(on||rn)&&o.ZP.createElement(Ms.ZP,{theme:k,message:t,origin:m.Cr.Inline,uploadProgress:D,lastSyncTime:ee,isSelectable:q,isSelected:ie,noAvatars:g,onPlay:Ht,onReadMedia:!rn||ot&&!X?void 0:zt,onCancelUpload:Wt,isDownloading:fe,isTranscribing:S,isTranscriptionHidden:Oe,isTranscribed:Boolean(M),isTranscriptionError:nt,canDownload:!$,onHideTranscription:Fe,canTranscribe:Z}),cn&&o.ZP.createElement(Ss.Z,{message:t,observeIntersection:c,canAutoLoad:ve,autoLoadFileMaxSizeMb:Pe,uploadProgress:D,isSelectable:q,isSelected:ie,onMediaClick:Gt,onCancelUpload:Wt,isDownloading:fe}),un&&o.ZP.createElement(ta,{contact:un}),mn&&o.ZP.createElement(la,{message:t,poll:mn,onSendVote:Xt}),vn&&o.ZP.createElement(Ea,{message:t,canAutoLoadMedia:ve,lastSyncTime:ee}),(null==gn?void 0:gn.extendedMedia)&&o.ZP.createElement(fa,{message:t,lastSyncTime:ee}),bt&&o.ZP.createElement("p",{className:(0,_e.Z)("transcription",!Oe&&nt&&"transcription-error"),dir:"auto"},nt?Le("NoWordsRecognized"):S&&M?o.ZP.createElement(ja.Z,{content:M}):M),!dt&&Cn&&o.ZP.createElement("div",{className:s,dir:"auto"},o.ZP.createElement($a.Z,{message:t,emojiSize:bn,highlight:ne,isProtected:$,observeIntersectionForLoading:c,observeIntersectionForPlaying:l,withTranslucentThumbs:lt}),"in-text"===En&&xn()),hn&&o.ZP.createElement(ma,{message:t,observeIntersection:c,noAvatars:g,canAutoLoad:ve,canAutoPlay:Ie,asForwarded:mt,lastSyncTime:ee,isDownloading:fe,isProtected:$,theme:k,onMediaClick:Gt,onCancelMediaTransfer:Wt}),gn&&!gn.extendedMedia&&o.ZP.createElement(ga,{message:t,shouldAffectAppendix:n,isInSelectMode:oe,isSelected:ie,theme:k}),pn&&o.ZP.createElement(ba,{message:t,lastSyncTime:ee,isInSelectMode:oe,isSelected:ie,theme:k,peer:A,serverTimeOffset:te}))}(),!pt&&"standalone"===En&&xn(),It&&wt?o.ZP.createElement(Rt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:Le("lng_context_forward_msg"),onClick:E?Jt:Yt},o.ZP.createElement("i",{className:"icon-share-filled"})):It&&Pt?o.ZP.createElement(Rt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:pe?Kt:Qt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,wn&&o.ZP.createElement(La,{threadInfo:Ze,disabled:w}),Zn&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:ot?Ga:Ha}),yn&&o.ZP.createElement("div",{className:(0,_e.Z)("quick-reaction",Ft&&!me&&"visible"),onClick:xt},o.ZP.createElement(ks.Z,{reaction:ue}))),t.inlineButtons&&o.ZP.createElement(xa,{message:t,onClick:Re}),"outside"===Sn&&o.ZP.createElement(Fa,{message:le,isOutside:!0,activeReaction:me,availableReactions:de})),$e&&o.ZP.createElement(Zs,{isOpen:qe,anchor:$e,message:t,album:u,chatUsername:n,messageListType:ge,onClose:Ve,onCloseAnimationEnd:ze}))}))),_a=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"AboutAdsModal",!t);return n?o.ZP.createElement(n,e):void 0})),za=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),Wa=(0,o.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;const s=(0,c.fS)(e,n),{chatId:a,isBot:o}=s||{};return{message:s,bot:a&&o?(0,c.dy)(e,a):void 0,channel:!o&&a?(0,c.Z1)(e,a):void 0}}))((e=>{let{chatId:t,message:n,containerRef:a,bot:i,channel:r}=e;const{viewSponsoredMessage:c,openChat:l,openChatByInvite:u,startBot:m,focusMessage:g}=(0,s.Sv)(),p=(0,yt.Z)(),f=(0,o.sO)(null),v=(0,o.sO)(null),I=Boolean(n),{observe:w}=(0,Kn.S1)({rootRef:a,debounceMs:200,threshold:1}),{isContextMenuOpen:y,contextMenuPosition:P,handleBeforeContextMenu:Z,handleContextMenu:C,handleContextMenuClose:b,handleContextMenuHide:E}=(0,ts.Z)(f,h.$b,!0,h.wZ),[S,M,R]=(0,vt.Z)(!1);(0,o.d4)((()=>I?w(v.current,(e=>{e.isIntersecting&&c({chatId:t})})):void 0),[t,I,w,c]);const k=(0,o.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 o.ZP.createElement("div",{ref:f,key:"sponsored-message",className:"SponsoredMessage Message open",onMouseDown:e=>{(0,_n.q)(e),Z(e)},onContextMenu:C},o.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},o.ZP.createElement("div",{className:"content-inner",dir:"auto"},o.ZP.createElement("div",{className:"message-title",dir:"ltr"},i&&(0,On.Z)((0,d.Js)(i)||""),r&&(0,On.Z)(n.chatInviteTitle||(0,d.U)(p,r,i)||"")),o.ZP.createElement("div",{className:"text-content with-meta",dir:"auto",ref:v},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,na.H)(n.text.text,n.text.entities)),o.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},o.ZP.createElement("span",{className:"message-signature"},n.isRecommended?p("Message.RecommendedLabel"):p("SponsoredMessage")))),o.ZP.createElement(Rt.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:k,className:"SponsoredMessage__button"},p(n.isBot?"Conversation.ViewBot":n.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))),P&&o.ZP.createElement(za,{isOpen:y,anchor:P,message:n,onAboutAds:M,onClose:b,onCloseAnimationEnd:E}),o.ZP.createElement(_a,{isOpen:S,onClose:R}))}))),Xa=(0,o.X$)((e=>{let{isCurrentUserPremium:t,chatId:n,messageIds:i,messageGroups:r,isViewportNewest:c,isUnread:l,withUsers:u,areReactionsInMeta:p,noAvatars:f,containerRef:v,anchorIdRef:I,memoUnreadDividerBeforeIdRef:w,memoFirstUnreadIdRef:y,threadId:P,type:Z,isReady:C,isScrollingRef:b,isScrollPatchNeededRef:E,threadTopMessageId:S,hasLinkedChat:M,isSchedule:R,noAppearanceAnimation:k,onFabToggle:A,onNotchToggle:N}=e;const{openHistoryCalendar:B}=(0,s.Sv)(),{observeIntersectionForReading:x,observeIntersectionForLoading:L,observeIntersectionForPlaying:O}=function(e,t,n){const{markMessageListRead:a,markMentionsRead:o,animateUnreadReaction:i}=(0,s.Sv)(),{observe:r,freeze:c,unfreeze:l}=(0,Kn.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,o=Number(a.lastMessageId||a.messageId);o>s&&(s=o),a.hasUnreadMention&&r.push(o),a.hasUnreadReaction&&c.push(o)})),n.current&&s>=n.current&&a({maxId:s}),r.length&&o({messageIds:r}),c.length&&i({messageIds:c})}));(0,Je.Z)(c,l);const{observe:d}=(0,Kn.S1)({rootRef:t,throttleMs:Qn,margin:es}),{observe:u}=(0,Kn.S1)({rootRef:t,throttleMs:Qn});return{observeIntersectionForReading:r,observeIntersectionForLoading:d,observeIntersectionForPlaying:u}}(Z,v,y),{backwardsTriggerRef:F,forwardsTriggerRef:U,fabTriggerRef:j}=function(e,t,n,i,r,c,l,d,u,g){const{loadViewportMessages:p}=(0,s.Sv)(),[f,v]=(0,o.Ye)((()=>"thread"===e?[(0,T.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,T.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,n]),I=(0,o.sO)(null),w=(0,o.sO)(null),y=(0,o.sO)(null);function P(){if(!d)return;if(!n||!n.length)return c(!1),void l(!1);if(!i)return c(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:s,scrollTop:a}=t.current,o=Math.round(s-a-e),u=o<=1;c(r?!u:!(o<=50)),l(!u)}const{observe:Z}=(0,Kn.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,Kn._N)(I,Z),(0,Kn._N)(w,Z);const{observe:C,freeze:b,unfreeze:E}=(0,Kn.S1)({rootRef:t,margin:100},P);(0,Kn._N)(y,C);const{observe:S,freeze:M,unfreeze:R}=(0,Kn.S1)({rootRef:t,margin:1},P);return(0,Kn._N)(y,S),(0,Ke.Z)((()=>{d&&P()}),[d]),(0,Ke.Z)((()=>{b(),M(),setTimeout((()=>{R(),E()}),250)}),[n]),{backwardsTriggerRef:I,forwardsTriggerRef:w,fabTriggerRef:y}}(Z,v,i,c,l,A,N,C,b,E),D=(0,yt.Z)(),q=o.ZP.createElement("div",{className:(0,_e.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,D("UnreadMessages"))),$=k?0:r.reduce(((e,t)=>e+t.senderGroups.flat().length),0);let G=0;const H=r.map(((e,t,n)=>{const s=e.senderGroups.map(((e,s,a)=>{var i;if(1===e.length&&!Hn(e[0])&&(0,d.FT)(e[0])&&(null===(i=e[0].content.action)||void 0===i||!i.phoneCall)){const i=e[0],r=s===a.length-1&&t===n.length-1;return(0,g.oA)([i.id===w.current&&q,o.ZP.createElement(bs,{key:i.id,message:i,observeIntersectionForReading:x,observeIntersectionForLoading:L,observeIntersectionForPlaying:O,memoFirstUnreadIdRef:y,appearanceOrder:$-++G,isLastInList:r})])}let r;return e.map(((i,c)=>{const l=Hn(i)?i.mainMessage:i,m=Hn(i)?i:void 0,h=(0,d.B4)(l),v=Hn(i),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,E=C&&!Hn(C)?C.groupedId:void 0,R={isFirstInGroup:0===c,isLastInGroup:c===e.length-1,isFirstInDocumentGroup:Boolean(b&&b!==r),isLastInDocumentGroup:Boolean(b&&b!==E),isLastInList:c===e.length-1&&s===a.length-1&&t===n.length-1};r=b;const k=(0,d.KK)(l),T=(0,d.jM)(l)?`${l.date}_${k}`:k;return(0,g.oA)([l.id===w.current&&q,o.ZP.createElement(Va,{key:T,message:l,observeIntersectionForBottom:x,observeIntersectionForLoading:L,observeIntersectionForPlaying:O,album:m,noAvatars:f,withAvatar:R.isLastInGroup&&u&&!h&&!(l.id===S),withSenderName:R.isFirstInGroup&&u&&!h,areReactionsInMeta:p,threadId:P,messageListType:Z,noComments:!1===M,appearanceOrder:$-++G,isFirstInGroup:R.isFirstInGroup,isLastInGroup:R.isLastInGroup,isFirstInDocumentGroup:R.isFirstInDocumentGroup,isLastInDocumentGroup:R.isLastInDocumentGroup,isLastInList:R.isLastInList,memoFirstUnreadIdRef:y}),l.id===S&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,D("DiscussionStarted")))])})).flat()}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:_n.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,_e.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:_n.q,onClick:R?void 0:()=>B({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},R&&e.originalDate===a.t4&&D("MessageScheduledUntilOnline"),R&&e.originalDate!==a.t4&&D("MessageScheduledOn",(0,z.j1)(D,e.datetime,void 0,!0)),!R&&(0,z.j1)(D,e.datetime))),s.flat())}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:F,key:"backwards-trigger",className:"backwards-trigger"}),H.flat(),!t&&c&&o.ZP.createElement(Wa,{key:n,chatId:n,containerRef:v}),o.ZP.createElement("div",{ref:U,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:j,key:"fab-trigger",className:"fab-trigger"}))}));var Ja=n(73547);const Ya=(0,o.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),o=null!=s&&s.length?s[a%s.length]:void 0,i=(0,c.Z1)(e,n);return i?{sticker:o,lastUnreadMessageId:i.lastMessage&&i.lastMessage.id!==i.lastReadInboxMessageId?i.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((e=>{let{sticker:t,connectionState:n,lastUnreadMessageId:a}=e;const{loadGreetingStickers:i,sendMessage:r,markMessageListRead:c}=(0,s.Sv)(),l=(0,yt.Z)(),d=(0,o.sO)(null),{observe:u}=(0,Kn.S1)({rootRef:d,debounceMs:200});(0,o.d4)((()=>{t||"connectionStateReady"!==n||i()}),[n,i,t]),(0,o.d4)((()=>{"connectionStateReady"===n&&a&&c({maxId:a})}),[n,c,a]);const m=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:d},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},l("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},l("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},t&&o.ZP.createElement(Ja.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large",noContextMenu:!0,isCurrentUserPremium:!0}))))}))),Ka=(0,o.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:s}=e;const a=(0,yt.Z)();return"scheduled"===n?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(a):t?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(a):s?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(a):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,a("NoMessages")))})),Qa=(0,T.Ds)((e=>e()),200,!1),eo=(0,o.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s,type:a}=t;const o=(0,c.Z1)(e,n);if(!o)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!==i._f&&!(l&&u&&l[u]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=o,p=(0,c.G$)(e,n),f=s===i._f&&!r&&!o.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)(o),isGroupChat:(0,d.Bf)(o),isCreator:o.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:o.fullInfo&&"linkedChatId"in o.fullInfo?Boolean(o.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...f&&{lastMessage:g}}}))((e=>{var t,n,i,r,l,u;let{chatId:p,threadId:f,type:v,hasTools:I,onFabToggle:w,onNotchToggle:y,isCurrentUserPremium:P,isChatLoaded:Z,isChannelChat:C,isGroupChat:b,canPost:E,isReady:S,isChatWithSelf:M,isRepliesChat:R,isCreator:k,isBot:A,messageIds:N,messagesById:B,firstUnreadId:x,isViewportNewest:L,threadFirstMessageId:O,isRestricted:F,restrictionReason:U,focusingId:j,isSelectModeActive:D,lastMessage:q,isLoadingBotInfo:$,botInfo:G,threadTopMessageId:H,hasLinkedChat:V,lastSyncTime:_,withBottomShift:z,withDefaultBg:W}=e;const{loadViewportMessages:X,setScrollOffset:J,loadSponsoredMessages:Y,loadMessageReactions:K,copyMessagesByIds:Q}=(0,s.Sv)(),ee=(0,o.sO)(null),te=(0,o.sO)("thread"===v&&(0,c.Vt)((0,s.Rd)(),p,f)||0),ne=(0,o.sO)(),se=(0,o.sO)(),ae=(0,o.sO)(),oe=(0,o.sO)(),ie=(0,o.sO)(),re=(0,o.sO)(),ce=(0,o.sO)(!1),le=(0,o.sO)(Boolean(q)),[de,ue]=(0,o.eJ)(),me=(0,fn.Z)(null!=G&&G.photo?(0,d.NF)(G.photo):void 0),he=(0,fn.Z)(null!=G&&G.gif?(0,d.ym)(G.gif):void 0),ge=null!=G&&G.photo?(0,d.bV)(G.photo):null!=G&&G.gif?(0,d.jC)(G.gif):void 0,pe=ge&&{width:ge.width/h.cL,height:ge.height/h.cL},fe=Boolean(N);(0,Ke.Z)((()=>{fe&&(0,T.R3)((()=>{le.current=!1}))}),[fe]),(0,Ke.Z)((()=>{oe.current=x}),[x]),(0,Ke.Z)((()=>{!P&&C&&S&&_&&Y({chatId:p})}),[P,p,S,C,_]),(0,Ke.Z)((()=>{fe&&(ie.current=oe.current)}),[fe]),(0,Ke.Z)((()=>{re.current=j}),[j]),(e=>{(0,It.y)({"Mod+C":function(t){const n=(0,Jn.Z)();n&&n.length>0&&(t.preventDefault(),e({messageIds:n}))}})})(Q);const ve=(0,o.Ye)((()=>{if(!N||!B)return;const e=!H||N[0]&&O!==N[0]?N:[H,...N];if(!e.length)return;const t=e.map((e=>B[e])).filter(Boolean);return Vn((0,g.Xo)(t,["date","id"]),ie.current)}),[N,B,O,H]);(0,it.Z)((()=>{if(!N||!B)return;const e=N.filter((e=>{var t;return null===(t=B[e])||void 0===t?void 0:t.reactions}));e.length&&K({chatId:p,ids:e})}),15e3);const Ie=(0,o.Ye)((()=>{if("thread"===v)return(0,T.Ds)((()=>X({direction:m.Uq.Around})),1e3,!0,!1)}),[X,N]),{isScrolled:we,updateStickyDates:ye}=function(){const[e,t]=(0,vt.Z)(!1),n=(0,Xn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,s)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,T.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,T.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,o=n-s;return-a<=o&&o<=(t?60:10)}))}(e,s);n&&n.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,n])}}(),Pe=(0,o.sO)(),Ze=(0,o.sO)(),Ce=(0,o.I4)((()=>{if(ce.current)return void(ce.current=!1);const e=ee.current;e&&(Pe.current=!0,re.current||ye(e,I),Qa((()=>{Pe.current=!1,(0,T.T2)((()=>{e.parentElement&&(te.current=e.scrollHeight-e.scrollTop,"thread"===v&&J({chatId:p,threadId:f,scrollOffset:te.current}))}))})))}),[ye,I,v,J,p,f]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((e=>{let[t]=e;t.target.offsetParent&&ue(t.contentRect.height)}));return e.observe(ee.current),()=>{e.disconnect()}}),[]);const{height:be}=(0,an.Z)();(0,o.d4)((()=>{ee.current.dataset.normalHeight=String(ee.current.offsetHeight)}),[be,E]),(0,o.d4)((()=>{if(!Ie||!Z||F||j)return;if(N&&N[N.length-1]>a.MP)return;const e=ee.current;(!N||N.length<a.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&Ie()}),[Z,N,Ie,j,F]),(0,Ke.Z)((()=>{if(!N||!ae.current)return;const e=ae.current.filter((e=>N.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(ne.current=t.id,se.current=t.getBoundingClientRect().top)}),[N,L,de,I]),(0,Yn.Z)((e=>{let[t,n,s]=e;const o=ee.current;ae.current=Array.from(o.querySelectorAll(".message-list-item"));const i=N&&t&&N[N.length-1]!==t[t.length-1],r=(null==N?void 0:N[0])!==(null==t?void 0:t[0])&&(null==N?void 0:N.length)===a.hT/2+1,c=i&&!r,l=N&&re.current===N[N.length-1],d=L&&c&&N&&N.length<a.hT/2&&!o.parentElement.classList.contains("force-messages-scroll")&&o.firstElementChild.clientHeight<=2*o.offsetHeight;d&&(o.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{o.parentElement&&o.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=o,g=te.current,p=ae.current[ae.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,T.T2)((()=>{(0,Wn.Z)(o,p,"end",20)})),w=m-h,te.current=Math.max(Math.ceil(m-w),h),!d))return;const y=void 0!==s&&s!==de,P=ne.current&&o.querySelector(`#${ne.current}`),Z=!P&&ie.current&&o.querySelector(".unread-divider");if(v&&y){if((0,Wn.N)())return;w=m-h}else P?(Ze.current&&(Ze.current=!1,(0,zn.z)(o)),w=u+(P.getBoundingClientRect().top-(se.current||0))):w=Z?Math.min(Z.offsetTop-(I?60:10),m-g):m-g;(0,zn.Z)(o,Math.ceil(w)),re.current||(ce.current=!0,(0,T.T2)((()=>{ce.current=!1}))),te.current=Math.max(Math.ceil(m-w),h)}),[N,L,de,I]),(0,Xe.Z)((e=>{let[t]=e;void 0!==t&&(0,ot.YW)(200+a.fK)}),[D]);const Ee=(0,yt.Z)(),Se=Boolean(p&&(0,d.YC)(p)),Me=Boolean(!Se&&!C||M||R),Re=Boolean(!Me||C),ke=(0,d.YC)(p)&&!M&&!A&&(!ve&&!q&&N&&(!ae.current||0===ae.current.length)||1===(null==N?void 0:N.length)&&"contactSignUp"===(null==B||null===(t=B[N[0]])||void 0===t||null===(n=t.content.action)||void 0===n?void 0:n.type)||"contactSignUp"===(null==q||null===(i=q.content)||void 0===i||null===(r=i.action)||void 0===r?void 0:r.type)),Te=b&&k&&1===(null==N?void 0:N.length)&&"chatCreate"===(null==B||null===(l=B[N[0]])||void 0===l||null===(u=l.content.action)||void 0===u?void 0:u.type),Ae=G&&!G.description,Ne=(0,_e.Z)("MessageList custom-scroll",Re&&"no-avatars",!E&&"no-composer","pinned"===v&&"type-pinned",z&&"with-bottom-shift",W&&"with-default-bg",D&&"select-mode-active",we&&"scrolled",!S&&"is-animating");return o.ZP.createElement("div",{ref:ee,className:Ne,onScroll:Ce,onMouseDown:_n.q},F?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,U?U.text:"This is a private "+(C?"channel":"chat"))):G?o.ZP.createElement("div",{className:"empty"},$&&o.ZP.createElement("span",null,Ee("Loading")),Ae&&o.ZP.createElement("span",null,Ee("NoMessages")),G&&o.ZP.createElement("div",{className:"bot-info",style:pe&&`width: ${pe.width}px`},me&&o.ZP.createElement("img",{src:me,width:null==pe?void 0:pe.width,height:null==pe?void 0:pe.height,alt:"Bot info"}),he&&o.ZP.createElement(Ks.Z,{canPlay:!0,src:he,loop:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0}),ge&&!me&&!he&&o.ZP.createElement(ha.Z,{width:null==pe?void 0:pe.width,height:null==pe?void 0:pe.height}),G.description&&o.ZP.createElement("div",{className:"bot-info-description"},o.ZP.createElement("p",{className:"bot-info-title"},Ee("BotInfoTitle")),(0,On.Z)(G.description,["br","emoji","links"])))):ke?o.ZP.createElement(Ya,{userId:p}):!N||ve&&!Te?N&&ve||q?o.ZP.createElement(Xa,{isCurrentUserPremium:P,chatId:p,messageIds:N||[q.id],messageGroups:ve||Vn([q]),isViewportNewest:Boolean(L),isUnread:Boolean(x),withUsers:Me,areReactionsInMeta:Se,noAvatars:Re,containerRef:ee,anchorIdRef:ne,memoUnreadDividerBeforeIdRef:ie,memoFirstUnreadIdRef:oe,threadId:f,type:v,isReady:S,isScrollingRef:Pe,isScrollPatchNeededRef:Ze,threadTopMessageId:H,hasLinkedChat:V,isSchedule:!!ve&&"scheduled"===v,noAppearanceAnimation:!ve||!le.current,onFabToggle:w,onNotchToggle:y}):o.ZP.createElement(qt.Z,{color:"white",backgroundColor:"dark"}):o.ZP.createElement(Ka,{chatId:p,type:v,isChatWithSelf:M,isGroupChatJustCreated:Te}))}))),to=(0,o.X$)((e=>{let{icon:t,ariaLabelLang:n,unreadCount:s,onClick:a,onReadAll:i,className:r}=e;const c=(0,yt.Z)(),l=(0,o.sO)(null),{isContextMenuOpen:d,handleContextMenu:u,handleContextMenuClose:m,handleContextMenuHide:h}=(0,ts.Z)(l,!i);return o.ZP.createElement("div",{className:(0,_e.Z)("KboxtoWkfx23zfklH_Zg",r),ref:l},o.ZP.createElement(Rt.Z,{color:"secondary",round:!0,className:"sgkkv3bmIMAZS9G9BHUz",onClick:a,onContextMenu:u,ariaLabel:c(n)},o.ZP.createElement("i",{className:(0,_e.Z)("AafG9_xBi_2eJ_bFNnNg",`icon-${t}`)})),Boolean(s)&&o.ZP.createElement("div",{className:"yKN1kQ3YXf4SHHIBcotS"},(0,ut.bi)(s)),i&&o.ZP.createElement(Ht.Z,{isOpen:d,onClose:m,onCloseAnimationEnd:h,autoClose:!0,positionX:"right",positionY:"bottom"},o.ZP.createElement(Mt.Z,{icon:"readchats",onClick:i},c("MarkAllAsRead"))))})),no=(0,o.X$)((0,s.c$)((e=>{const t=(0,c.Bt)(e);if(!t)return{};const{chatId:n,threadId:s,type:a}=t,o=(0,c.Z1)(e,n),r=o&&s===i._f&&"thread"===a;return{messageListType:a,chatId:n,reactionsCount:r?o.unreadReactionsCount:void 0,mentionsCount:r?o.unreadMentionsCount:void 0,unreadCount:r?o.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:n,messageListType:a,chatId:i,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,o.sO)(null),w=Boolean(c),y=Boolean(l);(0,o.d4)((()=>{w&&i&&g({chatId:i})}),[i,g,w]),(0,o.d4)((()=>{y&&i&&v({chatId:i})}),[i,v,y]);const P=(0,o.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,Wn.Z)(e,n,"end",20)}}),[t,a,u]),Z=(0,_e.Z)("quM3aP53TOfurCEOYgOE",(t||Boolean(c)||Boolean(l))&&"Gutr8PrNAFFTnrIdgK_l",(Boolean(c)||Boolean(l))&&!t&&"bHOz3QboabL0RvHuj3ku",!n&&"r7RXnwv5TF4Cf2V0d5Mf",!d&&"S98OqutuQVCNVHgTrKv4");return o.ZP.createElement("div",{ref:I,className:Z},w&&o.ZP.createElement(to,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:m,onReadAll:f,unreadCount:c}),y&&o.ZP.createElement(to,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:h,onReadAll:p,unreadCount:l}),o.ZP.createElement(to,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:P,unreadCount:r,className:"Hoi4yrJrfBHTmvB8TPce"}))})));var so=n(65723);const ao=1280,oo=/\.[^/.]+$/;async function io(e,t,s,o){const i=URL.createObjectURL(t),{type:r,size:c}=t;let l,d,u;if(a.oG.has(r))if(s){const t=await(0,sn.pt)(i),{width:n,height:s}=t,a=n>ao||s>ao;if(a||"image/jpeg"!==r){const t=await kn(i,a?ao/Math.max(n,s):1,"image/jpeg");return URL.revokeObjectURL(i),io(e,await(0,sn.gm)(t),!0,o)}"image/jpeg"===r&&(e=e.replace(oo,".jpg")),l={width:n,height:s}}else u=i;else if(a.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,sn.jj)(i);l={width:e,height:t,duration:n},u=await(0,sn.ud)(i)}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:o,artist:i,picture:r},format:{duration:c}}=a,l=s(r);return{title:o,performer:i,duration:c,coverUrl:l?`data:${l.format};base64,${l.data.toString("base64")}`:void 0}}(i);d={duration:e||0,title:t,performer:s},u=a}return{blobUrl:i,filename:e,mimeType:r,size:c,quick:l,audio:d,previewBlobUrl:u,...o}}var ro=n(41098),co=n(96391);let lo;function uo(e){lo.focus(),e.focus()}h.cj&&(lo=document.createElement("input"),lo.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(lo));var mo=n(74288),ho=n(94462),go=n(52400);const po=new RegExp(`^${a.t8.source}$`,"g");var fo=n(56389),vo=n(70971);const Io={encoderPath:new URL(n(68973),n.b).href,reuseWorker:!0},wo={type:"audio/ogg"};let yo,Po,Zo;async function Co(){return yo||(yo=n.e(1161).then(n.t.bind(n,1161,23)),Po=(await yo).default,Zo=new Po(Io)),yo}async function bo(e){await async function(){await Co(),await Zo.start()}();const t=Date.now();let n;const s=[],a=[];Zo.ondataavailable=e=>{s.push(e)};const o=function(t,n){const s=t.sourceNode,o=s.context.createAnalyser();o.fftSize=64,s.connect(o);const i=o.frequencyBinCount,r=new Uint8Array(i);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(r);const n=r.reduce(((e,t)=>e+t),0)/i/255;(t=>{a.push(255*t),e(t)})(n<.1?0:n),requestAnimationFrame(t)}(),()=>{c=!0}}(Zo);return{stop:()=>new Promise(((e,i)=>{Zo.onstop=()=>{e({blob:new Blob(s,wo),duration:Math.round(((n||Date.now())-t)/1e3),waveform:a})},Zo.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Zo.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Zo.pause(),n=Date.now(),o()}),e)}}}var Eo=n(21262),So=n(56266);const Mo=["image/png","image/jpeg","image/gif"],Ro=/<style>(.*?)<\/style>/gs;let ko,To;var Ao=n(72162),No=n(29295);function Bo(e,t,n){const[s,a]=(0,o.eJ)(),{isFrozen:i,updateWhenUnfrozen:r}=function(){const e=(0,o.sO)(!1),t=(0,o.I4)((()=>{e.current=!0}),[]),n=(0,st.Z)(),s=(0,o.I4)((()=>{e.current&&(e.current=!1,n())}),[n]);return(0,ot.ZP)(xo,s),{isFrozen:(0,ot.zG)(),updateWhenUnfrozen:t}}(),c=(0,Xn.Z)(t,!0);return(0,Ke.Z)((()=>{i?r():c((()=>{a(e())}))}),[...n,i]),s}function xo(){}const Lo=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Oo=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,Fo={username:"",query:"",canShowHelp:!1,usernameLowered:""},Uo=document.createElement("div");const jo=(0,T.P2)((e=>e()),500,!0),Do=/^[\w@]{1,32}\s?/i;var qo=n(33057),$o=n(60130);const Go=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"DeleteMessageModal",!t);return n?o.ZP.createElement(n,e):void 0}));function Ho(){return Ho=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},Ho.apply(this,arguments)}let Vo,_o=!0;const zo=(0,o.X$)((e=>{let{onActivate:t,...n}=e;const s=(0,o.sO)(!1),a=(0,o.I4)((()=>{if(s.current=!0,_o)return _o=!1,void t();Vo&&(clearTimeout(Vo),Vo=void 0),Vo=window.setTimeout((()=>{s.current&&t()}),200)}),[t]),i=(0,o.I4)((()=>{s.current=!1}),[]),r=(0,o.I4)((()=>{s.current=!0,t()}),[t]);return o.ZP.createElement(Rt.Z,Ho({},n,{onMouseEnter:h.$b?void 0:a,onMouseLeave:h.$b?void 0:i,onClick:h.$b?r:t}))}));var Wo=n(85655),Xo=n(56503),Jo=n(62898);const Yo="N3E1geoPu1vesCKf545F",Ko=/#fff/gi,Qo=(0,o.X$)((e=>{let{icon:t,theme:n}=e;const s=(0,fn.Z)((0,d.ym)(t),!1,i.IU.Text),a=(0,o.Ye)((()=>{if(!s)return"";const e="dark"===n?"rgb(170, 170, 170)":"rgb(112, 117, 121)",t=s.replace(Ko,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 o.ZP.createElement("i",{className:(0,_e.Z)("vL8HfVVnjTeFmp1ECFj8",h.FW&&Yo)},o.ZP.createElement("img",{src:a,alt:"",className:(0,_e.Z)("Fb4aIyDYEwOlaqY8oZkV",h.FW&&Yo)}))})),ei=(0,o.X$)((e=>{let{bot:t,theme:n,chatId:a,onMenuOpened:i,onMenuClosed:r}=e;const{callAttachBot:c,toggleAttachBot:l}=(0,s.Sv)(),d=(0,yt.Z)(),u=(0,o.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,vt.Z)(),[p,f]=(0,o.eJ)(void 0),v=(0,o.I4)((e=>{e.preventDefault();const t=e.currentTarget.getBoundingClientRect();f({x:t.right,y:t.bottom}),i(),h()}),[i,h]),I=(0,o.I4)((()=>{g(),r()}),[g,r]),w=(0,o.I4)((()=>{f(void 0)}),[]),y=(0,o.I4)((()=>{l({botId:t.id,isEnabled:!1})}),[t.id,l]);return o.ZP.createElement(Mt.Z,{key:t.id,customIcon:u&&o.ZP.createElement(Qo,{icon:u,theme:n}),icon:u?void 0:"bots",onClick:()=>c({botId:t.id,chatId:a}),onContextMenu:v},t.shortName,p&&o.ZP.createElement(Jo.Z,null,o.ZP.createElement(Ht.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},o.ZP.createElement(Mt.Z,{icon:"stop",destructive:!0,onClick:y},d("WebApp.RemoveBot")))))})),ti=(0,o.X$)((e=>{let{chatId:t,isButtonVisible:n,canAttachMedia:s,canAttachPolls:i,attachBots:r,peerType:c,isScheduled:l,onFileSelect:d,onPollCreate:u,theme:m}=e;const[g,p,f]=(0,vt.Z)(),[v,I,w]=(0,Xo.Z)(g,f),[y,P,Z]=(0,vt.Z)();(0,o.d4)((()=>{g&&w()}),[g,w]);const C=(0,o.I4)((()=>{g?f():p()}),[g,p,f]),b=(0,o.I4)(((e,t)=>{const{files:n}=e.target;n&&n.length>0&&d(Array.from(n),t)}),[d]),E=(0,o.I4)((()=>{(0,Wo.g)(Array.from(a.dI).join(","),(e=>b(e,!0)))}),[b]),S=(0,o.I4)((()=>{(0,Wo.g)("*",(e=>b(e,!1)))}),[b]),M=(0,o.Ye)((()=>Object.values(r).filter((e=>!!c&&(!("bots"!==c||e.id!==t||!e.peerTypes.includes("self"))||e.peerTypes.includes(c))))),[r,t,c]),R=(0,yt.Z)();if(n)return o.ZP.createElement("div",{className:"AttachMenu"},o.ZP.createElement(zo,{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},o.ZP.createElement("i",{className:"icon-attach"})),o.ZP.createElement(Ht.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&&o.ZP.createElement(Mt.Z,{className:"media-disabled",disabled:!0},"Posting media content is not allowed in this group."),s&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Mt.Z,{icon:"photo",onClick:E},R("AttachmentMenu.PhotoOrVideo")),o.ZP.createElement(Mt.Z,{icon:"document",onClick:S},R("AttachDocument"))),i&&o.ZP.createElement(Mt.Z,{icon:"poll",onClick:u},R("Poll")),s&&!l&&M.map((e=>o.ZP.createElement(ei,{bot:e,chatId:t,theme:m,onMenuOpened:P,onMenuClosed:Z})))))})),ni=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"SymbolMenu",!t);return n?o.ZP.createElement(n,e):void 0})),si=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"InlineBotTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),ai=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"MentionTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var oi=n(67146);const ii=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"StickerTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var ri=n(93219),ci=n(19830);const li=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"BotCommandTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),di=(0,o.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:i}=(0,s.Sv)(),[r,c]=(0,Xo.Z)(t,a),{isKeyboardSingleUse:l}=n||{};if(n&&n.keyboardButtons)return o.ZP.createElement(Ht.Z,{isOpen:t,autoClose:l,positionX:"right",positionY:"bottom",onClose:a,className:"BotKeyboardMenu",onCloseAnimationEnd:a,onMouseEnter:h.$b?void 0:r,onMouseLeave:h.$b?void 0:c,noCompact:!0},o.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Rt.Z,{ripple:!0,disabled:"unsupported"===e.type,onClick:()=>i({messageId:n.id,button:e})},e.text))))))))})));var ui=n(13616),mi=n(17891),hi=n(63394),gi=n(66902);const pi=(0,o.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:o,messageIds:i,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=o===t,p=null==i?void 0:i.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===i.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?i.length:void 0,noAuthors:r,noCaptions:l,forwardsHaveCaptions:I,isCurrentUserPremium:(0,c.wV)(e)}}))((e=>{let{replyingToId:t,editingId:n,message:a,sender:i,shouldAnimate:r,forwardedMessagesCount:c,noAuthors:l,noCaptions:u,forwardsHaveCaptions:m,isCurrentUserPremium:h,onClear:g}=e;const{setReplyingToId:p,setEditingId:f,focusMessage:v,changeForwardRecipient:I,setForwardNoAuthors:w,setForwardNoCaptions:y,exitForwardMode:P}=(0,s.Sv)(),Z=(0,o.sO)(null),C=(0,yt.Z)(),b=Boolean(c),E=Boolean((t||n)&&a||i&&c),S=(0,mi.Z)([c],c?300:void 0),{shouldRender:M,transitionClassNames:R}=(0,at.Z)(S&&E,void 0,!r,void 0,!r),k=(0,o.I4)((()=>{t?p({messageId:void 0}):n?f({messageId:void 0}):c&&P(),null==g||g()}),[t,n,c,g,p,f,P]);(0,o.d4)((()=>E?(0,pt.Z)(k):void 0),[E,k]);const T=(0,o.I4)((()=>{b||v({chatId:a.chatId,messageId:a.id})}),[v,b,a]),A=(0,o.I4)((e=>{e.stopPropagation(),k()}),[k]),N=(0,o.I4)((()=>{I()}),[I]),{isContextMenuOpen:B,contextMenuPosition:x,handleContextMenu:L,handleContextMenuClose:O,handleContextMenuHide:F}=(0,ts.Z)(Z),U=(0,o.I4)((()=>Z.current),[]),j=(0,o.I4)((()=>Z.current),[]),D=(0,o.I4)((()=>Z.current.querySelector(".forward-context-menu .bubble")),[]),{positionX:q,positionY:$,transformOriginX:G,transformOriginY:H,style:V}=(0,hi.Z)(x,U,j,D),_=(0,_e.Z)("ComposerEmbeddedMessage",R),z=(0,o.Ye)((()=>t?"icon-reply":n?"icon-edit":b?"icon-forward":void 0),[n,b,t]),W=c&&c>1?C("ForwardedMessageCount",c):void 0,X=(0,o.Ye)((()=>{if(!a||!b||!a.content.text||!l||h)return a;const e=(0,d.If)(a.content.text);return{...a,content:{...a.content,text:e}}}),[h,b,a,l]);if(M)return o.ZP.createElement("div",{className:_,ref:Z,onContextMenu:L,onClick:L},o.ZP.createElement("div",null,o.ZP.createElement("div",{className:"embedded-left-icon"},o.ZP.createElement("i",{className:z})),o.ZP.createElement(Es,{className:"inside-input",message:X,sender:l?void 0:i,customText:W,title:n?C("EditMessage"):l?C("HiddenSendersNameDescription"):void 0,onClick:T,hasContextMenu:b}),o.ZP.createElement(Rt.Z,{className:"embedded-cancel",round:!0,faded:!0,color:"translucent",ariaLabel:C("Cancel"),onClick:A},o.ZP.createElement("i",{className:"icon-close"})),b&&o.ZP.createElement(Ht.Z,{isOpen:B,transformOriginX:G,transformOriginY:H,positionX:q,positionY:$,style:V,className:"forward-context-menu",onClose:O,onCloseAnimationEnd:F},o.ZP.createElement(Mt.Z,{icon:l?void 0:"message-succeeded",customIcon:l?o.ZP.createElement("i",{className:"icon-placeholder"}):void 0,onClick:()=>w(!1)},C(c>1?"ShowSenderNames":"ShowSendersName")),o.ZP.createElement(Mt.Z,{icon:l?"message-succeeded":void 0,customIcon:l?void 0:o.ZP.createElement("i",{className:"icon-placeholder"}),onClick:()=>w(!0)},C(c>1?"HideSenderNames":"HideSendersName")),m&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(gi.Z,null),o.ZP.createElement(Mt.Z,{icon:u?void 0:"message-succeeded",customIcon:u?o.ZP.createElement("i",{className:"icon-placeholder"}):void 0,onClick:()=>y(!1)},C(c>1?"Conversation.ForwardOptions.ShowCaption":"ShowCaption")),o.ZP.createElement(Mt.Z,{icon:u?"message-succeeded":void 0,customIcon:u?void 0:o.ZP.createElement("i",{className:"icon-placeholder"}),onClick:()=>y(!0)},C(c>1?"Conversation.ForwardOptions.HideCaption":"HideCaption"))),o.ZP.createElement(gi.Z,null),o.ZP.createElement(Mt.Z,{icon:"replace",onClick:N},C("ChangeRecipient")))))}))),fi=(0,o.X$)((e=>{const{attachments:t}=e,n=(0,lt.Z)(ct.gl.Extra,"AttachmentModal",!t.length);return n?o.ZP.createElement(n,e):void 0})),vi=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"BotCommandMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Ii=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"PollModal",!t);return n?o.ZP.createElement(n,e):void 0})),wi=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"DropArea",!t);return n?o.ZP.createElement(n,e):void 0})),yi=new RegExp(a.FM,"i"),Pi=(0,o.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=Bo((()=>{const{text:e,entities:t}=(0,f.Z)(a),n=null==t?void 0:t.find((e=>e.type===i.Vv.TextUrl));if(n)return n.url;const s=e.match(yi);return s?s[0]:void 0}),300,[a]);(0,o.d4)((()=>{g?u({text:g}):(m(),h({chatId:t,threadId:n}))}),[t,h,m,g,u,n]),(0,Ke.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t]);const p=Boolean(c&&a.length&&!l&&!r),{shouldRender:v,transitionClassNames:I}=(0,at.Z)(p),w=(0,dn.Z)(c,!0),y=(0,o.I4)((()=>{h({chatId:t,threadId:n,noWebPage:!0})}),[t,n,h]);if(!v||!w)return;const{photo:P,...Z}=w,C={content:{webPage:Z}};return o.ZP.createElement("div",{className:(0,_e.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement("div",{className:"WebPagePreview-left-icon"},o.ZP.createElement("i",{className:"icon-link"})),o.ZP.createElement(ma,{message:C,inPreview:!0,theme:d}),o.ZP.createElement(Rt.Z,{className:"WebPagePreview-clear",round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:y},o.ZP.createElement("i",{className:"icon-close"}))))}))),Zi=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"SendAsMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Ci=(0,o.X$)((e=>{let{isOpen:t,onClick:n,text:s,isDisabled:a}=e;const i=(0,o.sO)(null);return(0,o.d4)((()=>{const e=i.current;if(!e)return;const t=e.scrollWidth+1;e.closest(".Composer").style.setProperty("--bot-menu-text-width",`${t}px`)}),[t,s]),(0,o.d4)((()=>{const e=i.current;if(!e)return;const t=e.closest(".Composer");return()=>{t.style.removeProperty("--bot-menu-text-width")}}),[]),o.ZP.createElement(Rt.Z,{className:(0,_e.Z)("bot-menu",t&&"open"),round:!0,color:"translucent",disabled:a,onClick:n,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:(0,_e.Z)("bot-menu-icon","icon-webapp",t&&"open")}),o.ZP.createElement("span",{ref:i,className:"bot-menu-text"},s))}));var bi;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(bi||(bi={}));const Ei="wonderful-voice-message.ogg",Si=(0,o.X$)((0,s.c$)(((e,t)=>{var n,s,o,r,l,u,m,h,g;let{chatId:p,threadId:f,messageListType:v}=t;const I=(0,c.Z1)(e,p),w=p!==a.FV?(0,c.IK)(e,p):void 0,y=Boolean(w),P=(0,c.FM)(e,p),Z=y&&(0,c.FT)(e,p),C=(0,c.qy)(e,p),{language:b,shouldSuggestStickers:E,shouldSuggestCustomEmoji:S}=e.settings.byKey,M=e.emojiKeywords[a.pR],R=b!==a.pR?e.emojiKeywords[b]:void 0,k=Z?Z.id:void 0,T=k?(0,c.hj)(e,p,k):void 0,{currentUserId:A}=e,N=null!=I&&I.fullInfo?(null==I||null===(n=I.fullInfo)||void 0===n?void 0:n.sendAsId)||A:void 0,B=null!=I&&I.sendAsPeerIds&&N&&I.sendAsPeerIds.some((e=>e.id===N))?N:null!=I&&null!==(s=I.adminRights)&&void 0!==s&&s.anonymous?null==I?void 0:I.id:void 0,x=B?(0,c.dy)(e,B):void 0,L=!x&&B?(0,c.Z1)(e,B):void 0,O=(0,c.uH)(e,p),F=(0,c.nA)(e,p),U=(0,c.Bt)(e),j=p===(null==U?void 0:U.chatId)&&f===(null==U?void 0:U.threadId)&&v===(null==U?void 0:U.type),D=(0,c.dy)(e,p),q=null===(o=D&&!(null!==(r=D.fullInfo)&&void 0!==r&&r.noVoiceMessages))||void 0===o||o,G="scheduled"===v?(0,c.hI)(e,p):(0,c.s)(e,p,f);return{editingMessage:(0,c.kK)(e,p,f,v),connectionState:e.connectionState,draft:(0,c.Ms)(e,p,f),chat:I,isChatWithBot:y,isChatWithSelf:P,isForCurrentMessageList:j,canScheduleUntilOnline:(0,c.Eh)(e,p),isChannel:I?(0,d.eA)(I):void 0,isRightColumnShown:(0,c.Jf)(e),isSelectModeActive:(0,c.CA)(e),withScheduledButton:f===i._f&&"thread"===v&&Boolean(null==C?void 0:C.length),shouldSchedule:"scheduled"===v,botKeyboardMessageId:k,botKeyboardPlaceholder:null==T?void 0:T.keyboardPlaceholder,isForwarding:p===e.forwardMessages.toChatId,pollModal:e.pollModal,stickersForEmoji:e.stickers.forEmoji.stickers,customEmojiForEmoji:e.customEmojis.forEmoji.stickers,groupChatMembers:null==I||null===(l=I.fullInfo)||void 0===l?void 0:l.members,topInlineBotIds:null===(u=e.topInlineBots)||void 0===u?void 0:u.userIds,currentUserId:A,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:E,shouldSuggestCustomEmoji:S,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==M?void 0:M.keywords,emojiKeywords:null==R?void 0:R.keywords,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:(null==I?void 0:I.fullInfo)&&I.fullInfo.botCommands,botCommands:null!=w&&w.fullInfo?(null===(m=w.fullInfo.botInfo)||void 0===m?void 0:m.commands)||!1:void 0,botMenuButton:null==w||null===(h=w.fullInfo)||void 0===h||null===(g=h.botInfo)||void 0===g?void 0:g.menuButton,sendAsUser:x,sendAsChat:L,sendAsId:B,editingDraft:G,requestedDraftText:O,requestedDraftFiles:F,attachBots:e.attachMenu.bots,attachMenuPeerType:(0,c.t)(e,p),theme:(0,c.Pu)(e),fileSizeLimit:(0,$.M)(e,"uploadMaxFileparts")*a.pJ,captionLimit:(0,$.M)(e,"captionLength"),isCurrentUserPremium:(0,c.wV)(e),canSendVoiceByPrivacy:q}}))((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:P,isCurrentUserPremium:Z,canSendVoiceByPrivacy:C,connectionState:b,isChatWithBot:E,isChatWithSelf:S,isChannel:M,fileSizeLimit:R,isRightColumnShown:k,isSelectModeActive:A,isForwarding:N,pollModal:B,botKeyboardMessageId:x,botKeyboardPlaceholder:L,withScheduledButton:O,stickersForEmoji:F,customEmojiForEmoji:U,groupChatMembers:j,topInlineBotIds:D,currentUserId:q,captionLimit:$,lastSyncTime:G,contentToBeScheduled:H,shouldSuggestStickers:V,shouldSuggestCustomEmoji:_,baseEmojiKeywords:W,emojiKeywords:X,recentEmojis:J,inlineBots:Y,isInlineBotLoading:K,botCommands:Q,chatBotCommands:ee,sendAsUser:te,sendAsChat:ne,sendAsId:se,editingDraft:ae,requestedDraftText:oe,requestedDraftFiles:ie,botMenuButton:re,attachBots:ce,attachMenuPeerType:le,theme:de}=e;const{sendMessage:ue,clearDraft:me,showDialog:he,setStickerSearchQuery:ge,setGifSearchQuery:pe,forwardMessages:fe,openPollModal:ve,closePollModal:Ie,loadScheduledHistory:we,openChat:ye,addRecentEmoji:Pe,sendInlineBotResult:Ze,loadSendAs:Ce,resetOpenChatWithDraft:be,callAttachBot:Ee,openLimitReachedModal:Me,openPremiumModal:Re,addRecentCustomEmoji:ke,showNotification:Te}=(0,s.Sv)(),Ae=(0,yt.Z)(),Ne=(0,o.sO)(null),[Be,xe]=(0,o.eJ)(""),Le=(0,vo.Y)(Be),Oe=(0,o.sO)(),Fe=(0,rn.Z)(t),{width:Ue}=Se.Z.get(),je=null==y?void 0:y.sendAsPeerIds,De=je&&(je.length>1||!je.some((e=>e.id===q))),[qe,$e,Ge]=(0,vt.Z)(),He=(0,fo.Z)(g,v),Ve=(0,o.I4)((e=>{xe(e),requestAnimationFrame((()=>{(0,mo.A)()}))}),[]),ze=(0,o.sO)(0),We=(0,o.I4)((()=>{Ge()}),[Ge]),[Qe,et]=(0,qo.Z)(r,We);(0,o.d4)((()=>{Oe.current=void 0}),[g]),(0,o.d4)((()=>{g&&G&&v===i._f&&c&&we({chatId:g})}),[c,g,we,G,v]),(0,o.d4)((()=>{g&&y&&G&&!je&&c&&(0,d.ZV)(y)&&Ce({chatId:g})}),[y,g,c,G,Ce,je]);const tt=(0,o.sO)(!1);(0,Ke.Z)((e=>{let[t,n]=e;tt.current=Boolean(g===t&&je&&!n)}),[g,je]),(0,o.bt)((()=>{Ne.current&&(Ne.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[nt,st]=(0,o.eJ)([]),[at,ot,rt]=(0,vt.Z)(),[ct,lt,dt]=(0,vt.Z)(),[ut,mt,ht]=(0,vt.Z)(),[gt,ft,It]=(0,vt.Z)(),[wt,Pt,Zt]=(0,vt.Z)(),[Ct,bt]=(0,vt.Z)(),[Et,St,Mt]=(0,vt.Z)(),kt=(0,o.I4)((e=>{const t="function"==typeof e?e(nt):e;t&&t.some((e=>e.size>R))?Me({limit:"uploadMaxFileparts"}):st(t)}),[nt,R,Me]),{startRecordingVoice:Tt,stopRecordingVoice:At,pauseRecordingVoice:Nt,activeVoiceRecording:xt,currentRecordTime:Lt,recordButtonRef:Ot,startRecordTimeRef:Ft}=(()=>{const e=(0,o.sO)(null),[t,n]=(0,o.eJ)(),s=(0,o.sO)(),[a,i]=(0,o.eJ)();(0,o.d4)((()=>{h.s$&&h.mh&&Co()}),[]);const r=(0,o.I4)((async()=>{try{const{stop:t,pause:a}=await bo((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)`),i(Date.now()))}));s.current=Date.now(),i(Date.now()),n({stop:t,pause:a})}catch(e){console.error(e)}}),[]),c=(0,o.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),l=(0,o.I4)((()=>{if(t){n(void 0),s.current=void 0,i(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,pt.Z)(l):void 0),[t,l]),{startRecordingVoice:r,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:a,recordButtonRef:e,startRecordTimeRef:s}})();(0,it.Z)((()=>{He({type:"recordAudio"})}),xt&&a.o_),(0,o.d4)((()=>{xt||He({type:"cancel"})}),[xt,He]),(0,o.d4)((()=>{Be&&!m&&He({type:"typing"})}),[m,Be,He]);const Ut=m?bi.Edit:!h.mh||xt||Be&&!nt.length||N?n?bi.Schedule:bi.Send:bi.Record,jt=!n,{isMentionTooltipOpen:Dt,closeMentionTooltip:qt,insertMention:$t,mentionFilteredUsers:Gt}=(0,No.Z)(!nt.length,a.Ed,Ve,j,D,q),{isOpen:Ht,id:Vt,isGallery:_t,switchPm:zt,results:Wt,closeTooltip:Xt,help:Jt,loadMore:Yt}=function(e,t,n,a){const{queryInlineBot:i,resetInlineBot:r}=(0,s.Sv)(),[c,l,d]=(0,vt.Z)(),{username:u,query:m,canShowHelp:h,usernameLowered:g}=Bo((()=>function(e){const t=function(e){return Uo.innerHTML=e.replace(/<br>/g,"\n"),Uo.innerText}(e),n=t.match(Lo);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(Oo),usernameLowered:n[1].toLowerCase()}:Fo}(n)),300,[n])||{},p=(0,rn.Z)(m),f=(0,rn.Z)(u),v=g?null==a?void 0:a[g]:void 0,{id:I,switchPm:w,offset:y,results:P,isGallery:Z,help:C}=v||{};(0,o.d4)((()=>{p!==m&&d()}),[p,m,d]),(0,o.d4)((()=>{e&&g&&t&&i({chatId:t,username:g,query:m})}),[m,e,i,t,g]);const b=(0,o.I4)((()=>{e&&g&&t&&i({chatId:t,username:g,query:m,offset:y})}),[e,g,t,i,m,y]);return(0,o.d4)((()=>{e&&I&&(w||null!=P&&P.length)?l():d()}),[I,e,l,P,w,d]),f!==u&&r({username:f}),{isOpen:c,id:I,isGallery:Z,switchPm:w,results:P,closeTooltip:d,help:h&&C?`@${u} ${C}`:void 0,loadMore:b}}(Boolean(!nt.length&&G),g,Be,Y),{isOpen:Kt,close:Qt,filteredBotCommands:en}=function(e,t,n,s){const[a,i,r]=(0,vt.Z)(),[c,l]=(0,o.eJ)(),d=(0,o.I4)((e=>{n||s?jo((()=>{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,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,go._)(t.substr(1)).match(Do);d(e?e[0]:"")}else l(void 0);else l(void 0)}),[d,t,e,r]),(0,o.d4)((()=>{c&&c.length&&t.length>0?i():r()}),[c,t.length,i,r]),{isOpen:a,close:r,filteredBotCommands:c}}(Boolean(Q&&Q.length||ee&&ee.length),Be,Q,ee),{isContextMenuOpen:nn,handleContextMenu:an,handleContextMenuClose:on,handleContextMenuHide:cn}=(0,ts.Z)(Ot,!(Ut===bi.Send&&jt)),{canSendStickers:ln,canSendGifs:dn,canAttachMedia:un,canAttachPolls:mn,canAttachEmbedLinks:hn}=(0,o.Ye)((()=>(0,d.H5)(y,E)),[y,E]),gn=y&&(0,d.Nl)(y),pn=(0,d.Hd)(y),{isStickerTooltipOpen:fn,closeStickerTooltip:vn}=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=(0,o.Ye)((()=>(0,go._)(t).trim()),[t]),{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,s.Sv)(),l=h.op&&1===(0,ho.Z)(i)||!h.op&&Boolean(t.match(po)),d=Boolean(null==n?void 0:n.length)&&l;return(0,o.d4)((()=>{var t;a||(e&&l?r({emoji:h.op?i:null===(t=i.match(/alt="(.+)"/))||void 0===t?void 0:t[1]}):!d&&l||c())}),[t,l,c,r,e,a]),{isStickerTooltipOpen:d,closeStickerTooltip:c}}(Boolean(V&&ln&&!nt.length),Be,F,!c),{isCustomEmojiTooltipOpen:In,closeCustomEmojiTooltip:wn,insertCustomEmoji:yn}=(0,$o.Z)(Boolean(_&&!nt.length),a.Ed,Be,Ve,U,!c),{isEmojiTooltipOpen:Pn,closeEmojiTooltip:Zn,filteredEmojis:Cn,filteredCustomEmojis:bn,insertEmoji:En,insertCustomEmoji:Sn}=(0,Ao.Z)(Boolean(V&&ln&&!nt.length),Le,J,void 0,Ve,W,X,!c),Mn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.R2;const n=window.getSelection();let s;if(s=t===a.R2?document.querySelector(a.Ed):document.getElementById(t),n.rangeCount){const a=n.getRangeAt(0);if((0,co.R)(a,t))return(0,ro.t)(e),void s.dispatchEvent(new Event("input",{bubbles:!0}))}Ve(`${Le.current}${e}`),requestAnimationFrame((()=>{(0,so.Z)(s)}))}),[Le,Ve]),Rn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.R2;const n=(0,na.z)(e);Mn(n,t)}),[Mn]),kn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.R2;const n=(0,On.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");Mn(n,t)}),[Mn]),Tn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.R2;Mn((0,ys.yR)(e),t)}),[Mn]),An=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,co.R)(t,a.R2))return void document.execCommand("delete",!1)}Ve(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(),o=window.getSelection();a.setStart(n,s),a.setEnd(n,s),o.removeAllRanges(),o.addRange(a),document.execCommand("delete",!1);const i=t.innerHTML;return document.body.removeChild(t),i}(Le.current))}),[Le,Ve]),Nn=(0,o.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||Ve(""),st(l.D),vn(),wn(),qt(),Zn(),h.wB?setTimeout((()=>ht()),350):ht()}),[vn,wn,qt,Zn,ht,Ve]),Bn=(0,o.sO)();Bn.current=At,(0,o.d4)((()=>()=>{Bn.current(),Nn()}),[g,Nn,Bn]);const xn=(0,o.I4)((()=>{const e=ze.current;Te(e?{message:Ae("UnlockPremiumEmojiHint2"),action:()=>ye({id:q,shouldReplaceHistory:!0}),actionText:Ae("Open")}:{message:Ae("UnlockPremiumEmojiHint"),action:()=>Re({initialSection:"animated_emoji"}),actionText:Ae("PremiumMore")}),ze.current=Number(!e)}),[q,Ae,ye,Re,Te]),[Ln,Fn]=((e,t,n,i,r,c,l,u,m,h)=>{const{editMessage:g,setEditingDraft:p}=(0,s.Sv)();(0,Xe.Z)((e=>{let[s]=e;if(!n)return;if((null==s?void 0:s.id)===n.id)return;const o=(0,na.z)(null!=h&&h.text.length?h:n.content.text);t(o),requestAnimationFrame((()=>{const e=document.querySelector(a.Ed);e&&(0,so.Z)(e,!0)}))}),[n,t]),(0,o.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,o.I4)((()=>{m&&(0,T.T2)((()=>{t((0,na.z)(m));const e=document.querySelector(a.Ed);e&&requestAnimationFrame((()=>{(0,so.Z)(e,!0)}))}))}),[m,t]),I=(0,o.I4)((()=>{i(),v()}),[i,v]),w=(0,o.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}),i(),v()):r())}),[g,n,e,r,i,v]),y=(0,o.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,Je.Z)(y),Ye(y),[w,I]})(Le,Ve,m,Nn,Pt,g,v,I,w,ae);((e,t,n,r,c,l,d)=>{const{saveDraft:u,clearDraft:m,loadCustomEmojis:g}=(0,s.Sv)(),p=(0,rn.Z)(e),v=(0,o.I4)(((e,t)=>{const n=r.current;void 0!==n&&!l&&d&&(n.length?u({chatId:e,threadId:t,draft:(0,f.Z)(n)}):m({chatId:e,threadId:t}))}),[m,l,r,d,u]),I=(0,o.Ye)((()=>(0,T.Ds)((e=>e()),a.r_,!1)),[t]),w=(0,rn.Z)(t),y=(0,rn.Z)(n);(0,o.d4)((()=>(ko=t,To=n,()=>{ko=void 0,To=void 0,v(t,n)})),[t,n,v]),(0,o.d4)((()=>{var s;if(t===w&&n===y)return void(!e&&p&&c(""));if(l||!e)return;c((0,na.z)(e));const o=(null===(s=e.entities)||void 0===s?void 0:s.map((e=>e.type===i.Vv.CustomEmoji&&e.documentId)).filter(Boolean))||[];o.length&&g({ids:o}),h.$b||requestAnimationFrame((()=>{const e=document.querySelector(a.Ed);e&&(0,so.Z)(e,!0)}))}),[t,n,e,c,v,w,y,l,p,g]);const P=r.current,Z=(0,rn.Z)(P);(0,o.d4)((()=>{t&&n&&w===t&&y===n&&Z!==P&&(P.length?I((()=>{ko===t&&To===n&&v(t,n)})):v(t,n))}),[t,P,w,Z,y,I,n,v]);const C=(0,o.I4)((()=>{t&&n&&v(t,n)}),[t,n,v]);(0,Je.Z)(C),Ye(C)})(w,g,v,Le,Ve,m,G),((e,t,n,s,r,c)=>{(0,o.d4)((()=>{if(e)return document.addEventListener("paste",o,!1),()=>{document.removeEventListener("paste",o,!1)};async function o(e){var o,l;if(!e.clipboardData)return;const d=document.activeElement;if(d&&![a.R2,a.nY].includes(d.id))return;const u=e.clipboardData.getData("text").substring(0,4096),m=e.clipboardData.getData("text/html");let h=m?(0,f.Z)(function(e){let t=document.createElement("div");t.innerHTML=e.replace(/\u00a0/g," ").replace(Ro,"");const n=t.querySelectorAll(".text-content");return n.length&&(t=n[n.length-1]),Array.from(t.getElementsByTagName("*")).forEach((e=>{if(e instanceof HTMLElement)switch(e.removeAttribute("style"),"BR"===e.tagName&&e.replaceWith("\n"),"P"===e.tagName&&e.appendChild(document.createTextNode("\n")),"IMG"!==e.tagName||e.dataset.entityType||e.replaceWith(e.getAttribute("alt")||""),e.dataset.ignoreOnPaste&&e.remove(),f.x[e.tagName]&&e.setAttribute("data-entity-type",f.x[e.tagName]),e.dataset.entityType||e.textContent!==e.innerText||e.replaceWith(e.textContent),e.dataset.alt&&e.setAttribute("alt",e.dataset.alt),e.dataset.entityType){case i.Vv.MentionName:e.replaceWith(e.textContent||"");break;case i.Vv.CustomEmoji:e.textContent=e.dataset.alt||""}})),t.innerHTML.trimEnd()}(m),void 0,!0):void 0;h&&(0,So.Lo)(h)&&r&&(h=(0,So.If)(h),null==c||c());const{items:g}=e.clipboardData;let p=[];if(e.preventDefault(),g.length>0&&(p=await(0,Eo.Z)(g)),0===p.length&&!u)return;if(p.length>0&&!s){const e=await Promise.all(p.map((e=>io(e.name,e,1===p.length&&Mo.includes(e.type)))));n((t=>t.concat(e)))}const v=null!==(o=h)&&void 0!==o&&null!==(l=o.entities)&&void 0!==l&&l.length?h:{text:u};v&&t(v,null==d?void 0:d.id)}}),[t,s,n,e,r,c])})(P,Rn,kt,m,!Z&&!S,xn);const Un=(0,o.I4)((()=>{m&&Fn()}),[m,Fn]),Dn=(0,o.I4)((async(e,t)=>{kt(await Promise.all(e.map((e=>io(e.name,e,t)))))}),[kt]),qn=(0,o.I4)((async(e,t)=>{kt([...nt,...await Promise.all(e.map((e=>io(e.name,e,t))))])}),[nt,kt]),$n=(0,o.I4)((()=>{st(l.D)}),[]),Gn=(0,o.I4)((async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;if("connectionStateReady"!==b)return;let n=nt;if(xt){const e=await At();if(e){const{blob:t,duration:s,waveform:a}=e;n=[await io(Ei,t,!1,{voice:{duration:s,waveform:a}})]}}const{text:o,entities:i}=(0,f.Z)(Le.current);if(!n.length&&!o&&!N)return;const{serverTimeOffset:r}=(0,s.Rd)(),c=n.length?$:4096;if((null==o?void 0:o.length)>c){const e=o.length-c;return void he({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||o){if(pn&&!gn){const e=(0,p.b)(r),t=Oe.current&&Math.floor(e-Oe.current),n=pn.nextSendDate&&pn.nextSendDate>e;if(t&&t<pn.seconds||n){const s=n?pn.nextSendDate-e:pn.seconds-t;return he({data:{message:Ae("SlowModeHint",(0,z.k9)(s)),isSlowMode:!0,hasErrorKey:!1}}),void(null==l||l.blur())}}ue({text:o,entities:i,attachments:n,scheduledAt:t,isSilent:e})}N&&fe({scheduledAt:t,isSilent:e}),Oe.current=(0,p.b)(r),me({chatId:g,localOnly:!0}),h.cj&&l&&l===document.activeElement&&uo(l),requestAnimationFrame((()=>{Nn()}))}),[b,nt,xt,N,me,g,$,Nn,At,he,pn,gn,ue,fe,Ae,Le]),Hn=(0,o.I4)((()=>{"webApp"===(null==re?void 0:re.type)&&Ee({botId:g,chatId:g,isFromBotMenu:!0,url:re.url})}),[re,Ee,g]),Vn=(0,o.I4)((()=>{ht(),lt()}),[ht,lt]),_n=(0,o.I4)((()=>{dt(),It(),mt()}),[dt,It,mt]),zn=(0,o.I4)(((e,t)=>{if(e&&"queryId"in e){const{id:n,queryId:s,isSilent:a}=e;return void Ze({id:n,queryId:s,scheduledAt:t,isSilent:a})}const{isSilent:n,...s}=e||{};e&&0!==Object.keys(s).length?ue({...e,scheduledAt:t}):Gn(Boolean(n),t)}),[Gn,Ze,ue]);(0,o.d4)((()=>{H&&Qe((e=>{zn(H,e)}))}),[H,zn,Qe]),(0,o.d4)((()=>{oe&&(Ve(oe),be(),requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,so.Z)(e,!0)})))}),[oe,be,Ve]),(0,o.d4)((()=>{if(null!=ie&&ie.length){const e=ie.every((e=>(0,sn.MD)(e)));Dn(ie,e),be()}}),[Dn,ie,be]);const Wn=(0,o.I4)((e=>{e.isFree||Z||S?Tn(e):xn()}),[Tn,S,Z,xn]),Xn=(0,o.I4)((function(e,t,s){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e={...e,isPreloadedGlobally:!0},n||s?($e(),Qe((n=>{Ge(),zn({sticker:e,isSilent:t},n),requestAnimationFrame((()=>{Nn(a)}))}))):(ue({sticker:e,isSilent:t}),requestAnimationFrame((()=>{Nn(a)})))}),[n,$e,Qe,Ge,zn,Nn,ue]),Jn=(0,o.I4)(((e,t,s)=>{n||s?($e(),Qe((n=>{Ge(),zn({gif:e,isSilent:t},n),requestAnimationFrame((()=>{Nn(!0)}))}))):(ue({gif:e,isSilent:t}),requestAnimationFrame((()=>{Nn(!0)})))}),[n,$e,Qe,Ge,zn,Nn,ue]),Yn=(0,o.I4)(((e,t,s)=>{if("connectionStateReady"!==b)return;n||s?Qe((n=>{zn({id:e.id,queryId:e.queryId,isSilent:t},n)})):Ze({id:e.id,queryId:e.queryId,isSilent:t});const o=document.querySelector(a.Ed);h.cj&&o&&o===document.activeElement&&uo(o),me({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{Nn()}))}),[g,me,b,zn,Qe,Nn,Ze,n]),Kn=(0,o.I4)((()=>{me({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{Nn()}))}),[g,me,Nn]),Qn=(0,o.I4)((e=>{n?(Qe((t=>{zn({poll:e},t)})),Ie()):(ue({poll:e}),Ie())}),[Ie,zn,Qe,ue,n]),es=(0,o.I4)((()=>{n?Qe((e=>{zn({isSilent:!0},e)})):Gn(!0)}),[zn,Gn,Qe,n]),ns=(0,o.I4)((e=>{"stickers"===e?(ge({query:""}),pe({query:void 0})):(pe({query:""}),ge({query:void 0}))}),[ge,pe]),ss=(0,o.I4)((()=>{const e=document.querySelector(a.Ed);h.wB&&e===document.activeElement?(null==e||e.blur(),setTimeout((()=>{dt(),mt()}),100)):mt()}),[mt,dt]),as=(0,o.I4)((()=>{const e=document.querySelector(a.Ed);if(!h.wB||e!==document.activeElement)return dt(),ht(),void ft();null==e||e.blur(),setTimeout((()=>{dt(),ht(),ft()}),100)}),[dt,ht,ft]),os=(0,o.I4)((()=>{ye({id:g,threadId:v,type:"scheduled"})}),[ye,g,v]);(0,o.d4)((()=>{k&&h.wB&&ht()}),[k,ht]),(0,o.d4)((()=>{c&&(A?St():setTimeout((()=>{Mt()}),200))}),[A,Mt,St,c]);const is=!(Ut!==bi.Record||un&&C),rs=(0,o.I4)((()=>{switch(Ut){case bi.Send:Gn();break;case bi.Record:is?C||Te({message:Ae("VoiceMessagesRestrictedByPrivacy",null==y?void 0:y.title)}):Tt();break;case bi.Edit:Ln();break;case bi.Schedule:xt&&Nt(),Qe((e=>{zn({},e)}))}}),[Ut,Gn,Ln,xt,Qe,is,C,Te,Ae,null==y?void 0:y.title,Tt,Nt,zn]),cs=(0,rn.Z)(m,!0),ls=m||cs,ds=new Date;ds.setSeconds(0),ds.setMilliseconds(0);const us=new Date;us.setFullYear(us.getFullYear()+1);let ms="SendMessage";switch(Ut){case bi.Edit:ms="Save edited message";break;case bi.Record:ms=un?"AccDescrVoiceMessage":"Conversation.DefaultRestrictedMedia"}const hs=(0,_e.Z)("Composer",!A&&"shown",Et&&"hover-disabled"),gs=(0,_e.Z)("mobile-symbol-menu-button",!c&&"not-ready",Ct?ut&&"menu-opened":ut&&"is-loading"),ps=(0,o.I4)((()=>{Qe((e=>{zn({},e)}))}),[zn,Qe]),fs=Ut===bi.Edit?Ln:Ut===bi.Schedule?ps:Gn,vs=re&&"commands"===(null==re?void 0:re.type);return o.ZP.createElement("div",{className:hs},un&&c&&o.ZP.createElement(wi,{isOpen:t!==tn.t.None,withQuick:t===tn.t.QuickFile||Fe===tn.t.QuickFile,onHide:u,onFileSelect:Dn}),o.ZP.createElement(fi,{chatId:g,threadId:v,canShowCustomSendMenu:jt,attachments:nt,captionLimit:$,caption:nt.length?Be:"",groupChatMembers:j,currentUserId:q,recentEmojis:J,isReady:c,isChatWithSelf:S,onCaptionUpdate:Ve,baseEmojiKeywords:W,emojiKeywords:X,shouldSchedule:n,onSendSilent:es,onSend:Gn,onSendScheduled:ps,onFileAppend:qn,onClear:$n,shouldSuggestCustomEmoji:_,customEmojiForEmoji:U}),o.ZP.createElement(Ii,{isOpen:B.isOpen,isQuiz:B.isQuiz,shouldBeAnonymous:M,onClear:Ie,onSend:Qn}),ls&&o.ZP.createElement(Go,{isOpen:wt,isSchedule:"scheduled"===I,onClose:Zt,message:ls}),o.ZP.createElement(Zi,{isOpen:gt,onClose:It,chatId:g,selectedSendAsId:se,sendAsPeerIds:je,isCurrentUserPremium:Z}),o.ZP.createElement(ai,{isOpen:Dt,onClose:qt,onInsertUserName:$t,filteredUsers:Gt}),o.ZP.createElement(si,{isOpen:Ht,botId:Vt,isGallery:_t,inlineBotResults:Wt,switchPm:zt,onSelectResult:Yn,loadMore:Yt,onClose:Xt,isSavedMessages:S,canSendGifs:dn,isCurrentUserPremium:Z}),o.ZP.createElement(li,{isOpen:Kt,withUsername:Boolean(ee),botCommands:en,onClick:Kn,onClose:Qt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:Ne}),o.ZP.createElement(pi,{onClear:Un}),o.ZP.createElement(Pi,{chatId:g,threadId:v,messageText:nt.length?"":Be,disabled:!hn}),o.ZP.createElement("div",{className:"message-input-wrapper"},E&&re&&"webApp"===re.type&&!m&&o.ZP.createElement(Ci,{isOpen:!Be&&!xt,onClick:Hn,text:re.text,isDisabled:Boolean(xt)}),E&&vs&&!1!==Q&&!xt&&!m&&o.ZP.createElement(zo,{className:(0,_e.Z)("bot-commands",ct&&"activated"),round:!0,disabled:void 0===Q,color:"translucent",onActivate:Vn,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),De&&(te||ne)&&o.ZP.createElement(Rt.Z,{round:!0,color:"translucent",onClick:gt?It:as,ariaLabel:Ae("SendMessageAsTitle"),className:(0,_e.Z)("send-as-button",tt.current&&"appear-animation")},o.ZP.createElement(jn.Z,{user:te,chat:ne,size:"tiny"})),h.wB?o.ZP.createElement(Rt.Z,{className:gs,round:!0,color:"translucent",onClick:ut?ht:ss,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),ut&&!Ct&&o.ZP.createElement(Bt.Z,{color:"gray"})):o.ZP.createElement(zo,{className:(0,_e.Z)("symbol-menu-button",ut&&"activated"),round:!0,color:"translucent",onActivate:_n,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(ui.Z,{id:"message-input-text",editableInputId:a.R2,chatId:g,threadId:v,html:nt.length?"":Be,placeholder:xt&&Ue<=600?"":L||Ae("Message"),forcedPlaceholder:Jt,canAutoFocus:c&&!nt.length,noFocusInterception:nt.length>0,shouldSuppressFocus:h.wB&&ut,shouldSuppressTextFormatter:Pn||Dt||Ht,onUpdate:Ve,onSend:fs,onSuppressedFocus:ht}),K&&Boolean(Vt)&&o.ZP.createElement(Bt.Z,{color:"gray"}),O&&o.ZP.createElement(Rt.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:os,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),x&&!xt&&!m&&o.ZP.createElement(zo,{className:at?"activated":"",round:!0,color:"translucent",onActivate:ot,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),xt&&Lt&&o.ZP.createElement("span",{className:"recording-state"},(0,z.rM)(Lt-Ft.current)),o.ZP.createElement(ti,{chatId:g,isButtonVisible:!xt&&!m,canAttachMedia:un,canAttachPolls:mn,onFileSelect:Dn,onPollCreate:ve,isScheduled:n,attachBots:ce,peerType:le,theme:de}),x&&o.ZP.createElement(di,{messageId:x,isOpen:at,onClose:rt}),Q&&o.ZP.createElement(vi,{isOpen:ct,botCommands:Q,onClose:dt}),o.ZP.createElement(ri.Z,{chatId:g,isOpen:In,onCustomEmojiSelect:yn,addRecentCustomEmoji:ke}),o.ZP.createElement(ii,{chatId:g,threadId:v,isOpen:fn,onStickerSelect:Xn}),o.ZP.createElement(ci.Z,{isOpen:Pn,emojis:Cn,customEmojis:bn,onClose:Zn,onEmojiSelect:En,addRecentEmoji:Pe,onCustomEmojiSelect:Sn,addRecentCustomEmoji:ke}),o.ZP.createElement(ni,{chatId:g,threadId:v,isOpen:ut||qe,canSendGifs:dn,canSendStickers:ln,onLoad:bt,onClose:ht,onEmojiSelect:kn,onStickerSelect:Xn,onCustomEmojiSelect:Wn,onGifSelect:Jn,onRemoveSymbol:An,onSearchOpen:ns,addRecentEmoji:Pe,addRecentCustomEmoji:ke}))),xt&&o.ZP.createElement(Rt.Z,{round:!0,color:"danger",className:"cancel",onClick:At,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Rt.Z,{ref:Ot,round:!0,color:"secondary",className:(0,_e.Z)(Ut,!c&&"not-ready",xt&&"recording"),disabled:is,allowDisabledClick:!0,ariaLabel:Ae(ms),onClick:rs,onContextMenu:Ut===bi.Send&&jt?an:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-schedule"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),jt&&o.ZP.createElement(oi.Z,{isOpen:nn,onSendSilent:S?void 0:es,onSendSchedule:n?void 0:ps,onClose:on,onCloseAnimationEnd:cn,isSavedMessages:S}),et)}))),Mi=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,lt.Z)(ct.gl.Extra,"MobileSearch",!t,!0);return n?o.ZP.createElement(n,e):void 0})),Ri=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,lt.Z)(ct.gl.Extra,"MessageSelectToolbar",!t);return n?o.ZP.createElement(n,e):void 0})),ki=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"UnpinAllMessagesModal",!t);return n?o.ZP.createElement(n,e):void 0})),Ti=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"SeenByModal",!t);return n?o.ZP.createElement(n,e):void 0})),Ai=(0,o.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,lt.Z)(ct.gl.Extra,"EmojiInteractionAnimation",!t);return n?o.ZP.createElement(n,e):void 0})),Ni=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"ReactorListModal",!t);return n?o.ZP.createElement(n,e):void 0})),Bi=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"GiftPremiumModal",!t);return n?o.ZP.createElement(n,e):void 0})),xi=h.wB?450+a.fK:void 0;function Li(e){return"file"===e.kind&&e.type&&a.oG.has(e.type)}const Oi=(0,o.X$)((0,s.c$)((e=>{var t;const n=(0,c.Pu)(e),{isBlurred:s,background:a,backgroundColor:o,patternColor:r}=e.settings.themes[n]||{},{messageLists:l}=e.messages,u=(0,c.Bt)(e),{isLeftColumnShown:m,chats:{listIds:g},activeEmojiInteractions:p,lastSyncTime:f}=e,v={theme:n,customBackground:a,backgroundColor:o,patternColor:r,isLeftColumnShown:m,isRightColumnShown:(0,c.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(h.wB&&(0,c.n5)(e)),isSelectModeActive:(0,c.CA)(e),isSeenByModalOpen:Boolean(e.seenByModal),isReactorListModalOpen:Boolean(e.reactorModal),isGiftPremiumModalOpen:null===(t=e.giftPremiumModal)||void 0===t?void 0:t.isOpen,animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,l.length-1),activeEmojiInteractions:p,lastSyncTime:f};if(!u||!g.active)return v;const{chatId:I,threadId:w,type:y}=u,P=(0,d.YC)(I),Z=(0,c.Z1)(e,I),C=(0,c.IK)(e,I),b=(0,c.KB)(e,I),{chatId:E,messageId:S}=e.audioPlayer,M=Z&&(0,d.Qm)(Z,w),R=(0,c.pk)(e,I),k="pinned"===y,T="scheduled"===y,A="thread"===y&&w===i._f,N=Boolean(Z&&(0,d.eA)(Z)),B=Boolean(Z&&A&&(N||(0,d.ZV)(Z))&&Z.isNotJoined&&!Z.joinRequests),x=Boolean((null==Z?void 0:Z.isNotJoined)&&Z.isJoinToSend),L=Boolean((null==Z?void 0:Z.isNotJoined)&&Z.isJoinRequest),O=Boolean(C&&(0,c.s4)(e,C.id)),F=!O&&R,U=Boolean(Z&&(0,d.Bf)(Z)&&!Z.fullInfo&&f);return{...v,chatId:I,threadId:w,messageListType:y,isPrivate:P,areChatSettingsLoaded:Boolean(null==Z?void 0:Z.settings),canPost:!k&&(!Z||M)&&!R&&!(x&&null!=Z&&Z.isNotJoined),isPinnedMessageList:k,isScheduledMessageList:T,currentUserBannedRights:null==Z?void 0:Z.currentUserBannedRights,defaultBannedRights:null==Z?void 0:Z.defaultBannedRights,hasPinnedOrAudioPlayer:w!==i._f||Boolean(!k&&(null==b?void 0:b.length))||Boolean(E&&S),pinnedMessagesCount:b?b.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,isChannel:N,canSubscribe:B,canStartBot:F,canRestartBot:O,shouldJoinToSend:x,shouldSendJoinRequest:L,shouldLoadFullChat:U}}))((e=>{let{chatId:t,threadId:n,messageListType:i,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:P,isBackgroundBlurred:Z,isMobileSearchActive:C,isSelectModeActive:b,isSeenByModalOpen:E,isReactorListModalOpen:S,isGiftPremiumModalOpen:M,animationLevel:R,shouldSkipHistoryAnimations:k,currentTransitionKey:T,isChannel:A,areChatSettingsLoaded:N,canSubscribe:B,canStartBot:x,canRestartBot:L,activeEmojiInteractions:O,shouldJoinToSend:F,shouldSendJoinRequest:U,shouldLoadFullChat:j,lastSyncTime:D}=e;const{openChat:q,openPreviousChat:$,unpinAllMessages:G,loadUser:H,loadChatSettings:V,closeLocalTextSearch:_,exitMessageSelectMode:z,joinChannel:W,sendBotCommand:X,restartBot:J,showNotification:Y,loadFullChat:K}=(0,s.Sv)(),{width:Q}=(0,an.Z)(),ee=(0,yt.Z)(),[te,ne]=(0,o.eJ)(tn.t.None),[se,ae]=(0,o.eJ)(),[oe,ie]=(0,o.eJ)(),[re,ce]=(0,o.eJ)(!1),le=g&&(Q<a.l3||P&&Q>a._m&&Q<a.QU||Q>=a.ks&&Q<a.jT),de=(0,on.Z)(t,xi),ue=(0,on.Z)(n,xi),me=(0,on.Z)(i,xi),he=(0,on.Z)(B,xi),ge=(0,on.Z)(x,xi),pe=(0,on.Z)(L,xi),fe=(0,on.Z)(l,xi)&&!pe&&!ge&&!he,ve=(0,on.Z)(le,xi),Ie=(0,on.Z)(se,xi),we=(0,on.Z)(A,xi),Se=(0,on.Z)(F,xi),Me=(0,on.Z)(U,xi),Re=(0,rn.Z)(T),ke=void 0!==Re&&Re<T?Re:void 0,{isReady:Te,handleOpenEnd:Ae,handleSlideStop:Ne}=function(e,t,n,s){const[a,i]=(0,o.eJ)(!h.wB),r=(0,st.Z)(),c=void 0!==n&&n!==t;return c&&(e?i(!1):r()),(0,Ke.Z)((()=>{e||i(!0)}),[e]),{isReady:a&&!c,handleOpenEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&i(Boolean(s))}:void 0,handleSlideStop:e?function(){i(!0)}:void 0}}(!k&&R!==a.oB,T,Re,t);(0,o.d4)((()=>t?(0,pt.Z)((()=>{q({id:void 0})})):void 0),[t,q]),(0,Ke.Z)((()=>{ne(tn.t.None),ae(void 0),ie(void 0)}),[t]),(0,o.d4)((()=>{const{visualViewport:e}=window;if(!e)return;const t=()=>{window.visualViewport.height!==document.documentElement.clientHeight?document.body.classList.add("keyboard-visible"):document.body.classList.remove("keyboard-visible")};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}}),[]),(0,o.d4)((()=>{r&&H({userId:t})}),[t,r,H]),(0,o.d4)((()=>{!N&&D&&V({chatId:t})}),[t,r,N,D,V]),(0,o.d4)((()=>{t&&j&&Te&&K({chatId:t})}),[j,t,Te,K]);const Be=(0,o.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(Li);ne(n?tn.t.QuickFile:tn.t.Document)}),[]),xe=(0,o.I4)((()=>{ne(tn.t.None)}),[]),Le=(0,o.I4)((()=>{ce(!0)}),[]),Oe=(0,o.I4)((()=>{ce(!1)}),[]),Fe=(0,o.I4)((()=>{G({chatId:t}),Oe(),$()}),[G,t,Oe,$]),Ue=(0,o.I4)((()=>{q({id:t})}),[q,t]),je=(0,o.I4)((()=>{W({chatId:t}),Me&&Y({message:ee(A?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[W,t,Me,Y,A,ee]),De=(0,o.I4)((()=>{X({command:"/start"})}),[X]),qe=(0,o.I4)((()=>{J({chatId:t})}),[t,J]),$e=((e,t)=>{const[n,s]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?s(t):nn.fetch(a.fo,e,nn.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,sn.pt)(t).then((()=>{s(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(v,f),Ge=(0,_e.Z)(ve&&"has-header-tools",h.aZ?"mask-image-disabled":"mask-image-enabled"),He=(0,_e.Z)("ON5E8MkEVA1mAlkuIxhG","OWFg9Wf1uioPWDz_IgS8",f&&"Ik9ZZlj3eKtKXRrUZKVk",I&&"avVozLQe3SaWcSkIt6pG",f&&Z&&"Tipa66fYcSvl6w0587Xz",P&&"vhOr8s3T_LCKSt2BF7fs"),Ve=(0,_e.Z)("messaging-disabled",!b&&"shown"),ze=(0,d.q8)(ee,u,m),{composerHiddenScale:We,toolbarHiddenScale:Xe,composerTranslateX:Je,toolbarTranslateX:Ye,unpinHiddenScale:Qe,toolbarForUnpinHiddenScale:et}=(0,o.Ye)((()=>function(e,t){const n=e<=a.l3?ye.Gw:2*ye.Gw,s=function(e){if(e>a._m){const t=Math.min(Math.max(.25*e,be),Ce),n=Math.min(.25*e,Ce);return Math.min(e-t-n,Ze)}if(e>a.ks){const t=Math.min(Math.max(.4*e,be),Ce);return Math.min(e-t,Ze)}return e>Ze?Ze:e}(e),o=e<=a.l3?3.375*ye.Gw:4*ye.Gw,i=t?s-n-o:s-n,r=e>a.l3?Math.min(s-n,Pe):s-n,c=r/i,l=i/r;return{composerHiddenScale:c,toolbarHiddenScale:l,composerTranslateX:t?o/2*l:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:r/Ee,toolbarForUnpinHiddenScale:Ee/r}}(Q,fe)),[fe,Q]),tt=(0,_e.Z)("middle-column-footer",!fe&&"no-composer",fe&&oe&&!b&&"with-notch");(0,Ft.Z)({isActive:b,onBack:z}),(0,Ft.Z)({isActive:C,onBack:_});const nt=Boolean(!c&&!fe&&!pe&&!ge&&!he&&ze),at=Boolean(pe||he||ge||c),ot=Boolean(nt||b||c);return o.ZP.createElement("div",{id:"MiddleColumn",className:Ge,onTransitionEnd:Ae,style:`\n --composer-hidden-scale: ${We};\n --toolbar-hidden-scale: ${Xe};\n --unpin-hidden-scale: ${Qe};\n --toolbar-unpin-hidden-scale: ${et};\n --composer-translate-x: ${Je}px;\n --toolbar-translate-x: ${Ye}px;\n --pattern-color: ${w};\n --theme-background-color:\n ${I||("dark"===v?a.It:a.p3)};\n `,onClick:h.p7&&y?Ue:void 0},o.ZP.createElement("div",{className:He,style:$e?`--custom-background: ${$e}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),de&&ue&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:fe?Be:void 0},o.ZP.createElement(Gn,{chatId:de,threadId:ue,messageListType:me,isReady:Te}),o.ZP.createElement(wt.Z,{name:k?"none":R===a.zy?"slide":"fade",activeKey:T,shouldCleanup:!0,cleanupExceptionKey:ke,onStop:Ne},o.ZP.createElement(eo,{key:`${de}-${ue}-${me}`,chatId:de,threadId:ue,type:me,canPost:fe,hasTools:ve,onFabToggle:ae,onNotchToggle:ie,isReady:Te,withBottomShift:at,withDefaultBg:Boolean(!f&&!I)}),o.ZP.createElement("div",{className:tt},fe&&o.ZP.createElement(Si,{chatId:de,threadId:ue,messageListType:me,dropAreaState:te,onDropHide:xe,isReady:Te}),c&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:ee.isRtl?"rtl":void 0},o.ZP.createElement(Rt.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Le},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,ee("Chat.Pinned.UnpinAll",p,"i")))),nt&&o.ZP.createElement("div",{className:Ve},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,ze))),h.wB&&(he||Se&&!Me)&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:ee.isRtl?"rtl":void 0},o.ZP.createElement(Rt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:je},ee(we?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&Me&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:ee.isRtl?"rtl":void 0},o.ZP.createElement(Rt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:je},ee("ChannelJoinRequest"))),h.wB&&ge&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:ee.isRtl?"rtl":void 0},o.ZP.createElement(Rt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:De},ee("BotStart"))),h.wB&&pe&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:ee.isRtl?"rtl":void 0},o.ZP.createElement(Rt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:qe},ee("BotRestart"))),o.ZP.createElement(Ri,{messageListType:me,isActive:b,canPost:fe}),o.ZP.createElement(Ti,{isOpen:E}),o.ZP.createElement(Ni,{isOpen:S}))),o.ZP.createElement(no,{isShown:Ie,canPost:fe,withExtraShift:ot})),h.wB&&o.ZP.createElement(Mi,{isActive:Boolean(C)})),t&&o.ZP.createElement(ki,{isOpen:re,chatId:t,pinnedMessagesCount:p,onClose:Oe,onUnpin:Fe}),o.ZP.createElement("div",{teactFastList:!0},null==O?void 0:O.map(((e,t)=>o.ZP.createElement(Ai,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))),o.ZP.createElement(Bi,{isOpen:M}))}))),Fi=450+a.fK,Ui=(0,T.Ds)((e=>e()),200,!1);var ji;!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"}(ji||(ji={}));const Di=(0,o.X$)((0,s.c$)(((e,t)=>{var n,s,a,o;let{chatId:i,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=i?(0,c.Z1)(e,i):void 0,p=g&&(0,d.eA)(g),f=r&&i&&(0,d.YC)(i)?(0,c.dy)(e,i):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(i&&(null===(n=e.management.byChatId[i])||void 0===n?void 0:n.editingInvite)),y=null==g||null===(s=g.fullInfo)||void 0===s?void 0:s.canViewStatistics,P=i?null===(a=e.management.byChatId[i])||void 0===a||null===(o=a.inviteInfo)||void 0===o?void 0:o.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:P,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}))((e=>{var t;let{chatId:n,isColumnOpen:a,isProfile:i,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:P,isChannel:Z,onClose:C,onScreenSelect:b,messageSearchQuery:E,stickerSearchQuery:S,gifSearchQuery:M,isEditingInvite:R,canViewStatistics:k,currentInviteInfo:T,shouldSkipHistoryAnimations:A}=e;const{setLocalTextSearchQuery:N,setStickerSearchQuery:B,setGifSearchQuery:x,searchTextMessagesLocal:L,toggleManagement:O,openHistoryCalendar:F,openAddContactDialog:U,toggleStatistics:j,setEditingExportedInvite:D,deleteExportedChatInvite:q}=(0,s.Sv)(),[$,G,H]=(0,vt.Z)(),V=(0,o.I4)((()=>{D({chatId:n,invite:T}),b(m.u1.EditInvite)}),[n,T,b,D]),_=(0,o.I4)((()=>{q({chatId:n,link:T.link}),b(m.u1.Invites),H()}),[n,H,T,q,b]),W=(0,o.I4)((e=>{N({query:e}),e.length&&Ui(L)}),[L,N]),X=(0,o.I4)((e=>{B({query:e})}),[B]),J=(0,o.I4)((e=>{x({query:e})}),[x]),Y=(0,o.I4)((()=>{U({userId:y})}),[U,y]),[K,Q]=(0,o.eJ)(!a);(0,o.d4)((()=>{setTimeout((()=>{Q(!a)}),Fi)}),[a]);const ee=(0,yt.Z)(),te=i?v===m.vi.Profile?ji.Profile:v===m.vi.SharedMedia?ji.SharedMedia:v===m.vi.MemberList?ji.MemberList:-1:r?ji.Search:p?ji.PollResults:u?ji.StickerSearch:g?ji.GifSearch:f?ji.AddingMembers:c?I===m.u1.Initial?ji.ManageInitial:I===m.u1.ChatPrivacyType?ji.ManageChatPrivacyType:I===m.u1.Discussion?ji.ManageDiscussion:I===m.u1.ChannelSubscribers?ji.ManageChannelSubscribers:I===m.u1.GroupPermissions?ji.ManageGroupPermissions:I===m.u1.ChatAdministrators?ji.ManageChatAdministrators:I===m.u1.GroupRemovedUsers?ji.ManageGroupRemovedUsers:I===m.u1.ChannelRemovedUsers?ji.ManageChannelRemovedUsers:I===m.u1.GroupUserPermissionsCreate?ji.ManageGroupUserPermissionsCreate:I===m.u1.GroupUserPermissions?ji.ManageGroupUserPermissions:I===m.u1.GroupRecentActions?ji.ManageGroupRecentActions:I===m.u1.ChatAdminRights?ji.ManageGroupAdminRights:I===m.u1.ChatNewAdminRights?ji.ManageGroupNewAdminRights:I===m.u1.GroupMembers?ji.ManageGroupMembers:I===m.u1.Invites?ji.ManageInvites:I===m.u1.EditInvite?ji.ManageEditInvite:I===m.u1.GroupAddAdmins?ji.ManageGroupAddAdmins:I===m.u1.Reactions?ji.ManageReactions:I===m.u1.InviteInfo?ji.ManageInviteInfo:I===m.u1.JoinRequests?ji.ManageJoinRequests:void 0:l?ji.Statistics:d?ji.MessageStatistics:void 0,ne=null!==(t=(0,dn.Z)(te,!0))&&void 0!==t?t:-1,se=h.wB||te===ji.SharedMedia||te===ji.MemberList||te===ji.AddingMembers||te===ji.MessageStatistics||c,ae=(0,_e.Z)("animated-close-icon",se&&"state-back",(K||A)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(Rt.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:C,ariaLabel:ee(se?"Common.Back":"Common.Close")},o.ZP.createElement("div",{className:ae})),o.ZP.createElement(wt.Z,{name:K||A?"none":"slide-fade",activeKey:ne},function(){if(-1!==ne)switch(ne){case ji.PollResults:return o.ZP.createElement("h3",null,ee("PollResults"));case ji.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(kt.Z,{parentContainerClassName:"RightSearch",value:E,onChange:W}),o.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>F({selectedAt:(0,z._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case ji.AddingMembers:return o.ZP.createElement("h3",null,ee(Z?"ChannelAddSubscribers":"GroupAddMembers"));case ji.ManageInitial:return o.ZP.createElement("h3",null,ee("Edit"));case ji.ManageChatPrivacyType:return o.ZP.createElement("h3",null,ee(Z?"ChannelTypeHeader":"GroupTypeHeader"));case ji.ManageDiscussion:return o.ZP.createElement("h3",null,ee("Discussion"));case ji.ManageChatAdministrators:return o.ZP.createElement("h3",null,ee("ChannelAdministrators"));case ji.ManageGroupRecentActions:return o.ZP.createElement("h3",null,ee("Group.Info.AdminLog"));case ji.ManageGroupAdminRights:return o.ZP.createElement("h3",null,ee("EditAdminRights"));case ji.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,ee("SetAsAdmin"));case ji.ManageGroupPermissions:return o.ZP.createElement("h3",null,ee("ChannelPermissions"));case ji.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,ee("BlockedUsers"));case ji.ManageChannelRemovedUsers:return o.ZP.createElement("h3",null,ee("ChannelBlockedUsers"));case ji.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,ee("ChannelAddException"));case ji.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,ee("UserRestrictions"));case ji.ManageInvites:return o.ZP.createElement("h3",null,ee("lng_group_invite_title"));case ji.ManageEditInvite:return o.ZP.createElement("h3",null,ee(R?"EditLink":"NewLink"));case ji.ManageInviteInfo:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,ee("InviteLink")),o.ZP.createElement("section",{className:"tools"},T&&!T.isRevoked&&o.ZP.createElement(Rt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("Edit"),onClick:V},o.ZP.createElement("i",{className:"icon-edit"})),T&&T.isRevoked&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Rt.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:ee("Delete"),onClick:G},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(wn.Z,{isOpen:$,onClose:H,title:ee("DeleteLink"),text:ee("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:ee("Delete"),confirmHandler:_}))));case ji.ManageJoinRequests:return o.ZP.createElement("h3",null,ee(Z?"SubscribeRequests":"MemberRequests"));case ji.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,ee("Channel.Management.AddModerator"));case ji.StickerSearch:return o.ZP.createElement(kt.Z,{value:S,placeholder:ee("SearchStickersHint"),autoFocusSearch:!0,onChange:X});case ji.GifSearch:return o.ZP.createElement(kt.Z,{value:M,placeholder:ee("SearchGifsTitle"),autoFocusSearch:!0,onChange:J});case ji.Statistics:return o.ZP.createElement("h3",null,ee(Z?"ChannelStats.Title":"GroupStats.Title"));case ji.MessageStatistics:return o.ZP.createElement("h3",null,ee("Stats.MessageTitle"));case ji.SharedMedia:return o.ZP.createElement("h3",null,ee("SharedMedia"));case ji.ManageChannelSubscribers:return o.ZP.createElement("h3",null,ee("ChannelSubscribers"));case ji.MemberList:case ji.ManageGroupMembers:return o.ZP.createElement("h3",null,ee("GroupMembers"));case ji.ManageReactions:return o.ZP.createElement("h3",null,ee("Reactions"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},w&&o.ZP.createElement(Rt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("AddContact"),onClick:Y},o.ZP.createElement("i",{className:"icon-add-user"})),P&&o.ZP.createElement(Rt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("Edit"),onClick:O},o.ZP.createElement("i",{className:"icon-edit"})),k&&o.ZP.createElement(Rt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ee("Statistics"),onClick:j},o.ZP.createElement("i",{className:"icon-stats"}))))}}()))})));var qi=n(91),$i=n(3474),Gi=n(27407);function Hi(e,t,n,s){const[o,i]=(0,Gi.Z)(n?t:void 0,s,void 0,a.Vk);return[o,i,!(!o||!s||o[0]===s[0])]}function Vi(e,t,n,s,i,r){const c=(0,o.sO)();(0,Ke.Z)((()=>{t===e&&i&&r&&(c.current=(0,d.R5)(i,r,e))}),[i,r,t,e]);const[l,u]=(0,Gi.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 _i=(0,T.P2)((e=>e()),250,!1);let zi=!1;var Wi=n(21273),Xi=n(31876),Ji=n(20787),Yi=n(70180),Ki=n(13709),Qi=n(45418),er=n(47262),tr=n(41151),nr=n(22275);const sr=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function ar(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const or=(0,o.X$)((0,s.c$)(((e,t)=>{var n,s,a;let{chatId:o}=t;const i=(0,c.Z1)(e,o),r=(0,c.Zw)(e,o),{currentType:l,resultsByType:u}=(0,c.we)(e)||{},{foundIds:m}=u&&l&&u[l]||{},{byId:h,statusesById:g}=e.users,{byId:p}=e.chats,f=i&&(0,d.Bf)(i),v=i&&(0,d.eA)(i),I=f||v&&(0,d.Nl)(i),w=null==i||null===(n=i.fullInfo)||void 0===n?void 0:n.members,y=null==i||null===(s=i.fullInfo)||void 0===s?void 0:s.adminMembersById,P=I&&i&&(i.isForbidden||i.fullInfo&&!i.fullInfo.canViewMembers),Z=I&&i&&((0,d.VE)(i,"inviteUsers")||!(0,d.Mg)(i,"inviteUsers")||i.isCreator),C=I&&i&&((0,d.VE)(i,"banUsers")||i.isCreator),b=(0,c.xs)(e,o);let E,S,M;return(0,d.YC)(o)&&(S=o,M=(0,c.dy)(e,S),E=M&&!M.isSelf&&!(0,d.cS)(M)),{theme:(0,c.Pu)(e),isChannel:v,resolvedUserId:S,chatMessages:r,foundIds:m,mediaSearchType:l,hasCommonChatsTab:E,hasMembersTab:I,areMembersHidden:P,canAddMembers:Z,canDeleteMembers:C,currentUserId:e.currentUserId,isRightColumnShown:(0,c.Jf)(e),isRestricted:null==i?void 0:i.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:b,usersById:h,userStatusesById:g,chatsById:p,isChatProtected:null==i?void 0:i.isProtected,...I&&w&&{members:w,adminMembersById:y},...E&&M&&{commonChatIds:null===(a=M.commonChats)||void 0===a?void 0:a.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:P,canDeleteMembers:Z,commonChatIds:C,members:b,adminMembersById:E,usersById:S,userStatusesById:M,chatsById:R,isRightColumnShown:k,isRestricted:T,lastSyncTime:A,activeDownloadIds:N,serverTimeOffset:B,isChatProtected:x}=e;const{setLocalMediaSearchType:L,loadMoreMembers:O,loadCommonChats:F,openChat:U,searchMediaMessagesLocal:j,openMediaViewer:D,openAudioPlayer:q,focusMessage:$,loadProfilePhotos:G,setNewChatMembersDialogState:H}=(0,s.Sv)(),V=(0,o.sO)(null),_=(0,o.sO)(null),z=(0,yt.Z)(),[W,X]=(0,o.eJ)(0),[J,Y]=(0,o.eJ)(),K=(0,o.Ye)((()=>[...w?[{type:"members",title:l?"ChannelSubscribers":"GroupMembers"}]:[],...sr,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,w,l]),Q=K[W].type,[ee,te,ne,se]=function(e,t,n,s,a,i,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&&i?i:a,w=(0,o.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,o.Ye)((()=>{if(c&&m)return(0,d.ih)(c,m,!0)}),[m,c]),[P,Z,C]=Hi(0,t,f,w),[b,E,S]=Vi("media",I,s,f,h,g),[M,R,k]=Vi("documents",I,s,f,h,g),[T,A,N]=Vi("links",I,s,f,h,g),[B,x,L]=Vi("audio",I,s,f,h,g),[O,F,U]=Vi("voice",I,s,f,h,g),[j,D,q]=Hi(0,n,f,y);let $,G,H=!1;switch(I){case"members":$=P,G=Z,H=C;break;case"commonChats":$=j,G=D,H=q;break;case"media":$=b,G=E,H=S;break;case"documents":$=M,G=R,H=k;break;case"links":$=T,G=A,H=N;break;case"audio":$=B,G=x,H=L;break;case"voice":$=O,G=F,H=U}return[I,$,G,H]}(k,O,F,j,Q,v,b,C,S,M,R,p,f,t,A,B),ae=K.findIndex((e=>{let{type:t}=e;return t===ee})),{handleScroll:oe}=function(e,t,n,s){(0,Xe.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),zi=!0,(0,Wn.Z)(n,a,"start",void 0,void 0,void 0,300),setTimeout((()=>{zi=!1}),350))}}),[t,s]),(0,Xe.Z)((t=>{let[a]=t;if(n!==m.vi.Profile||n===a)return;const o=e.current;if(!o)return;const i=o.querySelector(".TabList");!i||i.offsetTop>o.scrollTop||(zi=!0,(0,Wn.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{zi=!1}),350),s(n))}),[n]);const a=(0,o.I4)((()=>{const n=e.current;if(!n)return;const a=n.querySelector(".TabList");if(!a)return;let o=m.vi.Profile;n.scrollTop>=a.offsetTop&&(o="members"===t?m.vi.MemberList:m.vi.SharedMedia),s(o)}),[e,s,t]);return(0,o.d4)((()=>{zi||a()}),[a,t]),{handleScroll:(0,o.I4)((()=>{zi||_i(a)}),[a])}}(V,Q,n,r),{applyTransitionFix:ie,releaseTransitionFix:re}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,o.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,o.I4)((()=>{const t=e.current;if("hidden"!==t.style.overflowY){const e=t.offsetWidth-t.clientWidth;t.style.overflowY="hidden",t.style.marginRight=`${e}px`}}),[e]),s=(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e]);return{applyTransitionFix:n,releaseTransitionFix:s}}(V),[ce,le]=(0,$i.Z)(),{observe:de}=(0,Kn.S1)({rootRef:V,throttleMs:500}),ue=(0,o.I4)((()=>{re(),le()}),[re,le]),me=(0,o.I4)((()=>{H(m.WB.InProgress)}),[H]);(0,o.d4)((()=>{L({mediaType:Q})}),[L,Q]);const he=u||t;(0,o.d4)((()=>{A&&G({profileId:he})}),[G,he,A]);const ge=(0,o.I4)((e=>{D({chatId:he,threadId:i._f,mediaId:e,origin:m.bZ.SharedMedia})}),[he,D]),pe=(0,o.I4)((e=>{q({chatId:he,messageId:e})}),[he,q]),fe=(0,o.I4)((e=>{U({id:e})}),[U]),ve=(0,o.I4)((e=>{$({chatId:he,messageId:e})}),[he,$]),Ie=(0,o.I4)((()=>{Y(void 0)}),[]);let we;(0,o.d4)((()=>{if(_.current&&h.$b)return(0,Ot.sf)(_.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Ot.eM.Left?(X(Math.min(W+1,K.length-1)),!0):t===Ot.eM.Right&&(X(Math.max(0,W-1)),!0)})}),[W,K.length]);const ye="members"===ee||!w&&"media"===ee;ye?we=k?0:1e3:te||(we=a.Y);const Pe=(0,mi.Z)([t,ee],we);return o.ZP.createElement(Wi.Z,{ref:V,className:"Profile custom-scroll",itemSelector:ar(ee),items:Pe?te:void 0,cacheBuster:ce,sensitiveArea:a.qU,preloadBackwards:Pe?"members"===ee?a.Vk:a.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:ne,onScroll:oe},!se&&function(e,t,n){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Ji.Z,{userId:t||e,canPlayVideo:n}),o.ZP.createElement(Yi.Z,{chatOrUserId:t||e}))}(t,u,k&&Pe),!T&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(wt.Z,{ref:_,name:z.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ae,renderCount:K.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:ie,onStop:ue},function(){if(!te||!Pe||!p){const e=ye&&!Pe,t=Boolean("members"===ee&&y);return o.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&o.ZP.createElement(Bt.Z,null),t&&o.ZP.createElement(er.Z,{text:"You have no access to group members list."}))}if(!te.length){let e;switch(ee){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 o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(er.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${ee}-list`,dir:z.isRtl&&"media"===ee?"rtl":void 0,teactFastList:!0},"media"===ee?te.map((e=>p[e]&&o.ZP.createElement(Ki.Z,{key:e,message:p[e],isProtected:x||p[e].isProtected,observeIntersection:de,onClick:ge}))):"documents"===ee?te.map((e=>p[e]&&o.ZP.createElement(Ss.Z,{key:e,message:p[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:N.includes(e),observeIntersection:de,onDateClick:ve}))):"links"===ee?te.map((e=>p[e]&&o.ZP.createElement(Qi.Z,{key:e,message:p[e],isProtected:x||p[e].isProtected,observeIntersection:de,onMessageClick:ve}))):"audio"===ee?te.map((e=>p[e]&&o.ZP.createElement(Ms.ZP,{key:e,theme:c,message:p[e],origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:A,className:"scroll-item",onPlay:pe,onDateClick:ve,canDownload:!x&&!p[e].isProtected,isDownloading:N.includes(e)}))):"voice"===ee?te.map((e=>p[e]&&o.ZP.createElement(Ms.ZP,{key:e,theme:c,message:p[e],senderTitle:(0,qi.F)(z,p[e],R,S),origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:A,className:"scroll-item",onPlay:pe,onDateClick:ve,canDownload:!x&&!p[e].isProtected,isDownloading:N.includes(e)}))):"members"===ee?te.map(((e,t)=>{return o.ZP.createElement(Xi.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>fe(e),contextActions:(n=e,n!==g&&Z?[{title:z("lng_context_remove_from_group"),icon:"stop",handler:()=>{Y(n)}}]:void 0)},o.ZP.createElement(un.Z,{userId:e,adminMember:null==E?void 0:E[e],forceShowSelf:!0}));var n})):"commonChats"===ee?te.map(((e,t)=>o.ZP.createElement(Xi.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>U({id:e})},o.ZP.createElement(mn.Z,{chatId:e})))):void 0)}()),o.ZP.createElement(Ut.Z,{big:!0,activeTab:W,tabs:K,onSwitchTab:X})),P&&o.ZP.createElement(tr.Z,{isShown:"members"===ee,onClick:me,ariaLabel:z("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),Z&&o.ZP.createElement(nr.Z,{isOpen:Boolean(J),userId:J,onClose:Ie}))}))),ir=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)})),rr=(0,o.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)})),cr=e=>{const t=(0,lt.Z)(ct.gl.Extra,"Statistics");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)},lr=e=>{const t=(0,lt.Z)(ct.gl.Extra,"MessageStatistics");return t?o.ZP.createElement(t,e):o.ZP.createElement(qt.Z,null)},dr=(0,o.X$)((()=>{const e=(0,lt.Z)(ct.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qt.Z,null)})),ur=(0,o.X$)((()=>{const e=(0,lt.Z)(ct.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qt.Z,null)})),mr=(0,o.X$)((()=>{const e=(0,lt.Z)(ct.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(qt.Z,null)}));var hr=n(11820);const gr=(0,o.X$)((0,s.c$)(((e,t)=>{var n;let{chatId:s}=t;const a=(0,c.Z1)(e,s),{userIds:o}=e.contactList||{},{byId:i}=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:i,localContactIds:o,searchQuery:h,isSearching:g,isLoading:l===m.WB.Loading,globalUserIds:p,localUserIds:f}}))((e=>{let{isChannel:t,members:n,onNextStep:a,currentUserId:i,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,yt.Z)(),[y,P]=(0,o.eJ)([]),Z=(0,rn.Z)(y)===y;(0,Ft.Z)({isActive:v,onBack:f});const C=(0,o.Ye)((()=>n?n.map((e=>e.userId)):[]),[n]),b=(0,o.I4)((e=>{I({query:e})}),[I]),E=(0,o.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!==i&&(!s||!(0,d.cS)(s)||!t&&s.canBeInvitedToGroup)})),r)}),[c,r,u,h,p,i,C,t]),S=(0,o.I4)((()=>{y.length&&(I({query:""}),a(y))}),[y,I,a]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(hr.Z,{itemIds:E,selectedIds:y,filterValue:u,filterPlaceholder:w("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:m,onSelectedIdsChange:P,onFilterChange:b,noScrollRestore:Z}),o.ZP.createElement(tr.Z,{isShown:Boolean(y.length),disabled:l,ariaLabel:w("lng_channel_add_users"),onClick:S},l?o.ZP.createElement(Bt.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),pr=450+a.fK,fr=Object.keys(m.qt).length/2,vr=Object.keys(m.u1).length/2;function Ir(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const wr=(0,o.X$)((0,s.c$)((e=>{var t;const{chatId:n,threadId:s}=(0,c.Bt)(e)||{},a=(0,c.g4)(e),o=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:o}}))((e=>{var t;let{contentKey:n,chatId:i,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:P,toggleMessageStatistics:Z,setOpenedInviteInfo:C,requestNextManagementScreen:b}=(0,s.Sv)(),{width:E}=(0,an.Z)(),[S,M]=(0,o.eJ)(m.vi.Profile),[R,k]=(0,o.eJ)(m.u1.Initial),[T,A]=(0,o.eJ)(),[N,B]=(0,o.eJ)(),x=S!==m.vi.Profile,L=void 0!==n,O=n===m.qt.ChatInfo,F=n===m.qt.Search,U=n===m.qt.Management,j=n===m.qt.Statistics,D=n===m.qt.MessageStatistics,q=n===m.qt.StickerSearch,$=n===m.qt.GifSearch,G=n===m.qt.PollResults,H=n===m.qt.AddingMembers,V=E<=a._m,[_,z]=(0,o.eJ)(!L),W=null!==(t=(0,dn.Z)(n,!0,!c))&&void 0!==t?t:-1,X=(0,o.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){M(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),A(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:i,invite:void 0})}break;case m.qt.MessageStatistics:Z();break;case m.qt.Statistics:P();break;case m.qt.Search:Ir(),g();break;case m.qt.StickerSearch:Ir(),p({query:void 0});break;case m.qt.GifSearch:Ir(),f({query:void 0});break;case m.qt.PollResults:v()}}),[n,x,u,v,w,R,h,g,p,f,y,i,C,P,Z]),J=(0,o.I4)(((e,t)=>{A(e),B(t)}),[]),Y=(0,o.I4)((e=>{I({chatId:i,memberIds:e})}),[I,i]);function K(e){if(-1!==W)switch(W){case m.qt.AddingMembers:return o.ZP.createElement(gr,{key:i,chatId:i,isActive:L&&e,onNextStep:Y,onClose:X});case m.qt.ChatInfo:return o.ZP.createElement(or,{key:i,chatId:i,profileState:S,onProfileStateChange:M});case m.qt.Search:return o.ZP.createElement(ir,{chatId:i,threadId:r,onClose:X,isActive:L&&e});case m.qt.Management:return o.ZP.createElement(rr,{key:i,chatId:i,currentScreen:R,isPromotedByCurrentUser:N,selectedChatMemberId:T,isActive:L&&e,onScreenSelect:k,onChatMemberSelect:J,onClose:X});case m.qt.Statistics:return o.ZP.createElement(cr,{chatId:i});case m.qt.MessageStatistics:return o.ZP.createElement(lr,{chatId:i,isActive:L&&e});case m.qt.StickerSearch:return o.ZP.createElement(dr,{onClose:X,isActive:L&&e});case m.qt.GifSearch:return o.ZP.createElement(ur,{onClose:X,isActive:L&&e});case m.qt.PollResults:return o.ZP.createElement(mr,{onClose:X,isActive:L&&e})}}return(0,o.d4)((()=>L?(0,pt.Z)(X):void 0),[L,X]),(0,o.d4)((()=>{setTimeout((()=>{z(!L)}),pr)}),[L]),(0,o.d4)((()=>{d&&(k(d),b(void 0))}),[d,b]),(0,o.d4)((()=>{L&&V&&X()}),[V]),(0,Yn.Z)((e=>{let[t]=e;t!==i&&(M(m.vi.Profile),k(m.u1.Initial))}),[i]),(0,Ft.Z)({isActive:c&&(n===m.qt.ChatInfo||n===m.qt.Management||n===m.qt.AddingMembers),onBack:()=>X(!1)}),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:c?void 0:"is-hidden"},V&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:X}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(Di,{chatId:i,isColumnOpen:L,isProfile:O,isSearch:F,isManagement:U,isStatistics:j,isMessageStatistics:D,isStickerSearch:q,isGifSearch:$,isPollResults:G,isAddingChatMembers:H,profileState:S,managementScreen:R,onClose:X,onScreenSelect:k}),o.ZP.createElement(wt.Z,{name:_||l?"none":"zoom-fade",renderCount:fr+vr,activeKey:U?fr+R:W,shouldCleanup:!0,cleanupExceptionKey:W===m.qt.MessageStatistics?m.qt.Statistics:void 0},K)))}))),yr=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,lt.Z)(ct.gl.Extra,"MediaViewer",!t);return n?o.ZP.createElement(n,null):void 0}));let Pr=[],Zr=!1;function Cr(e,t){Pr.push({url:e,filename:t}),Zr||(Zr=!0,setTimeout((async()=>{await async function(){let e=0;for(const t of Pr)br(t),e++,10===e&&(await(0,T.wO)(1e3),e=0);Pr=[]}(),Zr=!1}),1e3))}function br(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,Sr=new Set,Mr=(0,o.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,Xn.Z)(1e3,!0),l=(0,o.I4)((e=>{Sr.add(e),c((()=>{Sr.size&&(a({messages:Array.from(Sr)}),Sr.clear())}))}),[a,c]);(0,o.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=Ie.UV(n);if(s)return Cr(s,(0,d.w6)(e)),void l(e);const{document:a,video:o,audio:c}=e.content;if(((null===(t=a||o||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");Ie.he(n,u,!0).then((t=>{if(u===i.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&&Cr(t,(0,d.w6)(e));l(e)}))})):Er.clear()}),[n,t,a,l,r])})));var Rr=n(13103);const kr=(0,o.X$)((0,s.c$)(((e,t)=>{let{openedGame:n}=t;const{chatId:s}=n||{},a=s&&(0,c.Z1)(e,s);return{canPost:Boolean(a)&&(0,d.Qm)(a,i._f)}}))((e=>{let{openedGame:t,gameTitle:n,canPost:s}=e;const{closeGame:a,openForwardMenu:i}=(0,Y.Sv)(),r=(0,yt.Z)(),{url:c,chatId:l,messageId:d}=t||{},u=Boolean(c),m=(0,fo.Z)(l);(0,it.Z)((()=>{m({type:"playingGame"})}),u&&s?5e3:void 0);const h=(0,o.I4)((e=>{try{const t=JSON.parse(e.data);"share_score"===t.eventType&&(i({fromChatId:l,messageIds:[d],withMyScore:!0}),a()),"share_game"===t.eventType&&(i({fromChatId:l,messageIds:[d]}),a())}catch(e){}}),[l,a,d,i]),g=(0,o.I4)((e=>{e.currentTarget.focus()}),[]);return(0,o.d4)((()=>(window.addEventListener("message",h),()=>window.removeEventListener("message",h))),[h]),(0,o.d4)((()=>{if(u)return Se.Z.disableRefresh(),()=>{Se.Z.enableRefresh()}}),[u]),o.ZP.createElement(Rr.Z,{className:"GameModal",isOpen:u,onClose:a,title:n,hasCloseButton:!0},u&&o.ZP.createElement("iframe",{className:"game-frame",onLoad:g,src:c,title:r("AttachGame"),sandbox:"allow-scripts allow-same-origin allow-orientation-lock",allow:"fullscreen"}))}))),Tr=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,lt.Z)(ct.gl.Extra,"Notifications",!t);return n?o.ZP.createElement(n,null):void 0})),Ar=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,lt.Z)(ct.gl.Extra,"Dialogs",!t);return n?o.ZP.createElement(n,null):void 0})),Nr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"ForwardRecipientPicker",!t);return n?o.ZP.createElement(n,e):void 0})),Br=(0,o.X$)((e=>{const{url:t}=e,n=(0,lt.Z)(ct.gl.Extra,"SafeLinkModal",!t);return n?o.ZP.createElement(n,e):void 0})),xr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"HistoryCalendar",!t);return n?o.ZP.createElement(n,e):void 0})),Lr=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,lt.Z)(ct.gl.Calls,"GroupCall",!t);return n?o.ZP.createElement(n,e):void 0})),Or=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,lt.Z)(ct.gl.Calls,"ActiveCallHeader",!t);return n?o.ZP.createElement(n,null):void 0})),Fr=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,lt.Z)(ct.gl.Calls,"PhoneCall",!t);return n?o.ZP.createElement(n,null):void 0}));function Ur(){return Ur=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},Ur.apply(this,arguments)}const jr=(0,o.X$)((0,Y.c$)((e=>({messageLists:e.messages.messageLists})))((e=>{let{messageLists:t}=e;const{openChat:n}=(0,Y.Sv)(),s=()=>{n({id:void 0},{forceSyncOnIOs:!0})},a=e=>{let{chatId:t,type:n,threadId:a}=e;(0,Ft.Z)({isActive:!0,hash:(0,rt.q2)(t,n,a),onBack:s})};return o.ZP.createElement("div",null,null==t?void 0:t.map(((e,t)=>o.ZP.createElement(a,Ur({key:`${e.chatId}_${e.threadId}_${e.type}_${t}`},e)))))}))),Dr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"NewContactModal",!t);return n?o.ZP.createElement(n,e):void 0})),qr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Calls,"RatePhoneCallModal",!t);return n?o.ZP.createElement(n,e):void 0})),$r=(0,o.X$)((e=>{const{webApp:t}=e,n=(0,lt.Z)(ct.gl.Extra,"WebAppModal",!t);return n?o.ZP.createElement(n,e):void 0})),Gr=(0,o.X$)((e=>{const{bot:t}=e,n=(0,lt.Z)(ct.gl.Extra,"BotTrustModal",!t);return n?o.ZP.createElement(n,e):void 0})),Hr=(0,o.X$)((e=>{const{bot:t}=e,n=(0,lt.Z)(ct.gl.Extra,"AttachBotInstallModal",!t);return n?o.ZP.createElement(n,e):void 0})),Vr={root:"vfd0Bo1X6k19aaxQ577t"},_r=h.wB?50:100,zr=["#E8BC2C","#D0049E","#02CBFE","#5723FD","#FE8C27","#6CB859"],Wr=(0,o.X$)((0,s.c$)((e=>(0,g.ei)(e,["confetti"])))((e=>{let{confetti:t}=e;const n=(0,o.sO)(null),s=(0,o.sO)([]),a=(0,o.sO)(!1),i=(0,an.Z)(),r=(0,st.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:o,height:i}=e;t.clearRect(0,0,o,i);const r=[];s.current.forEach(((e,n)=>{const{pos:a,velocity:o,size:c,color:l,flicker:d,flickerFrequency:u,rotation:m,lastDrawnAt:h,frameCount:g}=e,p=(Date.now()-h)/1e3,f={x:a.x+o.x*p,y:a.y+o.y*p},v={x:.98*o.x,y:o.y+=1e3*p},I=c*Math.abs(Math.sin(g*u)),w=5*g*u*(Math.PI/180),y=g+1,P=Date.now();if(f.y>i+e.size)return void r.push(e);const Z={...e,pos:f,velocity:v,flicker:I,rotation:w,lastDrawnAt:P,frameCount:y};s.current[n]=Z,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,Ke.Z)((e=>{let t,[n]=e;return n!==c&&(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_r;for(let a=0;a<n;a++){const n=a%2,o={x:e*(n?-.1:1.1),y:.75*t},i=Math.random()*e*1.5,r={x:n?i:-1*i,y:-t/2-Math.random()*t},c=zr[Math.floor(Math.random()*zr.length)],l=10;s.current.push({pos:o,size:l,color:c,velocity:r,flicker:l,flickerFrequency:.2*Math.random(),rotation:0,lastDrawnAt:Date.now(),frameCount:0})}}(d||i.width,m||i.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,Fs.Z)(Boolean(l)&&`top: ${l}px`,Boolean(u)&&`left: ${u}px`,Boolean(d)&&`width: ${d}px`,Boolean(m)&&`height: ${m}px`);return o.ZP.createElement("div",{id:"Confetti",className:Vr.root,style:g},o.ZP.createElement("canvas",{ref:n,className:Vr.canvas,width:i.width,height:i.height}))}))),Xr=(0,o.X$)((e=>{const{urlAuth:t}=e,n=(0,lt.Z)(ct.gl.Extra,"UrlAuthModal",!t);return n?o.ZP.createElement(n,e):void 0})),Jr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"PremiumMainModal",!t);return n?o.ZP.createElement(n,e):void 0})),Yr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"PaymentModal",!t);return n?o.ZP.createElement(n,e):void 0})),Kr=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"ReceiptModal",!t);return n?o.ZP.createElement(n,e):void 0})),Qr=(0,o.X$)((e=>{const{limit:t}=e,n=(0,lt.Z)(ct.gl.Extra,"PremiumLimitReachedModal",!t);return n?o.ZP.createElement(n,e):void 0})),ec=(0,o.X$)((e=>{const{deleteFolderDialogId:t}=e,n=(0,lt.Z)(ct.gl.Extra,"DeleteFolderDialog",!t);return n?o.ZP.createElement(n,e):void 0})),tc=(0,o.X$)((e=>{const{customEmojiSetIds:t}=e,n=(0,lt.Z)(ct.gl.Extra,"CustomEmojiSetsModal",!t);return n?o.ZP.createElement(n,e):void 0})),nc=(0,o.X$)((e=>{const{requestedDraft:t}=e,n=(0,lt.Z)(ct.gl.Extra,"DraftRecipientPicker",!t);return n?o.ZP.createElement(n,e):void 0})),sc=(0,o.X$)((e=>{const{requestedAttachBotInChat:t}=e,n=(0,lt.Z)(ct.gl.Extra,"AttachBotRecipientPicker",!t);return n?o.ZP.createElement(n,e):void 0}));let ac,oc=!1;function ic(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 rc(e){document.title!==e&&(document.title=e)}const cc=(0,o.X$)((0,s.c$)((e=>{var t,n,s,a,o;const{settings:{byKey:{animationLevel:i,language:r,wasTimeFormatSetManually:l}},botTrustRequest:d,requestedAttachBotInstall:u,requestedAttachBotInChat:m,requestedDraft:h,urlAuth:g,webApp:p,safeLinkModalUrl:f,lastSyncTime:v,openedStickerSetShortName:I,openedCustomEmojiSetIds:w,shouldSkipHistoryAnimations:y}=e,{chatId:P,messageId:Z}=e.audioPlayer,C=P&&Z?(0,c.hj)(e,P,Z):void 0,b=e.openedGame,E=b&&(0,c.hj)(e,b.chatId,b.messageId),S=null==E||null===(t=E.content.game)||void 0===t?void 0:t.title,M=e.currentUserId?(0,c.dy)(e,e.currentUserId):void 0;return{lastSyncTime:v,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:C,safeLinkModalUrl:f,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:y,openedStickerSetShortName:I,openedCustomEmojiSetIds:w,isServiceChatReady:(0,c.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:i,language:r,wasTimeFormatSetManually:l,isPhoneCallActive:Boolean(e.phoneCall),addedSetIds:e.stickers.added.setIds,addedCustomEmojiIds:e.customEmojis.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:b,gameTitle:S,isRatePhoneCallModalOpen:Boolean(e.ratingPhoneCall),botTrustRequest:d,botTrustRequestBot:d&&(0,c.dy)(e,d.botId),attachBotToInstall:u&&(0,c.dy)(e,u.botId),requestedAttachBotInChat:m,webApp:p,currentUser:M,urlAuth:g,isPremiumModalOpen:null===(a=e.premiumModal)||void 0===a?void 0:a.isOpen,limitReached:null===(o=e.limitReachedModal)||void 0===o?void 0:o.limit,isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),deleteFolderDialogId:e.deleteFolderDialogModal,requestedDraft:h}}))((e=>{let{lastSyncTime:t,isLeftColumnOpen:n,isRightColumnOpen:i,isMediaViewerOpen:r,isForwardModalOpen:c,hasNotifications:l,hasDialogs:d,audioMessage:u,activeGroupCallId:m,safeLinkModalUrl:g,isHistoryCalendarOpen:p,shouldSkipHistoryAnimations:f,limitReached:v,openedStickerSetShortName:I,openedCustomEmojiSetIds:w,isServiceChatReady:y,animationLevel:P,language:Z,wasTimeFormatSetManually:C,addedSetIds:b,addedCustomEmojiIds:E,isPhoneCallActive:S,newContactUserId:M,newContactByPhoneNumber:R,openedGame:k,gameTitle:A,isRatePhoneCallModalOpen:N,botTrustRequest:B,botTrustRequestBot:x,attachBotToInstall:L,requestedAttachBotInChat:O,requestedDraft:F,webApp:U,currentUser:j,urlAuth:D,isPremiumModalOpen:q,isPaymentModalOpen:$,isReceiptModalOpen:G,deleteFolderDialogId:H}=e;const{loadAnimatedEmojis:V,loadNotificationSettings:_,loadNotificationExceptions:z,updateIsOnline:W,loadTopInlineBots:X,loadEmojiKeywords:J,loadCountryList:Y,loadAvailableReactions:Q,loadStickerSets:ee,loadPremiumGifts:te,loadAddedStickers:ne,loadFavoriteStickers:se,ensureTimeFormat:ae,closeStickerSetModal:oe,closeCustomEmojiSets:ie,checkVersionNotification:re,loadAppConfig:ce,loadAttachBots:le,loadContactList:de,loadCustomEmojis:ue,closePaymentModal:me,clearReceipt:he,checkAppVersion:ge,openChat:pe}=(0,s.Sv)();a.eM&&!oc&&(oc=!0,console.log(">>> RENDER MAIN")),(0,it.Z)(ge,3e5,!0),(0,o.d4)((()=>{t&&(W(!0),ce(),Q(),V(),_(),z(),X(),J({language:a.pR}),le(),de(),te(),ge())}),[t,V,J,z,_,X,W,Q,ce,le,de,te,ge]),(0,o.d4)((()=>{t&&(Z!==a.pR&&J({language:Z}),Y({langCode:Z}))}),[Z,t,Y,J]),(0,Xe.Z)((e=>{let[n]=e;!n&&t&&ue({ids:Object.keys((0,s.Rd)().customEmojis.byId),ignoreCache:!0})}),[t]),(0,o.d4)((()=>{t&&(b&&E||(ee(),se()),b&&E&&ne())}),[t,b,ee,se,ne,E]),(0,o.d4)((()=>{t&&y&&re()}),[t,y,re]),(0,o.d4)((()=>{t&&!C&&ae()}),[t,C,ae]),(0,o.d4)((()=>{const e=(0,rt.dx)();t&&null!=e&&e.tgaddr&&(0,We.ou)(decodeURIComponent(e.tgaddr))}),[t]),(0,Xe.Z)((e=>{let[n]=e;const s=(0,rt.VX)();s&&!n&&t&&pe({id:s.chatId,threadId:s.threadId,type:s.type})}),[t]),(0,o.d4)((()=>{if(m||S)return Se.Z.disableRefresh(),()=>{Se.Z.enableRefresh()}}),[m,S]);const fe=(0,at.Z)(n,void 0,!0,void 0,f),ve=(0,o.sO)(!1),Ie=(0,st.Z)();(0,Ke.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;ve.current=!0,h.wZ&&(0,T.T2)((()=>{document.body.classList.toggle("android-left-blackout-open",!n)}));const s=(0,ot.YW)();(0,ze.L)(document.getElementById("MiddleColumn"),(()=>{s(),ve.current=!1,Ie()}))}),[n]);const we=(0,at.Z)(i,void 0,!0,void 0,f),ye=(0,o.sO)(!1),[Pe,Ze]=(0,o.eJ)(i);(0,Ke.Z)((e=>{let[t]=e;if(void 0===t)return;if(0===P)return void Ze(i);ye.current=!0;const n=(0,ot.YW)();(0,ze.L)(document.getElementById("RightColumn"),(()=>{n(),ye.current=!1,Ie(),Ze(i)}))}),[i]);const Ce=(0,_e.Z)(fe.hasShownClass&&"left-column-shown",fe.hasOpenClass&&"left-column-open",ve.current&&"left-column-animating",we.hasShownClass&&"right-column-shown",we.hasOpenClass&&"right-column-open",ye.current&&"right-column-animating",Pe&&"narrow-message-list",f&&"history-animation-disabled"),be=(0,o.I4)((()=>{W(!1);const e=(0,K.xW)();let t=0;clearInterval(ac),ac=window.setInterval((()=>{if(document.title.includes(a.ou))ic(!1);else{if(t%2==0){const t=(0,K.xW)()-e;t>0&&(rc(`${t} notification${t>1?"s":""}`),ic(!0))}else rc(a.Ti),ic(!1);t++}}),1e3)}),[W]),Ee=(0,o.I4)((()=>{W(!0),clearInterval(ac),ac=void 0,document.title.includes(a.ou)||rc(a.Ti),ic(!1)}),[W]),Me=(0,o.I4)((()=>{oe()}),[oe]),Re=(0,o.I4)((()=>{ie()}),[ie]);return(0,Je.Z)(be,Ee),Ye(be),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,o.d4)((()=>{if(h.$b){if(!e)return null==Qe||Qe.setAttribute("content",et),h.cj&&!h.fl&&document.addEventListener("gesturestart",nt),()=>{null==Qe||Qe.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",nt)};null==Qe||Qe.setAttribute("content",tt)}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:Ce},o.ZP.createElement(en,null),o.ZP.createElement(Oi,null),o.ZP.createElement(wr,null),o.ZP.createElement(yr,{isOpen:r}),o.ZP.createElement(Nr,{isOpen:c}),o.ZP.createElement(nc,{requestedDraft:F}),o.ZP.createElement(Tr,{isOpen:l}),o.ZP.createElement(Ar,{isOpen:d}),u&&o.ZP.createElement(Un,{key:u.id,message:u,noUi:!0}),o.ZP.createElement(Br,{url:g}),o.ZP.createElement(Xr,{urlAuth:D,currentUser:j}),o.ZP.createElement(xr,{isOpen:p}),o.ZP.createElement(dt,{isOpen:Boolean(I),onClose:Me,stickerSetShortName:I}),o.ZP.createElement(tc,{customEmojiSetIds:w,onClose:Re}),m&&o.ZP.createElement(Lr,{groupCallId:m}),o.ZP.createElement(Or,{isActive:Boolean(m||S)}),o.ZP.createElement(Dr,{isOpen:Boolean(M||R),userId:M,isByPhoneNumber:R}),o.ZP.createElement(kr,{openedGame:k,gameTitle:A}),o.ZP.createElement($r,{webApp:U}),o.ZP.createElement(Mr,null),o.ZP.createElement(Wr,null),o.ZP.createElement(Fr,{isActive:S}),o.ZP.createElement(gt,{isForAppBadge:!0}),o.ZP.createElement(qr,{isOpen:N}),o.ZP.createElement(Gr,{bot:x,type:null==B?void 0:B.type}),o.ZP.createElement(Hr,{bot:L}),o.ZP.createElement(sc,{requestedAttachBotInChat:O}),o.ZP.createElement(jr,null),q&&o.ZP.createElement(Jr,{isOpen:q}),o.ZP.createElement(Qr,{limit:v}),o.ZP.createElement(Yr,{isOpen:$,onClose:me}),o.ZP.createElement(Kr,{isOpen:G,onClose:he}),o.ZP.createElement(ec,{deleteFolderDialogId:H}))})));var lc=n(99364),dc=n(8337);var uc=n(2092);const mc=(0,o.X$)((0,s.c$)((e=>({passcodeSettings:e.passcode})))((e=>{let{isLocked:t,passcodeSettings:n}=e;const{unlockScreen:a,signOut:i,logInvalidUnlockAttempt:r,resetInvalidUnlockAttempts:c}=(0,s.Sv)(),{invalidAttemptsCount:l,isLoading:d}=n,u=(0,yt.Z)(),[m,h]=(0,o.eJ)(""),[g,p]=(0,o.eJ)(!1),[f,v,I]=(0,vt.Z)(!1),{shouldRender:w}=(0,at.Z)(t);(0,wa.Z)(c,l&&l>=5?18e4:void 0);const y=(0,o.I4)((()=>{h("")}),[]),P=(0,o.I4)((e=>{l&&l>=5?h(u("FloodWait")):(h(""),(0,R.so)(e).then(a,(()=>{r(),h(u("lng_passcode_wrong"))})))}),[l,u,r,a]);(0,o.d4)((()=>{l&&l>=5?h(u("FloodWait")):0===l&&h("")}),[l,u]);const Z=(0,o.I4)((()=>{I(),i()}),[I,i]);if(w)return o.ZP.createElement("div",{className:"sY59IPNwkaRsrfYPhEJc"},o.ZP.createElement("div",{className:"DlErQEIDwmZ0duQgO_2b",dir:u.isRtl?"rtl":void 0},o.ZP.createElement(Ds.Z,{tgsUrl:Ls.l.Lock,previewUrl:uc,size:160,className:"ar9YdQbWJreREHmnZa9m"}),o.ZP.createElement(lc.Z,{key:"password-form",shouldShowSubmit:!0,shouldDisablePasswordManager:!0,isLoading:d,error:m,placeholder:u("Passcode.EnterPasscodePlaceholder"),submitLabel:u("Next"),clearError:y,isPasswordVisible:g,noRipple:!0,onChangePasswordVisibility:p,onSubmit:P}),o.ZP.createElement("div",{className:"uOmdTQr_cJEvuTkQipx7"},o.ZP.createElement("p",null,o.ZP.createElement(dc.Z,{onClick:v},"Log out")," ","if you don't remember your passcode."),o.ZP.createElement("p",null,o.ZP.createElement(Rt.Z,{color:"translucent",size:"tiny",isText:!0,onClick:v},u("AccountSettings.Logout"))))),o.ZP.createElement(wn.Z,{isOpen:f,onClose:I,text:u("lng_sure_logout"),confirmLabel:u("AccountSettings.Logout"),confirmHandler:Z,confirmIsDestructive:!0}))})));a.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE");const{connectionState:hc,passcode:{isScreenLocked:gc}}=(0,s.Rd)();hc||gc||(0,s.Sv)().initApi()},68973:(e,t,n)=>{e.exports=n.p+"encoderWorker.min.8ea62f6317fbac7d4558.js"}}]);
|
||
//# sourceMappingURL=5769.bf4c5eb4786c6535f3ed.js.map
|