2 lines
257 KiB
JavaScript
2 lines
257 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[347],{9347:(e,t,n)=>{n.r(t),n.d(t,{Main:()=>ci});var a=n(5116),s=n(3716),o=n(4050),i=(n(7895),n(9959)),r=n(9066),c=n(735),l=n(8415);function d(e){const{chatId:t,threadId:n}=(0,r.Bt)(e)||{};return t&&n?(e=(0,i.qr)(e,t,n,!1),e=(0,i.Pb)(e,t,n,void 0)):e}(0,a.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:n}=(0,r.Bt)(e)||{};if(t&&n)return(0,i.qr)(e,t,n,!0)})),(0,a.Q6)("closeLocalTextSearch",d),(0,a.Q6)("setLocalTextSearchQuery",((e,t,n)=>{const{chatId:a,threadId:s}=(0,r.Bt)(e)||{};if(!a||!s)return;const{query:o}=n,d=(0,l.uw)(a,s),{query:u}=e.localTextSearch.byChatThreadKey[d]||{};return o!==u&&(e=(0,i.Pb)(e,a,s,c.D)),(0,i.qr)(e,a,s,!0,o)})),(0,a.Q6)("setLocalMediaSearchType",((e,t,n)=>{const{chatId:a}=(0,r.Bt)(e)||{};if(!a)return;const{mediaType:s}=n;return(0,i.z5)(e,a,s)})),(0,a.Q6)("openChat",((e,t,n)=>{const{id:s,threadId:o=-1,type:c="thread",shouldReplaceHistory:l=!1}=n,u=(0,r.Bt)(e);return u&&u.chatId===s&&u.threadId===o&&u.type===c||(e=(0,i.pf)(e,s,o,"replyStack",[]),e=d(e=(0,i.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...s!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,a.R3)(e)),(0,i.Wy)(e,s,o,c,l)})),(0,a.Q6)("openPreviousChat",(e=>(0,i.Wy)(e,void 0))),(0,a.Q6)("openChatWithInfo",((e,t,n)=>{(0,a.R3)({...e,isChatInfoShown:!0}),t.openChat(n)})),(0,a.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,a.Q6)("setNewChatMembersDialogState",((e,t,n)=>({...e,newChatMembersProgress:n}))),(0,a.Q6)("openNextChat",((e,t,n)=>{const{targetIndexDelta:a,orderedIds:s}=n,{chatId:o}=(0,r.Bt)(e)||{};if(!o)return void t.openChat({id:s[0]});const i=s.indexOf(o);if(-1===i)return;const c=s[i+a];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=n(6137),m=n(1713),h=n(7361),g=n(782),f=n(2267),p=n(3099);const v=s.ck+s.fK;let I;(0,a.Q6)("setScrollOffset",((e,t,n)=>{const{chatId:a,threadId:s,scrollOffset:o}=n;return(0,i.pf)(e,a,s,"scrollOffset",o)})),(0,a.Q6)("setReplyingToId",((e,t,n)=>{const{messageId:a}=n,s=(0,r.Bt)(e);if(!s)return;const{chatId:o,threadId:c}=s;return(0,i.pf)(e,o,c,"replyingToId",a)})),(0,a.Q6)("setEditingId",((e,t,n)=>{const{messageId:a}=n,s=(0,r.Bt)(e);if(!s)return;const{chatId:o,threadId:c,type:l}=s,d="scheduled"===l?"editingScheduledId":"editingId";return(0,i.pf)(e,o,c,d,a)})),(0,a.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:n}=(0,r.Bt)(e)||{};if(!t||!n)return;const a=(0,r.Zw)(e,t),s=(0,r.Cb)(e,t,n);if(!a||!s)return;const o=(0,g.dF)(s,(t=>Boolean(a[t]&&(0,r._k)(e,a[t],n).canEdit)));return o?(0,i.pf)(e,t,n,"editingId",o):void 0})),(0,a.Q6)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:a}=n,{chatId:s,threadId:o}=(0,r.Bt)(e)||{};if(!s||!o)return;const i=(0,r.Zw)(e,s),c=(0,r.Cb)(e,s,o);if(!i||!c)return;const l=(0,r.Yy)(e,s,o);let d;if((0,r.b9)(e,s,o)&&l){const e=Object.keys(i),t=e.indexOf(l.toString())+a;d=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){var m;const t=(0,r.Z1)(e,s);d=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,r.tZ)(e,s,o);d=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:d}),t.focusMessage({chatId:s,threadId:o,messageId:d})})),(0,a.Q6)("openMediaViewer",((e,t,n)=>{const{chatId:a,threadId:s,messageId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c}=n;return{...e,mediaViewer:{chatId:a,threadId:s,messageId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c},forwardMessages:{}}})),(0,a.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,a.Q6)("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.Q6)("setAudioPlayerVolume",((e,t,n)=>{const{volume:a}=n;return{...e,audioPlayer:{...e.audioPlayer,volume:a}}})),(0,a.Q6)("setAudioPlayerPlaybackRate",((e,t,n)=>{const{playbackRate:a}=n;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:a}}})),(0,a.Q6)("setAudioPlayerMuted",((e,t,n)=>{const{isMuted:a}=n;return{...e,audioPlayer:{...e.audioPlayer,isMuted:a}}})),(0,a.Q6)("setAudioPlayerOrigin",((e,t,n)=>{const{origin:a}=n;return{...e,audioPlayer:{...e.audioPlayer,origin:a}}})),(0,a.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,a.Q6)("openPollResults",((e,t,n)=>{const{chatId:s,messageId:o}=n;(0,r.Jf)(e)?s===e.pollResults.chatId&&o===e.pollResults.messageId||(0,a.R3)({...e,pollResults:{chatId:s,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,a.Rd)();(0,a.R3)({...e,pollResults:{chatId:s,messageId:o,voters:{}}})}),450)})),(0,a.Q6)("closePollResults",(e=>{(0,a.R3)({...e,pollResults:{}})})),(0,a.Q6)("focusLastMessage",((e,t)=>{const n=(0,r.Bt)(e);if(!n)return;const{chatId:a,threadId:s}=n;let o;if(s===u._f){var i;const t=(0,r.Z1)(e,a);o=null==t||null===(i=t.lastMessage)||void 0===i?void 0:i.id}else{const t=(0,r.tZ)(e,a,s);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:a,threadId:s,messageId:o,noHighlight:!0})})),(0,a.Q6)("focusNextReply",((e,t)=>{const n=(0,r.Bt)(e);if(!n)return;const{chatId:s,threadId:o}=n,c=(0,r.p9)(e,s,o);if(c&&0!==c.length){const n=c.pop();e=(0,i.pf)(e,s,o,"replyStack",[...c]),(0,a.R3)(e),t.focusMessage({chatId:s,threadId:o,messageId:n})}else t.focusLastMessage()})),(0,a.Q6)("focusMessage",((e,t,n)=>{const{chatId:s,threadId:o=u._f,messageListType:c="thread",noHighlight:l,groupedId:d,groupedChatId:h,replyMessageId:g,isResizingContainer:f}=n;let{messageId:p}=n;if(void 0!==d){const t=(0,r.y8)(e,h,d);null!=t&&t.length&&([p]=t)}const y=(0,r.Bt)(e),Z=!y||s!==y.chatId||o!==y.threadId||c!==y.type;if(I&&(clearTimeout(I),I=void 0),I=window.setTimeout((()=>{let e=(0,a.Rd)();e=(0,i.cq)(e),e=(0,i.wV)(e),(0,a.R3)(e)}),l?v:1500),e=(0,i.cq)(e,s,p,l,f),e=(0,i.wV)(e,void 0),g){const t=(0,r.p9)(e,s,o)||[];e=(0,i.pf)(e,s,o,"replyStack",[...t,g])}Z&&(e=(0,i.wV)(e,m.fo.Static));const P=(0,r.Cb)(e,s,o);if(P&&P.includes(p))return(0,a.R3)(e),void t.openChat({id:s,threadId:o});if(Z&&(e=(0,i.pf)(e,s,o,"viewportIds",void 0)),e=(0,i.pf)(e,s,o,"outlyingIds",void 0),P&&!Z){const t=p>P[0]?m.fo.Down:m.fo.Up;e=(0,i.wV)(e,t)}(0,a.R3)(e),t.openChat({id:s,threadId:o}),t.loadViewportMessages()})),(0,a.Q6)("openForwardMenu",((e,t,n)=>{const{fromChatId:a,messageIds:s,groupedId:o}=n;let i;return o&&(i=(0,r.xH)(e,a,o)),{...e,forwardMessages:{fromChatId:a,messageIds:i||s,isModalShown:!0}}})),(0,a.Q6)("exitForwardMode",(e=>{(0,a.R3)({...e,forwardMessages:{}})})),(0,a.Q6)("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.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:a}=e.selectedMessages;t.openForwardMenu({fromChatId:n,messageIds:a})})),(0,a.Q6)("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.Q6)("downloadMessageMedia",((e,t,n)=>{const{message:s}=n;s&&(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[s.chatId]:[...e.activeDownloads.byChatId[s.chatId]||[],s.id]}}})})),(0,a.Q6)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:a}=e.selectedMessages,{threadId:s}=(0,r.Bt)(e)||{},o=(0,r.Zw)(e,n);o&&s&&a.map((e=>o[e])).filter((t=>(0,r._k)(e,t,s).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,a.Q6)("enterMessageSelectMode",((e,t,n)=>{const{messageId:a}=n||{},s=(0,r.jr)(e);return s?(0,i.M6)(e,s.id,a):e})),(0,a.Q6)("toggleMessageSelection",((e,t,n)=>{const{messageId:s,groupedId:o,childMessageIds:c,withShift:l}=n,d=(0,r.Bt)(e);if(!d)return;const{chatId:u,threadId:m,type:g}=d;e=(0,i.Ob)(e,u,m,g,s,o,c,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.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,a.Q6)("exitMessageSelectMode",i.i9),(0,a.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,a.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,a.Q6)("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,f.b)(e.serverTimeOffset),content:{text:(0,p.Z)("**Telegram Web Z was updated to version v1.31**\n\n👏 **Harder**\n• Hide text with an animation using the crossed-eye icon 👁 in the formatting menu.\n• Quickly add Spoiler formatting with Ctrl + P (⌘ + P on macOS), or || markdown around the text.\n• Admins can manage Join Requests and revoked invites.\n• Promote new admins in your groups and channels via Global Search.\n\n🤩 **Better**\n• Network stability enhancements.\n• Various improvements and tuning for reactions and interactive emoji.\n• Media Viewer improved for mobile devices.\n• Numerous layout adjustments.\n\n🚀 **Faster**\n• The app better renders multiple components.\n\n💪 **Stronger**\n• Fixed inline playback for QuickTime videos.\n• Fixes for tooltips – including stickers, emoji, and mentions.\n• Unread counter now correctly reflects values on mobile devices.\n• Emoji now properly copy from message text.\n• Users’ display names now appear in service messages.\n• Fixed collapsing multiple spaces in messages.\n• Reactions and the “Send As” feature are now always available in Discussion Groups.\n")},isOutgoing:!1};t.createServiceNotification({message:o,version:n})})),(0,a.Q6)("createServiceNotification",((e,t,n)=>{var o;const{message:i,version:c}=n,{serviceNotifications:l}=e,d=(0,r.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.id=h;const g={id:h,message:i,version:c,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.Q6)("openReactorListModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,reactorModal:{chatId:a,messageId:s}}})),(0,a.Q6)("closeReactorListModal",(e=>({...e,reactorModal:void 0}))),(0,a.Q6)("openSeenByModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,seenByModal:{chatId:a,messageId:s}}})),(0,a.Q6)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,a.Q6)("setGlobalSearchQuery",((e,t,n)=>{const{query:a}=n,{chatId:s}=e.globalSearch;return(0,i.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!s,messages:!0}}:{fetchingStatus:void 0},query:a})})),(0,a.Q6)("addRecentlyFoundChatId",((e,t,n)=>{const{id:a}=n,{recentlyFoundChatIds:s}=e.globalSearch;if(!s)return(0,i.No)(e,{recentlyFoundChatIds:[a]});const o=s.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),(0,i.No)(e,{recentlyFoundChatIds:o})})),(0,a.Q6)("clearRecentlyFoundChats",(e=>(0,i.No)(e,{recentlyFoundChatIds:void 0}))),(0,a.Q6)("setGlobalSearchContent",((e,t,n)=>{const{content:a}=n;return(0,i.Og)(e,a)})),(0,a.Q6)("setGlobalSearchChatId",((e,t,n)=>{const{id:a}=n;return(0,i.No)(e,{chatId:a,query:void 0,resultsByType:void 0})})),(0,a.Q6)("setStickerSearchQuery",((e,t,n)=>{const{query:a}=n;return{...e,stickers:{...e.stickers,search:{query:a,resultIds:void 0}}}})),(0,a.Q6)("setGifSearchQuery",((e,t,n)=>{const{query:a}=n;return{...e,gifs:{...e.gifs,search:{query:a,offsetId:void 0,results:void 0}}}})),(0,a.Q6)("openUserInfo",((e,t,n)=>{const{id:a}=n;t.openChat({id:a})})),(0,a.Q6)("openChat",(e=>(0,i.x1)(e,void 0))),(0,a.Q6)("setUserSearchQuery",((e,t,n)=>{const{query:a}=n;return(0,i.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a})})),n(3781);var y=n(1947),Z=n(6926);(0,a.Q6)("toggleChatInfo",((e,t,n)=>({...e,isChatInfoShown:void 0!==n?n:!e.isChatInfoShown}))),(0,a.Q6)("setLeftColumnWidth",((e,t,n)=>({...e,leftColumnWidth:n}))),(0,a.Q6)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,a.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,r.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,a.Q6)("requestNextManagementScreen",((e,t,n)=>{const{screen:a}=n||{},{chatId:s}=(0,r.Bt)(e)||{};if(s)return{...e,management:{byChatId:{...e.management.byChatId,[s]:{...e.management.byChatId[s],isActive:!0,nextScreen:a}}}}})),(0,a.Q6)("closeManagement",(e=>{const{chatId:t}=(0,r.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,a.Q6)("openChat",(e=>{if(h.wB||h.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,a.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,a.Q6)("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.Q6)("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.Q6)("showNotification",((e,t,n)=>{const a=n;a.localId=(0,Z.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.Q6)("dismissNotification",((e,t,n)=>{const a=e.notifications.filter((e=>{let{localId:t}=e;return t!==n.localId}));return{...e,notifications:a}})),(0,a.Q6)("showDialog",((e,t,n)=>{const{data:a}=n;if("message"in a&&a.hasErrorKey&&!(0,y.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.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,a.Q6)("toggleSafeLinkModal",((e,t,n)=>{const{url:a}=n;return{...e,safeLinkModalUrl:a}})),(0,a.Q6)("openHistoryCalendar",((e,t,n)=>{const{selectedAt:a}=n;return{...e,historyCalendarSelectedAt:a}})),(0,a.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,a.Q6)("openPaymentModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,payment:{...e.payment,chatId:a,messageId:s,isPaymentModalOpen:!0}}})),(0,a.Q6)("closePaymentModal",(e=>{const t=(0,i.bp)(e);return(0,i.WY)(t)})),(0,a.Q6)("addPaymentError",((e,t,n)=>{const{error:a}=n;return{...e,payment:{...e.payment,error:a}}})),n(1689),n(1363),n(6204);var P=n(1226),C=n(9118);const w=new Map,b=(0,C.Ds)((e=>e()),500,!1);async function E(e,t,n,o){let c=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,P.t9)("fetchMessages",{chat:(0,r.Cm)((0,a.Rd)(),d,t),offsetId:n,addOffset:u,limit:s.hT,threadId:t});if(!h)return;const{messages:f,users:p,chats:v,threadInfos:I}=h;let y=(0,a.Rd)();const Z=d===s.aw?y.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],C=[].concat(f,Z),w=(0,g.ee)(C,"id"),b=Object.keys(w).map(Number);y=(0,i.c_)(y,d,w),y=c?(0,i.ff)(y,d,t,b):(0,i.xj)(y,d,t,b),y=(0,i.Sh)(y,(0,g.ee)(p,"id")),y=(0,i.fZ)(y,(0,g.ee)(v,"id")),y=(0,i.j6)(y,d,I);let E=(0,r.gb)(y,d,t);const M=(0,r.qC)(y,d,t);if(c&&E&&M&&(M.length&&!(0,g.YE)(E,M)||(y=(0,i.xj)(y,d,t,M),E=(0,r.gb)(y,d,t),y=(0,i.pf)(y,d,t,"outlyingIds",void 0),c=!1)),!l){const e=c?M:E,{newViewportIds:a}=S(e,n,o);y=(0,i.y9)(y,d,t,a)}(0,a.R3)(y)}function S(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 M(e){let t;const n=e.attachment?(e,s)=>{w.has(s)||(t=s,w.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,C.Pn)();const s=(0,a.Rd)();e.serverTimeOffset=s.serverTimeOffset;const o=(0,r.Bt)(s);if(!o)return;const{threadId:i}=o;e.replyingTo||i===u._f||(e.replyingTo=(0,r.qS)(s,e.chat.id,i)),await(0,P.t9)("sendMessage",e,n),n&&t&&w.delete(t)}(0,a.Q6)("loadViewportMessages",((e,t,n)=>{const{direction:a=m.Uq.Around,isBudgetPreload:o=!1}=n||{};let{chatId:c,threadId:l}=n||{};if(!c){const t=(0,r.Bt)(e);if(!t)return;c=t.chatId,l=t.threadId}const d=(0,r.Z1)(e,c);if(!d||d.isRestricted)return;const u=(0,r.Cb)(e,c,l),h=(0,r.gb)(e,c,l),g=(0,r.qC)(e,c,l);if(u&&u.length&&a!==m.Uq.Around){const n=a===m.Uq.Backwards?u[0]:u[u.length-1],s=Boolean(g),r=s?g:h,{newViewportIds:f,areSomeLocal:p,areAllLocal:v}=S(r,n,a);if(p&&(e=(0,i.y9)(e,c,l,f)),async function(e,t,n,a,s,o,i,r){t||await E(s,o,r,i,n,a),a||(await Promise.resolve(),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,r.G$)(e,c)||(0,r.rd)(e,c,l),n=Boolean(t&&h&&!h.includes(t)),a=(n?g:h)||[],{newViewportIds:u,areSomeLocal:f,areAllLocal:p}=S(a,t,m.Uq.Around);f&&u.length>=s.hT&&(e=(0,i.y9)(e,c,l,u)),p||E(d,l,t,m.Uq.Around,n,o)}return e})),(0,a.Q6)("loadMessage",((e,t,n)=>{const{chatId:s,messageId:o,replyOriginForId:c,threadUpdate:l}=n,d=(0,r.Z1)(e,s);d&&(async()=>{const e=await async function(e,t,n){const s=await(0,P.t9)("fetchMessage",{chat:e,messageId:t});if(!s)return;if(s===u._Q){if(n){let t=(0,a.Rd)();const s=(0,r.hj)(t,e.id,n);t=(0,i.cY)(t,e.id,n,{...s,replyToMessageId:void 0}),(0,a.R3)(t)}return}let o=(0,a.Rd)();return o=(0,i.cY)(o,e.id,t,s.message),o=(0,i.Sh)(o,(0,g.ee)(s.users,"id")),(0,a.R3)(o),s.message}(d,o,c);if(e&&l){const{lastMessageId:t,isDeleting:n}=l;(0,a.R3)((0,i.lG)((0,a.Rd)(),e,s,t,n))}})()})),(0,a.Q6)("sendMessage",((e,t,n)=>{const a=(0,r.Bt)(e);if(!a)return;const{chatId:o,threadId:i,type:c}=a;if("scheduled"===c&&!n.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:n}};const l=(0,r.Z1)(e,o),d={...n,chat:l,replyingTo:(0,r.Yy)(e,o,i),noWebPage:(0,r.tV)(e,o,i),sendAs:(0,r._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;M({...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}`;M({...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=>{M({...a,attachment:e,groupedId:r})}))}}else{const{text:e,entities:t,attachments:n,replyingTo:a,...s}=d;e&&M({...s,text:e,entities:t,replyingTo:a}),n.forEach((e=>{M({...s,attachment:e})}))}})),(0,a.Q6)("editMessage",((e,t,n)=>{const{serverTimeOffset:a}=e,{text:s,entities:o}=n,i=(0,r.Bt)(e);if(!i)return;const{chatId:c,threadId:l,type:d}=i,u=(0,r.Z1)(e,c),m=(0,r.kK)(e,c,l,d);u&&m&&((0,P.t9)("editMessage",{chat:u,message:m,text:s,entities:o,noWebPage:(0,r.tV)(e,c,l),serverTimeOffset:a}),t.setEditingId({messageId:void 0}))})),(0,a.Q6)("cancelSendingMessage",((e,t,n)=>{const{chatId:a,messageId:s}=n,o=(0,r.hj)(e,a,s),i=o&&w.get(o.previousLocalId||o.id);i&&(0,P.u3)(i),t.apiUpdate({"@type":"deleteMessages",ids:[s],chatId:a})})),(0,a.Q6)("saveDraft",((e,t,n)=>{const{chatId:a,threadId:s,draft:o}=n;if(!o)return;const{text:c,entities:l}=o,d=(0,r.Z1)(e,a);return s===u._f&&(0,P.t9)("saveDraft",{chat:d,text:c,entities:l,replyToMsgId:(0,r.Yy)(e,a,s)}),e=(0,i.pf)(e,a,s,"draft",o),(0,i.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)})})),(0,a.Q6)("clearDraft",((e,t,n)=>{const{chatId:a,threadId:s,localOnly:o}=n;if(!(0,r.Ms)(e,a,s))return;const c=(0,r.Z1)(e,a);return o||s!==u._f||(0,P.t9)("clearDraft",c),e=(0,i.pf)(e,a,s,"draft",void 0),(0,i.a4)(e,a,{draftDate:void 0})})),(0,a.Q6)("toggleMessageWebPage",((e,t,n)=>{const{chatId:a,threadId:s,noWebPage:o}=n;return(0,i.pf)(e,a,s,"noWebPage",o)})),(0,a.Q6)("pinMessage",((e,t,n)=>{const a=(0,r.jr)(e);if(!a)return;const{messageId:s,isUnpin:o,isOneSide:i,isSilent:c}=n;(0,P.t9)("pinMessage",{chat:a,messageId:s,isUnpin:o,isOneSide:i,isSilent:c})})),(0,a.Q6)("unpinAllMessages",((e,t,n)=>{const s=(0,r.Z1)(e,n.chatId);s&&async function(e){await(0,P.t9)("unpinAllMessages",{chat:e});let t=(0,a.Rd)();t=(0,i.pf)(t,e.id,u._f,"pinnedIds",[]),(0,a.R3)(t)}(s)})),(0,a.Q6)("deleteMessages",((e,t,n)=>{const{messageIds:a,shouldDeleteForAll:s}=n,o=(0,r.Bt)(e);if(!o)return;const{chatId:i,threadId:c}=o,l=(0,r.Z1)(e,i);(0,P.t9)("deleteMessages",{chat:l,messageIds:a,shouldDeleteForAll:s});const d=(0,r._$)(e,i,c);a.includes(d)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteScheduledMessages",((e,t,n)=>{const{messageIds:a}=n,s=(0,r.Bt)(e);if(!s)return;const{chatId:o}=s,i=(0,r.Z1)(e,o);(0,P.t9)("deleteScheduledMessages",{chat:i,messageIds:a});const c=(0,r.wU)(e,o);a.includes(c)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteHistory",((e,t,n)=>{(async()=>{var a;const{chatId:s,shouldDeleteForAll:o}=n,i=(0,r.Z1)(e,s);if(!i)return;const c=null===(a=i.lastMessage)||void 0===a?void 0:a.id;await(0,P.t9)("deleteHistory",{chat:i,shouldDeleteForAll:o,maxId:c});const l=(0,r.Bt)(e);l&&l.chatId===s&&t.openChat({id:void 0})})()})),(0,a.Q6)("reportMessages",((e,t,n)=>{(async()=>{const{messageIds:a,reason:s,description:o}=n,i=(0,r.Bt)(e);if(!i)return;const{chatId:c}=i,l=(0,r.Z1)(e,c),d=await(0,P.t9)("reportMessages",{peer:l,messageIds:a,reason:s,description:o});t.showNotification({message:d?"Thank you! Your report will be reviewed by our team.":"Error occured while submiting report. Please, try again later."})})()})),(0,a.Q6)("sendMessageAction",((e,t,n)=>{(async()=>{const{action:t,chatId:a,threadId:s}=n;if(a===e.currentUserId)return;const o=(0,r.Z1)(e,a);o&&await(0,P.t9)("sendMessageAction",{peer:o,threadId:s,action:t})})()})),(0,a.Q6)("markMessageListRead",((e,t,n)=>{const{serverTimeOffset:a}=e,o=(0,r.Bt)(e);if(!o)return;const{chatId:c,threadId:l}=o,d=(0,r.Cm)(e,c,l);if(!d)return;const{maxId:m}=n;if(b((()=>{(0,P.t9)("markMessageListRead",{serverTimeOffset:a,chat:d,threadId:l,maxId:m})})),l!==u._f)return;c===s.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=m?{...e,isUnread:!1}:e))});const h=(0,r.Cb)(e,c,l),g=(0,r.It)(e,c,l);if(!h||!g||!d.unreadCount)return e;const f=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 f?(0,i.a4)(e,c,{lastReadInboxMessageId:m,unreadCount:Math.max(0,d.unreadCount-f)}):e})),(0,a.Q6)("markMessagesRead",((e,t,n)=>{const a=(0,r.jr)(e);if(!a)return;const{messageIds:s}=n;(0,P.t9)("markMessagesRead",{chat:a,messageIds:s})})),(0,a.Q6)("loadWebPagePreview",((e,t,n)=>{const{text:s}=n;!async function(e){const t=await(0,P.t9)("fetchWebPagePreview",{message:e});(0,a.R3)({...(0,a.Rd)(),webPagePreview:t})}(s)})),(0,a.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,a.Q6)("sendPollVote",((e,t,n)=>{const{chatId:a,messageId:s,options:o}=n,i=(0,r.Z1)(e,a);i&&(0,P.t9)("sendPollVote",{chat:i,messageId:s,options:o})})),(0,a.Q6)("loadPollOptionResults",((e,t,n)=>{const{chat:s,messageId:o,option:r,offset:c,limit:l,shouldResetVoters:d}=n;!async function(e,t,n,s,o,r){const c=await(0,P.t9)("loadPollOptionResults",{chat:e,messageId:t,option:n,offset:s,limit:o});if(!c)return;let l=(0,a.Rd)();l=(0,i.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)([...!r&&d&&d[n]?d[n]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[n]:c.nextOffset||""}}})}(s,o,r,c,l,d)})),(0,a.Q6)("forwardMessages",((e,t,n)=>{const{fromChatId:s,messageIds:o,toChatId:i}=e.forwardMessages,c=s?(0,r.Z1)(e,s):void 0,d=i?(0,r.Z1)(e,i):void 0,u=s&&o?o.sort(((e,t)=>e-t)).map((t=>(0,r.hj)(e,s,t))).filter(Boolean):void 0;if(!c||!d||!u)return;const{isSilent:m,scheduledAt:h}=n,g=(0,r._5)(e,i),f=u.filter((e=>!(0,l.jM)(e)));f.length&&(0,P.t9)("forwardMessages",{fromChat:c,toChat:d,messages:f,serverTimeOffset:(0,a.Rd)().serverTimeOffset,isSilent:m,scheduledAt:h,sendAs:g}),u.filter((e=>(0,l.jM)(e))).forEach((e=>{const{text:t,entities:n}=e.content.text||{},{sticker:a,poll:s}=e.content;M({chat:d,text:t,entities:n,sticker:a,poll:s,isSilent:m,scheduledAt:h,sendAs:g})})),(0,a.R3)({...(0,a.Rd)(),forwardMessages:{}})})),(0,a.Q6)("loadScheduledHistory",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&async function(e){const t=await(0,P.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 r=(0,a.Rd)();r=(0,i.w3)(r,e.id,s),r=(0,i.pf)(r,e.id,u._f,"scheduledIds",o),(0,a.R3)(r)}(o)})),(0,a.Q6)("sendScheduledMessages",((e,t,n)=>{const{chatId:a,id:s}=n,o=(0,r.Z1)(e,a);o&&(0,P.t9)("sendScheduledMessages",{chat:o,ids:[s]})})),(0,a.Q6)("rescheduleMessage",((e,t,n)=>{const{chatId:a,messageId:s,scheduledAt:o}=n,i=(0,r.Z1)(e,a),c=i&&(0,r.Tm)(e,i.id,s);i&&c&&(0,P.t9)("rescheduleMessage",{chat:i,message:c,scheduledAt:o})})),(0,a.Q6)("requestThreadInfoUpdate",((e,t,n)=>{const{chatId:a,threadId:s}=n,o=(0,r.Cm)(e,a,s);o&&(0,P.t9)("requestThreadInfoUpdate",{chat:o,threadId:s})})),(0,a.Q6)("loadPinnedMessages",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&async function(e){const t=await(0,P.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:n,chats:s,users:o}=t,r=(0,g.ee)(n,"id"),c=Object.keys(r).map(Number).sort(((e,t)=>t-e));let l=(0,a.Rd)();l=(0,i.c_)(l,e.id,r),l=(0,i.pf)(l,e.id,u._f,"pinnedIds",c),l=(0,i.Sh)(l,(0,g.ee)(o,"id")),l=(0,i.fZ)(l,(0,g.ee)(s,"id")),(0,a.R3)(l)}(o)})),(0,a.Q6)("loadSeenBy",((e,t,n)=>{const{chatId:s,messageId:o}=n,c=(0,r.Z1)(e,s);c&&(async()=>{const e=await(0,P.t9)("fetchSeenBy",{chat:c,messageId:o});e&&(0,a.R3)((0,i.cY)((0,a.Rd)(),s,o,{seenByUserIds:e}))})()})),(0,a.Q6)("saveDefaultSendAs",((e,t,n)=>{const{chatId:a,sendAsId:s}=n,o=(0,r.Z1)(e,a),c=(0,r.Z1)(e,s)||(0,r.dy)(e,s);if(o&&c)return(0,P.t9)("saveDefaultSendAs",{sendAs:c,chat:o}),(0,i.a4)(e,a,{fullInfo:{...o.fullInfo,sendAsId:s}})})),(0,a.Q6)("loadSendAs",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&(async()=>{const t=await(0,P.t9)("fetchSendAs",{chat:o});if(!t)return e=(0,i.a4)(e,s,{sendAsIds:[]}),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,i.Sh)(e,(0,g.ee)(t.users,"id")),e=(0,i.fZ)(e,(0,g.ee)(t.chats,"id")),e=(0,i.a4)(e,s,{sendAsIds:t.ids}),(0,a.R3)(e)})()})),(0,a.Q6)("loadSponsoredMessages",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&(async()=>{const e=await(0,P.t9)("fetchSponsoredMessages",{chat:o});if(!e)return;let t=(0,i.Fn)((0,a.Rd)(),s,e.messages[0]);t=(0,i.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,i.fZ)(t,(0,g.ee)(e.chats,"id")),(0,a.R3)(t)})()})),(0,a.Q6)("viewSponsoredMessage",((e,t,n)=>{const{chatId:a}=n,s=(0,r.Z1)(e,a),o=(0,r.fS)(e,a);s&&o&&(0,P.t9)("viewSponsoredMessage",{chat:s,random:o.randomId})}));var R=n(5765);const k=(0,C.P2)((e=>e()),500,!1);async function T(e,t){const n=await(0,P.t9)("searchGifs",{query:e,offset:t});n&&(0,a.R3)((0,i.rq)((0,a.Rd)(),!t,n.gifs,n.nextOffset))}(0,a.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,P.t9)("fetchStickerSets",{hash:e});t&&(0,a.R3)((0,i.z3)((0,a.Rd)(),"added",t.hash,t.sets))}(t)})),(0,a.Q6)("loadAddedStickers",((e,t)=>{const{setIds:n}=e.stickers.added,a=e.stickers.setsById;n&&n.length&&(async()=>{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,C.wO)(200))}})()})),(0,a.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,P.t9)("fetchRecentStickers",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,recent:t}})}(t)})),(0,a.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,P.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,favorite:t}})}(t)})),(0,a.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,P.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,a.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,P.t9)("fetchFeaturedStickers",{hash:e});t&&(0,a.R3)((0,i.z3)((0,a.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,a.Q6)("loadStickers",((e,t,n)=>{const{stickerSetId:s,stickerSetShortName:o}=n;let{stickerSetAccessHash:c}=n;if(!c&&!o){const t=(0,r.Ny)(e,s);if(!t)return;c=t.accessHash}!async function(e,t,n){const s=await(0,P.t9)("fetchStickers",{stickerSetShortName:n,stickerSetId:e,accessHash:t});if(!s)return;const{set:o,stickers:r,packs:c}=s;let l=(0,a.Rd)();l=(0,i.Rg)(l,o.id,{...o,stickers:r,packs:c});const d=l.stickers.forEmoji.emoji;d&&c[d]&&(l=(0,i.vy)(l)),(0,a.R3)(l)}(s,c,o)})),(0,a.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,P.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:n}=e;(0,a.R3)((0,i.g_)((0,a.Rd)(),{...t,stickers:n}))}(),async function(){const e=await(0,P.t9)("fetchAnimatedEmojiEffects");if(!e)return;const{set:t,stickers:n}=e;(0,a.R3)({...(0,a.Rd)(),animatedEmojiEffects:{...t,stickers:n}})}()})),(0,a.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,P.t9)("fetchSavedGifs",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,gifs:{...n.gifs,saved:t}})}(t)})),(0,a.Q6)("faveSticker",((e,t,n)=>{const{sticker:a}=n;a&&(0,P.t9)("faveSticker",{sticker:a})})),(0,a.Q6)("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,P.t9)("faveSticker",{sticker:e,unfave:!0})}(s)})),(0,a.Q6)("toggleStickerSet",((e,t,n)=>{const{stickerSetId:a}=n,s=(0,r.Ny)(e,a);if(!s)return;const{accessHash:o,installedDate:i}=s;(0,P.t9)(i?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.Q6)("loadEmojiKeywords",((e,t,n)=>{var s;const{language:o}=n;let i=e.emojiKeywords[o];null!==(s=i)&&void 0!==s&&s.isLoading||((0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...i,isLoading:!0}}}),(async()=>{var t;const n=await(0,P.t9)("fetchEmojiKeywords",{language:o,fromVersion:i?i.version:0});e=(0,a.Rd)(),i=e.emojiKeywords[o],n?(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:n.version,keywords:{...null===(t=i)||void 0===t?void 0:t.keywords,...n.keywords}}}}):(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...i,isLoading:!1}}})})())})),(0,a.Q6)("setStickerSearchQuery",((e,t,n)=>{const{query:s}=n;s&&k((()=>{!async function(e,t){const n=await(0,P.t9)("searchStickers",{query:e,hash:void 0});if(!n)return;const s=(0,a.Rd)(),{setsById:o,added:r}=s.stickers,c=n.sets.map((e=>{let{id:t}=e;return t}));r.setIds&&r.setIds.forEach((t=>{if(!c.includes(t)){const{title:n}=o[t]||{};n&&(0,R.Z)(n,e)&&c.unshift(t)}})),(0,a.R3)((0,i.z3)(s,"search",n.hash,n.sets,c))}(s)}))})),(0,a.Q6)("setGifSearchQuery",((e,t,n)=>{const{query:a}=n;"string"==typeof a&&k((()=>{T(a)}))})),(0,a.Q6)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&k((()=>{T(t,n)}))})),(0,a.Q6)("loadStickersForEmoji",((e,t,n)=>{const{emoji:s}=n,{hash:o}=e.stickers.forEmoji;k((()=>{!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,P.t9)("fetchStickersForEmoji",{emoji:e,hash:t});n=(0,a.Rd)(),s&&n.stickers.forEmoji.emoji===e&&(n=(0,i.IM)(n,e,s.stickers,s.hash),(0,a.R3)(n))}(s,o)}))})),(0,a.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.Q6)("openStickerSetShortName",((e,t,n)=>{const{stickerSetShortName:a}=n;return{...e,openedStickerSetShortName:a}}));var N=n(790);const B=(0,C.P2)((e=>e()),500,!1);async function x(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,c=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0;if(c){const a=await(0,P.t9)("searchMessagesLocal",{chatOrUser:c,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,P.t9)("searchMessagesGlobal",{query:t,offsetRate:o,limit:s.Hk,type:n,maxDate:l,minDate:d});let u=(0,a.Rd)();const m=(0,r.JX)(u);if(!e||""!==t&&t!==m)return void(0,a.R3)((0,i.xv)(u,{messages:!1}));const{messages:h,users:f,chats:p,totalCount:v,nextRate:I}=e;p.length&&(u=(0,i.fZ)(u,(0,g.ee)(p,"id"))),f.length&&(u=(0,i.Sh)(u,(0,g.ee)(f,"id"))),h.length&&(u=(0,i.m6)(u,h)),u=(0,i.px)(u,h,v,n,I),(0,a.R3)(u)}async function A(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const c=await(0,P.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:2*s.EN,offsetId:n});if(!c)return;const{chats:l,users:d,messages:u,totalCount:m,nextOffsetId:h}=c,f=(0,g.ee)(u,"id"),p=Object.keys(f).map(Number);let v=(0,a.Rd)();const I=(0,r.we)(v);I&&(v=(0,i.fZ)(v,(0,g.ee)(l,"id")),v=(0,i.Sh)(v,(0,g.ee)(d,"id")),v=(0,i.c_)(v,e.id,f),v=(0,i.c1)(v,e.id,t,p,m,h),(0,a.R3)(v),o||A(e,t,h,!0))}let L;async function O(){const e=await(0,P.t9)("fetchChats",{limit:s.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,a.Rd)().serverTimeOffset});if(!e)return;let t=(0,a.Rd)();t=(0,i.eD)(t,(0,g.ee)(e.users,"id")),t=(0,i.zn)(t,e.userStatusesById),t=(0,i.GL)(t,(0,g.ee)(e.chats,"id")),t=(0,i.Mg)(t,"archived",e.chatIds),t=(0,i.vv)(t,"archived",e),(0,a.R3)(t)}async function U(){let e=(0,a.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:n}=e.contactList||{};if(!(n&&n.length||t&&t.length))return;const s=[...t||[],...n||[]].map((t=>(0,r.dy)(e,t))).filter(Boolean),o=await(0,P.t9)("fetchUsers",{users:s});if(!o)return;const{users:c,userStatusesById:l}=o;e=(0,a.Rd)(),e=(0,i.eD)(e,(0,g.ee)(c,"id")),e=(0,i.zn)(e,l),(0,a.R3)(e)}function F(e){return(0,P.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(s.hT/2)+1),limit:s.hT})}(0,a.Q6)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:s}=e.globalSearch,{query:o}=n;o&&!s&&B((()=>{!async function(e){const t=await(0,P.t9)("searchChats",{query:e});let n=(0,a.Rd)();const s=(0,r.JX)(n);if(!t||!s||e!==s)return void(0,a.R3)((0,i.xv)(n,{chats:!1}));const{localChats:o,localUsers:c,globalChats:l,globalUsers:d}=t;(o.length||l.length)&&(n=(0,i.fZ)(n,(0,g.ee)([...o,...l],"id"))),(c.length||d.length)&&(n=(0,i.Sh)(n,(0,g.ee)([...c,...d],"id"))),n=(0,i.xv)(n,{chats:!1}),n=(0,i.No)(n,{localResults:{chatIds:o.map((e=>{let{id:t}=e;return t})),userIds:c.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.Q6)("setGlobalSearchDate",((e,t,n)=>{const{date:s}=n,o=s?(0,N.IS)(s):s,c=(0,i.No)(e,{date:s,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,a.R3)(c);const{chatId:l}=e.globalSearch;x("","text",void 0,l?(0,r.Z1)(e,l):void 0,o,s)})),(0,a.Q6)("searchMessagesGlobal",((e,t,n)=>{var a;const{query:s,resultsByType:o,chatId:i,date:c}=e.globalSearch,l=c?(0,N.IS)(c):c,{type:d}=n;x(s,d,null==o||null===(a=o[d])||void 0===a?void 0:a.nextOffsetId,i?(0,r.Z1)(e,i):void 0,l,c)})),(0,a.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:n}=(0,r.Bt)(e)||{},o=t?(0,r.Z1)(e,t):void 0,c=(0,r.n5)(e);if(!o||!c||!n)return;const{query:l,results:d}=c,m=null==d?void 0:d.nextOffsetId;let h;if(n!==u._f){const a=(0,r.tZ)(e,t,n);h=null==a?void 0:a.topMessageId}!async function(e,t,n,o,c){if(!o)return;const l=await(0,P.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:n,limit:s.pn,offsetId:c});if(!l)return;const{chats:d,users:u,messages:m,totalCount:h,nextOffsetId:f}=l,p=(0,g.ee)(m,"id"),v=Object.keys(p).map(Number);let I=(0,a.Rd)();const y=(0,r.n5)(I);y&&o===y.query&&(I=(0,i.fZ)(I,(0,g.ee)(d,"id")),I=(0,i.Sh)(I,(0,g.ee)(u,"id")),I=(0,i.c_)(I,e.id,p),I=(0,i.dx)(I,e.id,t,v,h,f),(0,a.R3)(I))}(o,n,h,l,m)})),(0,a.Q6)("searchMediaMessagesLocal",(e=>{const t=(0,r.og)(e),n=t?e.users.byId[t]||e.chats.byId[t]:void 0,a=(0,r.we)(e);if(!n||!a)return;const{currentType:s,resultsByType:o}=a,i=s&&o&&o[s],c=null==i?void 0:i.nextOffsetId;s&&A(n,s,c)})),(0,a.Q6)("searchMessagesByDate",((e,t,n)=>{const{timestamp:s}=n,{chatId:o}=(0,r.Bt)(e)||{};if(!o)return;const i=(0,r.Z1)(e,o);i&&async function(e,t){const n=await(0,P.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});n&&(0,a.uC)().focusMessage({chatId:e.id,messageId:n})}(i,s)})),(0,a.Q6)("checkPublicLink",((e,t,n)=>{const{chatId:s}=(0,r.Bt)(e)||{};if(!s)return;if(e.management.progress===m.wv.InProgress)return;const{username:o}=n;(async()=>{e=(0,i.H9)(e,m.wv.InProgress),e=(0,i.fw)(e,s,{isUsernameAvailable:void 0}),(0,a.R3)(e);const t=await(0,P.t9)("checkChatUsername",{username:o});e=(0,a.Rd)(),e=(0,i.H9)(e,t?m.wv.Complete:m.wv.Error),e=(0,i.fw)(e,s,{isUsernameAvailable:t}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePublicLink",((e,t,n)=>{const{chatId:s}=(0,r.Bt)(e)||{};let o=s&&(0,r.Z1)(e,s);if(!s||!o)return;const{username:c}=n;(async()=>{if(e=(0,i.H9)(e,m.wv.InProgress),(0,a.R3)(e),(0,l.G9)(o)){if(o=await(0,P.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const n=await(0,P.t9)("setChatUsername",{chat:o,username:c});e=(0,a.Rd)(),e=(0,i.H9)(e,n?m.wv.Complete:m.wv.Error),e=(0,i.fw)(e,s,{isUsernameAvailable:void 0}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,r.Bt)(e)||{},n=t&&(0,r.Z1)(e,t);t&&n&&(0,P.t9)("updatePrivateLink",{chat:n})})),(0,a.Q6)("setEditingExportedInvite",((e,t,n)=>{const{chatId:s,invite:o}=n;(0,a.R3)((0,i.fw)(e,s,{editingInvite:o}))})),(0,a.Q6)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:s,invite:o}=n,r=o?{inviteInfo:{invite:o}}:{inviteInfo:void 0};(0,a.R3)((0,i.fw)(e,s,r))})),(0,a.Q6)("loadExportedChatInvites",((e,t,n)=>{const{chatId:s,adminId:o,isRevoked:c,limit:l}=n,d=(0,r.Z1)(e,s),u=(0,r.dy)(e,o||e.currentUserId);d&&u&&(async()=>{const e=await(0,P.t9)("fetchExportedChatInvites",{peer:d,admin:u,isRevoked:c,limit:l});if(!e)return;const t=c?{revokedInvites:e}:{invites:e};(0,a.R3)((0,i.fw)((0,a.Rd)(),s,t))})()})),(0,a.Q6)("editExportedChatInvite",((e,t,n)=>{const{chatId:s,link:o,isRevoked:c,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m}=n,h=(0,r.Z1)(e,s);h&&(async()=>{const t=await(0,P.t9)("editExportedChatInvite",{peer:h,link:o,isRevoked:c,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m});if(!t)return;let n=(e=(0,a.Rd)()).management.byChatId[s].invites||[];const r=e.management.byChatId[s].revokedInvites||[],{oldInvite:g,newInvite:f}=t;n=n.filter((e=>e.link!==g.link)),f.isRevoked?r.unshift(f):n.push(f),(0,a.R3)((0,i.fw)(e,s,{invites:n,revokedInvites:r}))})()})),(0,a.Q6)("exportChatInvite",((e,t,n)=>{const{chatId:s,expireDate:o,usageLimit:c,isRequestNeeded:l,title:d}=n,u=(0,r.Z1)(e,s);u&&(async()=>{const t=await(0,P.t9)("exportChatInvite",{peer:u,expireDate:o,usageLimit:c,isRequestNeeded:l,title:d});if(!t)return;const n=(e=(0,a.Rd)()).management.byChatId[s].invites||[];(0,a.R3)((0,i.fw)(e,s,{invites:[...n,t]}))})()})),(0,a.Q6)("deleteExportedChatInvite",((e,t,n)=>{const{chatId:s,link:o}=n,c=(0,r.Z1)(e,s);c&&(async()=>{var t,n;if(!await(0,P.t9)("deleteExportedChatInvite",{peer:c,link:o}))return;const r=(e=(0,a.Rd)()).management.byChatId[s];(0,a.R3)((0,i.fw)(e,s,{invites:null==r||null===(t=r.invites)||void 0===t?void 0:t.filter((e=>e.link!==o)),revokedInvites:null==r||null===(n=r.revokedInvites)||void 0===n?void 0:n.filter((e=>e.link!==o))}))})()})),(0,a.Q6)("deleteRevokedExportedChatInvites",((e,t,n)=>{const{chatId:s,adminId:o}=n,c=(0,r.Z1)(e,s),l=(0,r.dy)(e,o||e.currentUserId);c&&l&&(async()=>{await(0,P.t9)("deleteRevokedExportedChatInvites",{peer:c,admin:l})&&(e=(0,a.Rd)(),(0,a.R3)((0,i.fw)(e,s,{revokedInvites:[]})))})()})),(0,a.Q6)("loadChatInviteImporters",((e,t,n)=>{const{chatId:s,link:o,offsetDate:c,offsetUserId:l,limit:d}=n,u=(0,r.Z1)(e,s),m=(0,r.dy)(e,l);!u||l&&!m||(async()=>{var t;const n=await(0,P.t9)("fetchChatInviteImporters",{peer:u,link:o,offsetDate:c,offsetUser:m,limit:d});if(!n)return;const r=null===(t=(e=(0,a.Rd)()).management.byChatId[s])||void 0===t?void 0:t.inviteInfo;null!=r&&r.invite&&r.invite.link===o&&(0,a.R3)((0,i.fw)(e,s,{inviteInfo:{...r,importers:n}}))})()})),(0,a.Q6)("loadChatInviteRequesters",((e,t,n)=>{const{chatId:s,link:o,offsetDate:c,offsetUserId:l,limit:d}=n,u=(0,r.Z1)(e,s),m=(0,r.dy)(e,l);!u||l&&!m||(async()=>{var t;const n=await(0,P.t9)("fetchChatInviteImporters",{peer:u,link:o,offsetDate:c,offsetUser:m,limit:d,isRequested:!0});if(!n)return;const r=null===(t=(e=(0,a.Rd)()).management.byChatId[s])||void 0===t?void 0:t.inviteInfo;null!=r&&r.invite&&r.invite.link===o&&(0,a.R3)((0,i.fw)(e,s,{inviteInfo:{...r,requesters:n}}))})()})),(0,a.Q6)("loadChatJoinRequests",((e,t,n)=>{const{chatId:s,offsetDate:o,offsetUserId:c,limit:l}=n,d=(0,r.Z1)(e,s),u=(0,r.dy)(e,c);!d||c&&!u||(async()=>{const t=await(0,P.t9)("fetchChatInviteImporters",{peer:d,offsetDate:o,offsetUser:u,limit:l,isRequested:!0});t&&(e=(0,a.Rd)(),(0,a.R3)((0,i.a4)(e,s,{joinRequests:t})))})()})),(0,a.Q6)("hideChatJoinRequest",((e,t,n)=>{const{chatId:s,userId:o,isApproved:c}=n,l=(0,r.Z1)(e,s),d=(0,r.dy)(e,o);l&&d&&(async()=>{var t;if(!await(0,P.t9)("hideChatJoinRequest",{peer:l,user:d,isApproved:c}))return;e=(0,a.Rd)();const n=(0,r.Z1)(e,s);n&&(0,a.R3)((0,i.a4)(e,s,{joinRequests:null===(t=n.joinRequests)||void 0===t?void 0:t.filter((e=>e.userId!==o))}))})()})),(0,a.Q6)("hideAllChatJoinRequests",((e,t,n)=>{const{chatId:s,isApproved:o,link:c}=n,l=(0,r.Z1)(e,s);l&&(async()=>{if(!await(0,P.t9)("hideAllChatJoinRequests",{peer:l,isApproved:o,link:c}))return;e=(0,a.Rd)();const t=(0,r.Z1)(e,s);t&&(0,a.R3)((0,i.a4)(e,s,{joinRequests:[],fullInfo:{...t.fullInfo,recentRequesterIds:[],requestsPending:0}}))})()})),(0,a.Q6)("sync",((e,t)=>{!async function(e){s.eM&&console.log(">>> START SYNC"),L&&clearTimeout(L),(0,a.R3)({...(0,a.Rd)(),isSyncing:!0}),L=window.setTimeout((()=>{(0,a.R3)({...(0,a.Rd)(),isSyncing:!1}),L=void 0}),15e3),await(0,P.t9)("fetchCurrentUser");const t=await async function(){var e;let t=(0,a.Rd)();const n=await(0,P.t9)("fetchChats",{limit:s.Ov,withPinned:!0,serverTimeOffset:t.serverTimeOffset,lastLocalServiceMessage:null===(e=(0,r.VF)(t))||void 0===e?void 0:e.message});if(!n)return;t=(0,a.Rd)();const{recentlyFoundChatIds:o}=t.globalSearch,{userIds:c}=t.contactList||{},{currentUserId:d}=t,m=[...o||[],...c||[],...d?[d]:[]],h=m.map((e=>(0,r.dy)(t,e))).filter(Boolean),f=m.map((e=>(0,r.Z1)(t,e))).filter(Boolean),{chatId:p}=(0,r.Bt)(t)||{};if(p){const e=(0,r.Z1)(t,p);if(e&&!m.includes(p)&&f.push(e),(0,l.YC)(p)){const e=(0,r.dy)(t,p);e&&!m.includes(p)&&h.push(e)}}return h.push(...n.users),f.push(...n.chats),t=(0,i.ps)(t,n.userStatusesById),t=(0,i.SL)(t,(0,g.ee)(f,"id")),t=(0,i.Mg)(t,"active",n.chatIds),t=(0,i.vv)(t,"active",n),Object.keys(n.draftsById).forEach((e=>{t=(0,i.pf)(t,e,u._f,"draft",n.draftsById[e])})),Object.keys(n.replyingToById).forEach((e=>{t=(0,i.pf)(t,e,u._f,"replyingToId",n.replyingToById[e])})),(0,a.R3)(t),p&&!t.chats.byId[p]&&(0,a.uC)().openChat({id:void 0}),h}();await async function(e){let t=!1,n=e||[],o=(0,a.Rd)();const{chatId:c,threadId:l}=(0,r.Bt)(o)||{},d=Object.keys(o.messages.byChatId).reduce(((e,t)=>{const n=(0,r.Ms)(o,t,u._f);return n&&(e[t]=n),e}),{});if(c){const e=await F(o.chats.byId[c]);o=(0,a.Rd)();const{chatId:d}=(0,r.Bt)(o)||{},m=l&&(0,r.tZ)(o,c,l);if(e&&d===c){const a=o.messages.byChatId[c],r=c===s.aw?o.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],d=[].concat(e.messages,r),h=(0,g.ee)(d,"id"),f=Object.keys(h).map(Number);if(o={...o,messages:{...o.messages,byChatId:{}}},o=(0,i.c_)(o,c,h),o=(0,i.xj)(o,c,u._f,f),o=(0,i.y9)(o,c,u._f,f),l&&m&&m.originChannelId){const{originChannelId:e}=m,t=o.messages.byChatId[e],n=await F(o.chats.byId[e]);if(n){const e=(0,g.ee)(n.messages,"id"),s=Object.keys(e).map(Number);o={...o,messages:{...o.messages,byChatId:{...o.messages.byChatId,[m.originChannelId]:{byId:e,threadsById:{[u._f]:{...null==t?void 0:t.threadsById[u._f],listedIds:s,viewportIds:s,outlyingIds:void 0}}},[c]:{...o.messages.byChatId[c],threadsById:{...o.messages.byChatId[c].threadsById,[l]:{...null==a?void 0:a.threadsById[l],outlyingIds:void 0}}}}}}}}o=(0,i.GL)(o,(0,g.ee)(e.chats,"id")),o=(0,i.j6)(o,c,e.threadInfos),t=!0,n=Array.prototype.concat(n,e.users)}}t||(o={...o,messages:{...o.messages,byChatId:{}}}),Object.keys(d).forEach((e=>{o=(0,i.pf)(o,e,u._f,"draft",d[e])})),e?o=(0,i.s5)(o,(0,g.ee)(n,"id")):n&&(o=(0,i.eD)(o,(0,g.ee)(n,"id"))),(0,a.R3)(o);const{chatId:m,messageId:h}=o.audioPlayer;m&&h&&!(0,r.hj)(o,m,h)&&(0,a.uC)().closeAudioPlayer()}(t),(0,a.R3)({...(0,a.Rd)(),lastSyncTime:Date.now(),isSyncing:!1}),s.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,a.Q6)("afterSync",(()=>{!async function(){s.eM&&console.log(">>> START AFTER-SYNC"),await Promise.all([U(),O()]),await(0,P.t9)("fetchCurrentUser"),s.eM&&console.log(">>> FINISH AFTER-SYNC")}()}));const $=(0,C.Ds)((e=>e()),500,!1,!0),D=(0,C.P2)((e=>e()),500,!1);function q(e,t,n){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:n}}}}function j(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,a.Q6)("loadFullUser",((e,t,n)=>{const{userId:a}=n,s=(0,r.dy)(e,a);if(!s)return;const{id:o,accessHash:i}=s;$((()=>(0,P.t9)("fetchFullUser",{id:o,accessHash:i})))})),(0,a.Q6)("loadUser",((e,t,n)=>{const{userId:s}=n,o=(0,r.dy)(e,s);o&&(async()=>{const t=await(0,P.t9)("fetchUsers",{users:[o]});if(!t)return;const{users:n,userStatusesById:s}=t;e=(0,a.Rd)(),e=(0,i.eD)(e,(0,g.ee)(n,"id")),(0,a.R3)((0,i.ps)(e,{...e.users.statusesById,...s})),(0,a.R3)(e)})()})),(0,a.Q6)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,f.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,P.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:n}=e;let s=(0,a.Rd)();s=(0,i.Sh)(s,(0,g.ee)(n,"id")),s={...s,topPeers:{...s.topPeers,userIds:t,lastRequestedAt:(0,f.b)(s.serverTimeOffset)}},(0,a.R3)(s)}()})),(0,a.Q6)("loadContactList",(()=>{!async function(){const e=await(0,P.t9)("fetchContactList");if(!e)return;let t=(0,i.Sh)((0,a.Rd)(),(0,g.ee)(e.users,"id"));t=(0,i.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.Q6)("loadCurrentUser",(()=>{(0,P.t9)("fetchCurrentUser")})),(0,a.Q6)("loadCommonChats",(e=>{var t;const{chatId:n}=(0,r.Bt)(e)||{},s=n?(0,r.dy)(e,n):void 0;!s||(0,l.cS)(s)||null!==(t=s.commonChats)&&void 0!==t&&t.isFullyLoaded||(async()=>{var t,n;const o=null===(t=s.commonChats)||void 0===t?void 0:t.maxId,r=await(0,P.t9)("fetchCommonChats",s.id,s.accessHash,o);if(!r)return;const{chats:c,chatIds:l,isFullyLoaded:d}=r;e=(0,a.Rd)(),c.length&&(e=(0,i.fZ)(e,(0,g.ee)(c,"id"))),e=(0,i.Nq)(e,s.id,{commonChats:{maxId:l.length?l[l.length-1]:"0",ids:(0,g.Tw)(((null===(n=s.commonChats)||void 0===n?void 0:n.ids)||[]).concat(l)),isFullyLoaded:d}}),(0,a.R3)(e)})()})),(0,a.Q6)("updateContact",((e,t,n)=>{const{userId:s,isMuted:o,firstName:c,lastName:l}=n;!async function(e,t,n,s){const o=(0,a.Rd)(),c=(0,r.dy)(o,e);if(!c)return;let l;if((0,a.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,a.R3)((0,i.H9)((0,a.Rd)(),m.wv.InProgress)),c.phoneNumber)l=await(0,P.t9)("updateContact",{phone:c.phoneNumber,firstName:n,lastName:s});else{const{id:e,accessHash:t}=c;l=await(0,P.t9)("addContact",{id:e,accessHash:t,phoneNumber:"",firstName:n,lastName:s})}l&&(0,a.R3)((0,i.Nq)((0,a.Rd)(),c.id,{firstName:n,lastName:s})),(0,a.R3)((0,i.H9)((0,a.Rd)(),m.wv.Complete))}(s,o,c,l)})),(0,a.Q6)("deleteContact",((e,t,n)=>{const{userId:s}=n;!async function(e){const t=(0,a.Rd)(),n=(0,r.dy)(t,e);if(!n)return;const{id:s,accessHash:o}=n;await(0,P.t9)("deleteContact",{id:s,accessHash:o})}(s)})),(0,a.Q6)("loadProfilePhotos",((e,t,n)=>{const{profileId:s}=n,o=(0,l.YC)(s),c=o?(0,r.dy)(e,s):void 0,d=o?void 0:(0,r.Z1)(e,s);(c||d)&&(async()=>{const e=await(0,P.t9)("fetchProfilePhotos",c,d);if(!e||!e.photos)return;let t=(0,a.Rd)();o?t=(0,i.Nq)(t,s,{photos:e.photos}):(t=(0,i.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,i.a4)(t,s,{photos:e.photos})),(0,a.R3)(t)})()})),(0,a.Q6)("setUserSearchQuery",((e,t,n)=>{const{query:s}=n;s&&D((()=>{!async function(e){const t=await(0,P.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,i.Q3)(n,!1));const{localUsers:o,globalUsers:r}=t;let c,l;o.length&&(n=(0,i.Sh)(n,(0,g.ee)(o,"id")),c=o.map((e=>{let{id:t}=e;return t}))),r.length&&(n=(0,i.Sh)(n,(0,g.ee)(r,"id")),l=r.map((e=>{let{id:t}=e;return t}))),n=(0,i.Q3)(n,!1),n=(0,i.Lm)(n,{localUserIds:c,globalUserIds:l}),(0,a.R3)(n)}(s)}))})),(0,a.Q6)("addContact",((e,t,n)=>{const{userId:a}=n,s=(0,r.dy)(e,a);s&&(0,P.t9)("addContact",(0,g.ei)(s,["id","accessHash","firstName","lastName","phoneNumber"]))}));const Q=(0,C.Ds)((e=>e()),500,!1);async function G(e,t,n,a,s){await(0,P.t9)("sendMessage",{chat:e,text:n,replyingTo:a,sendAs:s})}(0,a.Q6)("clickInlineButton",((e,t,n)=>{const{button:o}=n;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(s.FS)||o.value.match(s.g$)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,r.jr)(e);if(!t)return;!async function(e,t,n){const s=await(0,P.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:n});if(!s)return;const{showDialog:o,showNotification:i,toggleSafeLinkModal:r}=(0,a.uC)(),{message:c,alert:l,url:d}=s;l?o({data:{message:c||"Error"}}):c?i({message:c}):d&&r({url:d})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"requestSelfContact":{const n=e.currentUserId?(0,r.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"buy":{const n=(0,r.jr)(e),{messageId:a,value:s}=o;if(!n)return;s?t.getReceipt({receiptMessageId:s,chatId:n.id,messageId:a}):(t.getPaymentForm({chat:n,messageId:a}),t.setInvoiceMessageInfo((0,r.hj)(e,n.id,a)),t.openPaymentModal({chatId:n.id,messageId:a}));break}}})),(0,a.Q6)("sendBotCommand",((e,t,n)=>{const{command:a,chatId:s}=n,{currentUserId:o}=e,i=s?(0,r.Z1)(e,s):(0,r.jr)(e),c=(0,r.Bt)(e);if(!o||!i||!c)return;const{threadId:l}=c;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i.id,threadId:l,value:!1}),G(i,0,a,(0,r.Yy)(e,i.id,l),(0,r._5)(e,s))})),(0,a.Q6)("restartBot",((e,t,n)=>{const{chatId:s}=n,{currentUserId:o}=e,c=(0,r.jr)(e),l=o&&(0,r.IK)(e,s);o&&c&&l&&(async()=>{await(0,P.t9)("unblockContact",l.id,l.accessHash)&&((0,a.R3)((0,i.rB)((0,a.Rd)(),l.id)),G(c,0,"/start",void 0,(0,r._5)(e,s)))})()})),(0,a.Q6)("loadTopInlineBots",(e=>{const{lastRequestedAt:t}=e.topInlineBots;t&&(0,f.b)(e.serverTimeOffset)-t<60||(async()=>{const t=await(0,P.t9)("fetchTopInlineBots");if(!t)return;const{ids:n,users:s}=t;let o=(0,a.Rd)();o=(0,i.Sh)(o,(0,g.ee)(s,"id")),o={...o,topInlineBots:{...o.topInlineBots,userIds:n,lastRequestedAt:(0,f.b)(e.serverTimeOffset)}},(0,a.R3)(o)})()})),(0,a.Q6)("queryInlineBot",((e,t,n)=>{const{chatId:s,username:o,query:c,offset:l}=n;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:n,chat:s}=await(0,P.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!n||!s)return void(0,a.R3)(q(e,o,!1));e=(0,i.Sh)(e,{[n.id]:n}),e=(0,i.fZ)(e,{[s.id]:s}),t={id:n.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=q(e,o,t),(0,a.R3)(e)}(c!==t.query||t.canLoadMore)&&Q((()=>{!async function(e){let{username:t,inlineBotData:n,chatId:s,query:o,offset:i}=e,c=(0,a.Rd)();const l=(0,r.dy)(c,n.id),d=(0,r.Z1)(c,s);if(!l||!d)return;const u=n.query!==o;c=j(c,!0),c=q(c,t,{...n,query:o,...u&&{offset:void 0,results:[]}}),(0,a.R3)(c);const m=await(0,P.t9)("fetchInlineBotResults",{bot:l,chat:d,query:o,offset:u?void 0:i}),h=c.inlineBots.byUsername[t];if(c=j((0,a.Rd)(),!1),!m||!h||o!==h.query)return void(0,a.R3)(c);const g=new Set((h.results||[]).map((e=>e.id))),f=m.results.filter((e=>!g.has(e.id)));c=q(c,t,{...h,help:m.help,...f.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(f),offset:f.length?m.nextOffset:""}),(0,a.R3)(c)}({username:o,inlineBotData:t,chatId:s,query:c,offset:l})}))}})()})),(0,a.Q6)("sendInlineBotResult",((e,t,n)=>{const{id:a,queryId:s}=n,o=(0,r.Bt)(e);if(!o||!a)return;const{chatId:i,threadId:c}=o,l=(0,r.Z1)(e,i);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i,threadId:c,value:!1}),(0,P.t9)("sendInlineBotResult",{chat:l,resultId:a,queryId:s,replyingTo:(0,r.Yy)(e,i,c),sendAs:(0,r._5)(e,i)})})),(0,a.Q6)("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)(q(e,s,o)))})),(0,a.Q6)("startBot",((e,t,n)=>{const{botId:a,param:s}=n,o=(0,r.dy)(e,a);o&&(async()=>{await(0,P.t9)("startBot",{bot:o,startParam:s})})()})),n(9667),(0,a.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,P.t9)("getPasswordInfo");if(!e)return;let t=(0,a.Rd)();t=(0,i.BI)(t,{hasPassword:e.hasPassword}),t=(0,i.IE)(t,{hint:e.hint}),(0,a.R3)(t)})()})),(0,a.Q6)("checkPassword",((e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("checkPassword",s);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("clearPassword",((e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("clearPassword",s);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("updatePassword",((e,t,n)=>{const{currentPassword:s,password:o,hint:r,email:c,onSuccess:l}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("updatePassword",s,o,r,c);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1})),e&&l()})()})),(0,a.Q6)("updateRecoveryEmail",((e,t,n)=>{const{currentPassword:s,email:o,onSuccess:r}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("updateRecoveryEmail",s,o);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&r()})()})),(0,a.Q6)("provideTwoFaEmailCode",((e,t,n)=>{const{code:a}=n;(0,P.t9)("provideRecoveryEmailCode",a)})),(0,a.Q6)("clearTwoFaError",(e=>(0,i.IE)(e,{error:void 0}))),(0,a.Q6)("validateRequestedInfo",((e,t,n)=>{const{requestInfo:s,saveInfo:o}=n,c=(0,r.gx)(e),l=c&&(0,r.Z1)(e,c),d=(0,r.Mz)(e);l&&d&&async function(e,t,n,s){const o=await(0,P.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:n,shouldSave:s});if(!o)return;const{id:r,shippingOptions:c}=o;if(!r)return;let l=(0,i.vT)((0,a.Rd)(),r);c?(l=(0,i.TM)(l,c),l=(0,i.Q$)(l,m.KB.Shipping)):l=(0,i.Q$)(l,m.KB.PaymentInfo),(0,a.R3)(l)}(l,d,s,o)})),(0,a.Q6)("getPaymentForm",((e,t,n)=>{const{chat:s,messageId:o}=n;s&&o&&async function(e,t){const n=await(0,P.t9)("getPaymentForm",{chat:e,messageId:t});if(!n)return;let s=(0,i._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,i.Q$)(s,o),(0,a.R3)(s)}(s,o)})),(0,a.Q6)("getReceipt",((e,t,n)=>{const{receiptMessageId:s,chatId:o,messageId:c}=n,l=o&&(0,r.Z1)(e,o);c&&s&&l&&async function(e,t,n){const s=await(0,P.t9)("getReceipt",e,n);if(!s)return;let o=(0,a.Rd)();const c=(0,r.hj)(o,e.id,t);o=(0,i.Dq)(o,s,c),(0,a.R3)(o)}(l,c,s)})),(0,a.Q6)("clearPaymentError",(e=>{(0,a.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,a.Q6)("clearReceipt",(e=>{(0,a.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,a.Q6)("sendCredentialsInfo",((e,t,n)=>{const s=(0,r.$$)(e);if(!s)return;const{credentials:o}=n,{data:c}=o;!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,l.Ow)(o.error),t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let r=(0,i.QH)((0,a.Rd)(),{type:o.type,id:o.id});r=(0,i.Q$)(r,m.KB.Checkout),(0,a.R3)(r)}(c,s)})),(0,a.Q6)("sendPaymentForm",((e,t,n)=>{const{shippingOptionId:s,saveCredentials:o}=n,c=(0,r.gx)(e),l=c&&(0,r.Z1)(e,c),d=(0,r.Mz)(e),u=(0,r.eh)(e),m=(0,r.sp)(e),h=(0,r.$$)(e),g=(0,r.i3)(e);l&&d&&h&&u&&async function(e,t,n,s,o,r){if(await(0,P.t9)("sendPaymentForm",{chat:e,messageId:t,formId:n,credentials:s,requestedInfoId:o,shippingOptionId:r})){const e=(0,i.bp)((0,a.Rd)());(0,a.R3)((0,i.WY)(e))}}(l,d,u,{save:o,data:g},m,s)})),(0,a.Q6)("setPaymentStep",(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,i.Q$)(e,n.step||m.KB.ShippingInfo)})),(0,a.Q6)("setInvoiceMessageInfo",((e,t,n)=>(0,i.nA)(e,n)));var H=n(647),_=n(3495);const z=728,V=424,X=288;var Y=n(3858);function W(e,t){return t-(e.isLeftColumnShown&&!h.wB?e.leftColumnWidth||((n=Y.Z.get().width)>s._m?Math.min(Math.max(.25*n,X),.33*n):n>s.ks?Math.min(Math.max(.33*n,X),.4*n):V):0);var n}(0,a.Q6)("loadAvailableReactions",(()=>{(async()=>{const e=await(0,P.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&H.he(`sticker${e.aroundAnimation.id}`,u.IU.Lottie),e.centerIcon&&H.he(`sticker${e.centerIcon.id}`,u.IU.Lottie)})),(0,a.R3)({...(0,a.Rd)(),availableReactions:e}))})()})),(0,a.Q6)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:a,x:s,y:o,localEffect:i,startSize:r,isReversed:c}=n;return{...e,activeEmojiInteraction:{animatedEffect:a||i,x:W(e,s),y:o,startSize:r,isReversed:c}}})),(0,a.Q6)("sendEmojiInteraction",((e,t,n)=>{const{messageId:a,chatId:s,emoji:o,interactions:i,localEffect:c,x:l,y:d,startX:u,startY:m,startSize:h}=n,g=(0,r.Z1)(e,s);if(g&&(o||c)&&s!==e.currentUserId&&((0,P.t9)("sendEmojiInteraction",{chat:g,messageId:a,emoticon:o||(0,r.ji)(c),timestamps:i}),e.activeEmojiInteraction))return{...e,activeEmojiInteraction:{...e.activeEmojiInteraction,endX:W(e,l),endY:d,...u&&{x:W(e,u)},...m&&{y:m},...h&&{startSize:h}}}})),(0,a.Q6)("sendDefaultReaction",((e,t,n)=>{const{chatId:a,messageId:s,x:o,y:i}=n,c=(0,r.q6)(e,a);c&&t.sendReaction({chatId:a,messageId:s,reaction:c,x:o,y:i})})),(0,a.Q6)("sendReaction",((e,t,n)=>{var a,o;const{chatId:i,messageId:c}=n;let{reaction:l}=n;const d=(0,r.Z1)(e,i),u=(0,r.hj)(e,i,c);if(!d||!u)return;null!==(a=u.reactions)&&void 0!==a&&null!==(o=a.results)&&void 0!==o&&o.some((e=>e.reaction===l&&e.isChosen))&&(l=void 0),(0,P.t9)("sendReaction",{chat:d,messageId:c,reaction:l});const{animationLevel:m}=e.settings.byKey;return m===s.zy&&(e={...e,activeReactions:{...l?e.activeReactions:(0,g.CE)(e.activeReactions,[c]),...l&&{[c]:{reaction:l,messageId:c}}}}),function(e,t,n,a){const{reactions:s}=(0,r.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,_.cY)(e,t,n,{reactions:{...s,results:o,recentReactions:i}})}(e,i,c,l)})),(0,a.Q6)("openChat",(e=>({...e,activeReactions:{}}))),(0,a.Q6)("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.Q6)("setDefaultReaction",((e,t,n)=>{const{reaction:s}=n;(async()=>{await(0,P.t9)("setDefaultReaction",{reaction:s})&&(e=(0,a.Rd)(),(0,a.R3)({...e,appConfig:{...e.appConfig,defaultReaction:s}}))})()})),(0,a.Q6)("stopActiveEmojiInteraction",(e=>({...e,activeEmojiInteraction:void 0}))),(0,a.Q6)("loadReactors",((e,t,n)=>{var s;const{chatId:o,messageId:c,reaction:l}=n,d=(0,r.Z1)(e,o),u=(0,r.hj)(e,o,c);if(!d||!u)return;const m=null===(s=u.reactors)||void 0===s?void 0:s.nextOffset;(async()=>{var t,n;const s=await(0,P.t9)("fetchMessageReactionsList",{reaction:l,chat:d,messageId:c,offset:m});if(!s)return;e=(0,a.Rd)(),null!==(t=s.users)&&void 0!==t&&t.length&&(e=(0,i.Sh)(e,(0,g.ee)(s.users,"id")));const{nextOffset:r,count:h,reactions:f}=s;(0,a.R3)((0,i.cY)(e,o,c,{reactors:{nextOffset:r,count:h,reactions:[...(null===(n=u.reactors)||void 0===n?void 0:n.reactions)||[],...f]}}))})()})),(0,a.Q6)("loadMessageReactions",((e,t,n)=>{const{ids:a,chatId:s}=n,o=(0,r.Z1)(e,s);o&&(0,P.t9)("fetchMessageReactions",{ids:a,chat:o})})),(0,a.Q6)("sendWatchingEmojiInteraction",((e,t,n)=>{const{chatId:a,emoticon:s,x:o,y:i,startSize:c,isReversed:l}=n,d=(0,r.Z1)(e,a);if(d&&e.activeEmojiInteraction&&a!==e.currentUserId)return(0,P.t9)("sendWatchingEmojiInteraction",{chat:d,emoticon:s}),{...e,activeEmojiInteraction:{...e.activeEmojiInteraction,x:W(e,o),y:i,startSize:c,isReversed:l}}})),n(4907);var K=n(8406);function J(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)=>J(e,a[t])))}const s=e,o=t;return Object.keys(s).every((e=>J(s[e],o[e])))}(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":{n.noTopChatsRequest||(0,r.N)(e,n.id)||t.loadTopChats();const s=(0,i.a4)(e,n.id,n.chat,n.newProfilePhoto);(0,a.R3)(s),n.chat.id&&(0,K.Vr)({chatId:n.chat.id,lastReadInboxMessageId:n.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const s=(0,r.Ek)(e,n.id);if(!s)break;e=(0,i.B1)(e,s,[n.id]),e=(0,i.a4)(e,n.id,{isNotJoined:!1}),(0,a.R3)(e);const o=(0,r.Z1)(e,n.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":(0,a.R3)((0,i.Dd)(e,n.id));break;case"updateChatInbox":(0,a.R3)((0,i.a4)(e,n.id,n.chat));break;case"updateChatTypingStatus":{const{id:t,typingStatus:s}=n;(0,a.R3)((0,i.a4)(e,t,{typingStatus:s})),setTimeout((()=>{const e=(0,a.Rd)(),n=(0,r.Z1)(e,t);n&&s&&n.typingStatus&&n.typingStatus.timestamp===s.timestamp&&(0,a.R3)((0,i.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:s}=n,{chatId:o,threadId:c,type:l}=(0,r.Bt)(e)||{};if(s.senderId===e.currentUserId&&!s.isFromScheduled)return;const d=(0,r.Z1)(e,n.chatId);if(!d)return;"thread"===l&&c===u._f&&n.chatId===o?setTimeout((()=>{t.requestChatUpdate({chatId:n.chatId})}),1500):(0,a.R3)((0,i.a4)(e,n.chatId,{unreadCount:d.unreadCount?d.unreadCount+1:1,...n.message.hasUnreadMention&&{unreadMentionsCount:d.unreadMentionsCount?d.unreadMentionsCount+1:1}})),(0,K.zP)({chat:d,message:s});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:s}=n;if(!1!==s.hasUnreadMention)return;t.forEach((t=>{const a="channelId"in n?n.channelId:(0,r.X5)(e,t),s=(0,r.Z1)(e,a);null!=s&&s.unreadMentionsCount&&(e=(0,i.a4)(e,a,{unreadMentionsCount:s.unreadMentionsCount-1}))})),(0,a.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=n,s=e.chats.byId[n.id];if(!s)return;(0,a.R3)((0,i.a4)(e,n.id,{fullInfo:{...s.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=n,i=o===s.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:t.length?t:void 0}}},(0,a.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=n,i=(0,r.Ek)(e,t);if(i){const{[i]:n}=e.chats.orderedPinnedIds;let a=n||[];if(o){if(!a.includes(t)){if("active"===i&&a.length>=s.EG){const t=e.chats.listIds.active;a=a.filter((e=>t&&t.includes(e)))}a=[t,...a]}}else a=a.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:a.length?a:void 0}}}}(0,a.R3)(e);break}case"updateChatListType":{const{id:t,folderId:s}=n;(0,a.R3)((0,i.Pi)(e,t,s));break}case"updateChatFolder":{const{id:t,folder:s}=n,{byId:o,orderedIds:i}=e.chatFolders,r=s?{...o,[t]:s}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=s?i&&i.includes(t)?i:[...i||[],t]:i?i.filter((e=>e!==t)):void 0;(0,a.R3)({...e,chatFolders:{...e.chatFolders,byId:r,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=n;(0,a.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=n;(0,a.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[n.id],{replacedMembers:s,addedMember:r,deletedMemberId:c}=n;if(!t)return;let l=!1,d=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(s)d=s,l=!0;else if(r)d.length&&d.some((e=>e.userId===r.userId))||(d.push(r),l=!0);else if(d.length&&c){const e=d.findIndex((e=>e.userId===c));e>-1&&(d.slice(e,1),l=!0)}if(l){const s=d.filter((e=>{let{isOwner:t,isAdmin:n}=e;return t||n}));(0,a.R3)((0,i.a4)(e,n.id,{membersCount:d.length,fullInfo:{...t.fullInfo,members:d,adminMembers:s}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:s}=n,o=e.chats.byId[t];null!=o&&o.photos&&(0,a.R3)((0,i.a4)(e,t,{photos:o.photos.filter((e=>!s.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:s,date:o,replyingToId:r}=n;e.chats.byId[t]&&(e=(0,i.pf)(e,t,u._f,"draft",s),e=(0,i.pf)(e,t,u._f,"replyingToId",r),e=(0,i.a4)(e,t,{draftDate:o}),(0,a.R3)(e));break}case"showInvite":{const{data:e}=n;t.showDialog({data:e});break}case"updatePendingJoinRequests":{const{chatId:s,requestsPending:o,recentRequesterIds:r}=n,c=e.chats.byId[s];c&&(e=(0,i.a4)(e,s,{fullInfo:{...c.fullInfo,requestsPending:o,recentRequesterIds:r}}),(0,a.R3)(e),t.loadChatJoinRequests({chatId:s}))}}}));const ee=350;function te(e,t,n,a){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=s?(0,r.Tm)(e,t,n):(0,r.hj)(e,t,n);if(o&&a.content){const{photo:e,video:t,sticker:n,document:s}=(0,l.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,i.P4)(e,t,n,a):(0,i.cY)(e,t,n,a)}function ne(e,t,n,a){const{chatId:s}=n,{threadInfo:o}=(0,r.Db)(e,s,n)||{};if(!o&&n.replyToMessageId){const o=(0,r.hj)(e,s,n.replyToMessageId);o?e=(0,i.lG)(e,o,s,n.id,a):t.loadMessage({chatId:s,messageId:n.replyToMessageId,threadUpdate:{isDeleting:a,lastMessageId:n.id}})}return e}function ae(e,t,n){const{id:a,chatId:s}=n,{threadInfo:o,firstMessageId:c}=(0,r.Db)(e,s,n)||{},d=(0,r.Z1)(e,s),m=(null==d?void 0:d.unreadCount)&&!(0,r.gb)(e,s,u._f);if(e=ne(e,t,n),o&&(!c&&(0,l.CI)(n)||(e=(0,i.xj)(e,s,o.threadId,[a]),(0,r.b9)(e,s,o.threadId)&&(e=(0,i.$S)(e,s,o.threadId,a),c||(e=(0,i.pf)(e,s,o.threadId,"firstMessageId",n.id)))),e=(0,i.pf)(e,s,o.threadId,"threadInfo",{...o,lastMessageId:n.id,messagesCount:o.messagesCount+1})),m)return e;if(e=(0,i.xj)(e,s,u._f,[a]),(0,r.b9)(e,s,u._f)){const t=(0,r.It)(e,s,u._f),n=(0,i.$S)(e,s,u._f,a),o=(0,r.Cb)(n,s,u._f);t&&!o.includes(t)||(e=n)}return e}function se(e,t,n){var a;let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:o}=e,r=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!r||s||r.id===n.id||r.id===n.previousLocalId||n.id>r.id?(0,i.a4)(e,t,{lastMessage:n}):e}function oe(e,t){const n=(0,r.Zw)(e,t),a=(0,r.gb)(e,t,u._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=oe(s=(0,i.cY)(s,e,t,{isDeleting:!0}),e);n&&(s=se(s,e,n,!0))})),(0,a.R3)(s),n.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const a=(0,r.hj)(s,e,t);if(!a)return;s=ne(s,n,a,!0);const{threadInfo:i}=(0,r.Db)(s,e,a)||{};i&&o.push(i.threadId)})),(0,a.R3)(s),void setTimeout((()=>{(0,a.R3)((0,i.K4)((0,a.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{n.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),ee)}const o=[];t.forEach((e=>{const t=(0,r.X5)(s,e);if(t){o.push(t);const n=oe(s=(0,i.cY)(s,t,e,{isDeleting:!0}),t);n&&(s=se(s,t,n,!0)),setTimeout((()=>{(0,a.R3)((0,i.K4)((0,a.Rd)(),t,[e]))}),ee)}})),(0,a.R3)(s),(0,g.Tw)(o).forEach((e=>{n.requestChatUpdate({chatId:e})}))}(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"newMessage":{const{chatId:o,id:c,message:d,shouldForceReply:m}=n;e=ae(e=te(e,o,c,d),t,d),d.threadInfo&&(e=(0,i.Xg)(e,d.threadInfo.chatId,d.threadInfo.threadId,d.threadInfo)),(0,a.R3)(e);const h=(0,r.hj)(e,o,c);if((0,r.hg)(e,o,d)){var s;if(d.isOutgoing&&(null===(s=d.content)||void 0===s||!s.action)){const n=(0,r.Bt)(e);n&&t.focusMessage({chatId:o,threadId:n.threadId,messageId:d.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:n}=(0,r.Db)(e,o,d)||{};n&&t.requestThreadInfoUpdate({chatId:o,threadId:n.threadId}),(0,l.CI)(d)||setTimeout((()=>{let e=(0,a.Rd)();m&&(e=(0,i.pf)(e,o,u._f,"replyingToId",c)),(0,a.R3)(se(e,o,h))}),ee)}else(0,a.R3)(se((0,a.Rd)(),o,h));(0,r.N)(e,o)||t.loadTopChats();break}case"updateStartEmojiInteraction":{const{chatId:t}=(0,r.Bt)(e)||{};if(e.activeEmojiInteraction||t!==n.id)return;const s=(0,r.CP)(e,n.emoji);e={...e,activeEmojiInteraction:{animatedEffect:s?(0,r.cu)(s):n.emoji,messageId:n.messageId}},(0,a.R3)(e);break}case"newScheduledMessage":{const{chatId:t,id:s,message:o}=n;e=te(e,t,s,o,!0);const c=(0,r.qy)(e,t)||[];e=(0,i.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,s])),(0,a.R3)(e);break}case"updateMessage":{var o,c;const{chatId:s,id:l,message:d}=n;if(!(0,r.hj)(e,s,l))return;e=te(e,s,l,d);const m=(0,r.hj)(e,s,l);d.threadInfo&&(e=(0,i.Xg)(e,d.threadInfo.chatId,d.threadInfo.threadId,d.threadInfo)),e=se(e,s,m),(0,a.R3)(e);const h=(0,r.Z1)(e,s);h&&!d.isOutgoing&&(null===(o=h.lastMessage)||void 0===o?void 0:o.id)===d.id&&(0,r.xo)(e,h)&&(0,r.hg)(e,s,d)&&(0,r.b9)(e,s,(null===(c=d.threadInfo)||void 0===c?void 0:c.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:s,message:o}=n;if(!(0,r.Tm)(e,t,s))return;e=te(e,t,s,o,!0);const c=Object.keys((0,r.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,i.pf)(e,t,u._f,"scheduledIds",c),(0,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:s,localId:o,message:c}=n;e=ae(e,t,c);const l=(0,r.hj)(e,s,o);e=(0,i.K4)(e,s,[o]),c.isScheduled&&(e=(0,i.bV)(e,s,[o])),e=(0,i.cY)(e,s,c.id,{...l,...c,previousLocalId:o});const d=(0,r.hj)(e,s,c.id);e=se(e,s,d);const u=(0,r.Db)(e,s,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,i.pf)(e,s,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:s,message:o}=n,c=(0,r.qy)(e,t)||[];e=(0,i.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const l=(0,r.Tm)(e,t,s);e=(0,i.bV)(e,t,[s]),e=(0,i.P4)(e,t,o.id,{...l,...o,previousLocalId:s}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:s,messageIds:o}=n,c=(0,r.KB)(e,t)||[],l=s?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,a.R3)((0,i.pf)(e,t,u._f,"pinnedIds",l));break}case"updateThreadInfo":{const{chatId:t,threadId:s,threadInfo:o,firstMessageId:c}=n,l={...(0,r.tZ)(e,t,s),...o};if(!l.threadId)return;e=(0,i.Xg)(e,t,s,l),c&&(e=(0,i.pf)(e,t,s,"firstMessageId",c)),(0,a.R3)(e);break}case"resetMessages":{const{id:s}=n,o=(0,r.Zw)(e,s);o&&!(0,l.YC)(s)&&(e=(0,i.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,i.P4)(s,e,t,{isDeleting:!0})})),(0,a.R3)(s),setTimeout((()=>{s=(0,i.bV)((0,a.Rd)(),e,t);const n=(0,r.Fn)(s,e);s=(0,i.pf)(s,e,u._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,a.R3)(s)}),ee))}(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,r.X5)(e,t);n&&(e=(0,i.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,i.cY)(e,t,n,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:s}=n,o=(0,r.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,i.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:s,options:o}=n,c=(0,r.ZB)(e,t);if(!c||!c.content.poll||!c.content.poll.results)break;const{poll:l}=c.content,{recentVoterIds:d,totalVoters:u,results:m}=l.results,h=d?[...d]:[],g=u?u+1:1,f=m?[...m]:[];h.push(s),o.forEach((t=>{const n=f.find((e=>e.option===t)),a=f.findIndex((e=>e.option===t)),o=n?{...n}:{option:t,votersCount:0};o.votersCount+=1,s===e.currentUserId&&(o.isChosen=!0),a?f[a]=o:f.push(o)})),(0,a.R3)((0,i.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...l,results:{...l.results,recentVoterIds:h,totalVoters:g,results:f}}}}));break}case"updateServiceNotification":{const{message:a}=n;(0,r.UW)(e)&&t.createServiceNotification({message:a});break}case"updateMessageReactions":{const{chatId:t,id:s,reactions:o}=n,c=(0,r.hj)(e,t,s),l=null==c?void 0:c.reactions;if(l&&J(o,l))return;(0,a.R3)((0,i.cY)(e,t,s,{reactions:n.reactions}));break}}}));const re=(0,C.P2)((function(){const e=(0,a.Rd)();(0,a.R3)((0,i.ps)(e,{...e.users.statusesById,...ce})),ce={}}),3e3,!0);let ce={};(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"deleteContact":return(0,i.GK)(e,n.id);case"updateUser":return(0,i.Nq)(e,n.id,n.user);case"updateUserStatus":return a=n.userId,s=n.status,ce[a]=s,void re();case"updateUserFullInfo":{const{id:t,fullInfo:a}=n,s=e.users.byId[t];if(!s)return;return(0,i.Nq)(e,t,{fullInfo:{...s.fullInfo,...a}})}}var a,s})),(0,a.Q6)("apiUpdate",((e,t,n)=>{if("updateStickerSet"===n["@type"])return(0,i.Rg)(e,n.id,n.stickerSet)})),(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updatePeerBlocked":return n.isBlocked?(0,i.O4)((0,a.Rd)(),n.id):(0,i.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}})),(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateNotifySettings":return(0,i.HN)(e,n.peerType,n.isSilent,n.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:s,isSilent:o,shouldShowPreviews:r}=n;e.chats.byId[t]&&(e=(0,i.a4)(e,t,{isMuted:s})),(0,a.R3)((0,i.aK)(e,t,{isMuted:s,isSilent:o,shouldShowPreviews:r}));break}}})),(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:n.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:n.message}}}}));var le=n(4446);(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateGroupCall":return"discarded"===n.call.connectionState?e.groupCalls.activeGroupCallId?void t.leaveGroupCall({shouldRemove:!0}):(0,le.dc)(e,n.call.id):(0,le.AH)(e,n.call.id,(0,g.CE)(n.call,["connectionState"]),void 0,n.call.participantsCount);case"updateGroupCallChatId":{const t=(0,r.Z1)(e,n.chatId);return t&&(e=(0,i.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,le.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,le.AH)(e,t,{nextOffset:o})),e}}}));var de=n(8674),ue=n(6752),me=n(1279),he=n(3551),ge=n(3227),fe=n(6974),pe=n(1212),ve=n(5332);function Ie(e){(0,o.d4)((()=>(0,C.Gq)(e)),[e])}var ye=n(9290);const Ze=document.querySelector('meta[name="viewport"]'),Pe=(null==Ze?void 0:Ze.getAttribute("content"))||"",Ce="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function we(e){e.preventDefault()}var be=n(6590),Ee=n(4851),Se=n(2155),Me=n(5616),Re=n(7358);const ke=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,Me.yi)();const n=(0,fe.xW)();if((0,o.d4)((()=>{t&&(0,Re.w)(n)}),[t,n]),!t&&n)return o.ZP.createElement("div",{className:"unread-count active"},(0,Se.bi)(n))}));var Te=n(3989),Ne=n(7529),Be=n(3455),xe=n(706),Ae=n(2255),Le=n(9107),Oe=n(7370),Ue=n(7926),Fe=n(1622);let $e;function De(e,t,n,a,s){let i,r,c;return i=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?$e.syncing:$e.online:$e.waitingForNetwork,r=i===$e.online?"none":a?"middleHeader":s?"minimized":"overlay",i===$e.waitingForNetwork?c=e("WaitingForNetwork"):i===$e.syncing&&(c=e("Updating")),"middleHeader"===r&&(c=c.toLowerCase().replace(/\.+$/,"")),{connectionStatus:i,connectionStatusPosition:r,connectionStatusText:c}}!function(e){e[e.waitingForNetwork=0]="waitingForNetwork",e[e.syncing=1]="syncing",e[e.online=2]="online"}($e||($e={}));var qe=n(3106),je=n(8964),Qe=n(231),Ge=n(9589),He=n(9187),_e=n(3321),ze=n(126),Ve=n(9204);const Xe=(0,o.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:a}=e;const s=(0,Le.Z)();return o.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:s.isRtl?"rtl":void 0,onClick:a},o.ZP.createElement(Ve.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},o.ZP.createElement(Ae.Z,{activeKey:t,name:"slide-fade"},(()=>n))),o.ZP.createElement(Qe.Z,{round:!0,size:"tiny",color:"translucent-black"},o.ZP.createElement("span",{className:"icon-close"})))})),Ye=[0,1,2],We=(0,o.X$)((0,a.c$)((e=>{const{query:t,fetchingStatus:n,chatId:a,date:s}=e.globalSearch,{currentUserId:o,connectionState:i,isSyncing:c}=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,r.Pu)(e),animationLevel:u,connectionState:i,isSyncing:c,isConnectionStatusMinimized:d,isMessageListOpen:Boolean((0,r.Bt)(e))}}))((e=>{let{content:t,contactsFilter:n,onSearchQuery:i,onSelectSettings:r,onSelectContacts:c,onSelectArchived:d,onReset:u,searchQuery:g,isLoading:f,shouldSkipTransition:p,currentUserId:v,globalSearchChatId:I,searchDate:y,theme:Z,animationLevel:P,chatsById:C,connectionState:w,isSyncing:b,isConnectionStatusMinimized:E,isMessageListOpen:S}=e;const{openChat:M,openTipsChat:R,setGlobalSearchDate:k,setSettingOption:T,setGlobalSearchChatId:B}=(0,a.uC)(),x=(0,Le.Z)(),A=t===m.du.ChatList,L=(0,o.Ye)((()=>y?(0,N.xH)(new Date(1e3*y)):void 0),[y]),O=(0,o.Ye)((()=>A&&C?Object.values(C).reduce(((e,t)=>(0,l.pE)(t)&&t.unreadCount?e+1:e),0):0),[A,C]),{connectionStatus:U,connectionStatusText:F,connectionStatusPosition:$}=De(x,w,b,S,E),D="web.telegram.org"===window.location.hostname,q=(0,o.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return o.ZP.createElement(Qe.Z,{round:!0,ripple:A&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:A?t:()=>u(),ariaLabel:A?x("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,ue.Z)("animated-menu-icon",!A&&"state-back",p&&"no-animation")}))}),[A,x,u,p]),j=(0,o.I4)((()=>{g||i("")}),[g,i]),Q=(0,o.I4)((()=>{T({isConnectionStatusMinimized:!E})}),[E,T]),G=(0,o.I4)((()=>{M({id:v,shouldReplaceHistory:!0})}),[v,M]),H=(0,o.I4)((e=>{e.stopPropagation();const t="light"===Z?"dark":"light";T({theme:t}),T({shouldUseSystemTheme:!1}),(0,Oe.Z)(t,P===s.zy)}),[P,T,Z]),_=(0,o.I4)((e=>{e.stopPropagation();const t=0===P?2:0;Ye.forEach(((e,n)=>{document.body.classList.toggle(`animation-level-${n}`,t===n)})),T({animationLevel:t})}),[P,T]),z=Boolean(I)||t===m.du.GlobalSearch||t===m.du.Contacts,V=t===m.du.Contacts?x("SearchFriends"):x("Search");return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(qe.Z,{trigger:q,footer:`${s.iC} ${s.Ji}`},o.ZP.createElement(je.Z,{icon:"saved-messages",onClick:G},x("SavedMessages")),o.ZP.createElement(je.Z,{icon:"archive",onClick:d},o.ZP.createElement("span",{className:"menu-item-name"},x("ArchivedChats")),O>0&&o.ZP.createElement("div",{className:"archived-badge"},O)),o.ZP.createElement(je.Z,{icon:"user",onClick:c},x("Contacts")),o.ZP.createElement(je.Z,{icon:"settings",onClick:r},x("Settings")),o.ZP.createElement(je.Z,{icon:"darkmode",onClick:H},o.ZP.createElement("span",{className:"menu-item-name"},x("lng_menu_night_mode")),o.ZP.createElement(_e.Z,{id:"darkmode",label:x("dark"===Z?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===Z,noAnimation:!0})),o.ZP.createElement(je.Z,{icon:"animations",onClick:_},o.ZP.createElement("span",{className:"menu-item-name capitalize"},x("Appearance.Animations").toLowerCase()),o.ZP.createElement(_e.Z,{id:"animations",label:"Toggle Animations",checked:P>0})),o.ZP.createElement(je.Z,{icon:"help",onClick:()=>{R({langCode:x.code})}},x("TelegramFeatures")),o.ZP.createElement(je.Z,{icon:"bug",href:s.mU},"Report Bug"),D&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(je.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{(0,Ue.L)("K"),(0,Fe.W8)(),(0,be.Wv)()}},"Switch to K Version"),o.ZP.createElement(je.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:be.Wv},"Switch to Old Version"))),o.ZP.createElement(Ge.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||y?"with-picker-item":"",value:n||g,focused:z,isLoading:f||"minimized"===$,spinnerColor:"minimized"===$?"yellow":void 0,spinnerBackgroundColor:"minimized"===$&&"light"===Z?"light":void 0,placeholder:V,autoComplete:"off",canClose:Boolean(I||y),onChange:i,onReset:u,onFocus:j,onSpinnerClick:"minimized"===$?Q:void 0},L&&o.ZP.createElement(He.Z,{icon:"calendar",title:L,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:k,clickArg:{date:void 0}}),I&&o.ZP.createElement(He.Z,{chatOrUserId:I,onClick:B,canClose:!0,clickArg:{id:void 0}})),o.ZP.createElement(ze.Z,{isOpen:"overlay"===$,isCustom:!0,className:"connection-state-wrapper"},(()=>o.ZP.createElement(Xe,{connectionStatus:U,connectionStatusText:F,onClick:Q})))))})));var Ke=n(1174),Je=n(3133),et=n(1080);const tt=(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:f}=(0,a.uC)(),p=(0,o.sO)(null),v=(0,Le.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,Me.yi)(),Z=(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]),P=(0,o.I4)((e=>{g(e,{forceOnHeavyAnimation:!0})}),[g]);(0,o.d4)((()=>{Z&&Z.length&&c>=Z.length&&g(0)}),[c,Z,g]),(0,o.d4)((()=>{if(p.current&&h.$b&&Z&&Z.length)return(0,Ke.sf)(p.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Ke.eM.Left?(g(Math.min(c+1,Z.length-1),{forceOnHeavyAnimation:!0}),!0):t===Ke.eM.Right&&(g(Math.max(0,c-1),{forceOnHeavyAnimation:!0}),!0)})}),[c,Z,g]);const C=(0,o.sO)();C.current=0!==c,(0,o.d4)((()=>C.current?(0,Te.Z)((()=>{C.current&&g(0)})):void 0),[c,g]),(0,be.ZP)(0!==c,(()=>g(0,{forceOnHeavyAnimation:!0}))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&Z){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void f({id:l,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>Z.length-1)return;g(n,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:w,transitionClassNames:b}=(0,pe.Z)(!r,void 0,!0);function E(e){const a=Object.values(i).find((e=>{let{id:t}=e;return t===Z[c].id}));return a&&0!==c?o.ZP.createElement(et.Z,{folderType:"folder",folderId:a.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t}):o.ZP.createElement(et.Z,{folderType:"all",isActive:e,lastSyncTime:d,foldersDispatch:t,onScreenSelect:n})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=Z&&Z.length?o.ZP.createElement(Je.Z,{tabs:Z,activeTab:c,onSwitchTab:P}):w?o.ZP.createElement("div",{className:(0,ue.Z)("tabs-placeholder",b)}):void 0,o.ZP.createElement(Ae.Z,{ref:p,name:u?"none":v.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:Z?Z.length:void 0},E))})));var nt=n(9203),at=n(8778),st=n(4288);const ot=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)})),it=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)}));var rt=n(2328);let ct;const lt=(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,Le.Z)(),l=(0,ue.Z)("NewChatButton",t&&"revealed",i&&"menu-is-open"),d=(0,o.I4)((()=>{ct&&(clearTimeout(ct),ct=void 0)}),[]),u=(0,o.I4)((()=>{ct&&(clearTimeout(ct),ct=void 0),ct=window.setTimeout((()=>{r(!1)}),750)}),[]);return o.ZP.createElement("div",{className:l,onMouseEnter:d,onMouseLeave:u},o.ZP.createElement(Qe.Z,{round:!0,color:"primary",className:i?"active":"",onClick:()=>{r(!i)},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(rt.Z,{isOpen:i,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(je.Z,{icon:"channel",onClick:a},c("NewChannel")),o.ZP.createElement(je.Z,{icon:"group",onClick:s},c("NewGroup")),o.ZP.createElement(je.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),dt=Object.keys(m.du).length/2;let ut;const mt=(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,f]=(0,o.eJ)(h.$b),p=(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]),Z=(0,o.I4)((()=>{l(m.du.NewGroupStep1)}),[l]),P=(0,o.I4)((()=>{l(m.du.Archived)}),[l]),C=(0,o.I4)((()=>{t===m.du.ChatList&&(p.current=!0,f(!0))}),[t]),w=(0,o.I4)((()=>{p.current=!1,ut&&(clearTimeout(ut),ut=void 0),ut=window.setTimeout((()=>{p.current||f(!1)}),250)}),[]);(0,o.d4)((()=>{let e;return t!==m.du.ChatList?e=window.setTimeout((()=>{f(!1)}),250):(p.current||h.$b)&&f(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const[b,E,S]=function(){const[e,t]=(0,xe.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:n,transitionClassNames:a}=(0,pe.Z)(e);return[n,a,()=>{window.location.reload()}]}(),M=(0,Le.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:C,onMouseLeave:h.$b?void 0:w},o.ZP.createElement(We,{content:t,contactsFilter:s,onSearchQuery:c,onSelectSettings:v,onSelectContacts:I,onSelectArchived:P,onReset:u,shouldSkipTransition:i}),o.ZP.createElement(Ae.Z,{name:i?"none":"zoom-fade",renderCount:dt,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return o.ZP.createElement(tt,{onScreenSelect:d,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement(ot,{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}})),b&&o.ZP.createElement(Qe.Z,{fluid:!0,pill:!0,className:(0,ue.Z)("btn-update",E),onClick:S},M("lng_update_telegram")),o.ZP.createElement(lt,{isShown:g,onNewPrivateChat:I,onNewChannel:y,onNewGroup:Z}))})),ht=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)})),gt=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)})),ft=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)}));var pt;!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"}(pt||(pt={}));const vt=Object.keys(pt).length/2,It=(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:f,setLeftColumnWidth:p,resetLeftColumnWidth:v}=(0,a.uC)(),I=(0,o.sO)(null),[y,Z]=(0,o.eJ)(m.du.ChatList),[P,C]=(0,o.eJ)(m.MT.Main),[w,b]=(0,o.eJ)(""),[E,S]=(0,Be.ZP)(),[M,R]=(0,o.eJ)(0);let k=pt.Main;switch(y){case m.du.Archived:k=pt.Archived;break;case m.du.Settings:k=pt.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:k=pt.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:k=pt.NewGroup}const T=(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(P){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.Language:return void C(m.MT.Main);case m.MT.GeneralChatBackground:case m.MT.QuickReaction:return void C(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void C(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.PrivacyActiveSessions:case m.MT.PrivacyBlockedUsers:case m.MT.TwoFaDisabled:case m.MT.TwoFaEnabled:case m.MT.TwoFaCongratulations:return void C(m.MT.Privacy);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void C(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void C(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void C(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void C(m.MT.PrivacyForwarding);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void C(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void C(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void C(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void C(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void C(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void C(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void C(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void C(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void C(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void C(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void C(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void C(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void C(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void C(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return Z(m.du.ChatList),void C(m.MT.Main)}y!==m.du.ChatList||0!==s?(Z(m.du.ChatList),b(""),c({query:""}),u({date:void 0}),l({id:void 0}),d(),setTimeout((()=>{R(Date.now())}),250)):Z(m.du.GlobalSearch)}else Z(m.du.NewChannelStep1);else Z(m.du.NewGroupStep1)}),[y,s,P,c,u,l,d]),N=(0,o.I4)((e=>{y!==m.du.Contacts?(Z(m.du.GlobalSearch),e!==t&&c({query:e})):b(e)}),[y,t,c]);(0,o.d4)((()=>y!==m.du.ChatList||0===s?(0,Te.Z)((()=>T())):void 0),[s,y,T]),(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,Ne.Z)(e)&&(e.preventDefault(),Z(m.du.GlobalSearch))}}),[y]),(0,o.d4)((()=>{f(),P===m.MT.Privacy&&g()}),[f,g,P]);const{initResize:B,resetResize:x,handleMouseUp:A}=((e,t,n,a)=>{const[s,i,r]=(0,xe.Z)(),[c,l]=(0,o.eJ)(),[d,u]=(0,o.eJ)();function m(){document.body.classList.remove("no-selection","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){document.body.classList.add("no-selection","cursor-ew-resize"),l(t.clientX),u(e.current.offsetWidth),i()},resetResize:function(t){t.preventDefault(),e.current.style.width="",n()},handleMouseUp:m}})(I,p,v,r),L=e=>{Z(m.du.Settings),C(e)};return o.ZP.createElement("div",{id:"LeftColumn",ref:I},o.ZP.createElement(Ae.Z,{name:i?"none":h.s0,renderCount:vt,activeKey:k,shouldCleanup:!0,cleanupExceptionKey:pt.Main},(e=>{switch(k){case pt.Archived:return o.ZP.createElement(ft,{isActive:e,onReset:T,onContentChange:Z});case pt.Settings:return o.ZP.createElement(ht,{isActive:e,currentScreen:P,foldersState:E,foldersDispatch:S,onScreenSelect:L,onReset:T,shouldSkipTransition:i});case pt.NewChannel:return o.ZP.createElement(gt,{key:M,isActive:e,isChannel:!0,content:y,onContentChange:Z,onReset:T});case pt.NewGroup:return o.ZP.createElement(gt,{key:M,isActive:e,content:y,onContentChange:Z,onReset:T});default:return o.ZP.createElement(mt,{content:y,searchQuery:t,searchDate:n,contactsFilter:w,foldersDispatch:S,onContentChange:Z,onSearchQuery:N,onScreenSelect:L,onReset:T,shouldSkipTransition:i})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:B,onMouseUp:A,onDoubleClick:x}))})));var yt=n(2420),Zt=n(5780),Pt=n(9524),Ct=n(1394);const wt=()=>{const[e,t]=(0,o.eJ)(Y.Z.get());return(0,o.d4)((()=>{const e=(0,C.P2)((()=>{t(Y.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var bt=n(2678),Et=n(7204),St=n(5326),Mt=n(3570),Rt=n(5790),kt=n(8360),Tt=n(6058),Nt=n(8799);const Bt=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"HeaderMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),xt=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s,threadId:o,messageListType:i}=t;const c=(0,r.Z1)(e,s),d=Boolean(c&&(0,l.eA)(c));if(!c||c.isRestricted||(0,r.CA)(e))return{noMenu:!0};const m=(0,r.IK)(e,s),g=(0,r.FM)(e,s),f="thread"===i&&o===u._f,p="thread"===i&&o!==u._f,v=(0,r.Jf)(e),I=Boolean(m&&(0,r.s4)(e,m.id)),y=!I&&Boolean((0,r.pk)(e,s)),Z=Boolean(f&&(d||(0,l.ZV)(c))&&c.isNotJoined);return{noMenu:!1,isChannel:d,isRightColumnShown:v,canStartBot:y,canRestartBot:I,canSubscribe:Z,canSearch:f||p,canCall:h.Bi&&(0,l.YC)(c.id)&&!g&&!m,canMute:f&&!g&&!Z,canLeave:f&&!Z,canEnterVoiceChat:h.Bi&&c.isCallActive,canCreateVoiceChat:h.Bi&&!c.isCallActive&&((null===(n=c.adminRights)||void 0===n?void 0:n.manageCall)||c.isCreator&&(0,l.G9)(c)),pendingJoinRequests:null===(a=c.fullInfo)||void 0===a?void 0:a.requestsPending}}))((e=>{let{chatId:t,threadId:n,noMenu:s,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canLeave:f,canEnterVoiceChat:p,canCreateVoiceChat:v,pendingJoinRequests:I,isRightColumnShown:y,canExpandActions:Z}=e;const{joinChannel:P,sendBotCommand:C,openLocalTextSearch:w,restartBot:b,openCallFallbackConfirm:E,requestNextManagementScreen:S}=(0,a.uC)(),M=(0,o.sO)(null),[R,k]=(0,o.eJ)(!1),[T,N]=(0,o.eJ)(void 0),B=(0,o.I4)((()=>{k(!0);const e=M.current.getBoundingClientRect();N({x:e.right,y:e.bottom})}),[]),x=(0,o.I4)((()=>{k(!1)}),[]),A=(0,o.I4)((()=>{N(void 0)}),[]),L=(0,o.I4)((()=>{P({chatId:t})}),[P,t]),O=(0,o.I4)((()=>{C({command:"/start"})}),[C]),U=(0,o.I4)((()=>{b({chatId:t})}),[t,b]),F=(0,o.I4)((()=>{S({screen:m.u1.JoinRequests})}),[S]),$=(0,o.I4)((()=>{w(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[w]);(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,Ne.Z)(e)&&(e.preventDefault(),$())}}),[d,$]);const D=(0,Le.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,Z&&l&&o.ZP.createElement(Qe.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:L},D(i?"ProfileJoinChannel":"ProfileJoinGroup")),Z&&r&&o.ZP.createElement(Qe.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:O},D("BotStart")),Z&&c&&o.ZP.createElement(Qe.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:U},D("BotRestart")),d&&o.ZP.createElement(Qe.Z,{round:!0,ripple:y,color:"translucent",size:"smaller",onClick:$,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),u&&o.ZP.createElement(Qe.Z,{round:!0,color:"translucent",size:"smaller",onClick:E,ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),Boolean(I)&&o.ZP.createElement(Qe.Z,{round:!0,className:"badge-button",ripple:y,color:"translucent",size:"smaller",onClick:F,ariaLabel:D(i?"SubscribeRequests":"MemberRequests")},o.ZP.createElement("i",{className:"icon-user"}),o.ZP.createElement("div",{className:"badge"},I)),o.ZP.createElement(Qe.Z,{ref:M,className:R?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:B},o.ZP.createElement("i",{className:"icon-more"})),T&&o.ZP.createElement(Bt,{chatId:t,threadId:n,isOpen:R,anchor:T,withExtraActions:h.wB||!Z,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canLeave:f,canEnterVoiceChat:p,canCreateVoiceChat:v,onSubscribeChannel:L,onSearchClick:$,onClose:x,onCloseAnimationEnd:A}))})));var At=n(4399),Lt=n(6202),Ot=n(862);function Ut(e){var t;const n=e&&(0,l.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)(Ot.Hu),d=null==e?void 0:e.id;return(0,o.bt)((()=>{i&&(0,Ot.p6)(`b64-${d}`,n).then(c).catch((e=>{s.eM&&console.error(e)}))}),[d,i,n]),i?r:n}var Ft=n(7551),$t=n(8512),Dt=n(996);function qt(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=qt(0,0,2,t,1)+qt(0,12,2,t+1,1)+qt(0,25,2,t,1);else for(let e=0;e<n;e++)a+=qt(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,ue.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:a,customTitle:s,className:i,onUnpinMessage:r,onClick:c,onAllPinnedClick:d}=e;const u=(0,Le.Z)(),m=Ut(t),h=(0,Lt.Z)((0,l.Ti)(t,"pictogram")),g=(0,Dt.e)(u,t,Boolean(m)),[f,p,v]=(0,xe.Z)(),I=(0,o.I4)((()=>{v(),r&&r(t.id)}),[v,r,t.id]);return o.ZP.createElement("div",{className:(0,ue.Z)("HeaderPinnedMessage-wrapper",i)},n>1&&o.ZP.createElement(Qe.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:u("EventLogFilterPinnedMessages"),onClick:d},o.ZP.createElement("i",{className:"icon-pin-list"})),r&&o.ZP.createElement(Qe.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:u("UnpinMessageAlertTitle"),className:"unpin-button",onClick:p},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Ft.Z,{isOpen:f,onClose:v,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:I}),o.ZP.createElement("div",{className:"HeaderPinnedMessage",onClick:c,dir:u.isRtl?"rtl":void 0},o.ZP.createElement(jt,{count:n,index:a}),m&&function(e,t){const{width:n,height:a}=(0,At.W7)();return o.ZP.createElement("img",{src:t||e,width:n,height:a,alt:""})}(m,h),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},s||`${u("PinnedMessage")} ${a>0?"#"+(n-a):""}`),o.ZP.createElement("p",{dir:"auto"},g)),o.ZP.createElement($t.Z,null)))}));var Gt=n(396),Ht=n(4532),_t=n(3186),zt=n(711);function Vt(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=()=>{Xt(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 Xt(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Yt(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 Yt(e,t,n,void 0,a)}}function Yt(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)}))}var Wt=n(4524);const Kt={width:200,height:200},Jt=115,en=(e,t,n)=>{const{audio:a,voice:s}=(0,l.qp)(e),i=a?a.title||a.fileName:s?"Voice message":"",r=a&&a.performer||t&&(0,l.OU)(zt.i0,t),c=n&&(0,l.U)(zt.i0,n)||"Telegram",d=a&&(0,l.MR)(a)&&(0,l.Ti)(e,"pictogram"),u=t&&(0,l.RT)(t,"big"),m=a&&d||s&&u,h=(0,Lt.Z)(m),g=(0,o.Ye)((()=>function(e,t,n){if(!n)return Kt;if(e){if(!e.thumbnailSizes||0===e.thumbnailSizes.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?At.vY:void 0}(a,s,h)),[a,h,s]),{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 e=!1;return function(e,t){if(!e)return Promise.resolve(Wt);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=()=>{Xt(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,Jt,Jt);const n=Math.min(t.width,t.height);return n<Jt?Vt(e,Jt/n):Promise.resolve(e)}(h,g).then((t=>{e||(s(!1),l(t))}),(t=>{e||(s(!1),r(t))})),()=>{e=!0}}),t),{isLoading:a,error:i,result:c}})(0,[h,g],Wt);return(0,o.Ye)((()=>(0,Ht.Of)({title:i,artist:r,album:c,artwork:[{src:f}]})),[c,r,i,f])};var tn=n(2340),nn=n(8051);const an=(0,a.c$)(((e,t)=>{let{message:n}=t;const a=(0,r.Ur)(e,n),s=(0,r.Z1)(e,n.chatId),{volume:o,playbackRate:i,isMuted:c}=e.audioPlayer;return{sender:a,chat:s,volume:o,playbackRate:i,isMuted:c}}))((e=>{let{message:t,className:n,noUi:s,sender:i,chat:r,volume:c,playbackRate:d,isMuted:u}=e;const{setAudioPlayerVolume:m,setAudioPlayerPlaybackRate:g,setAudioPlayerMuted:f,focusMessage:p,closeAudioPlayer:v}=(0,a.uC)(),I=(0,Le.Z)(),{audio:y,voice:Z,video:P}=(0,l.qp)(t),C=Boolean(Z||P),w=i?(0,l.OU)(I,i):void 0,b=H.UV((0,l.Ti)(t,"inline")),E=en(t,i,r),{playPause:S,stop:M,isPlaying:R,requestNextTrack:k,requestPreviousTrack:T,isFirst:N,isLast:B,setVolume:x,toggleMuted:A,setPlaybackRate:L}=(0,_t.Z)((0,Gt.An)(t),(0,l.XV)(t),C?"voice":"audio",b,void 0,E,void 0,!0,void 0,void 0,(0,l.CI)(t),!0),O=C&&R;(0,o.d4)((()=>{if(O)return Y.Z.disableRefresh(),()=>{Y.Z.enableRefresh()}}),[O]);const U=(0,o.I4)((()=>{p({chatId:t.chatId,messageId:t.id})}),[p,t.chatId,t.id]),F=(0,o.I4)((()=>{R&&S(),v(),(0,Ht.Ay)(),M()}),[v,R,S,M]),$=(0,o.I4)((e=>{m({volume:e/100}),f({isMuted:!1}),x(e/100)}),[f,m,x]),D=(0,o.I4)((()=>{h.$b&&!h.cj||(A(),f({isMuted:!u}))}),[u,f,A]),q=(0,o.I4)((()=>{1===d?(L(1.8),g({playbackRate:1.8})):(L(1),g({playbackRate:1}))}),[d,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,ue.Z)("AudioPlayer",n),dir:I.isRtl?"rtl":void 0},o.ZP.createElement(Qe.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:N(),onClick:T,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(Qe.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,ue.Z)("toggle-play","player-button",R?"pause":"play"),onClick:S,ariaLabel:R?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(Qe.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,tn.Z)(t||a)),n&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,tn.Z)(n)))}(y):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,tn.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(I("AttachAudio"),w),o.ZP.createElement($t.Z,null)),o.ZP.createElement(Qe.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",withClickPropagation:!0},o.ZP.createElement("i",{className:j,onClick:D}),!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(nn.Z,{value:u?0:100*c,onChange:$})))),C&&o.ZP.createElement(Qe.Z,{round:!0,className:(0,ue.Z)("playback-button",1!==d&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:q},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(Qe.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:F,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var sn=n(2607),on=n(172);const rn=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,r.Z1)(e,n),s=(0,sn.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.uC)(),u=(0,Le.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,ue.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(on.Z,{key:e.user.id,user:e.user}):o.ZP.createElement(on.Z,{key:e.chat.id,chat:e.chat})}))),o.ZP.createElement(Qe.Z,{round:!0,className:"join"},u("VoipChatJoin")))}))),cn=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,messageListType:s}=t;const{isLeftColumnShown:o,lastSyncTime:i,shouldSkipHistoryAnimations:c}=e,l=(0,r.Z1)(e,n),{typingStatus:d}=l||{},{chatId:m,messageId:h}=e.audioPlayer,g=m&&h?(0,r.hj)(e,m,h):void 0;let f;if("pinned"===s){const t=(0,r.KB)(e,n);f=null==t?void 0:t.length}else if("scheduled"===s){const t=(0,r.qy)(e,n);f=null==t?void 0:t.length}else if("thread"===s&&a!==u._f){const t=(0,r.tZ)(e,n,a);f=(null==t?void 0:t.messagesCount)||0}const p={typingStatus:d,isLeftColumnShown:o,isRightColumnShown:(0,r.Jf)(e),isSelectModeActive:(0,r.CA)(e),audioMessage:g,chat:l,messagesCount:f,isChatWithSelf:(0,r.FM)(e,n),isChatWithBot:l&&(0,r.xo)(e,l),lastSyncTime:i,shouldSkipHistoryAnimations:c,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing},v=(0,r.Zw)(e,n);if("thread"!==s||!v)return p;if(Object.assign(p,{messagesById:v}),a!==u._f){const t=(0,r.qS)(e,n,a),s=t?(0,r.hj)(e,n,t):void 0,o=s?(0,r.cv)(e,s):void 0;return{...p,pinnedMessageIds:t,canUnpin:!1,topMessageSender:o}}const I=(0,r.KB)(e,n);if(null!=I&&I.length){const t=v[I[0]],{canUnpin:n}=t&&(0,r._k)(e,t,a)||{};return{...p,pinnedMessageIds:I,canUnpin:n}}return p}))((e=>{let{chatId:t,threadId:n,messageListType:i,isReady:r,pinnedMessageIds:c,messagesById:d,canUnpin:m,topMessageSender:g,typingStatus:f,isSelectModeActive:p,isLeftColumnShown:v,isRightColumnShown:I,audioMessage:y,chat:Z,messagesCount:P,isChatWithSelf:C,isChatWithBot:w,lastSyncTime:b,shouldSkipHistoryAnimations:E,currentTransitionKey:S,connectionState:M,isSyncing:R}=e;const{openChatWithInfo:k,pinMessage:T,focusMessage:N,openChat:B,openPreviousChat:x,loadPinnedMessages:A,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,a.uC)(),U=(0,Le.Z)(),F=(0,o.sO)(!0),[$,D]=(0,o.eJ)(0),q=Array.isArray(c)?c[$]:c,j=d&&q?d[q]:void 0,Q=Array.isArray(c)?c.length:c?1:void 0,G=Z&&(0,l.U)(U,Z).length,H=g?(0,l.OU)(U,g):void 0;(0,o.d4)((()=>{n===u._f&&b&&r&&A({chatId:t})}),[t,A,b,n,r]),(0,o.d4)((()=>{D(0)}),[c]),(0,Rt.Z)(t,q,j);const{width:_}=wt(),z=_<=s.ks,V=h.p7&&v,X=(0,o.sO)(null),Y=(0,o.sO)(!0),W=(0,o.I4)((()=>{k({id:t})}),[k,t]),K=(0,o.I4)((e=>{T({chatId:t,messageId:e,isUnpin:!0})}),[T,t]),J=(0,o.I4)((()=>{if(j){N({chatId:j.chatId,threadId:n,messageId:j.id});const e=(0,Mt.Z)(Q||1,$+1);D(e)}}),[j,N,n,Q,$]),ee=(0,o.I4)((()=>{B({id:t,threadId:u._f,type:"pinned"})}),[B,t]),te=(0,o.I4)((()=>{setTimeout((()=>{F.current=!0}),450)}),[]),ne=(0,o.I4)((e=>{if(F.current){if(F.current=!1,h.wB){const e=document.getElementById(s.R2);e&&e.blur()}if(p)return O(),void te();if(n===u._f&&"thread"===i&&0===S)return h.wB||V?(e.stopPropagation(),B({id:void 0})):L(),void te();x(),te()}}),[n,i,S,p,x,V,B,L,O,te]),ae=_>=s.ks&&_<s.jT||_>s.l3&&_<s.ks&&(!G||G>30),se=ae||_>s._m&&_<s.QU,{shouldRender:oe,transitionClassNames:ie}=(0,pe.Z)(Boolean(y)),re=(0,kt.Z)(y,!0),{shouldRender:ce,transitionClassNames:le}=(0,pe.Z)(Boolean(j)),de=(0,kt.Z)(j,!0),me=(0,kt.Z)(Q,!0),he=(0,kt.Z)(m,!0),ge=(0,kt.Z)(H),fe=ce&&de||oe&&re;(0,o.d4)((()=>{const e=X.current;if(e)return se&&fe?void(I||ae?(Y.current&&(e.classList.add("tools-stacked","animated"),Y.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),Y.current=!0)):(e.classList.remove("tools-stacked","animated"),void(Y.current=!0))}),[se,fe,ae,I]);const{connectionStatusText:ve}=De(U,M,R,!0);function Ie(){return"thread"===i&&n===u._f?o.ZP.createElement(o.ZP.Fragment,null,(z||S>0)&&ye(V,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:W},(0,l.YC)(t)?o.ZP.createElement(Tt.Z,{userId:t,typingStatus:f,status:ve,withDots:Boolean(ve),withFullInfo:w,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(Nt.Z,{chatId:t,typingStatus:f,status:ve,withDots:Boolean(ve),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,noRtl:!0}))):"thread"===i?o.ZP.createElement(o.ZP.Fragment,null,ye(),o.ZP.createElement("h3",null,U("CommentsCount",P,"i"))):"pinned"===i?o.ZP.createElement(o.ZP.Fragment,null,ye(),o.ZP.createElement("h3",null,U("PinnedMessagesCount",P,"i"))):"scheduled"===i?o.ZP.createElement(o.ZP.Fragment,null,ye(),o.ZP.createElement("h3",null,C?U("Reminders"):U("messages",P,"i"))):void 0}function ye(){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(Qe.Z,{round:!0,size:"smaller",color:"translucent",onClick:ne,ariaLabel:U(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,ue.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(ke,null))}const Ze=Boolean(oe&&re);return o.ZP.createElement("div",{className:"MiddleHeader",ref:X},o.ZP.createElement(Ae.Z,{name:E?"none":"slide-fade",activeKey:S},Ie),o.ZP.createElement(rn,{hasPinnedOffset:ce&&Boolean(de)||oe&&Boolean(re),chatId:t}),ce&&de&&o.ZP.createElement(Qt,{key:t,message:de,count:me||0,index:$,customTitle:ge,className:(0,ue.Z)(le,Ze&&"full-width"),onUnpinMessage:he?K:void 0,onClick:J,onAllPinnedClick:ee}),o.ZP.createElement("div",{className:"header-tools"},Ze&&o.ZP.createElement(an,{key:(0,l.Tp)(re),message:re,className:ie}),o.ZP.createElement(xt,{chatId:t,threadId:n,messageListType:i,canExpandActions:!Ze})))})));var ln=n(2645),dn=n(274);function un(e){return"albumId"in e}function mn(e,t){let n,a=[],s={originalDate:e[0].date,datetime:Number((0,N.$Y)(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=Number((0,N.$Y)(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,l.Lo)(i)||(0,l.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 hn=n(386),gn=n(2202);var fn=n(7675),pn=n(539),vn=n(2357),In=n(3657);const yn=h.wZ?1e3:350,Zn=h.wB?300:500;var Pn=n(7240);function Cn(e){return"number"==typeof e}function wn(e,t){return e?t?238:175:t?238:100}function bn(e,t){const n=(0,l.B4)(e),a=(0,l.MF)(e),s=(0,l.O$)(e)||(0,l.F$)(e),o=(0,l.b7)(e),i=Boolean((0,l.F$)(e)),{width:r,height:c}=s?(0,At.Eh)(s,n,a,i,t):(0,At.GC)(o,n,a,t),d=wn(Boolean((0,l.UD)(e)));let u=1;r<d&&d-r<12&&(u=d/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<d||h<90}}function En(e,t){return e.reduce(((e,t)=>e+t),t)}function Sn(e,t,n){return e<t?t:e>n?n:e}function Mn(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 Rn(e,t,n,a){const s=function(e){return e.map((e=>{const t=bn(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,At.kc)(e,t,!1,n)-(t?2.5:0)*At.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?Sn(e,1,2.75):Sn(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=En(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=En(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,f=m.heights,p=g.length;let v=0,I=0;for(let e=0;e!==p;++e){const t=g[e],n=f[e],s=Math.round(n);let i=0;for(let c=0;c!==t;++c){const d=0|(0===e?1:0)|(e===p-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:Mn(d)}}let kn;function Tn(e){return kn||(kn=document.createElement("span"),kn.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',kn.style.whiteSpace="nowrap",kn.style.position="absolute",kn.style.left="-999px",kn.style.opacity=".01",document.body.appendChild(kn)),kn.innerHTML=e,kn.offsetWidth}function Nn(e,t,n,a,s,i){(0,o.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,pn.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 Bn=3*At.Gw,xn=Number(At.Gw),An="data-is-document-group-hover";function Ln(e,t,n,s,i,r,c,l,d,u,m,g,f,p){const{setReplyingToId:v,sendDefaultReaction:I}=(0,a.uC)(),[y,Z,P]=(0,xe.Z)(),[C,w,b]=(0,xe.Z)(),E=(0,o.sO)();return(0,o.d4)((()=>{if(!h.$b||i||!r||m)return;let e;return(0,Ke.sf)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,n)=>n===Ke.eM.Left&&(e||(e=Date.now()),w(),!0),onRelease:()=>{e&&(v({messageId:n}),setTimeout(b,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,i,n,v,w,b,r,m]),{handleMouseDown:i?void 0:function(e){(0,hn.q)(e),d(e)},handleClick:function(t){if(i)e(t);else if(h.$b)return E.current?(clearInterval(E.current),E.current=void 0,void function(e){const{pageX:t,pageY:a}=e;I({chatId:u,messageId:n,x:t,y:a})}(t)):void(E.current=setTimeout((()=>{E.current=void 0,function(e){if(h.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;Y.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:i?c?ge.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(f?n-s:s+o-n)<Bn,l=Math.abs(i+r-a)<xn;c&&l?Z():P()},handleSendQuickReaction:function(e){const{x:t,y:a}=e.currentTarget.getBoundingClientRect();I({chatId:u,messageId:n,x:t,y:a})},handleMouseLeave:function(e){P(),p&&function(e){const t=Un(e.currentTarget);t&&t.removeAttribute(An)}(e)},isSwiped:C,isQuickReactionVisible:y,handleDocumentGroupMouseEnter:On}}function On(e){const t=Un(e.currentTarget);t&&t.setAttribute(An,"")}function Un(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var Fn=n(8005);const $n=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"ContextMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),Dn=(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||{},c=n.replyToMessageId,d=c?(0,r.hj)(e,n.chatId,c):void 0,u=(0,r._X)(e,n),{direction:m,noHighlight:h}=u&&e.focusedMessage||{},g=(0,r.Z1)(e,n.chatId),f=g&&((0,l.eA)(g)||s===n.chatId);return{usersById:a,senderUser:!f&&s?(0,r.dy)(e,s):void 0,senderChat:f?g:void 0,targetChatId:i,targetUserIds:o,targetMessage:d,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:d,targetMessage:u,targetChatId:m,isFocused:h,focusDirection:g,noFocusHighlight:f}=e;const p=(0,o.sO)(null);(0,In._N)(p,n),(0,Rt.Z)(t.chatId,t.replyToMessageId,u),Nn(p,t.chatId,h,g,f);const v=(0,Le.Z)(),I=s<=0,[y,Z]=(0,xe.Z)(I);(0,o.d4)((()=>{I||setTimeout(Z,10*s)}),[s,Z,I]);const{transitionClassNames:P}=(0,pe.Z)(y,void 0,I,!1),C=(0,o.Ye)((()=>d?d.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[d,r]),w=(0,Fn.D)(v,t,c,l,C,u,m,{asTextWithSpoilers:a}),{isContextMenuOpen:b,contextMenuPosition:E,handleBeforeContextMenu:S,handleContextMenu:M,handleContextMenuClose:R,handleContextMenuHide:k}=(0,Pn.Z)(p),T=void 0!==E;if(a)return o.ZP.createElement("span",{className:"embedded-action-message"},w);const N=(0,ue.Z)("ActionMessage message-list-item",h&&!f&&"focused",T&&"has-menu-open",i&&"last-in-list",P);return o.ZP.createElement("div",{ref:p,id:`message${t.id}`,className:N,"data-message-id":t.id,onMouseDown:e=>{(0,hn.q)(e),S(e)},onContextMenu:M},o.ZP.createElement("span",null,w),E&&o.ZP.createElement($n,{isOpen:b,anchor:E,message:t,messageListType:"thread",onClose:R,onCloseAnimationEnd:k}))}))),qn=e=>{let{className:t,message:n,sender:a,title:s,customText:i,isProtected:r,observeIntersection:c,onClick:d}=e;const u=(0,o.sO)(null),m=(0,In.Op)(u,c),h=(0,Lt.Z)(n&&(0,l.Ti)(n,"pictogram"),!m),g=n&&`sticker-reply-thumb${n.id}`,f=Ut(n),p=Boolean(n&&(0,l.Y5)(n)),v=(0,Le.Z)(),I=a&&(0,l.OU)(v,a);return o.ZP.createElement("div",{ref:u,className:(0,ue.Z)("EmbeddedMessage",t),onClick:n?d:void 0},f&&function(e,t,n,a,s){const{width:i,height:r}=(0,At.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{id:e,src:n||t,width:i,height:r,alt:"",className:a?"round":"",draggable:!s}),s&&o.ZP.createElement("span",{className:"protector"}))}(g,f,h,p,r),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},n?(0,l.Lo)(n)?o.ZP.createElement(Dn,{message:n,isEmbedded:!0}):(0,Dt.e)(v,n,Boolean(f)):i||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,tn.Z)(I||s||" "))))};var jn=n(2535),Qn=n(4752),Gn=n(8018),Hn=n(8198),_n=n(7799);const zn=(0,o.X$)((e=>{var t,n;let{reaction:s,activeReaction:i,isInMeta:r,availableReactions:c}=e;const{stopActiveReaction:l}=(0,a.uC)(),d=null==c?void 0:c.find((e=>e.reaction===s)),m=null==d||null===(t=d.centerIcon)||void 0===t?void 0:t.id,h=null==d||null===(n=d.aroundAnimation)||void 0===n?void 0:n.id,g=(0,Lt.Z)(`sticker${m}`,!m,u.IU.Lottie),f=(0,Lt.Z)(`sticker${h}`,!h,u.IU.Lottie),p=Boolean((null==i?void 0:i.reaction)===s&&g&&f),{shouldRender:v,transitionClassNames:I}=(0,pe.Z)(p,void 0,!0,"slow"),y=(0,o.I4)((()=>{l({messageId:null==i?void 0:i.messageId,reaction:s})}),[null==i?void 0:i.messageId,s,l]),[Z,P,C]=(0,xe.Z)(),w=!p||!Z,b=(0,ue.Z)("ReactionAnimatedEmoji",r&&"in-meta",v&&"is-animating");return o.ZP.createElement("div",{className:b},w&&o.ZP.createElement(Hn.Z,{reaction:s}),v&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(_n.Z,{key:m,id:`reaction_emoji_${m}`,className:I,size:30,animationData:g,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:P,onEnded:C}),o.ZP.createElement(_n.Z,{key:h,id:`reaction_effect_${h}`,className:(0,ue.Z)("effect",I),size:100,animationData:f,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:y})))})),Vn=(0,o.X$)((e=>{var t;let{message:n,outgoingStatus:a,signature:s,onClick:i,withReactions:r,activeReaction:c,withReactionOffset:l,availableReactions:d}=e;const u=(0,Le.Z)(),[m,h]=(0,xe.Z)(),g=r&&(null===(t=n.reactions)||void 0===t?void 0:t.results.filter((e=>e.count>0))),f=(0,o.Ye)((()=>{if(!m)return;const e=(0,N.SA)(1e3*n.date,u.code),t=n.isEdited&&(0,N.SA)(1e3*n.editDate,u.code),a=n.forwardInfo&&(0,N.SA)(1e3*n.forwardInfo.date,u.code);let s=e;return t&&(s+="\n",s+=u("lng_edited_date").replace("{date}",t)),a&&(s+="\n",s+=u("lng_forwarded_date").replace("{date}",a)),s}),[m,u,n]);return o.ZP.createElement("span",{className:(0,ue.Z)("MessageMeta",l&&"reactions-offset"),dir:u.isRtl?"rtl":"ltr",onClick:i},g&&g.map((e=>o.ZP.createElement(zn,{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,Se.bi)(n.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,tn.Z)(s)),o.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:h},n.isEdited&&`${u("EditedMessage")} `,(0,N.mr)(u,1e3*n.date)),a&&o.ZP.createElement(Gn.Z,{status:a}))}));var Xn=n(692),Yn=n(4753);const Wn=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:a,shouldLoop:i,lastSyncTime:r}=e;const c=(0,o.sO)(null),[d,u,m]=(0,xe.Z)(),g=t.content.sticker,{isLottie:f,stickerSetId:p,isGif:v}=g,I=h.Hh,y=p===s.$E,Z=(0,In.Op)(c,n),P=(0,In.Op)(c,a),C=g.isPreloadedGlobally?`sticker${g.id}`:(0,l.Ti)(t,"inline"),w=v&&!I&&(g.isPreloadedGlobally?`sticker${g.id}?size=m`:(0,l.Ti)(t,"pictogram")),b=(0,Lt.Z)(w),E=Ut(t),S=b||E,M=(0,Lt.Z)(C,!Z,(0,l.kG)(t,"inline"),r),R=Boolean(M),[k,T]=(0,xe.Z)(R),N=f?k:R,B=(0,Xn.Z)(N),{width:x,height:A}=(0,At.Wr)(g),L=(0,ue.Z)("thumbnail",!E&&"empty"),O=(0,ue.Z)("Sticker media-inner",y&&"inactive");return(0,o.d4)((()=>{if(!v||!c.current)return;const e=c.current.querySelector("video");e&&(P?(0,Yn.Z)(e):e.pause())}),[v,P]),o.ZP.createElement("div",{ref:c,className:O,onClick:y?void 0:u},(!N||v&&!I)&&o.ZP.createElement("img",{id:`sticker-thumb-${t.id}`,src:S,width:x,height:A,alt:"",className:L}),!f&&!v&&o.ZP.createElement("img",{id:`sticker-${t.id}`,src:M,width:x,height:A,alt:"",className:(0,ue.Z)("full-media",B)}),v&&I&&N&&o.ZP.createElement("video",{id:`sticker-${t.id}`,src:M,width:x,height:A,autoPlay:P,playsInline:!0,loop:i,muted:!0}),f&&R&&o.ZP.createElement(_n.Z,{key:C,className:(0,ue.Z)("full-media",B),id:C,animationData:M,size:x,play:P,noLoop:!i,onLoad:T}),o.ZP.createElement(Ee.Z,{isOpen:d,fromSticker:g,onClose:m}))};var Kn=n(7854),Jn=n(2566),ea=n(5866);function ta(e,t){return(0,ea.Z)((0,l.DH)(e),Boolean(t),h.wB&&!h.vX)}const na={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var aa=n(9196);const sa=e=>{let{id:t,message:n,observeIntersection:a,noAvatars:s,canAutoLoad:i,isInSelectMode:r,isSelected:c,uploadProgress:d,size:u="inline",dimensions:m,nonInteractive:h,shouldAffectAppendix:g,isDownloading:f,isProtected:p,theme:v,onClick:I,onCancelUpload:y}=e;const Z=(0,o.sO)(null),P=((0,l.O$)(n)||(0,l.F$)(n)).blobUrl,C=(0,In.Op)(Z,a),[w,b]=(0,o.eJ)(i),E=w&&C,{mediaData:S,loadProgress:M}=(0,Jn.Z)((0,l.Ti)(n,u),!E),R=P||S,k=ta(n,R),{loadProgress:T}=(0,Jn.Z)((0,l.Ti)(n,"download"),!f),{isUploading:N,isTransferring:B,transferProgress:x}=(0,l.Sc)(n,d||(f?T:M),E&&!R),A=!1===(0,Et.Z)(w),L=(0,Xn.Z)(R),{shouldRender:O,transitionClassNames:U}=(0,pe.Z)(B,void 0,A,"slow"),{shouldRender:F,transitionClassNames:$}=(0,pe.Z)(!R&&!w),D=(0,o.I4)((()=>{N?y&&y(n):R?I&&I(n.id):b((e=>!e))}),[R,N,n,y,I]),q=(0,l.B4)(n);(0,o.bt)((()=>{if(!g)return;const e=Z.current.closest(".message-content");R?function(e,t,n,a,s){return a?Promise.resolve(na[s||"light"][t?"outgoing":"incoming"]):async function(e,t){const n=new Image;n.src=e,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)}(R,q,0,c,v).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[R,q,g,r,c,v]);const{width:j,height:Q,isSmall:G}=m||bn(n,s),H=(0,ue.Z)("media-inner",!N&&!h&&"interactive",G&&"small-image",j===Q&&"square-image"),_=m?`width: ${j}px; height: ${Q}px; left: ${m.x}px; top: ${m.y}px;`:"";return o.ZP.createElement("div",{id:t,ref:Z,className:H,style:_,onClick:N?void 0:D},o.ZP.createElement("canvas",{ref:k,className:"thumbnail",style:`width: ${j}px; height: ${Q}px`}),o.ZP.createElement("img",{src:R,className:`full-media ${L}`,width:j,height:Q,alt:"",draggable:!p}),p&&o.ZP.createElement("span",{className:"protector"}),O&&!F&&o.ZP.createElement("div",{className:`media-loading ${U}`},o.ZP.createElement(aa.Z,{progress:x,onClick:N?D:void 0})),F&&o.ZP.createElement("i",{className:(0,ue.Z)("icon-download",$)}),B&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*x),"%"))};var oa=n(2019),ia=n(6898);function ra(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,Yn.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,C.T2)(r)}),[r]);(0,ve.Z)(i,c),(0,de.ZP)(i,r)}function ca(){return ca=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},ca.apply(this,arguments)}const la=e=>{var t;let{id:n,message:s,observeIntersection:i,noAvatars:r,canAutoLoad:c,canAutoPlay:d,uploadProgress:m,lastSyncTime:h,dimensions:g,onClick:f,onCancelUpload:p,isDownloading:v,isProtected:I}=e;const y=(0,o.sO)(null),Z=(0,o.sO)(null),P=(0,l.b7)(s)||(0,l.Cg)(s),C=P.blobUrl,w=(0,In.Op)(y,i),[b,E]=(0,o.eJ)(c),S=Boolean(b&&w&&h),[M,R]=(0,o.eJ)(d),k=(0,Lt.Z)((0,l.Ti)(s,"pictogram"),!(w&&h),(0,l.kG)(s,"pictogram"),h),T=(0,Xn.Z)(k),{mediaData:B,loadProgress:x}=(0,Jn.Z)((0,l.Ti)(s,"inline"),!S,(0,l.kG)(s,"inline"),h),A=C||B,L=Boolean(w&&A),O=ta(s,k),{loadProgress:U}=(0,Jn.Z)((0,l.Ti)(s,"download"),!v,u.IU.BlobUrl,h),{isBuffered:F,bufferingHandlers:$}=(0,oa.Z)(!c),{isUploading:D,isTransferring:q,transferProgress:j}=(0,l.Sc)(s,m||(v?U:x),S&&!F||v),Q=!1===(0,Et.Z)(b),{shouldRender:G,transitionClassNames:H}=(0,pe.Z)(q,void 0,Q),{shouldRender:_,transitionClassNames:z}=(0,pe.Z)(b&&!M&&!G),[V,X]=(0,o.eJ)(0),Y=(0,o.I4)((e=>{X(Math.max(0,e.currentTarget.currentTime-1))}),[]),W=(null===(t=Z.current)||void 0===t?void 0:t.duration)||P.duration||0,K=(0,l.B4)(s),J=(0,l.MF)(s),{width:ee,height:te}=g||(0,At.GC)(P,K,J,r);ra(Z,L),(0,ia.Z)(Z,[L]);const ne=(0,o.I4)((()=>{D?p&&p(s):v?(0,a.uC)().cancelMessageMediaDownload({message:s}):A?A&&!M?(R(!0),Z.current.play()):f&&f(s.id):E((e=>!e))}),[D,v,A,M,f,p,s]),ae=(0,ue.Z)("media-inner dark",!D&&"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:D?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,ue.Z)("thumbnail",T),style:`width: ${ee}px; height: ${te}px;`,alt:"",draggable:!I}),L&&o.ZP.createElement("video",ca({ref:Z,className:"full-media",width:ee,height:te,autoPlay:M,muted:!0,loop:!0,playsInline:!0},$,{draggable:!I,onTimeUpdate:Y}),o.ZP.createElement("source",{src:A})),I&&o.ZP.createElement("span",{className:"protector"}),_&&o.ZP.createElement("i",{className:(0,ue.Z)("icon-large-play",z)}),G&&o.ZP.createElement("div",{className:(0,ue.Z)("media-loading",H)},o.ZP.createElement(aa.Z,{progress:j,onClick:ne})),!b&&o.ZP.createElement("i",{className:"icon-download"}),q?o.ZP.createElement("span",{className:"message-transfer-progress"},D||v?`${Math.round(100*j)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},P.isGif?"GIF":(0,N.k9)(Math.max(W-V,0))))};var da=n(6272);const ua=(0,a.c$)(((e,t)=>{let{contact:n}=t;const{countryList:{phoneCodes:a}}=e;return{user:(0,r.dy)(e,n.userId),phoneCodeList:a}}))((e=>{let{contact:t,user:n,phoneCodeList:s}=e;const{openUserInfo:i}=(0,a.uC)(),{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,ue.Z)("Contact",Boolean(d)&&"interactive"),onClick:d?u:void 0},o.ZP.createElement(on.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,da.WZ)(s,l))))}));var ma=n(8974),ha=n(1218),ga=n(4434),fa=n(6937);function pa(e,t){return t>0?(e/t*100).toFixed():0}const va=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?pa(c.votersCount,a||0):0,[m,h]=(0,o.eJ)(r?0:u),g=(0,o.sO)(null),f=c?pa(c.votersCount,s||0):0,p=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=p?"":"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>`}}),[p,r]),!n||!c)return;const v=`width: ${f}%; transform:scaleX(${p?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,ue.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,tn.Z)(t.text)),o.ZP.createElement("div",{className:(0,ue.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}))))},Ia=(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.uC)(),{id:u,chatId:m}=t,{summary:h,results:g}=n,[f,p]=(0,o.eJ)(!1),[v,I]=(0,o.eJ)([]),[y,Z]=(0,o.eJ)(!1),[P,C]=(0,o.eJ)(!1),[w,b]=(0,o.eJ)(!h.closed&&h.closeDate&&h.closeDate>0?Math.min(h.closeDate-Math.floor(Date.now()/1e3)+c,h.closePeriod):0),E=(0,o.sO)(null),{results:S,totalVoters:M}=g,R=S&&S.some((e=>e.isChosen)),k=!h.closed&&!R,T=!k&&h.isPublic&&Number(g.totalVoters)>0,B=k&&h.multipleChoice,x=S?Math.max(...S.map((e=>e.votersCount))):M,A=S?S.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],L=h.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(h.quiz&&h.closePeriod&&w<=0)})));(0,o.d4)((()=>{f&&n.results.results&&n.results.results.some((e=>e.isChosen))&&p(!1)}),[f,n.results.results]),(0,o.d4)((()=>{w>0&&setTimeout((()=>b(w-1)),1e3);const e=E.current;if(e){const t=12*Math.PI,n=e.lastElementChild,a=e.firstElementChild;if(w<=5&&e.classList.add("hurry-up"),n&&a){const e=(h.closePeriod-w)/h.closePeriod*t;a.textContent=(0,N.k9)(w),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,N.k9)(w)}</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>`}}),[w,h.closePeriod]),(0,o.d4)((()=>{h.quiz&&(w<=0||R&&!h.closed)&&l({chatId:m,messageId:u})}),[m,w,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]),p(!0),C(!0),r([e])}),[r]),F=(0,o.I4)((e=>{I(e)}),[]),$=(0,o.I4)((()=>{p(!0),C(!0),r(v)}),[r,v]),D=(0,o.I4)((()=>{d({chatId:m,messageId:u})}),[m,u,d]),q=(0,o.I4)((()=>{Z(!0)}),[]),j=(0,o.I4)((()=>{Z(!1),C(!1)}),[]);(0,o.d4)((()=>{P&&R&&h.quiz&&g.results&&n.results.solution&&(g.results.find((e=>e.isChosen&&e.isCorrect))||Z(!0))}),[R,P,g.results,h.quiz,n.results.solution]);const Q=(0,Le.Z)();return o.ZP.createElement("div",{className:"Poll",dir:Q.isRtl?"auto":"ltr"},y&&n.results.solution&&o.ZP.createElement(fa.Z,{message:(0,ma.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:j,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,tn.Z)(h.question,["emoji","br"])),o.ZP.createElement("div",{className:"poll-type"},Q(function(e){return void 0===e.isPublic?" ":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.closed?"FinalResults":e.isPublic?"PublicPoll":"AnonymousPoll"}(h)),O.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},O.map((e=>o.ZP.createElement(on.Z,{size:"micro",user:e})))),w>0&&k&&o.ZP.createElement("div",{ref:E,className:"poll-countdown"}),h.quiz&&n.results.solution&&!k&&o.ZP.createElement(Qe.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:y,onClick:q,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),k&&o.ZP.createElement("div",{className:"poll-answers"},B?o.ZP.createElement(ha.Z,{options:L,onChange:F,disabled:t.isScheduled||f,loadingOptions:f?v:void 0,round:!0}):o.ZP.createElement(ga.Z,{name:`poll-${u}`,options:L,onChange:U,disabled:t.isScheduled||f,loadingOption:f?v[0]:void 0})),!k&&o.ZP.createElement("div",{className:"poll-results"},h.answers.map((function(e){return o.ZP.createElement(va,{key:e.option,shouldAnimate:P,answer:e,voteResults:S,totalVoters:M,maxVotersCount:x,correctResults:A})}))),!T&&!B&&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")}(Q,h.quiz,g.totalVoters)),B&&o.ZP.createElement(Qe.Z,{isText:!0,disabled:0===v.length,size:"tiny",onClick:$},Q("PollSubmitVotes")),T&&o.ZP.createElement(Qe.Z,{isText:!0,size:"tiny",onClick:D},Q("PollViewResults")))})));var ya=n(8035),Za=n(88);const Pa=(0,o.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,inPreview:r,lastSyncTime:c,isDownloading:d=!1,isProtected:u,theme:m,onMediaClick:h,onCancelMediaTransfer:g}=e;const f=(0,l.s1)(t);let p=!1;if(null!=f&&f.photo&&!f.video){const{width:e,height:n}=bn(t);p=e===n}const v=(0,o.I4)((()=>{h()}),[h]);if(!f)return;const{siteName:I,url:y,displayUrl:Z,title:P,description:C,photo:w,video:b}=f,E=(w||b)&&h&&!p,S=(0,ya.Z)(C,170),M=(0,ue.Z)("WebPage",p&&"with-square-photo",!w&&!b&&!r&&"without-media",b&&"with-video");return o.ZP.createElement("div",{className:M,"data-initial":(I||Z)[0],dir:"auto"},w&&!b&&o.ZP.createElement(sa,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,size:p?"pictogram":"inline",nonInteractive:!E,onClick:E?v:void 0,onCancelUpload:g,isDownloading:d,isProtected:u,theme:m}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Za.Z,{className:"site-name",url:y,text:I||Z}),!r&&P&&o.ZP.createElement("p",{className:"site-title"},(0,tn.Z)(P)),S&&o.ZP.createElement("p",{className:"site-description"},(0,tn.Z)(S,["emoji","br"]))),!r&&b&&o.ZP.createElement(la,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,lastSyncTime:c,onClick:E?v:void 0,onCancelUpload:g,isDownloading:d,isProtected:u}))}));var Ca=n(9937);const wa=(0,o.X$)((e=>{let{message:t}=e;const n=(0,Le.Z)(),a=(0,l.eO)(t),{title:s,text:i,amount:r,currency:c,isTest:d,photoUrl:u}=a;return o.ZP.createElement("div",{className:"Invoice"},s&&o.ZP.createElement("p",{className:"title"},(0,tn.Z)(s)),i&&o.ZP.createElement("p",null,(0,tn.Z)(i,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(u?"has-image":"")},u&&o.ZP.createElement("img",{className:"invoice-image",src:u,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,Ca.x)(r,c,n.code),d&&o.ZP.createElement("span",null,n("PaymentTestInvoice")))))}));function ba(e){return(0,o.X$)((0,a.c$)(((e,t)=>{const{message:n}=t;return{isInSelectMode:(0,r.CA)(e),isSelected:(0,r.vk)(e,n.id)}}))((t=>{const{isInSelectMode:n,isSelected:s,message:i,dimensions:r}=t,{toggleMessageSelection:c}=(0,a.uC)(),l=(0,o.I4)((e=>{e.stopPropagation(),c({messageId:i.id,withShift:null==e?void 0:e.shiftKey})}),[c,i]),d=(0,o.Ye)((()=>({...t,isInSelectMode:n,isSelected:s,dimensions:{...t.dimensions,x:0,y:0},onClick:n?void 0:t.onClick})),[t,n,s]);return o.ZP.createElement("div",{className:(0,ue.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 Ea=ba(sa),Sa=ba(la),Ma=(0,a.c$)(((e,t)=>{let{album:n}=t;const{chatId:a}=n.mainMessage,s=(0,r.Pu)(e),o=(0,r.xs)(e,a);return{theme:s,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:o}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:s,lastSyncTime:i,isOwn:c,isProtected:d,albumLayout:u,onMediaClick:m,uploadsById:h,activeDownloadIds:g,theme:f}=e;const{cancelSendingMessage:p}=(0,a.uC)(),v=t.messages.length,I=(0,o.I4)((e=>{p({chatId:e.chatId,messageId:e.id})}),[p]),{width:y,height:Z}=u.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${y}px; height: ${Z}px;`},t.messages.map((function(e,t){const{photo:p,video:y}=(0,l.qp)(e),Z=h[e.previousLocalId||e.id],P=null==Z?void 0:Z.progress,{dimensions:C,sides:w}=u.layout[t],b=(0,r.bH)((0,a.Rd)(),e),E=(0,r.__)((0,a.Rd)(),e);if(p){const a=s&&(c?t===v-1:Boolean(8&w&&4&w));return o.ZP.createElement(Ea,{id:`album-media-${e.id}`,message:e,observeIntersection:n,canAutoLoad:b,shouldAffectAppendix:a,uploadProgress:P,dimensions:C,isProtected:d,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:f})}if(y)return o.ZP.createElement(Sa,{id:`album-media-${e.id}`,message:e,observeIntersection:n,canAutoLoad:b,canAutoPlay:E,uploadProgress:P,lastSyncTime:i,dimensions:C,isProtected:d,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:f})})))}));function Ra(){return Ra=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},Ra.apply(this,arguments)}let ka;const Ta=e=>{let{message:t,observeIntersection:n,canAutoLoad:s,lastSyncTime:i,isDownloading:r}=e;const c=(0,o.sO)(null),d=(0,o.sO)(null),m=(0,o.sO)(null),h=t.content.video,g=(0,In.Op)(c,n),[f,p]=(0,o.eJ)(s),v=Boolean(f&&g&&i),{mediaData:I,loadProgress:y}=(0,Jn.Z)((0,l.Ti)(t,"inline"),!v,(0,l.kG)(t,"inline"),i),{loadProgress:Z}=(0,Jn.Z)((0,l.Ti)(t,"download"),!r,u.IU.BlobUrl,i),P=ta(t,I),{isBuffered:w,bufferingHandlers:b}=(0,oa.Z)(),E=f&&!w||r,S=!1===(0,Et.Z)(f),M=(0,Xn.Z)(I),{shouldRender:R,transitionClassNames:k}=(0,pe.Z)(E||!w,void 0,S),[T,B]=(0,o.eJ)(!1),[x,A]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!T)return;const e=At.Rj/2,t=2*(e-6)*Math.PI,n=t-x*t,a=m.current,s=d.current,o=s.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):s.innerHTML=`\n <svg width="${At.Rj}px" height="${At.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)}),[T,x]);const L=Boolean(I&&g),O=()=>{B(!1),A(0),(0,Yn.Z)(m.current),(0,C.T2)((()=>{d.current.innerHTML=""}))},U=(F=O,()=>{ka&&ka(),ka=F});var F;(0,o.d4)((()=>{m.current&&(L?(0,Yn.Z)(m.current):m.current.pause())}),[L]),ra(m,L),(0,ia.Z)(m,[I]);const $=(0,o.I4)((()=>{if(!I)return void p((e=>!e));if(r)return void(0,a.uC)().cancelMessageMediaDownload({message:t});const e=m.current;T?e.paused?((0,Yn.Z)(e),(0,Gt.Es)()):e.pause():(U(),e.pause(),e.currentTime=0,(0,Yn.Z)(e),(0,Gt.Es)(),B(!0))}),[U,T,r,I,t]),D=(0,o.I4)((e=>{const t=e.currentTarget;A(t.currentTime/t.duration)}),[]),q=(0,ue.Z)("full-media",M);return o.ZP.createElement("div",{ref:c,className:"RoundVideo media-inner",onClick:$},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:P,className:"thumbnail",style:`width: ${At.Rj}px; height: ${At.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",Ra({ref:m,className:q,width:At.Rj,height:At.Rj,autoPlay:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?O:void 0},b,{onTimeUpdate:T?D:void 0}),o.ZP.createElement("source",{src:I}))),o.ZP.createElement("div",{className:"progress",ref:d}),R&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(aa.Z,{progress:r?Z:y})),!I&&!f&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},T?(0,N.k9)(m.current.currentTime):(0,N.k9)(h.duration),(!T||m.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},Na=e=>{let{message:t,onClick:n}=e;const a=(0,Le.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Qe.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>n({button:e})},(0,tn.Z)(a(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(s.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},Ba=(0,o.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:s}=(0,a.uC)(),i=(0,Le.Z)(),{threadId:r,chatId:c,messagesCount:d,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h}=t,g=(0,o.I4)((()=>{s({id:c,threadId:r})}),[s,c,r]),f=(0,o.Ye)((()=>{if(null==h||!h.length)return;const{users:{byId:e},chats:{byId:t}}=(0,a.Rd)();return h.map((n=>(0,l.YC)(n)?e[n]:t[n])).filter(Boolean)}),[h]);if(void 0===d)return;const p=Boolean(m&&u&&m<u);return o.ZP.createElement("div",{"data-cnt":(0,Se.bi)(d),className:(0,ue.Z)("CommentButton",p&&"has-unread",n&&"disabled"),dir:i.isRtl?"rtl":"ltr",onClick:g},o.ZP.createElement("i",{className:"icon-comments-sticker"}),(!f||0===f.length)&&o.ZP.createElement("i",{className:"icon-comments"}),f&&f.length>0&&o.ZP.createElement("div",{className:"recent-repliers",dir:i.isRtl?"rtl":"ltr"},f.map((e=>o.ZP.createElement(on.Z,{key:e.id,size:"small",user:(0,l.YC)(e.id)?e:void 0,chat:(0,l.YC)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},d?i("Comments",d,"i"):i("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))})),xa=(0,o.X$)((e=>{let{reaction:t,message:n,activeReaction:s,availableReactions:i}=e;const{sendReaction:r}=(0,a.uC)(),{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(Qe.Z,{className:(0,ue.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},o.ZP.createElement(zn,{activeReaction:s,reaction:t.reaction,availableReactions:i}),null!=l&&l.length?o.ZP.createElement("div",{className:"avatars"},l.map((e=>o.ZP.createElement(on.Z,{user:e,size:"micro"})))):(0,Se.bi)(t.count))})),Aa=(0,o.X$)((e=>{let{message:t,isOutside:n,activeReaction:a,availableReactions:s,metaChildren:i}=e;return o.ZP.createElement("div",{className:(0,ue.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>o.ZP.createElement(xa,{key:e.reaction,reaction:e,message:t,activeReaction:a,availableReactions:s}))),i)}));var La=n(7324),Oa=n(5296);const Ua=(0,o.X$)((e=>{let{localSticker:t,localEffect:n,isOwn:a,soundId:s,size:i="medium",observeIntersection:r,messageId:c,chatId:l,activeEmojiInteraction:d}=e;const{playKey:u,ref:m,style:h,width:g,handleClick:f,markAnimationLoaded:p}=(0,Oa.Z)(i,l,c,s,d,a,n),v=`local_emoji_${t}`,I=(0,In.Op)(m,r),[y,Z]=(0,o.eJ)();return(0,o.d4)((()=>{t&&(0,La.Z)(t).then((e=>{Z(e)}))}),[t]),o.ZP.createElement("div",{ref:m,className:"AnimatedEmoji media-inner",style:h,onClick:f},y&&o.ZP.createElement(_n.Z,{key:v,id:v,animationData:y,size:g,quality:1,play:I&&u,forceOnHeavyAnimation:!0,noLoop:!0,onLoad:p}))})),Fa={__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>'},$a={__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>'},Da=(0,o.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:n,forwardMessages:a,lastSyncTime:s}=e,{message:o,album:i,withSenderName:c,withAvatar:d,threadId:u,messageListType:m,isLastInDocumentGroup:h}=t,{id:g,chatId:f,viaBotId:p,replyToChatId:v,replyToMessageId:I,isOutgoing:y,threadInfo:Z}=o,P=(0,r.Z1)(e,f),C=(0,r.FM)(e,f),w=(0,l.pK)(f),b=P&&(0,l.eA)(P),E=null==P?void 0:P.username,S=!C&&(0,l.Ul)(o),M=c||d||S,R=(0,r.Ur)(e,o),k=(0,r.cv)(e,o),T=p?(0,r.dy)(e,p):void 0,N=u?(0,r.qS)(e,f,u):void 0,B=o.id===N,x=I===N,A=I&&!x?(0,r.hj)(e,w&&v?v:f,I):void 0,L=A&&(0,r.Ur)(e,A),O=(0,r.uZ)(e,o),U="thread"===m&&(i?i.messages.some((t=>(0,r._X)(e,t))):(0,r._X)(e,o)),{direction:F,noHighlight:$,isResizingContainer:D}=U&&n||{},q=a.messageIds&&a.messageIds.includes(g),{query:j}=(0,r.n5)(e)||{},Q=(0,l._O)(o);let G;G=null!=i&&i.messages?i.messages.every((t=>{let{id:n}=t;return(0,r.vk)(e,n)})):(0,r.vk)(e,g);const{canReply:H}="thread"===m&&(0,r._k)(e,o,u)||{},_=(0,r.te)(e,o),z=Z?(0,r.tZ)(e,Z.chatId,Z.threadId)||Z:void 0,V=Boolean(o.groupedId)&&!o.isInAlbum,X=V?(0,r.xH)(e,f,o.groupedId)[0]:void 0,Y=V?h?(0,r.hj)(e,f,X):void 0:o,W=Q?(0,r.CP)(e,Q):void 0;return{theme:(0,r.Pu)(e),chatUsername:E,forceSenderName:S,sender:M?R:void 0,originSender:k,botSender:T,shouldHideReply:x,isThreadTop:B,replyMessage:A,replyMessageSender:L,isInDocumentGroup:V,isProtected:(0,r.EV)(e,o),isFocused:U,isForwarding:q,reactionMessage:Y,isChatWithSelf:C,isRepliesChat:w,isChannel:b,canReply:H,lastSyncTime:s,highlight:j,isSingleEmoji:Boolean(Q),animatedEmoji:Q?(0,r.zB)(e,Q):void 0,animatedEmojiEffect:Q&&(0,l.YC)(f)?(0,r.tH)(e,Q):void 0,animatedEmojiSoundId:Q?(0,r.Oh)(e,Q):void 0,localSticker:W,localEffect:W&&(0,l.YC)(f)?(0,r.cu)(W):void 0,isInSelectMode:(0,r.CA)(e),isSelected:G,isGroupSelected:Boolean(o.groupedId)&&!o.isInAlbum&&(0,r.a6)(e,f,o.groupedId),threadId:u,isDownloading:_,isPinnedList:"pinned"===m,canAutoLoadMedia:(0,r.bH)(e,o),canAutoPlayMedia:(0,r.__)(e,o),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,r.yB)(e),threadInfo:z,availableReactions:e.availableReactions,defaultReaction:(0,r.q6)(e,f),activeReaction:e.activeReactions[g],activeEmojiInteraction:e.activeEmojiInteraction,...y&&{outgoingStatus:(0,r.dT)(e,o,"scheduled"===m)},..."number"==typeof O&&{uploadProgress:O},...U&&{focusDirection:F,noFocusHighlight:$,isResizingContainer:D}}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:s,observeIntersectionForMedia:i,observeIntersectionForAnimatedStickers:r,album:c,noAvatars:d,withAvatar:g,withSenderName:f,areReactionsInMeta:p,noComments:v,appearanceOrder:I,isFirstInGroup:y,isLastInGroup:Z,isFirstInDocumentGroup:P,isLastInDocumentGroup:C,isLastInList:w,theme:b,forceSenderName:E,sender:S,originSender:M,botSender:R,isThreadTop:k,shouldHideReply:T,replyMessage:N,replyMessageSender:B,outgoingStatus:x,uploadProgress:A,isInDocumentGroup:L,isProtected:O,isFocused:U,focusDirection:F,noFocusHighlight:$,isResizingContainer:D,isForwarding:q,isChatWithSelf:j,isRepliesChat:Q,isChannel:G,canReply:H,lastSyncTime:_,highlight:z,animatedEmoji:V,localSticker:X,localEffect:Y,animatedEmojiEffect:W,animatedEmojiSoundId:K,isInSelectMode:J,isSelected:ee,isGroupSelected:te,threadId:ne,reactionMessage:ae,availableReactions:se,defaultReaction:oe,activeReaction:ie,activeEmojiInteraction:re,messageListType:ce,isPinnedList:le,isDownloading:de,canAutoLoadMedia:me,canAutoPlayMedia:he,shouldLoopStickers:ge,autoLoadFileMaxSizeMb:fe,threadInfo:ve}=e;const{toggleMessageSelection:Ie,clickInlineButton:ye,disableContextMenuHint:Ze}=(0,a.uC)(),Pe=(0,o.sO)(null),Ce=(0,o.sO)(null),we=(0,o.sO)(null),be=(0,Le.Z)();(0,In._N)(Ce,s);const{isContextMenuOpen:Ee,contextMenuPosition:Se,handleBeforeContextMenu:Me,handleContextMenu:Re,handleContextMenuClose:ke,handleContextMenuHide:Te}=(0,Pn.Z)(Pe,h.$b&&J,!0,h.wZ);(0,o.d4)((()=>{Ee&&Ze()}),[Ee,Ze]);const Ne=I<=0,[Be,Ae]=(0,xe.Z)(Ne);(0,o.d4)((()=>{Ne||setTimeout(Ae,10*I)}),[I,Ae,Ne]);const{transitionClassNames:Oe}=(0,pe.Z)(Be,void 0,Ne,!1),{id:Ue,chatId:Fe,forwardInfo:$e,viaBotId:De}=t,qe=(0,l.CI)(t),je=(0,l.B4)(t),Ge="scheduled"===ce||t.isScheduled,He=(0,l.ss)(t)&&!T,_e=Boolean(ve)&&"thread"===ce,ze=(0,l.$D)(t),Ve=X||V,Xe=(null==ae?void 0:ae.reactions)&&!(0,l.JE)(ae.reactions),Ye=$e&&(!j||Ge)&&!Q&&!$e.isLinkedChannelPost&&!ze,We=Boolean(c)&&c.messages.length>1,Ke=L&&!P,Je=L&&!C,et=void 0!==Se,tt=!(et||J||q||Je),nt=G&&!Ge,at=Boolean(le||$e&&($e.isChannelPost||j&&!je||Q)&&$e.fromMessageId),st=ve&&!Je&&"thread"===ce&&!v,ot=!h.$b&&oe&&!Je,it=(0,o.I4)(((e,t)=>{Ie({messageId:Ue,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...We&&{childMessageIds:c.messages.map((e=>{let{id:t}=e;return t}))}})}),[Ie,Ue,We,c]),rt=$e&&(j||Q||!S)?M:S,ct=$e?M:S,{handleMouseDown:lt,handleClick:dt,handleContextMenu:ut,handleDoubleClick:mt,handleContentDoubleClick:ht,handleMouseMove:gt,handleSendQuickReaction:ft,handleMouseLeave:pt,isSwiped:vt,isQuickReactionVisible:It,handleDocumentGroupMouseEnter:yt}=Ln(it,Pe,Ue,0,Boolean(J),Boolean(H),Boolean(O),Re,Me,Fe,et,we,je,Je),{handleAvatarClick:Zt,handleSenderClick:Pt,handleViaBotClick:Ct,handleReplyClick:wt,handleMediaClick:bt,handleAudioPlay:Et,handleAlbumMediaClick:St,handleMetaClick:Mt,handleReadMedia:kt,handleCancelUpload:Tt,handleVoteSend:Nt,handleGroupForward:Bt,handleForward:xt,handleFocus:Lt,handleFocusForwarded:Ot,handleDocumentGroupSelectAll:Ut}=function(e,t,n,s,i,r,c,d,h,g,f,p,v){const{openUserInfo:I,openChat:y,showNotification:Z,focusMessage:P,openMediaViewer:C,openAudioPlayer:w,markMessagesRead:b,cancelSendingMessage:E,sendPollVote:S,openForwardMenu:M,focusMessageInComments:R}=(0,a.uC)(),{id:k,forwardInfo:T,replyToMessageId:N,replyToChatId:B,replyToTopMessageId:x,groupedId:A}=n,L=(0,o.I4)((()=>{f&&((0,l.YC)(f.id)?I({id:f.id}):y({id:f.id}))}),[f,I,y]),O=(0,o.I4)((()=>{p?c&&null!=T&&T.channelPostId?P({chatId:p.id,messageId:T.channelPostId}):(0,l.YC)(p.id)?I({id:p.id}):y({id:p.id}):Z({message:e("HidAccount")})}),[c,P,T,e,y,I,p,Z]),U=(0,o.I4)((()=>{v&&I({id:v.id})}),[v,I]),F=(0,o.I4)((()=>{P({chatId:h&&B?B:s,threadId:i,messageId:N,replyMessageId:h&&B?void 0:k})}),[P,h,B,s,i,N,k]),$=(0,o.I4)((()=>{C({chatId:s,threadId:i,messageId:k,origin:d?m.bZ.ScheduledInline:m.bZ.Inline})}),[s,i,k,C,d]),D=(0,o.I4)((()=>{w({chatId:s,messageId:k})}),[s,k,w]),q=(0,o.I4)((e=>{C({chatId:s,threadId:i,messageId:e,origin:d?m.bZ.ScheduledAlbum:m.bZ.Album})}),[s,i,C,d]),j=(0,o.I4)((()=>{b({messageIds:[k]})}),[k,b]),Q=(0,o.I4)((()=>{E({chatId:s,messageId:k})}),[E,s,k]),G=(0,o.I4)((e=>{S({chatId:s,messageId:k,options:e})}),[s,k,S]),H=(0,o.I4)((()=>{M({fromChatId:s,groupedId:A})}),[M,s,A]),_=(0,o.I4)((()=>{if(g&&g.messages){const e=g.messages.map((e=>{let{id:t}=e;return t}));M({fromChatId:s,messageIds:e})}else M({fromChatId:s,messageIds:[k]})}),[g,M,s,k]),z=(0,o.I4)((()=>{P({chatId:s,threadId:u._f,messageId:k})}),[P,s,k]),V=(0,o.I4)((()=>{r?P({chatId:T.fromChatId,groupedId:A,groupedChatId:s}):h&&B?R({chatId:B,threadId:x,messageId:T.fromMessageId}):P({chatId:T.fromChatId,messageId:T.fromMessageId})}),[r,h,B,P,T,A,s,R,x]),X=(0,o.I4)((e=>{e.stopPropagation(),t(e,A)}),[t,A]);return{handleAvatarClick:L,handleSenderClick:O,handleViaBotClick:U,handleReplyClick:F,handleMediaClick:$,handleAudioPlay:D,handleAlbumMediaClick:q,handleMetaClick:X,handleReadMedia:j,handleCancelUpload:Q,handleVoteSend:G,handleGroupForward:H,handleForward:_,handleFocus:z,handleFocusForwarded:V,handleDocumentGroupSelectAll:X}}(be,it,t,Fe,ne,L,Ye,Ge,Q,c,rt,ct,R),Ft=(0,ue.Z)("Message message-list-item",y&&"first-in-group",O&&"is-protected",Z&&"last-in-group",P&&"first-in-document-group",C&&"last-in-document-group",w&&"last-in-list",je&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",He&&"has-reply",et&&"has-menu-open",U&&!$&&"focused",q&&"is-forwarding",t.isDeleting&&"is-deleting",L&&"is-in-document-group",We&&"is-album",t.hasUnreadMention&&"has-unread-mention",ee&&"is-selected",J&&"is-in-selection-mode",k&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",vt&&"is-swiped",Oe,Boolean(ie)&&"has-active-reaction"),$t=function(e){let{hasReply:t,customShape:n,isLastInGroup:a,asForwarded:s,hasThread:o,forceSenderName:i,hasComments:r,hasActionButton:c,hasReactions:d}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:u,photo:m,video:h,audio:g,voice:f,document:p,poll:v,webPage:I,contact:y}=(0,l.qp)(e),Z=["message-content"],P=m||h,C=P&&!u,w=Boolean(e.viaBotId);return Cn(n)?Z.push(`emoji-only emoji-only-${n}`):u&&Z.push("text"),c&&Z.push("has-action-button"),n&&(Z.push("custom-shape"),null!=h&&h.isRound&&Z.push("round"),r&&Z.push("has-comments")),m||h?Z.push("media"):g?Z.push("audio"):f?Z.push("voice"):p?Z.push("document"):y?Z.push("contact"):v?Z.push("poll"):I&&(Z.push("web-page"),(I.photo||I.video)&&Z.push("media")),s&&Z.push("is-forwarded"),t&&Z.push("is-reply"),o&&Z.push("has-replies"),d&&Z.push("has-reactions"),w&&Z.push("is-via-bot"),i&&Z.push("force-sender-name"),n||(Z.push("has-shadow"),P&&r&&Z.push("has-background"),(t||s||!C||w||i)&&Z.push("has-solid-background"),!a||!m&&C||Z.push("has-appendix")),Z.join(" ")}(t,{hasReply:He,customShape:ze,isLastInGroup:Z,asForwarded:Ye,hasThread:_e,forceSenderName:E,hasComments:ve&&(null==ve?void 0:ve.messagesCount)>0,hasActionButton:nt||at,hasReactions:Xe}),qt=$t.includes("has-appendix"),jt=(0,Dt.X)(t,z,Cn(ze)),{text:Qt,photo:Gt,video:Ht,audio:_t,voice:zt,document:Vt,sticker:Xt,contact:Yt,poll:Wt,webPage:Kt,invoice:Jt}=(0,l.qp)(t);let en,nn;en=Je?"none":!jt||Ve||Kt?"standalone":"in-text",p?nn="in-meta":Xe?ze||(Gt||Ht||Ve)&&!jt?nn="outside":Ye?(en="standalone",nn="inside"):nn="inside":nn="none",(0,Rt.Z)(Q&&t.replyToChatId?t.replyToChatId:Fe,He?t.replyToMessageId:void 0,N,t.id),Nn(Pe,Fe,U,F,$,D);let an,sn="",rn=!1;const cn=(0,o.Ye)((()=>We?Rn(je,Boolean(Ye),Boolean(d),c):void 0),[We,je,Ye,d,c]),ln=Ye?28:0;if(We||!Gt&&!Ht)cn&&(an=Math.max(wn(Boolean(Qt),st),cn.containerStyle.width),an-cn.containerStyle.width>18&&(rn=!0));else{let e;Gt?e=bn(t,d).width:Ht&&(e=Ht.isRound?At.Rj:bn(t,d).width),e&&(an=Math.max(wn(Boolean(Qt),st),e),an-e>18&&(rn=!0))}an&&(sn=`width: ${an+ln}px`);const dn=G&&t.adminTitle||!Ye&&(null==$e?void 0:$e.adminTitle)||void 0,un=(0,o.Ye)((()=>dn?Tn(dn):void 0),[dn]);function mn(){const e=o.ZP.createElement(Vn,{message:t,outgoingStatus:x,signature:dn,withReactions:"in-meta"===nn,withReactionOffset:"inside"===nn,availableReactions:se,activeReaction:ie,onClick:Mt});return"inside"!==nn?e:o.ZP.createElement(Aa,{activeReaction:ie,message:ae,metaChildren:e,availableReactions:se})}return o.ZP.createElement("div",{ref:Pe,id:`message${Ue}`,className:Ft,style:un?`--meta-safe-author-width: ${un}px`:void 0,"data-message-id":Ue,onMouseDown:lt,onClick:dt,onContextMenu:ut,onDoubleClick:mt,onMouseEnter:Je?yt:void 0,onMouseMove:ot?gt:void 0,onMouseLeave:ot||Je?pt:void 0},o.ZP.createElement("div",{ref:Ce,className:"bottom-marker","data-message-id":Ue,"data-last-message-id":c?c.messages[c.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention}),!L&&o.ZP.createElement("div",{className:"message-select-control"},ee&&o.ZP.createElement("i",{className:"icon-select"})),C&&o.ZP.createElement("div",{className:(0,ue.Z)("message-select-control group-select",te&&"is-selected"),onClick:Ut},te&&o.ZP.createElement("i",{className:"icon-select"})),g&&function(){const e=rt&&(0,l.YC)(rt.id),t=rt&&e?rt:void 0,n=rt&&!e?rt:void 0,a=!rt&&$e?$e.hiddenUserName:void 0;return o.ZP.createElement(on.Z,{size:"small",user:t,chat:n,text:a,lastSyncTime:_,onClick:t||n?Zt:void 0})}(),o.ZP.createElement("div",{className:(0,ue.Z)("message-content-wrapper",$t.includes("text")&&"can-select-text")},o.ZP.createElement("div",{ref:we,className:$t,style:sn,dir:"auto"},Ye&&!Ke&&o.ZP.createElement("div",{className:"message-title"},be("ForwardedMessage")),function(){const e=(0,ue.Z)("content-inner",Ye&&"forwarded-message",He&&"reply-message",rn&&"no-media-corners"),n=Z&&!jt&&!Ye&&!_e,a=(0,ue.Z)("text-content","in-text"===en&&"with-meta",x&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:ht,dir:"auto"},function(){if(ze&&!De||!(f&&!Gt&&!Ht||Ye||De||E)||Ke||He&&ze)return;let e,n;return!ct||ze&&De?null!=$e&&$e.hiddenUserName&&(e=$e.hiddenUserName):(e=(0,l.OU)(be,ct),Ye||(n=`color-${(0,l.Rs)(ct)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?o.ZP.createElement("span",{className:(0,ue.Z)("interactive",n),onClick:Pt,dir:"auto"},(0,tn.Z)(e)):R?void 0:" ",R&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},be("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:Ct},(0,tn.Z)(`@${R.username}`))),null!=$e&&$e.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},be("DiscussChannel")):t.adminTitle&&!G?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.adminTitle):void 0)}(),He&&o.ZP.createElement(qn,{message:N,isProtected:O,sender:B,observeIntersection:i,onClick:wt}),Xt&&o.ZP.createElement(Wn,{message:t,observeIntersection:i,observeIntersectionForPlaying:r,shouldLoop:ge,lastSyncTime:_}),V&&o.ZP.createElement(Kn.Z,{size:"small",isOwn:je,sticker:V,effect:W,soundId:K,observeIntersection:i,lastSyncTime:_,forceLoadPreview:qe,messageId:Ue,chatId:Fe,activeEmojiInteraction:re}),X&&o.ZP.createElement(Ua,{size:"small",isOwn:je,localSticker:X,localEffect:Y,soundId:K,observeIntersection:i,lastSyncTime:_,forceLoadPreview:qe,messageId:Ue,chatId:Fe,activeEmojiInteraction:re}),We&&o.ZP.createElement(Ma,{album:c,albumLayout:cn,observeIntersection:i,isOwn:je,isProtected:O,hasCustomAppendix:n,lastSyncTime:_,onMediaClick:St}),!We&&Gt&&o.ZP.createElement(sa,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:me,uploadProgress:A,shouldAffectAppendix:n,onClick:bt,onCancelUpload:Tt,isDownloading:de,isProtected:O,theme:b}),!We&&Ht&&Ht.isRound&&o.ZP.createElement(Ta,{message:t,observeIntersection:i,canAutoLoad:me,lastSyncTime:_,isDownloading:de}),!We&&Ht&&!Ht.isRound&&o.ZP.createElement(la,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:me,canAutoPlay:he,uploadProgress:A,lastSyncTime:_,onClick:bt,onCancelUpload:Tt,isDownloading:de,isProtected:O}),(_t||zt)&&o.ZP.createElement(Qn.Z,{theme:b,message:t,origin:m.Cr.Inline,uploadProgress:A,lastSyncTime:_,isSelectable:L,isSelected:ee,onPlay:Et,onReadMedia:!zt||je&&!j?void 0:kt,onCancelUpload:Tt,isDownloading:de}),Vt&&o.ZP.createElement(jn.Z,{message:t,observeIntersection:i,canAutoLoad:me,autoLoadFileMaxSizeMb:fe,uploadProgress:A,isSelectable:L,isSelected:ee,onMediaClick:bt,onCancelUpload:Tt,isDownloading:de}),Yt&&o.ZP.createElement(ua,{contact:Yt}),Wt&&o.ZP.createElement(Ia,{message:t,poll:Wt,onSendVote:Nt}),!Ve&&jt&&o.ZP.createElement("p",{className:a,dir:"auto"},jt,"in-text"===en&&mn()),Kt&&o.ZP.createElement(Pa,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:me,canAutoPlay:he,lastSyncTime:_,onMediaClick:bt,onCancelMediaTransfer:Tt,isDownloading:de,isProtected:O,theme:b}),Jt&&o.ZP.createElement(wa,{message:t}))}(),!Je&&"standalone"===en&&mn(),tt&&nt?o.ZP.createElement(Qe.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:be("lng_context_forward_msg"),onClick:C?Bt:xt},o.ZP.createElement("i",{className:"icon-share-filled"})):tt&&at?o.ZP.createElement(Qe.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:le?Lt:Ot},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,st&&o.ZP.createElement(Ba,{threadInfo:ve,disabled:v}),qt&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:je?Fa:$a}),ot&&o.ZP.createElement("div",{className:(0,ue.Z)("quick-reaction",It&&!ie&&"visible"),onClick:ft},o.ZP.createElement(Hn.Z,{reaction:oe}))),t.inlineButtons&&o.ZP.createElement(Na,{message:t,onClick:ye}),"outside"===nn&&o.ZP.createElement(Aa,{message:ae,isOutside:!0,activeReaction:ie,availableReactions:se})),Se&&o.ZP.createElement($n,{isOpen:Ee,anchor:Se,message:t,album:c,chatUsername:n,messageListType:ce,onClose:ke,onCloseAnimationEnd:Te}))}))),qa=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,r.fS)(e,n),{chatId:s,isBot:o}=a||{};return{message:a,bot:s&&o?(0,r.dy)(e,s):void 0,channel:!o&&s?(0,r.Z1)(e,s):void 0}}))((e=>{let{chatId:t,message:n,containerRef:s,bot:i,channel:r}=e;const{viewSponsoredMessage:c,openChat:d,openChatByInvite:u,startBot:m,focusMessage:h}=(0,a.uC)(),g=(0,Le.Z)(),f=(0,o.sO)(null),p=Boolean(n),{observe:v}=(0,In.S1)({rootRef:s,debounceMs:200,threshold:1});if((0,o.d4)((()=>p?v(f.current,(e=>{e.isIntersecting&&c({chatId:t})})):void 0),[t,p,v,c]),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,tn.Z)((0,l.Js)(i)||""),r&&(0,tn.Z)(n.chatInviteTitle||(0,l.U)(g,r,i)||"")),o.ZP.createElement("p",{className:"text-content with-meta",dir:"auto",ref:f},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,ma.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(Qe.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:()=>{n.chatInviteHash?u({hash:n.chatInviteHash}):n.channelPostId?h({chatId:n.chatId,messageId:n.channelPostId}):(d({id:n.chatId}),n.startParam&&m({botId:n.chatId,param:n.startParam}))},className:"SponsoredMessage__button"},g(n.isBot?"Conversation.ViewBot":n.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))))}))),ja=(0,o.X$)((e=>{let{chatId:t,messageIds:n,messageGroups:i,isViewportNewest:r,isUnread:c,withUsers:d,areReactionsInMeta:u,noAvatars:f,containerRef:p,anchorIdRef:v,memoUnreadDividerBeforeIdRef:I,memoFirstUnreadIdRef:y,threadId:Z,type:P,isReady:w,isScrollingRef:b,isScrollPatchNeededRef:E,threadTopMessageId:S,hasLinkedChat:M,isSchedule:R,noAppearanceAnimation:k,onFabToggle:T,onNotchToggle:B}=e;const{openHistoryCalendar:x}=(0,a.uC)(),{observeIntersectionForMedia:A,observeIntersectionForReading:L,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:s,markMessagesRead:o}=(0,a.uC)(),{observe:i}=(0,In.S1)({rootRef:t,throttleMs:yn,margin:Zn}),{observe:r,freeze:c,unfreeze:l}=(0,In.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,ve.Z)(c,l);const{observe:d}=(0,In.S1)({rootRef:t,throttleMs:yn});return{observeIntersectionForMedia:i,observeIntersectionForReading:r,observeIntersectionForAnimatedStickers:d}}(P,p,y),{backwardsTriggerRef:U,forwardsTriggerRef:F,fabTriggerRef:$}=function(e,t,n,i,r,c,l,d,u,g){const{loadViewportMessages:f}=(0,a.uC)(),[p,v]=(0,o.Ye)((()=>"thread"===e?[(0,C.Ds)((()=>f({direction:m.Uq.Backwards})),1e3,!0,!1),(0,C.Ds)((()=>f({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[f,n]),I=(0,o.sO)(null),y=(0,o.sO)(null),Z=(0,o.sO)(null);function P(){if(!d)return;if(!n||!n.length)return c(!1),void l(!1);if(!i)return c(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:a,scrollTop:s}=t.current,o=Math.round(a-s-e),u=o<=1;c(r?!u:!(o<=50)),l(!u)}const{observe:w}=(0,In.S1)({rootRef:t,margin:h.gZ},(e=>{if(!v||!p)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),p()):"forwards-trigger"===a.className&&v()}));(0,In._N)(I,w),(0,In._N)(y,w);const{observe:b,freeze:E,unfreeze:S}=(0,In.S1)({rootRef:t,margin:100},P);(0,In._N)(Z,b);const{observe:M,freeze:R,unfreeze:k}=(0,In.S1)({rootRef:t,margin:1},P);return(0,In._N)(Z,M),(0,ye.Z)((()=>{d&&P()}),[d]),(0,ye.Z)((()=>{E(),R(),setTimeout((()=>{k(),S()}),250)}),[n]),{backwardsTriggerRef:I,forwardsTriggerRef:y,fabTriggerRef:Z}}(P,p,n,r,c,T,B,w,b,E),D=(0,Le.Z)(),q=o.ZP.createElement("div",{className:(0,ue.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,D("UnreadMessages"))),j=k?0:i.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let Q=0;const G=i.map(((e,t,n)=>{const a=e.senderGroups.map(((e,a,s)=>{if(1===e.length&&!un(e[0])&&(0,l.Lo)(e[0])){const i=e[0],r=a===s.length-1&&t===n.length-1;return(0,g.oA)([i.id===I.current&&q,o.ZP.createElement(Dn,{key:i.id,message:i,observeIntersection:L,appearanceOrder:j-++Q,isLastInList:r})])}let i;return(0,g.xH)(e.map(((r,c)=>{const m=un(r)?r.mainMessage:r,h=un(r)?r:void 0,p=(0,l.B4)(m),y=un(r),C=e[c+1];m.previousLocalId&&v.current===`message${m.previousLocalId}`&&(v.current=`message${m.id}`);const w=!y&&m.groupedId?m.groupedId:void 0,b=C&&!un(C)?C.groupedId:void 0,E={isFirstInGroup:0===c,isLastInGroup:c===e.length-1,isFirstInDocumentGroup:Boolean(w&&w!==i),isLastInDocumentGroup:Boolean(w&&w!==b),isLastInList:c===e.length-1&&a===s.length-1&&t===n.length-1};i=w;const R=(0,l.KK)(m),k="scheduled"!==P?R:`${m.date}_${R}`;return(0,g.oA)([m.id===I.current&&q,o.ZP.createElement(Da,{key:k,message:m,observeIntersectionForBottom:L,observeIntersectionForMedia:A,observeIntersectionForAnimatedStickers:O,album:h,noAvatars:f,withAvatar:E.isLastInGroup&&d&&!p&&!(m.id===S),withSenderName:E.isFirstInGroup&&d&&!p,areReactionsInMeta:u,threadId:Z,messageListType:P,noComments:!1===M,appearanceOrder:j-++Q,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,D("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:hn.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,ue.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:hn.q,onClick:R?void 0:()=>x({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},R&&e.originalDate===s.t4&&D("MessageScheduledUntilOnline"),R&&e.originalDate!==s.t4&&D("MessageScheduledOn",(0,N.j1)(D,e.datetime,void 0,!0)),!R&&(0,N.j1)(D,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)(G),r&&o.ZP.createElement(qa,{key:t,chatId:t,containerRef:p}),o.ZP.createElement("div",{ref:F,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:$,key:"fab-trigger",className:"fab-trigger"}))}));var Qa=n(3547);const Ga=(0,o.X$)((0,a.c$)(((e,t)=>{let{userId:n}=t;const{stickers:a}=e.stickers.greeting,s=(0,l.db)(n)+(0,l.db)(e.currentUserId),o=null!=a&&a.length?a[s%a.length]:void 0,i=(0,r.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.uC)(),l=(0,Le.Z)(),d=(0,o.sO)(null),{observe:u}=(0,In.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(Qa.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large"}))))}))),Ha=(0,o.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:a}=e;const s=(0,Le.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")))})),_a=(0,C.Ds)((e=>e()),200,!1),za=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,type:s}=t;const o=(0,r.Z1)(e,n);if(!o)return{};const i=(0,r.$W)(e,n,a,s),c="scheduled"===s?(0,r.Fn)(e,n):(0,r.Zw)(e,n),d=(0,r.qS)(e,n,a);if(a!==u._f&&!(c&&d&&c[d]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=o,f=(0,r.G$)(e,n),p=a===u._f&&!i&&!o.unreadCount&&!f&&g&&!g.groupedId,v=(0,r.IK)(e,n);let I;return(0,r.pk)(e,n)&&(I=v.fullInfo?v.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:m,restrictionReason:h,isChannelChat:(0,l.eA)(o),isGroupChat:(0,l.Bf)(o),isCreator:o.isCreator,isChatWithSelf:(0,r.FM)(e,n),isRepliesChat:(0,l.pK)(n),isBot:Boolean(v),messageIds:i,messagesById:c,firstUnreadId:(0,r.It)(e,n,a),isViewportNewest:"thread"!==s||(0,r.b9)(e,n,a),threadFirstMessageId:(0,r.yZ)(e,n,a),focusingId:f,isSelectModeActive:(0,r.CA)(e),botDescription:I,threadTopMessageId:d,hasLinkedChat:o.fullInfo&&"linkedChatId"in o.fullInfo?Boolean(o.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...p&&{lastMessage:g}}}))((e=>{var t,n,i,c,d,u;let{chatId:h,threadId:f,type:p,hasTools:v,onFabToggle:I,onNotchToggle:y,isChatLoaded:Z,isChannelChat:P,isGroupChat:w,canPost:b,isReady:E,isChatWithSelf:S,isRepliesChat:M,isCreator:R,isBot:k,messageIds:T,messagesById:N,firstUnreadId:B,isViewportNewest:x,threadFirstMessageId:A,isRestricted:L,restrictionReason:O,focusingId:U,isSelectModeActive:F,lastMessage:$,botDescription:D,threadTopMessageId:q,hasLinkedChat:j,lastSyncTime:Q,withBottomShift:G}=e;const{loadViewportMessages:H,setScrollOffset:_,loadSponsoredMessages:z,loadMessageReactions:V}=(0,a.uC)(),X=(0,o.sO)(null),Y=(0,o.sO)("thread"===p&&(0,r.Vt)((0,a.Rd)(),h,f)||0),W=(0,o.sO)(),K=(0,o.sO)(),J=(0,o.sO)(),ee=(0,o.sO)(),te=(0,o.sO)(),ne=(0,o.sO)(),ae=(0,o.sO)(!1),se=(0,o.sO)(Boolean($)),[oe,ie]=(0,o.eJ)(),re=Boolean(T);(0,ye.Z)((()=>{re&&(0,C.R3)((()=>{se.current=!1}))}),[re]),(0,ye.Z)((()=>{ee.current=B}),[B]),(0,ye.Z)((()=>{P&&E&&Q&&z({chatId:h})}),[h,E,P,Q]),(0,ye.Z)((()=>{re&&(te.current=ee.current)}),[re]),(0,ye.Z)((()=>{ne.current=U}),[U]);const ce=(0,o.Ye)((()=>{if(!T||!N)return;const e=!q||T[0]&&A!==T[0]?T:[q,...T];if(!e.length)return;const t=e.map((e=>N[e])).filter(Boolean);return mn((0,g.Xo)(t,["date","id"]),te.current)}),[T,N,A,q]);(0,vn.Z)((()=>{if(!T||!N)return;const e=T.filter((e=>{var t;return null===(t=N[e])||void 0===t?void 0:t.reactions}));e.length&&V({chatId:h,ids:e})}),15e3);const le=(0,o.Ye)((()=>{if("thread"===p)return(0,C.Ds)((()=>H({direction:m.Uq.Around})),1e3,!0,!1)}),[H,T]),{isScrolled:me,updateStickyDates:he}=function(){const[e,t]=(0,xe.Z)(!1),n=(0,gn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,C.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,C.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)(),fe=(0,o.sO)(),pe=(0,o.I4)((()=>{if(ae.current)return void(ae.current=!1);ge.current=!0;const e=X.current;ne.current||he(e,v),_a((()=>{ge.current=!1,(0,C.T2)((()=>{e.parentElement&&(Y.current=e.scrollHeight-e.scrollTop,"thread"===p&&_({chatId:h,threadId:f,scrollOffset:Y.current}))}))}))}),[he,v,p,_,h,f]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((e=>{let[t]=e;t.target.offsetParent&&ie(t.contentRect.height)}));return e.observe(X.current),()=>{e.disconnect()}}),[]);const{height:ve}=wt();(0,o.d4)((()=>{X.current.dataset.normalHeight=String(X.current.offsetHeight)}),[ve,b]),(0,o.d4)((()=>{if(!le||!Z||L||U)return;if(T&&T[T.length-1]>=s.AE)return;const e=X.current;(!T||T.length<s.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&le()}),[Z,T,le,U,L]),(0,ye.Z)((()=>{if(!T||!J.current)return;const e=J.current.filter((e=>T.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(W.current=t.id,K.current=t.getBoundingClientRect().top)}),[T,x,oe,v]),(0,ln.Z)((e=>{let[t,n,a]=e;const o=X.current;J.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&&ne.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=Y.current,f=J.current[J.current.length-1];let p=g-(a||h);c&&(p-=f?f.offsetHeight:0);const I=x&&n&&p<=20;let y;if(c&&I&&!l&&(f&&(0,C.T2)((()=>{(0,pn.Z)(o,f,"end",20)})),y=m-h,Y.current=Math.max(Math.ceil(m-y),h),!d))return;const Z=void 0!==a&&a!==oe,P=W.current&&o.querySelector(`#${W.current}`),w=!P&&te.current&&o.querySelector(".unread-divider");if(I&&Z){if((0,pn.N)())return;y=m-h}else P?(fe.current&&(fe.current=!1,(0,fn.z)(o)),y=u+(P.getBoundingClientRect().top-(K.current||0))):y=w?Math.min(w.offsetTop-(v?60:10),m-g):m-g;(0,fn.Z)(o,Math.ceil(y)),ne.current||(ae.current=!0,(0,C.T2)((()=>{ae.current=!1}))),Y.current=Math.max(Math.ceil(m-y),h)}),[T,x,oe,v]),(0,dn.Z)((e=>{let[t]=e;void 0!==t&&(0,de.YW)(200+s.fK)}),[F]);const Ie=(0,Le.Z)(),Ze=Boolean(h&&(0,l.YC)(h)),Pe=Boolean(!Ze&&!P||S||M),Ce=Boolean(!Pe||P),we=(0,l.YC)(h)&&!S&&!k&&(!ce&&!$&&T&&(!J.current||0===J.current.length)||1===(null==T?void 0:T.length)&&"contactSignUp"===(null==N||null===(t=N[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===(c=i.action)||void 0===c?void 0:c.type)),be=w&&R&&1===(null==T?void 0:T.length)&&"chatCreate"===(null==N||null===(d=N[T[0]])||void 0===d||null===(u=d.content.action)||void 0===u?void 0:u.type),Ee=(0,ue.Z)("MessageList custom-scroll",Ce&&"no-avatars",!b&&"no-composer","pinned"===p&&"type-pinned",G&&"with-bottom-shift",F&&"select-mode-active",me&&"scrolled",!E&&"is-animating");return o.ZP.createElement("div",{ref:X,className:Ee,onScroll:pe,onMouseDown:hn.q},L?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,O?O.text:"This is a private "+(P?"channel":"chat"))):D?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,tn.Z)(Ie(D),["br","emoji","links"]))):we?o.ZP.createElement(Ga,{userId:h}):!T||ce&&!be?T&&ce||$?o.ZP.createElement(ja,{chatId:h,messageIds:T||[$.id],messageGroups:ce||mn([$]),isViewportNewest:Boolean(x),isUnread:Boolean(B),withUsers:Pe,areReactionsInMeta:Ze,noAvatars:Ce,containerRef:X,anchorIdRef:W,memoUnreadDividerBeforeIdRef:te,memoFirstUnreadIdRef:ee,threadId:f,type:p,isReady:E,isScrollingRef:ge,isScrollPatchNeededRef:fe,threadTopMessageId:q,hasLinkedChat:j,isSchedule:!!ce&&"scheduled"===p,noAppearanceAnimation:!ce||!se.current,onFabToggle:I,onNotchToggle:y}):o.ZP.createElement(st.Z,{color:"white",backgroundColor:"dark"}):o.ZP.createElement(Ha,{chatId:h,type:p,isChatWithSelf:S,isGroupChatJustCreated:be}))}))),Va=(0,o.X$)((0,a.c$)((e=>{const t=(0,r.Bt)(e);if(!t)return{};const{chatId:n,threadId:a,type:s}=t,o=(0,r.Z1)(e,n);return{messageListType:s,unreadCount:o&&a===u._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.uC)(),l=(0,Le.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,pn.Z)(e,n,"end",20)}}),[t,s,c]),m=(0,ue.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(Qe.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,Se.bi)(i))))})));var Xa=n(5723);const Ya=1280,Wa=/\.[^/.]+$/;async function Ka(e,t,n,a){const o=URL.createObjectURL(t),{type:i,size:r}=t;let c,l;if(s.oG.has(i))if(n){const t=await(0,Ct.pt)(o),{width:n,height:s}=t;if(n>Ya||s>Ya||"image/jpeg"!==i){const t=await Vt(o,Ya/Math.max(n,s),"image/jpeg");return URL.revokeObjectURL(o),Ka(e,await(0,Ct.gm)(t),!0,a)}"image/jpeg"===i&&(e=e.replace(Wa,".jpg")),c={width:n,height:s}}else l=o;else if(s.wG.has(i)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,Ct.jj)(o);c={width:e,height:t,duration:n},l=await(0,Ct.ud)(o)}return{blobUrl:o,filename:e,mimeType:i,size:r,quick:c,previewBlobUrl:l,...a}}function Ja(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 es=n(6391);let ts;function ns(e){ts.focus(),e.focus()}h.cj&&(ts=document.createElement("input"),ts.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(ts));var as=n(4784),ss=n(2400),os=n(6389),is=n(971);const rs={encoderPath:n.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},cs={type:"audio/ogg"};let ls,ds,us;async function ms(){return ls||(ls=n.e(161).then(n.t.bind(n,1161,23)),ds=(await ls).default,us=new ds(rs)),ls}async function hs(e){await async function(){await ms(),await us.start()}();const t=Date.now();let n;const a=[],s=[];us.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}}(us);return{stop:()=>new Promise(((e,i)=>{us.onstop=()=>{e({blob:new Blob(a,cs),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},us.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{us.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{us.pause(),n=Date.now(),o()}),e)}}}var gs=n(1262);const fs=["image/png","image/jpeg","image/gif"];let ps,vs;var Is=n(3575),ys=n(9295);function Zs(e,t,n){const a=(0,gn.Z)(t,!0),[s,i]=(0,o.eJ)(),[r,c,l]=(0,xe.Z)();return(0,de.ZP)(c,l),(0,ye.Z)((()=>{r||a((()=>{i(e())}))}),[...n,r]),s}const Ps=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Cs=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,ws={username:"",query:"",canShowHelp:!1,usernameLowered:""},bs=document.createElement("div");const Es=(0,C.P2)((e=>e()),500,!0),Ss=/^[\w@]{1,32}\s?/i,Ms=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"DeleteMessageModal",!t);return n?o.ZP.createElement(n,e):void 0}));function Rs(){return Rs=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},Rs.apply(this,arguments)}let ks,Ts=!0;const Ns=(0,o.X$)((e=>{let{onActivate:t,...n}=e;const a=(0,o.sO)(!1),s=(0,o.I4)((()=>{if(a.current=!0,Ts)return Ts=!1,void t();ks&&(clearTimeout(ks),ks=void 0),ks=window.setTimeout((()=>{a.current&&t()}),200)}),[t]),i=(0,o.I4)((()=>{a.current=!1}),[]);return o.ZP.createElement(Qe.Z,Rs({},n,{onMouseEnter:h.$b?void 0:s,onMouseLeave:h.$b?void 0:i,onClick:h.$b?t:void 0}))})),Bs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"CalendarModal",!t);return n?o.ZP.createElement(n,e):void 0})),xs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"AttachMenu",!t);return n?o.ZP.createElement(n,e):void 0})),As=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"SymbolMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Ls=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"InlineBotTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),Os=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"MentionTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),Us=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"CustomSendMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Fs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"StickerTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var $s=n(9830);const Ds=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"BotCommandTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var qs=n(6503);const js=(0,o.X$)((0,a.c$)(((e,t)=>{let{messageId:n}=t;const{chatId:a}=(0,r.Bt)(e)||{};return a?{message:(0,r.hj)(e,a,n)}:{}}))((e=>{let{isOpen:t,message:n,onClose:s}=e;const{clickInlineButton:i}=(0,a.uC)(),[r,c]=(0,qs.Z)(t,s),{isKeyboardSingleUse:l}=n||{},[d,u,m]=(0,xe.Z)(!0),g=()=>{m(),s()};if((0,o.d4)((()=>{u()}),[u,null==n?void 0:n.keyboardButtons]),n&&n.keyboardButtons)return o.ZP.createElement(rt.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},o.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Qe.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>i({button:e})},e.text))))))))})));var Qs=n(3616),Gs=n(7891);const Hs=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:n,type:a}=(0,r.Bt)(e)||{};if(!t||!n||!a)return{};const{currentUserId:s,forwardMessages:{fromChatId:o,toChatId:i,messageIds:c}}=e,d=(0,r.Yy)(e,t,n),u="scheduled"===a?(0,r.wU)(e,t):(0,r._$)(e,t,n),m=e.settings.byKey.animationLevel>=1,h=i===t;let g,f;if(d?g=(0,r.hj)(e,t,d):u?g=(0,r.kK)(e,t,n,a):h&&1===c.length&&(g=(0,r.hj)(e,o,c[0])),d&&g){const{forwardInfo:n}=g,a=t===s;n&&(n.isChannelPost||a)&&(f=(0,r.cv)(e,g)),f||(f=(0,r.Ur)(e,g))}else h&&(f=(0,l.YC)(o)?(0,r.dy)(e,o):(0,r.Z1)(e,o));return{replyingToId:d,editingId:u,message:g,sender:f,shouldAnimate:m,forwardedMessagesCount:h?c.length:void 0}}))((e=>{let{replyingToId:t,editingId:n,message:s,sender:i,shouldAnimate:r,forwardedMessagesCount:c}=e;const{setReplyingToId:l,setEditingId:d,focusMessage:u,exitForwardMode:m}=(0,a.uC)(),h=Boolean((t||n)&&s||i&&c),g=(0,Gs.Z)([c],c?300:void 0),{shouldRender:f,transitionClassNames:p}=(0,pe.Z)(g&&h,void 0,!r,void 0,!r),v=(0,o.I4)((()=>{t?l({messageId:void 0}):n?d({messageId:void 0}):c&&m()}),[t,n,c,l,d,m]);(0,o.d4)((()=>h?(0,Te.Z)(v):void 0),[h,v]);const I=(0,o.I4)((()=>{u({chatId:s.chatId,messageId:s.id})}),[u,s]),y=(0,ue.Z)("ComposerEmbeddedMessage",p),Z=c&&c>1?`${c} forwarded messages`:void 0;if(f)return o.ZP.createElement("div",{className:y},o.ZP.createElement("div",null,o.ZP.createElement(Qe.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:v},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(qn,{className:"inside-input",message:s,sender:i,customText:Z,title:n?"Edit Message":void 0,onClick:I})))}))),_s=(0,o.X$)((e=>{const{attachments:t}=e,n=(0,at.Z)(nt.gl.Extra,"AttachmentModal",!t.length);return n?o.ZP.createElement(n,e):void 0})),zs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"BotCommandMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Vs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"PollModal",!t);return n?o.ZP.createElement(n,e):void 0})),Xs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"DropArea",!t);return n?o.ZP.createElement(n,e):void 0})),Ys=new RegExp(s.FM,"i"),Ws=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a}=t;const s=(0,r.tV)(e,n,a);return{theme:(0,r.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:s}}))((e=>{let{chatId:t,threadId:n,messageText:s,disabled:i,webPagePreview:r,noWebPage:c,theme:l}=e;const{loadWebPagePreview:d,clearWebPagePreview:m,toggleMessageWebPage:h}=(0,a.uC)(),g=Zs((()=>{const{text:e,entities:t}=(0,p.Z)(s),n=t&&t.find((e=>{let{type:t}=e;return t===u.Vv.TextUrl}));if(n)return n.url;const a=e.match(Ys);return a?a[0]:void 0}),300,[s]);(0,o.d4)((()=>{g?d({text:g}):(m(),h({chatId:t,threadId:n}))}),[t,h,m,g,d,n]),(0,ye.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t]);const f=Boolean(r&&s.length&&!c&&!i),{shouldRender:v,transitionClassNames:I}=(0,pe.Z)(f),y=(0,kt.Z)(r,!0);if(!v||!y)return;const{photo:Z,...P}=y,C={content:{webPage:P}};return o.ZP.createElement("div",{className:(0,ue.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement(Qe.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{h({chatId:t,threadId:n,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Pa,{message:C,inPreview:!0,theme:l})))}))),Ks=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"SendAsMenu",!t);return n?o.ZP.createElement(n,e):void 0}));var Js;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(Js||(Js={}));const eo="wonderful-voice-message.ogg",to=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,o,i,c;let{chatId:d,threadId:m,messageListType:h}=t;const g=(0,r.Z1)(e,d),f=g&&(0,r.Dg)(e,g),p=d!==s.FV?(0,r.IK)(e,d):void 0,v=Boolean(p),I=(0,r.FM)(e,d),y=v&&(0,r.FT)(e,d),Z=(0,r.qy)(e,d),{language:P,shouldSuggestStickers:C}=e.settings.byKey,w=e.emojiKeywords[s.pR],b=P!==s.pR?e.emojiKeywords[P]:void 0,E=y?y.id:void 0,S=E?(0,r.hj)(e,d,E):void 0,{currentUserId:M}=e,R=null!=g&&g.fullInfo?(null==g||null===(n=g.fullInfo)||void 0===n?void 0:n.sendAsId)||M:void 0,k=null!=g&&g.sendAsIds&&R&&g.sendAsIds.includes(R)?R:null!=g&&null!==(a=g.adminRights)&&void 0!==a&&a.anonymous?null==g?void 0:g.id:void 0,T=k?(0,r.dy)(e,k):void 0,N=!T&&k?(0,r.Z1)(e,k):void 0;return{editingMessage:(0,r.kK)(e,d,m,h),connectionState:e.connectionState,draft:(0,r.Ms)(e,d,m),chat:g,isChatWithBot:v,isChatWithSelf:I,canScheduleUntilOnline:Boolean(!I&&!v&&g&&f&&(0,l.YC)(d)&&(null===(o=(0,r.ss)(e,d))||void 0===o?void 0:o.wasOnline)),isRightColumnShown:(0,r.Jf)(e),isSelectModeActive:(0,r.CA)(e),withScheduledButton:m===u._f&&"thread"===h&&Boolean(null==Z?void 0:Z.length),shouldSchedule:"scheduled"===h,botKeyboardMessageId:E,botKeyboardPlaceholder:null==S?void 0:S.keyboardPlaceholder,isForwarding:d===e.forwardMessages.toChatId,isPollModalOpen:e.isPollModalOpen,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==g||null===(i=g.fullInfo)||void 0===i?void 0:i.members,topInlineBotIds:null===(c=e.topInlineBots)||void 0===c?void 0:c.userIds,currentUserId:M,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:C,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==w?void 0:w.keywords,emojiKeywords:null==b?void 0:b.keywords,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:g&&g.fullInfo&&g.fullInfo.botCommands,botCommands:p&&p.fullInfo?p.fullInfo.botCommands||!1:void 0,sendAsUser:T,sendAsChat:N,sendAsId:k}}))((e=>{let{dropAreaState:t,shouldSchedule:n,canScheduleUntilOnline:i,isReady:r,onDropHide:d,editingMessage:m,chatId:g,threadId:v,messageListType:I,draft:y,chat:Z,connectionState:P,isChatWithBot:w,isChatWithSelf:b,isRightColumnShown:E,isSelectModeActive:S,isForwarding:M,isPollModalOpen:R,botKeyboardMessageId:k,botKeyboardPlaceholder:T,withScheduledButton:B,stickersForEmoji:x,groupChatMembers:A,topInlineBotIds:L,currentUserId:O,lastSyncTime:U,contentToBeScheduled:F,shouldSuggestStickers:$,baseEmojiKeywords:D,emojiKeywords:q,serverTimeOffset:j,recentEmojis:Q,inlineBots:G,isInlineBotLoading:H,botCommands:_,chatBotCommands:z,sendAsUser:V,sendAsChat:X,sendAsId:W}=e;const{sendMessage:K,clearDraft:J,showDialog:ee,setStickerSearchQuery:te,setGifSearchQuery:ne,forwardMessages:ae,openPollModal:se,closePollModal:oe,loadScheduledHistory:ie,openChat:re,addRecentEmoji:ce,sendInlineBotResult:le,loadSendAs:de,loadFullChat:me}=(0,a.uC)(),he=(0,Le.Z)(),ge=(0,o.sO)(null),[fe,pe]=(0,o.eJ)(""),Ze=(0,is.Y)(fe),Pe=(0,o.sO)(),Ce=(0,Et.Z)(t),[we,be,Ee]=(0,xe.Z)(),[Se,Me]=(0,o.eJ)(),{width:Re}=Y.Z.get(),ke=null==Z?void 0:Z.sendAsIds,Ne=ke&&(ke.length>1||!ke.includes(O)),Be=(0,os.Z)(g,v);(0,o.d4)((()=>{Pe.current=void 0}),[g]),(0,o.d4)((()=>{g&&U&&v===u._f&&r&&ie({chatId:g})}),[r,g,ie,U,v]),(0,o.d4)((()=>{g&&Z&&U&&!ke&&r&&(0,l.ZV)(Z)&&de({chatId:g})}),[Z,g,r,U,de,ke]),(0,o.d4)((()=>{g&&Z&&U&&!Z.fullInfo&&r&&(0,l.ZV)(Z)&&me({chatId:g})}),[Z,g,r,U,me]);const Ae=(0,o.sO)(!1);(0,ye.Z)((e=>{let[t,n]=e;Ae.current=Boolean(g===t&&ke&&!n)}),[g,ke]),(0,o.bt)((()=>{ge.current&&(ge.current.innerHTML='<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#FFF" class="corner"/></g></svg>')}),[]),(0,o.d4)((()=>{F&&(Me(F),be())}),[F,be]);const[Oe,Ue]=(0,o.eJ)([]),[Fe,$e,De]=(0,xe.Z)(),[qe,je,Ge]=(0,xe.Z)(),[He,_e,ze]=(0,xe.Z)(),[Xe,Ye,We]=(0,xe.Z)(),[Ke,Je,et]=(0,xe.Z)(),[tt,nt,at]=(0,xe.Z)(),[st,ot]=(0,xe.Z)(),[it,rt,ct]=(0,xe.Z)(),{startRecordingVoice:lt,stopRecordingVoice:dt,pauseRecordingVoice:ut,activeVoiceRecording:mt,currentRecordTime:ht,recordButtonRef:gt,startRecordTimeRef:ft}=(()=>{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&&ms()}),[]);const r=(0,o.I4)((async()=>{try{const{stop:t,pause:s}=await hs((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,Te.Z)(l):void 0),[t,l]),{startRecordingVoice:r,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:s,recordButtonRef:e,startRecordTimeRef:a}})();(0,vn.Z)((()=>{Be({type:"recordAudio"})}),mt&&s.o_),(0,o.d4)((()=>{mt||Be({type:"cancel"})}),[mt,Be]);const pt=m?Js.Edit:!h.mh||mt||fe&&!Oe.length||M?n?Js.Schedule:Js.Send:Js.Record,vt=!n,{isMentionTooltipOpen:It,closeMentionTooltip:Zt,insertMention:Pt,mentionFilteredUsers:Ct}=(0,ys.Z)(!Oe.length,Ze,pe,void 0,A,L,O),{isOpen:wt,id:bt,isGallery:St,switchPm:Mt,results:Rt,closeTooltip:kt,help:Tt,loadMore:Nt}=function(e,t,n,s){const{queryInlineBot:i,resetInlineBot:r}=(0,a.uC)(),[c,l,d]=(0,xe.Z)(),{username:u,query:m,canShowHelp:h,usernameLowered:g}=Zs((()=>function(e){const t=function(e){return bs.innerHTML=e.replace(/<br>/g,"\n"),bs.innerText}(e),n=t.match(Ps);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(Cs),usernameLowered:n[1].toLowerCase()}:ws}(n)),300,[n])||{},f=(0,Et.Z)(m),p=(0,Et.Z)(u),v=g?null==s?void 0:s[g]:void 0,{id:I,switchPm:y,offset:Z,results:P,isGallery:C,help:w}=v||{};(0,o.d4)((()=>{f!==m&&d()}),[f,m,d]),(0,o.d4)((()=>{e&&g&&t&&i({chatId:t,username:g,query:m})}),[m,e,i,t,g]);const b=(0,o.I4)((()=>{i({chatId:t,username:g,query:m,offset:Z})}),[Z,t,m,i,g]);return(0,o.d4)((()=>{e&&I&&(y||null!=P&&P.length)?l():d()}),[I,e,l,P,y,d]),p!==u&&r({username:p}),{isOpen:c,id:I,isGallery:C,switchPm:y,results:P,closeTooltip:d,help:h&&w?`@${u} ${w}`:void 0,loadMore:b}}(Boolean(!Oe.length&&U),g,fe,G),{isOpen:Bt,close:xt,filteredBotCommands:At}=function(e,t,n,a){const[s,i,r]=(0,xe.Z)(),[c,l]=(0,o.eJ)(),d=(0,o.I4)((e=>{n||a?Es((()=>{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,ss._)(t.substr(1)).match(Ss);d(e?e[0]:"")}else r();else r()}),[d,t,e,r]),(0,o.d4)((()=>{c&&c.length?i():r()}),[c,i,r]),{isOpen:s,close:r,filteredBotCommands:c}}(Boolean(_&&_.length||z&&z.length),fe,_,z),{isContextMenuOpen:Lt,handleContextMenu:Ot,handleContextMenuClose:Ut,handleContextMenuHide:Ft}=(0,Pn.Z)(gt,!(pt===Js.Send&&vt)),{canSendStickers:$t,canSendGifs:Dt,canAttachMedia:qt,canAttachPolls:jt,canAttachEmbedLinks:Qt}=(0,o.Ye)((()=>(0,l.H5)(Z,w)),[Z,w]),Gt=Z&&(0,l.Nl)(Z),Ht=(0,l.Hd)(Z),{isStickerTooltipOpen:_t,closeStickerTooltip:zt}=function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=(0,o.Ye)((()=>(0,ss._)(t).trim()),[t]),{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,a.uC)(),l=h.op&&1===(0,as.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($&&$t&&!Oe.length),fe,x,!r),{isEmojiTooltipOpen:Vt,closeEmojiTooltip:Xt,filteredEmojis:Yt,insertEmoji:Wt}=(0,Is.Z)(Boolean($&&$t&&!Oe.length),Ze,Q,void 0,pe,D,q,!r),Kt=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.R2;const n=window.getSelection(),a=document.getElementById(t),o=(0,tn.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(n.rangeCount){const e=n.getRangeAt(0);if((0,es.R)(e,t))return Ja(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}pe(`${Ze.current}${o}`),requestAnimationFrame((()=>{(0,Xa.Z)(a)}))}),[Ze]),Jt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,es.R)(t,s.R2))return void document.execCommand("delete",!1)}pe(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}(Ze.current))}),[Ze]),en=(0,o.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||pe(""),Ue(c.D),zt(),Ee(),Me(void 0),Zt(),Xt(),h.wB?setTimeout((()=>We()),350):We()}),[zt,Ee,Zt,Xt,We]),nn=(0,o.sO)();nn.current=dt,(0,o.d4)((()=>()=>{nn.current(),en()}),[g,en,nn]);const an=((e,t,n,i,r)=>{const{editMessage:c}=(0,a.uC)();return(0,o.d4)((()=>{n?(t((0,ma.z)(n.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Xa.Z)(e,!0)}))):t("")}),[n,t]),(0,o.I4)((()=>{const{text:t,entities:a}=(0,p.Z)(e.current);n&&(t||(0,l.u8)(n)?(c({messageId:n.id,text:t,entities:a}),i()):r())}),[c,n,e,r,i])})(Ze,pe,m,en,nt);((e,t,n,i,r,c)=>{const{saveDraft:l,clearDraft:d}=(0,a.uC)(),u=(0,o.I4)(((e,t)=>{const n=i.current;n.length&&!c?l({chatId:e,threadId:t,draft:(0,p.Z)(n)}):d({chatId:e,threadId:t})}),[d,c,i,l]),m=(0,o.Ye)((()=>(0,C.Ds)((e=>e()),s.r_,!1)),[t]),g=(0,Et.Z)(t),f=(0,Et.Z)(n);(0,o.d4)((()=>(ps=t,vs=n,()=>{ps=void 0,vs=void 0,u(t,n)})),[t,n,u]),(0,o.d4)((()=>{t===g&&n===f||e&&(r((0,ma.z)(e)),h.$b||requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Xa.Z)(e,!0)})))}),[t,n,e,r,u,g,f]);const v=i.current,I=(0,Et.Z)(v);(0,o.d4)((()=>{t&&n&&g===t&&f===n&&I!==v&&(v.length?m((()=>{ps===t&&vs===n&&u(t,n)})):u(t,n))}),[t,v,g,I,f,m,n,u]);const y=(0,o.I4)((()=>{t&&n&&u(t,n)}),[t,n,u]);(0,ve.Z)(y),Ie(y)})(y,g,v,Ze,pe,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;a.preventDefault();const i=a.clipboardData.getData("text").substring(0,4096),{items:r}=a.clipboardData;let c=[];if(r.length>0&&(c=await(0,gs.Z)(r)),0!==c.length||i){if(c.length>0&&!n){const e=await Promise.all(c.map((e=>Ka(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])})(Kt,Ue,m);const sn=(0,o.I4)((async(e,t)=>{Ue(await Promise.all(e.map((e=>Ka(e.name,e,t)))))}),[]),rn=(0,o.I4)((async(e,t)=>{Ue([...Oe,...await Promise.all(e.map((e=>Ka(e.name,e,t))))])}),[Oe]),cn=(0,o.I4)((()=>{Ue(c.D)}),[]),ln=(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"!==P)return;let n=Oe;if(mt){const e=await dt();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await Ka(eo,t,!1,{voice:{duration:a,waveform:s}})]}}const{text:a,entities:o}=(0,p.Z)(Ze.current);if(!n.length&&!a&&!M)return;const i=n.length?1024:4096;if((null==a?void 0:a.length)>i){const e=a.length-i;return void ee({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const r=document.getElementById(s.R2);if(n.length||a){if(Ht&&!Gt){const e=(0,f.b)(j),t=Pe.current&&Math.floor(e-Pe.current),n=Ht.nextSendDate&&Ht.nextSendDate>e;if(t&&t<Ht.seconds||n){const a=n?Ht.nextSendDate-e:Ht.seconds-t;return ee({data:{message:he("SlowModeHint",(0,N.k9)(a)),isSlowMode:!0,hasErrorKey:!1}}),void r.blur()}}K({text:a,entities:o,attachments:n,scheduledAt:t,isSilent:e})}M&&ae({scheduledAt:t,isSilent:e}),Pe.current=(0,f.b)(j),J({chatId:g,localOnly:!0}),h.cj&&r===document.activeElement&&ns(r),requestAnimationFrame((()=>{en()}))}),[P,Oe,mt,M,J,g,j,en,dt,ee,Ht,Gt,K,ae,he,Ze]),dn=(0,o.I4)((()=>{We(),je()}),[We,je]),un=(0,o.I4)((()=>{Ge(),et(),Ye()}),[Ge,et,Ye]),mn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e={...e,isPreloadedGlobally:!0},n?(Me({sticker:e}),be()):(K({sticker:e}),requestAnimationFrame((()=>{en(t)})))}),[n,be,K,en]),hn=(0,o.I4)((e=>{n?(Me({gif:e}),be()):(K({gif:e}),requestAnimationFrame((()=>{en(!0)})))}),[n,be,K,en]),gn=(0,o.I4)((e=>{if("connectionStateReady"!==P)return;le({id:e.id,queryId:e.queryId});const t=document.getElementById(s.R2);h.cj&&t===document.activeElement&&ns(t),J({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{en()}))}),[g,J,P,en,le]),fn=(0,o.I4)((()=>{J({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{en()}))}),[g,J,en]),pn=(0,o.I4)((e=>{n?(Me({poll:e}),oe(),be()):(K({poll:e}),oe())}),[oe,be,K,n]),In=(0,o.I4)((()=>{n?(Me({isSilent:!0}),be()):ln(!0)}),[ln,be,n]),yn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{isSilent:n,...a}=Se||{},s=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:j);Se&&0!==Object.keys(a).length?(K({...Se,scheduledAt:s}),requestAnimationFrame((()=>{en()}))):ln(Boolean(n),s),Ee()}),[Ee,ln,en,Se,K,j]),Zn=(0,o.I4)((()=>{yn(new Date(1e3*s.t4),!0)}),[yn]),Cn=(0,o.I4)((()=>{Ee(),Me(void 0)}),[Ee]),wn=(0,o.I4)((e=>{"stickers"===e?(te({query:""}),ne({query:void 0})):(ne({query:""}),te({query:void 0}))}),[te,ne]),bn=(0,o.I4)((()=>{const e=document.getElementById(s.R2);h.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Ge(),Ye()}),100)):Ye()}),[Ye,Ge]),En=(0,o.I4)((()=>{const e=document.getElementById(s.R2);if(!h.wB||e!==document.activeElement)return Ge(),We(),void Je();e.blur(),setTimeout((()=>{Ge(),We(),Je()}),100)}),[Ge,We,Je]),Sn=(0,o.I4)((()=>{re({id:g,threadId:v,type:"scheduled"})}),[re,g,v]);(0,o.d4)((()=>{E&&h.wB&&We()}),[E,We]),(0,o.d4)((()=>{r&&(S?rt():setTimeout((()=>{ct()}),200))}),[S,ct,rt,r]);const Mn=(0,o.I4)((()=>{switch(pt){case Js.Send:ln();break;case Js.Record:lt();break;case Js.Edit:an();break;case Js.Schedule:mt&&ut(),be()}}),[pt,ln,lt,an,mt,be,ut]),Rn=pt===Js.Record&&!qt,kn=(0,Et.Z)(m,!0),Tn=m||kn,Nn=new Date;Nn.setSeconds(0),Nn.setMilliseconds(0);const Bn=new Date;Bn.setFullYear(Bn.getFullYear()+1);let xn="SendMessage";switch(pt){case Js.Edit:xn="Save edited message";break;case Js.Record:xn=Rn?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const An=(0,ue.Z)("Composer",!S&&"shown",it&&"hover-disabled"),Ln=(0,ue.Z)("mobile-symbol-menu-button",!r&&"not-ready",st?Xe&&"menu-opened":Xe&&"is-loading"),On=pt===Js.Edit?an:pt===Js.Schedule?be:ln;return o.ZP.createElement("div",{className:An},qt&&r&&o.ZP.createElement(Xs,{isOpen:t!==yt.t.None,withQuick:t===yt.t.QuickFile||Ce===yt.t.QuickFile,onHide:d,onFileSelect:sn}),o.ZP.createElement(_s,{chatId:g,threadId:v,attachments:Oe,caption:Oe.length?fe:"",groupChatMembers:A,currentUserId:O,recentEmojis:Q,isReady:r,onCaptionUpdate:pe,baseEmojiKeywords:D,emojiKeywords:q,addRecentEmoji:ce,onSend:n?be:ln,onFileAppend:rn,onClear:cn}),o.ZP.createElement(Vs,{isOpen:Boolean(R),onClear:oe,onSend:pn}),Tn&&o.ZP.createElement(Ms,{isOpen:tt,isSchedule:"scheduled"===I,onClose:at,message:Tn}),o.ZP.createElement(Ks,{isOpen:Ke,onClose:et,chatId:g,selectedSendAsId:W,sendAsIds:ke}),o.ZP.createElement(Os,{isOpen:It,onClose:Zt,onInsertUserName:Pt,filteredUsers:Ct}),o.ZP.createElement(Ls,{isOpen:wt,botId:bt,isGallery:St,inlineBotResults:Rt,switchPm:Mt,onSelectResult:gn,loadMore:Nt,onClose:kt}),o.ZP.createElement(Ds,{isOpen:Bt,withUsername:Boolean(z),botCommands:At,onClick:fn,onClose:xt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:ge}),o.ZP.createElement(Hs,null),o.ZP.createElement(Ws,{chatId:g,threadId:v,messageText:Oe.length?"":fe,disabled:!Qt}),o.ZP.createElement("div",{className:"message-input-wrapper"},w&&!1!==_&&!mt&&!m&&o.ZP.createElement(Ns,{className:(0,ue.Z)("bot-commands",qe&&"activated"),round:!0,disabled:void 0===_,color:"translucent",onActivate:dn,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),Ne&&(V||X)&&o.ZP.createElement(Qe.Z,{round:!0,color:"translucent",onClick:Ke?et:En,ariaLabel:he("SendMessageAsTitle"),className:(0,ue.Z)("send-as-button",Ae.current&&"appear-animation")},o.ZP.createElement(on.Z,{user:V,chat:X,size:"tiny"})),h.wB?o.ZP.createElement(Qe.Z,{className:Ln,round:!0,color:"translucent",onClick:Xe?We:bn,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),Xe&&!st&&o.ZP.createElement(Ve.Z,{color:"gray"})):o.ZP.createElement(Ns,{className:Xe?"activated":"",round:!0,color:"translucent",onActivate:un,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(Qs.Z,{id:"message-input-text",chatId:g,threadId:v,html:Oe.length?"":fe,placeholder:mt&&Re<=600?"":T||he("Message"),forcedPlaceholder:Tt,canAutoFocus:r&&!Oe.length,shouldSuppressFocus:h.wB&&Xe,shouldSuppressTextFormatter:Vt||It||wt,onUpdate:pe,onSend:On,onSuppressedFocus:We}),H&&Boolean(bt)&&o.ZP.createElement(Ve.Z,{color:"gray"}),B&&o.ZP.createElement(Qe.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:Sn,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),k&&!mt&&!m&&o.ZP.createElement(Ns,{className:Fe?"activated":"",round:!0,color:"translucent",onActivate:$e,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!mt&&!m&&o.ZP.createElement(Ns,{className:He?"activated":"",round:!0,color:"translucent",onActivate:_e,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),mt&&ht&&o.ZP.createElement("span",{className:"recording-state"},(0,N.rM)(ht-ft.current)),o.ZP.createElement(Fs,{chatId:g,threadId:v,isOpen:_t,onStickerSelect:mn}),o.ZP.createElement($s.Z,{isOpen:Vt,emojis:Yt,onClose:Xt,onEmojiSelect:Wt,addRecentEmoji:ce}),o.ZP.createElement(xs,{isOpen:He,canAttachMedia:qt,canAttachPolls:jt,onFileSelect:sn,onPollCreate:se,onClose:ze}),k&&o.ZP.createElement(js,{messageId:k,isOpen:Fe,onClose:De}),_&&o.ZP.createElement(zs,{isOpen:qe,botCommands:_,onClose:Ge}),o.ZP.createElement(As,{chatId:g,threadId:v,isOpen:Xe,canSendGifs:Dt,canSendStickers:$t,onLoad:ot,onClose:We,onEmojiSelect:Kt,onStickerSelect:mn,onGifSelect:hn,onRemoveSymbol:Jt,onSearchOpen:wn,addRecentEmoji:ce}))),mt&&o.ZP.createElement(Qe.Z,{round:!0,color:"danger",className:"cancel",onClick:dt,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Qe.Z,{ref:gt,round:!0,color:"secondary",className:(0,ue.Z)(pt,!r&&"not-ready",mt&&"recording"),disabled:Rn,ariaLabel:he(xn),onClick:Mn,onContextMenu:pt===Js.Send&&vt?Ot: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"})),vt&&o.ZP.createElement(Us,{isOpen:Lt,onSilentSend:b?void 0:In,onScheduleSend:n?void 0:be,onClose:Ut,onCloseAnimationEnd:Ft}),o.ZP.createElement(Bs,{isOpen:we,withTimePicker:!0,selectedAt:Nn.getTime(),maxAt:(0,N._F)(Bn),isFutureMode:!0,secondButtonLabel:i?he("Schedule.SendWhenOnline"):void 0,onClose:Cn,onSubmit:yn,onSecondButtonClick:i?Zn:void 0}))}))),no=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,at.Z)(nt.gl.Extra,"MobileSearch",!t,!0);return n?o.ZP.createElement(n,e):void 0})),ao=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,at.Z)(nt.gl.Extra,"MessageSelectToolbar",!t);return n?o.ZP.createElement(n,e):void 0})),so=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"UnpinAllMessagesModal",!t);return n?o.ZP.createElement(n,e):void 0})),oo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"PaymentModal",!t);return n?o.ZP.createElement(n,e):void 0})),io=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"ReceiptModal",!t);return n?o.ZP.createElement(n,e):void 0})),ro=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"SeenByModal",!t);return n?o.ZP.createElement(n,e):void 0})),co=(0,o.X$)((e=>{const{emojiInteraction:t}=e,n=(0,at.Z)(nt.gl.Extra,"EmojiInteractionAnimation",!t);return n?o.ZP.createElement(n,e):void 0})),lo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"ReactorListModal",!t);return n?o.ZP.createElement(n,e):void 0})),uo=h.wB?450+s.fK:void 0;function mo(e){return"file"===e.kind&&e.type&&s.oG.has(e.type)}const ho=(0,o.X$)((0,a.c$)((e=>{const t=(0,r.Pu)(e),{isBlurred:n,background:a,backgroundColor:s,patternColor:o}=e.settings.themes[t]||{},{messageLists:i}=e.messages,c=(0,r.Bt)(e),{isLeftColumnShown:d,chats:{listIds:m},activeEmojiInteraction:g}=e,f={theme:t,customBackground:a,backgroundColor:s,patternColor:o,isLeftColumnShown:d,isRightColumnShown:(0,r.Jf)(e),isBackgroundBlurred:n,isMobileSearchActive:Boolean(h.wB&&(0,r.n5)(e)),isSelectModeActive:(0,r.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),activeEmojiInteraction:g};if(!c||!m.active)return f;const{chatId:p,threadId:v,type:I}=c,y=(0,r.Z1)(e,p),Z=(0,r.IK)(e,p),P=(0,r.KB)(e,p),{chatId:C,messageId:w}=e.audioPlayer,b=y&&(0,l.Qm)(y,v),E=(0,r.pk)(e,p),S="pinned"===I,M="scheduled"===I,R="thread"===I&&v===u._f,k=Boolean(y&&(0,l.eA)(y)),T=Boolean(y&&R&&(k||(0,l.ZV)(y))&&y.isNotJoined),N=Boolean(Z&&(0,r.s4)(e,Z.id)),B=!N&&E;return{...f,chatId:p,threadId:v,messageListType:I,isPrivate:(0,l.YC)(p),canPost:!S&&(!y||b)&&!E,isPinnedMessageList:S,isScheduledMessageList:M,currentUserBannedRights:null==y?void 0:y.currentUserBannedRights,defaultBannedRights:null==y?void 0:y.defaultBannedRights,hasPinnedOrAudioPlayer:v!==u._f||Boolean(!S&&(null==P?void 0:P.length))||Boolean(C&&w),pinnedMessagesCount:P?P.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:i,isChannel:k,canSubscribe:T,canStartBot:B,canRestartBot:N}}))((e=>{let{chatId:t,threadId:n,messageListType:i,isPrivate:r,isPinnedMessageList:c,messageLists:d,canPost:u,currentUserBannedRights:m,defaultBannedRights:g,hasPinnedOrAudioPlayer:f,pinnedMessagesCount:p,customBackground:v,theme:I,backgroundColor:y,patternColor:Z,isLeftColumnShown:P,isRightColumnShown:C,isBackgroundBlurred:w,isMobileSearchActive:b,isSelectModeActive:E,isPaymentModalOpen:S,isReceiptModalOpen:M,isSeenByModalOpen:R,isReactorListModalOpen:k,animationLevel:T,shouldSkipHistoryAnimations:N,currentTransitionKey:B,isChannel:x,canSubscribe:A,canStartBot:L,canRestartBot:O,activeEmojiInteraction:U}=e;const{openChat:F,unpinAllMessages:$,loadUser:D,closeLocalTextSearch:q,exitMessageSelectMode:j,closePaymentModal:Q,clearReceipt:G,joinChannel:H,sendBotCommand:_,restartBot:Y}=(0,a.uC)(),{width:W}=wt(),K=(0,Le.Z)(),[J,ee]=(0,o.eJ)(yt.t.None),[te,ne]=(0,o.eJ)(),[ae,se]=(0,o.eJ)(),[oe,ie]=(0,o.eJ)(!1),re=f&&(W<s.l3||C&&W>s._m&&W<s.QU||W>=s.ks&&W<s.jT),ce=(0,bt.Z)(t,uo),le=(0,bt.Z)(n,uo),de=(0,bt.Z)(i,uo),me=(0,bt.Z)(A,uo),he=(0,bt.Z)(L,uo),ge=(0,bt.Z)(O,uo),fe=(0,bt.Z)(u,uo)&&!ge&&!he&&!me,pe=(0,bt.Z)(re,uo),ve=(0,bt.Z)(te,uo),Ie=(0,bt.Z)(x,uo),Ze=(0,Et.Z)(B),Pe=void 0!==Ze&&Ze<B?Ze:void 0,{isReady:Ce,handleOpenEnd:we,handleSlideStop:Ee}=function(e,t,n,a){const[s,i]=(0,o.eJ)(!h.wB),r=(0,St.Z)(),c=void 0!==n&&n!==t;return c&&(e?i(!1):r()),(0,ye.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}}(!N&&T!==s.oB,B,Ze,t);(0,o.d4)((()=>t?(0,Te.Z)((()=>{F({id:void 0})})):void 0),[t,F]),(0,ye.Z)((()=>{ee(yt.t.None),ne(void 0),se(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&&D({userId:t})}),[t,r,D]);const Se=(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(mo);ee(n?yt.t.QuickFile:yt.t.Document)}),[]),Me=(0,o.I4)((()=>{ee(yt.t.None)}),[]),Re=(0,o.I4)((()=>{ie(!0)}),[]),ke=(0,o.I4)((()=>{ie(!1)}),[]),Ne=(0,o.I4)((()=>{$({chatId:t}),ke(),F({id:t})}),[$,F,ke,t]),Be=(0,o.I4)((()=>{F({id:t})}),[F,t]),xe=(0,o.I4)((()=>{H({chatId:t})}),[H,t]),Oe=(0,o.I4)((()=>{_({command:"/start"})}),[_]),Ue=(0,o.I4)((()=>{Y({chatId:t})}),[t,Y]),Fe=((e,t)=>{const[n,a]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?a(t):Pt.fetch(s.fo,e,Pt.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,Ct.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(I,v),$e=(0,ue.Z)(pe&&"has-header-tools",v&&"custom-bg-image",y&&"custom-bg-color",v&&w&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),De=(0,ue.Z)("messaging-disabled",!E&&"shown"),qe=(0,l.q8)(K,m,g),{composerHiddenScale:je,toolbarHiddenScale:Ge,composerTranslateX:He,toolbarTranslateX:_e,unpinHiddenScale:ze,toolbarForUnpinHiddenScale:Ve}=(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,X),V),n=Math.min(.25*e,V);return Math.min(e-t-n,z)}if(e>s.ks){const t=Math.min(Math.max(.4*e,X),V);return Math.min(e-t,z)}return e>z?z: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}}(W,fe)),[fe,W]),Xe=(0,ue.Z)("middle-column-footer",!fe&&"no-composer",fe&&ae&&!E&&"with-notch");(0,be.ZP)(ce&&le,(()=>{F({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==d?void 0:d.map(Zt.q))||[]),(0,be.ZP)(b,q),(0,be.ZP)(E,j);const Ye=Boolean(!c&&!fe&&!ge&&!he&&!me&&qe),We=Boolean(ge||me||he||c),Ke=Boolean(Ye||E||c);return o.ZP.createElement("div",{id:"MiddleColumn",className:$e,onTransitionEnd:we,style:`\n --composer-hidden-scale: ${je};\n --toolbar-hidden-scale: ${Ge};\n --unpin-hidden-scale: ${ze};\n --toolbar-unpin-hidden-scale: ${Ve};\n --composer-translate-x: ${He}px;\n --toolbar-translate-x: ${_e}px;\n --pattern-color: ${Z};\n --theme-background-color:\n ${y||("dark"===I?s.It:s.p3)};\n `,onClick:h.p7&&P?Be:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:Fe?`--custom-background: ${Fe}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),ce&&le&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:fe?Se:void 0},o.ZP.createElement(cn,{chatId:ce,threadId:le,messageListType:de,isReady:Ce}),o.ZP.createElement(Ae.Z,{name:N?"none":T===s.zy?"slide":"fade",activeKey:B,shouldCleanup:!0,cleanupExceptionKey:Pe,onStop:Ee},(()=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(za,{key:`${ce}-${le}-${de}`,chatId:ce,threadId:le,type:de,canPost:fe,hasTools:pe,onFabToggle:ne,onNotchToggle:se,isReady:Ce,withBottomShift:We}),o.ZP.createElement("div",{className:Xe},fe&&o.ZP.createElement(to,{chatId:ce,threadId:le,messageListType:de,dropAreaState:J,onDropHide:Me,isReady:Ce}),c&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:K.isRtl?"rtl":void 0},o.ZP.createElement(Qe.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Re},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,K("Chat.Pinned.UnpinAll",p,"i")))),Ye&&o.ZP.createElement("div",{className:De},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,qe))),h.wB&&me&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:K.isRtl?"rtl":void 0},o.ZP.createElement(Qe.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:xe},K(Ie?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&he&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:K.isRtl?"rtl":void 0},o.ZP.createElement(Qe.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Oe},K("BotStart"))),h.wB&&ge&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:K.isRtl?"rtl":void 0},o.ZP.createElement(Qe.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ue},K("BotRestart"))),o.ZP.createElement(ao,{messageListType:de,isActive:E,canPost:fe}),o.ZP.createElement(oo,{isOpen:Boolean(S),onClose:Q}),o.ZP.createElement(io,{isOpen:Boolean(M),onClose:G}),o.ZP.createElement(ro,{isOpen:R}),o.ZP.createElement(lo,{isOpen:k}))))),o.ZP.createElement(Va,{isShown:ve,canPost:fe,withExtraShift:Ke})),h.wB&&o.ZP.createElement(no,{isActive:Boolean(b)})),t&&o.ZP.createElement(so,{isOpen:oe,chatId:t,pinnedMessagesCount:p,onClose:ke,onUnpin:Ne}),U&&o.ZP.createElement(co,{emojiInteraction:U}))}))),go=(0,C.Ds)((e=>e()),200,!1);var fo;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Management=4]="Management",e[e.ManageInitial=5]="ManageInitial",e[e.ManageChannelSubscribers=6]="ManageChannelSubscribers",e[e.ManageChatAdministrators=7]="ManageChatAdministrators",e[e.ManageChatPrivacyType=8]="ManageChatPrivacyType",e[e.ManageDiscussion=9]="ManageDiscussion",e[e.ManageGroupPermissions=10]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=11]="ManageGroupRemovedUsers",e[e.ManageGroupUserPermissionsCreate=12]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=13]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=14]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=15]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=16]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=17]="ManageGroupMembers",e[e.ManageGroupAddAdmins=18]="ManageGroupAddAdmins",e[e.StickerSearch=19]="StickerSearch",e[e.GifSearch=20]="GifSearch",e[e.PollResults=21]="PollResults",e[e.AddingMembers=22]="AddingMembers",e[e.ManageInvites=23]="ManageInvites",e[e.ManageEditInvite=24]="ManageEditInvite",e[e.ManageReactions=25]="ManageReactions",e[e.ManageInviteInfo=26]="ManageInviteInfo",e[e.ManageJoinRequests=27]="ManageJoinRequests"}(fo||(fo={}));const po=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,s;let{chatId:o,isProfile:i,isManagement:c}=t;const{query:d}=(0,r.n5)(e)||{},{query:u}=(0,r.y5)(e)||{},{query:m}=(0,r.yN)(e)||{},h=o?(0,r.Z1)(e,o):void 0,g=h&&(0,l.eA)(h),f=i&&o&&(0,l.YC)(o)?(0,r.dy)(e,o):void 0,p=f&&(0,l.kw)(f),v=Boolean(!c&&i&&!p&&h&&!(0,r.FM)(e,h.id)&&((0,l.YC)(h.id)||((0,l.Nl)(h)||h.isCreator)&&!h.isNotJoined)),I=Boolean(o&&(null===(n=e.management.byChatId[o])||void 0===n?void 0:n.editingInvite)),y=o?null===(a=e.management.byChatId[o])||void 0===a||null===(s=a.inviteInfo)||void 0===s?void 0:s.invite:void 0;return{canManage:v,canAddContact:p,isChannel:g,userId:null==f?void 0:f.id,messageSearchQuery:d,stickerSearchQuery:u,gifSearchQuery:m,isEditingInvite:I,currentInviteInfo:y}}))((e=>{var t;let{chatId:n,isColumnOpen:s,isProfile:i,isSearch:r,isManagement:c,isStickerSearch:l,isGifSearch:d,isPollResults:u,isAddingChatMembers:g,profileState:f,managementScreen:p,canAddContact:v,userId:I,canManage:y,isChannel:Z,onClose:P,onScreenSelect:C,messageSearchQuery:w,stickerSearchQuery:b,gifSearchQuery:E,shouldSkipAnimation:S,isEditingInvite:M,currentInviteInfo:R}=e;const{setLocalTextSearchQuery:k,setStickerSearchQuery:T,setGifSearchQuery:B,searchTextMessagesLocal:x,toggleManagement:A,openHistoryCalendar:L,addContact:O,setEditingExportedInvite:U,deleteExportedChatInvite:F}=(0,a.uC)(),$=(0,o.sO)(null),[D,q,j]=(0,xe.Z)(),Q=(0,o.I4)((()=>{U({chatId:n,invite:R}),C(m.u1.EditInvite)}),[n,R,C,U]),G=(0,o.I4)((()=>{F({chatId:n,link:R.link}),C(m.u1.Invites),j()}),[n,j,R,F,C]),H=(0,o.I4)((e=>{k({query:e}),e.length&&go(x)}),[x,k]),_=(0,o.I4)((e=>{T({query:e})}),[T]),z=(0,o.I4)((e=>{B({query:e})}),[B]),V=(0,o.I4)((()=>{O({userId:I})}),[O,I]),[X,Y]=(0,o.eJ)(!s);(0,o.d4)((()=>{setTimeout((()=>{Y(!s)}),300)}),[s]);const W=(0,Le.Z)(),K=i?f===m.vi.Profile?fo.Profile:f===m.vi.SharedMedia?fo.SharedMedia:f===m.vi.MemberList?fo.MemberList:-1:r?fo.Search:u?fo.PollResults:l?fo.StickerSearch:d?fo.GifSearch:g?fo.AddingMembers:c?p===m.u1.Initial?fo.ManageInitial:p===m.u1.ChatPrivacyType?fo.ManageChatPrivacyType:p===m.u1.Discussion?fo.ManageDiscussion:p===m.u1.ChannelSubscribers?fo.ManageChannelSubscribers:p===m.u1.GroupPermissions?fo.ManageGroupPermissions:p===m.u1.ChatAdministrators?fo.ManageChatAdministrators:p===m.u1.GroupRemovedUsers?fo.ManageGroupRemovedUsers:p===m.u1.GroupUserPermissionsCreate?fo.ManageGroupUserPermissionsCreate:p===m.u1.GroupUserPermissions?fo.ManageGroupUserPermissions:p===m.u1.GroupRecentActions?fo.ManageGroupRecentActions:p===m.u1.ChatAdminRights?fo.ManageGroupAdminRights:p===m.u1.ChatNewAdminRights?fo.ManageGroupNewAdminRights:p===m.u1.GroupMembers?fo.ManageGroupMembers:p===m.u1.Invites?fo.ManageInvites:p===m.u1.EditInvite?fo.ManageEditInvite:p===m.u1.GroupAddAdmins?fo.ManageGroupAddAdmins:p===m.u1.Reactions?fo.ManageReactions:p===m.u1.InviteInfo?fo.ManageInviteInfo:p===m.u1.JoinRequests?fo.ManageJoinRequests:void 0:void 0,J=null!==(t=(0,kt.Z)(K,!0))&&void 0!==t?t:-1;function ee(){if(-1!==J)switch(J){case fo.PollResults:return o.ZP.createElement("h3",null,W("PollResults"));case fo.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ge.Z,{parentContainerClassName:"RightSearch",value:w,onChange:H}),o.ZP.createElement(Qe.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>L({selectedAt:(0,N._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case fo.AddingMembers:return o.ZP.createElement("h3",null,W(Z?"ChannelAddSubscribers":"GroupAddMembers"));case fo.ManageInitial:return o.ZP.createElement("h3",null,W("Edit"));case fo.ManageChatPrivacyType:return o.ZP.createElement("h3",null,W(Z?"ChannelTypeHeader":"GroupTypeHeader"));case fo.ManageDiscussion:return o.ZP.createElement("h3",null,W("Discussion"));case fo.ManageChatAdministrators:return o.ZP.createElement("h3",null,W("ChannelAdministrators"));case fo.ManageGroupRecentActions:return o.ZP.createElement("h3",null,W("Group.Info.AdminLog"));case fo.ManageGroupAdminRights:return o.ZP.createElement("h3",null,W("EditAdminRights"));case fo.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,W("SetAsAdmin"));case fo.ManageGroupPermissions:return o.ZP.createElement("h3",null,W("ChannelPermissions"));case fo.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,W("ChannelBlockedUsers"));case fo.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,W("ChannelAddException"));case fo.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,W("UserRestrictions"));case fo.ManageInvites:return o.ZP.createElement("h3",null,W("lng_group_invite_title"));case fo.ManageEditInvite:return o.ZP.createElement("h3",null,W(M?"EditLink":"NewLink"));case fo.ManageInviteInfo:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,W("InviteLink")),o.ZP.createElement("section",{className:"tools"},R&&!R.isRevoked&&o.ZP.createElement(Qe.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:W("Edit"),onClick:Q},o.ZP.createElement("i",{className:"icon-edit"})),R&&R.isRevoked&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Qe.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:W("Delete"),onClick:q},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Ft.Z,{isOpen:D,onClose:j,title:W("DeleteLink"),text:W("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:W("Delete"),confirmHandler:G}))));case fo.ManageJoinRequests:return o.ZP.createElement("h3",null,W(Z?"SubscribeRequests":"MemberRequests"));case fo.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,W("Channel.Management.AddModerator"));case fo.StickerSearch:return o.ZP.createElement(Ge.Z,{value:b,placeholder:W("SearchStickersHint"),autoFocusSearch:!0,onChange:_});case fo.GifSearch:return o.ZP.createElement(Ge.Z,{value:E,placeholder:W("SearchGifsTitle"),autoFocusSearch:!0,onChange:z});case fo.SharedMedia:return o.ZP.createElement("h3",null,W("SharedMedia"));case fo.ManageChannelSubscribers:return o.ZP.createElement("h3",null,W("ChannelSubscribers"));case fo.MemberList:case fo.ManageGroupMembers:return o.ZP.createElement("h3",null,W("GroupMembers"));case fo.ManageReactions:return o.ZP.createElement("h3",null,W("Reactions"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},v&&o.ZP.createElement(Qe.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:W("AddContact"),onClick:V},o.ZP.createElement("i",{className:"icon-add-user"})),y&&o.ZP.createElement(Qe.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:W("Edit"),onClick:A},o.ZP.createElement("i",{className:"icon-edit"}))))}}const te=h.wB||K===fo.SharedMedia||K===fo.MemberList||K===fo.AddingMembers||c,ne=(0,ue.Z)("animated-close-icon",te&&"state-back",(X||S)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(Qe.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:P,ariaLabel:W(te?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:$,className:ne})),o.ZP.createElement(Ae.Z,{name:X||S?"none":"slide-fade",activeKey:J},ee))})));var vo=n(91);var Io=n(7407);function yo(e,t,n,a){const[o,i]=(0,Io.Z)(n?t:void 0,a,void 0,s.Vk);return[o,i,!(!o||!a||o[0]===a[0])]}function Zo(e,t,n,a,i,r){const c=(0,o.sO)();(0,ye.Z)((()=>{t===e&&i&&r&&(c.current=(0,l.R5)(i,r,e))}),[i,r,t,e]);const[d,u]=(0,Io.Z)(a?n:void 0,c.current,void 0,"media"===e?s.EN:s.pn);return[d,u,!(!d||!c.current||d[0]===c.current[0])]}const Po=(0,C.P2)((e=>e()),250,!1);let Co=!1;var wo=n(1273),bo=n(1876),Eo=n(787),So=n(180),Mo=n(3709),Ro=n(5418),ko=n(7262),To=n(1151),No=n(2275);const Bo=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function xo(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const Ao=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s,userId:o}=t;const i=(0,r.Z1)(e,s),c=(0,r.Zw)(e,o||s),{currentType:d,resultsByType:u}=(0,r.we)(e)||{},{foundIds:m}=u&&d&&u[d]||{},{byId:h,statusesById:g}=e.users,{byId:f}=e.chats,p=i&&(0,l.Bf)(i),v=i&&(0,l.eA)(i),I=p||v&&(0,l.Nl)(i),y=null==i||null===(n=i.fullInfo)||void 0===n?void 0:n.members,Z=I&&i&&i.fullInfo&&!i.fullInfo.canViewMembers,P=I&&i&&((0,l.VE)(i,"inviteUsers")||i.isCreator),C=I&&i&&((0,l.VE)(i,"banUsers")||i.isCreator),w=(0,r.xs)(e,s);let b,E,S;return o?E=o:(0,l.YC)(s)&&(E=s),E&&(S=(0,r.dy)(e,E),b=S&&!S.isSelf&&!(0,l.cS)(S)),{theme:(0,r.Pu)(e),isChannel:v,resolvedUserId:E,chatMessages:c,foundIds:m,mediaSearchType:d,hasCommonChatsTab:b,hasMembersTab:I,areMembersHidden:Z,canAddMembers:P,canDeleteMembers:C,currentUserId:e.currentUserId,isRightColumnShown:(0,r.Jf)(e),isRestricted:null==i?void 0:i.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:w,usersById:h,userStatusesById:g,chatsById:f,isChatProtected:null==i?void 0:i.isProtected,...I&&y&&{members:y},...b&&S&&{commonChatIds:null===(a=S.commonChats)||void 0===a?void 0:a.ids}}}))((e=>{let{chatId:t,profileState:n,onProfileStateChange:i,theme:r,isChannel:c,resolvedUserId:d,currentUserId:g,chatMessages:f,foundIds:p,mediaSearchType:v,hasCommonChatsTab:I,hasMembersTab:y,areMembersHidden:Z,canAddMembers:P,canDeleteMembers:C,commonChatIds:w,members:b,usersById:E,userStatusesById:S,chatsById:M,isRightColumnShown:R,isRestricted:k,lastSyncTime:T,activeDownloadIds:N,serverTimeOffset:B,isChatProtected:x}=e;const{setLocalMediaSearchType:A,loadMoreMembers:L,loadCommonChats:O,openChat:U,searchMediaMessagesLocal:F,openMediaViewer:$,openAudioPlayer:D,openUserInfo:q,focusMessage:j,loadProfilePhotos:Q,setNewChatMembersDialogState:G}=(0,a.uC)(),H=(0,o.sO)(null),_=(0,o.sO)(null),z=(0,Le.Z)(),[V,X]=(0,o.eJ)(0),[Y,W]=(0,o.eJ)(),K=(0,o.Ye)((()=>[...y?[{type:"members",title:c?"ChannelSubscribers":"GroupMembers"}]:[],...Bo,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,y,c]),J=K[V].type,[ee,te,ne,ae]=function(e,t,n,a,s,i,r,c,d,u,m,h,g,f,p){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&&d&&u)return(0,l.Z0)(r.map((e=>{let{userId:t}=e;return t})),d,u,void 0,v)}),[r,v,d,u]),Z=(0,o.Ye)((()=>{if(c&&m)return(0,l.ih)(c,m,!0)}),[m,c]),[P,C,w]=yo(0,t,p,y),[b,E,S]=Zo("media",I,a,p,h,g),[M,R,k]=Zo("documents",I,a,p,h,g),[T,N,B]=Zo("links",I,a,p,h,g),[x,A,L]=Zo("audio",I,a,p,h,g),[O,U,F]=Zo("voice",I,a,p,h,g),[$,D,q]=yo(0,n,p,Z);let j,Q,G=!1;switch(I){case"members":j=P,Q=C,G=w;break;case"commonChats":j=$,Q=D,G=q;break;case"media":j=b,Q=E,G=S;break;case"documents":j=M,Q=R,G=k;break;case"links":j=T,Q=N,G=B;break;case"audio":j=x,Q=A,G=L;break;case"voice":j=O,Q=U,G=F}return[I,j,Q,G]}(R,L,O,F,J,v,b,w,E,S,M,f,p,t,T,B),se=K.findIndex((e=>{let{type:t}=e;return t===ee})),{handleScroll:oe}=function(e,t,n,a){(0,dn.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),Co=!0,(0,pn.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{Co=!1}),350))}}),[t,a]),(0,dn.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||(Co=!0,(0,pn.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{Co=!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)((()=>{Co||s()}),[s,t]),{handleScroll:(0,o.I4)((()=>{Co||Po(s)}),[s])}}(H,J,n,i),{applyTransitionFix:ie,releaseTransitionFix:re}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,o.d4)((()=>{function n(){const n=e.current,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}}(H),[ce,le]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),{observe:de}=(0,In.S1)({rootRef:H,throttleMs:500}),ue=(0,o.I4)((()=>{re(),le()}),[re,le]),me=(0,o.I4)((()=>{G(m.WB.InProgress)}),[G]);(0,o.d4)((()=>{A({mediaType:J})}),[A,J]);const he=d||t;(0,o.d4)((()=>{T&&Q({profileId:he})}),[Q,he,T]);const ge=(0,o.I4)((e=>{$({chatId:he,threadId:u._f,messageId:e,origin:m.bZ.SharedMedia})}),[he,$]),fe=(0,o.I4)((e=>{D({chatId:he,messageId:e})}),[he,D]),pe=(0,o.I4)((e=>{q({id:e})}),[q]),ve=(0,o.I4)((e=>{j({chatId:he,messageId:e})}),[he,j]),Ie=(0,o.I4)((()=>{W(void 0)}),[]);let ye;(0,o.d4)((()=>{if(_.current&&h.$b)return(0,Ke.sf)(_.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Ke.eM.Left?(X(Math.min(V+1,K.length-1)),!0):t===Ke.eM.Right&&(X(Math.max(0,V-1)),!0)})}),[V,K.length]);const Ze="members"===ee||!y&&"media"===ee;Ze?ye=R?0:1e3:te||(ye=s.Y);const Pe=(0,Gs.Z)([t,ee],ye);function Ce(){if(!te||!Pe||!f){const e=Ze&&te&&!Pe;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Ve.Z,null))}if(!te.length){let e;switch(ee){case"members":e=Z?"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(ko.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${ee}-list`,dir:z.isRtl&&"media"===ee?"rtl":void 0,teactFastList:!0},"media"===ee?te.map((e=>f[e]&&o.ZP.createElement(Mo.Z,{key:e,message:f[e],isProtected:x||f[e].isProtected,observeIntersection:de,onClick:ge}))):"documents"===ee?te.map((e=>f[e]&&o.ZP.createElement(jn.Z,{key:e,message:f[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:N.includes(e),observeIntersection:de,onDateClick:ve}))):"links"===ee?te.map((e=>f[e]&&o.ZP.createElement(Ro.Z,{key:e,message:f[e],isProtected:x||f[e].isProtected,observeIntersection:de,onMessageClick:ve}))):"audio"===ee?te.map((e=>f[e]&&o.ZP.createElement(Qn.Z,{key:e,theme:r,message:f[e],origin:m.Cr.SharedMedia,date:f[e].date,lastSyncTime:T,className:"scroll-item",onPlay:fe,onDateClick:ve,isDownloading:N.includes(e)}))):"voice"===ee?te.map((e=>f[e]&&o.ZP.createElement(Qn.Z,{key:e,theme:r,message:f[e],senderTitle:(0,vo.F)(z,f[e],M,E),origin:m.Cr.SharedMedia,date:f[e].date,lastSyncTime:T,className:"scroll-item",onPlay:fe,onDateClick:ve,isDownloading:N.includes(e)}))):"members"===ee?te.map(((e,t)=>{return o.ZP.createElement(bo.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>pe(e),contextActions:(n=e,n!==g&&C?[{title:z("lng_context_remove_from_group"),icon:"stop",handler:()=>{W(n)}}]:void 0)},o.ZP.createElement(Tt.Z,{userId:e,forceShowSelf:!0}));var n})):"commonChats"===ee?te.map(((e,t)=>o.ZP.createElement(bo.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>U({id:e})},o.ZP.createElement(Nt.Z,{chatId:e})))):void 0)}return o.ZP.createElement(wo.Z,{ref:H,className:"Profile custom-scroll",itemSelector:xo(ee),items:Pe?te:void 0,cacheBuster:ce,sensitiveArea:s.qU,preloadBackwards:Pe?"members"===ee?s.Vk:s.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:ne,onScroll:oe},!ae&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Eo.Z,{userId:t||e}),o.ZP.createElement(So.Z,{chatOrUserId:t||e}))}(t,d),!k&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Ae.Z,{ref:_,name:z.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:se,renderCount:K.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:ie,onStop:ue},Ce),o.ZP.createElement(Je.Z,{big:!0,activeTab:V,tabs:K,onSwitchTab:X})),P&&o.ZP.createElement(To.Z,{isShown:"members"===ee,onClick:me,ariaLabel:z("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),C&&o.ZP.createElement(No.Z,{isOpen:Boolean(Y),userId:Y,onClose:Ie}))}))),Lo=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)})),Oo=(0,o.X$)((e=>{const t=(0,at.Z)(nt.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(st.Z,null)})),Uo=(0,o.X$)((()=>{const e=(0,at.Z)(nt.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(st.Z,null)})),Fo=(0,o.X$)((()=>{const e=(0,at.Z)(nt.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(st.Z,null)})),$o=(0,o.X$)((()=>{const e=(0,at.Z)(nt.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(st.Z,null)}));var Do=n(1820);const qo=(0,o.X$)((0,a.c$)(((e,t)=>{var n;let{chatId:a}=t;const s=(0,r.Z1)(e,a),{userIds:o}=e.contactList||{},{byId:i}=e.chats,{currentUserId:c,newChatMembersProgress:d,connectionState:u}=e,h=s&&(0,l.eA)(s),{query:g,fetchingStatus:f,globalUserIds:p,localUserIds:v}=e.userSearch;return{isChannel:h,members:null==s||null===(n=s.fullInfo)||void 0===n?void 0:n.members,currentUserId:c,chatsById:i,localContactIds:o,searchQuery:g,isSearching:f,isLoading:d===m.WB.Loading,globalUserIds:p,localUserIds:v,connectionState:u}}))((e=>{let{isChannel:t,connectionState:n,members:s,onNextStep:i,currentUserId:r,chatsById:c,localContactIds:d,isLoading:u,searchQuery:m,isSearching:h,localUserIds:f,globalUserIds:p,onClose:v,isActive:I}=e;const{setUserSearchQuery:y,loadContactList:Z}=(0,a.uC)(),P=(0,Le.Z)(),[C,w]=(0,o.eJ)([]),b=(0,Et.Z)(C)===C;(0,o.d4)((()=>{I&&"connectionStateReady"===n&&Z()}),[n,I,Z]),(0,be.ZP)(I,v);const E=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),S=(0,o.I4)((e=>{y({query:e})}),[y]),M=(0,o.Ye)((()=>{const e=(0,a.Rd)().users.byId,n=d?(0,l.kK)(d,e,m):[];return(0,l.ih)((0,g.Tw)([...n,...f||[],...p||[]]).filter((n=>{const a=e[n];return!E.includes(n)&&n!==r&&(!a||!(0,l.cS)(a)||!t&&a.canBeInvitedToGroup)})),c)}),[d,c,m,f,p,r,E,t]),R=(0,o.I4)((()=>{C.length&&(y({query:""}),i(C))}),[C,y,i]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(Do.Z,{itemIds:M,selectedIds:C,filterValue:m,filterPlaceholder:P("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:w,onFilterChange:S,noScrollRestore:b}),o.ZP.createElement(To.Z,{isShown:Boolean(C.length),disabled:u,ariaLabel:P("lng_channel_add_users"),onClick:R},u?o.ZP.createElement(Ve.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),jo=Object.keys(m.qt).length/2,Qo=Object.keys(m.u1).length/2;function Go(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Ho=(0,o.X$)((0,a.c$)((e=>{var t;const{chatId:n,threadId:a}=(0,r.Bt)(e)||{},s=(0,r.g4)(e),o=n?null===(t=e.management.byChatId[n])||void 0===t?void 0:t.nextScreen:void 0;return{contentKey:(0,r.Wq)(e),chatId:n,threadId:a,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(n&&s),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,nextManagementScreen:o}}))((e=>{var t;let{contentKey:n,chatId:i,threadId:r,currentProfileUserId:c,isChatSelected:l,shouldSkipHistoryAnimations:d,nextManagementScreen:u}=e;const{toggleChatInfo:h,toggleManagement:g,openUserInfo:f,closeLocalTextSearch:p,setStickerSearchQuery:v,setGifSearchQuery:I,closePollResults:y,addChatMembers:Z,setNewChatMembersDialogState:P,setEditingExportedInvite:C,setOpenedInviteInfo:w,requestNextManagementScreen:b}=(0,a.uC)(),{width:E}=wt(),[S,M]=(0,o.eJ)(m.vi.Profile),[R,k]=(0,o.eJ)(m.u1.Initial),[T,N]=(0,o.eJ)(),[B,x]=(0,o.eJ)(),A=S!==m.vi.Profile,L=void 0!==n,O=n===m.qt.ChatInfo||n===m.qt.UserInfo,U=n===m.qt.Search,F=n===m.qt.Management,$=n===m.qt.StickerSearch,D=n===m.qt.GifSearch,q=n===m.qt.PollResults,j=n===m.qt.AddingMembers,Q=E<=s._m,[G,H]=(0,o.eJ)(!L),_=null!==(t=(0,kt.Z)(n,!0,!l))&&void 0!==t?t:-1,z=(0,o.I4)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];switch(n){case m.qt.AddingMembers:P(m.WB.Closed);break;case m.qt.ChatInfo:if(A&&e){M(m.vi.Profile);break}h(void 0,{forceSyncOnIOs:!0});break;case m.qt.UserInfo:if(A&&e){M(m.vi.Profile);break}f({id:void 0},{forceSyncOnIOs:!0});break;case m.qt.Management:switch(R){case m.u1.Initial:g();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:k(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:k(m.u1.GroupPermissions),N(void 0),x(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),w({invite:void 0}),C({chatId:i,invite:void 0})}break;case m.qt.Search:Go(),p();break;case m.qt.StickerSearch:Go(),v({query:void 0});break;case m.qt.GifSearch:Go(),I({query:void 0});break;case m.qt.PollResults:y()}}),[n,A,h,f,y,P,R,g,p,v,I,C,i,w]),V=(0,o.I4)(((e,t)=>{N(e),x(t)}),[]),X=(0,o.I4)((e=>{Z({chatId:i,memberIds:e})}),[Z,i]);function Y(e){if(-1!==_)switch(_){case m.qt.AddingMembers:return o.ZP.createElement(qo,{chatId:i,onNextStep:X,isActive:L&&e,onClose:z});case m.qt.ChatInfo:case m.qt.UserInfo:return o.ZP.createElement(Ao,{key:c||i,chatId:i,userId:c,profileState:S,onProfileStateChange:M});case m.qt.Search:return o.ZP.createElement(Lo,{chatId:i,threadId:r,onClose:z,isActive:L&&e});case m.qt.Management:return o.ZP.createElement(Oo,{chatId:i,currentScreen:R,isPromotedByCurrentUser:B,selectedChatMemberId:T,onScreenSelect:k,onChatMemberSelect:V,isActive:L&&e,onClose:z});case m.qt.StickerSearch:return o.ZP.createElement(Uo,{onClose:z,isActive:L&&e});case m.qt.GifSearch:return o.ZP.createElement(Fo,{onClose:z,isActive:L&&e});case m.qt.PollResults:return o.ZP.createElement($o,{onClose:z,isActive:L&&e})}}return(0,o.d4)((()=>L?(0,Te.Z)(z):void 0),[L,z]),(0,o.d4)((()=>{setTimeout((()=>{H(!L)}),300)}),[L]),(0,o.d4)((()=>{u&&(k(u),b(void 0))}),[u,b]),(0,o.d4)((()=>{L&&Q&&z()}),[Q]),(0,ln.Z)((e=>{let[t,a]=e;(t===m.qt.ChatInfo&&n===m.qt.UserInfo||t===m.qt.UserInfo&&n===m.qt.ChatInfo||a!==i)&&(M(m.vi.Profile),k(m.u1.Initial))}),[n,i]),(0,be.ZP)(l&&(n===m.qt.ChatInfo||n===m.qt.UserInfo||n===m.qt.Management||n===m.qt.AddingMembers),(()=>z(!1)),h),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:l?void 0:"is-hidden"},Q&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:z}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(po,{chatId:i,isColumnOpen:L,isProfile:O,isSearch:U,isManagement:F,isStickerSearch:$,isGifSearch:D,isPollResults:q,isAddingChatMembers:j,profileState:S,managementScreen:R,onClose:z,shouldSkipAnimation:G||d,onScreenSelect:k}),o.ZP.createElement(Ae.Z,{name:G||d?"none":"zoom-fade",renderCount:jo+Qo,activeKey:F?jo+R:_,shouldCleanup:!0,cleanupExceptionKey:m.qt.ChatInfo},Y)))}))),_o=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,at.Z)(nt.gl.Extra,"MediaViewer",!t);return n?o.ZP.createElement(n,null):void 0}));function zo(e,t){const n=document.createElement("a");n.href=e,n.download=t;try{n.click()}catch(e){console.error(e)}}const Vo=new Set,Xo=(0,o.X$)((0,a.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})))((e=>{let{activeDownloads:t,messages:n}=e;const{cancelMessageMediaDownload:s}=(0,a.uC)();(0,o.d4)((()=>{Object.entries(t).forEach((e=>{let[t,a]=e;a.map((e=>n[Number(t)].byId[e])).forEach((e=>{const t=(0,l.Ti)(e,"download");if(t){if(!Vo.has(t)){const n=H.UV(t);if(n)return Vo.delete(t),zo(n,(0,l.w6)(e)),void s({message:e});H.he(t,u.IU.BlobUrl,!0).then((n=>{Vo.delete(t),n&&zo(n,(0,l.w6)(e)),s({message:e})})),Vo.add(t)}}else s({message:e})}))}))}),[s,n,t])}))),Yo=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,at.Z)(nt.gl.Extra,"Notifications",!t);return n?o.ZP.createElement(n,null):void 0})),Wo=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,at.Z)(nt.gl.Extra,"Dialogs",!t);return n?o.ZP.createElement(n,null):void 0})),Ko=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"ForwardPicker",!t);return n?o.ZP.createElement(n,e):void 0})),Jo=(0,o.X$)((e=>{const{url:t}=e,n=(0,at.Z)(nt.gl.Extra,"SafeLinkModal",!t);return n?o.ZP.createElement(n,e):void 0})),ei=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,at.Z)(nt.gl.Extra,"HistoryCalendar",!t);return n?o.ZP.createElement(n,e):void 0})),ti=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,at.Z)(nt.gl.Calls,"GroupCall",!t);return n?o.ZP.createElement(n,e):void 0})),ni=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,at.Z)(nt.gl.Calls,"ActiveCallHeader",!t);return n?o.ZP.createElement(n,null):void 0})),ai=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,at.Z)(nt.gl.Calls,"CallFallbackConfirm",!t);return n?o.ZP.createElement(n,{isOpen:t}):void 0}));let si,oi=!1;function ii(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 ri(e){document.title!==e&&(document.title=e)}const ci=(0,o.X$)((0,a.c$)((e=>{const{settings:{byKey:{animationLevel:t,language:n,wasTimeFormatSetManually:a}}}=e,{chatId:s,messageId:o}=e.audioPlayer,i=s&&o?(0,r.hj)(e,s,o):void 0;return{lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,r.Jf)(e),isMediaViewerOpen:(0,r.zQ)(e),isForwardModalOpen:(0,r.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:i,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,r.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:t,language:n,wasTimeFormatSetManually:a,isCallFallbackConfirmOpen:Boolean(e.groupCalls.isFallbackConfirmOpen),addedSetIds:e.stickers.added.setIds}}))((e=>{let{lastSyncTime:t,isLeftColumnShown:n,isRightColumnShown:i,isMediaViewerOpen:r,isForwardModalOpen:c,hasNotifications:l,hasDialogs:d,audioMessage:u,activeGroupCallId:m,safeLinkModalUrl:g,isHistoryCalendarOpen:f,shouldSkipHistoryAnimations:p,openedStickerSetShortName:v,isServiceChatReady:I,animationLevel:y,language:Z,wasTimeFormatSetManually:P,isCallFallbackConfirmOpen:w,addedSetIds:b}=e;const{loadAnimatedEmojis:E,loadNotificationSettings:S,loadNotificationExceptions:M,updateIsOnline:R,loadTopInlineBots:k,loadEmojiKeywords:T,loadCountryList:N,loadAvailableReactions:B,loadStickerSets:x,loadAddedStickers:A,loadFavoriteStickers:L,ensureTimeFormat:O,openStickerSetShortName:U,checkVersionNotification:F,loadAppConfig:$}=(0,a.uC)(),D=Boolean(t);s.eM&&!oi&&(oi=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{t&&(R(!0),$(),B(),E(),S(),M(),k(),T({language:s.pR}))}),[t,E,T,M,S,k,R,B,$]),(0,o.d4)((()=>{t&&(Z!==s.pR&&T({language:Z}),N({langCode:Z}))}),[Z,t,N,T]),(0,o.d4)((()=>{D&&(b?A():(x(),L()))}),[D,b,x,L,A]),(0,o.d4)((()=>{t&&I&&F()}),[t,I,F]),(0,o.d4)((()=>{t&&!P&&O()}),[t,P,O]),(0,o.d4)((()=>{t&&be.Oy.startsWith("#?tgaddr=")&&(0,he.o)(decodeURIComponent(be.Oy.substr("#?tgaddr=".length)))}),[t]),(0,o.d4)((()=>{if(m)return Y.Z.disableRefresh(),()=>{Y.Z.enableRefresh()}}),[m]);const{transitionClassNames:q}=(0,pe.Z)(!n,void 0,!0,void 0,p),{transitionClassNames:j}=(0,pe.Z)(i,void 0,!0,void 0,p),Q=(0,ue.Z)(q.replace(/([\w-]+)/g,"middle-column-$1"),j.replace(/([\w-]+)/g,"right-column-$1"),p&&"history-animation-disabled");(0,ye.Z)((e=>{let[t]=e;if(void 0===t||0===y)return;const n=(0,de.YW)();(0,me.L)(document.getElementById("MiddleColumn"),n)}),[n]),(0,ye.Z)((e=>{let[t]=e;if(void 0===t||0===y)return;(0,C.T2)((()=>{document.body.classList.add("animating-right-column")}));const n=(0,de.YW)();(0,me.L)(document.getElementById("RightColumn"),(()=>{n(),(0,C.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[i]);const G=(0,o.I4)((()=>{R(!1);const e=(0,fe.xW)();let t=0;clearInterval(si),si=window.setInterval((()=>{if(document.title.includes(s.ou))ii(!1);else{if(t%2==0){const t=(0,fe.xW)()-e;t>0&&(ri(`${t} notification${t>1?"s":""}`),ii(!0))}else ri(s.Ti),ii(!1);t++}}),1e3)}),[R]),H=(0,o.I4)((()=>{R(!0),clearInterval(si),si=void 0,document.title.includes(s.ou)||ri(s.Ti),ii(!1)}),[R]),_=(0,o.I4)((()=>{U({stickerSetShortName:void 0})}),[U]);return(0,ve.Z)(G,H),Ie(G),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,o.d4)((()=>{if(h.$b){if(!e)return null==Ze||Ze.setAttribute("content",Pe),h.cj&&!h.fl&&document.addEventListener("gesturestart",we),()=>{null==Ze||Ze.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",we)};null==Ze||Ze.setAttribute("content",Ce)}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:Q,onDrop:ge.Z,onDragOver:ge.Z},o.ZP.createElement(It,null),o.ZP.createElement(ho,null),o.ZP.createElement(Ho,null),o.ZP.createElement(_o,{isOpen:r}),o.ZP.createElement(Ko,{isOpen:c}),o.ZP.createElement(Yo,{isOpen:l}),o.ZP.createElement(Wo,{isOpen:d}),u&&o.ZP.createElement(an,{key:u.id,message:u,noUi:!0}),o.ZP.createElement(Jo,{url:g}),o.ZP.createElement(ei,{isOpen:f}),o.ZP.createElement(Ee.Z,{isOpen:Boolean(v),onClose:_,stickerSetShortName:v}),m&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(ti,{groupCallId:m}),o.ZP.createElement(ni,{groupCallId:m})),o.ZP.createElement(Xo,null),o.ZP.createElement(ai,{isOpen:w}),o.ZP.createElement(ke,{isForAppBadge:!0}))})));s.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,a.Rd)().connectionState||(0,a.uC)().initApi()},4524:(e,t,n)=>{e.exports=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg"}}]);
|
||
//# sourceMappingURL=347.5f26cfd12c2e5acbf04e.js.map
|