"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),i=n(14050),o=(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:i}=n,o=(0,d.uw)(s,a),{query:u}=e.localTextSearch.byChatThreadKey[o]||{};return i!==u&&(e=(0,r.Pb)(e,s,a,l.D)),(0,r.qr)(e,s,a,!0,i)})),(0,s.iw)("setLocalMediaSearchType",((e,t,n)=>{const{chatId:s}=(0,c.Bt)(e)||{};if(!s)return;const{mediaType:a}=n;return(0,r.z5)(e,s,a)})),(0,s.iw)("openChat",((e,t,n)=>{var s,a;const{id:i,threadId:l=o._f,type:d="thread",shouldReplaceHistory:m=!1}=n,h=(0,c.Bt)(e);return null!==(s=e.premiumModal)&&void 0!==s&&s.promo&&null!==(a=e.premiumModal)&&void 0!==a&&a.isOpen&&(e={...e,premiumModal:{...e.premiumModal,isOpen:!1}}),h&&h.chatId===i&&h.threadId===l&&h.type===d||(i&&(e=(0,r.pf)(e,i,l,"replyStack",[])),e=u(e=(0,r.i9)(e)),e={...e,isStatisticsShown:!1,messages:{...e.messages,contentToBeScheduled:void 0},...i!==e.forwardMessages.toChatId&&{forwardMessages:{}}}),(0,r.Wy)(e,i,l,d,m)})),(0,s.iw)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,s.iw)("openChatWithInfo",((e,t,n)=>{(0,s.R3)({...e,isChatInfoShown:!0}),t.openChat(n)})),(0,s.iw)("openChatWithDraft",((e,t,n)=>{const{chatId:s,text:a,files:i}=n;return s&&t.openChat({id:s}),{...e,requestedDraft:{chatId:s,text:a,files:i}}})),(0,s.iw)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,s.iw)("setNewChatMembersDialogState",((e,t,n)=>({...e,newChatMembersProgress:n}))),(0,s.iw)("openNextChat",((e,t,n)=>{const{targetIndexDelta:s,orderedIds:a}=n,{chatId:i}=(0,c.Bt)(e)||{};if(!i)return void t.openChat({id:a[0]});const o=a.indexOf(i);if(-1===o)return;const r=a[o+s];t.openChat({id:r,shouldReplaceHistory:!0})})),(0,s.iw)("openDeleteChatFolderModal",((e,t,n)=>{const{folderId:s}=n;return{...e,deleteFolderDialogModal:s}})),(0,s.iw)("closeDeleteChatFolderModal",(e=>({...e,deleteFolderDialogModal:void 0})));var m=n(91713),h=n(77361),g=n(60782),p=n(82267),f=n(83099),v=n(50711),I=n(64319),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)||{},i=v.i0,o="scheduled"===s?(0,c.Fn)(e,t):(0,c.Zw)(e,t);if(!o||!a)return;const r=n.map((e=>o[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)(i,s):""}:`),t.push(`${function(e,t){var n;const s=(0,y.Eb)(t),a=s?`${s} `:"",i=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,i,!0,!0)}`}(i,n)}\n`),t}),[]),u=r.reduce(((t,n)=>{const s=(0,c.Ur)(e,n);return t.push(`> ${s?(0,d.OU)(i,s):""}:`),t.push(`${(0,d.MK)(i,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:i}=n;return(0,r.pf)(e,s,a,"scrollOffset",i)})),(0,s.iw)("setReplyingToId",((e,t,n)=>{const{messageId:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:i,threadId:o}=a;return(0,r.pf)(e,i,o,"replyingToId",s)})),(0,s.iw)("setEditingId",((e,t,n)=>{const{messageId:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:i,threadId:o,type:l}=a,d="scheduled"===l?"editingScheduledId":"editingId";return(0,r.pf)(e,i,o,d,s)})),(0,s.iw)("setEditingDraft",((e,t,n)=>{const{text:s,chatId:a,threadId:i,type:o}=n,c="scheduled"===o?"editingScheduledDraft":"editingDraft";return(0,r.pf)(e,a,i,c,s)})),(0,s.iw)("editLastMessage",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{};if(!t||!n)return;const s=(0,c.Zw)(e,t),a=(0,c.Cb)(e,t,n);if(!s||!a)return;const i=(0,g.dF)(a,(t=>Boolean(s[t]&&(0,c._k)(e,s[t],n).canEdit)));return i?(0,r.pf)(e,t,n,"editingId",i):void 0})),(0,s.iw)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:s}=n,{chatId:a,threadId:i}=(0,c.Bt)(e)||{};if(!a||!i)return;const r=(0,c.Zw)(e,a),l=(0,c.Cb)(e,a,i);if(!r||!l)return;const d=(0,c.Yy)(e,a,i);let u;if((0,c.b9)(e,a,i)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+s;u=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(i===o._f){var m;const t=(0,c.Z1)(e,a);u=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,c.tZ)(e,a,i);u=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:u}),t.focusMessage({chatId:a,threadId:i,messageId:u})})),(0,s.iw)("openAudioPlayer",((e,t,n)=>{const{chatId:s,threadId:a,messageId:i,origin:o,volume:r,playbackRate:c,isMuted:l}=n;return{...e,audioPlayer:{chatId:s,threadId:a,messageId:i,origin:null!=o?o:e.audioPlayer.origin,volume:null!=r?r:e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:l||e.audioPlayer.isMuted}}})),(0,s.iw)("setAudioPlayerVolume",((e,t,n)=>{const{volume:s}=n;return{...e,audioPlayer:{...e.audioPlayer,volume:s,isMuted:!1}}})),(0,s.iw)("setAudioPlayerPlaybackRate",((e,t,n)=>{const{playbackRate:s}=n;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:s}}})),(0,s.iw)("setAudioPlayerMuted",((e,t,n)=>{const{isMuted:s}=n;return{...e,audioPlayer:{...e.audioPlayer,isMuted:s}}})),(0,s.iw)("setAudioPlayerOrigin",((e,t,n)=>{const{origin:s}=n;return{...e,audioPlayer:{...e.audioPlayer,origin:s}}})),(0,s.iw)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,s.iw)("openPollResults",((e,t,n)=>{const{chatId:a,messageId:i}=n;if((0,c.Jf)(e)){if(a!==e.pollResults.chatId||i!==e.pollResults.messageId)return{...e,pollResults:{chatId:a,messageId:i,voters:{}}}}else window.setTimeout((()=>{e=(0,s.Rd)(),(0,s.R3)({...e,pollResults:{chatId:a,messageId:i,voters:{}}})}),450)})),(0,s.iw)("closePollResults",(e=>({...e,pollResults:{}}))),(0,s.iw)("focusLastMessage",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:s,threadId:a}=n;let i;if(a===o._f){var r;const t=(0,c.Z1)(e,s);i=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,c.tZ)(e,s,a);i=null==t?void 0:t.lastMessageId}i&&t.focusMessage({chatId:s,threadId:a,messageId:i,noHighlight:!0})})),(0,s.iw)("focusNextReply",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:a,threadId:i}=n,o=(0,c.p9)(e,a,i);if(o&&0!==o.length){const n=o.pop();e=(0,r.pf)(e,a,i,"replyStack",[...o]),(0,s.R3)(e),t.focusMessage({chatId:a,threadId:i,messageId:n})}else t.focusLastMessage()})),(0,s.iw)("focusMessage",((e,t,n)=>{const{chatId:a,threadId:i=o._f,messageListType:l="thread",noHighlight:d,groupedId:u,groupedChatId:h,replyMessageId:g,isResizingContainer:p,shouldReplaceHistory:f}=n;let{messageId:v}=n;if(void 0!==u){const t=(0,c.y8)(e,h,u);null!=t&&t.length&&([v]=t)}const I=(0,c.Bt)(e),w=!I||a!==I.chatId||i!==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,i)||[];e=(0,r.pf)(e,a,i,"replyStack",[...t,g])}w&&(e=(0,r.wV)(e,m.fo.Static));const y=(0,c.Cb)(e,a,i);if(y&&y.includes(v))return(0,s.R3)(e),void t.openChat({id:a,threadId:i,shouldReplaceHistory:f});if(w&&(e=(0,r.pf)(e,a,i,"viewportIds",void 0)),e=(0,r.pf)(e,a,i,"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:i,shouldReplaceHistory:f}),t.loadViewportMessages()})),(0,s.iw)("openForwardMenu",((e,t,n)=>{const{fromChatId:s,messageIds:a,groupedId:i,withMyScore:o}=n;let r;return i&&(r=(0,c.xH)(e,s,i)),{...e,forwardMessages:{fromChatId:s,messageIds:r||a,isModalShown:!0,withMyScore:o}}})),(0,s.iw)("changeForwardRecipient",(e=>({...e,forwardMessages:{...e.forwardMessages,toChatId:void 0,isModalShown:!0,noAuthors:!1,noCaptions:!1}}))),(0,s.iw)("setForwardNoAuthors",((e,t,n)=>({...e,forwardMessages:{...e.forwardMessages,noAuthors:n,noCaptions:n&&e.forwardMessages.noCaptions}}))),(0,s.iw)("setForwardNoCaptions",((e,t,n)=>({...e,forwardMessages:{...e.forwardMessages,noCaptions:n,noAuthors:n}}))),(0,s.iw)("exitForwardMode",(e=>{(0,s.R3)({...e,forwardMessages:{}})})),(0,s.iw)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:s}=e.selectedMessages;t.openForwardMenu({fromChatId:n,messageIds:s})})),(0,s.iw)("cancelMessageMediaDownload",((e,t,n)=>{const{message:a}=n,i=e.activeDownloads.byChatId[a.chatId];i&&i.length&&(0,s.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:i.filter((e=>e!==a.id))}}})})),(0,s.iw)("cancelMessagesMediaDownload",((e,t,n)=>{const{messages:s}=n,a=e.activeDownloads.byChatId,i={};return Object.keys(a).forEach((e=>{i[e]=a[e].filter((e=>!s.find((t=>t.id===e))))})),{...e,activeDownloads:{byChatId:i}}})),(0,s.iw)("downloadMessageMedia",((e,t,n)=>{const{message:a}=n;(0,s.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:[...e.activeDownloads.byChatId[a.chatId]||[],a.id]}}})})),(0,s.iw)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:s}=e.selectedMessages,{threadId:a}=(0,c.Bt)(e)||{},i=(0,c.Zw)(e,n);i&&a&&s.map((e=>i[e])).filter((t=>(0,c._k)(e,t,a).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,s.iw)("enterMessageSelectMode",((e,t,n)=>{const{messageId:s}=n||{},a=(0,c.jr)(e);return a?(0,r.M6)(e,a.id,s):e})),(0,s.iw)("toggleMessageSelection",((e,t,n)=>{const{messageId:a,groupedId:i,childMessageIds:o,withShift:l}=n,d=(0,c.Bt)(e);if(!d)return;const{chatId:u,threadId:m,type:g}=d;e=(0,r.Ob)(e,u,m,g,a,i,o,l),(0,s.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${h.$b?"long tap":"right click"} on a message.`}))})),(0,s.iw)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,s.iw)("exitMessageSelectMode",r.i9),(0,s.iw)("openPollModal",((e,t,n)=>{const{isQuiz:s}=n||{};return{...e,pollModal:{isOpen:!0,isQuiz:s}}})),(0,s.iw)("closePollModal",(e=>({...e,pollModal:{isOpen:!1}}))),(0,s.iw)("checkVersionNotification",((e,t)=>{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 i={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:i,version:n})})),(0,s.iw)("createServiceNotification",((e,t,n)=>{var i;const{message:o,version:r}=n,{serviceNotifications:l}=e,d=(0,c.Z1)(e,a.aw),u=Math.max((null===(i=d.lastMessage)||void 0===i?void 0:i.id)||0,...l.map((e=>{let{id:t}=e;return t}))),m=(l.length+1)/1e3,h=Math.floor(u)+m;o.previousLocalId=o.id,o.id=h;const g={id:h,message:o,version:r,isUnread:!0};(0,s.R3)({...e,serviceNotifications:[...l.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:o.id,chatId:o.chatId,message:o})})),(0,s.iw)("openReactorListModal",((e,t,n)=>{const{chatId:s,messageId:a}=n;return{...e,reactorModal:{chatId:s,messageId:a}}})),(0,s.iw)("closeReactorListModal",(e=>({...e,reactorModal:void 0}))),(0,s.iw)("openSeenByModal",((e,t,n)=>{const{chatId:s,messageId:a}=n;return{...e,seenByModal:{chatId:s,messageId:a}}})),(0,s.iw)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,s.iw)("copySelectedMessages",(e=>{if(!e.selectedMessages)return;const{chatId:t,messageIds:n}=e.selectedMessages;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 i=a.filter((e=>e!==s));return i.unshift(s),i.length>10&&i.pop(),(0,r.No)(e,{recentlyFoundChatIds:i})})),(0,s.iw)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,s.iw)("setGlobalSearchContent",((e,t,n)=>{const{content:s}=n;return(0,r.Og)(e,s)})),(0,s.iw)("setGlobalSearchChatId",((e,t,n)=>{const{id:s}=n;return(0,r.No)(e,{chatId:s,query:void 0,resultsByType:void 0})})),(0,s.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:s}=n;return{...e,stickers:{...e.stickers,search:{query:s,resultIds:void 0}}}})),(0,s.iw)("setGifSearchQuery",((e,t,n)=>{const{query:s}=n;return{...e,gifs:{...e.gifs,search:{query:s,offsetId:void 0,results:void 0}}}})),(0,s.iw)("setUserSearchQuery",((e,t,n)=>{const{query:s}=n;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(s),query:s})})),(0,s.iw)("openAddContactDialog",((e,t,n)=>{const{userId:s}=n;return{...e,newContact:{userId:s}}})),(0,s.iw)("openNewContactDialog",(e=>({...e,newContact:{isByPhoneNumber:!0}}))),(0,s.iw)("closeNewContactDialog",(e=>(0,r.ft)(e))),n(73456);var 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 i=a.filter((e=>e!==s));return i.unshift(s),i.length>32&&i.pop(),{...e,recentEmojis:i}})),(0,s.iw)("addRecentSticker",((e,t,n)=>{const{sticker:s}=n,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[s]}}};const i=a.stickers.filter((e=>e.id!==s.id));return i.unshift(s),{...e,stickers:{...e.stickers,recent:{...a,stickers:i}}}})),(0,s.iw)("addRecentCustomEmoji",((e,t,n)=>{const{documentId:s}=n,{recentCustomEmojis:a}=e;if(!a)return{...e,recentCustomEmojis:[s]};const i=a.filter((e=>e!==s));return i.unshift(s),i.length>32&&i.pop(),{...e,recentCustomEmojis:i}})),(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],i=a.findIndex((e=>e.message===s.message));return-1!==i&&a.splice(i,1),a.push(s),{...e,notifications:a}})),(0,s.iw)("dismissNotification",((e,t,n)=>{const s=e.notifications.filter((e=>{let{localId:t}=e;return t!==n.localId}));return{...e,notifications:s}})),(0,s.iw)("showDialog",((e,t,n)=>{const{data:s}=n;if("message"in s&&s.hasErrorKey&&!(0,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:i,messageId:o}=n,r=(0,c.hj)(e,i,o);if(!r)return;const l=r.viaBotId||r.senderId;l&&((0,c.LM)(e,l)?(0,s.R3)({...e,openedGame:{url:a,chatId:i,messageId:o}}):(0,s.R3)({...e,botTrustRequest:{botId:l,type:"game",onConfirm:{action:"openGame",payload:n}}}))})),(0,s.iw)("closeGame",(e=>({...e,openedGame:void 0}))),(0,s.iw)("requestConfetti",((e,t,n)=>{const{top:s,left:a,width:i,height:o}=n||{},{animationLevel:r}=e.settings.byKey;if(0!==r)return{...e,confetti:{lastConfettiTime:Date.now(),top:s,left:a,width:i,height:o}}})),(0,s.iw)("openLimitReachedModal",((e,t,n)=>{const{limit:s}=n;return{...e,limitReachedModal:{limit:s}}})),(0,s.iw)("closeLimitReachedModal",(e=>({...e,limitReachedModal:void 0}))),(0,s.iw)("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:i}=e.customEmojis;return{...e,customEmojis:{...e.customEmojis,lastRendered:(0,g.Tw)([...i,...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:i,avatarOwnerId:o,profilePhotoIndex:r,origin:c,volume:l,playbackRate:d,isMuted:u}=n;return{...e,mediaViewer:{...e.mediaViewer,chatId:s,threadId:a,mediaId:i,avatarOwnerId:o,profilePhotoIndex:r,origin:c,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),N=n(69118),T=n(35369);let A=!1;(0,N.Gq)((()=>{(0,s.Rd)().passcode.hasPasscode&&!A&&(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 i=JSON.stringify({...(0,M.K8)(),userId:e.currentUserId}),o=(0,k.Uf)((0,r.vu)((0,s.Rd)(),{hasPasscode:!0,error:void 0,isLoading:!1}));await(0,R.H4)(i,o),(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:i}=n;const o=JSON.parse(a);(0,M.wX)(o,o.userId),e=JSON.parse(i),(0,k.nE)(e,(0,g.Xh)(T.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",(()=>{A=!0})),n(65456);var x=n(27225),B=n(71226),L=n(81396);const O=new Map,U=(0,N.Ds)((e=>e()),500,!1);async function F(e,t,n,i){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const d=e.id;let u;switch(i){case m.Uq.Backwards:u=void 0;break;case m.Uq.Around:u=-(Math.round(a.hT/2)+1);break;case m.Uq.Forwards:u=-(a.hT+1)}const h=await(0,B.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=o?(0,r.ff)(w,d,t,C):(0,r.xj)(w,d,t,C),w=(0,r.Sh)(w,(0,g.ee)(f,"id")),w=(0,r.fZ)(w,(0,g.ee)(v,"id")),w=(0,r.j6)(w,d,I);let b=(0,c.gb)(w,d,t);const E=(0,c.qC)(w,d,t);if(o&&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),o=!1)),!l){const e=o?E:b,{newViewportIds:s}=j(e,n,i);w=(0,r.y9)(w,d,t,s)}(0,s.R3)(w)}function j(e,t,n){const{length:s}=e,i=t?function(e,t){return te[e.length-1]?e.length-1:e.findIndex(((n,s)=>n===t||nt))}(e,t):-1,o=n===m.Uq.Backwards?i:i+1||s,r=o-a.hT,c=o+a.hT-1,l=e.slice(Math.max(0,r),c+1);let d,u;switch(n){case m.Uq.Backwards:d=o>0,u=r>=0;break;case m.Uq.Forwards:d=o0,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 i=(0,s.Rd)();(0,s.R3)({...i,fileUploads:{byMessageLocalId:{...i.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,N.Pn)();const a=(0,s.Rd)();e.serverTimeOffset=a.serverTimeOffset;const i=(0,c.Bt)(a);if(!i)return;const{threadId:r}=i;e.replyingTo||r===o._f||(e.replyingTo=(0,c.qS)(a,e.chat.id,r)),e.replyingTo&&!e.replyingToTopId&&r!==o._f&&(e.replyingToTopId=(0,c.qS)(a,e.chat.id,r)),await(0,B.t9)("sendMessage",e,n),n&&t&&O.delete(t)}(0,s.iw)("loadViewportMessages",((e,t,n)=>{const{direction:s=m.Uq.Around,isBudgetPreload:i=!1}=n||{};let{chatId:o,threadId:l}=n||{};if(!o){const t=(0,c.Bt)(e);if(!t)return;o=t.chatId,l=t.threadId}const d=(0,c.Z1)(e,o);if(!d||d.isRestricted)return;const u=(0,c.Cb)(e,o,l),h=(0,c.gb)(e,o,l),g=(0,c.qC)(e,o,l);if(u&&u.length&&s!==m.Uq.Around){const n=s===m.Uq.Backwards?u[0]:u[u.length-1],a=Boolean(g),c=a?g:h,{newViewportIds:p,areSomeLocal:f,areAllLocal:v}=j(c,n,s);if(f&&(e=(0,r.y9)(e,o,l,p)),(0,N.R3)((()=>{!async function(e,t,n,s,a,i,o,r){t||await F(a,i,r,o,n,s),s||e.loadViewportMessages({chatId:a.id,threadId:i,direction:o,isBudgetPreload:!0})}(t,v,a,i,d,l,s,n)})),i)return}else{const t=(0,c.G$)(e,o)||(0,c.rd)(e,o,l),n=Boolean(t&&h&&!h.includes(t)),s=(n?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=j(s,t,m.Uq.Around);p&&u.length>=a.hT&&(e=(0,r.y9)(e,o,l,u)),f||(0,N.R3)((()=>{F(d,l,t,m.Uq.Around,n,i)}))}return e})),(0,s.iw)("loadMessage",(async(e,t,n)=>{const{chatId:a,messageId:i,replyOriginForId:l,threadUpdate:d}=n,u=(0,c.Z1)(e,a);if(!u)return;const m=await async function(e,t,n){const a=await(0,B.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===o._Q){if(n){let t=(0,s.Rd)();const a=(0,c.hj)(t,e.id,n);t=(0,r.cY)(t,e.id,n,{...a,replyToMessageId:void 0}),(0,s.R3)(t)}return}let i=(0,s.Rd)();return i=(0,r.cY)(i,e.id,t,a.message),i=(0,r.Sh)(i,(0,g.ee)(a.users,"id")),(0,s.R3)(i),a.message}(u,i,l);if(m&&d){const{lastMessageId:e,isDeleting:t}=d;(0,s.R3)((0,r.lG)((0,s.Rd)(),m,a,e,t))}})),(0,s.iw)("sendMessage",((e,t,n)=>{const s=(0,c.Bt)(e);if(!s)return;const{chatId:i,threadId:o,type:r}=s;if("scheduled"===r&&!n.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:n}};const l=(0,c.Z1)(e,i),d={...n,chat:l,replyingTo:(0,c.Yy)(e,i,o),noWebPage:(0,c.tV)(e,i,o),sendAs:(0,c._5)(e,i)};t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i,threadId:o,value:!1});const u=!n.attachments||n.attachments.length<=1,m=!u&&n.attachments&&n.attachments.length>1;if(u){const{attachments:e,...t}=d;D({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:n,...s}=d,i=(0,g.Vl)(n,a.DU);for(let n=0;n0?r:void 0}),o.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:i}=n,o=(0,c.Bt)(e);if(!o)return;const{chatId:r,threadId:l,type:d}=o,u=(0,c.Z1)(e,r),m=(0,c.kK)(e,r,l,d);u&&m&&((0,B.t9)("editMessage",{chat:u,message:m,text:a,entities:i,noWebPage:(0,c.tV)(e,r,l),serverTimeOffset:s}),t.setEditingId({messageId:void 0}))})),(0,s.iw)("cancelSendingMessage",((e,t,n)=>{const{chatId:s,messageId:a}=n,i=(0,c.hj)(e,s,a),o=i&&O.get((0,d.KK)(i));o&&(0,B.u3)(o),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:s})})),(0,s.iw)("saveDraft",(async(e,t,n)=>{const{chatId:a,threadId:i,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)||(i===o._f&&(await(0,B.t9)("saveDraft",{chat:h,text:u,entities:m,replyToMsgId:(0,c.Yy)(e,a,i)})||(l.isLocal=!0)),e=(0,s.Rd)(),e=(0,r.pf)(e,a,i,"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:i}=n;if(!(0,c.Ms)(e,s,a))return;const l=(0,c.Z1)(e,s);return i||a!==o._f||(0,B.t9)("clearDraft",l),e=(0,r.pf)(e,s,a,"draft",void 0),(0,r.a4)(e,s,{draftDate:void 0})})),(0,s.iw)("toggleMessageWebPage",((e,t,n)=>{const{chatId:s,threadId:a,noWebPage:i}=n;return(0,r.pf)(e,s,a,"noWebPage",i)})),(0,s.iw)("pinMessage",((e,t,n)=>{const s=(0,c.jr)(e);if(!s)return;const{messageId:a,isUnpin:i,isOneSide:o,isSilent:r}=n;(0,B.t9)("pinMessage",{chat:s,messageId:a,isUnpin:i,isOneSide:o,isSilent:r})})),(0,s.iw)("unpinAllMessages",((e,t,n)=>{const a=(0,c.Z1)(e,n.chatId);a&&async function(e){await(0,B.t9)("unpinAllMessages",{chat:e});let t=(0,s.Rd)();t=(0,r.pf)(t,e.id,o._f,"pinnedIds",[]),(0,s.R3)(t)}(a)})),(0,s.iw)("deleteMessages",((e,t,n)=>{const{messageIds:s,shouldDeleteForAll:a}=n,i=(0,c.Bt)(e);if(!i)return;const{chatId:o,threadId:r}=i,l=(0,c.Z1)(e,o);(0,B.t9)("deleteMessages",{chat:l,messageIds:s,shouldDeleteForAll:a});const d=(0,c._$)(e,o,r);s.includes(d)&&t.setEditingId({messageId:void 0})})),(0,s.iw)("deleteScheduledMessages",((e,t,n)=>{const{messageIds:s}=n,a=(0,c.Bt)(e);if(!a)return;const{chatId:i}=a,o=(0,c.Z1)(e,i);(0,B.t9)("deleteScheduledMessages",{chat:o,messageIds:s});const r=(0,c.wU)(e,i);s.includes(r)&&t.setEditingId({messageId:void 0})})),(0,s.iw)("deleteHistory",(async(e,t,n)=>{const{chatId:s,shouldDeleteForAll:a}=n,i=(0,c.Z1)(e,s);if(!i)return;await(0,B.t9)("deleteHistory",{chat:i,shouldDeleteForAll:a});const o=(0,c.Bt)(e);o&&o.chatId===s&&t.openChat({id:void 0})})),(0,s.iw)("reportMessages",(async(e,t,n)=>{const{messageIds:s,reason:a,description:i}=n,o=(0,c.Bt)(e);if(!o)return;const{chatId:r}=o,l=(0,c.Z1)(e,r),d=await(0,B.t9)("reportMessages",{peer:l,messageIds:s,reason:a,description:i});t.showNotification({message:d?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,s.iw)("sendMessageAction",(async(e,t,n)=>{const{action:s,chatId:a,threadId:i}=n;if(a===e.currentUserId)return;const o=(0,c.Z1)(e,a);if(!o)return;const r=(0,c.dy)(e,a);r&&((0,d.cS)(r)||(0,d.NB)(r))||await(0,B.t9)("sendMessageAction",{peer:o,threadId:i,action:s})})),(0,s.iw)("markMessageListRead",((e,t,n)=>{const{serverTimeOffset:s}=e,i=(0,c.Bt)(e);if(!i)return;const{chatId:l,threadId:d}=i,u=(0,c.Cm)(e,l,d);if(!u)return;const{maxId:m}=n;if(U((()=>{(0,B.t9)("markMessageListRead",{serverTimeOffset:s,chat:u,threadId:d,maxId:m})})),d!==o._f)return;l===a.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=m?{...e,isUnread:!1}:e))});const h=(0,c.Cb)(e,l,d),g=(0,c.It)(e,l,d);if(!h||!g||!u.unreadCount)return e;const p=function(e,t,n){let s=0;for(let a=0,i=e.length;a=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,B.t9)("markMessagesRead",{chat:s,messageIds:a})})),(0,s.iw)("loadWebPagePreview",((e,t,n)=>{const{text:a}=n;!async function(e){const t=await(0,B.t9)("fetchWebPagePreview",{message:e});(0,s.R3)({...(0,s.Rd)(),webPagePreview:t})}(a)})),(0,s.iw)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,s.iw)("sendPollVote",((e,t,n)=>{const{chatId:s,messageId:a,options:i}=n,o=(0,c.Z1)(e,s);o&&(0,B.t9)("sendPollVote",{chat:o,messageId:a,options:i})})),(0,s.iw)("cancelPollVote",((e,t,n)=>{const{chatId:s,messageId:a}=n,i=(0,c.Z1)(e,s);i&&(0,B.t9)("sendPollVote",{chat:i,messageId:a,options:[]})})),(0,s.iw)("closePoll",((e,t,n)=>{var s;const{chatId:a,messageId:i}=n,o=(0,c.Z1)(e,a),r=null===(s=(0,c.hj)(e,a,i))||void 0===s?void 0:s.content.poll;o&&r&&(0,B.t9)("closePoll",{chat:o,messageId:i,poll:r})})),(0,s.iw)("loadPollOptionResults",((e,t,n)=>{const{chat:a,messageId:i,option:o,offset:c,limit:l,shouldResetVoters:d}=n;!async function(e,t,n,a,i,o){const c=await(0,B.t9)("loadPollOptionResults",{chat:e,messageId:t,option:n,offset:a,limit:i});if(!c)return;let l=(0,s.Rd)();l=(0,r.Sh)(l,(0,g.ee)(c.users,"id"));const{voters:d}=l.pollResults;(0,s.R3)({...l,pollResults:{...l.pollResults,voters:{...d,[n]:(0,g.Tw)([...!o&&d&&d[n]?d[n]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[n]:c.nextOffset||""}}})}(a,i,o,c,l,d)})),(0,s.iw)("loadExtendedMedia",((e,t,n)=>{const{chatId:s,ids:a}=n,i=(0,c.Z1)(e,s);i&&(0,B.t9)("fetchExtendedMedia",{chat:i,ids:a})})),(0,s.iw)("forwardMessages",((e,t,n)=>{const{fromChatId:a,messageIds:i,toChatId:o,withMyScore:r,noAuthors:l,noCaptions:u}=e.forwardMessages,m=(0,c.wV)(e),h=a?(0,c.Z1)(e,a):void 0,g=o?(0,c.Z1)(e,o):void 0,p=a&&i?i.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,o),w=p.filter((e=>!(0,d.jM)(e)));w.length&&(0,B.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,i=(0,c.Z1)(e,a);i&&async function(e){const t=await(0,B.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:n}=t,a=(0,g.ee)(n,"id"),i=Object.keys(a).map(Number).sort(((e,t)=>t-e));let c=(0,s.Rd)();c=(0,r.w3)(c,e.id,a),c=(0,r.pf)(c,e.id,o._f,"scheduledIds",i),(0,s.R3)(c)}(i)})),(0,s.iw)("sendScheduledMessages",((e,t,n)=>{const{chatId:s,id:a}=n,i=(0,c.Z1)(e,s);i&&(0,B.t9)("sendScheduledMessages",{chat:i,ids:[a]})})),(0,s.iw)("rescheduleMessage",((e,t,n)=>{const{chatId:s,messageId:a,scheduledAt:i}=n,o=(0,c.Z1)(e,s),r=o&&(0,c.Tm)(e,o.id,a);o&&r&&(0,B.t9)("rescheduleMessage",{chat:o,message:r,scheduledAt:i})})),(0,s.iw)("requestThreadInfoUpdate",((e,t,n)=>{const{chatId:s,threadId:a}=n,i=(0,c.Cm)(e,s,a);i&&(0,B.t9)("requestThreadInfoUpdate",{chat:i,threadId:a})})),(0,s.iw)("transcribeAudio",(async(e,t,n)=>{const{messageId:a,chatId:i}=n,o=(0,c.Z1)(e,i);if(!o)return;e=(0,r.cY)(e,i,a,{transcriptionId:""}),(0,s.R3)(e);const l=await(0,B.t9)("transcribeAudio",{chat:o,messageId:a});e=(0,r.cY)((0,s.Rd)(),i,a,{transcriptionId:l,isTranscriptionError:!l}),(0,s.R3)(e)})),(0,s.iw)("loadCustomEmojis",(async(e,t,n)=>{const{ids:a,ignoreCache:i}=n,o=i?a:(0,g.Tw)(a.filter((t=>!e.customEmojis.byId[t]))),r=await(0,B.t9)("fetchCustomEmoji",{documentId:o});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,i=(0,c.Z1)(e,a);i&&async function(e){const t=await(0,B.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:n,chats:a,users:i}=t,c=(0,g.ee)(n,"id"),l=Object.keys(c).map(Number).sort(((e,t)=>t-e));let d=(0,s.Rd)();d=(0,r.c_)(d,e.id,c),d=(0,r.pf)(d,e.id,o._f,"pinnedIds",l),d=(0,r.Sh)(d,(0,g.ee)(i,"id")),d=(0,r.fZ)(d,(0,g.ee)(a,"id")),(0,s.R3)(d)}(i)})),(0,s.iw)("loadSeenBy",(async(e,t,n)=>{const{chatId:a,messageId:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const l=await(0,B.t9)("fetchSeenBy",{chat:o,messageId:i});l&&(0,s.R3)((0,r.cY)((0,s.Rd)(),a,i,{seenByUserIds:l}))})),(0,s.iw)("saveDefaultSendAs",((e,t,n)=>{const{chatId:s,sendAsId:a}=n,i=(0,c.Z1)(e,s),o=(0,c.Z1)(e,a)||(0,c.dy)(e,a);if(i&&o)return(0,B.t9)("saveDefaultSendAs",{sendAs:o,chat:i}),(0,r.a4)(e,s,{fullInfo:{...i.fullInfo,sendAsId:a}})})),(0,s.iw)("loadSendAs",(async(e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);if(!i)return;const o=await(0,B.t9)("fetchSendAs",{chat:i});o?(e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(o.chats,"id")),e=(0,r.a4)(e,a,{sendAsPeerIds:o.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,i=(0,c.Z1)(e,a);if(!i)return;const o=await(0,B.t9)("fetchSponsoredMessages",{chat:i});o&&(e=(0,s.Rd)(),e=(0,r.Fn)(e,a,o.messages[0]),e=(0,r.Sh)(e,(0,g.ee)(o.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(o.chats,"id")),(0,s.R3)(e))})),(0,s.iw)("viewSponsoredMessage",((e,t,n)=>{const{chatId:s}=n,a=(0,c.Z1)(e,s),i=(0,c.fS)(e,s);a&&i&&(0,B.t9)("viewSponsoredMessage",{chat:a,random:i.randomId})})),(0,s.iw)("fetchUnreadMentions",(async(e,t,n)=>{const{chatId:a,offsetId:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const l=await(0,B.t9)("fetchUnreadMentions",{chat:o,offsetId:i});if(!l)return;const{messages:d,chats:u,users:m}=l,h=(0,g.ee)(d,"id"),p=Object.keys(h).map(Number);e=(0,s.Rd)(),e=(0,r.c_)(e,o.id,h),e=(0,r.Sh)(e,(0,g.ee)(m,"id")),e=(0,r.fZ)(e,(0,g.ee)(u,"id")),e=(0,r.a4)(e,a,{unreadMentions:[...o.unreadMentions||[],...p]}),(0,s.R3)(e)})),(0,s.iw)("markMentionsRead",((e,t,n)=>{const{messageIds:a}=n,i=(0,c.jr)(e);if(!i)return;const o=(i.unreadMentions||[]).filter((e=>!a.includes(e)));e=(0,r.a4)(e,i.id,{unreadMentions:o}),(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,B.t9)("readAllMentions",{chat:t}),(0,r.a4)(e,t.id,{unreadMentionsCount:void 0,unreadMentions:void 0})})),(0,s.iw)("openUrl",((e,t,n)=>{const{url:s,shouldSkipModal:i}=n,o=(0,L.X)(s);if(o.match(a.FS)||o.match(a.g$))return void t.openTelegramLink({url:s});const{appConfig:r}=e;if(r){const e=new URL(o);if(r.autologinDomains.includes(e.hostname))return e.searchParams.set("autologin_token",r.autologinToken),void window.open(e.href,"_blank","noopener");if(r.urlAuthDomains.includes(e.hostname))return void t.requestLinkUrlAuth({url:s})}o.match(a.jL)||i?window.open(o,"_blank","noopener"):t.toggleSafeLinkModal({url:o})})),(0,s.iw)("setForwardChatId",(async(e,t,n)=>{const{id:a}=n;let i=(0,c.dy)(e,a);if(i&&(0,c.Nm)(e)){var o;if(!i.fullInfo){const{accessHash:e}=i;i=await(0,B.t9)("fetchFullUser",{id:a,accessHash:e})}if(null!==(o=i)&&void 0!==o&&o.fullInfo.noVoiceMessages)return void t.showDialog({data:{message:(0,v.i0)("VoiceMessagesRestrictedByPrivacy",(0,d.Js)(i))}})}(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,N.P2)((e=>e()),500,!1);async function H(e){const t=await(0,B.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,B.t9)("fetchStickers",{stickerSetInfo:e});let n=(0,s.Rd)();if(!t)return(0,N.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:i,packs:o}=t;n=(0,r.Rg)(n,a.id,{...a,stickers:i,packs:o});const c=n.stickers.forEmoji.emoji;c&&o[c]&&(n=(0,r.vy)(n)),(0,s.R3)(n)}async function _(e,t){const n=await(0,B.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,B.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,B.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,i=[...n,...a];if(i.length)for(let e=0;e0&&await(0,N.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,B.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,B.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,B.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,B.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,B.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,B.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,i=(0,c.Ny)(e,a);i&&i.count===(null==i||null===(s=i.stickers)||void 0===s?void 0:s.length)||V(a)})),(0,s.iw)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,B.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,B.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,B.t9)("fetchSavedGifs",{hash:e});if(!t)return;const n=(0,s.Rd)();(0,s.R3)({...n,gifs:{...n.gifs,saved:t}})}(t)})),(0,s.iw)("saveGif",(async(e,t,n)=>{var a,i;const{gif:o,shouldUnsave:r}=n,l=null===(a=e.gifs.saved.gifs)||void 0===a?void 0:a.length,d=(0,$.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,B.t9)("saveGif",{gif:o,shouldUnsave:r}))return;const h=(null===(i=(e=(0,s.Rd)()).gifs.saved.gifs)||void 0===i?void 0:i.filter((e=>{let{id:t}=e;return t!==o.id})))||[],g=r?h:[o,...h];(0,s.R3)({...e,gifs:{...e.gifs,saved:{...e.gifs.saved,gifs:g}}})})),(0,s.iw)("faveSticker",((e,t,n)=>{const{sticker:s}=n,a=e.stickers.favorite.stickers.length,i=(0,$.M)(e,"stickersFaved"),o=(0,$.P)(e,"stickersFaved"),r=(0,c.wV)(e);a>=i&&t.showNotification({title:v.i0("LimitReachedFavoriteStickers",i.toString()),message:r?v.i0("LimitReachedFavoriteStickersSubtitlePremium"):v.i0("LimitReachedFavoriteStickersSubtitle",o.toString()),...!r&&{action:t.openPremiumModal},className:"bold-link"}),s&&(0,B.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,B.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,s.iw)("removeRecentSticker",(async(e,t,n)=>{const{sticker:s}=n;await(0,B.t9)("removeRecentSticker",{sticker:s})&&H()})),(0,s.iw)("clearRecentStickers",(async e=>{await(0,B.t9)("clearRecentStickers")&&(e=(0,s.Rd)(),(0,s.R3)({...e,stickers:{...e.stickers,recent:{stickers:[]}}}))})),(0,s.iw)("toggleStickerSet",((e,t,n)=>{const{stickerSetId:s}=n,a=(0,c.Ny)(e,s);if(!a)return;const{accessHash:i,installedDate:o}=a;(0,B.t9)(o?"uninstallStickerSet":"installStickerSet",{stickerSetId:s,accessHash:i})})),(0,s.iw)("loadEmojiKeywords",(async(e,t,n)=>{var a,i;const{language:o}=n;let r=e.emojiKeywords[o];if(null!==(a=r)&&void 0!==a&&a.isLoading)return;(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}});const c=await(0,B.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});r=(e=(0,s.Rd)()).emojiKeywords[o],c?(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:c.version,keywords:{...null===(i=r)||void 0===i?void 0:i.keywords,...c.keywords}}}}):(0,s.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})),(0,s.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:a}=n;a&&G((()=>{!async function(e,t){const n=await(0,B.t9)("searchStickers",{query:e,hash:void 0});if(!n)return;const a=(0,s.Rd)(),{setsById:i,added:o}=a.stickers,c=n.sets.map((e=>{let{id:t}=e;return t}));o.setIds&&o.setIds.forEach((t=>{if(!c.includes(t)){const{title:n}=i[t]||{};n&&(0,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:i}=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,B.t9)("fetchStickersForEmoji",{emoji:e,hash:t});n=(0,s.Rd)(),a&&n.stickers.forEmoji.emoji===e&&(n=(0,r.IM)(n,e,a.stickers,a.hash),(0,s.R3)(n))}(a,i)}))})),(0,s.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,s.iw)("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,B.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 i=(0,c.Ny)(e,a);null!=i&&i.shortName?(0,s.R3)({...e,openedStickerSetShortName:i.shortName}):t.showNotification({message:(0,v.i0)("StickerPack.ErrorNotFound")})}));var z=n(790);const W=(0,N.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,i=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0;if(o){const s=await(0,B.t9)("searchMessagesLocal",{chat:o,query:t,type:n,limit:a.Hk,offsetId:i,minDate:d,maxDate:l});if(s){const{messages:t,users:n,totalCount:a,nextOffsetId:i}=s;e={messages:t,users:n,chats:[],totalCount:a,nextRate:i}}}else e=await(0,B.t9)("searchMessagesGlobal",{query:t,offsetRate:i,limit:a.Hk,type:n,maxDate:l,minDate:d});let u=(0,s.Rd)();const m=(0,c.JX)(u);if(!e||""!==t&&t!==m)return void(0,s.R3)((0,r.xv)(u,{messages:!1}));const{messages:h,users:p,chats:f,totalCount:v,nextRate:I}=e;f.length&&(u=(0,r.fZ)(u,(0,g.ee)(f,"id"))),p.length&&(u=(0,r.Sh)(u,(0,g.ee)(p,"id"))),h.length&&(u=(0,r.m6)(u,h)),u=(0,r.px)(u,h,v,n,I),(0,s.R3)(u)}async function J(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const o=await(0,B.t9)("searchMessagesLocal",{chat:e,type:t,limit:2*a.EN,offsetId:n});if(!o)return;const{chats:l,users:d,messages:u,totalCount:m,nextOffsetId:h}=o,p=(0,g.ee)(u,"id"),f=Object.keys(p).map(Number);let v=(0,s.Rd)();const I=(0,c.we)(v);I&&(v=(0,r.fZ)(v,(0,g.ee)(l,"id")),v=(0,r.Sh)(v,(0,g.ee)(d,"id")),v=(0,r.c_)(v,e.id,p),v=(0,r.c1)(v,e.id,t,f,m,h),(0,s.R3)(v),i||J(e,t,h,!0))}(0,s.iw)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:a}=e.globalSearch,{query:i}=n;i&&!a&&W((()=>{!async function(e){const t=await(0,B.t9)("searchChats",{query:e});let n=(0,s.Rd)();const a=(0,c.JX)(n);if(!t||!a||e!==a)return void(0,s.R3)((0,r.xv)(n,{chats:!1}));const{localChats:i,localUsers:o,globalChats:l,globalUsers:d}=t;(i.length||l.length)&&(n=(0,r.fZ)(n,(0,g.ee)([...i,...l],"id"))),(o.length||d.length)&&(n=(0,r.Sh)(n,(0,g.ee)([...o,...d],"id"))),n=(0,r.xv)(n,{chats:!1}),n=(0,r.No)(n,{localResults:{chatIds:i.map((e=>{let{id:t}=e;return t})),userIds:o.map((e=>{let{id:t}=e;return t}))},globalResults:{...n.globalSearch.globalResults,chatIds:l.map((e=>{let{id:t}=e;return t})),userIds:d.map((e=>{let{id:t}=e;return t}))}}),(0,s.R3)(n)}(i)}))})),(0,s.iw)("setGlobalSearchDate",((e,t,n)=>{const{date:a}=n,i=a?(0,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:o}=e.globalSearch;X("","text",void 0,o?(0,c.Z1)(e,o):void 0,i,a)})),(0,s.iw)("searchMessagesGlobal",((e,t,n)=>{var s;const{query:a,resultsByType:i,chatId:o,date:r}=e.globalSearch,l=r?(0,z.IS)(r):r,{type:d}=n;X(a,d,null==i||null===(s=i[d])||void 0===s?void 0:s.nextOffsetId,o?(0,c.Z1)(e,o):void 0,l,r)})),(0,s.iw)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{},i=t?(0,c.Z1)(e,t):void 0,l=(0,c.n5)(e);if(!i||!l||!n)return;const{query:d,results:u}=l,m=null==u?void 0:u.nextOffsetId;let h;if(n!==o._f){const s=(0,c.tZ)(e,t,n);h=null==s?void 0:s.topMessageId}!async function(e,t,n,i,o){if(!i)return;const l=await(0,B.t9)("searchMessagesLocal",{chat:e,type:"text",query:i,topMessageId:n,limit:a.pn,offsetId:o});if(!l)return;const{chats:d,users:u,messages:m,totalCount:h,nextOffsetId:p}=l,f=(0,g.ee)(m,"id"),v=Object.keys(f).map(Number);let I=(0,s.Rd)();const w=(0,c.n5)(I);w&&i===w.query&&(I=(0,r.fZ)(I,(0,g.ee)(d,"id")),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.c_)(I,e.id,f),I=(0,r.dx)(I,e.id,t,v,h,p),(0,s.R3)(I))}(i,n,h,d,m)})),(0,s.iw)("searchMediaMessagesLocal",(e=>{const{chatId:t}=(0,c.Bt)(e)||{};if(!t)return;const n=(0,c.Z1)(e,t),s=(0,c.we)(e);if(!n||!s)return;const{currentType:a,resultsByType:i}=s,o=a&&i&&i[a],r=null==o?void 0:o.nextOffsetId;a&&J(n,a,r)})),(0,s.iw)("searchMessagesByDate",((e,t,n)=>{const{timestamp:a}=n,{chatId:i}=(0,c.Bt)(e)||{};if(!i)return;const o=(0,c.Z1)(e,i);o&&async function(e,t){const n=await(0,B.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});n&&(0,s.Sv)().focusMessage({chatId:e.id,messageId:n})}(o,a)})),(0,s.iw)("checkPublicLink",(async(e,t,n)=>{const{chatId:a}=(0,c.Bt)(e)||{};if(!a)return;if(e.management.progress===m.wv.InProgress)return;const{username:i}=n;e=(0,r.fw)(e,a,{isUsernameAvailable:void 0,checkedUsername:void 0}),(0,s.R3)(e);const o=await(0,B.t9)("checkChatUsername",{username:i});e=(0,s.Rd)(),e=(0,r.H9)(e,o?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:o,checkedUsername:i}),(0,s.R3)(e),void 0===o&&t.openLimitReachedModal({limit:"channelsPublic"})})),(0,s.iw)("updatePublicLink",(async(e,t,n)=>{const{chatId:a}=(0,c.Bt)(e)||{};let i=a&&(0,c.Z1)(e,a);if(!a||!i)return;const{username:o}=n;if(e=(0,r.H9)(e,m.wv.InProgress),(0,s.R3)(e),(0,d.G9)(i)){if(i=await(0,x.bZ)(i),!i)return;t.openChat({id:i.id})}const l=await(0,B.t9)("setChatUsername",{chat:i,username:o});e=(0,s.Rd)(),e=(0,r.H9)(e,l?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0,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,B.t9)("updatePrivateLink",{chat:n})})),(0,s.iw)("setEditingExportedInvite",((e,t,n)=>{const{chatId:a,invite:i}=n;(0,s.R3)((0,r.fw)(e,a,{editingInvite:i}))})),(0,s.iw)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:a,invite:i}=n,o=i?{inviteInfo:{invite:i}}:{inviteInfo:void 0};(0,s.R3)((0,r.fw)(e,a,o))})),(0,s.iw)("loadExportedChatInvites",(async(e,t,n)=>{const{chatId:a,adminId:i,isRevoked:o,limit:l}=n,d=(0,c.Z1)(e,a),u=(0,c.dy)(e,i||e.currentUserId);if(!d||!u)return;const m=await(0,B.t9)("fetchExportedChatInvites",{peer:d,admin:u,isRevoked:o,limit:l});if(!m)return;const h=o?{revokedInvites:m}:{invites:m};(0,s.R3)((0,r.fw)((0,s.Rd)(),a,h))})),(0,s.iw)("editExportedChatInvite",(async(e,t,n)=>{const{chatId:a,link:i,isRevoked:o,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m}=n,h=(0,c.Z1)(e,a);if(!h)return;const g=await(0,B.t9)("editExportedChatInvite",{peer:h,link:i,isRevoked:o,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m});if(!g)return;const{oldInvite:p,newInvite:f}=g,v=((e=(0,s.Rd)()).management.byChatId[a].invites||[]).filter((e=>e.link!==p.link)),I=[...e.management.byChatId[a].revokedInvites||[]];f.isRevoked?I.unshift(f):v.push(f),(0,s.R3)((0,r.fw)(e,a,{invites:v,revokedInvites:I}))})),(0,s.iw)("exportChatInvite",(async(e,t,n)=>{const{chatId:a,expireDate:i,usageLimit:o,isRequestNeeded:l,title:d}=n,u=(0,c.Z1)(e,a);if(!u)return;const m=await(0,B.t9)("exportChatInvite",{peer:u,expireDate:i,usageLimit:o,isRequestNeeded:l,title:d});if(!m)return;const h=(e=(0,s.Rd)()).management.byChatId[a].invites||[];(0,s.R3)((0,r.fw)(e,a,{invites:[...h,m]}))})),(0,s.iw)("deleteExportedChatInvite",(async(e,t,n)=>{var a,i;const{chatId:o,link:l}=n,d=(0,c.Z1)(e,o);if(!d)return;if(!await(0,B.t9)("deleteExportedChatInvite",{peer:d,link:l}))return;const u=(e=(0,s.Rd)()).management.byChatId[o];(0,s.R3)((0,r.fw)(e,o,{invites:null==u||null===(a=u.invites)||void 0===a?void 0:a.filter((e=>e.link!==l)),revokedInvites:null==u||null===(i=u.revokedInvites)||void 0===i?void 0:i.filter((e=>e.link!==l))}))})),(0,s.iw)("deleteRevokedExportedChatInvites",(async(e,t,n)=>{const{chatId:a,adminId:i}=n,o=(0,c.Z1)(e,a),l=(0,c.dy)(e,i||e.currentUserId);o&&l&&await(0,B.t9)("deleteRevokedExportedChatInvites",{peer:o,admin:l})&&(e=(0,s.Rd)(),(0,s.R3)((0,r.fw)(e,a,{revokedInvites:[]})))})),(0,s.iw)("loadChatInviteImporters",(async(e,t,n)=>{var a;const{chatId:i,link:o,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,i),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,B.t9)("fetchChatInviteImporters",{peer:m,link:o,offsetDate:l,offsetUser:h,limit:u});if(!g)return;const{importers:p,users:f}=g,v=null===(a=(e=(0,s.Rd)()).management.byChatId[i])||void 0===a?void 0:a.inviteInfo;null!=v&&v.invite&&v.invite.link===o&&(e=(0,r.fw)(e,i,{inviteInfo:{...v,importers:p}}),e=(0,r.Sh)(e,f),(0,s.R3)(e))})),(0,s.iw)("loadChatInviteRequesters",(async(e,t,n)=>{var a;const{chatId:i,link:o,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,i),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,B.t9)("fetchChatInviteImporters",{peer:m,link:o,offsetDate:l,offsetUser:h,limit:u,isRequested:!0});if(!g)return;const{importers:p,users:f}=g,v=null===(a=(e=(0,s.Rd)()).management.byChatId[i])||void 0===a?void 0:a.inviteInfo;null!=v&&v.invite&&v.invite.link===o&&(e=(0,r.fw)(e,i,{inviteInfo:{...v,requesters:p}}),e=(0,r.Sh)(e,f),(0,s.R3)(e))})),(0,s.iw)("loadChatJoinRequests",(async(e,t,n)=>{const{chatId:a,offsetDate:i,offsetUserId:o,limit:l}=n,d=(0,c.Z1)(e,a),u=(0,c.dy)(e,o);if(!d||o&&!u)return;const m=await(0,B.t9)("fetchChatInviteImporters",{peer:d,offsetDate:i,offsetUser:u,limit:l,isRequested:!0});if(!m)return;const{importers:h,users:g}=m;e=(0,s.Rd)(),e=(0,r.a4)(e,a,{joinRequests:h}),e=(0,r.Sh)(e,g),(0,s.R3)(e)})),(0,s.iw)("hideChatJoinRequest",(async(e,t,n)=>{var a;const{chatId:i,userId:o,isApproved:l}=n,d=(0,c.Z1)(e,i),u=(0,c.dy)(e,o);if(!d||!u)return;if(!await(0,B.t9)("hideChatJoinRequest",{peer:d,user:u,isApproved:l}))return;e=(0,s.Rd)();const m=(0,c.Z1)(e,i);m&&(0,s.R3)((0,r.a4)(e,i,{joinRequests:null===(a=m.joinRequests)||void 0===a?void 0:a.filter((e=>e.userId!==o))}))})),(0,s.iw)("hideAllChatJoinRequests",(async(e,t,n)=>{const{chatId:a,isApproved:i,link:o}=n,l=(0,c.Z1)(e,a);if(!l)return;if(!await(0,B.t9)("hideAllChatJoinRequests",{peer:l,isApproved:i,link:o}))return;e=(0,s.Rd)();const d=(0,c.Z1)(e,a);d&&(0,s.R3)((0,r.a4)(e,a,{joinRequests:[],fullInfo:{...d.fullInfo,recentRequesterIds:[],requestsPending:0}}))})),(0,s.iw)("hideChatReportPanel",(async(e,t,n)=>{const{chatId:a}=n,i=(0,c.Z1)(e,a);i&&await(0,B.t9)("hideChatReportPanel",i)&&(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,B.t9)("fetchMessages",{chat:e,threadId:o._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,s.iw)("sync",(()=>{a.eM&&console.log(">>> START SYNC"),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,o._f),e[n].editingId=(0,c._$)(t,n,o._f),e[n].editingDraft=(0,c.s)(t,n,o._f),e)),{}),{chatId:i,threadId:l}=(0,c.Bt)(t)||{},d=i?t.chats.byId[i]:void 0;if(i&&d){const n=await te(d);t=(0,s.Rd)();const{chatId:u}=(0,c.Bt)(t)||{},m=l&&(0,c.tZ)(t,i,l);if(n&&u===i){const s=t.messages.byChatId[i],c=i===a.aw?t.serviceNotifications.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,i,u),t=(0,r.xj)(t,i,o._f,h),t=(0,r.y9)(t,i,o._f,h),l&&m&&m.originChannelId){const{originChannelId:e}=m,n=t.messages.byChatId[e],a=await 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:{[o._f]:{...null==n?void 0:n.threadsById[o._f],listedIds:r,viewportIds:r,outlyingIds:void 0}}},[i]:{...t.messages.byChatId[i],threadsById:{...t.messages.byChatId[i].threadsById,[l]:{...null==s?void 0:s.threadsById[l],outlyingIds:void 0}}}}}}}}t=(0,r.GL)(t,(0,g.ee)(n.chats,"id")),t=(0,r.eD)(t,(0,g.ee)(n.users,"id")),t=(0,r.j6)(t,i,n.threadInfos),e=!0}}e||(t={...t,messages:{...t.messages,byChatId:{}}}),Object.keys(n).forEach((e=>{t=(0,r.sN)(t,e,o._f,n[e])})),(0,s.R3)(t);const{chatId:u,messageId:m}=t.audioPlayer;u&&m&&!(0,c.hj)(t,u,m)&&(0,s.Sv)().closeAudioPlayer()}(),(0,s.R3)({...(0,s.Rd)(),lastSyncTime:Date.now(),isSyncing:!1}),a.eM&&console.log(">>> FINISH SYNC"),(0,K.S1)(),e({listType:"archived",shouldReplace:!0}),(0,B.t9)("fetchCurrentUser"),t()}})})),(0,Y.ll)((e=>{var t,n;const{connectionState:a,authState:i}=e;(null===(t=ee)||void 0===t?void 0:t.connectionState)===a&&(null===(n=ee)||void 0===n?void 0:n.authState)===i||("connectionStateReady"===a&&"authorizationStateReady"===i&&(0,s.Sv)().sync(),ee=e)})),(0,s.iw)("reportPeer",(async(e,t,n)=>{const{chatId:s,reason:a,description:i}=n;if(!s)return;const o=(0,c.Z1)(e,s);if(!o)return;const r=await(0,B.t9)("reportPeer",{peer:o,reason:a,description:i});t.showNotification({message:r?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,s.iw)("reportProfilePhoto",(async(e,t,n)=>{const{chatId:s,reason:a,description:i,photo:o}=n;if(!s)return;const r=(0,c.Z1)(e,s);if(!r||!o)return;const l=await(0,B.t9)("reportProfilePhoto",{peer:r,photo:o,reason:a,description:i});t.showNotification({message:l?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,s.iw)("loadAuthorizations",(async()=>{const e=await(0,B.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,B.t9)("terminateAuthorization",a))return;e=(0,s.Rd)();const{[a]:i,...o}=e.activeSessions.byHash;(0,s.R3)({...e,activeSessions:{byHash:o,orderedHashes:e.activeSessions.orderedHashes.filter((e=>e!==a))}})})),(0,s.iw)("terminateAllAuthorizations",(async e=>{if(!await(0,B.t9)("terminateAllAuthorizations"))return;const t=(e=(0,s.Rd)()).activeSessions.orderedHashes.find((t=>e.activeSessions.byHash[t].isCurrent));if(!t)return;const n=e.activeSessions.byHash[t];(0,s.R3)({...e,activeSessions:{byHash:{[t]:n},orderedHashes:[t]}})})),(0,s.iw)("changeSessionSettings",(async(e,t,n)=>{const{hash:a,areCallsEnabled:i,areSecretChatsEnabled:o}=n;await(0,B.t9)("changeSessionSettings",{hash:a,areCallsEnabled:i,areSecretChatsEnabled:o})&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeSessions:{...e.activeSessions,byHash:{...e.activeSessions.byHash,[a]:{...e.activeSessions.byHash[a],...void 0!==i?{areCallsEnabled:i}:void 0,...void 0!==o?{areSecretChatsEnabled:o}:void 0}}}}))})),(0,s.iw)("changeSessionTtl",(async(e,t,n)=>{const{days:a}=n;await(0,B.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,B.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,B.t9)("terminateWebAuthorization",a))return;e=(0,s.Rd)();const{[a]:i,...o}=e.activeWebSessions.byHash;(0,s.R3)({...e,activeWebSessions:{byHash:o,orderedHashes:e.activeWebSessions.orderedHashes.filter((e=>e!==a))}})})),(0,s.iw)("terminateAllWebAuthorizations",(async e=>{await(0,B.t9)("terminateAllWebAuthorizations")&&(e=(0,s.Rd)(),(0,s.R3)({...e,activeWebSessions:{byHash:{},orderedHashes:[]}}))}));const ne=(0,N.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:i,accessHash:o}=a;(0,B.t9)("fetchFullUser",{id:i,accessHash:o})})),(0,s.iw)("loadUser",(async(e,t,n)=>{const{userId:a}=n,i=(0,c.dy)(e,a);if(!i)return;const o=await(0,B.t9)("fetchUsers",{users:[i]});if(!o)return;const{users:l,userStatusesById:d}=o;e=(0,s.Rd)(),e=(0,r.eD)(e,(0,g.ee)(l,"id")),e=(0,r.ps)(e,{...e.users.statusesById,...d}),(0,s.R3)(e)})),(0,s.iw)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,p.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,B.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,B.t9)("fetchContactList");if(!e)return;let t=(0,r.Sh)((0,s.Rd)(),(0,g.ee)(e.users,"id"));t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id")),t=(0,r.zn)(t,e.userStatusesById);const n=e=>e.lastName||e.firstName||"",a=new Intl.Collator("en-US"),i=e.users.sort(((e,t)=>a.compare(n(e),n(t)))).filter((e=>!e.isSelf));(0,s.R3)({...t,contactList:{userIds:i.map((e=>e.id))}})}()})),(0,s.iw)("loadCurrentUser",(()=>{(0,B.t9)("fetchCurrentUser")})),(0,s.iw)("loadCommonChats",(async e=>{var t,n,a;const{chatId:i}=(0,c.Bt)(e)||{},o=i?(0,c.dy)(e,i):void 0;if(!o||(0,d.cS)(o)||null!==(t=o.commonChats)&&void 0!==t&&t.isFullyLoaded)return;const l=null===(n=o.commonChats)||void 0===n?void 0:n.maxId,u=await(0,B.t9)("fetchCommonChats",o.id,o.accessHash,l);if(!u)return;const{chats:m,chatIds:h,isFullyLoaded:p}=u;e=(0,s.Rd)(),m.length&&(e=(0,r.fZ)(e,(0,g.ee)(m,"id"))),e=(0,r.Nq)(e,o.id,{commonChats:{maxId:h.length?h[h.length-1]:"0",ids:(0,g.Tw)(((null===(a=o.commonChats)||void 0===a?void 0:a.ids)||[]).concat(h)),isFullyLoaded:p}}),(0,s.R3)(e)})),(0,s.iw)("updateContact",((e,t,n)=>{const{userId:a,isMuted:i=!1,firstName:o,lastName:l,shouldSharePhoneNumber:d}=n;!async function(e,t,n,a,i){let o=(0,s.Rd)();const l=(0,c.dy)(o,e);if(!l)return;let d;if((0,s.Sv)().updateChatMutedState({chatId:e,isMuted:t}),(0,s.R3)((0,r.H9)((0,s.Rd)(),m.wv.InProgress)),!l.isContact&&l.phoneNumber)d=await(0,B.t9)("importContact",{phone:l.phoneNumber,firstName:n,lastName:a});else{const{id:e,accessHash:t}=l;d=await(0,B.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:n,lastName:a,shouldSharePhoneNumber:i})}d&&((0,s.Sv)().loadChatSettings({chatId:e}),(0,s.R3)((0,r.Nq)((0,s.Rd)(),l.id,{firstName:n,lastName:a}))),o=(0,s.Rd)(),o=(0,r.H9)(o,m.wv.Complete),o=(0,r.ft)(o),(0,s.R3)(o)}(a,i,o,l,d)})),(0,s.iw)("deleteContact",((e,t,n)=>{const{userId:a}=n;!async function(e){const t=(0,s.Rd)(),n=(0,c.dy)(t,e);if(!n)return;const{id:a,accessHash:i}=n;await(0,B.t9)("deleteContact",{id:a,accessHash:i})}(a)})),(0,s.iw)("loadProfilePhotos",(async(e,t,n)=>{const{profileId:a}=n,i=(0,d.YC)(a),o=i?(0,c.dy)(e,a):void 0,l=i?void 0:(0,c.Z1)(e,a);if(!o&&!l)return;const u=await(0,B.t9)("fetchProfilePhotos",o,l);u&&u.photos&&(e=(0,s.Rd)(),i?e=(0,r.Nq)(e,a,{photos:u.photos}):(e=(0,r.Sh)(e,(0,g.ee)(u.users,"id")),e=(0,r.a4)(e,a,{photos:u.photos})),(0,s.R3)(e))})),(0,s.iw)("setUserSearchQuery",((e,t,n)=>{const{query:a}=n;a&&ne((()=>{!async function(e){const t=await(0,B.t9)("searchChats",{query:e});let n=(0,s.Rd)();const a=n.userSearch.query;if(!t||!a||e!==a)return void(0,s.R3)((0,r.Q3)(n,!1));const{localUsers:i,globalUsers:o}=t;let c,l;i.length&&(n=(0,r.Sh)(n,(0,g.ee)(i,"id")),c=i.map((e=>{let{id:t}=e;return t}))),o.length&&(n=(0,r.Sh)(n,(0,g.ee)(o,"id")),l=o.map((e=>{let{id:t}=e;return t}))),n=(0,r.Q3)(n,!1),n=(0,r.Lm)(n,{localUserIds:c,globalUserIds:l}),(0,s.R3)(n)}(a)}))})),(0,s.iw)("importContact",(async(e,t,n)=>{const{phoneNumber:a,firstName:i,lastName:o}=n,c=await(0,B.t9)("importContact",{phone:a,firstName:i,lastName:o});c?(t.openChat({id:c}),(0,s.R3)((0,r.ft)((0,s.Rd)()))):t.showNotification({message:v.i0("Contacts.PhoneNumber.NotRegistred")})})),(0,s.iw)("reportSpam",((e,t,n)=>{const{chatId:s}=n,a=(0,d.YC)(s)?(0,c.dy)(e,s):(0,c.Z1)(e,s);a&&(0,B.t9)("reportSpam",a)}));var ie=n(18629);const oe=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;oe&&(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(!oe){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,N.Ds)((e=>e()),500,!1);async function de(e,t){await(0,B.t9)("toggleAttachBot",{bot:e,isEnabled:t}),await ue()}async function ue(e){const t=await(0,B.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:i}=t;return void(0,s.R3)({...e,urlAuth:{...e.urlAuth,request:{domain:n,botId:a.id,shouldRequestWriteAccess:i}}})}const n="accepted"===t.type?t.url:e;window.open(n,"_blank","noopener"),(0,s.Sv)().closeUrlAuthModal()}async function he(e,t,n,s,a){await(0,B.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:i,showNotification:o,openUrl:r,openGame:c}=(0,s.Sv)();a&&(ge||(ge=new re("popup,width=800,height=600",(()=>{o({message:"Allow browser to open popup window"})}))),ge.preOpenIfNeeded());const l=await(0,B.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:n,isGame:a});if(!l)return;const{message:d,alert:u,url:m}=l;u?i({data:{message:d||"Error"}}):d?o({message:d}):m&&(a?m.includes(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,B.t9)("getPaymentForm",e);if(!t)return;const{form:n,invoice:a}=t;let i=(0,r._7)((0,s.Rd)(),n);return i=(0,r.Q$)(i,m.KB.Checkout),(0,s.R3)(i),a}async function ve(e,t,n){const a=await(0,B.t9)("validateRequestedInfo",{inputInvoice:e,requestInfo:t,shouldSave:n});if(!a)return;const{id:i,shippingOptions:o}=a;let c=(0,r.vT)((0,s.Rd)(),i);o?(c=(0,r.TM)(c,o),c=(0,r.Q$)(c,m.KB.Shipping)):c=(0,r.Q$)(c,m.KB.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:i}=a;t.getReceipt({receiptMessageId:i,chatId:n.id,messageId:s});break}case"buy":{const n=(0,c.jr)(e);if(!n)return;t.openInvoice({chatId:n.id,messageId:s});break}case"game":{const t=(0,c.jr)(e);if(!t)return;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:i}=(0,c.Bt)(e)||{};if(!i)return;const o=(0,c.hj)(e,i,s);if(null==o||!o.senderId)return;const r=(0,ie.BS)();t.requestSimpleWebView({url:n,botId:null==o?void 0:o.senderId,theme:r,buttonText:a.text});break}case"webView":{const{url:n}=a,i=(0,c.jr)(e);if(!i)return;const o=(0,c.hj)(e,i.id,s);if(!o)return;const r=o.viaBotId||o.senderId;if(!r)return;const l=(0,ie.BS)();t.requestWebView({url:n,botId:r,peerId:i.id,theme:l,buttonText:a.text});break}case"urlAuth":{const{url:n}=a,i=(0,c.jr)(e);if(!i)return;t.requestBotUrlAuth({chatId:i.id,messageId:s,buttonId:a.buttonId,url:n});break}}})),(0,s.iw)("sendBotCommand",((e,t,n)=>{const{command:s,chatId:a}=n,{currentUserId:i}=e,o=a?(0,c.Z1)(e,a):(0,c.jr)(e),r=(0,c.Bt)(e);if(!i||!o||!r)return;const{threadId:l}=r;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o.id,threadId:l,value:!1}),he(o,0,s,(0,c.Yy)(e,o.id,l),(0,c._5)(e,a))})),(0,s.iw)("restartBot",(async(e,t,n)=>{const{chatId:a}=n,{currentUserId:i}=e,o=(0,c.jr)(e),l=i&&(0,c.IK)(e,a);i&&o&&l&&await(0,B.t9)("unblockContact",l.id,l.accessHash)&&((0,s.R3)((0,r.rB)((0,s.Rd)(),l.id)),he(o,0,"/start",void 0,(0,c._5)(e,a)))})),(0,s.iw)("loadTopInlineBots",(async e=>{const{lastRequestedAt:t}=e.topInlineBots;if(t&&(0,p.b)(e.serverTimeOffset)-t<60)return;const n=await(0,B.t9)("fetchTopInlineBots");if(!n)return;const{ids:a,users:i}=n;e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(i,"id")),e={...e,topInlineBots:{...e.topInlineBots,userIds:a,lastRequestedAt:(0,p.b)(e.serverTimeOffset)}},(0,s.R3)(e)})),(0,s.iw)("queryInlineBot",(async(e,t,n)=>{const{chatId:a,username:i,query:o,offset:l}=n;let d=e.inlineBots.byUsername[i];if(!1!==d){if(void 0===d){const{user:t,chat:n}=await(0,B.t9)("fetchInlineBot",{username:i})||{};if(e=(0,s.Rd)(),!t||!n)return void(0,s.R3)(se(e,i,!1));e=(0,r.Sh)(e,{[t.id]:t}),e=(0,r.fZ)(e,{[n.id]:n}),d={id:t.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=se(e,i,d),(0,s.R3)(e)}(o!==d.query||d.canLoadMore)&&le((()=>{!async function(e){let{username:t,inlineBotData:n,chatId:a,query:i,offset:o}=e,r=(0,s.Rd)();const l=(0,c.dy)(r,n.id),d=(0,c.Z1)(r,a);if(!l||!d)return;const u=n.query!==i;r=ae(r,!0),r=se(r,t,{...n,query:i,...u&&{offset:void 0,results:[]}}),(0,s.R3)(r);const m=await(0,B.t9)("fetchInlineBotResults",{bot:l,chat:d,query:i,offset:u?void 0:o}),h=r.inlineBots.byUsername[t];if(r=ae((0,s.Rd)(),!1),!m||!h||i!==h.query)return void(0,s.R3)(r);const g=new Set((h.results||[]).map((e=>e.id))),p=m.results.filter((e=>!g.has(e.id)));r=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:i,inlineBotData:d,chatId:a,query:o,offset:l})}))}})),(0,s.iw)("switchBotInline",((e,t,n)=>{const{query:s,isSamePeer:a,messageId:i}=n,o=(0,c.jr)(e);if(!o)return;const r=(0,c.hj)(e,o.id,i);if(!r)return;const l=(0,c.dy)(e,r.viaBotId||r.senderId);l&&t.openChatWithDraft({text:`@${l.username} ${s}`,chatId:a?o.id:void 0})})),(0,s.iw)("sendInlineBotResult",((e,t,n)=>{const{id:s,queryId:a,isSilent:i,scheduledAt:o}=n,r=(0,c.Bt)(e);if(!r||!s)return;const{chatId:l,threadId:d}=r,u=(0,c.Z1)(e,l);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:l,threadId:d,value:!1}),(0,B.t9)("sendInlineBotResult",{chat:u,resultId:s,queryId:a,replyingTo:(0,c.Yy)(e,l,d),sendAs:(0,c._5)(e,l),isSilent:i,scheduleDate:o})})),(0,s.iw)("resetInlineBot",((e,t,n)=>{const{username:a}=n;let i=e.inlineBots.byUsername[a];i&&(i={id:i.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,s.R3)(se(e,a,i)))})),(0,s.iw)("startBot",(async(e,t,n)=>{var a;const{botId:i,param:o}=n;let r=(0,c.dy)(e,i);r&&(r.fullInfo||await(0,B.t9)("fetchFullUser",{id:r.id,accessHash:r.accessHash}),r=(0,c.dy)((0,s.Rd)(),i),null!==(a=r.fullInfo)&&void 0!==a&&a.isBlocked&&await(0,B.t9)("unblockContact",r.id,r.accessHash),await(0,B.t9)("startBot",{bot:r,startParam:o}))})),(0,s.iw)("requestSimpleWebView",(async(e,t,n)=>{const{url:a,botId:i,theme:o,buttonText:r}=n,l=(0,c.dy)(e,i);if(!l)return;if(!(0,c.LM)(e,i))return void(0,s.R3)({...e,botTrustRequest:{botId:i,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:n}}});const d=await(0,B.t9)("requestSimpleWebView",{url:a,bot:l,theme:o});d&&(e=(0,s.Rd)(),(0,s.R3)({...e,webApp:{url:d,botId:i,buttonText:r}}))})),(0,s.iw)("requestWebView",(async(e,t,n)=>{const{url:a,botId:i,peerId:o,theme:r,isSilent:l,buttonText:d,isFromBotMenu:u,startParam:m}=n,h=(0,c.dy)(e,i);if(!h)return;const g=(0,c.Z1)(e,o);if(!g)return;if(!(0,c.LM)(e,i))return void(0,s.R3)({...e,botTrustRequest:{botId:i,type:"webApp",onConfirm:{action:"requestWebView",payload:n}}});const p=(0,c.Bt)(e);if(!p)return;const{chatId:f,threadId:v}=p,I=f&&(0,c.Yy)(e,f,v),w=(0,c._5)(e,f),y=await(0,B.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:i,queryId:Z,buttonText:d}})})),(0,s.iw)("prolongWebView",(async(e,t,n)=>{const{botId:s,peerId:a,isSilent:i,replyToMessageId:o,queryId:r}=n,l=(0,c.dy)(e,s);if(!l)return;const d=(0,c.Z1)(e,a);if(!d)return;const u=(0,c._5)(e,a);await(0,B.t9)("prolongWebView",{bot:l,peer:d,isSilent:i,replyToMessageId:o,queryId:r,sendAs:u})||t.closeWebApp()})),(0,s.iw)("sendWebViewData",((e,t,n)=>{const{bot:s,data:a,buttonText:i}=n;(0,B.t9)("sendWebViewData",{bot:s,data:a,buttonText:i})})),(0,s.iw)("closeWebApp",(e=>({...e,webApp:void 0}))),(0,s.iw)("setWebAppPaymentSlug",((e,t,n)=>{var s;if(null!==(s=e.webApp)&&void 0!==s&&s.url)return{...e,webApp:{...e.webApp,slug:n.slug}}})),(0,s.iw)("cancelBotTrustRequest",(e=>({...e,botTrustRequest:void 0}))),(0,s.iw)("markBotTrusted",((e,t,n)=>{var a;const{botId:i}=n,{trustedBotIds:o}=e,r=new Set(o);if(r.add(i),(0,s.R3)({...e,botTrustRequest:void 0,trustedBotIds:Array.from(r)}),null!==(a=e.botTrustRequest)&&void 0!==a&&a.onConfirm){const{action:n,payload:s}=e.botTrustRequest.onConfirm;t[n](s)}})),(0,s.iw)("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,i=(0,c.dy)(e,s);i&&await de(i,a)})),(0,s.iw)("callAttachBot",((e,t,n)=>{const{chatId:s,botId:a,isFromBotMenu:i,url:o,startParam:r}=n,{attachMenu:{bots:c}}=e;if(!i&&!c[a])return{...e,requestedAttachBotInstall:{botId:a,onConfirm:{action:"callAttachBot",payload:{chatId:s,botId:a,startParam:r}}}};const l=(0,ie.BS)();t.openChat({id:s}),t.requestWebView({url:o,peerId:s,botId:a,theme:l,buttonText:"",isFromBotMenu:i,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 i=(0,c.dy)(e,n);if(i&&(await de(i,!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:i,filter:o,startParam:r}=n,l=null===(a=(0,c.Bt)(e))||void 0===a?void 0:a.chatId,{attachMenu:{bots:d}}=e,u=d[i];if(!u)return;const m=u.peerTypes.filter((e=>"self"!==e&&o.includes(e)));m.length?(0,s.R3)({...e,requestedAttachBotInChat:{botId:i,filter:m,startParam:r}}):t.callAttachBot({chatId:l||i,botId:i,startParam:r})})),(0,s.iw)("cancelAttachBotInChat",(e=>({...e,requestedAttachBotInChat:void 0}))),(0,s.iw)("requestBotUrlAuth",(async(e,t,n)=>{const{chatId:a,buttonId:i,messageId:o,url:r}=n,l=(0,c.Z1)(e,a);if(!l)return;const d=await(0,B.t9)("requestBotUrlAuth",{chat:l,buttonId:i,messageId:o});d&&(e=(0,s.Rd)(),(0,s.R3)({...e,urlAuth:{url:r,button:{buttonId:i,messageId:o,chatId:l.id}}}),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:i,url:o}=e.urlAuth,{chatId:r,messageId:l,buttonId:d}=i,u=(0,c.Z1)(e,r);if(!u)return;const m=await(0,B.t9)("acceptBotUrlAuth",{chat:u,messageId:l,buttonId:d,isWriteAllowed:a});m&&me(o,m)})),(0,s.iw)("requestLinkUrlAuth",(async(e,t,n)=>{const{url:a}=n,i=await(0,B.t9)("requestLinkUrlAuth",{url:a});i&&(e=(0,s.Rd)(),(0,s.R3)({...e,urlAuth:{url:a}}),me(a,i))})),(0,s.iw)("acceptLinkUrlAuth",(async(e,t,n)=>{var s;const{isWriteAllowed:a}=n;if(null===(s=e.urlAuth)||void 0===s||!s.url)return;const{url:i}=e.urlAuth,o=await(0,B.t9)("acceptLinkUrlAuth",{url:i,isWriteAllowed:a});o&&me(i,o)})),(0,s.iw)("closeUrlAuthModal",(e=>({...e,urlAuth:void 0}))),n(51371),(0,s.iw)("loadPasswordInfo",(async e=>{const t=await(0,B.t9)("getPasswordInfo");t&&(e=(0,s.Rd)(),e=(0,r.BI)(e,{hasPassword:t.hasPassword}),e=(0,r.IE)(e,{hint:t.hint}),(0,s.R3)(e))})),(0,s.iw)("checkPassword",(async(e,t,n)=>{const{currentPassword:a,onSuccess:i}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const o=await(0,B.t9)("checkPassword",a);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),o&&i()})),(0,s.iw)("clearPassword",(async(e,t,n)=>{const{currentPassword:a,onSuccess:i}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const o=await(0,B.t9)("clearPassword",a);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),o&&i()})),(0,s.iw)("updatePassword",(async(e,t,n)=>{const{currentPassword:a,password:i,hint:o,email:c,onSuccess:l}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const d=await(0,B.t9)("updatePassword",a,i,o,c);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1})),d&&l()})),(0,s.iw)("updateRecoveryEmail",(async(e,t,n)=>{const{currentPassword:a,email:i,onSuccess:o}=n;(0,s.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const c=await(0,B.t9)("updateRecoveryEmail",a,i);(0,s.R3)((0,r.IE)((0,s.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),c&&o()})),(0,s.iw)("provideTwoFaEmailCode",((e,t,n)=>{const{code:s}=n;(0,B.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:i}=n;if("slug"in s)ve(s,a,i);else{const t=(0,c.Z1)(e,s.chatId);if(!t)return;ve({chat:t,messageId:s.messageId},a,i)}})),(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:i,messageId:o}=n,l=i&&(0,c.Z1)(e,i);o&&a&&l&&async function(e,t,n){const a=await(0,B.t9)("getReceipt",e,n);if(!a)return;let i=(0,s.Rd)();const o=(0,c.hj)(i,e.id,t);i=(0,r.Dq)(i,a,o),(0,s.R3)(i)}(l,o,a)})),(0,s.iw)("clearPaymentError",(e=>{(0,s.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,s.iw)("clearReceipt",(e=>{(0,s.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,s.iw)("sendCredentialsInfo",((e,t,n)=>{const{nativeProvider:i}=e.payment,{credentials:o}=n,{data:l}=o;if("stripe"===i){const t=(0,c.$$)(e);if(!t)return;!async function(e,t){const n=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvv,"card[address_zip]":e.zip,"card[address_country]":e.country}),a=await fetch(`https://api.stripe.com/v1/tokens${n}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),i=await a.json();if(i.error){const e=(0,d.Ow)(i.error),t=(0,s.Rd)();return void(0,s.R3)({...t,payment:{...t.payment,status:"failed",error:{...e}}})}let o=(0,r.QH)((0,s.Rd)(),{type:i.type,id:i.id});o=(0,r.Q$)(o,m.KB.Checkout),(0,s.R3)(o)}(l,t)}else if("smartglocal"===i){const t=(0,c.EB)(e);if(!t)return;!async function(e,t){const n={card:{number:e.cardNumber.replace(/\D+/g,""),expiration_month:e.expiryMonth,expiration_year:e.expiryYear,security_code:e.cvv.replace(/\D+/g,"")}},i=a.eA?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",o=await fetch(i,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":t},body:JSON.stringify(n)}),c=await o.json();if("ok"!==c.status){const e={description:"payment error"},t=(0,s.Rd)();return void(0,s.R3)({...t,payment:{...t.payment,status:"failed",error:{...e}}})}let l=(0,r.QD)((0,s.Rd)(),{type:"card",token:c.data.token});l=(0,r.Q$)(l,m.KB.Checkout),(0,s.R3)(l)}(l,t)}})),(0,s.iw)("sendPaymentForm",(async(e,t,n)=>{const{shippingOptionId:a,saveCredentials:i,savedCredentialId:o,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:i,data:"stripe"===h?(0,c.i3)(e):(0,c.Jg)(e)};await(0,B.t9)("sendPaymentForm",{inputInvoice:f,formId:u,credentials:v,requestedInfoId:m,shippingOptionId:a,savedCredentialId:o,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:i,isSuccess:o,isGift:c,monthsAmount:l,toUserId:d}=n||{};t.loadPremiumStickers();const u=await(0,B.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:i,toUserId:d,isGift:c,monthsAmount:l,isSuccess:o}}))})),(0,s.iw)("openGiftPremiumModal",(async(e,t,n)=>{const{forUserId:a}=n||{},i=await(0,B.t9)("fetchPremiumPromo");if(!i)return;e=(0,s.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(i.users,"id"));const o=i.promo.options.find((e=>1===e.months));(0,s.R3)({...e,giftPremiumModal:{isOpen:!0,forUserId:a,monthlyCurrency:o.currency,monthlyAmount:o.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 i=await(0,B.t9)("fetchTemporaryPaymentPassword",a);e=(0,s.Rd)(),e=i?"error"in i?(0,r.cQ)(e,{error:{message:i.error,field:"password"}}):(0,r.cQ)(e,{temporaryPassword:i,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 Ne=0;(0,s.iw)("loadAvailableReactions",(async()=>{const e=await(0,B.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&Ie.he(`sticker${e.aroundAnimation.id}`,o.IU.BlobUrl),e.centerIcon&&Ie.he(`sticker${e.centerIcon.id}`,o.IU.BlobUrl)})),(0,s.R3)({...(0,s.Rd)(),availableReactions:e}))})),(0,s.iw)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:s,x:a,y:i,localEffect:o,startSize:r,isReversed:c}=n,l={id:Ne++,animatedEffect:s||o,x:Re(e,a)+40*Math.random()-20,y:i+40*Math.random()-20,startSize:r,isReversed:c};return{...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],l]}})),(0,s.iw)("sendEmojiInteraction",((e,t,n)=>{const{messageId:s,chatId:a,emoji:i,interactions:o,localEffect:r}=n,l=(0,c.Z1)(e,a);l&&(i||r)&&a!==e.currentUserId&&(0,B.t9)("sendEmojiInteraction",{chat:l,messageId:s,emoticon:i||(0,c.ji)(r),timestamps:o})})),(0,s.iw)("sendDefaultReaction",((e,t,n)=>{const{chatId:s,messageId:a,x:i,y:o}=n,r=(0,c.q6)(e,s),l=(0,c.hj)(e,s,a);r&&l&&!(0,d.CI)(l)&&t.sendReaction({chatId:s,messageId:a,reaction:r,x:i,y:o})})),(0,s.iw)("sendReaction",((e,t,n)=>{var s,i,o;const{chatId:r}=n;let{messageId:l}=n,{reaction:d}=n;const u=(0,c.Z1)(e,r);let m=(0,c.hj)(e,r,l);if(!u||!m)return;const h=Boolean(m.groupedId)&&!m.isInAlbum,p=h?(0,c.xH)(e,r,m.groupedId)[0]:void 0;m=h&&(0,c.hj)(e,r,p)||m,l=(null===(s=m)||void 0===s?void 0:s.id)||l,null!==(i=m.reactions)&&void 0!==i&&null!==(o=i.results)&&void 0!==o&&o.some((e=>e.reaction===d&&e.isChosen))&&(d=void 0),(0,B.t9)("sendReaction",{chat:u,messageId:l,reaction:d});const{animationLevel:f}=e.settings.byKey;return f===a.zy&&(e={...e,activeReactions:{...d?e.activeReactions:(0,g.CE)(e.activeReactions,[l]),...d&&{[l]:{reaction:d,messageId:l}}}}),function(e,t,n,s){const{reactions:a}=(0,c.hj)(e,t,n)||{};if(!a)return e;let i=a.results.map((e=>e.reaction===s?{...e,count:e.isChosen?e.count:e.count+1,isChosen:!0}:e.isChosen?{...e,isChosen:!1,count:e.count-1}:e)).filter((e=>e.count>0)),{recentReactions:o}=a;if(s&&!i.some((e=>e.reaction===s))){const{currentUserId:t}=e;i=[...i,{reaction:s,isChosen:!0,count:1}],a.canSeeList&&(o=[...o||[],{userId:t,reaction:s}])}return(0,we.cY)(e,t,n,{reactions:{...a,results:i,recentReactions:o}})}(e,r,l,d)})),(0,s.iw)("openChat",(e=>({...e,activeReactions:{}}))),(0,s.iw)("stopActiveReaction",((e,t,n)=>{var s;const{messageId:a,reaction:i}=n;return(null===(s=e.activeReactions[a])||void 0===s?void 0:s.reaction)!==i?e:{...e,activeReactions:(0,g.CE)(e.activeReactions,[a])}})),(0,s.iw)("setDefaultReaction",(async(e,t,n)=>{const{reaction:a}=n;await(0,B.t9)("setDefaultReaction",{reaction:a})&&(0,s.R3)({...(0,s.Rd)(),appConfig:{...e.appConfig,defaultReaction:a}})})),(0,s.iw)("stopActiveEmojiInteraction",((e,t,n)=>{var s;const{id:a}=n;return{...e,activeEmojiInteractions:null===(s=e.activeEmojiInteractions)||void 0===s?void 0:s.filter((e=>e.id!==a))}})),(0,s.iw)("loadReactors",(async(e,t,n)=>{var a,i,o;const{chatId:l,messageId:d,reaction:u}=n,m=(0,c.Z1)(e,l),h=(0,c.hj)(e,l,d);if(!m||!h)return;const p=null===(a=h.reactors)||void 0===a?void 0:a.nextOffset,f=await(0,B.t9)("fetchMessageReactionsList",{reaction:u,chat:m,messageId:d,offset:p});if(!f)return;e=(0,s.Rd)(),null!==(i=f.users)&&void 0!==i&&i.length&&(e=(0,r.Sh)(e,(0,g.ee)(f.users,"id")));const{nextOffset:v,count:I,reactions:w}=f;(0,s.R3)((0,r.cY)(e,l,d,{reactors:{nextOffset:v,count:I,reactions:[...(null===(o=h.reactors)||void 0===o?void 0:o.reactions)||[],...w]}}))})),(0,s.iw)("loadMessageReactions",((e,t,n)=>{const{ids:s,chatId:a}=n,i=(0,c.Z1)(e,a);i&&(0,B.t9)("fetchMessageReactions",{ids:s,chat:i})})),(0,s.iw)("sendWatchingEmojiInteraction",((e,t,n)=>{var s;const{chatId:a,emoticon:i,x:o,y:r,startSize:l,isReversed:d,id:u}=n,m=(0,c.Z1)(e,a);if(m&&null!==(s=e.activeEmojiInteractions)&&void 0!==s&&s.some((e=>e.id===u))&&a!==e.currentUserId)return(0,B.t9)("sendWatchingEmojiInteraction",{chat:m,emoticon:i}),{...e,activeEmojiInteractions:e.activeEmojiInteractions.map((t=>t.id===u?{...t,x:Re(e,o),y:r,startSize:l,isReversed:d}:t))}})),(0,s.iw)("fetchUnreadReactions",(async(e,t,n)=>{const{chatId:a,offsetId:i}=n,o=(0,c.Z1)(e,a);if(!o)return;const l=await(0,B.t9)("fetchUnreadReactions",{chat:o,offsetId:i,addOffset:i?-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,o.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:[...o.unreadReactions||[],...p]}),(0,s.R3)(e)})),(0,s.iw)("animateUnreadReaction",((e,t,n)=>{const{messageIds:i}=n,{animationLevel:o}=e.settings.byKey,r=(0,c.jr)(e);if(r){if(r.unreadReactionsCount){const n=r.unreadReactionsCount-i.length,a=(r.unreadReactions||[]).filter((e=>!i.includes(e)));e=ke(e,r.id,{unreadReactions:a}),(0,s.R3)(e),!a.length&&n&&t.fetchUnreadReactions({chatId:r.id,offsetId:Math.min(...i)})}if(t.markMessagesRead({messageIds:i}),o===a.zy)return e=(0,s.Rd)(),{...e,activeReactions:{...e.activeReactions,...Object.fromEntries(i.map((t=>{var n,s;const a=(0,c.hj)(e,r.id,t);if(!a)return;const i=null===(n=a.reactions)||void 0===n||null===(s=n.recentReactions)||void 0===s?void 0:s.find((e=>e.isUnread));return i?[t,{messageId:t,reaction:null==i?void 0:i.reaction}]:void 0})).filter(Boolean))}}}})),(0,s.iw)("focusNextReaction",((e,t)=>{const n=(0,c.jr)(e);null!=n&&n.unreadReactions&&t.focusMessage({chatId:n.id,messageId:n.unreadReactions[0]})})),(0,s.iw)("readAllReactions",(e=>{const t=(0,c.jr)(e);if(t)return(0,B.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:i,isGroup:o}=n,l=(0,c.Z1)(e,i);if(null==l||!l.fullInfo)return;const d=await(0,B.t9)(o?"fetchGroupStatistics":"fetchChannelStatistics",{chat:l});if(d){if(e=(0,s.Rd)(),null!==(a=d.recentTopMessages)&&void 0!==a&&a.length){const t=(0,c.Zw)(e,i);d.recentTopMessages=d.recentTopMessages.map((e=>({...e,...t[e.msgId]})))}(0,s.R3)((0,r.ze)(e,i,d))}})),(0,s.iw)("loadMessageStatistics",(async(e,t,n)=>{const{chatId:a,messageId:i}=n,o=(0,c.Z1)(e,a);if(null==o||!o.fullInfo)return;let l=await(0,B.t9)("fetchMessageStatistics",{chat:o,messageId:i});l||(l={}),e=(0,s.Rd)();const{views:d,forwards:u}=(0,c.Zw)(e,a)[i];l.views=d,l.forwards=u;const m=o.fullInfo.statisticsDcId,h=await(0,B.t9)("fetchMessagePublicForwards",{chat:o,messageId:i,dcId:m});l.publicForwards=null==h?void 0:h.length,l.publicForwardsData=h,e=(0,s.Rd)(),(0,s.R3)((0,r.kM)(e,l))})),(0,s.iw)("loadStatisticsAsyncGraph",(async(e,t,n)=>{const{chatId:a,token:i,name:o,isPercentage:l}=n,d=(0,c.Z1)(e,a);if(null==d||!d.fullInfo)return;const u=d.fullInfo.statisticsDcId,m=await(0,B.t9)("fetchStatisticsAsyncGraph",{token:i,dcId:u,isPercentage:l});m&&(0,s.R3)((0,r.yC)((0,s.Rd)(),a,o,m))})),n(28304);var Te=n(28406);function Ae(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)=>Ae(e,s[t])))}const a=e,i=t;return Object.keys(a).every((e=>Ae(a[e],i[e])))}(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":return(0,s.R3)((0,r.a4)(e,n.id,n.chat,n.newProfilePhoto)),n.noTopChatsRequest||(0,c.N)(e,n.id)||t.loadTopChats(),void(n.chat.id&&(0,Te.Vr)({chatId:n.chat.id,lastReadInboxMessageId:n.chat.lastReadInboxMessageId}));case"updateChatJoin":{const a=(0,c.Ek)(e,n.id);if(!a)return;e=(0,r.B1)(e,a,[n.id]),e=(0,r.a4)(e,n.id,{isNotJoined:!1}),(0,s.R3)(e);const i=(0,c.Z1)(e,n.id);return void(i&&t.requestChatUpdate({chatId:i.id}))}case"updateChatLeave":return(0,r.Dd)(e,n.id);case"updateChatInbox":return(0,r.a4)(e,n.id,n.chat);case"updateChatTypingStatus":{const{id:t,typingStatus:a}=n;return(0,s.R3)((0,r.a4)(e,t,{typingStatus:a})),void setTimeout((()=>{e=(0,s.Rd)();const n=(0,c.Z1)(e,t);n&&a&&n.typingStatus&&n.typingStatus.timestamp===a.timestamp&&(0,s.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3)}case"newMessage":{const{message:a}=n,{chatId:i,threadId:l,type:d}=(0,c.Bt)(e)||{};if(a.senderId===e.currentUserId&&!a.isFromScheduled)return;const u=(0,c.Z1)(e,n.chatId);if(!u)return;const m="thread"===d&&l===o._f&&n.chatId===i,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,Te.rh)({chat:u,message:a})}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:s}=n;if(!1!==s.hasUnreadMention)return;return t.forEach((t=>{const s="channelId"in n?n.channelId:(0,c.X5)(e,t),a=(0,c.Z1)(e,s);var i,o;null!=a&&a.unreadReactionsCount&&(e=ke(e,s,{unreadReactionsCount:a.unreadReactionsCount-1||void 0,unreadReactions:null===(i=a.unreadReactions)||void 0===i?void 0:i.filter((e=>e!==t))})),null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,s,{unreadMentionsCount:a.unreadMentionsCount-1||void 0,unreadMentions:null===(o=a.unreadMentions)||void 0===o?void 0:o.filter((e=>e!==t))}))})),e}case"updateChatFullInfo":{const{fullInfo:t}=n,s=e.chats.byId[n.id];if(!s)return;return(0,r.a4)(e,n.id,{fullInfo:{...s.fullInfo,...t}})}case"updatePinnedChatIds":{const{ids:t,folderId:s}=n,i=s===a.WS?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:s}=n,i=(0,c.Ek)(e,t);if(!i)return;const{[i]:o}=e.chats.orderedPinnedIds;let r=o||[];if(s){if(!r.includes(t)){if("active"===i&&r.length>=a.EG){const t=e.chats.listIds.active;r=r.filter((e=>t&&t.includes(e)))}r=[t,...r]}}else r=r.filter((e=>e!==t));return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:r.length?r:void 0}}}}case"updateChatListType":{const{id:t,folderId:s}=n;return(0,r.Pi)(e,t,s)}case"updateChatFolder":{const{id:t,folder:s}=n,{byId:a,orderedIds:i}=e.chatFolders,o=s?{...a,[t]:s}:(0,g.ei)(a,Object.keys(a).map(Number).filter((e=>e!==t))),r=s?i&&i.includes(t)?i:[...i||[],t]:i?i.filter((e=>e!==t)):void 0;return{...e,chatFolders:{...e.chatFolders,byId:o,orderedIds:r}}}case"updateChatFoldersOrder":{const{orderedIds:t}=n;return{...e,chatFolders:{...e.chatFolders,orderedIds:t}}}case"updateRecommendedChatFolders":{const{folders:t}=n;return{...e,chatFolders:{...e.chatFolders,recommended:t}}}case"updateChatMembers":{var i;const t=e.chats.byId[n.id],{replacedMembers:s,addedMember:a,deletedMemberId:o}=n;if(!t)return;let c=!1,l=null!==(i=t.fullInfo)&&void 0!==i&&i.members?[...t.fullInfo.members]:[];if(s)l=s,c=!0;else if(a)l.length&&l.some((e=>e.userId===a.userId))||(l.push(a),c=!0);else if(l.length&&o){const e=l.findIndex((e=>e.userId===o));e>-1&&(l.slice(e,1),c=!0)}if(c){const s=l.filter((e=>{let{isOwner:t,isAdmin:n}=e;return t||n}));return(0,r.a4)(e,n.id,{membersCount:l.length,fullInfo:{...t.fullInfo,members:l,adminMembers:s}})}return}case"deleteProfilePhotos":{const{chatId:t,ids:s}=n,a=e.chats.byId[t];return null!=a&&a.photos?(0,r.a4)(e,t,{photos:a.photos.filter((e=>!s.includes(e.id)))}):void 0}case"draftMessage":{const{chatId:t,formattedText:s,date:a,replyingToId:i}=n;if(!e.chats.byId[t])return;return e=(0,r.pf)(e,t,o._f,"draft",s),e=(0,r.pf)(e,t,o._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:a})}case"showInvite":{const{data:e}=n;return void t.showDialog({data:e})}case"updatePendingJoinRequests":{const{chatId:a,requestsPending:i,recentRequesterIds:o}=n,c=e.chats.byId[a];if(!c)return;e=(0,r.a4)(e,a,{fullInfo:{...c.fullInfo,requestsPending:i,recentRequesterIds:o}}),(0,s.R3)(e),t.loadChatJoinRequests({chatId:a})}}}));const xe=350;function Be(e,t,n,s,a,i,o){var l;const u=null==o?void 0:o.reactions;if(u&&Ae(s,u))return e;if(e=(0,r.cY)(e,t,n,{reactions:s}),!i)return e;const m=null===(l=a.unreadReactions)||void 0===l?void 0:l.includes(n);if((0,d.yL)(e,s)&&!m){e=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,N.R3)((()=>{(0,Te.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 i=a?(0,c.Tm)(e,t,n):(0,c.hj)(e,t,n);if(i&&s.content){const{photo:e,video:t,sticker:n,document:a}=(0,d.qp)(i);e&&s.content.photo?(s.content.photo.blobUrl=e.blobUrl,s.content.photo.thumbnail=e.thumbnail):t&&s.content.video?s.content.video.blobUrl=t.blobUrl:n&&s.content.sticker?s.content.sticker.isPreloadedGlobally=n.isPreloadedGlobally:a&&s.content.document&&(s.content.document.previewBlobUrl=a.previewBlobUrl)}return a?(0,r.P4)(e,t,n,s):(0,r.cY)(e,t,n,s)}function Oe(e,t,n,s){const{chatId:a}=n,{threadInfo:i}=(0,c.Db)(e,a,n)||{};if(!i&&n.replyToMessageId){const i=(0,c.hj)(e,a,n.replyToMessageId);i?e=(0,r.lG)(e,i,a,n.id,s):t.loadMessage({chatId:a,messageId:n.replyToMessageId,threadUpdate:{isDeleting:s,lastMessageId:n.id}})}return e}function Ue(e,t,n){const{id:s,chatId:a}=n,{threadInfo:i,firstMessageId:l}=(0,c.Db)(e,a,n)||{},u=(0,c.Z1)(e,a),m=(null==u?void 0:u.unreadCount)&&!(0,c.gb)(e,a,o._f);if(e=Oe(e,t,n),i&&(!l&&(0,d.CI)(n)||(e=(0,r.xj)(e,a,i.threadId,[s]),(0,c.b9)(e,a,i.threadId)&&(e=(0,r.$S)(e,a,i.threadId,s),l||(e=(0,r.pf)(e,a,i.threadId,"firstMessageId",n.id)))),e=(0,r.pf)(e,a,i.threadId,"threadInfo",{...i,lastMessageId:n.id,messagesCount:i.messagesCount+1})),m)return e;if(e=(0,r.xj)(e,a,o._f,[s]),(0,c.b9)(e,a,o._f)){const t=(0,c.It)(e,a,o._f),n=(0,r.$S)(e,a,o._f,s),i=(0,c.Cb)(n,a,o._f);t&&!i.includes(t)||(e=n)}return e}function Fe(e,t,n){var s;let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:i}=e,o=null===(s=i.byId[t])||void 0===s?void 0:s.lastMessage;return!o||a||o.id===n.id||o.id===n.previousLocalId||n.id>o.id?(0,r.a4)(e,t,{lastMessage:n}):e}function je(e,t){const n=(0,c.Zw)(e,t),s=(0,c.gb)(e,t,o._f);if(!n||!s)return;let a=s.length;for(;a--;){const e=n[s[a]];if(!e.isDeleting)return e}}function 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=Fe(a,e,n,!0))})),n.requestChatUpdate({chatId:e});const i=[];return t.forEach((t=>{const s=(0,c.hj)(a,e,t);if(!s)return;a=Oe(a,n,s,!0);const{threadInfo:o}=(0,c.Db)(a,e,s)||{};o&&i.push(o.threadId)})),(0,s.R3)(a),void setTimeout((()=>{(0,s.R3)((0,r.K4)((0,s.Rd)(),e,t)),(0,g.Tw)(i).forEach((t=>{n.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),xe)}const i=[];t.forEach((e=>{const t=(0,c.X5)(a,e);if(t){i.push(t);const n=je(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);n&&(a=Fe(a,t,n,!0)),setTimeout((()=>{(0,s.R3)((0,r.K4)((0,s.Rd)(),t,[e]))}),xe)}})),(0,s.R3)(a),(0,g.Tw)(i).forEach((e=>{n.requestChatUpdate({chatId:e})}))}(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"newMessage":{const{chatId:a,id:l,message:u,shouldForceReply:m}=n;e=Ue(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 i;if(g&&u.isOutgoing&&(null===(i=u.content)||void 0===i||!i.action)){const n=(0,c.Bt)(e);n&&t.focusMessage({chatId:a,threadId:n.threadId,messageId:u.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:n}=(0,c.Db)(e,a,u)||{};n&&t.requestThreadInfoUpdate({chatId:a,threadId:n.threadId}),g||setTimeout((()=>{let e=(0,s.Rd)();m&&(e=(0,r.pf)(e,a,o._f,"replyingToId",l)),(0,s.R3)(Fe(e,a,h))}),xe)}else e=Fe(e,a,h);(0,s.R3)(e),(0,c.N)(e,a)||t.loadTopChats();break}case"updateStartEmojiInteraction":{var l;const{chatId:t}=(0,c.Bt)(e)||{};if(t!==n.id)return;const a=(0,c.hj)(e,t,n.messageId);if(!a)return;if((0,d.UD)(a)!==n.emoji)return;const i=(0,c.CP)(e,n.emoji);e={...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],{id:(null===(l=e.activeEmojiInteractions)||void 0===l?void 0:l.length)||0,animatedEffect:i?(0,c.cu)(i):n.emoji,messageId:n.messageId}]},(0,s.R3)(e);break}case"newScheduledMessage":{const{chatId:t,id:a,message:i}=n;e=Le(e,t,a,i,!0);const l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,o._f,"scheduledIds",(0,g.Tw)([...l,a])),(0,s.R3)(e);break}case"updateMessage":{var u,m;const{chatId:a,id:i,message:l}=n,d=(0,c.hj)(e,a,i),h=(0,c.Z1)(e,a);e=Le(e,a,i,l);const g=(0,c.hj)(e,a,i);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),d&&(e=Fe(e,a,g)),l.reactions&&h&&(e=Be(e,a,i,l.reactions,h,l.isOutgoing,d)),(0,s.R3)(e),d&&h&&!l.isOutgoing&&(null===(u=h.lastMessage)||void 0===u?void 0:u.id)===l.id&&(0,c.xo)(e,h)&&(0,c.KA)(e,a,l)&&(0,c.b9)(e,a,(null===(m=l.threadInfo)||void 0===m?void 0:m.threadId)||o._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:i}=n;if(!(0,c.Tm)(e,t,a))return;e=Le(e,t,a,i,!0);const l=Object.keys((0,c.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,o._f,"scheduledIds",l),(0,s.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:i,message:o}=n;e=Ue(e,t,o);const l=(0,c.hj)(e,a,i);e=(0,r.K4)(e,a,[i]),o.isScheduled&&(e=(0,r.bV)(e,a,[i])),e=(0,r.cY)(e,a,o.id,{...l,...o,previousLocalId:i});const d=(0,c.hj)(e,a,o.id);e=Fe(e,a,d);const u=(0,c.Db)(e,a,o);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:o.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:o.id,lastReadInboxMessageId:o.id})),(0,s.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:i}=n,l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,o._f,"scheduledIds",[...l,i.id]);const d=(0,c.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,i.id,{...d,...i,previousLocalId:a}),(0,s.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:i}=n,l=(0,c.KB)(e,t)||[],d=a?[...l,...i].sort(((e,t)=>t-e)):l.filter((e=>!i.includes(e)));(0,s.R3)((0,r.pf)(e,t,o._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:i,firstMessageId:o}=n,l={...(0,c.tZ)(e,t,a),...i};if(!l.threadId)return;e=(0,r.Xg)(e,t,a,l),o&&(e=(0,r.pf)(e,t,a,"firstMessageId",o)),(0,s.R3)(e);break}case"resetMessages":{const{id:a}=n,i=(0,c.Zw)(e,a);i&&!(0,d.YC)(a)&&(e=(0,r.K4)(e,a,Object.keys(i).map(Number)),(0,s.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:s,chatId:a}=n;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,o._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,s.R3)(a)}),xe))}(a,t,0,e);break}case"deleteHistory":{const{chatId:i}=n,o=e.messages.byChatId[i];i===a.aw&&(0,s.R3)({...e,serviceNotifications:e.serviceNotifications.map((e=>({...e,isDeleted:!0})))}),o?De(i,Object.keys(o.byId).map(Number),t,(0,s.Rd)()):t.requestChatUpdate({chatId:i});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=n;t.forEach((t=>{const n=(0,c.X5)(e,t);n&&(e=(0,r.cY)(e,n,t,a))})),(0,s.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:i}=n;a.forEach((n=>{e=(0,r.cY)(e,t,n,i)})),(0,s.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=n,i=(0,c.ZB)(e,t);if(null!=i&&i.content.poll){var h;const t=i.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 o={...i.content.poll,...a,results:n};(0,s.R3)((0,r.cY)(e,i.chatId,i.id,{content:{...i.content,poll:o}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:i}=n,o=(0,c.ZB)(e,t);if(!o||!o.content.poll||!o.content.poll.results)break;const{poll:l}=o.content,{recentVoterIds:d,totalVoters:u,results:m}=l.results,h=d?[...d]:[],g=u?u+1:1,p=m?[...m]:[];h.push(a),i.forEach((t=>{const n=p.findIndex((e=>e.option===t)),s=p[n],i=s?{...s}:{option:t,votersCount:0};i.votersCount+=1,a===e.currentUserId&&(i.isChosen=!0),n?p[n]=i:p.push(i)})),(0,s.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:{...l,results:{...l.results,recentVoterIds:h,totalVoters:g,results:p}}}}));break}case"updateServiceNotification":{const{message:s}=n;(0,c.UW)(e)&&t.createServiceNotification({message:s});break}case"updateMessageReactions":{const{chatId:t,id:a,reactions:i}=n,o=(0,c.hj)(e,t,a),r=(0,c.Z1)(e,n.chatId);if(!r||!o)return;(0,s.R3)(Be(e,t,a,i,r,o.isOutgoing,o));break}case"updateMessageExtendedMedia":{const{chatId:t,id:a,media:i,preview:o}=n,l=(0,c.hj)(e,t,a);if(!(0,c.Z1)(e,n.chatId)||!l)return;if(o){if(!l.content.invoice)return;(0,s.R3)((0,r.cY)(e,t,a,{content:{...l.content,invoice:{...l.content.invoice,extendedMedia:o}}}))}else i&&(0,s.R3)((0,r.cY)(e,t,a,{content:{...i}}));break}case"updateTranscribedAudio":{const{transcriptionId:t,text:a,isPending:i}=n;(0,s.R3)({...e,transcriptions:{...e.transcriptions,[t]:{...e.transcriptions[t]||{},transcriptionId:t,text:a,isPending:i}}});break}}}));const qe=(0,N.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,i=n.status,$e[a]=i,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,i=(0,c.dy)(e,t);if(null==i||null===(s=i.fullInfo)||void 0===s||!s.botInfo)return;return(0,r.Nq)(e,t,{fullInfo:{...i.fullInfo,botInfo:{...i.fullInfo.botInfo,menuButton:a}}})}}var a,i})),(0,s.iw)("apiUpdate",((e,t,n)=>{if("updateStickerSet"===n["@type"])return(0,r.Rg)(e,n.id,n.stickerSet)})),(0,s.iw)("apiUpdate",((e,t,n)=>{var a;switch(n["@type"]){case"updatePeerBlocked":return n.isBlocked?(0,r.O4)((0,s.Rd)(),n.id):(0,r.rB)((0,s.Rd)(),n.id);case"updateResetContactList":(0,s.R3)({...(0,s.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updateRecentStickers":t.loadRecentStickers();break;case"updateStickerSets":t.loadStickerSets();break;case"updateStickerSetsOrder":t.reorderStickerSets({order:n.order,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:i,shouldShowPreviews:o}=n;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,s.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:i,shouldShowPreviews:o}));break}}})),(0,s.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:n.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:n.message}}}}));var 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:i}=n,{currentUserId:o}=e;return e=(0,s.Rd)(),a.forEach((n=>{n.id&&(e=(0,Ge.B6)(e,t,n.id,n,Boolean(i)||o===n.id))})),i&&(e=(0,Ge.AH)(e,t,{nextOffset:i})),e}case"updatePhoneCall":{if(!h.Bi)return;const{phoneCall:a,currentUserId:i}=e,{call:o}=n;if(a)return"discarded"===o.state?(t.playGroupCallSound({sound:"end"}),{...e,...o.needRating&&{ratingPhoneCall:o},isCallPanelVisible:void 0,phoneCall:void 0}):void 0;if((null==o?void 0:o.adminId)!==i&&"requested"===o.state)return(0,N.R3)((()=>{(0,Te.TO)({call:o,user:(0,He.fu)((0,s.Rd)())})})),(0,S.o5)(),{...e,phoneCall:o,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,i.d4)((()=>(0,N.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),it=n(18674),ot=n(62357),rt=n(15780),ct=n(99203),lt=n(48778);const dt=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"StickerSetModal",!t);return n?i.ZP.createElement(n,e):void 0}));var ut=n(2155),mt=n(95616),ht=n(17358);const gt=(0,i.X$)((e=>{let{isForAppBadge:t}=e;(0,mt.yi)();const n=(0,K.xW)();if((0,i.d4)((()=>{t&&(0,ht.w)(n)}),[t,n]),!t&&n)return i.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,o){let r,c,l;return r=function(){const[e,t]=(0,i.eJ)(window.navigator.onLine);return(0,i.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}()&&"connectionStateConnecting"!==t?n?Ct.syncing:Ct.online:Ct.waitingForNetwork,c=r===Ct.online||o?"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),Nt=n(49187),Tt=n(83321),At=n(40126),xt=n(49204);const Bt=(0,i.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:s}=e;const a=(0,yt.Z)();return i.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:a.isRtl?"rtl":void 0,onClick:s},i.ZP.createElement(xt.Z,{color:"black"}),i.ZP.createElement("div",{className:"state-text"},i.ZP.createElement(wt.Z,{activeKey:t,name:"slide-fade"},n)),i.ZP.createElement(Rt.Z,{round:!0,size:"tiny",color:"translucent-black"},i.ZP.createElement("span",{className:"icon-close"})))})),Lt=(0,i.X$)((0,s.c$)((e=>{const{query:t,fetchingStatus:n,chatId:s,date:a}=e.globalSearch,{currentUserId:i,connectionState:o,isSyncing:r}=e,{byId:l}=e.chats,{isConnectionStatusMinimized:d,animationLevel:u}=e.settings.byKey;return{searchQuery:t,isLoading:!!n&&Boolean(n.chats||n.messages),currentUserId:i,chatsById:l,globalSearchChatId:s,searchDate:a,theme:(0,c.Pu)(e),animationLevel:u,connectionState:o,isSyncing:r,isMessageListOpen:Boolean((0,c.Bt)(e)),isConnectionStatusMinimized:d,areChatsLoaded:Boolean(e.chats.listIds.active),hasPasscode:Boolean(e.passcode.hasPasscode),canInstall:Boolean(e.canInstall)}}))((e=>{let{content:t,contactsFilter:n,onSearchQuery:o,onSelectSettings:r,onSelectContacts:c,onSelectArchived:l,onReset:u,searchQuery:g,isLoading:p,shouldSkipTransition:f,currentUserId:v,globalSearchChatId:I,searchDate:w,theme:y,animationLevel:P,chatsById:Z,connectionState:C,isSyncing:b,isMessageListOpen:E,isConnectionStatusMinimized:S,areChatsLoaded:M,hasPasscode:R,canInstall:k}=e;const{openChat:N,setGlobalSearchDate:T,setSettingOption:A,setGlobalSearchChatId:x,openChatByUsername:B,lockScreen:L,requestNextSettingsScreen:O,skipLockOnUnload:U}=(0,s.Sv)(),F=(0,yt.Z)(),j=t===m.du.ChatList,D=(0,i.Ye)((()=>w?(0,z.xH)(new Date(1e3*w)):void 0),[w]),q=(0,i.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(F,C,b,E,S,!M),V=(0,i.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,i.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return i.ZP.createElement(Rt.Z,{round:!0,ripple:j&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:j?t:()=>u(),ariaLabel:j?F("AccDescrOpenMenu2"):"Return to chat list"},i.ZP.createElement("div",{className:(0,_e.Z)("animated-menu-icon",!j&&"state-back",f&&"no-animation")}))}),[j,F,u,f]),X=(0,i.I4)((()=>{g||o("")}),[g,o]),J=(0,i.I4)((()=>{A({isConnectionStatusMinimized:!S})}),[S,A]),Y=(0,i.I4)((()=>{N({id:v,shouldReplaceHistory:!0})}),[v,N]),K=(0,i.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";A({theme:t}),A({shouldUseSystemTheme:!1}),(0,Pt.Z)(t,P===a.zy)}),[P,A,y]),Q=(0,i.I4)((()=>{window.open(a.ul,"_blank","noopener")}),[]),ee=(0,i.I4)((()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,Zt.W8)(),U()}),[U]),te=(0,i.I4)((()=>{U()}),[U]),ne=(0,i.I4)((()=>{B({username:F("Settings.TipsUsername")})}),[F,B]),se=(0,i.I4)((()=>{L()}),[L]),ae=Boolean(I)||t===m.du.GlobalSearch||t===m.du.Contacts;(0,i.d4)((()=>ae?(0,pt.Z)((()=>u())):void 0),[ae,u]);const ie=t===m.du.Contacts?F("SearchFriends"):F("Search"),oe=a.Tj?`${a.Ji} Beta (master)`:a.eM?"master":a.Ji;return i.ZP.createElement("div",{className:"LeftMainHeader"},i.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},i.ZP.createElement(St.Z,{trigger:W,footer:`${a.iC} ${oe}`},i.ZP.createElement(Mt.Z,{icon:"saved-messages",onClick:Y},F("SavedMessages")),i.ZP.createElement(Mt.Z,{icon:"archive",onClick:l},i.ZP.createElement("span",{className:"menu-item-name"},F("ArchivedChats")),q>0&&i.ZP.createElement("div",{className:"archived-badge"},q)),i.ZP.createElement(Mt.Z,{icon:"user",onClick:c},F("Contacts")),i.ZP.createElement(Mt.Z,{icon:"settings",onClick:r},F("Settings")),i.ZP.createElement(Mt.Z,{icon:"darkmode",onClick:K},i.ZP.createElement("span",{className:"menu-item-name"},F("lng_menu_night_mode")),i.ZP.createElement(Tt.Z,{id:"darkmode",label:F("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),i.ZP.createElement(Mt.Z,{icon:"help",onClick:ne},F("TelegramFeatures")),i.ZP.createElement(Mt.Z,{icon:"bug",href:a.mU},"Report Bug"),a.Tj&&i.ZP.createElement(Mt.Z,{icon:"permissions",onClick:Q},"Beta Changelog"),_&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Mt.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:ee},"Switch to K Version"),i.ZP.createElement(Mt.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:te},"Switch to Old Version")),k&&i.ZP.createElement(Mt.Z,{icon:"install",onClick:(0,Et.G)()},"Install App")),i.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:ie,autoComplete:"off",canClose:Boolean(I||w),onChange:o,onReset:u,onFocus:X,onSpinnerClick:"minimized"===H?J:void 0},D&&i.ZP.createElement(Nt.Z,{icon:"calendar",title:D,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:T,clickArg:{date:void 0}}),I&&i.ZP.createElement(Nt.Z,{chatOrUserId:I,onClick:x,canClose:!0,clickArg:{id:void 0}})),R&&i.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,size:"smaller",color:"translucent",ariaLabel:`${F("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:se,className:"passcode-lock"},i.ZP.createElement("i",{className:"icon-lock"})),i.ZP.createElement(At.Z,{isOpen:"overlay"===H,isCustom:!0,className:"connection-state-wrapper"},i.ZP.createElement(Bt,{connectionStatus:$,connectionStatusText:G,onClick:J}))))})));var Ot=n(64963),Ut=n(46590),Ft=n(93133),jt=n(1080);const Dt=(0,i.X$)((0,s.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n,activeChatFolder:s},currentUserId:a,lastSyncTime:i,shouldSkipHistoryAnimations:o}=e;return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:s,currentUserId:a,lastSyncTime:i,shouldSkipHistoryAnimations:o,maxFolders:(0,$.M)(e,"dialogFilters")}}))((e=>{let{foldersDispatch:t,onScreenSelect:n,chatFoldersById:o,orderedFolderIds:r,activeChatFolder:c,currentUserId:l,lastSyncTime:d,shouldSkipHistoryAnimations:u,maxFolders:m}=e;const{loadChatFolders:g,setActiveChatFolder:p,openChat:f}=(0,s.Sv)(),v=(0,i.sO)(null),I=(0,yt.Z)();(0,i.d4)((()=>{d&&g()}),[d,g]);const w=(0,i.Ye)((()=>({id:a.Nf,title:(null==r?void 0:r[0])===a.Nf?I("FilterAllChatsShort"):I("FilterAllChats")})),[r,I]),y=(0,i.Ye)((()=>r?r.map((e=>e===a.Nf?w:o[e]||{})).filter(Boolean):void 0),[o,w,r]),P=(null==y?void 0:y.findIndex((e=>e.id===a.Nf)))===c,Z=0===c,C=(0,mt.yi)(),b=(0,i.Ye)((()=>{if(y&&y.length)return y.map(((e,t)=>{var n,s;let{id:i,title:o}=e;const r=i!==a.Nf&&t>m-1;return{id:i,title:o,badgeCount:null===(n=C[i])||void 0===n?void 0:n.chatsCount,isBadgeActive:Boolean(null===(s=C[i])||void 0===s?void 0:s.notificationsCount),isBlocked:r}}))}),[y,C,m]),E=(0,i.I4)((e=>{p(e,{forceOnHeavyAnimation:!0})}),[p]);(0,i.d4)((()=>{b&&b.length&&c>=b.length&&p(0)}),[c,b,p]),(0,i.d4)((()=>{if(v.current&&h.$b&&b&&b.length)return(0,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,i.sO)();S.current=!Z,(0,i.d4)((()=>S.current?(0,pt.Z)((()=>{S.current&&p(0)})):void 0),[c,p]),(0,Ut.Z)({isActive:!Z,onBack:()=>p(0,{forceOnHeavyAnimation:!0})}),(0,i.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&b){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void f({id:l,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>b.length-1)return;p(n,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}),[l,b,f,p]);const{shouldRender:M,transitionClassNames:R}=(0,at.Z)(!r,void 0,!0);function k(e){const s=Object.values(o).find((e=>{let{id:t}=e;return t===b[c].id}));return!s||P?i.ZP.createElement(jt.Z,{folderType:"all",isActive:e,lastSyncTime:d,foldersDispatch:t,onScreenSelect:n}):i.ZP.createElement(jt.Z,{folderType:"folder",folderId:s.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t})}const N=b&&b.length>1;return i.ZP.createElement("div",{className:"ChatFolders"},N?i.ZP.createElement(Ft.Z,{tabs:b,activeTab:c,onSwitchTab:E,areFolders:!0}):M?i.ZP.createElement("div",{className:(0,_e.Z)("tabs-placeholder",R)}):void 0,i.ZP.createElement(wt.Z,{ref:v,name:u?"none":I.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:N?b.length:void 0},k))})));var qt=n(34288);const $t=(0,i.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"LeftSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(qt.Z,null)})),Gt=(0,i.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"ContactList");return t?i.ZP.createElement(t,e):i.ZP.createElement(qt.Z,null)}));var Ht=n(52328);const Vt=(0,i.X$)((e=>{let{isShown:t,onNewPrivateChat:n,onNewChannel:s,onNewGroup:a}=e;const[o,r]=(0,i.eJ)(!1);(0,i.d4)((()=>{t||r(!1)}),[t]);const c=(0,yt.Z)(),l=(0,_e.Z)("NewChatButton",t&&"revealed",o&&"menu-is-open"),d=(0,i.I4)((()=>{r(!o)}),[o]),u=(0,i.I4)((()=>{r(!1)}),[]);return i.ZP.createElement("div",{className:l,dir:c.isRtl?"rtl":void 0},i.ZP.createElement(Rt.Z,{round:!0,color:"primary",className:o?"active":"",onClick:d,ariaLabel:c(o?"Close":"NewMessageTitle"),tabIndex:-1},i.ZP.createElement("i",{className:"icon-new-chat-filled"}),i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(Ht.Z,{isOpen:o,positionX:c.isRtl?"left":"right",positionY:"bottom",autoClose:!0,onClose:u},i.ZP.createElement(Mt.Z,{icon:"channel",onClick:s},c("NewChannel")),i.ZP.createElement(Mt.Z,{icon:"group",onClick:a},c("NewGroup")),i.ZP.createElement(Mt.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),_t=Object.keys(m.du).length/2;let zt;const Wt=(0,i.X$)((e=>{let{content:t,searchQuery:n,searchDate:s,contactsFilter:a,shouldSkipTransition:o,foldersDispatch:r,isUpdateAvailable:c,onSearchQuery:l,onContentChange:d,onScreenSelect:u,onReset:g}=e;const[p,f]=(0,i.eJ)(h.$b),{shouldRender:v,transitionClassNames:I}=(0,at.Z)(c),w=(0,i.sO)(!1),y=(0,i.I4)((()=>{t===m.du.ChatList&&(w.current=!0,f(!0))}),[t]),P=(0,i.I4)((()=>{w.current=!1,zt&&(clearTimeout(zt),zt=void 0),zt=window.setTimeout((()=>{w.current||f(!1)}),250)}),[]),Z=(0,i.I4)((()=>{d(m.du.Settings)}),[d]),C=(0,i.I4)((()=>{d(m.du.Contacts)}),[d]),b=(0,i.I4)((()=>{d(m.du.Archived)}),[d]),E=(0,i.I4)((()=>{window.location.reload()}),[]),S=(0,i.I4)((()=>{d(m.du.NewChannelStep1)}),[d]),M=(0,i.I4)((()=>{d(m.du.NewGroupStep1)}),[d]);(0,i.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 i.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:y,onMouseLeave:h.$b?void 0:P},i.ZP.createElement(Lt,{content:t,contactsFilter:a,onSearchQuery:l,onSelectSettings:Z,onSelectContacts:C,onSelectArchived:b,onReset:g,shouldSkipTransition:o}),i.ZP.createElement(wt.Z,{name:o?"none":"zoom-fade",renderCount:_t,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return i.ZP.createElement(Dt,{onScreenSelect:u,foldersDispatch:r});case m.du.GlobalSearch:return i.ZP.createElement($t,{searchQuery:n,searchDate:s,isActive:e,onReset:g});case m.du.Contacts:return i.ZP.createElement(Gt,{filter:a,isActive:e,onReset:g});default:return}})),v&&i.ZP.createElement(Rt.Z,{fluid:!0,pill:!0,className:(0,_e.Z)("btn-update",I),onClick:E},R("lng_update_telegram")),i.ZP.createElement(Vt,{isShown:p,onNewPrivateChat:C,onNewChannel:S,onNewGroup:M}))})),Xt=(0,i.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"Settings");return t?i.ZP.createElement(t,e):i.ZP.createElement(qt.Z,null)})),Jt=(0,i.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"NewChat");return t?i.ZP.createElement(t,e):i.ZP.createElement(qt.Z,null)})),Yt=(0,i.X$)((e=>{const t=(0,lt.Z)(ct.gl.Extra,"ArchivedChats");return t?i.ZP.createElement(t,e):i.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,i.X$)((0,s.c$)((e=>{var t;const{globalSearch:{query:n,date:s},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:i,leftColumnWidth:o,currentUserId:r,passcode:{hasPasscode:l},settings:{nextScreen:d},isUpdateAvailable:u}=e;return{searchQuery:n,searchDate:s,isFirstChatFolderActive:0===a,shouldSkipHistoryAnimations:i,leftColumnWidth:o,currentUserId:r,hasPasscode:l,nextSettingsScreen:d,isChatOpen:Boolean(null===(t=(0,c.jr)(e))||void 0===t?void 0:t.id),isUpdateAvailable:u}}))((e=>{let{searchQuery:t,searchDate:n,isFirstChatFolderActive:a,shouldSkipHistoryAnimations:o,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,i.sO)(null),[S,M]=(0,i.eJ)(m.du.ChatList),[R,k]=(0,i.eJ)(m.MT.Main),[N,T]=(0,i.eJ)(""),[A,x]=(0,ft.ZP)(),[B,L]=(0,i.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 U=(0,i.I4)((e=>{function t(){M(m.du.ChatList),T(""),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]),F=(0,i.I4)((e=>{S!==m.du.Contacts?(M(m.du.GlobalSearch),e!==t&&p({query:e})):T(e)}),[S,t,p]);(0,i.d4)((()=>S!==m.du.ChatList||a&&!u?(0,pt.Z)((()=>U())):void 0),[a,S,U,u]);const j=(0,i.I4)((e=>{S!==m.du.GlobalSearch&&(e.preventDefault(),M(m.du.GlobalSearch))}),[S]),D=(0,i.I4)((e=>{e.preventDefault(),C({id:c,shouldReplaceHistory:!0})}),[c,C]),q=(0,i.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,i.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,o,r]=(0,vt.Z)(),[c,l]=(0,i.eJ)(),[d,u]=(0,i.eJ)();function m(){document.body.classList.remove("cursor-ew-resize")}return(0,i.bt)((()=>{e.current&&s&&(e.current.style.width=`${s}px`)}),[e,s]),(0,i.d4)((()=>{if(!a)return;const n=t=>{const n=Math.ceil(d+t.clientX-c);e.current.style.width=`${n}px`};function s(){i(),t(e.current.offsetWidth)}function i(){m(),document.removeEventListener("mousemove",n,!1),document.removeEventListener("mouseup",s,!1),document.removeEventListener("blur",s,!1),r()}return document.addEventListener("mousemove",n,!1),document.addEventListener("mouseup",s,!1),document.addEventListener("blur",s,!1),i}),[d,c,e,t,a,r]),{initResize:function(t){t.preventDefault(),document.body.classList.add("cursor-ew-resize"),l(t.clientX),u(e.current.offsetWidth),o()},resetResize:function(t){t.preventDefault(),e.current.style.width="",n()},handleMouseUp:m}}(E,P,Z,r),V=(0,i.I4)((e=>{M(m.du.Settings),k(e)}),[]);return i.ZP.createElement("div",{id:"LeftColumn",ref:E},i.ZP.createElement(wt.Z,{name:o?"none":h.s0,renderCount:Qt,activeKey:O,shouldCleanup:!0,cleanupExceptionKey:Kt.Main},(e=>{switch(O){case Kt.Archived:return i.ZP.createElement(Yt,{isActive:e,onReset:U,onContentChange:M});case Kt.Settings:return i.ZP.createElement(Xt,{isActive:e,currentScreen:R,foldersState:A,foldersDispatch:x,onScreenSelect:V,onReset:U,shouldSkipTransition:o});case Kt.NewChannel:return i.ZP.createElement(Jt,{key:B,isActive:e,isChannel:!0,content:S,onContentChange:M,onReset:U});case Kt.NewGroup:return i.ZP.createElement(Jt,{key:B,isActive:e,content:S,onContentChange:M,onReset:U});default:return i.ZP.createElement(Wt,{content:S,searchQuery:t,searchDate:n,contactsFilter:N,foldersDispatch:x,onContentChange:M,onSearchQuery:F,onScreenSelect:V,onReset:U,shouldSkipTransition:o,isUpdateAvailable:g})}})),i.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,i.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"HeaderMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),gn=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s,a;let{chatId:i,threadId:r,messageListType:l}=t;const u=(0,c.Z1)(e,i),m=Boolean(u&&(0,d.eA)(u));if(!u||u.isRestricted||(0,c.CA)(e))return{noMenu:!0};const g=(0,c.IK)(e,i),p=(0,c.FM)(e,i),f="thread"===l&&r===o._f,v="thread"===l&&r!==o._f,I=(0,c.Jf)(e),w=Boolean(g&&(0,c.s4)(e,g.id)),y=!w&&Boolean((0,c.pk)(e,i)),P=Boolean(f&&(m||(0,d.ZV)(u))&&u.isNotJoined),Z=f||v,C=h.Bi&&(0,d.YC)(u.id)&&!p&&!g,b=f&&!p&&!P,E=f&&!P,S=h.Bi&&u.isCallActive,M=h.Bi&&!u.isCallActive&&((null===(n=u.adminRights)||void 0===n?void 0:n.manageCall)||u.isCreator&&(0,d.G9)(u));return{noMenu:!1,isChannel:m,isRightColumnShown:I,canStartBot:y,canRestartBot:w,canSubscribe:P,canSearch:Z,canCall:C,canMute:b,canViewStatistics:null===(s=u.fullInfo)||void 0===s?void 0:s.canViewStatistics,canLeave:E,canEnterVoiceChat:S,canCreateVoiceChat:M,pendingJoinRequests:null===(a=u.fullInfo)||void 0===a?void 0:a.requestsPending,shouldJoinToSend:Boolean((null==u?void 0:u.isNotJoined)&&u.isJoinToSend),shouldSendJoinRequest:Boolean((null==u?void 0:u.isNotJoined)&&u.isJoinRequest)}}))((e=>{let{chatId:t,threadId:n,noMenu:a,isChannel:o,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,pendingJoinRequests:w,isRightColumnShown:y,canExpandActions:P,shouldJoinToSend:Z,shouldSendJoinRequest:C}=e;const{joinChannel:b,sendBotCommand:E,openLocalTextSearch:S,restartBot:M,requestCall:R,requestNextManagementScreen:k,showNotification:N}=(0,s.Sv)(),T=(0,i.sO)(null),A=(0,yt.Z)(),[x,B]=(0,i.eJ)(!1),[L,O]=(0,i.eJ)(void 0),U=(0,i.I4)((()=>{B(!0);const e=T.current.getBoundingClientRect();O({x:e.right,y:e.bottom})}),[]),F=(0,i.I4)((()=>{B(!1)}),[]),j=(0,i.I4)((()=>{O(void 0)}),[]),D=(0,i.I4)((()=>{b({chatId:t}),C&&N({message:A(o?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[b,t,C,N,o,A]),q=(0,i.I4)((()=>{E({command:"/start"})}),[E]),$=(0,i.I4)((()=>{M({chatId:t})}),[t,M]),G=(0,i.I4)((()=>{k({screen:m.u1.JoinRequests})}),[k]),H=(0,i.I4)((()=>{S(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[S]),V=(0,i.I4)((e=>{d&&h.fl&&!e.shiftKey&&(e.preventDefault(),H())}),[d,H]);return(0,It.y)({"Mod+F":V}),i.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&i.ZP.createElement(i.ZP.Fragment,null,P&&!C&&(l||Z)&&i.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:D},A(o?"ProfileJoinChannel":"ProfileJoinGroup")),P&&C&&i.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:D},A("ChannelJoinRequest")),P&&r&&i.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:q},A("BotStart")),P&&c&&i.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:$},A("BotRestart")),d&&i.ZP.createElement(Rt.Z,{round:!0,ripple:y,color:"translucent",size:"smaller",onClick:H,ariaLabel:"Search in this chat"},i.ZP.createElement("i",{className:"icon-search"})),u&&i.ZP.createElement(Rt.Z,{round:!0,color:"translucent",size:"smaller",onClick:function(){R({userId:t})},ariaLabel:"Call"},i.ZP.createElement("i",{className:"icon-phone"}))),Boolean(w)&&i.ZP.createElement(Rt.Z,{round:!0,className:"badge-button",ripple:y,color:"translucent",size:"smaller",onClick:G,ariaLabel:A(o?"SubscribeRequests":"MemberRequests")},i.ZP.createElement("i",{className:"icon-user"}),i.ZP.createElement("div",{className:"badge"},w)),i.ZP.createElement(Rt.Z,{ref:T,className:x?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:a,ariaLabel:"More actions",onClick:U},i.ZP.createElement("i",{className:"icon-more"})),L&&i.ZP.createElement(hn,{chatId:t,threadId:n,isOpen:x,anchor:L,withExtraActions:h.wB||!P,isChannel:o,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,onSubscribeChannel:D,onSearchClick:H,onClose:F,onCloseAnimationEnd:j}))})));var pn=n(6202),fn=n(2903),vn=n(68512),In=n(17551);function wn(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 yn=(0,i.X$)((e=>{let{count:t,index:n}=e;const s=(0,i.sO)(null),a=(0,i.Ye)((()=>function(e,t){const n=e-t-1,s=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),a=function(e,t){let n=36;return 1===e?n=36:2===e?n=17:3===e?n=1===t?12:11:(4===e||e>3)&&(n=7.5),n}(e,n),i=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,s),o=`clipPath${e}`,r=function(e,t,n){let s="";if(3===n)s=wn(0,0,2,t,1)+wn(0,12,2,t+1,1)+wn(0,25,2,t,1);else for(let e=0;e\n \n `}(o,s,e),c=function(e,t,n){return 1===n?0:2===n?0===e?0:t+2:3===n?0===e?0:1===e?12:25:(t+2)*e}(n,s,e),l=function(e,t,n,s){return t<=4||e<=1?0:e>=t-2?s-36:(n+4)/2+(e-2)*(n+2)}(n,e,s,i);return{markHeight:a,clipPath:r,markTranslateY:c,trackTranslateY:l,trackHeight:i,clipPathId:o}}(t,n)),[t,n]);if((0,i.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:i,clipPathId:o,clipPath:r}=a,c=s.current.firstElementChild;if(null!=s&&s.current){const a=s.current,{style:l}=a;l.height=`${e}px`,l.transform=`translateY(-${t}px)`,l.clipPath=`url("#${o}")`;const d=a.querySelector("svg"),u=a.querySelector("div"),m=a.querySelector("defs");d||c&&(c.innerHTML=` ${r} `),m&&(m.innerHTML=r),u&&(u.style.height=`${n}px`,u.style.transform=`translateY(${i}px)`)}}),[a]),1===t)return i.ZP.createElement("div",{className:"pinned-message-border"},i.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:o,trackTranslateY:r,markHeight:c,markTranslateY:l,clipPathId:d}=a;return i.ZP.createElement("div",{className:(0,_e.Z)("pinned-message-border",t>4&&"pinned-message-border-mask")},i.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${d}"); width: 2px;\n height: ${o}px; transform: translateY(-${r}px);`},i.ZP.createElement("span",null),i.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${c}px; transform: translateY(${l}px);`})))}));var Pn=n(45370);const Zn=(0,i.X$)((e=>{let{message:t,count:n,index:a,customTitle:o,className:r,onUnpinMessage:c,onClick:l,onAllPinnedClick:u}=e;const{clickBotInlineButton:m}=(0,s.Sv)(),g=(0,yt.Z)(),p=(0,fn.Z)(t),f=(0,pn.Z)((0,d.Ti)(t,"pictogram")),[v,I,w]=(0,vt.Z)(),y=(0,i.I4)((()=>{w(),c&&c(t.id)}),[w,c,t.id]),P=(0,d.eH)(t),Z=(0,i.I4)((()=>{P&&m({messageId:t.id,button:P})}),[m,P,t.id]),[C,b,E]=(0,vt.Z)();return i.ZP.createElement("div",{className:(0,_e.Z)("HeaderPinnedMessage-wrapper",r)},n>1&&i.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:g("EventLogFilterPinnedMessages"),onClick:u},i.ZP.createElement("i",{className:"icon-pin-list"})),c&&i.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:g("UnpinMessageAlertTitle"),className:"unpin-button",onClick:I},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(In.Z,{isOpen:v,onClose:w,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:y}),i.ZP.createElement("div",{className:(0,_e.Z)("HeaderPinnedMessage",C&&"no-hover"),onClick:l,dir:g.isRtl?"rtl":void 0},i.ZP.createElement(yn,{count:n,index:a}),p&&function(e,t){const{width:n,height:s}=(0,ye.W7)();return i.ZP.createElement("img",{src:t||e,width:n,height:s,alt:""})}(p,f),i.ZP.createElement("div",{className:"message-text"},i.ZP.createElement("div",{className:"title",dir:"auto"},o||`${g("PinnedMessage")} ${a>0?"#"+(n-a):""}`),i.ZP.createElement("p",{dir:"auto"},i.ZP.createElement(Pn.Z,{lang:g,message:t,noEmoji:Boolean(p)})),i.ZP.createElement(vn.Z,null)),P&&i.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 Cn=n(10396),bn=n(64532),En=n(23186),Sn=n(75851);const Mn=240;function Rn(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/png";const s=e instanceof Blob?URL.createObjectURL(e):e,a=new Image;return new Promise((i=>{a.onload=()=>{kn(a,a.width*t,a.height*t,n).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(i).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(s)}))},a.src=s}))}async function kn(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Nn(e,t,n,void 0,s);try{const a=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:n,resizeQuality:"high"});if(a.height!==n||a.width!==t)throw new Error("Image bitmap resize not supported!");const i=await(0,Sn.ix)(e.src),o=(0,Sn.rZ)(i){const t=document.createElement("canvas");t.width=a.width,t.height=a.height;const n=t.getContext("2d");n.fillStyle=o,n.fillRect(0,0,t.width,t.height);const i=t.getContext("bitmaprenderer");i?i.transferFromImageBitmap(a):n.drawImage(a,0,0),t.toBlob(e,s)}))}catch(a){return Nn(e,t,n,void 0,s)}}async function Nn(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"image/png";const i=document.createElement("canvas"),o=i.getContext("2d"),r=document.createElement("canvas"),c=r.getContext("2d");if(i.width=t,i.height=n,e.width*s>t){const n=1/s;let a={width:Math.floor(e.width*s),height:Math.floor(e.height*s)};for(r.width=a.width,r.height=a.height,c.drawImage(e,0,0,a.width,a.height);a.width*s>t;)a={width:Math.floor(a.width*s),height:Math.floor(a.height*s)},c.drawImage(r,0,0,a.width*n,a.height*n,0,0,a.width,a.height);o.drawImage(r,0,0,a.width,a.height,0,0,i.width,i.height)}else o.drawImage(e,0,0,i.width,i.height);const l=await(0,Sn.ix)(e.src),d=(0,Sn.rZ)(l){i.toBlob(e,a)}))}var Tn=n(77510);const An=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",xn={width:200,height:200},Bn=115;var Ln=n(32340),On=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:i,playbackRate:o,isMuted:r}=e.audioPlayer;return{sender:s,chat:a,volume:i,playbackRate:o,isMuted:r}}))((e=>{let{message:t,className:n,noUi:o,sender:r,chat:c,volume:l,playbackRate:u,isMuted:m}=e;const{setAudioPlayerVolume:g,setAudioPlayerPlaybackRate:p,setAudioPlayerMuted:f,focusMessage:v,closeAudioPlayer:I}=(0,s.Sv)(),w=(0,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:o}=(0,d.qp)(e),r=a?a.title||a.fileName:o?"Voice message":"",c=(null==a?void 0:a.performer)||t&&(0,d.OU)(s,t),l=n&&(0,d.U)(s,n)||"Telegram",u=a&&(0,d.MR)(a)&&(0,d.Ti)(e,"pictogram"),m=t&&(0,d.RT)(t,"big"),h=a&&u||o&&m,g=(0,pn.Z)(h),p=(0,i.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,o,g)),[a,g,o]),{result:f}=(0,Tn.Z)((()=>function(e,t){if(!e)return Promise.resolve(An);if(!t)return function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";const a=e instanceof Blob?URL.createObjectURL(e):e,i=new Image;return new Promise((o=>{i.onload=()=>{kn(i,t,n,s).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},i.src=a}))}(e,Bn,Bn);const n=Math.min(t.width,t.height);return n(0,bn.Of)({title:r,artist:c,album:l,artwork:[{src:f}]})),[l,c,r,f])})(t,r,c),{playPause:R,stop:k,isPlaying:N,requestNextTrack:T,requestPreviousTrack:A,isFirst:x,isLast:B,setVolume:L,toggleMuted:O,setPlaybackRate:U}=(0,En.Z)((0,Cn.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),F=C&&N;(0,i.d4)((()=>{if(F)return Se.Z.disableRefresh(),()=>{Se.Z.enableRefresh()}}),[F]);const j=(0,i.I4)((()=>{v({chatId:t.chatId,messageId:t.id})}),[v,t.chatId,t.id]),D=(0,i.I4)((()=>{N&&R(),I(),(0,bn.Ay)(),k()}),[I,N,R,k]),q=(0,i.I4)((e=>{g({volume:e/100}),L(e/100)}),[g,L]),$=(0,i.I4)((()=>{h.$b&&!h.cj||(O(),f({isMuted:!m}))}),[m,f,O]),G=(0,i.I4)((()=>{1===u?(U(1.8),p({playbackRate:1.8})):(U(1),p({playbackRate:1}))}),[u,p,U]),H=(0,i.Ye)((()=>0===l||m?"icon-muted":l<.3?"icon-volume-1":l<.6?"icon-volume-2":"icon-volume-3"),[l,m]);if(!o)return i.ZP.createElement("div",{className:(0,_e.Z)("AudioPlayer",n),dir:w.isRtl?"rtl":void 0},i.ZP.createElement("div",{className:"AudioPlayer-content",onClick:j},y?function(e){const{title:t,performer:n,fileName:s}=e;return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},(0,Ln.Z)(t||s)),n&&i.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Ln.Z)(n)))}(y):function(e,t){return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,Ln.Z)(t)),i.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(w("AttachAudio"),E),i.ZP.createElement(vn.Z,null)),i.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:x(),onClick:A,ariaLabel:"Previous track"},i.ZP.createElement("i",{className:"icon-skip-previous"})),i.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,_e.Z)("toggle-play","player-button",N?"pause":"play"),onClick:R,ariaLabel:N?"Pause audio":"Play audio"},i.ZP.createElement("i",{className:"icon-play"}),i.ZP.createElement("i",{className:"icon-pause"})),i.ZP.createElement(Rt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:B(),onClick:T,ariaLabel:"Next track"},i.ZP.createElement("i",{className:"icon-skip-next"})),i.ZP.createElement(Rt.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",noPreventDefault:!0},i.ZP.createElement("i",{className:H,onClick:$}),!h.cj&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"volume-slider-spacer"}),i.ZP.createElement("div",{className:"volume-slider"},i.ZP.createElement(On.Z,{bold:!0,value:m?0:100*l,onChange:q})))),b&&i.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},i.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),i.ZP.createElement(Rt.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:D,ariaLabel:"Close player"},i.ZP.createElement("i",{className:"icon-close"})))}));var Fn=n(70172);const jn=(0,i.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:o,usersById:r,chatsById:c,animationLevel:l}=e;const{joinGroupCall:d,subscribeToGroupCallUpdates:u}=(0,s.Sv)(),m=(0,yt.Z)(),h=(0,i.I4)((()=>{d({chatId:t})}),[d,t]),g=null==a?void 0:a.participants,p=(0,i.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,i.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 i.ZP.createElement("div",{className:(0,_e.Z)("GroupCallTopPane",o&&"has-pinned-offset",!n&&"is-hidden"),onClick:h},i.ZP.createElement("div",{className:"info"},i.ZP.createElement("span",{className:"title"},m("VoipGroupVoiceChat")),i.ZP.createElement("span",{className:"participants"},m("Participants",a.participantsCount||0,"i"))),i.ZP.createElement("div",{className:"avatars"},p.map((e=>{if(e)return e.user?i.ZP.createElement(Fn.Z,{key:e.user.id,user:e.user,animationLevel:l}):i.ZP.createElement(Fn.Z,{key:e.chat.id,chat:e.chat,animationLevel:l})}))),i.ZP.createElement(Rt.Z,{round:!0,className:"join"},m("VoipChatJoin")))})));var Dn=n(14605);const qn=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;return{currentUserId:e.currentUserId,chat:(0,c.Z1)(e,n),user:(0,d.YC)(n)?(0,c.dy)(e,n):void 0}}))((e=>{let{chatId:t,className:n,chat:a,user:o,settings:r,currentUserId:c}=e;const{openAddContactDialog:l,blockContact:u,reportSpam:m,deleteChat:h,leaveChannel:g,deleteChatUser:p,deleteHistory:f,toggleChatArchived:v,hideChatReportPanel:I}=(0,s.Sv)(),w=(0,yt.Z)(),[y,P,Z]=(0,vt.Z)(),[C,b]=(0,i.eJ)(!0),[E,S]=(0,i.eJ)(!0),{accessHash:M}=a||{},{isAutoArchived:R,canReportSpam:k,canAddContact:N,canBlockContact:T}=r||{},A=a&&(0,d.G9)(a),x=(0,i.I4)((()=>{l({userId:t}),R&&v({chatId:t})}),[l,R,v,t]),B=(0,i.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,i.I4)((()=>{I({chatId:t})}),[t,I]),O=(0,i.I4)((()=>{Z(),m({chatId:t}),A?(p({chatId:t,userId:c}),f({chatId:t,shouldDeleteForAll:!1})):g({chatId:t})}),[t,Z,c,p,f,A,g,m]);if(r)return i.ZP.createElement("div",{className:(0,_e.Z)("ChatReportPanel",n),dir:w.isRtl?"rtl":void 0},N&&i.ZP.createElement(Rt.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:x},w("lng_new_contact_add")),T&&i.ZP.createElement(Rt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:P},w("lng_new_contact_block")),k&&!T&&i.ZP.createElement(Rt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:P},w("lng_report_spam_and_leave")),i.ZP.createElement(Rt.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:L,ariaLabel:w("Close")},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(In.Z,{isOpen:y,onClose:Z,title:w("BlockUserTitle",o?(0,d.Vl)(o):(0,d.U)(w,a)),text:o?w("UserInfo.BlockConfirmationTitle",(0,d.Js)(o)):w("Chat.Confirm.ReportSpam.Channel"),isButtonsInOneRow:!0,confirmIsDestructive:!0,confirmLabel:w("Block"),confirmHandler:o?B:O},o&&i.ZP.createElement(Dn.Z,{label:w("DeleteThisChat"),checked:E,onCheck:S}),o&&k&&i.ZP.createElement(Dn.Z,{label:w("ReportChat"),checked:C,onCheck:b})))}))),$n=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s,messageListType:a}=t;const{isLeftColumnShown:i,lastSyncTime:r,shouldSkipHistoryAnimations:l}=e,u=(0,c.Z1)(e,n),{typingStatus:m}=u||{},{chatId:h,messageId:g}=e.audioPlayer,p=h&&g?(0,c.hj)(e,h,g):void 0;let f;if("pinned"===a){const t=(0,c.KB)(e,n);f=null==t?void 0:t.length}else if("scheduled"===a){const t=(0,c.qy)(e,n);f=null==t?void 0:t.length}else if("thread"===a&&s!==o._f){const t=(0,c.tZ)(e,n,s);f=(null==t?void 0:t.messagesCount)||0}const v="thread"===a&&s===o._f,I=u&&(0,c.xo)(e,u),w=Boolean(I&&(0,c.s4)(e,n)),y=I&&!w&&Boolean((0,c.pk)(e,n)),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:i,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!==o._f){const t=(0,c.qS)(e,n,s),a=t?(0,c.hj)(e,n,t):void 0,i=a?(0,c.cv)(e,a):void 0;return{...C,pinnedMessageIds:t,canUnpin:!1,topMessageSender:i}}const 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:N,focusMessage:T,openChat:A,openPreviousChat:x,loadPinnedMessages:B,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,s.Sv)(),U=(0,yt.Z)(),F=(0,i.sO)(!0),[j,D]=(0,i.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)(U,y).length,V=g?(0,d.OU)(U,g):void 0,{settings:_}=y||{};(0,i.d4)((()=>{n===o._f&&C&&c&&B({chatId:t})}),[t,B,C,n,c]),(0,i.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,i.sO)(null),Y=(0,i.sO)(!0),K=(0,i.I4)((()=>{k({id:t})}),[k,t]),Q=(0,i.I4)((e=>{N({chatId:t,messageId:e,isUnpin:!0})}),[N,t]),ee=(0,i.I4)((()=>{if($){T({chatId:$.chatId,threadId:n,messageId:$.id});const e=(0,cn.Z)(G||1,j+1);D(e)}}),[$,T,n,G,j]),te=(0,i.I4)((()=>{A({id:t,threadId:o._f,type:"pinned"})}),[A,t]),ne=(0,i.I4)((()=>{setTimeout((()=>{F.current=!0}),450)}),[]),se=(0,i.I4)((e=>{if(F.current){if(F.current=!1,h.wB){const e=document.querySelector(a.Ed);null==e||e.blur()}if(f)return O(),void ne();if(n===o._f&&"thread"===r&&0===S)return h.wB||X?(e.stopPropagation(),A({id:void 0},{forceOnHeavyAnimation:!0})):L(),void ne();x(),ne()}}),[n,r,S,f,x,X,A,L,O,ne]),ae=z>=a.ks&&za.l3&&z30),ie=ae||z>a._m&&z{const e=J.current;if(e)return ie&&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))}),[ie,Pe,ae,I]);const{connectionStatusText:Ze}=bt(U,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 i.ZP.createElement("div",{className:"back-button"},i.ZP.createElement(Rt.Z,{round:!0,size:"smaller",color:"translucent",onClick:se,ariaLabel:U(e?"Close":"Back")},i.ZP.createElement("div",{className:(0,_e.Z)("animated-close-icon",!e&&"state-back")})),t&&i.ZP.createElement(gt,null))}const be=Boolean(de&&me),Ee=be||!h.wB&&b&&z0)&&Ce(X,!0),i.ZP.createElement("div",{className:"chat-info-wrapper",onClick:K},(0,d.YC)(t)?i.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}):i.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?i.ZP.createElement(i.ZP.Fragment,null,Ce(),i.ZP.createElement("h3",null,U("CommentsCount",P,"i"))):"pinned"===r?i.ZP.createElement(i.ZP.Fragment,null,Ce(),i.ZP.createElement("h3",null,U("PinnedMessagesCount",P,"i"))):"scheduled"===r?i.ZP.createElement(i.ZP.Fragment,null,Ce(),i.ZP.createElement("h3",null,Z?U("Reminders"):U("messages",P,"i"))):void 0),i.ZP.createElement(jn,{hasPinnedOffset:he&&Boolean(pe)||de&&Boolean(me),chatId:t}),he&&pe&&i.ZP.createElement(Zn,{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&&i.ZP.createElement(qn,{key:t,chatId:t,settings:le,className:ce}),i.ZP.createElement("div",{className:"header-tools"},be&&i.ZP.createElement(Un,{key:(0,d.Tp)(me),message:me,className:ue}),i.ZP.createElement(gn,{chatId:t,threadId:n,messageListType:r,canExpandActions:!be})))})));function Gn(e){return"albumId"in e}function Hn(e,t){let n,s=[],a={originalDate:e[0].date,datetime:(0,z._F)(1e3*e[0].date),senderGroups:[s]};const i=[a];return e.forEach(((o,r)=>{o.isInAlbum?n?(n.messages.push(o),o.content.text&&(n.mainMessage=o)):n={albumId:o.groupedId,messages:[o],mainMessage:o}:s.push(o);const c=e[r+1];if(!n||c&&c.groupedId&&c.groupedId===n.albumId||(s.push(n),n=void 0),c){const e=(0,z._F)(1e3*c.date);a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},i.push(a),s=[],a.senderGroups.push(s)):(c.id===t||o.senderId!==c.senderId||o.isOutgoing!==c.isOutgoing||(0,d.FT)(o)||(0,d.FT)(c)||o.forwardInfo&&c.forwardInfo&&(o.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||o.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||o.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||o.inlineButtons||c.inlineButtons||c.date-o.date>600)&&(s=[],a.senderGroups.push(s))}})),i}var Vn=n(30386),_n=n(87675),zn=n(60539),Wn=n(88957);var Xn=n(60998);var Jn=n(72645),Yn=n(3657);const Kn=h.wZ?1e3:350,Qn=h.wB?300:500;var es=n(17240);function ts(e,t){return e?t?238:175:t?238:100}function ns(e,t){const n=(0,d.B4)(e),s=(0,d.MF)(e),a=(0,d.O$)(e)||(0,d.F$)(e),i=(0,d.b7)(e),o=Boolean((0,d.F$)(e)),{width:r,height:c}=a?(0,ye.Eh)(a,n,s,o,t):(0,ye.GC)(i,n,s,t),l=ts(Boolean((0,d.UD)(e)));let u=1;re+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 os(e,t,n,s){const a=function(e){return e.map((e=>{const t=ns(e);return t.width/t.height}))}(s.messages),i=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),o=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),r=a.length,c=a.some((e=>e>2)),l=(0,ye.kc)(e,t,!1,n)-(t?2.5:0)*ye.Gw;let d;const u={ratios:a,proportions:i,averageRatio:o,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return d=r>=5||c?function(e){let{ratios:t,averageRatio:n,maxWidth:s,minWidth:a,spacing:i,maxHeight:o=4*s/3}=e;const r=function(e,t){return e.map((e=>t>1.1?(0,ss.uZ)(e,1,2.75):(0,ss.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=as(r.slice(e,e+t),0);return(s-(t-1)*i)/n})(n,e)),n+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==c;++e){const t=c-e;e<=3&&t<=3&&u([e,t])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t){const s=c-e-t;e<=3&&t<=(n<.85?4:3)&&s<=3&&u([e,t,s])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t)for(let n=1;n!==c-e-t;++n){const s=c-e-t-n;e<=3&&t<=3&&n<=3&&s<=4&&u([e,t,n,s])}let m,h=0;for(let e=0;e{for(let e=1;e!==s;++e)if(n[e-1]>n[e])return 1.5;return 1})(),u=Math.abs(r-o)*c*l;(!m||u1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:n,spacing:s,maxHeight:a}=e,i=Math.round(Math.min(n/t[0],Math.min(n/t[1],(a-s)/2)));return[{dimensions:{x:0,y:0,width:n,height:i},sides:11},{dimensions:{x:0,y:i+s,width:n,height:i},sides:14}]}(e):"ww"===n||"qq"===n?function(e){const{ratios:t,maxWidth:n,spacing:s,maxHeight:a}=e,i=(n-s)/2,o=Math.round(Math.min(i/t[0],Math.min(i/t[1],a)));return[{dimensions:{x:0,y:0,width:i,height:o},sides:13},{dimensions:{x:i+s,y:0,width:i,height:o},sides:7}]}(e):function(e){const{ratios:t,minWidth:n,maxWidth:s,spacing:a,maxHeight:i}=e,o=Math.round(1.5*n),r=Math.min(Math.round(Math.max(.4*(s-a),(s-a)/t[0]/(1/t[0]+1/t[1]))),s-a-o),c=s-r-a,l=Math.min(i,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:l},sides:13},{dimensions:{x:c+a,y:0,width:r,height:l},sides:7}]}(e)}(u):3===r?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:n,ratios:s,maxWidth:a,minWidth:i}=e,o=t,r=Math.round(Math.min((t-n)/2,s[1]*(a-n)/(s[2]+s[1]))),c=o-r-n,l=Math.max(i,Math.round(Math.min((a-n)/2,Math.min(r*s[2],c*s[1])))),d=Math.min(Math.round(o*s[0]),a-n-l);return[{dimensions:{x:0,y:0,width:d,height:o},sides:13},{dimensions:{x:d+n,y:0,width:l,height:c},sides:3},{dimensions:{x:d+n,y:c+n,width:l,height:r},sides:6}]}(e):function(e){const{maxWidth:t,ratios:n,maxHeight:s,spacing:a}=e,i=t,o=Math.round(Math.min(i/n[0],.66*(s-a))),r=(t-a)/2,c=Math.min(s-o-a,Math.round(Math.min(r/n[1],r/n[2])));return[{dimensions:{x:0,y:0,width:i,height:o},sides:11},{dimensions:{x:0,y:o+a,width:r,height:c},sides:12},{dimensions:{x:r+a,y:o+a,width:i-r-a,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function(e){let{maxWidth:t,ratios:n,spacing:s,maxHeight:a,minWidth:i}=e;const o=t,r=Math.round(Math.min(o/n[0],.66*(a-s))),c=Math.round((t-2*s)/(n[1]+n[2]+n[3])),l=Math.max(i,Math.round(Math.min(.4*(t-2*s),c*n[1]))),d=Math.round(Math.max(Math.max(i,.33*(t-2*s)),c*n[3])),u=o-l-d-2*s,m=Math.min(a-r-s,c);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:l,height:m},sides:12},{dimensions:{x:l+s,y:r+s,width:u,height:m},sides:4},{dimensions:{x:l+s+u+s,y:r+s,width:d,height:m},sides:6}]}(e):function(e){let{maxHeight:t,ratios:n,maxWidth:s,spacing:a,minWidth:i}=e;const o=t,r=Math.round(Math.min(o*n[0],.6*(s-a))),c=Math.round((t-2*a)/(1/n[1]+1/n[2]+1/n[3])),l=Math.round(c/n[1]),d=Math.round(c/n[2]),u=o-l-d-2*a,m=Math.max(i,Math.min(s-r-a,c));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+a,y:0,width:m,height:l},sides:3},{dimensions:{x:r+a,y:l+a,width:m,height:d},sides:2},{dimensions:{x:r+a,y:l+d+2*a,width:m,height:u},sides:6}]}(e)}(u),{layout:d,containerStyle:is(d)}}let rs,cs;function ls(e){return cs||(cs=getComputedStyle(document.documentElement).getPropertyValue("--font-family")),rs||(rs=document.createElement("span"),rs.style.font=`400 12px ${cs}`,rs.style.whiteSpace="nowrap",rs.style.position="absolute",rs.style.left="-999px",rs.style.opacity=".01",document.body.appendChild(rs)),rs.innerHTML=e,rs.offsetWidth}function ds(e,t,n,s,a,o){(0,i.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,zn.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==s?1e3:void 0,s,void 0,o)}}),[e,t,n,s,a,o])}var us=n(3858);const ms=3*ye.Gw,hs=Number(ye.Gw),gs="data-is-document-group-hover";function ps(e,t,n,a,o,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,i.sO)();return(0,i.d4)((()=>{if(!h.$b||o||!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,o,n,v,C,b,r,m]),{handleMouseDown:o?void 0:function(e){(0,Vn.q)(e),d(e)},handleClick:function(t){if(o)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:o?c?us.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]")||m)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:o?void 0:function(){h.$b||v({messageId:n})},handleContentDoubleClick:h.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:function(e){const t=g.current;if(!t)return;const{clientX:n,clientY:s}=e,{x:a,width:i,y:o,height:r}=t.getBoundingClientRect(),c=Math.abs(p?n-a:a+i-n){const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"ContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0}));var Zs=n(45601);const Cs=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s;let{message:a}=t;const{byId:i}=e.users,o=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)||o===a.chatId);return{usersById:i,senderUser:!v&&o?(0,c.dy)(e,o):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:o,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,i.sO)(null);(0,Yn._N)(S,a),(0,ln.Z)(n.chatId,n.replyToMessageId,f),ds(S,n.chatId,I,w,y);const M=l<=0,[R,k]=(0,vt.Z)(M),N=Boolean(null===(t=n.content.action)||void 0===t?void 0:t.text.startsWith("ActionGift"));(0,i.d4)((()=>{M||setTimeout(k,10*l)}),[l,k,M]);const T=(0,Yn.Op)(S,r),A=(0,i.sO)((()=>{const e=(null==Z?void 0:Z.current)&&n.id>=Z.current;return N&&!n.isOutgoing&&e})());(0,i.d4)((()=>{T&&A.current&&(A.current=!1,b())}),[T,b]);const{transitionClassNames:x}=(0,at.Z)(R,void 0,M,!1),B=(0,i.Ye)((()=>p?p.map((e=>null==m?void 0:m[e])).filter(Boolean):void 0),[p,m]),L=(0,ys.D)(E,n,h,g,B,f,v,{isEmbedded:c},o,r),{isContextMenuOpen:O,contextMenuPosition:U,handleBeforeContextMenu:F,handleContextMenu:j,handleContextMenuClose:D,handleContextMenuHide:q}=(0,es.Z)(S),$=void 0!==U;if(c)return i.ZP.createElement("span",{ref:S,className:"embedded-action-message"},L);const G=(0,_e.Z)("ActionMessage message-list-item",I&&!y&&"focused",N&&"premium-gift",$&&"has-menu-open",u&&"last-in-list",x);return i.ZP.createElement("div",{ref:S,id:(0,d.d0)(n.id),className:G,"data-message-id":n.id,onMouseDown:e=>{(0,Vn.q)(e),F(e)},onContextMenu:j},i.ZP.createElement("span",null,L),N&&i.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})}},i.ZP.createElement(Zs.Z,{key:n.id,sticker:P,play:!0,noLoop:!0,nonInteractive:!0}),i.ZP.createElement("strong",null,E("ActionGiftPremiumTitle")),i.ZP.createElement("span",null,E("ActionGiftPremiumSubtitle",E("Months",null===(H=n.content.action)||void 0===H?void 0:H.months,"i"))),i.ZP.createElement("span",{className:"action-message-button"},E("ActionGiftPremiumView"))),U&&i.ZP.createElement(Ps,{isOpen:O,anchor:U,message:n,messageListType:"thread",onClose:D,onCloseAnimationEnd:q}));var H}))),bs=e=>{var t;let{className:n,message:s,sender:a,title:o,customText:r,isProtected:c,noUserColors:l,hasContextMenu:u,observeIntersectionForLoading:m,observeIntersectionForPlaying:h,onClick:g}=e;const p=(0,i.sO)(null),f=(0,Yn.Op)(p,m),v=(0,pn.Z)(s&&(0,d.Ti)(s,"pictogram"),!f),I=(0,fn.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 i.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:o}=(0,ye.W7)();return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("img",{src:t||e,width:a,height:o,alt:"",className:(0,_e.Z)("pictogram",n&&"round"),draggable:!s}),s&&i.ZP.createElement("span",{className:"protector"}))}(I,v,w,c),i.ZP.createElement("div",{className:"message-text"},i.ZP.createElement("p",{dir:"auto"},s?(0,d.FT)(s)?i.ZP.createElement(Cs,{message:s,isEmbedded:!0,observeIntersectionForLoading:m,observeIntersectionForPlaying:h}):i.ZP.createElement(Pn.Z,{lang:y,message:s,noEmoji:Boolean(I),observeIntersectionForLoading:m,observeIntersectionForPlaying:h}):r||" "),i.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Ln.Z)(P||o||" "))),u&&i.ZP.createElement("i",{className:"embedded-more icon-more"}))};var Es=n(82535),Ss=n(54752),Ms=n(8018),Rs=n(48198),ks=n(97799);const Ns=(0,i.X$)((e=>{var t,n;let{reaction:a,activeReaction:o,isInMeta:r,availableReactions:c}=e;const{stopActiveReaction:l}=(0,s.Sv)(),d=null==c?void 0:c.find((e=>e.reaction===a)),u=null==d||null===(t=d.centerIcon)||void 0===t?void 0:t.id,m=null==d||null===(n=d.aroundAnimation)||void 0===n?void 0:n.id,h=u&&`sticker${u}`,g=m&&`sticker${m}`,p=(0,pn.Z)(h,!u),f=(0,pn.Z)(g,!m),v=Boolean((null==o?void 0:o.reaction)===a&&p&&f),{shouldRender:I,transitionClassNames:w}=(0,at.Z)(v,void 0,!0,"slow"),y=(0,i.I4)((()=>{l({messageId:null==o?void 0:o.messageId,reaction:a})}),[null==o?void 0:o.messageId,a,l]),[P,Z,C]=(0,vt.Z)(),b=!v||!P,E=(0,_e.Z)("ReactionAnimatedEmoji",r&&"in-meta",I&&"is-animating");return i.ZP.createElement("div",{className:E},b&&i.ZP.createElement(Rs.Z,{reaction:a}),I&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(ks.Z,{key:u,className:w,size:30,tgsUrl:p,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:Z,onEnded:C}),i.ZP.createElement(ks.Z,{key:m,className:(0,_e.Z)("effect",w),size:100,tgsUrl:f,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:y})))})),Ts=(0,i.X$)((e=>{var t;let{message:n,outgoingStatus:s,signature:a,onClick:o,withReactions:r,activeReaction:c,withReactionOffset:l,availableReactions:d,reactionMessage:u}=e;const m=(0,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,i.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 i.ZP.createElement("span",{className:(0,_e.Z)("MessageMeta",l&&"reactions-offset"),dir:m.isRtl?"rtl":"ltr",onClick:o,"data-ignore-on-paste":!0},p&&p.map((e=>i.ZP.createElement(Ns,{activeReaction:c,reaction:e.reaction,isInMeta:!0,availableReactions:d}))),Boolean(n.views)&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"message-views"},(0,ut.bi)(n.views)),i.ZP.createElement("i",{className:"icon-channelviews"})),a&&i.ZP.createElement("span",{className:"message-signature"},(0,Ln.Z)(a)),i.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:g},n.isEdited&&`${m("EditedMessage")} `,(0,z.mr)(m,1e3*n.date)),s&&i.ZP.createElement(Ms.Z,{status:s}))}));var As=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,i.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,Yn.Op)(v,n),b=(0,Yn.Op)(v,a),E=`sticker${I.id}?size=f`,S=(0,pn.Z)(E,!C||!P,o.IU.BlobUrl,c),[M,R,k]=(0,vt.Z)(),N=(0,i.I4)((()=>{k(),null==m||m()}),[m,k]);(0,i.d4)((()=>{P&&b&&l&&(R(),null==u||u())}),[P,b,u,l,R]);const T=(0,i.I4)((()=>{p({stickerSetInfo:I.stickerSetInfo})}),[p,I]),A=(0,i.I4)((()=>{if(P)return M?void g({message:f("PremiumStickerTooltip"),action:T,actionText:f("ViewAction")}):(R(),void(null==u||u()));T()}),[P,M,f,u,T,g,R]),x="isMissing"in w,{width:B,height:L}=(0,ye.Wr)(I),O=(0,_e.Z)("Sticker media-inner",x&&"inactive",P&&!t.isOutgoing&&"reversed");return i.ZP.createElement("div",{ref:v,className:O,style:`width: ${B}px; height: ${L}px;`,onClick:x?void 0:A},i.ZP.createElement(As.Z,{containerRef:v,sticker:I,fullMediaHash:Z,fullMediaClassName:"full-media",size:B,shouldLoop:r,noLoad:!C,noPlay:!b,withSharedAnimation:!0,cacheBuster:c}),P&&C&&M&&i.ZP.createElement(ks.Z,{key:E,className:"effect-sticker",tgsUrl:S,size:1.49*B,play:!0,isLowPriority:!0,noLoop:!0,onEnded:N}))};var Bs=n(13365),Ls=n(74753),Os=n(80036);const Us=7*ye.Gw;function Fs(e,t,n,a,o,r,l,d){const{interactWithAnimatedEmoji:u,sendEmojiInteraction:m,sendWatchingEmojiInteraction:h}=(0,s.Sv)(),g=r||l,p=(0,i.sO)(null),f=(0,i.sO)(null),v=(0,pn.Z)(n?`document${n}`:void 0,!n),I=d||Us,w=(0,Os.Z)(`width: ${I}px`,`height: ${I}px`,(l||r)&&"cursor: pointer"),y=(0,i.sO)(void 0),P=(0,i.sO)(void 0),Z=(0,i.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,i.I4)((()=>{const e=f.current;v&&(e&&(e.pause(),e.remove()),f.current=new Audio,f.current.src=v,(0,Ls.Z)(f.current),f.current.addEventListener("ended",(()=>{f.current=void 0}),{once:!0}))}),[v]),b=(0,i.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:!o}),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,o,r,t,C,Z,I]);return(0,i.d4)((()=>{const n=p.current;n&&a&&a.forEach((s=>{let{id:a,startSize:i,messageId:d}=s;if(i||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:!o}),C()}))}),[a,e,l,o,r,t,C,h,I]),{ref:p,size:I,style:w,handleClick:b}}var js=n(21179);const Ds=(0,i.X$)((0,s.c$)(((e,t)=>{let{emoji:n,withEffects:s}=t;const a=(0,c.CP)(e,n);return{sticker:(0,c.zB)(e,n),effect:s?(0,c.tH)(e,n):void 0,soundId:(0,c.Oh)(e,n),localSticker:a,localEffect:a&&s?(0,c.cu)(a):void 0}}))((e=>{let{isOwn:t,observeIntersection:n,lastSyncTime:s,forceLoadPreview:a,messageId:o,chatId:r,activeEmojiInteractions:c,sticker:l,effect:d,localSticker:u,localEffect:m,soundId:h}=e;const{ref:g,size:p,style:f,handleClick:v}=Fs(r,o,h,c,t,m,null==d?void 0:d.emoji),I=(0,Yn.Op)(g,n);return u?i.ZP.createElement(js.Z,{tgsUrl:Bs.l[u],size:p,quality:1,play:I,forceOnHeavyAnimation:!0,ref:g,className:"AnimatedEmoji media-inner",style:f,onClick:v}):i.ZP.createElement(Zs.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 qs=n(41012);const $s=(0,i.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:o,sticker:r,effect:c,soundId:l,observeIntersection:d}=e;const{ref:u,size:m,style:h,handleClick:g}=Fs(a,s,l,o,t,void 0,null==c?void 0:c.emoji,(0,ws.qo)(1));return i.ZP.createElement(qs.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})}))),Gs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function Hs(e,t,n,s,a){return s?Promise.resolve(Gs[a||"light"][t?"outgoing":"incoming"]):async function(e,t){const n=new Image;n.src=e,n.crossOrigin="anonymous",n.width||await new Promise((e=>{n.onload=e}));const s=document.createElement("canvas"),a=s.getContext("2d");s.width=n.width,s.height=n.height,a.drawImage(n,0,0,n.width,n.height);const i=t?n.width-1:0,o=n.height-1;return`rgba(${Array.from(a.getImageData(i,o,1,1).data).join(",")})`}(e,t)}var Vs=n(92566),_s=n(15866);function zs(e,t){return(0,_s.Z)((0,d.DH)(e),Boolean(t),h.wB&&!h.vX)}var Ws=n(70692),Xs=n(39196);const Js=e=>{let{id:t,message:n,observeIntersection:s,noAvatars:o,canAutoLoad:r,isInSelectMode:c,isSelected:l,uploadProgress:u,size:m="inline",dimensions:h,nonInteractive:g,shouldAffectAppendix:p,isDownloading:f,isProtected:v,withAspectRatio:I,theme:w,onClick:y,onCancelUpload:P}=e;const Z=(0,i.sO)(null),C=((0,d.O$)(n)||(0,d.F$)(n)).blobUrl,b=(0,Yn.Op)(Z,s),[E,S]=(0,i.eJ)(r),M=E&&b,{mediaData:R,loadProgress:k}=(0,Vs.Z)((0,d.Ti)(n,m),!M),N=C||R,[T]=(0,i.eJ)(!N),A=zs(n,N),{loadProgress:x}=(0,Vs.Z)((0,d.Ti)(n,"download"),!f,(0,d.kG)(n,"download")),{isUploading:B,isTransferring:L,transferProgress:O}=(0,d.Sc)(n,u||(f?x:k),M&&!N),U=!1===(0,rn.Z)(E),F=(0,Ws.Z)(N),{shouldRender:j,transitionClassNames:D}=(0,at.Z)(L,void 0,U,"slow"),{shouldRender:q,transitionClassNames:$}=(0,at.Z)(!N&&!E),G=(0,i.I4)((()=>{B?P&&P(n):N?y&&y(n.id):S((e=>!e))}),[N,B,n,P,y]),H=(0,d.B4)(n);(0,Jn.Z)((e=>{let[t]=e;if(!p)return void(t&&Z.current.closest(".message-content").removeAttribute(a.s2));const n=Z.current.closest(".message-content");N?Hs(N,H,0,l,w).then((e=>{n.style.setProperty("--appendix-bg",e),n.setAttribute(a.s2,"")})):n.classList.add("has-appendix-thumb")}),[p,N,H,c,l,w]);const{width:V,height:_,isSmall:z}=h||ns(n,o),W=(0,_e.Z)("media-inner",!B&&!g&&"interactive",z&&"small-image",V===_&&"square-image"),X=I?`aspect-ratio: ${(V/_).toFixed(3)}/ 1`:"",J=h?`width: ${V}px; height: ${_}px; left: ${h.x}px; top: ${h.y}px;${X}`:"";return i.ZP.createElement("div",{id:t,ref:Z,className:W,style:J,onClick:B?void 0:G},T&&i.ZP.createElement("canvas",{ref:A,className:"thumbnail",style:`width: ${V}px; height: ${_}px;${X}`}),i.ZP.createElement("img",{src:N,className:`full-media ${F}`,width:V,height:_,alt:"",draggable:!v}),v&&i.ZP.createElement("span",{className:"protector"}),j&&!q&&i.ZP.createElement("div",{className:`media-loading ${D}`},i.ZP.createElement(Xs.Z,{progress:O,onClick:B?G:void 0})),q&&i.ZP.createElement("i",{className:(0,_e.Z)("icon-download",$)}),L&&i.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*O),"%"))};var Ys=n(12019),Ks=n(35148);function Qs(){return Qs=Object.assign||function(e){for(var t=1;t{var t;let{id:n,message:a,observeIntersection:o,noAvatars:r,canAutoLoad:c,canAutoPlay:l,uploadProgress:u,lastSyncTime:m,dimensions:h,onClick:g,onCancelUpload:p,isDownloading:f,isProtected:v,withAspectRatio:I}=e;const w=(0,i.sO)(null),y=(0,i.sO)(null),P=(0,d.b7)(a)||(0,d.Cg)(a),Z=P.blobUrl,C=(0,Yn.Op)(w,o),[b,E]=(0,i.eJ)(c),S=Boolean(b&&C&&m),[M,R]=(0,i.eJ)(l),k=(0,pn.Z)((0,d.Ti)(a,"pictogram"),!(C&&m),(0,d.kG)(a,"pictogram"),m),N=(0,Ws.Z)(k),{mediaData:T,loadProgress:A}=(0,Vs.Z)((0,d.Ti)(a,"inline"),!S,(0,d.kG)(a,"inline"),m),x=Z||T,B=Boolean(C&&x),[L]=(0,i.eJ)(!k),O=zs(a,k),{loadProgress:U}=(0,Vs.Z)((0,d.Ti)(a,"download"),!f,(0,d.kG)(a,"download"),m),{isBuffered:F,bufferingHandlers:j}=(0,Ys.Z)(!c),{isUploading:D,isTransferring:q,transferProgress:$}=(0,d.Sc)(a,u||(f?U:A),S&&!F||f),G=!1===(0,rn.Z)(b),{shouldRender:H,transitionClassNames:V}=(0,at.Z)(q,void 0,G),{shouldRender:_,transitionClassNames:W}=(0,at.Z)(b&&!M&&!H),[X,J]=(0,i.eJ)(0),Y=(0,i.I4)((e=>{J(Math.max(0,e.currentTarget.currentTime-1))}),[]),K=(null===(t=y.current)||void 0===t?void 0:t.duration)||P.duration||0,Q=(0,d.B4)(a),ee=(0,d.MF)(a),{width:te,height:ne}=h||(0,ye.GC)(P,Q,ee,r),se=(0,i.I4)((()=>{D?p&&p(a):f?(0,s.Sv)().cancelMessageMediaDownload({message:a}):x?x&&!M?R(!0):g&&g(a.id):E((e=>!e))}),[D,f,x,M,g,p,a]),ae=(0,_e.Z)("media-inner dark",!D&&"interactive"),ie=I?`aspect-ratio: ${(te/ne).toFixed(3)}/ 1`:"",oe=h?`width: ${te}px; height: ${ne}px; left: ${h.x}px; top: ${h.y}px;${ie}`:"";return i.ZP.createElement("div",{ref:w,id:n,className:ae,style:oe,onClick:D?void 0:se},L?i.ZP.createElement("canvas",{ref:O,className:"thumbnail",style:`width: ${te}px; height: ${ne}px;${ie}`}):i.ZP.createElement("img",{src:k,className:(0,_e.Z)("thumbnail",N),style:`width: ${te}px; height: ${ne}px;${ie}`,alt:"",draggable:!v}),B&&i.ZP.createElement(Ks.Z,Qs({ref:y,canPlay:M,src:x,className:"full-media",width:te,height:ne,muted:!0,loop:!0,playsInline:!0},j,{draggable:!v,onTimeUpdate:Y,style:ie})),v&&i.ZP.createElement("span",{className:"protector"}),_&&i.ZP.createElement("i",{className:(0,_e.Z)("icon-large-play",W)}),H&&i.ZP.createElement("div",{className:(0,_e.Z)("media-loading",V)},i.ZP.createElement(Xs.Z,{progress:$,onClick:se})),!b&&i.ZP.createElement("i",{className:"icon-download"}),q?i.ZP.createElement("span",{className:"message-transfer-progress"},D||f?`${Math.round(100*$)}%`:"..."):i.ZP.createElement("div",{className:"message-media-duration"},P.isGif?"GIF":(0,z.k9)(Math.max(K-X,0))))};var ta=n(6272);const na=(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:o}=e;const{openChat:r}=(0,s.Sv)(),{firstName:c,lastName:l,phoneNumber:d,userId:u}=t,m="0"!==u,h=(0,i.I4)((()=>{r({id:u})}),[r,u]);return i.ZP.createElement("div",{className:(0,_e.Z)("Contact",m&&"interactive"),onClick:m?h:void 0},i.ZP.createElement(Fn.Z,{size:"large",user:n,text:c||l,animationLevel:o,withVideo:!0}),i.ZP.createElement("div",{className:"contact-info"},i.ZP.createElement("div",{className:"contact-name"},c," ",l),i.ZP.createElement("div",{className:"contact-phone"},(0,ta.WZ)(a,d))))}));var sa=n(20230),aa=n(51218),ia=n(14434),oa=n(96937);function ra(e,t){return t>0?(e/t*100).toFixed():0}const ca=e=>{let{answer:t,voteResults:n,totalVoters:s,maxVotersCount:a,correctResults:o,shouldAnimate:r}=e;const c=n&&n.find((e=>e.option===t.option)),l=0===o.length||-1!==o.indexOf(t.option),d=o.length>0&&l||(null==c?void 0:c.isChosen),u=c?ra(c.votersCount,s||0):0,[m,h]=(0,i.eJ)(r?0:u),g=(0,i.sO)(null),p=c?ra(c.votersCount,a||0):0,f=m!==u;if((0,i.d4)((()=>{r&&h(u)}),[r,u]),(0,i.d4)((()=>{const e=g.current;if(e&&r){const t=e.firstElementChild,n=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",n):e.innerHTML=`\n \n \n `}}),[f,r]),!n||!c)return;const v=`width: ${p}%; transform:scaleX(${f?0:1})`;return i.ZP.createElement("div",{className:"PollOption",dir:"ltr"},i.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",d&&i.ZP.createElement("span",{className:(0,_e.Z)("poll-option-chosen",!l&&"wrong",r&&"animate")},i.ZP.createElement("i",{className:l?"icon-check":"icon-close"}))),i.ZP.createElement("div",{className:"poll-option-right"},i.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,Ln.Z)(t.text)),i.ZP.createElement("div",{className:(0,_e.Z)("poll-option-answer",d&&!l&&"wrong")},i.ZP.createElement("div",{className:"poll-option-corner",ref:g}),i.ZP.createElement("div",{className:"poll-option-line",style:v}))))};function la(e){e.stopPropagation()}const da=(0,i.X$)((0,s.c$)(((e,t)=>{let{poll:n}=t;const{recentVoterIds:s}=n.results,{serverTimeOffset:a,users:{byId:i}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:i,serverTimeOffset:a}:{}}))((e=>{let{message:t,poll:n,recentVoterIds:a,usersById:o,onSendVote:r,serverTimeOffset:c}=e;const{loadMessage:l,openPollResults:d,requestConfetti:u}=(0,s.Sv)(),{id:m,chatId:h}=t,{summary:g,results:p}=n,[f,v]=(0,i.eJ)(!1),[I,w]=(0,i.eJ)([]),[y,P]=(0,i.eJ)(!1),[Z,C]=(0,i.eJ)(!1),[b,E]=(0,i.eJ)(!g.closed&&g.closeDate&&g.closeDate>0?Math.min(g.closeDate-Math.floor(Date.now()/1e3)+c,g.closePeriod):0),S=(0,i.sO)(null),{results:M,totalVoters:R}=p,k=M&&M.some((e=>e.isChosen)),N=!g.closed&&!k,T=!N&&g.isPublic&&Number(p.totalVoters)>0,A=N&&g.multipleChoice,x=M?Math.max(...M.map((e=>e.votersCount))):R,B=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,i.d4)((()=>{var e;const t=null===(e=n.results.results)||void 0===e?void 0:e.find((e=>e.isChosen));f&&t&&(t.isCorrect&&u(),v(!1))}),[f,n.results.results,u]),(0,i.d4)((()=>{b>0&&setTimeout((()=>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 ${(0,z.k9)(b)}\n \n \n `}}),[b,g.closePeriod]),(0,i.d4)((()=>{g.quiz&&(b<=0||k&&!g.closed)&&l({chatId:h,messageId:m})}),[h,b,k,l,m,g.closed,g.quiz]),(0,i.d4)((()=>{let e;return g.quiz&&!g.closed&&g.closePeriod&&g.closePeriod>0&&(e=window.setTimeout((()=>{l({chatId:h,messageId:m})}),1e3*g.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[N,h,l,m,g.closePeriod,g.closed,g.quiz]);const O=(0,i.Ye)((()=>a?a.reduce(((e,t)=>{const n=o[t];return n&&e.push(n),e}),[]):[]),[o,a]),U=(0,i.I4)((e=>{w([e]),v(!0),C(!0),r([e])}),[r]),F=(0,i.I4)((e=>{w(e)}),[]),j=(0,i.I4)((()=>{v(!0),C(!0),r(I)}),[r,I]),D=(0,i.I4)((()=>{d({chatId:h,messageId:m})}),[h,m,d]),q=(0,i.I4)((()=>{P(!0)}),[]),$=(0,i.I4)((()=>{P(!1),C(!1)}),[]);(0,i.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 i.ZP.createElement("div",{className:"Poll",dir:G.isRtl?"auto":"ltr"},y&&n.results.solution&&i.ZP.createElement(oa.Z,{message:(0,sa.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:$,containerId:"#middle-column-portals"}),i.ZP.createElement("div",{className:"poll-question"},(0,Ln.Z)(g.question,["emoji","br"])),i.ZP.createElement("div",{className:"poll-type"},G(function(e){return void 0===e.isPublic?" ":e.closed?"FinalResults":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.isPublic?"PublicPoll":"AnonymousPoll"}(g)),O.length>0&&i.ZP.createElement("div",{className:"poll-recent-voters"},O.map((e=>i.ZP.createElement(Fn.Z,{size:"micro",user:e})))),b>0&&N&&i.ZP.createElement("div",{ref:S,className:"poll-countdown"}),g.quiz&&n.results.solution&&!N&&i.ZP.createElement(Rt.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:y,onClick:q,ariaLabel:"Show Solution"},i.ZP.createElement("i",{className:"icon-lamp"}))),N&&i.ZP.createElement("div",{className:"poll-answers",onClick:la},A?i.ZP.createElement(aa.Z,{options:L,onChange:F,disabled:t.isScheduled||f,loadingOptions:f?I:void 0,round:!0}):i.ZP.createElement(ia.Z,{name:`poll-${m}`,options:L,onChange:U,disabled:t.isScheduled||f,loadingOption:f?I[0]:void 0})),!N&&i.ZP.createElement("div",{className:"poll-results"},g.answers.map((function(e){return i.ZP.createElement(ca,{key:e.option,shouldAnimate:Z||!N,answer:e,voteResults:M,totalVoters:R,maxVotersCount:x,correctResults:B})}))),!T&&!A&&i.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,n){return n?e(t?"Answer":"Vote",n,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(G,g.quiz,p.totalVoters)),A&&i.ZP.createElement(Rt.Z,{isText:!0,disabled:0===I.length,size:"tiny",onClick:j},G("PollSubmitVotes")),T&&i.ZP.createElement(Rt.Z,{isText:!0,size:"tiny",onClick:D},G("PollViewResults")))})));var ua=n(48035),ma=n(10088);const ha=(0,i.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,canAutoPlay:o,inPreview:r,lastSyncTime:c,isDownloading:l=!1,isProtected:u,theme:m,onMediaClick:h,onCancelMediaTransfer:g}=e;const p=(0,d.s1)(t),f=(0,i.I4)((()=>{h()}),[h]);if(!p)return;const{siteName:v,url:I,displayUrl:w,title:y,description:P,photo:Z,video:C}=p,b=(0,ua.Z)(P,170),E=Boolean(b||y||v);let S=!1;if(E&&null!=p&&p.photo&&!p.video){const{width:e,height:n}=ns(t);S=e===n}const M=(Z||C)&&h&&!S,R=(0,_e.Z)("WebPage",r&&"in-preview",S&&"with-square-photo",!Z&&!C&&!r&&"without-media",C&&"with-video",!E&&"no-article");return i.ZP.createElement("div",{className:R,"data-initial":(v||w)[0],dir:"auto"},Z&&!C&&i.ZP.createElement(Js,{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,size:S?"pictogram":"inline",nonInteractive:!M,onClick:M?f:void 0,onCancelUpload:g,isDownloading:l,isProtected:u,withAspectRatio:!0,theme:m}),E&&i.ZP.createElement("div",{className:"WebPage-text"},i.ZP.createElement(ma.Z,{className:"site-name",url:I,text:v||w}),!r&&y&&i.ZP.createElement("p",{className:"site-title"},(0,Ln.Z)(y)),b&&i.ZP.createElement("p",{className:"site-description"},(0,Ln.Z)(b,["emoji","br"]))),!r&&C&&i.ZP.createElement(ea,{message:t,observeIntersection:n,noAvatars:s,canAutoLoad:a,canAutoPlay:o,lastSyncTime:c,onClick:M?f:void 0,onCancelUpload:g,isDownloading:l,isProtected:u,withAspectRatio:!0}))}));var ga=n(17921);const pa=(0,i.X$)((e=>{var t,n;let{message:s,shouldAffectAppendix:o,isInSelectMode:r,isSelected:c,theme:l}=e;const u=(0,i.sO)(null),m=(0,yt.Z)(),h=(0,d.eO)(s),{title:g,text:p,amount:f,currency:v,isTest:I,photo:w}=h,y=(0,pn.Z)((0,d.O9)(w));return(0,Jn.Z)((e=>{let[t]=e;if(o){if(y){const e=u.current.closest(".message-content");Hs(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)}),[o,y,r,c,l]),i.ZP.createElement("div",{ref:u,className:"Invoice"},g&&i.ZP.createElement("p",{className:"title"},(0,Ln.Z)(g)),p&&i.ZP.createElement("div",null,(0,Ln.Z)(p,["emoji","br"])),i.ZP.createElement("div",{className:"description "+(w?"has-image":"")},y&&i.ZP.createElement("img",{className:"invoice-image",src:y,alt:"",crossOrigin:"anonymous"}),!y&&w&&i.ZP.createElement(ga.Z,{width:null===(t=w.dimensions)||void 0===t?void 0:t.width,height:null===(n=w.dimensions)||void 0===n?void 0:n.height,forceAspectRatio:!0}),i.ZP.createElement("p",{className:"description-text"},(0,Ve.x)(f,v,m.code),I&&i.ZP.createElement("span",null,m("PaymentTestInvoice")))))})),fa={root:"rwnm0xOh31c2MY4kK2No",dots:"Nlcnrzv_f5cSxFsPOGt2",duration:"lKSp02aI8WDGX3393nkh",buy:"gxQfWp0jp0_2Z4qWiXKN",canvas:"a_WnxsI6X0B4j7QRRoOA"},va=(0,i.X$)((e=>{let{message:t,lastSyncTime:n}=e;const{openInvoice:a,loadExtendedMedia:o}=(0,s.Sv)(),r=(0,yt.Z)(),c=(0,d.eO)(t),{chatId:l,id:u}=t,m=(0,i.I4)((()=>{o({chatId:l,ids:[u]})}),[l,u,o]);(0,ot.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,_s.Z)(null==I?void 0:I.dataUri,!1,void 0,25,f,v),P=(0,i.I4)((()=>{a({chatId:l,messageId:u,isExtendedMedia:!0})}),[l,u,a]);return i.ZP.createElement("div",{className:(0,_e.Z)(fa.root,"media-inner"),onClick:P},i.ZP.createElement("canvas",{ref:y,className:fa.canvas,width:f,height:v}),i.ZP.createElement("div",{className:fa.dots}),Boolean(w)&&i.ZP.createElement("div",{className:fa.duration},(0,z.k9)(w)),i.ZP.createElement("div",{className:fa.buy},i.ZP.createElement("i",{className:(0,_e.Z)("icon-lock",fa.lock)}),r("Checkout.PayPrice",(0,Ve.x)(h,g))))})),Ia=new Map(Object.entries({"building/medical":"#43b3f4","building/gym":"#43b3f4","education/cafeteria":"#f7943f","travel/bedandbreakfast":"#9987ff","travel/hotel":"#9987ff","travel/hostel":"#9987ff","travel/resort":"#9987ff","travel/hotel_bar":"#e56dd6",arts_entertainment:"#e56dd6",building:"#6e81b2",education:"#a57348",event:"#959595",food:"#f7943f",home:"#00aeef",nightlife:"#e56dd6",parks_outdoors:"#6cc039",shops:"#ffb300",travel:"#1c9fff",work:"#ad7854"})),wa=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"];var ya=n(28183);const Pa=n.p+"map-pin.7b3c3e60ee24795e4bd2.svg",Za=1e-4,Ca={width:400,height:300,zoom:16,scale:2},ba={__html:''},Ea=(0,i.X$)((e=>{let{message:t,peer:n,lastSyncTime:s,isInSelectMode:o,isSelected:r,theme:c,serverTimeOffset:l}=e;const u=(0,i.sO)(null),m=(0,i.sO)(null),h=(0,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,i.eJ)(I),b="venue"===v||"geoLive"===v&&!y,{width:E,height:S,zoom:M,scale:R}=Ca,k=Boolean(s)&&(0,d.k6)(Z,E,S,M,R),N=(0,pn.Z)(k),T=(0,rn.Z)(N),A=N||T,x=n&&(0,d.YC)(n.id),B=n&&x?n:void 0,L=n&&!x?n:void 0,O=(0,d.B4)(t),U=(0,i.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]),F=(0,i.I4)((e=>{if("geoLive"!==v)return;const n=24*Math.PI,s=e.lastElementChild,a=e.firstElementChild,i=t.date+f.period-(0,p.b)(l),o=(1-i/f.period)*n,r=(0,z.mB)(h,1e3*i);s&&a?(a.textContent=r,s.firstElementChild.setAttribute("stroke-dashoffset",`-${o}`)):e.innerHTML=`\n ${r}\n \n \n `}),[v,t.date,f,l,h]);return(0,i.bt)((()=>{m.current&&F(m.current)}),[F]),(0,Jn.Z)((e=>{let[t]=e;if(b)t||u.current.closest(".message-content").removeAttribute(a.s2);else if(A){const e=u.current.closest(".message-content");Hs(A,O,0,r,c).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(a.s2,"")}))}}),[b,O,o,r,c,A]),(0,i.d4)((()=>{Math.abs(I.lat-Z.lat){g()}),y?void 0:1e3*(P||0)),(0,ot.Z)((()=>{const e=m.current;e&&F(e)}),P?1e3:void 0),i.ZP.createElement("div",{ref:u,className:"Location media-inner interactive",onClick:()=>{var e;const t=function(e,t,n){return`http://maps.google.com/maps/place/${e}+${t}/@${e},${t},${n}z`}(Z.lat,Z.long,M);null===(e=window.open(t,"_blank","noopener"))||void 0===e||e.focus()}},i.ZP.createElement("div",{className:"map-wrapper"},A?i.ZP.createElement("img",{className:"full-media map",src:A,alt:"Location on a map",width:Ca.width,height:Ca.height}):i.ZP.createElement(ga.Z,{width:E,height:S}),function(){if(A)return i.ZP.createElement(i.ZP.Fragment,null,Boolean(U)&&!y&&i.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*U}px; height: ${2*U}px`}),function(){const e=(0,_e.Z)("pin",v,y&&"expired");if("geoLive"===v)return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:ba},i.ZP.createElement(Fn.Z,{chat:L,user:B,className:"location-avatar"}),void 0!==f.heading&&i.ZP.createElement("div",{className:"direction",style:`--direction: ${f.heading}deg`}));if("venue"===v){const t=function(e){return e?Ia.get(e)||Ia.get(e.split("/")[0])||wa[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%wa.length)]:"#008df2";var t}(f.venueType),n=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(f.venueType);return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:ba,style:`--pin-color: ${t}`},i.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return i.ZP.createElement("img",{className:e,src:Pa,alt:""})}())}()),function(){if(b)return"venue"===v?i.ZP.createElement("div",{className:"location-info"},i.ZP.createElement("div",{className:"location-info-title"},f.title),i.ZP.createElement("div",{className:"location-info-subtitle"},f.address)):"geoLive"===v?i.ZP.createElement("div",{className:"location-info"},i.ZP.createElement("div",{className:"location-info-title"},h("AttachLiveLocation")),i.ZP.createElement("div",{className:"location-info-subtitle"},(0,z.dJ)(h,w,t.editDate)),!y&&i.ZP.createElement("div",{className:"geo-countdown",ref:m})):void 0}())})),Sa=(0,i.X$)((e=>{let{message:t,canAutoLoadMedia:n,lastSyncTime:a}=e;const{clickBotInlineButton:o}=(0,s.Sv)(),r=t.content.game,{title:c,description:l}=r,u=Boolean(a)&&(0,d.N)(r),m=Boolean(a)&&(0,d.Wc)(r),h=(0,pn.Z)(u,!n),g=(0,pn.Z)(m,!n);return i.ZP.createElement("div",{className:"Game"},i.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{o({messageId:t.id,button:t.inlineButtons[0][0]})}},!h&&!g&&i.ZP.createElement(ga.Z,{className:"skeleton preview-content"}),h&&i.ZP.createElement("img",{className:"preview-content",src:h,alt:c}),g&&i.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,disablePictureInPicture:!0,autoPlay:!0,loop:!0,src:g})),i.ZP.createElement("div",{className:"title"},c),!(0,d.UD)(t)&&i.ZP.createElement("div",{className:"description"},l))}));function Ma(e){return(0,i.X$)((0,s.c$)(((e,t)=>{const{message:n}=t;return{isInSelectMode:(0,c.CA)(e),isSelected:(0,c.vk)(e,n.id)}}))((t=>{const{isInSelectMode:n,isSelected:a,message:o,dimensions:r}=t,{toggleMessageSelection:c}=(0,s.Sv)(),l=(0,i.I4)((e=>{e.stopPropagation(),c({messageId:o.id,withShift:null==e?void 0:e.shiftKey})}),[c,o]),d=(0,i.Ye)((()=>{const{dimensions:e,onClick:s}=t;return{...t,isInSelectMode:n,isSelected:a,dimensions:{...e,x:0,y:0},onClick:n?void 0:s}}),[t,n,a]);return i.ZP.createElement("div",{className:(0,_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&&i.ZP.createElement("div",{className:"message-select-control"},a&&i.ZP.createElement("i",{className:"icon-select"})),i.ZP.createElement(e,d))})))}const Ra=Ma(Js),ka=Ma(ea),Na=(0,s.c$)(((e,t)=>{let{album:n}=t;const{chatId:s}=n.mainMessage,a=(0,c.Pu)(e),i=(0,c.xs)(e,s);return{theme:a,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:i}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:a,lastSyncTime:o,isOwn:r,isProtected:l,albumLayout:u,onMediaClick:m,uploadsById:h,activeDownloadIds:g,theme:p}=e;const{cancelSendingMessage:f}=(0,s.Sv)(),v=t.messages.length,I=(0,i.I4)((e=>{f({chatId:e.chatId,messageId:e.id})}),[f]),{width:w,height:y}=u.containerStyle;return i.ZP.createElement("div",{className:"Album",style:`width: ${w}px; height: ${y}px;`},t.messages.map((function(e,t){const{photo:f,video:w}=(0,d.qp)(e),y=h[(0,d.KK)(e)],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 i.ZP.createElement(Ra,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersection: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 i.ZP.createElement(ka,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersection:n,canAutoLoad:b,canAutoPlay:E,uploadProgress:P,lastSyncTime:o,dimensions:Z,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})})))}));function Ta(){return Ta=Object.assign||function(e){for(var t=1;t{let{message:t,observeIntersection:n,canAutoLoad:a,lastSyncTime:r,isDownloading:c}=e;const l=(0,i.sO)(null),u=(0,i.sO)(null),m=(0,i.sO)(null),h=t.content.video,g=(0,Yn.Op)(l,n),[p,f]=(0,i.eJ)(a),v=Boolean(p&&g&&r),{mediaData:I,loadProgress:w}=(0,Vs.Z)((0,d.Ti)(t,"inline"),!v,(0,d.kG)(t,"inline"),r),{loadProgress:y}=(0,Vs.Z)((0,d.Ti)(t,"download"),!c,o.IU.BlobUrl,r),[P]=(0,i.eJ)(!I),Z=zs(t,I),{isBuffered:C,bufferingHandlers:b}=(0,Ys.Z)(),E=p&&!C||c,S=!1===(0,rn.Z)(p),M=(0,Ws.Z)(I),{shouldRender:R,transitionClassNames:k}=(0,at.Z)(E||!C,void 0,S),[T,A]=(0,i.eJ)(!1),[x,B]=(0,i.eJ)(0);(0,i.d4)((()=>{if(!T)return;const e=ye.Rj/2,t=2*(e-6)*Math.PI,n=t-x*t,s=m.current,a=u.current,i=a.firstElementChild;i?i.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):a.innerHTML=`\n \n \n `,B(s.currentTime/s.duration)}),[T,x]);const L=Boolean(I&&g),O=(0,i.I4)((()=>{m.current&&(A(!1),B(0),(0,Ls.Z)(m.current),(0,N.T2)((()=>{u.current.innerHTML=""})))}),[]),U=(0,i.I4)((()=>{var e;null===(e=Aa)||void 0===e||e(),Aa=O}),[O]),F=(0,i.I4)((()=>{if(!I)return void f((e=>!e));if(c)return void(0,s.Sv)().cancelMessageMediaDownload({message:t});const e=m.current;T?e.paused?((0,Ls.Z)(e),(0,Cn.Es)()):e.pause():(U(),e.pause(),e.currentTime=0,(0,Ls.Z)(e),(0,Cn.Es)(),A(!0))}),[U,T,c,I,t]),j=(0,i.I4)((e=>{const t=e.currentTarget;B(t.currentTime/t.duration)}),[]),D=(0,_e.Z)("full-media",M);return i.ZP.createElement("div",{ref:l,className:"RoundVideo media-inner",onClick:F},P&&i.ZP.createElement("div",{className:"thumbnail-wrapper"},i.ZP.createElement("canvas",{ref:Z,className:"thumbnail",style:`width: ${ye.Rj}px; height: ${ye.Rj}px`})),I&&i.ZP.createElement("div",{className:"video-wrapper"},i.ZP.createElement(Ks.Z,Ta({canPlay:L,ref:m,src:I,className:D,width:ye.Rj,height:ye.Rj,autoPlay:!0,disablePictureInPicture:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?O:void 0},b,{onTimeUpdate:T?j:void 0}))),i.ZP.createElement("div",{className:"progress",ref:u}),R&&i.ZP.createElement("div",{className:`media-loading ${k}`},i.ZP.createElement(Xs.Z,{progress:c?y:w})),!I&&!p&&i.ZP.createElement("i",{className:"icon-download"}),i.ZP.createElement("div",{className:"message-media-duration"},T?(0,z.k9)(m.current.currentTime):(0,z.k9)(h.duration),(!T||m.current.paused)&&i.ZP.createElement("i",{className:"icon-muted"})))},Ba=e=>{let{message:t,onClick:n}=e;const s=(0,yt.Z)();return i.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>i.ZP.createElement("div",{className:"row"},e.map((e=>i.ZP.createElement(Rt.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===e.type,onClick:()=>n({messageId:t.id,button:e})},i.ZP.createElement("span",{className:"inline-button-text"},(0,Ln.Z)(s(e.text))),(e=>{const{type:t}=e;switch(t){case"url":if(!a.FS.test(e.url))return i.ZP.createElement("i",{className:"icon-arrow-right"});break;case"urlAuth":return i.ZP.createElement("i",{className:"icon-arrow-right"});case"buy":case"receipt":return i.ZP.createElement("i",{className:"icon-cart"});case"switchBotInline":return i.ZP.createElement("i",{className:"icon-share-filled"});case"webView":case"simpleWebView":return i.ZP.createElement("i",{className:"icon-webapp"})}})(e))))))))},La=(0,i.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:a}=(0,s.Sv)(),o=(0,yt.Z)(),{threadId:r,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h}=t,g=(0,i.I4)((()=>{a({id:c,threadId:r})}),[a,c,r]),p=(0,i.Ye)((()=>{if(null==h||!h.length)return;const{users:{byId:e},chats:{byId:t}}=(0,s.Rd)();return h.map((n=>(0,d.YC)(n)?e[n]:t[n])).filter(Boolean)}),[h]);if(void 0===l)return;const f=Boolean(m&&u&&m0&&i.ZP.createElement("div",{className:"recent-repliers",dir:o.isRtl?"rtl":"ltr"},p.map((e=>i.ZP.createElement(Fn.Z,{key:e.id,size:"small",user:(0,d.YC)(e.id)?e:void 0,chat:(0,d.YC)(e.id)?void 0:e})))),i.ZP.createElement("div",{className:"label",dir:"auto"},l?o("Comments",l,"i"):o("LeaveAComment")),i.ZP.createElement("i",{className:"icon-next"}))})),Oa=(0,i.X$)((e=>{let{reaction:t,message:n,activeReaction:a,availableReactions:o}=e;const{sendReaction:r}=(0,s.Sv)(),{recentReactions:c}=n.reactions,l=(0,i.Ye)((()=>{if(!c||t.count>3)return;const e=(0,s.Rd)().users.byId;return c.filter((e=>e.reaction===t.reaction)).map((t=>e[t.userId])).filter(Boolean)}),[t,c]),d=(0,i.I4)((()=>{r({reaction:t.isChosen?void 0:t.reaction,chatId:n.chatId,messageId:n.id})}),[n,t,r]);return i.ZP.createElement(Rt.Z,{className:(0,_e.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},i.ZP.createElement(Ns,{activeReaction:a,reaction:t.reaction,availableReactions:o}),null!=l&&l.length?i.ZP.createElement("div",{className:"avatars"},l.map((e=>i.ZP.createElement(Fn.Z,{user:e,size:"micro"})))):(0,ut.bi)(t.count))})),Ua=(0,i.X$)((e=>{let{message:t,isOutside:n,activeReaction:s,availableReactions:a,metaChildren:o}=e;return i.ZP.createElement("div",{className:(0,_e.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>i.ZP.createElement(Oa,{key:e.reaction,reaction:e,message:t,activeReaction:s,availableReactions:a}))),o)})),Fa=(0,i.X$)((e=>{let{phoneCall:t,message:n,chatId:a}=e;const{requestCall:o}=(0,s.Sv)(),r=(0,yt.Z)(),{isOutgoing:c,isVideo:l,reason:d}=t,u="missed"===d,m="busy"===d&&!c,g=(0,i.I4)((()=>{o({isVideo:l,userId:a})}),[a,l,o]),p=(0,i.Ye)((()=>l?m?"CallMessageVideoIncomingDeclined":u?c?"CallMessageVideoOutgoingMissed":"CallMessageVideoIncomingMissed":c?"CallMessageVideoOutgoing":"CallMessageVideoIncoming":m?"CallMessageIncomingDeclined":u?c?"CallMessageOutgoingMissed":"CallMessageIncomingMissed":c?"CallMessageOutgoing":"CallMessageIncoming"),[m,u,c,l]),f=(0,i.Ye)((()=>t.duration?(0,z.J_)(r,t.duration):void 0),[r,t.duration]),v=(0,z.mr)(r,1e3*n.date);return i.ZP.createElement("div",{className:"vDeypQzM845_JE14qGId"},i.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")},i.ZP.createElement("i",{className:l?"icon-video-outlined":"icon-phone"})),i.ZP.createElement("div",{className:"_0BG8sziTJQ_NYrsspMg"},i.ZP.createElement("div",{className:"LWVSvxVjeEyHPBrCb2sD"},r(p)),i.ZP.createElement("div",{className:"nuIsoCP15iD4ETadJ44R"},i.ZP.createElement("i",{className:(0,_e.Z)("icon-arrow-right","wrUkWet7enyh9L1iPKvA",u&&"V5tKkKZpcY5yq_f5nO8l",!c&&"e0Vhbj8gfzQn1zJQoFLK")}),i.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:''},Ha={__html:''},Va=(0,i.X$)((0,s.c$)(((e,t)=>{var n,s,a;const{focusedMessage:i,forwardMessages:o,lastSyncTime:r,serverTimeOffset:l}=e,{message:u,album:m,withSenderName:h,withAvatar:g,threadId:p,messageListType:f,isLastInDocumentGroup:v}=t,{id:I,chatId:w,viaBotId:y,replyToChatId:P,replyToMessageId:Z,isOutgoing:C,threadInfo:b,forwardInfo:E,transcriptionId:S}=u,M=(0,c.Z1)(e,w),R=(0,c.FM)(e,w),k=(0,d.pK)(w),N=M&&(0,d.eA)(M),T=null==M?void 0:M.username,A=!R&&(0,d.Ul)(u),x=h||g||A,B=(0,c.Ur)(e,u),L=(0,c.cv)(e,u),O=y?(0,c.dy)(e,y):void 0,U=p?(0,c.qS)(e,w,p):void 0,F=u.id===U,j=Z===U,D=Z&&!j?(0,c.hj)(e,k&&P?P:w,Z):void 0,q=D&&(0,c.Bz)(e,D,Boolean(E)),$=(0,c.uZ)(e,u),G="thread"===f&&(m?m.messages.some((t=>(0,c._X)(e,t))):(0,c._X)(e,u)),{direction:H,noHighlight:V,isResizingContainer:_}=G&&i||{},z=o.messageIds&&o.messageIds.includes(I),{query:W}=(0,c.n5)(e)||{},X=(0,d.h_)(u),J=X&&((0,c.zB)(e,X)||(0,c.CP)(e,X))?X:void 0,Y=(0,d.HW)(u);let K;K=null!=m&&m.messages?m.messages.every((t=>{let{id:n}=t;return(0,c.vk)(e,n)})):(0,c.vk)(e,I);const{canReply:Q}="thread"===f&&(0,c._k)(e,u,p)||{},ee=(0,c.te)(e,u),te=b?(0,c.tZ)(e,b.chatId,b.threadId)||b:void 0,ne=Boolean(u.groupedId)&&!u.isInAlbum,se=ne?(0,c.xH)(e,w,u.groupedId)[0]:void 0,ae=ne?v?(0,c.hj)(e,w,se):void 0:u,ie=null==M||null===(n=M.unreadReactions)||void 0===n?void 0:n.includes(u.id);return{theme:(0,c.Pu)(e),chatUsername:T,forceSenderName:A,sender:B,canShowSender:x,originSender:L,botSender:O,shouldHideReply:j,isThreadTop:F,replyMessage:D,replyMessageSender:q,isInDocumentGroup:ne,isProtected:(0,c.EV)(e,u),isChatProtected:(0,c.Am)(e,w),isFocused:G,isForwarding:z,reactionMessage:ae,isChatWithSelf:R,isRepliesChat:k,isChannel:N,canReply:Q,lastSyncTime:r,serverTimeOffset:l,highlight:W,animatedEmoji:J,animatedCustomEmoji:Y,isInSelectMode:(0,c.CA)(e),isSelected:K,isGroupSelected:Boolean(u.groupedId)&&!u.isInAlbum&&(0,c.a6)(e,w,u.groupedId),threadId:p,isDownloading:ee,isPinnedList:"pinned"===f,canAutoLoadMedia:(0,c.bH)(e,u),canAutoPlayMedia:(0,c.__)(e,u),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,c.yB)(e),threadInfo:te,availableReactions:e.availableReactions,defaultReaction:(0,d.CI)(u)?void 0:(0,c.q6)(e,w),activeReaction:ae&&e.activeReactions[ae.id],activeEmojiInteractions:e.activeEmojiInteractions,...C&&{outgoingStatus:(0,c.dT)(e,u,"scheduled"===f)},..."number"==typeof $&&{uploadProgress:$},...G&&{focusDirection:H,noFocusHighlight:V,isResizingContainer:_},hasUnreadReaction:ie,isTranscribing:void 0!==S&&(null===(s=e.transcriptions[S])||void 0===s?void 0:s.isPending),transcribedText:void 0!==S?null===(a=e.transcriptions[S])||void 0===a?void 0:a.text:void 0,isPremium:(0,c.wV)(e),animationLevel:e.settings.byKey.animationLevel}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:r,observeIntersectionForMedia:c,observeIntersectionForAnimatedStickers: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:N,sender:T,canShowSender:A,originSender:x,botSender:B,isThreadTop:L,shouldHideReply:O,replyMessage:U,replyMessageSender:F,outgoingStatus:j,uploadProgress:D,isInDocumentGroup:q,isProtected:$,isChatProtected:G,isFocused:H,focusDirection:V,noFocusHighlight:_,isResizingContainer:z,isForwarding:W,isChatWithSelf:X,isRepliesChat:J,isChannel:Y,canReply:K,lastSyncTime:Q,serverTimeOffset:ee,highlight:te,animatedEmoji:ne,animatedCustomEmoji:se,isInSelectMode:ae,isSelected:ie,isGroupSelected:oe,threadId:re,reactionMessage:ce,availableReactions:le,defaultReaction:de,activeReaction:ue,activeEmojiInteractions:me,messageListType:he,isPinnedList:ge,isDownloading:pe,canAutoLoadMedia:fe,canAutoPlayMedia:ve,shouldLoopStickers:Ie,autoLoadFileMaxSizeMb:we,threadInfo:Pe,hasUnreadReaction:Ze,memoFirstUnreadIdRef:Ce,animationLevel:be}=e;const{toggleMessageSelection:Ee,clickBotInlineButton:Se,disableContextMenuHint:Me,animateUnreadReaction:Re,focusLastMessage:ke}=(0,s.Sv)(),Ne=(0,i.sO)(null),Te=(0,i.sO)(null),Ae=(0,i.sO)(null),xe=(0,yt.Z)(),[Be,Le]=(0,i.eJ)(!1),[Oe,Ue,Fe]=(0,vt.Z)();(0,Yn._N)(Te,r);const{isContextMenuOpen:je,contextMenuPosition:De,handleBeforeContextMenu:qe,handleContextMenu:$e,handleContextMenuClose:Ge,handleContextMenuHide:He}=(0,es.Z)(Ne,h.$b&&ae,!0,h.wZ);(0,i.d4)((()=>{je&&Me()}),[je,Me]);const Ve=y<=0,[ze,We]=(0,vt.Z)(Ve);(0,i.d4)((()=>{Ve||setTimeout(We,10*y)}),[y,We,Ve]);const{transitionClassNames:Xe}=(0,at.Z)(ze,void 0,Ve,!1),{id:Je,chatId:Ye,forwardInfo:Ke,viaBotId:Qe,isTranscriptionError:et}=t,tt=(0,d.CI)(t),nt=(0,d.B4)(t),st="scheduled"===he||t.isScheduled,it=(0,d.ss)(t)&&!O,ot=Boolean(Pe)&&"thread"===he,rt=(0,d.$D)(t),ct=rt&&(ne||se),lt=(null==ce?void 0:ce.reactions)&&!(0,d.JE)(ce.reactions),dt=Ke&&(!X||st)&&!J&&!Ke.isLinkedChannelPost&&!rt,ut=Boolean(u)&&u.messages.length>1&&!(null!=u&&u.messages.some((e=>0===Object.keys(e.content).length))),mt=q&&!b,ht=q&&!E,gt=void 0!==De,pt=!(gt||ae||W||ht),ft=Y&&!st&&t.isForwardingAllowed&&!G,It=Boolean(ge||Ke&&(Ke.isChannelPost||X&&!nt||J)&&Ke.fromMessageId),wt=(0,i.I4)(((e,t)=>{Ee({messageId:Je,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...ut&&{childMessageIds:u.messages.map((e=>{let{id:t}=e;return t}))}})}),[Ee,Je,ut,u]),Pt=A?T:void 0,Zt=Boolean(!Be&&(et||M)),Ct=Ke&&(X||J||!Pt)?x:Pt,bt=Ke?x:Pt,{handleMouseDown:Et,handleClick:St,handleContextMenu:Mt,handleDoubleClick:kt,handleContentDoubleClick:Nt,handleMouseMove:Tt,handleSendQuickReaction:At,handleMouseLeave:xt,isSwiped:Bt,isQuickReactionVisible:Lt,handleDocumentGroupMouseEnter:Ot}=ps(wt,Ne,Je,0,Boolean(ae),Boolean(K),Boolean($),$e,qe,Ye,gt,Ae,nt,ht),{handleAvatarClick:Ut,handleSenderClick:Ft,handleViaBotClick:jt,handleReplyClick:Dt,handleMediaClick:qt,handleAudioPlay:$t,handleAlbumMediaClick:Gt,handleMetaClick:Ht,handleReadMedia:Vt,handleCancelUpload:_t,handleVoteSend:zt,handleGroupForward:Wt,handleForward:Xt,handleFocus:Jt,handleFocusForwarded:Yt,handleDocumentGroupSelectAll:Kt}=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:N,replyToTopMessageId:T,groupedId:A}=n,x=(0,i.I4)((()=>{g&&v({id:g.id})}),[g,v]),B=(0,i.I4)((()=>{p?l&&null!=R&&R.channelPostId?w({chatId:p.id,messageId:R.channelPostId}):v({id:p.id}):I({message:e("HidAccount")})}),[l,w,R,e,v,p,I]),L=(0,i.I4)((()=>{f&&v({id:f.id})}),[f,v]),O=(0,i.I4)((()=>{w({chatId:u&&N?N:a,threadId:r,messageId:k,replyMessageId:u&&N?void 0:M})}),[w,u,N,a,r,k,M]),U=(0,i.I4)((()=>{y({chatId:a,threadId:r,mediaId:M,origin:d?m.bZ.ScheduledInline:m.bZ.Inline})}),[a,r,M,y,d]),F=(0,i.I4)((()=>{P({chatId:a,messageId:M})}),[a,M,P]),j=(0,i.I4)((e=>{y({chatId:a,threadId:r,mediaId:e,origin:d?m.bZ.ScheduledAlbum:m.bZ.Album})}),[a,r,y,d]),D=(0,i.I4)((()=>{Z({messageIds:[M]})}),[M,Z]),q=(0,i.I4)((()=>{C({chatId:a,messageId:M})}),[C,a,M]),$=(0,i.I4)((e=>{b({chatId:a,messageId:M,options:e})}),[a,M,b]),G=(0,i.I4)((()=>{E({fromChatId:a,groupedId:A})}),[E,a,A]),H=(0,i.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,i.I4)((()=>{w({chatId:a,threadId:o._f,messageId:M})}),[w,a,M]),_=(0,i.I4)((()=>{c?w({chatId:R.fromChatId,groupedId:A,groupedChatId:a}):u&&N?S({chatId:N,threadId:T,messageId:R.fromMessageId}):w({chatId:R.fromChatId,messageId:R.fromMessageId})}),[c,u,N,w,R,A,a,S,T]),z=(0,i.I4)((e=>{e.stopPropagation(),t(e,A)}),[t,A]);return{handleAvatarClick:x,handleSenderClick:B,handleViaBotClick:L,handleReplyClick:O,handleMediaClick:U,handleAudioPlay:F,handleAlbumMediaClick:j,handleMetaClick:z,handleReadMedia:D,handleCancelUpload:q,handleVoteSend:$,handleGroupForward:G,handleForward:H,handleFocus:V,handleFocusForwarded:_,handleDocumentGroupSelectAll:z}}(xe,wt,t,Ye,re,q,dt,st,J,u,Ct,bt,B);(0,i.d4)((()=>{R&&Zt&&M&&ke()}),[ke,R,M,Zt]);const Qt=(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",nt&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",it&&"has-reply",gt&&"has-menu-open",H&&!_&&"focused",W&&"is-forwarding",t.isDeleting&&"is-deleting",q&&"is-in-document-group",ut&&"is-album",t.hasUnreadMention&&"has-unread-mention",ie&&"is-selected",ae&&"is-in-selection-mode",L&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",Bt&&"is-swiped",Xe,(Boolean(ue)||Oe)&&"has-active-reaction"),{text:en,photo:tn,video:nn,audio:sn,voice:an,document:on,sticker:rn,contact:cn,poll:dn,webPage:un,invoice:mn,location:hn,action:gn,game:pn}=(0,d.qp)(t),{phoneCall:fn}=gn||{},vn=Pe&&!ht&&"thread"===he&&!w,In=!h.$b&&!fn&&!ae&&de&&!ht,wn=function(e){let{hasReply:t,isCustomShape:n,isLastInGroup:s,asForwarded:i,hasThread:o,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"),i&&E.push("is-forwarded"),t&&E.push("is-reply"),o&&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||i||k||!R||r)&&E.push("has-solid-background"),s&&(p||C&&!M||!R)&&E.push("has-appendix")),E.join(" ")}(t,{hasReply:it,isCustomShape:rt,isLastInGroup:C,asForwarded:dt,hasThread:ot,forceSenderName:N,hasComments:Pe&&(null==Pe?void 0:Pe.messagesCount)>0,hasActionButton:ft||It,hasReactions:lt,isGeoLiveActive:"geoLive"===(null==hn?void 0:hn.type)&&!(0,d.$R)(t,(0,p.b)(ee)),withVoiceTranscription:Zt}),yn=wn.includes("has-appendix"),Pn=(0,d.fY)(t),Zn=(0,ws.qo)(t.emojiOnlyCount);let Cn,bn;Cn=fn||ht?"none":!Pn||un||ct?"standalone":"in-text",I?bn="in-meta":lt?rt||(tn||nn)&&!Pn?bn="outside":dt?(Cn="standalone",bn="inside"):bn="inside":bn="none",(0,ln.Z)(J&&t.replyToChatId?t.replyToChatId:Ye,it?t.replyToMessageId:void 0,U,t.id),ds(Ne,Ye,H,V,_,z),(0,i.d4)((()=>{const e=Te.current;Ze&&e&&(0,Is.P)(e)&&Re({messageIds:[Je]})}),[Ze,Je,Re]);let En,Sn="",Mn=!1;const Rn=(0,i.Ye)((()=>ut?os(nt,Boolean(dt),Boolean(g),u):void 0),[ut,nt,dt,g,u]),kn=dt?28:0;if(!ut&&(tn||nn||null!=mn&&mn.extendedMedia)){let e;if(tn)e=ns(t,g).width;else if(nn)e=nn.isRound?ye.Rj:ns(t,g).width;else if(null!=mn&&mn.extendedMedia&&mn.extendedMedia.width&&mn.extendedMedia.height){const{width:t,height:n}=mn.extendedMedia;e=(0,ye.Kf)({width:t,height:n,fromOwnMessage:nt,isForwarded:W,noAvatars:g}).width}e&&(En=Math.max(ts(Boolean(en),vn),e),En-e>18&&(Mn=!0))}else Rn&&(En=Math.max(ts(Boolean(en),vn),Rn.containerStyle.width),En-Rn.containerStyle.width>18&&(Mn=!0));En&&(Sn=`width: ${En+kn}px`);const Nn=Y&&t.adminTitle||!dt&&(null==Ke?void 0:Ke.adminTitle)||void 0,Tn=(0,i.Ye)((()=>Nn?ls(Nn):void 0),[Nn]);function An(){const e=i.ZP.createElement(Ts,{message:t,reactionMessage:ce,outgoingStatus:j,signature:Nn,withReactions:"in-meta"===bn,withReactionOffset:"inside"===bn,availableReactions:le,activeReaction:ue,onClick:Ht});return"inside"!==bn?e:i.ZP.createElement(Ua,{activeReaction:ue,message:ce,metaChildren:e,availableReactions:le})}return i.ZP.createElement("div",{ref:Ne,id:(0,d.d0)(t.id),className:Qt,style:Tn?`--meta-safe-author-width: ${Tn}px`:void 0,"data-message-id":Je,onMouseDown:Et,onClick:St,onContextMenu:Mt,onDoubleClick:kt,onMouseEnter:ht?Ot:void 0,onMouseMove:In?Tt:void 0,onMouseLeave:In||ht?xt:void 0},i.ZP.createElement("div",{ref:Te,className:"bottom-marker","data-message-id":Je,"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":Ze||void 0}),!q&&i.ZP.createElement("div",{className:"message-select-control"},ie&&i.ZP.createElement("i",{className:"icon-select"})),E&&i.ZP.createElement("div",{className:(0,_e.Z)("message-select-control group-select",oe&&"is-selected"),onClick:Kt},oe&&i.ZP.createElement("i",{className:"icon-select"})),f&&function(){const e=Ct&&(0,d.YC)(Ct.id),t=Ct&&e?Ct:void 0,n=Ct&&!e?Ct:void 0,s=!Ct&&Ke?Ke.hiddenUserName:void 0;return i.ZP.createElement(Fn.Z,{size:"small",user:t,chat:n,text:s,lastSyncTime:Q,onClick:t||n?Ut:void 0,observeIntersection:c,animationLevel:be,withVideo:!0})}(),i.ZP.createElement("div",{className:(0,_e.Z)("message-content-wrapper",wn.includes("text")&&"can-select-text")},i.ZP.createElement("div",{ref:Ae,className:wn,style:Sn,dir:"auto"},dt&&!mt&&i.ZP.createElement("div",{className:"message-title"},xe("ForwardedMessage")),function(){const e=(0,_e.Z)("content-inner",dt&&"forwarded-message",it&&"reply-message",Mn&&"no-media-corners"),n=C&&!Pn&&!dt&&!ot,s=(0,_e.Z)("text-content","in-text"===Cn&&"with-meta",j&&"with-outgoing-icon");return i.ZP.createElement("div",{className:e,onDoubleClick:Nt,dir:"auto"},function(){if(rt&&!Qe||!(v&&!(tn||nn||hn)||dt||Qe||N)||mt||it&&rt)return;let e,n;!bt||rt&&Qe?null!=Ke&&Ke.hiddenUserName&&(e=Ke.hiddenUserName):(e=(0,d.OU)(xe,bt),dt||(n=`color-${(0,d.Rs)(bt)}`));const s=bt&&"emojiStatus"in bt&&bt.emojiStatus,o=bt&&"isPremium"in bt&&bt.isPremium;return i.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?i.ZP.createElement("span",{className:(0,_e.Z)("message-title-name interactive",n),onClick:Ft,dir:"ltr"},(0,Ln.Z)(e),!dt&&s&&i.ZP.createElement(qs.Z,{documentId:s.documentId,loopLimit:a.y3,observeIntersectionForLoading:c,observeIntersectionForPlaying:l}),!dt&&!s&&o&&i.ZP.createElement(Da.Z,null),(null==bt?void 0:bt.fakeType)&&i.ZP.createElement(qa.Z,{fakeType:bt.fakeType})):B?void 0:" ",B&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"via"},xe("ViaBot")),i.ZP.createElement("span",{className:"interactive",onClick:jt},(0,Ln.Z)(`@${B.username}`))),null!=Ke&&Ke.isLinkedChannelPost?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},xe("DiscussChannel")):t.adminTitle&&!Y?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.adminTitle):void 0)}(),it&&i.ZP.createElement(bs,{message:U,noUserColors:nt,isProtected:$,sender:F,observeIntersectionForLoading:c,observeIntersectionForPlaying:l,onClick:Dt}),rn&&i.ZP.createElement(xs,{message:t,observeIntersection:c,observeIntersectionForPlaying:l,shouldLoop:Ie,lastSyncTime:Q,shouldPlayEffect:rn.hasEffect&&(Ce.current&&Je>=Ce.current||tt)||void 0,onPlayEffect:Ue,onStopEffect:Fe}),ct&&se&&i.ZP.createElement($s,{customEmojiId:se,withEffects:(0,d.YC)(Ye),isOwn:nt,observeIntersection:c,lastSyncTime:Q,forceLoadPreview:tt,messageId:Je,chatId:Ye,activeEmojiInteractions:me}),ct&&ne&&i.ZP.createElement(Ds,{emoji:ne,withEffects:(0,d.YC)(Ye),isOwn:nt,observeIntersection:c,lastSyncTime:Q,forceLoadPreview:tt,messageId:Je,chatId:Ye,activeEmojiInteractions:me}),ut&&i.ZP.createElement(Na,{album:u,albumLayout:Rn,observeIntersection:c,isOwn:nt,isProtected:$,hasCustomAppendix:n,lastSyncTime:Q,onMediaClick:Gt}),fn&&i.ZP.createElement(Fa,{message:t,phoneCall:fn,chatId:Ye}),!ut&&tn&&i.ZP.createElement(Js,{message:t,observeIntersection:c,noAvatars:g,canAutoLoad:fe,uploadProgress:D,shouldAffectAppendix:n,onClick:qt,onCancelUpload:_t,isDownloading:pe,isProtected:$,theme:k}),!ut&&nn&&nn.isRound&&i.ZP.createElement(xa,{message:t,observeIntersection:c,canAutoLoad:fe,lastSyncTime:Q,isDownloading:pe}),!ut&&nn&&!nn.isRound&&i.ZP.createElement(ea,{message:t,observeIntersection:c,noAvatars:g,canAutoLoad:fe,canAutoPlay:ve,uploadProgress:D,lastSyncTime:Q,onClick:qt,onCancelUpload:_t,isDownloading:pe,isProtected:$}),(sn||an)&&i.ZP.createElement(Ss.ZP,{theme:k,message:t,origin:m.Cr.Inline,uploadProgress:D,lastSyncTime:Q,isSelectable:q,isSelected:ie,noAvatars:g,onPlay:$t,onReadMedia:!an||nt&&!X?void 0:Vt,onCancelUpload:_t,isDownloading:pe,isTranscribing:S,isTranscriptionHidden:Be,isTranscribed:Boolean(M),isTranscriptionError:et,canDownload:!$,onHideTranscription:Le,canTranscribe:Z}),on&&i.ZP.createElement(Es.Z,{message:t,observeIntersection:c,canAutoLoad:fe,autoLoadFileMaxSizeMb:we,uploadProgress:D,isSelectable:q,isSelected:ie,onMediaClick:qt,onCancelUpload:_t,isDownloading:pe}),cn&&i.ZP.createElement(na,{contact:cn}),dn&&i.ZP.createElement(da,{message:t,poll:dn,onSendVote:zt}),pn&&i.ZP.createElement(Sa,{message:t,canAutoLoadMedia:fe,lastSyncTime:Q}),(null==mn?void 0:mn.extendedMedia)&&i.ZP.createElement(va,{message:t,lastSyncTime:Q}),Zt&&i.ZP.createElement("p",{className:(0,_e.Z)("transcription",!Be&&et&&"transcription-error"),dir:"auto"},et?xe("NoWordsRecognized"):S&&M?i.ZP.createElement(ja.Z,{content:M}):M),!ct&&Pn&&i.ZP.createElement("div",{className:s,dir:"auto"},i.ZP.createElement($a.Z,{message:t,emojiSize:Zn,highlight:te,isProtected:$,observeIntersectionForLoading:c,observeIntersectionForPlaying:l,withTranslucentThumbs:rt}),"in-text"===Cn&&An()),un&&i.ZP.createElement(ha,{message:t,observeIntersection:c,noAvatars:g,canAutoLoad:fe,canAutoPlay:ve,lastSyncTime:Q,onMediaClick:qt,onCancelMediaTransfer:_t,isDownloading:pe,isProtected:$,theme:k}),mn&&!mn.extendedMedia&&i.ZP.createElement(pa,{message:t,shouldAffectAppendix:n,isInSelectMode:ae,isSelected:ie,theme:k}),hn&&i.ZP.createElement(Ea,{message:t,lastSyncTime:Q,isInSelectMode:ae,isSelected:ie,theme:k,peer:T,serverTimeOffset:ee}))}(),!ht&&"standalone"===Cn&&An(),pt&&ft?i.ZP.createElement(Rt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:xe("lng_context_forward_msg"),onClick:E?Wt:Xt},i.ZP.createElement("i",{className:"icon-share-filled"})):pt&&It?i.ZP.createElement(Rt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:ge?Jt:Yt},i.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,vn&&i.ZP.createElement(La,{threadInfo:Pe,disabled:w}),yn&&i.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:nt?Ga:Ha}),In&&i.ZP.createElement("div",{className:(0,_e.Z)("quick-reaction",Lt&&!ue&&"visible"),onClick:At},i.ZP.createElement(Rs.Z,{reaction:de}))),t.inlineButtons&&i.ZP.createElement(Ba,{message:t,onClick:Se}),"outside"===bn&&i.ZP.createElement(Ua,{message:ce,isOutside:!0,activeReaction:ue,availableReactions:le})),De&&i.ZP.createElement(Ps,{isOpen:je,anchor:De,message:t,album:u,chatUsername:n,messageListType:he,onClose:Ge,onCloseAnimationEnd:He}))}))),_a=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"AboutAdsModal",!t);return n?i.ZP.createElement(n,e):void 0})),za=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,lt.Z)(ct.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),Wa=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n}=t;const s=(0,c.fS)(e,n),{chatId:a,isBot:i}=s||{};return{message:s,bot:a&&i?(0,c.dy)(e,a):void 0,channel:!i&&a?(0,c.Z1)(e,a):void 0}}))((e=>{let{chatId:t,message:n,containerRef:a,bot:o,channel:r}=e;const{viewSponsoredMessage:c,openChat:l,openChatByInvite:u,startBot:m,focusMessage:g}=(0,s.Sv)(),p=(0,yt.Z)(),f=(0,i.sO)(null),v=(0,i.sO)(null),I=Boolean(n),{observe:w}=(0,Yn.S1)({rootRef:a,debounceMs:200,threshold:1}),{isContextMenuOpen:y,contextMenuPosition:P,handleBeforeContextMenu:Z,handleContextMenu:C,handleContextMenuClose:b,handleContextMenuHide:E}=(0,es.Z)(f,h.$b,!0,h.wZ),[S,M,R]=(0,vt.Z)(!1);(0,i.d4)((()=>I?w(v.current,(e=>{e.isIntersecting&&c({chatId:t})})):void 0),[t,I,w,c]);const k=(0,i.I4)((()=>{n&&(n.chatInviteHash?u({hash:n.chatInviteHash}):n.channelPostId?g({chatId:n.chatId,messageId:n.channelPostId}):(l({id:n.chatId}),n.startParam&&m({botId:n.chatId,param:n.startParam})))}),[g,n,l,u,m]);if(n)return i.ZP.createElement("div",{ref:f,key:"sponsored-message",className:"SponsoredMessage Message open",onMouseDown:e=>{(0,Vn.q)(e),Z(e)},onContextMenu:C},i.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},i.ZP.createElement("div",{className:"content-inner",dir:"auto"},i.ZP.createElement("div",{className:"message-title",dir:"ltr"},o&&(0,Ln.Z)((0,d.Js)(o)||""),r&&(0,Ln.Z)(n.chatInviteTitle||(0,d.U)(p,r,o)||"")),i.ZP.createElement("div",{className:"text-content with-meta",dir:"auto",ref:v},i.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,sa.H)(n.text.text,n.text.entities)),i.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},i.ZP.createElement("span",{className:"message-signature"},n.isRecommended?p("Message.RecommendedLabel"):p("SponsoredMessage")))),i.ZP.createElement(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&&i.ZP.createElement(za,{isOpen:y,anchor:P,message:n,onAboutAds:M,onClose:b,onCloseAnimationEnd:E}),i.ZP.createElement(_a,{isOpen:S,onClose:R}))}))),Xa=(0,i.X$)((e=>{let{isCurrentUserPremium:t,chatId:n,messageIds:o,messageGroups:r,isViewportNewest:c,isUnread:l,withUsers:u,areReactionsInMeta:p,noAvatars:f,containerRef:v,anchorIdRef:I,memoUnreadDividerBeforeIdRef:w,memoFirstUnreadIdRef:y,threadId:P,type:Z,isReady:C,isScrollingRef:b,isScrollPatchNeededRef:E,threadTopMessageId:S,hasLinkedChat:M,isSchedule:R,noAppearanceAnimation:k,onFabToggle:T,onNotchToggle:A}=e;const{openHistoryCalendar:x}=(0,s.Sv)(),{observeIntersectionForMedia:B,observeIntersectionForReading:L,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:a,markMentionsRead:i,animateUnreadReaction:o}=(0,s.Sv)(),{observe:r}=(0,Yn.S1)({rootRef:t,throttleMs:Kn,margin:Qn}),{observe:c,freeze:l,unfreeze:d}=(0,Yn.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let s=0;const r=[],c=[];t.forEach((e=>{const{isIntersecting:t,target:n}=e;if(!t)return;const{dataset:a}=n,i=Number(a.lastMessageId||a.messageId);i>s&&(s=i),a.hasUnreadMention&&r.push(i),a.hasUnreadReaction&&c.push(i)})),n.current&&s>=n.current&&a({maxId:s}),r.length&&i({messageIds:r}),c.length&&o({messageIds:c})}));(0,Je.Z)(l,d);const{observe:u}=(0,Yn.S1)({rootRef:t,throttleMs:Kn});return{observeIntersectionForMedia:r,observeIntersectionForReading:c,observeIntersectionForAnimatedStickers:u}}(Z,v,y),{backwardsTriggerRef:U,forwardsTriggerRef:F,fabTriggerRef:j}=function(e,t,n,o,r,c,l,d,u,g){const{loadViewportMessages:p}=(0,s.Sv)(),[f,v]=(0,i.Ye)((()=>"thread"===e?[(0,N.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,N.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,n]),I=(0,i.sO)(null),w=(0,i.sO)(null),y=(0,i.sO)(null);function P(){if(!d)return;if(!n||!n.length)return c(!1),void l(!1);if(!o)return c(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:s,scrollTop:a}=t.current,i=Math.round(s-a-e),u=i<=1;c(r?!u:!(i<=50)),l(!u)}const{observe:Z}=(0,Yn.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,Yn._N)(I,Z),(0,Yn._N)(w,Z);const{observe:C,freeze:b,unfreeze:E}=(0,Yn.S1)({rootRef:t,margin:100},P);(0,Yn._N)(y,C);const{observe:S,freeze:M,unfreeze:R}=(0,Yn.S1)({rootRef:t,margin:1},P);return(0,Yn._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,o,c,l,T,A,C,b,E),D=(0,yt.Z)(),q=i.ZP.createElement("div",{className:(0,_e.Z)("unread-divider","local-action-message"),key:"unread-messages"},i.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 o;if(1===e.length&&!Gn(e[0])&&(0,d.FT)(e[0])&&(null===(o=e[0].content.action)||void 0===o||!o.phoneCall)){const o=e[0],r=s===a.length-1&&t===n.length-1;return(0,g.oA)([o.id===w.current&&q,i.ZP.createElement(Cs,{key:o.id,message:o,observeIntersectionForReading:L,observeIntersectionForLoading:B,observeIntersectionForPlaying:O,memoFirstUnreadIdRef:y,appearanceOrder:$-++G,isLastInList:r})])}let r;return e.map(((o,c)=>{const l=Gn(o)?o.mainMessage:o,m=Gn(o)?o:void 0,h=(0,d.B4)(l),v=Gn(o),C=e[c+1];l.previousLocalId&&I.current===(0,d.d0)(l.previousLocalId)&&(I.current=(0,d.d0)(l.id));const b=!v&&l.groupedId?l.groupedId:void 0,E=C&&!Gn(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),N=(0,d.jM)(l)?`${l.date}_${k}`:k;return(0,g.oA)([l.id===w.current&&q,i.ZP.createElement(Va,{key:N,message:l,observeIntersectionForBottom:L,observeIntersectionForMedia:B,observeIntersectionForAnimatedStickers: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&&i.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},i.ZP.createElement("span",null,D("DiscussionStarted")))])})).flat()}));return i.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:Vn.q,teactFastList:!0},i.ZP.createElement("div",{className:(0,_e.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:Vn.q,onClick:R?void 0:()=>x({selectedAt:e.datetime})},i.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 i.ZP.createElement("div",{className:"messages-container",teactFastList:!0},i.ZP.createElement("div",{ref:U,key:"backwards-trigger",className:"backwards-trigger"}),H.flat(),!t&&c&&i.ZP.createElement(Wa,{key:n,chatId:n,containerRef:v}),i.ZP.createElement("div",{ref:F,key:"forwards-trigger",className:"forwards-trigger"}),i.ZP.createElement("div",{ref:j,key:"fab-trigger",className:"fab-trigger"}))}));var Ja=n(73547);const Ya=(0,i.X$)((0,s.c$)(((e,t)=>{let{userId:n}=t;const{stickers:s}=e.stickers.greeting,a=(0,d.db)(n)+(0,d.db)(e.currentUserId),i=null!=s&&s.length?s[a%s.length]:void 0,o=(0,c.Z1)(e,n);return o?{sticker:i,lastUnreadMessageId:o.lastMessage&&o.lastMessage.id!==o.lastReadInboxMessageId?o.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((e=>{let{sticker:t,connectionState:n,lastUnreadMessageId:a}=e;const{loadGreetingStickers:o,sendMessage:r,markMessageListRead:c}=(0,s.Sv)(),l=(0,yt.Z)(),d=(0,i.sO)(null),{observe:u}=(0,Yn.S1)({rootRef:d,debounceMs:200});(0,i.d4)((()=>{t||"connectionStateReady"!==n||o()}),[n,o,t]),(0,i.d4)((()=>{"connectionStateReady"===n&&a&&c({maxId:a})}),[n,c,a]);const m=(0,i.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return i.ZP.createElement("div",{className:"ContactGreeting",ref:d},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement("p",{className:"title",dir:"auto"},l("Conversation.EmptyPlaceholder")),i.ZP.createElement("p",{className:"description",dir:"auto"},l("Conversation.GreetingText")),i.ZP.createElement("div",{className:"sticker"},t&&i.ZP.createElement(Ja.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large",noContextMenu:!0,isCurrentUserPremium:!0}))))}))),Ka=(0,i.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:s}=e;const a=(0,yt.Z)();return"scheduled"===n?function(e){return i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(a):t?function(e){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement("i",{className:"icon icon-cloud-download"}),i.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),i.ZP.createElement("ul",{className:"description"},i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(a):s?function(e){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},i.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),i.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),i.ZP.createElement("ul",{className:"list-checkmarks"},i.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(a):i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,a("NoMessages")))})),Qa=(0,N.Ds)((e=>e()),200,!1),ei=(0,i.X$)((0,s.c$)(((e,t)=>{let{chatId:n,threadId:s,type:a}=t;const i=(0,c.Z1)(e,n);if(!i)return{};const r=(0,c.$W)(e,n,s,a),l="scheduled"===a?(0,c.Fn)(e,n):(0,c.Zw)(e,n),u=(0,c.qS)(e,n,s);if(s!==o._f&&!(l&&u&&l[u]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=i,p=(0,c.G$)(e,n),f=s===o._f&&!r&&!i.unreadCount&&!p&&g&&!g.groupedId,v=(0,c.IK)(e,n);let I,w=!1;return(0,c.pk)(e,n)&&(v.fullInfo?I=v.fullInfo.botInfo:w=!0),{isCurrentUserPremium:(0,c.wV)(e),isChatLoaded:!0,isRestricted:m,restrictionReason:h,isChannelChat:(0,d.eA)(i),isGroupChat:(0,d.Bf)(i),isCreator:i.isCreator,isChatWithSelf:(0,c.FM)(e,n),isRepliesChat:(0,d.pK)(n),isBot:Boolean(v),messageIds:r,messagesById:l,firstUnreadId:(0,c.It)(e,n,s),isViewportNewest:"thread"!==a||(0,c.b9)(e,n,s),threadFirstMessageId:(0,c.yZ)(e,n,s),focusingId:p,isSelectModeActive:(0,c.CA)(e),isLoadingBotInfo:w,botInfo:I,threadTopMessageId:u,hasLinkedChat:i.fullInfo&&"linkedChatId"in i.fullInfo?Boolean(i.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...f&&{lastMessage:g}}}))((e=>{var t,n,o,r,l,u;let{chatId:p,threadId:f,type:v,hasTools:I,onFabToggle:w,onNotchToggle:y,isCurrentUserPremium:P,isChatLoaded:Z,isChannelChat:C,isGroupChat:b,canPost:E,isReady:S,isChatWithSelf:M,isRepliesChat:R,isCreator:k,isBot:T,messageIds:A,messagesById:x,firstUnreadId:B,isViewportNewest:L,threadFirstMessageId:O,isRestricted:U,restrictionReason:F,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,i.sO)(null),te=(0,i.sO)("thread"===v&&(0,c.Vt)((0,s.Rd)(),p,f)||0),ne=(0,i.sO)(),se=(0,i.sO)(),ae=(0,i.sO)(),ie=(0,i.sO)(),oe=(0,i.sO)(),re=(0,i.sO)(),ce=(0,i.sO)(!1),le=(0,i.sO)(Boolean(q)),[de,ue]=(0,i.eJ)(),me=(0,pn.Z)(null!=G&&G.photo?(0,d.NF)(G.photo):void 0),he=(0,pn.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(A);(0,Ke.Z)((()=>{fe&&(0,N.R3)((()=>{le.current=!1}))}),[fe]),(0,Ke.Z)((()=>{ie.current=B}),[B]),(0,Ke.Z)((()=>{!P&&C&&S&&_&&Y({chatId:p})}),[P,p,S,C,_]),(0,Ke.Z)((()=>{fe&&(oe.current=ie.current)}),[fe]),(0,Ke.Z)((()=>{re.current=j}),[j]),(e=>{(0,It.y)({"Mod+C":function(t){const n=(0,Xn.Z)();n&&n.length>0&&(t.preventDefault(),e({messageIds:n}))}})})(Q);const ve=(0,i.Ye)((()=>{if(!A||!x)return;const e=!H||A[0]&&O!==A[0]?A:[H,...A];if(!e.length)return;const t=e.map((e=>x[e])).filter(Boolean);return Hn((0,g.Xo)(t,["date","id"]),oe.current)}),[A,x,O,H]);(0,ot.Z)((()=>{if(!A||!x)return;const e=A.filter((e=>{var t;return null===(t=x[e])||void 0===t?void 0:t.reactions}));e.length&&K({chatId:p,ids:e})}),15e3);const Ie=(0,i.Ye)((()=>{if("thread"===v)return(0,N.Ds)((()=>X({direction:m.Uq.Around})),1e3,!0,!1)}),[X,A]),{isScrolled:we,updateStickyDates:ye}=function(){const[e,t]=(0,vt.Z)(!1),n=(0,Wn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,i.I4)(((e,s)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,N.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,N.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const n=function(e,t){const n=e.querySelectorAll(".sticky-date"),s=e.scrollTop;return Array.from(n).find((e=>{const{offsetTop:n,offsetHeight:a}=e,i=n-s;return-a<=i&&i<=(t?60:10)}))}(e,s);n&&n.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,n])}}(),Pe=(0,i.sO)(),Ze=(0,i.sO)(),Ce=(0,i.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,N.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,i.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,i.d4)((()=>{ee.current.dataset.normalHeight=String(ee.current.offsetHeight)}),[be,E]),(0,i.d4)((()=>{if(!Ie||!Z||U||j)return;if(A&&A[A.length-1]>a.MP)return;const e=ee.current;(!A||A.length{if(!A||!ae.current)return;const e=ae.current.filter((e=>A.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(ne.current=t.id,se.current=t.getBoundingClientRect().top)}),[A,L,de,I]),(0,Jn.Z)((e=>{let[t,n,s]=e;const i=ee.current;ae.current=Array.from(i.querySelectorAll(".message-list-item"));const o=A&&t&&A[A.length-1]!==t[t.length-1],r=(null==A?void 0:A[0])!==(null==t?void 0:t[0])&&(null==A?void 0:A.length)===a.hT/2+1,c=o&&!r,l=A&&re.current===A[A.length-1],d=L&&c&&A&&A.length{i.parentElement&&i.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=i,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,N.T2)((()=>{(0,zn.Z)(i,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&&i.querySelector(`#${ne.current}`),Z=!P&&oe.current&&i.querySelector(".unread-divider");if(v&&y){if((0,zn.N)())return;w=m-h}else P?(Ze.current&&(Ze.current=!1,(0,_n.z)(i)),w=u+(P.getBoundingClientRect().top-(se.current||0))):w=Z?Math.min(Z.offsetTop-(I?60:10),m-g):m-g;(0,_n.Z)(i,Math.ceil(w)),re.current||(ce.current=!0,(0,N.T2)((()=>{ce.current=!1}))),te.current=Math.max(Math.ceil(m-w),h)}),[A,L,de,I]),(0,Xe.Z)((e=>{let[t]=e;void 0!==t&&(0,it.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&&!T&&(!ve&&!q&&A&&(!ae.current||0===ae.current.length)||1===(null==A?void 0:A.length)&&"contactSignUp"===(null==x||null===(t=x[A[0]])||void 0===t||null===(n=t.content.action)||void 0===n?void 0:n.type)||"contactSignUp"===(null==q||null===(o=q.content)||void 0===o||null===(r=o.action)||void 0===r?void 0:r.type)),Ne=b&&k&&1===(null==A?void 0:A.length)&&"chatCreate"===(null==x||null===(l=x[A[0]])||void 0===l||null===(u=l.content.action)||void 0===u?void 0:u.type),Te=G&&!G.description,Ae=(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 i.ZP.createElement("div",{ref:ee,className:Ae,onScroll:Ce,onMouseDown:Vn.q},U?i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,F?F.text:"This is a private "+(C?"channel":"chat"))):G?i.ZP.createElement("div",{className:"empty"},$&&i.ZP.createElement("span",null,Ee("Loading")),Te&&i.ZP.createElement("span",null,Ee("NoMessages")),G&&i.ZP.createElement("div",{className:"bot-info",style:pe&&`width: ${pe.width}px`},me&&i.ZP.createElement("img",{src:me,width:null==pe?void 0:pe.width,height:null==pe?void 0:pe.height,alt:"Bot info"}),he&&i.ZP.createElement(Ks.Z,{canPlay:!0,src:he,loop:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0}),ge&&!me&&!he&&i.ZP.createElement(ga.Z,{width:null==pe?void 0:pe.width,height:null==pe?void 0:pe.height}),G.description&&i.ZP.createElement("div",{className:"bot-info-description"},i.ZP.createElement("p",{className:"bot-info-title"},Ee("BotInfoTitle")),(0,Ln.Z)(G.description,["br","emoji","links"])))):ke?i.ZP.createElement(Ya,{userId:p}):!A||ve&&!Ne?A&&ve||q?i.ZP.createElement(Xa,{isCurrentUserPremium:P,chatId:p,messageIds:A||[q.id],messageGroups:ve||Hn([q]),isViewportNewest:Boolean(L),isUnread:Boolean(B),withUsers:Me,areReactionsInMeta:Se,noAvatars:Re,containerRef:ee,anchorIdRef:ne,memoUnreadDividerBeforeIdRef:oe,memoFirstUnreadIdRef:ie,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}):i.ZP.createElement(qt.Z,{color:"white",backgroundColor:"dark"}):i.ZP.createElement(Ka,{chatId:p,type:v,isChatWithSelf:M,isGroupChatJustCreated:Ne}))}))),ti=(0,i.X$)((e=>{let{icon:t,ariaLabelLang:n,unreadCount:s,onClick:a,onReadAll:o,className:r}=e;const c=(0,yt.Z)(),l=(0,i.sO)(null),{isContextMenuOpen:d,handleContextMenu:u,handleContextMenuClose:m,handleContextMenuHide:h}=(0,es.Z)(l,!o);return i.ZP.createElement("div",{className:(0,_e.Z)("KboxtoWkfx23zfklH_Zg",r),ref:l},i.ZP.createElement(Rt.Z,{color:"secondary",round:!0,className:"sgkkv3bmIMAZS9G9BHUz",onClick:a,onContextMenu:u,ariaLabel:c(n)},i.ZP.createElement("i",{className:(0,_e.Z)("AafG9_xBi_2eJ_bFNnNg",`icon-${t}`)})),Boolean(s)&&i.ZP.createElement("div",{className:"yKN1kQ3YXf4SHHIBcotS"},(0,ut.bi)(s)),o&&i.ZP.createElement(Ht.Z,{isOpen:d,onClose:m,onCloseAnimationEnd:h,autoClose:!0,positionX:"right",positionY:"bottom"},i.ZP.createElement(Mt.Z,{icon:"readchats",onClick:o},c("MarkAllAsRead"))))})),ni=(0,i.X$)((0,s.c$)((e=>{const t=(0,c.Bt)(e);if(!t)return{};const{chatId:n,threadId:s,type:a}=t,i=(0,c.Z1)(e,n),r=i&&s===o._f&&"thread"===a;return{messageListType:a,chatId:n,reactionsCount:r?i.unreadReactionsCount:void 0,mentionsCount:r?i.unreadMentionsCount:void 0,unreadCount:r?i.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:n,messageListType:a,chatId:o,unreadCount:r,reactionsCount:c,mentionsCount:l,withExtraShift:d}=e;const{focusNextReply:u,focusNextReaction:m,focusNextMention:h,fetchUnreadReactions:g,readAllMentions:p,readAllReactions:f,fetchUnreadMentions:v}=(0,s.Sv)(),I=(0,i.sO)(null),w=Boolean(c),y=Boolean(l);(0,i.d4)((()=>{w&&o&&g({chatId:o})}),[o,g,w]),(0,i.d4)((()=>{y&&o&&v({chatId:o})}),[o,v,y]);const P=(0,i.I4)((()=>{if(t)if("thread"===a)u();else{const e=I.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),n=t[t.length-1];if(!n)return;(0,zn.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 i.ZP.createElement("div",{ref:I,className:Z},w&&i.ZP.createElement(ti,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:m,onReadAll:f,unreadCount:c}),y&&i.ZP.createElement(ti,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:h,onReadAll:p,unreadCount:l}),i.ZP.createElement(ti,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:P,unreadCount:r,className:"Hoi4yrJrfBHTmvB8TPce"}))})));var si=n(65723);const ai=1280,ii=/\.[^/.]+$/;async function oi(e,t,s,i){const o=URL.createObjectURL(t),{type:r,size:c}=t;let l,d,u;if(a.oG.has(r))if(s){const t=await(0,sn.pt)(o),{width:n,height:s}=t,a=n>ai||s>ai;if(a||"image/jpeg"!==r){const t=await Rn(o,a?ai/Math.max(n,s):1,"image/jpeg");return URL.revokeObjectURL(o),oi(e,await(0,sn.gm)(t),!0,i)}"image/jpeg"===r&&(e=e.replace(ii,".jpg")),l={width:n,height:s}}else u=o;else if(a.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,sn.jj)(o);l={width:e,height:t,duration:n},u=await(0,sn.ud)(o)}else if(a.e7.has(r)){const{duration:e,title:t,performer:s,coverUrl:a}=await async function(e){const{fetchFromUrl:t,selectCover:s}=await n.e(8505).then(n.t.bind(n,38505,23)),a=await t(e),{common:{title:i,artist:o,picture:r},format:{duration:c}}=a,l=s(r);return{title:i,performer:o,duration:c,coverUrl:l?`data:${l.format};base64,${l.data.toString("base64")}`:void 0}}(o);d={duration:e||0,title:t,performer:s},u=a}return{blobUrl:o,filename:e,mimeType:r,size:c,quick:l,audio:d,previewBlobUrl:u,...i}}var ri=n(41098),ci=n(96391);let li;function di(e){li.focus(),e.focus()}h.cj&&(li=document.createElement("input"),li.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(li));var ui=n(74288),mi=n(94462),hi=n(52400);const gi=new RegExp(`^${a.t8.source}$`,"g");var pi=n(56389),fi=n(70971);const vi={encoderPath:new URL(n(68973),n.b).href,reuseWorker:!0},Ii={type:"audio/ogg"};let wi,yi,Pi;async function Zi(){return wi||(wi=n.e(1161).then(n.t.bind(n,1161,23)),yi=(await wi).default,Pi=new yi(vi)),wi}async function Ci(e){await async function(){await Zi(),await Pi.start()}();const t=Date.now();let n;const s=[],a=[];Pi.ondataavailable=e=>{s.push(e)};const i=function(t,n){const s=t.sourceNode,i=s.context.createAnalyser();i.fftSize=64,s.connect(i);const o=i.frequencyBinCount,r=new Uint8Array(o);let c=!1;return function t(){if(c)return;i.getByteFrequencyData(r);const n=r.reduce(((e,t)=>e+t),0)/o/255;(t=>{a.push(255*t),e(t)})(n<.1?0:n),requestAnimationFrame(t)}(),()=>{c=!0}}(Pi);return{stop:()=>new Promise(((e,o)=>{Pi.onstop=()=>{e({blob:new Blob(s,Ii),duration:Math.round(((n||Date.now())-t)/1e3),waveform:a})},Pi.onerror=o;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Pi.stop(),i()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Pi.pause(),n=Date.now(),i()}),e)}}}var bi=n(21262),Ei=n(56266);const Si=["image/png","image/jpeg","image/gif"],Mi=/