mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-12 09:09:45 +01:00
2 lines
220 KiB
JavaScript
2 lines
220 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[25],{8025:(e,t,s)=>{s.r(t),s.d(t,{Main:()=>ao});var a=s(5116),n=s(3716),o=s(4050),r=(s(7895),s(1752)),i=s(8085),c=s(735),d=s(2858);function l(e){const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};return t&&s?(e=(0,r.qr)(e,t,s,!1),e=(0,r.Pb)(e,t,s,void 0)):e}(0,a.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(t&&s)return(0,r.qr)(e,t,s,!0)})),(0,a.Q6)("closeLocalTextSearch",l),(0,a.Q6)("setLocalTextSearchQuery",((e,t,s)=>{const{chatId:a,threadId:n}=(0,i.Bt)(e)||{};if(!a||!n)return;const{query:o}=s,l=(0,d.uw)(a,n),{query:u}=e.localTextSearch.byChatThreadKey[l]||{};return o!==u&&(e=(0,r.Pb)(e,a,n,c.D)),(0,r.qr)(e,a,n,!0,o)})),(0,a.Q6)("setLocalMediaSearchType",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};if(!a)return;const{mediaType:n}=s;return(0,r.z5)(e,a,n)})),(0,a.Q6)("openChat",((e,t,s)=>{const{id:n,threadId:o=-1,type:c="thread",shouldReplaceHistory:d=!1}=s,u=(0,i.Bt)(e);return u&&u.chatId===n&&u.threadId===o&&u.type===c||(e=(0,r.pf)(e,n,o,"replyStack",[]),e=l(e=(0,r.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...n!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,a.R3)(e)),(0,r.Wy)(e,n,o,c,d)})),(0,a.Q6)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,a.Q6)("openChatWithInfo",((e,t,s)=>{(0,a.R3)({...e,isChatInfoShown:!0}),t.openChat(s)})),(0,a.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,a.Q6)("setNewChatMembersDialogState",((e,t,s)=>({...e,newChatMembersProgress:s}))),(0,a.Q6)("openNextChat",((e,t,s)=>{const{targetIndexDelta:a,orderedIds:n}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return void t.openChat({id:n[0]});const r=n.indexOf(o);if(-1===r)return;const c=n[r+a];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=s(6137),h=s(1713),m=s(7361),g=s(782);const f=n.ck+n.fK;let p;(0,a.Q6)("setScrollOffset",((e,t,s)=>{const{chatId:a,threadId:n,scrollOffset:o}=s;return(0,r.pf)(e,a,n,"scrollOffset",o)})),(0,a.Q6)("setReplyingToId",((e,t,s)=>{const{messageId:a}=s,n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:c}=n;return(0,r.pf)(e,o,c,"replyingToId",a)})),(0,a.Q6)("setEditingId",((e,t,s)=>{const{messageId:a}=s,n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:c,type:d}=n,l="scheduled"===d?"editingScheduledId":"editingId";return(0,r.pf)(e,o,c,l,a)})),(0,a.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(!t||!s)return;const a=(0,i.Zw)(e,t),n=(0,i.Cb)(e,t,s);if(!a||!n)return;const o=(0,g.dF)(n,(t=>Boolean(a[t]&&(0,i._k)(e,a[t],s).canEdit)));return o?(0,r.pf)(e,t,s,"editingId",o):void 0})),(0,a.Q6)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:a}=s,{chatId:n,threadId:o}=(0,i.Bt)(e)||{};if(!n||!o)return;const r=(0,i.Zw)(e,n),c=(0,i.Cb)(e,n,o);if(!r||!c)return;const d=(0,i.Yy)(e,n,o);let l;if((0,i.b9)(e,n,o)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+a;l=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){const t=(0,i.Z1)(e,n);l=t&&t.lastMessage?t.lastMessage.id:void 0}else{const t=(0,i.tZ)(e,n,o);l=t?t.lastMessageId:void 0}t.setReplyingToId({messageId:l}),t.focusMessage({chatId:n,threadId:o,messageId:l})})),(0,a.Q6)("openMediaViewer",((e,t,s)=>{const{chatId:a,threadId:n,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c}=s;return{...e,mediaViewer:{chatId:a,threadId:n,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c},forwardMessages:{}}})),(0,a.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,a.Q6)("openAudioPlayer",((e,t,s)=>{const{chatId:a,threadId:n,messageId:o}=s;return{...e,audioPlayer:{chatId:a,threadId:n,messageId:o}}})),(0,a.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{}}))),(0,a.Q6)("openPollResults",((e,t,s)=>{const{chatId:n,messageId:o}=s;(0,i.Jf)(e)?n===e.pollResults.chatId&&o===e.pollResults.messageId||(0,a.R3)({...e,pollResults:{chatId:n,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,a.Rd)();(0,a.R3)({...e,pollResults:{chatId:n,messageId:o,voters:{}}})}),450)})),(0,a.Q6)("closePollResults",(e=>{(0,a.R3)({...e,pollResults:{}})})),(0,a.Q6)("focusLastMessage",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:a,threadId:n}=s;let o;if(n===u._f){const t=(0,i.Z1)(e,a);o=t&&t.lastMessage?t.lastMessage.id:void 0}else{const t=(0,i.tZ)(e,a,n);o=t?t.lastMessageId:void 0}o&&t.focusMessage({chatId:a,threadId:n,messageId:o,noHighlight:!0})})),(0,a.Q6)("focusNextReply",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:n,threadId:o}=s,c=(0,i.p9)(e,n,o);if(c&&0!==c.length){const s=c.pop();e=(0,r.pf)(e,n,o,"replyStack",[...c]),(0,a.R3)(e),t.focusMessage({chatId:n,threadId:o,messageId:s})}else t.focusLastMessage()})),(0,a.Q6)("focusMessage",((e,t,s)=>{const{chatId:n,threadId:o=u._f,messageListType:c="thread",noHighlight:d,groupedId:l,groupedChatId:m,replyMessageId:g,isResizingContainer:I}=s;let{messageId:v}=s;if(void 0!==l){const t=(0,i.y8)(e,m,l);t&&t.length&&([v]=t)}const y=(0,i.Bt)(e),Z=!y||n!==y.chatId||o!==y.threadId||c!==y.type;if(p&&(clearTimeout(p),p=void 0),p=window.setTimeout((()=>{let e=(0,a.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,a.R3)(e)}),d?f:1500),e=(0,r.cq)(e,n,v,d,I),e=(0,r.wV)(e,void 0),g){const t=(0,i.p9)(e,n,o)||[];e=(0,r.pf)(e,n,o,"replyStack",[...t,g])}Z&&(e=(0,r.wV)(e,h.fo.Static));const P=(0,i.Cb)(e,n,o);if(P&&P.includes(v))return(0,a.R3)(e),void t.openChat({id:n,threadId:o});if(Z&&(e=(0,r.pf)(e,n,o,"viewportIds",void 0)),e=(0,r.pf)(e,n,o,"outlyingIds",void 0),P&&!Z){const t=v>P[0]?h.fo.Down:h.fo.Up;e=(0,r.wV)(e,t)}(0,a.R3)(e),t.openChat({id:n,threadId:o}),t.loadViewportMessages()})),(0,a.Q6)("openForwardMenu",((e,t,s)=>{const{fromChatId:a,messageIds:n,groupedId:o}=s;let r;return o&&(r=(0,i.xH)(e,a,o)),{...e,forwardMessages:{fromChatId:a,messageIds:r||n,isModalShown:!0}}})),(0,a.Q6)("exitForwardMode",(e=>{(0,a.R3)({...e,forwardMessages:{}})})),(0,a.Q6)("setForwardChatId",((e,t,s)=>{const{id:n}=s;(0,a.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:n,isModalShown:!1}}),t.openChat({id:n}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,a.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:a}=e.selectedMessages;t.openForwardMenu({fromChatId:s,messageIds:a})})),(0,a.Q6)("enterMessageSelectMode",((e,t,s)=>{const{messageId:a}=s||{},n=(0,i.jr)(e);return n?(0,r.M6)(e,n.id,a):e})),(0,a.Q6)("toggleMessageSelection",((e,t,s)=>{const{messageId:n,groupedId:o,childMessageIds:c,withShift:d}=s,l=(0,i.Bt)(e);if(!l)return;const{chatId:u,threadId:h,type:g}=l;e=(0,r.Ob)(e,u,h,g,n,o,c,d),(0,a.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${m.$b?"long tap":"right click"} on a message.`}))})),(0,a.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,a.Q6)("exitMessageSelectMode",r.i9),(0,a.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,a.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,a.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{query:a}=s,{chatId:n}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!n,messages:!0}}:{fetchingStatus:void 0},query:a})})),(0,a.Q6)("addRecentlyFoundChatId",((e,t,s)=>{const{id:a}=s,{recentlyFoundChatIds:n}=e.globalSearch;if(!n)return(0,r.No)(e,{recentlyFoundChatIds:[a]});const o=n.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,a.Q6)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,a.Q6)("setGlobalSearchContent",((e,t,s)=>{const{content:a}=s;return(0,r.Og)(e,a)})),(0,a.Q6)("setGlobalSearchChatId",((e,t,s)=>{const{id:a}=s;return(0,r.No)(e,{chatId:a,query:void 0,resultsByType:void 0})})),(0,a.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:a}=s;return{...e,stickers:{...e.stickers,search:{query:a,resultIds:void 0}}}})),(0,a.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:a}=s;return{...e,gifs:{...e.gifs,search:{query:a,offsetId:void 0,results:void 0}}}})),(0,a.Q6)("openUserInfo",((e,t,s)=>{const{id:a}=s;t.openChat({id:a})})),(0,a.Q6)("openChat",(e=>(0,r.x1)(e,void 0))),(0,a.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:a}=s;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a})})),s(3781);var I=s(1947),v=s(6926);(0,a.Q6)("toggleChatInfo",(e=>({...e,isChatInfoShown:!e.isChatInfoShown}))),(0,a.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,i.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)("closeManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,a.Q6)("openChat",(e=>{if(m.wB||m.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,a.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,a.Q6)("addRecentEmoji",((e,t,s)=>{const{emoji:a}=s,{recentEmojis:n}=e;if(!n)return{...e,recentEmojis:[a]};const o=n.filter((e=>e!==a));return o.unshift(a),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,a.Q6)("addRecentSticker",((e,t,s)=>{const{sticker:a}=s,{recent:n}=e.stickers;if(!n)return{...e,stickers:{...e.stickers,recent:{hash:0,stickers:[a]}}};const o=n.stickers.filter((e=>e.id!==a.id));return o.unshift(a),{...e,stickers:{...e.stickers,recent:{...n,stickers:o}}}})),(0,a.Q6)("showNotification",((e,t,s)=>{const a=s;a.localId=(0,v.Z)({});const n=[...e.notifications],o=n.findIndex((e=>e.message===a.message));return-1!==o&&n.splice(o,1),n.push(a),{...e,notifications:n}})),(0,a.Q6)("dismissNotification",((e,t,s)=>{const a=e.notifications.filter((({localId:e})=>e!==s.localId));return{...e,notifications:a}})),(0,a.Q6)("showDialog",((e,t,s)=>{const{data:a}=s;if("message"in a&&a.hasErrorKey&&!(0,I.ZP)(a))return e;const n=[...e.dialogs];if("message"in a){const e=n.findIndex((e=>e.message===a.message));-1!==e&&n.splice(e,1)}return n.push(a),{...e,dialogs:n}})),(0,a.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,a.Q6)("toggleSafeLinkModal",((e,t,s)=>{const{url:a}=s;return{...e,safeLinkModalUrl:a}})),(0,a.Q6)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:a}=s;return{...e,historyCalendarSelectedAt:a}})),(0,a.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,a.Q6)("openPaymentModal",((e,t,s)=>{const{chatId:a,messageId:n}=s;return{...e,payment:{...e.payment,chatId:a,messageId:n,isPaymentModalOpen:!0}}})),(0,a.Q6)("closePaymentModal",(e=>{const t=(0,r.bp)(e);return(0,r.WY)(t)})),(0,a.Q6)("addPaymentError",((e,t,s)=>{const{error:a}=s;return{...e,payment:{...e.payment,error:a}}})),s(1363);var y=s(1226),Z=s(9118);const P=(0,Z.P2)((e=>e()),1e3,!0),C=(0,Z.P2)((e=>e()),3e3,!0),w=(0,Z.Ds)((e=>e()),500,!1,!0);async function b(e,t,s){const o=await(0,y.t9)("fetchChats",{limit:n.Ov,offsetDate:s,archived:"archived"===e,withPinned:void 0===(0,a.Rd)().chats.orderedPinnedIds[e],serverTimeOffset:(0,a.Rd)().serverTimeOffset});if(!o)return;const{chatIds:i}=o;i.length>0&&i[0]===t&&i.shift();let c=(0,a.Rd)();c=(0,r.Sh)(c,(0,g.ee)(o.users,"id")),c=(0,r.GL)(c,(0,g.ee)(o.chats,"id")),c=(0,r.B1)(c,e,i),c=(0,r.vv)(c,e,o),Object.keys(o.draftsById).map(Number).forEach((e=>{c=(0,r.pf)(c,e,u._f,"draft",o.draftsById[e])})),Object.keys(o.replyingToById).map(Number).forEach((e=>{c=(0,r.pf)(c,e,u._f,"replyingToId",o.replyingToById[e])})),0!==i.length||c.chats.isFullyLoaded[e]||(c={...c,chats:{...c.chats,isFullyLoaded:{...c.chats.isFullyLoaded,[e]:!0}}}),(0,a.R3)(c)}async function M(e){const t=await(0,y.t9)("fetchFullChat",e);if(!t)return;const{users:s,fullInfo:n}=t;let o=(0,a.Rd)();s&&(o=(0,r.Sh)(o,(0,g.ee)(s,"id"))),o=(0,r.a4)(o,e.id,{fullInfo:n}),(0,a.R3)(o)}async function S(e,t,s){const n=(0,a.Rd)(),o=(0,i.DI)(n,t);if(o&&!o.isMin)return void(s?e.focusMessage({chatId:o.id,messageId:s}):e.openChat({id:o.id}));const c=(0,i.jr)(n);e.openChat({id:-1});const d=await(0,y.t9)("getChatByUsername",t);if(!d)return c&&e.openChat({id:c.id}),void e.showNotification({message:"User does not exist"});(0,a.R3)((0,r.a4)((0,a.Rd)(),d.id,d)),s?e.focusMessage({chatId:d.id,messageId:s}):e.openChat({id:d.id})}(0,a.Q6)("preloadTopChatMessages",((e,t)=>{(async()=>{const s=[];for(let o=0;o<n.ul;o++){await(0,Z.wO)(100);const{byId:n,listIds:{active:o},orderedPinnedIds:{active:r}}=(0,a.Rd)().chats;if(!o)return;const{chatId:c}=(0,i.Bt)(e)||{},{pinnedChats:l,otherChats:h}=(0,d.O)(n,o,r),m=[...l,...h].find((({id:e})=>e!==c&&!s.includes(e)));if(!m)return;s.push(m.id),t.loadViewportMessages({chatId:m.id,threadId:u._f})}})()})),(0,a.Q6)("openChat",((e,t,s)=>{const{id:a,threadId:n}=s,{currentUserId:o}=e,r=(0,i.Z1)(e,a);if(r&&r.hasUnreadMark&&t.toggleChatUnread({id:a}),r&&r.lastMessage&&r.lastMessage.threadInfo&&t.requestThreadInfoUpdate({chatId:r.lastMessage.threadInfo.chatId,threadId:r.lastMessage.threadInfo.threadId}),r)(0,d.Hp)(r)&&!r.isMin&&t.requestChatUpdate({chatId:a});else if(a===o)(0,y.t9)("fetchChat",{type:"self"});else{const t=(0,i.dy)(e,a);t&&(0,y.t9)("fetchChat",{type:"user",user:t})}n!==u._f&&((0,i.qS)(e,a,n)||t.requestThreadInfoUpdate({chatId:a,threadId:n}))})),(0,a.Q6)("openSupportChat",((e,t)=>{const s=(0,i.P_)(e);t.openChat({id:s?s.id:-1}),s||(async()=>{const e=await(0,y.t9)("fetchChat",{type:"support"});e&&t.openChat({id:e.chatId})})()})),(0,a.Q6)("openTipsChat",((e,t,s)=>{const{langCode:a}=s,o="pt-br"===a?"BR":n.Db.includes(a)?a.toUpperCase():"";t.openChatByUsername({username:`${n.vi}${o}`})})),(0,a.Q6)("loadMoreChats",((e,t,s)=>{const{listType:a="active"}=s,n=e.chats.listIds[a];if(e.chats.isFullyLoaded[a])return;const o=n?n.map((t=>e.chats.byId[t])).filter((t=>Boolean(t&&t.lastMessage)&&!(0,i.ep)(e,t.id))).sort(((e,t)=>e.lastMessage.date-t.lastMessage.date))[0]:void 0;P(o?()=>b(a,o.id,o.lastMessage.date):()=>b(a))})),(0,a.Q6)("loadFullChat",((e,t,s)=>{const{chatId:a,force:n}=s,o=(0,i.Z1)(e,a);o&&(n?M(o):w((()=>M(o))))})),(0,a.Q6)("loadTopChats",(()=>{C((()=>b("active")))})),(0,a.Q6)("requestChatUpdate",((e,t,s)=>{const{serverTimeOffset:a}=e,{chatId:n}=s,o=(0,i.Z1)(e,n);o&&(0,y.t9)("requestChatUpdate",{chat:o,serverTimeOffset:a})})),(0,a.Q6)("updateChatMutedState",((e,t,s)=>{const{serverTimeOffset:n}=e,{chatId:o,isMuted:c}=s,d=(0,i.Z1)(e,o);d&&((0,a.R3)((0,r.a4)(e,o,{isMuted:c})),(0,y.t9)("updateChatMutedState",{chat:d,isMuted:c,serverTimeOffset:n}))})),(0,a.Q6)("createChannel",((e,t,s)=>{const{title:n,about:o,photo:c,memberIds:d}=s;!async function(e,t,s,n){(0,a.R3)({...(0,a.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const o=await(0,y.t9)("createChannel",{title:e,about:s,users:t});if(!o)return;const{id:i,accessHash:c}=o;let d=(0,a.Rd)();d=(0,r.a4)(d,i,o),d={...d,chatCreation:{...d.chatCreation,progress:o?h.Nh.Complete:h.Nh.Error}},(0,a.R3)(d),(0,a.uC)().openChat({id:i}),i&&c&&n&&await(0,y.t9)("editChatPhoto",{chatId:i,accessHash:c,photo:n})}(n,d.map((t=>(0,i.dy)(e,t))).filter(Boolean),o,c)})),(0,a.Q6)("joinChannel",((e,t,s)=>{const{chatId:a}=s,n=(0,i.Z1)(e,a);if(!n)return;const{id:o,accessHash:r}=n;o&&r&&(0,y.t9)("joinChannel",{channelId:o,accessHash:r})})),(0,a.Q6)("deleteChatUser",((e,t,s)=>{(async()=>{const{chatId:a,userId:n}=s,o=(0,i.Z1)(e,a),r=(0,i.dy)(e,n);if(!o||!r)return;await(0,y.t9)("deleteChatUser",{chat:o,user:r});const c=(0,i.Bt)(e);c&&c.chatId===a&&e.currentUserId===n&&t.openChat({id:void 0})})()})),(0,a.Q6)("deleteChat",((e,t,s)=>{(async()=>{const{chatId:a}=s,n=(0,i.Z1)(e,a);if(!n)return;await(0,y.t9)("deleteChat",{chatId:n.id});const o=(0,i.Bt)(e);o&&o.chatId===a&&t.openChat({id:void 0})})()})),(0,a.Q6)("leaveChannel",((e,t,s)=>{(async()=>{const{chatId:a}=s,n=(0,i.Z1)(e,a);if(!n)return;const{id:o,accessHash:r}=n;o&&r&&await(0,y.t9)("leaveChannel",{channelId:o,accessHash:r});const c=(0,i.Bt)(e);c&&c.chatId===a&&t.openChat({id:void 0})})()})),(0,a.Q6)("deleteChannel",((e,t,s)=>{(async()=>{const{chatId:a}=s,n=(0,i.Z1)(e,a);if(!n)return;const{id:o,accessHash:r}=n;o&&r&&await(0,y.t9)("deleteChannel",{channelId:o,accessHash:r});const c=(0,i.Bt)(e);c&&c.chatId===a&&t.openChat({id:void 0})})()})),(0,a.Q6)("createGroupChat",((e,t,s)=>{const{title:n,memberIds:o,photo:c}=s;!async function(e,t,s){(0,a.R3)({...(0,a.Rd)(),chatCreation:{progress:h.Nh.InProgress}});const n=await(0,y.t9)("createGroupChat",{title:e,users:t});if(!n)return;const{id:o}=n;let i=(0,a.Rd)();i=(0,r.a4)(i,o,n),i={...i,chatCreation:{...i.chatCreation,progress:n?h.Nh.Complete:h.Nh.Error}},(0,a.R3)(i),(0,a.uC)().openChat({id:o}),o&&s&&await(0,y.t9)("editChatPhoto",{chatId:o,photo:s})}(n,o.map((t=>(0,i.dy)(e,t))).filter(Boolean),c)})),(0,a.Q6)("toggleChatPinned",((e,t,s)=>{const{id:a,folderId:o}=s,r=(0,i.Z1)(e,a);if(r)if(o){const t=(0,i.Mw)(e,o);if(t){const s=!(0,i.ep)(e,a,o),{pinnedChatIds:n,includedChatIds:r}=t,c=s?[a,...n||[]]:(n||[]).filter((e=>e!==a)),d=[a,...r];(0,y.t9)("editChatFolder",{id:o,folderUpdate:{...t,pinnedChatIds:c,includedChatIds:d}})}}else{const t=(0,i.Ek)(e,a),s=(0,i.ep)(e,a,"archived"===t?n.WS:void 0);(0,y.t9)("toggleChatPinned",{chat:r,shouldBePinned:!s})}})),(0,a.Q6)("toggleChatArchived",((e,t,s)=>{const{id:a}=s,o=(0,i.Z1)(e,a);o&&(0,y.t9)("toggleChatArchived",{chat:o,folderId:(0,d.pE)(o)?0:n.WS})})),(0,a.Q6)("loadChatFolders",(()=>{!async function(){const e=await(0,y.t9)("fetchChatFolders");if(e){const t=(0,a.Rd)();(0,a.R3)({...t,chatFolders:{...t.chatFolders,...e}})}}()})),(0,a.Q6)("loadRecommendedChatFolders",(()=>{!async function(){const e=await(0,y.t9)("fetchRecommendedChatFolders");if(e){const t=(0,a.Rd)();(0,a.R3)({...t,chatFolders:{...t.chatFolders,recommended:e}})}}()})),(0,a.Q6)("editChatFolder",((e,t,s)=>{const{id:a,folderUpdate:n}=s,o=(0,i.Mw)(e,a);o&&(0,y.t9)("editChatFolder",{id:a,folderUpdate:{id:a,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...n}})})),(0,a.Q6)("addChatFolder",((e,t,s)=>{const{folder:o}=s,{orderedIds:r}=e.chatFolders;!async function(e,t){const{id:s,description:n,...o}=e;if(await(0,y.t9)("editChatFolder",{id:t+1,folderUpdate:{id:t+1,...o}}),!n)return;const r=(0,a.Rd)(),{recommended:i}=r.chatFolders;i&&(0,a.R3)({...r,chatFolders:{...r.chatFolders,recommended:i.filter((({id:e})=>e!==s))}})}(o,r&&r.length?Math.max.apply(Math.max,r):n.WS)})),(0,a.Q6)("deleteChatFolder",((e,t,s)=>{const{id:a}=s;(0,i.Mw)(e,a)&&async function(e){await(0,y.t9)("deleteChatFolder",e)}(a)})),(0,a.Q6)("toggleChatUnread",((e,t,s)=>{const{id:a}=s,{serverTimeOffset:n}=e,o=(0,i.Z1)(e,a);o&&(o.unreadCount?(0,y.t9)("markMessageListRead",{serverTimeOffset:n,chat:o,threadId:u._f}):(0,y.t9)("toggleDialogUnread",{chat:o,hasUnreadMark:!o.hasUnreadMark}))})),(0,a.Q6)("openTelegramLink",((e,t,s)=>{const{url:a}=s;let o=n.Lj.exec(a);if(o){const e=o[1];(async()=>{const s=await(0,y.t9)("openChatByInvite",e);s&&t.openChat({id:s.chatId})})()}else{o=n.FS.exec(a);const e=o[1],s=o[2]?Number(o[2]):void 0,r=o[3]?Number(o[3]):void 0;"c"===e&&s&&r?t.focusMessage({chatId:-s,messageId:r}):S(t,e,s)}})),(0,a.Q6)("acceptInviteConfirmation",((e,t,s)=>{const{hash:a}=s;(async()=>{const e=await(0,y.t9)("importChatInvite",{hash:a});e&&t.openChat({id:e.id})})()})),(0,a.Q6)("openChatByUsername",((e,t,s)=>{const{username:a}=s;S(t,a)})),(0,a.Q6)("togglePreHistoryHidden",((e,t,s)=>{const{chatId:a,isEnabled:n}=s;let o=(0,i.Z1)(e,a);o&&(async()=>{if((0,d.G9)(o)){if(o=await(0,y.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}(0,y.t9)("togglePreHistoryHidden",{chat:o,isEnabled:n})})()})),(0,a.Q6)("updateChatDefaultBannedRights",((e,t,s)=>{const{chatId:a,bannedRights:n}=s,o=(0,i.Z1)(e,a);o&&(0,y.t9)("updateChatDefaultBannedRights",{chat:o,bannedRights:n})})),(0,a.Q6)("updateChatMemberBannedRights",((e,t,s)=>{const{chatId:n,userId:o,bannedRights:c}=s;let l=(0,i.Z1)(e,n);const u=(0,i.dy)(e,o);l&&u&&(async()=>{if((0,d.G9)(l)){if(l=await(0,y.t9)("migrateChat",l),!l)return;t.openChat({id:l.id})}await(0,y.t9)("updateChatMemberBannedRights",{chat:l,user:u,bannedRights:c});const e=(0,a.Rd)(),s=(0,i.Z1)(e,n);if(!s||!s.fullInfo)return;const{members:h,kickedMembers:m}=s.fullInfo,g=!!c.viewMessages,f=!Object.keys(c).length;(0,a.R3)((0,r.a4)(e,n,{fullInfo:{...s.fullInfo,...h&&g&&{members:h.filter((e=>e.userId!==o))},...h&&!g&&{members:h.map((e=>e.userId===o?{...e,bannedRights:c}:e))},...f&&m&&{kickedMembers:m.filter((e=>e.userId!==o))}}}))})()})),(0,a.Q6)("updateChatAdmin",((e,t,s)=>{const{chatId:n,userId:o,adminRights:c,customTitle:l}=s;let u=(0,i.Z1)(e,n);const h=(0,i.dy)(e,o);u&&h&&(async()=>{if((0,d.G9)(u)){if(u=await(0,y.t9)("migrateChat",u),!u)return;t.openChat({id:u.id})}await(0,y.t9)("updateChatAdmin",{chat:u,user:h,adminRights:c,customTitle:l});const e=(0,a.Rd)(),s=(0,i.Z1)(e,n);if(!s||!s.fullInfo)return;const{adminMembers:m}=s.fullInfo,g=!Object.keys(c).length;(0,a.R3)((0,r.a4)(e,n,{fullInfo:{...s.fullInfo,...m&&g&&{adminMembers:m.filter((e=>e.userId!==o))},...m&&!g&&{adminMembers:m.map((e=>e.userId===o?{...e,adminRights:c,customTitle:l}:e))}}}))})()})),(0,a.Q6)("updateChat",((e,t,s)=>{const{chatId:n,title:o,about:c,photo:d}=s,l=(0,i.Z1)(e,n);l&&(async()=>{(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.InProgress)),await Promise.all([l.title!==o?(0,y.t9)("updateChatTitle",l,o):void 0,l.fullInfo&&l.fullInfo.about!==c?(0,y.t9)("updateChatAbout",l,c):void 0,d?(0,y.t9)("editChatPhoto",{chatId:n,accessHash:l.accessHash,photo:d}):void 0]),(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.Complete))})()})),(0,a.Q6)("toggleSignatures",((e,t,s)=>{const{chatId:a,isEnabled:n}=s,o=(0,i.Z1)(e,a);o&&(0,y.t9)("toggleSignatures",{chat:o,isEnabled:n})})),(0,a.Q6)("loadGroupsForDiscussion",(()=>{(async()=>{const e=await(0,y.t9)("fetchGroupsForDiscussion");if(!e)return;const t=e.reduce(((e,t)=>(t&&(e[t.id]=t),e)),{}),s=(0,r.fZ)((0,a.Rd)(),t);(0,a.R3)({...s,chats:{...s.chats,forDiscussionIds:Object.keys(t).map(Number)}})})()})),(0,a.Q6)("linkDiscussionGroup",((e,t,s)=>{const{channelId:a,chatId:n}=s,o=(0,i.Z1)(e,a);let r=(0,i.Z1)(e,n);o&&r&&(async()=>{if((0,d.G9)(r)){if(r=await(0,y.t9)("migrateChat",r),!r)return;t.openChat({id:r.id})}let{fullInfo:e}=r;if(!e){const t=await(0,y.t9)("fetchFullChat",r);if(!t)return;e=t.fullInfo}e.isPreHistoryHidden&&await(0,y.t9)("togglePreHistoryHidden",{chat:r,isEnabled:!1}),(0,y.t9)("setDiscussionGroup",{channel:o,chat:r})})()})),(0,a.Q6)("unlinkDiscussionGroup",((e,t,s)=>{const{channelId:a}=s,n=(0,i.Z1)(e,a);if(!n)return;let o;n.fullInfo&&n.fullInfo.linkedChatId&&(o=(0,i.Z1)(e,n.fullInfo.linkedChatId)),(async()=>{await(0,y.t9)("setDiscussionGroup",{channel:n}),o&&M(o)})()})),(0,a.Q6)("setActiveChatFolder",((e,t,s)=>({...e,chatFolders:{...e.chatFolders,activeChatFolder:s}}))),(0,a.Q6)("loadMoreMembers",(e=>{(async()=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t?(0,i.Z1)(e,t):void 0;if(!s||(0,d.G9)(s))return;const n=s.fullInfo&&s.fullInfo.members&&s.fullInfo.members.length||void 0,o=await(0,y.t9)("fetchMembers",s.id,s.accessHash,"recent",n);if(!o)return;const{members:c,users:l}=o;c&&c.length&&(e=(0,a.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(l,"id")),e=(0,r.a4)(e,s.id,{fullInfo:{...s.fullInfo,members:[...(s.fullInfo||{}).members||[],...c||[]]}}),(0,a.R3)(e))})()})),(0,a.Q6)("addChatMembers",((e,t,s)=>{const{chatId:a,memberIds:n}=s,o=(0,i.Z1)(e,a),r=n.map((t=>(0,i.dy)(e,t))).filter(Boolean);o&&r.length&&(t.setNewChatMembersDialogState(h.WB.Loading),(async()=>{await(0,y.t9)("addChatMembers",o,r),t.setNewChatMembersDialogState(h.WB.Closed),M(o)})())})),(0,a.Q6)("deleteChatMember",((e,t,s)=>{const{chatId:a,userId:n}=s,o=(0,i.Z1)(e,a),r=(0,i.dy)(e,n);o&&r&&(async()=>{await(0,y.t9)("deleteChatMember",o,r),M(o)})()}));const E=new Map,k=(0,Z.Ds)((e=>e()),500,!1);async function R(e,t,s,o,c=!1,d=!1){const l=e.id;let u;switch(o){case h.Uq.Backwards:u=void 0;break;case h.Uq.Around:u=-(Math.round(n.hT/2)+1);break;case h.Uq.Forwards:u=-(n.hT+1)}const m=await(0,y.t9)("fetchMessages",{chat:(0,i.Cm)((0,a.Rd)(),l,t),offsetId:s,addOffset:u,limit:n.hT,threadId:t});if(!m)return;const{messages:f,users:p,chats:I,threadInfos:v}=m,Z=(0,g.ee)(f,"id"),P=Object.keys(Z).map(Number);let C=(0,a.Rd)();C=(0,r.c_)(C,l,Z),C=c?(0,r.ff)(C,l,t,P):(0,r.xj)(C,l,t,P),C=(0,r.Sh)(C,(0,g.ee)(p,"id")),C=(0,r.fZ)(C,(0,g.ee)(I,"id")),C=(0,r.j6)(C,l,v);let w=(0,i.gb)(C,l,t);const b=(0,i.qC)(C,l,t);if(c&&w&&b&&(0,g.YE)(w,b)&&(C=(0,r.xj)(C,l,t,b),w=(0,i.gb)(C,l,t),C=(0,r.pf)(C,l,t,"outlyingIds",void 0),c=!1),!d){const e=c?b:w,{newViewportIds:a}=T(e,s,o);C=(0,r.y9)(C,l,t,a)}(0,a.R3)(C)}function T(e,t,s){const{length:a}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,a)=>s===t||s<t&&e[a+1]>t))}(e,t):-1,r=s===h.Uq.Backwards?o:o+1||a,i=r-n.hT,c=r+n.hT-1,d=e.slice(Math.max(0,i),c+1);let l,u;switch(s){case h.Uq.Backwards:l=r>0,u=i>=0;break;case h.Uq.Forwards:l=r<a,u=c<=a-1;break;case h.Uq.Around:default:l=d.length>0,u=d.length===n.hT}return{newViewportIds:d,areSomeLocal:l,areAllLocal:u}}async function N(e){let t;const s=e.attachment?(e,n)=>{E.has(n)||(t=n,E.set(n,s));const o=(0,a.Rd)();(0,a.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[n]:{progress:e}}}})}:void 0;(e.replyingTo||m.cj)&&await(0,Z.Pn)();const n=(0,a.Rd)();e.serverTimeOffset=n.serverTimeOffset;const o=(0,i.Bt)(n);if(!o)return;const{threadId:r}=o;e.replyingTo||r===u._f||(e.replyingTo=(0,i.qS)(n,e.chat.id,r)),await(0,y.t9)("sendMessage",e,s),s&&t&&E.delete(t)}(0,a.Q6)("loadViewportMessages",((e,t,s)=>{const{direction:a=h.Uq.Around,isBudgetPreload:o=!1}=s||{};let{chatId:c,threadId:d}=s||{};if(!c){const t=(0,i.Bt)(e);if(!t)return;c=t.chatId,d=t.threadId}const l=(0,i.Z1)(e,c);if(!l||l.isRestricted)return;const u=(0,i.Cb)(e,c,d),m=(0,i.gb)(e,c,d),g=(0,i.qC)(e,c,d);if(u&&u.length&&a!==h.Uq.Around){const s=a===h.Uq.Backwards?u[0]:u[u.length-1],n=Boolean(g),i=n?g:m,{newViewportIds:f,areSomeLocal:p,areAllLocal:I}=T(i,s,a);if(p&&(e=(0,r.y9)(e,c,d,f)),async function(e,t,s,a,n,o,r,i){t||await R(n,o,i,r,s,a),a||(await Promise.resolve(),e.loadViewportMessages({chatId:n.id,threadId:o,direction:r,isBudgetPreload:!0}))}(t,I,n,o,l,d,a,s),o)return}else{const t=(0,i.G$)(e,c)||(0,i.rd)(e,c,d),s=Boolean(t&&m&&!m.includes(t)),a=(s?g:m)||[],{newViewportIds:u,areSomeLocal:f,areAllLocal:p}=T(a,t,h.Uq.Around);f&&u.length>=n.hT&&(e=(0,r.y9)(e,c,d,u)),p||R(l,d,t,h.Uq.Around,s,o)}return e})),(0,a.Q6)("loadMessage",((e,t,s)=>{const{chatId:n,messageId:o,replyOriginForId:c,threadUpdate:d}=s,l=(0,i.Z1)(e,n);l&&(async()=>{const e=await async function(e,t,s){const n=await(0,y.t9)("fetchMessage",{chat:e,messageId:t});if(!n)return;if(n===u._Q){if(s){let t=(0,a.Rd)();const n=(0,i.hj)(t,e.id,s);t=(0,r.cY)(t,e.id,s,{...n,replyToMessageId:void 0}),(0,a.R3)(t)}return}let o=(0,a.Rd)();return o=(0,r.cY)(o,e.id,t,n.message),o=(0,r.Sh)(o,(0,g.ee)(n.users,"id")),(0,a.R3)(o),n.message}(l,o,c);if(e&&d){const{lastMessageId:t,isDeleting:s}=d;(0,a.R3)((0,r.lG)((0,a.Rd)(),e,n,t,s))}})()})),(0,a.Q6)("sendMessage",((e,t,s)=>{const a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:r,type:c}=a;if("scheduled"===c&&!s.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:s}};const d=(0,i.Z1)(e,o);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:r,value:!1});const l={...s,chat:d,replyingTo:(0,i.Yy)(e,o,r),noWebPage:(0,i.tV)(e,o,r)},u=!s.attachments||s.attachments.length<=1,h=!u&&s.attachments&&s.attachments.length>1;if(u){const{attachments:e,...t}=l;N({...t,attachment:e?e[0]:void 0})}else if(h){const{text:e,entities:t,attachments:s,...a}=l,o=(0,g.Vl)(s,n.DU);for(let s=0;s<o.length;s++){const[n,...r]=o[s],i=`${Date.now()}${s}`;N({...a,text:0===s?e:void 0,entities:0===s?t:void 0,attachment:n,groupedId:r.length>0?i:void 0}),r.forEach((e=>{N({...a,attachment:e,groupedId:i})}))}}else{const{text:e,entities:t,attachments:s,replyingTo:a,...n}=l;e&&N({...n,text:e,entities:t,replyingTo:a}),s.forEach((e=>{N({...n,attachment:e})}))}})),(0,a.Q6)("editMessage",((e,t,s)=>{const{serverTimeOffset:a}=e,{text:n,entities:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c,threadId:d,type:l}=r,u=(0,i.Z1)(e,c),h=(0,i.kK)(e,c,d,l);u&&h&&((0,y.t9)("editMessage",{chat:u,message:h,text:n,entities:o,noWebPage:(0,i.tV)(e,c,d),serverTimeOffset:a}),t.setEditingId({messageId:void 0}))})),(0,a.Q6)("cancelSendingMessage",((e,t,s)=>{const{chatId:a,messageId:n}=s,o=(0,i.hj)(e,a,n),r=o&&E.get(o.previousLocalId||o.id);r&&(0,y.u3)(r),t.apiUpdate({"@type":"deleteMessages",ids:[n],chatId:a})})),(0,a.Q6)("saveDraft",((e,t,s)=>{const{chatId:a,threadId:n,draft:o}=s;if(!o)return;const{text:c,entities:d}=o,l=(0,i.Z1)(e,a);return n===u._f&&(0,y.t9)("saveDraft",{chat:l,text:c,entities:d,replyToMsgId:(0,i.Yy)(e,a,n)}),e=(0,r.pf)(e,a,n,"draft",o),(0,r.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)})})),(0,a.Q6)("clearDraft",((e,t,s)=>{const{chatId:a,threadId:n,localOnly:o}=s;if(!(0,i.Ms)(e,a,n))return;const c=(0,i.Z1)(e,a);return o||n!==u._f||(0,y.t9)("clearDraft",c),e=(0,r.pf)(e,a,n,"draft",void 0),(0,r.a4)(e,a,{draftDate:void 0})})),(0,a.Q6)("toggleMessageWebPage",((e,t,s)=>{const{chatId:a,threadId:n,noWebPage:o}=s;return(0,r.pf)(e,a,n,"noWebPage",o)})),(0,a.Q6)("pinMessage",((e,t,s)=>{const a=(0,i.jr)(e);if(!a)return;const{messageId:n,isUnpin:o,isOneSide:r,isSilent:c}=s;(0,y.t9)("pinMessage",{chat:a,messageId:n,isUnpin:o,isOneSide:r,isSilent:c})})),(0,a.Q6)("unpinAllMessages",((e,t,s)=>{const n=(0,i.Z1)(e,s.chatId);n&&async function(e){await(0,y.t9)("unpinAllMessages",{chat:e});let t=(0,a.Rd)();t=(0,r.pf)(t,e.id,u._f,"pinnedIds",[]),(0,a.R3)(t)}(n)})),(0,a.Q6)("deleteMessages",((e,t,s)=>{const{messageIds:a,shouldDeleteForAll:n}=s,o=(0,i.Bt)(e);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);(0,y.t9)("deleteMessages",{chat:d,messageIds:a,shouldDeleteForAll:n});const l=(0,i._$)(e,r,c);a.includes(l)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:a}=s,n=(0,i.Bt)(e);if(!n)return;const{chatId:o}=n,r=(0,i.Z1)(e,o);(0,y.t9)("deleteScheduledMessages",{chat:r,messageIds:a});const c=(0,i.wU)(e,o);a.includes(c)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteHistory",((e,t,s)=>{(async()=>{const{chatId:a,shouldDeleteForAll:n}=s,o=(0,i.Z1)(e,a);if(!o)return;const r=o.lastMessage&&o.lastMessage.id;await(0,y.t9)("deleteHistory",{chat:o,shouldDeleteForAll:n,maxId:r});const c=(0,i.Bt)(e);c&&c.chatId===a&&t.openChat({id:void 0})})()})),(0,a.Q6)("reportMessages",((e,t,s)=>{(async()=>{const{messageIds:a,reason:n,description:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c}=r,d=(0,i.Z1)(e,c),l=await(0,y.t9)("reportMessages",{peer:d,messageIds:a,reason:n,description:o});t.showNotification({message:l?"Thank you! Your report will be reviewed by our team.":"Error occured while submiting report. Please, try again later."})})()})),(0,a.Q6)("markMessageListRead",((e,t,s)=>{const{serverTimeOffset:a}=e,n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:c}=n,d=(0,i.Cm)(e,o,c);if(!d)return;const{maxId:l}=s;if(k((()=>{(0,y.t9)("markMessageListRead",{serverTimeOffset:a,chat:d,threadId:c,maxId:l})})),c!==u._f)return;const h=(0,i.Cb)(e,o,c),m=(0,i.It)(e,o,c);if(!h||!m||!d.unreadCount)return;const g=function(e,t,s){let a=0;for(let n=0,o=e.length;n<o&&(e[n]>=t&&e[n]<=s&&a++,!(e[n]>=s));n++);return a}(h,m,l);return g?(0,r.a4)(e,o,{lastReadInboxMessageId:l,unreadCount:Math.max(0,d.unreadCount-g)}):void 0})),(0,a.Q6)("markMessagesRead",((e,t,s)=>{const a=(0,i.jr)(e);if(!a)return;const{messageIds:n}=s;(0,y.t9)("markMessagesRead",{chat:a,messageIds:n})})),(0,a.Q6)("loadWebPagePreview",((e,t,s)=>{const{text:n}=s;!async function(e){const t=await(0,y.t9)("fetchWebPagePreview",{message:e});(0,a.R3)({...(0,a.Rd)(),webPagePreview:t})}(n)})),(0,a.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,a.Q6)("sendPollVote",((e,t,s)=>{const{chatId:a,messageId:n,options:o}=s,r=(0,i.Z1)(e,a);r&&(0,y.t9)("sendPollVote",{chat:r,messageId:n,options:o})})),(0,a.Q6)("loadPollOptionResults",((e,t,s)=>{const{chat:n,messageId:o,option:i,offset:c,limit:d,shouldResetVoters:l}=s;!async function(e,t,s,n,o,i){const c=await(0,y.t9)("loadPollOptionResults",{chat:e,messageId:t,option:s,offset:n,limit:o});if(!c)return;let d=(0,a.Rd)();d=(0,r.Sh)(d,(0,g.ee)(c.users,"id"));const{voters:l}=d.pollResults;(0,a.R3)({...d,pollResults:{...d.pollResults,voters:{...l,[s]:[...!i&&l&&l[s]?l[s]:[],...c&&c.users.map((e=>e.id))].filter(((e,t,s)=>s.indexOf(e)===t))},offsets:{...d.pollResults.offsets?d.pollResults.offsets:{},[s]:c.nextOffset||""}}})}(n,o,i,c,d,l)})),(0,a.Q6)("forwardMessages",(e=>{const{fromChatId:t,messageIds:s,toChatId:n}=e.forwardMessages,o=t?(0,i.Z1)(e,t):void 0,r=n?(0,i.Z1)(e,n):void 0,c=t&&s?s.sort(((e,t)=>e-t)).map((s=>(0,i.hj)(e,t,s))).filter(Boolean):void 0;o&&r&&c&&c.length&&function(e,t,s){(0,y.t9)("forwardMessages",{fromChat:e,toChat:t,messages:s,serverTimeOffset:(0,a.Rd)().serverTimeOffset}),(0,a.R3)({...(0,a.Rd)(),forwardMessages:{}})}(o,r,c)})),(0,a.Q6)("loadScheduledHistory",(e=>{const t=(0,i.jr)(e);if(!t)return;const{hash:s}=e.scheduledMessages.byChatId[t.id]||{};!async function(e,t){const s=await(0,y.t9)("fetchScheduledHistory",{chat:e,hash:t});if(!s)return;const{hash:n,messages:o}=s,i=(0,g.ee)(o,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,a.Rd)();d=(0,r.w3)(d,e.id,i,n),d=(0,r.pf)(d,e.id,u._f,"scheduledIds",c),(0,a.R3)(d)}(t,s)})),(0,a.Q6)("sendScheduledMessages",((e,t,s)=>{const{chatId:a,id:n}=s,o=(0,i.Z1)(e,a);o&&(0,y.t9)("sendScheduledMessages",{chat:o,ids:[n]})})),(0,a.Q6)("rescheduleMessage",((e,t,s)=>{const{chatId:a,messageId:n,scheduledAt:o}=s,r=(0,i.Z1)(e,a),c=r&&(0,i.Tm)(e,r.id,n);r&&c&&(0,y.t9)("rescheduleMessage",{chat:r,message:c,scheduledAt:o})})),(0,a.Q6)("requestThreadInfoUpdate",((e,t,s)=>{const{chatId:a,threadId:n}=s,o=(0,i.Cm)(e,a,n);o&&(0,y.t9)("requestThreadInfoUpdate",{chat:o,threadId:n})})),(0,a.Q6)("loadPinnedMessages",((e,t,s)=>{const{chatId:n}=s,o=(0,i.Z1)(e,n);o&&async function(e){const t=await(0,y.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:s,chats:n,users:o}=t,i=(0,g.ee)(s,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,a.Rd)();d=(0,r.c_)(d,e.id,i),d=(0,r.pf)(d,e.id,u._f,"pinnedIds",c),d=(0,r.Sh)(d,(0,g.ee)(o,"id")),d=(0,r.fZ)(d,(0,g.ee)(n,"id")),(0,a.R3)(d)}(o)}));var B=s(5765);const A=(0,Z.P2)((e=>e()),500,!1);async function x(e,t){const s=await(0,y.t9)("searchGifs",{query:e,offset:t});s&&(0,a.R3)((0,r.rq)((0,a.Rd)(),!t,s.gifs,s.nextOffset))}(0,a.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e=0){const t=await(0,y.t9)("fetchStickerSets",{hash:e});t&&(0,a.R3)((0,r.z3)((0,a.Rd)(),"added",t.hash,t.sets))}(t)})),(0,a.Q6)("loadAddedStickers",((e,t)=>{const{setIds:s}=e.stickers.added;s&&s.length&&(async()=>{for(let e=0;e<s.length;e++)t.loadStickers({stickerSetId:s[e]}),e%50==0&&e>0&&await(0,Z.wO)(500)})()})),(0,a.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e=0){const t=await(0,y.t9)("fetchRecentStickers",{hash:e});if(!t)return;const s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,recent:t}})}(t)})),(0,a.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e=0){const t=await(0,y.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,favorite:t}})}(t)})),(0,a.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,y.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.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=0){const t=await(0,y.t9)("fetchFeaturedStickers",{hash:e});t&&(0,a.R3)((0,r.z3)((0,a.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,a.Q6)("loadStickers",((e,t,s)=>{const{stickerSetId:n,stickerSetShortName:o}=s;let{stickerSetAccessHash:c}=s;if(!c&&!o){const t=(0,i.Ny)(e,n);if(!t)return;c=t.accessHash}!async function(e,t,s){const n=await(0,y.t9)("fetchStickers",{stickerSetShortName:s,stickerSetId:e,accessHash:t});if(!n)return;const{set:o,stickers:i,packs:c}=n;let d=(0,a.Rd)();d=(0,r.Rg)(d,o.id,{...o,stickers:i,packs:c});const l=d.stickers.forEmoji.emoji;l&&c[l]&&(d=(0,r.vy)(d)),(0,a.R3)(d)}(n,c,o)})),(0,a.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,y.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:s}=e;(0,a.R3)((0,r.g_)((0,a.Rd)(),{...t,stickers:s}))}()})),(0,a.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e=0){const t=await(0,y.t9)("fetchSavedGifs",{hash:e});if(!t)return;const s=(0,a.Rd)();(0,a.R3)({...s,gifs:{...s.gifs,saved:t}})}(t)})),(0,a.Q6)("faveSticker",((e,t,s)=>{const{sticker:a}=s;a&&(0,y.t9)("faveSticker",{sticker:a})})),(0,a.Q6)("unfaveSticker",((e,t,s)=>{const{sticker:n}=s;n&&function(e){const t=(0,a.Rd)();(0,a.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((({id:t})=>t!==e.id))}}}),(0,y.t9)("faveSticker",{sticker:e,unfave:!0})}(n)})),(0,a.Q6)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:a}=s,n=(0,i.Ny)(e,a);if(!n)return;const{accessHash:o,installedDate:r}=n;(0,y.t9)(r?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.Q6)("loadEmojiKeywords",((e,t,s)=>{const{language:n}=s;let o=e.emojiKeywords[n];o&&o.isLoading||((0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[n]:{...o,isLoading:!0}}}),(async()=>{const t=await(0,y.t9)("fetchEmojiKeywords",{language:n,fromVersion:o?o.version:0});e=(0,a.Rd)(),o=e.emojiKeywords[n],t?(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[n]:{isLoading:!1,version:t.version,keywords:{...o&&o.keywords,...t.keywords}}}}):(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[n]:{...o,isLoading:!1}}})})())})),(0,a.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:n}=s;n&&A((()=>{!async function(e,t=0){const s=await(0,y.t9)("searchStickers",{query:e,hash:t});if(!s)return;const n=(0,a.Rd)(),{setsById:o,added:i}=n.stickers,c=s.sets.map((({id:e})=>e));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:s}=o[t]||{};s&&(0,B.Z)(s,e)&&c.unshift(t)}})),(0,a.R3)((0,r.z3)(n,"search",s.hash,s.sets,c))}(n)}))})),(0,a.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:a}=s;"string"==typeof a&&A((()=>{x(a)}))})),(0,a.Q6)("searchMoreGifs",(e=>{const{query:t,offset:s}=e.gifs.search;"string"==typeof t&&A((()=>{x(t,s)}))})),(0,a.Q6)("loadStickersForEmoji",((e,t,s)=>{const{emoji:n}=s,{hash:o}=e.stickers.forEmoji;A((()=>{!async function(e,t=0){let s=(0,a.Rd)();(0,a.R3)({...s,stickers:{...s.stickers,forEmoji:{...s.stickers.forEmoji,emoji:e}}});const n=await(0,y.t9)("fetchStickersForEmoji",{emoji:e,hash:t});s=(0,a.Rd)(),n&&s.stickers.forEmoji.emoji===e&&(s=(0,r.IM)(s,e,n.stickers,n.hash),(0,a.R3)(s))}(n,o)}))})),(0,a.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.Q6)("openStickerSetShortName",((e,t,s)=>{const{stickerSetShortName:a}=s;return{...e,openedStickerSetShortName:a}}));var L=s(790);const O=(0,Z.P2)((e=>e()),500,!1);async function F(e="",t,s,o,c,d){let l;if(o){const a=await(0,y.t9)("searchMessagesLocal",{chatOrUser:o,query:e,type:t,limit:n.Hk,offsetId:s,minDate:d,maxDate:c});if(a){const{messages:e,users:t,totalCount:s,nextOffsetId:n}=a;l={messages:e,users:t,chats:[],totalCount:s,nextRate:n}}}else l=await(0,y.t9)("searchMessagesGlobal",{query:e,offsetRate:s,limit:n.Hk,type:t,maxDate:c,minDate:d});let u=(0,a.Rd)();const h=(0,i.JX)(u);if(!l||""!==e&&e!==h)return void(0,a.R3)((0,r.xv)(u,{messages:!1}));const{messages:m,users:f,chats:p,totalCount:I,nextRate:v}=l;p.length&&(u=(0,r.fZ)(u,(0,g.ee)(p,"id"))),f.length&&(u=(0,r.Sh)(u,(0,g.ee)(f,"id"))),m.length&&(u=(0,r.m6)(u,m)),u=(0,r.px)(u,m,I,t,v),(0,a.R3)(u)}async function U(){const e=await(0,y.t9)("fetchChats",{limit:n.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,a.Rd)().serverTimeOffset});if(!e)return;let t=(0,a.Rd)();t=(0,r.eD)(t,(0,g.ee)(e.users,"id")),t=(0,r.GL)(t,(0,g.ee)(e.chats,"id")),t=(0,r.Mg)(t,"archived",e.chatIds),t=(0,r.vv)(t,"archived",e),(0,a.R3)(t)}async function $(){let e=(0,a.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:s}=e.contactList||{};if(!(s&&s.length||t&&t.length))return;const n=[...t||[],...s||[]].map((t=>(0,i.dy)(e,t))).filter(Boolean),o=await(0,y.t9)("fetchUsers",{users:n});o&&(e=(0,a.Rd)(),e=(0,r.eD)(e,(0,g.ee)(o,"id")),(0,a.R3)(e))}function Q(e){return(0,y.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(n.hT/2)+1),limit:n.hT})}(0,a.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{chatId:n}=e.globalSearch,{query:o}=s;o&&!n&&O((()=>{!async function(e){const t=await(0,y.t9)("searchChats",{query:e});let s=(0,a.Rd)();const n=(0,i.JX)(s);if(!t||!n||e!==n)return void(0,a.R3)((0,r.xv)(s,{chats:!1}));const{localChats:o,localUsers:c,globalChats:d,globalUsers:l}=t;(o.length||d.length)&&(s=(0,r.fZ)(s,(0,g.ee)([...o,...d],"id"))),(c.length||l.length)&&(s=(0,r.Sh)(s,(0,g.ee)([...c,...l],"id"))),s=(0,r.xv)(s,{chats:!1}),s=(0,r.No)(s,{localResults:{chatIds:o.map((({id:e})=>e)),userIds:c.map((({id:e})=>e))},globalResults:{...s.globalSearch.globalResults,chatIds:l.map((({id:e})=>e)),userIds:d.map((({id:e})=>e))}}),(0,a.R3)(s)}(o)}))})),(0,a.Q6)("setGlobalSearchDate",((e,t,s)=>{const{date:n}=s,o=n?(0,L.IS)(n):n,c=(0,r.No)(e,{date:n,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,a.R3)(c);const{chatId:d}=e.globalSearch;F("","text",void 0,d?(0,i.Z1)(e,d):void 0,o,n)})),(0,a.Q6)("searchMessagesGlobal",((e,t,s)=>{const{query:a,resultsByType:n,chatId:o,date:r}=e.globalSearch,c=r?(0,L.IS)(r):r,{type:d}=s,{nextOffsetId:l}=n&&n[d]||{};F(a,d,l,o?(0,i.Z1)(e,o):void 0,c,r)})),(0,a.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},o=t?(0,i.Z1)(e,t):void 0,c=(0,i.n5)(e);if(!o||!c||!s)return;const{query:d,results:l}=c,h=l?l.nextOffsetId:void 0;let m;if(s!==u._f){const a=(0,i.tZ)(e,t,s);m=a?a.topMessageId:void 0}!async function(e,t,s,o,c){const d=await(0,y.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:s,limit:n.pn,offsetId:c});if(!d)return;const{messages:l,users:u,totalCount:h,nextOffsetId:m}=d,f=(0,g.ee)(l,"id"),p=Object.keys(f).map(Number);let I=(0,a.Rd)();const v=(0,i.n5)(I);!v||o&&o!==v.query||(I=(0,r.c_)(I,e.id,f),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.dx)(I,e.id,t,p,h,m),(0,a.R3)(I))}(o,s,m,d,h)})),(0,a.Q6)("searchMediaMessagesLocal",(e=>{const t=(0,i.og)(e),s=t?e.users.byId[t]||e.chats.byId[t]:void 0,o=(0,i.we)(e);if(!s||!o)return;const{currentType:c,resultsByType:d}=o,l=c&&d&&d[c],u=l?l.nextOffsetId:void 0;c&&async function(e,t,s){const o=await(0,y.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:n.EN,offsetId:s});if(!o)return;const{messages:c,users:d,totalCount:l,nextOffsetId:u}=o,h=(0,g.ee)(c,"id"),m=Object.keys(h).map(Number);let f=(0,a.Rd)();(0,i.we)(f)&&(f=(0,r.c_)(f,e.id,h),f=(0,r.Sh)(f,(0,g.ee)(d,"id")),f=(0,r.c1)(f,e.id,t,m,l,u),(0,a.R3)(f))}(s,c,u)})),(0,a.Q6)("searchMessagesByDate",((e,t,s)=>{const{timestamp:n}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return;const r=(0,i.Z1)(e,o);r&&async function(e,t){const s=await(0,y.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});s&&(0,a.uC)().focusMessage({chatId:e.id,messageId:s})}(r,n)})),(0,a.Q6)("checkPublicLink",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};if(!n)return;if(e.management.progress===h.wv.InProgress)return;const{username:o}=s;(async()=>{e=(0,r.H9)(e,h.wv.InProgress),e=(0,r.fw)(e,n,{isUsernameAvailable:void 0}),(0,a.R3)(e);const t=await(0,y.t9)("checkChatUsername",{username:o});e=(0,a.Rd)(),e=(0,r.H9)(e,t?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,n,{isUsernameAvailable:t}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePublicLink",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};let o=n&&(0,i.Z1)(e,n);if(!n||!o)return;const{username:c}=s;(async()=>{if(e=(0,r.H9)(e,h.wv.InProgress),(0,a.R3)(e),(0,d.G9)(o)){if(o=await(0,y.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const s=await(0,y.t9)("setChatUsername",{chat:o,username:c});e=(0,a.Rd)(),e=(0,r.H9)(e,s?h.wv.Complete:h.wv.Error),e=(0,r.fw)(e,n,{isUsernameAvailable:void 0}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t&&(0,i.Z1)(e,t);t&&s&&(0,y.t9)("updatePrivateLink",{chat:s})})),(0,a.Q6)("sync",((e,t)=>{!async function(e){n.eM&&console.log(">>> START SYNC"),await(0,y.t9)("fetchCurrentUser");const t=await async function(){const e=await(0,y.t9)("fetchChats",{limit:n.Ov,withPinned:!0,serverTimeOffset:(0,a.Rd)().serverTimeOffset});if(!e)return;let t=(0,a.Rd)();const{recentlyFoundChatIds:s}=t.globalSearch,{userIds:o}=t.contactList||{},{currentUserId:c}=t,l=[...s||[],...o||[],...c?[c]:[]],h=l.map((e=>(0,i.dy)(t,e))).filter(Boolean),m=l.map((e=>(0,i.Z1)(t,e))).filter(Boolean),{chatId:f}=(0,i.Bt)(t)||{};if(f){const e=(0,i.Z1)(t,f);if(e&&!l.includes(f)&&m.push(e),(0,d.YA)(f)){const e=(0,i.dy)(t,f);e&&!l.includes(f)&&h.push(e)}}return h.push(...e.users),m.push(...e.chats),t=(0,r.SL)(t,(0,g.ee)(m,"id")),t=(0,r.Mg)(t,"active",e.chatIds),t={...t,chats:{...t.chats}},t=(0,r.vv)(t,"active",e),Object.keys(e.draftsById).map(Number).forEach((s=>{t=(0,r.pf)(t,s,u._f,"draft",e.draftsById[s])})),Object.keys(e.replyingToById).map(Number).forEach((s=>{t=(0,r.pf)(t,s,u._f,"replyingToId",e.replyingToById[s])})),(0,a.R3)(t),f&&!t.chats.byId[f]&&(0,a.uC)().openChat({id:void 0}),h}();await async function(e){let t=!1,s=e||[],n=(0,a.Rd)();const{chatId:o,threadId:c}=(0,i.Bt)(n)||{},d=Object.keys(n.messages.byChatId).map(Number).reduce(((e,t)=>{const s=(0,i.Ms)(n,t,u._f);return s?{...e,[t]:s}:e}),{});if(o){const e=await Q(n.chats.byId[o]);n=(0,a.Rd)();const{chatId:d}=(0,i.Bt)(n)||{},l=c&&(0,i.tZ)(n,o,c);if(e&&d===o){const a=n.messages.byChatId[o],i=(0,g.ee)(e.messages,"id"),d=Object.keys(i).map(Number);if(n={...n,messages:{...n.messages,byChatId:{[o]:{byId:i,threadsById:{[u._f]:{...a&&a.threadsById[u._f],listedIds:d,viewportIds:d,outlyingIds:void 0}}}}}},c&&l&&l.originChannelId){const{originChannelId:e}=l,t=n.messages.byChatId[e],s=await Q(n.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),r=Object.keys(e).map(Number);n={...n,messages:{...n.messages,byChatId:{...n.messages.byChatId,[l.originChannelId]:{byId:e,threadsById:{[u._f]:{...t&&t.threadsById[u._f],listedIds:r,viewportIds:r,outlyingIds:void 0}}},[o]:{...n.messages.byChatId[o],threadsById:{...n.messages.byChatId[o].threadsById,[c]:{...a&&a.threadsById[c],outlyingIds:void 0}}}}}}}}n=(0,r.GL)(n,(0,g.ee)(e.chats,"id")),n=(0,r.j6)(n,o,e.threadInfos),t=!0,s=Array.prototype.concat(s,e.users)}}t||(n={...n,messages:{...n.messages,byChatId:{}}}),Object.keys(d).map(Number).forEach((e=>{n=(0,r.pf)(n,e,u._f,"draft",d[e])})),e?n=(0,r.s5)(n,(0,g.ee)(s,"id")):s&&(n=(0,r.eD)(n,(0,g.ee)(s,"id"))),(0,a.R3)(n);const{chatId:l,messageId:h}=n.audioPlayer;l&&h&&!(0,i.hj)(n,l,h)&&(0,a.uC)().closeAudioPlayer()}(t),(0,a.R3)({...(0,a.Rd)(),lastSyncTime:Date.now()}),n.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,a.Q6)("afterSync",((e,t)=>{!async function(e){n.eM&&console.log(">>> START AFTER-SYNC"),e.loadFavoriteStickers(),await Promise.all([$(),U()]),await(0,y.t9)("fetchCurrentUser"),n.eM&&console.log(">>> FINISH AFTER-SYNC")}(t)}));var D=s(2267);const q=(0,Z.Ds)((e=>e()),500,!1,!0),G=(0,Z.P2)((e=>e()),500,!1);function H(e,t,s){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:s}}}}function j(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,a.Q6)("loadFullUser",((e,t,s)=>{const{userId:a}=s,n=(0,i.dy)(e,a);if(!n)return;const{id:o,accessHash:r}=n;q((()=>(0,y.t9)("fetchFullUser",{id:o,accessHash:r})))})),(0,a.Q6)("loadUser",((e,t,s)=>{const{userId:n}=s,o=(0,i.dy)(e,n);o&&(async()=>{const t=await(0,y.t9)("fetchUsers",{users:[o]});t&&(e=(0,a.Rd)(),e=(0,r.eD)(e,(0,g.ee)(t,"id")),(0,a.R3)(e))})()})),(0,a.Q6)("loadTopUsers",(e=>{const{topPeers:{hash:t,lastRequestedAt:s}}=e;(!s||(0,D.b)(e.serverTimeOffset)-s>60)&&async function(e){const t=await(0,y.t9)("fetchTopUsers",{hash:e});if(!t)return;const{hash:s,ids:n,users:o}=t;let i=(0,a.Rd)();i=(0,r.Sh)(i,(0,g.ee)(o,"id")),i={...i,topPeers:{...i.topPeers,hash:s,userIds:n,lastRequestedAt:(0,D.b)(i.serverTimeOffset)}},(0,a.R3)(i)}(t)})),(0,a.Q6)("loadContactList",(e=>{const{hash:t}=e.contactList||{};!async function(e){const t=await(0,y.t9)("fetchContactList",{hash:e});if(!t)return;let s=(0,r.Sh)((0,a.Rd)(),(0,g.ee)(t.users,"id"));s=(0,r.fZ)(s,(0,g.ee)(t.chats,"id"));const n=e=>e.lastName||e.firstName||"",o=new Intl.Collator("en-US"),i=t.users.sort(((e,t)=>o.compare(n(e),n(t)))).filter((e=>!e.isSelf));(0,a.R3)({...s,contactList:{hash:t.hash,userIds:i.map((e=>e.id))}})}(t)})),(0,a.Q6)("loadCurrentUser",(()=>{(0,y.t9)("fetchCurrentUser")})),(0,a.Q6)("updateContact",((e,t,s)=>{const{userId:n,isMuted:o,firstName:c,lastName:d}=s;!async function(e,t,s,n){const o=(0,a.Rd)(),c=(0,i.dy)(o,e);c&&((0,a.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.InProgress)),await(0,y.t9)("updateContact",{phone:c.phoneNumber,firstName:s,lastName:n})&&(0,a.R3)((0,r.Nq)((0,a.Rd)(),c.id,{firstName:s,lastName:n})),(0,a.R3)((0,r.H9)((0,a.Rd)(),h.wv.Complete)))}(n,o,c,d)})),(0,a.Q6)("deleteUser",((e,t,s)=>{const{userId:n}=s;!async function(e){const t=(0,a.Rd)(),s=(0,i.dy)(t,e);if(!s)return;const{id:n,accessHash:o}=s;await(0,y.t9)("deleteUser",{id:n,accessHash:o})}(n)})),(0,a.Q6)("loadProfilePhotos",((e,t,s)=>{const{profileId:n}=s,o=(0,d.YA)(n),c=o?(0,i.dy)(e,n):void 0,l=o?void 0:(0,i.Z1)(e,n);(async()=>{const e=await(0,y.t9)("fetchProfilePhotos",c,l);if(!e||!e.photos)return;let t=(0,a.Rd)();o?t=(0,r.Nq)(t,n,{photos:e.photos}):(t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.a4)(t,n,{photos:e.photos})),(0,a.R3)(t)})()})),(0,a.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:n}=s;n&&G((()=>{!async function(e){const t=await(0,y.t9)("searchChats",{query:e});let s=(0,a.Rd)();const n=s.userSearch.query;if(!t||!n||e!==n)return void(0,a.R3)((0,r.Q3)(s,!1));const{localUsers:o,globalUsers:i}=t;let c,d;o.length&&(s=(0,r.Sh)(s,(0,g.ee)(o,"id")),c=o.map((({id:e})=>e))),i.length&&(s=(0,r.Sh)(s,(0,g.ee)(i,"id")),d=i.map((({id:e})=>e))),s=(0,r.Q3)(s,!1),s=(0,r.Lm)(s,{localUserIds:c,globalUserIds:d}),(0,a.R3)(s)}(n)}))}));const _=(0,Z.Ds)((e=>e()),500,!1);async function V(e,t,s){await(0,y.t9)("sendMessage",{chat:e,text:s})}(0,a.Q6)("clickInlineButton",((e,t,s)=>{const{button:o}=s;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(n.Lj)||o.value.match(n.FS)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,i.jr)(e);if(!t)return;!async function(e,t,s){const n=await(0,y.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:s});if(!n||!n.message)return;const{message:o,alert:r}=n;r?(0,a.uC)().showDialog({data:{message:o}}):(0,a.uC)().showNotification({message:o})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"buy":{const s=(0,i.jr)(e),{messageId:a,value:n}=o;if(!s)return;n?t.getReceipt({receiptMessageId:n,chatId:s.id,messageId:a}):(t.getPaymentForm({chat:s,messageId:a}),t.setInvoiceMessageInfo((0,i.hj)(e,s.id,a)),t.openPaymentModal({chatId:s.id,messageId:a}));break}}})),(0,a.Q6)("sendBotCommand",((e,t,s)=>{const{command:a,chatId:n}=s,{currentUserId:o}=e,r=n?(0,i.Z1)(e,n):(0,i.jr)(e);o&&r&&V(r,0,a)})),(0,a.Q6)("restartBot",((e,t,s)=>{const{chatId:n}=s,{currentUserId:o}=e,c=(0,i.jr)(e),d=o&&(0,i.IK)(e,n);o&&c&&d&&(async()=>{await(0,y.t9)("unblockContact",d.id,d.accessHash)&&((0,a.R3)((0,r.rB)((0,a.Rd)(),d.id)),V(c,0,"/start"))})()})),(0,a.Q6)("loadTopInlineBots",(e=>{const{hash:t,lastRequestedAt:s}=e.topInlineBots;s&&(0,D.b)(e.serverTimeOffset)-s<60||(async()=>{const s=await(0,y.t9)("fetchTopInlineBots",{hash:t});if(!s)return;const{hash:n,ids:o,users:i}=s;let c=(0,a.Rd)();c=(0,r.Sh)(c,(0,g.ee)(i,"id")),c={...c,topInlineBots:{...c.topInlineBots,hash:n,userIds:o,lastRequestedAt:(0,D.b)(e.serverTimeOffset)}},(0,a.R3)(c)})()})),(0,a.Q6)("queryInlineBot",((e,t,s)=>{const{chatId:n,username:o,query:c,offset:d}=s;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:s,chat:n}=await(0,y.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!s||!n)return void(0,a.R3)(H(e,o,!1));e=(0,r.Sh)(e,{[s.id]:s}),e=(0,r.fZ)(e,{[n.id]:n}),t={id:s.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=H(e,o,t),(0,a.R3)(e)}(c!==t.query||t.canLoadMore)&&_((()=>{!async function({username:e,inlineBotData:t,chatId:s,query:n,offset:o}){let r=(0,a.Rd)();const c=(0,i.dy)(r,t.id),d=(0,i.Z1)(r,s);if(!c||!d)return;const l=t.query!==n;r=j(r,!0),r=H(r,e,{...t,query:n,...l&&{offset:void 0,results:[]}}),(0,a.R3)(r);const u=await(0,y.t9)("fetchInlineBotResults",{bot:c,chat:d,query:n,offset:l?void 0:o}),h=r.inlineBots.byUsername[e];if(r=j((0,a.Rd)(),!1),!u||!h||n!==h.query)return void(0,a.R3)(r);const m=new Set((h.results||[]).map((e=>e.id))),g=u.results.filter((e=>!m.has(e.id)));r=H(r,e,{...h,help:u.help,...g.length&&{isGallery:u.isGallery},...u.switchPm&&{switchPm:u.switchPm},canLoadMore:u.results.length>0&&Boolean(u.nextOffset),results:""===h.offset||h.offset===u.nextOffset?u.results:(h.results||[]).concat(g),offset:g.length?u.nextOffset:""}),(0,a.R3)(r)}({username:o,inlineBotData:t,chatId:n,query:c,offset:d})}))}})()})),(0,a.Q6)("sendInlineBotResult",((e,t,s)=>{const{id:a,queryId:n}=s,o=(0,i.Bt)(e);if(!o||!a)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r,threadId:c,value:!1}),(0,y.t9)("sendInlineBotResult",{chat:d,resultId:a,queryId:n,replyingTo:(0,i.Yy)(e,r,c)})})),(0,a.Q6)("resetInlineBot",((e,t,s)=>{const{username:n}=s;let o=e.inlineBots.byUsername[n];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,a.R3)(H(e,n,o)))})),(0,a.Q6)("startBot",((e,t,s)=>{const{botId:a,param:n}=s,o=(0,i.dy)(e,a);o&&(async()=>{await(0,y.t9)("startBot",{bot:o,startParam:n})})()})),s(9667),(0,a.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,y.t9)("getPasswordInfo");if(!e)return;let t=(0,a.Rd)();t=(0,r.BI)(t,{hasPassword:e.hasPassword}),t=(0,r.IE)(t,{hint:e.hint}),(0,a.R3)(t)})()})),(0,a.Q6)("checkPassword",((e,t,s)=>{const{currentPassword:n,onSuccess:o}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("checkPassword",n);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("clearPassword",((e,t,s)=>{const{currentPassword:n,onSuccess:o}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("clearPassword",n);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("updatePassword",((e,t,s)=>{const{currentPassword:n,password:o,hint:i,email:c,onSuccess:d}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("updatePassword",n,o,i,c);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1})),e&&d()})()})),(0,a.Q6)("updateRecoveryEmail",((e,t,s)=>{const{currentPassword:n,email:o,onSuccess:i}=s;(0,a.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,y.t9)("updateRecoveryEmail",n,o);(0,a.R3)((0,r.IE)((0,a.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&i()})()})),(0,a.Q6)("provideTwoFaEmailCode",((e,t,s)=>{const{code:a}=s;(0,y.t9)("provideRecoveryEmailCode",a)})),(0,a.Q6)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,a.Q6)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:n,saveInfo:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e);d&&l&&async function(e,t,s,n){const o=await(0,y.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:s,shouldSave:n});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let d=(0,r.vT)((0,a.Rd)(),i);c?(d=(0,r.TM)(d,c),d=(0,r.Q$)(d,h.KB.Shipping)):d=(0,r.Q$)(d,h.KB.PaymentInfo),(0,a.R3)(d)}(d,l,n,o)})),(0,a.Q6)("getPaymentForm",((e,t,s)=>{const{chat:n,messageId:o}=s;n&&o&&async function(e,t){const s=await(0,y.t9)("getPaymentForm",{chat:e,messageId:t});if(!s)return;let n=(0,r._7)((0,a.Rd)(),s),o=h.KB.PaymentInfo;n.payment.invoice&&(n.payment.invoice.shippingAddressRequested||n.payment.invoice.nameRequested||n.payment.invoice.phoneRequested||n.payment.invoice.emailRequested)&&(o=h.KB.ShippingInfo),n=(0,r.Q$)(n,o),(0,a.R3)(n)}(n,o)})),(0,a.Q6)("getReceipt",((e,t,s)=>{const{receiptMessageId:n,chatId:o,messageId:c}=s,d=o&&(0,i.Z1)(e,o);c&&n&&d&&async function(e,t,s){const n=await(0,y.t9)("getReceipt",e,s);if(!n)return;let o=(0,a.Rd)();const c=(0,i.hj)(o,e.id,t);o=(0,r.Dq)(o,n,c),(0,a.R3)(o)}(d,c,n)})),(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,s)=>{const n=(0,i.$$)(e);if(!n)return;const{credentials:o}=s,{data:c}=o;!async function(e,t){const s=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}),n=await fetch(`https://api.stripe.com/v1/tokens${s}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await n.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,a.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,h.KB.Checkout),(0,a.R3)(i)}(c,n)})),(0,a.Q6)("sendPaymentForm",((e,t,s)=>{const{shippingOptionId:n,saveCredentials:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e),u=(0,i.eh)(e),h=(0,i.sp)(e),m=(0,i.$$)(e),g=(0,i.i3)(e);d&&l&&m&&u&&async function(e,t,s,n,o,i){if(await(0,y.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:n,requestedInfoId:o,shippingOptionId:i})){const e=(0,r.bp)((0,a.Rd)());(0,a.R3)((0,r.WY)(e))}}(d,l,u,{save:o,data:g},h,n)})),(0,a.Q6)("setPaymentStep",((e,t,s={})=>(0,r.Q$)(e,s.step||h.KB.ShippingInfo))),(0,a.Q6)("setInvoiceMessageInfo",((e,t,s)=>(0,r.nA)(e,s))),s(4907);var W=s(8406),K=s(7358);const X=(0,Z.P2)((e=>e()),500,!0);(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{s.noTopChatsRequest||(0,i.N)(e,s.id)||t.loadTopChats();const n=(0,r.a4)(e,s.id,s.chat,s.newProfilePhoto);(0,a.R3)(n),X((()=>(0,K.w)((0,i.A1)((0,a.Rd)()))));break}case"updateChatJoin":{const n=(0,i.Ek)(e,s.id);if(!n)break;e=(0,r.B1)(e,n,[s.id]),e=(0,r.a4)(e,s.id,{isNotJoined:!1}),(0,a.R3)(e);const o=(0,i.Z1)(e,s.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":{const t=(0,i.Ek)(e,s.id);if(!t)break;const{[t]:n}=e.chats.listIds;n&&(e=(0,r.Mg)(e,t,n.filter((e=>e!==s.id)))),e=(0,r.a4)(e,s.id,{isNotJoined:!0}),(0,a.R3)(e);break}case"updateChatInbox":(0,a.R3)((0,r.a4)(e,s.id,s.chat)),X((()=>(0,K.w)((0,i.A1)((0,a.Rd)()))));break;case"updateChatTypingStatus":{const{id:t,typingStatus:n}=s;(0,a.R3)((0,r.a4)(e,t,{typingStatus:n})),setTimeout((()=>{const e=(0,a.Rd)(),s=(0,i.Z1)(e,t);s&&n&&s.typingStatus&&s.typingStatus.timestamp===n.timestamp&&(0,a.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:n}=s,{chatId:o,threadId:c,type:d}=(0,i.Bt)(e)||{};if(n.senderId===e.currentUserId&&!n.isFromScheduled)return;const l=(0,i.Z1)(e,s.chatId);if(!l)return;const h="thread"===d&&c===u._f&&s.chatId===o;h?setTimeout((()=>{t.requestChatUpdate({chatId:s.chatId})}),1500):(0,a.R3)((0,r.a4)(e,s.chatId,{unreadCount:l.unreadCount?l.unreadCount+1:1,...s.message.hasUnreadMention&&{unreadMentionsCount:l.unreadMentionsCount?l.unreadMentionsCount+1:1}})),(0,K.w)((0,i.A1)((0,a.Rd)()));const{hasWebNotifications:m}=(0,i.dZ)(e);m&&(0,W.VL)({chat:l,message:n,isActiveChat:h});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:n}=s;if(!1!==n.hasUnreadMention)return;t.forEach((t=>{const a="channelId"in s?s.channelId:(0,i.X5)(e,t),n=(0,i.Z1)(e,a);n&&n.unreadMentionsCount&&(e=(0,r.a4)(e,a,{unreadMentionsCount:n.unreadMentionsCount-1}))})),(0,a.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=s,n=e.chats.byId[s.id];if(!n)return;(0,a.R3)((0,r.a4)(e,s.id,{fullInfo:{...n.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=s,r=o===n.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:t.length?t:void 0}}},(0,a.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=s,r=(0,i.Ek)(e,t);if(r){const{[r]:s}=e.chats.orderedPinnedIds;let a=s||[];if(o){if(!a.includes(t)){if("active"===r&&a.length>=n.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,[r]:a.length?a:void 0}}}}(0,a.R3)(e);break}case"updateChatListType":{const{id:t,folderId:n}=s;(0,a.R3)((0,r.Pi)(e,t,n));break}case"updateChatFolder":{const{id:t,folder:n}=s,{byId:o,orderedIds:r}=e.chatFolders,i=n?{...o,[t]:n}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=n?r&&r.includes(t)?r:[...r||[],t]:r?r.filter((e=>e!==t)):void 0;(0,a.R3)({...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=s;(0,a.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=s;(0,a.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{const t=e.chats.byId[s.id],{replacedMembers:n,addedMember:o,deletedMemberId:i}=s;if(!t)return;let c=!1,d=t.fullInfo&&t.fullInfo.members?[...t.fullInfo.members]:[];if(n)d=n,c=!0;else if(o)d.length&&d.some((e=>e.userId===o.userId))||(d.push(o),c=!0);else if(d.length&&i){const e=d.findIndex((e=>e.userId===i));e>-1&&(d.slice(e,1),c=!0)}if(c){const n=d.filter((({isOwner:e,isAdmin:t})=>e||t));(0,a.R3)((0,r.a4)(e,s.id,{membersCount:d.length,fullInfo:{...t.fullInfo,members:d,adminMembers:n}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:n}=s,o=e.chats.byId[t];o&&o.photos&&(0,a.R3)((0,r.a4)(e,t,{photos:o.photos.filter((e=>!n.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:n,date:o,replyingToId:i}=s;e.chats.byId[t]&&(e=(0,r.pf)(e,t,u._f,"draft",n),e=(0,r.pf)(e,t,u._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:o}),(0,a.R3)(e));break}case"showInvite":{const{data:e}=s;t.showDialog({data:e});break}}}));const Y=350;function z(e,t,s,a,n=!1){const o=n?(0,i.Tm)(e,t,s):(0,i.hj)(e,t,s);if(o&&a.content){const{photo:e,video:t,sticker:s,document:n}=(0,d.qp)(o);e&&a.content.photo?(a.content.photo.blobUrl=e.blobUrl,a.content.photo.thumbnail=e.thumbnail):t&&a.content.video?a.content.video.blobUrl=t.blobUrl:s&&a.content.sticker?a.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:n&&a.content.document&&(a.content.document.previewBlobUrl=n.previewBlobUrl)}return n?(0,r.P4)(e,t,s,a):(0,r.cY)(e,t,s,a)}function J(e,t,s,a){const{chatId:n}=s,{threadInfo:o}=(0,i.Db)(e,n,s)||{};if(!o&&s.replyToMessageId){const o=(0,i.hj)(e,n,s.replyToMessageId);o?e=(0,r.lG)(e,o,n,s.id,a):t.loadMessage({chatId:n,messageId:s.replyToMessageId,threadUpdate:{isDeleting:a,lastMessageId:s.id}})}return e}function ee(e,t,s){const{id:a,chatId:n}=s,{threadInfo:o,firstMessageId:c}=(0,i.Db)(e,n,s)||{},l=(0,i.Z1)(e,n),h=l&&l.unreadCount&&!(0,i.gb)(e,n,u._f);if(e=J(e,t,s),o&&(!c&&(0,d.CI)(s)||(e=(0,r.xj)(e,n,o.threadId,[a]),(0,i.b9)(e,n,o.threadId)&&(e=(0,r.$S)(e,n,o.threadId,a),c||(e=(0,r.pf)(e,n,o.threadId,"firstMessageId",s.id)))),e=(0,r.pf)(e,n,o.threadId,"threadInfo",{...o,lastMessageId:s.id,messagesCount:o.messagesCount+1})),h)return e;if(e=(0,r.xj)(e,n,u._f,[a]),(0,i.b9)(e,n,u._f)){const t=(0,i.It)(e,n,u._f),s=(0,r.$S)(e,n,u._f,a),o=(0,i.Cb)(s,n,u._f);t&&!o.includes(t)||(e=s)}return e}function te(e,t,s,a=!1){const{chats:n}=e,o=n.byId[t]&&n.byId[t].lastMessage;return!o||a||o.id===s.id||o.id===s.previousLocalId||s.id>o.id?(0,r.a4)(e,t,{lastMessage:s}):e}function se(e,t){const s=(0,i.Zw)(e,t),a=(0,i.gb)(e,t,u._f);if(!s||!a)return;let n=a.length;for(;n--;){const e=s[a[n]];if(!e.isDeleting)return e}}function ae(e,t,s,n){if(e){t.forEach((t=>{const s=se(n=(0,r.cY)(n,e,t,{isDeleting:!0}),e);s&&(n=te(n,e,s,!0))})),(0,a.R3)(n),s.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const a=(0,i.hj)(n,e,t);if(!a)return;n=J(n,s,a,!0);const{threadInfo:r}=(0,i.Db)(n,e,a)||{};r&&o.push(r.threadId)})),(0,a.R3)(n),void setTimeout((()=>{(0,a.R3)((0,r.K4)((0,a.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{s.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),Y)}const o=[];t.forEach((e=>{const t=(0,i.X5)(n,e);if(t){o.push(t);const s=se(n=(0,r.cY)(n,t,e,{isDeleting:!0}),t);s&&(n=te(n,t,s,!0)),setTimeout((()=>{(0,a.R3)((0,r.K4)((0,a.Rd)(),t,[e]))}),Y)}})),(0,a.R3)(n),(0,g.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:n,id:o,message:c}=s;e=ee(e=z(e,n,o,c),t,c),c.threadInfo&&(e=(0,r.Xg)(e,c.threadInfo.chatId,c.threadInfo.threadId,c.threadInfo)),(0,a.R3)(e);const l=(0,i.hj)(e,n,o);if((0,i.hg)(e,n,c)){if(c.isOutgoing&&(!c.content||!c.content.action)){const s=(0,i.Bt)(e);s&&t.focusMessage({chatId:n,threadId:s.threadId,messageId:c.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:s}=(0,i.Db)(e,n,c)||{};s&&t.requestThreadInfoUpdate({chatId:n,threadId:s.threadId}),(0,d.CI)(c)||setTimeout((()=>{(0,a.R3)(te((0,a.Rd)(),n,l))}),Y)}else(0,a.R3)(te((0,a.Rd)(),n,l));(0,i.N)(e,n)||t.loadTopChats();break}case"newScheduledMessage":{const{chatId:t,id:n,message:o}=s;e=z(e,t,n,o,!0);const c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,n])),(0,a.R3)(e);break}case"updateMessage":{const{chatId:t,id:n,message:o}=s;if(!(0,i.hj)(e,t,n))return;e=z(e,t,n,o);const c=(0,i.hj)(e,t,n);o.threadInfo&&(e=(0,r.Xg)(e,o.threadInfo.chatId,o.threadInfo.threadId,o.threadInfo)),e=te(e,t,c),(0,a.R3)(e);break}case"updateScheduledMessage":{const{chatId:t,id:n,message:o}=s;if(!(0,i.Tm)(e,t,n))return;e=z(e,t,n,o,!0);const c=Object.keys((0,i.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,u._f,"scheduledIds",c),(0,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:n,localId:o,message:c}=s;e=ee(e,t,c);const d=(0,i.hj)(e,n,o);e=(0,r.K4)(e,n,[o]),c.isScheduled&&(e=(0,r.bV)(e,n,[o])),e=(0,r.cY)(e,n,c.id,{...d,...c,previousLocalId:o});const l=(0,i.hj)(e,n,c.id);e=te(e,n,l);const u=(0,i.Db)(e,n,c);u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,r.pf)(e,n,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:n,message:o}=s,c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const d=(0,i.Tm)(e,t,n);e=(0,r.bV)(e,t,[n]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:n}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:n,messageIds:o}=s,c=(0,i.KB)(e,t)||[],d=n?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,a.R3)((0,r.pf)(e,t,u._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:n,threadInfo:o,firstMessageId:c}=s,d={...(0,i.tZ)(e,t,n),...o};if(!d.threadId)return;e=(0,r.Xg)(e,t,n,d),c&&(e=(0,r.pf)(e,t,n,"firstMessageId",c)),(0,a.R3)(e);break}case"resetMessages":{const{id:n}=s,o=(0,i.Zw)(e,n);o&&!(0,d.YA)(n)&&(e=(0,r.K4)(e,n,Object.keys(o).map(Number)),(0,a.R3)(e),t.loadFullChat({chatId:n,force:!0}));break}case"deleteMessages":{const{ids:a,chatId:n}=s;ae(n,a,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:n}=s;!function(e,t,s,n){e&&(t.forEach((t=>{n=(0,r.P4)(n,e,t,{isDeleting:!0})})),(0,a.R3)(n),setTimeout((()=>{n=(0,r.bV)((0,a.Rd)(),e,t);const s=(0,i.Fn)(n,e);n=(0,r.pf)(n,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,a.R3)(n)}),Y))}(n,t,0,e);break}case"deleteHistory":{const{chatId:a}=s,n=e.messages.byChatId[a];n?ae(a,Object.keys(n.byId).map(Number),t,e):t.requestChatUpdate({chatId:a});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:n}=s;t.forEach((t=>{const s=(0,i.X5)(e,t);s&&(e=(0,r.cY)(e,s,t,n))})),(0,a.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:n,messageUpdate:o}=s;n.forEach((s=>{e=(0,r.cY)(e,t,s,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:n}=s,o=(0,i.ZB)(e,t);if(o&&o.content.poll){const t={...o.content.poll,...n},{results:s}=t.results||{};if(s&&!s.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,a=e&&e.filter((e=>e.isChosen));a&&a.forEach((e=>{const a=s.findIndex((t=>t.option===e.option));a>=0&&(t.results.results[a].isChosen=!0)}))}(0,a.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:n,options:o}=s,c=(0,i.ZB)(e,t);if(!c||!c.content.poll||!c.content.poll.results)break;const{poll:d}=c.content,{recentVoterIds:l,totalVoters:u,results:h}=d.results,m=l?[...l]:[],g=u?u+1:1,f=h?[...h]:[];m.push(n),o.forEach((t=>{const s=f.find((e=>e.option===t)),a=f.findIndex((e=>e.option===t)),o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,n===e.currentUserId&&(o.isChosen=!0),a?f[a]=o:f.push(o)})),(0,a.R3)((0,r.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...d,results:{...d.results,recentVoterIds:m,totalVoters:g,results:f}}}}));break}}}));const ne=(0,Z.P2)((function(){let e=(0,a.Rd)();oe.forEach((([t,s])=>{e=(0,r.Nq)(e,t,{status:s})})),(0,a.R3)(e),oe=[]}),3e3,!0);let oe=[];(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteUser":return(0,r.h8)(e,s.id);case"updateUser":return(0,r.Nq)(e,s.id,s.user);case"updateUserStatus":return a=s.userId,n=s.status,oe.push([a,n]),void ne();case"updateUserFullInfo":{const{id:t,fullInfo:a}=s,n=e.users.byId[t];if(!n)return;return(0,r.Nq)(e,t,{fullInfo:{...n.fullInfo,...a}})}}var a,n})),(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateStickerSet":return(0,r.Rg)(e,s.id,s.stickerSet)}})),(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,r.O4)((0,a.Rd)(),s.id):(0,r.rB)((0,a.Rd)(),s.id);case"updateResetContactList":(0,a.R3)({...(0,a.Rd)(),contactList:{hash:0,userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[s.key]=s.rules}})),(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,r.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:n,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:n})),(0,a.R3)((0,r.aK)(e,t,{isMuted:n,isSilent:o,shouldShowPreviews:i}));break}}})),(0,a.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:s.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:s.message}}}}));var re=s(8674),ie=s(6752),ce=s(1279),de=s(1212),le=s(5332);function ue(e){(0,o.d4)((()=>(0,Z.Gq)(e)),[e])}var he=s(9290);function me(e){e.preventDefault()}var ge=s(6590),fe=s(3989),pe=s(3455),Ie=s(2255),ve=s(706),ye=s(9107),Ze=s(6917),Pe=s(3106),Ce=s(8964),we=s(231),be=s(9589),Me=s(9187),Se=s(3321);const Ee=[0,1,2],ke=(0,o.X$)((0,a.c$)((e=>{const{query:t,fetchingStatus:s,chatId:a,date:n}=e.globalSearch,{currentUserId:o}=e,{byId:r}=e.chats,{animationLevel:c}=e.settings.byKey;return{searchQuery:t,isLoading:!!s&&Boolean(s.chats||s.messages),currentUserId:o,chatsById:r,globalSearchChatId:a,searchDate:n,theme:(0,i.Pu)(e),animationLevel:c}}),((e,t)=>(0,g.ei)(t,["openChat","openTipsChat","setGlobalSearchDate","setGlobalSearchChatId","setSettingOption"])))((({content:e,contactsFilter:t,onSearchQuery:s,onSelectSettings:a,onSelectContacts:r,onSelectArchived:i,setGlobalSearchChatId:c,onReset:l,searchQuery:u,isLoading:g,shouldSkipTransition:f,currentUserId:p,globalSearchChatId:I,searchDate:v,theme:y,animationLevel:Z,chatsById:P,openChat:C,openTipsChat:w,setGlobalSearchDate:b,setSettingOption:M})=>{const S=(0,ye.Z)(),E=e===h.du.ChatList,k=(0,o.Ye)((()=>v?(0,L.xH)(new Date(1e3*v)):void 0),[v]),R=(0,o.Ye)((()=>E&&P?Object.values(P).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[E,P]),T="web.telegram.org"===window.location.hostname,N=(0,o.Ye)((()=>({onTrigger:e,isOpen:t})=>o.ZP.createElement(we.Z,{round:!0,ripple:E&&!m.wB,size:"smaller",color:"translucent",className:t?"active":"",onClick:E?e:()=>l(),ariaLabel:E?S("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,ie.Z)("animated-menu-icon",!E&&"state-back",f&&"no-animation")}))),[E,S,l,f]),B=(0,o.I4)((()=>{u||s("")}),[u,s]),A=(0,o.I4)((()=>{C({id:p,shouldReplaceHistory:!0})}),[p,C]),x=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";M({theme:t}),M({shouldUseSystemTheme:!1}),(0,Ze.Z)(t,Z===n.zy)}),[Z,M,y]),O=(0,o.I4)((e=>{e.stopPropagation();const t=0===Z?2:0;Ee.forEach(((e,s)=>{document.body.classList.toggle(`animation-level-${s}`,t===s)})),M({animationLevel:t})}),[Z,M]),F=Boolean(I)||e===h.du.GlobalSearch||e===h.du.Contacts,U=e===h.du.Contacts?S("SearchFriends"):S("Search");return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(Pe.Z,{trigger:N,footer:`${n.iC} alpha ${n.Ji}`},o.ZP.createElement(Ce.Z,{icon:"saved-messages",onClick:A},S("SavedMessages")),o.ZP.createElement(Ce.Z,{icon:"archive",onClick:i},o.ZP.createElement("span",{className:"menu-item-name"},S("ArchivedChats")),R>0&&o.ZP.createElement("div",{className:"archived-badge"},R)),o.ZP.createElement(Ce.Z,{icon:"user",onClick:r},S("Contacts")),o.ZP.createElement(Ce.Z,{icon:"settings",onClick:a},S("Settings")),o.ZP.createElement(Ce.Z,{icon:"darkmode",onClick:x},o.ZP.createElement("span",{className:"menu-item-name"},S("lng_menu_night_mode")),o.ZP.createElement(Se.Z,{id:"darkmode",label:S("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),o.ZP.createElement(Ce.Z,{icon:"animations",onClick:O},o.ZP.createElement("span",{className:"menu-item-name capitalize"},S("Appearance.Animations").toLowerCase()),o.ZP.createElement(Se.Z,{id:"animations",label:"Toggle Animations",checked:Z>0})),o.ZP.createElement(Ce.Z,{icon:"help",onClick:()=>{w({langCode:S.code})}},S("TelegramFeatures")),o.ZP.createElement(Ce.Z,{icon:"bug",href:n.mU},"Report Bug"),T&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ce.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,ge.Wv)()}},"Switch to K Version"),o.ZP.createElement(Ce.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:ge.Wv},"Switch to Old Version"))),o.ZP.createElement(be.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||v?"with-picker-item":"",value:t||u,focused:F,isLoading:g,placeholder:U,autoComplete:"off",canClose:Boolean(I||v),onChange:s,onReset:l,onFocus:B},k&&o.ZP.createElement(Me.Z,{icon:"calendar",title:k,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:b,clickArg:{date:void 0}}),I&&o.ZP.createElement(Me.Z,{chatOrUserId:I,onClick:c,canClose:!0,clickArg:{id:void 0}}))))})));var Re=s(9204);const Te=(0,o.X$)((()=>{const e=(0,ye.Z)();return o.ZP.createElement("div",{id:"ConnectionState",dir:e.isRtl?"rtl":void 0},o.ZP.createElement(Re.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},e("WaitingForNetwork")))}));var Ne=s(1174);var Be=s(3133),Ae=s(9359);const xe=(0,o.X$)((0,a.c$)((e=>{const{chats:{byId:t},users:{byId:s},chatFolders:{byId:a,orderedIds:n,activeChatFolder:o},currentUserId:r,lastSyncTime:c,shouldSkipHistoryAnimations:d}=e;return{chatsById:t,usersById:s,chatFoldersById:a,orderedFolderIds:n,lastSyncTime:c,notifySettings:(0,i.dZ)(e),notifyExceptions:(0,i.NJ)(e),activeChatFolder:o,currentUserId:r,shouldSkipHistoryAnimations:d}}),((e,t)=>(0,g.ei)(t,["loadChatFolders","setActiveChatFolder","openChat"])))((({chatsById:e,usersById:t,chatFoldersById:s,notifySettings:a,notifyExceptions:n,orderedFolderIds:r,activeChatFolder:i,currentUserId:c,lastSyncTime:l,shouldSkipHistoryAnimations:u,foldersDispatch:h,onScreenSelect:f,loadChatFolders:p,setActiveChatFolder:I,openChat:v})=>{const y=(0,o.sO)(null),P=(0,ye.Z)();(0,o.d4)((()=>{l&&p()}),[l,p]);const C=(0,o.Ye)((()=>r?r.map((e=>s[e]||{})).filter(Boolean):void 0),[s,r]),w=((e,t,s)=>{const a=((e,t=!1)=>(0,o.Ye)((()=>(0,Z.P2)((e=>e()),e,!t)),[e,t]))(t,!0),[n,r]=(0,o.eJ)(),[i,c,d]=(0,ve.Z)();return(0,re.ZP)(c,d),(0,he.Z)((()=>{i||a((()=>{r(e())}))}),s.concat([i])),n})((()=>{if(!C||!C.length)return;const s=Object.keys(e).map(Number),o=C.map((o=>{const{unreadDialogsCount:r,hasActiveDialogs:i}=(0,d.Fu)(e,t,o,s,a,n)||{};return{id:o.id,badgeCount:r,isBadgeActive:i}}));return(0,g.ee)(o,"id")}),3e3,[C,e,t,a,n]),b=(0,o.Ye)((()=>{if(C&&C.length)return[{title:"en"===P.code?"All":P("FilterAllChats")},...C.map((e=>({title:e.title,...w&&w[e.id]})))]}),[C,w,P]),M=(0,o.I4)((e=>{I(e)}),[I]);(0,o.d4)((()=>{b&&b.length&&i>=b.length&&I(0)}),[i,b,I]),(0,o.d4)((()=>{if(y.current&&m.$b&&b&&b.length)return(0,Ne.s)(y.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Ne.e.Left?(I(Math.min(i+1,b.length-1)),!0):t===Ne.e.Right&&(I(Math.max(0,i-1)),!0)})}),[i,b,I]);const S=(0,o.sO)();S.current=0!==i,(0,o.d4)((()=>S.current?(0,fe.Z)((()=>{S.current&&I(0)})):void 0),[i,I]),(0,ge.ZP)(0!==i,(()=>I(0))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&b){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void v({id:c,shouldReplaceHistory:!0});const s=Number(t)-1;if(s>b.length-1)return;I(s),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:E,transitionClassNames:k}=(0,de.Z)(!r,void 0,!0);function R(e){const t=Object.values(s).find((({title:e})=>e===b[i].title));return t&&0!==i?o.ZP.createElement(Ae.Z,{folderType:"folder",folderId:t.id,isActive:e,onScreenSelect:f,foldersDispatch:h}):o.ZP.createElement(Ae.Z,{folderType:"all",isActive:e,foldersDispatch:h,onScreenSelect:f})}return o.ZP.createElement("div",{className:"ChatFolders"},b&&b.length?o.ZP.createElement(Be.Z,{tabs:b,activeTab:i,onSwitchTab:M}):E?o.ZP.createElement("div",{className:(0,ie.Z)("tabs-placeholder",k)}):void 0,o.ZP.createElement(Ie.Z,{ref:y,name:u?"none":P.isRtl?"slide-reversed":"slide",activeKey:i,renderCount:b?b.length:void 0},R))})));var Le=s(9203),Oe=s(8778),Fe=s(4288);const Ue=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)})),$e=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)}));var Qe=s(2328);let De;const qe=(0,o.X$)((({isShown:e,onNewPrivateChat:t,onNewChannel:s,onNewGroup:a})=>{const[n,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{e||r(!1)}),[e]);const i=(0,ye.Z)(),c=(0,ie.Z)("NewChatButton",e&&"revealed",n&&"menu-is-open"),d=(0,o.I4)((()=>{De&&(clearTimeout(De),De=void 0)}),[]),l=(0,o.I4)((()=>{De&&(clearTimeout(De),De=void 0),De=window.setTimeout((()=>{r(!1)}),750)}),[]);return o.ZP.createElement("div",{className:c,onMouseEnter:d,onMouseLeave:l},o.ZP.createElement(we.Z,{round:!0,color:"primary",className:n?"active":"",onClick:()=>{r(!n)},ariaLabel:i(n?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Qe.Z,{isOpen:n,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(Ce.Z,{icon:"channel",onClick:s},i("NewChannel")),o.ZP.createElement(Ce.Z,{icon:"group",onClick:a},i("NewGroup")),o.ZP.createElement(Ce.Z,{icon:"user",onClick:t},i("NewMessageTitle"))))}));var Ge=s(126);const He=Object.keys(h.du).length/2;let je;const _e=(0,a.c$)((e=>(0,g.ei)(e,["connectionState"])))((({content:e,searchQuery:t,searchDate:s,contactsFilter:a,shouldSkipTransition:n,foldersDispatch:r,onSearchQuery:i,onContentChange:c,onScreenSelect:d,onReset:l,connectionState:u})=>{const[g,f]=(0,o.eJ)(m.$b),p=!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"===u,I=(0,o.sO)(!1),v=(0,o.I4)((()=>{c(h.du.Settings)}),[c]),y=(0,o.I4)((()=>{c(h.du.Contacts)}),[c]),Z=(0,o.I4)((()=>{c(h.du.NewChannelStep1)}),[c]),P=(0,o.I4)((()=>{c(h.du.NewGroupStep1)}),[c]),C=(0,o.I4)((()=>{c(h.du.Archived)}),[c]),w=(0,o.I4)((()=>{e===h.du.ChatList&&(I.current=!0,f(!0))}),[e]),b=(0,o.I4)((()=>{I.current=!1,je&&(clearTimeout(je),je=void 0),je=window.setTimeout((()=>{I.current||f(!1)}),250)}),[]);(0,o.d4)((()=>{let t;return e!==h.du.ChatList?t=window.setTimeout((()=>{f(!1)}),250):(I.current||m.$b)&&f(!0),()=>{t&&(clearTimeout(t),t=void 0)}}),[e]);const[M,S,E]=function(){const[e,t]=(0,ve.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:s,transitionClassNames:a}=(0,de.Z)(e);return[s,a,()=>{window.location.reload()}]}(),k=(0,ye.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:m.$b?void 0:w,onMouseLeave:m.$b?void 0:b},o.ZP.createElement(ke,{content:e,contactsFilter:a,onSearchQuery:i,onSelectSettings:v,onSelectContacts:y,onSelectArchived:C,onReset:l,shouldSkipTransition:n}),o.ZP.createElement(Ge.Z,{isOpen:p,isCustom:!0,className:"connection-state-wrapper opacity-transition slow"},(()=>o.ZP.createElement(Te,null))),o.ZP.createElement(Ie.Z,{name:n?"none":"zoom-fade",renderCount:He,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:h.du.ChatList,className:p?"pull-down":void 0},(n=>{switch(e){case h.du.ChatList:return o.ZP.createElement(xe,{onScreenSelect:d,foldersDispatch:r});case h.du.GlobalSearch:return o.ZP.createElement(Ue,{searchQuery:t,searchDate:s,isActive:n,onReset:l});case h.du.Contacts:return o.ZP.createElement($e,{filter:a,isActive:n,onReset:l});default:return}})),M&&o.ZP.createElement(we.Z,{fluid:!0,pill:!0,className:(0,ie.Z)("btn-update",S),onClick:E},k("lng_update_telegram")),o.ZP.createElement(qe,{isShown:g,onNewPrivateChat:y,onNewChannel:Z,onNewGroup:P}))})),Ve=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)})),We=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)})),Ke=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)}));var Xe;!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"}(Xe||(Xe={}));const Ye=Object.keys(Xe).length/2,ze=(0,o.X$)((0,a.c$)((e=>{const{globalSearch:{query:t,date:s},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:n}=e;return{searchQuery:t,searchDate:s,activeChatFolder:a,shouldSkipHistoryAnimations:n}}),((e,t)=>(0,g.ei)(t,["setGlobalSearchQuery","setGlobalSearchChatId","resetChatCreation","setGlobalSearchDate","loadPasswordInfo","clearTwoFaError"])))((({searchQuery:e,searchDate:t,activeChatFolder:s,shouldSkipHistoryAnimations:a,setGlobalSearchQuery:n,setGlobalSearchChatId:r,resetChatCreation:i,setGlobalSearchDate:c,loadPasswordInfo:d,clearTwoFaError:l})=>{const[u,g]=(0,o.eJ)(h.du.ChatList),[f,p]=(0,o.eJ)(h.MT.Main),[I,v]=(0,o.eJ)(""),[y,Z]=(0,pe.ZP)(),[P,C]=(0,o.eJ)(0);let w=Xe.Main;switch(u){case h.du.Archived:w=Xe.Archived;break;case h.du.Settings:w=Xe.Settings;break;case h.du.NewChannelStep1:case h.du.NewChannelStep2:w=Xe.NewChannel;break;case h.du.NewGroupStep1:case h.du.NewGroupStep2:w=Xe.NewGroup}const b=(0,o.I4)((e=>{if(u!==h.du.NewGroupStep2||e)if(u!==h.du.NewChannelStep2||e){if(u===h.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(u===h.du.Settings)switch(f){case h.MT.EditProfile:case h.MT.Folders:case h.MT.General:case h.MT.Notifications:case h.MT.Privacy:case h.MT.Language:return void p(h.MT.Main);case h.MT.GeneralChatBackground:return void p(h.MT.General);case h.MT.GeneralChatBackgroundColor:return void p(h.MT.GeneralChatBackground);case h.MT.PrivacyPhoneNumber:case h.MT.PrivacyLastSeen:case h.MT.PrivacyProfilePhoto:case h.MT.PrivacyForwarding:case h.MT.PrivacyGroupChats:case h.MT.PrivacyActiveSessions:case h.MT.PrivacyBlockedUsers:case h.MT.TwoFaDisabled:case h.MT.TwoFaEnabled:case h.MT.TwoFaCongratulations:return void p(h.MT.Privacy);case h.MT.PrivacyPhoneNumberAllowedContacts:case h.MT.PrivacyPhoneNumberDeniedContacts:return void p(h.MT.PrivacyPhoneNumber);case h.MT.PrivacyLastSeenAllowedContacts:case h.MT.PrivacyLastSeenDeniedContacts:return void p(h.MT.PrivacyLastSeen);case h.MT.PrivacyProfilePhotoAllowedContacts:case h.MT.PrivacyProfilePhotoDeniedContacts:return void p(h.MT.PrivacyProfilePhoto);case h.MT.PrivacyForwardingAllowedContacts:case h.MT.PrivacyForwardingDeniedContacts:return void p(h.MT.PrivacyForwarding);case h.MT.PrivacyGroupChatsAllowedContacts:case h.MT.PrivacyGroupChatsDeniedContacts:return void p(h.MT.PrivacyGroupChats);case h.MT.TwoFaNewPassword:return void p(h.MT.TwoFaDisabled);case h.MT.TwoFaNewPasswordConfirm:return void p(h.MT.TwoFaNewPassword);case h.MT.TwoFaNewPasswordHint:return void p(h.MT.TwoFaNewPasswordConfirm);case h.MT.TwoFaNewPasswordEmail:return void p(h.MT.TwoFaNewPasswordHint);case h.MT.TwoFaNewPasswordEmailCode:return void p(h.MT.TwoFaNewPasswordEmail);case h.MT.TwoFaChangePasswordCurrent:case h.MT.TwoFaTurnOff:case h.MT.TwoFaRecoveryEmailCurrentPassword:return void p(h.MT.TwoFaEnabled);case h.MT.TwoFaChangePasswordNew:return void p(h.MT.TwoFaChangePasswordCurrent);case h.MT.TwoFaChangePasswordConfirm:return void p(h.MT.TwoFaChangePasswordNew);case h.MT.TwoFaChangePasswordHint:return void p(h.MT.TwoFaChangePasswordConfirm);case h.MT.TwoFaRecoveryEmail:return void p(h.MT.TwoFaRecoveryEmailCurrentPassword);case h.MT.TwoFaRecoveryEmailCode:return void p(h.MT.TwoFaRecoveryEmail);case h.MT.FoldersCreateFolder:case h.MT.FoldersEditFolder:return void p(h.MT.Folders);case h.MT.FoldersIncludedChatsFromChatList:case h.MT.FoldersExcludedChatsFromChatList:return void p(h.MT.FoldersEditFolderFromChatList);case h.MT.FoldersEditFolderFromChatList:return g(h.du.ChatList),void p(h.MT.Main)}u!==h.du.ChatList||0!==s?(g(h.du.ChatList),v(""),n({query:""}),c({date:void 0}),r({id:void 0}),i(),setTimeout((()=>{C(Date.now())}),250)):g(h.du.GlobalSearch)}else g(h.du.NewChannelStep1);else g(h.du.NewGroupStep1)}),[u,s,f,n,c,r,i]),M=(0,o.I4)((t=>{u!==h.du.Contacts?(g(h.du.GlobalSearch),t!==e&&n({query:t})):v(t)}),[u,e,n]);(0,o.d4)((()=>u!==h.du.ChatList||0===s?(0,fe.Z)((()=>b())):void 0),[s,u,b]),(0,o.d4)((()=>{l(),f===h.MT.Privacy&&d()}),[l,d,f]);const S=e=>{g(h.du.Settings),p(e)};return o.ZP.createElement(Ie.Z,{id:"LeftColumn",name:a?"none":m.s0,renderCount:Ye,activeKey:w,shouldCleanup:!0,cleanupExceptionKey:Xe.Main},(s=>{switch(w){case Xe.Archived:return o.ZP.createElement(Ke,{isActive:s,onReset:b,onContentChange:g});case Xe.Settings:return o.ZP.createElement(Ve,{isActive:s,currentScreen:f,foldersState:y,foldersDispatch:Z,onScreenSelect:S,onReset:b,shouldSkipTransition:a});case Xe.NewChannel:return o.ZP.createElement(We,{key:P,isActive:s,isChannel:!0,content:u,onContentChange:g,onReset:b});case Xe.NewGroup:return o.ZP.createElement(We,{key:P,isActive:s,content:u,onContentChange:g,onReset:b});default:return o.ZP.createElement(_e,{content:u,searchQuery:e,searchDate:t,contactsFilter:I,foldersDispatch:Z,onContentChange:g,onSearchQuery:M,onScreenSelect:S,onReset:b,shouldSkipTransition:a})}}))})));var Je=s(2420),et=s(9524),tt=s(1394),st=s(3858);const at=()=>{const[e,t]=(0,o.eJ)(st.Z.get());return(0,o.d4)((()=>{const e=(0,Z.P2)((()=>{t(st.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var nt=s(2678);const ot=728;const rt=e=>e.chatId.toString()+("thread"!==e.type?`_${e.type}`:-1!==e.threadId?`_${e.threadId}`:"");var it=s(3570),ct=s(5790),dt=s(8360),lt=s(2155),ut=s(6058),ht=s(8799);const mt=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"HeaderMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),gt=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a})=>{const n=(0,i.Z1)(e,t),o=Boolean(n&&(0,d.eA)(n));if(n&&n.isRestricted)return{noMenu:!0};const r=(0,i.IK)(e,t),c=(0,i.FM)(e,t),l="thread"===a&&s===u._f,h="thread"===a&&s!==u._f,g=(0,i.Jf)(e),f=Boolean(r&&(0,i.s4)(e,r.id)),p=!f&&Boolean((0,i.pk)(e,t)),I=Boolean(l&&n&&(o||(0,d.ZV)(n))&&n.isNotJoined),v=l||h,y=l&&!c&&!I,Z=!(0,i.CA)(e),P=l&&!I;return{noMenu:!(m.wB&&I||m.wB&&v||y||Z||P),isChannel:o,isRightColumnShown:g,canStartBot:p,canRestartBot:f,canSubscribe:I,canSearch:v,canMute:y,canSelect:Z,canLeave:P}}),((e,t)=>(0,g.ei)(t,["joinChannel","sendBotCommand","openLocalTextSearch","restartBot"])))((({chatId:e,threadId:t,noMenu:s,isChannel:a,canStartBot:n,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canSelect:l,canLeave:u,isRightColumnShown:h,joinChannel:g,sendBotCommand:f,openLocalTextSearch:p,restartBot:I})=>{const v=(0,o.sO)(null),[y,Z]=(0,o.eJ)(!1),[P,C]=(0,o.eJ)(void 0),w=(0,o.I4)((()=>{Z(!0);const e=v.current.getBoundingClientRect();C({x:e.right,y:e.bottom})}),[]),b=(0,o.I4)((()=>{Z(!1)}),[]),M=(0,o.I4)((()=>{C(void 0)}),[]),S=(0,o.I4)((()=>{g({chatId:e})}),[g,e]),E=(0,o.I4)((()=>{f({command:"/start"})}),[f]),k=(0,o.I4)((()=>{I({chatId:e})}),[e,I]),R=(0,o.I4)((()=>{p(),m.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[p]),T=(0,ye.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!m.wB&&i&&o.ZP.createElement(we.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:S},T(a?"Subscribe":"Join Group")),!m.wB&&n&&o.ZP.createElement(we.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:E},T("BotStart")),!m.wB&&r&&o.ZP.createElement(we.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:k},T("BotRestart")),!m.wB&&c&&o.ZP.createElement(we.Z,{round:!0,ripple:h,color:"translucent",size:"smaller",onClick:R,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),(m.wB||!i)&&o.ZP.createElement(we.Z,{ref:v,className:y?"active":"",round:!0,ripple:!m.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:w},o.ZP.createElement("i",{className:"icon-more"})),P&&o.ZP.createElement(mt,{chatId:e,threadId:t,isOpen:y,anchor:P,isChannel:a,canStartBot:n,canRestartBot:r,canSubscribe:i,canSearch:c,canMute:d,canSelect:l,canLeave:u,onSubscribeChannel:S,onSearchClick:R,onClose:b,onCloseAnimationEnd:M}))})));var ft=s(4399),pt=s(2340),It=s(6202),vt=s(862);function yt(e){const t=e&&(0,d.DH)(e),{sticker:s}=e&&e.content||{},a=t&&s&&!(0,m.on)()&&t.includes("image/webp"),[r,i]=(0,o.eJ)(vt.Hu),c=e&&e.id;return(0,o.bt)((()=>{a&&(0,vt.p6)(`b64-${c}`,t).then(i).catch((e=>{n.eM&&console.error(e)}))}),[c,a,t]),a?r:t}var Zt=s(7551),Pt=s(8512);function Ct(e,t,s,a,n){return`M${e},${t+n}a${n},${n},0,0,1,\n ${s},0v${a-2*n}a${n},${n},0,0,1,${-s},0Z`}const wt=(0,o.X$)((({count:e,index:t})=>{const s=(0,o.sO)(null),a=(0,o.Ye)((()=>function(e,t){const s=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),n=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,a),r=`clipPath${e}`;return{markHeight:n,clipPath:function(e,t,s){let a="";if(3===s)a=Ct(0,0,2,t,1)+Ct(0,12,2,t+1,1)+Ct(0,25,2,t,1);else for(let e=0;e<s;e++)a+=Ct(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${a}" />\n </clipPath>`}(r,a,e),markTranslateY:function(e,t,s){return 1===s?0:2===s?0===e?0:t+2:3===s?0===e?0:1===e?12:25:(t+2)*e}(s,a,e),trackTranslateY:function(e,t,s,a){return t<=4||e<=1?0:e>=t-2?a-36:(s+4)/2+(e-2)*(s+2)}(s,e,a,o),trackHeight:o,clipPathId:r}}(e,t)),[e,t]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:r,clipPath:i}=a,c=s.current.firstElementChild;if(s&&s.current){const a=s.current,{style:d}=a;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${r}")`;const l=a.querySelector("svg"),u=a.querySelector("div"),h=a.querySelector("defs");l||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${i} </defs></svg>`),h&&(h.innerHTML=i),u&&(u.style.height=`${n}px`,u.style.transform=`translateY(${o}px)`)}}),[a]),1===e)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:n,trackTranslateY:r,markHeight:i,markTranslateY:c,clipPathId:d}=a;return o.ZP.createElement("div",{className:(0,ie.Z)("pinned-message-border",e>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${d}"); width: 2px;\n height: ${n}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${i}px; transform: translateY(${c}px);`})))})),bt=(0,o.X$)((({message:e,count:t,index:s,customTitle:a,className:n,onUnpinMessage:r,onClick:i,onAllPinnedClick:c})=>{const l=(0,ye.Z)(),u=yt(e),h=(0,It.Z)((0,d.Ti)(e,"pictogram")),m=(0,d.MK)(l,e,Boolean(u)),[g,f,p]=(0,ve.Z)(),I=(0,o.I4)((()=>{p(),r&&r(e.id)}),[p,r,e.id]);return o.ZP.createElement("div",{className:(0,ie.Z)("HeaderPinnedMessage-wrapper",n)},t>1&&o.ZP.createElement(we.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:l("EventLogFilterPinnedMessages"),onClick:c},o.ZP.createElement("i",{className:"icon-pin-list"})),r&&o.ZP.createElement(we.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:l("UnpinMessageAlertTitle"),className:"unpin-button",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Zt.Z,{isOpen:g,onClose:p,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:I}),o.ZP.createElement("div",{className:"HeaderPinnedMessage",onClick:i,dir:l.isRtl?"rtl":void 0},o.ZP.createElement(wt,{count:t,index:s}),u&&function(e,t){const{width:s,height:a}=(0,ft.W7)();return o.ZP.createElement("img",{src:t||e,width:s,height:a,alt:""})}(u,h),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},a||`${l("PinnedMessage")} ${s>0?"#"+(t-s):""}`),o.ZP.createElement("p",{dir:"auto"},(0,pt.Z)(m))),o.ZP.createElement(Pt.Z,null)))}));var Mt=s(647),St=s(3186);const Et=(0,a.c$)(((e,{message:t})=>({sender:(0,i.Ur)(e,t)})),((e,t)=>(0,g.ei)(t,["focusMessage","closeAudioPlayer"])))((({message:e,className:t,noUi:s,sender:a,focusMessage:n,closeAudioPlayer:r})=>{const i=(0,ye.Z)(),c=a?(0,d.OU)(i,a):void 0,l=Mt.UV((0,d.Ti)(e,"inline")),{playPause:u,isPlaying:h}=(0,St.Z)((0,d.Tp)(e),(0,d.XV)(e),l,void 0,void 0,!0),g=(0,o.I4)((()=>{n({chatId:e.chatId,messageId:e.id})}),[n,e.chatId,e.id]),f=(0,o.I4)((()=>{h&&u(),r()}),[r,h,u]);if(s)return;const p=(0,d.oP)(e);return o.ZP.createElement("div",{className:(0,ie.Z)("AudioPlayer",t),dir:i.isRtl?"rtl":void 0},o.ZP.createElement(we.Z,{round:!0,ripple:!m.wB,color:"translucent",size:"smaller",className:(0,ie.Z)("toggle-play",h?"pause":"play"),onClick:u,ariaLabel:h?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:g},p?function(e){const{title:t,performer:s,fileName:a}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,pt.Z)(t||a)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,pt.Z)(s)))}(p):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,pt.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(i("AttachAudio"),c),o.ZP.createElement(Pt.Z,null)),o.ZP.createElement(we.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:f,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))})),kt=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a})=>{const{isLeftColumnShown:n,lastSyncTime:o,shouldSkipHistoryAnimations:r}=e,{byId:c}=e.chats,d=(0,i.Z1)(e,t),{typingStatus:l}=d||{},{chatId:h,messageId:m}=e.audioPlayer,g=h&&m?(0,i.hj)(e,h,m):void 0;let f;if("pinned"===a){const s=(0,i.KB)(e,t);f=s&&s.length}else if("scheduled"===a){const s=(0,i.qy)(e,t);f=s&&s.length}else if("thread"===a&&s!==u._f){const a=(0,i.tZ)(e,t,s);a&&(f=a.messagesCount)}const p={typingStatus:l,isLeftColumnShown:n,isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),audioMessage:g,chat:d,chatsById:c,messagesCount:f,isChatWithSelf:(0,i.FM)(e,t),isChatWithBot:d&&(0,i.xo)(e,d),lastSyncTime:o,shouldSkipHistoryAnimations:r,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1)},I=(0,i.Zw)(e,t);if("thread"!==a||!I)return p;if(Object.assign(p,{messagesById:I}),s!==u._f){const a=(0,i.qS)(e,t,s),n=a?(0,i.hj)(e,t,a):void 0,o=n?(0,i.cv)(e,n):void 0;return{...p,pinnedMessageIds:a,canUnpin:!1,topMessageSender:o}}const v=(0,i.KB)(e,t);if(v&&v.length){const t=I[v[0]],{canUnpin:a}=t&&(0,i._k)(e,t,s)||{};return{...p,pinnedMessageIds:v,canUnpin:a}}return p}),((e,t)=>(0,g.ei)(t,["openChatWithInfo","pinMessage","focusMessage","openChat","openPreviousChat","loadPinnedMessages","toggleLeftColumn","exitMessageSelectMode"])))((({chatId:e,threadId:t,messageListType:s,isReady:r,pinnedMessageIds:c,messagesById:l,canUnpin:h,topMessageSender:g,typingStatus:f,isSelectModeActive:p,isLeftColumnShown:I,isRightColumnShown:v,audioMessage:y,chat:Z,chatsById:P,messagesCount:C,isChatWithSelf:w,isChatWithBot:b,lastSyncTime:M,shouldSkipHistoryAnimations:S,currentTransitionKey:E,openChatWithInfo:k,pinMessage:R,focusMessage:T,openChat:N,openPreviousChat:B,loadPinnedMessages:A,toggleLeftColumn:x,exitMessageSelectMode:L})=>{const O=(0,ye.Z)(),[F,U]=(0,o.eJ)(0),$=Array.isArray(c)?c[F]:c,Q=l&&$?l[$]:void 0,D=Array.isArray(c)?c.length:c?1:0,q=Z&&(0,d.U)(O,Z).length,G=g?(0,d.OU)(O,g):void 0;(0,o.d4)((()=>{t===u._f&&M&&r&&A({chatId:e})}),[e,A,M,t,r]),(0,o.d4)((()=>{U(0)}),[c]),(0,ct.Z)(e,$,Q);const{width:H}=at(),j=H<=n.ks,_=m.p7&&I,V=(0,o.sO)(null),W=(0,o.sO)(!0),K=(0,o.I4)((()=>{k({id:e})}),[k,e]),X=(0,o.I4)((t=>{R({chatId:e,messageId:t,isUnpin:!0})}),[R,e]),Y=(0,o.I4)((()=>{if(Q){T({chatId:Q.chatId,threadId:t,messageId:Q.id});const e=(0,it.Z)(D,F+1);U(e)}}),[Q,T,t,D,F]),z=(0,o.I4)((()=>{N({id:e,threadId:u._f,type:"pinned"})}),[N,e]),J=(0,o.I4)((e=>{if(m.wB){const e=document.getElementById(n.R2);e&&e.blur()}p?L():t!==u._f||"thread"!==s||0!==E?B():m.wB||_?(e.stopPropagation(),N({id:void 0})):x()}),[t,s,E,p,B,_,N,x,L]),ee=(0,o.Ye)((()=>{if(j&&P)return(0,i.A1)((0,a.Rd)())||void 0}),[j,P]),te=H>=n.ks&&H<n.jT||H>n.l3&&H<n.ks&&(!q||q>30),se=te||H>n._m&&H<n.QU,{shouldRender:ae,transitionClassNames:ne}=(0,de.Z)(Boolean(y)),oe=(0,dt.Z)(y),{shouldRender:re,transitionClassNames:ce}=(0,de.Z)(Q&&!ae),le=(0,dt.Z)(Q),ue=(0,dt.Z)(G),he=re&&le||ae&&oe;function me(){return"thread"===s&&t===u._f?o.ZP.createElement(o.ZP.Fragment,null,(j||E>0)&&ge(_,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:K},(0,d.YA)(e)?o.ZP.createElement(ut.Z,{userId:e,typingStatus:f,withFullInfo:b,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(ht.Z,{chatId:e,typingStatus:f,noRtl:!0,withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0}))):"thread"===s?o.ZP.createElement(o.ZP.Fragment,null,ge(),o.ZP.createElement("h3",null,O("CommentsCount",C))):"pinned"===s?o.ZP.createElement(o.ZP.Fragment,null,ge(),o.ZP.createElement("h3",null,O("PinnedMessagesCount",C))):"scheduled"===s?o.ZP.createElement(o.ZP.Fragment,null,ge(),o.ZP.createElement("h3",null,w?O("Reminders"):O("messages",C,"i"))):void 0}function ge(e=!1,t=!1){return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(we.Z,{round:!0,size:"smaller",color:"translucent",onClick:J,ariaLabel:e?"Close":"Back"},o.ZP.createElement("div",{className:(0,ie.Z)("animated-close-icon",!e&&"state-back")})),t&&ee&&o.ZP.createElement("div",{className:"unread-count active"},(0,lt.bi)(ee)))}return(0,o.d4)((()=>{const e=V.current;if(e)return se&&he?void(v||te?(W.current&&(e.classList.add("tools-stacked","animated"),W.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),W.current=!0)):(e.classList.remove("tools-stacked","animated"),void(W.current=!0))}),[se,he,te,v]),o.ZP.createElement("div",{className:"MiddleHeader",ref:V},o.ZP.createElement(Ie.Z,{name:S?"none":"slide-fade",activeKey:E},me),o.ZP.createElement("div",{className:"header-tools"},re&&le&&!ae&&o.ZP.createElement(bt,{key:e,message:le,count:D,index:F,customTitle:ue,className:ce,onUnpinMessage:h?X:void 0,onClick:Y,onAllPinnedClick:z}),ae&&oe&&o.ZP.createElement(Et,{key:(0,d.Tp)(oe),message:oe,className:ne}),o.ZP.createElement(gt,{chatId:e,threadId:t,messageListType:s})))})));var Rt=s(2645),Tt=s(274);function Nt(e){return"albumId"in e}function Bt(e,t){let s,a=[],n={originalDate:e[0].date,datetime:Number((0,L.$Y)(1e3*e[0].date)),senderGroups:[a]};const o=[n];return e.forEach(((r,i)=>{r.isInAlbum?s?(s.messages.push(r),r.content.text&&(s.mainMessage=r)):s={albumId:r.groupedId,messages:[r],mainMessage:r}:a.push(r);const c=e[i+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(a.push(s),s=void 0),c){const e=Number((0,L.$Y)(1e3*c.date));n.datetime!==e?(n={originalDate:c.date,datetime:e,senderGroups:[]},o.push(n),a=[],n.senderGroups.push(a)):(c.id===t||r.senderId!==c.senderId||r.isOutgoing!==c.isOutgoing||(0,d.Lo)(r)||(0,d.Lo)(c)||r.forwardInfo&&c.forwardInfo&&(r.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||r.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||r.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||r.inlineButtons||c.inlineButtons||c.date-r.date>600)&&(a=[],n.senderGroups.push(a))}})),o}function At(e){!m.wB&&document.activeElement&&document.activeElement.id===n.R2&&e.target===e.currentTarget&&e.preventDefault()}var xt=s(7675),Lt=s(539),Ot=s(3657);const Ft=m.wZ?1e3:350,Ut=m.wB?300:500;var $t=s(7240),Qt=s(935);function Dt(e){return"number"==typeof e}function qt(e,t){return e?t?238:175:t?238:100}function Gt(e,t){const s=(0,d.B4)(e),a=(0,d.MF)(e),n=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),r=Boolean((0,d.F$)(e)),{width:i,height:c}=n?(0,ft.Eh)(n,s,a,r,t):(0,ft.GC)(o,s,a,t),l=qt(Boolean((0,d.UD)(e)));let u=1;i<l&&l-i<12&&(u=l/i),c*u<90&&90-c*u<12&&(u=90/c);const h=Math.round(i*u),m=Math.round(c*u);return{width:h,height:m,isSmall:h<l||m<90}}function Ht(e,t){return e.reduce(((e,t)=>e+t),t)}function jt(e,t,s){return e<t?t:e>s?s:e}function _t(e){const t={width:0,height:0};return e.forEach((({dimensions:e,sides:s})=>{2&s&&(t.width=e.width+e.x),4&s&&(t.height=e.height+e.y)})),t}function Vt(e,t,s,a){const n=a.messages.map((e=>{const t=Gt(e);return t.width/t.height})),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(n),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(n),i=n.length,c=n.some((e=>e>2)),d=(0,ft.kc)(e,t,!1,s)-(t?2.5:0)*ft.Gw;let l;const u={ratios:n,proportions:o,averageRatio:r,maxWidth:d,minWidth:100,maxHeight:d,spacing:2};return l=i>=5||c?function({ratios:e,averageRatio:t,maxWidth:s,minWidth:a,spacing:n,maxHeight:o=4*s/3}){const r=function(e,t){return e.map((e=>t>1.1?jt(e,1,2.75):jt(e,.6667,1)))}(e,t),i=e.length,c=new Array(i),d=[],l=e=>{const t=[];let a=0;e.forEach((e=>{t.push(((e,t)=>{const a=Ht(r.slice(e,e+t),0);return(s-(t-1)*n)/a})(a,e)),a+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==i;++e){const t=i-e;e<=3&&t<=3&&l([e,t])}for(let e=1;e!==i-1;++e)for(let s=1;s!==i-e;++s){const a=i-e-s;e<=3&&s<=(t<.85?4:3)&&a<=3&&l([e,s,a])}for(let e=1;e!==i-1;++e)for(let t=1;t!==i-e;++t)for(let s=1;s!==i-e-t;++s){const a=i-e-t-s;e<=3&&t<=3&&s<=3&&a<=4&&l([e,t,s,a])}let u,h=0;for(let e=0;e<d.length;e++){const{heights:t,lineCounts:s}=d[e],r=s.length,i=Ht(t,0)+n*(r-1),c=Math.min(...t)<a?1.5:1,l=(()=>{for(let e=1;e!==r;++e)if(s[e-1]>s[e])return 1.5;return 1})(),m=Math.abs(i-o)*c*l;(!u||m<h)&&(u=d[e],h=m)}const m=u.lineCounts,g=u.heights,f=m.length;let p=0,I=0;for(let e=0;e!==f;++e){const t=m[e],a=g[e],o=Math.round(a);let i=0;for(let d=0;d!==t;++d){const l=0|(0===e?1:0)|(e===f-1?4:0)|(0===d?8:0)|(d===t-1?2:0),u=r[p],h=d===t-1?s-i:Math.round(u*a);c[p]={dimensions:{x:i,y:I,width:h,height:o},sides:l},i+=h+n,++p}I+=o+n}return c}(u):2===i?function(e){const{ratios:t,proportions:s,averageRatio:a}=e;return"ww"===s&&a>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:a,maxHeight:n}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(n-a)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:11},{dimensions:{x:0,y:o+a,width:s,height:o},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:a,maxHeight:n}=e,o=(s-a)/2,r=Math.round(Math.min(o/t[0],Math.min(o/t[1],n)));return[{dimensions:{x:0,y:0,width:o,height:r},sides:13},{dimensions:{x:o+a,y:0,width:o,height:r},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:a,spacing:n,maxHeight:o}=e,r=Math.round(1.5*s),i=Math.min(Math.round(Math.max(.4*(a-n),(a-n)/t[0]/(1/t[0]+1/t[1]))),a-n-r),c=a-i-n,d=Math.min(o,Math.round(Math.min(c/t[0],i/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:13},{dimensions:{x:c+n,y:0,width:i,height:d},sides:7}]}(e)}(u):3===i?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:a,maxWidth:n,minWidth:o}=e,r=t,i=Math.round(Math.min((t-s)/2,a[1]*(n-s)/(a[2]+a[1]))),c=r-i-s,d=Math.max(o,Math.round(Math.min((n-s)/2,Math.min(i*a[2],c*a[1])))),l=Math.min(Math.round(r*a[0]),n-s-d);return[{dimensions:{x:0,y:0,width:l,height:r},sides:13},{dimensions:{x:l+s,y:0,width:d,height:c},sides:3},{dimensions:{x:l+s,y:c+s,width:d,height:i},sides:6}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:a,spacing:n}=e,o=t,r=Math.round(Math.min(o/s[0],.66*(a-n))),i=(t-n)/2,c=Math.min(a-r-n,Math.round(Math.min(i/s[1],i/s[2])));return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+n,width:i,height:c},sides:12},{dimensions:{x:i+n,y:r+n,width:o-i-n,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:a,minWidth:n}){const o=e,r=Math.round(Math.min(o/t[0],.66*(a-s))),i=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(n,Math.round(Math.min(.4*(e-2*s),i*t[1]))),d=Math.round(Math.max(Math.max(n,.33*(e-2*s)),i*t[3])),l=o-c-d-2*s,u=Math.min(a-r-s,i);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:c,height:u},sides:12},{dimensions:{x:c+s,y:r+s,width:l,height:u},sides:4},{dimensions:{x:c+s+l+s,y:r+s,width:d,height:u},sides:6}]}(e):function({maxHeight:e,ratios:t,maxWidth:s,spacing:a,minWidth:n}){const o=e,r=Math.round(Math.min(o*t[0],.6*(s-a))),i=Math.round((e-2*a)/(1/t[1]+1/t[2]+1/t[3])),c=Math.round(i/t[1]),d=Math.round(i/t[2]),l=o-c-d-2*a,u=Math.max(n,Math.min(s-r-a,i));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+a,y:0,width:u,height:c},sides:3},{dimensions:{x:r+a,y:c+a,width:u,height:d},sides:2},{dimensions:{x:r+a,y:c+d+2*a,width:u,height:l},sides:6}]}(e)}(u),{layout:l,containerStyle:_t(l)}}let Wt;function Kt(e){return Wt||(Wt=document.createElement("span"),Wt.style.font=m.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',Wt.style.whiteSpace="nowrap",Wt.style.position="absolute",Wt.style.left="-999px",Wt.style.opacity=".01",document.body.appendChild(Wt)),Wt.innerHTML=e,Wt.offsetWidth}function Xt(e,t,s,a,n,r){(0,o.bt)((()=>{if(s&&e.current){const t=e.current.closest(".MessageList");(0,Lt.Z)(t,e.current,n?"end":"centerOrTop",20,void 0!==a?1e3:void 0,a,void 0,r)}}),[e,t,s,a,n,r])}var Yt=s(172),zt=s(2864);const Jt=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"ContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),es=(0,o.X$)((0,a.c$)(((e,{message:t})=>{const{byId:s}=e.users,a=t.senderId,{targetUserIds:n,targetChatId:o}=t.content.action||{},r=t.replyToMessageId,c=r?(0,i.hj)(e,t.chatId,r):void 0,l=(0,i._X)(e,t),{direction:u,noHighlight:h}=l&&e.focusedMessage||{},m=(0,i.Z1)(e,t.chatId);return{usersById:s,sender:m&&((0,d.eA)(m)||a===t.chatId)?m:a?(0,i.dy)(e,a):void 0,targetChatId:o,targetUserIds:n,targetMessage:c,isFocused:l,...l&&{focusDirection:u,noFocusHighlight:h}}}))((({message:e,observeIntersection:t,isEmbedded:s,appearanceOrder:a=0,isLastInList:n,usersById:r,sender:i,targetUserIds:c,targetMessage:d,targetChatId:l,isFocused:u,focusDirection:h,noFocusHighlight:m})=>{const g=(0,o.sO)(null);(0,Ot._N)(g,t),(0,ct.Z)(e.chatId,e.replyToMessageId,d),Xt(g,e.chatId,u,h,m);const f=(0,ye.Z)(),p=a<=0,[I,v]=(0,ve.Z)(p);(0,o.d4)((()=>{p||setTimeout(v,10*a)}),[a,v,p]);const{transitionClassNames:y}=(0,de.Z)(I,void 0,p,!1),Z=(0,o.Ye)((()=>c?c.map((e=>r&&r[e])).filter(Boolean):void 0),[c,r]),P=(0,zt.D)(f,e,i,Z,d,l,s?{isEmbedded:!0,asPlain:!0}:void 0),{isContextMenuOpen:C,contextMenuPosition:w,handleBeforeContextMenu:b,handleContextMenu:M,handleContextMenuClose:S,handleContextMenuHide:E}=(0,$t.Z)(g),k=void 0!==w;if(s)return o.ZP.createElement("span",{className:"embedded-action-message"},(0,pt.Z)(P));const R=(0,ie.Z)("ActionMessage message-list-item",u&&!m&&"focused",k&&"has-menu-open",n&&"last-in-list",y);return o.ZP.createElement("div",{ref:g,id:`message${e.id}`,className:R,"data-message-id":e.id,onMouseDown:e=>{At(e),b(e)},onContextMenu:M},o.ZP.createElement("span",null,P),w&&o.ZP.createElement(Jt,{isOpen:C,anchor:w,message:e,messageListType:"thread",onClose:S,onCloseAnimationEnd:E}))}))),ts=({className:e,message:t,sender:s,title:a,customText:n,observeIntersection:r,onClick:i})=>{const c=(0,o.sO)(null),l=(0,Ot.Op)(c,r),u=(0,It.Z)(t&&(0,d.Ti)(t,"pictogram"),!l),h=t&&`sticker-reply-thumb${t.id}`,m=yt(t),g=Boolean(t&&(0,d.Y5)(t)),f=(0,ye.Z)(),p=s&&(0,d.OU)(f,s);return o.ZP.createElement("div",{ref:c,className:(0,ie.Z)("EmbeddedMessage",e),onClick:t?i:void 0},m&&function(e,t,s,a){const{width:n,height:r}=(0,ft.W7)();return o.ZP.createElement("img",{id:e,src:s||t,width:n,height:r,alt:"",className:a?"round":""})}(h,m,u,g),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},t?(0,d.Lo)(t)?o.ZP.createElement(es,{message:t,isEmbedded:!0}):(0,pt.Z)((0,d.MK)(f,t,Boolean(m))):n||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,pt.Z)(p||a||" "))))};var ss=s(2535),as=s(4752),ns=s(8018);const os=(0,o.X$)((({message:e,outgoingStatus:t,signature:s,onClick:a})=>{const n=(0,ye.Z)();return o.ZP.createElement("span",{className:"MessageMeta",dir:n.isRtl?"rtl":"ltr",onClick:a},Boolean(e.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,lt.bi)(e.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,pt.Z)(s)),o.ZP.createElement("span",{className:"message-time"},e.isEdited&&`${n("EditedMessage")} `,(0,L.mr)(1e3*e.date)),t&&o.ZP.createElement(ns.Z,{status:t}))}));var rs=s(8835),is=s(7799),cs=s(4851);const ds=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:a,lastSyncTime:r})=>{const i=(0,o.sO)(null),[c,l,u]=(0,ve.Z)(),h=e.content.sticker,{isAnimated:m,stickerSetId:g}=h,f=g===n.n,p=(0,Ot.Op)(i,t),I=(0,Ot.Op)(i,s),v=h.isPreloadedGlobally?`sticker${h.id}`:(0,d.Ti)(e,"inline"),y=yt(e),Z=(0,It.Z)(v,!p,(0,d.kG)(e,"inline",!0),r),P=Boolean(Z),[C,w]=(0,ve.Z)(P),b=m?C:P,{shouldRenderFullMedia:M,transitionClassNames:S}=(0,rs.Z)(b,"slow"),{width:E,height:k}=(0,ft.Wr)(h),R=(0,ie.Z)("thumbnail",!y&&"empty"),T=(0,ie.Z)("Sticker media-inner",f&&"inactive");return o.ZP.createElement("div",{ref:i,className:T,onClick:f?void 0:l},!b&&o.ZP.createElement("img",{id:`sticker-thumb-${e.id}`,src:y,width:E,height:k,alt:"",className:R}),!m&&M&&o.ZP.createElement("img",{id:`sticker-${e.id}`,src:Z,width:E,height:k,alt:"",className:(0,ie.Z)("full-media",S)}),m&&P&&o.ZP.createElement(is.Z,{key:v,className:(0,ie.Z)("full-media",S),id:v,animationData:Z,size:E,play:I,noLoop:!a,onLoad:w}),o.ZP.createElement(cs.Z,{isOpen:c,fromSticker:h,onClose:u}))};var ls=s(7854),us=s(2761),hs=s(5866);function ms(e,t){return(0,hs.Z)((0,d.DH)(e),Boolean(t),m.wB&&!m.vX)}var gs=s(7204);const fs=Promise.resolve("rgba(255,255,255,1)");var ps=s(9196);const Is=({id:e,message:t,observeIntersection:s,noAvatars:a,shouldAutoLoad:n,isInSelectMode:r,isSelected:i,uploadProgress:c,size:l="inline",dimensions:u,nonInteractive:h,shouldAffectAppendix:m,onClick:g,onCancelUpload:f})=>{const p=(0,o.sO)(null),I=((0,d.O$)(t)||(0,d.F$)(t)).blobUrl,v=(0,Ot.Op)(p,s),[y,Z]=(0,o.eJ)(n),P=y&&v,{mediaData:C,downloadProgress:w}=(0,us.Z)((0,d.Ti)(t,l),!P),b=I||C,M=ms(t,b),{isUploading:S,isTransferring:E,transferProgress:k}=(0,d.Sc)(t,c||w,P&&!b),R=!1===(0,gs.Z)(y),{shouldRender:T,transitionClassNames:N}=(0,de.Z)(E,void 0,R,"slow"),{shouldRenderThumb:B,shouldRenderFullMedia:A,transitionClassNames:x}=(0,rs.Z)(b,"slow"),L=(0,o.I4)((()=>{S?f&&f(t):b?g&&g(t.id):Z((e=>!e))}),[b,S,t,f,g]),O=(0,d.B4)(t);(0,o.bt)((()=>{if(!m)return;const e=p.current.closest(".message-content");b?function(e,t,s,a){return a?fs:async function(e,t){const s=new Image;s.src=e,s.width||await new Promise((e=>{s.onload=e}));const a=document.createElement("canvas"),n=a.getContext("2d");a.width=s.width,a.height=s.height,n.drawImage(s,0,0,s.width,s.height);const o=t?s.width-1:0,r=s.height-1;return`rgba(${Array.from(n.getImageData(o,r,1,1).data).join(",")})`}(e,t)}(b,O,0,i).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[b,O,m,r,i]);const{width:F,height:U,isSmall:$}=u||Gt(t,a),Q=(0,ie.Z)("media-inner",!S&&!h&&"interactive",$&&"small-image",F===U&&"square-image"),D=u?`width: ${F}px; height: ${U}px; left: ${u.x}px; top: ${u.y}px;`:"";return o.ZP.createElement("div",{id:e,ref:p,className:Q,style:D,onClick:S?void 0:L},B&&o.ZP.createElement("canvas",{ref:M,className:"thumbnail",style:`width: ${F}px; height: ${U}px`}),A&&o.ZP.createElement("img",{src:b,className:`full-media ${x}`,width:F,height:U,alt:""}),T&&o.ZP.createElement("div",{className:`media-loading ${N}`},o.ZP.createElement(ps.Z,{progress:k,onClick:S?L:void 0})),!b&&!y&&o.ZP.createElement("i",{className:"icon-download"}),E&&o.ZP.createElement("span",{className:"message-upload-progress"},Math.round(100*k),"%"))};var vs=s(2019),ys=s(4753);function Zs(e,t){const s=(0,o.sO)();s.current=t;const a=(0,o.I4)((()=>{e.current&&e.current.pause()}),[e]),n=(0,o.I4)((()=>{e.current&&s.current&&(0,ys.Z)(e.current)}),[e]);(0,re.ZP)(a,n)}var Ps=s(6898);const Cs=(e,t=!1)=>{const s=(0,o.sO)(!1),a=(0,o.sO)(!1),n=(0,o.I4)((()=>{a.current=!0,t&&e.current&&(s.current||(s.current=!e.current.paused),e.current.pause())}),[t,e]),r=(0,o.I4)((()=>{t&&e.current&&s.current&&document.body.contains(e.current)&&(0,ys.Z)(e.current),s.current=!1,a.current=!1}),[t,e]),i=(0,o.I4)((()=>{(0,Z.T2)(r)}),[r]);document.hasFocus()||n(),(0,le.Z)(n,i)};function ws(){return(ws=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}const bs=({id:e,message:t,observeIntersection:s,noAvatars:a,shouldAutoLoad:n,shouldAutoPlay:r,uploadProgress:i,lastSyncTime:c,dimensions:l,onClick:u,onCancelUpload:h})=>{const m=(0,o.sO)(null),g=(0,o.sO)(null),f=(0,d.b7)(t)||(0,d.Cg)(t),p=f.blobUrl,I=(0,Ot.Op)(m,s),[v,y]=(0,o.eJ)(n),Z=Boolean(v&&I&&c),[P,C]=(0,o.eJ)(r),w=(0,It.Z)((0,d.Ti)(t,"pictogram"),!(I&&c),(0,d.kG)(t,"pictogram"),c),{mediaData:b,downloadProgress:M}=(0,us.Z)((0,d.Ti)(t,"inline"),!Z,(0,d.kG)(t,"inline"),c),S=p||b,E=Boolean(I&&S),k=ms(t,w),{isBuffered:R,bufferingHandlers:T}=(0,vs.Z)(!n),{isUploading:N,isTransferring:B,transferProgress:A}=(0,d.Sc)(t,i||M,Z&&!R),x=!1===(0,gs.Z)(v),{shouldRender:O,transitionClassNames:F}=(0,de.Z)(B,void 0,x),{transitionClassNames:U}=(0,rs.Z)(S,"slow"),[$,Q]=(0,o.eJ)(0),D=(0,o.I4)((e=>{Q(Math.max(0,e.currentTarget.currentTime-1))}),[]),q=g.current&&g.current.duration||f.duration||0,G=(0,d.B4)(t),H=(0,d.MF)(t),{width:j,height:_}=l||(0,ft.GC)(f,G,H,a);Zs(g,Boolean(E&&r)),Cs(g,P),(0,Ps.Z)(g,[E]);const V=(0,o.I4)((()=>{N?h&&h(t):S?S&&!P?(C(!0),g.current.play()):u&&u(t.id):y((e=>!e))}),[N,S,P,u,h,t]),W=(0,ie.Z)("media-inner dark",!N&&"interactive"),K=(0,ie.Z)("full-media",U),X=l?`width: ${j}px; height: ${_}px; left: ${l.x}px; top: ${l.y}px;`:"";return o.ZP.createElement("div",{ref:m,id:e,className:W,style:X,onClick:N?void 0:V},!w&&o.ZP.createElement("canvas",{ref:k,className:"thumbnail",style:`width: ${j}px; height: ${_}px;`}),w&&o.ZP.createElement("img",{src:w,className:"thumbnail",style:`width: ${j}px; height: ${_}px;`,alt:""}),E&&o.ZP.createElement("video",ws({ref:g,className:K,width:j,height:_,autoPlay:P,muted:!0,loop:!0,playsInline:!0},T,{onTimeUpdate:D}),o.ZP.createElement("source",{src:S})),v&&!P&&!O&&o.ZP.createElement("i",{className:"icon-large-play"}),O&&o.ZP.createElement("div",{className:`media-loading ${F}`},o.ZP.createElement(ps.Z,{progress:A,onClick:N?V:void 0})),!v&&o.ZP.createElement("i",{className:"icon-download"}),B?o.ZP.createElement("span",{className:"message-upload-progress"},"..."):o.ZP.createElement("div",{className:"message-media-duration"},f.isGif?"GIF":(0,L.k9)(Math.max(q-$,0))))};var Ms=s(2969);const Ss=(0,a.c$)(((e,{contact:t})=>({user:(0,i.dy)(e,t.userId)})),((e,t)=>(0,g.ei)(t,["openUserInfo"])))((({contact:e,user:t,openUserInfo:s})=>{const{firstName:a,lastName:n,phoneNumber:r,userId:i}=e,c=(0,o.I4)((()=>{s({id:i})}),[s,i]);return o.ZP.createElement("div",{className:(0,ie.Z)("Contact",Boolean(i)&&"interactive"),onClick:i?c:void 0},o.ZP.createElement(Yt.Z,{size:"large",user:t,text:a||n}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},a," ",n),o.ZP.createElement("div",{className:"contact-phone"},(0,Ms.WZ)(r))))}));var Es=s(4605);const ks=(0,o.X$)((({id:e,options:t,selected:s=[],disabled:a,round:n,loadingOptions:r,onChange:i})=>{const[c,d]=(0,o.eJ)([]),l=(0,o.I4)((e=>{const{value:t,checked:s}=e.currentTarget;let a;a=s?[...c,t]:c.filter((e=>e!==t)),d(a),i(a)}),[i,c]);return o.ZP.createElement("div",{id:e,className:"radio-group"},t.map((e=>o.ZP.createElement(Es.Z,{label:e.label,subLabel:e.subLabel,value:e.value,checked:-1!==s.indexOf(e.value),disabled:a,round:n,isLoading:r?-1!==r.indexOf(e.value):void 0,onChange:l}))))}));var Rs=s(4434),Ts=s(6937);function Ns(e,t){return t>0?(e/t*100).toFixed():0}const Bs=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:a,correctResults:n,shouldAnimate:r})=>{const i=t&&t.find((t=>t.option===e.option)),c=0===n.length||-1!==n.indexOf(e.option),d=n.length>0&&c||i&&i.isChosen,l=i?Ns(i.votersCount,s||0):0,[u,h]=(0,o.eJ)(r?0:l),m=(0,o.sO)(null),g=i?Ns(i.votersCount,a||0):0,f=u<l;if((0,o.d4)((()=>{r&&h(l)}),[r,l]),(0,o.d4)((()=>{const e=m.current;if(e&&r){const t=e.firstElementChild,s=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",s):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${s}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[f,r]),!t||!i)return;const p=`width: ${g}%; transform:scaleX(${f?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===l?"limit-width":"")},l,"%",d&&o.ZP.createElement("span",{className:(0,ie.Z)("poll-option-chosen",!c&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:c?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,pt.Z)(e.text)),o.ZP.createElement("div",{className:(0,ie.Z)("poll-option-answer",d&&!c&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:m}),o.ZP.createElement("div",{className:"poll-option-line",style:p}))))},As=(0,o.X$)((0,a.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{serverTimeOffset:a,users:{byId:n}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:n,serverTimeOffset:a}:{}}),((e,t)=>(0,g.ei)(t,["loadMessage","openPollResults"])))((({message:e,poll:t,recentVoterIds:s,usersById:a,loadMessage:n,onSendVote:r,openPollResults:i,serverTimeOffset:c})=>{const{id:d,chatId:l}=e,{summary:u,results:h}=t,[m,g]=(0,o.eJ)(!1),[f,p]=(0,o.eJ)([]),[I,v]=(0,o.eJ)(!1),[y,Z]=(0,o.eJ)(!1),[P,C]=(0,o.eJ)(!u.closed&&u.closeDate&&u.closeDate>0?Math.min(u.closeDate-Math.floor(Date.now()/1e3)+c,u.closePeriod):0),w=(0,o.sO)(null),{results:b,totalVoters:M}=h,S=b&&b.some((e=>e.isChosen)),E=!u.closed&&!S,k=!E&&u.isPublic&&Number(h.totalVoters)>0,R=E&&u.multipleChoice,T=b?Math.max(...b.map((e=>e.votersCount))):M,N=b?b.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],B=u.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(u.quiz&&u.closePeriod&&P<=0)})));(0,o.d4)((()=>{m&&t.results.results&&t.results.results.some((e=>e.isChosen))&&g(!1)}),[m,t.results.results]),(0,o.d4)((()=>{P>0&&setTimeout((()=>C(P-1)),1e3);const e=w.current;if(e){const t=12*Math.PI,s=e.lastElementChild,a=e.firstElementChild;if(P<=5&&e.classList.add("hurry-up"),s&&a){const e=(u.closePeriod-P)/u.closePeriod*t;a.textContent=(0,L.k9)(P),s.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,L.k9)(P)}</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>`}}),[P,u.closePeriod]),(0,o.d4)((()=>{u.quiz&&(P<=0||S&&!u.closed)&&n({chatId:l,messageId:d})}),[l,P,S,n,d,u.closed,u.quiz]),(0,o.d4)((()=>{let e;return u.quiz&&!u.closed&&u.closePeriod&&u.closePeriod>0&&(e=window.setTimeout((()=>{n({chatId:l,messageId:d})}),1e3*u.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[E,l,n,d,u.closePeriod,u.closed,u.quiz]);const A=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const s=a[t];return s&&e.push(s),e}),[]):[]),[a,s]),x=(0,o.I4)((e=>{p([e]),g(!0),Z(!0),r([e])}),[r]),O=(0,o.I4)((e=>{p(e)}),[]),F=(0,o.I4)((()=>{g(!0),Z(!0),r(f)}),[r,f]),U=(0,o.I4)((()=>{i({chatId:l,messageId:d})}),[l,d,i]),$=(0,o.I4)((()=>{v(!0)}),[]),Q=(0,o.I4)((()=>{v(!1),Z(!1)}),[]);(0,o.d4)((()=>{y&&S&&u.quiz&&h.results&&t.results.solution&&(h.results.find((e=>e.isChosen&&e.isCorrect))||v(!0))}),[S,y,h.results,u.quiz,t.results.solution]);const D=(0,ye.Z)();return o.ZP.createElement("div",{className:"Poll",dir:D.isRtl?"auto":"ltr"},I&&t.results.solution&&o.ZP.createElement(Ts.Z,{message:(0,Qt.H)(t.results.solution,t.results.solutionEntities),duration:5e3,onDismiss:Q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,pt.Z)(u.question)),o.ZP.createElement("div",{className:"poll-type"},D(function(e){return void 0===e.isPublic?" ":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.closed?"FinalResults":e.isPublic?"PublicPoll":"AnonymousPoll"}(u)),A.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},A.map((e=>o.ZP.createElement(Yt.Z,{size:"micro",user:e})))),P>0&&E&&o.ZP.createElement("div",{ref:w,className:"poll-countdown"}),u.quiz&&t.results.solution&&!E&&o.ZP.createElement(we.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:I,onClick:$,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),E&&o.ZP.createElement("div",{className:"poll-answers"},R?o.ZP.createElement(ks,{options:B,onChange:O,disabled:e.isScheduled||m,loadingOptions:m?f:void 0,round:!0}):o.ZP.createElement(Rs.Z,{name:`poll-${d}`,options:B,onChange:x,disabled:e.isScheduled||m,loadingOption:m?f[0]:void 0})),!E&&o.ZP.createElement("div",{className:"poll-results"},u.answers.map((function(e){return o.ZP.createElement(Bs,{key:e.option,shouldAnimate:y,answer:e,voteResults:b,totalVoters:M,maxVotersCount:T,correctResults:N})}))),!k&&!R&&o.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,s){return s?e(t?"Answer":"Vote",s,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(D,u.quiz,h.totalVoters)),R&&o.ZP.createElement(we.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:F},D("PollSubmitVotes")),k&&o.ZP.createElement(we.Z,{isText:!0,size:"tiny",onClick:U},D("PollViewResults")))})));var xs=s(8035),Ls=s(88);const Os=(0,o.X$)((({message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:a,shouldAutoPlay:n,inPreview:r,lastSyncTime:i,onMediaClick:c,onCancelMediaTransfer:l})=>{const u=(0,d.s1)(e);let h=!1;if(u&&u.photo&&!u.video){const{width:t,height:s}=Gt(e);h=t===s}const m=(0,o.I4)((()=>{c()}),[c]);if(!u)return;const{siteName:g,url:f,displayUrl:p,title:I,description:v,photo:y,video:Z}=u,P=(y||Z)&&c&&!h,C=(0,xs.Z)(v,170),w=(0,ie.Z)("WebPage",h&&"with-square-photo",!y&&!Z&&!r&&"without-media",Z&&"with-video");return o.ZP.createElement("div",{className:w,"data-initial":(g||p)[0],dir:"auto"},y&&!Z&&o.ZP.createElement(Is,{message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:a,size:h?"pictogram":"inline",nonInteractive:!P,onClick:P?m:void 0,onCancelUpload:l}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Ls.Z,{className:"site-name",url:f,text:g||p}),!r&&I&&o.ZP.createElement("p",{className:"site-title"},(0,pt.Z)(I)),C&&o.ZP.createElement("p",{className:"site-description"},(0,pt.Z)(C,["emoji","br"]))),!r&&Z&&o.ZP.createElement(bs,{message:e,observeIntersection:t,noAvatars:s,shouldAutoLoad:a,shouldAutoPlay:n,lastSyncTime:i,onClick:P?m:void 0,onCancelUpload:l}))}));var Fs=s(9937);const Us=(0,o.X$)((({message:e})=>{const t=(0,ye.Z)(),s=(0,d.eO)(e),{title:a,text:n,amount:r,currency:i,isTest:c,photoUrl:l}=s;return o.ZP.createElement("div",{className:"Invoice"},a&&o.ZP.createElement("p",{className:"title"},(0,pt.Z)(a)),n&&o.ZP.createElement("p",null,(0,pt.Z)(n,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(l?"has-image":"")},l&&o.ZP.createElement("img",{className:"invoice-image",src:l,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,Fs.x)(r,i,t.code),c&&o.ZP.createElement("span",null,t("PaymentTestInvoice")))))}));function $s(e){return(0,o.X$)((0,a.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,i.CA)(e),isSelected:(0,i.vk)(e,s.id)}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection"])))((t=>{const{isInSelectMode:s,isSelected:a,message:n,toggleMessageSelection:r,dimensions:i}=t,c=(0,o.I4)((e=>{e.stopPropagation(),r({messageId:n.id,withShift:e&&e.shiftKey})}),[r,n]),d=(0,o.Ye)((()=>({...t,isInSelectMode:s,isSelected:a,dimensions:{...t.dimensions,x:0,y:0},onClick:s?void 0:t.onClick})),[t,s,a]);return o.ZP.createElement("div",{className:(0,ie.Z)("album-item-select-wrapper",a&&"is-selected"),style:i?`left: ${i.x}px; top: ${i.y}px;`:"",onClick:s?c:void 0},s&&o.ZP.createElement("div",{className:"message-select-control"},a&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const Qs=$s(Is),Ds=$s(bs),qs=(0,a.c$)((e=>({uploadsById:e.fileUploads.byMessageLocalId})),((e,t)=>(0,g.ei)(t,["cancelSendingMessage"])))((({album:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:a,hasCustomAppendix:n,lastSyncTime:r,isOwn:i,albumLayout:c,onMediaClick:l,uploadsById:u,cancelSendingMessage:h})=>{const m=e.messages.length,g=(0,o.I4)((e=>{h({chatId:e.chatId,messageId:e.id})}),[h]),{width:f,height:p}=c.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${f}px; height: ${p}px;`},e.messages.map((function(e,h){const{photo:f,video:p}=(0,d.qp)(e),I=u[e.previousLocalId||e.id],v=I?I.progress:void 0,{dimensions:y,sides:Z}=c.layout[h];if(f){const a=n&&(i?h===m-1:Boolean(8&Z&&4&Z));return o.ZP.createElement(Qs,{id:`album-media-${e.id}`,message:e,observeIntersection:t,shouldAutoLoad:s,shouldAffectAppendix:a,uploadProgress:v,dimensions:y,onClick:l,onCancelUpload:g})}if(p)return o.ZP.createElement(Ds,{id:`album-media-${e.id}`,message:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:a,uploadProgress:v,lastSyncTime:r,dimensions:y,onClick:l,onCancelUpload:g})})))}));function Gs(){return(Gs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}let Hs;const js=({message:e,observeIntersection:t,shouldAutoLoad:s,shouldAutoPlay:a,lastSyncTime:n})=>{const r=(0,o.sO)(null),i=(0,o.sO)(null),c=(0,o.sO)(null),l=e.content.video,u=(0,Ot.Op)(r,t),[h,m]=(0,o.eJ)(s&&a),g=Boolean(h&&u&&n),{mediaData:f,downloadProgress:p}=(0,us.Z)((0,d.Ti)(e,"inline"),!g,(0,d.kG)(e,"inline"),n),I=ms(e,f),{isBuffered:v,bufferingHandlers:y}=(0,vs.Z)(),P=h&&!v,C=!1===(0,gs.Z)(h),{shouldRender:w,transitionClassNames:b}=(0,de.Z)(P||!v,void 0,C),{shouldRenderThumb:M,transitionClassNames:S}=(0,rs.Z)(f,"slow"),[E,k]=(0,o.eJ)(!1),[R,T]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!E)return;const e=188*Math.PI,t=e-R*e,s=c.current,a=i.current,n=a.firstElementChild;n?n.firstElementChild.setAttribute("stroke-dashoffset",t.toString()):a.innerHTML=`<svg width="200px" height="200px">\n <circle cx="100" cy="100" r="94" class="progress-circle" transform="rotate(-90, 100, 100)"\n stroke-dasharray="${e} ${e}"\n stroke-dashoffset="${e}"\n />\n </svg>`,T(s.currentTime/s.duration)}),[E,R]);const N=Boolean(f&&u),B=()=>{k(!1),T(0),(0,ys.Z)(c.current),(0,Z.T2)((()=>{i.current.innerHTML=""}))},A=(x=B,()=>{Hs&&Hs(),Hs=x});var x;(0,o.d4)((()=>{c.current&&(N?(0,ys.Z)(c.current):c.current.pause())}),[N]),Zs(c,N),Cs(c,Boolean(f)),(0,Ps.Z)(c,[f]);const O=(0,o.I4)((()=>{if(!f)return void m((e=>!e));const e=c.current;E?e.paused?(0,ys.Z)(e):e.pause():(A(),e.pause(),e.currentTime=0,(0,ys.Z)(e),k(!0))}),[A,E,f]),F=(0,o.I4)((e=>{const t=e.currentTarget;T(t.currentTime/t.duration)}),[]),U=(0,ie.Z)("full-media",S);return o.ZP.createElement("div",{ref:r,className:"RoundVideo media-inner",onClick:O},(M||f)&&o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:I,className:"thumbnail",style:`width: ${ft.vw}px; height: ${ft.vw}px`})),f&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",Gs({ref:c,className:U,width:ft.vw,height:ft.vw,autoPlay:!0,muted:!E,loop:!E,playsInline:!0,onEnded:E?B:void 0},y,{onTimeUpdate:E?F:void 0}),o.ZP.createElement("source",{src:f}))),o.ZP.createElement("div",{className:"progress",ref:i}),w&&o.ZP.createElement("div",{className:`media-loading ${b}`},o.ZP.createElement(ps.Z,{progress:p})),!f&&!h&&o.ZP.createElement("i",{className:"icon-large-play"}),o.ZP.createElement("div",{className:"message-media-duration"},E?(0,L.k9)(c.current.currentTime):(0,L.k9)(l.duration),(!E||c.current.paused)&&o.ZP.createElement("i",{className:"icon-muted-chat"})))},_s=({message:e,onClick:t})=>{const s=(0,ye.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},e.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(we.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>t({button:e})},(0,pt.Z)(s(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(n.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},Vs=(0,o.X$)((0,a.c$)(((e,{message:t})=>{const{threadId:s,chatId:a}=t.threadInfo,n=(0,i.tZ)(e,a,s)||t.threadInfo,{byId:o}=e.users,{byId:r}=e.chats;return{threadInfo:n,usersById:o,chatsById:r}}),((e,t)=>(0,g.ei)(t,["openChat"])))((({disabled:e,threadInfo:t,usersById:s,chatsById:a,openChat:n})=>{const r=(0,ye.Z)(),{threadId:i,chatId:c,messagesCount:l,lastMessageId:u,lastReadInboxMessageId:h,recentReplierIds:m}=t,g=(0,o.I4)((()=>{n({id:c,threadId:i})}),[n,c,i]);if(void 0===l)return;const f=m&&m.map((e=>(0,d.YA)(e)?s[e]:a[e])).filter(Boolean),p=Boolean(h&&u&&h<u);return o.ZP.createElement("div",{"data-cnt":(0,lt.bi)(l),className:(0,ie.Z)("CommentButton",p&&"has-unread",e&&"disabled"),dir:r.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:r.isRtl?"rtl":"ltr"},f.map((e=>o.ZP.createElement(Yt.Z,{key:e.id,size:"small",user:(0,d.YA)(e.id)?e:void 0,chat:(0,d.YA)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},l?r("Comments",l,"i"):r("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))}))),Ws="data-is-document-group-hover";function Ks(e){const t=Ys(e.currentTarget);t&&t.setAttribute(Ws,"")}function Xs(e){const t=Ys(e.currentTarget);t&&t.removeAttribute(Ws)}function Ys(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}const zs=(0,o.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:a,lastSyncTime:n}=e,{message:o,album:r,withSenderName:c,withAvatar:l,threadId:u,messageListType:h}=t,{id:m,chatId:g,viaBotId:f,replyToMessageId:p,isOutgoing:I}=o,v=(0,i.Z1)(e,g),y=(0,i.FM)(e,g),Z=v&&(0,d.eA)(v),P=v&&v.username,C=!y&&(0,d.Ul)(o),w=c||l||C?(0,i.Ur)(e,o):void 0,b=(0,i.cv)(e,o),M=f?(0,i.dy)(e,f):void 0,S=u?(0,i.qS)(e,g,u):void 0,E=o.id===S,k=p===S,R=p&&!k?(0,i.hj)(e,g,p):void 0,T=R&&(0,i.Ur)(e,R),N=(0,i.uZ)(e,o),B="thread"===h&&(r?r.messages.some((t=>(0,i._X)(e,t))):(0,i._X)(e,o)),{direction:A,noHighlight:x,isResizingContainer:L}=B&&s||{},O=a.messageIds&&a.messageIds.includes(m),{query:F}=(0,i.n5)(e)||{},U=(0,d._O)(o);let $;return $=r&&r.messages?r.messages.every((({id:t})=>(0,i.vk)(e,t))):(0,i.vk)(e,m),{theme:(0,i.Pu)(e),chatUsername:P,forceSenderName:C,sender:w,originSender:b,botSender:M,shouldHideReply:k,isThreadTop:E,replyMessage:R,replyMessageSender:T,isFocused:B,isForwarding:O,isChatWithSelf:y,isChannel:Z,lastSyncTime:n,highlight:F,isSingleEmoji:Boolean(U),animatedEmoji:U?(0,i.zB)(e,U):void 0,isInSelectMode:(0,i.CA)(e),isSelected:$,isGroupSelected:!!o.groupedId&&!o.isInAlbum&&(0,i.a6)(e,g,o.groupedId),threadId:u,isPinnedList:"pinned"===h,shouldAutoLoadMedia:v?(0,i.TD)(e,o,v,w):void 0,shouldAutoPlayMedia:(0,i.pv)(e,o),shouldLoopStickers:(0,i.yB)(e),...I&&{outgoingStatus:(0,i.dT)(e,o,"scheduled"===h)},..."number"==typeof N&&{uploadProgress:N},...B&&{focusDirection:A,noFocusHighlight:x,isResizingContainer:L}}}),((e,t)=>(0,g.ei)(t,["toggleMessageSelection","clickInlineButton","disableContextMenuHint"])))((({message:e,chatUsername:t,observeIntersectionForBottom:s,observeIntersectionForMedia:n,observeIntersectionForAnimatedStickers:r,album:i,noAvatars:c,withAvatar:l,withSenderName:g,noComments:f,appearanceOrder:p,isFirstInGroup:I,isLastInGroup:v,isFirstInDocumentGroup:y,isLastInDocumentGroup:Z,isLastInList:P,theme:C,forceSenderName:w,sender:b,originSender:M,botSender:S,isThreadTop:E,shouldHideReply:k,replyMessage:R,replyMessageSender:T,outgoingStatus:N,uploadProgress:B,isFocused:A,focusDirection:x,noFocusHighlight:L,isResizingContainer:O,isForwarding:F,isChatWithSelf:U,isChannel:$,lastSyncTime:Q,highlight:D,animatedEmoji:q,isInSelectMode:G,isSelected:H,isGroupSelected:j,threadId:_,messageListType:V,isPinnedList:W,shouldAutoLoadMedia:K,shouldAutoPlayMedia:X,shouldLoopStickers:Y,toggleMessageSelection:z,clickInlineButton:J,disableContextMenuHint:ee})=>{const te=(0,o.sO)(null),se=(0,o.sO)(null),ae=(0,o.sO)(null),ne=(0,ye.Z)();(0,Ot._N)(se,s);const{isContextMenuOpen:oe,contextMenuPosition:re,handleBeforeContextMenu:ce,handleContextMenu:le,handleContextMenuClose:ue,handleContextMenuHide:he}=(0,$t.Z)(te,m.$b&&G,!0,m.wZ);(0,o.d4)((()=>{oe&&ee()}),[oe,ee]);const me=p<=0,[ge,fe]=(0,ve.Z)(me);(0,o.d4)((()=>{me||setTimeout(fe,10*p)}),[p,fe,me]);const{transitionClassNames:pe}=(0,de.Z)(ge,void 0,me,!1),{id:Ie,chatId:Ze,threadInfo:Pe}=e,Ce=(0,d.CI)(e),be=(0,d.B4)(e),Me="scheduled"===V||e.isScheduled,Se=(0,d.ss)(e)&&!k,Ee=Boolean(Pe)&&"thread"===V,{forwardInfo:ke,viaBotId:Re}=e,Te=ke&&!U&&!ke.isLinkedChannelPost,Be=Boolean(e.groupedId)&&!e.isInAlbum,Ae=Boolean(i)&&i.messages.length>1,{text:xe,photo:Le,video:Oe,audio:Fe,voice:Ue,document:$e,sticker:Qe,contact:De,poll:qe,webPage:Ge,invoice:He}=(0,d.qp)(e),je=(0,d.$D)(e),_e=(0,Qt.X)(e,D,Dt(je)),Ve=void 0!==re,We=$&&e.adminTitle||ke&&!Te&&ke.adminTitle||void 0,Ke=(0,o.Ye)((()=>We?Kt(We):void 0),[We]),Xe=!(Ve||G||F)&&(!Be||Z),Ye=$&&!Me,ze=Boolean(W||ke&&(ke.isChannelPost||U&&!be)&&ke.fromMessageId),Je=!ke||!U&&b?b:M,et=ke?M:b,tt=(0,o.I4)(((e,t)=>{Ce||z({messageId:Ie,groupedId:t,...e&&e.shiftKey&&{withShift:!0},...Ae&&{childMessageIds:i.messages.map((({id:e})=>e))}})}),[Ce,z,Ie,Ae,i]),{handleMouseDown:at,handleClick:nt,handleContextMenu:ot,handleDoubleClick:rt,handleContentDoubleClick:it,isSwiped:dt}=function(e,t,s,n,r,i,c,d){const{setReplyingToId:l}=(0,a.uC)(),[u,h,g]=(0,ve.Z)();return(0,o.d4)((()=>{if(!m.$b||i)return;let e;return(0,Ne.s)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,s)=>s===Ne.e.Left&&(e||(e=Date.now()),h(),!0),onRelease:()=>{e&&(l({messageId:s}),setTimeout(g,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,i,s,l,h,g]),{handleMouseDown:i?void 0:function(e){At(e),n||d(e)},handleClick:function(t){if(i&&!n)e(t);else if(m.wZ){const e=t.target;if(!e.classList.contains("text-content")&&!e.classList.contains("Message"))return;st.Z.getIsKeyboardVisible()?setTimeout((()=>{c(t)}),350):c(t)}},handleContextMenu:i||n?void 0:function(t){m.wZ?e():c(t)},handleDoubleClick:i?void 0:function(){l({messageId:s})},handleContentDoubleClick:m.$b?void 0:function(e){e.stopPropagation()},isSwiped:u}}(tt,te,Ie,Ce,0,Boolean(G),le,ce),{handleAvatarClick:lt,handleSenderClick:ut,handleViaBotClick:ht,handleReplyClick:mt,handleMediaClick:gt,handleAudioPlay:It,handleAlbumMediaClick:vt,handleMetaClick:yt,handleReadMedia:Zt,handleCancelUpload:Pt,handleVoteSend:Ct,handleGroupForward:wt,handleForward:bt,handleFocus:Mt,handleFocusForwarded:St,handleDocumentGroupSelectAll:Et}=function(e,t,s,n,r,i,c,l,m,g,f){const{openUserInfo:p,openChat:I,showNotification:v,focusMessage:y,openMediaViewer:Z,openAudioPlayer:P,markMessagesRead:C,cancelSendingMessage:w,sendPollVote:b,openForwardMenu:M}=(0,a.uC)(),{id:S,forwardInfo:E,replyToMessageId:k,groupedId:R}=s,T=(0,o.I4)((()=>{m&&((0,d.YA)(m.id)?p({id:m.id}):I({id:m.id}))}),[m,p,I]),N=(0,o.I4)((()=>{g?(0,d.YA)(g.id)?p({id:g.id}):I({id:g.id}):v({message:e("HidAccount")})}),[g,v,e,p,I]),B=(0,o.I4)((()=>{f&&p({id:f.id})}),[f,p]),A=(0,o.I4)((()=>{y({chatId:n,threadId:r,messageId:k,replyMessageId:S})}),[y,n,r,k,S]),x=(0,o.I4)((()=>{Z({chatId:n,threadId:r,messageId:S,origin:c?h.bZ.ScheduledInline:h.bZ.Inline})}),[n,r,S,Z,c]),L=(0,o.I4)((()=>{P({chatId:n,messageId:S})}),[n,S,P]),O=(0,o.I4)((e=>{Z({chatId:n,threadId:r,messageId:e,origin:c?h.bZ.ScheduledAlbum:h.bZ.Album})}),[n,r,Z,c]),F=(0,o.I4)((()=>{C({messageIds:[S]})}),[S,C]),U=(0,o.I4)((()=>{w({chatId:n,messageId:S})}),[w,n,S]),$=(0,o.I4)((e=>{b({chatId:n,messageId:S,options:e})}),[n,S,b]),Q=(0,o.I4)((()=>{M({fromChatId:n,groupedId:R})}),[M,n,R]),D=(0,o.I4)((()=>{if(l&&l.messages){const e=l.messages.map((({id:e})=>e));M({fromChatId:n,messageIds:e})}else M({fromChatId:n,messageIds:[S]})}),[l,M,n,S]),q=(0,o.I4)((()=>{y({chatId:n,threadId:u._f,messageId:S})}),[y,n,S]),G=(0,o.I4)((()=>{y(i?{chatId:E.fromChatId,groupedId:R,groupedChatId:n}:{chatId:E.fromChatId,messageId:E.fromMessageId})}),[i,y,E,R,n]),H=(0,o.I4)((e=>{e.stopPropagation(),t(e,R)}),[t,R]);return{handleAvatarClick:T,handleSenderClick:N,handleViaBotClick:B,handleReplyClick:A,handleMediaClick:x,handleAudioPlay:L,handleAlbumMediaClick:O,handleMetaClick:H,handleReadMedia:F,handleCancelUpload:U,handleVoteSend:$,handleGroupForward:Q,handleForward:D,handleFocus:q,handleFocusForwarded:G,handleDocumentGroupSelectAll:H}}(ne,tt,e,Ze,_,Be,Boolean(Me),i,Je,et,S),kt=(0,ie.Z)("Message message-list-item",I&&"first-in-group",v&&"last-in-group",y&&"first-in-document-group",Z&&"last-in-document-group",P&&"last-in-list",be&&"own",Boolean(e.views)&&"has-views",e.isEdited&&"was-edited",Se&&"has-reply",Ve&&"has-menu-open",A&&!L&&"focused",F&&"is-forwarding",e.isDeleting&&"is-deleting",Be&&"is-in-document-group",Ae&&"is-album",e.hasUnreadMention&&"has-unread-mention",H&&"is-selected",G&&"is-in-selection-mode",E&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",dt&&"is-swiped",pe),Rt=function(e,{hasReply:t,customShape:s,isLastInGroup:a,asForwarded:n,hasThread:o,forceSenderName:r,hasComments:i,hasActionButton:c}={}){const{text:l,photo:u,video:h,audio:m,voice:g,document:f,poll:p,webPage:I,contact:v}=(0,d.qp)(e),y=["message-content"],Z=u||h,P=Z&&!l,C=Boolean(e.viaBotId);return Dt(s)?y.push(`emoji-only emoji-only-${s}`):l&&y.push("text"),c&&y.push("has-action-button"),s&&(y.push("custom-shape"),h&&h.isRound&&y.push("round"),i&&y.push("has-comments")),u||h?y.push("media"):m?y.push("audio"):g?y.push("voice"):f?y.push("document"):v?y.push("contact"):p?y.push("poll"):I&&(y.push("web-page"),(I.photo||I.video)&&y.push("media")),n&&!s&&y.push("is-forwarded"),t&&y.push("is-reply"),o&&y.push("has-replies"),C&&y.push("is-via-bot"),r&&y.push("force-sender-name"),s||(y.push("has-shadow"),Z&&i&&y.push("has-background"),(t||n||!P||C||r)&&y.push("has-solid-background"),!a||!u&&P||y.push("has-appendix")),y.join(" ")}(e,{hasReply:Se,customShape:je,isLastInGroup:v,asForwarded:Te,hasThread:Ee,forceSenderName:w,hasComments:e.threadInfo&&e.threadInfo.messagesCount>0,hasActionButton:Ye||ze}),Tt=e.threadInfo&&(!Be||Z)&&"thread"===V&&!f,Nt=Rt.includes("has-appendix");(0,ct.Z)(Ze,Se?e.replyToMessageId:void 0,R,e.id),Xt(te,Ze,A,x,L,O),(0,o.bt)((()=>{ae.current&&(ae.current.innerHTML=be?'<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>':'<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>')}),[be,Nt]);let Bt,xt="",Lt=!1;const Ft=(0,o.Ye)((()=>Ae?Vt(be,Boolean(Te),Boolean(c),i):void 0),[Ae,be,Te,c,i]),Ut=Te?28:0;if(Ae||!Le&&!Oe)Ft&&(Bt=Math.max(qt(Boolean(xe),Tt),Ft.containerStyle.width),Bt-Ft.containerStyle.width>18&&(Lt=!0));else{let t;Le?t=Gt(e,c).width:Oe&&(t=Oe.isRound?ft.vw:Gt(e,c).width),t&&(Bt=Math.max(qt(Boolean(xe),Tt),t),Bt-t>18&&(Lt=!0))}return Bt&&(xt=`width: ${Bt+Ut}px`),o.ZP.createElement("div",{ref:te,id:`message${Ie}`,className:kt,style:Ke?`--meta-safe-author-width: ${Ke}px`:void 0,"data-message-id":Ie,onMouseDown:at,onClick:nt,onContextMenu:ot,onDoubleClick:rt,onMouseEnter:Be&&!Z?Ks:void 0,onMouseLeave:Be&&!Z?Xs:void 0},o.ZP.createElement("div",{ref:se,className:"bottom-marker","data-message-id":Ie,"data-last-message-id":i?i.messages[i.messages.length-1].id:void 0,"data-has-unread-mention":e.hasUnreadMention}),!Ce&&!Be&&o.ZP.createElement("div",{className:"message-select-control"},H&&o.ZP.createElement("i",{className:"icon-select"})),!Ce&&Z&&o.ZP.createElement("div",{className:(0,ie.Z)("message-select-control group-select",j&&"is-selected"),onClick:Et},j&&o.ZP.createElement("i",{className:"icon-select"})),l&&function(){const e=Je&&(0,d.YA)(Je.id),t=Je&&e?Je:void 0,s=Je&&!e?Je:void 0,a=!Je&&ke?ke.hiddenUserName:void 0;return o.ZP.createElement(Yt.Z,{size:"small",user:t,chat:s,text:a,lastSyncTime:Q,onClick:t||s?lt:void 0})}(),o.ZP.createElement("div",{className:(0,ie.Z)("message-content-wrapper",Rt.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:Rt,style:xt,dir:"auto"},Te&&!je&&(!Be||y)&&o.ZP.createElement("div",{className:"message-title"},ne("ForwardedMessage")),function(){const t=(0,ie.Z)("content-inner",Te&&!je&&"forwarded-message",Se&&"reply-message",Lt&&"no-media-corners"),s=v&&!_e&&!Te&&!Ee,a=!Ge&&!q&&_e,l=(0,ie.Z)("text-content",a&&"with-meta",N&&"with-outgoing-icon");return o.ZP.createElement("div",{className:t,onDoubleClick:it,dir:"auto"},function(){if(je&&!Re||!(g&&!Le&&!Oe||Te||Re||w)||Be&&!y)return;let t,s;return!et||je&&Re?ke&&ke.hiddenUserName&&(t=ke.hiddenUserName):(t=(0,d.OU)(ne,et),Te||(s=`color-${(0,d.Rs)(et)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},t?o.ZP.createElement("span",{className:(0,ie.Z)("interactive",s),onClick:ut,dir:"auto"},(0,pt.Z)(t)):S?void 0:" ",S&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},ne("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:ht},(0,pt.Z)(`@${S.username}`))),ke&&ke.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},ne("DiscussChannel")):e.adminTitle&&!$?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.adminTitle):void 0)}(),Se&&o.ZP.createElement(ts,{message:R,sender:T,observeIntersection:n,onClick:mt}),Qe&&o.ZP.createElement(ds,{message:e,observeIntersection:n,observeIntersectionForPlaying:r,shouldLoop:Y,lastSyncTime:Q}),q&&o.ZP.createElement(ls.Z,{size:"small",sticker:q,observeIntersection:n,lastSyncTime:Q,forceLoadPreview:Ce}),Ae&&o.ZP.createElement(qs,{album:i,albumLayout:Ft,observeIntersection:n,shouldAutoLoad:K,shouldAutoPlay:X,isOwn:be,hasCustomAppendix:s,lastSyncTime:Q,onMediaClick:vt}),!Ae&&Le&&o.ZP.createElement(Is,{message:e,observeIntersection:n,noAvatars:c,shouldAutoLoad:K,uploadProgress:B,shouldAffectAppendix:s,onClick:gt,onCancelUpload:Pt}),!Ae&&Oe&&Oe.isRound&&o.ZP.createElement(js,{message:e,observeIntersection:n,shouldAutoLoad:K,shouldAutoPlay:X,lastSyncTime:Q}),!Ae&&Oe&&!Oe.isRound&&o.ZP.createElement(bs,{message:e,observeIntersection:n,noAvatars:c,shouldAutoLoad:K,shouldAutoPlay:X,uploadProgress:B,lastSyncTime:Q,onClick:gt,onCancelUpload:Pt}),(Fe||Ue)&&o.ZP.createElement(as.Z,{theme:C,message:e,uploadProgress:B,lastSyncTime:Q,isSelectable:Be,isSelected:H,onPlay:It,onReadMedia:!Ue||be&&!U?void 0:Zt,onCancelUpload:Pt}),$e&&o.ZP.createElement(ss.Z,{message:e,observeIntersection:n,uploadProgress:B,isSelectable:Be,isSelected:H,onMediaClick:gt,onCancelUpload:Pt}),De&&o.ZP.createElement(Ss,{contact:De}),qe&&o.ZP.createElement(As,{message:e,poll:qe,onSendVote:Ct}),!q&&_e&&o.ZP.createElement("p",{className:l,dir:"auto"},_e,a&&o.ZP.createElement(os,{message:e,outgoingStatus:N,signature:We,onClick:yt})),Ge&&o.ZP.createElement(Os,{message:e,observeIntersection:n,noAvatars:c,shouldAutoLoad:K,shouldAutoPlay:X,lastSyncTime:Q,onMediaClick:gt,onCancelMediaTransfer:Pt}),He&&o.ZP.createElement(Us,{message:e}))}(),(!Be||Z)&&!(!Ge&&!q&&_e)&&o.ZP.createElement(os,{message:e,outgoingStatus:N,signature:We,onClick:yt}),Xe&&Ye?o.ZP.createElement(we.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:ne("lng_context_forward_msg"),onClick:Z?wt:bt},o.ZP.createElement("i",{className:"icon-share-filled"})):Xe&&ze?o.ZP.createElement(we.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:W?Mt:St},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Tt&&o.ZP.createElement(Vs,{message:e,disabled:f}),Nt&&o.ZP.createElement("div",{className:"svg-appendix",ref:ae})),e.inlineButtons&&o.ZP.createElement(_s,{message:e,onClick:J})),re&&o.ZP.createElement(Jt,{isOpen:oe,anchor:re,message:e,album:i,chatUsername:t,messageListType:V,onClose:ue,onCloseAnimationEnd:he}))}))),Js=(0,o.X$)((({messageIds:e,messageGroups:t,isViewportNewest:s,isUnread:r,withUsers:i,noAvatars:c,containerRef:l,anchorIdRef:u,memoUnreadDividerBeforeIdRef:m,memoFirstUnreadIdRef:f,threadId:p,type:I,isActive:v,threadTopMessageId:y,hasLinkedChat:P,isSchedule:C,noAppearanceAnimation:w,onFabToggle:b,onNotchToggle:M,openHistoryCalendar:S})=>{const{observeIntersectionForMedia:E,observeIntersectionForReading:k,observeIntersectionForAnimatedStickers:R}=function(e,t,s){const{markMessageListRead:n,markMessagesRead:o}=(0,a.uC)(),{observe:r}=(0,Ot.S1)({rootRef:t,throttleMs:Ft,margin:Ut}),{observe:i,freeze:c,unfreeze:d}=(0,Ot.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let a=0;const r=[];t.forEach((e=>{const{isIntersecting:t,target:s}=e;if(!t)return;const{dataset:n}=s,o=Number(n.lastMessageId||n.messageId);o>a&&(a=o),n.hasUnreadMention&&r.push(o)})),s.current&&a>=s.current&&n({maxId:a}),r.length&&o({messageIds:r})}));(0,le.Z)(c,d);const{observe:l}=(0,Ot.S1)({rootRef:t,throttleMs:Ft});return{observeIntersectionForMedia:r,observeIntersectionForReading:i,observeIntersectionForAnimatedStickers:l}}(I,l,f),{backwardsTriggerRef:T,forwardsTriggerRef:N,fabTriggerRef:B}=function(e,t,s,r,i,c,d,l){const{loadViewportMessages:u}=(0,a.uC)(),[m,g]=(0,o.Ye)((()=>"thread"===e?[(0,Z.Ds)((()=>u({direction:h.Uq.Backwards})),1e3,!0,!1),(0,Z.Ds)((()=>u({direction:h.Uq.Forwards})),1e3,!0,!1)]:[]),[u,s]),f=(0,o.sO)(null),p=(0,o.sO)(null),I=(0,o.sO)(null),v=(0,o.I4)((()=>{if(!l)return;if(!s||!s.length)return c(!1),void d(!1);if(!r)return c(!0),void d(!0);const{offsetHeight:e,scrollHeight:a,scrollTop:n}=t.current,o=a-n-e,u=o<=0;c(i?!u:!(o<=50)),d(!u)}),[l,s,r,t,c,i,d]),{observe:y}=(0,Ot.S1)({rootRef:t,margin:n.gZ},(e=>{if(!g||!m)return;const s=e.find((({isIntersecting:e})=>e));if(!s)return;const{target:a}=s;"backwards-trigger"===a.className?((0,xt.Z)(t.current),m()):"forwards-trigger"===a.className&&((0,xt.Z)(t.current),g())}));(0,Ot._N)(f,y),(0,Ot._N)(p,y);const{observe:P,freeze:C,unfreeze:w}=(0,Ot.S1)({rootRef:t,margin:50},v);(0,Ot._N)(I,P);const{observe:b,freeze:M,unfreeze:S}=(0,Ot.S1)({rootRef:t},v);return(0,Ot._N)(I,b),(0,he.Z)((()=>{C(),M(),setTimeout((()=>{S(),w()}),100)}),[s]),{backwardsTriggerRef:f,forwardsTriggerRef:p,fabTriggerRef:I}}(I,l,e,s,r,b,M,v),A=(0,ye.Z)(),x=o.ZP.createElement("div",{className:(0,ie.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,A("UnreadMessages"))),O=w?0:t.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let F=0;const U=t.map(((e,t,s)=>{const a=e.senderGroups.map(((e,a,n)=>{if(1===e.length&&!Nt(e[0])&&(0,d.Lo)(e[0])){const r=e[0],i=a===n.length-1&&t===s.length-1;return(0,g.oA)([r.id===m.current&&x,o.ZP.createElement(es,{key:r.id,message:r,observeIntersection:k,appearanceOrder:O-++F,isLastInList:i})])}let r;return(0,g.xH)(e.map(((l,h)=>{const f=Nt(l)?l.mainMessage:l,v=Nt(l)?l:void 0,Z=(0,d.B4)(f),C=Nt(l),w=e[h+1];f.previousLocalId&&u.current===`message${f.previousLocalId}`&&(u.current=`message${f.id}`);const b=!C&&f.groupedId?f.groupedId:void 0,M=w&&!Nt(w)?w.groupedId:void 0,S={isFirstInGroup:0===h,isLastInGroup:h===e.length-1,isFirstInDocumentGroup:Boolean(b&&b!==r),isLastInDocumentGroup:Boolean(b&&b!==M),isLastInList:h===e.length-1&&a===n.length-1&&t===s.length-1};r=b;const T=(0,d.KK)(f),N="scheduled"!==I?T:`${f.date}_${T}`;return(0,g.oA)([f.id===m.current&&x,o.ZP.createElement(zs,{key:N,message:f,observeIntersectionForBottom:k,observeIntersectionForMedia:E,observeIntersectionForAnimatedStickers:R,album:v,noAvatars:c,withAvatar:S.isLastInGroup&&i&&!Z&&!(f.id===y),withSenderName:S.isFirstInGroup&&i&&!Z,threadId:p,messageListType:I,noComments:!1===P,appearanceOrder:O-++F,isFirstInGroup:S.isFirstInGroup,isLastInGroup:S.isLastInGroup,isFirstInDocumentGroup:S.isFirstInDocumentGroup,isLastInDocumentGroup:S.isLastInDocumentGroup,isLastInList:S.isLastInList}),f.id===y&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,A("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:At,teactFastList:!0},o.ZP.createElement("div",{className:(0,ie.Z)("sticky-date",!C&&"interactive"),key:"date-header",onMouseDown:At,onClick:C?void 0:()=>S({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},C&&e.originalDate===n.t4&&A("MessageScheduledUntilOnline"),C&&e.originalDate!==n.t4&&A("MessageScheduledOn",(0,L.j1)(A,e.datetime,void 0,!0)),!C&&(0,L.j1)(A,e.datetime))),(0,g.xH)(a))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:T,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(U),o.ZP.createElement("div",{ref:N,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:B,key:"fab-trigger",className:"fab-trigger"}))}));var ea=s(3547);const ta=(0,o.X$)((0,a.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,a=s&&s.length?s[t%s.length]:void 0,n=(0,i.Z1)(e,t);return n?{sticker:a,lastUnreadMessageId:n.lastMessage&&n.lastMessage.id!==n.lastReadInboxMessageId?n.lastMessage.id:void 0,connectionState:e.connectionState}:{}}),((e,t)=>(0,g.ei)(t,["loadGreetingStickers","sendMessage","markMessageListRead"])))((({sticker:e,connectionState:t,lastUnreadMessageId:s,loadGreetingStickers:a,sendMessage:n,markMessageListRead:r})=>{const i=(0,ye.Z)(),c=(0,o.sO)(null),{observe:d}=(0,Ot.S1)({rootRef:c,debounceMs:200});(0,o.d4)((()=>{e||"connectionStateReady"!==t||a()}),[t,a,e]),(0,o.d4)((()=>{"connectionStateReady"===t&&s&&r({maxId:s})}),[t,r,s]);const l=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},n({sticker:e})}),[n]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:c},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},i("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},i("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},e&&o.ZP.createElement(ea.Z,{sticker:e,onClick:l,clickArg:e,observeIntersection:d,size:160,className:"large"}))))}))),sa=(0,o.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s})=>{const a=(0,ye.Z)();return"scheduled"===t?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(a):e?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(a):s?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(a):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,a("NoMessages")))})),aa=(0,Z.Ds)((e=>e()),200,!1);function na(e,t){return t&&1===t.length&&1===t[0].senderGroups.length&&1===t[0].senderGroups[0].length&&"content"in t[0].senderGroups[0][0]&&t[0].senderGroups[0][0].content.action&&t[0].senderGroups[0][0].content.action.type===e}const oa=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,type:a})=>{const n=(0,i.Z1)(e,t);if(!n)return{};const o=(0,i.$W)(e,t,s,a),r="scheduled"===a?(0,i.Fn)(e,t):(0,i.Zw)(e,t),c=(0,i.qS)(e,t,s);if(s!==u._f&&!(r&&c&&r[c]))return{};const{isRestricted:l,restrictionReason:h,lastMessage:m}=n,g=(0,i.G$)(e,t),f=g?!e.focusedMessage.noHighlight:void 0,p=s===u._f&&!o&&!n.unreadCount&&!g&&m&&!m.groupedId,I=(0,i.IK)(e,t);let v;return(0,i.pk)(e,t)&&(v=I.fullInfo?I.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:l,restrictionReason:h,isChannelChat:(0,d.eA)(n),isGroupChat:(0,d.Bf)(n),isCreator:n.isCreator,isChatWithSelf:(0,i.FM)(e,t),isBot:Boolean(I),messageIds:o,messagesById:r,firstUnreadId:(0,i.It)(e,t,s),isViewportNewest:"thread"!==a||(0,i.b9)(e,t,s),threadFirstMessageId:(0,i.yZ)(e,t,s),focusingId:g,hasFocusHighlight:f,isSelectModeActive:(0,i.CA)(e),botDescription:v,threadTopMessageId:c,hasLinkedChat:n.fullInfo&&"linkedChatId"in n.fullInfo?Boolean(n.fullInfo.linkedChatId):void 0,...p&&{lastMessage:m}}}),((e,t)=>(0,g.ei)(t,["loadViewportMessages","setScrollOffset","openHistoryCalendar"])))((({chatId:e,threadId:t,type:s,hasTools:r,onFabToggle:c,onNotchToggle:l,isChatLoaded:u,isChannelChat:m,isGroupChat:f,canPost:p,isReady:I,isActive:v,isChatWithSelf:y,isCreator:P,isBot:C,messageIds:w,messagesById:b,firstUnreadId:M,isViewportNewest:S,threadFirstMessageId:E,isRestricted:k,restrictionReason:R,focusingId:T,hasFocusHighlight:N,isSelectModeActive:B,loadViewportMessages:A,setScrollOffset:x,lastMessage:L,botDescription:O,threadTopMessageId:F,hasLinkedChat:U,openHistoryCalendar:$})=>{const Q=(0,o.sO)(null),D=(0,o.sO)("thread"===s&&(0,i.Vt)((0,a.Rd)(),e,t)||0),q=(0,o.sO)(),G=(0,o.sO)(),H=(0,o.sO)(),j=(0,o.sO)(),_=(0,o.sO)(),V=(0,o.sO)(),W=(0,o.sO)(!1),K=(0,o.sO)(Boolean(L)),[X,Y]=(0,o.eJ)(),z=Boolean(w);(0,he.Z)((()=>{z&&(0,Z.R3)((()=>{K.current=!1}))}),[z]),(0,he.Z)((()=>{j.current=M}),[M]),(0,he.Z)((()=>{z&&(_.current=j.current)}),[z]),(0,he.Z)((()=>{V.current=T}),[T]);const J=(0,o.Ye)((()=>{if(!w||!b)return;const e=!F||w[0]&&E!==w[0]?w:[F,...w];if(!e.length)return;const t=e.map((e=>b[e])).filter(Boolean);return Bt((0,g.Xo)(t,["date","id"]),_.current)}),[w,b,E,F]),ee=(0,o.Ye)((()=>{if("thread"===s)return(0,Z.Ds)((()=>A({direction:h.Uq.Around})),1e3,!0,!1)}),[A,w]),{isScrolled:te,updateStickyDates:se}=function(){const[e,t]=(0,ve.Z)(!1),s=(0,o.Ye)((()=>(0,Z.Ds)((e=>e()),1e3,!1,a)),[1e3,!1,a]);var a;return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,Z.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{(0,Z.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const s=function(e,t){const s=e.querySelectorAll(".sticky-date"),a=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:n}=e,o=s-a;return-n<=o&&o<=(t?60:10)}))}(e,a);s&&s.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,s])}}(),ae=(0,o.I4)((()=>{if(W.current)return void(W.current=!1);const a=Q.current;V.current||se(a,r),aa((()=>{(0,Z.T2)((()=>{a.parentElement&&(D.current=a.scrollHeight-a.scrollTop,"thread"===s&&x({chatId:e,threadId:t,scrollOffset:D.current}))}))}))}),[se,r,s,x,e,t]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{e.target.offsetParent&&Y(e.contentRect.height)}));return e.observe(Q.current),()=>{e.disconnect()}}),[]);const{height:ne}=at();(0,o.d4)((()=>{I&&(Q.current.dataset.normalHeight=String(Q.current.offsetHeight))}),[ne,I]),(0,o.d4)((()=>{if(!ee||!u||k||T)return;const e=Q.current;(!w||w.length<n.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&ee()}),[u,w,ee,T,k]),(0,he.Z)((()=>{if(!w||!H.current||!I)return;const e=H.current.filter((e=>w.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(q.current=t.id,G.current=t.getBoundingClientRect().top)}),[w,S,X,r,I]),(0,Rt.Z)((([e,t,s])=>{const a=Q.current;if(H.current=Array.from(a.querySelectorAll(".message-list-item")),!a.offsetParent)return;const o=S&&w&&w.length<n.hT/2&&!a.parentElement.classList.contains("force-messages-scroll")&&a.firstElementChild.clientHeight<=2*a.offsetHeight;o&&(a.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{a.parentElement&&a.parentElement.classList.remove("force-messages-scroll")}),1e3));const i=w&&e&&w[0]!==e[0],c=w&&e&&w[w.length-1]!==e[e.length-1]&&!i,d=w&&V.current===w[w.length-1],{scrollTop:l,scrollHeight:u,offsetHeight:h}=a,m=D.current,g=H.current[H.current.length-1];let f=m-(s||h);c&&(f-=g?g.offsetHeight:0);const p=S&&t&&f<=20;let I;if(c&&p&&!d&&(g&&(0,Z.T2)((()=>{(0,Lt.Z)(a,g,"end",20)})),I=u-h,D.current=Math.max(u-I,h),!o))return;const v=void 0!==s&&s!==X,y=q.current&&a.querySelector(`#${q.current}`),P=!y&&_.current&&a.querySelector(".unread-divider");if(p&&v){if((0,Lt.N)())return;I=u-h}else I=y?l+(y.getBoundingClientRect().top-(G.current||0)):P?Math.min(P.offsetTop-(r?60:10),u-m):u-m;(0,xt.Z)(a,I),V.current||(W.current=!0,(0,Z.T2)((()=>{W.current=!1}))),D.current=Math.max(u-I,h)}),[w,S,X,r]),(0,Tt.Z)((([e])=>{void 0!==e&&(0,re.YW)(200+n.fK)}),[B]);const oe=(0,ye.Z)(),ce=Boolean(e&&(0,d.YA)(e)),de=Boolean(!ce&&!m||y),le=Boolean(!de||m),ue=(0,d.YA)(e)&&!y&&!C&&(!J&&!L&&w&&(!H.current||0===H.current.length)||na("contactSignUp",J)||L&&L.content.action&&"contactSignUp"===L.content.action.type),me=f&&P&&na("chatCreate",J),ge=(0,ie.Z)("MessageList custom-scroll",le&&"no-avatars",!p&&"no-composer","pinned"===s&&"type-pinned",N&&"has-focus-highlight",B&&"select-mode-active",te&&"scrolled",!I&&"is-animating");return o.ZP.createElement("div",{ref:Q,className:ge,onScroll:ae,onMouseDown:At},k?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,R?R.text:"This is a private "+(m?"channel":"chat"))):O?o.ZP.createElement("div",{className:"empty rich"},o.ZP.createElement("span",null,(0,pt.Z)(oe(O),["br","emoji","links"]))):ue?o.ZP.createElement(ta,{userId:e}):!w||J&&!me?w&&J||L?o.ZP.createElement(Js,{messageIds:w||[L.id],messageGroups:J||Bt([L]),isViewportNewest:Boolean(S),isUnread:Boolean(M),withUsers:de,noAvatars:le,containerRef:Q,anchorIdRef:q,memoUnreadDividerBeforeIdRef:_,memoFirstUnreadIdRef:j,threadId:t,type:s,isActive:v,threadTopMessageId:F,hasLinkedChat:U,isSchedule:!!J&&"scheduled"===s,noAppearanceAnimation:!J||!K.current,onFabToggle:c,onNotchToggle:l,openHistoryCalendar:$}):o.ZP.createElement(Fe.Z,{color:"white"}):o.ZP.createElement(sa,{chatId:e,type:s,isChatWithSelf:y,isGroupChatJustCreated:me}))}))),ra=(0,o.X$)((0,a.c$)((e=>{const t=(0,i.Bt)(e);if(!t)return{};const{chatId:s,threadId:a,type:n}=t,o=(0,i.Z1)(e,s);return{messageListType:n,unreadCount:o&&a===u._f&&"thread"===n?o.unreadCount:void 0}}),((e,t)=>(0,g.ei)(t,["focusNextReply"])))((({isShown:e,canPost:t,messageListType:s,unreadCount:a,focusNextReply:n})=>{const r=(0,ye.Z)(),i=(0,o.sO)(null),c=(0,o.I4)((()=>{if(e)if("thread"===s)n();else{const e=i.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,Lt.Z)(e,s,"end",20)}}),[e,s,n]),d=(0,ie.Z)("ScrollDownButton",e&&"revealed",!t&&"no-composer");return o.ZP.createElement("div",{ref:i,className:d},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(we.Z,{color:"secondary",round:!0,onClick:c,ariaLabel:r("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(a)&&o.ZP.createElement("div",{className:"unread-count"},(0,lt.bi)(a))))})));var ia=s(5723),ca=s(6980);const da=1280;async function la(e,t,s,a){const n=URL.createObjectURL(t),{type:o,size:r}=t;let i,c;if(o.startsWith("image/"))if(s){const s=await(0,tt.pt)(n),{width:r,height:c}=s;if(r>da||c>da||"image/jpeg"!==o){const o=await function(e){return new Promise((t=>{const s=document.createElement("canvas"),a=s.getContext("2d");let{width:n,height:o}=e;(n>da||o>da)&&(n>=o?(o*=da/n,n=da):(n*=da/o,o=da)),s.width=n,s.height=o,a.drawImage(e,0,0,e.width,e.height,0,0,n,o),s.toBlob(t,"image/jpeg",100)}))}(s);return o?(URL.revokeObjectURL(n),la(e,o,!0,a)):la(e,t,!1,a)}i={width:r,height:c}}else c=n;else if(o.startsWith("video/")){if(r<10485760){const{videoWidth:e,videoHeight:t,duration:s}=await(0,tt.jj)(n);i={width:e,height:t,duration:s}}c=await(0,tt.ud)(n)}return{blobUrl:n,filename:e,mimeType:o,size:r,quick:i,previewBlobUrl:c,...a}}var ua=s(6391);let ha;function ma(e){ha.focus(),e.focus()}m.cj&&(ha=document.createElement("input"),ha.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(ha));const ga={encoderPath:s.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},fa={type:"audio/ogg"};let pa,Ia,va;async function ya(){return pa||(pa=s.e(161).then(s.t.bind(s,1161,23)),Ia=(await pa).default,va=new Ia(ga)),pa}async function Za(e){await async function(){await ya(),await va.start()}();const t=Date.now();let s;const a=[],n=[];va.ondataavailable=e=>{a.push(e)};const o=function(t,s){const a=t.sourceNode,o=a.context.createAnalyser();o.fftSize=64,a.connect(o);const r=o.frequencyBinCount,i=new Uint8Array(r);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(i);const s=i.reduce(((e,t)=>e+t),0)/r/255;(t=>{n.push(255*t),e(t)})(s<.1?0:s),requestAnimationFrame(t)}(),()=>{c=!0}}(va);return{stop:()=>new Promise(((e,r)=>{va.onstop=()=>{e({blob:new Blob(a,fa),duration:Math.round(((s||Date.now())-t)/1e3),waveform:n})},va.onerror=r;const i=Math.max(0,t+1e3-Date.now());setTimeout((()=>{va.stop(),o()}),i)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{va.pause(),s=Date.now(),o()}),e)}}}const Pa=["image/png","image/jpeg","image/gif"];function Ca(e){const{text:t,entities:s}=e||{};if(!t)return"";const a=(0,Qt.H)(t,s,void 0,void 0,!0);return Array.isArray(a)?a.join(""):a}let wa,ba;var Ma=s(4784),Sa=s(8353),Ea=s(2365);const ka=document.createElement("div"),Ra=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Ta=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i;const Na=(0,Z.P2)((e=>e()),500,!0),Ba=/[\w\d_-]*/i,Aa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"DeleteMessageModal",!t);return s?o.ZP.createElement(s,e):void 0}));function xa(){return(xa=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}let La,Oa=!0;const Fa=(0,o.X$)((({onActivate:e,...t})=>{const s=(0,o.sO)(!1),a=(0,o.I4)((()=>{if(s.current=!0,Oa)return Oa=!1,void e();La&&(clearTimeout(La),La=void 0),La=window.setTimeout((()=>{s.current&&e()}),200)}),[e]),n=(0,o.I4)((()=>{s.current=!1}),[]);return o.ZP.createElement(we.Z,xa({},t,{onMouseEnter:m.$b?void 0:a,onMouseLeave:m.$b?void 0:n,onClick:m.$b?e:void 0}))})),Ua=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"AttachMenu",!t);return s?o.ZP.createElement(s,e):void 0})),$a=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"SymbolMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Qa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"InlineBotTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),Da=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"MentionTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),qa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"CustomSendMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Ga=e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"StickerTooltip",!t);return s?o.ZP.createElement(s,e):void 0};var Ha=s(9830);const ja=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"BotCommandTooltip",!t);return s?o.ZP.createElement(s,e):void 0}));var _a=s(6503);const Va=(0,o.X$)((0,a.c$)(((e,{messageId:t})=>{const{chatId:s}=(0,i.Bt)(e)||{};return s?{message:(0,i.hj)(e,s,t)}:{}}),((e,t)=>(0,g.ei)(t,["clickInlineButton"])))((({isOpen:e,message:t,onClose:s,clickInlineButton:a})=>{const[n,r]=(0,_a.Z)(e,s),{isKeyboardSingleUse:i}=t||{},[c,d,l]=(0,ve.Z)(!0),u=()=>{l(),s()};if((0,o.d4)((()=>{d()}),[d,t]),t&&t.keyboardButtons)return o.ZP.createElement(Qe.Z,{isOpen:e||c,autoClose:i,positionX:"right",positionY:"bottom",onClose:u,className:"BotKeyboardMenu",onCloseAnimationEnd:u,onMouseEnter:m.$b?void 0:n,onMouseLeave:m.$b?void 0:r},o.ZP.createElement("div",{className:"content"},t.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(we.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>a({button:e})},e.text))))))))})));var Wa=s(3616),Ka=s(7891);const Xa=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:s,type:a}=(0,i.Bt)(e)||{};if(!t||!s||!a)return{};const{currentUserId:n,forwardMessages:{fromChatId:o,toChatId:r,messageIds:c}}=e,l=(0,i.Yy)(e,t,s),u="scheduled"===a?(0,i.wU)(e,t):(0,i._$)(e,t,s),h=e.settings.byKey.animationLevel>=1,m=r===t;let g,f;if(l?g=(0,i.hj)(e,t,l):u?g=(0,i.kK)(e,t,s,a):m&&1===c.length&&(g=(0,i.hj)(e,o,c[0])),l&&g){const{forwardInfo:s}=g,a=t===n;s&&(s.isChannelPost||a)&&(f=(0,i.cv)(e,g)),f||(f=(0,i.Ur)(e,g))}else m&&(f=(0,d.YA)(o)?(0,i.dy)(e,o):(0,i.Z1)(e,o));return{replyingToId:l,editingId:u,message:g,sender:f,shouldAnimate:h,forwardedMessagesCount:m?c.length:void 0}}),((e,t)=>(0,g.ei)(t,["setReplyingToId","setEditingId","focusMessage","exitForwardMode"])))((({replyingToId:e,editingId:t,message:s,sender:a,shouldAnimate:n,forwardedMessagesCount:r,setReplyingToId:i,setEditingId:c,focusMessage:d,exitForwardMode:l})=>{const u=Boolean((e||t)&&s||a&&r),h=(0,Ka.Z)([r],r?300:void 0),{shouldRender:m,transitionClassNames:g}=(0,de.Z)(h&&u,void 0,!n,void 0,!n),f=(0,o.I4)((()=>{e?i({messageId:void 0}):t?c({messageId:void 0}):r&&l()}),[e,t,r,i,c,l]);(0,o.d4)((()=>u?(0,fe.Z)(f):void 0),[u,f]);const p=(0,o.I4)((()=>{d({chatId:s.chatId,messageId:s.id})}),[d,s]),I=(0,ie.Z)("ComposerEmbeddedMessage",g),v=r&&r>1?`${r} forwarded messages`:void 0;if(m)return o.ZP.createElement("div",{className:I},o.ZP.createElement("div",null,o.ZP.createElement(we.Z,{round:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(ts,{className:"inside-input",message:s,sender:a,customText:v,title:t?"Edit Message":void 0,onClick:p})))}))),Ya=(0,o.X$)((e=>{const{attachments:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"AttachmentModal",!t.length);return s?o.ZP.createElement(s,e):void 0})),za=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"BotCommandMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Ja=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"PollModal",!t);return s?o.ZP.createElement(s,e):void 0})),en=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"DropArea",!t);return s?o.ZP.createElement(s,e):void 0})),tn=new RegExp(n.FM,"i"),sn=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s})=>{const a=(0,i.tV)(e,t,s);return{webPagePreview:e.webPagePreview,noWebPage:a}}),((e,t)=>(0,g.ei)(t,["loadWebPagePreview","clearWebPagePreview","toggleMessageWebPage"])))((({chatId:e,threadId:t,messageText:s,disabled:a,webPagePreview:n,noWebPage:r,loadWebPagePreview:i,clearWebPagePreview:c,toggleMessageWebPage:d})=>{const l=(0,o.Ye)((()=>{const{text:e,entities:t}=(0,ca.Z)(s),a=t&&t.find((({type:e})=>e===u.Vv.TextUrl));if(a)return a.url;const n=e.match(tn);return n?n[0]:void 0}),[s]);(0,o.d4)((()=>{l?i({text:l}):(c(),d({chatId:e,threadId:t}))}),[e,d,c,l,i,t]),(0,he.Z)((()=>{c(),d({chatId:e,threadId:t})}),[e]);const h=Boolean(n&&s.length&&!r&&!a),{shouldRender:m,transitionClassNames:g}=(0,de.Z)(h),f=(0,dt.Z)(n);if(!m||!f)return;const{photo:p,...I}=f,v={content:{webPage:I}};return o.ZP.createElement("div",{className:(0,ie.Z)("WebPagePreview",g)},o.ZP.createElement("div",null,o.ZP.createElement(we.Z,{round:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{d({chatId:e,threadId:t,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Os,{message:v,inPreview:!0})))})));var an=s(2898);const nn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"CalendarModal",!t);return s?o.ZP.createElement(s,e):void 0})),on=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0})),rn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0}));var cn;!function(e){e.Send="send",e.Record="record",e.Edit="edit"}(cn||(cn={}));const dn=(0,o.X$)((0,a.c$)(((e,{chatId:t,threadId:s,messageListType:a})=>{const o=(0,i.Z1)(e,t),r=o&&(0,i.Dg)(e,o),c=t!==n.FV?(0,i.IK)(e,t):void 0,l=Boolean(c),h=(0,i.FM)(e,t),m=l&&(0,i.FT)(e,t),g=(0,i.qy)(e,t),{language:f}=e.settings.byKey,p=e.emojiKeywords[n.pR],I=f!==n.pR?e.emojiKeywords[f]:void 0,v=m?m.id:void 0,y=v?(0,i.hj)(e,t,v):void 0;return{editingMessage:(0,i.kK)(e,t,s,a),connectionState:e.connectionState,draft:(0,i.Ms)(e,t,s),chat:o,isChatWithBot:l,isChatWithSelf:h,canScheduleUntilOnline:!h&&!l&&o&&r&&(0,d.YA)(t)&&r.status&&Boolean(r.status.wasOnline),isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),withScheduledButton:s===u._f&&"thread"===a&&Boolean(g&&g.length),shouldSchedule:"scheduled"===a,botKeyboardMessageId:v,botKeyboardPlaceholder:y?y.keyboardPlaceholder:void 0,isForwarding:t===e.forwardMessages.toChatId,isPollModalOpen:e.isPollModalOpen,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:o&&o.fullInfo&&o.fullInfo.members,topInlineBotIds:e.topInlineBots&&e.topInlineBots.userIds,currentUserId:e.currentUserId,usersById:e.users.byId,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),shouldSuggestStickers:e.settings.byKey.shouldSuggestStickers,recentEmojis:e.recentEmojis,baseEmojiKeywords:p?p.keywords:void 0,emojiKeywords:I?I.keywords:void 0,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:o&&o.fullInfo&&o.fullInfo.botCommands,botCommands:c&&c.fullInfo?c.fullInfo.botCommands||!1:void 0}}),((e,t)=>(0,g.ei)(t,["sendMessage","editMessage","saveDraft","clearDraft","showDialog","setStickerSearchQuery","setGifSearchQuery","forwardMessages","openPollModal","closePollModal","closePaymentModal","clearReceipt","loadScheduledHistory","openChat","addRecentEmoji","sendInlineBotResult"])))((({dropAreaState:e,shouldSchedule:t,canScheduleUntilOnline:s,isReady:r,onDropHide:i,editingMessage:c,chatId:l,threadId:h,messageListType:g,draft:f,chat:p,connectionState:I,isChatWithBot:v,isChatWithSelf:y,isRightColumnShown:P,isSelectModeActive:C,isForwarding:w,isPollModalOpen:b,isPaymentModalOpen:M,isReceiptModalOpen:S,botKeyboardMessageId:E,botKeyboardPlaceholder:k,withScheduledButton:R,stickersForEmoji:T,groupChatMembers:N,topInlineBotIds:B,currentUserId:A,usersById:x,lastSyncTime:O,contentToBeScheduled:F,shouldSuggestStickers:U,baseEmojiKeywords:$,emojiKeywords:Q,serverTimeOffset:q,recentEmojis:G,inlineBots:H,isInlineBotLoading:j,botCommands:_,chatBotCommands:V,sendMessage:W,editMessage:K,saveDraft:X,clearDraft:Y,showDialog:z,setStickerSearchQuery:J,setGifSearchQuery:ee,forwardMessages:te,openPollModal:se,closePollModal:ae,loadScheduledHistory:ne,closePaymentModal:oe,openChat:re,clearReceipt:ce,addRecentEmoji:de,sendInlineBotResult:he})=>{const me=(0,ye.Z)(),ge=(0,o.sO)(null),[pe,Ie]=(0,o.eJ)(""),Ze=(0,o.sO)(),Pe=(0,gs.Z)(e),[Ce,be,Me]=(0,ve.Z)(),[Se,Ee]=(0,o.eJ)(),{width:ke}=st.Z.get(),Te=(0,o.sO)(pe);(0,o.d4)((()=>{Te.current=pe}),[pe]),(0,o.d4)((()=>{Ze.current=void 0}),[l]),(0,o.d4)((()=>{l&&O&&h===u._f&&r&&ne()}),[r,l,ne,O,h]),(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&&(Ee(F),be())}),[F,be]);const[Ne,Be]=(0,o.eJ)([]),[Ae,xe,Le]=(0,ve.Z)(),[Oe,Fe,Ue]=(0,ve.Z)(),[$e,Qe,De]=(0,ve.Z)(),[qe,Ge,He]=(0,ve.Z)(),[je,_e,Ve]=(0,ve.Z)(),[We,Ke]=(0,ve.Z)(),[Xe,Ye,ze]=(0,ve.Z)(),{startRecordingVoice:et,stopRecordingVoice:tt,pauseRecordingVoice:at,activeVoiceRecording:nt,currentRecordTime:ot,recordButtonRef:rt,startRecordTimeRef:it}=(()=>{const e=(0,o.sO)(null),[t,s]=(0,o.eJ)(),a=(0,o.sO)(),[n,r]=(0,o.eJ)();(0,o.d4)((()=>{m.cj&&m.mh&&ya()}),[]);const i=(0,o.I4)((async()=>{try{const{stop:t,pause:n}=await Za((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)`),r(Date.now()))}));a.current=Date.now(),r(Date.now()),s({stop:t,pause:n})}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]),d=(0,o.I4)((()=>{if(t){s(void 0),a.current=void 0,r(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,fe.Z)(d):void 0),[t,d]),{startRecordingVoice:i,pauseRecordingVoice:c,stopRecordingVoice:d,activeVoiceRecording:t,currentRecordTime:n,recordButtonRef:e,startRecordTimeRef:a}})(),ct=c?cn.Edit:!m.mh||nt||pe&&!Ne.length||w?cn.Send:cn.Record,dt=!t,{isMentionTooltipOpen:lt,closeMentionTooltip:ut,insertMention:ht,mentionFilteredUsers:mt}=(0,Ea.Z)(!Ne.length,pe,Ie,void 0,N,B,A,x),{isOpen:gt,id:ft,isGallery:It,switchPm:vt,results:yt,closeTooltip:Zt,help:Pt,loadMore:Ct}=function(e,t,s,n){const[r,i,c]=(0,ve.Z)(),d=function(e){return ka.innerHTML=e.replace(/<br>/g,"\n"),ka.innerText}(s),{queryInlineBot:l,resetInlineBot:u}=(0,a.uC)(),{username:h,query:m,canShowHelp:g}=function(e){const t=e.match(Ra);return t?{username:t[1],query:t[2],canShowHelp:""===t[2]&&!e.match(Ta)}:{username:"",query:"",canShowHelp:!1}}(d),f=h.toLowerCase(),p=(0,gs.Z)(m),I=(0,gs.Z)(h),v=n&&n[f],{id:y,switchPm:Z,offset:P,results:C,isGallery:w,help:b}=v||{};(0,o.d4)((()=>{p!==m&&c()}),[p,m,c]),(0,o.d4)((()=>{e&&f&&t&&l({chatId:t,username:f,query:m})}),[m,e,l,t,f]);const M=(0,o.I4)((()=>{l({chatId:t,username:f,query:m,offset:P})}),[P,t,m,l,f]);return(0,o.d4)((()=>{e&&y&&(Z||C&&C.length)?i():c()}),[y,e,i,C,Z,c]),I!==h&&u({username:I}),{isOpen:r,closeTooltip:c,loadMore:M,username:h,id:y,isGallery:w,switchPm:Z,results:C,help:g&&b?`@${h} ${b}`:void 0}}(Boolean(!Ne.length&&O),l,pe,H),{isOpen:wt,close:bt,filteredBotCommands:Mt}=function(e,t,s,a){const[n,r,i]=(0,ve.Z)(),[c,d]=(0,o.eJ)(),l=(0,o.I4)((e=>{s||a?Na((()=>{const t=(s||a||[]).filter((({command:t})=>!e||t.includes(e)));d(t&&t.length?t:void 0)})):d(void 0)}),[s,a]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=t.substr(1).match(Ba);l(e?e[0]:"")}else i();else i()}),[l,t,e,i]),(0,o.d4)((()=>{c&&c.length?r():i()}),[c,r,i]),{isOpen:n,close:i,filteredBotCommands:c}}(Boolean(_&&_.length||V&&V.length),pe,_,V),{isContextMenuOpen:St,handleContextMenu:Et,handleContextMenuClose:kt,handleContextMenuHide:Rt}=(0,$t.Z)(rt,!(ct===cn.Send&&dt)),Tt=(0,o.Ye)((()=>(0,d.H5)(p,v)),[p,v]),Nt=p&&(0,d.Nl)(p),Bt=(0,d.Hd)(p),{isStickerTooltipOpen:At,closeStickerTooltip:xt}=function(e,t,s,n=!1){const{loadStickersForEmoji:r,clearStickersForEmoji:i}=(0,a.uC)(),c=m.op&&1===(0,Ma.Z)(t)||!m.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),d=Boolean(s)&&c;return(0,o.d4)((()=>{n||(e&&c?r({emoji:t}):!d&&c||i())}),[t,c,i,r,e,n]),{isStickerTooltipOpen:d,closeStickerTooltip:i}}(Boolean(U&&Tt.canSendStickers&&!Ne.length),pe,T,!r),{isEmojiTooltipOpen:Lt,closeEmojiTooltip:Ot,filteredEmojis:Ft,insertEmoji:Ut}=(0,Sa.Z)(Boolean(U&&Tt.canSendStickers&&!Ne.length),pe,G,void 0,Ie,$,Q,!r),Qt=(0,o.I4)(((e,t=n.R2)=>{const s=window.getSelection(),a=document.getElementById(t),o=(0,pt.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(s.rangeCount){const e=s.getRangeAt(0);if((0,ua.R)(e,t))return function(e){const t=window.getSelection();if(t&&t.getRangeAt&&t.rangeCount){const s=t.getRangeAt(0);s.deleteContents();const a=s.createContextualFragment(e),n=a.lastChild;s.insertNode(a),n?(s.setStartAfter(n),s.setEndAfter(n)):s.collapse(!1),t.removeAllRanges(),t.addRange(s)}}(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}Ie(`${Te.current}${o}`),requestAnimationFrame((()=>{(0,ia.Z)(a)}))}),[]),Dt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,ua.R)(t,n.R2))return void document.execCommand("delete",!1)}Ie(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 s=t.lastChild;if(s.lastChild)for(;s.lastChild;)s=s.lastChild;const a=s.textContent.length,n=document.createRange(),o=window.getSelection();n.setStart(s,a),n.setEnd(s,a),o.removeAllRanges(),o.addRange(n),document.execCommand("delete",!1);const r=t.innerHTML;return document.body.removeChild(t),r}(Te.current))}),[]),qt=(0,o.I4)(((e=!1)=>{e||Ie(""),Be([]),xt(),Me(),Ee(void 0),ut(),Ot(),m.wB?setTimeout((()=>He()),350):He()}),[xt,Me,ut,Ot,He]),Gt=(0,gs.Z)(l);(0,o.d4)((()=>{Gt&&l!==Gt&&(tt(),qt())}),[l,Gt,qt,tt]);const Ht=((e,t,s,a,r,i)=>((0,o.d4)((()=>{s?(t(Ca(s.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(n.R2);(0,ia.Z)(e,!0)}))):t("")}),[s,t]),(0,o.I4)((()=>{const{text:t,entities:n}=(0,ca.Z)(e.current);s&&(t||(0,d.u8)(s)?(i({messageId:s.id,text:t,entities:n}),a()):r())}),[i,s,e,r,a])))(Te,Ie,c,qt,_e,K);((e,t,s,a,r,i,c,d,l)=>{const u=(0,o.I4)(((e,t)=>{r.current.length&&!c?d({chatId:e,threadId:t,draft:(0,ca.Z)(r.current)}):l({chatId:e,threadId:t})}),[l,c,r,d]),h=(0,o.Ye)((()=>(0,Z.Ds)((e=>e()),n.r_,!1)),[t]),g=(0,gs.Z)(t),f=(0,gs.Z)(s);(0,o.d4)((()=>(wa=t,ba=s,()=>{wa=void 0,ba=void 0,u(t,s)})),[t,s,u]),(0,o.d4)((()=>{t===g&&s===f||e&&(i(Ca(e)),m.$b||requestAnimationFrame((()=>{const e=document.getElementById(n.R2);(0,ia.Z)(e,!0)})))}),[t,s,e,i,u,g,f]);const p=(0,gs.Z)(a);(0,o.d4)((()=>{t&&s&&g===t&&f===s&&p!==a&&(a.length?h((()=>{wa===t&&ba===s&&u(t,s)})):u(t,s))}),[t,a,g,p,f,h,s,u]);const I=(0,o.I4)((()=>{t&&s&&u(t,s)}),[t,s,u]);(0,le.Z)(I),ue(I)})(f,l,h,pe,Te,Ie,c,X,Y),((e,t,s)=>{(0,o.d4)((()=>{async function a(a){if(!a.clipboardData)return;const o=document.activeElement;if(o&&![n.R2,n.nY].includes(o.id))return;const{items:r}=a.clipboardData,i=Array.from(r).find((e=>Pa.includes(e.type))),c=i&&i.getAsFile(),d=a.clipboardData.getData("text").substring(0,4096);if(c||d){if(a.preventDefault(),c&&!s){const e=await la(c.name,c,!0);t((t=>[...t,e]))}d&&e(d,o?o.id:void 0)}}return document.addEventListener("paste",a,!1),()=>{document.removeEventListener("paste",a,!1)}}),[e,s,t])})(Qt,Be,c);const jt=(0,o.I4)((async(e,t)=>{Be(await Promise.all(e.map((e=>la(e.name,e,t)))))}),[]),_t=(0,o.I4)((async(e,t)=>{Be([...Ne,...await Promise.all(e.map((e=>la(e.name,e,t))))])}),[Ne]),Vt=(0,o.I4)((()=>{Be([])}),[]),Wt=(0,o.I4)((async(e=!1,t)=>{if("connectionStateReady"!==I)return;let s=Ne;if(nt){const e=await tt();if(e){const{blob:t,duration:a,waveform:n}=e;s=[await la("wonderful-voice-message.ogg",t,!1,{voice:{duration:a,waveform:n}})]}}const{text:a,entities:o}=(0,ca.Z)(Te.current);if(!s.length&&!a&&!w)return;const r=s.length?1024:4096;if((null==a?void 0:a.length)>r){const e=a.length-r;return void z({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const i=document.getElementById(n.R2);if(s.length||a){if(Bt&&!Nt){const e=(0,D.b)(q),t=Ze.current&&Math.floor(e-Ze.current),s=Bt.nextSendDate&&Bt.nextSendDate>e;if(t&&t<Bt.seconds||s){const a=s?Bt.nextSendDate-e:Bt.seconds-t;return z({data:{message:me("SlowModeHint",(0,L.k9)(a)),isSlowMode:!0,hasErrorKey:!1}}),void i.blur()}}W({text:a,entities:o,attachments:s,scheduledAt:t,isSilent:e})}w&&te(),Ze.current=(0,D.b)(q),Y({chatId:l,localOnly:!0}),m.cj&&i===document.activeElement&&ma(i),requestAnimationFrame((()=>{qt()}))}),[I,Ne,nt,w,Y,l,q,qt,tt,z,Bt,Nt,W,te,me]),Kt=(0,o.I4)((()=>{He(),Fe()}),[He,Fe]),Xt=(0,o.I4)((()=>{Ue(),Ge()}),[Ue,Ge]),Yt=(0,o.I4)(((e,s=!1)=>{e={...e,isPreloadedGlobally:!0},t?(Ee({sticker:e}),be()):(W({sticker:e}),requestAnimationFrame((()=>{qt(s)})))}),[t,be,W,qt]),zt=(0,o.I4)((e=>{t?(Ee({gif:e}),be()):(W({gif:e}),requestAnimationFrame((()=>{qt(!0)})))}),[t,be,W,qt]),Jt=(0,o.I4)((e=>{if("connectionStateReady"!==I)return;he({id:e.id,queryId:e.queryId});const t=document.getElementById(n.R2);m.cj&&t===document.activeElement&&ma(t),Y({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{qt()}))}),[l,Y,I,qt,he]),es=(0,o.I4)((()=>{Y({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{qt()}))}),[l,Y,qt]),ts=(0,o.I4)((e=>{t?(Ee({poll:e}),ae(),be()):(W({poll:e}),ae())}),[ae,be,W,t]),ss=(0,o.I4)((()=>{t?(Ee({isSilent:!0}),be()):Wt(!0)}),[Wt,be,t]),as=(0,o.I4)(((e,t=!1)=>{const{isSilent:s,...a}=Se||{},n=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:q);Se&&0!==Object.keys(a).length?(W({...Se,scheduledAt:n}),requestAnimationFrame((()=>{qt()}))):Wt(!!s,n),Me()}),[Me,Wt,qt,Se,W,q]),ns=(0,o.I4)((()=>{as(new Date(1e3*n.t4),!0)}),[as]),os=(0,o.I4)((()=>{Me(),Ee(void 0)}),[Me]),rs=(0,o.I4)((e=>{"stickers"===e?(J({query:""}),ee({query:void 0})):(ee({query:""}),J({query:void 0}))}),[J,ee]),is=(0,o.I4)((()=>{const e=document.getElementById(n.R2);m.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Ue(),Ge()}),100)):Ge()}),[Ge,Ue]),cs=(0,o.I4)((()=>{re({id:l,threadId:h,type:"scheduled"})}),[re,l,h]);(0,o.d4)((()=>{P&&m.wB&&He()}),[P,He]),(0,o.d4)((()=>{r&&(C?Ye():setTimeout((()=>{ze()}),200))}),[C,ze,Ye,r]);const ds=(0,o.I4)((()=>{switch(ct){case cn.Send:t?(nt&&at(),be()):Wt();break;case cn.Record:et();break;case cn.Edit:Ht()}}),[ct,t,et,Ht,nt,be,at,Wt]),ls=ct===cn.Record&&!Tt.canAttachMedia,us=(0,gs.Z)(c,!0),hs=c||us,ms=new Date;ms.setSeconds(0),ms.setMilliseconds(0);const fs=new Date;fs.setFullYear(fs.getFullYear()+1);let ps="SendMessage";switch(ct){case cn.Edit:ps="Save edited message";break;case cn.Record:ps=ls?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const Is=(0,ie.Z)("Composer",!C&&"shown",Xe&&"hover-disabled"),vs=(0,ie.Z)("mobile-symbol-menu-button",!r&&"not-ready",We?qe&&"menu-opened":qe&&"is-loading"),ys=ct===cn.Edit?Ht:t?be:Wt;return o.ZP.createElement("div",{className:Is},Tt.canAttachMedia&&r&&o.ZP.createElement(an.Z,{containerId:"#middle-column-portals"},o.ZP.createElement(en,{isOpen:e!==Je.t.None,withQuick:[e,Pe].includes(Je.t.QuickFile),onHide:i,onFileSelect:jt})),o.ZP.createElement(Ya,{attachments:Ne,caption:Ne.length?pe:"",groupChatMembers:N,currentUserId:A,usersById:x,recentEmojis:G,isReady:r,onCaptionUpdate:Ie,baseEmojiKeywords:$,emojiKeywords:Q,addRecentEmoji:de,onSend:t?be:Wt,onFileAppend:_t,onClear:Vt}),o.ZP.createElement(Ja,{isOpen:Boolean(b),onClear:ae,onSend:ts}),o.ZP.createElement(on,{isOpen:Boolean(M),onClose:oe}),o.ZP.createElement(rn,{isOpen:Boolean(S),onClose:ce}),hs&&o.ZP.createElement(Aa,{isOpen:je,isSchedule:"scheduled"===g,onClose:Ve,message:hs}),o.ZP.createElement(Da,{isOpen:lt,onClose:ut,onInsertUserName:ht,filteredUsers:mt,usersById:x}),o.ZP.createElement(Qa,{isOpen:gt,botId:ft,allowedAttachmentOptions:Tt,isGallery:It,inlineBotResults:yt,switchPm:vt,onSelectResult:Jt,loadMore:Ct,onClose:Zt}),o.ZP.createElement(ja,{isOpen:wt,withUsername:Boolean(V),botCommands:Mt,onClick:es,onClose:bt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:ge}),o.ZP.createElement(Xa,null),o.ZP.createElement(sn,{chatId:l,threadId:h,messageText:Ne.length?"":pe,disabled:!Tt.canAttachEmbedLinks}),o.ZP.createElement("div",{className:"message-input-wrapper"},v&&!1!==_&&!nt&&!c&&o.ZP.createElement(Fa,{className:(0,ie.Z)("bot-commands",Oe&&"activated"),round:!0,faded:!0,disabled:void 0===_,color:"translucent",onActivate:Kt,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),m.wB?o.ZP.createElement(we.Z,{className:vs,round:!0,faded:!0,color:"translucent",onClick:qe?He:is,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),qe&&!We&&o.ZP.createElement(Re.Z,{color:"gray"})):o.ZP.createElement(Fa,{className:qe?"activated":"",round:!0,faded:!0,color:"translucent",onActivate:Xt,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(Wa.Z,{id:"message-input-text",html:Ne.length?"":pe,placeholder:nt&&ke<=600?"":k||me("Message"),forcedPlaceholder:Pt,shouldSetFocus:!Ne.length,shouldSuppressFocus:m.wB&&qe,shouldSuppressTextFormatter:Lt||lt||gt,onUpdate:Ie,onSend:ys,onSuppressedFocus:He}),j&&Boolean(ft)&&o.ZP.createElement(Re.Z,{color:"gray"}),R&&o.ZP.createElement(we.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:cs,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),E&&!nt&&!c&&o.ZP.createElement(Fa,{className:Ae?"activated":"",round:!0,faded:!0,color:"translucent",onActivate:xe,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!nt&&!c&&o.ZP.createElement(Fa,{className:$e?"activated":"",round:!0,faded:!0,color:"translucent",onActivate:Qe,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),nt&&ot&&o.ZP.createElement("span",{className:"recording-state"},(0,L.rM)(ot-it.current)),o.ZP.createElement(Ga,{isOpen:At,onStickerSelect:Yt}),o.ZP.createElement(Ha.Z,{isOpen:Lt,emojis:Ft,onClose:Ot,onEmojiSelect:Ut,addRecentEmoji:de}),o.ZP.createElement(Ua,{isOpen:$e,allowedAttachmentOptions:Tt,onFileSelect:jt,onPollCreate:se,onClose:De}),E&&o.ZP.createElement(Va,{messageId:E,isOpen:Ae,onClose:Le}),_&&o.ZP.createElement(za,{isOpen:Oe,botCommands:_,onClose:Ue}),o.ZP.createElement($a,{isOpen:qe,allowedAttachmentOptions:Tt,onLoad:Ke,onClose:He,onEmojiSelect:Qt,onStickerSelect:Yt,onGifSelect:zt,onRemoveSymbol:Dt,onSearchOpen:rs,addRecentEmoji:de}))),nt&&o.ZP.createElement(we.Z,{round:!0,color:"danger",className:"cancel",onClick:tt,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(we.Z,{ref:rt,round:!0,color:"secondary",className:(0,ie.Z)(ct,!r&&"not-ready",nt&&"recording"),disabled:ls,ariaLabel:me(ps),onClick:ds,onContextMenu:ct===cn.Send&&dt?Et:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),dt&&o.ZP.createElement(qa,{isOpen:St,onSilentSend:y?void 0:ss,onScheduleSend:t?void 0:be,onClose:kt,onCloseAnimationEnd:Rt}),o.ZP.createElement(nn,{isOpen:Ce,withTimePicker:!0,selectedAt:ms.getTime(),maxAt:(0,L._F)(fs),isFutureMode:!0,secondButtonLabel:s?"Send When Online":void 0,onClose:os,onSubmit:as,onSecondButtonClick:s?ns:void 0}))}))),ln=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0})),un=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0})),hn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0})),mn=m.wB?450+n.fK:void 0;function gn(e){return"file"===e.kind&&e.type&&n.AK.has(e.type)}const fn=(0,o.X$)((0,a.c$)((e=>{const t=(0,i.Pu)(e),{isBlurred:s,background:a,backgroundColor:n,patternColor:o}=e.settings.themes[t]||{},{messageLists:r}=e.messages,c=(0,i.Bt)(e),{isLeftColumnShown:l,chats:{listIds:h}}=e,g={theme:t,customBackground:a,backgroundColor:n,patternColor:o,isLeftColumnShown:l,isRightColumnShown:(0,i.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(m.wB&&(0,i.n5)(e)),isSelectModeActive:(0,i.CA)(e),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1)};if(!c||!h.active)return g;const{chatId:f,threadId:p,type:I}=c,v=(0,i.Z1)(e,f),y=(0,i.KB)(e,f),{chatId:Z,messageId:P}=e.audioPlayer,C=v&&(0,d.Qm)(v,p),w=(0,i.pk)(e,f),b="pinned"===I,M="scheduled"===I;return{...g,chatId:f,threadId:p,messageListType:I,isPrivate:(0,d.YA)(f),canPost:!b&&(!v||C)&&!w,isPinnedMessageList:b,isScheduledMessageList:M,currentUserBannedRights:v&&v.currentUserBannedRights,defaultBannedRights:v&&v.defaultBannedRights,hasPinnedOrAudioMessage:p!==u._f||Boolean(y&&y.length)||Boolean(Z&&P),pinnedMessagesCount:y?y.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:r}}),((e,t)=>(0,g.ei)(t,["openChat","unpinAllMessages","loadUser","closeLocalTextSearch","exitMessageSelectMode"])))((({chatId:e,threadId:t,messageListType:s,isPrivate:a,isPinnedMessageList:r,messageLists:i,canPost:c,currentUserBannedRights:l,defaultBannedRights:u,hasPinnedOrAudioMessage:h,pinnedMessagesCount:g,customBackground:f,theme:p,backgroundColor:I,patternColor:v,isLeftColumnShown:y,isRightColumnShown:Z,isBackgroundBlurred:P,isMobileSearchActive:C,isSelectModeActive:w,animationLevel:b,shouldSkipHistoryAnimations:M,currentTransitionKey:S,openChat:E,unpinAllMessages:k,loadUser:R,closeLocalTextSearch:T,exitMessageSelectMode:N})=>{const{width:B}=at(),A=(0,ye.Z)(),[x,L]=(0,o.eJ)(Je.t.None),[O,F]=(0,o.eJ)(),[U,$]=(0,o.eJ)(),[Q,D]=(0,o.eJ)(!1),[q,G]=(0,o.eJ)(!m.wB||b===n.oB),H=h&&(B<n.l3||Z&&B>n._m&&B<n.QU||B>=n.ks&&B<n.jT),j=(0,nt.Z)(e,mn),_=(0,nt.Z)(t,mn),V=(0,nt.Z)(s,mn),W=(0,nt.Z)(c,mn),K=(0,nt.Z)(H,mn),X=(0,nt.Z)(O,mn);(0,o.d4)((()=>e?(0,fe.Z)((()=>{E({id:void 0})})):void 0),[e,E]),(0,o.d4)((()=>{L(Je.t.None),F(void 0),$(void 0)}),[e]),(0,o.d4)((()=>{b===n.oB&&G(!0)}),[b]),(0,o.d4)((()=>{a&&R({userId:e})}),[e,a,R]);const Y=(0,o.I4)((e=>{if(m.$b)return;const{items:t}=e.dataTransfer||{},s=t&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(gn);L(s?Je.t.QuickFile:Je.t.Document)}),[]),z=(0,o.I4)((()=>{L(Je.t.None)}),[]),J=(0,o.I4)((()=>{D(!0)}),[]),ee=(0,o.I4)((()=>{D(!1)}),[]),te=(0,o.I4)((()=>{k({chatId:e}),ee(),E({id:e})}),[k,E,ee,e]),se=(0,o.I4)((()=>{E({id:e})}),[E,e]),ae=((e,t)=>{const[s,a]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?a(t):et.fetch(n.fo,e,et.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,tt.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?s:void 0})(p,f),ne=(0,ie.Z)(K&&"has-header-tools",f&&"custom-bg-image",I&&"custom-bg-color",f&&P&&"blurred",m.aZ?"mask-image-disabled":"mask-image-enabled"),oe=(0,ie.Z)("messaging-disabled",!w&&"shown"),re=(0,d.q8)(A,l,u),{composerHiddenScale:ce,toolbarHiddenScale:de,composerTranslateX:le,toolbarTranslateX:ue,unpinHiddenScale:he,toolbarForUnpinHiddenScale:me}=(0,o.Ye)((()=>function(e,t){const s=e<=n.l3?16:32,a=function(e){if(e>n._m){const t=Math.min(Math.max(.25*e,288),424),s=Math.min(.25*e,424);return Math.min(e-t-s,ot)}if(e>n.ks){const t=Math.min(Math.max(.4*e,288),424);return Math.min(e-t,ot)}return e>ot?ot:e}(e),o=e<=n.l3?54:64,r=t?a-s-o:a-s,i=e>n.l3?Math.min(a-s,512):a-s,c=i/r,d=r/i;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?o/2*d:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:i/258,toolbarForUnpinHiddenScale:258/i}}(B,W)),[W,B]),pe=(0,ie.Z)("middle-column-footer",!W&&"no-composer",W&&U&&!w&&"with-notch");return(0,ge.ZP)(j&&_,(()=>{E({id:void 0},!0)}),void 0,void 0,void 0,i?i.map(rt):[]),(0,ge.ZP)(C,T),(0,ge.ZP)(w,N),o.ZP.createElement("div",{id:"MiddleColumn",className:ne,onTransitionEnd:t=>{"transform"===t.propertyName&&t.target===t.currentTarget&&G(Boolean(e))},style:`\n --composer-hidden-scale: ${ce};\n --toolbar-hidden-scale: ${de};\n --unpin-hidden-scale: ${he};\n --toolbar-unpin-hidden-scale: ${me};\n --composer-translate-x: ${le}px;\n --toolbar-translate-x: ${ue}px;\n --pattern-color: ${v};\n --theme-background-color:\n ${I||("dark"===p?n.It:n.p3)};\n `,onClick:m.p7&&y?se:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:ae?`--custom-background: ${ae}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),j&&_&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:W?Y:void 0},o.ZP.createElement(kt,{chatId:j,threadId:_,messageListType:V,isReady:q}),o.ZP.createElement(Ie.Z,{name:M?"none":b===n.zy?"slide":"fade",activeKey:S,shouldCleanup:!0},(e=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(oa,{key:`${j}-${_}-${V}`,chatId:j,threadId:_,type:V,canPost:W,hasTools:K,onFabToggle:F,onNotchToggle:$,isReady:q,isActive:e}),o.ZP.createElement("div",{className:pe},W&&o.ZP.createElement(dn,{chatId:j,threadId:_,messageListType:V,dropAreaState:x,onDropHide:z,isReady:q}),r&&o.ZP.createElement("div",{className:"unpin-button-container",dir:A.isRtl?"rtl":void 0},o.ZP.createElement(we.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:J},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,A("Chat.Pinned.UnpinAll",g,"i")))),!r&&!W&&re&&o.ZP.createElement("div",{className:oe},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,re))),o.ZP.createElement(un,{messageListType:V,isActive:w,canPost:W}))))),o.ZP.createElement(ra,{isShown:X,canPost:W})),m.wB&&o.ZP.createElement(ln,{isActive:Boolean(C)})),e&&o.ZP.createElement(hn,{isOpen:Q,chatId:e,pinnedMessagesCount:g,onClose:ee,onUnpin:te}))}))),pn=(0,Z.Ds)((e=>e()),200,!1);var In;!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.ManageGroupMembers=16]="ManageGroupMembers",e[e.StickerSearch=17]="StickerSearch",e[e.GifSearch=18]="GifSearch",e[e.PollResults=19]="PollResults",e[e.AddingMembers=20]="AddingMembers"}(In||(In={}));const vn=(0,o.X$)((0,a.c$)(((e,{chatId:t,isProfile:s,isManagement:a})=>{const{query:n}=(0,i.n5)(e)||{},{query:o}=(0,i.y5)(e)||{},{query:r}=(0,i.yN)(e)||{},c=t?(0,i.Z1)(e,t):void 0,l=c&&(0,d.eA)(c);return{canManage:Boolean(!a&&s&&c&&!(0,i.FM)(e,c.id)&&((0,d.YA)(c.id)||((0,d.Nl)(c)||c.isCreator)&&!c.isNotJoined)),isChannel:l,messageSearchQuery:n,stickerSearchQuery:o,gifSearchQuery:r}}),((e,t)=>(0,g.ei)(t,["setLocalTextSearchQuery","setStickerSearchQuery","setGifSearchQuery","searchTextMessagesLocal","toggleManagement","openHistoryCalendar"])))((({isColumnOpen:e,isProfile:t,isSearch:s,isManagement:a,isStickerSearch:n,isGifSearch:r,isPollResults:i,isAddingChatMembers:c,profileState:d,managementScreen:l,canManage:u,isChannel:g,onClose:f,messageSearchQuery:p,stickerSearchQuery:I,gifSearchQuery:v,setLocalTextSearchQuery:y,setStickerSearchQuery:Z,setGifSearchQuery:P,searchTextMessagesLocal:C,toggleManagement:w,openHistoryCalendar:b,shouldSkipAnimation:M})=>{var S;const E=(0,o.sO)(null),k=(0,o.I4)((e=>{y({query:e}),e.length&&pn(C)}),[C,y]),R=(0,o.I4)((e=>{Z({query:e})}),[Z]),T=(0,o.I4)((e=>{P({query:e})}),[P]),[N,B]=(0,o.eJ)(!e);(0,o.d4)((()=>{setTimeout((()=>{B(!e)}),300)}),[e]);const A=(0,ye.Z)(),x=t?d===h.vi.Profile?In.Profile:d===h.vi.SharedMedia?In.SharedMedia:d===h.vi.MemberList?In.MemberList:-1:s?In.Search:i?In.PollResults:n?In.StickerSearch:r?In.GifSearch:c?In.AddingMembers:a?l===h.u1.Initial?In.ManageInitial:l===h.u1.ChatPrivacyType?In.ManageChatPrivacyType:l===h.u1.Discussion?In.ManageDiscussion:l===h.u1.ChannelSubscribers?In.ManageChannelSubscribers:l===h.u1.GroupPermissions?In.ManageGroupPermissions:l===h.u1.ChatAdministrators?In.ManageChatAdministrators:l===h.u1.GroupRemovedUsers?In.ManageGroupRemovedUsers:l===h.u1.GroupUserPermissionsCreate?In.ManageGroupUserPermissionsCreate:l===h.u1.GroupUserPermissions?In.ManageGroupUserPermissions:l===h.u1.GroupRecentActions?In.ManageGroupRecentActions:l===h.u1.ChatAdminRights?In.ManageGroupAdminRights:l===h.u1.GroupMembers?In.ManageGroupMembers:void 0:void 0,O=null!==(S=(0,dt.Z)(x,!0))&&void 0!==S?S:-1;function F(){if(-1!==O)switch(O){case In.PollResults:return o.ZP.createElement("h3",null,A("PollResults"));case In.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(be.Z,{parentContainerClassName:"RightSearch",value:p,onChange:k}),o.ZP.createElement(we.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>b({selectedAt:(0,L._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case In.AddingMembers:return o.ZP.createElement("h3",null,A("GroupAddMembers"));case In.ManageInitial:return o.ZP.createElement("h3",null,A("Edit"));case In.ManageChatPrivacyType:return o.ZP.createElement("h3",null,A(g?"ChannelTypeHeader":"GroupTypeHeader"));case In.ManageDiscussion:return o.ZP.createElement("h3",null,A("Discussion"));case In.ManageChatAdministrators:return o.ZP.createElement("h3",null,A("ChannelAdministrators"));case In.ManageGroupRecentActions:return o.ZP.createElement("h3",null,A("Group.Info.AdminLog"));case In.ManageGroupAdminRights:return o.ZP.createElement("h3",null,A("EditAdminRights"));case In.ManageGroupPermissions:return o.ZP.createElement("h3",null,A("ChannelPermissions"));case In.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,A("ChannelBlockedUsers"));case In.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,A("ChannelAddException"));case In.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,A("UserRestrictions"));case In.StickerSearch:return o.ZP.createElement(be.Z,{value:I,placeholder:A("SearchStickersHint"),onChange:R});case In.GifSearch:return o.ZP.createElement(be.Z,{value:v,placeholder:A("SearchGifsTitle"),onChange:T});case In.SharedMedia:return o.ZP.createElement("h3",null,A("SharedMedia"));case In.ManageChannelSubscribers:return o.ZP.createElement("h3",null,A("ChannelSubscribers"));case In.MemberList:case In.ManageGroupMembers:return o.ZP.createElement("h3",null,A("GroupMembers"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},u&&o.ZP.createElement(we.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:A("Edit"),onClick:w},o.ZP.createElement("i",{className:"icon-edit"}))))}}const U=m.wB||x===In.SharedMedia||x===In.MemberList||x===In.AddingMembers||a,$=(0,ie.Z)("animated-close-icon",(N||M)&&"no-transition");return(0,o.d4)((()=>{E.current.classList.toggle("state-back",U)}),[U]),o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(we.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:f,ariaLabel:A(U?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:E,className:$})),o.ZP.createElement(Ie.Z,{name:N||M?"none":"slide-fade",activeKey:O},F))})));var yn=s(7407);function Zn(e,t,s,a,r,i){const c=(0,o.sO)();(0,he.Z)((()=>{t===e&&r&&i&&(c.current=(0,d.R5)(r,i,e).reverse())}),[r,i,t,e]);const[l,u]=(0,yn.Z)(a?s:void 0,c.current,void 0,"media"===e?n.EN:n.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const Pn=(0,Z.P2)((e=>e()),250,!1);let Cn=!1;var wn=s(1273),bn=s(1876),Mn=s(787),Sn=s(180),En=s(3709),kn=s(5418),Rn=s(7262),Tn=s(1151),Nn=s(3103);const Bn=(0,o.X$)((0,a.c$)(((e,{userId:t})=>{const s=(0,i.jr)(e),a=t&&(0,i.dy)(e,t);return{chat:s,contactName:a?(0,d.Vl)(a):void 0}}),((e,t)=>(0,g.ei)(t,["deleteChatMember"])))((({isOpen:e,chat:t,userId:s,contactName:a,onClose:n,deleteChatMember:r})=>{const i=(0,ye.Z)(),c=(0,o.I4)((()=>{r({chatId:t.id,userId:s}),n()}),[t,r,n,s]);if(t&&s)return o.ZP.createElement(Nn.Z,{isOpen:e,onClose:n,onEnter:c,className:"delete",title:i("GroupRemoved.Remove")},o.ZP.createElement("p",null,(0,pt.Z)(i("PeerInfo.Confirm.RemovePeer",a))),o.ZP.createElement(we.Z,{color:"danger",className:"confirm-dialog-button",isText:!0,onClick:c},i("lng_box_remove")),o.ZP.createElement(we.Z,{className:"confirm-dialog-button",isText:!0,onClick:n},i("Cancel")))}))),An=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"}];function xn(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > div.active > .${e}-list > .scroll-item`].join(", ")}const Ln=(0,o.X$)((0,a.c$)(((e,{chatId:t,userId:s})=>{const a=(0,i.Z1)(e,t),n=(0,i.Zw)(e,s||t),{currentType:o,resultsByType:r}=(0,i.we)(e)||{},{foundIds:c}=r&&o&&r[o]||{},{byId:l}=e.users,u=a&&(0,d.Bf)(a),h=a&&(0,d.eA)(a),m=u||h&&(0,d.Nl)(a),g=a&&a.fullInfo&&a.fullInfo.members,f=m&&a&&a.fullInfo&&!a.fullInfo.canViewMembers,p=m&&a&&((0,d.VE)(a,"inviteUsers")||a.isCreator),I=m&&a&&((0,d.VE)(a,"banUsers")||a.isCreator);let v;return s?v=s:(0,d.YA)(t)&&(v=t),{theme:(0,i.Pu)(e),isChannel:h,resolvedUserId:v,chatMessages:n,foundIds:c,mediaSearchType:o,hasMembersTab:m,areMembersHidden:f,canAddMembers:p,canDeleteMembers:I,currentUserId:e.currentUserId,isRightColumnShown:(0,i.Jf)(e),isRestricted:a&&a.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,...m&&g&&{members:g,usersById:l}}}),((e,t)=>(0,g.ei)(t,["setLocalMediaSearchType","loadMoreMembers","searchMediaMessagesLocal","openMediaViewer","openAudioPlayer","openUserInfo","focusMessage","loadProfilePhotos","setNewChatMembersDialogState"])))((({chatId:e,profileState:t,onProfileStateChange:s,theme:a,isChannel:r,resolvedUserId:i,currentUserId:c,chatMessages:l,foundIds:g,mediaSearchType:f,hasMembersTab:p,areMembersHidden:I,canAddMembers:v,canDeleteMembers:y,members:Z,usersById:P,isRightColumnShown:C,isRestricted:w,lastSyncTime:b,setLocalMediaSearchType:M,loadMoreMembers:S,searchMediaMessagesLocal:E,openMediaViewer:k,openAudioPlayer:R,openUserInfo:T,focusMessage:N,loadProfilePhotos:B,setNewChatMembersDialogState:A,serverTimeOffset:x})=>{const L=(0,o.sO)(null),O=(0,o.sO)(null),F=(0,ye.Z)(),[U,$]=(0,o.eJ)(0),[Q,D]=(0,o.eJ)(),q=(0,o.Ye)((()=>[...p?[{type:"members",title:r?"ChannelSubscribers":"GroupMembers"}]:[],...An]),[p,r]),G=q[U].type,[H,j,_,V]=function(e,t,s,a,r,i,c,l,u,h,m,g=0){const f="members"!==a&&r?r:a,p=(0,o.Ye)((()=>{if(i&&c)return(0,d.Z0)(i.map((({userId:e})=>e)),c,void 0,g)}),[i,g,c]),[I,v,y]=function(e,t,s,a){const[o,r]=(0,yn.Z)(s?t:void 0,a,void 0,n.Vk);return[o,r,!(!o||!a||o[0]===a[0])]}(0,t,m,p),[Z,P,C]=Zn("media",f,s,m,l,u),[w,b,M]=Zn("documents",f,s,m,l,u),[S,E,k]=Zn("links",f,s,m,l,u),[R,T,N]=Zn("audio",f,s,m,l,u);let B,A,x=!1;switch(f){case"members":B=I,A=v,x=y;break;case"media":B=Z,A=P,x=C;break;case"documents":B=w,A=b,x=M;break;case"links":B=S,A=E,x=k;break;case"audio":B=R,A=T,x=N}return[f,B,A,x]}(0,S,E,G,f,Z,P,l,g,0,b,x),W=q.findIndex((({type:e})=>e===H)),{handleScroll:K}=function(e,t,s,a){(0,Tt.Z)((([s])=>{if(s&&s!==t){const s=e.current,n=s.querySelector(".TabList");s.scrollTop<n.offsetTop&&(a("members"===t?h.vi.MemberList:h.vi.SharedMedia),Cn=!0,(0,Lt.Z)(s,n,"start",void 0,void 0,void 0,300),setTimeout((()=>{Cn=!1}),350))}}),[t,a]),(0,Tt.Z)((([t])=>{if(s!==h.vi.Profile||s===t)return;const n=e.current;if(!n)return;const o=n.querySelector(".TabList");!o||o.offsetTop>n.scrollTop||(Cn=!0,(0,Lt.Z)(n,n.firstElementChild,"start",void 0,2*n.offsetHeight),setTimeout((()=>{Cn=!1}),350),a(s))}),[s]);const n=(0,o.I4)((()=>{const s=e.current;if(!s)return;const n=s.querySelector(".TabList");if(!n)return;let o=h.vi.Profile;s.scrollTop>=n.offsetTop&&(o="members"===t?h.vi.MemberList:h.vi.SharedMedia),a(o)}),[e,a,t]);return(0,o.d4)((()=>{Cn||n()}),[n,t]),{handleScroll:(0,o.I4)((()=>{Cn||Pn(n)}),[n])}}(L,G,t,s),{applyTransitionFix:X,releaseTransitionFix:Y}=function(e,t=".Transition.shared-media-transition"){return(0,o.d4)((()=>{function s(){const s=e.current,a=s.querySelector(t),n=s.querySelector(".TabList");a&&n&&(a.style.minHeight=s.offsetHeight-n.offsetHeight+"px")}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]),{applyTransitionFix:(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]),releaseTransitionFix:(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e])}}(L),[z,J]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),ee=(0,o.I4)((()=>{Y(),J()}),[Y,J]),te=(0,o.I4)((()=>{A(h.WB.InProgress)}),[A]);(0,o.d4)((()=>{M({mediaType:G})}),[M,G]);const se=i||e;(0,o.d4)((()=>{b&&B({profileId:se})}),[B,se,b]);const ae=(0,o.I4)((e=>{k({chatId:se,threadId:u._f,messageId:e,origin:h.bZ.SharedMedia})}),[se,k]),ne=(0,o.I4)((e=>{R({chatId:se,messageId:e})}),[se,R]),oe=(0,o.I4)((e=>{T({id:e})}),[T]),re=(0,o.I4)((e=>{N({chatId:se,messageId:e})}),[se,N]),ie=(0,o.I4)((()=>{D(void 0)}),[]);let ce;(0,o.d4)((()=>{if(O.current&&m.$b)return(0,Ne.s)(O.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Ne.e.Left?($(Math.min(U+1,q.length-1)),!0):t===Ne.e.Right&&($(Math.max(0,U-1)),!0)})}),[U,q.length]);const de="members"===H||!p&&"media"===H;de?ce=C?0:1e3:j||(ce=n.Y);const le=(0,Ka.Z)([e,H],ce);function ue(e){return e!==c&&y?[{title:F("lng_context_remove_from_group"),icon:"stop",handler:()=>{D(e)}}]:void 0}function he(){if(!j||!le||!l){const e=de&&j&&!le;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Re.Z,null))}if(!j.length){let e;switch(H){case"members":e=I?"You have no access to group members list.":"No members found";break;case"documents":e=F("lng_media_file_empty_search");break;case"links":e=F("lng_media_link_empty_search");break;case"audio":e=F("lng_media_song_empty_search");break;default:e=F("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(Rn.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${H}-list`,dir:F.isRtl&&"media"===H?"rtl":void 0,teactFastList:!0},"media"===H?j.map((e=>l[e]&&o.ZP.createElement(En.Z,{key:e,message:l[e],onClick:ae}))):"documents"===H?j.map((e=>l[e]&&o.ZP.createElement(ss.Z,{key:e,message:l[e],withDate:!0,smaller:!0,className:"scroll-item",onDateClick:re}))):"links"===H?j.map((e=>l[e]&&o.ZP.createElement(kn.Z,{key:e,message:l[e],onMessageClick:re}))):"audio"===H?j.map((e=>l[e]&&o.ZP.createElement(as.Z,{key:e,theme:a,message:l[e],target:"sharedMedia",date:l[e].date,lastSyncTime:b,className:"scroll-item",onPlay:ne,onDateClick:re}))):"members"===H?j.map(((e,t)=>o.ZP.createElement(bn.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>oe(e),contextActions:ue(e)},o.ZP.createElement(ut.Z,{userId:e,forceShowSelf:!0})))):void 0)}return o.ZP.createElement(wn.Z,{ref:L,className:"Profile custom-scroll",itemSelector:xn(H),items:le?j:void 0,cacheBuster:z,sensitiveArea:n.qU,preloadBackwards:le?"members"===H?n.Vk:n.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:_,onScroll:K},!V&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Mn.Z,{userId:t||e}),o.ZP.createElement(Sn.Z,{chatOrUserId:t||e}))}(e,i),!w&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Ie.Z,{ref:O,name:F.isRtl?"slide-reversed":"slide",activeKey:W,renderCount:q.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:X,onStop:ee},he),o.ZP.createElement(Be.Z,{big:!0,activeTab:U,tabs:q,onSwitchTab:$})),v&&o.ZP.createElement(Tn.Z,{isShown:"members"===H,onClick:te,ariaLabel:F("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),y&&o.ZP.createElement(Bn,{isOpen:Boolean(Q),userId:Q,onClose:ie}))}))),On=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)})),Fn=(0,o.X$)((e=>{const t=(0,Oe.Z)(Le.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(Fe.Z,null)})),Un=(0,o.X$)((()=>{const e=(0,Oe.Z)(Le.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Fe.Z,null)})),$n=(0,o.X$)((()=>{const e=(0,Oe.Z)(Le.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Fe.Z,null)})),Qn=(0,o.X$)((()=>{const e=(0,Oe.Z)(Le.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(Fe.Z,null)}));var Dn=s(1820);const qn=(0,o.X$)((0,a.c$)(((e,{chatId:t})=>{const s=(0,i.Z1)(e,t),{userIds:a}=e.contactList||{},{byId:n}=e.users,{byId:o}=e.chats,{currentUserId:r,newChatMembersProgress:c,connectionState:l}=e,u=s&&(0,d.eA)(s),{query:m,fetchingStatus:g,globalUserIds:f,localUserIds:p}=e.userSearch;return{isChannel:u,members:s&&s.fullInfo?s.fullInfo.members:void 0,currentUserId:r,usersById:n,chatsById:o,localContactIds:a,searchQuery:m,isSearching:g,isLoading:c===h.WB.Loading,globalUserIds:f,localUserIds:p,connectionState:l}}),((e,t)=>(0,g.ei)(t,["loadContactList","setUserSearchQuery"])))((({isChannel:e,connectionState:t,members:s,onNextStep:a,currentUserId:n,usersById:r,chatsById:i,localContactIds:c,isLoading:l,searchQuery:u,isSearching:h,localUserIds:m,globalUserIds:f,setUserSearchQuery:p,onClose:I,isActive:v,loadContactList:y})=>{const Z=(0,ye.Z)(),[P,C]=(0,o.eJ)([]),w=(0,gs.Z)(P)===P;(0,o.d4)((()=>{v&&"connectionStateReady"===t&&y()}),[t,v,y]),(0,ge.ZP)(v,I);const b=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),M=(0,o.I4)((e=>{p({query:e})}),[p]),S=(0,o.Ye)((()=>{const t=c?(0,d.ih)(c.filter((e=>e!==n)),i):[];if(!u)return t.filter((e=>!b.includes(e)));const s=t.filter((e=>{const t=r[e];if(!t)return!1;const s=(0,d.Js)(t);return s&&(0,B.Z)(s,u)}));return(0,d.ih)((0,g.Tw)([...s,...m||[],...f||[]]).filter((t=>{const s=r[t];return!b.includes(t)&&(!s||!(0,d.cS)(s)||!e&&s.canBeInvitedToGroup)})),i)}),[c,i,u,m,f,n,r,b,e]),E=(0,o.I4)((()=>{P.length&&(p({query:""}),a(P))}),[P,p,a]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(Dn.Z,{itemIds:S,selectedIds:P,filterValue:u,filterPlaceholder:Z("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:C,onFilterChange:M,noScrollRestore:w}),o.ZP.createElement(Tn.Z,{isShown:Boolean(P.length),disabled:l,ariaLabel:Z("lng_channel_add_users"),onClick:E},l?o.ZP.createElement(Re.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),Gn=Object.keys(h.qt).length/2,Hn=Object.keys(h.u1).length/2;function jn(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const _n=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},a=(0,i.g4)(e);return{contentKey:(0,i.Wq)(e),chatId:t,threadId:s,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(t&&a),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}),((e,t)=>(0,g.ei)(t,["openUserInfo","toggleChatInfo","toggleManagement","closeLocalTextSearch","setStickerSearchQuery","setGifSearchQuery","closePollResults","addChatMembers","setNewChatMembersDialogState"])))((({contentKey:e,chatId:t,threadId:s,currentProfileUserId:a,isChatSelected:r,toggleChatInfo:i,toggleManagement:c,openUserInfo:d,closeLocalTextSearch:l,setStickerSearchQuery:u,setGifSearchQuery:m,closePollResults:g,addChatMembers:f,setNewChatMembersDialogState:p,shouldSkipHistoryAnimations:I})=>{var v;const{width:y}=at(),[Z,P]=(0,o.eJ)(h.vi.Profile),[C,w]=(0,o.eJ)(h.u1.Initial),[b,M]=(0,o.eJ)(),[S,E]=(0,o.eJ)(),k=Z!==h.vi.Profile,R=void 0!==e,T=e===h.qt.ChatInfo||e===h.qt.UserInfo,N=e===h.qt.Search,B=e===h.qt.Management,A=e===h.qt.StickerSearch,x=e===h.qt.GifSearch,L=e===h.qt.PollResults,O=e===h.qt.AddingMembers,F=y<=n._m,[U,$]=(0,o.eJ)(!R),Q=null!==(v=(0,dt.Z)(e,!0,!r))&&void 0!==v?v:-1,D=(0,o.I4)(((t=!0)=>{switch(e){case h.qt.AddingMembers:p(h.WB.Closed);break;case h.qt.ChatInfo:if(k&&t){P(h.vi.Profile);break}i(void 0,!0);break;case h.qt.UserInfo:if(k&&t){P(h.vi.Profile);break}d({id:void 0},!0);break;case h.qt.Management:switch(C){case h.u1.Initial:c();break;case h.u1.ChatPrivacyType:case h.u1.Discussion:case h.u1.GroupPermissions:case h.u1.GroupType:case h.u1.ChatAdministrators:case h.u1.ChannelSubscribers:case h.u1.GroupMembers:w(h.u1.Initial);break;case h.u1.GroupUserPermissionsCreate:case h.u1.GroupRemovedUsers:case h.u1.GroupUserPermissions:w(h.u1.GroupPermissions),M(void 0),E(void 0);break;case h.u1.ChatAdminRights:case h.u1.GroupRecentActions:w(h.u1.ChatAdministrators)}break;case h.qt.Search:jn(),l();break;case h.qt.StickerSearch:jn(),u({query:void 0});break;case h.qt.GifSearch:jn(),m({query:void 0});break;case h.qt.PollResults:g()}}),[e,k,i,d,g,p,C,c,l,u,m]),q=(0,o.I4)(((e,t)=>{M(e),E(t)}),[]),G=(0,o.I4)((e=>{f({chatId:t,memberIds:e})}),[f,t]);function H(e){if(-1!==Q)switch(Q){case h.qt.AddingMembers:return o.ZP.createElement(qn,{chatId:t,onNextStep:G,isActive:R&&e,onClose:D});case h.qt.ChatInfo:case h.qt.UserInfo:return o.ZP.createElement(Ln,{key:a||t,chatId:t,userId:a,profileState:Z,onProfileStateChange:P});case h.qt.Search:return o.ZP.createElement(On,{chatId:t,threadId:s,onClose:D,isActive:R&&e});case h.qt.Management:return o.ZP.createElement(Fn,{chatId:t,currentScreen:C,isPromotedByCurrentUser:S,selectedChatMemberId:b,onScreenSelect:w,onChatMemberSelect:q,isActive:R&&e,onClose:D});case h.qt.StickerSearch:return o.ZP.createElement(Un,{onClose:D,isActive:R&&e});case h.qt.GifSearch:return o.ZP.createElement($n,{onClose:D,isActive:R&&e});case h.qt.PollResults:return o.ZP.createElement(Qn,{onClose:D,isActive:R&&e})}}return(0,o.d4)((()=>R?(0,fe.Z)(D):void 0),[R,D]),(0,o.d4)((()=>{setTimeout((()=>{$(!R)}),300)}),[R]),(0,o.d4)((()=>{R&&F&&D()}),[F]),(0,Rt.Z)((([s,a])=>{(s===h.qt.ChatInfo&&e===h.qt.UserInfo||s===h.qt.UserInfo&&e===h.qt.ChatInfo||a!==t)&&(P(h.vi.Profile),w(h.u1.Initial))}),[e,t]),(0,ge.ZP)(r&&(e===h.qt.ChatInfo||e===h.qt.UserInfo||e===h.qt.Management||e===h.qt.AddingMembers),(()=>D(!1)),i),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:r?void 0:"is-hidden"},F&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:D}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(vn,{chatId:t,isColumnOpen:R,isProfile:T,isSearch:N,isManagement:B,isStickerSearch:A,isGifSearch:x,isPollResults:L,isAddingChatMembers:O,profileState:Z,managementScreen:C,onClose:D,shouldSkipAnimation:U||I}),o.ZP.createElement(Ie.Z,{name:U||I?"none":"zoom-fade",renderCount:Gn+Hn,activeKey:B?Gn+C:Q,shouldCleanup:!0,cleanupExceptionKey:h.qt.ChatInfo},H)))}))),Vn=(0,o.X$)((({isOpen:e})=>{const t=(0,Oe.Z)(Le.gl.Extra,"MediaViewer",!e);return t?o.ZP.createElement(t,null):void 0})),Wn=(0,o.X$)((({isOpen:e})=>{const t=(0,Oe.Z)(Le.gl.Extra,"Notifications",!e);return t?o.ZP.createElement(t,null):void 0})),Kn=(0,o.X$)((({isOpen:e})=>{const t=(0,Oe.Z)(Le.gl.Extra,"Dialogs",!e);return t?o.ZP.createElement(t,null):void 0})),Xn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"ForwardPicker",!t);return s?o.ZP.createElement(s,e):void 0})),Yn=(0,o.X$)((e=>{const{url:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0})),zn=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,Oe.Z)(Le.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0}));let Jn,eo=!1;function to(e){document.querySelectorAll('link[rel="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 so(e){document.title!==e&&(document.title=e)}const ao=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,messageId:s}=e.audioPlayer,a=t&&s?(0,i.hj)(e,t,s):void 0;return{animationLevel:e.settings.byKey.animationLevel,lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,i.Jf)(e),isMediaViewerOpen:(0,i.zQ)(e),isForwardModalOpen:(0,i.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:a,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,language:e.settings.byKey.language,openedStickerSetShortName:e.openedStickerSetShortName}}),((e,t)=>(0,g.ei)(t,["loadAnimatedEmojis","loadNotificationSettings","loadNotificationExceptions","updateIsOnline","loadTopInlineBots","loadEmojiKeywords","openStickerSetShortName"])))((({lastSyncTime:e,isLeftColumnShown:t,isRightColumnShown:s,isMediaViewerOpen:r,isForwardModalOpen:c,animationLevel:d,hasNotifications:l,hasDialogs:u,audioMessage:h,safeLinkModalUrl:g,isHistoryCalendarOpen:f,shouldSkipHistoryAnimations:p,language:I,openedStickerSetShortName:v,loadAnimatedEmojis:y,loadNotificationSettings:P,loadNotificationExceptions:C,updateIsOnline:w,loadTopInlineBots:b,loadEmojiKeywords:M,openStickerSetShortName:S})=>{n.eM&&!eo&&(eo=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{e&&(w(!0),y(),P(),C(),b(),M({language:n.pR}),I!==n.pR&&M({language:I}))}),[e,y,C,P,w,b,M,I]),(0,o.d4)((()=>{e&&ge.Oy.startsWith("#?tgaddr=")&&(e=>{const{protocol:t,searchParams:s,pathname:n}=new URL(e);if("tg:"!==t)return;const{openChatByUsername:o,openStickerSetShortName:r}=(0,a.uC)(),i=n.replace(/^\/\//,""),c={};switch(s.forEach(((e,t)=>{c[t]=e})),i){case"resolve":{const{domain:e}=c;"telegrampassport"!==e&&o({username:e});break}case"privatepost":case"bg":case"join":break;case"addstickers":{const{set:e}=c;r({stickerSetShortName:e});break}}})(decodeURIComponent(ge.Oy.substr("#?tgaddr=".length)))}),[e]);const{transitionClassNames:E}=(0,de.Z)(!t,void 0,!0,void 0,p),{transitionClassNames:k}=(0,de.Z)(s,void 0,!0,void 0,p),R=(0,ie.Z)(E.replace(/([\w-]+)/g,"middle-column-$1"),k.replace(/([\w-]+)/g,"right-column-$1"),p&&"history-animation-disabled");(0,he.Z)((([e])=>{if(void 0===e||0===d)return;const t=(0,re.YW)();(0,ce.L)(document.getElementById("MiddleColumn"),t)}),[t]),(0,he.Z)((([e])=>{if(void 0===e||0===d)return;(0,Z.T2)((()=>{document.body.classList.add("animating-right-column")}));const t=(0,re.YW)();(0,ce.L)(document.getElementById("RightColumn"),(()=>{t(),(0,Z.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[s]);const T=(0,o.I4)((()=>{w(!1);const e=(0,i.A1)((0,a.Rd)());let t=0;clearInterval(Jn),Jn=window.setInterval((()=>{if(document.title.includes(n.ou))to(!1);else{if(t%2==0){const t=(0,i.A1)((0,a.Rd)())-e;t>0&&(so(`${t} notification${t>1?"s":""}`),to(!0))}else so(n.Ti),to(!1);t++}}),1e3)}),[w]),N=(0,o.I4)((()=>{w(!0),clearInterval(Jn),Jn=void 0,document.title.includes(n.ou)||so(n.Ti),to(!1)}),[w]),B=(0,o.I4)((()=>{S({stickerSetShortName:void 0})}),[S]);function A(e){e.preventDefault(),e.stopPropagation()}return(0,le.Z)(T,N),ue(T),function(e=!1){(0,o.d4)((()=>{if(m.cj&&!e)return document.addEventListener("gesturestart",me),()=>{document.removeEventListener("gesturestart",me)}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:R,onDrop:A,onDragOver:A},o.ZP.createElement(ze,null),o.ZP.createElement(fn,null),o.ZP.createElement(_n,null),o.ZP.createElement(Vn,{isOpen:r}),o.ZP.createElement(Xn,{isOpen:c}),o.ZP.createElement(Wn,{isOpen:l}),o.ZP.createElement(Kn,{isOpen:u}),h&&o.ZP.createElement(Et,{key:h.id,message:h,noUi:!0}),o.ZP.createElement(Yn,{url:g}),o.ZP.createElement(zn,{isOpen:f}),o.ZP.createElement(cs.Z,{isOpen:Boolean(v),onClose:B,stickerSetShortName:v}))})));n.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,a.Rd)().connectionState||(0,a.uC)().initApi()}}]);
|
||
//# sourceMappingURL=25.8ea9a7a9791a531e0216.js.map
|