2 lines
291 KiB
JavaScript
2 lines
291 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[596],{8173:(e,t,n)=>{n.r(t),n.d(t,{Main:()=>tr});var a=n(3555),s=n(3716),o=n(4050),i=(n(9005),n(6137)),r=n(5406),c=n(1192),l=n(735),d=n(5806);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,a.iw)("openLocalTextSearch",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{};if(t&&n)return(0,r.qr)(e,t,n,!0)})),(0,a.iw)("closeLocalTextSearch",u),(0,a.iw)("setLocalTextSearchQuery",((e,t,n)=>{const{chatId:a,threadId:s}=(0,c.Bt)(e)||{};if(!a||!s)return;const{query:o}=n,i=(0,d.uw)(a,s),{query:u}=e.localTextSearch.byChatThreadKey[i]||{};return o!==u&&(e=(0,r.Pb)(e,a,s,l.D)),(0,r.qr)(e,a,s,!0,o)})),(0,a.iw)("setLocalMediaSearchType",((e,t,n)=>{const{chatId:a}=(0,c.Bt)(e)||{};if(!a)return;const{mediaType:s}=n;return(0,r.z5)(e,a,s)})),(0,a.iw)("openChat",((e,t,n)=>{const{id:a,threadId:s=i._f,type:o="thread",shouldReplaceHistory:l=!1}=n,d=(0,c.Bt)(e);return d&&d.chatId===a&&d.threadId===s&&d.type===o||(a&&(e=(0,r.pf)(e,a,s,"replyStack",[])),e=u(e=(0,r.i9)(e)),e={...e,isStatisticsShown:!1,messages:{...e.messages,contentToBeScheduled:void 0},...a!==e.forwardMessages.toChatId&&{forwardMessages:{}}}),(0,r.Wy)(e,a,s,o,l)})),(0,a.iw)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,a.iw)("openChatWithInfo",((e,t,n)=>{(0,a.R3)({...e,isChatInfoShown:!0}),t.openChat(n)})),(0,a.iw)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,a.iw)("setNewChatMembersDialogState",((e,t,n)=>({...e,newChatMembersProgress:n}))),(0,a.iw)("openNextChat",((e,t,n)=>{const{targetIndexDelta:a,orderedIds:s}=n,{chatId:o}=(0,c.Bt)(e)||{};if(!o)return void t.openChat({id:s[0]});const i=s.indexOf(o);if(-1===i)return;const r=s[i+a];t.openChat({id:r,shouldReplaceHistory:!0})}));var m=n(1713),h=n(7361),g=n(782),p=n(2267),f=n(3099),v=n(711),I=n(4319);const y=s.ck+s.fK;let w;function Z(e,t,n){const{threadId:a}=(0,c.Bt)(e)||{},s=v.i0,o=(0,c.Zw)(e,t);if(!o||!a)return;const i=n.map((e=>o[e])).filter((t=>(0,c._k)(e,t,a).canCopy)).sort(((e,t)=>e.id-t.id)).reduce(((t,n)=>{const a=(0,c.Ur)(e,n);return t.push(`> ${a?(0,d.OU)(s,a):""}:`),t.push(`${(0,d.MK)(s,n,!1,0,void 0,!0)}\n`),t}),[]);(0,I.TE)(i.join("\n"))}(0,a.iw)("setScrollOffset",((e,t,n)=>{const{chatId:a,threadId:s,scrollOffset:o}=n;return(0,r.pf)(e,a,s,"scrollOffset",o)})),(0,a.iw)("setReplyingToId",((e,t,n)=>{const{messageId:a}=n,s=(0,c.Bt)(e);if(!s)return;const{chatId:o,threadId:i}=s;return(0,r.pf)(e,o,i,"replyingToId",a)})),(0,a.iw)("setEditingId",((e,t,n)=>{const{messageId:a}=n,s=(0,c.Bt)(e);if(!s)return;const{chatId:o,threadId:i,type:l}=s,d="scheduled"===l?"editingScheduledId":"editingId";return(0,r.pf)(e,o,i,d,a)})),(0,a.iw)("setEditingDraft",((e,t,n)=>{const{text:a,chatId:s,threadId:o,type:i}=n,c="scheduled"===i?"editingScheduledDraft":"editingDraft";return(0,r.pf)(e,s,o,c,a)})),(0,a.iw)("editLastMessage",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{};if(!t||!n)return;const a=(0,c.Zw)(e,t),s=(0,c.Cb)(e,t,n);if(!a||!s)return;const o=(0,g.dF)(s,(t=>Boolean(a[t]&&(0,c._k)(e,a[t],n).canEdit)));return o?(0,r.pf)(e,t,n,"editingId",o):void 0})),(0,a.iw)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:a}=n,{chatId:s,threadId:o}=(0,c.Bt)(e)||{};if(!s||!o)return;const r=(0,c.Zw)(e,s),l=(0,c.Cb)(e,s,o);if(!r||!l)return;const d=(0,c.Yy)(e,s,o);let u;if((0,c.b9)(e,s,o)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+a;u=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===i._f){var m;const t=(0,c.Z1)(e,s);u=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,c.tZ)(e,s,o);u=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:u}),t.focusMessage({chatId:s,threadId:o,messageId:u})})),(0,a.iw)("openAudioPlayer",((e,t,n)=>{const{chatId:a,threadId:s,messageId:o,origin:i,volume:r,playbackRate:c,isMuted:l}=n;return{...e,audioPlayer:{chatId:a,threadId:s,messageId:o,origin:null!=i?i:e.audioPlayer.origin,volume:null!=r?r:e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:l||e.audioPlayer.isMuted}}})),(0,a.iw)("setAudioPlayerVolume",((e,t,n)=>{const{volume:a}=n;return{...e,audioPlayer:{...e.audioPlayer,volume:a,isMuted:!1}}})),(0,a.iw)("setAudioPlayerPlaybackRate",((e,t,n)=>{const{playbackRate:a}=n;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:a}}})),(0,a.iw)("setAudioPlayerMuted",((e,t,n)=>{const{isMuted:a}=n;return{...e,audioPlayer:{...e.audioPlayer,isMuted:a}}})),(0,a.iw)("setAudioPlayerOrigin",((e,t,n)=>{const{origin:a}=n;return{...e,audioPlayer:{...e.audioPlayer,origin:a}}})),(0,a.iw)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,a.iw)("openPollResults",((e,t,n)=>{const{chatId:s,messageId:o}=n;if((0,c.Jf)(e)){if(s!==e.pollResults.chatId||o!==e.pollResults.messageId)return{...e,pollResults:{chatId:s,messageId:o,voters:{}}}}else window.setTimeout((()=>{e=(0,a.Rd)(),(0,a.R3)({...e,pollResults:{chatId:s,messageId:o,voters:{}}})}),450)})),(0,a.iw)("closePollResults",(e=>({...e,pollResults:{}}))),(0,a.iw)("focusLastMessage",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:a,threadId:s}=n;let o;if(s===i._f){var r;const t=(0,c.Z1)(e,a);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,c.tZ)(e,a,s);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:a,threadId:s,messageId:o,noHighlight:!0})})),(0,a.iw)("focusNextReply",((e,t)=>{const n=(0,c.Bt)(e);if(!n)return;const{chatId:s,threadId:o}=n,i=(0,c.p9)(e,s,o);if(i&&0!==i.length){const n=i.pop();e=(0,r.pf)(e,s,o,"replyStack",[...i]),(0,a.R3)(e),t.focusMessage({chatId:s,threadId:o,messageId:n})}else t.focusLastMessage()})),(0,a.iw)("focusMessage",((e,t,n)=>{const{chatId:s,threadId:o=i._f,messageListType:l="thread",noHighlight:d,groupedId:u,groupedChatId:h,replyMessageId:g,isResizingContainer:p}=n;let{messageId:f}=n;if(void 0!==u){const t=(0,c.y8)(e,h,u);null!=t&&t.length&&([f]=t)}const v=(0,c.Bt)(e),I=!v||s!==v.chatId||o!==v.threadId||l!==v.type;if(w&&(clearTimeout(w),w=void 0),w=window.setTimeout((()=>{let e=(0,a.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,a.R3)(e)}),d?y:1500),e=(0,r.cq)(e,s,f,d,p),e=(0,r.wV)(e,void 0),g){const t=(0,c.p9)(e,s,o)||[];e=(0,r.pf)(e,s,o,"replyStack",[...t,g])}I&&(e=(0,r.wV)(e,m.fo.Static));const Z=(0,c.Cb)(e,s,o);if(Z&&Z.includes(f))return(0,a.R3)(e),void t.openChat({id:s,threadId:o});if(I&&(e=(0,r.pf)(e,s,o,"viewportIds",void 0)),e=(0,r.pf)(e,s,o,"outlyingIds",void 0),Z&&!I){const t=f>Z[0]?m.fo.Down:m.fo.Up;e=(0,r.wV)(e,t)}(0,a.R3)(e),t.openChat({id:s,threadId:o}),t.loadViewportMessages()})),(0,a.iw)("openForwardMenu",((e,t,n)=>{const{fromChatId:a,messageIds:s,groupedId:o,withMyScore:i}=n;let r;return o&&(r=(0,c.xH)(e,a,o)),{...e,forwardMessages:{fromChatId:a,messageIds:r||s,isModalShown:!0,withMyScore:i}}})),(0,a.iw)("exitForwardMode",(e=>{(0,a.R3)({...e,forwardMessages:{}})})),(0,a.iw)("setForwardChatId",((e,t,n)=>{const{id:s}=n;(0,a.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:s,isModalShown:!1}}),t.openChat({id:s}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,a.iw)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:a}=e.selectedMessages;t.openForwardMenu({fromChatId:n,messageIds:a})})),(0,a.iw)("cancelMessageMediaDownload",((e,t,n)=>{const{message:s}=n,o=e.activeDownloads.byChatId[s.chatId];o&&o.length&&(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[s.chatId]:o.filter((e=>e!==s.id))}}})})),(0,a.iw)("cancelMessagesMediaDownload",((e,t,n)=>{const{messages:a}=n,s=e.activeDownloads.byChatId,o={};return Object.keys(s).forEach((e=>{o[e]=s[e].filter((e=>!a.find((t=>t.id===e))))})),{...e,activeDownloads:{byChatId:o}}})),(0,a.iw)("downloadMessageMedia",((e,t,n)=>{const{message:s}=n;(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[s.chatId]:[...e.activeDownloads.byChatId[s.chatId]||[],s.id]}}})})),(0,a.iw)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:a}=e.selectedMessages,{threadId:s}=(0,c.Bt)(e)||{},o=(0,c.Zw)(e,n);o&&s&&a.map((e=>o[e])).filter((t=>(0,c._k)(e,t,s).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,a.iw)("enterMessageSelectMode",((e,t,n)=>{const{messageId:a}=n||{},s=(0,c.jr)(e);return s?(0,r.M6)(e,s.id,a):e})),(0,a.iw)("toggleMessageSelection",((e,t,n)=>{const{messageId:s,groupedId:o,childMessageIds:i,withShift:l}=n,d=(0,c.Bt)(e);if(!d)return;const{chatId:u,threadId:m,type:g}=d;e=(0,r.Ob)(e,u,m,g,s,o,i,l),(0,a.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,a.iw)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,a.iw)("exitMessageSelectMode",r.i9),(0,a.iw)("openPollModal",((e,t,n)=>{const{isQuiz:a}=n||{};return{...e,pollModal:{isOpen:!0,isQuiz:a}}})),(0,a.iw)("closePollModal",(e=>({...e,pollModal:{isOpen:!1}}))),(0,a.iw)("checkVersionNotification",((e,t)=>{const n=s.Ji.split(".").slice(0,2).join("."),{serviceNotifications:a}=e;if(a.find((e=>{let{version:t}=e;return t===n})))return;const o={chatId:s.aw,date:(0,p.b)(e.serverTimeOffset),content:{text:(0,f.Z)("**Telegram Web Z was updated to version 1.42**\n\n👏 **Harder**\n• Telegram bots just became even [more powerful](https://t.me/telegram/178) – and Web Z fully supports their flexible interfaces.\n• Statistics for large groups and channels have expanded – see new metrics for recent posts at the bottom of the statistics page.\n\n🤩 **Better**\n• Emoji load faster on all platforms.\n\n💪 **Stronger**\n• An issue when adding users to groups has been fixed.\n• Fixed unwanted notifications caused by reactions to posts.\n• Online indicators for group members now work as expected.\n• Unexpected logouts should no longer occur.\n• Service notifications containing media are now rendered properly.\n• Read receipts now appear in groups with exactly 100 members.\n\n🦄 **We also welcome** you to join our official channels in **[English](t.me/webztalks)** and **[Russian](t.me/webzchannelru)** — where we post app updates and share our experiences building one of the world’s most feature-rich web applications.\n",!0)},isOutgoing:!1};t.createServiceNotification({message:o,version:n})})),(0,a.iw)("createServiceNotification",((e,t,n)=>{var o;const{message:i,version:r}=n,{serviceNotifications:l}=e,d=(0,c.Z1)(e,s.aw),u=Math.max((null===(o=d.lastMessage)||void 0===o?void 0:o.id)||0,...l.map((e=>{let{id:t}=e;return t}))),m=(l.length+1)/1e3,h=Math.floor(u)+m;i.previousLocalId=i.id,i.id=h;const g={id:h,message:i,version:r,isUnread:!0};(0,a.R3)({...e,serviceNotifications:[...l.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:i.id,chatId:i.chatId,message:i})})),(0,a.iw)("openReactorListModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,reactorModal:{chatId:a,messageId:s}}})),(0,a.iw)("closeReactorListModal",(e=>({...e,reactorModal:void 0}))),(0,a.iw)("openSeenByModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,seenByModal:{chatId:a,messageId:s}}})),(0,a.iw)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,a.iw)("copySelectedMessages",(e=>{if(!e.selectedMessages)return;const{chatId:t,messageIds:n}=e.selectedMessages;Z(e,t,n)})),(0,a.iw)("copyMessagesByIds",((e,t,n)=>{const{messageIds:a}=n,s=(0,c.jr)(e);a&&0!==a.length&&s&&Z(e,s.id,a)})),(0,a.iw)("setGlobalSearchQuery",((e,t,n)=>{const{query:a}=n,{chatId:s}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!s,messages:!0}}:{fetchingStatus:void 0},query:a})})),(0,a.iw)("addRecentlyFoundChatId",((e,t,n)=>{const{id:a}=n,{recentlyFoundChatIds:s}=e.globalSearch;if(!s)return(0,r.No)(e,{recentlyFoundChatIds:[a]});const o=s.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,a.iw)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,a.iw)("setGlobalSearchContent",((e,t,n)=>{const{content:a}=n;return(0,r.Og)(e,a)})),(0,a.iw)("setGlobalSearchChatId",((e,t,n)=>{const{id:a}=n;return(0,r.No)(e,{chatId:a,query:void 0,resultsByType:void 0})})),(0,a.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:a}=n;return{...e,stickers:{...e.stickers,search:{query:a,resultIds:void 0}}}})),(0,a.iw)("setGifSearchQuery",((e,t,n)=>{const{query:a}=n;return{...e,gifs:{...e.gifs,search:{query:a,offsetId:void 0,results:void 0}}}})),(0,a.iw)("setUserSearchQuery",((e,t,n)=>{const{query:a}=n;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a})})),(0,a.iw)("openAddContactDialog",((e,t,n)=>{const{userId:a}=n;return{...e,newContact:{userId:a}}})),(0,a.iw)("openNewContactDialog",(e=>({...e,newContact:{isByPhoneNumber:!0}}))),(0,a.iw)("closeNewContactDialog",(e=>(0,r.ft)(e))),n(3456);var P=n(1947),b=n(6926);(0,a.iw)("toggleChatInfo",((e,t,n)=>({...e,isChatInfoShown:void 0!==n?n:!e.isChatInfoShown}))),(0,a.iw)("setLeftColumnWidth",((e,t,n)=>({...e,leftColumnWidth:n}))),(0,a.iw)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,a.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,a.iw)("requestNextManagementScreen",((e,t,n)=>{const{screen:a}=n||{},{chatId:s}=(0,c.Bt)(e)||{};if(s)return{...e,management:{byChatId:{...e.management.byChatId,[s]:{...e.management.byChatId[s],isActive:!0,nextScreen:a}}}}})),(0,a.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,a.iw)("openChat",(e=>{if(h.wB||h.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,a.iw)("toggleStatistics",(e=>({...e,isStatisticsShown:!e.isStatisticsShown,statistics:{...e.statistics,currentMessageId:void 0}}))),(0,a.iw)("toggleMessageStatistics",((e,t,n)=>({...e,statistics:{...e.statistics,currentMessageId:null==n?void 0:n.messageId}}))),(0,a.iw)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,a.iw)("addRecentEmoji",((e,t,n)=>{const{emoji:a}=n,{recentEmojis:s}=e;if(!s)return{...e,recentEmojis:[a]};const o=s.filter((e=>e!==a));return o.unshift(a),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,a.iw)("addRecentSticker",((e,t,n)=>{const{sticker:a}=n,{recent:s}=e.stickers;if(!s)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[a]}}};const o=s.stickers.filter((e=>e.id!==a.id));return o.unshift(a),{...e,stickers:{...e.stickers,recent:{...s,stickers:o}}}})),(0,a.iw)("showNotification",((e,t,n)=>{const a=n;a.localId=(0,b.Z)({});const s=[...e.notifications],o=s.findIndex((e=>e.message===a.message));return-1!==o&&s.splice(o,1),s.push(a),{...e,notifications:s}})),(0,a.iw)("dismissNotification",((e,t,n)=>{const a=e.notifications.filter((e=>{let{localId:t}=e;return t!==n.localId}));return{...e,notifications:a}})),(0,a.iw)("showDialog",((e,t,n)=>{const{data:a}=n;if("message"in a&&a.hasErrorKey&&!(0,P.ZP)(a))return e;const s=[...e.dialogs];if("message"in a){const e=s.findIndex((e=>e.message===a.message));-1!==e&&s.splice(e,1)}return s.push(a),{...e,dialogs:s}})),(0,a.iw)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,a.iw)("toggleSafeLinkModal",((e,t,n)=>{const{url:a}=n;return{...e,safeLinkModalUrl:a}})),(0,a.iw)("openHistoryCalendar",((e,t,n)=>{const{selectedAt:a}=n;return{...e,historyCalendarSelectedAt:a}})),(0,a.iw)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,a.iw)("openGame",((e,t,n)=>{const{url:s,chatId:o,messageId:i}=n,r=(0,c.hj)(e,o,i);if(!r)return;const l=r.viaBotId||r.senderId,d=l&&(0,c.IK)(e,l);d&&((0,c.LM)(e,d)?(0,a.R3)({...e,openedGame:{url:s,chatId:o,messageId:i}}):(0,a.R3)({...e,botTrustRequest:{bot:d,type:"game",onConfirm:{action:"openGame",payload:n}}}))})),(0,a.iw)("closeGame",(e=>({...e,openedGame:void 0}))),(0,a.iw)("openPaymentModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,payment:{...e.payment,chatId:a,messageId:s,isPaymentModalOpen:!0}}})),(0,a.iw)("closePaymentModal",(e=>(e=(0,r.bp)(e),(0,r.WY)(e)))),(0,a.iw)("addPaymentError",((e,t,n)=>{const{error:a}=n;return{...e,payment:{...e.payment,error:a}}}));var C=n(8422);(0,a.iw)("openMediaViewer",((e,t,n)=>{const{chatId:a,threadId:s,messageId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c,volume:l,playbackRate:d,isMuted:u}=n;return{...e,mediaViewer:{...e.mediaViewer,chatId:a,threadId:s,messageId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c,volume:null!=l?l:e.mediaViewer.volume,playbackRate:d||e.mediaViewer.playbackRate,isMuted:u||e.mediaViewer.isMuted},forwardMessages:{}}})),(0,a.iw)("closeMediaViewer",(e=>{const{volume:t,isMuted:n,playbackRate:a}=e.mediaViewer;return{...e,mediaViewer:{volume:t,isMuted:n,playbackRate:a}}})),(0,a.iw)("setMediaViewerVolume",((e,t,n)=>{const{volume:a}=n;return{...e,mediaViewer:{...e.mediaViewer,volume:a,isMuted:!1}}})),(0,a.iw)("setMediaViewerPlaybackRate",((e,t,n)=>{const{playbackRate:a}=n;return{...e,mediaViewer:{...e.mediaViewer,playbackRate:a}}})),(0,a.iw)("setMediaViewerMuted",((e,t,n)=>{const{isMuted:a}=n;return{...e,mediaViewer:{...e.mediaViewer,isMuted:a}}})),n(5456),n(7225);var S=n(1226),E=n(9118);const M=new Map,R=(0,E.Ds)((e=>e()),500,!1);async function k(e,t,n,o){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const d=e.id;let u;switch(o){case m.Uq.Backwards:u=void 0;break;case m.Uq.Around:u=-(Math.round(s.hT/2)+1);break;case m.Uq.Forwards:u=-(s.hT+1)}const h=await(0,S.t9)("fetchMessages",{chat:(0,c.Cm)((0,a.Rd)(),d,t),offsetId:n,addOffset:u,limit:s.hT,threadId:t});if(!h)return;const{messages:p,users:f,chats:v,threadInfos:I}=h;let y=(0,a.Rd)();const w=d===s.aw?y.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],Z=[].concat(p,w),P=(0,g.ee)(Z,"id"),b=Object.keys(P).map(Number);y=(0,r.c_)(y,d,P),y=i?(0,r.ff)(y,d,t,b):(0,r.xj)(y,d,t,b),y=(0,r.Sh)(y,(0,g.ee)(f,"id")),y=(0,r.fZ)(y,(0,g.ee)(v,"id")),y=(0,r.j6)(y,d,I);let C=(0,c.gb)(y,d,t);const E=(0,c.qC)(y,d,t);if(i&&C&&E&&(E.length&&!(0,g.YE)(C,E)||(y=(0,r.xj)(y,d,t,E),C=(0,c.gb)(y,d,t),y=(0,r.pf)(y,d,t,"outlyingIds",void 0),i=!1)),!l){const e=i?E:C,{newViewportIds:a}=N(e,n,o);y=(0,r.y9)(y,d,t,a)}(0,a.R3)(y)}function N(e,t,n){const{length:a}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((n,a)=>n===t||n<t&&e[a+1]>t))}(e,t):-1,i=n===m.Uq.Backwards?o:o+1||a,r=i-s.hT,c=i+s.hT-1,l=e.slice(Math.max(0,r),c+1);let d,u;switch(n){case m.Uq.Backwards:d=i>0,u=r>=0;break;case m.Uq.Forwards:d=i<a,u=c<=a-1;break;case m.Uq.Around:default:d=l.length>0,u=l.length===s.hT}return{newViewportIds:l,areSomeLocal:d,areAllLocal:u}}async function T(e){let t;const n=e.attachment?(e,s)=>{M.has(s)||(t=s,M.set(s,n));const o=(0,a.Rd)();(0,a.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[s]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,E.Pn)();const s=(0,a.Rd)();e.serverTimeOffset=s.serverTimeOffset;const o=(0,c.Bt)(s);if(!o)return;const{threadId:r}=o;e.replyingTo||r===i._f||(e.replyingTo=(0,c.qS)(s,e.chat.id,r)),await(0,S.t9)("sendMessage",e,n),n&&t&&M.delete(t)}(0,a.iw)("loadViewportMessages",((e,t,n)=>{const{direction:a=m.Uq.Around,isBudgetPreload:o=!1}=n||{};let{chatId:i,threadId:l}=n||{};if(!i){const t=(0,c.Bt)(e);if(!t)return;i=t.chatId,l=t.threadId}const d=(0,c.Z1)(e,i);if(!d||d.isRestricted)return;const u=(0,c.Cb)(e,i,l),h=(0,c.gb)(e,i,l),g=(0,c.qC)(e,i,l);if(u&&u.length&&a!==m.Uq.Around){const n=a===m.Uq.Backwards?u[0]:u[u.length-1],s=Boolean(g),c=s?g:h,{newViewportIds:p,areSomeLocal:f,areAllLocal:v}=N(c,n,a);if(f&&(e=(0,r.y9)(e,i,l,p)),(0,E.R3)((()=>{!async function(e,t,n,a,s,o,i,r){t||await k(s,o,r,i,n,a),a||e.loadViewportMessages({chatId:s.id,threadId:o,direction:i,isBudgetPreload:!0})}(t,v,s,o,d,l,a,n)})),o)return}else{const t=(0,c.G$)(e,i)||(0,c.rd)(e,i,l),n=Boolean(t&&h&&!h.includes(t)),a=(n?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=N(a,t,m.Uq.Around);p&&u.length>=s.hT&&(e=(0,r.y9)(e,i,l,u)),f||(0,E.R3)((()=>{k(d,l,t,m.Uq.Around,n,o)}))}return e})),(0,a.iw)("loadMessage",(async(e,t,n)=>{const{chatId:s,messageId:o,replyOriginForId:l,threadUpdate:d}=n,u=(0,c.Z1)(e,s);if(!u)return;const m=await async function(e,t,n){const s=await(0,S.t9)("fetchMessage",{chat:e,messageId:t});if(!s)return;if(s===i._Q){if(n){let t=(0,a.Rd)();const s=(0,c.hj)(t,e.id,n);t=(0,r.cY)(t,e.id,n,{...s,replyToMessageId:void 0}),(0,a.R3)(t)}return}let o=(0,a.Rd)();return o=(0,r.cY)(o,e.id,t,s.message),o=(0,r.Sh)(o,(0,g.ee)(s.users,"id")),(0,a.R3)(o),s.message}(u,o,l);if(m&&d){const{lastMessageId:e,isDeleting:t}=d;(0,a.R3)((0,r.lG)((0,a.Rd)(),m,s,e,t))}})),(0,a.iw)("sendMessage",((e,t,n)=>{const a=(0,c.Bt)(e);if(!a)return;const{chatId:o,threadId:i,type:r}=a;if("scheduled"===r&&!n.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:n}};const l=(0,c.Z1)(e,o),d={...n,chat:l,replyingTo:(0,c.Yy)(e,o,i),noWebPage:(0,c.tV)(e,o,i),sendAs:(0,c._5)(e,o)};t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:i,value:!1});const u=!n.attachments||n.attachments.length<=1,m=!u&&n.attachments&&n.attachments.length>1;if(u){const{attachments:e,...t}=d;T({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:n,...a}=d,o=(0,g.Vl)(n,s.DU);for(let n=0;n<o.length;n++){const[s,...i]=o[n],r=`${Date.now()}${n}`;T({...a,text:0===n?e:void 0,entities:0===n?t:void 0,attachment:s,groupedId:i.length>0?r:void 0}),i.forEach((e=>{T({...a,attachment:e,groupedId:r})}))}}else{const{text:e,entities:t,attachments:n,replyingTo:a,...s}=d;e&&T({...s,text:e,entities:t,replyingTo:a}),n.forEach((e=>{T({...s,attachment:e})}))}})),(0,a.iw)("editMessage",((e,t,n)=>{const{serverTimeOffset:a}=e,{text:s,entities:o}=n,i=(0,c.Bt)(e);if(!i)return;const{chatId:r,threadId:l,type:d}=i,u=(0,c.Z1)(e,r),m=(0,c.kK)(e,r,l,d);u&&m&&((0,S.t9)("editMessage",{chat:u,message:m,text:s,entities:o,noWebPage:(0,c.tV)(e,r,l),serverTimeOffset:a}),t.setEditingId({messageId:void 0}))})),(0,a.iw)("cancelSendingMessage",((e,t,n)=>{const{chatId:a,messageId:s}=n,o=(0,c.hj)(e,a,s),i=o&&M.get(o.previousLocalId||o.id);i&&(0,S.u3)(i),t.apiUpdate({"@type":"deleteMessages",ids:[s],chatId:a})})),(0,a.iw)("saveDraft",((e,t,n)=>{const{chatId:a,threadId:s,draft:o}=n;if(!o)return;const{text:l,entities:d}=o,u=(0,c.Z1)(e,a);return s===i._f&&(0,S.t9)("saveDraft",{chat:u,text:l,entities:d,replyToMsgId:(0,c.Yy)(e,a,s)}),e=(0,r.pf)(e,a,s,"draft",o),(0,r.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)})})),(0,a.iw)("clearDraft",((e,t,n)=>{const{chatId:a,threadId:s,localOnly:o}=n;if(!(0,c.Ms)(e,a,s))return;const l=(0,c.Z1)(e,a);return o||s!==i._f||(0,S.t9)("clearDraft",l),e=(0,r.pf)(e,a,s,"draft",void 0),(0,r.a4)(e,a,{draftDate:void 0})})),(0,a.iw)("toggleMessageWebPage",((e,t,n)=>{const{chatId:a,threadId:s,noWebPage:o}=n;return(0,r.pf)(e,a,s,"noWebPage",o)})),(0,a.iw)("pinMessage",((e,t,n)=>{const a=(0,c.jr)(e);if(!a)return;const{messageId:s,isUnpin:o,isOneSide:i,isSilent:r}=n;(0,S.t9)("pinMessage",{chat:a,messageId:s,isUnpin:o,isOneSide:i,isSilent:r})})),(0,a.iw)("unpinAllMessages",((e,t,n)=>{const s=(0,c.Z1)(e,n.chatId);s&&async function(e){await(0,S.t9)("unpinAllMessages",{chat:e});let t=(0,a.Rd)();t=(0,r.pf)(t,e.id,i._f,"pinnedIds",[]),(0,a.R3)(t)}(s)})),(0,a.iw)("deleteMessages",((e,t,n)=>{const{messageIds:a,shouldDeleteForAll:s}=n,o=(0,c.Bt)(e);if(!o)return;const{chatId:i,threadId:r}=o,l=(0,c.Z1)(e,i);(0,S.t9)("deleteMessages",{chat:l,messageIds:a,shouldDeleteForAll:s});const d=(0,c._$)(e,i,r);a.includes(d)&&t.setEditingId({messageId:void 0})})),(0,a.iw)("deleteScheduledMessages",((e,t,n)=>{const{messageIds:a}=n,s=(0,c.Bt)(e);if(!s)return;const{chatId:o}=s,i=(0,c.Z1)(e,o);(0,S.t9)("deleteScheduledMessages",{chat:i,messageIds:a});const r=(0,c.wU)(e,o);a.includes(r)&&t.setEditingId({messageId:void 0})})),(0,a.iw)("deleteHistory",(async(e,t,n)=>{var a;const{chatId:s,shouldDeleteForAll:o}=n,i=(0,c.Z1)(e,s);if(!i)return;const r=null===(a=i.lastMessage)||void 0===a?void 0:a.id;await(0,S.t9)("deleteHistory",{chat:i,shouldDeleteForAll:o,maxId:r});const l=(0,c.Bt)(e);l&&l.chatId===s&&t.openChat({id:void 0})})),(0,a.iw)("reportMessages",(async(e,t,n)=>{const{messageIds:a,reason:s,description:o}=n,i=(0,c.Bt)(e);if(!i)return;const{chatId:r}=i,l=(0,c.Z1)(e,r),d=await(0,S.t9)("reportMessages",{peer:l,messageIds:a,reason:s,description:o});t.showNotification({message:d?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,a.iw)("sendMessageAction",(async(e,t,n)=>{const{action:a,chatId:s,threadId:o}=n;if(s===e.currentUserId)return;const i=(0,c.Z1)(e,s);i&&await(0,S.t9)("sendMessageAction",{peer:i,threadId:o,action:a})})),(0,a.iw)("markMessageListRead",((e,t,n)=>{const{serverTimeOffset:a}=e,o=(0,c.Bt)(e);if(!o)return;const{chatId:l,threadId:d}=o,u=(0,c.Cm)(e,l,d);if(!u)return;const{maxId:m}=n;if(R((()=>{(0,S.t9)("markMessageListRead",{serverTimeOffset:a,chat:u,threadId:d,maxId:m})})),d!==i._f)return;l===s.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 a=0;for(let s=0,o=e.length;s<o&&(e[s]>=t&&e[s]<=n&&a++,!(e[s]>=n));s++);return a}(h,g,m);return p?(0,r.a4)(e,l,{lastReadInboxMessageId:m,unreadCount:Math.max(0,u.unreadCount-p)}):e})),(0,a.iw)("markMessagesRead",((e,t,n)=>{const a=(0,c.jr)(e);if(!a)return;const{messageIds:s}=n;(0,S.t9)("markMessagesRead",{chat:a,messageIds:s})})),(0,a.iw)("loadWebPagePreview",((e,t,n)=>{const{text:s}=n;!async function(e){const t=await(0,S.t9)("fetchWebPagePreview",{message:e});(0,a.R3)({...(0,a.Rd)(),webPagePreview:t})}(s)})),(0,a.iw)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,a.iw)("sendPollVote",((e,t,n)=>{const{chatId:a,messageId:s,options:o}=n,i=(0,c.Z1)(e,a);i&&(0,S.t9)("sendPollVote",{chat:i,messageId:s,options:o})})),(0,a.iw)("loadPollOptionResults",((e,t,n)=>{const{chat:s,messageId:o,option:i,offset:c,limit:l,shouldResetVoters:d}=n;!async function(e,t,n,s,o,i){const c=await(0,S.t9)("loadPollOptionResults",{chat:e,messageId:t,option:n,offset:s,limit:o});if(!c)return;let l=(0,a.Rd)();l=(0,r.Sh)(l,(0,g.ee)(c.users,"id"));const{voters:d}=l.pollResults;(0,a.R3)({...l,pollResults:{...l.pollResults,voters:{...d,[n]:(0,g.Tw)([...!i&&d&&d[n]?d[n]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[n]:c.nextOffset||""}}})}(s,o,i,c,l,d)})),(0,a.iw)("forwardMessages",((e,t,n)=>{const{fromChatId:s,messageIds:o,toChatId:i,withMyScore:r}=e.forwardMessages,l=s?(0,c.Z1)(e,s):void 0,u=i?(0,c.Z1)(e,i):void 0,m=s&&o?o.sort(((e,t)=>e-t)).map((t=>(0,c.hj)(e,s,t))).filter(Boolean):void 0;if(!l||!u||!m)return;const{isSilent:h,scheduledAt:g}=n,p=(0,c._5)(e,i),f=m.filter((e=>!(0,d.jM)(e)));f.length&&(0,S.t9)("forwardMessages",{fromChat:l,toChat:u,messages:f,serverTimeOffset:(0,a.Rd)().serverTimeOffset,isSilent:h,scheduledAt:g,sendAs:p,withMyScore:r}),m.filter((e=>(0,d.jM)(e))).forEach((e=>{const{text:t,entities:n}=e.content.text||{},{sticker:a,poll:s}=e.content;T({chat:u,text:t,entities:n,sticker:a,poll:s,isSilent:h,scheduledAt:g,sendAs:p})})),(0,a.R3)({...(0,a.Rd)(),forwardMessages:{}})})),(0,a.iw)("loadScheduledHistory",((e,t,n)=>{const{chatId:s}=n,o=(0,c.Z1)(e,s);o&&async function(e){const t=await(0,S.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:n}=t,s=(0,g.ee)(n,"id"),o=Object.keys(s).map(Number).sort(((e,t)=>t-e));let c=(0,a.Rd)();c=(0,r.w3)(c,e.id,s),c=(0,r.pf)(c,e.id,i._f,"scheduledIds",o),(0,a.R3)(c)}(o)})),(0,a.iw)("sendScheduledMessages",((e,t,n)=>{const{chatId:a,id:s}=n,o=(0,c.Z1)(e,a);o&&(0,S.t9)("sendScheduledMessages",{chat:o,ids:[s]})})),(0,a.iw)("rescheduleMessage",((e,t,n)=>{const{chatId:a,messageId:s,scheduledAt:o}=n,i=(0,c.Z1)(e,a),r=i&&(0,c.Tm)(e,i.id,s);i&&r&&(0,S.t9)("rescheduleMessage",{chat:i,message:r,scheduledAt:o})})),(0,a.iw)("requestThreadInfoUpdate",((e,t,n)=>{const{chatId:a,threadId:s}=n,o=(0,c.Cm)(e,a,s);o&&(0,S.t9)("requestThreadInfoUpdate",{chat:o,threadId:s})})),(0,a.iw)("loadPinnedMessages",((e,t,n)=>{const{chatId:s}=n,o=(0,c.Z1)(e,s);o&&async function(e){const t=await(0,S.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:n,chats:s,users:o}=t,c=(0,g.ee)(n,"id"),l=Object.keys(c).map(Number).sort(((e,t)=>t-e));let d=(0,a.Rd)();d=(0,r.c_)(d,e.id,c),d=(0,r.pf)(d,e.id,i._f,"pinnedIds",l),d=(0,r.Sh)(d,(0,g.ee)(o,"id")),d=(0,r.fZ)(d,(0,g.ee)(s,"id")),(0,a.R3)(d)}(o)})),(0,a.iw)("loadSeenBy",(async(e,t,n)=>{const{chatId:s,messageId:o}=n,i=(0,c.Z1)(e,s);if(!i)return;const l=await(0,S.t9)("fetchSeenBy",{chat:i,messageId:o});l&&(0,a.R3)((0,r.cY)((0,a.Rd)(),s,o,{seenByUserIds:l}))})),(0,a.iw)("saveDefaultSendAs",((e,t,n)=>{const{chatId:a,sendAsId:s}=n,o=(0,c.Z1)(e,a),i=(0,c.Z1)(e,s)||(0,c.dy)(e,s);if(o&&i)return(0,S.t9)("saveDefaultSendAs",{sendAs:i,chat:o}),(0,r.a4)(e,a,{fullInfo:{...o.fullInfo,sendAsId:s}})})),(0,a.iw)("loadSendAs",(async(e,t,n)=>{const{chatId:s}=n,o=(0,c.Z1)(e,s);if(!o)return;const i=await(0,S.t9)("fetchSendAs",{chat:o});i?(e=(0,a.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(i.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(i.chats,"id")),e=(0,r.a4)(e,s,{sendAsIds:i.ids}),(0,a.R3)(e)):(0,a.R3)((0,r.a4)((0,a.Rd)(),s,{sendAsIds:[]}))})),(0,a.iw)("loadSponsoredMessages",(async(e,t,n)=>{const{chatId:s}=n,o=(0,c.Z1)(e,s);if(!o)return;const i=await(0,S.t9)("fetchSponsoredMessages",{chat:o});i&&(e=(0,a.Rd)(),e=(0,r.Fn)(e,s,i.messages[0]),e=(0,r.Sh)(e,(0,g.ee)(i.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(i.chats,"id")),(0,a.R3)(e))})),(0,a.iw)("viewSponsoredMessage",((e,t,n)=>{const{chatId:a}=n,s=(0,c.Z1)(e,a),o=(0,c.fS)(e,a);s&&o&&(0,S.t9)("viewSponsoredMessage",{chat:s,random:o.randomId})}));var B=n(5765);const A=(0,E.P2)((e=>e()),500,!1);async function x(e,t){const n=await(0,S.t9)("searchGifs",{query:e,offset:t});n&&(0,a.R3)((0,r.rq)((0,a.Rd)(),!t,n.gifs,n.nextOffset))}(0,a.iw)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,S.t9)("fetchStickerSets",{hash:e});t&&(0,a.R3)((0,r.z3)((0,a.Rd)(),"added",t.hash,t.sets))}(t)})),(0,a.iw)("loadAddedStickers",(async(e,t)=>{const{setIds:n}=e.stickers.added,a=e.stickers.setsById;if(n&&n.length)for(let e=0;e<n.length;e++){const s=n[e];a[s].stickers||(t.loadStickers({stickerSetId:s}),e%10==0&&e>0&&await(0,E.wO)(200))}})),(0,a.iw)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,S.t9)("fetchRecentStickers",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,recent:t}})}(t)})),(0,a.iw)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,S.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,favorite:t}})}(t)})),(0,a.iw)("loadGreetingStickers",(async e=>{const{hash:t}=e.stickers.greeting||{},n=await(0,S.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});n&&(e=(0,a.Rd)(),(0,a.R3)({...e,stickers:{...e.stickers,greeting:{hash:n.hash,stickers:n.stickers.filter((e=>"👋"===e.emoji))}}}))})),(0,a.iw)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,S.t9)("fetchFeaturedStickers",{hash:e});t&&(0,a.R3)((0,r.z3)((0,a.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,a.iw)("loadStickers",((e,t,n)=>{const{stickerSetId:s,stickerSetShortName:o}=n;let{stickerSetAccessHash:i}=n;if(!i&&!o){const t=(0,c.Ny)(e,s);if(!t)return;i=t.accessHash}!async function(e,t,n){const s=await(0,S.t9)("fetchStickers",{stickerSetShortName:n,stickerSetId:e,accessHash:t});if(!s)return;const{set:o,stickers:i,packs:c}=s;let l=(0,a.Rd)();l=(0,r.Rg)(l,o.id,{...o,stickers:i,packs:c});const d=l.stickers.forEmoji.emoji;d&&c[d]&&(l=(0,r.vy)(l)),(0,a.R3)(l)}(s,i,o)})),(0,a.iw)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,S.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:n}=e;(0,a.R3)((0,r.g_)((0,a.Rd)(),{...t,stickers:n}))}(),async function(){const e=await(0,S.t9)("fetchAnimatedEmojiEffects");if(!e)return;const{set:t,stickers:n}=e;(0,a.R3)({...(0,a.Rd)(),animatedEmojiEffects:{...t,stickers:n}})}()})),(0,a.iw)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,S.t9)("fetchSavedGifs",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,gifs:{...n.gifs,saved:t}})}(t)})),(0,a.iw)("saveGif",(async(e,t,n)=>{var s;const{gif:o,shouldUnsave:i}=n;if(!await(0,S.t9)("saveGif",{gif:o,shouldUnsave:i}))return;const r=(null===(s=(e=(0,a.Rd)()).gifs.saved.gifs)||void 0===s?void 0:s.filter((e=>{let{id:t}=e;return t!==o.id})))||[],c=i?r:[o,...r];(0,a.R3)({...e,gifs:{...e.gifs,saved:{...e.gifs.saved,gifs:c}}})})),(0,a.iw)("faveSticker",((e,t,n)=>{const{sticker:a}=n;a&&(0,S.t9)("faveSticker",{sticker:a})})),(0,a.iw)("unfaveSticker",((e,t,n)=>{const{sticker:s}=n;s&&function(e){const t=(0,a.Rd)();(0,a.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,S.t9)("faveSticker",{sticker:e,unfave:!0})}(s)})),(0,a.iw)("toggleStickerSet",((e,t,n)=>{const{stickerSetId:a}=n,s=(0,c.Ny)(e,a);if(!s)return;const{accessHash:o,installedDate:i}=s;(0,S.t9)(i?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.iw)("loadEmojiKeywords",(async(e,t,n)=>{var s,o;const{language:i}=n;let r=e.emojiKeywords[i];if(null!==(s=r)&&void 0!==s&&s.isLoading)return;(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[i]:{...r,isLoading:!0}}});const c=await(0,S.t9)("fetchEmojiKeywords",{language:i,fromVersion:r?r.version:0});r=(e=(0,a.Rd)()).emojiKeywords[i],c?(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[i]:{isLoading:!1,version:c.version,keywords:{...null===(o=r)||void 0===o?void 0:o.keywords,...c.keywords}}}}):(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[i]:{...r,isLoading:!1}}})})),(0,a.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:s}=n;s&&A((()=>{!async function(e,t){const n=await(0,S.t9)("searchStickers",{query:e,hash:void 0});if(!n)return;const s=(0,a.Rd)(),{setsById:o,added:i}=s.stickers,c=n.sets.map((e=>{let{id:t}=e;return t}));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:n}=o[t]||{};n&&(0,B.Z)(n,e)&&c.unshift(t)}})),(0,a.R3)((0,r.z3)(s,"search",n.hash,n.sets,c))}(s)}))})),(0,a.iw)("setGifSearchQuery",((e,t,n)=>{const{query:a}=n;"string"==typeof a&&A((()=>{x(a)}))})),(0,a.iw)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&A((()=>{x(t,n)}))})),(0,a.iw)("loadStickersForEmoji",((e,t,n)=>{const{emoji:s}=n,{hash:o}=e.stickers.forEmoji;A((()=>{!async function(e,t){let n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,forEmoji:{...n.stickers.forEmoji,emoji:e}}});const s=await(0,S.t9)("fetchStickersForEmoji",{emoji:e,hash:t});n=(0,a.Rd)(),s&&n.stickers.forEmoji.emoji===e&&(n=(0,r.IM)(n,e,s.stickers,s.hash),(0,a.R3)(n))}(s,o)}))})),(0,a.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.iw)("openStickerSetShortName",((e,t,n)=>{const{stickerSetShortName:a}=n;return{...e,openedStickerSetShortName:a}}));var L=n(790);const O=(0,E.P2)((e=>e()),500,!1);async function U(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0;if(i){const a=await(0,S.t9)("searchMessagesLocal",{chat:i,query:t,type:n,limit:s.Hk,offsetId:o,minDate:d,maxDate:l});if(a){const{messages:t,users:n,totalCount:s,nextOffsetId:o}=a;e={messages:t,users:n,chats:[],totalCount:s,nextRate:o}}}else e=await(0,S.t9)("searchMessagesGlobal",{query:t,offsetRate:o,limit:s.Hk,type:n,maxDate:l,minDate:d});let u=(0,a.Rd)();const m=(0,c.JX)(u);if(!e||""!==t&&t!==m)return void(0,a.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,a.R3)(u)}async function F(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=await(0,S.t9)("searchMessagesLocal",{chat:e,type:t,limit:2*s.EN,offsetId:n});if(!i)return;const{chats:l,users:d,messages:u,totalCount:m,nextOffsetId:h}=i,p=(0,g.ee)(u,"id"),f=Object.keys(p).map(Number);let v=(0,a.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,a.R3)(v),o||F(e,t,h,!0))}(0,a.iw)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:s}=e.globalSearch,{query:o}=n;o&&!s&&O((()=>{!async function(e){const t=await(0,S.t9)("searchChats",{query:e});let n=(0,a.Rd)();const s=(0,c.JX)(n);if(!t||!s||e!==s)return void(0,a.R3)((0,r.xv)(n,{chats:!1}));const{localChats:o,localUsers:i,globalChats:l,globalUsers:d}=t;(o.length||l.length)&&(n=(0,r.fZ)(n,(0,g.ee)([...o,...l],"id"))),(i.length||d.length)&&(n=(0,r.Sh)(n,(0,g.ee)([...i,...d],"id"))),n=(0,r.xv)(n,{chats:!1}),n=(0,r.No)(n,{localResults:{chatIds:o.map((e=>{let{id:t}=e;return t})),userIds:i.map((e=>{let{id:t}=e;return t}))},globalResults:{...n.globalSearch.globalResults,chatIds:l.map((e=>{let{id:t}=e;return t})),userIds:d.map((e=>{let{id:t}=e;return t}))}}),(0,a.R3)(n)}(o)}))})),(0,a.iw)("setGlobalSearchDate",((e,t,n)=>{const{date:s}=n,o=s?(0,L.IS)(s):s;e=(0,r.No)(e,{date:s,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}}),(0,a.R3)(e);const{chatId:i}=e.globalSearch;U("","text",void 0,i?(0,c.Z1)(e,i):void 0,o,s)})),(0,a.iw)("searchMessagesGlobal",((e,t,n)=>{var a;const{query:s,resultsByType:o,chatId:i,date:r}=e.globalSearch,l=r?(0,L.IS)(r):r,{type:d}=n;U(s,d,null==o||null===(a=o[d])||void 0===a?void 0:a.nextOffsetId,i?(0,c.Z1)(e,i):void 0,l,r)})),(0,a.iw)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:n}=(0,c.Bt)(e)||{},o=t?(0,c.Z1)(e,t):void 0,l=(0,c.n5)(e);if(!o||!l||!n)return;const{query:d,results:u}=l,m=null==u?void 0:u.nextOffsetId;let h;if(n!==i._f){const a=(0,c.tZ)(e,t,n);h=null==a?void 0:a.topMessageId}!async function(e,t,n,o,i){if(!o)return;const l=await(0,S.t9)("searchMessagesLocal",{chat:e,type:"text",query:o,topMessageId:n,limit:s.pn,offsetId:i});if(!l)return;const{chats:d,users:u,messages:m,totalCount:h,nextOffsetId:p}=l,f=(0,g.ee)(m,"id"),v=Object.keys(f).map(Number);let I=(0,a.Rd)();const y=(0,c.n5)(I);y&&o===y.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,a.R3)(I))}(o,n,h,d,m)})),(0,a.iw)("searchMediaMessagesLocal",(e=>{const{chatId:t}=(0,c.Bt)(e)||{};if(!t)return;const n=(0,c.Z1)(e,t),a=(0,c.we)(e);if(!n||!a)return;const{currentType:s,resultsByType:o}=a,i=s&&o&&o[s],r=null==i?void 0:i.nextOffsetId;s&&F(n,s,r)})),(0,a.iw)("searchMessagesByDate",((e,t,n)=>{const{timestamp:s}=n,{chatId:o}=(0,c.Bt)(e)||{};if(!o)return;const i=(0,c.Z1)(e,o);i&&async function(e,t){const n=await(0,S.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});n&&(0,a.Sv)().focusMessage({chatId:e.id,messageId:n})}(i,s)})),(0,a.iw)("checkPublicLink",(async(e,t,n)=>{const{chatId:s}=(0,c.Bt)(e)||{};if(!s)return;if(e.management.progress===m.wv.InProgress)return;const{username:o}=n;e=(0,r.H9)(e,m.wv.InProgress),e=(0,r.fw)(e,s,{isUsernameAvailable:void 0}),(0,a.R3)(e);const i=await(0,S.t9)("checkChatUsername",{username:o});e=(0,a.Rd)(),e=(0,r.H9)(e,i?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,s,{isUsernameAvailable:i}),(0,a.R3)(e)})),(0,a.iw)("updatePublicLink",(async(e,t,n)=>{const{chatId:s}=(0,c.Bt)(e)||{};let o=s&&(0,c.Z1)(e,s);if(!s||!o)return;const{username:i}=n;if(e=(0,r.H9)(e,m.wv.InProgress),(0,a.R3)(e),(0,d.G9)(o)){if(o=await(0,S.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const l=await(0,S.t9)("setChatUsername",{chat:o,username:i});e=(0,a.Rd)(),e=(0,r.H9)(e,l?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,s,{isUsernameAvailable:void 0}),(0,a.R3)(e)})),(0,a.iw)("updatePrivateLink",(e=>{const{chatId:t}=(0,c.Bt)(e)||{},n=t&&(0,c.Z1)(e,t);t&&n&&(0,S.t9)("updatePrivateLink",{chat:n})})),(0,a.iw)("setEditingExportedInvite",((e,t,n)=>{const{chatId:s,invite:o}=n;(0,a.R3)((0,r.fw)(e,s,{editingInvite:o}))})),(0,a.iw)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:s,invite:o}=n,i=o?{inviteInfo:{invite:o}}:{inviteInfo:void 0};(0,a.R3)((0,r.fw)(e,s,i))})),(0,a.iw)("loadExportedChatInvites",(async(e,t,n)=>{const{chatId:s,adminId:o,isRevoked:i,limit:l}=n,d=(0,c.Z1)(e,s),u=(0,c.dy)(e,o||e.currentUserId);if(!d||!u)return;const m=await(0,S.t9)("fetchExportedChatInvites",{peer:d,admin:u,isRevoked:i,limit:l});if(!m)return;const h=i?{revokedInvites:m}:{invites:m};(0,a.R3)((0,r.fw)((0,a.Rd)(),s,h))})),(0,a.iw)("editExportedChatInvite",(async(e,t,n)=>{const{chatId:s,link:o,isRevoked:i,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m}=n,h=(0,c.Z1)(e,s);if(!h)return;const g=await(0,S.t9)("editExportedChatInvite",{peer:h,link:o,isRevoked:i,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m});if(!g)return;const{oldInvite:p,newInvite:f}=g,v=((e=(0,a.Rd)()).management.byChatId[s].invites||[]).filter((e=>e.link!==p.link)),I=[...e.management.byChatId[s].revokedInvites||[]];f.isRevoked?I.unshift(f):v.push(f),(0,a.R3)((0,r.fw)(e,s,{invites:v,revokedInvites:I}))})),(0,a.iw)("exportChatInvite",(async(e,t,n)=>{const{chatId:s,expireDate:o,usageLimit:i,isRequestNeeded:l,title:d}=n,u=(0,c.Z1)(e,s);if(!u)return;const m=await(0,S.t9)("exportChatInvite",{peer:u,expireDate:o,usageLimit:i,isRequestNeeded:l,title:d});if(!m)return;const h=(e=(0,a.Rd)()).management.byChatId[s].invites||[];(0,a.R3)((0,r.fw)(e,s,{invites:[...h,m]}))})),(0,a.iw)("deleteExportedChatInvite",(async(e,t,n)=>{var s,o;const{chatId:i,link:l}=n,d=(0,c.Z1)(e,i);if(!d)return;if(!await(0,S.t9)("deleteExportedChatInvite",{peer:d,link:l}))return;const u=(e=(0,a.Rd)()).management.byChatId[i];(0,a.R3)((0,r.fw)(e,i,{invites:null==u||null===(s=u.invites)||void 0===s?void 0:s.filter((e=>e.link!==l)),revokedInvites:null==u||null===(o=u.revokedInvites)||void 0===o?void 0:o.filter((e=>e.link!==l))}))})),(0,a.iw)("deleteRevokedExportedChatInvites",(async(e,t,n)=>{const{chatId:s,adminId:o}=n,i=(0,c.Z1)(e,s),l=(0,c.dy)(e,o||e.currentUserId);i&&l&&await(0,S.t9)("deleteRevokedExportedChatInvites",{peer:i,admin:l})&&(e=(0,a.Rd)(),(0,a.R3)((0,r.fw)(e,s,{revokedInvites:[]})))})),(0,a.iw)("loadChatInviteImporters",(async(e,t,n)=>{var s;const{chatId:o,link:i,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,o),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,S.t9)("fetchChatInviteImporters",{peer:m,link:i,offsetDate:l,offsetUser:h,limit:u});if(!g)return;const p=null===(s=(e=(0,a.Rd)()).management.byChatId[o])||void 0===s?void 0:s.inviteInfo;null!=p&&p.invite&&p.invite.link===i&&(0,a.R3)((0,r.fw)(e,o,{inviteInfo:{...p,importers:g}}))})),(0,a.iw)("loadChatInviteRequesters",(async(e,t,n)=>{var s;const{chatId:o,link:i,offsetDate:l,offsetUserId:d,limit:u}=n,m=(0,c.Z1)(e,o),h=(0,c.dy)(e,d);if(!m||d&&!h)return;const g=await(0,S.t9)("fetchChatInviteImporters",{peer:m,link:i,offsetDate:l,offsetUser:h,limit:u,isRequested:!0});if(!g)return;const p=null===(s=(e=(0,a.Rd)()).management.byChatId[o])||void 0===s?void 0:s.inviteInfo;null!=p&&p.invite&&p.invite.link===i&&(0,a.R3)((0,r.fw)(e,o,{inviteInfo:{...p,requesters:g}}))})),(0,a.iw)("loadChatJoinRequests",(async(e,t,n)=>{const{chatId:s,offsetDate:o,offsetUserId:i,limit:l}=n,d=(0,c.Z1)(e,s),u=(0,c.dy)(e,i);if(!d||i&&!u)return;const m=await(0,S.t9)("fetchChatInviteImporters",{peer:d,offsetDate:o,offsetUser:u,limit:l,isRequested:!0});m&&(e=(0,a.Rd)(),(0,a.R3)((0,r.a4)(e,s,{joinRequests:m})))})),(0,a.iw)("hideChatJoinRequest",(async(e,t,n)=>{var s;const{chatId:o,userId:i,isApproved:l}=n,d=(0,c.Z1)(e,o),u=(0,c.dy)(e,i);if(!d||!u)return;if(!await(0,S.t9)("hideChatJoinRequest",{peer:d,user:u,isApproved:l}))return;e=(0,a.Rd)();const m=(0,c.Z1)(e,o);m&&(0,a.R3)((0,r.a4)(e,o,{joinRequests:null===(s=m.joinRequests)||void 0===s?void 0:s.filter((e=>e.userId!==i))}))})),(0,a.iw)("hideAllChatJoinRequests",(async(e,t,n)=>{const{chatId:s,isApproved:o,link:i}=n,l=(0,c.Z1)(e,s);if(!l)return;if(!await(0,S.t9)("hideAllChatJoinRequests",{peer:l,isApproved:o,link:i}))return;e=(0,a.Rd)();const d=(0,c.Z1)(e,s);d&&(0,a.R3)((0,r.a4)(e,s,{joinRequests:[],fullInfo:{...d.fullInfo,recentRequesterIds:[],requestsPending:0}}))})),(0,a.iw)("hideChatReportPanel",(async(e,t,n)=>{const{chatId:s}=n,o=(0,c.Z1)(e,s);o&&await(0,S.t9)("hideChatReportPanel",o)&&(0,a.R3)((0,r.a4)((0,a.Rd)(),s,{settings:void 0}))}));var q=n(6974);let $;function D(e){return(0,S.t9)("fetchMessages",{chat:e,threadId:i._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(s.hT/2)+1),limit:s.hT})}(0,a.iw)("sync",(()=>{s.eM&&console.log(">>> START SYNC"),$&&clearTimeout($),(0,a.R3)({...(0,a.Rd)(),isSyncing:!0}),$=window.setTimeout((()=>{(0,a.R3)({...(0,a.Rd)(),isSyncing:!1}),$=void 0}),15e3);const{loadAllChats:e,preloadTopChatMessages:t}=(0,a.Sv)();e({listType:"active",shouldReplace:!0,onReplace:async()=>{await async function(){let e=!1,t=(0,a.Rd)();const n=Object.keys(t.messages.byChatId).reduce(((e,n)=>(e[n]={},e[n].draft=(0,c.Ms)(t,n,i._f),e[n].editingId=(0,c._$)(t,n,i._f),e[n].editingDraft=(0,c.s)(t,n,i._f),e)),{}),{chatId:o,threadId:l}=(0,c.Bt)(t)||{},d=o?t.chats.byId[o]:void 0;if(o&&d){const n=await D(d);t=(0,a.Rd)();const{chatId:u}=(0,c.Bt)(t)||{},m=l&&(0,c.tZ)(t,o,l);if(n&&u===o){const a=t.messages.byChatId[o],c=o===s.aw?t.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],d=[].concat(n.messages,c),u=(0,g.ee)(d,"id"),h=Object.keys(u).map(Number);if(t={...t,messages:{...t.messages,byChatId:{}}},t=(0,r.c_)(t,o,u),t=(0,r.xj)(t,o,i._f,h),t=(0,r.y9)(t,o,i._f,h),l&&m&&m.originChannelId){const{originChannelId:e}=m,n=t.messages.byChatId[e],s=await D(t.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),r=Object.keys(e).map(Number);t={...t,messages:{...t.messages,byChatId:{...t.messages.byChatId,[m.originChannelId]:{byId:e,threadsById:{[i._f]:{...null==n?void 0:n.threadsById[i._f],listedIds:r,viewportIds:r,outlyingIds:void 0}}},[o]:{...t.messages.byChatId[o],threadsById:{...t.messages.byChatId[o].threadsById,[l]:{...null==a?void 0:a.threadsById[l],outlyingIds:void 0}}}}}}}}t=(0,r.GL)(t,(0,g.ee)(n.chats,"id")),t=(0,r.eD)(t,(0,g.ee)(n.users,"id")),t=(0,r.j6)(t,o,n.threadInfos),e=!0}}e||(t={...t,messages:{...t.messages,byChatId:{}}}),Object.keys(n).forEach((e=>{t=(0,r.sN)(t,e,i._f,n[e])})),(0,a.R3)(t);const{chatId:u,messageId:m}=t.audioPlayer;u&&m&&!(0,c.hj)(t,u,m)&&(0,a.Sv)().closeAudioPlayer()}(),(0,a.R3)({...(0,a.Rd)(),lastSyncTime:Date.now(),isSyncing:!1}),s.eM&&console.log(">>> FINISH SYNC"),(0,q.S1)(),e({listType:"archived",shouldReplace:!0}),(0,S.t9)("fetchCurrentUser"),t()}})})),(0,a.iw)("reportPeer",(async(e,t,n)=>{const{chatId:a,reason:s,description:o}=n;if(!a)return;const i=(0,c.Z1)(e,a);if(!i)return;const r=await(0,S.t9)("reportPeer",{peer:i,reason:s,description:o});t.showNotification({message:r?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})})),(0,a.iw)("reportProfilePhoto",(async(e,t,n)=>{const{chatId:a,reason:s,description:o,photo:i}=n;if(!a)return;const r=(0,c.Z1)(e,a);if(!r||!i)return;const l=await(0,S.t9)("reportProfilePhoto",{peer:r,photo:i,reason:s,description:o});t.showNotification({message:l?(0,v.i0)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later."})}));const j=(0,E.Ds)((e=>e()),500,!1,!0),G=(0,E.P2)((e=>e()),500,!1);function _(e,t,n){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:n}}}}function H(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,a.iw)("loadFullUser",((e,t,n)=>{const{userId:a}=n,s=(0,c.dy)(e,a);if(!s)return;const{id:o,accessHash:i}=s;j((()=>(0,S.t9)("fetchFullUser",{id:o,accessHash:i})))})),(0,a.iw)("loadUser",(async(e,t,n)=>{const{userId:s}=n,o=(0,c.dy)(e,s);if(!o)return;const i=await(0,S.t9)("fetchUsers",{users:[o]});if(!i)return;const{users:l,userStatusesById:d}=i;e=(0,a.Rd)(),e=(0,r.eD)(e,(0,g.ee)(l,"id")),e=(0,r.ps)(e,{...e.users.statusesById,...d}),(0,a.R3)(e)})),(0,a.iw)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,p.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,S.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:n}=e;let s=(0,a.Rd)();s=(0,r.Sh)(s,(0,g.ee)(n,"id")),s={...s,topPeers:{...s.topPeers,userIds:t,lastRequestedAt:(0,p.b)(s.serverTimeOffset)}},(0,a.R3)(s)}()})),(0,a.iw)("loadContactList",(()=>{!async function(){const e=await(0,S.t9)("fetchContactList");if(!e)return;let t=(0,r.Sh)((0,a.Rd)(),(0,g.ee)(e.users,"id"));t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id"));const n=e=>e.lastName||e.firstName||"",s=new Intl.Collator("en-US"),o=e.users.sort(((e,t)=>s.compare(n(e),n(t)))).filter((e=>!e.isSelf));(0,a.R3)({...t,contactList:{userIds:o.map((e=>e.id))}})}()})),(0,a.iw)("loadCurrentUser",(()=>{(0,S.t9)("fetchCurrentUser")})),(0,a.iw)("loadCommonChats",(async e=>{var t,n,s;const{chatId:o}=(0,c.Bt)(e)||{},i=o?(0,c.dy)(e,o):void 0;if(!i||(0,d.cS)(i)||null!==(t=i.commonChats)&&void 0!==t&&t.isFullyLoaded)return;const l=null===(n=i.commonChats)||void 0===n?void 0:n.maxId,u=await(0,S.t9)("fetchCommonChats",i.id,i.accessHash,l);if(!u)return;const{chats:m,chatIds:h,isFullyLoaded:p}=u;e=(0,a.Rd)(),m.length&&(e=(0,r.fZ)(e,(0,g.ee)(m,"id"))),e=(0,r.Nq)(e,i.id,{commonChats:{maxId:h.length?h[h.length-1]:"0",ids:(0,g.Tw)(((null===(s=i.commonChats)||void 0===s?void 0:s.ids)||[]).concat(h)),isFullyLoaded:p}}),(0,a.R3)(e)})),(0,a.iw)("updateContact",((e,t,n)=>{const{userId:s,isMuted:o=!1,firstName:i,lastName:l,shouldSharePhoneNumber:d}=n;!async function(e,t,n,s,o){let i=(0,a.Rd)();const l=(0,c.dy)(i,e);if(!l)return;let d;if((0,a.Sv)().updateChatMutedState({chatId:e,isMuted:t}),(0,a.R3)((0,r.H9)((0,a.Rd)(),m.wv.InProgress)),!l.isContact&&l.phoneNumber)d=await(0,S.t9)("importContact",{phone:l.phoneNumber,firstName:n,lastName:s});else{const{id:e,accessHash:t}=l;d=await(0,S.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:n,lastName:s,shouldSharePhoneNumber:o})}i=(0,a.Rd)(),d&&((0,a.Sv)().loadChatSettings({chatId:e}),(0,a.R3)((0,r.Nq)(i,l.id,{firstName:n,lastName:s}))),i=(0,r.H9)(i,m.wv.Complete),i=(0,r.ft)(i),(0,a.R3)(i)}(s,o,i,l,d)})),(0,a.iw)("deleteContact",((e,t,n)=>{const{userId:s}=n;!async function(e){const t=(0,a.Rd)(),n=(0,c.dy)(t,e);if(!n)return;const{id:s,accessHash:o}=n;await(0,S.t9)("deleteContact",{id:s,accessHash:o})}(s)})),(0,a.iw)("loadProfilePhotos",(async(e,t,n)=>{const{profileId:s}=n,o=(0,d.YC)(s),i=o?(0,c.dy)(e,s):void 0,l=o?void 0:(0,c.Z1)(e,s);if(!i&&!l)return;const u=await(0,S.t9)("fetchProfilePhotos",i,l);u&&u.photos&&(e=(0,a.Rd)(),o?e=(0,r.Nq)(e,s,{photos:u.photos}):(e=(0,r.Sh)(e,(0,g.ee)(u.users,"id")),e=(0,r.a4)(e,s,{photos:u.photos})),(0,a.R3)(e))})),(0,a.iw)("setUserSearchQuery",((e,t,n)=>{const{query:s}=n;s&&G((()=>{!async function(e){const t=await(0,S.t9)("searchChats",{query:e});let n=(0,a.Rd)();const s=n.userSearch.query;if(!t||!s||e!==s)return void(0,a.R3)((0,r.Q3)(n,!1));const{localUsers:o,globalUsers:i}=t;let c,l;o.length&&(n=(0,r.Sh)(n,(0,g.ee)(o,"id")),c=o.map((e=>{let{id:t}=e;return t}))),i.length&&(n=(0,r.Sh)(n,(0,g.ee)(i,"id")),l=i.map((e=>{let{id:t}=e;return t}))),n=(0,r.Q3)(n,!1),n=(0,r.Lm)(n,{localUserIds:c,globalUserIds:l}),(0,a.R3)(n)}(s)}))})),(0,a.iw)("importContact",(async(e,t,n)=>{const{phoneNumber:s,firstName:o,lastName:i}=n,c=await(0,S.t9)("importContact",{phone:s,firstName:o,lastName:i});c?(t.openChat({id:c}),(0,a.R3)((0,r.ft)((0,a.Rd)()))):t.showNotification({message:v.i0("Contacts.PhoneNumber.NotRegistred")})})),(0,a.iw)("reportSpam",((e,t,n)=>{const{chatId:a}=n,s=(0,d.YC)(a)?(0,c.dy)(e,a):(0,c.Z1)(e,a);s&&(0,S.t9)("reportSpam",s)}));var z=n(8629);const V=h.cj||h.wZ;class W{constructor(e,t){var n,a;this.features=e,this.onFail=t,a=void 0,(n="preOpened")in this?Object.defineProperty(this,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):this[n]=a}preOpenIfNeeded(){var e;V&&(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(!V){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 X="https://prizes.gamee.com/",K=(0,E.Ds)((e=>e()),500,!1);async function Y(e,t){await(0,S.t9)("toggleBotInAttachMenu",{bot:e,isEnabled:t}),await J()}async function J(e){const t=await(0,S.t9)("loadAttachMenuBots",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,attachMenu:{hash:t.hash,bots:t.bots}})}async function Q(e,t,n,a,s){await(0,S.t9)("sendMessage",{chat:e,text:n,replyingTo:a,sendAs:s})}let ee;async function te(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{showDialog:o,showNotification:i,toggleSafeLinkModal:r,openGame:c}=(0,a.Sv)();s&&(ee||(ee=new W("popup,width=800,height=600",(()=>{i({message:"Allow browser to open popup window"})}))),ee.preOpenIfNeeded());const l=await(0,S.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:n,isGame:s});if(!l)return;const{message:d,alert:u,url:m}=l;u?o({data:{message:d||"Error"}}):d?i({message:d}):m&&(s?m.includes(X)?ee.open(m):(ee.cancelPreOpen(),c({url:m,chatId:e.id,messageId:t})):r({url:m}))}(0,a.iw)("clickBotInlineButton",((e,t,n)=>{const{messageId:a,button:o}=n;switch(o.type){case"command":t.sendBotCommand({command:o.text});break;case"url":{const{url:e}=o;e.match(s.FS)||e.match(s.g$)?t.openTelegramLink({url:e}):t.toggleSafeLinkModal({url:e});break}case"callback":{const t=(0,c.jr)(e);if(!t)return;te(t,a,o.data);break}case"requestPoll":t.openPollModal({isQuiz:o.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:s}=o;t.getReceipt({receiptMessageId:s,chatId:n.id,messageId:a});break}case"buy":{const n=(0,c.jr)(e);if(!n)return;t.getPaymentForm({chat:n,messageId:a}),t.setInvoiceMessageInfo((0,c.hj)(e,n.id,a)),t.openPaymentModal({chatId:n.id,messageId:a});break}case"game":{const t=(0,c.jr)(e);if(!t)return;te(t,a,void 0,!0);break}case"switchBotInline":{const{query:e,isSamePeer:n}=o;t.switchBotInline({query:e,isSamePeer:n,messageId:a});break}case"userProfile":{const{userId:e}=o;t.openChatWithInfo({id:e});break}case"simpleWebView":{const{url:n}=o,{chatId:a}=(0,c.Bt)(e)||{};if(!a)return;const s=(0,c.IK)(e,a);if(!s)return;const i=(0,z.B)();t.requestSimpleWebView({url:n,bot:s,theme:i,buttonText:o.text});break}case"webView":{const{url:n}=o,s=(0,c.jr)(e);if(!s)return;const i=(0,c.hj)(e,s.id,a);if(!i)return;if(!i.viaBotId&&!i.senderId)return;const r=(0,c.IK)(e,i.viaBotId||i.senderId);if(!r)return;const l=(0,z.B)();t.requestWebView({url:n,bot:r,peer:s,theme:l,buttonText:o.text});break}}})),(0,a.iw)("sendBotCommand",((e,t,n)=>{const{command:a,chatId:s}=n,{currentUserId:o}=e,i=s?(0,c.Z1)(e,s):(0,c.jr)(e),r=(0,c.Bt)(e);if(!o||!i||!r)return;const{threadId:l}=r;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i.id,threadId:l,value:!1}),Q(i,0,a,(0,c.Yy)(e,i.id,l),(0,c._5)(e,s))})),(0,a.iw)("restartBot",(async(e,t,n)=>{const{chatId:s}=n,{currentUserId:o}=e,i=(0,c.jr)(e),l=o&&(0,c.IK)(e,s);o&&i&&l&&await(0,S.t9)("unblockContact",l.id,l.accessHash)&&((0,a.R3)((0,r.rB)((0,a.Rd)(),l.id)),Q(i,0,"/start",void 0,(0,c._5)(e,s)))})),(0,a.iw)("loadTopInlineBots",(async e=>{const{lastRequestedAt:t}=e.topInlineBots;if(t&&(0,p.b)(e.serverTimeOffset)-t<60)return;const n=await(0,S.t9)("fetchTopInlineBots");if(!n)return;const{ids:s,users:o}=n;e=(0,a.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(o,"id")),e={...e,topInlineBots:{...e.topInlineBots,userIds:s,lastRequestedAt:(0,p.b)(e.serverTimeOffset)}},(0,a.R3)(e)})),(0,a.iw)("queryInlineBot",(async(e,t,n)=>{const{chatId:s,username:o,query:i,offset:l}=n;let d=e.inlineBots.byUsername[o];if(!1!==d){if(void 0===d){const{user:t,chat:n}=await(0,S.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!t||!n)return void(0,a.R3)(_(e,o,!1));e=(0,r.Sh)(e,{[t.id]:t}),e=(0,r.fZ)(e,{[n.id]:n}),d={id:t.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=_(e,o,d),(0,a.R3)(e)}(i!==d.query||d.canLoadMore)&&K((()=>{!async function(e){let{username:t,inlineBotData:n,chatId:s,query:o,offset:i}=e,r=(0,a.Rd)();const l=(0,c.dy)(r,n.id),d=(0,c.Z1)(r,s);if(!l||!d)return;const u=n.query!==o;r=H(r,!0),r=_(r,t,{...n,query:o,...u&&{offset:void 0,results:[]}}),(0,a.R3)(r);const m=await(0,S.t9)("fetchInlineBotResults",{bot:l,chat:d,query:o,offset:u?void 0:i}),h=r.inlineBots.byUsername[t];if(r=H((0,a.Rd)(),!1),!m||!h||o!==h.query)return void(0,a.R3)(r);const g=new Set((h.results||[]).map((e=>e.id))),p=m.results.filter((e=>!g.has(e.id)));r=_(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,a.R3)(r)}({username:o,inlineBotData:d,chatId:s,query:i,offset:l})}))}})),(0,a.iw)("switchBotInline",((e,t,n)=>{const{query:a,isSamePeer:s,messageId:o}=n,i=(0,c.jr)(e);if(!i)return;const r=(0,c.hj)(e,i.id,o);if(!r)return;const l=(0,c.IK)(e,r.senderId);if(!l)return;const d=`@${l.username} ${a}`;if(!s)return{...e,switchBotInline:{query:a,botUsername:l.username}};t.openChatWithText({chatId:i.id,text:d})})),(0,a.iw)("resetSwitchBotInline",(e=>({...e,switchBotInline:void 0}))),(0,a.iw)("sendInlineBotResult",((e,t,n)=>{const{id:a,queryId:s,isSilent:o,scheduledAt:i}=n,r=(0,c.Bt)(e);if(!r||!a)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,S.t9)("sendInlineBotResult",{chat:u,resultId:a,queryId:s,replyingTo:(0,c.Yy)(e,l,d),sendAs:(0,c._5)(e,l),isSilent:o,scheduleDate:i})})),(0,a.iw)("resetInlineBot",((e,t,n)=>{const{username:s}=n;let o=e.inlineBots.byUsername[s];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,a.R3)(_(e,s,o)))})),(0,a.iw)("startBot",(async(e,t,n)=>{const{botId:a,param:s}=n,o=(0,c.dy)(e,a);o&&await(0,S.t9)("startBot",{bot:o,startParam:s})})),(0,a.iw)("requestSimpleWebView",(async(e,t,n)=>{const{url:s,bot:o,theme:i,buttonText:r}=n;if(!(0,c.LM)(e,o))return void(0,a.R3)({...e,botTrustRequest:{bot:o,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:n}}});const l=await(0,S.t9)("requestSimpleWebView",{url:s,bot:o,theme:i});l&&(e=(0,a.Rd)(),(0,a.R3)({...e,webApp:{url:l,bot:o,buttonText:r}}))})),(0,a.iw)("requestWebView",(async(e,t,n)=>{const{url:s,bot:o,peer:i,theme:r,isSilent:l,buttonText:d,isFromBotMenu:u,startParam:m}=n;if(!(0,c.LM)(e,o))return void(0,a.R3)({...e,botTrustRequest:{bot:o,type:"webApp",onConfirm:{action:"requestWebView",payload:n}}});const h=(0,c.Bt)(e);if(!h)return;const{chatId:g,threadId:p}=h,f=g&&(0,c.Yy)(e,g,p),v=await(0,S.t9)("requestWebView",{url:s,bot:o,peer:i,theme:r,isSilent:l,replyToMessageId:f||void 0,isFromBotMenu:u,startParam:m});if(!v)return;const{url:I,queryId:y}=v;e=(0,a.Rd)(),(0,a.R3)({...e,webApp:{url:I,bot:o,queryId:y,buttonText:d}})})),(0,a.iw)("prolongWebView",((e,t,n)=>{const{bot:a,peer:s,isSilent:o,replyToMessageId:i,queryId:r}=n;(0,S.t9)("prolongWebView",{bot:a,peer:s,isSilent:o,replyToMessageId:i,queryId:r})||t.closeWebApp()})),(0,a.iw)("sendWebViewData",((e,t,n)=>{const{bot:a,data:s,buttonText:o}=n;(0,S.t9)("sendWebViewData",{bot:a,data:s,buttonText:o})})),(0,a.iw)("closeWebApp",(e=>({...e,webApp:void 0}))),(0,a.iw)("cancelBotTrustRequest",(e=>({...e,botTrustRequest:void 0}))),(0,a.iw)("markBotTrusted",((e,t,n)=>{var s;const{botId:o}=n,{trustedBotIds:i}=e,r=new Set(i);if(r.add(o),(0,a.R3)({...e,botTrustRequest:void 0,trustedBotIds:Array.from(r)}),null!==(s=e.botTrustRequest)&&void 0!==s&&s.onConfirm){const{action:n,payload:a}=e.botTrustRequest.onConfirm;t[n](a)}})),(0,a.iw)("loadAttachMenuBots",(async(e,t,n)=>{const{hash:a}=n||{};await J(a)})),(0,a.iw)("toggleBotInAttachMenu",(async(e,t,n)=>{const{botId:a,isEnabled:s}=n,o=(0,c.dy)(e,a);o&&await Y(o,s)})),(0,a.iw)("callAttachMenuBot",((e,t,n)=>{const{chatId:a,botId:s,isFromBotMenu:o,url:i,startParam:r}=n,l=(0,c.Z1)(e,a),d=(0,c.IK)(e,s);if(!l||!d)return;const{attachMenu:{bots:u}}=e;if(!o&&!u[s])return{...e,botAttachRequest:{bot:d,chatId:a,startParam:r}};const m=(0,z.B)();t.requestWebView({url:i,peer:l,bot:d,theme:m,buttonText:"",isFromBotMenu:o,startParam:r})})),(0,a.iw)("confirmBotAttachRequest",(async(e,t)=>{const{botAttachRequest:n}=e;if(!n)return;const{bot:s,chatId:o,startParam:i}=n;(0,a.R3)({...e,botAttachRequest:void 0}),await Y(s,!0),t.callAttachMenuBot({chatId:o,botId:s.id,startParam:i})})),(0,a.iw)("closeBotAttachRequestModal",(e=>({...e,botAttachRequest:void 0}))),n(1371),(0,a.iw)("loadPasswordInfo",(async e=>{const t=await(0,S.t9)("getPasswordInfo");t&&(e=(0,a.Rd)(),e=(0,r.BI)(e,{hasPassword:t.hasPassword}),e=(0,r.IE)(e,{hint:t.hint}),(0,a.R3)(e))})),(0,a.iw)("checkPassword",(async(e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const i=await(0,S.t9)("checkPassword",s);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),i&&o()})),(0,a.iw)("clearPassword",(async(e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const i=await(0,S.t9)("clearPassword",s);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),i&&o()})),(0,a.iw)("updatePassword",(async(e,t,n)=>{const{currentPassword:s,password:o,hint:i,email:c,onSuccess:l}=n;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const d=await(0,S.t9)("updatePassword",s,o,i,c);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),d&&l()})),(0,a.iw)("updateRecoveryEmail",(async(e,t,n)=>{const{currentPassword:s,email:o,onSuccess:i}=n;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0}));const c=await(0,S.t9)("updateRecoveryEmail",s,o);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),c&&i()})),(0,a.iw)("provideTwoFaEmailCode",((e,t,n)=>{const{code:a}=n;(0,S.t9)("provideRecoveryEmailCode",a)})),(0,a.iw)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,a.iw)("validateRequestedInfo",((e,t,n)=>{const{requestInfo:s,saveInfo:o}=n,i=(0,c.gx)(e),l=i&&(0,c.Z1)(e,i),d=(0,c.Mz)(e);l&&d&&async function(e,t,n,s){const o=await(0,S.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:n,shouldSave:s});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let l=(0,r.vT)((0,a.Rd)(),i);c?(l=(0,r.TM)(l,c),l=(0,r.Q$)(l,m.KB.Shipping)):l=(0,r.Q$)(l,m.KB.PaymentInfo),(0,a.R3)(l)}(l,d,s,o)})),(0,a.iw)("getPaymentForm",((e,t,n)=>{const{chat:s,messageId:o}=n;s&&o&&async function(e,t){const n=await(0,S.t9)("getPaymentForm",{chat:e,messageId:t});if(!n)return;let s=(0,r._7)((0,a.Rd)(),n),o=m.KB.PaymentInfo;s.payment.invoice&&(s.payment.invoice.shippingAddressRequested||s.payment.invoice.nameRequested||s.payment.invoice.phoneRequested||s.payment.invoice.emailRequested)&&(o=m.KB.ShippingInfo),s=(0,r.Q$)(s,o),(0,a.R3)(s)}(s,o)})),(0,a.iw)("getReceipt",((e,t,n)=>{const{receiptMessageId:s,chatId:o,messageId:i}=n,l=o&&(0,c.Z1)(e,o);i&&s&&l&&async function(e,t,n){const s=await(0,S.t9)("getReceipt",e,n);if(!s)return;let o=(0,a.Rd)();const i=(0,c.hj)(o,e.id,t);o=(0,r.Dq)(o,s,i),(0,a.R3)(o)}(l,i,s)})),(0,a.iw)("clearPaymentError",(e=>{(0,a.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,a.iw)("clearReceipt",(e=>{(0,a.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,a.iw)("sendCredentialsInfo",((e,t,n)=>{const{nativeProvider:o}=e.payment,{credentials:i}=n,{data:l}=i;if("stripe"===o){const t=(0,c.$$)(e);if(!t)return;!async function(e,t){const n=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvv,"card[address_zip]":e.zip,"card[address_country]":e.country}),s=await fetch(`https://api.stripe.com/v1/tokens${n}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await s.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,a.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,m.KB.Checkout),(0,a.R3)(i)}(l,t)}else if("smartglocal"===o){const t=(0,c.EB)(e);if(!t)return;!async function(e,t){const n={card:{number:e.cardNumber.replace(/[^\d]+/g,""),expiration_month:e.expiryMonth,expiration_year:e.expiryYear,security_code:e.cvv.replace(/[^\d]+/g,"")}},o=s.eA?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",i=await fetch(o,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":t},body:JSON.stringify(n)}),c=await i.json();if("ok"!==c.status){const e={description:"payment error"},t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let l=(0,r.QD)((0,a.Rd)(),{type:"card",token:c.data.token});l=(0,r.Q$)(l,m.KB.Checkout),(0,a.R3)(l)}(l,t)}})),(0,a.iw)("sendPaymentForm",((e,t,n)=>{const{shippingOptionId:s,saveCredentials:o}=n,i=(0,c.gx)(e),l=i&&(0,c.Z1)(e,i),d=(0,c.Mz)(e),u=(0,c.eh)(e),m=(0,c.sp)(e),{nativeProvider:h}=e.payment,g="stripe"===h?(0,c.$$)(e):(0,c.EB)(e);l&&d&&g&&u&&h&&async function(e,t,n,s,o,i,c){if(!0===await(0,S.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:o,requestedInfoId:i,shippingOptionId:c})){const e=(0,r.bp)((0,a.Rd)());(0,a.R3)((0,r.WY)(e))}}(l,d,0,u,{save:o,data:"stripe"===h?(0,c.i3)(e):(0,c.Jg)(e)},m,s)})),(0,a.iw)("setPaymentStep",(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,r.Q$)(e,n.step||m.KB.ShippingInfo)})),(0,a.iw)("setInvoiceMessageInfo",((e,t,n)=>(0,r.nA)(e,n)));var ne=n(647),ae=n(4907);const se=728,oe=424,ie=288;var re=n(3858);function ce(e,t){return t-(e.isLeftColumnShown&&!h.wB?e.leftColumnWidth||((n=re.Z.get().width)>s._m?Math.min(Math.max(.25*n,ie),.33*n):n>s.ks?Math.min(Math.max(.33*n,ie),.4*n):oe):0);var n}let le=0;(0,a.iw)("loadAvailableReactions",(async()=>{const e=await(0,S.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&ne.he(`sticker${e.aroundAnimation.id}`,i.IU.Lottie),e.centerIcon&&ne.he(`sticker${e.centerIcon.id}`,i.IU.Lottie)})),(0,a.R3)({...(0,a.Rd)(),availableReactions:e}))})),(0,a.iw)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:a,x:s,y:o,localEffect:i,startSize:r,isReversed:c}=n,l={id:le++,animatedEffect:a||i,x:ce(e,s)+40*Math.random()-20,y:o+40*Math.random()-20,startSize:r,isReversed:c};return{...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],l]}})),(0,a.iw)("sendEmojiInteraction",((e,t,n)=>{const{messageId:a,chatId:s,emoji:o,interactions:i,localEffect:r}=n,l=(0,c.Z1)(e,s);l&&(o||r)&&s!==e.currentUserId&&(0,S.t9)("sendEmojiInteraction",{chat:l,messageId:a,emoticon:o||(0,c.ji)(r),timestamps:i})})),(0,a.iw)("sendDefaultReaction",((e,t,n)=>{const{chatId:a,messageId:s,x:o,y:i}=n,r=(0,c.q6)(e,a),l=(0,c.hj)(e,a,s);r&&l&&!(0,d.CI)(l)&&t.sendReaction({chatId:a,messageId:s,reaction:r,x:o,y:i})})),(0,a.iw)("sendReaction",((e,t,n)=>{var a,o,i;const{chatId:r}=n;let{messageId:l}=n,{reaction:d}=n;const u=(0,c.Z1)(e,r);let m=(0,c.hj)(e,r,l);if(!u||!m)return;const h=Boolean(m.groupedId)&&!m.isInAlbum,p=h?(0,c.xH)(e,r,m.groupedId)[0]:void 0;m=h&&(0,c.hj)(e,r,p)||m,l=(null===(a=m)||void 0===a?void 0:a.id)||l,null!==(o=m.reactions)&&void 0!==o&&null!==(i=o.results)&&void 0!==i&&i.some((e=>e.reaction===d&&e.isChosen))&&(d=void 0),(0,S.t9)("sendReaction",{chat:u,messageId:l,reaction:d});const{animationLevel:f}=e.settings.byKey;return f===s.zy&&(e={...e,activeReactions:{...d?e.activeReactions:(0,g.CE)(e.activeReactions,[l]),...d&&{[l]:{reaction:d,messageId:l}}}}),function(e,t,n,a){const{reactions:s}=(0,c.hj)(e,t,n)||{};if(!s)return e;let o=s.results.map((e=>e.reaction===a?{...e,count:e.isChosen?e.count:e.count+1,isChosen:!0}:e.isChosen?{...e,isChosen:!1,count:e.count-1}:e)).filter((e=>e.count>0)),{recentReactions:i}=s;if(a&&!o.some((e=>e.reaction===a))){const{currentUserId:t}=e;o=[...o,{reaction:a,isChosen:!0,count:1}],s.canSeeList&&(i=[...i||[],{userId:t,reaction:a}])}return(0,ae.cY)(e,t,n,{reactions:{...s,results:o,recentReactions:i}})}(e,r,l,d)})),(0,a.iw)("openChat",(e=>({...e,activeReactions:{}}))),(0,a.iw)("startActiveReaction",((e,t,n)=>{var a;const{messageId:o,reaction:i}=n,{animationLevel:r}=e.settings.byKey;return r!==s.zy||(null===(a=e.activeReactions[o])||void 0===a?void 0:a.reaction)===i?e:{...e,activeReactions:{...i?e.activeReactions:(0,g.CE)(e.activeReactions,[o]),...i&&{[o]:{reaction:i,messageId:o}}}}})),(0,a.iw)("stopActiveReaction",((e,t,n)=>{var a;const{messageId:s,reaction:o}=n;return(null===(a=e.activeReactions[s])||void 0===a?void 0:a.reaction)!==o?e:{...e,activeReactions:(0,g.CE)(e.activeReactions,[s])}})),(0,a.iw)("setDefaultReaction",(async(e,t,n)=>{const{reaction:s}=n;await(0,S.t9)("setDefaultReaction",{reaction:s})&&(0,a.R3)({...(0,a.Rd)(),appConfig:{...e.appConfig,defaultReaction:s}})})),(0,a.iw)("stopActiveEmojiInteraction",((e,t,n)=>{var a;const{id:s}=n;return{...e,activeEmojiInteractions:null===(a=e.activeEmojiInteractions)||void 0===a?void 0:a.filter((e=>e.id!==s))}})),(0,a.iw)("loadReactors",(async(e,t,n)=>{var s,o,i;const{chatId:l,messageId:d,reaction:u}=n,m=(0,c.Z1)(e,l),h=(0,c.hj)(e,l,d);if(!m||!h)return;const p=null===(s=h.reactors)||void 0===s?void 0:s.nextOffset,f=await(0,S.t9)("fetchMessageReactionsList",{reaction:u,chat:m,messageId:d,offset:p});if(!f)return;e=(0,a.Rd)(),null!==(o=f.users)&&void 0!==o&&o.length&&(e=(0,r.Sh)(e,(0,g.ee)(f.users,"id")));const{nextOffset:v,count:I,reactions:y}=f;(0,a.R3)((0,r.cY)(e,l,d,{reactors:{nextOffset:v,count:I,reactions:[...(null===(i=h.reactors)||void 0===i?void 0:i.reactions)||[],...y]}}))})),(0,a.iw)("loadMessageReactions",((e,t,n)=>{const{ids:a,chatId:s}=n,o=(0,c.Z1)(e,s);o&&(0,S.t9)("fetchMessageReactions",{ids:a,chat:o})})),(0,a.iw)("sendWatchingEmojiInteraction",((e,t,n)=>{var a;const{chatId:s,emoticon:o,x:i,y:r,startSize:l,isReversed:d,id:u}=n,m=(0,c.Z1)(e,s);if(m&&null!==(a=e.activeEmojiInteractions)&&void 0!==a&&a.some((e=>e.id===u))&&s!==e.currentUserId)return(0,S.t9)("sendWatchingEmojiInteraction",{chat:m,emoticon:o}),{...e,activeEmojiInteractions:e.activeEmojiInteractions.map((t=>t.id===u?{...t,x:ce(e,i),y:r,startSize:l,isReversed:d}:t))}})),(0,a.iw)("loadStatistics",(async(e,t,n)=>{var s;const{chatId:o,isGroup:i}=n,l=(0,c.Z1)(e,o);if(null==l||!l.fullInfo)return;const d=await(0,S.t9)(i?"fetchGroupStatistics":"fetchChannelStatistics",{chat:l});if(d){if(e=(0,a.Rd)(),null!==(s=d.recentTopMessages)&&void 0!==s&&s.length){const t=(0,c.Zw)(e,o);d.recentTopMessages=d.recentTopMessages.map((e=>({...e,...t[e.msgId]})))}(0,a.R3)((0,r.ze)(e,o,d))}})),(0,a.iw)("loadMessageStatistics",(async(e,t,n)=>{const{chatId:s,messageId:o}=n,i=(0,c.Z1)(e,s);if(null==i||!i.fullInfo)return;let l=await(0,S.t9)("fetchMessageStatistics",{chat:i,messageId:o});l||(l={}),e=(0,a.Rd)();const{views:d,forwards:u}=(0,c.Zw)(e,s)[o];l.views=d,l.forwards=u,(0,a.R3)((0,r.kM)(e,l))})),(0,a.iw)("loadStatisticsAsyncGraph",(async(e,t,n)=>{const{chatId:s,token:o,name:i,isPercentage:l}=n,d=(0,c.Z1)(e,s);if(null==d||!d.fullInfo)return;const u=d.fullInfo.statisticsDcId,m=await(0,S.t9)("fetchStatisticsAsyncGraph",{token:o,dcId:u,isPercentage:l});m&&(0,a.R3)((0,r.yC)((0,a.Rd)(),s,i,m))})),n(8304);var de=n(8406);function ue(e,t){const n=typeof e;if(n!==typeof t)return!1;if("object"!==n)return e===t;const a=Array.isArray(e);if(a!==Array.isArray(t))return!1;if(a){const n=e,a=t;return n.length===a.length&&n.every(((e,t)=>ue(e,a[t])))}const s=e,o=t;return Object.keys(s).every((e=>ue(s[e],o[e])))}(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":return(0,a.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,de.Vr)({chatId:n.chat.id,lastReadInboxMessageId:n.chat.lastReadInboxMessageId}));case"updateChatJoin":{const s=(0,c.Ek)(e,n.id);if(!s)return;e=(0,r.B1)(e,s,[n.id]),e=(0,r.a4)(e,n.id,{isNotJoined:!1}),(0,a.R3)(e);const o=(0,c.Z1)(e,n.id);return void(o&&t.requestChatUpdate({chatId:o.id}))}case"updateChatLeave":return(0,r.Dd)(e,n.id);case"updateChatInbox":return(0,r.a4)(e,n.id,n.chat);case"updateChatTypingStatus":{const{id:t,typingStatus:s}=n;return(0,a.R3)((0,r.a4)(e,t,{typingStatus:s})),void setTimeout((()=>{e=(0,a.Rd)();const n=(0,c.Z1)(e,t);n&&s&&n.typingStatus&&n.typingStatus.timestamp===s.timestamp&&(0,a.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3)}case"newMessage":{const{message:s}=n,{chatId:o,threadId:l,type:d}=(0,c.Bt)(e)||{};if(s.senderId===e.currentUserId&&!s.isFromScheduled)return;const u=(0,c.Z1)(e,n.chatId);if(!u)return;return"thread"===d&&l===i._f&&n.chatId===o?setTimeout((()=>{t.requestChatUpdate({chatId:n.chatId})}),1500):(0,a.R3)((0,r.a4)(e,n.chatId,{unreadCount:u.unreadCount?u.unreadCount+1:1,...n.message.hasUnreadMention&&{unreadMentionsCount:u.unreadMentionsCount?u.unreadMentionsCount+1:1}})),void(0,de.rh)({chat:u,message:s})}case"updateMessage":{const{message:t}=n,a=(0,c.Z1)(e,n.chatId);if(!a)return;return void((0,d.dT)(t)&&(0,de.rh)({chat:a,message:t,isReaction:!0}))}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=n;if(!1!==a.hasUnreadMention)return;return t.forEach((t=>{const a="channelId"in n?n.channelId:(0,c.X5)(e,t),s=(0,c.Z1)(e,a);null!=s&&s.unreadMentionsCount&&(e=(0,r.a4)(e,a,{unreadMentionsCount:s.unreadMentionsCount-1}))})),e}case"updateChatFullInfo":{const{fullInfo:t}=n,a=e.chats.byId[n.id];if(!a)return;return(0,r.a4)(e,n.id,{fullInfo:{...a.fullInfo,...t}})}case"updatePinnedChatIds":{const{ids:t,folderId:a}=n,o=a===s.WS?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[o]:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:a}=n,o=(0,c.Ek)(e,t);if(!o)return;const{[o]:i}=e.chats.orderedPinnedIds;let r=i||[];if(a){if(!r.includes(t)){if("active"===o&&r.length>=s.EG){const t=e.chats.listIds.active;r=r.filter((e=>t&&t.includes(e)))}r=[t,...r]}}else r=r.filter((e=>e!==t));return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[o]:r.length?r:void 0}}}}case"updateChatListType":{const{id:t,folderId:a}=n;return(0,r.Pi)(e,t,a)}case"updateChatFolder":{const{id:t,folder:a}=n,{byId:s,orderedIds:o}=e.chatFolders,i=a?{...s,[t]:a}:(0,g.ei)(s,Object.keys(s).map(Number).filter((e=>e!==t))),r=a?o&&o.includes(t)?o:[...o||[],t]:o?o.filter((e=>e!==t)):void 0;return{...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:r}}}case"updateChatFoldersOrder":{const{orderedIds:t}=n;return{...e,chatFolders:{...e.chatFolders,orderedIds:t}}}case"updateRecommendedChatFolders":{const{folders:t}=n;return{...e,chatFolders:{...e.chatFolders,recommended:t}}}case"updateChatMembers":{var o;const t=e.chats.byId[n.id],{replacedMembers:a,addedMember:s,deletedMemberId:i}=n;if(!t)return;let c=!1,l=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(a)l=a,c=!0;else if(s)l.length&&l.some((e=>e.userId===s.userId))||(l.push(s),c=!0);else if(l.length&&i){const e=l.findIndex((e=>e.userId===i));e>-1&&(l.slice(e,1),c=!0)}if(c){const a=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:a}})}return}case"deleteProfilePhotos":{const{chatId:t,ids:a}=n,s=e.chats.byId[t];return null!=s&&s.photos?(0,r.a4)(e,t,{photos:s.photos.filter((e=>!a.includes(e.id)))}):void 0}case"draftMessage":{const{chatId:t,formattedText:a,date:s,replyingToId:o}=n;if(!e.chats.byId[t])return;return e=(0,r.pf)(e,t,i._f,"draft",a),e=(0,r.pf)(e,t,i._f,"replyingToId",o),e=(0,r.a4)(e,t,{draftDate:s})}case"showInvite":{const{data:e}=n;return void t.showDialog({data:e})}case"updatePendingJoinRequests":{const{chatId:s,requestsPending:o,recentRequesterIds:i}=n,c=e.chats.byId[s];if(!c)return;e=(0,r.a4)(e,s,{fullInfo:{...c.fullInfo,requestsPending:o,recentRequesterIds:i}}),(0,a.R3)(e),t.loadChatJoinRequests({chatId:s})}}}));const me=350;function he(e,t,n,a){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=s?(0,c.Tm)(e,t,n):(0,c.hj)(e,t,n);if(o&&a.content){const{photo:e,video:t,sticker:n,document:s}=(0,d.qp)(o);e&&a.content.photo?(a.content.photo.blobUrl=e.blobUrl,a.content.photo.thumbnail=e.thumbnail):t&&a.content.video?a.content.video.blobUrl=t.blobUrl:n&&a.content.sticker?a.content.sticker.isPreloadedGlobally=n.isPreloadedGlobally:s&&a.content.document&&(a.content.document.previewBlobUrl=s.previewBlobUrl)}return s?(0,r.P4)(e,t,n,a):(0,r.cY)(e,t,n,a)}function ge(e,t,n,a){const{chatId:s}=n,{threadInfo:o}=(0,c.Db)(e,s,n)||{};if(!o&&n.replyToMessageId){const o=(0,c.hj)(e,s,n.replyToMessageId);o?e=(0,r.lG)(e,o,s,n.id,a):t.loadMessage({chatId:s,messageId:n.replyToMessageId,threadUpdate:{isDeleting:a,lastMessageId:n.id}})}return e}function pe(e,t,n){const{id:a,chatId:s}=n,{threadInfo:o,firstMessageId:l}=(0,c.Db)(e,s,n)||{},u=(0,c.Z1)(e,s),m=(null==u?void 0:u.unreadCount)&&!(0,c.gb)(e,s,i._f);if(e=ge(e,t,n),o&&(!l&&(0,d.CI)(n)||(e=(0,r.xj)(e,s,o.threadId,[a]),(0,c.b9)(e,s,o.threadId)&&(e=(0,r.$S)(e,s,o.threadId,a),l||(e=(0,r.pf)(e,s,o.threadId,"firstMessageId",n.id)))),e=(0,r.pf)(e,s,o.threadId,"threadInfo",{...o,lastMessageId:n.id,messagesCount:o.messagesCount+1})),m)return e;if(e=(0,r.xj)(e,s,i._f,[a]),(0,c.b9)(e,s,i._f)){const t=(0,c.It)(e,s,i._f),n=(0,r.$S)(e,s,i._f,a),o=(0,c.Cb)(n,s,i._f);t&&!o.includes(t)||(e=n)}return e}function fe(e,t,n){var a;let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:o}=e,i=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!i||s||i.id===n.id||i.id===n.previousLocalId||n.id>i.id?(0,r.a4)(e,t,{lastMessage:n}):e}function ve(e,t){const n=(0,c.Zw)(e,t),a=(0,c.gb)(e,t,i._f);if(!n||!a)return;let s=a.length;for(;s--;){const e=n[a[s]];if(!e.isDeleting)return e}}function Ie(e,t,n,s){if(e){t.forEach((t=>{const n=ve(s=(0,r.cY)(s,e,t,{isDeleting:!0}),e);n&&(s=fe(s,e,n,!0))})),n.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const a=(0,c.hj)(s,e,t);if(!a)return;s=ge(s,n,a,!0);const{threadInfo:i}=(0,c.Db)(s,e,a)||{};i&&o.push(i.threadId)})),(0,a.R3)(s),void setTimeout((()=>{(0,a.R3)((0,r.K4)((0,a.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{n.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),me)}const o=[];t.forEach((e=>{const t=(0,c.X5)(s,e);if(t){o.push(t);const n=ve(s=(0,r.cY)(s,t,e,{isDeleting:!0}),t);n&&(s=fe(s,t,n,!0)),setTimeout((()=>{(0,a.R3)((0,r.K4)((0,a.Rd)(),t,[e]))}),me)}})),(0,a.R3)(s),(0,g.Tw)(o).forEach((e=>{n.requestChatUpdate({chatId:e})}))}(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"newMessage":{const{chatId:o,id:l,message:u,shouldForceReply:m}=n;e=pe(e=he(e,o,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,o,l);if((0,c.KA)(e,o,u)){var s;if(u.isOutgoing&&(null===(s=u.content)||void 0===s||!s.action)){const n=(0,c.Bt)(e);n&&t.focusMessage({chatId:o,threadId:n.threadId,messageId:u.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:n}=(0,c.Db)(e,o,u)||{};n&&t.requestThreadInfoUpdate({chatId:o,threadId:n.threadId}),(0,d.CI)(u)||setTimeout((()=>{let e=(0,a.Rd)();m&&(e=(0,r.pf)(e,o,i._f,"replyingToId",l)),(0,a.R3)(fe(e,o,h))}),me)}else e=fe(e,o,h);(0,a.R3)(e),(0,c.N)(e,o)||t.loadTopChats();break}case"updateStartEmojiInteraction":{var o;const{chatId:t}=(0,c.Bt)(e)||{};if(t!==n.id)return;const s=(0,c.hj)(e,t,n.messageId);if(!s)return;if((0,d.UD)(s)!==n.emoji)return;const i=(0,c.CP)(e,n.emoji);e={...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],{id:(null===(o=e.activeEmojiInteractions)||void 0===o?void 0:o.length)||0,animatedEffect:i?(0,c.cu)(i):n.emoji,messageId:n.messageId}]},(0,a.R3)(e);break}case"newScheduledMessage":{const{chatId:t,id:s,message:o}=n;e=he(e,t,s,o,!0);const l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,i._f,"scheduledIds",(0,g.Tw)([...l,s])),(0,a.R3)(e);break}case"updateMessage":{var l,u;const{chatId:s,id:o,message:d}=n;if(!(0,c.hj)(e,s,o))return;e=he(e,s,o,d);const m=(0,c.hj)(e,s,o);d.threadInfo&&(e=(0,r.Xg)(e,d.threadInfo.chatId,d.threadInfo.threadId,d.threadInfo)),e=fe(e,s,m),(0,a.R3)(e);const h=(0,c.Z1)(e,s);h&&!d.isOutgoing&&(null===(l=h.lastMessage)||void 0===l?void 0:l.id)===d.id&&(0,c.xo)(e,h)&&(0,c.KA)(e,s,d)&&(0,c.b9)(e,s,(null===(u=d.threadInfo)||void 0===u?void 0:u.threadId)||i._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:s,message:o}=n;if(!(0,c.Tm)(e,t,s))return;e=he(e,t,s,o,!0);const l=Object.keys((0,c.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,i._f,"scheduledIds",l),(0,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:s,localId:o,message:i}=n;e=pe(e,t,i);const l=(0,c.hj)(e,s,o);e=(0,r.K4)(e,s,[o]),i.isScheduled&&(e=(0,r.bV)(e,s,[o])),e=(0,r.cY)(e,s,i.id,{...l,...i,previousLocalId:o});const d=(0,c.hj)(e,s,i.id);e=fe(e,s,d);const u=(0,c.Db)(e,s,i);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:i.id}),e=(0,r.pf)(e,s,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:i.id,lastReadInboxMessageId:i.id})),(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:s,message:o}=n,l=(0,c.qy)(e,t)||[];e=(0,r.pf)(e,t,i._f,"scheduledIds",[...l,o.id]);const d=(0,c.Tm)(e,t,s);e=(0,r.bV)(e,t,[s]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:s}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:s,messageIds:o}=n,l=(0,c.KB)(e,t)||[],d=s?[...l,...o].sort(((e,t)=>t-e)):l.filter((e=>!o.includes(e)));(0,a.R3)((0,r.pf)(e,t,i._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:s,threadInfo:o,firstMessageId:i}=n,l={...(0,c.tZ)(e,t,s),...o};if(!l.threadId)return;e=(0,r.Xg)(e,t,s,l),i&&(e=(0,r.pf)(e,t,s,"firstMessageId",i)),(0,a.R3)(e);break}case"resetMessages":{const{id:s}=n,o=(0,c.Zw)(e,s);o&&!(0,d.YC)(s)&&(e=(0,r.K4)(e,s,Object.keys(o).map(Number)),(0,a.R3)(e),t.loadFullChat({chatId:s,force:!0}));break}case"deleteMessages":{const{ids:a,chatId:s}=n;Ie(s,a,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:s}=n;!function(e,t,n,s){e&&(t.forEach((t=>{s=(0,r.P4)(s,e,t,{isDeleting:!0})})),(0,a.R3)(s),setTimeout((()=>{s=(0,r.bV)((0,a.Rd)(),e,t);const n=(0,c.Fn)(s,e);s=(0,r.pf)(s,e,i._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,a.R3)(s)}),me))}(s,t,0,e);break}case"deleteHistory":{const{chatId:a}=n,s=e.messages.byChatId[a];s?Ie(a,Object.keys(s.byId).map(Number),t,e):t.requestChatUpdate({chatId:a});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:s}=n;t.forEach((t=>{const n=(0,c.X5)(e,t);n&&(e=(0,r.cY)(e,n,t,s))})),(0,a.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:s,messageUpdate:o}=n;s.forEach((n=>{e=(0,r.cY)(e,t,n,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:s}=n,o=(0,c.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...s},{results:n}=t.results||{};if(n&&!n.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,a=e&&e.filter((e=>e.isChosen));a&&a.forEach((e=>{const a=n.findIndex((t=>t.option===e.option));a>=0&&(t.results.results[a].isChosen=!0)}))}(0,a.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:s,options:o}=n,i=(0,c.ZB)(e,t);if(!i||!i.content.poll||!i.content.poll.results)break;const{poll:l}=i.content,{recentVoterIds:d,totalVoters:u,results:m}=l.results,h=d?[...d]:[],g=u?u+1:1,p=m?[...m]:[];h.push(s),o.forEach((t=>{const n=p.find((e=>e.option===t)),a=p.findIndex((e=>e.option===t)),o=n?{...n}:{option:t,votersCount:0};o.votersCount+=1,s===e.currentUserId&&(o.isChosen=!0),a?p[a]=o:p.push(o)})),(0,a.R3)((0,r.cY)(e,i.chatId,i.id,{content:{...i.content,poll:{...l,results:{...l.results,recentVoterIds:h,totalVoters:g,results:p}}}}));break}case"updateServiceNotification":{const{message:a}=n;(0,c.UW)(e)&&t.createServiceNotification({message:a});break}case"updateMessageReactions":{const{chatId:t,id:s,reactions:o}=n,i=(0,c.hj)(e,t,s),l=(0,c.Z1)(e,n.chatId),u=null==i?void 0:i.reactions;if(u&&ue(o,u))return;const m=(0,d.lb)(u,o,e.currentUserId);if(e=(0,r.cY)(e,t,s,{reactions:n.reactions}),(0,a.R3)(e),m){const n=(0,c.hj)(e,t,s);if(!l||!n)return;(0,de.rh)({chat:l,message:n,isReaction:!0})}break}}}));const ye=(0,E.P2)((function(){const e=(0,a.Rd)();(0,a.R3)((0,r.ps)(e,{...e.users.statusesById,...we})),we={}}),3e3,!0);let we={};(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"deleteContact":return(0,r.GK)(e,n.id);case"updateUser":return(0,r.Nq)(e,n.id,n.user);case"updateUserStatus":return s=n.userId,o=n.status,we[s]=o,void ye();case"updateUserFullInfo":{const{id:t,fullInfo:a}=n,s=e.users.byId[t];if(!s)return;return(0,r.Nq)(e,t,{fullInfo:{...s.fullInfo,...a}})}case"updateBotMenuButton":{var a;const{botId:t,button:s}=n,o=(0,c.dy)(e,t);if(null==o||null===(a=o.fullInfo)||void 0===a||!a.botInfo)return;return(0,r.Nq)(e,t,{fullInfo:{...o.fullInfo,botInfo:{...o.fullInfo.botInfo,menuButton:s}}})}}var s,o})),(0,a.iw)("apiUpdate",((e,t,n)=>{if("updateStickerSet"===n["@type"])return(0,r.Rg)(e,n.id,n.stickerSet)})),(0,a.iw)("apiUpdate",((e,t,n)=>{var s;switch(n["@type"]){case"updatePeerBlocked":return n.isBlocked?(0,r.O4)((0,a.Rd)(),n.id):(0,r.rB)((0,a.Rd)(),n.id);case"updateResetContactList":(0,a.R3)({...(0,a.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[n.key]=n.rules;break;case"updatePaymentVerificationNeeded":e=(0,r.fS)((0,a.Rd)(),n.url),e=(0,r.Q$)(e,m.KB.ConfirmPayment),(0,a.R3)(e);break;case"updateWebViewResultSent":(null===(s=e.webApp)||void 0===s?void 0:s.queryId)===n.queryId&&(t.setReplyingToId({messageId:void 0}),t.closeWebApp())}})),(0,a.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:s,isSilent:o,shouldShowPreviews:i}=n;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:s})),(0,a.R3)((0,r.aK)(e,t,{isMuted:s,isSilent:o,shouldShowPreviews:i}));break}}})),(0,a.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 Ze=n(8958),Pe=n(2431);(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateGroupCall":return"discarded"===n.call.connectionState?e.groupCalls.activeGroupCallId?void t.leaveGroupCall({shouldRemove:!0}):(0,Ze.dc)(e,n.call.id):(0,Ze.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:s,nextOffset:o}=n,{currentUserId:i}=e;return e=(0,a.Rd)(),s.forEach((n=>{n.id&&(e=(0,Ze.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,Ze.AH)(e,t,{nextOffset:o})),e}case"updatePhoneCall":{if(!h.Bi)return;const{phoneCall:t,currentUserId:a}=e;if(t)return;const{call:s}=n;if((null==s?void 0:s.adminId)!==a&&"requested"===s.state)return(0,de.TO)({call:s,user:(0,Pe.fu)(e)}),(0,C.o5)(),{...e,phoneCall:s,isCallPanelVisible:!1}}}})),(0,a.iw)("apiUpdate",((e,t,n)=>{if("updatePaymentStateCompleted"===n["@type"])return(0,r.bp)(e)}));var be=n(8674),Ce=n(6752),Se=n(1279),Ee=n(3551),Me=n(3227),Re=n(5332);function ke(e){(0,o.d4)((()=>(0,E.Gq)(e)),[e])}var Ne=n(9290);const Te=document.querySelector('meta[name="viewport"]'),Be=(null==Te?void 0:Te.getAttribute("content"))||"",Ae="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function xe(e){e.preventDefault()}var Le=n(5326),Oe=n(6590),Ue=n(1212),Fe=n(4851),qe=n(2155),$e=n(5616),De=n(7358);const je=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,$e.yi)();const n=(0,q.xW)();if((0,o.d4)((()=>{t&&(0,De.w)(n)}),[t,n]),!t&&n)return o.ZP.createElement("div",{className:"unread-count active"},(0,qe.bi)(n))}));var Ge=n(3989),_e=n(7529),He=n(3455),ze=n(706),Ve=n(2255),We=n(9107),Xe=n(7370),Ke=n(7926),Ye=n(1622);let Je;function Qe(e,t,n,a,s,i){let r,c,l;return r=function(){const[e,t]=(0,o.eJ)(window.navigator.onLine);return(0,o.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}()&&"connectionStateConnecting"!==t?n?Je.syncing:Je.online:Je.waitingForNetwork,c=r===Je.online||i?"none":a?"middleHeader":s?"minimized":"overlay",r===Je.waitingForNetwork?l=e("WaitingForNetwork"):r===Je.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"}(Je||(Je={}));var et=n(3106),tt=n(8964),nt=n(231),at=n(9589),st=n(9187),ot=n(3321),it=n(126),rt=n(9204);const ct=(0,o.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:a}=e;const s=(0,We.Z)();return o.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:s.isRtl?"rtl":void 0,onClick:a},o.ZP.createElement(rt.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},o.ZP.createElement(Ve.Z,{activeKey:t,name:"slide-fade"},n)),o.ZP.createElement(nt.Z,{round:!0,size:"tiny",color:"translucent-black"},o.ZP.createElement("span",{className:"icon-close"})))})),lt=(0,o.X$)((0,a.c$)((e=>{const{query:t,fetchingStatus:n,chatId:a,date:s}=e.globalSearch,{currentUserId:o,connectionState:i,isSyncing:r}=e,{byId:l}=e.chats,{isConnectionStatusMinimized:d,animationLevel:u}=e.settings.byKey;return{searchQuery:t,isLoading:!!n&&Boolean(n.chats||n.messages),currentUserId:o,chatsById:l,globalSearchChatId:a,searchDate:s,theme:(0,c.Pu)(e),animationLevel:u,connectionState:i,isSyncing:r,isMessageListOpen:Boolean((0,c.Bt)(e)),isConnectionStatusMinimized:d,areChatsLoaded:Boolean(e.chats.listIds.active)}}))((e=>{let{content:t,contactsFilter:n,onSearchQuery:i,onSelectSettings:r,onSelectContacts:c,onSelectArchived:l,onReset:u,searchQuery:g,isLoading:p,shouldSkipTransition:f,currentUserId:v,globalSearchChatId:I,searchDate:y,theme:w,animationLevel:Z,chatsById:P,connectionState:b,isSyncing:C,isMessageListOpen:S,isConnectionStatusMinimized:E,areChatsLoaded:M}=e;const{openChat:R,openTipsChat:k,setGlobalSearchDate:N,setSettingOption:T,setGlobalSearchChatId:B,openChatByUsername:A}=(0,a.Sv)(),x=(0,We.Z)(),O=t===m.du.ChatList,U=(0,o.Ye)((()=>y?(0,L.xH)(new Date(1e3*y)):void 0),[y]),F=(0,o.Ye)((()=>O&&P?Object.values(P).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[O,P]),{connectionStatus:q,connectionStatusText:$,connectionStatusPosition:D}=Qe(x,b,C,S,E,!M),j="web.telegram.org"===window.location.hostname,G=(0,o.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return o.ZP.createElement(nt.Z,{round:!0,ripple:O&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:O?t:()=>u(),ariaLabel:O?x("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,Ce.Z)("animated-menu-icon",!O&&"state-back",f&&"no-animation")}))}),[O,x,u,f]),_=(0,o.I4)((()=>{g||i("")}),[g,i]),H=(0,o.I4)((()=>{T({isConnectionStatusMinimized:!E})}),[E,T]),z=(0,o.I4)((()=>{R({id:v,shouldReplaceHistory:!0})}),[v,R]),V=(0,o.I4)((e=>{e.stopPropagation();const t="light"===w?"dark":"light";T({theme:t}),T({shouldUseSystemTheme:!1}),(0,Xe.Z)(t,Z===s.zy)}),[Z,T,w]),W=(0,o.I4)((()=>{window.open(s.ul,"_blank")}),[]),X=(0,o.I4)((()=>{A({username:s.vz})}),[A]),K=(0,o.I4)((()=>{(0,Ke.L)("K"),(0,Ye.W8)(),(0,Oe.Wv)()}),[]),Y=(0,o.I4)((()=>{k({langCode:x.code})}),[x.code,k]),J=Boolean(I)||t===m.du.GlobalSearch||t===m.du.Contacts,Q=t===m.du.Contacts?x("SearchFriends"):x("Search"),ee=s.Tj?`${s.Ji} Beta (master)`:s.eM?"master":s.Ji;return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(et.Z,{trigger:G,footer:`${s.iC} ${ee}`},o.ZP.createElement(tt.Z,{icon:"saved-messages",onClick:z},x("SavedMessages")),o.ZP.createElement(tt.Z,{icon:"archive",onClick:l},o.ZP.createElement("span",{className:"menu-item-name"},x("ArchivedChats")),F>0&&o.ZP.createElement("div",{className:"archived-badge"},F)),o.ZP.createElement(tt.Z,{icon:"user",onClick:c},x("Contacts")),o.ZP.createElement(tt.Z,{icon:"settings",onClick:r},x("Settings")),o.ZP.createElement(tt.Z,{icon:"darkmode",onClick:V},o.ZP.createElement("span",{className:"menu-item-name"},x("lng_menu_night_mode")),o.ZP.createElement(ot.Z,{id:"darkmode",label:x("dark"===w?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===w,noAnimation:!0})),o.ZP.createElement(tt.Z,{icon:"help",onClick:Y},x("TelegramFeatures")),o.ZP.createElement(tt.Z,{icon:"bug",href:s.mU},"Report Bug"),s.Tj&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(tt.Z,{icon:"permissions",onClick:W},"Beta Changelog"),o.ZP.createElement(tt.Z,{icon:"comments",onClick:X},"Beta Discussion (ru)")),j&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(tt.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:K},"Switch to K Version"),o.ZP.createElement(tt.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:Oe.Wv},"Switch to Old Version"))),o.ZP.createElement(at.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||y?"with-picker-item":"",value:n||g,focused:J,isLoading:p||"minimized"===D,spinnerColor:"minimized"===D?"yellow":void 0,spinnerBackgroundColor:"minimized"===D&&"light"===w?"light":void 0,placeholder:Q,autoComplete:"off",canClose:Boolean(I||y),onChange:i,onReset:u,onFocus:_,onSpinnerClick:"minimized"===D?H:void 0},U&&o.ZP.createElement(st.Z,{icon:"calendar",title:U,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:N,clickArg:{date:void 0}}),I&&o.ZP.createElement(st.Z,{chatOrUserId:I,onClick:B,canClose:!0,clickArg:{id:void 0}})),o.ZP.createElement(it.Z,{isOpen:"overlay"===D,isCustom:!0,className:"connection-state-wrapper"},o.ZP.createElement(ct,{connectionStatus:q,connectionStatusText:$,onClick:H}))))})));var dt=n(1174),ut=n(3133),mt=n(1080);const ht=(0,o.X$)((0,a.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n,activeChatFolder:a},currentUserId:s,lastSyncTime:o,shouldSkipHistoryAnimations:i}=e;return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:a,currentUserId:s,lastSyncTime:o,shouldSkipHistoryAnimations:i}}))((e=>{let{foldersDispatch:t,onScreenSelect:n,chatFoldersById:i,orderedFolderIds:r,activeChatFolder:c,currentUserId:l,lastSyncTime:d,shouldSkipHistoryAnimations:u}=e;const{loadChatFolders:m,setActiveChatFolder:g,openChat:p}=(0,a.Sv)(),f=(0,o.sO)(null),v=(0,We.Z)();(0,o.d4)((()=>{d&&m()}),[d,m]);const I=(0,o.Ye)((()=>r?r.map((e=>i[e]||{})).filter(Boolean):void 0),[i,r]),y=(0,$e.yi)(),w=(0,o.Ye)((()=>{if(I&&I.length)return[{id:s.Nf,title:"en"===v.code?"All":v("FilterAllChats")},...I.map((e=>{var t,n;let{id:a,title:s}=e;return{id:a,title:s,badgeCount:null===(t=y[a])||void 0===t?void 0:t.chatsCount,isBadgeActive:Boolean(null===(n=y[a])||void 0===n?void 0:n.notificationsCount)}}))]}),[I,y,v]),Z=(0,o.I4)((e=>{g(e,{forceOnHeavyAnimation:!0})}),[g]);(0,o.d4)((()=>{w&&w.length&&c>=w.length&&g(0)}),[c,w,g]),(0,o.d4)((()=>{if(f.current&&h.$b&&w&&w.length)return(0,dt.sf)(f.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===dt.eM.Left?(g(Math.min(c+1,w.length-1),{forceOnHeavyAnimation:!0}),!0):t===dt.eM.Right&&(g(Math.max(0,c-1),{forceOnHeavyAnimation:!0}),!0)})}),[c,w,g]);const P=(0,o.sO)();P.current=0!==c,(0,o.d4)((()=>P.current?(0,Ge.Z)((()=>{P.current&&g(0)})):void 0),[c,g]),(0,Oe.ZP)(0!==c,(()=>g(0,{forceOnHeavyAnimation:!0}))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&w){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void p({id:l,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>w.length-1)return;g(n,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:b,transitionClassNames:C}=(0,Ue.Z)(!r,void 0,!0);function S(e){const a=Object.values(i).find((e=>{let{id:t}=e;return t===w[c].id}));return a&&0!==c?o.ZP.createElement(mt.Z,{folderType:"folder",folderId:a.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t}):o.ZP.createElement(mt.Z,{folderType:"all",isActive:e,lastSyncTime:d,foldersDispatch:t,onScreenSelect:n})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=w&&w.length?o.ZP.createElement(ut.Z,{tabs:w,activeTab:c,onSwitchTab:Z}):b?o.ZP.createElement("div",{className:(0,Ce.Z)("tabs-placeholder",C)}):void 0,o.ZP.createElement(Ve.Z,{ref:f,name:u?"none":v.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:w?w.length:void 0},S))})));var gt=n(9203),pt=n(8778),ft=n(4288);const vt=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)})),It=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)}));var yt=n(2328);const wt=(0,o.X$)((e=>{let{isShown:t,onNewPrivateChat:n,onNewChannel:a,onNewGroup:s}=e;const[i,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{t||r(!1)}),[t]);const c=(0,We.Z)(),l=(0,Ce.Z)("NewChatButton",t&&"revealed",i&&"menu-is-open"),d=(0,o.I4)((()=>{r(!i)}),[i]),u=(0,o.I4)((()=>{r(!1)}),[]);return o.ZP.createElement("div",{className:l},o.ZP.createElement(nt.Z,{round:!0,color:"primary",className:i?"active":"",onClick:d,ariaLabel:c(i?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(yt.Z,{isOpen:i,positionX:"right",positionY:"bottom",autoClose:!0,onClose:u},o.ZP.createElement(tt.Z,{icon:"channel",onClick:a},c("NewChannel")),o.ZP.createElement(tt.Z,{icon:"group",onClick:s},c("NewGroup")),o.ZP.createElement(tt.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),Zt=Object.keys(m.du).length/2;let Pt;const bt=(0,o.X$)((e=>{let{content:t,searchQuery:n,searchDate:a,contactsFilter:s,shouldSkipTransition:i,foldersDispatch:r,onSearchQuery:c,onContentChange:l,onScreenSelect:d,onReset:u}=e;const[g,p]=(0,o.eJ)(h.$b),f=(0,o.sO)(!1),v=(0,o.I4)((()=>{l(m.du.Settings)}),[l]),I=(0,o.I4)((()=>{l(m.du.Contacts)}),[l]),y=(0,o.I4)((()=>{l(m.du.NewChannelStep1)}),[l]),w=(0,o.I4)((()=>{l(m.du.NewGroupStep1)}),[l]),Z=(0,o.I4)((()=>{l(m.du.Archived)}),[l]),P=(0,o.I4)((()=>{t===m.du.ChatList&&(f.current=!0,p(!0))}),[t]),b=(0,o.I4)((()=>{f.current=!1,Pt&&(clearTimeout(Pt),Pt=void 0),Pt=window.setTimeout((()=>{f.current||p(!1)}),250)}),[]);(0,o.d4)((()=>{let e;return t!==m.du.ChatList?e=window.setTimeout((()=>{p(!1)}),250):(f.current||h.$b)&&p(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const[C,S,E]=function(){const[e,t]=(0,ze.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:n,transitionClassNames:a}=(0,Ue.Z)(e);return[n,a,()=>{window.location.reload()}]}(),M=(0,We.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:P,onMouseLeave:h.$b?void 0:b},o.ZP.createElement(lt,{content:t,contactsFilter:s,onSearchQuery:c,onSelectSettings:v,onSelectContacts:I,onSelectArchived:Z,onReset:u,shouldSkipTransition:i}),o.ZP.createElement(Ve.Z,{name:i?"none":"zoom-fade",renderCount:Zt,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return o.ZP.createElement(ht,{onScreenSelect:d,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement(vt,{searchQuery:n,searchDate:a,isActive:e,onReset:u});case m.du.Contacts:return o.ZP.createElement(It,{filter:s,isActive:e,onReset:u});default:return}})),C&&o.ZP.createElement(nt.Z,{fluid:!0,pill:!0,className:(0,Ce.Z)("btn-update",S),onClick:E},M("lng_update_telegram")),o.ZP.createElement(wt,{isShown:g,onNewPrivateChat:I,onNewChannel:y,onNewGroup:w}))})),Ct=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)})),St=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)})),Et=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)}));var Mt;!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"}(Mt||(Mt={}));const Rt=Object.keys(Mt).length/2,kt=(0,o.X$)((0,a.c$)((e=>{const{globalSearch:{query:t,date:n},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:s,leftColumnWidth:o}=e;return{searchQuery:t,searchDate:n,activeChatFolder:a,shouldSkipHistoryAnimations:s,leftColumnWidth:o}}))((e=>{let{searchQuery:t,searchDate:n,activeChatFolder:s,shouldSkipHistoryAnimations:i,leftColumnWidth:r}=e;const{setGlobalSearchQuery:c,setGlobalSearchChatId:l,resetChatCreation:d,setGlobalSearchDate:u,loadPasswordInfo:g,clearTwoFaError:p,setLeftColumnWidth:f,resetLeftColumnWidth:v}=(0,a.Sv)(),I=(0,o.sO)(null),[y,w]=(0,o.eJ)(m.du.ChatList),[Z,P]=(0,o.eJ)(m.MT.Main),[b,C]=(0,o.eJ)(""),[S,E]=(0,He.ZP)(),[M,R]=(0,o.eJ)(0);let k=Mt.Main;switch(y){case m.du.Archived:k=Mt.Archived;break;case m.du.Settings:k=Mt.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:k=Mt.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:k=Mt.NewGroup}const N=(0,o.I4)((e=>{if(y!==m.du.NewGroupStep2||e)if(y!==m.du.NewChannelStep2||e){if(y===m.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(y===m.du.Settings)switch(Z){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:return void P(m.MT.Main);case m.MT.GeneralChatBackground:case m.MT.QuickReaction:return void P(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void P(m.MT.GeneralChatBackground);case m.MT.PrivacyPhoneNumber:case m.MT.PrivacyLastSeen:case m.MT.PrivacyProfilePhoto:case m.MT.PrivacyForwarding:case m.MT.PrivacyGroupChats:case m.MT.PrivacyBlockedUsers:case m.MT.TwoFaDisabled:case m.MT.TwoFaEnabled:case m.MT.TwoFaCongratulations:return void P(m.MT.Privacy);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void P(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void P(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void P(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void P(m.MT.PrivacyForwarding);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void P(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void P(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void P(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void P(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void P(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void P(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void P(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void P(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void P(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void P(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void P(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void P(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void P(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void P(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return w(m.du.ChatList),void P(m.MT.Main)}y!==m.du.ChatList||0!==s?(w(m.du.ChatList),C(""),c({query:""}),u({date:void 0}),l({id:void 0}),d(),setTimeout((()=>{R(Date.now())}),250)):w(m.du.GlobalSearch)}else w(m.du.NewChannelStep1);else w(m.du.NewGroupStep1)}),[y,s,Z,c,u,l,d]),T=(0,o.I4)((e=>{y!==m.du.Contacts?(w(m.du.GlobalSearch),e!==t&&c({query:e})):C(e)}),[y,t,c]);(0,o.d4)((()=>y!==m.du.ChatList||0===s?(0,Ge.Z)((()=>N())):void 0),[s,y,N]),(0,o.d4)((()=>{if(y!==m.du.GlobalSearch)return document.addEventListener("keydown",e,!1),()=>{document.removeEventListener("keydown",e,!1)};function e(e){(h.jm&&e.metaKey||!h.jm&&e.ctrlKey)&&e.shiftKey&&"f"===(0,_e.Z)(e)&&(e.preventDefault(),w(m.du.GlobalSearch))}}),[y]),(0,o.d4)((()=>{p(),Z===m.MT.Privacy&&g()}),[p,g,Z]);const{initResize:B,resetResize:A,handleMouseUp:x}=function(e,t,n,a){const[s,i,r]=(0,ze.Z)(),[c,l]=(0,o.eJ)(),[d,u]=(0,o.eJ)();function m(){document.body.classList.remove("cursor-ew-resize")}return(0,o.d4)((()=>{e.current&&a&&(e.current.style.width=`${a}px`)}),[e,a]),(0,o.d4)((()=>{if(!s)return;const n=t=>{const n=Math.ceil(d+t.clientX-c);e.current.style.width=`${n}px`};function a(){o(),t(e.current.offsetWidth)}function o(){m(),document.removeEventListener("mousemove",n,!1),document.removeEventListener("mouseup",a,!1),document.removeEventListener("blur",a,!1),r()}return document.addEventListener("mousemove",n,!1),document.addEventListener("mouseup",a,!1),document.addEventListener("blur",a,!1),o}),[d,c,e,t,s,r]),{initResize:function(t){t.preventDefault(),document.body.classList.add("cursor-ew-resize"),l(t.clientX),u(e.current.offsetWidth),i()},resetResize:function(t){t.preventDefault(),e.current.style.width="",n()},handleMouseUp:m}}(I,f,v,r),L=(0,o.I4)((e=>{w(m.du.Settings),P(e)}),[]);return o.ZP.createElement("div",{id:"LeftColumn",ref:I},o.ZP.createElement(Ve.Z,{name:i?"none":h.s0,renderCount:Rt,activeKey:k,shouldCleanup:!0,cleanupExceptionKey:Mt.Main},(e=>{switch(k){case Mt.Archived:return o.ZP.createElement(Et,{isActive:e,onReset:N,onContentChange:w});case Mt.Settings:return o.ZP.createElement(Ct,{isActive:e,currentScreen:Z,foldersState:S,foldersDispatch:E,onScreenSelect:L,onReset:N,shouldSkipTransition:i});case Mt.NewChannel:return o.ZP.createElement(St,{key:M,isActive:e,isChannel:!0,content:y,onContentChange:w,onReset:N});case Mt.NewGroup:return o.ZP.createElement(St,{key:M,isActive:e,content:y,onContentChange:w,onReset:N});default:return o.ZP.createElement(bt,{content:y,searchQuery:t,searchDate:n,contactsFilter:b,foldersDispatch:E,onContentChange:w,onSearchQuery:T,onScreenSelect:L,onReset:N,shouldSkipTransition:i})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:B,onMouseUp:x,onDoubleClick:A}))})));var Nt=n(2420),Tt=n(5780),Bt=n(9524),At=n(1394);var xt=n(8986),Lt=n(2678),Ot=n(7204),Ut=n(3570),Ft=n(5790),qt=n(8360),$t=n(6058),Dt=n(8799);const jt=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"HeaderMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),Gt=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,s;let{chatId:o,threadId:r,messageListType:l}=t;const u=(0,c.Z1)(e,o),m=Boolean(u&&(0,d.eA)(u));if(!u||u.isRestricted||(0,c.CA)(e))return{noMenu:!0};const g=(0,c.IK)(e,o),p=(0,c.FM)(e,o),f="thread"===l&&r===i._f,v="thread"===l&&r!==i._f,I=(0,c.Jf)(e),y=Boolean(g&&(0,c.s4)(e,g.id)),w=!y&&Boolean((0,c.pk)(e,o)),Z=Boolean(f&&(m||(0,d.ZV)(u))&&u.isNotJoined),P=f||v,b=h.Bi&&(0,d.YC)(u.id)&&!p&&!g,C=f&&!p&&!Z,S=f&&!Z,E=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:w,canRestartBot:y,canSubscribe:Z,canSearch:P,canCall:b,canMute:C,canViewStatistics:null===(a=u.fullInfo)||void 0===a?void 0:a.canViewStatistics,canLeave:S,canEnterVoiceChat:E,canCreateVoiceChat:M,pendingJoinRequests:null===(s=u.fullInfo)||void 0===s?void 0:s.requestsPending}}))((e=>{let{chatId:t,threadId:n,noMenu:s,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,pendingJoinRequests:y,isRightColumnShown:w,canExpandActions:Z}=e;const{joinChannel:P,sendBotCommand:b,openLocalTextSearch:C,restartBot:S,requestCall:E,requestNextManagementScreen:M}=(0,a.Sv)(),R=(0,o.sO)(null),[k,N]=(0,o.eJ)(!1),[T,B]=(0,o.eJ)(void 0),A=(0,o.I4)((()=>{N(!0);const e=R.current.getBoundingClientRect();B({x:e.right,y:e.bottom})}),[]),x=(0,o.I4)((()=>{N(!1)}),[]),L=(0,o.I4)((()=>{B(void 0)}),[]),O=(0,o.I4)((()=>{P({chatId:t})}),[P,t]),U=(0,o.I4)((()=>{b({command:"/start"})}),[b]),F=(0,o.I4)((()=>{S({chatId:t})}),[t,S]),q=(0,o.I4)((()=>{M({screen:m.u1.JoinRequests})}),[M]),$=(0,o.I4)((()=>{C(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[C]);(0,o.d4)((()=>{if(d)return document.addEventListener("keydown",e,!1),()=>{document.removeEventListener("keydown",e,!1)};function e(e){h.fl&&(h.jm&&e.metaKey||!h.jm&&e.ctrlKey)&&!e.shiftKey&&"f"===(0,_e.Z)(e)&&(e.preventDefault(),$())}}),[d,$]);const D=(0,We.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,Z&&l&&o.ZP.createElement(nt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:O},D(i?"ProfileJoinChannel":"ProfileJoinGroup")),Z&&r&&o.ZP.createElement(nt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:U},D("BotStart")),Z&&c&&o.ZP.createElement(nt.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:F},D("BotRestart")),d&&o.ZP.createElement(nt.Z,{round:!0,ripple:w,color:"translucent",size:"smaller",onClick:$,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),u&&o.ZP.createElement(nt.Z,{round:!0,color:"translucent",size:"smaller",onClick:function(){E({userId:t})},ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),Boolean(y)&&o.ZP.createElement(nt.Z,{round:!0,className:"badge-button",ripple:w,color:"translucent",size:"smaller",onClick:q,ariaLabel:D(i?"SubscribeRequests":"MemberRequests")},o.ZP.createElement("i",{className:"icon-user"}),o.ZP.createElement("div",{className:"badge"},y)),o.ZP.createElement(nt.Z,{ref:R,className:k?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:A},o.ZP.createElement("i",{className:"icon-more"})),T&&o.ZP.createElement(jt,{chatId:t,threadId:n,isOpen:k,anchor:T,withExtraActions:h.wB||!Z,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canViewStatistics:p,canLeave:f,canEnterVoiceChat:v,canCreateVoiceChat:I,onSubscribeChannel:O,onSearchClick:$,onClose:x,onCloseAnimationEnd:L}))})));var _t=n(4399),Ht=n(996),zt=n(6202),Vt=n(862);function Wt(e){var t;const n=e&&(0,d.DH)(e),a=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,i=n&&a&&!(0,h.on)()&&n.includes("image/webp"),[r,c]=(0,o.eJ)(Vt.Hu),l=null==e?void 0:e.id;return(0,o.bt)((()=>{i&&(0,Vt.p6)(`b64-${l}`,n).then(c).catch((e=>{s.eM&&console.error(e)}))}),[l,i,n]),i?r:n}var Xt=n(8512),Kt=n(7551);function Yt(e,t,n,a,s){return`M${e},${t+s}a${s},${s},0,0,1,\n ${n},0v${a-2*s}a${s},${s},0,0,1,${-n},0Z`}const Jt=(0,o.X$)((e=>{let{count:t,index:n}=e;const a=(0,o.sO)(null),s=(0,o.Ye)((()=>function(e,t){const n=e-t-1,a=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),s=function(e,t){let n=36;return 1===e?n=36:2===e?n=17:3===e?n=1===t?12:11:(4===e||e>3)&&(n=7.5),n}(e,n),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,a),i=`clipPath${e}`,r=function(e,t,n){let a="";if(3===n)a=Yt(0,0,2,t,1)+Yt(0,12,2,t+1,1)+Yt(0,25,2,t,1);else for(let e=0;e<n;e++)a+=Yt(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${a}" />\n </clipPath>`}(i,a,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,a,e),l=function(e,t,n,a){return t<=4||e<=1?0:e>=t-2?a-36:(n+4)/2+(e-2)*(n+2)}(n,e,a,o);return{markHeight:s,clipPath:r,markTranslateY:c,trackTranslateY:l,trackHeight:o,clipPathId:i}}(t,n)),[t,n]);if((0,o.d4)((()=>{if(!a.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:i,clipPath:r}=s,c=a.current.firstElementChild;if(null!=a&&a.current){const s=a.current,{style:l}=s;l.height=`${e}px`,l.transform=`translateY(-${t}px)`,l.clipPath=`url("#${i}")`;const d=s.querySelector("svg"),u=s.querySelector("div"),m=s.querySelector("defs");d||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${r} </defs></svg>`),m&&(m.innerHTML=r),u&&(u.style.height=`${n}px`,u.style.transform=`translateY(${o}px)`)}}),[s]),1===t)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:a}));const{trackHeight:i,trackTranslateY:r,markHeight:c,markTranslateY:l,clipPathId:d}=s;return o.ZP.createElement("div",{className:(0,Ce.Z)("pinned-message-border",t>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:a,style:`clip-path: url("#${d}"); width: 2px;\n height: ${i}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${c}px; transform: translateY(${l}px);`})))})),Qt=(0,o.X$)((e=>{let{message:t,count:n,index:s,customTitle:i,className:r,onUnpinMessage:c,onClick:l,onAllPinnedClick:u}=e;const{clickBotInlineButton:m}=(0,a.Sv)(),g=(0,We.Z)(),p=Wt(t),f=(0,zt.Z)((0,d.Ti)(t,"pictogram")),v=(0,Ht.e)(g,t,Boolean(p)),[I,y,w]=(0,ze.Z)(),Z=(0,o.I4)((()=>{w(),c&&c(t.id)}),[w,c,t.id]),P=(0,d.eH)(t),b=(0,o.I4)((()=>{P&&m({messageId:t.id,button:P})}),[m,P,t.id]),[C,S,E]=(0,ze.Z)();return o.ZP.createElement("div",{className:(0,Ce.Z)("HeaderPinnedMessage-wrapper",r)},n>1&&o.ZP.createElement(nt.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:g("EventLogFilterPinnedMessages"),onClick:u},o.ZP.createElement("i",{className:"icon-pin-list"})),c&&o.ZP.createElement(nt.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:g("UnpinMessageAlertTitle"),className:"unpin-button",onClick:y},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Kt.Z,{isOpen:I,onClose:w,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:Z}),o.ZP.createElement("div",{className:(0,Ce.Z)("HeaderPinnedMessage",C&&"no-hover"),onClick:l,dir:g.isRtl?"rtl":void 0},o.ZP.createElement(Jt,{count:n,index:s}),p&&function(e,t){const{width:n,height:a}=(0,_t.W7)();return o.ZP.createElement("img",{src:t||e,width:n,height:a,alt:""})}(p,f),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},i||`${g("PinnedMessage")} ${s>0?"#"+(n-s):""}`),o.ZP.createElement("p",{dir:"auto"},v),o.ZP.createElement(Xt.Z,null)),P&&o.ZP.createElement(nt.Z,{size:"tiny",className:"inline-button",onClick:b,shouldStopPropagation:!0,onMouseEnter:h.$b?void 0:S,onMouseLeave:h.$b?void 0:E},P.text)))}));var en=n(396),tn=n(4532),nn=n(3186);function an(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/png";const a=e instanceof Blob?URL.createObjectURL(e):e,s=new Image;return new Promise((o=>{s.onload=()=>{sn(s,s.width*t,s.height*t,n).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},s.src=a}))}async function sn(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return on(e,t,n,void 0,a);try{const s=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:n,resizeQuality:"high"});if(s.height!==n||s.width!==t)throw new Error("Image bitmap resize not supported!");return await new Promise((e=>{const t=document.createElement("canvas");t.width=s.width,t.height=s.height;const n=t.getContext("bitmaprenderer");n?n.transferFromImageBitmap(s):t.getContext("2d").drawImage(s,0,0),t.toBlob(e,a)}))}catch(s){return on(e,t,n,void 0,a)}}function on(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"image/png";const o=document.createElement("canvas"),i=o.getContext("2d"),r=document.createElement("canvas"),c=r.getContext("2d");if(o.width=t,o.height=n,e.width*a>t){const n=1/a;let s={width:Math.floor(e.width*a),height:Math.floor(e.height*a)};for(r.width=s.width,r.height=s.height,c.drawImage(e,0,0,s.width,s.height);s.width*a>t;)s={width:Math.floor(s.width*a),height:Math.floor(s.height*a)},c.drawImage(r,0,0,s.width*n,s.height*n,0,0,s.width,s.height);i.drawImage(r,0,0,s.width,s.height,0,0,o.width,o.height)}else i.drawImage(e,0,0,o.width,o.height);return new Promise((e=>{o.toBlob(e,s)}))}const rn=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg",cn={width:200,height:200},ln=115,dn=(e,t,n)=>{const a=(0,We.Z)(),{audio:s,voice:i}=(0,d.qp)(e),r=s?s.title||s.fileName:i?"Voice message":"",c=(null==s?void 0:s.performer)||t&&(0,d.OU)(a,t),l=n&&(0,d.U)(a,n)||"Telegram",u=s&&(0,d.MR)(s)&&(0,d.Ti)(e,"pictogram"),m=t&&(0,d.RT)(t,"big"),h=s&&u||i&&m,g=(0,zt.Z)(h),p=(0,o.Ye)((()=>function(e,t,n){if(!n)return cn;if(e){var a;if(null===(a=e.thumbnailSizes)||void 0===a||!a.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?_t.vY:void 0}(s,i,g)),[s,g,i]),{result:f}=((e,t,n)=>{const[a,s]=(0,o.eJ)(!1),[i,r]=(0,o.eJ)(),[c,l]=(0,o.eJ)(n);return(0,o.d4)((()=>{s(!0);let t=!1;return e().then((e=>{t||(s(!1),l(e))}),(e=>{t||(s(!1),r(e))})),()=>{t=!0}}),t),{isLoading:a,error:i,result:c}})((()=>function(e,t){if(!e)return Promise.resolve(rn);if(!t)return function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";const s=e instanceof Blob?URL.createObjectURL(e):e,o=new Image;return new Promise((i=>{o.onload=()=>{sn(o,t,n,a).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(i).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(s)}))},o.src=s}))}(e,ln,ln);const n=Math.min(t.width,t.height);return n<ln?an(e,ln/n):Promise.resolve(e)}(g,p)),[g,p],rn);return(0,o.Ye)((()=>(0,tn.Of)({title:r,artist:c,album:l,artwork:[{src:f}]})),[l,c,r,f])};var un=n(2340),mn=n(8051);const hn=(0,a.c$)(((e,t)=>{let{message:n}=t;const a=(0,c.Ur)(e,n),s=(0,c.Z1)(e,n.chatId),{volume:o,playbackRate:i,isMuted:r}=e.audioPlayer;return{sender:a,chat:s,volume:o,playbackRate:i,isMuted:r}}))((e=>{let{message:t,className:n,noUi:s,sender:i,chat:r,volume:c,playbackRate:l,isMuted:u}=e;const{setAudioPlayerVolume:m,setAudioPlayerPlaybackRate:g,setAudioPlayerMuted:p,focusMessage:f,closeAudioPlayer:v}=(0,a.Sv)(),I=(0,We.Z)(),{audio:y,voice:w,video:Z}=(0,d.qp)(t),P=Boolean(w||Z),b=i?(0,d.OU)(I,i):void 0,C=ne.UV((0,d.Ti)(t,"inline")),S=dn(t,i,r),{playPause:E,stop:M,isPlaying:R,requestNextTrack:k,requestPreviousTrack:N,isFirst:T,isLast:B,setVolume:A,toggleMuted:x,setPlaybackRate:L}=(0,nn.Z)((0,en.An)(t),(0,d.XV)(t),P?"voice":"audio",C,void 0,S,void 0,!0,void 0,void 0,(0,d.CI)(t),!0),O=P&&R;(0,o.d4)((()=>{if(O)return re.Z.disableRefresh(),()=>{re.Z.enableRefresh()}}),[O]);const U=(0,o.I4)((()=>{f({chatId:t.chatId,messageId:t.id})}),[f,t.chatId,t.id]),F=(0,o.I4)((()=>{R&&E(),v(),(0,tn.Ay)(),M()}),[v,R,E,M]),q=(0,o.I4)((e=>{m({volume:e/100}),A(e/100)}),[m,A]),$=(0,o.I4)((()=>{h.$b&&!h.cj||(x(),p({isMuted:!u}))}),[u,p,x]),D=(0,o.I4)((()=>{1===l?(L(1.8),g({playbackRate:1.8})):(L(1),g({playbackRate:1}))}),[l,g,L]),j=(0,o.Ye)((()=>0===c||u?"icon-muted":c<.3?"icon-volume-1":c<.6?"icon-volume-2":"icon-volume-3"),[c,u]);if(!s)return o.ZP.createElement("div",{className:(0,Ce.Z)("AudioPlayer",n),dir:I.isRtl?"rtl":void 0},o.ZP.createElement(nt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:T(),onClick:N,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(nt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,Ce.Z)("toggle-play","player-button",R?"pause":"play"),onClick:E,ariaLabel:R?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(nt.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:B(),onClick:k,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon-skip-next"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:U},y?function(e){const{title:t,performer:n,fileName:a}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,un.Z)(t||a)),n&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,un.Z)(n)))}(y):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,un.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(I("AttachAudio"),b),o.ZP.createElement(Xt.Z,null)),o.ZP.createElement(nt.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",noPreventDefault:!0},o.ZP.createElement("i",{className:j,onClick:$}),!h.cj&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"volume-slider-spacer"}),o.ZP.createElement("div",{className:"volume-slider"},o.ZP.createElement(mn.Z,{bold:!0,value:u?0:100*c,onChange:q})))),P&&o.ZP.createElement(nt.Z,{round:!0,className:(0,Ce.Z)("playback-button",1!==l&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:D},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(nt.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:F,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var gn=n(172);const pn=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,c.Z1)(e,n),s=(0,Pe.Bj)(e,n);return{groupCall:s,usersById:e.users.byId,chatsById:e.chats.byId,activeGroupCallId:e.groupCalls.activeGroupCallId,isActive:(s?s.participantsCount>0&&s.isLoaded:a&&a.isCallNotEmpty&&a.isCallActive)&&e.groupCalls.activeGroupCallId!==(null==s?void 0:s.id)}}))((e=>{let{chatId:t,isActive:n,groupCall:s,hasPinnedOffset:i,usersById:r,chatsById:c}=e;const{joinGroupCall:l,subscribeToGroupCallUpdates:d}=(0,a.Sv)(),u=(0,We.Z)(),m=(0,o.I4)((()=>{l({chatId:t})}),[l,t]),h=null==s?void 0:s.participants,g=(0,o.Ye)((()=>h?Object.values(h).filter(((e,t)=>t<3)).map((e=>{let{id:t,isUser:n}=e;if(n){if(!r[t])return;return{user:r[t]}}if(c[t])return{chat:c[t]}})).filter(Boolean):[]),[c,h,r]);if((0,o.d4)((()=>{if(null!=s&&s.id&&(n||!s.isLoaded))return d({id:s.id,subscribed:!0}),()=>{d({id:s.id,subscribed:!1})}}),[null==s?void 0:s.id,null==s?void 0:s.isLoaded,n,d]),s)return o.ZP.createElement("div",{className:(0,Ce.Z)("GroupCallTopPane",i&&"has-pinned-offset",!n&&"is-hidden"),onClick:m},o.ZP.createElement("div",{className:"info"},o.ZP.createElement("span",{className:"title"},u("VoipGroupVoiceChat")),o.ZP.createElement("span",{className:"participants"},u("Participants",s.participantsCount||0,"i"))),o.ZP.createElement("div",{className:"avatars"},g.map((e=>{if(e)return e.user?o.ZP.createElement(gn.Z,{key:e.user.id,user:e.user}):o.ZP.createElement(gn.Z,{key:e.chat.id,chat:e.chat})}))),o.ZP.createElement(nt.Z,{round:!0,className:"join"},u("VoipChatJoin")))})));var fn=n(4605);const vn=(0,o.X$)((0,a.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:s,user:i,settings:r,currentUserId:c}=e;const{openAddContactDialog:l,blockContact:u,reportSpam:m,deleteChat:h,leaveChannel:g,deleteChatUser:p,deleteHistory:f,toggleChatArchived:v,hideChatReportPanel:I}=(0,a.Sv)(),y=(0,We.Z)(),[w,Z,P]=(0,ze.Z)(),[b,C]=(0,o.eJ)(!0),[S,E]=(0,o.eJ)(!0),{accessHash:M}=s||{},{isAutoArchived:R,canReportSpam:k,canAddContact:N,canBlockContact:T}=r||{},B=s&&(0,d.G9)(s),A=(0,o.I4)((()=>{l({userId:t}),R&&v({chatId:t})}),[l,R,v,t]),x=(0,o.I4)((()=>{P(),u({contactId:t,accessHash:M}),k&&b&&m({chatId:t}),S&&h({chatId:t})}),[M,u,P,h,m,k,S,b,t]),L=(0,o.I4)((()=>{I({chatId:t})}),[t,I]),O=(0,o.I4)((()=>{P(),m({chatId:t}),B?(p({chatId:t,userId:c}),f({chatId:t,shouldDeleteForAll:!1})):g({chatId:t})}),[t,P,c,p,f,B,g,m]);if(r)return o.ZP.createElement("div",{className:(0,Ce.Z)("ChatReportPanel",n),dir:y.isRtl?"rtl":void 0},N&&o.ZP.createElement(nt.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:A},y("lng_new_contact_add")),T&&o.ZP.createElement(nt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:Z},y("lng_new_contact_block")),k&&!T&&o.ZP.createElement(nt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:Z},y("lng_report_spam_and_leave")),o.ZP.createElement(nt.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:L,ariaLabel:y("Close")},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Kt.Z,{isOpen:w,onClose:P,title:y("BlockUserTitle",i?(0,d.Vl)(i):(0,d.U)(y,s)),text:i?y("UserInfo.BlockConfirmationTitle",(0,d.Js)(i)):y("Chat.Confirm.ReportSpam.Channel"),isButtonsInOneRow:!0,confirmIsDestructive:!0,confirmLabel:y("Block"),confirmHandler:i?x:O},i&&o.ZP.createElement(fn.Z,{label:y("DeleteThisChat"),checked:S,onCheck:E}),i&&k&&o.ZP.createElement(fn.Z,{label:y("ReportChat"),checked:b,onCheck:C})))}))),In=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,messageListType:s}=t;const{isLeftColumnShown:o,lastSyncTime:r,shouldSkipHistoryAnimations:l}=e,d=(0,c.Z1)(e,n),{typingStatus:u}=d||{},{chatId:m,messageId:h}=e.audioPlayer,g=m&&h?(0,c.hj)(e,m,h):void 0;let p;if("pinned"===s){const t=(0,c.KB)(e,n);p=null==t?void 0:t.length}else if("scheduled"===s){const t=(0,c.qy)(e,n);p=null==t?void 0:t.length}else if("thread"===s&&a!==i._f){const t=(0,c.tZ)(e,n,a);p=(null==t?void 0:t.messagesCount)||0}const f={typingStatus:u,isLeftColumnShown:o,isRightColumnShown:(0,c.Jf)(e),isSelectModeActive:(0,c.CA)(e),audioMessage:g,chat:d,messagesCount:p,isChatWithSelf:(0,c.FM)(e,n),isChatWithBot:d&&(0,c.xo)(e,d),lastSyncTime:r,shouldSkipHistoryAnimations:l,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing},v=(0,c.Zw)(e,n);if("thread"!==s||!v)return f;if(Object.assign(f,{messagesById:v}),a!==i._f){const t=(0,c.qS)(e,n,a),s=t?(0,c.hj)(e,n,t):void 0,o=s?(0,c.cv)(e,s):void 0;return{...f,pinnedMessageIds:t,canUnpin:!1,topMessageSender:o}}const I=(0,c.KB)(e,n);if(null!=I&&I.length){const t=v[I[0]],{canUnpin:n}=t&&(0,c._k)(e,t,a)||{};return{...f,pinnedMessageIds:I,canUnpin:n}}return f}))((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:y,chat:w,messagesCount:Z,isChatWithSelf:P,isChatWithBot:b,lastSyncTime:C,shouldSkipHistoryAnimations:S,currentTransitionKey:E,connectionState:M,isSyncing:R}=e;const{openChatWithInfo:k,pinMessage:N,focusMessage:T,openChat:B,openPreviousChat:A,loadPinnedMessages:x,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,a.Sv)(),U=(0,We.Z)(),F=(0,o.sO)(!0),[q,$]=(0,o.eJ)(0),D=Array.isArray(l)?l[q]:l,j=u&&D?u[D]:void 0,G=Array.isArray(l)?l.length:l?1:void 0,_=w&&(0,d.U)(U,w).length,H=g?(0,d.OU)(U,g):void 0,{settings:z}=w||{};(0,o.d4)((()=>{n===i._f&&C&&c&&x({chatId:t})}),[t,x,C,n,c]),(0,o.d4)((()=>{$(0)}),[l]),(0,Ft.Z)(t,D,j);const{width:V}=(0,xt.Z)(),W=V<=s.ks,X=h.p7&&v,K=(0,o.sO)(null),Y=(0,o.sO)(!0),J=(0,o.I4)((()=>{k({id:t})}),[k,t]),Q=(0,o.I4)((e=>{N({chatId:t,messageId:e,isUnpin:!0})}),[N,t]),ee=(0,o.I4)((()=>{if(j){T({chatId:j.chatId,threadId:n,messageId:j.id});const e=(0,Ut.Z)(G||1,q+1);$(e)}}),[j,T,n,G,q]),te=(0,o.I4)((()=>{B({id:t,threadId:i._f,type:"pinned"})}),[B,t]),ne=(0,o.I4)((()=>{setTimeout((()=>{F.current=!0}),450)}),[]),ae=(0,o.I4)((e=>{if(F.current){if(F.current=!1,h.wB){const e=document.querySelector(s.Ed);null==e||e.blur()}if(f)return O(),void ne();if(n===i._f&&"thread"===r&&0===E)return h.wB||X?(e.stopPropagation(),B({id:void 0})):L(),void ne();A(),ne()}}),[n,r,E,f,A,X,B,L,O,ne]),se=V>=s.ks&&V<s.jT||V>s.l3&&V<s.ks&&(!_||_>30),oe=se||V>s._m&&V<s.QU,ie=Boolean((null==z?void 0:z.canAddContact)||(null==z?void 0:z.canBlockContact)||(null==z?void 0:z.canReportSpam)),{shouldRender:re,transitionClassNames:ce}=(0,Ue.Z)(ie),le=(0,qt.Z)(ie?z:void 0,!0),{shouldRender:de,transitionClassNames:ue}=(0,Ue.Z)(Boolean(y)),me=(0,qt.Z)(y,!0),{shouldRender:he,transitionClassNames:ge}=(0,Ue.Z)(Boolean(j)),pe=(0,qt.Z)(j,!0),fe=(0,qt.Z)(G,!0),ve=(0,qt.Z)(m,!0),Ie=(0,qt.Z)(H),ye=he&&pe||de&&me;(0,o.d4)((()=>{const e=K.current;if(e)return oe&&ye?void(I||se?(Y.current&&(e.classList.add("tools-stacked","animated"),Y.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),Y.current=!0)):(e.classList.remove("tools-stacked","animated"),void(Y.current=!0))}),[oe,ye,se,I]);const{connectionStatusText:we}=Qe(U,M,R,!0);function Ze(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(nt.Z,{round:!0,size:"smaller",color:"translucent",onClick:ae,ariaLabel:U(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,Ce.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(je,null))}const Pe=Boolean(de&&me);return o.ZP.createElement("div",{className:"MiddleHeader",ref:K},o.ZP.createElement(Ve.Z,{name:S?"none":"slide-fade",activeKey:E},"thread"===r&&n===i._f?o.ZP.createElement(o.ZP.Fragment,null,(W||E>0)&&Ze(X,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:J},(0,d.YC)(t)?o.ZP.createElement($t.Z,{userId:t,typingStatus:p,status:we,withDots:Boolean(we),withFullInfo:b,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(Dt.Z,{chatId:t,typingStatus:p,status:we,withDots:Boolean(we),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,noRtl:!0}))):"thread"===r?o.ZP.createElement(o.ZP.Fragment,null,Ze(),o.ZP.createElement("h3",null,U("CommentsCount",Z,"i"))):"pinned"===r?o.ZP.createElement(o.ZP.Fragment,null,Ze(),o.ZP.createElement("h3",null,U("PinnedMessagesCount",Z,"i"))):"scheduled"===r?o.ZP.createElement(o.ZP.Fragment,null,Ze(),o.ZP.createElement("h3",null,P?U("Reminders"):U("messages",Z,"i"))):void 0),o.ZP.createElement(pn,{hasPinnedOffset:he&&Boolean(pe)||de&&Boolean(me),chatId:t}),he&&pe&&o.ZP.createElement(Qt,{key:t,message:pe,count:fe||0,index:q,customTitle:Ie,className:(0,Ce.Z)(ge,Pe&&"full-width"),onUnpinMessage:ve?Q:void 0,onClick:ee,onAllPinnedClick:te}),re&&o.ZP.createElement(vn,{key:t,chatId:t,settings:le,className:ce}),o.ZP.createElement("div",{className:"header-tools"},Pe&&o.ZP.createElement(hn,{key:(0,d.Tp)(me),message:me,className:ue}),o.ZP.createElement(Gt,{chatId:t,threadId:n,messageListType:r,canExpandActions:!Pe})))})));var yn=n(2645),wn=n(274);function Zn(e){return"albumId"in e}function Pn(e,t){let n,a=[],s={originalDate:e[0].date,datetime:(0,L._F)(1e3*e[0].date),senderGroups:[a]};const o=[s];return e.forEach(((i,r)=>{i.isInAlbum?n?(n.messages.push(i),i.content.text&&(n.mainMessage=i)):n={albumId:i.groupedId,messages:[i],mainMessage:i}:a.push(i);const c=e[r+1];if(!n||c&&c.groupedId&&c.groupedId===n.albumId||(a.push(n),n=void 0),c){const e=(0,L._F)(1e3*c.date);s.datetime!==e?(s={originalDate:c.date,datetime:e,senderGroups:[]},o.push(s),a=[],s.senderGroups.push(a)):(c.id===t||i.senderId!==c.senderId||i.isOutgoing!==c.isOutgoing||(0,d.Lo)(i)||(0,d.Lo)(c)||i.forwardInfo&&c.forwardInfo&&(i.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||i.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||i.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||i.inlineButtons||c.inlineButtons||c.date-i.date>600)&&(a=[],s.senderGroups.push(a))}})),o}var bn=n(386),Cn=n(8957);var Sn=n(7675),En=n(539),Mn=n(2357),Rn=n(998);var kn=n(3657);const Nn=h.wZ?1e3:350,Tn=h.wB?300:500;var Bn=n(7240);function An(e){return"number"==typeof e}function xn(e,t){return e?t?238:175:t?238:100}function Ln(e,t){const n=(0,d.B4)(e),a=(0,d.MF)(e),s=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),i=Boolean((0,d.F$)(e)),{width:r,height:c}=s?(0,_t.Eh)(s,n,a,i,t):(0,_t.GC)(o,n,a,t),l=xn(Boolean((0,d.UD)(e)));let u=1;r<l&&l-r<12&&(u=l/r),c*u<90&&90-c*u<12&&(u=90/c);const m=Math.round(r*u),h=Math.round(c*u);return{width:m,height:h,isSmall:m<l||h<90}}function On(e,t){return e.reduce(((e,t)=>e+t),t)}function Un(e,t,n){return e<t?t:e>n?n:e}function Fn(e){const t={width:0,height:0};return e.forEach((e=>{let{dimensions:n,sides:a}=e;2&a&&(t.width=n.width+n.x),4&a&&(t.height=n.height+n.y)})),t}function qn(e,t,n,a){const s=function(e){return e.map((e=>{const t=Ln(e);return t.width/t.height}))}(a.messages),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(s),i=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(s),r=s.length,c=s.some((e=>e>2)),l=(0,_t.kc)(e,t,!1,n)-(t?2.5:0)*_t.Gw;let d;const u={ratios:s,proportions:o,averageRatio:i,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return d=r>=5||c?function(e){let{ratios:t,averageRatio:n,maxWidth:a,minWidth:s,spacing:o,maxHeight:i=4*a/3}=e;const r=function(e,t){return e.map((e=>t>1.1?Un(e,1,2.75):Un(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=On(r.slice(e,e+t),0);return(a-(t-1)*o)/n})(n,e)),n+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==c;++e){const t=c-e;e<=3&&t<=3&&u([e,t])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t){const a=c-e-t;e<=3&&t<=(n<.85?4:3)&&a<=3&&u([e,t,a])}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 a=c-e-t-n;e<=3&&t<=3&&n<=3&&a<=4&&u([e,t,n,a])}let m,h=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:n}=d[e],a=n.length,r=On(t,0)+o*(a-1),c=Math.min(...t)<s?1.5:1,l=(()=>{for(let e=1;e!==a;++e)if(n[e-1]>n[e])return 1.5;return 1})(),u=Math.abs(r-i)*c*l;(!m||u<h)&&(m=d[e],h=u)}const g=m.lineCounts,p=m.heights,f=g.length;let v=0,I=0;for(let e=0;e!==f;++e){const t=g[e],n=p[e],s=Math.round(n);let i=0;for(let c=0;c!==t;++c){const d=0|(0===e?1:0)|(e===f-1?4:0)|(0===c?8:0)|(c===t-1?2:0),u=r[v],m=c===t-1?a-i:Math.round(u*n);l[v]={dimensions:{x:i,y:I,width:m,height:s},sides:d},i+=m+o,++v}I+=s+o}return l}(u):2===r?function(e){const{ratios:t,proportions:n,averageRatio:a}=e;return"ww"===n&&a>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:n,spacing:a,maxHeight:s}=e,o=Math.round(Math.min(n/t[0],Math.min(n/t[1],(s-a)/2)));return[{dimensions:{x:0,y:0,width:n,height:o},sides:11},{dimensions:{x:0,y:o+a,width:n,height:o},sides:14}]}(e):"ww"===n||"qq"===n?function(e){const{ratios:t,maxWidth:n,spacing:a,maxHeight:s}=e,o=(n-a)/2,i=Math.round(Math.min(o/t[0],Math.min(o/t[1],s)));return[{dimensions:{x:0,y:0,width:o,height:i},sides:13},{dimensions:{x:o+a,y:0,width:o,height:i},sides:7}]}(e):function(e){const{ratios:t,minWidth:n,maxWidth:a,spacing:s,maxHeight:o}=e,i=Math.round(1.5*n),r=Math.min(Math.round(Math.max(.4*(a-s),(a-s)/t[0]/(1/t[0]+1/t[1]))),a-s-i),c=a-r-s,l=Math.min(o,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:l},sides:13},{dimensions:{x:c+s,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:a,maxWidth:s,minWidth:o}=e,i=t,r=Math.round(Math.min((t-n)/2,a[1]*(s-n)/(a[2]+a[1]))),c=i-r-n,l=Math.max(o,Math.round(Math.min((s-n)/2,Math.min(r*a[2],c*a[1])))),d=Math.min(Math.round(i*a[0]),s-n-l);return[{dimensions:{x:0,y:0,width:d,height:i},sides:13},{dimensions:{x:d+n,y:0,width:l,height:c},sides:3},{dimensions:{x:d+n,y:c+n,width:l,height:r},sides:6}]}(e):function(e){const{maxWidth:t,ratios:n,maxHeight:a,spacing:s}=e,o=t,i=Math.round(Math.min(o/n[0],.66*(a-s))),r=(t-s)/2,c=Math.min(a-i-s,Math.round(Math.min(r/n[1],r/n[2])));return[{dimensions:{x:0,y:0,width:o,height:i},sides:11},{dimensions:{x:0,y:i+s,width:r,height:c},sides:12},{dimensions:{x:r+s,y:i+s,width:o-r-s,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function(e){let{maxWidth:t,ratios:n,spacing:a,maxHeight:s,minWidth:o}=e;const i=t,r=Math.round(Math.min(i/n[0],.66*(s-a))),c=Math.round((t-2*a)/(n[1]+n[2]+n[3])),l=Math.max(o,Math.round(Math.min(.4*(t-2*a),c*n[1]))),d=Math.round(Math.max(Math.max(o,.33*(t-2*a)),c*n[3])),u=i-l-d-2*a,m=Math.min(s-r-a,c);return[{dimensions:{x:0,y:0,width:i,height:r},sides:11},{dimensions:{x:0,y:r+a,width:l,height:m},sides:12},{dimensions:{x:l+a,y:r+a,width:u,height:m},sides:4},{dimensions:{x:l+a+u+a,y:r+a,width:d,height:m},sides:6}]}(e):function(e){let{maxHeight:t,ratios:n,maxWidth:a,spacing:s,minWidth:o}=e;const i=t,r=Math.round(Math.min(i*n[0],.6*(a-s))),c=Math.round((t-2*s)/(1/n[1]+1/n[2]+1/n[3])),l=Math.round(c/n[1]),d=Math.round(c/n[2]),u=i-l-d-2*s,m=Math.max(o,Math.min(a-r-s,c));return[{dimensions:{x:0,y:0,width:r,height:i},sides:13},{dimensions:{x:r+s,y:0,width:m,height:l},sides:3},{dimensions:{x:r+s,y:l+s,width:m,height:d},sides:2},{dimensions:{x:r+s,y:l+d+2*s,width:m,height:u},sides:6}]}(e)}(u),{layout:d,containerStyle:Fn(d)}}let $n;function Dn(e){return $n||($n=document.createElement("span"),$n.style.font=h.cj?'400 12px system-ui, -apple-system, BlinkMacSystemFont, "Roboto", "Apple Color Emoji", "Helvetica Neue", sans-serif':'400 12px "Roboto", -apple-system, "Apple Color Emoji", BlinkMacSystemFont, "Helvetica Neue", sans-serif',$n.style.whiteSpace="nowrap",$n.style.position="absolute",$n.style.left="-999px",$n.style.opacity=".01",document.body.appendChild($n)),$n.innerHTML=e,$n.offsetWidth}function jn(e,t,n,a,s,i){(0,o.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,En.Z)(t,e.current,s?"end":"centerOrTop",20,void 0!==a?1e3:void 0,a,void 0,i)}}),[e,t,n,a,s,i])}const Gn=3*_t.Gw,_n=Number(_t.Gw),Hn="data-is-document-group-hover";function zn(e,t,n,s,i,r,c,l,d,u,m,g,p,f){const{setReplyingToId:v,sendDefaultReaction:I}=(0,a.Sv)(),[y,w,Z]=(0,ze.Z)(),[P,b,C]=(0,ze.Z)(),S=(0,o.sO)();return(0,o.d4)((()=>{if(!h.$b||i||!r||m)return;let e;return(0,dt.sf)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,n)=>n===dt.eM.Left&&(e||(e=Date.now()),b(),!0),onRelease:()=>{e&&(v({messageId:n}),setTimeout(C,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,i,n,v,b,C,r,m]),{handleMouseDown:i?void 0:function(e){(0,bn.q)(e),d(e)},handleClick:function(t){if(i)e(t);else if(h.$b)return S.current?(clearInterval(S.current),S.current=void 0,void function(e){const{pageX:t,pageY:a}=e;I({chatId:u,messageId:n,x:t,y:a})}(t)):void(S.current=setTimeout((()=>{S.current=void 0,function(e){if(h.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;re.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:i?c?Me.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]")||m)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:i?void 0:function(){h.$b||v({messageId:n})},handleContentDoubleClick:h.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:function(e){const t=g.current;if(!t)return;const{clientX:n,clientY:a}=e,{x:s,width:o,y:i,height:r}=t.getBoundingClientRect(),c=Math.abs(p?n-s:s+o-n)<Gn,l=Math.abs(i+r-a)<_n;c&&l?w():Z()},handleSendQuickReaction:function(e){const{x:t,y:a}=e.currentTarget.getBoundingClientRect();I({chatId:u,messageId:n,x:t,y:a})},handleMouseLeave:function(e){Z(),f&&function(e){const t=Wn(e.currentTarget);t&&t.removeAttribute(Hn)}(e)},isSwiped:P,isQuickReactionVisible:y,handleDocumentGroupMouseEnter:Vn}}function Vn(e){const t=Wn(e.currentTarget);t&&t.setAttribute(Hn,"")}function Wn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var Xn=n(8005);const Kn=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"ContextMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),Yn=(0,o.X$)((0,a.c$)(((e,t)=>{let{message:n}=t;const{byId:a}=e.users,s=n.senderId,{targetUserIds:o,targetChatId:i}=n.content.action||{},r=n.replyToMessageId,l=r?(0,c.hj)(e,n.chatId,r):void 0,u=(0,c._X)(e,n),{direction:m,noHighlight:h}=u&&e.focusedMessage||{},g=(0,c.Z1)(e,n.chatId),p=g&&((0,d.eA)(g)||s===n.chatId);return{usersById:a,senderUser:!p&&s?(0,c.dy)(e,s):void 0,senderChat:p?g:void 0,targetChatId:i,targetUserIds:o,targetMessage:l,isFocused:u,...u&&{focusDirection:m,noFocusHighlight:h}}}))((e=>{let{message:t,observeIntersection:n,isEmbedded:a,appearanceOrder:s=0,isLastInList:i,usersById:r,senderUser:c,senderChat:l,targetUserIds:u,targetMessage:m,targetChatId:h,isFocused:g,focusDirection:p,noFocusHighlight:f}=e;const v=(0,o.sO)(null);(0,kn._N)(v,n),(0,Ft.Z)(t.chatId,t.replyToMessageId,m),jn(v,t.chatId,g,p,f);const I=(0,We.Z)(),y=s<=0,[w,Z]=(0,ze.Z)(y);(0,o.d4)((()=>{y||setTimeout(Z,10*s)}),[s,Z,y]);const{transitionClassNames:P}=(0,Ue.Z)(w,void 0,y,!1),b=(0,o.Ye)((()=>u?u.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[u,r]),C=(0,Xn.D)(I,t,c,l,b,m,h,{asTextWithSpoilers:a}),{isContextMenuOpen:S,contextMenuPosition:E,handleBeforeContextMenu:M,handleContextMenu:R,handleContextMenuClose:k,handleContextMenuHide:N}=(0,Bn.Z)(v),T=void 0!==E;if(a)return o.ZP.createElement("span",{className:"embedded-action-message"},C);const B=(0,Ce.Z)("ActionMessage message-list-item",g&&!f&&"focused",T&&"has-menu-open",i&&"last-in-list",P);return o.ZP.createElement("div",{ref:v,id:(0,d.d0)(t.id),className:B,"data-message-id":t.id,onMouseDown:e=>{(0,bn.q)(e),M(e)},onContextMenu:R},o.ZP.createElement("span",null,C),E&&o.ZP.createElement(Kn,{isOpen:S,anchor:E,message:t,messageListType:"thread",onClose:k,onCloseAnimationEnd:N}))}))),Jn=e=>{var t;let{className:n,message:a,sender:s,title:i,customText:r,isProtected:c,observeIntersection:l,onClick:u}=e;const m=(0,o.sO)(null),h=(0,kn.Op)(m,l),g=(0,zt.Z)(a&&(0,d.Ti)(a,"pictogram"),!h),p=Wt(a),f=Boolean(a&&(0,d.Y5)(a)),v=(0,We.Z)(),I=s?(0,d.OU)(v,s):null==a||null===(t=a.forwardInfo)||void 0===t?void 0:t.hiddenUserName;return o.ZP.createElement("div",{ref:m,className:(0,Ce.Z)("EmbeddedMessage",n),onClick:a?u:void 0},p&&function(e,t,n,a){const{width:s,height:i}=(0,_t.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{src:t||e,width:s,height:i,alt:"",className:n?"round":"",draggable:!a}),a&&o.ZP.createElement("span",{className:"protector"}))}(p,g,f,c),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},a?(0,d.Lo)(a)?o.ZP.createElement(Yn,{message:a,isEmbedded:!0}):(0,Ht.e)(v,a,Boolean(p)):r||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,un.Z)(I||i||" "))))};var Qn=n(2535),ea=n(4752),ta=n(8018),na=n(8198),aa=n(7799);const sa=(0,o.X$)((e=>{var t,n;let{reaction:s,activeReaction:r,isInMeta:c,availableReactions:l}=e;const{stopActiveReaction:d}=(0,a.Sv)(),u=null==l?void 0:l.find((e=>e.reaction===s)),m=null==u||null===(t=u.centerIcon)||void 0===t?void 0:t.id,h=null==u||null===(n=u.aroundAnimation)||void 0===n?void 0:n.id,g=(0,zt.Z)(`sticker${m}`,!m,i.IU.Lottie),p=(0,zt.Z)(`sticker${h}`,!h,i.IU.Lottie),f=Boolean((null==r?void 0:r.reaction)===s&&g&&p),{shouldRender:v,transitionClassNames:I}=(0,Ue.Z)(f,void 0,!0,"slow"),y=(0,o.I4)((()=>{d({messageId:null==r?void 0:r.messageId,reaction:s})}),[null==r?void 0:r.messageId,s,d]),[w,Z,P]=(0,ze.Z)(),b=!f||!w,C=(0,Ce.Z)("ReactionAnimatedEmoji",c&&"in-meta",v&&"is-animating");return o.ZP.createElement("div",{className:C},b&&o.ZP.createElement(na.Z,{reaction:s}),v&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(aa.Z,{key:m,id:`reaction_emoji_${m}`,className:I,size:30,animationData:g,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:Z,onEnded:P}),o.ZP.createElement(aa.Z,{key:h,id:`reaction_effect_${h}`,className:(0,Ce.Z)("effect",I),size:100,animationData:p,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:y})))})),oa=(0,o.X$)((e=>{var t;let{message:n,outgoingStatus:a,signature:s,onClick:i,withReactions:r,activeReaction:c,withReactionOffset:l,availableReactions:d,reactionMessage:u}=e;const m=(0,We.Z)(),[h,g]=(0,ze.Z)(),p=r&&(null==u||null===(t=u.reactions)||void 0===t?void 0:t.results.filter((e=>e.count>0))),f=(0,o.Ye)((()=>{if(!h)return;const e=(0,L.SA)(1e3*n.date,m.code),t=n.isEdited&&(0,L.SA)(1e3*n.editDate,m.code),a=n.forwardInfo&&(0,L.SA)(1e3*n.forwardInfo.date,m.code);let s=e;return t&&(s+="\n",s+=m("lng_edited_date").replace("{date}",t)),a&&(s+="\n",s+=m("lng_forwarded_date").replace("{date}",a)),s}),[h,m,n]);return o.ZP.createElement("span",{className:(0,Ce.Z)("MessageMeta",l&&"reactions-offset"),dir:m.isRtl?"rtl":"ltr",onClick:i},p&&p.map((e=>o.ZP.createElement(sa,{activeReaction:c,reaction:e.reaction,isInMeta:!0,availableReactions:d}))),Boolean(n.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,qe.bi)(n.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,un.Z)(s)),o.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:g},n.isEdited&&`${m("EditedMessage")} `,(0,L.mr)(m,1e3*n.date)),a&&o.ZP.createElement(ta.Z,{status:a}))}));var ia=n(692),ra=n(4753);const ca=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:a,shouldLoop:i,lastSyncTime:r}=e;const c=(0,o.sO)(null),[l,u,m]=(0,ze.Z)(),g=t.content.sticker,{isLottie:p,stickerSetId:f,isVideo:v}=g,I=h.Hh,y=f===s.$E,w=(0,kn.Op)(c,n),Z=(0,kn.Op)(c,a),P=g.isPreloadedGlobally?`sticker${g.id}`:(0,d.Ti)(t,"inline"),b=v&&!I&&(g.isPreloadedGlobally?`sticker${g.id}?size=m`:(0,d.Ti)(t,"pictogram")),C=(0,zt.Z)(b),S=Wt(t),E=C||S,M=(0,zt.Z)(P,!w,(0,d.kG)(t,"inline"),r),R=Boolean(M),[k,N]=(0,ze.Z)(R),T=p?k:R,B=(0,ia.Z)(T),{width:A,height:x}=(0,_t.Wr)(g),L=(0,Ce.Z)("thumbnail",!S&&"empty"),O=(0,Ce.Z)("Sticker media-inner",y&&"inactive");return(0,o.d4)((()=>{if(!v||!c.current)return;const e=c.current.querySelector("video");e&&(Z?(0,ra.Z)(e):e.pause())}),[v,Z]),o.ZP.createElement("div",{ref:c,className:O,onClick:y?void 0:u},(!T||v&&!I)&&o.ZP.createElement("img",{src:E,width:A,height:x,alt:"",className:L}),!p&&!v&&o.ZP.createElement("img",{src:M,width:A,height:x,alt:"",className:(0,Ce.Z)("full-media",B)}),v&&I&&T&&o.ZP.createElement("video",{src:M,width:A,height:x,autoPlay:Z,playsInline:!0,loop:i,muted:!0}),p&&R&&o.ZP.createElement(aa.Z,{key:P,className:(0,Ce.Z)("full-media",B),id:P,animationData:M,size:A,play:Z,noLoop:!i,onLoad:N}),o.ZP.createElement(Fe.Z,{isOpen:l,fromSticker:g,onClose:m}))};var la=n(7854),da=n(2566),ua=n(5866);function ma(e,t){return(0,ua.Z)((0,d.DH)(e),Boolean(t),h.wB&&!h.vX)}const ha={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function ga(e,t,n,a,s){return a?Promise.resolve(ha[s||"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 a=document.createElement("canvas"),s=a.getContext("2d");a.width=n.width,a.height=n.height,s.drawImage(n,0,0,n.width,n.height);const o=t?n.width-1:0,i=n.height-1;return`rgba(${Array.from(s.getImageData(o,i,1,1).data).join(",")})`}(e,t)}var pa=n(9196);const fa=e=>{let{id:t,message:n,observeIntersection:a,noAvatars:i,canAutoLoad:r,isInSelectMode:c,isSelected:l,uploadProgress:u,size:m="inline",dimensions:h,nonInteractive:g,shouldAffectAppendix:p,isDownloading:f,isProtected:v,theme:I,onClick:y,onCancelUpload:w}=e;const Z=(0,o.sO)(null),P=((0,d.O$)(n)||(0,d.F$)(n)).blobUrl,b=(0,kn.Op)(Z,a),[C,S]=(0,o.eJ)(r),E=C&&b,{mediaData:M,loadProgress:R}=(0,da.Z)((0,d.Ti)(n,m),!E),k=P||M,N=ma(n,k),{loadProgress:T}=(0,da.Z)((0,d.Ti)(n,"download"),!f),{isUploading:B,isTransferring:A,transferProgress:x}=(0,d.Sc)(n,u||(f?T:R),E&&!k),L=!1===(0,Ot.Z)(C),O=(0,ia.Z)(k),{shouldRender:U,transitionClassNames:F}=(0,Ue.Z)(A,void 0,L,"slow"),{shouldRender:q,transitionClassNames:$}=(0,Ue.Z)(!k&&!C),D=(0,o.I4)((()=>{B?w&&w(n):k?y&&y(n.id):S((e=>!e))}),[k,B,n,w,y]),j=(0,d.B4)(n);(0,o.bt)((()=>{if(!p)return;const e=Z.current.closest(".message-content");k?ga(k,j,0,l,I).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(s.s2,"")})):e.classList.add("has-appendix-thumb")}),[k,j,p,c,l,I]);const{width:G,height:_,isSmall:H}=h||Ln(n,i),z=(0,Ce.Z)("media-inner",!B&&!g&&"interactive",H&&"small-image",G===_&&"square-image"),V=h?`width: ${G}px; height: ${_}px; left: ${h.x}px; top: ${h.y}px;`:"";return o.ZP.createElement("div",{id:t,ref:Z,className:z,style:V,onClick:B?void 0:D},o.ZP.createElement("canvas",{ref:N,className:"thumbnail",style:`width: ${G}px; height: ${_}px`}),o.ZP.createElement("img",{src:k,className:`full-media ${O}`,width:G,height:_,alt:"",draggable:!v}),v&&o.ZP.createElement("span",{className:"protector"}),U&&!q&&o.ZP.createElement("div",{className:`media-loading ${F}`},o.ZP.createElement(pa.Z,{progress:x,onClick:B?D:void 0})),q&&o.ZP.createElement("i",{className:(0,Ce.Z)("icon-download",$)}),A&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*x),"%"))};var va=n(2019),Ia=n(6898);function ya(e,t){var n;const a=(0,o.sO)(null===(n=e.current)||void 0===n?void 0:n.paused),s=(0,o.sO)();s.current=t;const i=(0,o.I4)((()=>{e.current&&(a.current=!e.current.paused,a.current&&e.current.pause())}),[e]),r=(0,o.I4)((()=>{e.current&&a.current&&s.current&&document.body.contains(e.current)&&(0,ra.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,E.T2)(r)}),[r]);(0,Re.Z)(i,c),(0,be.ZP)(i,r)}function wa(){return wa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},wa.apply(this,arguments)}const Za=e=>{var t;let{id:n,message:s,observeIntersection:r,noAvatars:c,canAutoLoad:l,canAutoPlay:u,uploadProgress:m,lastSyncTime:h,dimensions:g,onClick:p,onCancelUpload:f,isDownloading:v,isProtected:I}=e;const y=(0,o.sO)(null),w=(0,o.sO)(null),Z=(0,d.b7)(s)||(0,d.Cg)(s),P=Z.blobUrl,b=(0,kn.Op)(y,r),[C,S]=(0,o.eJ)(l),E=Boolean(C&&b&&h),[M,R]=(0,o.eJ)(u),k=(0,zt.Z)((0,d.Ti)(s,"pictogram"),!(b&&h),(0,d.kG)(s,"pictogram"),h),N=(0,ia.Z)(k),{mediaData:T,loadProgress:B}=(0,da.Z)((0,d.Ti)(s,"inline"),!E,(0,d.kG)(s,"inline"),h),A=P||T,x=Boolean(b&&A),O=ma(s,k),{loadProgress:U}=(0,da.Z)((0,d.Ti)(s,"download"),!v,i.IU.BlobUrl,h),{isBuffered:F,bufferingHandlers:q}=(0,va.Z)(!l),{isUploading:$,isTransferring:D,transferProgress:j}=(0,d.Sc)(s,m||(v?U:B),E&&!F||v),G=!1===(0,Ot.Z)(C),{shouldRender:_,transitionClassNames:H}=(0,Ue.Z)(D,void 0,G),{shouldRender:z,transitionClassNames:V}=(0,Ue.Z)(C&&!M&&!_),[W,X]=(0,o.eJ)(0),K=(0,o.I4)((e=>{X(Math.max(0,e.currentTarget.currentTime-1))}),[]),Y=(null===(t=w.current)||void 0===t?void 0:t.duration)||Z.duration||0,J=(0,d.B4)(s),Q=(0,d.MF)(s),{width:ee,height:te}=g||(0,_t.GC)(Z,J,Q,c);ya(w,x),(0,Ia.Z)(w,[x]);const ne=(0,o.I4)((()=>{$?f&&f(s):v?(0,a.Sv)().cancelMessageMediaDownload({message:s}):A?A&&!M?(R(!0),w.current.play()):p&&p(s.id):S((e=>!e))}),[$,v,A,M,p,f,s]),ae=(0,Ce.Z)("media-inner dark",!$&&"interactive"),se=g?`width: ${ee}px; height: ${te}px; left: ${g.x}px; top: ${g.y}px;`:"";return o.ZP.createElement("div",{ref:y,id:n,className:ae,style:se,onClick:$?void 0:ne},o.ZP.createElement("canvas",{ref:O,className:"thumbnail",style:`width: ${ee}px; height: ${te}px;`}),o.ZP.createElement("img",{src:k,className:(0,Ce.Z)("thumbnail",N),style:`width: ${ee}px; height: ${te}px;`,alt:"",draggable:!I}),x&&o.ZP.createElement("video",wa({ref:w,className:"full-media",width:ee,height:te,autoPlay:M,muted:!0,loop:!0,playsInline:!0},q,{draggable:!I,onTimeUpdate:K}),o.ZP.createElement("source",{src:A})),I&&o.ZP.createElement("span",{className:"protector"}),z&&o.ZP.createElement("i",{className:(0,Ce.Z)("icon-large-play",V)}),_&&o.ZP.createElement("div",{className:(0,Ce.Z)("media-loading",H)},o.ZP.createElement(pa.Z,{progress:j,onClick:ne})),!C&&o.ZP.createElement("i",{className:"icon-download"}),D?o.ZP.createElement("span",{className:"message-transfer-progress"},$||v?`${Math.round(100*j)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},Z.isGif?"GIF":(0,L.k9)(Math.max(Y-W,0))))};var Pa=n(6272);const ba=(0,a.c$)(((e,t)=>{let{contact:n}=t;const{countryList:{phoneCodes:a}}=e;return{user:(0,c.dy)(e,n.userId),phoneCodeList:a}}))((e=>{let{contact:t,user:n,phoneCodeList:s}=e;const{openChat:i}=(0,a.Sv)(),{firstName:r,lastName:c,phoneNumber:l,userId:d}=t,u=(0,o.I4)((()=>{i({id:d})}),[i,d]);return o.ZP.createElement("div",{className:(0,Ce.Z)("Contact",Boolean(d)&&"interactive"),onClick:d?u:void 0},o.ZP.createElement(gn.Z,{size:"large",user:n,text:r||c}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},r," ",c),o.ZP.createElement("div",{className:"contact-phone"},(0,Pa.WZ)(s,l))))}));var Ca=n(8974),Sa=n(1218),Ea=n(4434),Ma=n(6937);function Ra(e,t){return t>0?(e/t*100).toFixed():0}const ka=e=>{let{answer:t,voteResults:n,totalVoters:a,maxVotersCount:s,correctResults:i,shouldAnimate:r}=e;const c=n&&n.find((e=>e.option===t.option)),l=0===i.length||-1!==i.indexOf(t.option),d=i.length>0&&l||(null==c?void 0:c.isChosen),u=c?Ra(c.votersCount,a||0):0,[m,h]=(0,o.eJ)(r?0:u),g=(0,o.sO)(null),p=c?Ra(c.votersCount,s||0):0,f=m<u;if((0,o.d4)((()=>{r&&h(u)}),[r,u]),(0,o.d4)((()=>{const e=g.current;if(e&&r){const t=e.firstElementChild,n=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",n):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${n}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[f,r]),!n||!c)return;const v=`width: ${p}%; transform:scaleX(${f?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",d&&o.ZP.createElement("span",{className:(0,Ce.Z)("poll-option-chosen",!l&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:l?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,un.Z)(t.text)),o.ZP.createElement("div",{className:(0,Ce.Z)("poll-option-answer",d&&!l&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:g}),o.ZP.createElement("div",{className:"poll-option-line",style:v}))))},Na=(0,o.X$)((0,a.c$)(((e,t)=>{let{poll:n}=t;const{recentVoterIds:a}=n.results,{serverTimeOffset:s,users:{byId:o}}=e;return a&&0!==a.length?{recentVoterIds:a,usersById:o,serverTimeOffset:s}:{}}))((e=>{let{message:t,poll:n,recentVoterIds:s,usersById:i,onSendVote:r,serverTimeOffset:c}=e;const{loadMessage:l,openPollResults:d}=(0,a.Sv)(),{id:u,chatId:m}=t,{summary:h,results:g}=n,[p,f]=(0,o.eJ)(!1),[v,I]=(0,o.eJ)([]),[y,w]=(0,o.eJ)(!1),[Z,P]=(0,o.eJ)(!1),[b,C]=(0,o.eJ)(!h.closed&&h.closeDate&&h.closeDate>0?Math.min(h.closeDate-Math.floor(Date.now()/1e3)+c,h.closePeriod):0),S=(0,o.sO)(null),{results:E,totalVoters:M}=g,R=E&&E.some((e=>e.isChosen)),k=!h.closed&&!R,N=!k&&h.isPublic&&Number(g.totalVoters)>0,T=k&&h.multipleChoice,B=E?Math.max(...E.map((e=>e.votersCount))):M,A=E?E.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],x=h.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(h.quiz&&h.closePeriod&&b<=0)})));(0,o.d4)((()=>{p&&n.results.results&&n.results.results.some((e=>e.isChosen))&&f(!1)}),[p,n.results.results]),(0,o.d4)((()=>{b>0&&setTimeout((()=>C(b-1)),1e3);const e=S.current;if(e){const t=12*Math.PI,n=e.lastElementChild,a=e.firstElementChild;if(b<=5&&e.classList.add("hurry-up"),n&&a){const e=(h.closePeriod-b)/h.closePeriod*t;a.textContent=(0,L.k9)(b),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,L.k9)(b)}</span>\n <svg width="16px" height="16px">\n <circle cx="8" cy="8" r="6" class="poll-countdown-progress" transform="rotate(-90, 8, 8)"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="0"\n />\n </svg>`}}),[b,h.closePeriod]),(0,o.d4)((()=>{h.quiz&&(b<=0||R&&!h.closed)&&l({chatId:m,messageId:u})}),[m,b,R,l,u,h.closed,h.quiz]),(0,o.d4)((()=>{let e;return h.quiz&&!h.closed&&h.closePeriod&&h.closePeriod>0&&(e=window.setTimeout((()=>{l({chatId:m,messageId:u})}),1e3*h.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[k,m,l,u,h.closePeriod,h.closed,h.quiz]);const O=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const n=i[t];return n&&e.push(n),e}),[]):[]),[i,s]),U=(0,o.I4)((e=>{I([e]),f(!0),P(!0),r([e])}),[r]),F=(0,o.I4)((e=>{I(e)}),[]),q=(0,o.I4)((()=>{f(!0),P(!0),r(v)}),[r,v]),$=(0,o.I4)((()=>{d({chatId:m,messageId:u})}),[m,u,d]),D=(0,o.I4)((()=>{w(!0)}),[]),j=(0,o.I4)((()=>{w(!1),P(!1)}),[]);(0,o.d4)((()=>{Z&&R&&h.quiz&&g.results&&n.results.solution&&(g.results.find((e=>e.isChosen&&e.isCorrect))||w(!0))}),[R,Z,g.results,h.quiz,n.results.solution]);const G=(0,We.Z)();return o.ZP.createElement("div",{className:"Poll",dir:G.isRtl?"auto":"ltr"},y&&n.results.solution&&o.ZP.createElement(Ma.Z,{message:(0,Ca.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:j,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,un.Z)(h.question,["emoji","br"])),o.ZP.createElement("div",{className:"poll-type"},G(function(e){return void 0===e.isPublic?" ":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.closed?"FinalResults":e.isPublic?"PublicPoll":"AnonymousPoll"}(h)),O.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},O.map((e=>o.ZP.createElement(gn.Z,{size:"micro",user:e})))),b>0&&k&&o.ZP.createElement("div",{ref:S,className:"poll-countdown"}),h.quiz&&n.results.solution&&!k&&o.ZP.createElement(nt.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:y,onClick:D,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),k&&o.ZP.createElement("div",{className:"poll-answers"},T?o.ZP.createElement(Sa.Z,{options:x,onChange:F,disabled:t.isScheduled||p,loadingOptions:p?v:void 0,round:!0}):o.ZP.createElement(Ea.Z,{name:`poll-${u}`,options:x,onChange:U,disabled:t.isScheduled||p,loadingOption:p?v[0]:void 0})),!k&&o.ZP.createElement("div",{className:"poll-results"},h.answers.map((function(e){return o.ZP.createElement(ka,{key:e.option,shouldAnimate:Z,answer:e,voteResults:E,totalVoters:M,maxVotersCount:B,correctResults:A})}))),!N&&!T&&o.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,n){return n?e(t?"Answer":"Vote",n,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(G,h.quiz,g.totalVoters)),T&&o.ZP.createElement(nt.Z,{isText:!0,disabled:0===v.length,size:"tiny",onClick:q},G("PollSubmitVotes")),N&&o.ZP.createElement(nt.Z,{isText:!0,size:"tiny",onClick:$},G("PollViewResults")))})));var Ta=n(8035),Ba=n(88);const Aa=(0,o.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,inPreview:r,lastSyncTime:c,isDownloading:l=!1,isProtected:u,theme:m,onMediaClick:h,onCancelMediaTransfer:g}=e;const p=(0,d.s1)(t);let f=!1;if(null!=p&&p.photo&&!p.video){const{width:e,height:n}=Ln(t);f=e===n}const v=(0,o.I4)((()=>{h()}),[h]);if(!p)return;const{siteName:I,url:y,displayUrl:w,title:Z,description:P,photo:b,video:C}=p,S=(b||C)&&h&&!f,E=(0,Ta.Z)(P,170),M=(0,Ce.Z)("WebPage",f&&"with-square-photo",!b&&!C&&!r&&"without-media",C&&"with-video");return o.ZP.createElement("div",{className:M,"data-initial":(I||w)[0],dir:"auto"},b&&!C&&o.ZP.createElement(fa,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,size:f?"pictogram":"inline",nonInteractive:!S,onClick:S?v:void 0,onCancelUpload:g,isDownloading:l,isProtected:u,theme:m}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Ba.Z,{className:"site-name",url:y,text:I||w}),!r&&Z&&o.ZP.createElement("p",{className:"site-title"},(0,un.Z)(Z)),E&&o.ZP.createElement("p",{className:"site-description"},(0,un.Z)(E,["emoji","br"]))),!r&&C&&o.ZP.createElement(Za,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,lastSyncTime:c,onClick:S?v:void 0,onCancelUpload:g,isDownloading:l,isProtected:u}))}));var xa=n(9937);const La=(0,o.X$)((e=>{let{message:t,shouldAffectAppendix:n,isInSelectMode:a,isSelected:i,theme:r}=e;const c=(0,o.sO)(null),l=(0,We.Z)(),u=(0,d.eO)(t),{title:m,text:h,amount:g,currency:p,isTest:f,photoUrl:v,photoWidth:I,photoHeight:y}=u;(0,o.bt)((()=>{if(!n)return;const e=c.current.closest(".message-content");v&&ga(v,!1,0,i,r).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(s.s2,"")}))}),[n,v,a,i,r]);const w=y&&I?`aspect-ratio: ${I/y};`:void 0;return o.ZP.createElement("div",{ref:c,className:"Invoice"},m&&o.ZP.createElement("p",{className:"title"},(0,un.Z)(m)),h&&o.ZP.createElement("p",null,(0,un.Z)(h,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(v?"has-image":"")},v&&o.ZP.createElement("img",{className:"invoice-image",src:v,alt:"",style:w,crossOrigin:"anonymous"}),o.ZP.createElement("p",{className:"description-text"},(0,xa.x)(g,p,l.code),f&&o.ZP.createElement("span",null,l("PaymentTestInvoice")))))}));var Oa=n(8183);const Ua=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"})),Fa=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"],qa=e=>{let{variant:t="rectangular",animation:n="wave",width:a,height:s,className:i}=e;const r=(0,Ce.Z)("Skeleton",t,n,i),c=(a?`width: ${a}px;`:"")+(s?`height: ${s}px;`:"");return o.ZP.createElement("div",{className:r,style:c})},$a=n.p+"map-pin.7b3c3e60ee24795e4bd2..svg",Da=1e-4,ja={width:400,height:300,zoom:16,scale:2},Ga={__html:'<svg version="1.1" class="round-pin" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve"><g><circle cx="32" cy="32" r="24.5"/><path d="M32,8c13.23,0,24,10.77,24,24S45.23,56,32,56S8,45.23,8,32S18.77,8,32,8 M32,7C18.19,7,7,18.19,7,32s11.19,25,25,25 s25-11.19,25-25S45.81,7,32,7L32,7z"/></g><g><polygon points="29.38,57.67 27.4,56.08 30.42,54.42 32,51.54 33.58,54.42 36.6,56.08 34.69,57.61 32,60.73"/><path d="M32,52.58l1.07,1.95l0.14,0.26l0.26,0.14l2.24,1.22l-1.33,1.06l-0.07,0.06l-0.06,0.07L32,59.96l-2.24-2.61l-0.06-0.07 l-0.07-0.06l-1.33-1.06l2.24-1.22l0.26-0.14l0.14-0.26L32,52.58 M32,50.5l-1.94,3.56L26.5,56l2.5,2l3,3.5l3-3.5l2.5-2l-3.56-1.94 L32,50.5L32,50.5z"/></g></svg>'},_a=(0,o.X$)((e=>{let{message:t,peer:n,lastSyncTime:a,isInSelectMode:i,isSelected:r,theme:c,serverTimeOffset:l}=e;const u=(0,o.sO)(null),m=(0,o.sO)(null),h=(0,We.Z)(),g=(0,Le.Z)(),f=(0,d.nf)(t),{type:v,geo:I}=f,y=(0,p.b)(l),w=(0,d.$R)(t,y),Z="geoLive"!==v||w?void 0:t.date+f.period-y,[P,b]=(0,o.eJ)(I),C="venue"===v||"geoLive"===v&&!w,{width:S,height:E,zoom:M,scale:R}=ja,k=Boolean(a)&&(0,d.k6)(P,S,E,M,R),N=(0,zt.Z)(k),T=(0,Ot.Z)(N),B=N||T,A=n&&(0,d.YC)(n.id),x=n&&A?n:void 0,O=n&&!A?n:void 0,U=(0,d.B4)(t),F=(0,o.Ye)((()=>{if("geoLive"!==v||!P.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=P;return t/function(e,t){return 156543.03392*Math.cos(e*(Math.PI/180))/2**t}(e,M)}),[v,P,M]),q=(0,o.I4)((e=>{if("geoLive"!==v)return;const n=24*Math.PI,a=e.lastElementChild,s=e.firstElementChild,o=t.date+f.period-(0,p.b)(l),i=(1-o/f.period)*n,r=(0,L.mB)(h,1e3*o);a&&s?(s.textContent=r,a.firstElementChild.setAttribute("stroke-dashoffset",`-${i}`)):e.innerHTML=`\n <span class="geo-countdown-text">${r}</span>\n <svg width="32px" height="32px">\n <circle cx="16" cy="16" r="12" class="geo-countdown-progress" transform="rotate(-90, 16, 16)"\n stroke-dasharray="${n} ${n}"\n stroke-dashoffset="-${i}"\n />\n </svg>`}),[v,t.date,f,l,h]);return(0,o.bt)((()=>{m.current&&q(m.current)}),[q]),(0,o.bt)((()=>{if(C)return;const e=u.current.closest(".message-content");B&&ga(B,U,0,r,c).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(s.s2,"")}))}),[U,i,r,c,B,C]),(0,o.d4)((()=>{Math.abs(I.lat-P.lat)<Da&&Math.abs(I.long-P.long)<Da?P.accuracyRadius!==I.accuracyRadius&&b({...P,accuracyRadius:I.accuracyRadius}):b(I)}),[I,P]),(0,Oa.Z)((()=>{g()}),w?void 0:1e3*(Z||0)),(0,Mn.Z)((()=>{const e=m.current;e&&q(e)}),Z?1e3:void 0),o.ZP.createElement("div",{ref:u,className:"Location media-inner interactive",onClick:()=>{var e;const t=function(e,t,n){return`http://maps.google.com/maps/place/${e}+${t}/@${e},${t},${n}z`}(P.lat,P.long,M);null===(e=window.open(t,"_blank"))||void 0===e||e.focus()}},o.ZP.createElement("div",{className:"map-wrapper"},B?o.ZP.createElement("img",{className:"full-media map",src:B,alt:"Location on a map",width:ja.width,height:ja.height}):o.ZP.createElement(qa,{width:S,height:E}),function(){if(B)return o.ZP.createElement(o.ZP.Fragment,null,Boolean(F)&&!w&&o.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*F}px; height: ${2*F}px`}),function(){const e=(0,Ce.Z)("pin",v,w&&"expired");if("geoLive"===v)return o.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Ga},o.ZP.createElement(gn.Z,{chat:O,user:x,className:"location-avatar"}),void 0!==f.heading&&o.ZP.createElement("div",{className:"direction",style:`--direction: ${f.heading}deg`}));if("venue"===v){const t=function(e){return e?Ua.get(e)||Ua.get(e.split("/")[0])||Fa[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%Fa.length)]:"#008df2";var t}(f.venueType),n=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(f.venueType);return o.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Ga,style:`--pin-color: ${t}`},o.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return o.ZP.createElement("img",{className:e,src:$a,alt:""})}())}()),function(){if(C)return"venue"===v?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},f.title),o.ZP.createElement("div",{className:"location-info-subtitle"},f.address)):"geoLive"===v?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},h("AttachLiveLocation")),o.ZP.createElement("div",{className:"location-info-subtitle"},(0,L.dJ)(h,y,t.editDate)),!w&&o.ZP.createElement("div",{className:"geo-countdown",ref:m})):void 0}())})),Ha=(0,o.X$)((e=>{let{message:t,canAutoLoadMedia:n,lastSyncTime:s}=e;const{clickBotInlineButton:i}=(0,a.Sv)(),r=t.content.game,{title:c,description:l}=r,u=Boolean(s)&&(0,d.N)(r),m=Boolean(s)&&(0,d.Wc)(r),h=(0,zt.Z)(u,!n),g=(0,zt.Z)(m,!n);return o.ZP.createElement("div",{className:"Game"},o.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{i({messageId:t.id,button:t.inlineButtons[0][0]})}},!h&&!g&&o.ZP.createElement(qa,{className:"skeleton preview-content"}),h&&o.ZP.createElement("img",{className:"preview-content",src:h,alt:c}),g&&o.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,autoPlay:!0,loop:!0,src:g})),o.ZP.createElement("div",{className:"title"},c),!(0,d.UD)(t)&&o.ZP.createElement("div",{className:"description"},l))}));function za(e){return(0,o.X$)((0,a.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:s,message:i,dimensions:r}=t,{toggleMessageSelection:c}=(0,a.Sv)(),l=(0,o.I4)((e=>{e.stopPropagation(),c({messageId:i.id,withShift:null==e?void 0:e.shiftKey})}),[c,i]),d=(0,o.Ye)((()=>{const{dimensions:e,onClick:a}=t;return{...t,isInSelectMode:n,isSelected:s,dimensions:{...e,x:0,y:0},onClick:n?void 0:a}}),[t,n,s]);return o.ZP.createElement("div",{className:(0,Ce.Z)("album-item-select-wrapper",s&&"is-selected"),style:r?`left: ${r.x}px; top: ${r.y}px;`:"",onClick:n?l:void 0},n&&o.ZP.createElement("div",{className:"message-select-control"},s&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const Va=za(fa),Wa=za(Za),Xa=(0,a.c$)(((e,t)=>{let{album:n}=t;const{chatId:a}=n.mainMessage,s=(0,c.Pu)(e),o=(0,c.xs)(e,a);return{theme:s,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:o}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:s,lastSyncTime:i,isOwn:r,isProtected:l,albumLayout:u,onMediaClick:m,uploadsById:h,activeDownloadIds:g,theme:p}=e;const{cancelSendingMessage:f}=(0,a.Sv)(),v=t.messages.length,I=(0,o.I4)((e=>{f({chatId:e.chatId,messageId:e.id})}),[f]),{width:y,height:w}=u.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${y}px; height: ${w}px;`},t.messages.map((function(e,t){const{photo:f,video:y}=(0,d.qp)(e),w=h[e.previousLocalId||e.id],Z=null==w?void 0:w.progress,{dimensions:P,sides:b}=u.layout[t],C=(0,c.bH)((0,a.Rd)(),e),S=(0,c.__)((0,a.Rd)(),e);if(f){const a=s&&(r?t===v-1:Boolean(8&b&&4&b));return o.ZP.createElement(Va,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersection:n,canAutoLoad:C,shouldAffectAppendix:a,uploadProgress:Z,dimensions:P,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})}if(y)return o.ZP.createElement(Wa,{id:`album-media-${(0,d.d0)(e.id)}`,message:e,observeIntersection:n,canAutoLoad:C,canAutoPlay:S,uploadProgress:Z,lastSyncTime:i,dimensions:P,isProtected:l,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})})))}));function Ka(){return Ka=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Ka.apply(this,arguments)}let Ya;const Ja=e=>{let{message:t,observeIntersection:n,canAutoLoad:s,lastSyncTime:r,isDownloading:c}=e;const l=(0,o.sO)(null),u=(0,o.sO)(null),m=(0,o.sO)(null),h=t.content.video,g=(0,kn.Op)(l,n),[p,f]=(0,o.eJ)(s),v=Boolean(p&&g&&r),{mediaData:I,loadProgress:y}=(0,da.Z)((0,d.Ti)(t,"inline"),!v,(0,d.kG)(t,"inline"),r),{loadProgress:w}=(0,da.Z)((0,d.Ti)(t,"download"),!c,i.IU.BlobUrl,r),Z=ma(t,I),{isBuffered:P,bufferingHandlers:b}=(0,va.Z)(),C=p&&!P||c,S=!1===(0,Ot.Z)(p),M=(0,ia.Z)(I),{shouldRender:R,transitionClassNames:k}=(0,Ue.Z)(C||!P,void 0,S),[N,T]=(0,o.eJ)(!1),[B,A]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!N)return;const e=_t.Rj/2,t=2*(e-6)*Math.PI,n=t-B*t,a=m.current,s=u.current,o=s.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):s.innerHTML=`\n <svg width="${_t.Rj}px" height="${_t.Rj}px">\n <circle cx="${e}" cy="${e}" r="${e-6}" class="progress-circle"\n transform="rotate(-90, ${e}, ${e})"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="${t}"\n />\n </svg>`,A(a.currentTime/a.duration)}),[N,B]);const x=Boolean(I&&g),O=(0,o.I4)((()=>{m.current&&(T(!1),A(0),(0,ra.Z)(m.current),(0,E.T2)((()=>{u.current.innerHTML=""})))}),[]),U=(0,o.I4)((()=>{var e;null===(e=Ya)||void 0===e||e(),Ya=O}),[O]);(0,o.d4)((()=>{m.current&&(x?(0,ra.Z)(m.current):m.current.pause())}),[x]),ya(m,x),(0,Ia.Z)(m,[I]);const F=(0,o.I4)((()=>{if(!I)return void f((e=>!e));if(c)return void(0,a.Sv)().cancelMessageMediaDownload({message:t});const e=m.current;N?e.paused?((0,ra.Z)(e),(0,en.Es)()):e.pause():(U(),e.pause(),e.currentTime=0,(0,ra.Z)(e),(0,en.Es)(),T(!0))}),[U,N,c,I,t]),q=(0,o.I4)((e=>{const t=e.currentTarget;A(t.currentTime/t.duration)}),[]),$=(0,Ce.Z)("full-media",M);return o.ZP.createElement("div",{ref:l,className:"RoundVideo media-inner",onClick:F},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:Z,className:"thumbnail",style:`width: ${_t.Rj}px; height: ${_t.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",Ka({ref:m,className:$,width:_t.Rj,height:_t.Rj,autoPlay:!0,muted:!N,loop:!N,playsInline:!0,onEnded:N?O:void 0},b,{onTimeUpdate:N?q:void 0}),o.ZP.createElement("source",{src:I}))),o.ZP.createElement("div",{className:"progress",ref:u}),R&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(pa.Z,{progress:c?w:y})),!I&&!p&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},N?(0,L.k9)(m.current.currentTime):(0,L.k9)(h.duration),(!N||m.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},Qa=e=>{let{message:t,onClick:n}=e;const a=(0,We.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(nt.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===e.type,onClick:()=>n({messageId:t.id,button:e})},o.ZP.createElement("span",{className:"inline-button-text"},(0,un.Z)(a(e.text))),["buy","receipt"].includes(e.type)&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!s.FS.test(e.url)&&o.ZP.createElement("i",{className:"icon-arrow-right"}),"switchBotInline"===e.type&&o.ZP.createElement("i",{className:"icon-share-filled"}),["webView","simpleWebView"].includes(e.type)&&o.ZP.createElement("i",{className:"icon-webapp"}))))))))},es=(0,o.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:s}=(0,a.Sv)(),i=(0,We.Z)(),{threadId:r,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h}=t,g=(0,o.I4)((()=>{s({id:c,threadId:r})}),[s,c,r]),p=(0,o.Ye)((()=>{if(null==h||!h.length)return;const{users:{byId:e},chats:{byId:t}}=(0,a.Rd)();return h.map((n=>(0,d.YC)(n)?e[n]:t[n])).filter(Boolean)}),[h]);if(void 0===l)return;const f=Boolean(m&&u&&m<u);return o.ZP.createElement("div",{"data-cnt":(0,qe.bi)(l),className:(0,Ce.Z)("CommentButton",f&&"has-unread",n&&"disabled"),dir:i.isRtl?"rtl":"ltr",onClick:g},o.ZP.createElement("i",{className:"icon-comments-sticker"}),(!p||0===p.length)&&o.ZP.createElement("i",{className:"icon-comments"}),p&&p.length>0&&o.ZP.createElement("div",{className:"recent-repliers",dir:i.isRtl?"rtl":"ltr"},p.map((e=>o.ZP.createElement(gn.Z,{key:e.id,size:"small",user:(0,d.YC)(e.id)?e:void 0,chat:(0,d.YC)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},l?i("Comments",l,"i"):i("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))})),ts=(0,o.X$)((e=>{let{reaction:t,message:n,activeReaction:s,availableReactions:i}=e;const{sendReaction:r}=(0,a.Sv)(),{recentReactions:c}=n.reactions,l=(0,o.Ye)((()=>{if(!c||t.count>3)return;const e=(0,a.Rd)().users.byId;return c.filter((e=>e.reaction===t.reaction)).map((t=>e[t.userId])).filter(Boolean)}),[t,c]),d=(0,o.I4)((()=>{r({reaction:t.isChosen?void 0:t.reaction,chatId:n.chatId,messageId:n.id})}),[n,t,r]);return o.ZP.createElement(nt.Z,{className:(0,Ce.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},o.ZP.createElement(sa,{activeReaction:s,reaction:t.reaction,availableReactions:i}),null!=l&&l.length?o.ZP.createElement("div",{className:"avatars"},l.map((e=>o.ZP.createElement(gn.Z,{user:e,size:"micro"})))):(0,qe.bi)(t.count))})),ns=(0,o.X$)((e=>{let{message:t,isOutside:n,activeReaction:a,availableReactions:s,metaChildren:i}=e;return o.ZP.createElement("div",{className:(0,Ce.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>o.ZP.createElement(ts,{key:e.reaction,reaction:e,message:t,activeReaction:a,availableReactions:s}))),i)}));var as=n(9332),ss=n(5296);const os=(0,o.X$)((e=>{let{localSticker:t,localEffect:n,isOwn:a,soundId:s,size:i="medium",observeIntersection:r,messageId:c,chatId:l,activeEmojiInteractions:d}=e;const{playKey:u,ref:m,style:h,width:g,handleClick:p,markAnimationLoaded:f}=(0,ss.Z)(i,l,c,s,d,a,n),v=`local_emoji_${t}`,I=(0,kn.Op)(m,r),[y,w]=(0,o.eJ)();return(0,o.d4)((()=>{t&&(0,as.Z)(t).then((e=>{w(e)}))}),[t]),o.ZP.createElement("div",{ref:m,className:"AnimatedEmoji media-inner",style:h,onClick:p},y&&o.ZP.createElement(aa.Z,{key:v,id:v,animationData:y,size:g,quality:1,play:I&&u,forceOnHeavyAnimation:!0,noLoop:!0,onLoad:f}))})),is=(0,o.X$)((e=>{let{phoneCall:t,message:n,chatId:s}=e;const{requestCall:i}=(0,a.Sv)(),r=(0,We.Z)(),{isOutgoing:c,isVideo:l,reason:d}=t,u="missed"===d,m="busy"===d&&!c,g=(0,o.I4)((()=>{i({isVideo:l,userId:s})}),[s,l,i]),p=(0,o.Ye)((()=>l?m?"CallMessageVideoIncomingDeclined":u?c?"CallMessageVideoOutgoingMissed":"CallMessageVideoIncomingMissed":c?"CallMessageVideoOutgoing":"CallMessageVideoIncoming":m?"CallMessageIncomingDeclined":u?c?"CallMessageOutgoingMissed":"CallMessageIncomingMissed":c?"CallMessageOutgoing":"CallMessageIncoming"),[m,u,c,l]),f=(0,o.Ye)((()=>t.duration?(0,L.J_)(r,t.duration):void 0),[r,t.duration]),v=(0,L.mr)(r,1e3*n.date);return o.ZP.createElement("div",{className:"src-components-middle-message-MessagePhoneCall-module__root"},o.ZP.createElement(nt.Z,{size:"smaller",color:"translucent",round:!0,ripple:!0,onClick:g,className:"src-components-middle-message-MessagePhoneCall-module__button",disabled:!h.Bi,ariaLabel:r(c?"CallAgain":"CallBack")},o.ZP.createElement("i",{className:l?"icon-video-outlined":"icon-phone"})),o.ZP.createElement("div",{className:"src-components-middle-message-MessagePhoneCall-module__info"},o.ZP.createElement("div",{className:"src-components-middle-message-MessagePhoneCall-module__reason"},r(p)),o.ZP.createElement("div",{className:"src-components-middle-message-MessagePhoneCall-module__meta"},o.ZP.createElement("i",{className:(0,Ce.Z)("icon-arrow-right","src-components-middle-message-MessagePhoneCall-module__arrow",u&&"src-components-middle-message-MessagePhoneCall-module__missed",!c&&"src-components-middle-message-MessagePhoneCall-module__incoming")}),o.ZP.createElement("span",{className:"src-components-middle-message-MessagePhoneCall-module__duration"},f?r("CallMessageWithDuration",[v,f]):v))))})),rs={__html:'<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#EEFFDE" class="corner"/></g></svg>'},cs={__html:'<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M3 17h6V0c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 003 17z" fill="#000" filter="url(#a)"/><path d="M3 17h6V0c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 003 17z" fill="#FFF" class="corner"/></g></svg>'},ls=(0,o.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:n,forwardMessages:a,lastSyncTime:s,serverTimeOffset:o}=e,{message:i,album:r,withSenderName:l,withAvatar:u,threadId:m,messageListType:h,isLastInDocumentGroup:g}=t,{id:p,chatId:f,viaBotId:v,replyToChatId:I,replyToMessageId:y,isOutgoing:w,threadInfo:Z,forwardInfo:P}=i,b=(0,c.Z1)(e,f),C=(0,c.FM)(e,f),S=(0,d.pK)(f),E=b&&(0,d.eA)(b),M=null==b?void 0:b.username,R=!C&&(0,d.Ul)(i),k=l||u||R,N=(0,c.Ur)(e,i),T=(0,c.cv)(e,i),B=v?(0,c.dy)(e,v):void 0,A=m?(0,c.qS)(e,f,m):void 0,x=i.id===A,L=y===A,O=y&&!L?(0,c.hj)(e,S&&I?I:f,y):void 0,U=O&&(0,c.Bz)(e,O,Boolean(P)),F=(0,c.uZ)(e,i),q="thread"===h&&(r?r.messages.some((t=>(0,c._X)(e,t))):(0,c._X)(e,i)),{direction:$,noHighlight:D,isResizingContainer:j}=q&&n||{},G=a.messageIds&&a.messageIds.includes(p),{query:_}=(0,c.n5)(e)||{},H=(0,d._O)(i);let z;z=null!=r&&r.messages?r.messages.every((t=>{let{id:n}=t;return(0,c.vk)(e,n)})):(0,c.vk)(e,p);const{canReply:V}="thread"===h&&(0,c._k)(e,i,m)||{},W=(0,c.te)(e,i),X=Z?(0,c.tZ)(e,Z.chatId,Z.threadId)||Z:void 0,K=Boolean(i.groupedId)&&!i.isInAlbum,Y=K?(0,c.xH)(e,f,i.groupedId)[0]:void 0,J=K?g?(0,c.hj)(e,f,Y):void 0:i,Q=H?(0,c.CP)(e,H):void 0;return{theme:(0,c.Pu)(e),chatUsername:M,forceSenderName:R,sender:N,canShowSender:k,originSender:T,botSender:B,shouldHideReply:L,isThreadTop:x,replyMessage:O,replyMessageSender:U,isInDocumentGroup:K,isProtected:(0,c.EV)(e,i),isFocused:q,isForwarding:G,reactionMessage:J,isChatWithSelf:C,isRepliesChat:S,isChannel:E,canReply:V,lastSyncTime:s,serverTimeOffset:o,highlight:_,isSingleEmoji:Boolean(H),animatedEmoji:H?(0,c.zB)(e,H):void 0,animatedEmojiEffect:H&&(0,d.YC)(f)?(0,c.tH)(e,H):void 0,animatedEmojiSoundId:H?(0,c.Oh)(e,H):void 0,localSticker:Q,localEffect:Q&&(0,d.YC)(f)?(0,c.cu)(Q):void 0,isInSelectMode:(0,c.CA)(e),isSelected:z,isGroupSelected:Boolean(i.groupedId)&&!i.isInAlbum&&(0,c.a6)(e,f,i.groupedId),threadId:m,isDownloading:W,isPinnedList:"pinned"===h,canAutoLoadMedia:(0,c.bH)(e,i),canAutoPlayMedia:(0,c.__)(e,i),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,c.yB)(e),threadInfo:X,availableReactions:e.availableReactions,defaultReaction:(0,d.CI)(i)?void 0:(0,c.q6)(e,f),activeReaction:J&&e.activeReactions[J.id],activeEmojiInteractions:e.activeEmojiInteractions,...w&&{outgoingStatus:(0,c.dT)(e,i,"scheduled"===h)},..."number"==typeof F&&{uploadProgress:F},...q&&{focusDirection:$,noFocusHighlight:D,isResizingContainer:j}}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:s,observeIntersectionForMedia:r,observeIntersectionForAnimatedStickers:c,album:l,noAvatars:u,withAvatar:g,withSenderName:f,areReactionsInMeta:v,noComments:I,appearanceOrder:y,isFirstInGroup:w,isLastInGroup:Z,isFirstInDocumentGroup:P,isLastInDocumentGroup:b,isLastInList:C,theme:S,forceSenderName:E,sender:M,canShowSender:R,originSender:k,botSender:N,isThreadTop:T,shouldHideReply:B,replyMessage:A,replyMessageSender:x,outgoingStatus:L,uploadProgress:O,isInDocumentGroup:U,isProtected:F,isFocused:q,focusDirection:$,noFocusHighlight:D,isResizingContainer:j,isForwarding:G,isChatWithSelf:_,isRepliesChat:H,isChannel:z,canReply:V,lastSyncTime:W,serverTimeOffset:X,highlight:K,animatedEmoji:Y,localSticker:J,localEffect:Q,animatedEmojiEffect:ee,animatedEmojiSoundId:te,isInSelectMode:ne,isSelected:ae,isGroupSelected:se,threadId:oe,reactionMessage:ie,availableReactions:re,defaultReaction:ce,activeReaction:le,activeEmojiInteractions:de,messageListType:ue,isPinnedList:me,isDownloading:he,canAutoLoadMedia:ge,canAutoPlayMedia:pe,shouldLoopStickers:fe,autoLoadFileMaxSizeMb:ve,threadInfo:Ie}=e;const{toggleMessageSelection:ye,clickBotInlineButton:we,disableContextMenuHint:Ze}=(0,a.Sv)(),Pe=(0,o.sO)(null),be=(0,o.sO)(null),Se=(0,o.sO)(null),Ee=(0,We.Z)();(0,kn._N)(be,s);const{isContextMenuOpen:Me,contextMenuPosition:Re,handleBeforeContextMenu:ke,handleContextMenu:Ne,handleContextMenuClose:Te,handleContextMenuHide:Be}=(0,Bn.Z)(Pe,h.$b&&ne,!0,h.wZ);(0,o.d4)((()=>{Me&&Ze()}),[Me,Ze]);const Ae=y<=0,[xe,Le]=(0,ze.Z)(Ae);(0,o.d4)((()=>{Ae||setTimeout(Le,10*y)}),[y,Le,Ae]);const{transitionClassNames:Oe}=(0,Ue.Z)(xe,void 0,Ae,!1),{id:Fe,chatId:qe,forwardInfo:$e,viaBotId:De}=t,je=(0,d.CI)(t),Ge=(0,d.B4)(t),_e="scheduled"===ue||t.isScheduled,He=(0,d.ss)(t)&&!B,Ve=Boolean(Ie)&&"thread"===ue,Xe=(0,d.$D)(t),Ke=J||Y,Ye=(null==ie?void 0:ie.reactions)&&!(0,d.JE)(ie.reactions),Je=$e&&(!_||_e)&&!H&&!$e.isLinkedChannelPost&&!Xe,Qe=Boolean(l)&&l.messages.length>1,et=U&&!P,tt=U&&!b,at=void 0!==Re,st=!(at||ne||G||tt),ot=z&&!_e&&!F,it=Boolean(me||$e&&($e.isChannelPost||_&&!Ge||H)&&$e.fromMessageId),rt=(0,o.I4)(((e,t)=>{ye({messageId:Fe,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...Qe&&{childMessageIds:l.messages.map((e=>{let{id:t}=e;return t}))}})}),[ye,Fe,Qe,l]),ct=R?M:void 0,lt=$e&&(_||H||!ct)?k:ct,dt=$e?k:ct,{handleMouseDown:ut,handleClick:mt,handleContextMenu:ht,handleDoubleClick:gt,handleContentDoubleClick:pt,handleMouseMove:ft,handleSendQuickReaction:vt,handleMouseLeave:It,isSwiped:yt,isQuickReactionVisible:wt,handleDocumentGroupMouseEnter:Zt}=zn(rt,Pe,Fe,0,Boolean(ne),Boolean(V),Boolean(F),Ne,ke,qe,at,Se,Ge,tt),{handleAvatarClick:Pt,handleSenderClick:bt,handleViaBotClick:Ct,handleReplyClick:St,handleMediaClick:Et,handleAudioPlay:Mt,handleAlbumMediaClick:Rt,handleMetaClick:kt,handleReadMedia:Nt,handleCancelUpload:Tt,handleVoteSend:Bt,handleGroupForward:At,handleForward:xt,handleFocus:Lt,handleFocusForwarded:Ot,handleDocumentGroupSelectAll:Ut}=function(e,t,n,s,r,c,l,d,u,h,g,p,f){const{openChat:v,showNotification:I,focusMessage:y,openMediaViewer:w,openAudioPlayer:Z,markMessagesRead:P,cancelSendingMessage:b,sendPollVote:C,openForwardMenu:S,focusMessageInComments:E}=(0,a.Sv)(),{id:M,forwardInfo:R,replyToMessageId:k,replyToChatId:N,replyToTopMessageId:T,groupedId:B}=n,A=(0,o.I4)((()=>{g&&v({id:g.id})}),[g,v]),x=(0,o.I4)((()=>{p?l&&null!=R&&R.channelPostId?y({chatId:p.id,messageId:R.channelPostId}):v({id:p.id}):I({message:e("HidAccount")})}),[l,y,R,e,v,p,I]),L=(0,o.I4)((()=>{f&&v({id:f.id})}),[f,v]),O=(0,o.I4)((()=>{y({chatId:u&&N?N:s,threadId:r,messageId:k,replyMessageId:u&&N?void 0:M})}),[y,u,N,s,r,k,M]),U=(0,o.I4)((()=>{w({chatId:s,threadId:r,messageId:M,origin:d?m.bZ.ScheduledInline:m.bZ.Inline})}),[s,r,M,w,d]),F=(0,o.I4)((()=>{Z({chatId:s,messageId:M})}),[s,M,Z]),q=(0,o.I4)((e=>{w({chatId:s,threadId:r,messageId:e,origin:d?m.bZ.ScheduledAlbum:m.bZ.Album})}),[s,r,w,d]),$=(0,o.I4)((()=>{P({messageIds:[M]})}),[M,P]),D=(0,o.I4)((()=>{b({chatId:s,messageId:M})}),[b,s,M]),j=(0,o.I4)((e=>{C({chatId:s,messageId:M,options:e})}),[s,M,C]),G=(0,o.I4)((()=>{S({fromChatId:s,groupedId:B})}),[S,s,B]),_=(0,o.I4)((()=>{if(h&&h.messages){const e=h.messages.map((e=>{let{id:t}=e;return t}));S({fromChatId:s,messageIds:e})}else S({fromChatId:s,messageIds:[M]})}),[h,S,s,M]),H=(0,o.I4)((()=>{y({chatId:s,threadId:i._f,messageId:M})}),[y,s,M]),z=(0,o.I4)((()=>{c?y({chatId:R.fromChatId,groupedId:B,groupedChatId:s}):u&&N?E({chatId:N,threadId:T,messageId:R.fromMessageId}):y({chatId:R.fromChatId,messageId:R.fromMessageId})}),[c,u,N,y,R,B,s,E,T]),V=(0,o.I4)((e=>{e.stopPropagation(),t(e,B)}),[t,B]);return{handleAvatarClick:A,handleSenderClick:x,handleViaBotClick:L,handleReplyClick:O,handleMediaClick:U,handleAudioPlay:F,handleAlbumMediaClick:q,handleMetaClick:V,handleReadMedia:$,handleCancelUpload:D,handleVoteSend:j,handleGroupForward:G,handleForward:_,handleFocus:H,handleFocusForwarded:z,handleDocumentGroupSelectAll:V}}(Ee,rt,t,qe,oe,U,Je,_e,H,l,lt,dt,N),qt=(0,Ce.Z)("Message message-list-item",w&&"first-in-group",F&&"is-protected",Z&&"last-in-group",P&&"first-in-document-group",b&&"last-in-document-group",C&&"last-in-list",Ge&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",He&&"has-reply",at&&"has-menu-open",q&&!D&&"focused",G&&"is-forwarding",t.isDeleting&&"is-deleting",U&&"is-in-document-group",Qe&&"is-album",t.hasUnreadMention&&"has-unread-mention",ae&&"is-selected",ne&&"is-in-selection-mode",T&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",yt&&"is-swiped",Oe,Boolean(le)&&"has-active-reaction"),{text:$t,photo:Dt,video:jt,audio:Gt,voice:zt,document:Vt,sticker:Wt,contact:Xt,poll:Kt,webPage:Yt,invoice:Jt,location:Qt,action:en,game:tn}=(0,d.qp)(t),{phoneCall:nn}=en||{},an=Ie&&!tt&&"thread"===ue&&!I,sn=!h.$b&&!nn&&!ne&&ce&&!tt,on=function(e){let{hasReply:t,customShape:n,isLastInGroup:a,asForwarded:s,hasThread:o,forceSenderName:i,hasComments:r,hasActionButton:c,hasReactions:l,isGeoLiveActive:u}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:m,photo:h,video:g,audio:p,voice:f,document:v,poll:I,webPage:y,contact:w,location:Z,invoice:P}=(0,d.qp)(e),b=["message-content"],C=h||g||Z,S=m||"venue"===(null==Z?void 0:Z.type)||u,E=C&&!S,M=Boolean(e.viaBotId);return An(n)?b.push(`emoji-only emoji-only-${n}`):S&&b.push("text"),c&&b.push("has-action-button"),n&&(b.push("custom-shape"),null!=g&&g.isRound&&b.push("round"),r&&b.push("has-comments")),C?b.push("media"):p?b.push("audio"):f?b.push("voice"):v?b.push("document"):w?b.push("contact"):I?b.push("poll"):y&&(b.push("web-page"),(y.photo||y.video)&&b.push("media")),P&&b.push("invoice"),s&&b.push("is-forwarded"),t&&b.push("is-reply"),o&&b.push("has-replies"),l&&b.push("has-reactions"),M&&b.push("is-via-bot"),i&&b.push("force-sender-name"),n||(b.push("has-shadow"),C&&r&&b.push("has-background"),(t||s||!E||M||i)&&b.push("has-solid-background"),a&&(h||Z&&!S||!E)&&b.push("has-appendix")),b.join(" ")}(t,{hasReply:He,customShape:Xe,isLastInGroup:Z,asForwarded:Je,hasThread:Ve,forceSenderName:E,hasComments:Ie&&(null==Ie?void 0:Ie.messagesCount)>0,hasActionButton:ot||it,hasReactions:Ye,isGeoLiveActive:"geoLive"===(null==Qt?void 0:Qt.type)&&!(0,d.$R)(t,(0,p.b)(X))}),rn=on.includes("has-appendix"),cn=(0,Ht.X)(t,K,An(Xe));let ln,dn;ln=nn||tt?"none":!cn||Ke||Yt?"standalone":"in-text",v?dn="in-meta":Ye?Xe||(Dt||jt||Ke)&&!cn?dn="outside":Je?(ln="standalone",dn="inside"):dn="inside":dn="none",(0,Ft.Z)(H&&t.replyToChatId?t.replyToChatId:qe,He?t.replyToMessageId:void 0,A,t.id),jn(Pe,qe,q,$,D,j);let mn,hn="",pn=!1;const fn=(0,o.Ye)((()=>Qe?qn(Ge,Boolean(Je),Boolean(u),l):void 0),[Qe,Ge,Je,u,l]),vn=Je?28:0;if(Qe||!Dt&&!jt)fn&&(mn=Math.max(xn(Boolean($t),an),fn.containerStyle.width),mn-fn.containerStyle.width>18&&(pn=!0));else{let e;Dt?e=Ln(t,u).width:jt&&(e=jt.isRound?_t.Rj:Ln(t,u).width),e&&(mn=Math.max(xn(Boolean($t),an),e),mn-e>18&&(pn=!0))}mn&&(hn=`width: ${mn+vn}px`);const In=z&&t.adminTitle||!Je&&(null==$e?void 0:$e.adminTitle)||void 0,yn=(0,o.Ye)((()=>In?Dn(In):void 0),[In]);function wn(){const e=o.ZP.createElement(oa,{message:t,reactionMessage:ie,outgoingStatus:L,signature:In,withReactions:"in-meta"===dn,withReactionOffset:"inside"===dn,availableReactions:re,activeReaction:le,onClick:kt});return"inside"!==dn?e:o.ZP.createElement(ns,{activeReaction:le,message:ie,metaChildren:e,availableReactions:re})}return o.ZP.createElement("div",{ref:Pe,id:(0,d.d0)(t.id),className:qt,style:yn?`--meta-safe-author-width: ${yn}px`:void 0,"data-message-id":Fe,onMouseDown:ut,onClick:mt,onContextMenu:ht,onDoubleClick:gt,onMouseEnter:tt?Zt:void 0,onMouseMove:sn?ft:void 0,onMouseLeave:sn||tt?It:void 0},o.ZP.createElement("div",{ref:be,className:"bottom-marker","data-message-id":Fe,"data-last-message-id":l?l.messages[l.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention}),!U&&o.ZP.createElement("div",{className:"message-select-control"},ae&&o.ZP.createElement("i",{className:"icon-select"})),b&&o.ZP.createElement("div",{className:(0,Ce.Z)("message-select-control group-select",se&&"is-selected"),onClick:Ut},se&&o.ZP.createElement("i",{className:"icon-select"})),g&&function(){const e=lt&&(0,d.YC)(lt.id),t=lt&&e?lt:void 0,n=lt&&!e?lt:void 0,a=!lt&&$e?$e.hiddenUserName:void 0;return o.ZP.createElement(gn.Z,{size:"small",user:t,chat:n,text:a,lastSyncTime:W,onClick:t||n?Pt:void 0})}(),o.ZP.createElement("div",{className:(0,Ce.Z)("message-content-wrapper",on.includes("text")&&"can-select-text")},o.ZP.createElement("div",{ref:Se,className:on,style:hn,dir:"auto"},Je&&!et&&o.ZP.createElement("div",{className:"message-title"},Ee("ForwardedMessage")),function(){const e=(0,Ce.Z)("content-inner",Je&&"forwarded-message",He&&"reply-message",pn&&"no-media-corners"),n=Z&&!cn&&!Je&&!Ve,a=(0,Ce.Z)("text-content","in-text"===ln&&"with-meta",L&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:pt,dir:"auto"},function(){if(Xe&&!De||!(f&&!(Dt||jt||Qt)||Je||De||E)||et||He&&Xe)return;let e,n;return!dt||Xe&&De?null!=$e&&$e.hiddenUserName&&(e=$e.hiddenUserName):(e=(0,d.OU)(Ee,dt),Je||(n=`color-${(0,d.Rs)(dt)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?o.ZP.createElement("span",{className:(0,Ce.Z)("interactive",n),onClick:bt,dir:"auto"},(0,un.Z)(e)):N?void 0:" ",N&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},Ee("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:Ct},(0,un.Z)(`@${N.username}`))),null!=$e&&$e.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Ee("DiscussChannel")):t.adminTitle&&!z?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.adminTitle):void 0)}(),He&&o.ZP.createElement(Jn,{message:A,isProtected:F,sender:x,observeIntersection:r,onClick:St}),Wt&&o.ZP.createElement(ca,{message:t,observeIntersection:r,observeIntersectionForPlaying:c,shouldLoop:fe,lastSyncTime:W}),Y&&o.ZP.createElement(la.Z,{size:"small",isOwn:Ge,sticker:Y,effect:ee,soundId:te,observeIntersection:r,lastSyncTime:W,forceLoadPreview:je,messageId:Fe,chatId:qe,activeEmojiInteractions:de}),J&&o.ZP.createElement(os,{size:"small",isOwn:Ge,localSticker:J,localEffect:Q,soundId:te,observeIntersection:r,lastSyncTime:W,forceLoadPreview:je,messageId:Fe,chatId:qe,activeEmojiInteractions:de}),Qe&&o.ZP.createElement(Xa,{album:l,albumLayout:fn,observeIntersection:r,isOwn:Ge,isProtected:F,hasCustomAppendix:n,lastSyncTime:W,onMediaClick:Rt}),nn&&o.ZP.createElement(is,{message:t,phoneCall:nn,chatId:qe}),!Qe&&Dt&&o.ZP.createElement(fa,{message:t,observeIntersection:r,noAvatars:u,canAutoLoad:ge,uploadProgress:O,shouldAffectAppendix:n,onClick:Et,onCancelUpload:Tt,isDownloading:he,isProtected:F,theme:S}),!Qe&&jt&&jt.isRound&&o.ZP.createElement(Ja,{message:t,observeIntersection:r,canAutoLoad:ge,lastSyncTime:W,isDownloading:he}),!Qe&&jt&&!jt.isRound&&o.ZP.createElement(Za,{message:t,observeIntersection:r,noAvatars:u,canAutoLoad:ge,canAutoPlay:pe,uploadProgress:O,lastSyncTime:W,onClick:Et,onCancelUpload:Tt,isDownloading:he,isProtected:F}),(Gt||zt)&&o.ZP.createElement(ea.Z,{theme:S,message:t,origin:m.Cr.Inline,uploadProgress:O,lastSyncTime:W,isSelectable:U,isSelected:ae,onPlay:Mt,onReadMedia:!zt||Ge&&!_?void 0:Nt,onCancelUpload:Tt,isDownloading:he}),Vt&&o.ZP.createElement(Qn.Z,{message:t,observeIntersection:r,canAutoLoad:ge,autoLoadFileMaxSizeMb:ve,uploadProgress:O,isSelectable:U,isSelected:ae,onMediaClick:Et,onCancelUpload:Tt,isDownloading:he}),Xt&&o.ZP.createElement(ba,{contact:Xt}),Kt&&o.ZP.createElement(Na,{message:t,poll:Kt,onSendVote:Bt}),tn&&o.ZP.createElement(Ha,{message:t,canAutoLoadMedia:ge,lastSyncTime:W}),!Ke&&cn&&o.ZP.createElement("p",{className:a,dir:"auto"},cn,"in-text"===ln&&wn()),Yt&&o.ZP.createElement(Aa,{message:t,observeIntersection:r,noAvatars:u,canAutoLoad:ge,canAutoPlay:pe,lastSyncTime:W,onMediaClick:Et,onCancelMediaTransfer:Tt,isDownloading:he,isProtected:F,theme:S}),Jt&&o.ZP.createElement(La,{message:t,shouldAffectAppendix:n,isInSelectMode:ne,isSelected:ae,theme:S}),Qt&&o.ZP.createElement(_a,{message:t,lastSyncTime:W,isInSelectMode:ne,isSelected:ae,theme:S,peer:M,serverTimeOffset:X}))}(),!tt&&"standalone"===ln&&wn(),st&&ot?o.ZP.createElement(nt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:Ee("lng_context_forward_msg"),onClick:b?At:xt},o.ZP.createElement("i",{className:"icon-share-filled"})):st&&it?o.ZP.createElement(nt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:me?Lt:Ot},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,an&&o.ZP.createElement(es,{threadInfo:Ie,disabled:I}),rn&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:Ge?rs:cs}),sn&&o.ZP.createElement("div",{className:(0,Ce.Z)("quick-reaction",wt&&!le&&"visible"),onClick:vt},o.ZP.createElement(na.Z,{reaction:ce}))),t.inlineButtons&&o.ZP.createElement(Qa,{message:t,onClick:we}),"outside"===dn&&o.ZP.createElement(ns,{message:ie,isOutside:!0,activeReaction:le,availableReactions:re})),Re&&o.ZP.createElement(Kn,{isOpen:Me,anchor:Re,message:t,album:l,chatUsername:n,messageListType:ue,onClose:Te,onCloseAnimationEnd:Be}))}))),ds=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,c.fS)(e,n),{chatId:s,isBot:o}=a||{};return{message:a,bot:s&&o?(0,c.dy)(e,s):void 0,channel:!o&&s?(0,c.Z1)(e,s):void 0}}))((e=>{let{chatId:t,message:n,containerRef:s,bot:i,channel:r}=e;const{viewSponsoredMessage:c,openChat:l,openChatByInvite:u,startBot:m,focusMessage:h}=(0,a.Sv)(),g=(0,We.Z)(),p=(0,o.sO)(null),f=Boolean(n),{observe:v}=(0,kn.S1)({rootRef:s,debounceMs:200,threshold:1});(0,o.d4)((()=>f?v(p.current,(e=>{e.isIntersecting&&c({chatId:t})})):void 0),[t,f,v,c]);const I=(0,o.I4)((()=>{n&&(n.chatInviteHash?u({hash:n.chatInviteHash}):n.channelPostId?h({chatId:n.chatId,messageId:n.channelPostId}):(l({id:n.chatId}),n.startParam&&m({botId:n.chatId,param:n.startParam})))}),[h,n,l,u,m]);if(n)return o.ZP.createElement("div",{className:"SponsoredMessage Message open",key:"sponsored-message"},o.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},o.ZP.createElement("div",{className:"content-inner",dir:"auto"},o.ZP.createElement("div",{className:"message-title",dir:"ltr"},i&&(0,un.Z)((0,d.Js)(i)||""),r&&(0,un.Z)(n.chatInviteTitle||(0,d.U)(g,r,i)||"")),o.ZP.createElement("p",{className:"text-content with-meta",dir:"auto",ref:p},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,Ca.H)(n.text.text,n.text.entities)),o.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},o.ZP.createElement("span",{className:"message-signature"},g("SponsoredMessage")))),o.ZP.createElement(nt.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:I,className:"SponsoredMessage__button"},g(n.isBot?"Conversation.ViewBot":n.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))))}))),us=(0,o.X$)((e=>{let{chatId:t,messageIds:n,messageGroups:i,isViewportNewest:r,isUnread:c,withUsers:l,areReactionsInMeta:u,noAvatars:p,containerRef:f,anchorIdRef:v,memoUnreadDividerBeforeIdRef:I,memoFirstUnreadIdRef:y,threadId:w,type:Z,isReady:P,isScrollingRef:b,isScrollPatchNeededRef:C,threadTopMessageId:S,hasLinkedChat:M,isSchedule:R,noAppearanceAnimation:k,onFabToggle:N,onNotchToggle:T}=e;const{openHistoryCalendar:B}=(0,a.Sv)(),{observeIntersectionForMedia:A,observeIntersectionForReading:x,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:s,markMessagesRead:o}=(0,a.Sv)(),{observe:i}=(0,kn.S1)({rootRef:t,throttleMs:Nn,margin:Tn}),{observe:r,freeze:c,unfreeze:l}=(0,kn.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let a=0;const i=[];t.forEach((e=>{const{isIntersecting:t,target:n}=e;if(!t)return;const{dataset:s}=n,o=Number(s.lastMessageId||s.messageId);o>a&&(a=o),s.hasUnreadMention&&i.push(o)})),n.current&&a>=n.current&&s({maxId:a}),i.length&&o({messageIds:i})}));(0,Re.Z)(c,l);const{observe:d}=(0,kn.S1)({rootRef:t,throttleMs:Nn});return{observeIntersectionForMedia:i,observeIntersectionForReading:r,observeIntersectionForAnimatedStickers:d}}(Z,f,y),{backwardsTriggerRef:U,forwardsTriggerRef:F,fabTriggerRef:q}=function(e,t,n,i,r,c,l,d,u,g){const{loadViewportMessages:p}=(0,a.Sv)(),[f,v]=(0,o.Ye)((()=>"thread"===e?[(0,E.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,E.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,n]),I=(0,o.sO)(null),y=(0,o.sO)(null),w=(0,o.sO)(null);function Z(){if(!d)return;if(!n||!n.length)return c(!1),void l(!1);if(!i)return c(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:a,scrollTop:s}=t.current,o=Math.round(a-s-e),u=o<=1;c(r?!u:!(o<=50)),l(!u)}const{observe:P}=(0,kn.S1)({rootRef:t,margin:h.gZ},(e=>{if(!v||!f)return;if(n[0]>=s.AE)return;const t=e.find((e=>{let{isIntersecting:t}=e;return t}));if(!t)return;const{target:a}=t;"backwards-trigger"===a.className?(h.i4&&u.current&&n.length<=s.hT&&(g.current=!0),f()):"forwards-trigger"===a.className&&v()}));(0,kn._N)(I,P),(0,kn._N)(y,P);const{observe:b,freeze:C,unfreeze:S}=(0,kn.S1)({rootRef:t,margin:100},Z);(0,kn._N)(w,b);const{observe:M,freeze:R,unfreeze:k}=(0,kn.S1)({rootRef:t,margin:1},Z);return(0,kn._N)(w,M),(0,Ne.Z)((()=>{d&&Z()}),[d]),(0,Ne.Z)((()=>{C(),R(),setTimeout((()=>{k(),S()}),250)}),[n]),{backwardsTriggerRef:I,forwardsTriggerRef:y,fabTriggerRef:w}}(Z,f,n,r,c,N,T,P,b,C),$=(0,We.Z)(),D=o.ZP.createElement("div",{className:(0,Ce.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,$("UnreadMessages"))),j=k?0:i.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let G=0;const _=i.map(((e,t,n)=>{const a=e.senderGroups.map(((e,a,s)=>{var i;if(1===e.length&&!Zn(e[0])&&(0,d.Lo)(e[0])&&(null===(i=e[0].content.action)||void 0===i||!i.phoneCall)){const i=e[0],r=a===s.length-1&&t===n.length-1;return(0,g.oA)([i.id===I.current&&D,o.ZP.createElement(Yn,{key:i.id,message:i,observeIntersection:x,appearanceOrder:j-++G,isLastInList:r})])}let r;return(0,g.xH)(e.map(((i,c)=>{const m=Zn(i)?i.mainMessage:i,h=Zn(i)?i:void 0,f=(0,d.B4)(m),y=Zn(i),P=e[c+1];m.previousLocalId&&v.current===(0,d.d0)(m.previousLocalId)&&(v.current=(0,d.d0)(m.id));const b=!y&&m.groupedId?m.groupedId:void 0,C=P&&!Zn(P)?P.groupedId:void 0,E={isFirstInGroup:0===c,isLastInGroup:c===e.length-1,isFirstInDocumentGroup:Boolean(b&&b!==r),isLastInDocumentGroup:Boolean(b&&b!==C),isLastInList:c===e.length-1&&a===s.length-1&&t===n.length-1};r=b;const R=(0,d.KK)(m),k="scheduled"!==Z?R:`${m.date}_${R}`;return(0,g.oA)([m.id===I.current&&D,o.ZP.createElement(ls,{key:k,message:m,observeIntersectionForBottom:x,observeIntersectionForMedia:A,observeIntersectionForAnimatedStickers:O,album:h,noAvatars:p,withAvatar:E.isLastInGroup&&l&&!f&&!(m.id===S),withSenderName:E.isFirstInGroup&&l&&!f,areReactionsInMeta:u,threadId:w,messageListType:Z,noComments:!1===M,appearanceOrder:j-++G,isFirstInGroup:E.isFirstInGroup,isLastInGroup:E.isLastInGroup,isFirstInDocumentGroup:E.isFirstInDocumentGroup,isLastInDocumentGroup:E.isLastInDocumentGroup,isLastInList:E.isLastInList}),m.id===S&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,$("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:bn.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,Ce.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:bn.q,onClick:R?void 0:()=>B({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},R&&e.originalDate===s.t4&&$("MessageScheduledUntilOnline"),R&&e.originalDate!==s.t4&&$("MessageScheduledOn",(0,L.j1)($,e.datetime,void 0,!0)),!R&&(0,L.j1)($,e.datetime))),(0,g.xH)(a))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:U,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(_),r&&o.ZP.createElement(ds,{key:t,chatId:t,containerRef:f}),o.ZP.createElement("div",{ref:F,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:q,key:"fab-trigger",className:"fab-trigger"}))}));var ms=n(3547);const hs=(0,o.X$)((0,a.c$)(((e,t)=>{let{userId:n}=t;const{stickers:a}=e.stickers.greeting,s=(0,d.db)(n)+(0,d.db)(e.currentUserId),o=null!=a&&a.length?a[s%a.length]:void 0,i=(0,c.Z1)(e,n);return i?{sticker:o,lastUnreadMessageId:i.lastMessage&&i.lastMessage.id!==i.lastReadInboxMessageId?i.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((e=>{let{sticker:t,connectionState:n,lastUnreadMessageId:s}=e;const{loadGreetingStickers:i,sendMessage:r,markMessageListRead:c}=(0,a.Sv)(),l=(0,We.Z)(),d=(0,o.sO)(null),{observe:u}=(0,kn.S1)({rootRef:d,debounceMs:200});(0,o.d4)((()=>{t||"connectionStateReady"!==n||i()}),[n,i,t]),(0,o.d4)((()=>{"connectionStateReady"===n&&s&&c({maxId:s})}),[n,c,s]);const m=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:d},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},l("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},l("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},t&&o.ZP.createElement(ms.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large",noContextMenu:!0}))))}))),gs=(0,o.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:a}=e;const s=(0,We.Z)();return"scheduled"===n?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(s):t?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(s):a?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(s):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,s("NoMessages")))})),ps=(0,E.Ds)((e=>e()),200,!1),fs=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,type:s}=t;const o=(0,c.Z1)(e,n);if(!o)return{};const r=(0,c.$W)(e,n,a,s),l="scheduled"===s?(0,c.Fn)(e,n):(0,c.Zw)(e,n),u=(0,c.qS)(e,n,a);if(a!==i._f&&!(l&&u&&l[u]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=o,p=(0,c.G$)(e,n),f=a===i._f&&!r&&!o.unreadCount&&!p&&g&&!g.groupedId,v=(0,c.IK)(e,n);let I;var y;return(0,c.pk)(e,n)&&(I=v.fullInfo?(null===(y=v.fullInfo.botInfo)||void 0===y?void 0:y.description)||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:m,restrictionReason:h,isChannelChat:(0,d.eA)(o),isGroupChat:(0,d.Bf)(o),isCreator:o.isCreator,isChatWithSelf:(0,c.FM)(e,n),isRepliesChat:(0,d.pK)(n),isBot:Boolean(v),messageIds:r,messagesById:l,firstUnreadId:(0,c.It)(e,n,a),isViewportNewest:"thread"!==s||(0,c.b9)(e,n,a),threadFirstMessageId:(0,c.yZ)(e,n,a),focusingId:p,isSelectModeActive:(0,c.CA)(e),botDescription:I,threadTopMessageId:u,hasLinkedChat:o.fullInfo&&"linkedChatId"in o.fullInfo?Boolean(o.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...f&&{lastMessage:g}}}))((e=>{var t,n,i,r,l,u;let{chatId:p,threadId:f,type:v,hasTools:I,onFabToggle:y,onNotchToggle:w,isChatLoaded:Z,isChannelChat:P,isGroupChat:b,canPost:C,isReady:S,isChatWithSelf:M,isRepliesChat:R,isCreator:k,isBot:N,messageIds:T,messagesById:B,firstUnreadId:A,isViewportNewest:x,threadFirstMessageId:L,isRestricted:O,restrictionReason:U,focusingId:F,isSelectModeActive:q,lastMessage:$,botDescription:D,threadTopMessageId:j,hasLinkedChat:G,lastSyncTime:_,withBottomShift:H}=e;const{loadViewportMessages:z,setScrollOffset:V,loadSponsoredMessages:W,loadMessageReactions:X,copyMessagesByIds:K}=(0,a.Sv)(),Y=(0,o.sO)(null),J=(0,o.sO)("thread"===v&&(0,c.Vt)((0,a.Rd)(),p,f)||0),Q=(0,o.sO)(),ee=(0,o.sO)(),te=(0,o.sO)(),ne=(0,o.sO)(),ae=(0,o.sO)(),se=(0,o.sO)(),oe=(0,o.sO)(!1),ie=(0,o.sO)(Boolean($)),[re,ce]=(0,o.eJ)(),le=Boolean(T);(0,Ne.Z)((()=>{le&&(0,E.R3)((()=>{ie.current=!1}))}),[le]),(0,Ne.Z)((()=>{ne.current=A}),[A]),(0,Ne.Z)((()=>{P&&S&&_&&W({chatId:p})}),[p,S,P,_]),(0,Ne.Z)((()=>{le&&(ae.current=ne.current)}),[le]),(0,Ne.Z)((()=>{se.current=F}),[F]),(e=>{(0,o.d4)((()=>{function t(t){if((h.jm&&t.metaKey||!h.jm&&t.ctrlKey)&&"c"===(0,_e.Z)(t)){const n=(0,Rn.Z)();n&&n.length>0&&(t.preventDefault(),e({messageIds:n}))}}return document.addEventListener("keydown",t,!1),()=>{document.removeEventListener("keydown",t,!1)}}),[e])})(K);const de=(0,o.Ye)((()=>{if(!T||!B)return;const e=!j||T[0]&&L!==T[0]?T:[j,...T];if(!e.length)return;const t=e.map((e=>B[e])).filter(Boolean);return Pn((0,g.Xo)(t,["date","id"]),ae.current)}),[T,B,L,j]);(0,Mn.Z)((()=>{if(!T||!B)return;const e=T.filter((e=>{var t;return null===(t=B[e])||void 0===t?void 0:t.reactions}));e.length&&X({chatId:p,ids:e})}),15e3);const ue=(0,o.Ye)((()=>{if("thread"===v)return(0,E.Ds)((()=>z({direction:m.Uq.Around})),1e3,!0,!1)}),[z,T]),{isScrolled:me,updateStickyDates:he}=function(){const[e,t]=(0,ze.Z)(!1),n=(0,Cn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,E.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,E.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const n=function(e,t){const n=e.querySelectorAll(".sticky-date"),a=e.scrollTop;return Array.from(n).find((e=>{const{offsetTop:n,offsetHeight:s}=e,o=n-a;return-s<=o&&o<=(t?60:10)}))}(e,a);n&&n.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,n])}}(),ge=(0,o.sO)(),pe=(0,o.sO)(),fe=(0,o.I4)((()=>{if(oe.current)return void(oe.current=!1);ge.current=!0;const e=Y.current;se.current||he(e,I),ps((()=>{ge.current=!1,(0,E.T2)((()=>{e.parentElement&&(J.current=e.scrollHeight-e.scrollTop,"thread"===v&&V({chatId:p,threadId:f,scrollOffset:J.current}))}))}))}),[he,I,v,V,p,f]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((e=>{let[t]=e;t.target.offsetParent&&ce(t.contentRect.height)}));return e.observe(Y.current),()=>{e.disconnect()}}),[]);const{height:ve}=(0,xt.Z)();(0,o.d4)((()=>{Y.current.dataset.normalHeight=String(Y.current.offsetHeight)}),[ve,C]),(0,o.d4)((()=>{if(!ue||!Z||O||F)return;if(T&&T[T.length-1]>=s.AE)return;const e=Y.current;(!T||T.length<s.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&ue()}),[Z,T,ue,F,O]),(0,Ne.Z)((()=>{if(!T||!te.current)return;const e=te.current.filter((e=>T.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(Q.current=t.id,ee.current=t.getBoundingClientRect().top)}),[T,x,re,I]),(0,yn.Z)((e=>{let[t,n,a]=e;const o=Y.current;te.current=Array.from(o.querySelectorAll(".message-list-item"));const i=T&&t&&T[T.length-1]!==t[t.length-1],r=(null==T?void 0:T[0])!==(null==t?void 0:t[0])&&(null==T?void 0:T.length)===s.hT/2+1,c=i&&!r,l=T&&se.current===T[T.length-1],d=x&&c&&T&&T.length<s.hT/2&&!o.parentElement.classList.contains("force-messages-scroll")&&o.firstElementChild.clientHeight<=2*o.offsetHeight;d&&(o.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{o.parentElement&&o.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=o,g=J.current,p=te.current[te.current.length-1];let f=g-(a||h);c&&(f-=p?p.offsetHeight:0);const v=x&&n&&f<=20;let y;if(c&&v&&!l&&(p&&(0,E.T2)((()=>{(0,En.Z)(o,p,"end",20)})),y=m-h,J.current=Math.max(Math.ceil(m-y),h),!d))return;const w=void 0!==a&&a!==re,Z=Q.current&&o.querySelector(`#${Q.current}`),P=!Z&&ae.current&&o.querySelector(".unread-divider");if(v&&w){if((0,En.N)())return;y=m-h}else Z?(pe.current&&(pe.current=!1,(0,Sn.z)(o)),y=u+(Z.getBoundingClientRect().top-(ee.current||0))):y=P?Math.min(P.offsetTop-(I?60:10),m-g):m-g;(0,Sn.Z)(o,Math.ceil(y)),se.current||(oe.current=!0,(0,E.T2)((()=>{oe.current=!1}))),J.current=Math.max(Math.ceil(m-y),h)}),[T,x,re,I]),(0,wn.Z)((e=>{let[t]=e;void 0!==t&&(0,be.YW)(200+s.fK)}),[q]);const Ie=(0,We.Z)(),ye=Boolean(p&&(0,d.YC)(p)),we=Boolean(!ye&&!P||M||R),Ze=Boolean(!we||P),Pe=(0,d.YC)(p)&&!M&&!N&&(!de&&!$&&T&&(!te.current||0===te.current.length)||1===(null==T?void 0:T.length)&&"contactSignUp"===(null==B||null===(t=B[T[0]])||void 0===t||null===(n=t.content.action)||void 0===n?void 0:n.type)||"contactSignUp"===(null==$||null===(i=$.content)||void 0===i||null===(r=i.action)||void 0===r?void 0:r.type)),Se=b&&k&&1===(null==T?void 0:T.length)&&"chatCreate"===(null==B||null===(l=B[T[0]])||void 0===l||null===(u=l.content.action)||void 0===u?void 0:u.type),Ee=(0,Ce.Z)("MessageList custom-scroll",Ze&&"no-avatars",!C&&"no-composer","pinned"===v&&"type-pinned",H&&"with-bottom-shift",q&&"select-mode-active",me&&"scrolled",!S&&"is-animating");return o.ZP.createElement("div",{ref:Y,className:Ee,onScroll:fe,onMouseDown:bn.q},O?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,U?U.text:"This is a private "+(P?"channel":"chat"))):D?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,un.Z)(Ie(D),["br","emoji","links"]))):Pe?o.ZP.createElement(hs,{userId:p}):!T||de&&!Se?T&&de||$?o.ZP.createElement(us,{chatId:p,messageIds:T||[$.id],messageGroups:de||Pn([$]),isViewportNewest:Boolean(x),isUnread:Boolean(A),withUsers:we,areReactionsInMeta:ye,noAvatars:Ze,containerRef:Y,anchorIdRef:Q,memoUnreadDividerBeforeIdRef:ae,memoFirstUnreadIdRef:ne,threadId:f,type:v,isReady:S,isScrollingRef:ge,isScrollPatchNeededRef:pe,threadTopMessageId:j,hasLinkedChat:G,isSchedule:!!de&&"scheduled"===v,noAppearanceAnimation:!de||!ie.current,onFabToggle:y,onNotchToggle:w}):o.ZP.createElement(ft.Z,{color:"white",backgroundColor:"dark"}):o.ZP.createElement(gs,{chatId:p,type:v,isChatWithSelf:M,isGroupChatJustCreated:Se}))}))),vs=(0,o.X$)((0,a.c$)((e=>{const t=(0,c.Bt)(e);if(!t)return{};const{chatId:n,threadId:a,type:s}=t,o=(0,c.Z1)(e,n);return{messageListType:s,unreadCount:o&&a===i._f&&"thread"===s?o.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:n,messageListType:s,unreadCount:i,withExtraShift:r}=e;const{focusNextReply:c}=(0,a.Sv)(),l=(0,We.Z)(),d=(0,o.sO)(null),u=(0,o.I4)((()=>{if(t)if("thread"===s)c();else{const e=d.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),n=t[t.length-1];if(!n)return;(0,En.Z)(e,n,"end",20)}}),[t,s,c]),m=(0,Ce.Z)("ScrollDownButton",t&&"revealed",!n&&"no-composer",r&&"with-extra-shift");return o.ZP.createElement("div",{ref:d,className:m},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(nt.Z,{color:"secondary",round:!0,onClick:u,ariaLabel:l("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(i)&&o.ZP.createElement("div",{className:"unread-count"},(0,qe.bi)(i))))})));var Is=n(5723);const ys=1280,ws=/\.[^/.]+$/;async function Zs(e,t,a,o){const i=URL.createObjectURL(t),{type:r,size:c}=t;let l,d,u;if(s.oG.has(r))if(a){const t=await(0,At.pt)(i),{width:n,height:a}=t;if(n>ys||a>ys||"image/jpeg"!==r){const t=await an(i,ys/Math.max(n,a),"image/jpeg");return URL.revokeObjectURL(i),Zs(e,await(0,At.gm)(t),!0,o)}"image/jpeg"===r&&(e=e.replace(ws,".jpg")),l={width:n,height:a}}else u=i;else if(s.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,At.jj)(i);l={width:e,height:t,duration:n},u=await(0,At.ud)(i)}else if(s.e7.has(r)){const{duration:e,title:t,performer:a,coverUrl:s}=await async function(e){const{fetchFromUrl:t,selectCover:a}=await n.e(505).then(n.t.bind(n,8505,23)),s=await t(e),{common:{title:o,artist:i,picture:r},format:{duration:c}}=s,l=a(r);return{title:o,performer:i,duration:c,coverUrl:l?`data:${l.format};base64,${l.data.toString("base64")}`:void 0}}(i);d={duration:e||0,title:t,performer:a},u=s}return{blobUrl:i,filename:e,mimeType:r,size:c,quick:l,audio:d,previewBlobUrl:u,...o}}function Ps(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const n=t.getRangeAt(0);n.deleteContents();const a=n.createContextualFragment(e),s=a.lastChild;n.insertNode(a),s?(n.setStartAfter(s),n.setEndAfter(s)):n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}var bs=n(6391);let Cs;function Ss(e){Cs.focus(),e.focus()}h.cj&&(Cs=document.createElement("input"),Cs.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Cs));var Es=n(4784),Ms=n(2400),Rs=n(6389),ks=n(971);const Ns={encoderPath:new URL(n(8973),n.b).href,reuseWorker:!0},Ts={type:"audio/ogg"};let Bs,As,xs;async function Ls(){return Bs||(Bs=n.e(161).then(n.t.bind(n,1161,23)),As=(await Bs).default,xs=new As(Ns)),Bs}async function Os(e){await async function(){await Ls(),await xs.start()}();const t=Date.now();let n;const a=[],s=[];xs.ondataavailable=e=>{a.push(e)};const o=function(t,n){const a=t.sourceNode,o=a.context.createAnalyser();o.fftSize=64,a.connect(o);const i=o.frequencyBinCount,r=new Uint8Array(i);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(r);const n=r.reduce(((e,t)=>e+t),0)/i/255;(t=>{s.push(255*t),e(t)})(n<.1?0:n),requestAnimationFrame(t)}(),()=>{c=!0}}(xs);return{stop:()=>new Promise(((e,i)=>{xs.onstop=()=>{e({blob:new Blob(a,Ts),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},xs.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{xs.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{xs.pause(),n=Date.now(),o()}),e)}}}var Us=n(1262);const Fs=["image/png","image/jpeg","image/gif"];let qs,$s;var Ds=n(3575),js=n(9295);function Gs(e,t,n){const[a,s]=(0,o.eJ)(),{isFrozen:i,updateWhenUnfrozen:r}=function(){const e=(0,o.sO)(!1),t=(0,o.I4)((()=>{e.current=!0}),[]),n=(0,Le.Z)(),a=(0,o.I4)((()=>{e.current&&(e.current=!1,n())}),[n]);return(0,be.ZP)(_s,a),{isFrozen:(0,be.zG)(),updateWhenUnfrozen:t}}(),c=(0,Cn.Z)(t,!0);return(0,Ne.Z)((()=>{i?r():c((()=>{s(e())}))}),[...n,i]),a}function _s(){}const Hs=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,zs=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,Vs={username:"",query:"",canShowHelp:!1,usernameLowered:""},Ws=document.createElement("div");const Xs=(0,E.P2)((e=>e()),500,!0),Ks=/^[\w@]{1,32}\s?/i;var Ys=n(3057);const Js=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"DeleteMessageModal",!t);return n?o.ZP.createElement(n,e):void 0}));function Qs(){return Qs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Qs.apply(this,arguments)}let eo,to=!0;const no=(0,o.X$)((e=>{let{onActivate:t,...n}=e;const a=(0,o.sO)(!1),s=(0,o.I4)((()=>{if(a.current=!0,to)return to=!1,void t();eo&&(clearTimeout(eo),eo=void 0),eo=window.setTimeout((()=>{a.current&&t()}),200)}),[t]),i=(0,o.I4)((()=>{a.current=!1}),[]);return o.ZP.createElement(nt.Z,Qs({},n,{onMouseEnter:h.$b?void 0:s,onMouseLeave:h.$b?void 0:i,onClick:t}))}));var ao=n(5655),so=n(6503),oo=n(2898);const io="src-components-middle-composer-AttachmentMenuBotIcon-module__compact",ro=/#fff/gi,co=(0,o.X$)((e=>{let{icon:t,theme:n}=e;const a=(0,zt.Z)((0,d.ym)(t),!1,i.IU.Text),s=(0,o.Ye)((()=>{if(!a)return"";const e="dark"===n?"rgb(170, 170, 170)":"rgb(112, 117, 121)",t=a.replace(ro,e),s=(new DOMParser).parseFromString(t,"image/svg+xml");return s.querySelectorAll("path").forEach((t=>{t.style.stroke=e,t.style.strokeWidth="0.5px"})),`data:image/svg+xml;utf8,${s.documentElement.outerHTML}`}),[a,n]);return o.ZP.createElement("i",{className:(0,Ce.Z)("src-components-middle-composer-AttachmentMenuBotIcon-module__root",h.FW&&io)},o.ZP.createElement("img",{src:s,alt:"",className:(0,Ce.Z)("src-components-middle-composer-AttachmentMenuBotIcon-module__image",h.FW&&io)}))})),lo=(0,o.X$)((e=>{let{bot:t,theme:n,chatId:s,onMenuOpened:i,onMenuClosed:r}=e;const{callAttachMenuBot:c,toggleBotInAttachMenu:l}=(0,a.Sv)(),d=(0,We.Z)(),u=(0,o.Ye)((()=>{var e;return null===(e=t.icons.find((e=>{let{name:t}=e;return"default_static"===t})))||void 0===e?void 0:e.document}),[t.icons]),[m,h,g]=(0,ze.Z)(),[p,f]=(0,o.eJ)(void 0),v=(0,o.I4)((e=>{e.preventDefault();const t=e.currentTarget.getBoundingClientRect();f({x:t.right,y:t.bottom}),i(),h()}),[i,h]),I=(0,o.I4)((()=>{g(),r()}),[g,r]),y=(0,o.I4)((()=>{f(void 0)}),[]),w=(0,o.I4)((()=>{l({botId:t.id,isEnabled:!1})}),[t.id,l]);return o.ZP.createElement(tt.Z,{key:t.id,customIcon:u&&o.ZP.createElement(co,{icon:u,theme:n}),icon:u?void 0:"bots",onClick:()=>c({botId:t.id,chatId:s}),onContextMenu:v},t.shortName,p&&o.ZP.createElement(oo.Z,null,o.ZP.createElement(yt.Z,{isOpen:m,positionX:"right",style:`left: ${p.x}px;top: ${p.y}px;`,className:"bot-attach-context-menu",autoClose:!0,onClose:I,onCloseAnimationEnd:y},o.ZP.createElement(tt.Z,{icon:"stop",destructive:!0,onClick:w},d("WebApp.RemoveBot")))))})),uo=(0,o.X$)((e=>{let{chatId:t,isButtonVisible:n,canAttachMedia:a,canAttachPolls:i,attachMenuBots:r,isScheduled:c,isPrivateChat:l,onFileSelect:d,onPollCreate:u,theme:m}=e;const[g,p,f]=(0,ze.Z)(),[v,I,y]=(0,so.Z)(g,f),[w,Z,P]=(0,ze.Z)();(0,o.d4)((()=>{g&&y()}),[g,y]);const b=(0,o.I4)((()=>{g?f():p()}),[g,p,f]),C=(0,o.I4)(((e,t)=>{const{files:n}=e.target;n&&n.length>0&&d(Array.from(n),t)}),[d]),S=(0,o.I4)((()=>{(0,ao.g)(Array.from(s.dI).join(","),(e=>C(e,!0)))}),[C]),E=(0,o.I4)((()=>{(0,ao.g)("*",(e=>C(e,!1)))}),[C]),M=(0,We.Z)();if(n)return o.ZP.createElement("div",{className:"AttachMenu"},o.ZP.createElement(no,{id:"attach-menu-button",className:g?"AttachMenu--button activated":"AttachMenu--button",round:!0,color:"translucent",onActivate:b,ariaLabel:"Add an attachment",ariaControls:"attach-menu-controls",hasPopup:!0},o.ZP.createElement("i",{className:"icon-attach"})),o.ZP.createElement(yt.Z,{id:"attach-menu-controls",isOpen:g||w,autoClose:!0,positionX:"right",positionY:"bottom",onClose:f,className:"AttachMenu--menu fluid",onCloseAnimationEnd:f,onMouseEnter:h.$b?void 0:v,onMouseLeave:h.$b?void 0:I,noCloseOnBackdrop:!h.$b,ariaLabelledBy:"attach-menu-button"},!a&&o.ZP.createElement(tt.Z,{className:"media-disabled",disabled:!0},"Posting media content is not allowed in this group."),a&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(tt.Z,{icon:"photo",onClick:S},M("AttachmentMenu.PhotoOrVideo")),o.ZP.createElement(tt.Z,{icon:"document",onClick:E},M("AttachDocument"))),i&&o.ZP.createElement(tt.Z,{icon:"poll",onClick:u},M("Poll")),a&&!c&&l&&Object.values(r).map((e=>o.ZP.createElement(lo,{bot:e,chatId:t,theme:m,onMenuOpened:Z,onMenuClosed:P})))))})),mo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"SymbolMenu",!t);return n?o.ZP.createElement(n,e):void 0})),ho=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"InlineBotTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),go=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"MentionTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var po=n(7146);const fo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"StickerTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var vo=n(9830);const Io=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"BotCommandTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),yo=(0,o.X$)((0,a.c$)(((e,t)=>{let{messageId:n}=t;const{chatId:a}=(0,c.Bt)(e)||{};return a?{message:(0,c.hj)(e,a,n)}:{}}))((e=>{let{isOpen:t,message:n,onClose:s}=e;const{clickBotInlineButton:i}=(0,a.Sv)(),[r,c]=(0,so.Z)(t,s),{isKeyboardSingleUse:l}=n||{},[d,u,m]=(0,ze.Z)(!0),g=(0,o.I4)((()=>{m(),s()}),[s,m]);if((0,o.d4)((()=>{u()}),[u,null==n?void 0:n.keyboardButtons]),n&&n.keyboardButtons)return o.ZP.createElement(yt.Z,{isOpen:t||d,autoClose:l,positionX:"right",positionY:"bottom",onClose:g,className:"BotKeyboardMenu",onCloseAnimationEnd:g,onMouseEnter:h.$b?void 0:r,onMouseLeave:h.$b?void 0:c,noCompact:!0},o.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(nt.Z,{ripple:!0,disabled:"unsupported"===e.type,onClick:()=>i({messageId:n.id,button:e})},e.text))))))))})));var wo=n(3616),Zo=n(7891);const Po=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:n,type:a}=(0,c.Bt)(e)||{};if(!t||!n||!a)return{};const{forwardMessages:{fromChatId:s,toChatId:o,messageIds:i}}=e,r=(0,c.Yy)(e,t,n),l="scheduled"===a?(0,c.wU)(e,t):(0,c._$)(e,t,n),u=e.settings.byKey.animationLevel>=1,m=o===t;let h,g;if(r?h=(0,c.hj)(e,t,r):l?h=(0,c.kK)(e,t,n,a):m&&1===i.length&&(h=(0,c.hj)(e,s,i[0])),r&&h){const{forwardInfo:n}=h,a=(0,c.FM)(e,t);n&&(n.isChannelPost||a)&&(g=(0,c.cv)(e,h)),g||null!=n&&n.hiddenUserName||(g=(0,c.Ur)(e,h))}else m&&(h&&(g=(0,c.cv)(e,h),g||(g=(0,c.Ur)(e,h))),g||(g=(0,d.YC)(s)?(0,c.dy)(e,s):(0,c.Z1)(e,s)));return{replyingToId:r,editingId:l,message:h,sender:g,shouldAnimate:u,forwardedMessagesCount:m?i.length:void 0}}))((e=>{let{replyingToId:t,editingId:n,message:s,sender:i,shouldAnimate:r,forwardedMessagesCount:c,onClear:l}=e;const{setReplyingToId:d,setEditingId:u,focusMessage:m,exitForwardMode:h}=(0,a.Sv)(),g=Boolean((t||n)&&s||i&&c),p=(0,Zo.Z)([c],c?300:void 0),{shouldRender:f,transitionClassNames:v}=(0,Ue.Z)(p&&g,void 0,!r,void 0,!r),I=(0,o.I4)((()=>{t?d({messageId:void 0}):n?u({messageId:void 0}):c&&h(),null==l||l()}),[t,n,c,l,d,u,h]);(0,o.d4)((()=>g?(0,Ge.Z)(I):void 0),[g,I]);const y=(0,o.I4)((()=>{m({chatId:s.chatId,messageId:s.id})}),[m,s]),w=(0,Ce.Z)("ComposerEmbeddedMessage",v),Z=c&&c>1?`${c} forwarded messages`:void 0;if(f)return o.ZP.createElement("div",{className:w},o.ZP.createElement("div",null,o.ZP.createElement(nt.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:I},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Jn,{className:"inside-input",message:s,sender:i,customText:Z,title:n?"Edit Message":void 0,onClick:y})))}))),bo=(0,o.X$)((e=>{const{attachments:t}=e,n=(0,pt.Z)(gt.gl.Extra,"AttachmentModal",!t.length);return n?o.ZP.createElement(n,e):void 0})),Co=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"BotCommandMenu",!t);return n?o.ZP.createElement(n,e):void 0})),So=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"PollModal",!t);return n?o.ZP.createElement(n,e):void 0})),Eo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"DropArea",!t);return n?o.ZP.createElement(n,e):void 0})),Mo=new RegExp(s.FM,"i"),Ro=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a}=t;const s=(0,c.tV)(e,n,a);return{theme:(0,c.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:s}}))((e=>{let{chatId:t,threadId:n,messageText:s,disabled:r,webPagePreview:c,noWebPage:l,theme:d}=e;const{loadWebPagePreview:u,clearWebPagePreview:m,toggleMessageWebPage:h}=(0,a.Sv)(),g=Gs((()=>{const{text:e,entities:t}=(0,f.Z)(s),n=t&&t.find((e=>{let{type:t}=e;return t===i.Vv.TextUrl}));if(n)return n.url;const a=e.match(Mo);return a?a[0]:void 0}),300,[s]);(0,o.d4)((()=>{g?u({text:g}):(m(),h({chatId:t,threadId:n}))}),[t,h,m,g,u,n]),(0,Ne.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t]);const p=Boolean(c&&s.length&&!l&&!r),{shouldRender:v,transitionClassNames:I}=(0,Ue.Z)(p),y=(0,qt.Z)(c,!0),w=(0,o.I4)((()=>{h({chatId:t,threadId:n,noWebPage:!0})}),[t,n,h]);if(!v||!y)return;const{photo:Z,...P}=y,b={content:{webPage:P}};return o.ZP.createElement("div",{className:(0,Ce.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement(nt.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:w},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Aa,{message:b,inPreview:!0,theme:d})))}))),ko=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"SendAsMenu",!t);return n?o.ZP.createElement(n,e):void 0})),No=(0,o.X$)((e=>{let{isOpen:t,onClick:n,text:a,isDisabled:s}=e;const i=(0,o.sO)(null);return(0,o.d4)((()=>{const e=i.current;if(!e)return;const t=e.scrollWidth+1;e.closest(".Composer").style.setProperty("--bot-menu-text-width",`${t}px`)}),[t,a]),(0,o.d4)((()=>{const e=i.current;if(!e)return;const t=e.closest(".Composer");return()=>{t.style.removeProperty("--bot-menu-text-width")}}),[]),o.ZP.createElement(nt.Z,{className:(0,Ce.Z)("bot-menu",t&&"open"),round:!0,color:"translucent",disabled:s,onClick:n,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:(0,Ce.Z)("bot-menu-icon","icon-webapp",t&&"open")}),o.ZP.createElement("span",{ref:i,className:"bot-menu-text"},a))}));var To;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(To||(To={}));const Bo="wonderful-voice-message.ogg",Ao=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,o,r,l,u,m;let{chatId:h,threadId:g,messageListType:p}=t;const f=(0,c.Z1)(e,h),v=h!==s.FV?(0,c.IK)(e,h):void 0,I=Boolean(v),y=(0,c.FM)(e,h),w=Boolean((0,c.dy)(e,h)),Z=I&&(0,c.FT)(e,h),P=(0,c.qy)(e,h),{language:b,shouldSuggestStickers:C}=e.settings.byKey,S=e.emojiKeywords[s.pR],E=b!==s.pR?e.emojiKeywords[b]:void 0,M=Z?Z.id:void 0,R=M?(0,c.hj)(e,h,M):void 0,{currentUserId:k}=e,N=null!=f&&f.fullInfo?(null==f||null===(n=f.fullInfo)||void 0===n?void 0:n.sendAsId)||k:void 0,T=null!=f&&f.sendAsIds&&N&&f.sendAsIds.includes(N)?N:null!=f&&null!==(a=f.adminRights)&&void 0!==a&&a.anonymous?null==f?void 0:f.id:void 0,B=T?(0,c.dy)(e,T):void 0,A=!B&&T?(0,c.Z1)(e,T):void 0,x=(0,c.QV)(e,h),L="scheduled"===p?(0,c.hI)(e,h):(0,c.s)(e,h,g);return{editingMessage:(0,c.kK)(e,h,g,p),connectionState:e.connectionState,draft:(0,c.Ms)(e,h,g),chat:f,isChatWithBot:I,isChatWithSelf:y,isPrivateChat:w,canScheduleUntilOnline:(0,c.Eh)(e,h),isChannel:f?(0,d.eA)(f):void 0,isRightColumnShown:(0,c.Jf)(e),isSelectModeActive:(0,c.CA)(e),withScheduledButton:g===i._f&&"thread"===p&&Boolean(null==P?void 0:P.length),shouldSchedule:"scheduled"===p,botKeyboardMessageId:M,botKeyboardPlaceholder:null==R?void 0:R.keyboardPlaceholder,isForwarding:h===e.forwardMessages.toChatId,pollModal:e.pollModal,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==f||null===(o=f.fullInfo)||void 0===o?void 0:o.members,topInlineBotIds:null===(r=e.topInlineBots)||void 0===r?void 0:r.userIds,currentUserId:k,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:C,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==S?void 0:S.keywords,emojiKeywords:null==E?void 0:E.keywords,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:(null==f?void 0:f.fullInfo)&&f.fullInfo.botCommands,botCommands:null!=v&&v.fullInfo?(null===(l=v.fullInfo.botInfo)||void 0===l?void 0:l.commands)||!1:void 0,botMenuButton:null==v||null===(u=v.fullInfo)||void 0===u||null===(m=u.botInfo)||void 0===m?void 0:m.menuButton,sendAsUser:B,sendAsChat:A,sendAsId:T,editingDraft:L,requestedText:x,attachMenuBots:e.attachMenu.bots,theme:(0,c.Pu)(e)}}))((e=>{let{dropAreaState:t,shouldSchedule:n,canScheduleUntilOnline:r,isReady:c,onDropHide:u,editingMessage:m,chatId:g,threadId:v,messageListType:I,draft:y,chat:w,connectionState:Z,isChatWithBot:P,isChatWithSelf:b,isChannel:C,isRightColumnShown:S,isSelectModeActive:M,isForwarding:R,pollModal:k,botKeyboardMessageId:N,botKeyboardPlaceholder:T,withScheduledButton:B,stickersForEmoji:A,groupChatMembers:x,topInlineBotIds:O,currentUserId:U,lastSyncTime:F,contentToBeScheduled:q,shouldSuggestStickers:$,baseEmojiKeywords:D,emojiKeywords:j,recentEmojis:G,inlineBots:_,isInlineBotLoading:H,botCommands:z,chatBotCommands:V,sendAsUser:W,sendAsChat:X,sendAsId:K,editingDraft:Y,requestedText:J,botMenuButton:Q,attachMenuBots:ee,isPrivateChat:te,theme:ne}=e;const{sendMessage:ae,clearDraft:se,showDialog:oe,setStickerSearchQuery:ie,setGifSearchQuery:ce,forwardMessages:le,openPollModal:de,closePollModal:ue,loadScheduledHistory:me,openChat:he,addRecentEmoji:ge,sendInlineBotResult:pe,loadSendAs:fe,loadFullChat:ve,resetOpenChatWithText:Ie,callAttachMenuBot:ye}=(0,a.Sv)(),we=(0,We.Z)(),Ze=(0,o.sO)(null),[Pe,be]=(0,o.eJ)(""),Se=(0,ks.Y)(Pe),Ee=(0,o.sO)(),Me=(0,Ot.Z)(t),{width:Te}=re.Z.get(),Be=null==w?void 0:w.sendAsIds,Ae=Be&&(Be.length>1||!Be.includes(U)),[xe,Le,Oe]=(0,ze.Z)(),Ue=(0,Rs.Z)(g,v),Fe=(0,o.I4)((()=>{Oe()}),[Oe]),[qe,$e]=(0,Ys.Z)(r,Fe);(0,o.d4)((()=>{Ee.current=void 0}),[g]),(0,o.d4)((()=>{g&&F&&v===i._f&&c&&me({chatId:g})}),[c,g,me,F,v]),(0,o.d4)((()=>{g&&w&&F&&!Be&&c&&(0,d.ZV)(w)&&fe({chatId:g})}),[w,g,c,F,fe,Be]),(0,o.d4)((()=>{g&&w&&F&&!w.fullInfo&&c&&(0,d.ZV)(w)&&ve({chatId:g})}),[w,g,c,F,ve]);const De=(0,o.sO)(!1);(0,Ne.Z)((e=>{let[t,n]=e;De.current=Boolean(g===t&&Be&&!n)}),[g,Be]),(0,o.bt)((()=>{Ze.current&&(Ze.current.innerHTML='<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#FFF" class="corner"/></g></svg>')}),[]);const[je,_e]=(0,o.eJ)([]),[He,Ve,Xe]=(0,ze.Z)(),[Ke,Ye,Je]=(0,ze.Z)(),[Qe,et,tt]=(0,ze.Z)(),[at,st,ot]=(0,ze.Z)(),[it,ct,lt]=(0,ze.Z)(),[dt,ut]=(0,ze.Z)(),[mt,ht,gt]=(0,ze.Z)(),{startRecordingVoice:pt,stopRecordingVoice:ft,pauseRecordingVoice:vt,activeVoiceRecording:It,currentRecordTime:yt,recordButtonRef:wt,startRecordTimeRef:Zt}=(()=>{const e=(0,o.sO)(null),[t,n]=(0,o.eJ)(),a=(0,o.sO)(),[s,i]=(0,o.eJ)();(0,o.d4)((()=>{h.s$&&h.mh&&Ls()}),[]);const r=(0,o.I4)((async()=>{try{const{stop:t,pause:s}=await Os((t=>{e.current&&(a.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),i(Date.now()))}));a.current=Date.now(),i(Date.now()),n({stop:t,pause:s})}catch(e){console.error(e)}}),[]),c=(0,o.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),l=(0,o.I4)((()=>{if(t){n(void 0),a.current=void 0,i(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,Ge.Z)(l):void 0),[t,l]),{startRecordingVoice:r,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:s,recordButtonRef:e,startRecordTimeRef:a}})();(0,Mn.Z)((()=>{Ue({type:"recordAudio"})}),It&&s.o_),(0,o.d4)((()=>{It||Ue({type:"cancel"})}),[It,Ue]);const Pt=m?To.Edit:!h.mh||It||Pe&&!je.length||R?n?To.Schedule:To.Send:To.Record,bt=!n,{isMentionTooltipOpen:Ct,closeMentionTooltip:St,insertMention:Et,mentionFilteredUsers:Mt}=(0,js.Z)(!je.length,Se,be,void 0,x,O,U),{isOpen:Rt,id:kt,isGallery:Tt,switchPm:Bt,results:At,closeTooltip:xt,help:Lt,loadMore:Ut}=function(e,t,n,s){const{queryInlineBot:i,resetInlineBot:r}=(0,a.Sv)(),[c,l,d]=(0,ze.Z)(),{username:u,query:m,canShowHelp:h,usernameLowered:g}=Gs((()=>function(e){const t=function(e){return Ws.innerHTML=e.replace(/<br>/g,"\n"),Ws.innerText}(e),n=t.match(Hs);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(zs),usernameLowered:n[1].toLowerCase()}:Vs}(n)),300,[n])||{},p=(0,Ot.Z)(m),f=(0,Ot.Z)(u),v=g?null==s?void 0:s[g]:void 0,{id:I,switchPm:y,offset:w,results:Z,isGallery:P,help:b}=v||{};(0,o.d4)((()=>{p!==m&&d()}),[p,m,d]),(0,o.d4)((()=>{e&&g&&t&&i({chatId:t,username:g,query:m})}),[m,e,i,t,g]);const C=(0,o.I4)((()=>{i({chatId:t,username:g,query:m,offset:w})}),[w,t,m,i,g]);return(0,o.d4)((()=>{e&&I&&(y||null!=Z&&Z.length)?l():d()}),[I,e,l,Z,y,d]),f!==u&&r({username:f}),{isOpen:c,id:I,isGallery:P,switchPm:y,results:Z,closeTooltip:d,help:h&&b?`@${u} ${b}`:void 0,loadMore:C}}(Boolean(!je.length&&F),g,Pe,_),{isOpen:Ft,close:qt,filteredBotCommands:$t}=function(e,t,n,a){const[s,i,r]=(0,ze.Z)(),[c,l]=(0,o.eJ)(),d=(0,o.I4)((e=>{n||a?Xs((()=>{const t=(n||a||[]).filter((t=>{let{command:n}=t;return!e||n.includes(e)}));l(t&&t.length?t:void 0)})):l(void 0)}),[n,a]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,Ms._)(t.substr(1)).match(Ks);d(e?e[0]:"")}else l(void 0);else l(void 0)}),[d,t,e,r]),(0,o.d4)((()=>{c&&c.length&&t.length>0?i():r()}),[c,t.length,i,r]),{isOpen:s,close:r,filteredBotCommands:c}}(Boolean(z&&z.length||V&&V.length),Pe,z,V),{isContextMenuOpen:Dt,handleContextMenu:jt,handleContextMenuClose:Gt,handleContextMenuHide:_t}=(0,Bn.Z)(wt,!(Pt===To.Send&&bt)),{canSendStickers:Ht,canSendGifs:zt,canAttachMedia:Vt,canAttachPolls:Wt,canAttachEmbedLinks:Xt}=(0,o.Ye)((()=>(0,d.H5)(w,P)),[w,P]),Kt=w&&(0,d.Nl)(w),Yt=(0,d.Hd)(w),{isStickerTooltipOpen:Jt,closeStickerTooltip:Qt}=function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=(0,o.Ye)((()=>(0,Ms._)(t).trim()),[t]),{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,a.Sv)(),l=h.op&&1===(0,Es.Z)(i)||!h.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),d=Boolean(n)&&l;return(0,o.d4)((()=>{var t;s||(e&&l?r({emoji:h.op?i:null===(t=i.match(/alt="(.+)"/))||void 0===t?void 0:t[1]}):!d&&l||c())}),[t,l,c,r,e,s]),{isStickerTooltipOpen:d,closeStickerTooltip:c}}(Boolean($&&Ht&&!je.length),Pe,A,!c),{isEmojiTooltipOpen:en,closeEmojiTooltip:tn,filteredEmojis:nn,insertEmoji:an}=(0,Ds.Z)(Boolean($&&Ht&&!je.length),Se,G,void 0,be,D,j,!c),sn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.R2;const n=window.getSelection();let a;a=t===s.R2?document.querySelector(s.Ed):document.getElementById(t);const o=(0,un.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(n.rangeCount){const e=n.getRangeAt(0);if((0,bs.R)(e,t))return Ps(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}be(`${Se.current}${o}`),requestAnimationFrame((()=>{(0,Is.Z)(a)}))}),[Se]),on=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,bs.R)(t,s.R2))return void document.execCommand("delete",!1)}be(function(e){const t=document.createElement("div");t.contentEditable="true",t.style.position="absolute",t.style.left="-10000px",t.style.top="-10000px",t.innerHTML=e,document.body.appendChild(t);let n=t.lastChild;if(n.lastChild)for(;n.lastChild;)n=n.lastChild;const a=n.textContent.length,s=document.createRange(),o=window.getSelection();s.setStart(n,a),s.setEnd(n,a),o.removeAllRanges(),o.addRange(s),document.execCommand("delete",!1);const i=t.innerHTML;return document.body.removeChild(t),i}(Se.current))}),[Se]),rn=(0,o.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||be(""),_e(l.D),Qt(),St(),tn(),h.wB?setTimeout((()=>tt()),350):tt()}),[Qt,St,tn,tt]),cn=(0,o.sO)();cn.current=ft,(0,o.d4)((()=>()=>{cn.current(),rn()}),[g,rn,cn]);const[ln,dn]=((e,t,n,i,r,c,l,u,m,h)=>{const{editMessage:g,setEditingDraft:p}=(0,a.Sv)();(0,wn.Z)((e=>{let[a]=e;if(!n)return;if((null==a?void 0:a.id)===n.id)return;const o=(0,Ca.z)(null!=h&&h.text.length?h:n.content.text);t(o),requestAnimationFrame((()=>{const e=document.querySelector(s.Ed);e&&(0,Is.Z)(e,!0)}))}),[n,t]),(0,o.d4)((()=>{if(n)return()=>{const t=(0,f.Z)(e.current),n=t.text.length?t:void 0;p({chatId:c,threadId:l,type:u,text:n})}}),[c,n,e,p,l,u]);const v=(0,o.I4)((()=>{m&&(0,E.T2)((()=>{t((0,Ca.z)(m));const e=document.querySelector(s.Ed);e&&requestAnimationFrame((()=>{(0,Is.Z)(e,!0)}))}))}),[m,t]),I=(0,o.I4)((()=>{i(),v()}),[i,v]),y=(0,o.I4)((()=>{const{text:t,entities:a}=(0,f.Z)(e.current);n&&(t||(0,d.u8)(n)?(g({messageId:n.id,text:t,entities:a}),i(),v()):r())}),[g,n,e,r,i,v]),w=(0,o.I4)((()=>{if(!n)return;const t=(0,f.Z)(e.current),a=t.text.length?t:void 0;p({chatId:c,threadId:l,type:u,text:a})}),[c,n,e,p,l,u]);return(0,Re.Z)(w),ke(w),[y,I]})(Se,be,m,rn,ct,g,v,I,y,Y);((e,t,n,i,r,c)=>{const{saveDraft:l,clearDraft:d}=(0,a.Sv)(),u=(0,o.I4)(((e,t)=>{const n=i.current;c||(n.length?l({chatId:e,threadId:t,draft:(0,f.Z)(n)}):void 0!==n&&d({chatId:e,threadId:t}))}),[d,c,i,l]),m=(0,o.Ye)((()=>(0,E.Ds)((e=>e()),s.r_,!1)),[t]),g=(0,Ot.Z)(t),p=(0,Ot.Z)(n);(0,o.d4)((()=>(qs=t,$s=n,()=>{qs=void 0,$s=void 0,u(t,n)})),[t,n,u]),(0,o.d4)((()=>{t===g&&n===p||!c&&e&&(r((0,Ca.z)(e)),h.$b||requestAnimationFrame((()=>{const e=document.querySelector(s.Ed);e&&(0,Is.Z)(e,!0)})))}),[t,n,e,r,u,g,p,c]);const v=i.current,I=(0,Ot.Z)(v);(0,o.d4)((()=>{t&&n&&g===t&&p===n&&I!==v&&(v.length?m((()=>{qs===t&&$s===n&&u(t,n)})):u(t,n))}),[t,v,g,I,p,m,n,u]);const y=(0,o.I4)((()=>{t&&n&&u(t,n)}),[t,n,u]);(0,Re.Z)(y),ke(y)})(y,g,v,Se,be,m),((e,t,n)=>{(0,o.d4)((()=>{async function a(a){if(!a.clipboardData)return;const o=document.activeElement;if(o&&![s.R2,s.nY].includes(o.id))return;const i=a.clipboardData.getData("text").substring(0,4096),{items:r}=a.clipboardData;let c=[];if(a.preventDefault(),r.length>0&&(c=await(0,Us.Z)(r)),0!==c.length||i){if(c.length>0&&!n){const e=await Promise.all(c.map((e=>Zs(e.name,e,1===c.length&&Fs.includes(e.type)))));t((t=>t.concat(e)))}i&&e(i,null==o?void 0:o.id)}}return document.addEventListener("paste",a,!1),()=>{document.removeEventListener("paste",a,!1)}}),[e,n,t])})(sn,_e,m);const mn=(0,o.I4)((()=>{m&&dn()}),[m,dn]),hn=(0,o.I4)((async(e,t)=>{_e(await Promise.all(e.map((e=>Zs(e.name,e,t)))))}),[]),pn=(0,o.I4)((async(e,t)=>{_e([...je,...await Promise.all(e.map((e=>Zs(e.name,e,t))))])}),[je]),fn=(0,o.I4)((()=>{_e(l.D)}),[]),vn=(0,o.I4)((async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;if("connectionStateReady"!==Z)return;let n=je;if(It){const e=await ft();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await Zs(Bo,t,!1,{voice:{duration:a,waveform:s}})]}}const{text:o,entities:i}=(0,f.Z)(Se.current);if(!n.length&&!o&&!R)return;const{serverTimeOffset:r}=(0,a.Rd)(),c=n.length?1024:4096;if((null==o?void 0:o.length)>c){const e=o.length-c;return void oe({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const l=document.querySelector(s.Ed);if(n.length||o){if(Yt&&!Kt){const e=(0,p.b)(r),t=Ee.current&&Math.floor(e-Ee.current),n=Yt.nextSendDate&&Yt.nextSendDate>e;if(t&&t<Yt.seconds||n){const a=n?Yt.nextSendDate-e:Yt.seconds-t;return oe({data:{message:we("SlowModeHint",(0,L.k9)(a)),isSlowMode:!0,hasErrorKey:!1}}),void(null==l||l.blur())}}ae({text:o,entities:i,attachments:n,scheduledAt:t,isSilent:e})}R&&le({scheduledAt:t,isSilent:e}),Ee.current=(0,p.b)(r),se({chatId:g,localOnly:!0}),h.cj&&l&&l===document.activeElement&&Ss(l),requestAnimationFrame((()=>{rn()}))}),[Z,je,It,R,se,g,rn,ft,oe,Yt,Kt,ae,le,we,Se]),In=(0,o.I4)((()=>{"webApp"===(null==Q?void 0:Q.type)&&ye({botId:g,chatId:g,isFromBotMenu:!0,url:Q.url})}),[Q,ye,g]),yn=(0,o.I4)((()=>{tt(),Ye()}),[tt,Ye]),Zn=(0,o.I4)((()=>{Je(),ot(),et()}),[Je,ot,et]),Pn=(0,o.I4)(((e,t)=>{if(e&&"queryId"in e){const{id:n,queryId:a,isSilent:s}=e;return void pe({id:n,queryId:a,scheduledAt:t,isSilent:s})}const{isSilent:n,...a}=e||{};e&&0!==Object.keys(a).length?ae({...e,scheduledAt:t}):vn(Boolean(n),t)}),[vn,pe,ae]);(0,o.d4)((()=>{q&&qe((e=>{Pn(q,e)}))}),[q,Pn,qe]),(0,o.d4)((()=>{J&&(be(J),Ie(),requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Is.Z)(e,!0)})))}),[J,Ie]);const bn=(0,o.I4)((function(e,t,a){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e={...e,isPreloadedGlobally:!0},n||a?(Le(),qe((n=>{Oe(),Pn({sticker:e,isSilent:t},n),requestAnimationFrame((()=>{rn(s)}))}))):(ae({sticker:e,isSilent:t}),requestAnimationFrame((()=>{rn(s)})))}),[n,Le,qe,Oe,Pn,rn,ae]),Cn=(0,o.I4)(((e,t,a)=>{n||a?(Le(),qe((n=>{Oe(),Pn({gif:e,isSilent:t},n),requestAnimationFrame((()=>{rn(!0)}))}))):(ae({gif:e,isSilent:t}),requestAnimationFrame((()=>{rn(!0)})))}),[n,Le,qe,Oe,Pn,rn,ae]),Sn=(0,o.I4)(((e,t,a)=>{if("connectionStateReady"!==Z)return;n||a?qe((n=>{Pn({id:e.id,queryId:e.queryId,isSilent:t},n)})):pe({id:e.id,queryId:e.queryId,isSilent:t});const o=document.querySelector(s.Ed);h.cj&&o&&o===document.activeElement&&Ss(o),se({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{rn()}))}),[g,se,Z,Pn,qe,rn,pe,n]),En=(0,o.I4)((()=>{se({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{rn()}))}),[g,se,rn]),Rn=(0,o.I4)((e=>{n?(qe((t=>{Pn({poll:e},t)})),ue()):(ae({poll:e}),ue())}),[ue,Pn,qe,ae,n]),kn=(0,o.I4)((()=>{n?qe((e=>{Pn({isSilent:!0},e)})):vn(!0)}),[Pn,vn,qe,n]),Nn=(0,o.I4)((e=>{"stickers"===e?(ie({query:""}),ce({query:void 0})):(ce({query:""}),ie({query:void 0}))}),[ie,ce]),Tn=(0,o.I4)((()=>{const e=document.querySelector(s.Ed);h.wB&&e===document.activeElement?(null==e||e.blur(),setTimeout((()=>{Je(),et()}),100)):et()}),[et,Je]),An=(0,o.I4)((()=>{const e=document.querySelector(s.Ed);if(!h.wB||e!==document.activeElement)return Je(),tt(),void st();null==e||e.blur(),setTimeout((()=>{Je(),tt(),st()}),100)}),[Je,tt,st]),xn=(0,o.I4)((()=>{he({id:g,threadId:v,type:"scheduled"})}),[he,g,v]);(0,o.d4)((()=>{S&&h.wB&&tt()}),[S,tt]),(0,o.d4)((()=>{c&&(M?ht():setTimeout((()=>{gt()}),200))}),[M,gt,ht,c]);const Ln=(0,o.I4)((()=>{switch(Pt){case To.Send:vn();break;case To.Record:pt();break;case To.Edit:ln();break;case To.Schedule:It&&vt(),qe((e=>{Pn({},e)}))}}),[Pt,vn,pt,ln,It,qe,vt,Pn]),On=Pt===To.Record&&!Vt,Un=(0,Ot.Z)(m,!0),Fn=m||Un,qn=new Date;qn.setSeconds(0),qn.setMilliseconds(0);const $n=new Date;$n.setFullYear($n.getFullYear()+1);let Dn="SendMessage";switch(Pt){case To.Edit:Dn="Save edited message";break;case To.Record:Dn=On?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const jn=(0,Ce.Z)("Composer",!M&&"shown",mt&&"hover-disabled"),Gn=(0,Ce.Z)("mobile-symbol-menu-button",!c&&"not-ready",dt?Qe&&"menu-opened":Qe&&"is-loading"),_n=(0,o.I4)((()=>{qe((e=>{Pn({},e)}))}),[Pn,qe]),Hn=Pt===To.Edit?ln:Pt===To.Schedule?_n:vn,zn=Q&&"commands"===(null==Q?void 0:Q.type);return o.ZP.createElement("div",{className:jn},Vt&&c&&o.ZP.createElement(Eo,{isOpen:t!==Nt.t.None,withQuick:t===Nt.t.QuickFile||Me===Nt.t.QuickFile,onHide:u,onFileSelect:hn}),o.ZP.createElement(bo,{chatId:g,threadId:v,canShowCustomSendMenu:bt,attachments:je,caption:je.length?Pe:"",groupChatMembers:x,currentUserId:U,recentEmojis:G,isReady:c,isChatWithSelf:b,onCaptionUpdate:be,baseEmojiKeywords:D,emojiKeywords:j,addRecentEmoji:ge,shouldSchedule:n,onSendSilent:kn,onSend:vn,onSendScheduled:_n,onFileAppend:pn,onClear:fn}),o.ZP.createElement(So,{isOpen:k.isOpen,isQuiz:k.isQuiz,shouldBeAnonimous:C,onClear:ue,onSend:Rn}),Fn&&o.ZP.createElement(Js,{isOpen:it,isSchedule:"scheduled"===I,onClose:lt,message:Fn}),o.ZP.createElement(ko,{isOpen:at,onClose:ot,chatId:g,selectedSendAsId:K,sendAsIds:Be}),o.ZP.createElement(go,{isOpen:Ct,onClose:St,onInsertUserName:Et,filteredUsers:Mt}),o.ZP.createElement(ho,{isOpen:Rt,botId:kt,isGallery:Tt,inlineBotResults:At,switchPm:Bt,onSelectResult:Sn,loadMore:Ut,onClose:xt,isSavedMessages:b,canSendGifs:zt}),o.ZP.createElement(Io,{isOpen:Ft,withUsername:Boolean(V),botCommands:$t,onClick:En,onClose:qt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:Ze}),o.ZP.createElement(Po,{onClear:mn}),o.ZP.createElement(Ro,{chatId:g,threadId:v,messageText:je.length?"":Pe,disabled:!Xt}),o.ZP.createElement("div",{className:"message-input-wrapper"},P&&Q&&"webApp"===Q.type&&!m&&o.ZP.createElement(No,{isOpen:!Pe&&!It,onClick:In,text:Q.text,isDisabled:Boolean(It)}),P&&zn&&!1!==z&&!It&&!m&&o.ZP.createElement(no,{className:(0,Ce.Z)("bot-commands",Ke&&"activated"),round:!0,disabled:void 0===z,color:"translucent",onActivate:yn,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),Ae&&(W||X)&&o.ZP.createElement(nt.Z,{round:!0,color:"translucent",onClick:at?ot:An,ariaLabel:we("SendMessageAsTitle"),className:(0,Ce.Z)("send-as-button",De.current&&"appear-animation")},o.ZP.createElement(gn.Z,{user:W,chat:X,size:"tiny"})),h.wB?o.ZP.createElement(nt.Z,{className:Gn,round:!0,color:"translucent",onClick:Qe?tt:Tn,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),Qe&&!dt&&o.ZP.createElement(rt.Z,{color:"gray"})):o.ZP.createElement(no,{className:Qe?"activated":"",round:!0,color:"translucent",onActivate:Zn,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(wo.Z,{id:"message-input-text",chatId:g,threadId:v,html:je.length?"":Pe,placeholder:It&&Te<=600?"":T||we("Message"),forcedPlaceholder:Lt,canAutoFocus:c&&!je.length,shouldSuppressFocus:h.wB&&Qe,shouldSuppressTextFormatter:en||Ct||Rt,onUpdate:be,onSend:Hn,onSuppressedFocus:tt}),H&&Boolean(kt)&&o.ZP.createElement(rt.Z,{color:"gray"}),B&&o.ZP.createElement(nt.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:xn,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),N&&!It&&!m&&o.ZP.createElement(no,{className:He?"activated":"",round:!0,color:"translucent",onActivate:Ve,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),It&&yt&&o.ZP.createElement("span",{className:"recording-state"},(0,L.rM)(yt-Zt.current)),o.ZP.createElement(fo,{chatId:g,threadId:v,isOpen:Jt,onStickerSelect:bn}),o.ZP.createElement(vo.Z,{isOpen:en,emojis:nn,onClose:tn,onEmojiSelect:an,addRecentEmoji:ge}),o.ZP.createElement(uo,{chatId:g,isButtonVisible:!It&&!m,canAttachMedia:Vt,canAttachPolls:Wt,onFileSelect:hn,onPollCreate:de,isScheduled:n,isPrivateChat:te,attachMenuBots:ee,theme:ne}),N&&o.ZP.createElement(yo,{messageId:N,isOpen:He,onClose:Xe}),z&&o.ZP.createElement(Co,{isOpen:Ke,botCommands:z,onClose:Je}),o.ZP.createElement(mo,{chatId:g,threadId:v,isOpen:Qe||xe,canSendGifs:zt,canSendStickers:Ht,onLoad:ut,onClose:tt,onEmojiSelect:sn,onStickerSelect:bn,onGifSelect:Cn,onRemoveSymbol:on,onSearchOpen:Nn,addRecentEmoji:ge}))),It&&o.ZP.createElement(nt.Z,{round:!0,color:"danger",className:"cancel",onClick:ft,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(nt.Z,{ref:wt,round:!0,color:"secondary",className:(0,Ce.Z)(Pt,!c&&"not-ready",It&&"recording"),disabled:On,ariaLabel:we(Dn),onClick:Ln,onContextMenu:Pt===To.Send&&bt?jt:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-schedule"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),bt&&o.ZP.createElement(po.Z,{isOpen:Dt,onSendSilent:b?void 0:kn,onSendSchedule:n?void 0:_n,onClose:Gt,onCloseAnimationEnd:_t,isSavedMessages:b}),$e)}))),xo=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,pt.Z)(gt.gl.Extra,"MobileSearch",!t,!0);return n?o.ZP.createElement(n,e):void 0})),Lo=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,pt.Z)(gt.gl.Extra,"MessageSelectToolbar",!t);return n?o.ZP.createElement(n,e):void 0})),Oo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"UnpinAllMessagesModal",!t);return n?o.ZP.createElement(n,e):void 0})),Uo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"PaymentModal",!t);return n?o.ZP.createElement(n,e):void 0})),Fo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"ReceiptModal",!t);return n?o.ZP.createElement(n,e):void 0})),qo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"SeenByModal",!t);return n?o.ZP.createElement(n,e):void 0})),$o=(0,o.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,pt.Z)(gt.gl.Extra,"EmojiInteractionAnimation",!t);return n?o.ZP.createElement(n,e):void 0})),Do=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"ReactorListModal",!t);return n?o.ZP.createElement(n,e):void 0})),jo=h.wB?450+s.fK:void 0;function Go(e){return"file"===e.kind&&e.type&&s.oG.has(e.type)}const _o=(0,o.X$)((0,a.c$)((e=>{const t=(0,c.Pu)(e),{isBlurred:n,background:a,backgroundColor:s,patternColor:o}=e.settings.themes[t]||{},{messageLists:r}=e.messages,l=(0,c.Bt)(e),{isLeftColumnShown:u,chats:{listIds:m},activeEmojiInteractions:g,lastSyncTime:p}=e,f={theme:t,customBackground:a,backgroundColor:s,patternColor:o,isLeftColumnShown:u,isRightColumnShown:(0,c.Jf)(e),isBackgroundBlurred:n,isMobileSearchActive:Boolean(h.wB&&(0,c.n5)(e)),isSelectModeActive:(0,c.CA)(e),isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),isSeenByModalOpen:Boolean(e.seenByModal),isReactorListModalOpen:Boolean(e.reactorModal),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),activeEmojiInteractions:g,lastSyncTime:p};if(!l||!m.active)return f;const{chatId:v,threadId:I,type:y}=l,w=(0,d.YC)(v),Z=(0,c.Z1)(e,v),P=(0,c.IK)(e,v),b=(0,c.KB)(e,v),{chatId:C,messageId:S}=e.audioPlayer,E=Z&&(0,d.Qm)(Z,I),M=(0,c.pk)(e,v),R="pinned"===y,k="scheduled"===y,N="thread"===y&&I===i._f,T=Boolean(Z&&(0,d.eA)(Z)),B=Boolean(Z&&N&&(T||(0,d.ZV)(Z))&&Z.isNotJoined),A=Boolean(P&&(0,c.s4)(e,P.id)),x=!A&&M;return{...f,chatId:v,threadId:I,messageListType:y,isPrivate:w,areChatSettingsLoaded:Boolean(null==Z?void 0:Z.settings),canPost:!R&&(!Z||E)&&!M,isPinnedMessageList:R,isScheduledMessageList:k,currentUserBannedRights:null==Z?void 0:Z.currentUserBannedRights,defaultBannedRights:null==Z?void 0:Z.defaultBannedRights,hasPinnedOrAudioPlayer:I!==i._f||Boolean(!R&&(null==b?void 0:b.length))||Boolean(C&&S),pinnedMessagesCount:b?b.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:r,isChannel:T,canSubscribe:B,canStartBot:x,canRestartBot:A}}))((e=>{let{chatId:t,threadId:n,messageListType:i,isPrivate:r,isPinnedMessageList:c,messageLists:l,canPost:u,currentUserBannedRights:m,defaultBannedRights:g,hasPinnedOrAudioPlayer:p,pinnedMessagesCount:f,customBackground:v,theme:I,backgroundColor:y,patternColor:w,isLeftColumnShown:Z,isRightColumnShown:P,isBackgroundBlurred:b,isMobileSearchActive:C,isSelectModeActive:S,isPaymentModalOpen:E,isReceiptModalOpen:M,isSeenByModalOpen:R,isReactorListModalOpen:k,animationLevel:N,shouldSkipHistoryAnimations:T,currentTransitionKey:B,isChannel:A,areChatSettingsLoaded:x,canSubscribe:L,canStartBot:O,canRestartBot:U,activeEmojiInteractions:F,lastSyncTime:q}=e;const{openChat:$,unpinAllMessages:D,loadUser:j,loadChatSettings:G,closeLocalTextSearch:_,exitMessageSelectMode:H,closePaymentModal:z,clearReceipt:V,joinChannel:W,sendBotCommand:X,restartBot:K}=(0,a.Sv)(),{width:Y}=(0,xt.Z)(),J=(0,We.Z)(),[Q,ee]=(0,o.eJ)(Nt.t.None),[te,ne]=(0,o.eJ)(),[ae,re]=(0,o.eJ)(),[ce,le]=(0,o.eJ)(!1),de=p&&(Y<s.l3||P&&Y>s._m&&Y<s.QU||Y>=s.ks&&Y<s.jT),ue=(0,Lt.Z)(t,jo),me=(0,Lt.Z)(n,jo),he=(0,Lt.Z)(i,jo),ge=(0,Lt.Z)(L,jo),pe=(0,Lt.Z)(O,jo),fe=(0,Lt.Z)(U,jo),ve=(0,Lt.Z)(u,jo)&&!fe&&!pe&&!ge,Ie=(0,Lt.Z)(de,jo),ye=(0,Lt.Z)(te,jo),we=(0,Lt.Z)(A,jo),Ze=(0,Ot.Z)(B),Pe=void 0!==Ze&&Ze<B?Ze:void 0,{isReady:be,handleOpenEnd:Se,handleSlideStop:Ee}=function(e,t,n,a){const[s,i]=(0,o.eJ)(!h.wB),r=(0,Le.Z)(),c=void 0!==n&&n!==t;return c&&(e?i(!1):r()),(0,Ne.Z)((()=>{e||i(!0)}),[e]),{isReady:s&&!c,handleOpenEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&i(Boolean(a))}:void 0,handleSlideStop:e?function(){i(!0)}:void 0}}(!T&&N!==s.oB,B,Ze,t);(0,o.d4)((()=>t?(0,Ge.Z)((()=>{$({id:void 0})})):void 0),[t,$]),(0,Ne.Z)((()=>{ee(Nt.t.None),ne(void 0),re(void 0)}),[t]),(0,o.d4)((()=>{const{visualViewport:e}=window;if(!e)return;const t=()=>{window.visualViewport.height!==document.documentElement.clientHeight?document.body.classList.add("keyboard-visible"):document.body.classList.remove("keyboard-visible")};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}}),[]),(0,o.d4)((()=>{r&&j({userId:t})}),[t,r,j]),(0,o.d4)((()=>{!x&&q&&G({chatId:t})}),[t,r,x,q,G]);const Me=(0,o.I4)((e=>{if(h.$b)return;const{items:t}=e.dataTransfer||{},n=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(Go);ee(n?Nt.t.QuickFile:Nt.t.Document)}),[]),Re=(0,o.I4)((()=>{ee(Nt.t.None)}),[]),ke=(0,o.I4)((()=>{le(!0)}),[]),Te=(0,o.I4)((()=>{le(!1)}),[]),Be=(0,o.I4)((()=>{D({chatId:t}),Te(),$({id:t})}),[D,$,Te,t]),Ae=(0,o.I4)((()=>{$({id:t})}),[$,t]),xe=(0,o.I4)((()=>{W({chatId:t})}),[W,t]),Ue=(0,o.I4)((()=>{X({command:"/start"})}),[X]),Fe=(0,o.I4)((()=>{K({chatId:t})}),[t,K]),qe=((e,t)=>{const[n,a]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?a(t):Bt.fetch(s.fo,e,Bt.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,At.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(I,v),$e=(0,Ce.Z)(Ie&&"has-header-tools",v&&"custom-bg-image",y&&"custom-bg-color",v&&b&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),De=(0,Ce.Z)("messaging-disabled",!S&&"shown"),je=(0,d.q8)(J,m,g),{composerHiddenScale:_e,toolbarHiddenScale:He,composerTranslateX:ze,toolbarTranslateX:Xe,unpinHiddenScale:Ke,toolbarForUnpinHiddenScale:Ye}=(0,o.Ye)((()=>function(e,t){const n=e<=s.l3?16:32,a=function(e){if(e>s._m){const t=Math.min(Math.max(.25*e,ie),oe),n=Math.min(.25*e,oe);return Math.min(e-t-n,se)}if(e>s.ks){const t=Math.min(Math.max(.4*e,ie),oe);return Math.min(e-t,se)}return e>se?se:e}(e),o=e<=s.l3?54:64,i=t?a-n-o:a-n,r=e>s.l3?Math.min(a-n,512):a-n,c=r/i,l=i/r;return{composerHiddenScale:c,toolbarHiddenScale:l,composerTranslateX:t?o/2*l:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:r/258,toolbarForUnpinHiddenScale:258/r}}(Y,ve)),[ve,Y]),Je=(0,Ce.Z)("middle-column-footer",!ve&&"no-composer",ve&&ae&&!S&&"with-notch");(0,Oe.ZP)(ue&&me,(()=>{$({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==l?void 0:l.map(Tt.q))||[]),(0,Oe.ZP)(C,_),(0,Oe.ZP)(S,H);const Qe=Boolean(!c&&!ve&&!fe&&!pe&&!ge&&je),et=Boolean(fe||ge||pe||c),tt=Boolean(Qe||S||c);return o.ZP.createElement("div",{id:"MiddleColumn",className:$e,onTransitionEnd:Se,style:`\n --composer-hidden-scale: ${_e};\n --toolbar-hidden-scale: ${He};\n --unpin-hidden-scale: ${Ke};\n --toolbar-unpin-hidden-scale: ${Ye};\n --composer-translate-x: ${ze}px;\n --toolbar-translate-x: ${Xe}px;\n --pattern-color: ${w};\n --theme-background-color:\n ${y||("dark"===I?s.It:s.p3)};\n `,onClick:h.p7&&Z?Ae:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:qe?`--custom-background: ${qe}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),ue&&me&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:ve?Me:void 0},o.ZP.createElement(In,{chatId:ue,threadId:me,messageListType:he,isReady:be}),o.ZP.createElement(Ve.Z,{name:T?"none":N===s.zy?"slide":"fade",activeKey:B,shouldCleanup:!0,cleanupExceptionKey:Pe,onStop:Ee},o.ZP.createElement(fs,{key:`${ue}-${me}-${he}`,chatId:ue,threadId:me,type:he,canPost:ve,hasTools:Ie,onFabToggle:ne,onNotchToggle:re,isReady:be,withBottomShift:et}),o.ZP.createElement("div",{className:Je},ve&&o.ZP.createElement(Ao,{chatId:ue,threadId:me,messageListType:he,dropAreaState:Q,onDropHide:Re,isReady:be}),c&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:J.isRtl?"rtl":void 0},o.ZP.createElement(nt.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:ke},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,J("Chat.Pinned.UnpinAll",f,"i")))),Qe&&o.ZP.createElement("div",{className:De},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,je))),h.wB&&ge&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:J.isRtl?"rtl":void 0},o.ZP.createElement(nt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:xe},J(we?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&pe&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:J.isRtl?"rtl":void 0},o.ZP.createElement(nt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ue},J("BotStart"))),h.wB&&fe&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:J.isRtl?"rtl":void 0},o.ZP.createElement(nt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Fe},J("BotRestart"))),o.ZP.createElement(Lo,{messageListType:he,isActive:S,canPost:ve}),o.ZP.createElement(Uo,{isOpen:Boolean(E),onClose:z}),o.ZP.createElement(Fo,{isOpen:Boolean(M),onClose:V}),o.ZP.createElement(qo,{isOpen:R}),o.ZP.createElement(Do,{isOpen:k}))),o.ZP.createElement(vs,{isShown:ye,canPost:ve,withExtraShift:tt})),h.wB&&o.ZP.createElement(xo,{isActive:Boolean(C)})),t&&o.ZP.createElement(Oo,{isOpen:ce,chatId:t,pinnedMessagesCount:f,onClose:Te,onUnpin:Be}),o.ZP.createElement("div",{teactFastList:!0},null==F?void 0:F.map(((e,t)=>o.ZP.createElement($o,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))))}))),Ho=450+s.fK,zo=(0,E.Ds)((e=>e()),200,!1);var Vo;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Statistics=4]="Statistics",e[e.MessageStatistics=5]="MessageStatistics",e[e.Management=6]="Management",e[e.ManageInitial=7]="ManageInitial",e[e.ManageChannelSubscribers=8]="ManageChannelSubscribers",e[e.ManageChatAdministrators=9]="ManageChatAdministrators",e[e.ManageChatPrivacyType=10]="ManageChatPrivacyType",e[e.ManageDiscussion=11]="ManageDiscussion",e[e.ManageGroupPermissions=12]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=13]="ManageGroupRemovedUsers",e[e.ManageChannelRemovedUsers=14]="ManageChannelRemovedUsers",e[e.ManageGroupUserPermissionsCreate=15]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=16]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=17]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=18]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=19]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=20]="ManageGroupMembers",e[e.ManageGroupAddAdmins=21]="ManageGroupAddAdmins",e[e.StickerSearch=22]="StickerSearch",e[e.GifSearch=23]="GifSearch",e[e.PollResults=24]="PollResults",e[e.AddingMembers=25]="AddingMembers",e[e.ManageInvites=26]="ManageInvites",e[e.ManageEditInvite=27]="ManageEditInvite",e[e.ManageReactions=28]="ManageReactions",e[e.ManageInviteInfo=29]="ManageInviteInfo",e[e.ManageJoinRequests=30]="ManageJoinRequests"}(Vo||(Vo={}));const Wo=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,s,o;let{chatId:i,isProfile:r,isManagement:l}=t;const{query:u}=(0,c.n5)(e)||{},{query:m}=(0,c.y5)(e)||{},{query:h}=(0,c.yN)(e)||{},g=i?(0,c.Z1)(e,i):void 0,p=g&&(0,d.eA)(g),f=r&&i&&(0,d.YC)(i)?(0,c.dy)(e,i):void 0,v=f&&(0,d.kw)(f),I=Boolean(!l&&r&&!v&&g&&!(0,c.FM)(e,g.id)&&((0,d.YC)(g.id)||((0,d.Nl)(g)||g.isCreator)&&!g.isNotJoined)),y=Boolean(i&&(null===(n=e.management.byChatId[i])||void 0===n?void 0:n.editingInvite)),w=null==g||null===(a=g.fullInfo)||void 0===a?void 0:a.canViewStatistics,Z=i?null===(s=e.management.byChatId[i])||void 0===s||null===(o=s.inviteInfo)||void 0===o?void 0:o.invite:void 0;return{canManage:I,canAddContact:v,canViewStatistics:w,isChannel:p,userId:null==f?void 0:f.id,messageSearchQuery:u,stickerSearchQuery:m,gifSearchQuery:h,isEditingInvite:y,currentInviteInfo:Z,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}))((e=>{var t;let{chatId:n,isColumnOpen:s,isProfile:i,isSearch:r,isManagement:c,isStatistics:l,isMessageStatistics:d,isStickerSearch:u,isGifSearch:g,isPollResults:p,isAddingChatMembers:f,profileState:v,managementScreen:I,canAddContact:y,userId:w,canManage:Z,isChannel:P,onClose:b,onScreenSelect:C,messageSearchQuery:S,stickerSearchQuery:E,gifSearchQuery:M,isEditingInvite:R,canViewStatistics:k,currentInviteInfo:N,shouldSkipHistoryAnimations:T}=e;const{setLocalTextSearchQuery:B,setStickerSearchQuery:A,setGifSearchQuery:x,searchTextMessagesLocal:O,toggleManagement:U,openHistoryCalendar:F,openAddContactDialog:q,toggleStatistics:$,setEditingExportedInvite:D,deleteExportedChatInvite:j}=(0,a.Sv)(),G=(0,o.sO)(null),[_,H,z]=(0,ze.Z)(),V=(0,o.I4)((()=>{D({chatId:n,invite:N}),C(m.u1.EditInvite)}),[n,N,C,D]),W=(0,o.I4)((()=>{j({chatId:n,link:N.link}),C(m.u1.Invites),z()}),[n,z,N,j,C]),X=(0,o.I4)((e=>{B({query:e}),e.length&&zo(O)}),[O,B]),K=(0,o.I4)((e=>{A({query:e})}),[A]),Y=(0,o.I4)((e=>{x({query:e})}),[x]),J=(0,o.I4)((()=>{q({userId:w})}),[q,w]),[Q,ee]=(0,o.eJ)(!s);(0,o.d4)((()=>{setTimeout((()=>{ee(!s)}),Ho)}),[s]);const te=(0,We.Z)(),ne=i?v===m.vi.Profile?Vo.Profile:v===m.vi.SharedMedia?Vo.SharedMedia:v===m.vi.MemberList?Vo.MemberList:-1:r?Vo.Search:p?Vo.PollResults:u?Vo.StickerSearch:g?Vo.GifSearch:f?Vo.AddingMembers:c?I===m.u1.Initial?Vo.ManageInitial:I===m.u1.ChatPrivacyType?Vo.ManageChatPrivacyType:I===m.u1.Discussion?Vo.ManageDiscussion:I===m.u1.ChannelSubscribers?Vo.ManageChannelSubscribers:I===m.u1.GroupPermissions?Vo.ManageGroupPermissions:I===m.u1.ChatAdministrators?Vo.ManageChatAdministrators:I===m.u1.GroupRemovedUsers?Vo.ManageGroupRemovedUsers:I===m.u1.ChannelRemovedUsers?Vo.ManageChannelRemovedUsers:I===m.u1.GroupUserPermissionsCreate?Vo.ManageGroupUserPermissionsCreate:I===m.u1.GroupUserPermissions?Vo.ManageGroupUserPermissions:I===m.u1.GroupRecentActions?Vo.ManageGroupRecentActions:I===m.u1.ChatAdminRights?Vo.ManageGroupAdminRights:I===m.u1.ChatNewAdminRights?Vo.ManageGroupNewAdminRights:I===m.u1.GroupMembers?Vo.ManageGroupMembers:I===m.u1.Invites?Vo.ManageInvites:I===m.u1.EditInvite?Vo.ManageEditInvite:I===m.u1.GroupAddAdmins?Vo.ManageGroupAddAdmins:I===m.u1.Reactions?Vo.ManageReactions:I===m.u1.InviteInfo?Vo.ManageInviteInfo:I===m.u1.JoinRequests?Vo.ManageJoinRequests:void 0:l?Vo.Statistics:d?Vo.MessageStatistics:void 0,ae=null!==(t=(0,qt.Z)(ne,!0))&&void 0!==t?t:-1,se=h.wB||ne===Vo.SharedMedia||ne===Vo.MemberList||ne===Vo.AddingMembers||c,oe=(0,Ce.Z)("animated-close-icon",se&&"state-back",(Q||T)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(nt.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:b,ariaLabel:te(se?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:G,className:oe})),o.ZP.createElement(Ve.Z,{name:Q||T?"none":"slide-fade",activeKey:ae},function(){if(-1!==ae)switch(ae){case Vo.PollResults:return o.ZP.createElement("h3",null,te("PollResults"));case Vo.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(at.Z,{parentContainerClassName:"RightSearch",value:S,onChange:X}),o.ZP.createElement(nt.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>F({selectedAt:(0,L._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case Vo.AddingMembers:return o.ZP.createElement("h3",null,te(P?"ChannelAddSubscribers":"GroupAddMembers"));case Vo.ManageInitial:return o.ZP.createElement("h3",null,te("Edit"));case Vo.ManageChatPrivacyType:return o.ZP.createElement("h3",null,te(P?"ChannelTypeHeader":"GroupTypeHeader"));case Vo.ManageDiscussion:return o.ZP.createElement("h3",null,te("Discussion"));case Vo.ManageChatAdministrators:return o.ZP.createElement("h3",null,te("ChannelAdministrators"));case Vo.ManageGroupRecentActions:return o.ZP.createElement("h3",null,te("Group.Info.AdminLog"));case Vo.ManageGroupAdminRights:return o.ZP.createElement("h3",null,te("EditAdminRights"));case Vo.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,te("SetAsAdmin"));case Vo.ManageGroupPermissions:return o.ZP.createElement("h3",null,te("ChannelPermissions"));case Vo.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,te("BlockedUsers"));case Vo.ManageChannelRemovedUsers:return o.ZP.createElement("h3",null,te("ChannelBlockedUsers"));case Vo.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,te("ChannelAddException"));case Vo.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,te("UserRestrictions"));case Vo.ManageInvites:return o.ZP.createElement("h3",null,te("lng_group_invite_title"));case Vo.ManageEditInvite:return o.ZP.createElement("h3",null,te(R?"EditLink":"NewLink"));case Vo.ManageInviteInfo:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,te("InviteLink")),o.ZP.createElement("section",{className:"tools"},N&&!N.isRevoked&&o.ZP.createElement(nt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:te("Edit"),onClick:V},o.ZP.createElement("i",{className:"icon-edit"})),N&&N.isRevoked&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(nt.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:te("Delete"),onClick:H},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Kt.Z,{isOpen:_,onClose:z,title:te("DeleteLink"),text:te("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:te("Delete"),confirmHandler:W}))));case Vo.ManageJoinRequests:return o.ZP.createElement("h3",null,te(P?"SubscribeRequests":"MemberRequests"));case Vo.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,te("Channel.Management.AddModerator"));case Vo.StickerSearch:return o.ZP.createElement(at.Z,{value:E,placeholder:te("SearchStickersHint"),autoFocusSearch:!0,onChange:K});case Vo.GifSearch:return o.ZP.createElement(at.Z,{value:M,placeholder:te("SearchGifsTitle"),autoFocusSearch:!0,onChange:Y});case Vo.Statistics:return o.ZP.createElement("h3",null,te(P?"ChannelStats.Title":"GroupStats.Title"));case Vo.MessageStatistics:return o.ZP.createElement("h3",null,te("Stats.MessageTitle"));case Vo.SharedMedia:return o.ZP.createElement("h3",null,te("SharedMedia"));case Vo.ManageChannelSubscribers:return o.ZP.createElement("h3",null,te("ChannelSubscribers"));case Vo.MemberList:case Vo.ManageGroupMembers:return o.ZP.createElement("h3",null,te("GroupMembers"));case Vo.ManageReactions:return o.ZP.createElement("h3",null,te("Reactions"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},y&&o.ZP.createElement(nt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:te("AddContact"),onClick:J},o.ZP.createElement("i",{className:"icon-add-user"})),Z&&o.ZP.createElement(nt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:te("Edit"),onClick:U},o.ZP.createElement("i",{className:"icon-edit"})),k&&o.ZP.createElement(nt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:te("Statistics"),onClick:$},o.ZP.createElement("i",{className:"icon-stats"}))))}}()))})));var Xo=n(91);var Ko=n(7407);function Yo(e,t,n,a){const[o,i]=(0,Ko.Z)(n?t:void 0,a,void 0,s.Vk);return[o,i,!(!o||!a||o[0]===a[0])]}function Jo(e,t,n,a,i,r){const c=(0,o.sO)();(0,Ne.Z)((()=>{t===e&&i&&r&&(c.current=(0,d.R5)(i,r,e))}),[i,r,t,e]);const[l,u]=(0,Ko.Z)(a?n:void 0,c.current,void 0,"media"===e?s.EN:s.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const Qo=(0,E.P2)((e=>e()),250,!1);let ei=!1;var ti=n(1273),ni=n(1876),ai=n(787),si=n(180),oi=n(3709),ii=n(5418),ri=n(7262),ci=n(1151),li=n(2275);const di=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function ui(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const mi=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s}=t;const o=(0,c.Z1)(e,s),i=(0,c.Zw)(e,s),{currentType:r,resultsByType:l}=(0,c.we)(e)||{},{foundIds:u}=l&&r&&l[r]||{},{byId:m,statusesById:h}=e.users,{byId:g}=e.chats,p=o&&(0,d.Bf)(o),f=o&&(0,d.eA)(o),v=p||f&&(0,d.Nl)(o),I=null==o||null===(n=o.fullInfo)||void 0===n?void 0:n.members,y=v&&o&&(o.isForbidden||o.fullInfo&&!o.fullInfo.canViewMembers),w=v&&o&&((0,d.VE)(o,"inviteUsers")||!(0,d.Mg)(o,"inviteUsers")||o.isCreator),Z=v&&o&&((0,d.VE)(o,"banUsers")||o.isCreator),P=(0,c.xs)(e,s);let b,C,S;return(0,d.YC)(s)&&(C=s,S=(0,c.dy)(e,C),b=S&&!S.isSelf&&!(0,d.cS)(S)),{theme:(0,c.Pu)(e),isChannel:f,resolvedUserId:C,chatMessages:i,foundIds:u,mediaSearchType:r,hasCommonChatsTab:b,hasMembersTab:v,areMembersHidden:y,canAddMembers:w,canDeleteMembers:Z,currentUserId:e.currentUserId,isRightColumnShown:(0,c.Jf)(e),isRestricted:null==o?void 0:o.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:P,usersById:m,userStatusesById:h,chatsById:g,isChatProtected:null==o?void 0:o.isProtected,...v&&I&&{members:I},...b&&S&&{commonChatIds:null===(a=S.commonChats)||void 0===a?void 0:a.ids}}}))((e=>{let{chatId:t,profileState:n,onProfileStateChange:r,theme:c,isChannel:l,resolvedUserId:u,currentUserId:g,chatMessages:p,foundIds:f,mediaSearchType:v,hasCommonChatsTab:I,hasMembersTab:y,areMembersHidden:w,canAddMembers:Z,canDeleteMembers:P,commonChatIds:b,members:C,usersById:S,userStatusesById:E,chatsById:M,isRightColumnShown:R,isRestricted:k,lastSyncTime:N,activeDownloadIds:T,serverTimeOffset:B,isChatProtected:A}=e;const{setLocalMediaSearchType:x,loadMoreMembers:L,loadCommonChats:O,openChat:U,searchMediaMessagesLocal:F,openMediaViewer:q,openAudioPlayer:$,focusMessage:D,loadProfilePhotos:j,setNewChatMembersDialogState:G}=(0,a.Sv)(),_=(0,o.sO)(null),H=(0,o.sO)(null),z=(0,We.Z)(),[V,W]=(0,o.eJ)(0),[X,K]=(0,o.eJ)(),Y=(0,o.Ye)((()=>[...y?[{type:"members",title:l?"ChannelSubscribers":"GroupMembers"}]:[],...di,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,y,l]),J=Y[V].type,[Q,ee,te,ne]=function(e,t,n,a,s,i,r,c,l,u,m,h,g,p,f){let v=arguments.length>15&&void 0!==arguments[15]?arguments[15]:0;const I="members"!==s&&i?i:s,y=(0,o.Ye)((()=>{if(r&&l&&u)return(0,d.Z0)(r.map((e=>{let{userId:t}=e;return t})),l,u,void 0,v)}),[r,v,l,u]),w=(0,o.Ye)((()=>{if(c&&m)return(0,d.ih)(c,m,!0)}),[m,c]),[Z,P,b]=Yo(0,t,f,y),[C,S,E]=Jo("media",I,a,f,h,g),[M,R,k]=Jo("documents",I,a,f,h,g),[N,T,B]=Jo("links",I,a,f,h,g),[A,x,L]=Jo("audio",I,a,f,h,g),[O,U,F]=Jo("voice",I,a,f,h,g),[q,$,D]=Yo(0,n,f,w);let j,G,_=!1;switch(I){case"members":j=Z,G=P,_=b;break;case"commonChats":j=q,G=$,_=D;break;case"media":j=C,G=S,_=E;break;case"documents":j=M,G=R,_=k;break;case"links":j=N,G=T,_=B;break;case"audio":j=A,G=x,_=L;break;case"voice":j=O,G=U,_=F}return[I,j,G,_]}(R,L,O,F,J,v,C,b,S,E,M,p,f,t,N,B),ae=Y.findIndex((e=>{let{type:t}=e;return t===Q})),{handleScroll:se}=function(e,t,n,a){(0,wn.Z)((n=>{let[s]=n;if(s&&s!==t){const n=e.current,s=n.querySelector(".TabList");n.scrollTop<s.offsetTop&&(a("members"===t?m.vi.MemberList:m.vi.SharedMedia),ei=!0,(0,En.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{ei=!1}),350))}}),[t,a]),(0,wn.Z)((t=>{let[s]=t;if(n!==m.vi.Profile||n===s)return;const o=e.current;if(!o)return;const i=o.querySelector(".TabList");!i||i.offsetTop>o.scrollTop||(ei=!0,(0,En.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{ei=!1}),350),a(n))}),[n]);const s=(0,o.I4)((()=>{const n=e.current;if(!n)return;const s=n.querySelector(".TabList");if(!s)return;let o=m.vi.Profile;n.scrollTop>=s.offsetTop&&(o="members"===t?m.vi.MemberList:m.vi.SharedMedia),a(o)}),[e,a,t]);return(0,o.d4)((()=>{ei||s()}),[s,t]),{handleScroll:(0,o.I4)((()=>{ei||Qo(s)}),[s])}}(_,J,n,r),{applyTransitionFix:oe,releaseTransitionFix:ie}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,o.d4)((()=>{function n(){const n=e.current,a=n.querySelector(t),s=n.querySelector(".TabList");a&&s&&(a.style.minHeight=n.offsetHeight-s.offsetHeight+"px")}return n(),window.addEventListener("resize",n,!1),()=>{window.removeEventListener("resize",n,!1)}}),[e,t]);const n=(0,o.I4)((()=>{const t=e.current;if("hidden"!==t.style.overflowY){const e=t.offsetWidth-t.clientWidth;t.style.overflowY="hidden",t.style.marginRight=`${e}px`}}),[e]),a=(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e]);return{applyTransitionFix:n,releaseTransitionFix:a}}(_),[re,ce]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),{observe:le}=(0,kn.S1)({rootRef:_,throttleMs:500}),de=(0,o.I4)((()=>{ie(),ce()}),[ie,ce]),ue=(0,o.I4)((()=>{G(m.WB.InProgress)}),[G]);(0,o.d4)((()=>{x({mediaType:J})}),[x,J]);const me=u||t;(0,o.d4)((()=>{N&&j({profileId:me})}),[j,me,N]);const he=(0,o.I4)((e=>{q({chatId:me,threadId:i._f,messageId:e,origin:m.bZ.SharedMedia})}),[me,q]),ge=(0,o.I4)((e=>{$({chatId:me,messageId:e})}),[me,$]),pe=(0,o.I4)((e=>{U({id:e})}),[U]),fe=(0,o.I4)((e=>{D({chatId:me,messageId:e})}),[me,D]),ve=(0,o.I4)((()=>{K(void 0)}),[]);let Ie;(0,o.d4)((()=>{if(H.current&&h.$b)return(0,dt.sf)(H.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===dt.eM.Left?(W(Math.min(V+1,Y.length-1)),!0):t===dt.eM.Right&&(W(Math.max(0,V-1)),!0)})}),[V,Y.length]);const ye="members"===Q||!y&&"media"===Q;ye?Ie=R?0:1e3:ee||(Ie=s.Y);const we=(0,Zo.Z)([t,Q],Ie);return o.ZP.createElement(ti.Z,{ref:_,className:"Profile custom-scroll",itemSelector:ui(Q),items:we?ee:void 0,cacheBuster:re,sensitiveArea:s.qU,preloadBackwards:we?"members"===Q?s.Vk:s.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:te,onScroll:se},!ne&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(ai.Z,{userId:t||e}),o.ZP.createElement(si.Z,{chatOrUserId:t||e}))}(t,u),!k&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Ve.Z,{ref:H,name:z.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ae,renderCount:Y.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:oe,onStop:de},function(){if(!ee||!we||!p){const e=ye&&!we,t=Boolean("members"===Q&&w);return o.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&o.ZP.createElement(rt.Z,null),t&&o.ZP.createElement(ri.Z,{text:"You have no access to group members list."}))}if(!ee.length){let e;switch(Q){case"members":e=w?"You have no access to group members list.":"No members found";break;case"commonChats":e=z("NoGroupsInCommon");break;case"documents":e=z("lng_media_file_empty");break;case"links":e=z("lng_media_link_empty");break;case"audio":e=z("lng_media_song_empty");break;case"voice":e=z("lng_media_audio_empty");break;default:e=z("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(ri.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${Q}-list`,dir:z.isRtl&&"media"===Q?"rtl":void 0,teactFastList:!0},"media"===Q?ee.map((e=>p[e]&&o.ZP.createElement(oi.Z,{key:e,message:p[e],isProtected:A||p[e].isProtected,observeIntersection:le,onClick:he}))):"documents"===Q?ee.map((e=>p[e]&&o.ZP.createElement(Qn.Z,{key:e,message:p[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:T.includes(e),observeIntersection:le,onDateClick:fe}))):"links"===Q?ee.map((e=>p[e]&&o.ZP.createElement(ii.Z,{key:e,message:p[e],isProtected:A||p[e].isProtected,observeIntersection:le,onMessageClick:fe}))):"audio"===Q?ee.map((e=>p[e]&&o.ZP.createElement(ea.Z,{key:e,theme:c,message:p[e],origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:N,className:"scroll-item",onPlay:ge,onDateClick:fe,isDownloading:T.includes(e)}))):"voice"===Q?ee.map((e=>p[e]&&o.ZP.createElement(ea.Z,{key:e,theme:c,message:p[e],senderTitle:(0,Xo.F)(z,p[e],M,S),origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:N,className:"scroll-item",onPlay:ge,onDateClick:fe,isDownloading:T.includes(e)}))):"members"===Q?ee.map(((e,t)=>{return o.ZP.createElement(ni.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>pe(e),contextActions:(n=e,n!==g&&P?[{title:z("lng_context_remove_from_group"),icon:"stop",handler:()=>{K(n)}}]:void 0)},o.ZP.createElement($t.Z,{userId:e,forceShowSelf:!0}));var n})):"commonChats"===Q?ee.map(((e,t)=>o.ZP.createElement(ni.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>U({id:e})},o.ZP.createElement(Dt.Z,{chatId:e})))):void 0)}()),o.ZP.createElement(ut.Z,{big:!0,activeTab:V,tabs:Y,onSwitchTab:W})),Z&&o.ZP.createElement(ci.Z,{isShown:"members"===Q,onClick:ue,ariaLabel:z("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),P&&o.ZP.createElement(li.Z,{isOpen:Boolean(X),userId:X,onClose:ve}))}))),hi=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)})),gi=(0,o.X$)((e=>{const t=(0,pt.Z)(gt.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)})),pi=e=>{const t=(0,pt.Z)(gt.gl.Extra,"Statistics");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)},fi=e=>{const t=(0,pt.Z)(gt.gl.Extra,"MessageStatistics");return t?o.ZP.createElement(t,e):o.ZP.createElement(ft.Z,null)},vi=(0,o.X$)((()=>{const e=(0,pt.Z)(gt.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(ft.Z,null)})),Ii=(0,o.X$)((()=>{const e=(0,pt.Z)(gt.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(ft.Z,null)})),yi=(0,o.X$)((()=>{const e=(0,pt.Z)(gt.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(ft.Z,null)}));var wi=n(1820);const Zi=(0,o.X$)((0,a.c$)(((e,t)=>{var n;let{chatId:a}=t;const s=(0,c.Z1)(e,a),{userIds:o}=e.contactList||{},{byId:i}=e.chats,{currentUserId:r,newChatMembersProgress:l,connectionState:u}=e,h=s&&(0,d.eA)(s),{query:g,fetchingStatus:p,globalUserIds:f,localUserIds:v}=e.userSearch;return{isChannel:h,members:null==s||null===(n=s.fullInfo)||void 0===n?void 0:n.members,currentUserId:r,chatsById:i,localContactIds:o,searchQuery:g,isSearching:p,isLoading:l===m.WB.Loading,globalUserIds:f,localUserIds:v,connectionState:u}}))((e=>{let{isChannel:t,connectionState:n,members:s,onNextStep:i,currentUserId:r,chatsById:c,localContactIds:l,isLoading:u,searchQuery:m,isSearching:h,localUserIds:p,globalUserIds:f,onClose:v,isActive:I}=e;const{setUserSearchQuery:y,loadContactList:w}=(0,a.Sv)(),Z=(0,We.Z)(),[P,b]=(0,o.eJ)([]),C=(0,Ot.Z)(P)===P;(0,o.d4)((()=>{I&&"connectionStateReady"===n&&w()}),[n,I,w]),(0,Oe.ZP)(I,v);const S=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),E=(0,o.I4)((e=>{y({query:e})}),[y]),M=(0,o.Ye)((()=>{const e=(0,a.Rd)().users.byId,n=l?(0,d.kK)(l,e,m):[];return(0,d.ih)((0,g.Tw)([...n,...p||[],...f||[]]).filter((n=>{const a=e[n];return!S.includes(n)&&n!==r&&(!a||!(0,d.cS)(a)||!t&&a.canBeInvitedToGroup)})),c)}),[l,c,m,p,f,r,S,t]),R=(0,o.I4)((()=>{P.length&&(y({query:""}),i(P))}),[P,y,i]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(wi.Z,{itemIds:M,selectedIds:P,filterValue:m,filterPlaceholder:Z("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:b,onFilterChange:E,noScrollRestore:C}),o.ZP.createElement(ci.Z,{isShown:Boolean(P.length),disabled:u,ariaLabel:Z("lng_channel_add_users"),onClick:R},u?o.ZP.createElement(rt.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),Pi=450+s.fK,bi=Object.keys(m.qt).length/2,Ci=Object.keys(m.u1).length/2;function Si(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Ei=(0,o.X$)((0,a.c$)((e=>{var t;const{chatId:n,threadId:a}=(0,c.Bt)(e)||{},s=(0,c.g4)(e),o=n?null===(t=e.management.byChatId[n])||void 0===t?void 0:t.nextScreen:void 0;return{contentKey:(0,c.Wq)(e),chatId:n,threadId:a,isChatSelected:Boolean(n&&s),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,nextManagementScreen:o}}))((e=>{var t;let{contentKey:n,chatId:i,threadId:r,isChatSelected:c,shouldSkipHistoryAnimations:l,nextManagementScreen:d}=e;const{toggleChatInfo:u,toggleManagement:h,closeLocalTextSearch:g,setStickerSearchQuery:p,setGifSearchQuery:f,closePollResults:v,addChatMembers:I,setNewChatMembersDialogState:y,setEditingExportedInvite:w,toggleStatistics:Z,toggleMessageStatistics:P,setOpenedInviteInfo:b,requestNextManagementScreen:C}=(0,a.Sv)(),{width:S}=(0,xt.Z)(),[E,M]=(0,o.eJ)(m.vi.Profile),[R,k]=(0,o.eJ)(m.u1.Initial),[N,T]=(0,o.eJ)(),[B,A]=(0,o.eJ)(),x=E!==m.vi.Profile,L=void 0!==n,O=n===m.qt.ChatInfo,U=n===m.qt.Search,F=n===m.qt.Management,q=n===m.qt.Statistics,$=n===m.qt.MessageStatistics,D=n===m.qt.StickerSearch,j=n===m.qt.GifSearch,G=n===m.qt.PollResults,_=n===m.qt.AddingMembers,H=S<=s._m,[z,V]=(0,o.eJ)(!L),W=null!==(t=(0,qt.Z)(n,!0,!c))&&void 0!==t?t:-1,X=(0,o.I4)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];switch(n){case m.qt.AddingMembers:y(m.WB.Closed);break;case m.qt.ChatInfo:if(x&&e){M(m.vi.Profile);break}u(void 0,{forceSyncOnIOs:!0});break;case m.qt.Management:switch(R){case m.u1.Initial:h();break;case m.u1.ChatPrivacyType:case m.u1.Discussion:case m.u1.GroupPermissions:case m.u1.GroupType:case m.u1.ChatAdministrators:case m.u1.ChannelSubscribers:case m.u1.GroupMembers:case m.u1.Invites:case m.u1.Reactions:case m.u1.JoinRequests:case m.u1.ChannelRemovedUsers:k(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:k(m.u1.GroupPermissions),T(void 0),A(void 0);break;case m.u1.ChatAdminRights:case m.u1.ChatNewAdminRights:case m.u1.GroupAddAdmins:case m.u1.GroupRecentActions:k(m.u1.ChatAdministrators);break;case m.u1.EditInvite:case m.u1.InviteInfo:k(m.u1.Invites),b({invite:void 0}),w({chatId:i,invite:void 0})}break;case m.qt.MessageStatistics:P();break;case m.qt.Statistics:Z();break;case m.qt.Search:Si(),g();break;case m.qt.StickerSearch:Si(),p({query:void 0});break;case m.qt.GifSearch:Si(),f({query:void 0});break;case m.qt.PollResults:v()}}),[n,x,u,v,y,R,h,g,p,f,w,i,b,Z,P]),K=(0,o.I4)(((e,t)=>{T(e),A(t)}),[]),Y=(0,o.I4)((e=>{I({chatId:i,memberIds:e})}),[I,i]);function J(e){if(-1!==W)switch(W){case m.qt.AddingMembers:return o.ZP.createElement(Zi,{key:i,chatId:i,isActive:L&&e,onNextStep:Y,onClose:X});case m.qt.ChatInfo:return o.ZP.createElement(mi,{key:i,chatId:i,profileState:E,onProfileStateChange:M});case m.qt.Search:return o.ZP.createElement(hi,{chatId:i,threadId:r,onClose:X,isActive:L&&e});case m.qt.Management:return o.ZP.createElement(gi,{key:i,chatId:i,currentScreen:R,isPromotedByCurrentUser:B,selectedChatMemberId:N,isActive:L&&e,onScreenSelect:k,onChatMemberSelect:K,onClose:X});case m.qt.Statistics:return o.ZP.createElement(pi,{chatId:i,isActive:L&&e});case m.qt.MessageStatistics:return o.ZP.createElement(fi,{chatId:i,isActive:L&&e});case m.qt.StickerSearch:return o.ZP.createElement(vi,{onClose:X,isActive:L&&e});case m.qt.GifSearch:return o.ZP.createElement(Ii,{onClose:X,isActive:L&&e});case m.qt.PollResults:return o.ZP.createElement(yi,{onClose:X,isActive:L&&e})}}return(0,o.d4)((()=>L?(0,Ge.Z)(X):void 0),[L,X]),(0,o.d4)((()=>{setTimeout((()=>{V(!L)}),Pi)}),[L]),(0,o.d4)((()=>{d&&(k(d),C(void 0))}),[d,C]),(0,o.d4)((()=>{L&&H&&X()}),[H]),(0,yn.Z)((e=>{let[t]=e;t!==i&&(M(m.vi.Profile),k(m.u1.Initial))}),[i]),(0,Oe.ZP)(c&&(n===m.qt.ChatInfo||n===m.qt.Management||n===m.qt.AddingMembers),(()=>X(!1)),u),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:c?void 0:"is-hidden"},H&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:X}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(Wo,{chatId:i,isColumnOpen:L,isProfile:O,isSearch:U,isManagement:F,isStatistics:q,isMessageStatistics:$,isStickerSearch:D,isGifSearch:j,isPollResults:G,isAddingChatMembers:_,profileState:E,managementScreen:R,onClose:X,onScreenSelect:k}),o.ZP.createElement(Ve.Z,{name:z||l?"none":"zoom-fade",renderCount:bi+Ci,activeKey:F?bi+R:W,shouldCleanup:!0},J)))}))),Mi=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,pt.Z)(gt.gl.Extra,"MediaViewer",!t);return n?o.ZP.createElement(n,null):void 0}));let Ri=[],ki=!1;function Ni(e,t){Ri.push({url:e,filename:t}),ki||(ki=!0,setTimeout((async()=>{await async function(){let e=0;for(const t of Ri)Ti(t),e++,10===e&&(await(0,E.wO)(1e3),e=0);Ri=[]}(),ki=!1}),1e3))}function Ti(e){let{url:t,filename:n}=e;const a=document.createElement("a");a.href=t,a.download=n;try{a.click()}catch(e){console.error(e)}}const Bi=new Set,Ai=new Set,xi=(0,o.X$)((0,a.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})))((e=>{let{activeDownloads:t,messages:n}=e;const{cancelMessagesMediaDownload:s}=(0,a.Sv)(),r=(0,Cn.Z)(1e3,!0),c=(0,o.I4)((e=>{Ai.add(e),r((()=>{Ai.size&&(s({messages:Array.from(Ai)}),Ai.clear())}))}),[s,r]);(0,o.d4)((()=>{const e=Object.entries(t).map((e=>{let[t,a]=e;return a.map((e=>n[t].byId[e]))})).flat();e.length?e.forEach((e=>{if(Bi.has(e))return;Bi.add(e);const t=(0,d.Ti)(e,"download");if(!t)return void c(e);const n=ne.UV(t);if(n)return Ni(n,(0,d.w6)(e)),void c(e);ne.he(t,i.IU.BlobUrl,!0).then((t=>{t&&Ni(t,(0,d.w6)(e)),c(e)}))})):Bi.clear()}),[n,t,s,c])})));var Li=n(5116),Oi=n(3103);const Ui=(0,o.X$)((e=>{let{openedGame:t,gameTitle:n}=e;const{closeGame:a,showNotification:s,openForwardMenu:i}=(0,Li.Sv)(),r=(0,We.Z)(),{url:c,chatId:l,messageId:d}=t||{},u=Boolean(c),m=(0,Rs.Z)(l);(0,Mn.Z)((()=>{m({type:"playingGame"})}),u?5e3:void 0);const h=(0,o.I4)((e=>{try{const t=JSON.parse(e.data);"share_score"===t.eventType&&(i({fromChatId:l,messageIds:[d],withMyScore:!0}),a()),"share_game"===t.eventType&&s({message:"Unsupported game action"})}catch(e){}}),[l,a,d,i,s]),g=(0,o.I4)((e=>{e.currentTarget.focus()}),[]);return(0,o.d4)((()=>(window.addEventListener("message",h),()=>window.removeEventListener("message",h))),[h]),(0,o.d4)((()=>{if(u)return re.Z.disableRefresh(),()=>{re.Z.enableRefresh()}}),[u]),o.ZP.createElement(Oi.Z,{className:"GameModal",isOpen:u,onClose:a,title:n,hasCloseButton:!0},u&&o.ZP.createElement("iframe",{className:"game-frame",onLoad:g,src:c,title:r("AttachGame"),sandbox:"allow-scripts allow-same-origin allow-orientation-lock",allow:"fullscreen"}))})),Fi=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,pt.Z)(gt.gl.Extra,"Notifications",!t);return n?o.ZP.createElement(n,null):void 0})),qi=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,pt.Z)(gt.gl.Extra,"Dialogs",!t);return n?o.ZP.createElement(n,null):void 0})),$i=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"ForwardPicker",!t);return n?o.ZP.createElement(n,e):void 0})),Di=(0,o.X$)((e=>{const{url:t}=e,n=(0,pt.Z)(gt.gl.Extra,"SafeLinkModal",!t);return n?o.ZP.createElement(n,e):void 0})),ji=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"HistoryCalendar",!t);return n?o.ZP.createElement(n,e):void 0})),Gi=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,pt.Z)(gt.gl.Calls,"GroupCall",!t);return n?o.ZP.createElement(n,e):void 0})),_i=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,pt.Z)(gt.gl.Calls,"ActiveCallHeader",!t);return n?o.ZP.createElement(n,null):void 0})),Hi=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,pt.Z)(gt.gl.Calls,"PhoneCall",!t);return n?o.ZP.createElement(n,null):void 0})),zi=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Extra,"NewContactModal",!t);return n?o.ZP.createElement(n,e):void 0})),Vi=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,pt.Z)(gt.gl.Calls,"RatePhoneCallModal",!t);return n?o.ZP.createElement(n,e):void 0})),Wi=(0,o.X$)((e=>{const{webApp:t}=e,n=(0,pt.Z)(gt.gl.Extra,"WebAppModal",!t);return n?o.ZP.createElement(n,e):void 0})),Xi=(0,o.X$)((e=>{const{bot:t}=e,n=(0,pt.Z)(gt.gl.Extra,"BotTrustModal",!t);return n?o.ZP.createElement(n,e):void 0})),Ki=(0,o.X$)((e=>{const{bot:t}=e,n=(0,pt.Z)(gt.gl.Extra,"BotAttachModal",!t);return n?o.ZP.createElement(n,e):void 0}));let Yi,Ji=!1;function Qi(e){document.querySelectorAll('link[rel="icon"], link[rel="alternate icon"]').forEach((t=>{e?t.href.includes("favicon-unread")||(t.href=t.href.replace("favicon","favicon-unread")):t.href=t.href.replace("favicon-unread","favicon")}))}function er(e){document.title!==e&&(document.title=e)}const tr=(0,o.X$)((0,a.c$)((e=>{var t,n,a;const{settings:{byKey:{animationLevel:s,language:o,wasTimeFormatSetManually:i}}}=e,{chatId:r,messageId:l}=e.audioPlayer,d=r&&l?(0,c.hj)(e,r,l):void 0,u=e.openedGame,m=u&&(0,c.hj)(e,u.chatId,u.messageId),h=null==m||null===(t=m.content.game)||void 0===t?void 0:t.title;return{connectionState:e.connectionState,authState:e.authState,lastSyncTime:e.lastSyncTime,isLeftColumnOpen:e.isLeftColumnShown,isRightColumnOpen:(0,c.Jf)(e),isMediaViewerOpen:(0,c.zQ)(e),isForwardModalOpen:(0,c.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:d,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,c.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:s,language:o,wasTimeFormatSetManually:i,isPhoneCallActive:Boolean(e.phoneCall),addedSetIds:e.stickers.added.setIds,newContactUserId:null===(n=e.newContact)||void 0===n?void 0:n.userId,newContactByPhoneNumber:null===(a=e.newContact)||void 0===a?void 0:a.isByPhoneNumber,openedGame:u,gameTitle:h,isRatePhoneCallModalOpen:Boolean(e.ratingPhoneCall),botTrustRequest:e.botTrustRequest,botAttachRequest:e.botAttachRequest,webApp:e.webApp}}))((e=>{let{connectionState:t,authState:n,lastSyncTime:i,isLeftColumnOpen:r,isRightColumnOpen:c,isMediaViewerOpen:l,isForwardModalOpen:d,hasNotifications:u,hasDialogs:m,audioMessage:g,activeGroupCallId:p,safeLinkModalUrl:f,isHistoryCalendarOpen:v,shouldSkipHistoryAnimations:I,openedStickerSetShortName:y,isServiceChatReady:w,animationLevel:Z,language:P,wasTimeFormatSetManually:b,addedSetIds:C,isPhoneCallActive:S,newContactUserId:M,newContactByPhoneNumber:R,openedGame:k,gameTitle:N,isRatePhoneCallModalOpen:T,botTrustRequest:B,botAttachRequest:A,webApp:x}=e;const{sync:L,loadAnimatedEmojis:O,loadNotificationSettings:U,loadNotificationExceptions:F,updateIsOnline:$,loadTopInlineBots:D,loadEmojiKeywords:j,loadCountryList:G,loadAvailableReactions:_,loadStickerSets:H,loadAddedStickers:z,loadFavoriteStickers:V,ensureTimeFormat:W,openStickerSetShortName:X,checkVersionNotification:K,loadAppConfig:Y,loadAttachMenuBots:J}=(0,a.Sv)();s.eM&&!Ji&&(Ji=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{"connectionStateReady"===t&&"authorizationStateReady"===n&&L()}),[t,n,L]),(0,o.d4)((()=>{i&&($(!0),Y(),_(),O(),U(),F(),D(),j({language:s.pR}),J())}),[i,O,j,F,U,D,$,_,Y,J]),(0,o.d4)((()=>{i&&(P!==s.pR&&j({language:P}),G({langCode:P}))}),[P,i,G,j]),(0,o.d4)((()=>{i&&(C?z():(H(),V()))}),[i,C,H,V,z]),(0,o.d4)((()=>{i&&w&&K()}),[i,w,K]),(0,o.d4)((()=>{i&&!b&&W()}),[i,b,W]),(0,o.d4)((()=>{i&&Oe.Oy.startsWith("#?tgaddr=")&&(0,Ee.o)(decodeURIComponent(Oe.Oy.substr("#?tgaddr=".length)))}),[i]),(0,o.d4)((()=>{if(p)return re.Z.disableRefresh(),()=>{re.Z.enableRefresh()}}),[p]);const Q=(0,Ue.Z)(r,void 0,!0,void 0,I),ee=(0,o.sO)(!1),te=(0,Le.Z)();(0,Ne.Z)((e=>{let[t]=e;if(void 0===t||0===Z)return;ee.current=!0,h.wZ&&(0,E.T2)((()=>{document.body.classList.toggle("android-left-blackout-open",!r)}));const n=(0,be.YW)();(0,Se.L)(document.getElementById("MiddleColumn"),(()=>{n(),ee.current=!1,te()}))}),[r]);const ne=(0,Ue.Z)(c,void 0,!0,void 0,I),ae=(0,o.sO)(!1),[se,oe]=(0,o.eJ)(c);(0,Ne.Z)((e=>{let[t]=e;if(void 0===t||0===Z)return;ae.current=!0;const n=(0,be.YW)();(0,Se.L)(document.getElementById("RightColumn"),(()=>{n(),ae.current=!1,te(),oe(c)}))}),[c]);const ie=(0,Ce.Z)(Q.hasShownClass&&"left-column-shown",Q.hasOpenClass&&"left-column-open",ee.current&&"left-column-animating",ne.hasShownClass&&"right-column-shown",ne.hasOpenClass&&"right-column-open",ae.current&&"right-column-animating",se&&"narrow-message-list",I&&"history-animation-disabled"),ce=(0,o.I4)((()=>{$(!1);const e=(0,q.xW)();let t=0;clearInterval(Yi),Yi=window.setInterval((()=>{if(document.title.includes(s.ou))Qi(!1);else{if(t%2==0){const t=(0,q.xW)()-e;t>0&&(er(`${t} notification${t>1?"s":""}`),Qi(!0))}else er(s.Ti),Qi(!1);t++}}),1e3)}),[$]),le=(0,o.I4)((()=>{$(!0),clearInterval(Yi),Yi=void 0,document.title.includes(s.ou)||er(s.Ti),Qi(!1)}),[$]),de=(0,o.I4)((()=>{X({stickerSetShortName:void 0})}),[X]);return(0,Re.Z)(ce,le),ke(ce),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,o.d4)((()=>{if(h.$b){if(!e)return null==Te||Te.setAttribute("content",Be),h.cj&&!h.fl&&document.addEventListener("gesturestart",xe),()=>{null==Te||Te.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",xe)};null==Te||Te.setAttribute("content",Ae)}}),[e])}(l),o.ZP.createElement("div",{id:"Main",className:ie,onDrop:Me.Z,onDragOver:Me.Z},o.ZP.createElement(kt,null),o.ZP.createElement(_o,null),o.ZP.createElement(Ei,null),o.ZP.createElement(Mi,{isOpen:l}),o.ZP.createElement($i,{isOpen:d}),o.ZP.createElement(Fi,{isOpen:u}),o.ZP.createElement(qi,{isOpen:m}),g&&o.ZP.createElement(hn,{key:g.id,message:g,noUi:!0}),o.ZP.createElement(Di,{url:f}),o.ZP.createElement(ji,{isOpen:v}),o.ZP.createElement(Fe.Z,{isOpen:Boolean(y),onClose:de,stickerSetShortName:y}),p&&o.ZP.createElement(Gi,{groupCallId:p}),o.ZP.createElement(_i,{isActive:Boolean(p||S)}),o.ZP.createElement(zi,{isOpen:Boolean(M||R),userId:M,isByPhoneNumber:R}),o.ZP.createElement(Ui,{openedGame:k,gameTitle:N}),o.ZP.createElement(Wi,{webApp:x}),o.ZP.createElement(xi,null),o.ZP.createElement(Hi,{isActive:S}),o.ZP.createElement(je,{isForAppBadge:!0}),o.ZP.createElement(Vi,{isOpen:T}),o.ZP.createElement(Xi,{bot:null==B?void 0:B.bot,type:null==B?void 0:B.type}),o.ZP.createElement(Ki,{bot:null==A?void 0:A.bot}))})));s.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,a.Rd)().connectionState||(0,a.Sv)().initApi()},8973:(e,t,n)=>{e.exports=n.p+"encoderWorker.min.8ea62f6317fbac7d4558..js"}}]);
|
||
//# sourceMappingURL=596.aeee18515698ebbfb151.js.map
|